Skip to content

fix(pm-dispatch): no orphan spec-less issues — spec gate + enqueue-failure cleanup (#4925) - #4948

Closed
dezren39 wants to merge 1 commit into
mainfrom
queue/8043-4925-dispatch-orphan
Closed

dezren39 wants to merge 1 commit into
mainfrom
queue/8043-4925-dispatch-orphan

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #4925. (The bulk placeholder cleanup turned out to be already owned by queue task 8030 for #4917 — see the 2026-11-03 progress note on #4925; this PR is the code half.)

Problem

pm-dispatch created the GitHub tracking issue before the queue enqueue in both POST /v1/sessions and POST /v1/tasks. On an enqueue (or packet-validation) failure the handler returned the error and left the issue open and unannotated — a spec-less orphan whose footer promised task/session ids that never arrived. parseSessionRequest also put no floor on spec quality, so a placeholder prompt became a real issue title: 59 open do the thing issues accumulated, each then consuming a coverage triage lane.

Changes

  • Spec gate (src/validate.ts): a session request with no explicit title whose prompt is under MIN_DERIVED_TITLE_PROMPT_CHARS (40) is rejected 400 — a title can no longer be derived from a placeholder prompt. An explicit title exempts the request (the caller named the work). The gate runs after all other field validation, so existing field errors keep precedence. Specimen coverage: do the thing (12 chars) 400s.
  • Enqueue-failure cleanup (src/enqueue_failure.ts, new): mirror of launch_failure.ts. When the enqueue or the preceding packet validation fails, an issue this request created is commented with the failure and closed as not planned; each step is best-effort and the outcome is returned. Both endpoints wire it in:
    • handleSessions: packet-validation 500 path and enqueue 502 path (response gains issue_closed).
    • handleTasks: same two paths, but only for the create path — an issue attached via issue_number is the caller's and is never closed.
  • GitHubClient.closeIssue (src/github.ts): app-API PATCH with state_reason: not_planned, gh issue close --reason "not planned" fallback, mirroring comment().

Tests

  • test/enqueue_failure.test.ts (new): comment-then-close ordering and content, close still runs when the comment fails, honest outcome when the close fails.
  • test/validate.test.ts: gate cases (short prompt rejected, explicit title exempt, full prompt passes, priority errors keep precedence); existing cases that used specimen prompts (do the thing, x) as valid requests now use a compliant prompt or an explicit title — their original assertions are unchanged.
  • test/server.test.ts: the shared fixture prompt now clears the gate so the directory/body-cap tests behind it still exercise their own gates (assertions unchanged).
  • Laptop run: 121 tests pass across the other 10 dispatch test files; server.test.ts foreign-directory test passes. The two server.test.ts "passes validation" tests time out only on a host with live GitHub credentials — the handler's gh fallback then creates a real issue (the fetch stub cannot intercept the subprocess). That accident was a live end-to-end proof of this PR: the run created do the thing properly, with a real spec and acceptance criteria #4944 and the new cleanup closed it NOT_PLANNED (its evidence comment hit the current GitHub addComment secondary rate limit; the close still landed, as designed). In CI's credential-free environment those tests take the issue-null path as before.
  • bunx tsc --noEmit: one pre-existing error in untouched test/queue.test.ts (fetch preconnect typing vs installed bun types); no errors in the changed files.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 14:08
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T14:08:47.196845Z
We couldn’t complete this review. Comment @codex review to try again.
7589552 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dbb31a97-806f-4ff6-a789-f949e9ac96e9
Commits

Reviewing files that changed from the base of the PR and between a8dbda7 and 7589552.

Files selected for processing: 7
  • pm-stack/dispatch/src/enqueue_failure.ts
  • pm-stack/dispatch/src/github.ts
  • pm-stack/dispatch/src/server.ts
  • pm-stack/dispatch/src/validate.ts
  • pm-stack/dispatch/test/enqueue_failure.test.ts
  • pm-stack/dispatch/test/server.test.ts
  • pm-stack/dispatch/test/validate.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@dezren39

dezren39 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

Closing as superseded (task 14250, lane code-h). Salvage check posted on canonical PR #7633 before closure: nothing unique remains here — the enqueue-failure cleanup landed on main via #4917 (compensateOrphanedIssue), and the minimum spec gate (same 40-char floor) just merged in PR #7633 (merge 9b4457b), which closed issue #4925. Tests for the gate verified on laptop: bun test validate+server, 54 pass.

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

Labels

None yet

Projects

None yet

1 participant