Skip to content

Restart restores the newest valid snapshot set; range where_type_mismatch; memnet-mcp extra check - #254

Merged
chouswei merged 9 commits into
masterfrom
fix/restart-restore
Nov 4, 2026
Merged

chouswei merged 9 commits into
masterfrom
fix/restart-restore

Conversation

@chouswei

@chouswei chouswei commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Why

Owner goal: after a memnet serve restart, every session comes back, restored from the newest valid snapshot set, with a defined rule for which set wins when there is both a checkpoint and an upgrade-prepare. Range WHERE refuses type mismatches such as n.rowRev > '123'. memnet-mcp without the extra tells you exactly what to install. The model (SysML) matches.

Root cause

When serve starts, it only looked at upgrade-manifest.json. It never read checkpoint/checkpoint-manifest.json. After the first restore, retire_manifest marked the upgrade manifest retired, and later starts skipped retired manifests without saying so. So a restart after a checkpoint, or a second restart after an upgrade, came up with 0 sessions.

Fix

  • upgrade.startup_restore_or_exit looks at both sets (restore_candidates()). The newest valid set wins, by manifest timestamp or else mtime, and a tie goes to upgrade. A retired manifest is still a candidate.
  • If the newest set is corrupt, restore falls back to the next one with @WARN: restore_fallback. If no set is valid, serve exits 3. @STAT: restore_source names the set it used.
  • Range WHERE: a quoted operand against a stored number, or the reverse, is refused where_type_mismatch. Equality is unchanged.
  • memnet_mcp/entry.py checks for the extra before it parses arguments. Without it, it exits 2 with one line: pip install 'memnet-llm[mcp]'. The console entry is now memnet_mcp.entry:main.
  • Model: MN-REQ-06.17 (restart restore), 06.18 (mcp extra) and 14.1 (range refusal), with S15 and S16. Validator counts are unchanged from base.
  • CHANGELOG [Unreleased].

Tests

  • tests/test_restart_restore.py starts a real serve subprocess, kills it (SIGKILL and SIGTERM) and restarts it, then checks per-session rows and relations. It also covers precedence, retired manifests and the corrupt-set fallback.
  • tests/test_typed_walk_where.py covers the range type refusal. The rowRev test is renamed ..._is_refused.
  • memnet-mcp extra check test, and updated ssot-to-code pins.
  • Full suite on this branch, rebased on master c2f802d (keep-alive Serve keep-alive + client socket pool for pass-through (3 RTT → 1) #253): all pass. ruff is clean.

Real-serve proof (kill and restart, 3 seeded sessions, after a checkpoint)

Base 0a9c7c5:

restart 1 (SIGKILL): 0 sessions
restart 2 (SIGTERM): 0 sessions

This branch, combined with keep-alive:

before kill: 3 sessions [(5, 2), (7, 3), (9, 4)]
restart 1 (SIGKILL): 3 sessions [(5, 2), (7, 3), (9, 4)] | same ids and counts: True
restart 2 (SIGTERM): 3 sessions [(5, 2), (7, 3), (9, 4)] | same ids and counts: True

Nits (not fixed)

  • docs/lan-mcp-front.md:13 wording; safe-upgrade.md:35 cross-reference.
  • upgrade.py: a missing sessions key is accepted as empty.

LATER

  • A non-integer rows/edges value in a manifest gives a traceback (pre-existing).
  • retire_manifest errors print no @ERR (pre-existing).
  • entry.py error names a dependency module.
  • L-RR-1: auto-checkpoint on SIGTERM.
  • L-RR-M1: rules held by code reading with no test yet (an empty newest set wins; a load failure exits 3 with no fallback; upgrade_restore_registry_busy).
  • L-RR-M2: move the new model leaves to package-level usages with derivation edges once the validator resolves references between files.
  • L-RR-M3: sysml-models/outputs/ docs (ssot-to-code-allocate-map, safe-upgrade-case-study, checkpoint-case-study) still describe the old retire behaviour and the old console entry.

The upgrade-safety points (mixed-version clients, health gate, one-step rollback, binds across upgrade and rollback) will come in a companion PR on top of this one.

…(red-first, P-restart)

New tests/test_restart_restore.py (real process SIGKILL/SIGTERM, precedence both ways,
field case, tie, loud fallback, exit 3, skipped). test_safe_upgrade: a later start still
restores; the third TCP start finds kept-fact. Red on 0a9c7c5 by design.
…ore)

Start-up now ranks the checkpoint and upgrade-prepare manifests by
timestamp (else mtime; tie goes to upgrade), pre-flights each, falls
back loudly past broken newer sets, and exits 3 when none is valid.
A retired upgrade manifest stays a candidate. prepare_upgrade stamps
its manifest. Docs: Restart restore section, [mcp] install extra.
… (P-type)

Score /tmp/srs/score.md §1.6-1.7. New tests/test_range_type_refusal.py and
tests/test_mcp_extra_missing.py; in test_range_where.py the four quoted-string
vs numeric-field NO_MATCH params move to a where_type_mismatch refusal; in
test_typed_walk_where.py the mixed-pair rows become refusals and the rowRev
quoted-operand test is renamed ..._is_refused.
…ows (P-type)

Owner settlement of blocker r00002438. test_main_use_row_rev_quoted_operand_gives_no_rows
keeps its old name (body stays the refusal; rename moves to M4 MODEL-ALIGN).
In test_range_where.py, string-skips-numeric (n.x > '2000') moves out of
ONE_MATCH to a where_type_mismatch refusal, and the r.n > 'a' row of
test_relationship_range_delete_cardinality expects where_type_mismatch.
A quoted number range operand refuses at parse time; a quoted string
against a stored number refuses at evaluation. AND/OR evaluate every
child so the refusal does not depend on sibling order. Inline WHERE
re-raises the refusal instead of falling to the relationship parser.
Docs: cap-contract Range WHERE typing rules, gql-wire-profile WHERE row.
New memnet_mcp.entry checks mcp.server.fastmcp and uvicorn before argument
parsing and writes one @err: mcp_extra_missing line naming
pip install 'memnet-llm[mcp]'. Console script and python -m memnet_mcp now
go through it. README and gateway/LAN front docs say any host running
memnet-mcp installs the extra.

Symphony restart-restore, movement M2, node E-mcp.
…tch 14.1; S15, S16; console memnet_mcp.entry:main (MODEL-ALIGN)
@chouswei
chouswei merged commit afcfab4 into master Nov 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant