0%

Rule-slice Banner feeder (engine-gated)

Goal

Generalize the workflow engine’s Banner mechanism (today 9 hand-authored orientation strings) into a state-keyed rule-SLICE feeder: a new Banner MODULE that renders the relevant .claude/rules §anchor slice for the served state’s active components (consuming their spec_ref), riding the next_action handoff envelope. A new Banner MODULE, NOT a new KIND — it does not trip the engine’s sec-10.1 bounded-vocabulary go/no-go.

Depends On (cross-plan)

BLOCKED-BY plans/workflow-engine-rework engine-core (s-e585be74: Banner interface + ComponentMetadata.spec_ref) + rails-components (s-b6c8160c: Banner components + --docs). This section cannot execute until those land.

Implementation Sketch

  • Author banners/rule_context.py: render(ctx) -> Optional[BannerText] (side_effect_class = RENDER, read-only) that reads the served state’s active components’ spec_ref, looks up the S2 mapping, and returns the pinned rule §anchor slice(s) for that state.
  • STATELESS delivery: no ‘already-fed’ tracking (compaction makes it unreliable); render the relevant slices every serve, appended AFTER the cached prefix via the next_action/banner envelope so the prompt-cache prefix is never mutated; err toward over-delivery.
  • The engine’s generated --docs renders the rule_context banner + its state->slice mapping (consumes the engine’s own --docs surface).

Spec References

  • plans/workflow-engine-rework/spec/workflow-state-machines.md sec 1.6 (rails/banner), sec 10.1 (Banner vocabulary — new MODULE not KIND), sec 10.2 (Banner interface, ComponentMetadata, WorkflowContext, --docs).
  • plans/workflow-engine-rework/content/rails-components--s-b6c8160c.md (Banner components + generated --docs).
  • Anthropic prompt-caching (prefix match; append after breakpoint; do not mutate the frozen prefix).

Work Items

  • Author banners/rule_context.py — render the served state’s mapped rule §anchor slice(s) from spec_ref (RENDER/read-only, new MODULE)
  • Wire the feeder to the S2 mapping + S1 spec_ref pins; STATELESS per-serve rendering, appended after the cache prefix
  • Extend the engine’s --docs to render the rule_context banner + its state->slice mapping
  • Tests: banner renders the correct slice per served state; is a new MODULE not a new KIND; stateless (no fed-tracking); prefix untouched

Test strategy / acceptance

Pin: for a given served state, the banner renders exactly the mapped rule §anchor slices; a state with no mapped rule renders nothing. Negative pin: the banner adds no new Banner KIND (sec-10.1 go/no-go untripped). ENGINE-GATED.