Skip to content

refactor(maintenance): delete archive repair and bootstrap commands - #5646

Merged
Sinity merged 4 commits into
masterfrom
claude/prep-maint
Sep 27, 2026
Merged

Sinity merged 4 commits into
masterfrom
claude/prep-maint

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Deletes seven ops maintenance commands that initialize an archive, migrate a durable tier, or repair or salvage archive state. No current code path produces the state any of them handled, or the state has a named invariant task. The MCP recovery operations go with the CLI route. The fresh v1 archive is created when the daemon first opens its root, so none of these commands has work to do there.

Command Decision Why it is unnecessary
archive-init, archive-plan delete Opening an archive root creates it: _initialize_active_archive_root creates every tier under one pending intent and publishes the format marker. archive-init --replace-existing could not replace a durable tier (its own planner blocked that), so it only recreated derived tiers, which bootstrap also creates. archive-plan only planned archive-init.
migrate-tier delete No durable migration is declared: storage/sqlite/migrations/{source,user,audit} contain only __init__.py. Its audit-adoption, restore, rebind and --initialize-missing routes existed for archives that predate the audit tier. Bootstrap now creates audit.db with the other durable tiers, and a lost durable tier is refused by name.
blob-disposition, blob-residue-compare delete These were one-time planners for the old archive's physical blob namespace; the module named this deletion trigger itself. The fresh archive receives blobs only through publication-before-row, and lease-safe GC collects unreferenced objects. The old namespace is inert salvage.
embedding-preservation delete No product route replaces embeddings.db: reset keeps it, and vectors are keyed by content and reused after an index rebuild. Reusing the old root's vectors once after the fresh build is a private one-off, not a product route.
operation-recovery (+ MCP recovery_status / recovery_adjudicate) delete Operator testimony is not an acceptable recovery route. A current path still produces the state, so the invariant is tracked separately (see Residuals).

Problem

  • Each command was either an ordinary lifecycle step that the daemon's open already performs, or a repair for damage that no current writer can produce.
  • migrate-tier, archive-init and operation-recovery were offline writers. They refused to run beside a live daemon, so an operator had to stop the daemon to use them.
  • ops status, capability readiness and archive debt told operators to run archive-init --yes for a missing tier. Durable schema skew and a lost audit.db pointed at migrate-tier.

Solution

  • Removed the command modules, their maintenance modules (archive_init.py, the planner half of archive_plan.py, blob_disposition*.py, blob_residue_comparison.py, embedding_preservation.py), declarations, output schema and tests.
  • Removed the CLI-only engine entry point rebind_audit_adoption_archive_identity. The rest of the adoption engine is still wired into bootstrap, so retiring it is a separate task.
  • AuditRepository.adjudicate_recovery, its continuity replay kind, and list_recovery_operations / list_targets are gone. The MCP maintenance tool now declares only rebuild_insights.
  • The missing-tier hint in status, readiness and archive debt is now polylogued run.
  • A lost audit.db is refused as a lost durable tier and is never recreated.
  • The durable skew remedy names the runtime that wrote the tier.
  • One lost_durable_tiers predicate (fresh root, pending bootstrap intent and an audit tier with an adoption receipt are not lost) drives both archive debt and the archive_storage readiness hint: a lost durable tier is blocked with a verified-backup restore remedy, and everything else keeps polylogued run.
  • A pending audit continuity command of a kind this runtime does not declare raises the typed AuditContinuityUnknownMutationError and stays pending.
  • The MCP maintenance declaration's minimal call carries confirm=true.
  • Docs and generated surfaces are updated. The deleted verbs are added to the retired-verb ratchet.

Verification

  • devtools test over 29 affected CLI, MCP, agent-integration, daemon-status, readiness, operations and storage files: 823 selected, 768 passed, 55 failed. The same 33 test functions (55 parametrized cases) fail identically on the base 2da021c54 (55 failed): stale test_offline_writers rows for backup and scan-secrets, which now route through the daemon; MCP write-tool routing; test_read_path_no_writer_lease; test_connection_profile skew cases; and durable-train fixtures that assume a numbered source slot. None come from this change.
  • devtools verify --quick: verify: PASSED.
  • devtools gate mypy: Success: no issues found in 3113 source files.
  • devtools render all --check: exit 0, no out of sync.
  • devtools gate layering: 0 violations; the baseline drops from 198 to 193 entries.
  • devtools schema closure: IN for operations/audit.py, operations/durable_change_train.py, operations/mutation_transaction.py, readiness/capability.py, storage/sqlite/archive_tiers/{archive_plan,bootstrap}.py, storage/sqlite/connection_profile.py and storage/sqlite/durable_change_train.py.

