Skip to content

Raise work queue publication retry budget for contended ledgers - #76425

Merged
elefthei merged 5 commits into
mainfrom
fix/wq/cas-publication-budget
Nov 11, 2026
Merged

elefthei merged 5 commits into
mainfrom
fix/wq/cas-publication-budget

Conversation

@elefthei

Copy link
Copy Markdown
Collaborator

Work Queue Stress was repeatedly exhausting its CAS publication retries when four workers contended on the same ledger. This keeps the existing exponential backoff and raises the attempt budget to cover the measured contention tail.

  • Raise the default publication retry count from 5 to 32 and the accepted upper bound from 10 to 128.
  • Give the stress worker 64 retries.
  • Add workflow_dispatch inputs for the main-sized profiles and raise the pull-request lifecycle profile from 16 to 128 items so PR CI exercises concurrent publishers.
  • Add a regression test that survives 20 consecutive stale fast-forward conflicts and checks the 128-retry bound.

CI proof

Work Queue Stress run 42767352887 passed on commit b181560325781fe66557f4d9449ffc4794ffb16b in 9m14s.

  • Worker lifecycles: 1,024 submitted, 1,024 completed in 240.75s.
  • Contention exercised: 599 CAS conflicts and 598 retry sleeps, with no publication exhaustion.
  • Retained history, admission saturation, simulator invariants, summary publication, and artifact upload all passed.

Validation

  • make agent-report-progress
  • npx vitest run work_queue_store.test.cjs work_queue_telemetry.test.cjs work_queue_checkpoint.test.cjs work_queue_aw_bootstrap.test.cjs work_queue_stress_workflow.test.cjs — 115 tests passed
  • node --test .github/scripts/work-queue-stress.test.cjs .github/scripts/work-queue-stress-summary.test.cjs — 26 tests passed
  • Local 256-item lifecycle profile — 256 submitted, 256 completed
  • Local 1,024-item lifecycle profile — 1,024 submitted, 1,024 completed

Raise the default maxRetries from 5 to 32, the validation bound from 10 to 128, and the stress worker budget from 10 to 64. Keep the exponential schedule unchanged because immediate retries measured slower (135 s / max attempt 39 versus 69 s / max attempt 13 on the 256-item profile). Add workflow_dispatch inputs and raise the PR lifecycle profile from 16 to 128.
@elefthei
elefthei marked this pull request as ready for review November 10, 2026 06:33
@elefthei
elefthei requested a review from pelikhan November 10, 2026 06:33
@github-actions

github-actions Bot commented Nov 10, 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 Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #76425

@github-actions

github-actions Bot commented Nov 10, 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.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: sonnet55 high · ~6 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.5K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76425

Copilot AI adaptive review requested due to automatic review settings November 10, 2026 06:35
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Code Quality Reviewer · gpt56 · ~3 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-10T06:37:51Z
review_event: COMMENT
top_themes: shared retry budget increases compaction API work under contention
files_reviewed: actions/setup/js/work_queue_store.cjs, actions/setup/js/work_queue_store_checks.cjs, .github/workflows/work-queue-stress.yml, .github/scripts/work-queue-stress-worker.cjs
comment_count: 1

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 · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
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.

Found one non-blocking performance/operational concern: the shared retry default also affects compaction, increasing its unbacked API work under checkpoint contention. Inline comment added. Static review only; no tests run per review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

const LEGACY_LOGS = ["dispatch-work-coordinator.jsonl"];
const DEFAULT_MAX_RETRIES = 5;
// Contended ledgers routinely need 10+ fast-forward attempts; exponential backoff caps at 1 s, so 33 attempts bound a publication to ~30 s of sleep.
const DEFAULT_MAX_RETRIES = 32;

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.

The retry default is shared by publishWorkQueueRequest and compactWorkQueueImpl, so this change also raises compaction from 6 attempts to 33. Compaction retries do not back off and each attempt rereads and validates the ledger, which can substantially increase API calls and contention under a checkpoint race. Please either give compaction an explicit, independently justified retry budget or add coverage/telemetry demonstrating that the larger shared default is safe for both publication paths.

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.

Publication keeps its larger retry budget; compaction now has an independent default of five retries, covered by a regression test. Commit: 24e9e77.

