Repository navigation
feat(runner): add declarative JSON gate policy - #34
Conversation
422c7a3 to
b9605f9
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 11:16 PM ET / July 31, 2026, 03:16 UTC. ClawSweeper reviewWhat this changesThis PR adds opt-in declarative JSON gate rules to scanner profile definitions, records matching rules in run artifacts and CLI summaries, and publishes a JSON Schema for profile authoring. Merge readinessKeep this PR open for maintainer review. The declarative gate capability is not on current Priority: P2 Review scores
Verification
How this fits togetherClawScan turns YAML profile scanner entries into runner options, invokes scanners that preserve their raw JSON evidence, and writes artifacts for operators or an external judge. This PR inserts an optional gate-evaluation step over valid scanner JSON, producing recorded flowchart LR
A[Profile YAML] --> B[Profile resolver]
B --> C[Scanner options]
C --> D[Scanner JSON evidence]
D --> E[Optional gate evaluation]
E --> F[Run artifact]
F --> G[CLI summary and judge input]
Decision needed
Why: The patch is technically bounded and preserves the previously identified embedded-profile compatibility contract, but it creates a lasting user-facing configuration language and artifact behavior that needs maintainer acceptance. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt the feature only with the gate language kept opt-in, the embedded ClawHub profiles permanently evidence-only, and focused regression coverage for profile resolution plus ordinary versus infrastructure scanner exits. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a new profile capability rather than reporting broken current-main behavior. The relevant verification is behavioral coverage of explicit gate rules and preservation of gate-free embedded profiles. Is this the best way to solve the issue? Yes, conditionally: evaluating raw scanner JSON from an opt-in profile rule is a narrow way to add policy without changing scanner implementations, provided maintainers accept the new configuration contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3d041c6cc08c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
b9605f9 to
916d6df
Compare
916d6df to
d8e57e3
Compare
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat(runner): add declarative JSON gate policy This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
New behavior
Trusted profiles can now attach declarative rules to the JSON already emitted by any built-in or command-defined scanner. Scanner implementations do not need ClawScan-specific policy support, wrappers, or changed exit codes.
equalsmatches string, boolean, or exact JSON-number values.exists: truefires when a path resolves to non-empty evidence.blockwins overwarn..clawscan.ymlauthors completion and early validation without replacing ClawScan's runtime checks.The existing embedded
clawhubandclawhub-aigprofiles deliberately remain gate-free and evidence-only. Declarative gates are opt-in through a custom profile; regression tests protect that compatibility contract.Profile and artifact proof
An immutable third-party scanner can be gated directly. The schema directive is optional and understood by YAML language-server integrations:
A fired JSON rule is recorded alongside the preserved scanner evidence:
{ "gate": "block", "gateRules": [ { "scanner": "third-party", "rule": "critical-risk", "path": "result.risk", "value": "CRITICAL", "action": "block" } ] }How to verify
.clawscan.ymlfile and confirm an editor flags an unknown profile field, invalid scanner ID, missing{{target}}, malformed gate rule, or unsupported path expression.clawhubandclawhub-aigprofiles and confirm neither produces gate rules.equalsorexistsrule and inspectgate,gateRules, and the unchanged scannerrawvalue.blockOnExitCode; confirm both rules fire and the strongest action is recorded.Checks
TMPDIR=/private/tmp go test -count=1 ./...— passed.TMPDIR=/private/tmp go vet ./...— passed.make docs-site— passed with no tracked output changes.Implementation notes
The path language is intentionally small: dotted object fields,
[]array traversal, and|field aliases. It is not a general JSONPath evaluator. Runtime parsing rejects unknown fields, duplicate IDs or paths, ambiguous conditions, invalid actions, unsupported normalization, malformed paths, and non-finite numeric values.YAML-specific decoding and compatibility logic live in
internal/profiles/yaml.go;resolver.goremains focused on profile selection and CLI option resolution. The schema provides authoring feedback, while runtime validation remains the source of truth for execution.