From fd576c9a3285ec5a13beaf335296468c0a8c65ba Mon Sep 17 00:00:00 2001 From: Amos Mastbaum Date: Mon, 30 Nov 2026 19:15:58 -0500 Subject: [PATCH] docs(ADR-0166): resolve planning workloads through validated descriptors Epic Decomposer stages resolve workload behavior from a versioned descriptor selected once at entry, instead of hard-coding one workload's planning policy in shared code. Adding a workload means adding a descriptor and its policies; legacy single-workload behavior stays as a compatibility path. Implementation tracked in #9966. Signed-off-by: Amos Mastbaum --- ...66-descriptor-driven-planning-workloads.md | 400 ++++++++++++++++++ docs/architecture.md | 9 + docs/problems/durable-work-recovery.md | 6 + 3 files changed, 415 insertions(+) create mode 100644 docs/ADRs/0166-descriptor-driven-planning-workloads.md diff --git a/docs/ADRs/0166-descriptor-driven-planning-workloads.md b/docs/ADRs/0166-descriptor-driven-planning-workloads.md new file mode 100644 index 0000000000..8c0a5c660b --- /dev/null +++ b/docs/ADRs/0166-descriptor-driven-planning-workloads.md @@ -0,0 +1,400 @@ +--- +title: "166. Descriptor-driven planning workloads" +status: Accepted +relates_to: + - agent-architecture + - durable-work-recovery +topics: + - workloads + - descriptors + - jira + - planning +--- + +# 166. Descriptor-driven planning workloads + +Date: 2026-11-30 + +## Status + +Accepted + +## Context + +Epic Creator decomposes approved strategies into implementation epics. A +strategy is a document Strategy Creator attaches to a Jira ticket; today +the pipeline reads it only from a RHAISTRAT Feature. This decision adds +the RHAISTRAT Initiative as a second carrier: a signed-off Initiative's +attached strategy is decomposed into epics parented to that Initiative. + +Today, its shared discovery, decomposition, review, revision, and Jira +submission stages hard-code one workload's planning behavior, fused in +three places. The pipeline driver binds the workload identity into its +orchestration: RHAISTRAT IDs and Jira Query Language (JQL). The +per-stage agent prompts are at once stage procedure and workload +policy. The review prompt carries the whole scoring rubric in prose. +The decompose prompt carries the triage and Directed Acyclic Graph +(DAG) construction rules. The scripts carry the rest as module-level +constants: the submission target project, the processed label, the +component-cache path, and the intake attachment pattern. Adding a new +source of work means editing every one of these. Any per-workload fork +replicates each fix across copies. + +This ADR aims to make workload behavior a validated, versioned data +contract, so a consuming pipeline takes on new planning workloads by +configuration instead of per-workload code, while preserving the existing +single-workload behavior as a compatibility path. + +## Options + +- **Fork per workload** — rejected: every fix and policy change must be + replicated across forks. +- **Branch on workload in shared code** — rejected: scattering + `if workload == ...` dispatch through the stages keeps workload-specific + logic embedded in shared code; every new workload touches every stage. +- **Wait for a shared planning engine** — rejected: the peer creators stay + separate pipelines and the descriptor contract is the agreed integration + point; deferring blocks new workloads now. + +## Decision + +We adopt a descriptor-driven consuming architecture: one pipeline whose +stages resolve workload behavior from a validated, versioned descriptor +selected once at entry. + +### The workload descriptor + +A workload is a YAML document in an in-repo registry (`workloads/`), +validated against `workloads/_schema/workload.schema.json`. The full shape, +for the RHAI Initiative workload: + +```yaml +schema_version: 1 +id: rhai-initiative # unique registry ID +version: 1 # descriptor version +source: # intake contract + project: RHAISTRAT + issue_type: Initiative + id_pattern: '^RHAISTRAT-\d+$' + attachment_template: '{key}-strategy.md' # strategy: this attachment + description_fallback: false # never read the description + ready_labels: [strat-creator-human-sign-off, strat-creator-rubric-pass] + skip_policy: processed-label # or: child-epics + processed_label: epic-creator-auto-decomposed + handoff_type: initiative-strategy + identity_fields: [strat_id, jira_key, source_initiative] +submission: # typed submission contract + project: RHAI + issue_type: Epic + parent: {relation: parent} + dependency_link_type: Blocks + labels: + created: epic-creator-auto-created + investigation: epic-creator-investigation + implementation_prefix: epic-creator-impl- + ai_prefix: epic-creator-ai-impl- + needs_component: epic-creator-needs-component +planning: # planning and review contract + artifact_template: workloads/policies/rhai/v1/artifacts.md + scoring: workloads/policies/rhai/v1/scoring.yaml + decompose: workloads/policies/rhai/v1/decompose.md + review: workloads/policies/rhai/v1/review.md + revise: workloads/policies/rhai/v1/revise.md + components: {project: RHAI, file: .context/rhai-components.txt} + review_gate: + criteria: [HLR Coverage, DAG Coherence, Epic Boundaries, + Type Correctness, AI Implementability Scoring, + Acceptance Criteria Quality, Completeness] + points_per_criterion: 2 + pass_score: 10 + zero_fails: true +``` + +- `source` defines intake: + - where source work items live (project, issue type), and how a valid + source key is recognized (`id_pattern`); + - where the planning content comes from — for the two initial workloads, a + strategy document (`attachment_template`). `description_fallback` + is configurable per workload, and the setting reflects what the + ticket's description holds. For the Feature workload the + description is itself strategy content, so it is a valid fallback. + For the Initiative workload the description is the Initiative's + own intake text and the strategy exists only as the attachment, so + a missing attachment means skip. When several revisions of the + attachment exist, the newest is used — one strategy per source, + latest revision; + - which labels evidence approval (`ready_labels`) — both labels + must be present on the ticket; + - how a processed source is recognized (`skip_policy`): + `processed-label` checks the processed label — the reliable signal, + since only the pipeline sets it; `child-epics` checks for existing + child epics — a heuristic retained for the Feature workload's + compatibility path, where any child epic blocks intake regardless + of origin; + - which handoff identity fields the source carries + (`identity_fields`), and the handoff type it receives + (`handoff_type`). +- `submission` defines the tracker destination (`project`, `issue_type`), + the relation each generated epic carries to its source (`parent`, or a + link relation), the `dependency_link_type` between generated epics, and + the `labels` used for idempotent writes: `created`, + `investigation`, `implementation_prefix`, `ai_prefix`, and + `needs_component`. +- `planning` binds the policy set by path (see Policies below) plus the + component vocabulary — the tracker project and the component cache file + the typed writes validate against — and the review gate: named criteria, + points per criterion, a pass score, and `zero_fails` (a zero on any + criterion fails the gate regardless of the total). + +An intake-only descriptor (`source` alone) is valid. Planning requires +`planning`. Typed submission requires both `planning` and `submission`. + +The descriptor is data. It loads no executable plugins. + +Fields with derivable values are optional with defaults — for +example, `id_pattern` derives from `project`, and +`attachment_template` defaults to `{key}-strategy.md`. + +Together, a workload's `source` block is the complete list of +prerequisites a ticket must satisfy: right project, right issue type, +right key format, approval labels, and strategy content — the +attachment, or the description when the descriptor allows the fallback. +The pipeline rejects any ticket that fails a prerequisite before +starting work, and processes only tickets that a registered workload +claims. + +Where a concept already exists in the shared vocabulary used by RFE +Creator and Strategy Creator (`types//type.yaml`, +`types/_schema/type.schema.json`), it corresponds as follows. Epic +Creator keeps its flat `source` / `submission` / `planning` shape +because `skip_policy: child-epics` and the `planning` block have no +counterpart and the registry is workload-scoped, not type-scoped: + +- `source.{project, issue_type, id_pattern}` → `inputs[].jira.{project, issue_type, key_prefixes}` +- `handoff_type` → `from_type` +- `ready_labels` → `gate.labels_all` +- `attachment_template` / `description_fallback` → `body_source.{attachment, fallback}` +- `skip_policy: processed-label` + `processed_label` → `skip_if.labels_any` / `label_on_input` +- `submission.parent` + `dependency_link_type` → `relation` +- `submission.labels.*` → `conventions.labels.*` + +`skip_policy: child-epics` and the `planning` block have no +counterpart and remain Epic Creator-specific. + +The registry's initial content is two descriptors. The other, +`rhaistrat-strategy`, is today's production workload — the Feature path +the pipeline has always +run. It differs from the example above only in its `id` and its +`source` block: + +```yaml +source: + project: RHAISTRAT + issue_type: Feature + id_pattern: '^RHAISTRAT-\d+$' + attachment_template: '{key}-strategy.md' + description_fallback: true + ready_labels: [strat-creator-human-sign-off, strat-creator-rubric-pass] + skip_policy: child-epics + processed_label: epic-creator-auto-decomposed + handoff_type: rfe-strategy + identity_fields: [strat_id, jira_key] +``` + +Its `submission` and `planning` blocks are the same as the Initiative +descriptor's, shared verbatim. The two workloads differ in their `id` +and in that one `source` block: a different issue type, a description +fallback instead of attachment-only, the Feature path's skip heuristic +instead of the processed label, a different handoff type, and one fewer +identity field. + +### Policies + +Stage policy is the instructions the stage agents read and follow at +runtime — the workload's judgment, kept out of both the shared prompts +and the descriptor. It lives in documents under `workloads/policies/`, +each referenced by repository-root-relative path from the descriptor's +`planning` block and constrained by the workload schema's path pattern: + +- `decompose.md` — the decomposition procedure: triage rules, the + epic-boundary and DAG-construction rules, requirement-to-epic mapping +- `review.md` — the review procedure: the named criteria of the review + gate, what counts as critical or major, how to score each criterion +- `revise.md` — how review corrections are applied to a decomposition +- `artifacts.md` — the body templates for generated epic and summary + files +- `scoring.yaml` — the machine-readable counterpart: the thresholds the + deterministic layer enforces (AI-implementability routing), validated + against `workloads/_schema/scoring.schema.json` + +These documents come in two kinds. The four markdown files are +procedures: at runtime the stage's language-model agent follows the +bound `POLICY_FILE` (see Stage resolution) the way code follows a +program. The fifth, `scoring.yaml`, involves no model — deterministic +code enforces its thresholds. + +Policies are referenced by path, not inlined. The family — the middle +segment of the path (`policies/rhai/v1/` names the `rhai` family) — +names a policy set, not a group of workloads: any descriptor may +reference any family. The two initial workloads are different work with +different source contracts, yet both reference `policies/rhai/v1/` +because they decompose and review identically — one edit to the shared +set serves both, and adding a workload is a source contract plus policy +references, not new stage code. + +A family may carry generation directories (`policies/rhai/v1/`, a +future `v2/`), so a new generation can be added without rewriting the +documents other descriptors still point at. The generation number is +just a name; what a run binds is each document's content digest, so +editing a policy rejects resume exactly like editing the descriptor. + +### Handoff from Strategy Creator + +This handoff is not between Epic Creator's own internal steps — it is +the work entering from the previous pipeline in the chain (RFE +Creator → Strategy Creator → Epic Creator). The `source` block is this +pipeline's record of that inbound handoff from Strategy Creator. +Its identity fields are station-specific and must not be +extrapolated between stations. The Strategy Creator handoff carries +`strat_id`, `jira_key`, and `source_rfe` or `source_initiative`. RFE +Creator artifacts carry `type`, `tracker_ref`, and `local_id`. + +Strategy Creator records what this pipeline reads: project, issue type, +approval labels, id pattern, attachment pattern, strategy headings, and +High Level Requirements (HLR) priorities. It keeps that list as a data +fixture and tests its types against it without importing this +repository. In the descriptor architecture the contract splits +naturally. The intake fields land in `source`. The content-structure +expectations land in the planning policy documents. + +The descriptor vocabulary is copied between stations, not imported. +Strategy Creator's design also publishes an `inputs:` block as carried +data; the stations import nothing from each other. That block stays +lint-check vocabulary there. It is not an executable gate interface +here. + +### Registry validation + +The registry is the `workloads/` directory — the set of workload +descriptors this installation knows about, nothing more than a folder of +YAML files next to their schemas and policies. At the start of every run +it is loaded whole, and loading rejects missing fields, duplicate IDs, +duplicate intake bindings — two descriptors claiming the same +`(project, issue_type)`, so automatic selection is never ambiguous — +unknown schema versions, unsafe path declarations, and references to +policies that are not in the registry. A run never starts against a +registry that fails to load. + +### Selection and binding + +A run picks its workload once, at entry, one of three ways. Explicitly: +`--workload ID`, the pipeline's own command-line and skill interface, +not a fullsend flag. By omission: this keeps today's single-workload +invocation unchanged. That compatibility path is a flow guarantee, not +a code freeze. The restructure moves the Feature workload's rules from +fused prompts and script constants into descriptor and policy +documents, the same values and the same words. A run without the flag +takes the same steps and submits to the same destination with the same +labels as before. Or through opt-in Jira intake: the source issue's +`(project, issue_type)` names the workload bound to it. + +Before any work starts, intake checks the door: the source key must +match `id_pattern`, the approval labels must be present, and the +source's identity must agree with the selected workload. A mismatch or +an unknown workload ID stops the run before decomposition or any Jira +write. The source issue itself is never cloned or re-keyed, and, under +the `processed-label` policy, hand-made child issues do not block +intake. + +The choice is written into pipeline state together with the workload +version, the descriptor's digest, the digest of every referenced policy +document, and the source revision. Every stage boundary re-checks these +bindings; a failing review is not a binding failure — it routes the plan +into revise, and passing scores are required only when a plan is +admitted to submission. If the descriptor, a policy document, or the +bound source changed since the run started, resume is refused: typed +artifacts require a fresh fetch and a new planning run. A half-done plan +is never finished under rules it was not built with. + +### Discovery + +Discovery belongs to the workload: each descriptor carries its own +discovery query — which sources it picks up, including the filters the +caller maintains today (project, issue type, approval labels, and the +Feature path's Target Version gate) — so adding a workload wires up how +it finds work without touching shared code or deployment +configuration. This is decided but not yet implemented: today the +caller still supplies the query, and moving it into the descriptor is +follow-up work. + +### Stage resolution + +Every stage — fetch, decompose, review, revise, submit — resolves its +behavior from the selected descriptor. Shared stage code keeps only the +stage procedure, artifact locations, and safety and validation instructions; +it holds no workload-specific policy. Cross-station document parsing — +strategy title headings spanning the peer stations' key prefixes — and +artifact filename conventions stay in shared code: they are station +mechanics, not workload policy. Concretely, each stage's agent prompt +is a shell: the policy path and artifact template are injected as bound +values from pipeline state (`POLICY_FILE`, `ARTIFACT_TEMPLATE`), the stage +reads and follows them, and it never chooses a workload or policy itself. +The producer contract for generated +artifacts is exposed per workload through the frontmatter CLI +(`schema TYPE --workload ID`), including the exact rubric criterion names +and canonical component names, so typed epic writes reject unknown +components and a reviewed component cannot be silently dropped from a +submitted plan. + +### Submission and recovery + +Submission is a separate explicit command per workload. A credential-free +dry run validates local artifacts without any HTTP. A real run validates the +full artifact set, review scores, components and the dependency graph before +the first Jira write, then rechecks live source approval and content +freshness. Main and conditional plans are both validated before anything is +created; conditional plans stay attachments on a main investigation rather +than separate issues, and a main epic's `gated_by` must name a main +investigation included in its dependencies. + +Writes go through stable identity labels and reviewed-plan fingerprints, +backed by an atomically persisted, locally locked intent journal: + +- Intent is saved before creation. +- Reruns recover known effects and reconcile missing relationships, labels + and content-addressed evidence. +- Create and upload requests are never blindly retried after ambiguous + outcomes; an unresolved prior create stops for later reconciliation. +- The source is marked processed only after all phases succeed. + +The descriptors and registry live in the repository of the pipeline +that consumes them — Epic Creator's today — not in a central store; a +second consumer would decide with the maintainers whether they move. + +## Forge scope + +Forge-neutral. Workload descriptors configure Jira-backed planning — +projects, issue types, labels, relationships — and the pipeline reads source +content through the same generic fetch mechanics it uses. Nothing in +this decision depends on GitHub, GitLab or Forgejo specifics. + +## Consequences + +- Adding a workload means adding a validated descriptor and its policies, + not forking the pipeline or editing shared stages. +- The existing single-workload discovery, artifact, DAG, review and + submission behavior is preserved as a compatibility path — the + restructure changes how the code is organized, not what a run without + the flag does. +- Strategy Creator's published approval is a precondition this + pipeline trusts and does not re-run; how Strategy Creator reaches it + is Strategy Creator's business. The local gate is this pipeline's own: the + descriptor configures it — criteria, points, pass score — the + pipeline's code enforces it, and a workload cannot ship executable + checks or switch it off. +- Recovery depends on retaining the artifact directory and journal; a lost + journal plus an invisible or unindexed source issue cannot guarantee + duplicate prevention. +- Changes to planning prompts and policies require model-quality evaluation + against the existing corpus, in addition to deterministic orchestration + tests. diff --git a/docs/architecture.md b/docs/architecture.md index 64606c2fe5..065b30eb75 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -805,6 +805,15 @@ The existing design principle is that [the repo is the coordinator](problems/age group-configured Jira URL field, which polling agents use as a discovery signal ([ADR 0176](ADRs/0176-repository-driven-epic-creation.md)). +- Descriptor-driven planning workloads: a decomposition pipeline's stages + (fetch, decompose, review, revise, submit) resolve workload behavior from + a validated, versioned descriptor selected once at entry, instead of + hard-coding one workload's planning policy in shared code. Adding a + workload means adding a descriptor and its policies; the legacy + single-workload behavior is preserved as a compatibility path, and + each workload is to own its own discovery query (decided; the caller + supplies it today) + ([ADR 0166](ADRs/0166-descriptor-driven-planning-workloads.md)). **Open questions:** diff --git a/docs/problems/durable-work-recovery.md b/docs/problems/durable-work-recovery.md index 74f996920e..64b4aa8ecf 100644 --- a/docs/problems/durable-work-recovery.md +++ b/docs/problems/durable-work-recovery.md @@ -77,6 +77,12 @@ do not receive journal-write credentials. CI finalization is a best-effort checkpoint, not the recovery guarantee. Its implementation remains separate from the decision. A local database test is not distributed acceptance. +[ADR 0166](../ADRs/0166-descriptor-driven-planning-workloads.md) applies +the same shape inside a consuming pipeline. An atomically persisted, +locally locked intent journal gates Jira submission: intent is saved +before creation, reruns reconcile known effects, and an ambiguous +create is never blindly retried. + Entity-first discovery must also find eligible work whose trigger was lost before admission. Trackers retain business and handled state; the journal records mechanical progress after admission. Publish-only retry from retained