Repository navigation
Expand file tree
/
Copy pathrequirements.sysml
More file actions
4433 lines (4152 loc) · 236 KB
/
Copy pathrequirements.sysml
File metadata and controls
4433 lines (4152 loc) · 236 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
MemNet requirements -- nested + atomic baseline (2026-07).
ID scheme:
MN-REQ-00 mission root (sole parent)
MN-REQ-NN group requirement (organisational; short framing doc)
MN-REQ-NN.M atomic leaf (one SHALL/SHOULD idea)
MN-REQ-10 LLM assumed properties + limitation leaves
MN-REQ-11 Snapshot / interoperability (map of pins)
MN-REQ-12 Multitask Mode (parent/worker; shared session as-is)
MN-REQ-13 0.5 Recall/Commit (thin; math skeleton; no engine cut)
MN-REQ-13.2 SameThingAbsorb — in-session Commit rule (not ImportAbsorb)
MN-REQ-02.8 GraphElement identity; optional nickname; leftover mint/store-key
MN-REQ-02.9 MUST NOT copy cousin store-key / unique-name / embedding Recall
MN-REQ-04.8 Cue |Q|>1 stays RelativeSeed bounded + honest; CueConflict
on find/pin_map emit; same name is a candidate only
MN-REQ-04.9 Empty-q session outline: Recall census of S (kinds +
LIMIT exemplars); leftover empty-seed skip not TARGET
MN-REQ-04.10 Peak_L last-resort residual cue on codebook miss;
never default goldfish
MN-REQ-04.11 pin_map order is a function of Shape observables,
not hid / nickname id / CREATE order (gauge)
MN-REQ-04.12 Housekeep orphan/dangling/stale resolve edge ends by
hid and nickname; prune --apply refuses a referenced node
MN-REQ-06.5 Human usage look (read-only dashboard; not agent wire)
MN-REQ-06.6 Device MemNet services; one MemNet MCP (tip/ops) at the droplet; product face is sysmledge (tip≠face)
MN-REQ-06.7 Allocate SSOT parts to live code in this checkout (one Hatch wheel, many hosts; sysmledge not in wheel)
MN-REQ-06.8 Tip MemNet access portal (ops): admin invite, Google login, Bearer for keyed tip MCP; tip≠face
MN-REQ-06.9 LAN MCP front invent (#191): ClusterRoute — where the session lives; one MCP catalogue, N LAN serves; cousin of #47; inventOnly
MN-REQ-06.10 SliceHandCarry invent (#47 cousin): bounded WorkingMemorySlice copy into another session; not a live hop; inventOnly
MN-REQ-01.9 Snapshot save/load lossless property round-trip; fail-closed save;
expire-save failure keeps RAM and counts against the session cap
MN-REQ-01.10 CapsPolicy who-check on session save / load-into-ACL / close
MN-REQ-01.11 Session copy --from: exact in-memory copy under a new id; source untouched
MN-REQ-03.4 MATCH WHERE SET/DELETE SHALL honour the predicate or refuse
MN-REQ-09.2 Invalid wire refused, not stored: a bare $name value is refused parameter_unsupported (implemented; tests/test_gql_codec.py)
MN-REQ-05.3 One decoded value_bytes cap on pipe mutate, GQL mutate, snapshot load
MN-REQ-05.4 One effective-field cap (default 64) on SCHEMA register, mutate, snapshot save/load; save never stricter than write
MN-REQ-05.5 Session cap evicts least-recently-touched saveable session (shipped, unreleased); save victim first; none evictable refuses limit_exceeded ("all sessions are in use"); restore: same ACL, no lease carried over
MN-REQ-05.6 Live session TTL and size-cap change (session limits / set-limits); cap = min(override, process cap); below usage refuses, never drops rows; #@LIM snapshot line
MN-REQ-06.11 Admin-only serve usage report (counts/caps; opaque session alias; not agent MCP)
MN-REQ-06.12 Product gateway on memnet-mcp: per-product route to owning serve (not mn_tip_)
MN-REQ-06.13 Serve request isolation: each command's stdout, stderr, and exit_code
MN-REQ-06.14 Safe serve upgrade inside memnet serve: drain, manifest, restore, retire (audit mark; a later restart still restores, 06.17); no silent session loss
MN-REQ-06.15 Admin checkpoint of every loaded session: lossless snaps, no drain, no traffic refuse
MN-REQ-06.16 Session snapshot carries the ACL (enabled, grants, digest-only bind); format 2 SHALL carry #@ACL:; format 1 loads ACL off (@ACL: absent|off); files 0600; first v2 write over v1 keeps <file>.v1.bak once (0600); no dual write
MN-REQ-06.17 Restart restore from the newest valid snapshot set (checkpoint or upgrade-prepare); every restart restores; loud fallback (@WARN: restore_fallback); none valid exits 3; (13) live candidate when MEMNET_PERSIST=full (implemented; tests/test_restart_restore.py, tests/test_restore_live.py)
MN-REQ-06.18 memnet-mcp fails fast without the [mcp] extra: one stderr line mcp_extra_missing, exit 2 (implemented; tests/test_mcp_extra_missing.py)
MN-REQ-06.19 Restart-safe transport: stateless memnet-mcp-http; ServePool/gateway pause through a serve restart or drain by bounded retry (30 s); a write is never replayed after send (implemented; tests/test_serve_restart_retry.py)
MN-REQ-06.20 Incremental live persist, stage 1: MEMNET_PERSIST=off (default, zero change) | full; persist worker writes byte-identical full snapshots to R/live off the session lock; SIGTERM drain; @STAT: persist lines (worker implemented in PR 3; restore from live implemented in PR 4; stage 2 delta planned, not approved)
MN-REQ-11.17 Catalog Snap / model Snap — session strata (0.15)
MN-REQ-11.17.1 Cross-cut satisfy locators on the catalog; SysMLEdge
pin_map is a different tool (not this catalog)
MN-REQ-11.17.2 Snap session grain is package / kind-band / nested
package; never one session per part or requirement
MN-REQ-11.17.3 Snap budget pre-check; refuse named; mint all-or-nothing
MN-REQ-11.17.4 Caller gone or wait exceeded: named refuse; rollback
MN-REQ-11.17.5 Repeat Snap of the same model identity replaces, not doubles
MN-REQ-14 Atelier-board engine asks (PROPOSAL, 2026-11-02; Atelier Keeper
benchmarks, synthetic, origin/master bb4a4dc); 14.1, 14.3, 14.4, 14.9-14.13 implemented; 14.2 PARKED; 14.5-14.8 PROPOSAL
MN-REQ-14.1 WHERE range comparisons < > <= >= on SET / DELETE WHERE, never on id; a quoted number or a quoted string against a stored number is refused where_type_mismatch (implemented; tests/test_range_where.py, test_range_type_refusal.py)
MN-REQ-14.2 Paged reads past the 50-row cap (PARKED: Elon review; since-filter note)
MN-REQ-14.3 Typed directed walks: query typed-walk, one edge type, out/in/both, 1..10 hops (implemented; tests/test_typed_walk.py, test_walk_index.py)
MN-REQ-14.4 Nickname id index and linear session load (implemented; tests/test_id_index.py, test_id_index_perf.py)
MN-REQ-14.5 Session record cap raisable once 14.4 lands (depends on 14.4)
MN-REQ-14.6 Id design: UUIDv7 minted, never reused, tombstoned (PROPOSAL; traced to 14.4)
MN-REQ-14.7 MCP surface: handles only, never real ids (PROPOSAL; traced to 14.6)
MN-REQ-14.8 Developer surface: real ids, stable outside references (PROPOSAL; traced to 14.6)
MN-REQ-14.9 Value cap 4096 -> 32768 bytes and line cap 135168, no chunking (implemented; tests/test_value_cap_32k.py, test_line_cap_whole_line.py, test_line_cap_edge_schema.py, test_line_cap_widening.py)
MN-REQ-14.10 Per-session total-bytes cap: escaped snapshot line bytes (default 163,840,000 bytes)
MN-REQ-14.11 Write paths that bypass the mutate gate enforce the same caps (import, CLI delete/prune; load and save budget)
MN-REQ-14.12 Budget check is incremental: re-encodes changed nodes + their incident edges, total equal to a full recount (implemented; tests/test_session_bytes_incremental.py, test_join_payload_vectorised.py)
MN-REQ-14.13 Opaque paging cursor for find and typed walks: limit + cursor in, next cursor out; bad_cursor / cursor_mismatch / stale_cursor; opt-in, replies unchanged otherwise (implemented; tests/test_paging_cursor.py)
MN-REQ-15 One-hop PROXY nodes: fixed tag (target_session, target, target_backend), shape-checked writes, no auto-follow; query follow / follow_proxy one hop (ok / dangling / not_reachable); gateway hop by owners map; housekeep lists, prune keeps; user PROXY tag refused user_proxy_tag (implemented; tests/test_proxy_nodes.py)
Nesting: requirement def inside requirement def only (SysML requirements
tree). Deploy software elements satisfy leaves; they are not the
requirement structure.
Formal derivation (SysML v2 idiom for SysML 1.x deriveReqt):
import RequirementDerivation::*; then
#derivation connection {
end #original ::> <parent usage>;
end #derive ::> <child usage>;
}
Groups derive from MN-REQ-00; leaves derive from their group.
Nesting = structure; #derivation = formal deriveReqt edge.
Breaking rename: MN-R1...MN-R9 retired. Do not map old numbers 1:1.
Etymology: MemNet = Net of Memory -- durable facts + relations, not a chat
notepad and not the search corpus.
Mission SSOT: Net of Memory between LLM pipelines and data searching; aids
system, programme, software, firmware, hardware, and documentation
development; save time and tokens; high factual accuracy; LLM-friendly
grammar on stdio/MCP; canonical parser for human inspection. GQL/openCypher
has no store key: GraphElement (node or edge) is the identity.
CREATE () is legal. properties() MAY be empty. Later MATCH/MERGE =
labels + properties; an edge is type + end elements. NicknameIdProperty
id is optional -- not identity. HiddenStoreHandle (elementId-style)
is not a property, not on the wire, not a business key. 0.9 leftover
invented store: leftover_by_id / leftover_id_first / leftover_NEW_mint /
leftover_MERGE_by_id / leftover_allocate_from_locator /
leftover_ingestIsIdRule. SHALL NOT invent a replacement application
store key. Grammar spelling/identity SSOT is docs/grammar/openCypher.bnf
(official file, Apache-2.0; NOTICE-openCypher.md) -- not a MemNet-invented
id law, not TCK compliance, not a second accept path.
Current realisation notes (not eternal identity):
Target agent wire is openCypher-shaped GQL (ADR-001); Write = display
redefined as bounded shaped pin_map subgraph wrapping GQL.
Layer / Tier A = leftover engine only (not product accept; M2
retired MutateGate accept; the memnet.tier_a / memnet.layer codecs are
deleted, and the mutate record classes live in memnet.records).
Legacy @TAG pipe may still appear in old session files (import once).
Store is in-memory Node|Edge property-graph records; process binding
prefers in-process, then local IPC, TCP as fallback; fixed engine laws
often LAW01-LAW05. No durable cabinet ships; the file snapshot is the
durable copy (any future store sits behind MemNet, not LLM-direct). Requirements state behavioural contracts;
surface spellings may change if the boundary still meets the contract.
Stakeholders (comment only -- no structural defs in this file):
LLM pipelines; data-search steps; MCP host; human inspectors who verify
what the memory net knows via parse-faithful inspect/render.
Out of scope: novel-writer product and general application framework.
Structure (software elements, ports, connections) lives in deploy.sysml,
connections.sysml, and implementation.sysml (allocate).
*/
package MemNetRequirements {
private import ScalarValues::*;
private import RequirementDerivation::*;
// --- Mission root (nested requirement tree only) ---
requirement def MN_REQ_00_MissionBridge {
doc /*
SHALL provide a Net of Memory (MemNet): an in-memory working-memory
network of facts and relations -- not a chat notepad and not the
search corpus -- that sits between pipelines of LLM calls and data
searching, aiding the LLM for system, programme, software, firmware,
hardware, and documentation development, with the aims of saving
wall-clock time and token usage while keeping high accuracy when
presenting facts. The live graph is working memory. Durability is a
file snapshot (explicit save and expire-save are one blob) or an
optional cabinet ego slice. The session id is the mission handle.
The model SSOT is git sysml-models/ on this repo and on
modelbasedPrj-*. A bound SysMLEdge desk is the working model only
on SysMLEdgePrj-*.
*/
attribute requirementId : String = "MN-REQ-00";
// ----- Session lifecycle -----
requirement def MN_REQ_01_SessionLifecycle {
doc /*
Group: named session working memory across pipeline turns.
The live graph is working memory. The session id is the mission
handle, not the model SSOT. Durability is the file snapshot
(explicit save and expire-save write one blob) or an optional
cabinet ego slice.
*/
attribute requirementId : String = "MN-REQ-01";
requirement def MN_REQ_01_1_NamedSessions {
doc /*
SHALL provide named sessions that retain working-memory state across
turns so pipeline facts outlive chat context.
*/
attribute requirementId : String = "MN-REQ-01.1";
}
requirement def MN_REQ_01_2_SessionLifecycleOps {
doc /*
SHALL support open, resume, and close for each named session.
A live session MAY be copied under a new id (MN-REQ-01.11).
*/
attribute requirementId : String = "MN-REQ-01.2";
}
requirement def MN_REQ_01_3_SessionTtlAndCaps {
doc /*
SHALL apply configurable session TTL and a cap on concurrent
sessions. Sliding TTL: live access extends expires_at. After
TTL the in-memory session SHALL drop, except when expire-save
is on and the snapshot cannot be written: RAM SHALL stay
(MN-REQ-01.9) and the session still counts against
MEMNET_MAX_SESSIONS. Optional expire session_save is
configurable (MEMNET_SAVE_ON_EXPIRE, default off): file
snapshot MAY remain on disk until the user deletes it;
session_load restores RAM. When save-on-expire is off, TTL
drops RAM as before. SHALL NOT auto-flush Neo4j. Explicit
session_save and this expire-save write one
SessionSnapshotBlob.
*/
attribute requirementId : String = "MN-REQ-01.3";
}
requirement def MN_REQ_01_4_SaveSessionSnapshot {
doc /*
SHALL persist a named session to one durable file snapshot so
working-memory state can outlive the process (schema, records,
relations). Explicit session_save and expire-save write that
same blob. The file is not the cabinet and not the model SSOT.
*/
attribute requirementId : String = "MN-REQ-01.4";
}
requirement def MN_REQ_01_5_LoadSessionSnapshot {
doc /*
SHALL restore a named session from a durable snapshot into an active
working-memory session.
*/
attribute requirementId : String = "MN-REQ-01.5";
}
requirement def MN_REQ_01_6_OptionalKeepSessionId {
doc /*
On load, SHALL allow the caller to optionally keep the session id
from the snapshot (keep_id); otherwise assign a new id.
*/
attribute requirementId : String = "MN-REQ-01.6";
}
requirement def MN_REQ_01_7_SessionAsSsotHandle {
doc /*
A named session MAY be the SSOT for a mission SOMETHING
(MissionWorkingSet). When so, an LLM SHALL pass that SOMETHING by
delivering the session id only (SessionHandoff; module A → B pipe).
Peers SHALL re-pin_map; chat, MissionDock payloads, and HTTP bodies
SHALL NOT be treated as SSOT (extends MN-REQ-10.1; Multitask
MN-REQ-12.1). This SSOT is the mission working-set handle. It
is not the model SSOT (git sysml-models/ on this repo and on
modelbasedPrj-*; a bound SysMLEdge desk only on SysMLEdgePrj-*).
*/
attribute requirementId : String = "MN-REQ-01.7";
}
requirement def MN_REQ_01_8_NoGraphDumpHandoff {
doc /*
Session handoff SHALL NOT carry a full graph dump (or mission SSOT
prose blob) as the handoff payload. SessionHandoff carries sessionId
and caller, plus optional missionId, lease, anchors, and writeScope.
Chat, MissionDock, and HTTP bodies SHALL NOT carry the graph.
Mutate still hits CapsPolicy (who / what / bind).
*/
attribute requirementId : String = "MN-REQ-01.8";
}
requirement def MN_REQ_01_9_SnapshotLosslessRoundTrip {
doc /*
Anything the write path accepts SHALL session_save and
session_load byte-for-byte as the same property values.
That includes LF, CR, tab, VT, FF, file/group/record
separators, NEL, line/paragraph separators, backslash,
both quote kinds, dollar, braces, pipe, and CJK. Snapshot
emit SHALL escape those losslessly; load SHALL decode them.
Record split SHALL be LF-only (MUST NOT use
str.splitlines(), which splits on CR/VT/FF/NEL/LS/PS
before unescape). Mutate stdin, leftover pipe batches,
and GQL statement breaks SHALL use that same LF-only
split (optional trailing CR stripped). A raw VT, FF,
FS, GS, RS, NEL, LS, or PS inside a value SHALL stay
inside that value and SHALL NOT start another statement.
Properties mutate stores that are absent from the live
tag SCHEMA SHALL persist by widening the snapshot SCHEMA
(GraphElement extras and Path-B locators such as qname),
including when the CREATE label spelling differs in case
from the SCHEMA tag. A live SCHEMA that omits the id
column SHALL still save: the snapshot SCHEMA gains an
id column and a minted nickname. Live session SCHEMA is
unchanged until load. Fixed
tags EDG/LAW SHALL NOT widen; extras there SHALL fail
closed. A CREATE, SET, or MERGE that would make a tag's
effective field set (declared SCHEMA fields, undeclared
extras on any row of that tag, and the id column save
appends) exceed max_fields SHALL refuse
limit_exceeded|fields n/max and SHALL NOT write
(MN-REQ-05.4). Mutate and snapshot save SHALL share one
effective-field count so save is never stricter than a
mutate that succeeded. Default max_fields is 64
(MEMNET_MAX_FIELDS). Snapshot load SHALL refuse a SCHEMA
over that cap with the same fields n/max code. Save SHALL
fail closed (snapshot_unsaveable naming the row) as a
backstop rather than write an unloadable file,
including when extras would exceed max_fields or the
escaped line exceeds line_bytes. The backstop checks the
header lines (ACL, LIM, SCHEMA) reload, each record line
against line_bytes and value_bytes, and the byte budget;
it SHALL NOT re-parse every record line by default, because
the codec round trip holds for every accepted write
(tests/test_snapshot_codec_property.py). With
MEMNET_DEBUG_SNAPSHOT_VERIFY=1 save, persist, checkpoint
and copy SHALL also parse every line back and refuse
snapshot_unsaveable on any difference
(tests/test_snapshot_reload_debug.py). Expire-save that cannot
write (snapshot_unsaveable or any other save failure,
such as an unwritable disk or directory) SHALL NOT write
a file and SHALL NOT drop RAM. The session stays live,
still counts against MEMNET_MAX_SESSIONS, and every sweep
or access that retries expiry SHALL emit
@WRN: expire_snapshot_failed|<code>. Access after TTL
SHALL report the session overdue
(session_expired|overdue) so the caller can fix and save,
or close. An explicit session_save that succeeds, or an
explicit session_close, ends that hold. When
MEMNET_SAVE_ON_EXPIRE is off, TTL still drops RAM as
MN-REQ-01.3. Snapshots written by 0.19.18 (pipe and
backslash escapes only) SHALL still load.
*/
attribute requirementId : String = "MN-REQ-01.9";
}
requirement def MN_REQ_01_10_SessionLifecycleAclWho {
doc /*
When session ACL is enabled, session_save, session_load into
that ACL'd session, and session_close SHALL accept --caller /
MEMNET_CALLER and enforce CapsPolicy who-check with the same
codes as pin_map / mutate (acl_who, acl_denied, acl_forbidden).
MCP SHALL pass caller through on those tools. Without ACL,
behaviour is unchanged.
*/
attribute requirementId : String = "MN-REQ-01.10";
}
requirement def MN_REQ_01_11_SessionCopy {
doc /*
session copy --from <sid> (CLI, serve argv, MCP session_copy)
SHALL register a new session id holding an exact in-memory
copy of the live source: same hids, nicknames, write order,
id high-water, properties in their stored order, labels,
relations, tag map, cap overrides, product label and ACL
(bind included). Reads on the copy (pin_map, find, walk)
SHALL equal the source, order included; the build SHALL NOT
go through snapshot text. The copy gets a fresh TTL clock from
the source's ttl_minutes, no eviction mark and empty
neighbourhood reserves, and is independent of the source
afterwards. The source SHALL NOT be touched: no TTL slide, no
modified_at or eviction-mark change, no expire drop; a missing
or overdue source refuses session_not_found / session_expired.
The copy is built and checked privately (the save checks:
header lines reload, line and value caps, byte budget; the
full re-parse only under MEMNET_DEBUG_SNAPSHOT_VERIFY=1) and
registered only after the checks pass; a failure registers
nothing. The session cap SHALL NOT evict the source
(limit_exceeded instead). Caller needs pin_map on the source
(MN-REQ-01.10 codes). The reply names the new id only.
The product gateway checks ownership on --from and gives the
new id to the copier. Serve retry treats it as a WRITE. Verify: MN-VER-01-S06
(tests/test_session_copy.py).
*/
attribute requirementId : String = "MN-REQ-01.11";
}
}
// ----- Memory net information model: GQL node, edge, property -----
requirement def MN_REQ_02_MemoryNetGraph {
doc /*
Group: the Net of Memory is a GQL property graph whose three elements
are node (ISO synonym vertex), edge (ISO synonym relationship), and
property (ADR-001; gql-wire-profile). GraphElement is the identity
(CREATE () legal; properties MAY be empty). Grammar has no store
key. Labels name kinds; they are not a fourth element. MUST NOT
invent PORT (or nested graph) as a graph-element kind — those facts
live as property values. MUST NOT invent an application store key.
Agent wire is openCypher-shaped GQL; primary read is shaped pin_map
(not raw MATCH/RETURN tables). NicknameIdProperty is optional
(MN-REQ-02.8), not identity. HiddenStoreHandle off-wire.
Layer / Tier A are archived (not product accept); @TAG pipe
remains import-once only.
*/
attribute requirementId : String = "MN-REQ-02";
requirement def MN_REQ_02_1_ExactlyNodeAndEdge {
doc /*
SHALL model the Net of Memory as a GQL property graph with three
elements: node (vertex), edge (relationship), and property. Topology
is node--edge--node; property values attach to nodes and to edges.
The graph element is the identity. CREATE () is legal. properties()
MAY be empty. GQL grammar has no store key. SHALL NOT add a fourth
graph-element kind (PORT nodes, nested graphs, prose blobs) and
SHALL NOT invent an application store key in place of the element.
*/
attribute requirementId : String = "MN-REQ-02.1";
}
requirement def MN_REQ_02_2_NodesHoldAtomisedFacts {
doc /*
Nodes SHALL hold atomised facts as property values --
one idea per property -- not free-form prose or merged
multi-idea blobs.
*/
attribute requirementId : String = "MN-REQ-02.2";
}
requirement def MN_REQ_02_3_EdgesAreFirstClass {
doc /*
Edges (relationships) SHALL be first-class links between nodes,
not buried in node property values or narrative.
*/
attribute requirementId : String = "MN-REQ-02.3";
}
requirement def MN_REQ_02_4_QueryOverNodeEdgeGraph {
doc /*
Pin map, walk, bounded MATCH find, and query SHALL operate over the
node/edge graph (property values included). Recall SHALL seed from
a cue or pattern (find); pin_map then walks a shape. An optional
nickname id MAY seed pin_map when present -- SHALL NOT require
--anchor as law. Bounded MATCH find (hard LIMIT; shaped subgraph
emit) is the un-nicknamed seed (Recall seed = MATCH; leftover #73)
-- still not unbounded raw MATCH/RETURN dumps as goldfish. Both
seeds are one Recall operator (MN-REQ-13).
*/
attribute requirementId : String = "MN-REQ-02.4";
}
requirement def MN_REQ_02_5_GrammarExpressesNodeAndEdge {
doc /*
Agent-facing grammar and I/O SHALL express node, edge, and property as
openCypher-shaped GQL (labels, edge/relationship types, property maps).
Spelling/identity SSOT is the vendored official BNF
docs/grammar/openCypher.bnf (Apache-2.0; NOTICE-openCypher.md) -- not
a MemNet-invented id law, not TCK compliance, not a second accept
path. Write = display means shaped subgraph emit matches mutate family.
Layer / Tier A SHALL NOT be accepted on the product mutate path.
*/
attribute requirementId : String = "MN-REQ-02.5";
}
requirement def MN_REQ_02_6_ParserRecoversNodeAndEdge {
doc /*
The canonical parser SHALL recover node, edge, and property structure for
human inspection. Grammar parse front is GraphGlot (official grammar);
MemNet product gate is a separate part after parse.
*/
attribute requirementId : String = "MN-REQ-02.6";
}
requirement def MN_REQ_02_7_SchemaValidatedIngest {
doc /*
SHALL validate ingest against the session schema and reject unknown
or reserved surface kinds. Tags MAY realise node labels; GQL
elements remain node (vertex), edge (relationship), and property.
SCHEMA SHALL NOT put id first as a required field. 0.9 leftover
tag_map id_first remains engine as-is, not TARGET.
*/
attribute requirementId : String = "MN-REQ-02.7";
}
requirement def MN_REQ_02_8_IdNotRequiredOnWire {
doc /*
Headline: GraphElement is identity. CREATE () is legal.
properties() MAY be empty. Later MATCH/MERGE looks up labels +
properties; an edge is type + end elements. HiddenStoreHandle
stays inside the store -- not a property, not on the wire, not
a business key. Agent wire SHALL NOT require NicknameIdProperty.
Create, find, and pin_map MAY omit it. When present, id is a
nickname only -- not identity. SHALL NOT invent a replacement
application store key (locator-as-PK, qname-as-PK, minted
string-as-PK). Id-exists / not-found (MN-REQ-03.1 / 03.2)
remain valid only when an optional nickname is present.
0.9 leftover invented store (not TARGET SHALL): leftover_by_id,
leftover_id_first, leftover_NEW_mint, leftover_MERGE_by_id,
leftover_allocate_from_locator, leftover_ingestIsIdRule,
pin_map require_anchor.
*/
attribute requirementId : String = "MN-REQ-02.8";
}
requirement def MN_REQ_02_9_MustNotCopyCousinStoreKey {
doc /*
Cousin pointing contrast (not a product switch). SHALL keep
GraphElement identity and TARGET cue → RelativeSeed → ShapeWalk
→ pin_map emit. MAY copy cue-without-store-key and neighbourhood
emit. SHALL NOT copy: GQL engine; content-hash-of-entire-property-map
as identity; SQLite-clone product job; unique-name MERGE as
universal identity; silent LLM merge of same-name nodes into
the store (Recall SHALL NOT collapse; SameThingAbsorb is an
agent-gated Commit rule); vector/fulltext as pointing; elementId
writeback; Unicode id-normalization; substring/IDF as identity;
Leiden; Cypher export as the query API; type:path:name as agent
language; Fuse+embeddings as TARGET; commit-the-JSON as the
memory product; SiYuan minted block id; NL2GQL vid / id(n) on
the query wire; Logseq unique :block/name as required identity
law. GraphLite SHALL remain a cabinet/store cousin — SHALL NOT
replace the MemNet session-memory product. Cousins confirm
TARGET; they SHALL NOT force a store-key back onto the wire.
*/
attribute requirementId : String = "MN-REQ-02.9";
}
}
// ----- Strict mutate -----
requirement def MN_REQ_03_StrictMutate {
doc /*
Group: explicit create vs replace; no silent upsert.
*/
attribute requirementId : String = "MN-REQ-03";
requirement def MN_REQ_03_1_AddFailsIfExists {
doc /*
When an optional nickname id is present on create, SHALL fail with
an id-exists error if that nickname is already taken. SHALL NOT
require id on create. TARGET create is CREATE () / CREATE
(:Label {props}) without id; properties MAY be empty.
leftover_NEW_mint / leftover_by_id is 0.9 as-is, not this
contract.
*/
attribute requirementId : String = "MN-REQ-03.1";
}
requirement def MN_REQ_03_2_UpdateFailsIfAbsent {
doc /*
When an optional nickname id is present on replace (update), SHALL
fail with a not-found error if that nickname is absent. Ends MATCH
by label + properties when no nickname. SHALL NOT treat missing id
as not-found of identity.
*/
attribute requirementId : String = "MN-REQ-03.2";
}
requirement def MN_REQ_03_3_NoSilentUpsert {
doc /*
Silent upsert SHALL NOT be offered.
*/
attribute requirementId : String = "MN-REQ-03.3";
}
requirement def MN_REQ_03_4_HonourWherePredicate {
doc /*
MATCH ... WHERE ... SET and MATCH ... WHERE ... DELETE SHALL
NOT ignore the WHERE predicate. If lowering cannot honour it,
the whole statement SHALL refuse with unsupported_predicate
naming that predicate, and SHALL apply nothing. Forms that
work today SHALL remain: MATCH (n WHERE true)-[r {id}]->()
DELETE r (edge delete); property-map equality in MATCH.
Honoured WHERE forms (equality, CONTAINS, STARTS WITH,
ENDS WITH, =~, IN, true/false, AND/OR/NOT of those) SHALL
actually filter.
*/
attribute requirementId : String = "MN-REQ-03.4";
}
}
// ----- Slice economy (pin map / recycle / walk) -----
requirement def MN_REQ_04_SliceEconomy {
doc /*
Group: bounded live pin map for LLM turns (not the whole net);
hide recyclable rows; optional relation walk; bounded MATCH find
as cue/pattern seed (MN-REQ-04.6; shipped seed-only). Dark session
empty q is session outline (MN-REQ-04.9) — census of S, not a
neighbourhood and not leftover skip. 0.5 names this family
Recall(q) (MN-REQ-13); pin_map and leftover find are the same
operator with different seed rules. Nickname id is optional.
Engine fixed-law rows (often LAW01-LAW05) are a current
realisation, not the contract identity. Legacy name "warm" = live
pin map (deprecated alias).
*/
attribute requirementId : String = "MN-REQ-04";
requirement def MN_REQ_04_1_AnchoredPinMap {
doc /*
SHALL return a bounded live pin map for a cued request -- a shaped
neighbourhood digest of pins -- not the full session or a raw
search dump. Goldfish seeds from a cue or pattern (find); pin_map
walks a shape. RelativeSeed MATCH_L yields walk-root elements Q;
ShapeWalk walks from Q. A dark session with empty q is outline
(MN-REQ-04.9), not this neighbourhood and not view=shell grain.
Nickname id as pin_map anchor is optional when a nickname exists.
SHALL NOT require --anchor as law. 0.9 leftover require_anchor /
by_id is engine as-is, not TARGET.
*/
attribute requirementId : String = "MN-REQ-04.1";
}
requirement def MN_REQ_04_2_RecycleHiddenFromPinMap {
doc /*
SHALL hide rows marked for settle or expire recycle from the live
pin map.
*/
attribute requirementId : String = "MN-REQ-04.2";
}
requirement def MN_REQ_04_3_PinMapDepthAndRowCaps {
doc /*
SHALL cap live pin map depth and row count.
*/
attribute requirementId : String = "MN-REQ-04.3";
}
requirement def MN_REQ_04_4_EngineLawPrepend {
doc /*
SHALL prepend session engine-law rows to the live pin map when
those rows are present in the store.
*/
attribute requirementId : String = "MN-REQ-04.4";
}
requirement def MN_REQ_04_5_AnchoredWalk {
doc /*
Anchored walk hop lines over the NODE and EDGE graph SHOULD be
available for relation enumeration without loading the whole graph.
*/
attribute requirementId : String = "MN-REQ-04.5";
}
requirement def MN_REQ_04_6_BoundedMatchFind {
doc /*
When no nickname id is known, or when pin_map caps dropped a
needed row, the agent surface SHOULD offer a bounded MATCH find:
label and/or property/locator predicates with LIMIT required
(hard); optional max_rows aligned with MN-REQ-04.3; emit the same
shaped subgraph family as pin_map / mutate (MN-REQ-08.9).
SHALL NOT: binding-table RETURN as primary emit; missing LIMIT;
unbounded MATCH; variable-length path as default; teach full
openCypher (WITH / UNWIND / CALL / subqueries / ORDER BY).
Distinct from mutate MATCH … SET. Shipped as BoundedMatchFind
(implemented=true; #73) — realizes RelativeSeed MATCH_L, not
pin_map k-hop, not copy-id then --anchor.
*/
attribute requirementId : String = "MN-REQ-04.6";
}
requirement def MN_REQ_04_7_RelativeSeedThenShapeWalk {
doc /*
Goldfish query SHALL be discrete codebook tokens (kind / primary
label, properties including locators, keyword; optional nickname
id only if already set) — not a store-key id, not elementId, not
a prose/embedding sentence, not rag_query / cosine / ANN, not
free MATCH RETURN. Recall SHALL seed by RelativeSeed MATCH_L on
those tokens (hard LIMIT L) yielding seed set Q of graph elements
(relative nodes). Empty token / empty q SHALL be session outline
(MN-REQ-04.9): Recall of S as a census — not skip, not invent a
node, not MATCH a leftover id / --anchor as seed. leftover 0.10
empty-seed skip remains leftover_* (productCommand=false; not
TARGET). ShapeWalk SHALL walk k hops from Q under one M (not
M×|Q|), hide recycled, and emit a shaped subgraph. SHALL NOT
require a store-key anchor. Peak_L is a last-resort residual
cue on codebook miss (MN-REQ-04.10), not this MATCH_L mechanism
and not default goldfish. leftover 0.9 require_anchor / by_id /
copied-id is leftover, not TARGET law. BoundedMatchFind / CmdFind
realize RelativeSeed; PinMapShapedRead / CmdPinMap realize
ShapeWalk (and empty-q outline). Peak_L nests under RelativeSeed.
Still ONE Recall operator (MN-REQ-13.1).
*/
attribute requirementId : String = "MN-REQ-04.7";
}
requirement def MN_REQ_04_8_CueMultiRootHonest {
doc /*
Open hard part without a third operator: a codebook cue MAY hit
several relative roots (|Q| > 1). RelativeSeed SHALL stay
bounded (hard LIMIT L) and honest — emit Q as walk roots, do
not invent a node, do not silently pick a store-key. ShapeWalk
SHALL union k-hop under one M (not M×|Q|). SHALL NOT add a new
verb, Peak_L default, or rag_query / ANN to resolve ambiguity.
Re-cue with a tighter token is the product move. Same name (or
any shared cue) is a candidate only — not a find hit that
collapses, not silent MERGE-by-name, not an LLM merge inside
Recall. RelativeSeed / find SHALL emit Q honestly when |Q| > 1
and SHALL NOT absorb. The existing find / pin_map shaped emit
SHALL point the conflict out: Q listed, cardinality visible,
CueConflict mark (usual case: shared name property; any shared
cue that yields several roots is the same signal). SHALL NOT
silently pick one root. Two different world-things that share a
name SHALL appear as conflict (two roots), not as one merged
node. SHALL NOT add name_conflict / merge / absorb as a product
command. SameThingAbsorb stays a Commit rule after the agent
sees the conflict. Contrast nest CousinPointingContrast
records this; Recall/Commit operatorCount stays 2.
*/
attribute requirementId : String = "MN-REQ-04.8";
}
requirement def MN_REQ_04_9_SessionOutlineEmptyCue {
doc /*
Teach name = outline. A dark session SHALL join the handed
session id and ask the session, not a node. Empty q SHALL be
Recall of S: a census of kinds that exist plus a few real
nodes of each, with their actual labels and properties, under
one hard LIMIT (Neo4j Browser / db.labels / AGE ag_label style
+ LIMIT exemplars). SHALL NOT MATCH a node as the seed (no
leftover id, no --anchor). SHALL NOT skip empty seed as TARGET
(leftover_empty_seed_skip is leftover only). SHALL NOT dump
edges, dump S, absorb on the outline, MATCH-all, RAG search,
HostSearch, getAllPages, Pattern C precomputed tour, or
Pattern D seeded RAG. view=shell SHALL NOT be the outline
(that is grain on an already-seeded walk). Leftover ids are
not the next law; after outline the agent picks one seen cue
and pin_maps. Still ONE Recall operator. CueConflict applies
if exemplars collide on a name cue (two roots stay two).
SHALL NOT: third operator; required property id; elementId on
the wire; invent a store key; SameThingAbsorb as this cut;
revive Layer; restore the retired Neo4j cabinet.
*/
attribute requirementId : String = "MN-REQ-04.9";
}
requirement def MN_REQ_04_10_PeakLLastResort {
doc /*
Peak_L is a cue under RelativeSeed, not a third operator.
When seed MATCH_L is empty and q is a non-empty codebook token
(kind / props / keyword present, no hit), Recall SHALL seed from
the typed residual local max of ρ* inside one S (incident edges
except hierarchical contains; hide recycled), then ShapeWalk as
usual. Empty q SHALL remain session outline (MN-REQ-04.9) —
Peak_L SHALL NOT hijack outline. Peak_L SHALL NOT be default
goldfish (defaultGoldfish=false). SHALL NOT use raw contains-tree
degree, density-peak cluster assignment, Leiden from peaks, or
global top-k degree as goldfish. SHALL NOT be a nest fix.
Two peaks / two roots SHALL CueConflict (MN-REQ-04.8); SHALL NOT
absorb in Recall; SHALL NOT silent MERGE-by-name. Hidden handle
stays off the wire. operatorCount stays 2.
*/
attribute requirementId : String = "MN-REQ-04.10";
}
requirement def MN_REQ_04_11_PinMapOrderFromObservables {
doc /*
Gauge honesty (0.19.c; not a usage-method b, not 0.20, not 1.0).
The emitted order of a live pin_map SHALL be a function of the
Recall Shape's observables: kind (primary label) plus the
remaining property payload. HiddenStoreHandle (Record.hid /
_elN / elementId-style) SHALL NOT be a ranking key, SHALL NOT
appear on the wire, and SHALL NOT decide BFS expansion, edge
emit, MATCH_L seed order, outline exemplars, Peak_L tie-break,
max_rows admission, fan-out clamp, or view=shell truncation.
Optional NicknameIdProperty id SHALL NOT be a ranking key
either — ranking by nickname is the same class of leak as
ranking by hid. Name / slug / locators are cue tokens, not
identity. CREATE order and physical write_order SHALL NOT
decide pin_map sequence. Still ONE Recall operator
(MN-REQ-13.1): Recall = pin_map, Commit = mutate. SHALL NOT
add rag_query, leftover add as product, Layer dialect, a third
operator, or raise M. Cue by codebook tokens (kind + locator
slug), never leftover id as the rank key.
*/
attribute requirementId : String = "MN-REQ-04.11";
}
requirement def MN_REQ_04_12_HousekeepEndpointIdentity {
doc /*
Housekeep orphan, dangling, and stale counts SHALL resolve
each edge endpoint by hidden element id (_elN) and by the
optional id nickname. A GQL edge stores _elN. Comparing that
token only to the nickname SHALL NOT mark every node an
orphan. A node is an orphan only when no edge names it.
An edge is dangling only when an end does not resolve.
prune orphans and prune stale with --apply SHALL recompute
with that rule and SHALL refuse prune_referenced, deleting
nothing, when a candidate node is still an edge endpoint.
The stale_orphans warning SHALL NOT suggest prune while
edges still name those nodes. No sweep, housekeep job, or
MCP tool SHALL run prune --apply; only an explicit CLI
--apply does.
*/
attribute requirementId : String = "MN-REQ-04.12";
}
}
// ----- Hard caps -----
requirement def MN_REQ_05_HardCaps {
doc /*
Group: bounded resource use under misuse.
*/
attribute requirementId : String = "MN-REQ-05";
requirement def MN_REQ_05_1_StoreResourceCaps {
doc /*
SHALL enforce hard caps on rows, law rows, relations, tags, fields,
and value/line/batch bytes so the store cannot grow unbounded.
*/
attribute requirementId : String = "MN-REQ-05.1";
}
requirement def MN_REQ_05_2_QueryFanoutCaps {
doc /*
SHALL enforce hard caps on pin-map/walk depth and fanout so token
cost stays bounded under misuse.
*/
attribute requirementId : String = "MN-REQ-05.2";
}
requirement def MN_REQ_05_3_ConsistentValueByteCap {
doc /*
The field-value byte cap SHALL be one hard cap on leftover
pipe mutate, GQL mutate, and snapshot load, measured as the
UTF-8 byte length of the decoded (raw) property value.
Knob MEMNET_MAX_VALUE_BYTES, default 32768. Over-cap SHALL refuse
limit_exceeded|value_bytes n/max and SHALL NOT accept the
write. line_bytes is the UTF-8 byte length of the
escaped/raw leftover-pipe or snapshot line (backslash and
pipe count twice). Save verify and load SHALL use the same
check (MEMNET_MAX_LINE_BYTES, default 135168 (4 x 32768 + 4096,
worst-case escaping)). A single
field under value_bytes still fits default line_bytes;
many fields whose escaped form exceeds line_bytes SHALL
fail closed at save (snapshot_unsaveable wrapping
line_bytes) rather than write a file load will refuse.
*/
attribute requirementId : String = "MN-REQ-05.3";
}
requirement def MN_REQ_05_4_ConsistentFieldCap {
doc /*
The fields-per-tag cap SHALL be one hard cap on SCHEMA
register, GQL mutate, leftover pipe mutate, and snapshot
save/load. The effective count is declared SCHEMA fields
plus undeclared extras stored on any row of that tag,
plus the id column snapshot save appends when the live
SCHEMA omitted it. Default 64. Knob MEMNET_MAX_FIELDS.
Over-cap mutate SHALL refuse limit_exceeded|fields n/max
and SHALL NOT accept the write. Save SHALL use the same
count (one shared helper) so anything mutate accepts can
save and reload. Snapshot load SHALL refuse a SCHEMA over
the cap with that same fields n/max code.
snapshot_unsaveable remains the fail-closed save backstop
when RAM still exceeds the cap (MN-REQ-01.9). Verify:
MN-VER-05-S02 (tests/test_field_cap.py).
*/
attribute requirementId : String = "MN-REQ-05.4";
}
requirement def MN_REQ_05_5_SessionCapEvictLru {
doc /*
Shipped in the unreleased engine. Runtime checks:
tests/test_session_evict.py (no xfail).
State (checked at 0.19.25 source). Session-scoped CLI commands
call _load_session, which calls ss.touch(). So the MCP reads
pin_map, query_warm, find, query_walk, read_list, export_pin_map,
housekeep_stats and session_current already touch today, and so do
the CLI-only reads (session_resume calls ss.touch() itself). The
in-process get_session() only extends the TTL and does NOT touch:
a read through get_session() alone leaves modified_at unchanged
today. That is the gap the touch rule below closes. session_list,
serve_status and the admin commands do not touch. The saves
session_save, expire-save, admin checkpoint and evict-save do not
touch either (MAINTENANCE-SAVES below); a save is not a read surface.
Cap. At session open or load, after purge_expired, when the count
reaches MEMNET_MAX_SESSIONS (default 1024) the engine SHALL pick at
most one victim. One cap lock SHALL cover the count, the victim pick
and the slot reservation; the victim is marked evicting under that
lock. The save then runs outside the cap lock, under the victim's
session lock.
Victim. The live, non-evicting session with the oldest last touch,
ordered by (modified_at, touch_seq) and compared as parsed instants,
not as strings. SessionMeta.modified_at is set by SessionStore.touch();
touch_seq is the tie-break (see Tie order). Every non-admin caller
read SHALL set SessionMeta.modified_at through SessionStore.touch().
The caller read surfaces are the READ-SURFACES block below; the
reads that are NOT touches are the NON-TOUCH-READS block below.
Writes (mutate, add, update, import_slice, ingest_*) are touches.
Load (session_load) is a touch with a fresh TTL. Saves SHALL NOT
touch: session_save, expire-save, admin checkpoint and evict-save
(the MAINTENANCE-SAVES block below) SHALL leave modified_at and
touch_seq unchanged. Open stamps the first touch (modified_at =
created_at) and takes a touch_seq, so a never-read session has a
defined last touch.
Tie order. touch_seq is a process-wide monotonic counter held on the
registry entry (SessionEntry) and advanced at every touch and open.
Build option: touchSeqMonotonic=true, touchSeqInSnapshot=false. The
counter is not persisted: a session loaded from a snapshot gets a
fresh touch_seq, because the load is a touch. Order by name then id
is the fallback only if a build cannot hold the counter; this build
can, so the fallback is not used.
The READ-SURFACES, NON-TOUCH-READS and MAINTENANCE-SAVES lists cover
the MCP tools and the CLI-only surfaces. READ-SURFACES is MCP read
tools, CLI-only reads
(session_resume, tagmap_show, relations_list, query_neighbors,
query_path, query_context, query_typed_walk (14.3),
housekeep_stale, housekeep_orphans,
housekeep_dangling, housekeep_recyclable, query_follow (15)) and the in-process
get_session. Every session-scoped CLI command in cli.py is a read,
a non-touch read, a maintenance save, or a non-read; the sync test fails
on any other.
READ-SURFACES-BEGIN
get_session
pin_map
query_warm
find
query_walk
query_typed_walk
typed_walk
read_list
export_pin_map
housekeep_stats
session_limits
session_current
session_resume
tagmap_show
relations_list
query_neighbors
query_path
query_context
housekeep_stale
housekeep_orphans
housekeep_dangling
housekeep_recyclable
follow_proxy
query_follow
READ-SURFACES-END
NON-TOUCH-READS-BEGIN
serve_status
session_list
admin_usage_report
admin_checkpoint_verify
NON-TOUCH-READS-END
MAINTENANCE-SAVES-BEGIN
session_save
expire_save
admin_checkpoint
evict_save
MAINTENANCE-SAVES-END
A fresh open cannot be its own victim: its session is not in the
registry until its slot is reserved under the cap lock, so the pick
never sees it. A load of an evicted id is excluded from its own pick
the same way. Only an open bind or live writes (its session lock held
by an in-flight mutate or commit) exempt any other session. A reserve
(RSV) lease alone does NOT exempt its session. Exempt sessions are
never auto-dropped.
Save first. The victim's session lock SHALL be held from pick
through save, RAM drop and registry removal, then released. The
victim keeps its slot until it is dropped: the open that picked it
waits for that save and takes the slot only after the drop. Under
that lock the victim SHALL be written to MEMNET_EXPIRE_SNAPSHOT_DIR
(reused; written whether or not MEMNET_SAVE_ON_EXPIRE is on) as an
atomic write: temp file in the same directory, fsync the file,
rename over the final name, fsync the directory; mode 0600; @SNAP
version 2 with the ACL. Only after a complete save SHALL the engine
drop the victim from RAM, then remove its registry entry. A failed
save keeps the victim live (EvError: evictSaving to active); the
engine then tries the next-oldest candidate, or refuses with
limit_exceeded if none is left.
Crash safety. A crash after the fsync and before the drop SHALL
leave a complete snapshot. On restart the session is restored from
that snapshot or is absent; never torn. Crash safety holds only where
the filesystem supports directory fsync: EINVAL, ENOTSUP and
EOPNOTSUPP from that fsync are tolerated, so there the rename is not
guaranteed durable.
No snapshot dir. MEMNET_EXPIRE_SNAPSHOT_DIR has no default. Without
it the cap refuses and nothing is evicted. With it set, a full cap
evicts. An optional neutral alias MEMNET_SNAPSHOT_DIR MAY name the
same directory. If both are set to different paths, serve SHALL
refuse to start: Caps construction fails with config_conflict and
neither path is printed. The same path under both names is accepted.
Dropping a separate eviction knob is deliberate: one dir, one meaning.
Expiry never blocks reads; CLI and MCP reads of a session another thread holds wait for that holder; in-process get_session takes no lock and does not wait.
Unsaveable. An unsaveable candidate (snapshot_unsaveable, over cap,
or write error) SHALL stay live and the engine SHALL try the
next-oldest candidate. No auto-drop of unsaveable sessions. The
count of sessions held unsaveable SHALL be reported as
sessions_unsaveable_held on serve_status and surfaced to admin.
Refusal. If no session is evictable, the engine SHALL refuse with
code limit_exceeded and the plain message "all sessions are in use".
Nothing SHALL be dropped and no snapshot written.
Restore. session_load of an evicted id from its snapshot SHALL give
the same ACL, no lease carried over: reserve leases do not survive
and the restored session has no bind. A load is a touch and starts
a fresh TTL. The reopened session returns restored=true and emits
no alerts.
Lost lease. A commit naming a lease the caller no longer holds SHALL
be refused with code lease_lost; nothing is written; the refused
commit is not a touch. The commit names the held reserve with the
new wire arg rid (MCP mutate rid=, CLI mutate --rid), and llm_id
names the holder. lease= is not this arg: it stays the SessionBind
lease (MN-REQ-06.16). The arg is new and shipped
(deploy commitRefusesLostLease=true).
A rid naming a live lease held by a different llm_id SHALL be refused
with the existing code reserved (MutateGate reserve check,
check_mutate_ids). reserve_conflict is the acquire-side overlap code
and is not used on commit. Not lease_lost: the lease is still live.
A commit that names no rid SHALL behave exactly as today: the
MN-REQ-12.13 reserve check is unchanged (no_llm_id or reserved on a
leased row). lease_lost fires only when a rid is named, so a no-rid
commit after eviction and reload succeeds and changes the field.
Regression, not xfail: tests/test_mutate_no_rid_regression.py.