Residuals

  • polylogue-aw070: every mutation actuator except session delete (33 classes) still fails closed to an operator-blocking unknown after an interrupted apply. Adjudication was the only way out, so until that task lands, a daemon crash mid-mutation keeps refusing later mutations that overlap the interrupted operation's targets.
  • polylogue-rtmx6: the legacy audit-adoption engine (receipts, restore, continuity) remains wired into bootstrap and train reconciliation, although no current writer produces a receipt.
  • polylogue-ywsgj: the durable-change-train engine has no production caller until the first declared migration arrives with a daemon-open apply route.
  • polylogue-dwivx: the embeddings schema has no in-place migration route, and its skew remedy still says rebuild or recreate.
  • tests/unit/daemon/test_daemon_status.py::test_caller_payload_refresh_uses_invocation_frame fails identically on the base; the rest of the review-fix selection passed (173 passed).
  • Several changed files are in the derived schema-identity closure (bootstrap, archive_plan, both durable_change_train modules, audit, connection_profile, readiness/capability). This must land before the fresh build starts.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T20:00:37.705996Z eae234d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3375619686

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/operations/archive_debt.py Resolved
Comment thread polylogue/operations/audit.py Resolved
Comment thread polylogue/mcp/declarations/registry.py Resolved
Sinity and others added 3 commits September 27, 2026 20:45
Opening an archive root already creates it, no durable migration is
declared, and no current writer produces the states the blob
disposition, embedding preservation, audit adoption, or recovery
adjudication routes handled. Delete archive-init, archive-plan,
migrate-tier, blob-disposition, blob-residue-compare,
embedding-preservation and operation-recovery, with the MCP
recovery_status/recovery_adjudicate operations and the audit
adjudication method. Point missing-tier hints at polylogued run and
refuse a lost audit.db by name.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
…ng reuse

A pending audit continuity command of a kind this runtime does not
declare now raises a typed AuditContinuityUnknownMutationError and stays
pending, instead of an untyped RuntimeError. Archive debt classifies a
durable tier lost from an established root as blocked with a
restore-from-backup remedy; only a fresh root or a missing derived tier
points at polylogued run. The maintenance tool's declared minimal call
now carries confirm=true.

Embedding preservation and reuse verification stay: reusing the preserved
vectors after the fresh build is lifecycle work (polylogue-6j5a9 moves it
onto a daemon operation).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
The preserved vectors are needed once, after the fresh build, through a
private one-off script; the repository keeps no reuse route. Correct the
AGENTS.md tier row, and fix a test's Optional type.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 408a886819

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/operations/archive_debt.py Resolved
Comment thread polylogue/daemon/status.py Resolved
Share one lost_durable_tiers predicate between archive debt and the
archive_storage readiness component. A pending bootstrap intent, a fresh
root, and an audit tier with an adoption receipt stay actionable through
polylogued run; a durable tier lost beside a surviving one points at a
verified-backup restore.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@Sinity
Sinity enabled auto-merge (squash) September 27, 2026 20:01
@Sinity
Sinity merged commit 5dee64b into master Sep 27, 2026
3 checks passed
@Sinity
Sinity deleted the claude/prep-maint branch September 27, 2026 20:05
Sinity added a commit that referenced this pull request Sep 27, 2026
## Summary

`polylogued run` now applies pending declared durable migrations when it
opens the archive, before it serves anything. A step that changes
existing data runs only behind a backup the daemon takes itself and
scratch-verifies.

## Problem

