Rules-as-data detection-descriptor schema
Goal
Extend the impl-hygiene-rules.json SSOT with a structured detection: descriptor per category and subcat, render the approved compact facet into the generated view, and keep generator/loader/staleness_lint green (round-trip).
Implementation Sketch
- Add the
detectionblock to the rules schema (schema_version bump + validator). - Extend generator.py to render
Detection (graph): <tier> - <detector/query-id>per rule. - Extend loader.py + api.py to expose descriptors to the engine; staleness_lint covers the new field.
Spec References
scripts/impl_hygiene_rules_runtime/{generator,loader,api,staleness_lint}.py; .claude/rules/impl-hygiene-rules.json; generated view banner.
Work Items
- Define the
detectionschema block {tier, detector|query_id, graph_props[], graph_edges[], enrichment_needed, narrowing_query, ast_linter}; bump schema_version; add validator. - Extend generator.py to render the compact
Detection (graph): <tier> - <id>facet per rule. - Extend loader.py + api.py to expose detection descriptors to the engine; staleness_lint covers the new field (round-trip green).
- Tests: schema validation, byte-stable generated view with the facet, staleness round-trip, loader/api exposure.
Items
- Define the
detectionschema block {tier: enum(graph-native|graph-assist|ast-lint|graph-gap|llm-only), detector|query_id, graph_props[], graph_edges[], enrichment_needed, narrowing_query, ast_linter}; bump schema_version; add validator enforcing the closed tier enum + the detector/query_id presence rule per tier. - Define the
detectionschema block {tier: enum(graph-native|graph-assist|ast-lint|graph-gap|llm-only), detector|query_id, graph_props[], graph_edges[], enrichment_needed, narrowing_query, ast_linter} in impl-hygiene-rules.schema.json (extend the$defs/subcat.detectionproperties map under itsadditionalProperties:false); bump schema_version; add a validator enforcing the closed tier enum + the per-tier detector/query_id presence rule. Move the consumer’sscripts/impl_hygiene_review_runtime/detection_descriptor.pyKNOWN_TIERStuple +validate_detection_descriptorshape in lockstep so the two-runtime contract does not drift.
Fresh intel (regenerated)
{ “schema_version”: 1, “target”: { “kind”: “plan-section”, “ref”: “graph-driven-hygiene/s-c6147920” }, “generated_at”: “2026-06-21T22:17:04.552529+00:00”, “graph_state”: { “head_sha”: “d1b2a9dc”, “last_code_import_at”: “2026-06-21T21:59:53.923Z”, “embedding_stale”: true, “insights_stale”: false, “cpg_stale”: false }, “surfaces”: {}, “summary”: “intel-package[plan-section:graph-driven-hygiene/s-c6147920] agent-authored dossier”, “degraded”: false, “dossier”: { “objective_symbols”: [], “tiers”: {}, “agent_authored”: true, “difficulty”: { “class”: “routine”, “research_online”: false, “research_mode”: “auto”, “signals”: [], “plan_dir”: “/home/eric/projects/ori_lang/plans/graph-driven-hygiene” } } }
(full dossier: rules-detection-schema—s-c6147920.intel.json)