Skip to content

Support multiple work-queue claims and claim-scoped safe outputs - #65682

Closed
pelikhan with Copilot wants to merge 5 commits into
mainfrom
copilot/update-work-queue-api-support-multiple-claims
Closed

pelikhan with Copilot wants to merge 5 commits into
mainfrom
copilot/update-work-queue-api-support-multiple-claims

Conversation

Copilot AI commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Workers can receive multiple claims in aw_context, but the existing finish and safe-output flow assumes one claim. This change supports partial completion without applying outputs for unfinished claims.

  • Claim lifecycle: Accept a single assignment or an array. Array assignments require a finish intent for every claim_id; a missing intent cancels the batch and blocks safe outputs.
  • Safe outputs: Tool calls may include claim_id. Tagged outputs apply only after that claim’s completion is verified. Untagged outputs and custom steps/actions require every claim to complete.
  • Compatibility: Preserve single-claim behavior and update worker prompts, documentation, and coverage.

Copilot AI and others added 2 commits October 4, 2026 23:24
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Support multi-claim work-queue workers and claim-scoped safe outputs Support multiple work-queue claims and claim-scoped safe outputs Oct 4, 2026
Copilot AI requested a review from pelikhan October 4, 2026 23:39
@pelikhan
pelikhan marked this pull request as ready for review October 5, 2026 04:04
Copilot AI balanced review requested due to automatic review settings October 5, 2026 04:04

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

Some side-effect jobs bypass claim reconciliation, and an existing integration assertion is now stale.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Adds multi-claim work-queue reconciliation and claim-scoped safe-output processing while retaining single-claim compatibility.

Changes:

  • Accepts and validates arrays of worker assignments and finish intents.
  • Filters safe outputs by successfully completed claims.
  • Updates compiler gating, prompts, documentation, and tests.
File Description
pkg/​workflow/​compiler_safe_outputs_job.go Adds all-claim gating for custom effects.
pkg/​workflow/​compiler_safe_outputs_job_test.go Tests partial-claim step gating.
actions/​setup/​js/​write_work_queue_snapshot.cjs Admits multiple effective assignments.
actions/​setup/​js/​write_work_queue_snapshot.test.cjs Tests batch assignment validation.
actions/​setup/​js/​work_queue_summary.cjs Summarizes every assigned claim.
actions/​setup/​js/​work_queue_mcp_server.cjs Adds per-claim finish intents.
actions/​setup/​js/​work_queue_mcp_server.test.cjs Tests batch finish handling.
actions/​setup/​js/​generate_safe_outputs_tools.cjs Adds optional claim identifiers to tools.
actions/​setup/​js/​generate_safe_outputs_tools.test.cjs Tests claim-aware tool schemas.
actions/​setup/​js/​finish_work_queue_claim.cjs Reconciles batches and filters outputs.
actions/​setup/​js/​finish_work_queue_claim.test.cjs Covers partial and incomplete batches.
actions/​setup/​js/​create_prompt.cjs Instructs workers about multiple claims.
actions/​setup/​js/​collect_ndjson_output.cjs Preserves validated claim identifiers.
actions/​setup/​js/​aw_context.cjs Parses single or array assignments.
.github/​workflows/​smoke-work-queue.lock.yml Regenerates the all-claims gate.
.github/​aw/​work-queue.md Documents multi-claim behavior.

