fix(bridge): report a GOODBYE'd call as unknown-outcome, not failed
A route GOODBYE against an in-flight request currently surfaces as a bare transport error. It reads as "the call failed", which invites a re-run.
It isn't a failure. The daemon emits route GOODBYEs after its drain wait, regardless of whether that drain completed (supervise.rs — the quiescence result is consumed only by a warn!; route release and GOODBYE emission run unconditionally). So a call in flight at GOODBYE was admitted before the gate closed and may already have run to completion, with only its reply lost.
We hit this concretely: a ck module restart aft issued from an aft-served session lost the reply to its own command, and the already-produced stdout went with it. The command had succeeded.
Re-running such a call double-applies whatever it did. Since harness bash executes through this path, the realistic case is a second git push, migration, or npm publish.
Change
Append a disposition saying the outcome is UNKNOWN and that state should be verified before re-running:
The AFT daemon module restarted while this call was in flight, so its outcome is
UNKNOWN: it may or may not have executed. Verify actual state before re-running,
and never blind-retry a mutation.
Deliberately distinct from BASH_TRANSPORT_DISPOSITION, whose "no background task was created … Re-run the command" is correct for a not-sent transport failure and wrong here. The GOODBYE branch is checked before the bash branch so a GOODBYE'd bash call cannot pick up the re-run guidance, and a test asserts that specific negative.
No retry behaviour changes. isRouteProvenAbsentError still gates the single in-place retry on unknown_channel / StaleRouteHandleError — errors proving the bytes never left. GOODBYE is outcome-unknown by construction and stays out. The existing "outcome-unknown request failures still surface without an in-place retry" test is untouched and still passing.
The one ugly part, stated plainly
The match is on the message literal "route closed by subc", because subc-client raises the GOODBYE as a bare SubcError with no code — there is no other discriminator on the wire. It's documented as a seam and fails open: if the string changes, callers lose the disposition rather than getting a wrong one. A stable code on that error has been requested upstream in cortexkit/subconscious; when it lands this becomes a code check and the string goes away.
Also excluded: a SubcError that does carry a code (e.g. module_reloading, which is proven-not-forwarded and legitimately retryable) is left alone, with a test pinning that.
Verification
6/6 in error-contract.test.ts, each assertion observed failing before being trusted — disabling the predicate reds exactly the three new behavioural tests and leaves the pre-existing two green. Full plugin suites at baseline (bridge 456, aft 198, pi 712, opencode 1289), lint/format clean, v0.49 audit passes, release artifacts untouched.
Wording came out of a review with the subconscious side. The specific ask was to say UNKNOWN rather than "failed" — an operator who reads "failed" re-runs it, which is the same trap in prose that a blanket retry would be in code.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Treat route GOODBYE on in‑flight calls as UNKNOWN outcome instead of a failure. This prevents unsafe retries that could double-apply mutations.
- Bug Fixes
- Append
SUBC_MODULE_RESTART_DISPOSITIONto bare GOODBYESubcErrormessages so they state the outcome is UNKNOWN and advise verifying state before any retry. - Handle GOODBYE before bash transport logic so
bashcalls don’t getBASH_TRANSPORT_DISPOSITIONre-run guidance. - Retry behavior unchanged; only proven-not-sent errors (e.g.,
StaleRouteHandleError,unknown_channel) trigger the single in-place retry. - Detect via the literal “route closed by subc” from
@cortexkit/subc-client; fails open if it changes. Tests cover single append, bash path, and leaving coded errors (e.g.,module_reloading) untouched.
- Append
Greptile Summary
The PR distinguishes route GOODBYEs from proven-not-sent transport failures and appends unknown-outcome guidance without changing retry behavior.
- Detects bare route-GOODBYE
SubcErrorinstances before bash-specific transport handling. - Warns callers to verify state rather than blindly retrying a potentially completed mutation.
- Adds coverage for bash precedence, idempotent annotation, required wording, and exclusion of coded errors.
Confidence Score: 5/5
The PR appears safe to merge with no actionable correctness or security issues identified.
The new branch preserves the original error and existing retry decisions while ensuring matching route GOODBYEs cannot receive the contradictory bash re-run guidance.
Important Files Changed
| Filename | Overview |
|---|---|
| packages/aft-bridge/src/error-contract.ts | Adds narrowly scoped, idempotent GOODBYE classification and unknown-outcome guidance ahead of existing bash transport handling; no actionable defect found. |
| packages/aft-bridge/src/tests/error-contract.test.ts | Adds focused tests for disposition wording, branch precedence, duplicate adaptation, and coded-error exclusion. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[adaptToolError receives error] --> B{Bare route GOODBYE SubcError?}
B -->|Yes| C[Append UNKNOWN-outcome disposition]
C --> D[Return original error]
B -->|No| E{Bash transport-class error?}
E -->|Yes| F[Append safe re-run disposition]
E -->|No| D
F --> D
Reviews (1): Last reviewed commit: "fix(bridge): report a GOODBYE'd call as ..." | Re-trigger Greptile