Repository navigation
fix(broker): a park-path refusal keeps its own code, and hosted becomes hostedTurn - #2010
Merged
Merged
Conversation
…omes `hostedTurn` Two recorded follow-ups from TASK-172 slice 3c-2, in one diff because both are in the same call path and neither changes behaviour beyond what is named. 1. The park path's catch relabelled every cause `approval_unavailable` (503). `resolveApprovalPodId` refuses `connection_mismatch` when a seat grant's connection names no owner, and `invalid_target` when the target is malformed — permanent 403s. Reporting them as a retryable 503 told the agent to retry something no retry can fix, and the ledger recorded a `reason` that was not the cause. A cause that is already a `RoomGrantError` now keeps its code, message and status; only an unclassified failure (the approval store being unavailable) stays `approval_unavailable`. Vera's remedy as stated — `safeReason(error)` on this path — is deliberately NOT implemented: `reason` is a code column with exact-match arms, so free text there is a format-or-schema decision that belongs with the first vendor entry, not here. 2. `BrokerCallInput.hosted` named a connection while answering a question about the turn, so the seat-confinement bypass read as a property of the provider — a shelled seat calling a hosted tool must still be judged. Renamed `hostedTurn`, with the type naming its single caller (`grantBrokerProjectionService.dispatchHostedBrokerTool`). AX audit entry 73. Tests: the hosted arm that pinned the outcome (`approval_unavailable`) now pins the cause (`connection_mismatch`, 403) and the ledger reason; the positive control that a non-`RoomGrantError` cause still reports `approval_unavailable` already existed in `toolBrokerApprovalService.test.js` and is unchanged. Ledger (5 suites, baseline 67 tests, anchor count printed, source restored and re-asserted per mutant): 4 mutations, 4 killed, 0 survivors. M01 blanket conversion restored -> hosted refusal arm red M02 hosted-turn bypass deleted -> "a hosted turn is out of scope" red M03 any error read for its code -> proposal-throws control red M04 ledger reason back to generic -> hosted refusal arm red Full backend: 492 suites passed / 6 skipped; 4676 tests passed / 24 skipped / 0 failed. eslint on both changed services: 0 errors.
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.
Closes the two follow-ups recorded on TASK-172's row in slice 3c-2 (PR #2005, merged). Both are in the same call path; neither changes behaviour beyond what is named. Backend-only, so no version bump.
1. A park-path refusal keeps its own code
callTool's park path wrappedresolveApprovalPodIdandproposeActionin onecatch {}and threwapproval_unavailable(503) for every cause. ButresolveApprovalPodIdrefuses:connection_mismatch— "grant connection owner is missing" (:781), andinvalid_target— a malformed grant target (:777),both permanent 403s. Relabelled as a retryable 503, the agent is told to try again at something no retry can fix, and the ledger's
reasoncolumn records a reason that is not the cause.Now a cause that is already a
RoomGrantErrorkeeps its own code, message and status — recorded to the ledger under that code, stillrecorded: trueso the outer catch does not double-record — and only an unclassified failure (the approval store unavailable) isapproval_unavailable. The explicit{ ok: false }branch below is untouched: a card that could not be built is genuinelyapproval_unavailable.The one deviation, and its resolution. The remedy as first stated was
safeReason(error)on this path; it is deliberately not implemented, and @vera withdrew it after measuring the schema (msg 75382):tool_calls.reasonisVARCHAR(255)with noCHECK, so free text is accepted right up to 256 characters — where theINSERTthrows22001inside the catch, replacing the original cause with a Postgres error. The proposed remedy could have destroyed the diagnostic it was meant to add. So the column stays a code column on a ground harder than taste: it is read by exact match (toolBrokerApprovalService.test.js:112), and the defect here was never that the ledger held a code — it held the wrong one.2.
hosted→hostedTurnBrokerCallInput.hostednamed a connection while answering a question about the turn:assertSeatCanConfineopens withif (input.hosted) return;. Read as a name, that says the bypass is a property of the provider (connectionType === 'hosted-mcp'), when it means the runtime is Commonly's own and has no shell to confine — a shelled seat calling a hosted tool must still be judged. RenamedhostedTurn; the type now names its single caller (grantBrokerProjectionService.dispatchHostedBrokerTool), and the four suites that pass the flag follow. AX audit entry 73.Evidence
Two arms carry the change, and the positive control pre-existed:
toolBrokerService.hosted.test.js"refuses a hosted write whose row names no owner as a connection mismatch…"code: 'connection_mismatch', statusCode: 403and ledgerreason: 'connection_mismatch'; no room requested, nothing reaches the vendortoolBrokerApprovalService.test.js"records a refusal when the approval proposal throws" (unchanged)Errorstill yieldsapproval_unavailable+reason: 'approval_unavailable'Mutation ledger — 5 suites, baseline 67 tests, anchor occurrence count printed and asserted, pristine source restored and re-asserted after each arm (
/tmp/kai-172b-ledger.py):Full backend suite: 492 suites passed / 6 skipped; 4676 tests passed / 24 skipped / 0 failed.
eslinton both changed services: 0 errors.Gate: vera.