const completed = new Set(workers.filter((_, index) => results[index].authorized).map(item => item.claim_id));
const allCompleted = completed.size === workers.length;
const authorized = completeBatch && completed.size > 0;
if (authorized) filterClaimOutputs(completed, allCompleted, options.agentOutputPath || `${TMP_GH_AW_PATH}/${AGENT_OUTPUT_FILENAME}`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f9a913a. Both downstream jobs now depend on safe_outputs and consume its filtered reconciliation artifact with no fallback to the original artifact. Asset uploads require claim authorization and reconciled output types; custom jobs additionally require all claims completed. Added partial/cancelled/completed batch tests and downstream compilation coverage. Focused queue integration, full workflow-package unit tests, and 68 JavaScript tests pass.

}
if isWorkQueueEnabled(data) {
typedStep.If = combineGitHubIfExpressions(workQueueClaimAuthorizedExpression, typedStep.If)
typedStep.If = combineGitHubIfExpressions("steps.work_queue_claim_reconciliation.outputs.all_authorized == 'true'", typedStep.If)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f9a913a: the user-step assertion now expects all_authorized, while ordinary handler assertions retain authorized. The queue compilation integration check passes locally.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/finish_work_queue_claim.cjs:190): Filtering this job's local agent_output.json does not protect side-effect jobs that consume the original agent artifact. upload_assets is gated directly from needs.agent.outputs.output_types and depends on agent/activation (pkg/workflow/publish_assets.go:186-229), while custom safe jobs also depend on agent and download that unfiltered artifact (pkg/workflow/safe_jobs.go:335-414). Consequently, a missing/cancelled claim can still trigger these outputs (and untagged outputs can run during partial completion), bypassing the new reconciliation gate. Make every such job depend on r... - Support multiple work-queue claims and claim-scoped safe outputs #65682 (comment)
  3. Review (pkg/workflow/compiler_safe_outputs_job.go:329): This changes user-provided steps to all_authorized, but TestWorkQueueCompilationPhases still requires the old outputs.authorized expression inside the user-step block (pkg/workflow/work_queue_compilation_integration_test.go:60-78). The integration suite will therefore fail for this intentional behavior change; update that assertion to expect outputs.all_authorized. - Support multiple work-queue claims and claim-scoped safe outputs #65682 (comment)
  4. Fix failing check Compile queue phases (FAILURE): https://github.com/github/gh-aw/actions/runs/37244517597/job/111610812336.
  5. Fix failing check impacted-go-tests (FAILURE): https://github.com/github/gh-aw/actions/runs/37244517712/job/111610886449.

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 128ee74
Sous-chef work: 1dcac6c4a72c1e9d2aa3c06d7b8bc0f55bbc03f204de26c5e88482aaab84b6f4 42e5d572d9d75b7168fe7d0aeda0717cc07e65ed240f6d299e6fec661214f1ac 57b160f058c0cf0ae8470606e768b98956d9e31df7d52cc35017efdeeaeffab1 8b1d0a9c7eb61f9904830caab0f89fed10be3caf4e6f080431ebf2d48580e274
Sous-chef state: f7cd44559e0f9fe51710d337806ae2b6a1dd40a2f89ae480eec6d094210fb6d3

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · 3.82 AIC · ⌖ 8.31 AIC · ⊞ 3.2K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits October 5, 2026 04:48
…ueue-api-support-multiple-claims

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🔎 PR Code Quality Reviewer is reviewing code quality for this pull request...

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #65682

Copilot AI commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Merged latest main using make merge-main (ded4e71) and pushed fixes in f9a913a. Closed the downstream artifact/authorization bypass, updated the integration assertion, fixed expression-valued concurrency queue schema validation, and corrected batch completion attempt collisions. Full workflow-package tests, queue integration, 68 JS tests, make lint, secret scanning, and 320-workflow drift validation pass. The progress gate still reports four pre-existing custom-linter findings in publish_assets.go. Replied to both review threads; thread resolution is unavailable with the authenticated tools here. Final automated review was unavailable and CodeQL timed out. CI on the new HEAD remains unverified; no CI was triggered.

Copilot AI requested a review from gh-aw-bot October 5, 2026 05:11
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-05T05:08:59Z
review_event: REQUEST_CHANGES
submission_status: failed-to-submit-permission-denied
top_themes:
  - claim_id is exposed on unassigned work-queue runs
  - unknown claim_id values pass ingestion and are dropped later
files_reviewed:
  - actions/setup/js/aw_context.cjs
  - actions/setup/js/collect_ndjson_output.cjs
  - actions/setup/js/create_prompt.cjs
  - actions/setup/js/finish_work_queue_claim.cjs
  - actions/setup/js/generate_safe_outputs_tools.cjs
  - actions/setup/js/work_queue_mcp_server.cjs
  - actions/setup/js/work_queue_summary.cjs
  - actions/setup/js/write_work_queue_snapshot.cjs
  - pkg/workflow/compiler_safe_outputs_job.go
comment_count: 2

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 81 AIC · ⌖ 7.3 AIC · ⊞ 19.4K · ◷
Comment /review to run again

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Reviewed with /codebase-design and /tdd. Note: the pre-fetched diff (commit 128ee74) is one commit behind the current HEAD (f9a913a, "Reconcile downstream queue effects and fix compilation checks"). I verified the current checkout state directly instead.

