Skip to content

refactor(broker): rewire gate-egress/gate-fs onto canonical exec-broker decisions (reconciliation R3) - #310

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 10, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

Reconciliation R3 (design: kit-research/docs/research/pillar3-broker-reconciliation-5.0.md) — the dedup win. The PreToolUse gates now use the one canonical exec-broker decision core instead of my parallel one.

Type of Change

  • Refactoring

Related Issues

Changes Made

  • src/commands/gate.ts — cmdGateEgress / cmdGateFs now consult:
    • the signed source profileBrokerPolicy (R2 bridge) → BrokerPolicy,
    • decisions.checkEgress (the stronger host parser) per host,
    • decisions.checkFsWrite across policyFsRoots (resolving the hook path against cwd first),
      instead of src/broker/decide.ts (brokerScope) + src/broker/scope.ts (hostInScope/pathInScope).
  • Fail-closed semantics preserved exactly: a wired gate with no verified scope (policy null) grants nothing.

Testing

Test Coverage

  • Behavior unchanged — all 9 subprocess gate tests (real compiled CLI, hook payload on stdin) still pass
  • All tests pass (npm test) — full suite 2719 pass / 0 fail (no net change; a rewire)

Manual Testing

  1. npx tsc --noEmit → clean; npx eslint src → 0 errors.
  2. npm run build && node scripts/test.mjs → 2719 pass, 0 fail.

Breaking Changes

None / N/A — internal rewire; identical externally-observable gate behavior.

Checklist

  • All tests pass locally (npm test)
  • No new warnings or errors introduced
  • No hardcoded secrets or sensitive data
  • Code has been self-reviewed

Performance Impact

  • No performance impact

Reviewer Notes

After this, src/broker/decide.ts + src/broker/scope.ts have only src/broker/needs.ts left as a consumer — R4 removes needs.ts (routing withGovernance scope via the existing runGovernedBrokered/BrokerContext) and deletes the duplicate core, leaving one broker: src/exec-broker/* (canonical decisions + signed profile-policy provider), with the gates + kit doctor + host-extractor as the net-new surfaces on top. The one behavioral nuance to check: the fs gate now resolves the hook's filePath against the agent cwd before the containment check (previously done inside pathInScope), so absolute and cwd-relative paths are handled identically — covered by the traversal-escape subprocess test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

…er decisions (reconciliation R3)

The PreToolUse gates now use the ONE canonical decision core instead of the duplicate:
- signed source: profileBrokerPolicy (exec-broker/profile-policy) → BrokerPolicy (R2 bridge);
- egress: decisions.checkEgress (stronger host parser) per host;
- fs: decisions.checkFsWrite across policyFsRoots (resolve the hook path against cwd first).

Fail-closed semantics preserved exactly: a wired gate with no VERIFIED scope (policy null)
grants nothing. Removes the gates' dependency on src/broker/decide.ts + src/broker/scope.ts —
those now have only broker/needs.ts as a consumer, deleted next in R4. Behavior unchanged: all
9 subprocess gate tests (real CLI, hook payload on stdin) still pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit dde0b94 into main Jul 10, 2026
18 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 10, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants