Skip to content

fix(service): queue-check reports advisory instead of failure for a missing or stale prepared queue - #65

Merged
nish3451 merged 3 commits into
mainfrom
fix/queue-check-stale-advisory
Aug 11, 2026
Merged

fix(service): queue-check reports advisory instead of failure for a missing or stale prepared queue#65
nish3451 merged 3 commits into
mainfrom
fix/queue-check-stale-advisory

Conversation

@nish3451

@nish3451 nish3451 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

What

npm run service:queue-check could never pass after the preparation day: checkQueue() rebuilt the expected queue in-memory with asOfDate = today and compared sha256 against the stored runs/service-engine/queue.json, which embeds its own asOfDate/generatedAt. The hashes only match on the exact calendar day the queue was prepared, so any artifact older than 24h (or none at all in a fresh checkout) made the human-review gate red — a red signal that carried no actionable meaning and conflated "queue never prepared" with "queue corrupted".

Change

  • scripts/lib/review-queue.mjscheckQueue() now distinguishes the three states:
    • advisory (status advisory, exit 0): stored artifact missing → queue not prepared - run service:queue; stored artifact prepared on an earlier calendar date → queue not prepared since <date> - run service:queue.
    • failed (status failed, exit 1): current-date artifact whose content no longer matches the rebuilt queue (queue output is stale or altered), invalid JSON, or any item-level failure (blocked items, invalid decisions, missing/stale agent work packets).
    • passed: a current prepared queue matches the rebuilt queue exactly.
  • scripts/check-review-queue.mjs and scripts/run-review-queue.mjs — exit non-zero only for status === "failed".
  • Queue artifact format and prepare path unchanged; existing prepared queues still verify via --as-of their own date.
  • scripts/test-service-engine.mjs — queue-check assertions now cover passed / same-day tamper (failed, exit 1) / missing artifact (advisory, exit 0) / stale artifact naming its date (advisory).

Verification

Live runs in this worktree:

  • no artifact → status: advisory, queue not prepared - run service:queue, exit 0
  • artifact from 2026-08-07 checked 2026-08-11 → status: advisory, queue not prepared since 2026-08-07 - run service:queue, exit 0
  • prepare → status: passed, exit 0
  • same-day tamper → status: failed, queue output is stale or altered, exit 1

npm run ci passes (38 engine checks + all gates), git diff --check clean, sgscan: no new findings.

Summary by CodeRabbit

  • Bug Fixes
    • Queue checks now distinguish advisory conditions from actual failures.
    • Missing or outdated queue data produces advisories without failing the check.
    • Invalid or altered queue data continues to fail validation.
    • Command-line checks now exit unsuccessfully only for confirmed failures.
  • Tests
    • Added coverage for advisory statuses, failure scenarios, CLI messaging, and queue restoration.

…g or stale prepared queue

checkQueue conflated 'queue never prepared' and 'queue corrupted' into one
red hash-mismatch failure. A prepared queue artifact embeds its asOfDate, so
the hash can only match on the exact preparation day; any artifact older than
today (or none at all in a fresh checkout) made service:queue-check exit 1
~always, leaving the human-review gate red without actionable meaning.

Now a missing artifact reports 'queue not prepared - run service:queue' and
an artifact prepared on an earlier calendar day reports 'queue not prepared
since <date> - run service:queue' as a non-failing advisory (status advisory,
exit 0). Same-day corruption (invalid JSON, or a current-date artifact whose
content no longer matches the rebuilt queue) and item-level failures stay red
(status failed, exit 1). The queue artifact format and prepare path are
unchanged; existing prepared queues still verify with --as-of their own date.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nish3451 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The queue checker now separates advisory conditions from failures. Missing or outdated queues return advisory, while invalid or altered queues return failed. CLI commands fail only for failed results. Tests cover both outcomes.

Queue status handling

Layer / File(s) Summary
Queue status classification
scripts/lib/review-queue.mjs
checkQueue now returns an advisories array and reports advisory for missing or outdated queues. Invalid and altered queues remain failures.
CLI exit handling
scripts/check-review-queue.mjs, scripts/run-review-queue.mjs
Check commands now set a failing exit code only for failed results.
Queue status validation
scripts/test-service-engine.mjs
Tests verify failed altered queues and successful advisory results for missing or outdated queues.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: missing or stale prepared queues now report advisory status instead of failure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/queue-check-stale-advisory

Comment @coderabbitai help to get the list of available commands.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nish3451 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
scripts/test-service-engine.mjs (1)

1244-1264: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the exact CLI contract for failure and stale-date advisories.

Line 1251 accepts any nonzero exit code, although failed queues must exit with code 1. Change it to eq(alteredQueueCli.status, 1).

Lines 1262-1264 test only checkQueueWithClock. Add the matching CLI check with a July 30, 2026 clock, and assert exit code 0 plus the queue not prepared since 2026-07-29 advisory.

Suggested test update
-	neq(alteredQueueCli.status, 0)
+	eq(alteredQueueCli.status, 1)
...
 	assert(staleQueueCheck.advisories.some(message => message.includes("queue not prepared since 2026-07-29")))
+	const staleQueueCli = run(QUEUE, ["--mode", "check", "--as-of", "2026-07-30"], E("2026-07-30T12:00:00.000+05:30"))
+	eq(staleQueueCli.status, 0, staleQueueCli.stderr)
+	const staleQueueCliResult = JSON.parse(staleQueueCli.stdout)
+	assert(staleQueueCliResult.advisories.some(message => message.includes("queue not prepared since 2026-07-29")))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/test-service-engine.mjs` around lines 1244 - 1264, Update the CLI
assertions around alteredQueueCli and staleQueueCheck: require
alteredQueueCli.status to equal 1 instead of merely being nonzero, then add a
CLI checkQueue invocation using the July 30, 2026 clock and assert status 0 with
the “queue not prepared since 2026-07-29” advisory. Preserve the existing
checkQueueWithClock assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/test-service-engine.mjs`:
- Around line 1244-1264: Update the CLI assertions around alteredQueueCli and
staleQueueCheck: require alteredQueueCli.status to equal 1 instead of merely
being nonzero, then add a CLI checkQueue invocation using the July 30, 2026
clock and assert status 0 with the “queue not prepared since 2026-07-29”
advisory. Preserve the existing checkQueueWithClock assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 982d2730-8ccb-4c65-ac82-415601551e33

📥 Commits

Reviewing files that changed from the base of the PR and between eaeb937 and db93027.

📒 Files selected for processing (4)
  • scripts/check-review-queue.mjs
  • scripts/lib/review-queue.mjs
  • scripts/run-review-queue.mjs
  • scripts/test-service-engine.mjs

@nish3451
nish3451 merged commit 623576d into main Aug 11, 2026
3 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.

1 participant