Skip to content

feat(broker): pure scope-decision core (Pillar 3 step 1) - #303

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

First build step of the Pillar 3 exec-broker (5.0-rc). The deterministic, zero-LLM floor: three pure predicates that answer "is this action inside the agent's SCOPE?" against a ProfileScope (Pillar 4's signed RoE). No I/O, no CLI, no enforcement yet — those sit above this in later steps and feed the scope via verifiedScope() (fail-closed).

Type of Change

  • New feature (non-breaking change that adds functionality)

Related Issues

Changes Made

  • src/broker/scope.ts:
    • hostInScope — egress allowlist with exact + subdomain match; an exact entry always wins, but loopback / RFC1918 / link-local hosts are never subdomain-matched (a broad example.com entry can't be tricked into permitting an internal target). Undefined/empty egress ⇒ nothing reachable.
    • pathInScope — traversal-safe containment against the fs write-scope (a .. escape resolves outside and is denied); undefined/empty fs defaults to the project root ..
    • secretInScope — secret-scoped by default: only declared keys; undefined/empty ⇒ none.
    • isLoopbackOrPrivate (exported) for the egress guard.
  • src/broker/scope.test.ts — 13 tests (exact/subdomain/suffix-trick/empty egress; loopback never subdomain-matched but honored if exact; case + trailing-dot; fs default-root / traversal-escape / explicit sub-scope / root-itself; secret declared-only; RFC1918 boundary cases).

Testing

Test Coverage

  • Added new tests (13)
  • All tests pass (npm test) — full suite 2677 pass / 0 fail (2664 baseline + 13)

Manual Testing

  1. npx tsc --noEmit → clean.
  2. npx eslint src → 0 errors.
  3. npm run build && node scripts/test.mjs → 2677 pass, 0 fail.
  4. npx prettier --check → formatted.

Breaking Changes

None / N/A — new module; nothing imports it yet.

Checklist

  • All new code has test coverage
  • 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

The security-relevant subtlety is in hostInScope: subdomain matching is convenient but must never widen to internal targets, so loopback/private hosts are matchable only by a verbatim allowlist entry — a broad public entry can't be leveraged into SSRF against an internal host. Next steps: fail-closed scope source (brokerScope = verifiedScope → scope|null) + kit doctor status, then the PreToolUse enforcer, then integration into withGovernance.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

The deterministic, zero-LLM floor for the exec-broker (design:
kit-research/docs/research/pillar3-exec-broker-5.0.md §3.1). Adds src/broker/scope.ts —
three pure predicates over a ProfileScope (Pillar 4's signed RoE), no I/O:

- hostInScope: egress allowlist with exact + subdomain match; an exact entry always wins,
  but loopback/RFC1918/link-local hosts are never subdomain-matched (a broad entry can't be
  tricked into permitting an internal target). Undefined/empty egress => nothing reachable.
- pathInScope: traversal-safe containment against fs write-scope (a '..' escape lands outside
  and is denied); undefined/empty fs defaults to the project root '.'.
- secretInScope: secret-scoped by default — only declared keys; undefined/empty => none.
- isLoopbackOrPrivate helper (exported) for the egress guard.

Enforcement points (PreToolUse hooks, withGovernance) sit above this and feed the scope via
verifiedScope() (fail-closed — a null scope never reaches here). 13 unit tests.

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

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