Skip to content

fix(recovery): resolve interrupted mutations from durable state - #5688

Merged
Sinity merged 1 commit into
masterfrom
claude/prep-recovery
Sep 28, 2026
Merged

Sinity merged 1 commit into
masterfrom
claude/prep-recovery

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026

Copy link
Copy Markdown
Owner

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 refactor(maintenance): delete archive repair and bootstrap commands #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.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 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: ff7409b887

ℹ️ 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/annotations/importer.py Resolved
Comment thread polylogue/operations/mutation_replay.py Resolved
Comment thread polylogue/operations/audit.py Resolved
Comment thread polylogue/operations/mutation_replay.py Resolved
@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-28T03:32:32.313061Z 15d38e4 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: 3af5e74926

ℹ️ 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".

@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: 82399d49dd

ℹ️ 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".

@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: eb5b8eed1b

ℹ️ 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".

@Sinity
Sinity enabled auto-merge (squash) September 28, 2026 00:06
@Sinity
Sinity force-pushed the claude/prep-recovery branch 2 times, most recently from c646539 to 3be1b8e Compare September 28, 2026 00:31

@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: 3be1b8e228

ℹ️ 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".

@Sinity
Sinity force-pushed the claude/prep-recovery branch from 3be1b8e to c646a2b Compare September 28, 2026 00:49

@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: c646a2b921

ℹ️ 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".

@Sinity
Sinity force-pushed the claude/prep-recovery branch from c646a2b to ee8cb1f Compare September 28, 2026 01:03

@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: ee8cb1fbbc

ℹ️ 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".

@Sinity
Sinity force-pushed the claude/prep-recovery branch from ee8cb1f to 7f65ba2 Compare September 28, 2026 01:20

@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: 7f65ba25af

ℹ️ 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".

