Skip to content

Commit 34a1b8a

Browse files
docs(site): add Public JSON summary section to ir.mdx (#1067)
1 parent 16a892f commit 34a1b8a

1 file changed

Lines changed: 153 additions & 0 deletions

File tree

  • site/src/content/docs/reference

site/src/content/docs/reference/ir.mdx

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,156 @@ The production target wrappers are:
266266
The canonical 5-job Setup → Agent → Detection → SafeOutputs → Teardown shape itself lives in `agentic_pipeline.rs` and is reused unchanged by every wrapper above; extensions plug into it via `Declarations` (steps, env, hosts, MCPG entries, and Agent-job condition clauses — see `Declarations::agent_conditions`).
267267

268268
When adding a target, follow the same pattern: parse and validate front matter, collect extension `Declarations`, build typed jobs/stages/steps, set the correct `PipelineShape`, and call the shared emit path.
269+
270+
## Public JSON summary
271+
272+
The internal IR types (`Pipeline`, `Job`, `Step`, `Graph`, …) are intentionally tied to the compiler's lowering needs and are **not** public API. `src/compile/ir/summary.rs` defines a parallel **summary tree** with `#[derive(Serialize)]` that provides agent-facing tooling with a stable JSON view of a compiled pipeline.
273+
274+
This is the schema consumed by:
275+
276+
- `ado-aw inspect <source> --json` — returns a full `PipelineSummary`
277+
- `ado-aw graph dump <source> --format json` — returns a `GraphSummary` subset
278+
- `ado-aw graph deps` / `ado-aw graph outputs` — focused graph queries
279+
- `ado-aw whatif` — static downstream skip analysis built on graph reachability
280+
- `ado-aw audit --json` — the `pipeline_graph` field in `AuditData`
281+
- The [author MCP server](/ado-aw/reference/mcp-author/) tools (`inspect_workflow`, `graph_summary`, `graph_dump`)
282+
283+
### Stability contract
284+
285+
`PipelineSummary::schema_version` (currently `1`) is the public schema version. It is bumped when the JSON shape changes in a backwards-incompatible way — renamed field, removed variant, or changed semantics. Additive changes (new optional fields) do not require a bump. New enum variants do require a bump because the serialized enums have no catch-all `Unknown` variants.
286+
287+
Internal IR types may change freely without bumping the summary version, as long as the `summary.rs` lowering keeps the existing field set populated correctly.
288+
289+
### Top-level shape
290+
291+
```jsonc
292+
{
293+
"schema_version": 1,
294+
"name": "<pipeline name>", // ADO build-number format string
295+
"shape": "standalone" | "1es" | "job-template" | "stage-template",
296+
"body": { "kind": "jobs", "jobs": [...] },
297+
// OR
298+
{ "kind": "stages", "stages": [...] },
299+
"graph": { ... } // see GraphSummary below
300+
}
301+
```
302+
303+
The `body` discriminant (`kind`) mirrors `PipelineBody`: flat pipelines (`standalone`, `job-template`) use `"jobs"`, stage-wrapped pipelines (`1es`, `stage-template`) use `"stages"`.
304+
305+
### `JobSummary`
306+
307+
Each entry in `body.jobs` (or inside a stage's `jobs` array):
308+
309+
| Field | Type | Description |
310+
|-------|------|-------------|
311+
| `id` | string | ADO job identifier (`name:` in YAML) |
312+
| `stage` | string or null | Stage id this job belongs to; `null` for flat (non-stage) pipelines |
313+
| `display_name` | string | Human-readable `displayName:` |
314+
| `depends_on` | string[] | `dependsOn:` entries — both explicitly declared and graph-derived |
315+
| `condition` | string or null | Lowered ADO condition expression, e.g. `"succeeded()"` |
316+
| `pool` | object | Pool summary — see `PoolSummary` below |
317+
| `steps` | object[] | Ordered list of step summaries — see `StepSummary` below |
318+
319+
`PoolSummary` has one of two shapes depending on pool type:
320+
321+
```jsonc
322+
// Microsoft-hosted
323+
{ "kind": "vm_image", "image": "ubuntu-22.04" }
324+
325+
// Self-hosted or 1ES
326+
{ "kind": "named", "name": "MyPool", "image": null, "os": "linux" }
327+
```
328+
329+
### `StepSummary`
330+
331+
Each entry in `job.steps`:
332+
333+
| Field | Type | Description |
334+
|-------|------|-------------|
335+
| `id` | string or null | ADO step `name:` — present when other steps read this step's outputs |
336+
| `kind` | string | Step variant: `"bash"`, `"task"`, `"checkout"`, `"download"`, `"publish"`, `"raw_yaml"` |
337+
| `display_name` | string or null | Human-readable `displayName:` |
338+
| `task` | string or null | For `task` steps only: ADO task identifier, e.g. `"UseNode@1"` |
339+
| `condition` | string or null | Lowered ADO condition expression |
340+
| `outputs` | object[] | Output variables declared by this step |
341+
| `env_refs` | object[] | Other steps' outputs read via this step's `env:` block |
342+
| `condition_refs` | object[] | Other steps' outputs read via this step's `condition:` |
343+
344+
Each entry in `outputs`:
345+
346+
```jsonc
347+
{
348+
"name": "AW_SYNTHETIC_PR_ID", // ##vso[task.setvariable variable=...] name
349+
"is_secret": false, // true → value is masked in logs
350+
"auto_is_output": true // true → at least one cross-step consumer → emit isOutput=true
351+
}
352+
```
353+
354+
Each entry in `env_refs` / `condition_refs`:
355+
356+
```jsonc
357+
{ "step": "synthPr", "name": "AW_SYNTHETIC_PR_ID" }
358+
```
359+
360+
### `GraphSummary`
361+
362+
The `graph` field is a JSON-friendly view of the typed `Graph` built during lowering:
363+
364+
| Field | Type | Description |
365+
|-------|------|-------------|
366+
| `step_locations` | object[] | Every named step with its job/stage location and declared outputs |
367+
| `job_edges` | object[] | Derived job-level `dependsOn` edges |
368+
| `stage_edges` | object[] | Derived stage-level `dependsOn` edges |
369+
| `outputs_needing_is_output` | object[] | Producer steps whose outputs are read cross-step (need `isOutput=true`) |
370+
371+
Each `job_edges` / `stage_edges` entry:
372+
373+
```jsonc
374+
{ "consumer": "Agent", "producer": "Setup" }
375+
// means: Agent dependsOn Setup
376+
```
377+
378+
Each `step_locations` entry:
379+
380+
```jsonc
381+
{ "step": "synthPr", "stage": null, "job": "Setup", "outputs": ["AW_SYNTHETIC_PR_ID"] }
382+
```
383+
384+
Each `outputs_needing_is_output` entry:
385+
386+
```jsonc
387+
{ "step": "synthPr", "outputs": ["AW_SYNTHETIC_PR_ID"] }
388+
```
389+
390+
### Example: inspect output
391+
392+
Running `ado-aw inspect examples/sample-agent.md --json` for a simple PR-triggered pipeline returns a summary like:
393+
394+
```jsonc
395+
{
396+
"schema_version": 1,
397+
"name": "sample-agent",
398+
"shape": "standalone",
399+
"body": {
400+
"kind": "jobs",
401+
"jobs": [
402+
{ "id": "Setup", "stage": null, "depends_on": [], ... },
403+
{ "id": "Agent", "stage": null, "depends_on": ["Setup"], ... },
404+
{ "id": "Detection", "stage": null, "depends_on": ["Agent"], ... },
405+
{ "id": "SafeOutputs", "stage": null, "depends_on": ["Detection"], ... },
406+
{ "id": "Teardown", "stage": null, "depends_on": ["SafeOutputs"], ... }
407+
]
408+
},
409+
"graph": {
410+
"job_edges": [
411+
{ "consumer": "Agent", "producer": "Setup" },
412+
{ "consumer": "Detection", "producer": "Agent" },
413+
{ "consumer": "SafeOutputs", "producer": "Detection" },
414+
{ "consumer": "Teardown", "producer": "SafeOutputs" }
415+
],
416+
...
417+
}
418+
}
419+
```
420+
421+
The five jobs reflect the canonical Setup → Agent → Detection → SafeOutputs → Teardown shape for every compiled pipeline.

0 commit comments

Comments
 (0)