Skip to content

Speed up work queue checkpoint verification - #75352

Merged
pelikhan merged 2 commits into
mainfrom
pelikhan/work-queue-smoke-test
Nov 6, 2026
Merged

pelikhan merged 2 commits into
mainfrom
pelikhan/work-queue-smoke-test

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Cold work queue history validation could exhaust the five-minute durable Completion verification budget before independent delivery verification began. The smoke worker could record its completed finish but fail to publish a verified Result.

Changes

  • Reuse already-validated canonical causal prefixes, including complete native Git blob identities, instead of repeatedly reading and replaying the same payloads.
  • Verify checkpoint source history and state hashes without constructing, compressing and replaying throwaway replacement checkpoints.
  • Avoid redundant receipt parsing and cloning while retaining exact canonical-byte validation.
  • Add synthetic and captured-history benchmarks plus regressions for malformed history, altered checkpoint boundaries and noncanonical compressed receipts.
  • Add always-on full cold Git-history coverage: 70 checkpoint generations, 1,470 ancestry commits, 135 Work items, 16 Claims and 1,200 retained control requests. Check exact head, full replayed projection, transactions and retained counts; reject a broken oldest-checkpoint Git-parent binding despite valid newer snapshots. Construct local history with length-delimited Git fast-import rather than thousands of subprocesses.

Single-parent ancestry, checkpoint reconstruction, authenticated cache scope, strict transaction parsing, immutable assignment authority and durable delivery deadlines remain enforced.

Validation

  • Original implementation: 382 focused tests passed; typecheck, formatting/lint and the final make agent-report-progress gate passed.
  • Full-history follow-up: 42 focused tests passed, four optional captured-history tests skipped; typecheck, formatting/lint and the change-scoped publication gate passed. The gate ran all 22 Git transport tests with no environment flags or captured queue required.
  • Synthetic production-Git benchmark: 135 Work items, 1,200 retained requests, four checkpoint generations and 128 ancestry commits. Original cold validation: 391 ms; warm: 39 ms. Follow-up: 402 ms cold, 51 ms warm. Enforced budget: 3 seconds.
  • Always-on full-history slow path: 2.880 seconds cold; oldest-boundary corruption rejected in 3.174 seconds. Both include production Git object transfer, integrity checks and full history validation, exclude fixture construction, and enforce a 10-second local ceiling.
  • Read-only replay of current queue head 71a8b707c53344d53540482eb0179b5a043a90a0: 135 Work items, 147 Claims and 1,325 retained requests. Full cold Git verification, including local object transfer and integrity checks: 5.769 seconds. Ledger replay alone: 78 ms. Exact head and full replayed projection matched.
  • The optional captured-history benchmark has a documented 10-second local cold-read ceiling. The initially attempted five-second ceiling was not met; it is not reported as passing.
  • Read-only security review found no confirmed vulnerabilities in the implementation and follow-up harness deltas.

No new hosted workflow run, production queue mutation or uncertain-effect replay was performed. Hosted delivery verification with this revision has not been rerun.

Reuse validated canonical prefixes and native Git blob identities, reconstruct checkpoint source hashes without repeated replay, and avoid redundant compressed receipt parsing and cloning. Add bounded synthetic and captured-history benchmarks plus integrity regressions while preserving delivery deadlines and authority checks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 6, 2026 07:24
Copilot AI auto review requested due to automatic review settings November 6, 2026 07:24
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills...

@github-actions

github-actions Bot commented Nov 6, 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: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 6, 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: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #75352

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #75352

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

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

Reviewed PR head cbc92af against the work-queue contract, especially docs/src/content/docs/specs/work-queue-specification.md section 7.6 (checkpoint verification and causal Git history).

Blocking finding: the new canonical-prefix shortcut can skip the declared checkpoint boundary when the prior commit is itself a checkpoint root, causing valid nested checkpoint history to be rejected and bypassing the required fresh source replay. See the inline comment on actions/setup/js/work_queue_store.cjs:422.

The benchmark and specification additions otherwise align with the stated optimization intent; no code or specification edits were made by this review.

Generated by PR Specification Reviewer for #75352 · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review-specs to run again

Comment thread actions/setup/js/work_queue_store.cjs Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

What this change does: It avoids replaying validated checkpoint prefixes and adds stricter checkpoint-source checks. It also adds synthetic and captured Git-history benchmarks.

Should fix:

  1. Prefix cache stores data the caller never reads (actions/setup/js/work_queue_store.cjs:L489)

    • What this is: canonicalGitPrefixes builds a lookup for already validated Git blob IDs.
    • Problem: readQueueContentsAtSHA only tests whether get(logs[0].sha) is defined, then uses prefixVerified; it never consumes the stored prefix string. A 256-line log therefore retains 256 overlapping copies of the log.
    • Fix: Store only the blob IDs in a Set, use has, and return the verification marker without retaining prefix text.
    • If we skip it: The fast path keeps needless data alive and makes large-history validation allocate far more than the lookup needs.

Verdict: fix 1 first.
Lean: -1 line possible.

Generated by ✂️ Ponytail Reviewer for #75352 · codex · routed: gpt56 max · ~7 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again

.update(`blob ${offset}\0`, "utf8")
.update(bytes.subarray(0, offset))
.digest("hex");
prefixes.set(oid, contents.slice(0, end));

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.

Ponytail: This stores a full canonical prefix for every blob ID, but the caller only checks whether the ID exists and uses prefixVerified; keep a Set of IDs instead so large logs do not retain overlapping prefix strings.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679601984

No code change is needed for this reviewer-start notice. It contains no actionable code-quality finding.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679599424