An operation whose owner died between its durable intent and its
terminal record used to end as an operator-blocking "unknown" for every
family except session delete, and operator adjudication was the only
way out. Every executor-routed actuator now registers a recovery route:
most re-apply the recorded plan convergently, without restamping rows
already stored and only within the authorized plan; the annotation
batch import reports whether its one transaction committed; insight
pages and ingests are terminalized for their owners to reconverge.
Daemon startup, and a later request overlapping a dead run, record a
terminal resolution that never blocks the targets.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@Sinity
Sinity force-pushed the claude/prep-recovery branch from 7f65ba2 to 15d38e4 Compare September 28, 2026 03:27
@Sinity
Sinity merged commit aa7a3e0 into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the claude/prep-recovery branch September 28, 2026 03:37
Sinity added a commit that referenced this pull request Sep 28, 2026
Both fail on origin/master 5312edb as well. The relayed 401 keeps its
code as the rejection outcome while the message is the ingress detail
(#5705), and startup recovery now re-applies a dead operation's plan
convergently (#5688), so the no-replay check counts only the client's
resend.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
Sinity added a commit that referenced this pull request Sep 28, 2026
…5729)

## Summary

Fixes six tests that fail on master and one intake bug. Five tests
encoded contracts that earlier PRs changed on purpose, and are
realigned. The intake bug: a SQLite database that could not be read at
probe time was excluded for good.

## Problem

A focused run on `7e5b96e15d` failed six tests:

| Test | Broken by | Cause |
| --- | --- | --- |
| `test_live_full_ingest_offloads_sync_work_to_keep_loop_responsive` |
#5557 | `_ingest_full_paths` now passes `prepared_json_paths`; the test
stub rejected the keyword. |
|
`test_source_only_full_ingest_streams_admitted_zip_members_without_decoding`
| #5557 | #5557 removed `_detect_provider_from_raw_bytes` from
`live.batch`, and `monkeypatch.setattr` failed on the missing name. |
| `test_every_planned_path_is_accounted_for`,
`test_offered_bytes_split_puts_a_refused_file_in_the_refused_bucket` |
#5557 | #5557 retains a JSON document of any shape and lets the parser
record unsupported-shape evidence. The `notes.json` fixture meant to be
refused therefore succeeds. |
| `test_authentication_refusal_is_not_an_indeterminate_mutation` | #5705
| The exception text is now the daemon's detail (`machine authentication
required`), not the code. |
| `test_restart_recovers_indeterminate_mutation_without_replaying_it` |
#5688 | Startup recovery now resolves an `unknown` run by convergent
replay, so the restarted daemon applies once more. |

Intake bug: the Codex, Hermes and Antigravity recognizers catch
`sqlite3.Error`/`OSError` and answer "not ours".
`classify_pre_acquisition` turns that answer into an exclusion, and
`_mark_excluded_cursor` records `excluded=True`. A database that is
locked or unreadable during the probe (EACCES, SQLITE_BUSY/CANTOPEN) was
never retried while its observation stayed unchanged. #5724 had guarded
only the cold-build baseline against this.

## Solution

- Tests: accept `prepared_json_paths` in the stub. Point the ZIP
no-decode guard at `detect_provider_from_path_sample_evidence`. Refuse a
JSONL record stream that no origin claims instead of a JSON document.
Assert `rejected.value.outcome == "unauthorized"`. In the restart test,
count the one startup replay and check that the retried request id does
not dispatch again.
- Intake: `classify_pre_acquisition` probes a SQLite path before
excluding it and raises a retryable read fault. The batch records that
fault as an ordinary retryable failure. Bytes that are not a database
stay excluded. The baseline's own probe and `_retryable_read_fault` move
into `batch_support`, so intake and the baseline apply the same rule.
The baseline branch those helpers made dead is removed.

`batch.py`, `batch_support.py` and `production_baseline.py` are in the
derived schema-identity closure (`devtools schema closure`), so this
must land before a rebuild starts.

## Verification

- `devtools test tests/unit/sources/test_live_watcher.py
tests/unit/sources/test_raw_admission_settlement.py
tests/unit/sources/test_live_batch_support.py
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_cold_build_generation.py
tests/unit/daemon/test_daemon_operation_route.py`: `418 passed`, 1
flaky. The flaky test was
`test_cancelled_long_delete_retains_writer_until_blocked_apply_releases`:
a 25 ms deadline returned `completed` under load, and the test passed
when rerun alone.
- After the final baseline cleanup: `devtools test
tests/unit/sources/test_production_baseline.py
tests/unit/sources/test_cold_build_generation.py`: `64 passed`.
- `devtools verify --quick`: `PASSED` (includes mypy, patterns,
schema-closure).
- The new
`test_unreadable_state_database_stays_retryable_instead_of_excluded`
drives a mode-0 `state_5.sqlite` through `_ingest_full_paths_sync`.
Without the probe, the file is not failed and gets an excluded cursor.

## Residuals

- If a lock clears between the recognizer's failed read and the probe,
the file is still excluded. That window was already accepted for the
baseline in #5724. Closing it needs the recognizers to propagate read
faults.
- The unbounded JSONL session scan is filed separately and is not
changed here.

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

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

---------

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

`raw_existence_changes` is now declared once in `SESSION_CARRIERS`, as
EXCISED. A table declared twice is now an import-time error, so one
declaration can no longer silently replace another.

## Problem

`test_raw_existence_journal_is_declared_as_content_free_bookkeeping`
fails on master: `TOMBSTONE is RETIRED`. Two PRs each declared the
table:

- #5688 (aa7a3e0) declared it TOMBSTONE: content-free evidence,
deliberately kept after excision.
- #5727 (ee567d0) added a second declaration, EXCISED. In the same PR
it made `apply_session_excision` delete the journal rows by name
(`excision.py:1252`). `test_excision` asserts that no rows survive.

`_carriers` built a dict, so the later TOMBSTONE entry silently replaced
the EXCISED one. The actual behavior is EXCISED. The #5727 test asserted
RETIRED, but that reach applies only to tables that fresh tiers omit,
and this table is present in a fresh source tier.

## Solution

- Remove the TOMBSTONE declaration.
- `_carriers` raises `ValueError` on a duplicate table.
- The test (renamed `test_raw_existence_journal_is_declared_as_excised`)
asserts EXCISED.

## Verification

- `devtools test` over
`tests/unit/security/test_excision_carrier_reach.py`,
`tests/unit/security/test_excision.py` and the other master-health
files: `PASSED exit=0`

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

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

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