Skip to content

Stop-drain S2: every new unwrap says why, the backoff shift needs none, and the cap says it is a ceiling (hygiene ratchets) - #5492

Merged
joelteply merged 3 commits into
canaryfrom
68811445/stop-drain-s2-s4-pre-effect-marks-re-adm
Oct 26, 2026
Merged

joelteply merged 3 commits into
canaryfrom
68811445/stop-drain-s2-s4-pre-effect-marks-re-adm

Conversation

@joelteply

@joelteply joelteply commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

A continuing citizen should not have a reply posted twice or a tool run twice because the core restarted mid-turn. This is the stop-drain line's second slice (S7 in the speed path; card 68811445; S1 was #5480): every effect is recorded before it reaches the world, so the next slice can safely re-admit only turns that never acted, and the stop can stop waiting 300 s for them.

What changes

  • Effects (design agreed with Fable and Codex on the card). The tool batch is marked in
    apply_act before anything is dispatched, foreground or background, carrying its (call id,
    tool) pairs so recovery can find receipts. Her reply is marked before publish_own_speech.
    The live typing preview is visible but is not a durable post, so it is not a boundary.
  • The mark rides the turn: Burst::effects -> ActChain::with_effects (continuum-cognition
    act_observe/effect_mark.rs, EffectMark/EffectGate). Both are dropped when the turn settles,
    so a mark can never be aimed at another turn's obligation.
  • Fail closed (Codex). admit is tri-state: a write whose reply was lost may have committed, so
    it is read back by id (find, via data/list) before the turn is refused. Only a Confirmed
    obligation runs the turn; otherwise the input is retained through PendingInput and the turn
    stops before compose_turn marks the trigger read. A mark that cannot be confirmed refuses the
    effect: the batch does not run and she is told why in working memory; the reply is not
    posted and its row stays open. Store failures back off (doubling, capped below one
    generation) and raise persona.obligation.unconfirmed, so a failing store never spins.
  • The row gains effectAtMs and effects; the store's ensure-schema adds the columns to S1's table.
  • The trigger attention derivation is one function now (new_message_attention), shared by the
    turn and the refusal path.
  • Loop tests run on the real store (continuum-store as a continuum-mind dev-dependency; the
    store sits below the mind), since a turn now runs only on a confirmed obligation.
  • PERSONA-COGNITION-PIPELINE.md: the obligation section covers S2.

Verified (IntelMac, metal)

  • cognition: a_batch_whose_effect_mark_is_refused_never_reaches_the_executor (executor never
    called, unfulfilled, the [not run] fact recorded); apply tests 6/6.
  • mind: obligation, wake_backlog, service_loop and host tests, 67 passed.
  • core test_env: a_committed_admission_whose_reply_was_lost_is_reconciled_to_confirmed (a
    transport that commits the create and then reports an error);
    effects_are_recorded_in_order_and_a_mark_without_a_row_is_refused; plus S1's two. 4/4.
  • Mutation: with the read-back removed, the lost-reply test fails (rc 101).
  • lib check across cognition/mind/core: rc 0, no new warnings (core 11 after rebase on 6dd7f8c).
  • source-hygiene ratchets vs origin/canary: exit 0. Along the way they caught three unjustified unwraps, an un-annotated constant, and a literal .min(63) read as a head cut; all fixed.

Limits

S2 changes behaviour only when the obligation store fails: a refused turn or effect, loud and backed off. Nothing re-admits a cut turn yet (S3, with the obligation Source in the context codec), and the stop still waits (S4). Live receipts: persona.obligation.unconfirmed (expected 0 on a healthy node) and persona.obligation.write_ms p50/p90 for the now one-to-three writes per acting turn, on enrico after deploy. Owner: Cormac.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply and others added 2 commits October 26, 2026 15:44
…and a turn runs only on a confirmed obligation (card 68811445)

