← Back to Pull requests

A packaged workflow can name a shared output schema #6479

Open
unknown opened this pull request with 638 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:55 UTC
Author

Problem and outcome

Once a workflow is split into blocks, steps that share a schema are in different files. Archon had no way to share a schema across files: anchors work in one file only, $ref is refused, and with: can't carry a schema. So each block kept its own copy of every schema it shared.

  • Outcome: in a packaged workflow, output_format: <name> uses the pack's .shared/schemas/<name>.yaml. Archon puts the schema in place of the name when it loads the workflow, so running, type generation, validation and Codex strict mode all see an ordinary inline schema.

  • Invariant: a step never carries a schema name at run time.

  • Scope boundary: inline and anchored schemas don't change. The Web UI builder doesn't handle names. Without a pack it gets the error named schemas need a packaged workflow, so it refuses to open such a workflow instead of rewriting it.
  • Review guidance

  • Feedback requested: how schema read errors are scoped (one broken schema should fail only the workflows that name it), and finding schemas in source, bundled and captured packs.

  • Start here: packages/workflows/src/pack-schemas.ts, which reads a pack's schema folder and looks up names.

  • Review order: pack-schemas.ts → loader/yaml.ts and loader.ts (where names are replaced) → workflow-discovery/load-dir.ts and scopes.ts → defaults/bundle-inventory.ts and run-source.ts (the compiled binary and captured run sources) → output-types.ts (types for a single file).

  • Lower-attention areas: the reference doc and the row added to .archon/workflow-language-constitution.md.

  • Known risk or uncertainty: an unreadable schema shipped with a source install stops archon workflow list, the same as any other unreadable file shipped with a source install. In project and home packs, the error goes on each workflow that names the schema.
  • Solution

    Each packaged workflow loads with its pack's schemas. A string output_format is looked up there, and each step gets its own copy, so two steps that name one schema never share an object. A missing file, a file that isn't a mapping, a .yml-only file or a name with a path fails that workflow's load, and the error gives the schema's path. A broken file that no workflow names is a warning. The compiled binary carries .shared/schemas/, so it finds the same names. archon workflow types on one file finds that file's pack, even through a symlinked pack folder.

    Behavior change

    | | Before | After |
    |---|---|---|
    | Observable behavior | output_format had to be an inline mapping. | A packaged workflow can name a shared schema instead. |
    | Failure behavior | A string output_format failed schema validation. | A bad name fails that workflow's load with the schema's path. Outside a pack, the error says named schemas need a packaged workflow. |

    Validation

    On upstream dev at fdc50f6, without the other two changes:

  • CI passes on this branch in a fork, including the Windows suites and the pack tests: https://github.com/Codagent-AI/Archon/actions/runs/46223701396

  • pack-schemas.test.ts covers lookup, every load error, and keeping a pack's read errors to the workflows that name the broken schema. output-types.test.ts covers types for a single file, a symlinked pack folder and duplicate file names in one pack. Other tests cover the compiled binary and a captured run source.

  • Real use: the same code, merged in a fork, let our pack replace its anchored copies with 10 shared schemas, 9 of them used in more than one file. archon validate workflows accepts every workflow, and the pack's 79 workflow fixtures pass.
  • This doesn't depend on the changes for #6475 or #6477: each of the three applies to dev on its own. Where two add tests or doc lines in the same place, whichever merges second needs a small rebase.

    Closes #6476

    Size

    Counted with cloc --git --diff fdc50f6 7b57f59 (merge base to the PR head). Blank lines left out.

    | Language | Files | Code added | Code modified | Code removed | Comments added | Comments removed |
    | --- | ---: | ---: | ---: | ---: | ---: | ---: |
    | TypeScript | 17 | 930 | 62 | 29 | 14 | 7 |
    | Markdown | 2 | 9 | 2 | 0 | 0 | 0 |
    | Total | 19 | 939 | 64 | 29 | 14 | 7 |

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Named output schemas can now be stored in a workflow pack’s shared schemas directory and referenced by name. They support the same structured-output validation and type generation as inline schemas.
    Workflow runs capture shared schemas with their source, preserving the original schema when a run is resumed.
    Bug Fixes
    Invalid or unreadable schemas now produce workflow discovery errors or warnings, while unrelated workflows and scripts can still be discovered.
    Documentation
    * Updated the workflow language reference with named schema setup, usage, and limitations.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 638 lines (+478 / -160) across 7 files Reviewer: coderabbitai[bot] Review duration: 10m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.50) × (1 − Review Confidence (0.34)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 638 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 62% · Reviewer familiarity: 35%
    33%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.386
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6479"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 33.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.4% (MEDIUM) · Higher = larger blast radius
    50.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 33.7% · Lower = rushed or shallow review
    33.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 33.5% · Safe to merge
    33.5%