Add command risk engine, MCP trust registry, audit export and network mode#43
Merged
Conversation
… mode Productize four self-contained governance/safety features (Strategy §Phase3 + §Gap5): - Command risk engine (command_risk.py): deterministic classify() mapping a command to a category + risk level + matched signal; conservative rules prefer "unknown" over wrong-confident. CLI `continuum command classify` (human + --json) exits non-zero on high risk to gate scripts. Policy gains approval_required_risk (default "high") and requires_approval() helper. - MCP trust registry (mcp_trust.py): .continuum/mcp_trust.json with per-server status/allow/deny/risk_score/last_changed. CLI `continuum mcp trust list|add|set|allow|deny|remove`; each mutation audits mcp_trust_changed. is_tool_allowed() precedence deny > allow > status default; unknown servers default-untrusted per MCP guidance. - Audit export (audit_export.py): `continuum audit export [--since][--format json|md][--output]` exports the event log; no secret values are stored or emitted. - Network mode: policy gains network on|local_only|off. ProviderManager refuses hosted providers under local_only/off (and local under off) with a policy_network_block audit event; surfaced in status and doctor. 279 tests pass (246 + 33 new). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Why
Strategy §Phase3 + §Gap5: productize security/governance (81% of devs cite security concern). Four self-contained, deterministic, stdlib-only features in one cohesive PR. Existing default behavior is unchanged (network absent/
on, approval thresholdhigh).Features
1. Command risk engine (§Phase3.10) —
continuum/command_risk.pyclassify(command_str)returns{category, level, signal, command}. Categories: read_only, build, test, file_write, network, package_install, destructive, credential_access, unknown. Conservative ordered rules; prefersunknown/lowover a wrong-confident guess.destructive/credential_accessare alwayshigh.continuum command classify "<cmd>" [--json]— exits non-zero when level==high so it can gate scripts.approval_required_risk(defaulthigh) +requires_approval(command, policy)helper.2. MCP trust registry (§Phase3.11 / #33) —
continuum/mcp_trust.py.continuum/mcp_trust.jsonwith entries{server, status, tool_allow, tool_deny, risk_score, last_changed}.continuum mcp trust list|add|set|allow|deny|remove; every mutation auditsmcp_trust_changedand stampslast_changed.is_tool_allowed(registry, server, tool): deny > allow > status default; untrusted/blocked servers' tools denied unless explicitly allow-listed; unknown servers default-untrusted (MCP guidance).3. Audit export (§Gap5) —
continuum/audit_export.pycontinuum audit export [--since <ISO|Nd>] [--format json|md] [--output <path>]. Default stdout. No secret values are stored or emitted (the scrubber only records counts/types).4. Local-only / no-network mode (§Gap5)
Policy gains
network: on | local_only | off(defaulton).ProviderManagerrefuses hosted providers (openrouter) underlocal_only/off, and local Ollama underoff, with apolicy_network_blockaudit event. Surfaced as a badge incontinuum statusandcontinuum doctor.Real smoke output
F1:
F2:
F3:
F4 (policy network=local_only):
Tests
CI-mimic
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null python -m unittest discover -s tests: 279 passed (246 + 33 new). New:tests/test_command_risk.py,tests/test_mcp_trust.py,tests/test_governance.py(audit export + network mode).🤖 Generated with Claude Code