fix(cli-bridge): state which call can add a turn after reconstruction - #233
Merged
Conversation
tangletools
approved these changes
Aug 21, 2026
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — 9858aaab
This PR was opened by the trusted drewstone account.
This approval is provisional and was applied by the local stand-in because the pr-reviewer webhook host is unreachable (2026-08-21). CI on this head is fully green. The full PR reviewer audit re-runs via the resweep when the service returns and will publish findings if it detects issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Both issues were largely shipped in 0.9.0–0.9.2. What was left is honesty about what a reconstructed environment can do, plus the interaction acknowledgements no test had ever produced against a real bridge.
session.continueNative(src/retained-environment.ts:484-514→POST /v1/sessions/:id/continue), proven live attests/cli-bridge.integration.test.ts:307-620. The README still promised thatsession.promptcontinues a conversation afterprovider.get(), which it never does.respondToInteraction(src/interaction-response.ts:109-171), (b)interactionsderived fromGET /v1/capabilities(src/capability-discovery.ts:116-120), (c) canonical interaction events with binding (src/retained-canonical-event.ts:17-69) all shipped. Only (d) was open: three acknowledgement statuses no contract test had produced.What
dispatch/stream/promptadd a turn; afterprovider.get()onlysession.continueNativedoes, and only with thenativeContinuationcapability (Pi today). Names why a runtime caller usesRetainedRunHandle.continueNativeand notstartRetainedRunInEnvironment(that path needsprovider.list, which this provider does not expose, and then callsdispatch, which a reconstructed environment refuses). Generic-harness continuation stays blocked on Bridge-side native sessions (drewstone/cli-bridge).stream,dispatch, andsession.prompthad three separately-worded errors for one rule. They now route throughassertCliBridgeTurnAllowed, whose message names the surface, the one call that works (session.continueNative), and the capability it needs.tests/cli-bridge.integration.test.ts: afteraccepted, a new operationId with a different answer →already_resolved_different(409); a new operationId with the same answer →already_resolved_same(200); a third run cancelled while its permission is outstanding, then answered →cancelled(409).[409, already_resolved_different],[409, cancelled],[409, expired].Capability honesty: the requested narrowing is not expressible, and the test pins why
The plan was to publish
sessions.continue: falseon a reconstructed non-Pi environment while keepingretainedControl. That document is invalid.AgentEnvironmentCapabilitiesSchema(agent-interfacesrc/environment-runtime.ts:522-532) refuses it with:Measured directly against
defaultCliBridgeCapabilities("codex")withsessions.continueflipped tofalse:safeParse→success: false, that one issue. DroppingretainedControlinstead would remove replay, result, and cancellation from every reconstructed environment — the only reasonget()exists — so it is a regression, not honesty.nativeContinuationis the flag that already carries this answer: present ⇒continueNativeadds a turn; absent ⇒ no call on that environment adds one. The new test asserts that per harness AND asserts the narrowed document fails validation, so nobody "fixes" the document into an invalid state later.Proof
pnpm build: 10 packages Done.pnpm check-types: 0 errors.pnpm test: cli-bridge 204 passed (was 199); workspace 1524 passed, 0 failed.pnpm check:package-artifacts: 9 packages, 31 exports, 62 export targets.pnpm check:control-artifacts: 7 files, 141 tests.backend pi requires an enforced Linux fs-jail ... enable bubblewrap. The three new scenarios are verified by the CLI Bridge integration job in this PR's CI, which is the environment that has bubblewrap. Server behavior was read at the pinned commit before writing them:src/sessions/retained/interactions.ts:279-290(resolved-digest compare → same/different),:284+src/runs/run.ts:353-364(cancel()→cancelOutstandingInteractions→cancelled),statusForAcknowledgement→ 409/200.expiredis not producible live: the pinned Bridge maps the status but never emits it (interactions.ts:514is the only occurrence). It stays unit-covered only, and the README says so.Simplification: three separately-worded refusals for one rule collapsed into
assertCliBridgeTurnAllowed; the refusal now names the call that works instead of only the call that does not.Net: +208 / -13 lines, 6 files, 3 refusal copies → 1.
Tests: +5 (2: a reconstructed codex/pi environment publishes which call adds a turn and refuses the three that do not, and the narrowed capability document is proven invalid; 3: unit rows for
already_resolved_different/cancelled/expiredHTTP-status agreement) and +3 live acknowledgement scenarios that pin the wire contract with the Bridge server across two repos, -0 deleted.Not done here: generic-harness native sessions in the Bridge server, the only real closure of #216 beyond Pi; it is server-side work in
drewstone/cli-bridge.Closes #216
Closes #204