Skip to content

Add durable implementation session provenance - #2065

Merged
bradygaster merged 5 commits into
devfrom
bradygaster-session-provenance-producer
Sep 21, 2026
Merged

bradygaster merged 5 commits into
devfrom
bradygaster-session-provenance-producer

Conversation

@bradygaster

@bradygaster bradygaster commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the authoritative Squad producer contract required by bradygaster/squadcaster#44.

  • introduces versioned implementation-provenance/v1 JSON Schema and runtime validator
  • binds repository, origin issue, opaque implementation session, dispatcher run, worker run/attempt, actual PR number, explicit goals, and verified replacement PRs
  • mints one session ID per authoritative dispatcher scheduling wave and rejects direct worker identity fabrication
  • uses a validated two-phase path: the agent emits a typed record referencing the PR temporary ID, then a handler resolves the created PR, validates live GitHub evidence, and writes the durable bot-authored provenance comment with the actual PR number
  • loads guard code from immutable github.workflow_sha, eliminating mutable-default-branch validator TOCTOU
  • preserves the existing <!-- squad:implement issue=... run=... --> marker and closing references unchanged
  • documents lifetime, retry/rerun, replacement, multi-PR, multi-goal, cache/stale/malformed/partial, and migration semantics
  • adds positive, negative, worker-path, compiled-runtime, install-closure, and realistic mutation coverage

Validation

  • npm run build
  • npm test -- --run test/gh-aw-implementation-provenance.test.ts test/gh-aw-implement-workflow.test.ts test/gh-aw-deps-routing.test.ts test/gh-aw-retro-workflow.test.ts test/gh-aw-quality.test.ts — 493 passed
  • full-suite run by the revision owner — 9,111 passed; the dependency-worker CHANGELOG.md catalog assertion was reproduced unchanged on base commit 2099faf5
  • ESLint, TypeScript typecheck, and docs lint pass
  • strict gh-aw compilation and emitted-artifact inspection pass for the dispatcher, implementation worker, dependency worker, and retrospective
  • authored source remains within budget at 198,587 / 198,656 bytes; existing ambient prompt 40 KB guard passes

Security review

The pre-agent and safe-output validators are loaded from an immutable checkout pinned to github.workflow_sha, with persisted credentials disabled. Worker identity is corroborated against the authoritative dispatcher Actions run and durable bot dispatch receipt. The post-create handler resolves the safe-output temporary-ID map, fetches the created PR, validates the actual repository/number/head ref, verifies replacement PR provenance through the GitHub API, and only then writes the bot-authored durable payload.

No new permissions, secrets, dependencies, or unpinned actions are introduced. The new guard uses only the existing pinned actions/checkout and actions/github-script actions.

Compatibility

Older PRs are not rewritten. Missing v1 evidence leaves the implementation session unknown; consumers may continue using legacy explicit markers and closing references without manufacturing a session ID. Malformed, partial, duplicated, fabricated, or stale evidence is never silently upgraded to authoritative v1 provenance.

Scope

Infrastructure/workflow contract only; no CLI or SDK public API change. No package changeset is included.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 21, 2026 21:58
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #2065

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 14
Files added 5
Files modified 9
Files deleted 0
Modules touched 3

🎯 Risk Factors

  • 14 files changed (6-20 → MEDIUM)
  • 3 modules touched (2-4 → MEDIUM)

📦 Modules Affected

docs (1 file)
  • docs/src/content/docs/guide/gh-aw.md
root (9 files)
  • test-fixtures/implementation-provenance/multi-goal-replacement-v1.json
  • test-fixtures/implementation-provenance/valid-v1.json
  • workflows/shared/implementation-provenance-v1.schema.json
  • workflows/shared/squad-implementation-provenance.mjs
  • workflows/shared/squad-retro-provenance.mjs
  • workflows/squad-deps-worker.md
  • workflows/squad-implement-worker.md
  • workflows/squad-retro.md
  • workflows/squad.md
tests (4 files)
  • test/gh-aw-implement-workflow.test.ts
  • test/gh-aw-implementation-provenance.test.ts
  • test/gh-aw-quality.test.ts
  • test/gh-aw-retro-workflow.test.ts

This report is generated automatically for every PR. See #733 for details.

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 1ae9eeb

PR Scope: 🔧 Infrastructure

⚠️ 2 item(s) to address before review

Status Check Details
❌ Single commit 5 commits — consider squashing before review
✅ Not in draft Ready for review
✅ Branch up to date Up to date with dev
❌ Copilot review No Copilot review yet — it may still be processing
✅ Changeset present No source files changed — changeset not required
✅ Scope clean No .squad/ or docs/proposals/ files
✅ No merge conflicts No merge conflicts
✅ Copilot threads resolved 1 active Copilot thread(s) resolved (2 outdated skipped)
✅ CI passing All checks passing

