0%

Make the always-global rule dump measurable

Goal

The acceptance probe cannot currently see the problem this plan targets. measure_invocation_cost.py charges only rules that paths:-glob-match the measured skill OR are explicitly @-included by it; a no-paths:, non-@-included rule is charged ZERO. But no-paths: rules load unconditionally every turn (native Claude Code behavior; confirmed empirically by a session’s own start-of-session context loading routing/learning-ledger/etc with no skill active). Extend the probe to charge the always-global load so the window-reduction north-star is measurable at all, and correct the 9 no-paths: files whose inline comment falsely claims ’@-include ONLY’.

Implementation Sketch

  • Extend enumerate_auto_loaded_rules / measure_rules with an always_on_core_rules component that charges EVERY .claude/rules/*.md file carrying neither paths: frontmatter nor a matched @-include, as resident in every turn.
  • Record the real baseline (total no-paths: protocol-rule tokens resident) into scripts/plan_orchestrator/tests/baseline.json.
  • Correct each of the 9 no-paths: rule files’ inline # No paths: glob — load via explicit @-include from ... comment to state the true always-loaded reality (litter-pickup per CLAUDE.md §Scope Expansion; the comment is a factual defect).
  • Add a probe self-test fixture proving a no-paths: rule is now charged.

Spec References

  • scripts/plan_orchestrator/tests/measure_invocation_cost.py (enumerate_auto_loaded_rules, CONTROLLED_SURFACE_COMPONENTS).
  • .claude/rules/context-discipline.md §4 (token-budget probe SSOT).
  • Official Claude Code Rules docs: absent paths: => unconditional load.

Work Items

  • Extend the probe with an always_on_core_rules component charging every no-paths:/non-@-included rule as resident every turn
  • Record the real always-global protocol-rule baseline into baseline.json (the number the north-star reduces)
  • Correct the 9 no-paths: rule files’ false ’@-include ONLY’ inline comments to state the always-loaded reality
  • Add a probe self-test fixture asserting a no-paths: rule is charged (negative pin: the old probe scored it zero)

Test strategy / acceptance

Semantic pin: the extended probe reports a non-zero always_on_core_rules reading for the current corpus; the pre-extension probe reported zero for the same rules (the pin fails if reverted). Baseline recorded in baseline.json. This section is engine-INDEPENDENT and startable immediately.