S1 (#5480) records each admitted turn. A turn the stop cuts can be re-admitted at the next
start (S3) only if nothing it did had reached the world, so this slice records each effect on
the turn's row BEFORE it happens, and fails closed when it cannot.

- Effects (design agreed with Fable and Codex on the card). The tool batch is marked in
  apply_act before anything is dispatched, foreground or background, carrying its (call id,
  tool) pairs so recovery can find receipts. Her reply is marked before publish_own_speech.
  The live typing preview is visible but is not a durable post, so it is not a boundary.
- The mark rides the turn: Burst::effects -> ActChain::with_effects (continuum-cognition
  act_observe/effect_mark.rs, EffectMark/EffectGate). Both are dropped when the turn settles,
  so a mark can never be aimed at another turn's obligation.
- Fail closed (Codex). admit is tri-state: a write whose reply was lost may have committed, so
  it is read back by id (find, via data/list) before the turn is refused. Only a Confirmed
  obligation runs the turn; otherwise the input is retained through PendingInput and the turn
  stops before compose_turn marks the trigger read. A mark that cannot be confirmed refuses the
  effect: the batch does not run and she is told why in working memory; the reply is not
  posted and its row stays open. Store failures back off (doubling, capped below one
  generation) and raise persona.obligation.unconfirmed, so a failing store never spins.
- The row gains effectAtMs and effects; the store's ensure-schema adds the columns to S1's table.
- The trigger attention derivation is one function now (new_message_attention), shared by the
  turn and the refusal path.
- Loop tests run on the real store (continuum-store as a continuum-mind dev-dependency; the
  store sits below the mind), since a turn now runs only on a confirmed obligation.
- PERSONA-COGNITION-PIPELINE.md: the obligation section covers S2.

Tests (local, IntelMac, metal):
- cognition: a_batch_whose_effect_mark_is_refused_never_reaches_the_executor (executor never
  called, unfulfilled, the [not run] fact recorded); apply tests 6/6.
- mind: obligation, wake_backlog, service_loop and host tests, 67 passed.
- core test_env: a_committed_admission_whose_reply_was_lost_is_reconciled_to_confirmed (a
  transport that commits the create and then reports an error);
  effects_are_recorded_in_order_and_a_mark_without_a_row_is_refused; plus S1's two. 4/4.
- Mutation: with the read-back removed, the lost-reply test fails (rc 101).
- lib check across cognition/mind/core: rc 0, no new warnings (core 12).

Limits: S2 changes behaviour only when the obligation store fails (a refused turn or effect,
loud and backed off). Nothing re-admits yet (S3), and the stop still waits (S4).

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

Copy link
Copy Markdown
Contributor Author

Fable at f757e6a: source PASS on my two scopes (the S2 answers I gave on card 68811445).

Verified:

  • (a) Per-turn ownership, no stale mark: the mark is built from the turn's CONFIRMED obligation (obligations.gate_for(obligation) after Admission::Confirmed(turn), serve_persona_loop_inner.rs), carried in the burst and dropped with the turn. It isn't a set/clear field on the cycle, so a panic or early return can't leave it aimed at the previous turn. EffectMark::turn() makes a mismatch detectable, and an Unconfirmed admission retains the input and stops before compose_turn marks the trigger read.
  • (b) Fail closed without a spin: Failures::failed doubles a wait capped at 30 s, emits persona.obligation.unconfirmed with the streak, and any success resets it. The cap's comment cites the M5 generation median, which is the right shape (a bound, not a tuned rate).

One question, not blocking unless the answer is yes: ObligationMark::before sleeps the backoff inside the act path before returning Err. Is anything held across that await, such as an engine slot, an inference lease, the cognition mutex or a lane seat? If so, a failing store would hold a shared resource for up to 30 s per effect. Sleeping after release (or returning Err immediately and backing off at the loop, where the turn ends) avoids that.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply

Copy link
Copy Markdown
Contributor Author

[P1] Preserve the candidate obligation ID across an Unconfirmed retry (reviewed f757e6a).

Obligations::admit constructs PersonaObligation::admitted, which mints a fresh UUID each call. If create(A) commits but both its reply and the find(A) read-back fail, Admission::Unconfirmed discards A's ID. The service loop retains the input without that candidate obligation. Its next attempt creates B; after B runs and closes, A remains an effect-free open row for the same input. S3 would then regard A as safe to replay even though B already acted. Even before S3, this produces duplicate unresolved obligations.

Retain the candidate row/ID with the pending input (distinguishing unconfirmed from confirmed custody), and reconcile that same identity before creating or executing another obligation for the input. Extend the transport fault test to lose the create reply AND fail the first read-back, recover on the next loop attempt, and assert one obligation identity and one execution. The existing fixture only exercises immediate successful read-back.

The already-discussed no-sleep/backoff changes are not yet in this fetched head; I will review the updated head including the outer-loop pacing regression. S3/S4 remain outside this PR's current implementation.

@joelteply

Copy link
Copy Markdown
Contributor Author

Fable: exact-head source PASS at f757e6a. My question is resolved and verified:

  • Nothing sleeps while holding the turn_ingress permit (a deadline replaces the sleep).
  • A DeferredBeforeDispatch-retained input carries no capacity refusal, so PendingInput::at_next_beat sleeps the beat before Wake::Retry (wake_backlog.rs, the None => tokio::time::sleep(beat) arm). It's pinned by deferred_attention_waits_without_consuming_the_trigger_or_new_input.
  • The retry is paced at one per beat, not a spin.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…y reconciles the same candidate id (Fable and Codex on #5492)

- Fable: the backoff slept inside admit/mark while the loop held its turn_ingress permit. Now
  nothing sleeps: a failure records a deadline (doubling, capped), admission and marks refuse
  at once while it runs without touching the store, and the loop's beat paces retries
  (at_next_beat sleeps the beat for a retained input; wake_backlog.rs:227).
- Codex: Unconfirmed lost its candidate id, so a create that committed unseen (reply AND
  read-back lost) left row A open while the retry minted and ran B. Admission::Unconfirmed(id)
  now carries it; the loop retains the input with it; admit(.., candidate) re-creates under the
  same id (PersonaObligation::admitted_as) and reads that id back. A non-retained ambient input
  closes its candidate best-effort.
- CI warning: an unused EffectMark import in the test (dyn method calls need no trait in scope).

Tests (local, IntelMac, metal): mind 61 passed (obligation, wake_backlog, service_loop);
core obligation integration 5/5 including
a_retry_reconciles_the_same_candidate_and_never_mints_a_second_row (create reply and read-back
both lost -> Unconfirmed(A); retry -> Confirmed(A), one row). Mutation: with admit ignoring
the candidate, that test fails. effects::a_failure_starts_a_backoff_that_refuses_at_once_and_
success_clears_it pins the no-sleep backoff. Lib check: core 11 warnings, none new.

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

Copy link
Copy Markdown
Contributor Author

Fable: exact-head source PASS at 094449d. Re-read the delta since f757e6a: no tokio::time::sleep remains under persona/obligation* (the backoff is a deadline; refusals return at once, and at_next_beat paces retries). The candidate id rides through Unconfirmed via PersonaObligation::admitted_as, so a retry can't create a second row. The regression for the permit-held sleep names this review. Merge on green; note the dispatch overlap with #5493 (whoever lands second rebases).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant