Skip to content

fix(memory): restore member snapshots from the 0.7.0 pre-release layout - #16253

Merged
bolichen97 merged 1 commit into
mainfrom
fix/member-backup-pre-identity-layout
Oct 3, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/member-backup-pre-identity-layout

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A crew member's memory snapshot or pending restore from 0.7.0-insider.1 to .5 can still be restored or cancelled after the upgrade.

Those pre-release builds wrote member snapshot manifests and pending-restore journals that name the owner as owner_member, the member's alias. They also wrote a memory.db with no member_database row. Today's build refuses all of it. An old backup cannot be restored, and a restore the old build staged before the upgrade can be neither activated nor cancelled. The next gateway start reports it as an ownership mismatch, and it stays that way.

Why it matters

A member snapshot is the operator's recovery point for that member's memory. Anyone who backed up a member on a 0.7.0 pre-release loses that recovery point on upgrade. Anyone who requested a restore just before upgrading is left with a pending restore they cannot finish or withdraw.

Not a goal

  • Importing the pre-release lessons.jsonl and memory/history/<date>.md into memory.db. They are carried into the restored tree but not read, as the spec records.
  • Recovering a store whose live directory is lost, whose old activation crashed between its two renames, or whose live database is corrupt. The store upgrade cannot attribute such a store, so its legacy restore stays refused.
  • Member schedules and task records from the same builds. Those are a separate PR (fix/memory-v2-upgrade-compat), and the two share no code.
  • Any change to the default memory store or global memory.

What changed (motivation → approach → change)