No code change is needed because this notice contains no test improvement request. The reported_no_action status is not evidence that test coverage is sufficient; the focused nested-checkpoint and full-history tests were independently rerun and passed.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679599607

Successful reviewer execution does not establish PR correctness, so no code change is justified by this completion notice alone. The separate checkpoint finding was evaluated and answered in its inline thread: distinct canonical roots prevent the alleged shortcut, and the nested-checkpoint and full-history tests passed.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679600139

No code change is needed for this reviewer-start notice. It contains no actionable simplification request.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679596334

No code change is needed for this reviewer-start notice. It contains no actionable finding.

@pelikhan

pelikhan commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to comment 6679598263

No code change is needed because this notice reports no requested action. The reported_no_action status alone does not establish that the PR satisfies the design requirements.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-06T07:34:00Z
review_event: COMMENT
top_themes: [strict parser resource bounds, quadratic Git prefix hashing]
files_reviewed: [actions/setup/js/work_queue_replay.cjs, actions/setup/js/work_queue_store.cjs, actions/setup/js/work_queue_checkpoint_regression.test.cjs, actions/setup/js/work_queue_git_transport.test.cjs, actions/setup/js/work_queue_live_performance.test.cjs, docs/src/content/docs/specs/work-queue-specification.md]
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 · gpt50 · ~8 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 two actionable performance/resource regressions in the checkpoint verification changes.

Highlights
  • The compressed receipt path no longer uses the strict parser limits, allowing oversized request arrays/payloads during queue reads.
  • Git prefix object-ID generation rehashes the complete growing history for every prefix, making the new fast path quadratic in payload size.

The specialist pass completed; its additional candidates were adjudicated and not included.

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

const requestsText = inflateRawSync(Buffer.from(wire.requests_compressed, "base64"), { maxOutputLength: 64 << 20 }).toString("utf8");
const requests = parseStrictJSON(requestsText);
// Exact canonical equality also rejects duplicate keys and lossy numbers.
const requests = JSON.parse(requestsText);

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.

Replacing parseStrictJSON with JSON.parse removes the snapshot parser's resource bounds: compressed requests can now contain more than 16 MiB of JSON or arrays larger than 16,384 elements, and canonical does not restore the array-size limit. An untrusted checkpoint can therefore drive substantially more allocation/CPU during every queue read.

💡 Preserve the strict parser limits

Use parseStrictJSON(requestsText, { maxBytes: ... }) (or add equivalent explicit size/member checks before canonicalization) so duplicate-key rejection and the existing depth, integer, and array bounds remain enforced. Keep the canonical-byte equality check for the compressed receipt.

let end = 0;
for (const line of lines) {
offset += Buffer.byteLength(line, "utf8");
end += line.length;

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.

canonicalGitPrefixes hashes bytes.subarray(0, offset) from the beginning for every line, making prefix construction O(total-history-bytes × number-of-lines) rather than linear. On the large ledgers this optimization is intended to accelerate, it needlessly rehashes the growing payload and can consume the cold-validation budget before Git traversal begins.

💡 Build prefix object IDs incrementally

Maintain a running hash for the blob body and derive each prefix object ID from the accumulated state (or cache/reuse the computed prefix bytes) instead of hashing the entire prior prefix on every iteration. Add a benchmark that isolates this helper for the production-sized history.

@pelikhan
pelikhan merged commit 0bf1db2 into main Nov 6, 2026
43 checks passed
@pelikhan
pelikhan deleted the pelikhan/work-queue-smoke-test branch November 6, 2026 07:37

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

Checkpoint parsing can consume excessive resources before structural limits are enforced, and verification can skip source-root ID validation, allowing conflicting records under one durable ID.

3 open issues
What changed in this PR

This PR speeds up gh-aw’s work-queue checkpoint verification, leaving more of the durable completion budget available for independent delivery verification.

Changes:

  • Reuses validated canonical history prefixes, including matches established through complete Git blob identities.
  • Verifies checkpoint source snapshots directly and reduces receipt parsing and cloning overhead.
  • Adds performance benchmarks, malformed-history regressions, and documented local timing budgets.
File Description
docs/​src/​content/​docs/​specs/​work-queue-specification.md Documents prefix reuse, verification boundaries, and benchmark budgets.
actions/​setup/​js/​work_queue_store.cjs Adds canonical-prefix reuse and direct checkpoint-source verification during ancestry traversal.
actions/​setup/​js/​work_queue_replay.cjs Refactors checkpoint reconstruction and receipt parsing to reduce repeated work.
actions/​setup/​js/​work_queue_live_performance.test.cjs Adds a captured-history benchmark using production Git transport.
actions/​setup/​js/​work_queue_git_transport.test.cjs Adds synthetic cold/warm benchmarks and malformed-ancestor regressions.
actions/​setup/​js/​work_queue_checkpoint_regression.test.cjs Tests source-boundary validation and rejection of noncanonical compressed receipts.

Review effort: Max (auto)

Comment on lines +1187 to +1188
// Exact canonical equality also rejects duplicate keys and lossy numbers.
const requests = JSON.parse(requestsText);
}
if (parent === checkpoint.prior_git_sha) {
try {
const state = replayCheckpointSource(contents, parent, root);
Comment on lines +399 to +402
let lines = transactions.map(transaction => canonical(transaction) + "\n");
const rootBytes = Buffer.byteLength(lines[0], "utf8");
let validatedPrefix = lines.join("");
let prefixes = queueGitScope(githubClient) ? canonicalGitPrefixes(lines, head.length) : undefined;
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