fix(egress): wire reviewer-mode L2 import-audit (ast-based)#3
Open
kicrazom wants to merge 1 commit into
Open
Conversation
egress_guard: audit_imports rewritten on ast (catches dotted `from a.b import`, comma `import a, b`, aliased imports the line-regex missed); add assert_local_imports (reviewer-mode; no-op otherwise); drop _IMPORT_RE/re; docstring L2 wired, L3 scaffolded kb/query.py: reviewer-mode audits dispatched provider source via assert_local_imports (L2) tests: dotted/comma audit, assert_local_imports reviewer/author, reviewer+folder e2e ok Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Makes egress_guard Level 2 real (was scaffolded but unwired, and
status()falsely reported it "active"). Chosen over deletion: keep the defense-in-depth roadmap, make it enforce.Changes
audit_imports→ AST. The old line-regex missed dotted (from urllib.request import x), comma (import os, socket), and aliased imports — a reviewer-path script could pull network capability undetected.ast.parse+ walk catches all import forms (top-level module, absolute only). Drops_IMPORT_RE/re.assert_local_imports(paths, mode)— Level-2 companion toassert_local_only; in reviewer-mode raisesEgressViolationif any audited script imports a network module; no-op otherwise.kb/query.py— reviewer-mode now audits the dispatched provider's source file before running it (inspect.getsourcefile).folder/obsidianare clean, so local reviewer queries still succeed.run_sandboxed) left scaffolded — no reviewer subprocess chokepoint wires it yet; docstring says so honestly.Tests
+4: AST catches dotted/comma imports;
assert_local_importsblocks network in reviewer / allows clean+author; reviewer+folder e2e still ok. Full suite green; ruff clean. Manually verified a leaky provider is blocked in reviewer mode, allowed in author mode.Not included
permutation_test/multiple_testingreimplement scipy/statsmodels — deliberate deterministic-core, kept.🤖 Generated with Claude Code