fix(bridge): send the coordination MCP as a runtime attachment - #919
Merged
Conversation
`driveHarnessFromBackend` added the coordination MCP URL to the AgentProfile it sent to cli-bridge. That URL names a process-ephemeral port, so a resumed supervisor bound a new port into the canonical profile digest and the bridge refused the durable session it had bound to the authored profile. The authored profile now reaches the wire exactly as authored. The coordination server travels on a new executor seam and rides `runtime_attachments.mcp` beside `agent_profile`, which cli-bridge mounts for the run and keeps out of the session binding. A bridge that does not advertise `capabilities.runtimeAttachments.mcp` is refused before the first paid turn; the profile is never rewritten instead. The fake bridge in the kernel tests now enforces the real session binding, so a resume test fails if the digest moves between turns.
tangletools
approved these changes
Aug 21, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — a44fa8ac
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
A supervised bridge run serves its coordination MCP on a process-ephemeral port.
driveHarnessFromBackendfolded that URL into theAgentProfileit sent to cli-bridge, so the canonical profile digest moved every time the port changed. cli-bridge binds a durable session to the exact profile digest plus model, so a resumed manager was refused withsession ... is bound to a different AgentProfile/modelbefore it could spend a token — the incident in #774 (discovery runq36-classical-sharp-constant-flash-20260810a, Runtime 0.131.5, zero tool calls, zero spend).The receipt layer already told the truth:
platformAttachmentsare recorded apart from the authored profile. Only the wire lied.What
driveHarnessFromBackendno longer rewrites the profile. The authored profile reaches the wire exactly as authored; the reserved-alias check stays, so a profile that declaresagent-runtime-coordinationis still refused.bridgeRuntimeAttachmentsKey, besidebridgeStopSignalKey.bridgeExecutorsends it asruntime_attachments: { mcp: { … } }next toagent_profile(cli-bridge feat(attachments): carry runtime MCP attachments outside the bound profile drewstone/cli-bridge#181, server 0.3.0), which mounts it for the run and excludes it from the session binding, from receipt digests, and from durable-run identity.capabilities.runtimeAttachments.mcp, the capability preflight throws aValidationErrornaming the bridge URL and the missing capability, before the first paid turn. The old profile-injection path is deleted, not kept behind a flag.authoredProfileFromDriverExecution— the helper that stripped the alias back out before comparing digests — is gone; the pending-executor check now compares the authored digest directly.Proof
pnpm run typecheck,pnpm run lint,pnpm run build,pnpm run check:api-surface(2087 exports, record current),pnpm run docs:check(no drift),pnpm run check:version-bump— all clean. The gate reports no consumer-visible surface change, so package.json stays at 0.143.0; the seam key is a module export, not a package export.pnpm exec vitest run tests/kernel/supervise-full-profile-bridge.test.ts tests/runtime/bridge-executor.test.ts tests/kernel/loop-dispatch.test.ts— 16 + 51 + 26 passed.{profile digest, model}; a later mismatch answers 400). Re-injecting the coordination URL into the profile makesreuses one durable manager session on restartfail with that 400 — checked by patching the injection back in and re-running, so the test now proves what it claims.candidate-execution-*,improvement-*,mcp/local-harness,version-bump-check, andcoordination-mcp's127.0.0.53bind, which fails identically on the base commit —EADDRNOTAVAIL). None touch the bridge path; CI is the authority.Simplification
Simplification: one concept, one representation — the authored profile is no longer rewritten on the wire, so the receipt's
platformAttachmentssplit and the request finally agree; the strip-it-back-out helper (authoredProfileFromDriverExecution, 10 lines) is deleted along with the re-parse it forced.Net: +229 / -48 lines across 6 files (src: +57 runtime.ts, -12 net supervise.ts), 1 helper and 1 profile-rewrite path removed.
Tests: +2 (
sends runtime_attachments beside agent_profile and never inside it— a regression would put an ephemeral port back into the bound digest;refuses when the bridge does not advertise runtimeAttachments— an old bridge must stop the run instead of silently binding the port), -0 deleted. The existing restart test was left in place and made meaningful by the enforcing fake bridge rather than duplicated.Not done here: peer-mail endpoints for bridge workers ride this same seam later (#889 gap 1); no second attachment kind is added now.
Closes #774