100%

JSON schema + loader

Goal

Author the full impl-hygiene-rules.schema.json and the production loader. The schema captures every de-facto field the prose carries today: token, severity_default, scope (authoring|review|both), subcats[] (each: token, description, optional severity_override, optional detect, optional cure), detect[], cure, banned_phrases[], guidance (free-text prose body — the nuance is preserved, not flattened), and detector_keys[] (the seam-detector routing key consumed by §06). The loader mirrors the plan_orchestrator/rules.py 3-layer pattern (parse -> jsonschema validate -> enum re-validate, cached singleton) and exposes a scope filter mirroring prose-lint _compile_patterns.

Implementation Sketch

Author .claude/rules/impl-hygiene-rules.schema.json. Author scripts/impl_hygiene_rules_runtime/loader.py:load() mirroring rules.py:load() (3-layer, _CACHED singleton, force_reload). Add a scope enum (authoring|review|both) mirroring AppliesTo. api.py declares the public surface (load, categories, subcats, rules_for_scope) per script-first.md §4 api.py. __main__.py --self-test round-trips. SRP/SSOT: zero duplication of the loader algorithm (cite rules.py, do not re-derive).

Spec References

scripts/plan_orchestrator/rules.py:362-366 (AppliesTo enum), :474-481 (banned-pattern dict shape), :496-570 (load); scripts/prose-lint.py:87-125 (_compile_patterns scope/context filter); script-first.md §4 (api.py surface).

Work Items

  • Author .claude/rules/impl-hygiene-rules.schema.json: category record (token, severity_default, scope enum, subcats[], detect[], cure, banned_phrases[], guidance, detector_keys[]).
  • Author loader.py:load() mirroring plan_orchestrator/rules.py 3-layer (parse -> jsonschema -> enum-revalidate, cached); scope filter mirroring prose-lint _compile_patterns.
  • Author api.py public surface + main.py —self-test + pytest covering load, scope-filter, schema-reject of a malformed record.

Success Criteria

  • [sc-5ba5e9b7] Schema + loader validate impl-hygiene-rules.json (3-layer) and —self-test passes. (probe: python -m scripts.impl_hygiene_rules_runtime --self-test; expect: exit 0)

Fresh intel (regenerated)

{ “schema_version”: 1, “target”: { “kind”: “plan-section”, “ref”: “impl-hygiene-rules-as-data/s-44298980” }, “generated_at”: “2026-06-21T04:47:26.134878+00:00”, “graph_state”: { “head_sha”: “b0bd51a8”, “last_code_import_at”: “2026-06-21T04:43:48.879Z”, “embedding_stale”: false, “insights_stale”: false, “cpg_stale”: false }, “surfaces”: {}, “summary”: “intel-package[plan-section:impl-hygiene-rules-as-data/s-44298980] 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/impl-hygiene-rules-as-data” } } }

(full dossier: schema-and-loader—s-44298980.intel.json)