The old files carry enough to identify the owner. The alias resolves through the attribution that the start-of-process store upgrade (#12103) already made. In member_memory_backup.py, a pre-identity manifest or journal belongs to the member only when the store record's owner_member is that alias and the member under that alias is bound to the store and carries owner_member_id. Its legacy file names are accepted only inside a manifest of that layout. Its database must pass the integrity check, carry this store's store_name stamp, and name no other store or member.

The copy is completed before live memory is touched, so a failure never leaves the live tree replaced by an unfinished one. An old snapshot is completed in its stage and staged in the current layout. A restore the old build staged is completed on a fresh copy of its stage. An atomic journal rewrite then switches to that copy, so a failure or crash before the switch leaves the old stage matching its own checksums, and the next start retries. Only a tree the old build itself activated is completed in place.

In memory_stores.py, the store upgrade's directory completion becomes complete_legacy_member_directory, shared with restore. Both legacy SQLite helpers now use _sqlite_compat, the FTS5-capable driver. Cancelling over an unreadable live database is now a ValueError that keeps the journal.

Backwards compatibility

Compatible: every manifest and journal main accepts takes the same path. Only the pre-identity layout, which main refuses, is newly read.

Removes nothing: no file, key, row or public function is removed. migrate_legacy_member_stores calls the extracted helper with the same steps in the same order.

Tests

test/test_member_memory_backup_legacy.py builds the pre-identity layout directly:

  • An old snapshot restores and gains its member identity, and is staged in the current layout.
  • A restore the old build staged activates, and can be cancelled.
  • A completion that fails at activation leaves live memory in place.
  • A stop after the database step, before the new manifest, or before the journal rewrite still retries to activation.
  • The switch produces a current-layout stage and journal, and cancel works afterwards.
  • A tree the old build activated before an interruption is completed.
  • Another member's snapshot is refused. Legacy-only files are refused in a current manifest.
  • Cancel refuses cleanly over an unreadable database.
  • The completion uses the FTS5-capable driver.
  • A snapshot that cannot be completed is refused before staging.

Manual verification

N/A: the tests build the manifest, journal and database shapes of 0.7.0-insider.1 to .5 (checked against those tags) and run the real staging, activation and cancel paths.

Related Issues

Follow-up to #12103, which upgraded pre-identity member stores.

Pattern harvest

Not generalizable: this is a one-time reader for one pre-release layout, keyed on that layout's owner_member field.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): memory-skills-hooks spec
  • No secrets, credentials, or internal references in the diff

0.7.0-insider.1 to .5 wrote member snapshot manifests and
pending-restore journals that name the owner as owner_member (an
alias), and a memory.db with no member_database row. Old backups were
refused, and a restore staged before the upgrade could be neither
activated nor cancelled.

The alias is read back through the store upgrade's attribution, and
the old database is checked against its own stamps. A pre-identity
copy is completed in its stage and given a current-layout manifest
before live memory is touched: at staging for an old snapshot, and
at activation, before the live tree moves aside, for a restore the
old build staged. That one is completed on a fresh copy of its stage
that an atomic journal rewrite switches to, so a completion that
fails or is interrupted leaves the old stage matching its own
manifest: live memory stays in place and the restore can be retried
or cancelled. Only a tree the old build itself activated is completed
in place. Both legacy database helpers use the FTS5-capable driver,
and cancelling over an unreadable live database is a clean refusal.

The memory-skills-hooks spec records the decisions.
@bolichen97
bolichen97 requested a review from a team as a code owner October 2, 2026 20:49
@bolichen97
bolichen97 requested a review from buluoray October 2, 2026 20:49
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 96013441a3dc54b2329290128e3ddeeb8455ba52 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Alias is the only ownership proof for legacy bundles — confirm an alias rebound to a different member since 0.7.0 cannot pass _names_owner.

[DESIGN-REVIEWED] 9601344

Description read

[DESCRIPTION-READ] fd7a8feec806764d72c7d2c44b4a41caaee75aae2cd50e074ba2a99b4fe18a7a

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 96013441a3dc54b2329290128e3ddeeb8455ba52 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the manifest/journal shape the tests fabricate against a real 0.7.0-insider backup zip — the author checked only "against those tags."

Not justified as shipped

  • Item 7 — rides along: declared ("Cancelling over an unreadable live database is now a ValueError that keeps the journal") but applies to every store's cancel path, not just the legacy layout the fix targets; harm is named (clean refusal, journal kept) and tested, so inventory only.

What this change ships

Inventory (10 items) — 9 justified

Intent: let a member memory snapshot or pending restore written by 0.7.0-insider.1–.5 be restored, activated or cancelled after upgrading — a FIX (the new tests fail on base, and the pre-identity layout is already pinned in-repo by #12103's store upgrade).

  1. A snapshot a 0.7.0 pre-release wrote restores again instead of being refused — justified
  2. A restore the old build staged before the upgrade activates again — justified
  3. That same staged restore can be cancelled again — justified
  4. Legacy bundle files (lessons.jsonl, memory/history/*.md) accepted only inside legacy manifests, carried not imported — justified
  5. A failed or interrupted legacy completion leaves live memory untouched and retries next start — justified
  6. A tree the old build activated before interruption is completed at next start — justified
  7. Cancel over an unreadable live database refuses with a clean error and keeps the journal, on all stores — rides along (declared; harm named and tested)
  8. Both legacy SQLite helpers open through the FTS5-capable _sqlite_compat driver — justified
  9. New shared helper complete_legacy_member_directory — justified (3 counted consumers: migrate_legacy_member_stores, member_memory_backup.py:395,441)
  10. memory-skills-hooks spec updated in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] 9601344

Description read

[DESCRIPTION-READ] 59056d0f9c0caed882ee3dc46b369d0ab405d040d16d67462fad8ca204cd2b28

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 96013441a3dc54b2329290128e3ddeeb8455ba52 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9601344

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 96013441a3dc54b2329290128e3ddeeb8455ba52: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 96013441a3dc54b2329290128e3ddeeb8455ba52 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9601344

Verdict parsed from the review's SHA-scoped output markers for commit 96013441a3dc54b2329290128e3ddeeb8455ba52.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 96013441a3dc54b2329290128e3ddeeb8455ba52: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 2, 2026
@iamwhatever
iamwhatever added this pull request to the merge queue Oct 2, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Companion PR for the same 0.7.0 pre-release range (member task records and schedules): #16269. The two PRs share no code and can merge in either order.

@bolichen97
bolichen97 enabled auto-merge (squash) October 3, 2026 01:30
@bolichen97
bolichen97 merged commit 0a67f97 into main Oct 3, 2026
96 checks passed
@bolichen97
bolichen97 deleted the fix/member-backup-pre-identity-layout branch October 3, 2026 01:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
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.

2 participants