Finding: both prior Copilot review comments on this PR are already resolved in f9a913a:

  • Claim-filtered agent_output.json is now consumed correctly by downstream jobs — upload_assets and safe-outputs.jobs now depend on safe_outputs and download the reconciled artifact (workQueueReconciledArtifactName) instead of the raw agent artifact, with ContinueOnError disabled for the fallback (pkg/workflow/safe_jobs.go, pkg/workflow/publish_assets.go, pkg/workflow/safe_outputs_steps.go).
  • TestWorkQueueCompilationPhases now asserts all_authorized for the user-step block and adds coverage for upload_assets/deploy gating on work_queue_output_types/work_queue_all_authorized.

I additionally confirmed reconcileWorkerClaim now derives a per-claim attempt identity (`${attempt}/claim/${encodeURIComponent(item.claim_id)}`) for multi-claim batches, which avoids Completion-transaction collisions when several claims are reconciled in the same workflow attempt — a correctness detail worth calling out as a strength.

📋 Verification performed
  • go build ./... — passes
  • go test ./pkg/workflow/... -run TestGateSafeOutputStepsForPartialWorkQueueClaims — passes
  • go test -tags integration ./pkg/workflow/... -run TestWorkQueueCompilationPhases — passes
  • go vet ./pkg/workflow/... — clean
  • JS vitest suites could not run locally (no network access for vitest install), but manual inspection of finish_work_queue_claim.test.cjs, work_queue_mcp_server.test.cjs, and write_work_queue_snapshot.test.cjs shows solid coverage of the new batch/array-claim paths (duplicate claim rejection, conflicting finish intents, per-claim filtering of agent_output.json, and claim_id schema injection into safe-output tool schemas).
✅ Positive highlights
  • Backward compatibility is preserved cleanly: single-claim behavior is unchanged (multiple branch is opt-in based on Array.isArray).
  • The "all-or-nothing" semantics for an omitted finish intent (cancelling the entire batch) is a sound, conservative security default and is clearly documented in work-queue.md and in-code comments.
  • Good symmetry between validWorker duplication in finish_work_queue_claim.cjs and work_queue_mcp_server.cjs — consider extracting to a shared helper in a follow-up to avoid drift, but not blocking.

No blocking issues found in the current HEAD state.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 82.7 AIC · ⌖ 14.4 AIC · ⊞ 10K
Comment /matt to run again

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR adds 158 lines across business-logic directories (threshold: 100) and no existing ADR covers it, so ADR enforcement applies. I generated a draft ADR and pushed it to this branch.

Draft ADR: docs/adr/65682-claim-scoped-safe-outputs-for-batch-work-queue-claims.md (status: Draft)

Decision captured: accept an array of work-queue assignments in aw_context.work_queue and make safe outputs claim-scoped — outputs tagged with claim_id apply only once that claim's completion is verified; untagged outputs and custom steps/jobs require all claims to complete; a missing finish intent cancels the whole batch.

Evidence used
  • actions/setup/js/aw_context.cjs — readWorkQueueAssignment now accepts an array, rejecting duplicate claim_id/work_id.
  • actions/setup/js/finish_work_queue_claim.cjs (+96/−28) — per-claim reconciliation, claim-scoped attempt identity <attempt>/claim/<claim_id>, new partial status, filterClaimOutputs rewrite of agent_output.json, new all_authorized / output_types outputs.
  • actions/setup/js/work_queue_mcp_server.cjs — work_queue_claim_finish requires claim_id for batches and validates it against the trusted snapshot.
  • actions/setup/js/generate_safe_outputs_tools.cjs / collect_ndjson_output.cjs — optional claim_id on every safe-output tool, validated only when a work-queue snapshot exists.
  • .github/workflows/*.lock.yml — smoke test gate switched from authorized to all_authorized.
⚠️ Conflict with an existing ADR

ADR-64955 (Git-Backed Work Queue Coordination) states in its Worker protocol commitment:

Trusted aw_context.work_queue supplies one immutable inbound Claim ... each worker records at most one Completion and has one pass through safe-output processing.

This PR changes both commitments. ADR-64955 should be amended or superseded so the two records do not disagree.

Next action: review the drafted ADR, correct anything I inferred wrongly (especially the [TODO: verify] note about amending ADR-64955), then change its status from Draft to Proposed or Accepted.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · opus50 · 84.1 AIC · ⌖ 50.4 AIC · ⊞ 6.7K · ◷
Comment /review to run again

@pelikhan

pelikhan commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

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.

4 participants