# Tier Consumers

## Why This Exists

The IR contract should guide implementation without forcing every future field into the first parser milestone. This page maps which tiers produce or consume each semantic area so implementation can stay incremental.

## Producer Timeline

| Tiers | Producer Scope | IR Areas |
| --- | --- | --- |
| 0-2 | Lexer/parser scaffolding and minimal parser | Source spans, pipeline names, bare steps. |
| 3-4 | Step modifiers and invocation args | Call nodes with `target`/`args` payloads, `need`/`want` dependency roles, `export`/`capture` binding roles. |
| 5-8 | Types, env, declarations, scripts, main | File-level `env`, `declaration`, `script`, `entrypoint` items with array payloads; typed values. |
| 9-12 | Control flow and expressions | `branch` nodes with `case`/`default`/`finally` clause payloads, `when` conditions, `loop` nodes, dependency constructs. |
| 13-15 | Resolver | Graph metadata, env merging, hooks, validation, warnings, safety/skip metadata. |
| 16-21 | Emitter/build | POSIX output via generation contributors (role-based dispatch), root/group scripts, drill files, standalone scripts, embedded source maps. |
| 22 | Engine cutover | Runtime compatibility with generated artifacts and registry updates. |
| 23+ | Cross-pipeline drilling | Imported drill trees and cross-pipeline help provenance. |

## Consumer Map

| IR Area | First Producer | First Consumer | Later Consumers |
| --- | --- | --- | --- |
| `$schema`, `ir_version`, `unit` | lowering | resolver | emitter, fixtures |
| `role: "source"`, `sourcemap` | lowering | diagnostics | emitter, standalone scripts, machine output |
| `role: "import"` | lowering | resolver/build | drilling |
| `role: "env"` | lowering | resolver env validation | emitter CLI/help, drilling |
| `role: "script"` | lowering | build | standalone emitter |
| `role: "declaration"` | lowering | resolver/type checker | emitter |
| `role: "pipeline"` | lowering | resolver graph | emitter, drilling |
| `call`, `need`, `want`, `export`, `capture` | lowering | resolver validation | emitter contributors |
| `branch`, `when`, `loop` | lowering | resolver validation | emitter contributors |
| graph metadata | resolver | emitter | drilling/help |
| safety/skip metadata | resolver | emitter | help/machine output |

## Implementation Guidance

- Early tiers may produce a strict subset of the target IR, but field names should match the canonical contract from the beginning.
- Tests should compare focused slices of IR rather than full target-state objects until the relevant tier exists.
- Resolver-owned metadata should be additive and separate from lowered author intent.
- The `opc compile` command should stay unavailable until the emitted IR is useful enough to treat as a contract rather than debug noise.

## Design References

- [build_tiers](../build_tiers.md) is the authoritative tier order.
- [architecture](../architecture.md) shows the parser → lowering → resolver → emitter flow.
- [ir_schema](../ir_schema.md) defines the target-state object shape.