@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 🧠

Applied /diagnosing-bugs and /tdd. The change is a sound fix for CAS exhaustion, and the new test covers the stale fast-forward path. One behaviour change needs a decision before merge: the shared retry default also governs compaction.

📋 Key Themes & Highlights

Key Themes

  • Shared default leaks into compaction: DEFAULT_MAX_RETRIES also drives compactWorkQueueImpl, which has no backoff. Its attempts go from 6 to 33 with no delay.
  • Regression test asserts too much in one it: the default-budget behaviour and the 128 bound are combined, so a failure in one hides the other.
  • Boundary not exercised: the 128 check only confirms validation accepts the value. It does not show the loop honours a 128-retry budget.

Positive Highlights

  • ✅ Keeps the existing exponential backoff and caps it at 1 s, as the PR describes.
  • ✅ The new test asserts exact delays ([50, 100, 200, 400, 800, 1000×15]) and checks the replayed state, not just that publish succeeded.
  • ✅ The CI proof is verifiable: run 42767352887 succeeded on b181560, which matches the PR head.
  • ✅ The workflow_dispatch inputs keep 100k/1024 as defaults, so scheduled and push runs are unchanged.

Verification

  • Ran the new regression test with node --test (via work_queue_store_checks.cjs): passes.
  • Could not run vitest: the npm registry is unreachable from this sandbox (TLS certificate error), so the vitest suites were not run.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~9 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

const LEGACY_LOGS = ["dispatch-work-coordinator.jsonl"];
const DEFAULT_MAX_RETRIES = 5;
// Contended ledgers routinely need 10+ fast-forward attempts; exponential backoff caps at 1 s, so 33 attempts bound a publication to ~30 s of sleep.
const DEFAULT_MAX_RETRIES = 32;

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.

[/diagnosing-bugs] This shared default also drives compactWorkQueueImpl, whose retry loop (around line 565) has no backoff sleep. Raising it to 32 lets compaction make up to 33 back-to-back read and CAS attempts, up from 6, with no delay between them. Give compaction its own budget, or add the same backoff there.

💡 Suggested change
const DEFAULT_MAX_RETRIES = 32;
const COMPACTION_MAX_RETRIES = 5;

Then default maxRetries to COMPACTION_MAX_RETRIES in compactWorkQueueImpl so its behavior is unchanged.

@copilot please address this.

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.

Compaction now uses its own five-retry default; publication retains the 32-retry default. Added a test verifying compaction’s default attempt count. Commit: 24e9e77.

