Repository navigation
Harden work-queue initialization for empty repositories - #67297
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. No ADR enforcement needed for PR #67297: has_implementation_label=false and default_business_additions=0 (<=100 new lines in business logic directories), with no custom .design-gate.yml overrides.
|
|
✅ Test Quality Sentinel completed test quality analysis.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
@copilot update TLA+ specs |
There was a problem hiding this comment.
L111: shrink: redundant nameWithOwner echo comparison after repository(owner:$owner,name:$repo). Use response?.repository?.isEmpty === true, 1 fewer condition.
net: -1 lines possible.
Generated by ✂️ Ponytail Reviewer for #67297 · codex · gpt56 · 9.33 AIC · ⌖ 6.48 AIC · ⊞ 13.5K
Comment /ponytail to run again
| // GitHub returns 409 rather than 404 for refs in a branchless repository. | ||
| // A generic conflict is not proof of absence: confirm the native state. | ||
| const response = await githubClient.graphql("query WorkQueueEmptyRepository($owner:String!,$repo:String!) { repository(owner:$owner,name:$repo) { nameWithOwner isEmpty } }", { owner, repo }); | ||
| if (response?.repository?.nameWithOwner?.toLowerCase() === `${owner}/${repo}`.toLowerCase() && response.repository.isEmpty === true) return null; |
There was a problem hiding this comment.
L111: shrink: redundant nameWithOwner echo comparison after repository(owner:$owner,name:$repo). Use response?.repository?.isEmpty === true, 1 fewer condition.
There was a problem hiding this comment.
🟡 Changes recommended
Empty Issues configuration still activates staged snapshot behavior and can skip worker binding.
1 open finding
What changed in this PR
Hardens work-queue configuration parsing and initialization for branchless repositories.
Changes:
- Treats empty optional settings as unconfigured.
- Safely bootstraps empty repositories before queue publication.
- Adds protocol documentation and regression coverage.
| File | Description |
|---|---|
docs/src/content/docs/reference/work-queue.md |
Documents empty-repository bootstrap behavior. |
actions/setup/js/work_queue_store.cjs |
Adds empty-state verification and repository preparation. |
actions/setup/js/work_queue_store_checks.cjs |
Tests bootstrap, retry, and conflict handling. |
actions/setup/js/work_queue_issues.cjs |
Normalizes empty Issues configuration. |
actions/setup/js/work_queue_issues_checks.cjs |
Tests empty and malformed Issues settings. |
actions/setup/js/work_queue_control_adapter.cjs |
Normalizes empty credential bindings. |
actions/setup/js/work_queue_control_adapter_checks.cjs |
Tests credential-setting parsing. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| const coreApi = options.core || core; | ||
| const raw = Object.hasOwn(options, "issues") ? options.issues : process.env.GH_AW_WORK_QUEUE_ISSUES; | ||
| const config = issuesConfiguration(typeof raw === "string" ? parseStrictJSON(raw) : raw); | ||
| const config = issuesConfiguration(typeof raw === "string" && raw !== "" ? parseStrictJSON(raw) : raw === "" ? undefined : raw); |
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Verdict
Requesting changes: the new empty-repository bootstrap flow still relies on an immutable worker ref that cannot exist for the same submission once bootstrap creates the repository's first commit.
Blocking themes
- The production code verifies
Policy + Workagainst a pre-bootstrapprofile.ref, but bootstrap necessarily changes the repository's immutable revision before any worker workflow can exist. - The new tests hide that ref churn by pinning
mainto a preselected fake SHA, so they currently validate a path GitHub cannot reproduce.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 44 AIC · ⌖ 5.78 AIC · ⊞ 20K
Comment /review to run again
| const checked = appendCommit(current.transactions, candidate); | ||
| log.debug("request.candidate.checked", { operations: checked.commit.operations.length }); | ||
| if (bootstrapOperation) await prepareEmptyRepository(githubClient, owner, repo, branch); | ||
| if (policyOp) await verifyWorkerRoutes({ githubClient, owner, repo, policy: checked.state.policy }); |
There was a problem hiding this comment.
Bootstrapping main before this validation makes the new empty-repository flow impossible to satisfy against the same submission in production.
💡 Why this blocks merge
prepareEmptyRepository() creates the repository's first commit on the default branch, but checked.state.policy still carries the pre-bootstrap immutable profile.ref. In a truly branchless repository there is no commit to point that ref at before bootstrap, and once the worker workflow is deployed afterward it necessarily lands on a different OID than the one already embedded in the Policy. That means the documented "deploy the worker, then retry the same submission" path cannot actually pass verifyWorkerRoutes() outside this test double.
A safer shape here is to treat bootstrap as a separate preparation step: initialize the default branch, return a dedicated "repository prepared, resubmit with a Policy compiled from the new immutable worker ref" result, and only attempt Policy + Work publication after the caller provides a Policy whose profile.ref exists in the real repository.
| assert.ok(Buffer.from(content, "base64").toString("utf8").includes("authoritative queue ledger")); | ||
| state.bootstrapWrites++; | ||
| if (refs.has("main")) throw Object.assign(new Error("Already initialized"), { status: 422 }); | ||
| refs.set("main", state.defaultRevision); |
There was a problem hiding this comment.
This fake bootstrap path masks the production ref change, so the new empty-repository tests are proving an impossible invariant.
💡 Why this blocks merge
The real repos.createOrUpdateFileContents call creates a fresh commit for the repository's first branch. Here the stub just assigns refs.main to a preselected state.defaultRevision, so every test can keep using the original policy.ref as if bootstrap had not changed the immutable revision at all. That is exactly the case the implementation above depends on, so these tests will stay green while the real empty-repository flow still cannot verify a worker route after bootstrap.
Please make the fake create a new commit OID (or at least mutate defaultRevision) and assert that callers must rebuild/revalidate Policy from the post-bootstrap revision before publication succeeds.
🧪 Test Quality Sentinel Report✅ Test Quality Score: 90/100 — Excellent
📊 Metrics (5 tests)
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 90/100. 0% implementation tests (threshold: 30%). No guideline violations; all five tests assert observable behavior with explicit edge/error coverage.
🧪 Test quality analysis by Test Quality Sentinel · copilot · sonnet50 · 108.6 AIC · ⌖ 15.1 AIC · ⊞ 11.2K
Comment /review to run again
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Updated in 082b98d and 9822f8d: added |
|
🎉 This pull request is included in a new release. Release: |

The work-queue runtime needs to handle empty optional settings and repositories with no branches without treating an ambiguous Git response as proof of absence or weakening Policy and worker-route checks.
isEmptystate before treating a ref as absent. A validated first submission can prepare the default branch, then create a separate queue branch.