Files Changed (14 files, +2066 −76)

File +/−
docs/src/content/docs/guide/gh-aw.md +74 −1
test-fixtures/implementation-provenance/multi-goal-replacement-v1.json +44 −0
test-fixtures/implementation-provenance/valid-v1.json +34 −0
test/gh-aw-implement-workflow.test.ts +7 −7
test/gh-aw-implementation-provenance.test.ts +637 −0
test/gh-aw-quality.test.ts +12 −6
test/gh-aw-retro-workflow.test.ts +17 −7
workflows/shared/implementation-provenance-v1.schema.json +120 −0
workflows/shared/squad-implementation-provenance.mjs +750 −0
workflows/shared/squad-retro-provenance.mjs +35 −3
workflows/squad-deps-worker.md +151 −0
workflows/squad-implement-worker.md +139 −10
workflows/squad-retro.md +17 −14
workflows/squad.md +29 −28

Total: +2066 −76


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical mutable-ref trust issues and schema-validation gaps remain, along with an inappropriate package changeset.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds durable implementation-session provenance across Squad workflows, validation, schemas, tests, fixtures, and documentation.

Changes:

  • Propagates session IDs through implementation, dependency, and retrospective workflows.
  • Adds provenance schema, runtime guards, fixtures, and contract tests.
  • Documents provenance lifecycle and migration semantics.
File Summary
workflows/​squad.md Adds session IDs to implementation dispatches.
workflows/​squad-retro.md Propagates retrospective session IDs.
workflows/​squad-implement-worker.md Validates and emits implementation provenance.
workflows/​squad-deps-worker.md Adds dependency-worker provenance enforcement.
workflows/​shared/​squad-retro-provenance.mjs Updates retrospective input validation.
workflows/​shared/​squad-implementation-provenance.mjs Implements provenance parsing and validation.
workflows/​shared/​implementation-provenance-v1.schema.json Defines the v1 provenance schema.
test/​gh-aw-retro-workflow.test.ts Updates retrospective workflow coverage.
test/​gh-aw-implementation-provenance.test.ts Tests provenance behavior and wiring.
test-fixtures/​implementation-provenance/​valid-v1.json Adds a valid provenance fixture.
test-fixtures/​implementation-provenance/​multi-goal-replacement-v1.json Adds multi-goal and replacement coverage.
docs/​src/​content/​docs/​guide/​gh-aw.md Documents provenance semantics.
.changeset/​implementation-session-provenance.md Records package release metadata.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread workflows/squad-deps-worker.md Resolved
Comment thread workflows/squad-implement-worker.md Resolved

@bradygaster bradygaster left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Blocking authoritative-producer review for Squadcaster issue #44. I cannot use GitHub’s REQUEST_CHANGES state on my own PR, so treat this COMMENT review as blocking. The provenance contract is not yet safe to consume: unresolved self PR identity can reach durable output, dispatcher/runtime identity is not bound strongly enough, trusted validation code is loaded from a mutable default branch, replacement evidence is under-validated, negative/worker-path coverage is incomplete, and release metadata is incorrect. CI also fails the clean-install runtime closure and authored-source growth guards. Please address every inline finding and restore all required checks before rereview.

Comment thread workflows/squad-implement-worker.md Resolved
bradygaster and others added 3 commits September 21, 2026 15:17
Closes #2065

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Closes #2065

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #2065

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@bradygaster bradygaster left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Final exact-head rereview remains blocking. GitHub does not allow REQUEST_CHANGES on my own PR, so treat this COMMENT review as a blocking verdict. The temporary-PR provenance guard checks a field that the compiled add_comment output does not use.

function provenanceCommentsForPull(items, pull) {
const id = normalizeTemporaryId(pull.temporary_id);
return items.filter(item => item.type === 'add_comment' &&
normalizeTemporaryId(item.temporary_id) === id &&

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Blocking: Compiled add_comment safe outputs target the temporary PR with item_number, but this boundary filters on item.temporary_id. A malformed provenance-like comment using the production shape (item_number: "#aw_impl42") is therefore not selected for validation, returns ok: true, and can cross both worker guards into a bot-authored durable comment. Match the compiled field (item_number) and update the adversarial tests to use the real output shape; prove malformed/partial/unknown/duplicate/mixed candidates fail closed in both compiled worker handlers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@bradygaster
bradygaster merged commit fa739bd into dev Sep 21, 2026
18 checks 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