assert.equal(state.claims.size, 2);
assert.equal(state.requests.get("local-grant").request.fingerprint, request.fingerprint);
});
it("keeps retrying stale fast-forward CAS conflicts within the default budget and bounds explicit budgets at 128", async () => {

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.

[/tdd] This it covers two behaviours: default-budget retries and the explicit 128 bound. Split it so each name reads as a specification, for example retries 20 consecutive stale fast-forward conflicts under the default budget and rejects explicit publication retry budgets above 128. A failure in one should not hide the other.

@copilot please address this.

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.

Split the default 20-conflict retry test from the explicit retry-budget validation and boundary tests. Commit: 24e9e77.

const fake2 = fakeGitHub(initial);
const request2 = newRequest("explicit-retry-bound", "dispatch_next", dispatcher, { pool: "default", max_claims: 1, max_dispatches: 1, max_bytes: 49152 });
await assert.rejects(publishWorkQueueRequest(options(fake2, request2, dispatcher, { maxRetries: 129 })), /publication retries/);
await publishWorkQueueRequest(options(fake2, request2, dispatcher, { maxRetries: 128 }));

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.

[/diagnosing-bugs] This line only shows that 128 passes validation, since the publish succeeds on the first attempt with no conflicts. It does not show that the loop honors a 128-retry budget. Assert the boundary directly: with maxRetries: 128, 128 consecutive conflicts should still publish, and 129 should throw publication_unresolved. That exercises attempt <= maxRetries, which the validator check does not cover.

@copilot please address this.

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.

Added direct boundary tests: 128 consecutive conflicts succeed with 128 retries, while 129 conflicts exhaust that budget. Commit: 24e9e77.

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.

🟡 Changes recommended

The shared retry increase expands unpaced compaction retries, while deterministic publisher backoff can prolong collisions and repeat costly work under contention.

2 open issues
What changed in this PR

Improves gh-aw work-queue publication resilience under contention by increasing retry budgets while preserving the existing capped exponential backoff.

Changes:

  • Raise default publication retries from 5 to 32 and the accepted maximum from 10 to 128.
  • Give stress workers 64 retries, add manual profile inputs, and increase the pull-request lifecycle profile to 128 items.
  • Add regression coverage for 20 consecutive conflicts and the retry-budget boundary.
File Description
actions/​setup/​js/​work_queue_stress_workflow.test.cjs Verify manual profile defaults and updated CI profile sizes.
actions/​setup/​js/​work_queue_store.cjs Increase the shared retry default and publication retry limit.
actions/​setup/​js/​work_queue_store_checks.cjs Test sustained conflict recovery and retry-limit validation.
.github/​workflows/​work-queue-stress.yml Add manual profile inputs and expand pull-request stress coverage.
.github/​scripts/​work-queue-stress-worker.cjs Increase stress-worker publication retries to 64.

Review effort: Max (auto)

const LEGACY_LOGS = ["dispatch-work-coordinator.jsonl"];
const DEFAULT_MAX_RETRIES = 5;
// Contended ledgers routinely need 10+ fast-forward attempts; exponential backoff caps at 1 s, so 33 attempts bound a publication to ~30 s of sleep.
const DEFAULT_MAX_RETRIES = 32;
const LEGACY_LOGS = ["dispatch-work-coordinator.jsonl"];
const DEFAULT_MAX_RETRIES = 5;
// Contended ledgers routinely need 10+ fast-forward attempts; exponential backoff caps at 1 s, so 33 attempts bound a publication to ~30 s of sleep.
const DEFAULT_MAX_RETRIES = 32;
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  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/work_queue_store.cjs:42): address unresolved feedback - Review comment
  3. Review (actions/setup/js/work_queue_store.cjs:42): address unresolved feedback - Review comment
  4. Review (actions/setup/js/work_queue_store_checks.cjs:1326): address unresolved feedback - Review comment
  5. Review (actions/setup/js/work_queue_store_checks.cjs:1352): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "b181560325781fe66557f4d9449ffc4794ffb16b",
  "kind": "requested",
  "schema_version": "1",
  "state": "69380319910ba5d30637c5635b90502fc18718abf26b984cb6875a372cc83cf1",
  "work": [
    "7f3b39a3615219246b72bcbaec170b1f03862c516219b4bdce4916d14513cfa5",
    "b3d97b697b16dceb141513939d5ad38393a4f696d129b182a5b91719051c5c18",
    "b5c9d853c7b2d20476dc348b19e0dd589c390875c25c3b3af7403f50a6db856a",
    "bbb878249c8e93fcb3c00860362a72f34d7d10c29d2001201bdb2f98a99b684f"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

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.

🟡 Changes recommended

Rejection-settlement failures can let undeclared outputs perform writes, and staging asset URLs no longer match the publisher’s branch path.

4 open issues

Review effort: Max (auto)

Comment on lines +2147 to +2149
} catch {
// Delivery settlement reports invalid immutable contracts.
}
const [owner, repo] = repository.split("/");
const namespace = path.basename(claimArtifactPath("", factoryClaim));
const branch = normalizeBranchName(config.branch || `assets/${process.env.GH_AW_WORKFLOW_ID || "work-queue"}`) + `/claims/${namespace}`;
const branch = normalizeBranchName(config.branch || `assets/${process.env.GH_AW_WORKFLOW_ID || "work-queue"}`) + `-claims/${namespace}`;
@github-actions

Copy link
Copy Markdown
Contributor

Category: bug | Risk: medium | Priority: medium | Score: 63/100 (impact 34 + urgency 17 + quality 12)
Recommended action: batch_review | Batch: pr-batch:runtime-safety

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~6 AIC · ⌖ ~2 AIC · ⊞ 15.9K · ◷

@elefthei
elefthei merged commit 6e5eba6 into main Nov 11, 2026
33 checks passed
@elefthei
elefthei deleted the fix/wq/cas-publication-budget branch November 11, 2026 20:23
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants