Skip to content

M1 PR-6: pipeline orchestrator, bounded repair loop, audit report v1#4

Merged
ryandmonk merged 2 commits into
feat/adaptersfrom
feat/pipeline
Jul 2, 2026
Merged

M1 PR-6: pipeline orchestrator, bounded repair loop, audit report v1#4
ryandmonk merged 2 commits into
feat/adaptersfrom
feat/pipeline

Conversation

@ryandmonk

Copy link
Copy Markdown
Contributor

What this is

PR-6 of Milestone 1 (stacked on #3). The orchestrator: generate → S1–S3 → bounded repair (default 2; ADR-7) → emit via the pinned git dependency @aestheticfunction/dspack-to-a2ui#e68a17e → A1–A3 (both A2UI versions) → audit report v1.

  • Every outcome is a first-class artifact: passed / failed-lint-exhausted (exit 2) / failed-gate (exit 3) / failed-adapter (exit 1 — added to the plan's enum because the S0 spike showed runtimes can silently fail to constrain; documented in docs/AUDIT.md).
  • ADR-7 exactly: the system prompt is byte-identical across attempts (asserted); the only conversation delta is the model's own output + the repair message, which is rendered deterministically from the same findings object embedded in the report — one object, two serializations. Linked examples ride along verbatim as corrected references.
  • Audit report v1 (schemas/audit-report.v1.schema.json + docs/AUDIT.md): additive-only guarantee, stable enums, reproducibility fields (contract sha256, schema sha256, adapter id, per-attempt model + provider meta), honesty fields (ruleSteering, emitter warnings). Markdown rendering is a derived view.
  • CLI run writes audit-report.json/.md + the emitted surface; ScriptedAdapter (src/adapters/fake.ts) is the deterministic instrument for CI/demo/evals.

Live runs during development (local out*/, not committed): one local 8B-class model violated S3 on attempt 1, repaired 5 findings → 1, exhausted honestly; a ~20B model passed everything first attempt. Model-quality claims stay out of docs pending the PR-10 eval matrix.

Acceptance (in CI on this PR)

npm test   # scripted-adapter pipeline tests: repair path (repair message == checked-in golden;
           # required-composition VERIFIED on attempt 2; A1–A3 pass both versions; report
           # validates against its schema), exhaustion path, emitter-gate-failure path (A3 FAIL),
           # adapter-failure path — all deterministic/offline

Hand-review focus

schemas/audit-report.v1.schema.json + docs/AUDIT.md (the enterprise-facing artifact contract — on your queue) and the RunOptions/RunResult surface in src/run/orchestrator.ts.

ADRs: 4, 5, 7, 8, 9, 11.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Milestone 1’s full pipeline orchestrator (generation → S1–S3 → bounded repair loop → A2UI emission + A1–A3 validation) and introduces Audit Report v1 as a first-class, versioned artifact, with deterministic CI coverage via a scripted adapter.

Changes:

  • Implement runPipeline orchestrator with bounded repair loop and emission/validation through pinned @aestheticfunction/dspack-to-a2ui.
  • Add Audit Report v1 types + Markdown renderer and a v1 JSON schema contract (+ AUDIT stability documentation).
  • Add deterministic end-to-end pipeline tests via ScriptedAdapter and golden repair-message fixtures; extend CLI with run.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/run/pipeline.test.ts Deterministic acceptance tests covering pass, repair, exhaustion, gate-failure, and adapter-failure trails.
src/run/orchestrator.ts Core pipeline orchestration with bounded repair loop and A2UI emission + validation.
src/repair/render.ts Deterministic repair-message rendering from lint findings (ADR-7).
src/index.ts Public exports expanded to include adapters, orchestrator, repair rendering, and audit reporting.
src/cli.ts Adds run command that writes audit report outputs and exits with orchestrator exit codes.
src/audit/report.ts Audit Report v1 types, hashing helpers, and Markdown rendering of the JSON artifact.
src/adapters/fake.ts Scripted deterministic adapter used for offline/CI and golden trails.
schemas/audit-report.v1.schema.json JSON Schema contract for audit report v1 (consumer-facing stability surface).
package.json Adds pinned GitHub dependency for @aestheticfunction/dspack-to-a2ui.
package-lock.json Lockfile updates for the pinned emitter dependency.
fixtures/golden/repair/F1.repair.txt Golden repair prompt text used to assert deterministic ADR-7 rendering.
docs/AUDIT.md Documents audit report v1 guarantees (additive-only, stable enums, reproducibility/honesty fields).
.gitignore Ignores out* directories produced by local runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.ts
Comment on lines +139 to +142
if (command === "run") {
void commandRun(flags);
return;
}
Comment thread src/cli.ts
Comment on lines +98 to +109
try {
result = await runPipeline({
contract,
intent,
prompt,
adapter: adapterFor(modelRef),
maxRepairs: flags.has("max-repairs") ? Number(flags.get("max-repairs")) : undefined,
compile: {
depth: flags.has("depth") ? Number(flags.get("depth")) : undefined,
omitRuleSteering: flags.get("no-steering") === "true",
},
});
Comment thread src/cli.ts
Comment on lines +123 to +127
writeFileSync(join(resolve(outDir), "audit-report.json"), JSON.stringify(result.report, null, 2) + "\n");
writeFileSync(join(resolve(outDir), "audit-report.md"), renderMarkdown(result.report));
if (result.surfaceMessages) {
writeFileSync(join(resolve(outDir), "generated.surface.json"), JSON.stringify(result.surfaceMessages, null, 2) + "\n");
}
Comment thread src/run/orchestrator.ts
Comment on lines +65 to +68
const { contract, intent, prompt, adapter } = options;
const maxRepairs = options.maxRepairs ?? 2;
const now = options.now ?? (() => new Date());
const startedAt = now();
Comment thread src/run/orchestrator.ts
Comment on lines +146 to +149
if (index < maxRepairs) {
const repair = renderRepairMessage(lint.findings, contract);
repairMessages.push(repair);
conversation.push({ role: "assistant", content: generated.raw }, { role: "user", content: repair });
Comment on lines +94 to +100
"emitted": {
"type": "object",
"required": ["target", "validations"],
"properties": {
"target": { "const": "a2ui" },
"surfaceMessages": {},
"warnings": {
ryandmonk and others added 2 commits July 2, 2026 17:01
… PR-6)

- src/run/orchestrator.ts: generate → surface gates S1-S3 → bounded repair
  (default 2; system prompt immutable across attempts — the only delta is the
  model's own output + rendered repair feedback, snapshot per attempt) →
  emit via the pinned @aestheticfunction/dspack-to-a2ui git dependency →
  emitter gates A1-A3 (both A2UI versions) → audit report v1. Every outcome
  is a first-class artifact: passed / failed-lint-exhausted (exit 2) /
  failed-gate (exit 3) / failed-adapter (exit 1; added to the plan's enum —
  the S0 spike showed runtimes can fail to constrain, and that must be a
  reported outcome, never a silent retry).
- src/repair/render.ts (ADR-7): one findings object, two serializations —
  the repair message is rendered deterministically from the same findings
  embedded in the report, with linked examples verbatim as corrected
  references. Golden-file tested.
- src/audit/: report v1 + schemas/audit-report.v1.schema.json + markdown
  rendering + docs/AUDIT.md (additive-only guarantee, stable enums,
  reproducibility fields: contract sha256, schema sha256, adapter id,
  per-attempt model + provider meta).
- src/adapters/fake.ts: ScriptedAdapter — the deterministic instrument for
  CI, the demo's verification mode, and eval goldens.
- CLI `run` writes audit-report.json/.md + generated.surface.json; exit
  codes per the README table.

Live verification (recorded in out/ locally, not committed): qwen3:8b
violates S3 on attempt 1 (5 findings), repairs to 1, exhausts honestly
(failed-lint-exhausted); gpt-oss 20B passes S1-S3 + A1-A3 on attempt 1.

Verify: npm test (52 tests, offline/deterministic); npx tsx src/cli.ts run
--dspack fixtures/shadcn.v0_3.dspack.json --intent destructive-action
--prompt "a screen to delete my account" --model ollama:<tag> --out out

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ryandmonk added a commit that referenced this pull request Jul 2, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ryandmonk ryandmonk merged commit 551eb41 into feat/adapters Jul 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants