100%

Section 01 — schema-optin-watermark

Goal

Add the plan-agnostic opt-in field + watermark + sanctioned write-API setter so a grind plan can declare hygiene-sweep and the engine can record its watermark.

Implementation Sketch

Add optional top-level hygiene_sweep {enabled:bool, interval:int, last_swept_count:int>=0} to scripts/plan_corpus/schemas/v7/plan-routing.schema.json (additionalProperties:false-safe, modeled on gate_metric/evolution_pre_attempt_gates). Add validate_hygiene_sweep to scripts/plan_corpus/schemas.py and wire it into validate_v7_plan_json. Add record_hygiene_sweep_watermark(plan_dir, count, *, recorded_at=None) to scripts/plan_corpus/write.py mirroring set_gate_metric (fcntl.flock via _with_plan_lock + in-memory validate before _write_plan_json).

Spec References

scripts/plan_corpus/schemas/v7/plan-routing.schema.json; scripts/plan_corpus/schemas.py:validate_gate_metric; scripts/plan_corpus/write.py:set_gate_metric; .claude/rules/script-first.md §11 (plan-agnostic tooling).

Work Items

  • Add optional top-level hygiene_sweep object to the v7 plan-routing schema (additionalProperties:false-safe).
  • Add validate_hygiene_sweep to schemas.py and wire it into validate_v7_plan_json.
  • Add record_hygiene_sweep_watermark setter to write.py (flock + in-memory validate, mirroring set_gate_metric).
  • pytest: schema accept/reject of hygiene_sweep shapes + setter idempotency + invalid-count rejection.

Fresh intel (regenerated)

{ “schema_version”: 1, “target”: { “kind”: “plan-section”, “ref”: “grind-hygiene-sweep/s-84fe3c19” }, “generated_at”: “2026-06-19T18:19:54.899958+00:00”, “graph_state”: { “head_sha”: “dbb10f0e”, “last_code_import_at”: “2026-06-19T17:39:41.692Z”, “embedding_stale”: false, “insights_stale”: false, “cpg_stale”: false }, “surfaces”: {}, “summary”: “intel-package[plan-section:grind-hygiene-sweep/s-84fe3c19] 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/grind-hygiene-sweep” } } }

(full dossier: schema-optin-watermark—s-84fe3c19.intel.json)