feat(runner): add declarative JSON gate policy - #34
Conversation
422c7a3 to
b9605f9
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 6:08 PM ET / 22:08 UTC. ClawSweeper reviewWhat this changesThe branch adds declarative JSON gate rules to profile-configured scanners, evaluates those rules against preserved scanner JSON, records matched rules in run artifacts, migrates the embedded ClawHub profile, and publishes a Merge readinessKeep this PR open for explicit maintainer review. It is a MEMBER-authored, draft feature that intentionally changes the embedded Priority: P3 Review scores
Verification
How this fits togetherClawScan resolves profile YAML into scanner runs, preserves each scanner's raw JSON evidence, and writes run artifacts consumed by CLI users and optional judge harnesses. This PR inserts profile-defined JSON policy evaluation between scanner evidence collection and the final gate/artifact summary. flowchart LR
A[Profile YAML] --> B[Profile resolver]
B --> C[Scanner execution]
C --> D[Raw JSON evidence]
D --> E[Declarative gate rules]
E --> F[Run artifact gate]
F --> G[CLI summary and judge harness]
Decision needed
Why: The branch is technically scoped around a new declarative policy format, but changing a built-in profile's artifact semantics affects operators and downstream consumers even when scanner evidence is unchanged. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the feature only after a maintainer explicitly accepts the embedded ClawHub gate-outcome compatibility change and confirms that artifact consumers should treat the new Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature PR, not a report of broken established behavior. The relevant validation is after-fix profile resolution and real scan-artifact output rather than a failing current-main reproduction. Is this the best way to solve the issue? Unclear: the declarative engine is a coherent way to avoid scanner-specific wrappers, but enabling it in the embedded AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ef760b176da7. LabelsLabel 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 (7 earlier review cycles)
|
b9605f9 to
916d6df
Compare
916d6df to
d8e57e3
Compare
|
/clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
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 embedded
clawhubprofiles now express their SkillSpector and static-scanner policy with the same public rule format.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" } ] }The shipped ClawHub policy blocks
DO_NOT_INSTALLrecommendations andCRITICALfindings, warns onHIGHfindings, and warns whenclawscan-staticreports any finding. Preferred filtered finding collections override legacy raw collections when present.How to verify
.clawscan.ymlfile and confirm an editor flags an unknown profile field, invalid scanner ID, missing{{target}}, or malformed gate rule.equalsorexistsrule and inspectgate,gateRules, and the unchanged scannerrawvalue.blockOnExitCode; confirm both rules fire and the strongest action is recorded.Checks
env TMPDIR=/private/tmp go test -count=1 ./...— passed.go vet ./...— passed.make docs-site— passed.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, and non-finite numeric values.YAML-specific decoding and compatibility logic now 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.