Skip to content

feat(security): TrajectorySentinel and ScopedToolExecutor for capability governance#3588

Merged
bug-ops merged 1 commit intomainfrom
security-capability-governance
May 4, 2026
Merged

feat(security): TrajectorySentinel and ScopedToolExecutor for capability governance#3588
bug-ops merged 1 commit intomainfrom
security-capability-governance

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 4, 2026

Summary

Closes

Test plan

  • cargo nextest run --workspace --lib --bins — 8727 tests pass
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --lib --bins -- -D warnings — clean
  • Live session: cargo run --features full -- --config .local/config/testing.toml — see .local/testing/playbooks/security-capability-governance.md for 8 test scenarios
  • Verify /trajectory status shows Normal at startup
  • Verify /scope list shows configured scopes
  • Verify PolicyGate blocks tool calls when manually seeding Critical via tests
  • Verify RiskLevel does not appear in LLM-visible tool error messages

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels May 4, 2026
…ability governance

Implements Phase 1 of spec 050 (security capability governance), addressing
research findings from issues #3563 (Aethelgard), #3569 (CapSeal/SUDP spec),
and #3570 (SafeAgent).

TrajectorySentinel (zeph-core):
- Accumulates risk signals across turns with multiplicative decay (default 0.85/turn)
- 9 signal types: VigilFlagged, PolicyDeny, PiiRedaction, ToolFailure, HighCallRate,
  UnusualReadVolume, ToolPairTransition, OutOfScope, TrajectoryAutoRecover
- 4 risk levels: Normal, Elevated, High, Critical
- Hard reset to 0.0 after auto_recover_after_turns (default 16) consecutive Critical turns
- Subagent score inheritance via spawn_child() with configurable inheritance factor
- advance_turn() fires before gate evaluation on every turn (spec Invariant 2)
- RiskAlert never exposed to LLM-callable tools (spec NEVER clause)

ScopedToolExecutor (zeph-tools):
- Generic wrapper enforcing per-task-type tool allow-lists from config
- Mandatory namespace prefixes: builtin:, skill:, mcp:, acp:, a2a:
- Build-time glob resolution to HashSet<ToolId>; strict for builtin:/skill:,
  provisional (re-resolved on dynamic registration) for mcp:/acp:/a2a:
- scope_at_definition and scope_at_dispatch fields in AuditEntry (FR-CG-012)
- Wired outermost in executor stack in runner.rs

PolicyGateExecutor integration:
- Reads trajectory_risk_slot atomic; overrides Allow → Deny at Critical
- RiskSignalQueue decouples signal recording from sentinel to avoid circular deps
- PolicyDeny and OutOfScope push signals; sanitizer pushes VigilFlagged/PiiRedaction

CLI/TUI/config integration:
- /trajectory status, /trajectory reset (operator-only), /scope list, /scope reset
- --scope <task_type> CLI flag
- [security.trajectory] and [security.capability_scopes] config sections
- --init wizard step for trajectory thresholds
- --migrate-config picks up new sections from default.toml automatically

CapSeal/SUDP (issue #3569): spec-only in specs/050-security-capability-governance/spec.md;
Phase 3 design around BoundSecret<Op> typestate documented.

Closes #3563
Closes #3570
Resolves #3569
@bug-ops bug-ops force-pushed the security-capability-governance branch from a02ebe6 to 0373a88 Compare May 4, 2026 18:03
@bug-ops bug-ops enabled auto-merge (squash) May 4, 2026 18:03
@bug-ops bug-ops merged commit 3408c6c into main May 4, 2026
32 checks passed
@bug-ops bug-ops deleted the security-capability-governance branch May 4, 2026 18:11
bug-ops added a commit that referenced this pull request May 4, 2026
…nflicts

Both branches added fields to AuditEntry:
- #3572: execution_env, resolved_cwd
- #3588: scope_at_definition, scope_at_dispatch

Keep all four fields. Fix missing context: None in scope.rs test helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

1 participant