Repository navigation
feat: the decision hook's egress stage - #61
Merged
Merged
Conversation
The result stage: fold serializes what an upstream returned and asks the hook before the caller sees it. Which is the straightforward half. The half the design record was missing is what it means. By egress the upstream has already acted. A denial there withholds the disclosure, not the effect — the row is deleted, the message is sent, and the caller is told the result was withheld. Egress is a data-loss control; stopping an action means refusing it at ingress. The error message says so in those words, because "denied" otherwise reads as "did not happen", and an organization deploying egress as a control on what its agents can do has misread the feature. The test asserts the upstream ran, so the caveat is demonstrated rather than described. A result too large to inspect is not truncated. A partial body is precisely the blind spot an inspector must not be handed, so a result past 1 MiB takes the onError path — which under "deny" means refusing results nobody could have inspected. Fail-safe, and the bound is a constant until someone needs it to be a field. Serializing the result is what egress costs over ingress: fold holds the decoded form and the hook needs bytes. It happens only for inspected methods on a configured stage, so deployments without egress pay nothing, and the added-latency gate is unmoved. Phase 2 of docs/design-decision-hook.md. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
Phase 2 of
docs/design-decision-hook.md, following #60.fold serializes what an upstream returned and asks the hook before the caller sees it. That is the straightforward half. The half the design record was missing is what it means:
By egress, the upstream has already acted
A denial at egress withholds the disclosure, not the effect. The row is deleted, the message is sent, and the caller is told the result was withheld. Egress is a data-loss control; stopping an action means refusing it at ingress.
The error message says exactly that —
"decision hook withheld the result of tools/call \"charge\" (the upstream has already acted)"— because "denied" otherwise reads as "did not happen", and an organization deploying egress as a control on what its agents can do has misread the feature.TestHookEgressWithholdsTheResultasserts the upstream actually ran, so the caveat is demonstrated rather than described.This is now in the README, the security model, and the design record, which did not have it.
Oversize results are not truncated
A partial body is precisely the blind spot an inspector must not be handed, so a result past 1 MiB takes the
onErrorpath — under"deny", refusing results nobody could have inspected. Fail-safe, and documented rather than discovered. The bound is a constant until someone needs it to be a field.Cost
Serializing the result is what egress adds over ingress: fold holds the decoded form and the hook needs bytes. It happens only for inspected methods on a configured stage, so deployments without egress pay nothing and the added-latency gate is unmoved.
Verification
make checkincluding lint (ineffassigncaught a dead initializer),make conformance40/40, and two new integration tests: the withholding path with a tool that records having run, and the oversize path.Phases 3 (the reverse path — where "refuse an elicitation asking for a password" finally becomes real) and 4 (docs pass) remain.
🤖 Generated with Claude Code