- Durable tiers (`source`, `user`, `audit`) evolve by numbered
migrations with change-train sidecars. #5646 deleted `ops maintenance
migrate-tier`, their only application route, so
`execute_durable_change_train` had no production caller.
- No durable migration is declared today. The first one would therefore
have shipped with no way to apply it except a maintenance command, which
the operator has ruled out.

## Solution

- `operations/durable_change_train.py` gains
`pending_durable_migrations`. It lists each durable tier standing below
the runtime's declared version that has a complete declared route (every
step from the current version to the target) and says whether any step
requires a backup. A tier with no declared route is left alone, and
schema preflight still reports its skew.
- `daemon/durable_migrations.py` adds
`apply_declared_durable_migrations`. For each pending tier it runs
`execute_durable_change_train` under the daemon's write lease, with the
daemon's exclusive archive ownership. The daemon keeps that ownership
afterwards, so the train's release is a no-op.
- For a step that requires a backup, `pre_migration_backup` first runs
`backup_archive(verify=True)` into
`.maintenance-state/pre-migration-backups/`:
- It uses the `user_overlays` profile for user and audit, and
`rebuildable_cache_exclude` for source, which carries its blobs.
- The train binds the backup's authenticated receipt to the exact
pre-apply bytes.
  - A failed backup refuses startup.
- `backup_archive` accepts `archive_owner`: the caller's existing
exclusive ownership. The backup copies under that ownership instead of
acquiring its own, which the daemon's own lock would refuse at open.
- `daemon/cli.py` calls the route right after durable-change-train
reconciliation, inside the same ownership scope, and emits
`daemon.durable_migration.applied` for each applied tier.
- The durable-schema section of `docs/maintenance.md` describes the
route.

## Verification

- `tests/unit/daemon/test_durable_migrations.py` ships synthetic
numbered migration packages:
- An archive already at the runtime version is left alone and gets no
backup directory.
- An additive `source` step applies without a backup, and a second open
is a no-op.
- A data-changing `user` step applies only after a verified backup; the
manifest and verification receipt are present.
- `devtools test` over `test_durable_migrations.py`,
`test_daemon_cli.py` and `test_backup.py`: `185 passed, 3 failed`.
-
`test_run_daemon_services_parks_operation_recovery_on_audit_schema_mismatch`
failed because the first version tried to migrate a tier with no
declared route. That is fixed, and it passes on rerun with the migration
tests.
- `test_run_daemon_services_waits_for_fts_startup_before_watcher` (2
parametrizations) fails the same way on current master: its fake
converger lacks the `derivation_barrier` argument #5664 added.
- `devtools gate mypy`: `Success`.
- `devtools gate schema-closure`: `ok`, no change (567).

## Residuals

- The source-tier backup copies referenced blobs, so a data-changing
source migration pays that copy at open.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 28, 2026
## Summary

An interrupted mutation now always ends in a definite, terminal state
that no later request is refused by. Every executor-routed mutation
family declares a recovery route, and daemon startup resolves each dead
operation with it. The operator-adjudication route is gone (#5646), and
this PR removes the `unknown` outcome it existed to clear.

## Problem

- An operation whose owner died between its durable intent and its
terminal record was classified by `inspect_recovery`. Every actuator
except session delete inherited `_FailClosedRecovery`, which always
answered `unknown`/`operator-blocking`. Family or version drift did the
same.
- The run then became a `recovery_unknown` barrier: every later mutation
overlapping its targets was refused. With #5646 there is no adjudication
route left, so a daemon crash in the middle of a tag write could wedge
that session's user-state writes permanently.
- `recovered_applied` also installed a duplicate-effect barrier that
refused later identical requests.

## Solution

- `ConvergentReplay` (in `operations/mutation_transaction.py`) replaces
`_FailClosedRecovery`. An actuator's `apply` must reach the plan's
effect from any state an interrupted apply of the same plan can leave.
`replay_args` rebuilds its arguments from the recorded plan context plus
writable handles.
- Every plan context now carries every input `apply` reads. This PR adds
author to tag add, actor and `now_ms` to lifecycle request, session id
and actor to excision, and `sample_size` to the blob-ref actuators.
- Four actuators needed changes to become convergent:
  - Session delete and identity reset skip ids that are already gone.
  - Excision reports a session it no longer finds as already satisfied.
  - Blocker resolve treats an already-resolved blocker as satisfied.
- Two families are not re-applied:
- The annotation batch import cannot be re-applied, because its rows are
not in the plan. It commits in one transaction, so `recover` reports
`complete` or `absent` from the batch row.
- An interrupted ingest is left to the next intake pass, which re-admits
it idempotently.
  - The sealed insight page re-derives its frozen targets.
- `operations/mutation_replay.py` holds the registry of recovery routes,
keyed by operation name, and `recover_interrupted_operations`, which
moves here from `mutation_transaction`.
- Each orphan resolves to one of `recovered_complete`,
`recovered_absent`, `recovery_not_replayable` (family or version
retired) or `recovery_replay_failed`, recorded by
`AuditRepository.record_recovery_resolution` (a new audit-continuity
command).
  - None of these outcomes is a barrier.
  - Binding validation now requires a `recover` route.
- The executor's overlap check waits on live owners and resolves dead
ones through the same route before it proceeds. `mutation_transaction`
cannot import the registry, because the registry would pull every
actuator into the derived schema-identity closure. The registry
therefore installs itself as a resolver on import.
- Deleted, with no remaining callers: `RecoveryDisposition` and
`RecoveryTargetDisposition`, every `inspect_recovery`,
`has_recovered_effect` and the `recovered_applied` barrier,
`find_interrupted_operation`, and `recovery_operation`.
- `docs/maintenance.md` and the durable-write census are updated.

## Verification

- `tests/unit/operations/test_mutation_crash_recovery.py` covers 31
actuator families. For each, a kill before apply and a kill after apply
each go through restart, and every run must end `recovered_complete`
with the effect present and no nonterminal run left. The same file
checks that every executor-routed spec has a registered route.
- Crash tests beside their owners cover the sealed insight page
(`test_insight_acceptance.py`) and the annotation batch import
(`test_importer.py`, `complete` versus `absent`).
- `devtools test` over the 11 affected operations, annotations and
daemon test files: `288 passed, 1 failed`. The failure is
`test_importer.py::test_import_uses_concrete_delegation_schema_and_exact_retry_is_idempotent`,
which fails the same way on the base (`FacadeDaemonRequiredError` in its
judge step).
- The daemon startup tests that patch the moved recovery route pass.
- `devtools gate mypy`: `Success`.
- `devtools gate schema-closure`: `ok`, 566 → 562 entries. The closure
shrinks because `mutation_actuators`, `excision` and `lifecycle` leave
it.

## Residuals

- A family or version this runtime no longer declares ends
`recovery_not_replayable`: failed and terminal, never re-applied.
- In-process `unknown` finalizations from ingest and insight
cancellation remain. They are resolved at the next startup or by an
overlapping request, as above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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