Repository navigation
feat(broker): scope enforcement inside withGovernance — exec-broker proper (Pillar 3 step 5) - #306
Merged
Merged
Conversation
…roper (Pillar 3 step 5)
Completes the exec-broker (design: pillar3-exec-broker-5.0.md §3.4): the governance floor now
ENFORCES the signed [scope]/RoE at exec time, including secret-scoped env.
- broker/needs.ts: ScopeNeeds { egress, fsWrites, secrets } — what a governed operation
declares it is about to touch — and checkScopeNeeds(needs, cwd) → denial reason | null:
* no scope regime declared (state none) → null — advisory floor unchanged, fully backward
compatible (projects without a profile see no behavior change);
* scope declared but unsigned/tampered → declared needs DENIED (declaring a scope is the
opt-in; only a verified one grants — same fail-closed rule as the PreToolUse gates);
* verified → each need checked with the pure predicates (hostInScope/pathInScope/
secretInScope). Secret-scoped env lands here: an op that declares a key outside
[scope].secrets is denied before it runs.
- governance-middleware.ts: additive optional OperationContext.scopeNeeds (frozen-contract
safe) + enforcement step 2.5 — checked BEFORE any approval prompt, because a scope denial
is not operator-overridable (widening the RoE means editing + re-signing the profile);
deny → auditDeny + throw, the operation never executes.
9 tests (unit: none/empty/unsigned/verified-in+off-scope/tampered; integration: withGovernance
runs in-scope ops, never executes off-scope ops, fail-closes on unsigned regime, and is
byte-compatible for ops without scopeNeeds). Existing middleware suite untouched and green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
|
✅ Docker image built successfully
|
9 tasks done
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.
Description
The final build step of the Pillar 3 exec-broker (design:
kit-research/docs/research/pillar3-exec-broker-5.0.md§3.4). The governance floor (withGovernance) now enforces the signed[scope]/RoE at exec time — including secret-scoped env — completing the advisory→enforced shift: every surface (PreToolUse gates #305, MCP/CLI governed ops here) now shares one scope core (#303) and one verified scope source (#304).Type of Change
Related Issues
Changes Made
src/broker/needs.ts—ScopeNeeds{ egress, fsWrites, secrets }: what a governed operation declares it is about to touch;checkScopeNeeds→ denial reason |null:none) →null— advisory floor unchanged, fully backward compatible;[scope].secretsis denied before it runs.src/governance-middleware.ts— additive optionalOperationContext.scopeNeeds(frozen-contract safe) + enforcement step 2.5, checked before any approval prompt — a scope denial is not operator-overridable (widening the RoE means editing + re-signing the profile), so the operator is never prompted for an op that will be scope-denied anyway. Deny ⇒auditDeny+ throw; the operation never executes.src/broker/needs.test.ts— 9 tests: unit (none / empty / unsigned / verified in+off-scope per dimension / tampered) + integration (withGovernanceruns in-scope ops, never executes off-scope ops, fail-closes on an unsigned regime, byte-compatible for ops withoutscopeNeeds).Testing
Test Coverage
npm test) — full suite 2709 pass / 0 fail (2700 baseline + 9); the existinggovernance-middleware.test.tssuite is untouched and greenManual Testing
npx tsc --noEmit→ clean;npx eslint src→ 0 errors.npm run build && node scripts/test.mjs→ 2709 pass, 0 fail.OperationContextis an internal type).Breaking Changes
None / N/A —
scopeNeedsis optional and additive; projects without a profile see no behavior change (proven by the backward-compat test).Checklist
npm test)Performance Impact
scopeNeeds(one profile read + offline verify)Reviewer Notes
Two placement decisions to sanity-check: (1) the scope step runs before approval prompts because a scope denial cannot be approved away — the RoE is a signed artifact, so prompting first would invite an approval that changes nothing; (2) the
nonevsunsignedasymmetry — no profile at all means no RoE regime (advisory floor unchanged), while a declared but unsigned scope is a taken opt-in that must be trustworthy to grant. This is deliberately the same rule the PreToolUse gates enforce, so the two enforcement points can't diverge. With this, the exec-broker's incremental plan (design §5, steps 1–5) is complete; what remains in Pillar 3 is adoption — wiringscopeNeedsdeclarations into individual MCP operations and anagent-configconvenience for installing the gates.🤖 Generated with Claude Code
https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
Generated by Claude Code