Repository navigation
fix(capture): defer a bound session under F1 for up to 1h, so F1 cannot flip it into a 410 hold - #317
Conversation
F1 ("a tool input names the program and the read ledger is EMPTY this
run") reverts when the ledger line lands; a move does not. The instance a
session is withdrawn from keeps the withdrawal as a final deletion, so
routing a BOUND session on F1 made a two-pass flip that ended in a
permanent hold:
1. a session the repo arm bound to the non-default instance (empty V)
runs a `cairn` call. Claude Code writes the tool input to the
transcript before the client appends its ledger line, so a pass
landing in between sees F1, answers the default instance and moves
the session there (`withdraw ... its routing answer changed`);
2. the next pass reads the ledger line, whose scope routes back to the
instance it was just withdrawn from; the probe answers 410 and the
session is HELD on the default for good.
DecideRun now keeps a bound session where it is whenever the answer with
F1 or the answer without it names that instance; only when both leave it
does it move (to the answer with F1, as before). A new session is still
placed on the default by F1. Staying is safe for the bytes: a served call
appends its ledger line before it prints, so a pass that sees F1 over a
served call holds its input, not its output; a failed ledger write (T3)
is covered by the pod's own view-time F1.
--dry-run routed the derived V with F1's * in it as if recorded, which
forces the default; it now routes Declare + F1 through DecideRun, so it
prints --run's decision for a bound session under F1.
Red/green (tests copied onto 1c529c5's route.go/dryrun.go):
TestF1DoesNotMoveABoundSessionAndSoCannotFlipItIntoAHold red -> green
TestF1CanOnlyKeepABoundSessionWhereItIs (2 regression rows) red -> green
TestADryRunPrintsRunsDecisionForABoundSessionUnderF1 red -> green
The remaining table rows are invariant guards (green at both).
Mutants on the new guard: wrapper removed, alt returned unconditionally,
== Bound flipped, alt computed with F1 -> all killed; the dec==Bound and
Bound=="" short-circuits are equivalent mutants (same instance).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Round 0 (requirements & deletion) — verdict: requirement questioned (Q1). Ledger: Operator answer to Q1: no — DEFER instead. While F1 is live, a bound session ships nothing and withdraws nothing (the existing |
…ing it Operator decision on #317: while F1 is live, a session already BOUND to an instance ships nothing and withdraws nothing, through the existing `deferred` decision (#293), and routes normally on the first pass where F1 is false. This replaces the "stay if either answer names the bound instance" rule. New sessions keep F1's placement on the default, unchanged. DecideRun: f1 && Bound != "" && multi-instance => Deferred, whatever either answer would be (a hold included). One-instance hosts are exempt: F1 changes no answer there and there is nowhere to be withdrawn to, so a deferral would only stall capture (removing the exemption reds 11 existing one-instance tests). --dry-run already routes through DecideRun, so it prints `decision=deferred`; --run counts it `refused=`, exit 0, as #293. Comments/README/CHANGELOG now state exactly what defer guarantees (no ship and no withdrawal while F1 is live, so no flip into a 410 hold) and the pre-existing T3 residual it does NOT close: the pod's view-time F1 hides a session only while its ledger is empty, so output with no ledger record of its own ships under a LATER record's scope. Pinned as a known residual by TestTheUnledgeredOutputResidualShipsUnderTheLaterScope. Red/green (tests on 1c529c5's route.go/dryrun.go/agent.go): TestF1DefersABoundSessionAndSoCannotFlipItIntoAHold red -> green TestADryRunPrintsRunsDecisionForABoundSessionUnderF1 red -> green TestF1DefersOnlyABoundSession: 5 bound+F1 rows red -> green 5 unbound+F1 / bound+!F1 rows green -> green Mutants: arm removed, arm applied to unbound, arm ignoring F1, exemption removed, reason without F1 -> all killed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Operator's answer to round 0's Q1 (given in the authoring session, recorded here verbatim as the decision): |
|
Round 1 (nine axes) on 377ed84 — 🔴 0 · 🟡 1 · 🟢 0. The 🟡 (T3 coverage claim wider than the code) is addressed in 15ddd9d together with the operator-decided redesign; because the redesign changes behaviour, a delta round 2 runs on it. |
|
Round 2 (delta 377ed84..15ddd9d) — 🔴 1 · 🟡 1 · 🟢 1. Prior: deferral-under-F1 = fixed as specified; r1 🟡 (T3 claim) = fixed.
Operator re-decision on the 🔴: bounded defer — defer for at most a fixed window (1 h, persisted per session, reset when F1 clears), then fall back to the pre-#317 rule (move to the default instance). The 🟡 is being fixed in the same revision ( |
…e base rule Audit round 2 on 15ddd9d: F1's evidence is sticky (any tool input naming the program, restored every pass), so a bound session that never makes a ledgered call was deferred forever, and the docs called that temporary. Operator re-decision: a bound session on a multi-instance host under F1 is deferred (no ship, no withdrawal) for at most F1DeferWindow = 1h, measured from the first pass that saw F1 live while it was bound. The start is kept per session as `f1_since` (unix seconds) in the state and cleared on any pass where F1 is false, so a later episode gets a fresh window. Once the window expires with F1 still live, DecideRun routes exactly as before #317: F1's * forces the default instance, through the usual probe and withdrawal. --dry-run reads `f1_since` read-only against its clock and prints the same decision. Round 2's yellow: an F1 deferral is no longer a refusal. It is counted on a new run-line field `deferred=` (appended after `export-skipped=`, so no field moved), logged once when the window starts and once when it expires, and never fails a pass (exit status unchanged). The #293 no-worker deferral is still `refused=`, unchanged. Docs name two residuals: the flip into a 410 hold survives for a session whose F1 outlives the window (pinned by TestF1PastTheWindowFallsBackToTheBaseRule), and the pre-existing T3 residual (pinned by TestTheUnledgeredOutputResidualShipsUnderTheLaterScope). f1seam_test.go follows repo_seam_test.go's pattern so f1move_test.go compiles unchanged on 1c529c5 with a stand-in seam, and its tests fail there on their own assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
|
Round 3 (delta 15ddd9d..51bfaf7) — 🔴 0 · 🟡 1 · 🟢 2. Ladder ends (no 🔴). Prior: r2 🔴 permanent deferral = fixed (1 h |
… skew, F1Lapsed guard)
- The run-line claim is now true: `deferred=` is INSERTED after
`export-skipped=`, which is mid-line on `--run`'s `cairn-capture: run …`
line, so `omitted=`, `recheck-omitted=`, `requests=` and `held-backlog=`
each shift one position right. Name-keyed parsers are unaffected;
positional ones must update. Corrected in CHANGELOG, the capture README
and the Summary comments. The field does not move.
- Clock skew: a future-dated `f1_since` (stamped while the clock ran ahead)
is restamped to now and persisted, so it can no longer stretch the window
by the skew. TestAFutureDatedF1StartIsRestampedToNow is red without the
restamp ("a future-dated f1_since … was not restamped to now") and green
with it. No clamp is needed in the window predicate: a future start is
"not expired" either way, so `--dry-run` already agrees.
- Surviving mutant killed: TestASecondEpisodeLapsesAgain asserts that
F1Lapsed clears along with f1_since when F1 clears, and that a second
lapsed episode's expiry is logged again.
- The literal pin's name matches route.go again
(TestTheF1DeferWindowIsTheOperatorsDecision).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The defect
On a two-instance host, a routing flip ends in a permanent hold:
cairncall. Claude Code writes the call's tool input to the transcript before the client appends its read-ledger line. A capture pass that lands between the two sees F1 (names_programand an empty ledger), andDecideRunanswers the default instance. The session is withdrawn from where it was and re-shipped to the default (withdraw <id> from <x>: its routing answer changed).Root cause. With V empty, or naming only the bound instance, the only input that can make
DecideRunanswer the default isf1. F1 is a fact about one run. Routing a bound session on it turned a one-run fact into an irreversible move.The fix (operator decisions: DEFER, then BOUNDED)
DecideRun: a session that is already bound, on a multi-instance host, with F1 live, isDeferred. That holds whatever the answer with or without F1 would be, a hold included, but only for at mostF1DeferWindow= 1h.f1_since(unix seconds) in the state.*forces the default instance, through the usual probe and withdrawal.deferred=, inserted afterexport-skipped=. That is mid-line on--run'scairn-capture: run …line, soomitted=,recheck-omitted=,requests=andheld-backlog=each shift one position right. Parsers keyed on field names are unaffected; positional parsers must update.refused=, unchanged.--dry-runroutes F1 as--rundoes. It readsf1_sinceread-only against its own clock and printsdecision=deferredinside the window, and the base rule's answer after it.f1_since(stamped while the clock ran ahead) is restamped to now and persisted, so it cannot stretch the window (TestAFutureDatedF1StartIsRestampedToNow).What it guarantees, and the named residuals
TestF1PastTheWindowFallsBackToTheBaseRule.archive.Meta.LedgerScopes).sudo,env -i,ssh). That includes the headerless verbs (transcript,routes,arcs,doctor).TestTheUnledgeredOutputResidualShipsUnderTheLaterScope.--clear-heldkeeps any hold that names an instance, and the archive's deletion journal has no route that removes an entry.Red/green matrix
f1move_test.goreaches the new API only throughf1seam_test.go(therepo_seam_test.gopattern). So it compiles unchanged on1c529c5with a base stand-in seam (not committed; it reports no window, no counter, and the base rule), and each test fails there on its own assertion.TestF1DefersABoundSessionAndSoCannotFlipItIntoAHold: bound via the repo arm → 2 passes under F1 → the ledger line lands inside the window; ends bound to client, not held, 0 withdrawals, 0 probes, 0 records during F1, window clearedpass at +5m0s (F1 live, in the window): bound to "personal"TestF1PastTheWindowFallsBackToTheBaseRule: deferred at window−1s; base move at expiry; expiry logged once; residual 1 pinnedTestAClearedF1ResetsTheWindowTestTheF1WindowStartSurvivesAStateRoundTripdeferred=counts, notrefused=, logged once (inside (a)); plusTestTheRunLinePrintsDeferredTestADryRunPrintsRunsDecisionForABoundSessionUnderF1:deferredbefore and inside the window,ship:personalat its end, never writesf1_sinceship:personalinside the window)TestF1DefersOnlyABoundSession: 5 bound+F1-in-window rowsF1Lapsedflag only; the instance (personal) equals the base answerTestTheUnledgeredOutputResidualShipsUnderTheLaterScope(a residual pin)go test ./internal/capture/... ./cmd/cairn-capture/...was run on go 1.25.14 (the flake's dev shell).leakscan.pyand--self-testboth exit 0.Mutation battery
at expiry: bound to "client", … deferred=1 — want the base rule's move to personal;a fresh agent at the persisted window's end: deferred=1; the dry run printsdecision=deferredat the window's end; both expired-window rowspass at +5m0s (F1 live, in the window): bound to "personal"(12 failures)f1_sincenot cleared when F1 clearsledger landed: … f1_since 946782300 … want the window CLEARED;F1 false: f1_since 946782300 … want the window CLEAREDrefuseddeferred=0 refused=1 — want deferred=1 and NOT a refusal(6 tests)pass at +10m0s: f1_since …, want the FIRST F1 pass's clock;the deferral was logged 3 times over two episodes, want once per episode (2)f1_sincenot restamped (round 3)a future-dated f1_since 946793100 was not restamped to now 946782600 — it stretches the window by the skewF1Lapsednot cleared when F1 clears (round 3)F1 false: f1_since 0, lapsed true … want BOTH cleared(TestASecondEpisodeLapsesAgain)unbound, …rows getDeferred:true; #309'sTestAnF1PassDoesNotFreezeStar*(17 failures)🤖 Generated with Claude Code