GeezerVison is showing github.com — fleet-queue: needs-drew alerts into the PM throat on escalated blocks (code#8568) by dezren39 · Pull Request #8598 · developing-today/code
Conversation
dezren39
commented
Nov 11, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fleet (Rust) half of PM-stack notifications Phase 1 for #8568: the queue block path now raises a needs-drew event into the PM alert throat.
Wire contract (as fixed by the aggregator lane, unchanged): POST http://127.0.0.1:4870/api/alerts (env override FLEET_ALERTS_URL), Authorization: Bearer <token> where the token is the Bitwarden secret named pm-aggregator.alerts-intake-token resolved by name, body {"source": "fleet-queue", "key": "needs-drew:<ledgerId>", "severity": "warning", "title": <question>, "body": <context or blocker>, "needsDrew": {...}}. The throat dedupes by (source, key); the raise is idempotent.
What changed (pkgs/fleet/crates/fleet-queue):
src/needs_drew.rs (new): pure payload builder build_throat_body(&BlockNeedsDrew) -> serde_json::Value pinned by unit tests (exact key/title/needsDrew shape, optionals omitted when absent, blocker as body fallback); a minimal HTTP/1.1 JSON POST helper over std TcpStream (client.rs transport style); post_needs_drew(token, nd) returning the response's answerUrl when present; plus the snake_case needs_drew block-request parser both halves share.
src/client.rs (cmd_block): new optional flags --ledger-id, --question, --context, --options-json, --links-json. For escalated-to-user blocks with --ledger-id + --question: the /block body gains "needs_drew": {ledger_id, question, context?, options, links}, and "needs_drew": {"ledger_id": …} is merged into the progress object (preserving caller --progress content) so the current broker stamps the ledger id onto the task row with no broker change. After the block succeeds, the intake token is resolved by name in-process via fleet_secrets::Resolver::default_chain — the exact machinery behind the fleet secrets get verb (direct secrets-broker source on the laptop, session-proxy source in the sandbox, bws fallback; the queue CLI has no other named-secret resolver of its own) — and the alert posts. Emission failure prints repo-queue: WARNING: needs-drew throat post failed: <err> to stderr and still exits 0; success prints repo-queue: needs-drew raised for ledger item <id> to stderr; stdout keeps its current JSON shape exactly. Escalated blocks without the flags behave exactly as before.
src/queue_broker.rs (/block): after a successful block with reason_class == "escalated-to-user" and a needs_drew payload, the same POST fires from inside the broker process, fire-and-forget on a spawned thread, token resolved via the in-process secrets source (DirectSecrets — the colocated secrets broker, the same source every other broker credential uses); failures are logged to stderr only. The hook is applied on both the Postgres simple_rpc arm and the Turso dispatch branch (dispatch hands /block to the Turso backend before the match, so a Turso-backed broker would otherwise never see it).
Deployment, plainly: the CLI half is the live path once the CLI binary is replaced. The broker half cannot go live until the broker binary is replaced (the coordinated switch) — this PR does not replace any binary and does not restart queue-broker. The release fleet binary built from this branch is staged on the laptop at ~/tools/staging/fleet-8568/fleet (sha256 5735008dd51b85a11ee2412351e130dd416fab5155aca826b2ba691e683a0b90, 6,982,776 bytes) for that switch.
Tests: cargo test -p fleet-queue — 30 passed (default features); cargo test -p fleet-queue --all-features — 257 lib tests passed including the 7 new needs_drew tests, plus 2 broker_bin_args tests; 0 failures. cargo build --release -p fleet clean (pre-existing warnings only). Staged-binary smoke: new flags parse and bad --options-json/--links-json die with exit 2 before any broker contact. No live block was performed (that would block a real task and push Drew's phone).
Refs #8568.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…blocks (code#8568)
Phase 1 of PM-stack notifications: the queue block path learns to speak to the aggregator alert throat (POST /api/alerts, source fleet-queue, key needs-drew:<ledgerId>, deduped by the throat so both halves may post safely).
- New needs_drew module: pure throat-body builder pinned by unit tests, a minimal std-TcpStream HTTP/1.1 POST helper, and the snake_case needs_drew block-request parser both halves share.
- CLI (cmd_block): --ledger-id/--question/--context/--options-json/--links-json on an escalated-to-user block add needs_drew to the /block body and merge needs_drew.ledger_id into progress (so the current broker stamps the ledger id onto the task row with no broker change); after the block lands, the intake token resolves by name via fleet-secrets Resolver::default_chain (the fleet secrets machinery) and the alert posts. Emission failure warns on stderr and still exits 0; stdout shape unchanged. Escalated blocks without the flags behave exactly as before.
- Broker (/block route): after a successful block with reason_class escalated-to-user and a needs_drew payload, the same post fires fire-and-forget on a spawned thread, token resolved via the in-process DirectSecrets secrets source; failures log to stderr only. Hooked on both the Postgres simple_rpc arm and the Turso dispatch branch.
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 51 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:
ab97342e-0abd-4fb4-b14d-86972d2c6675
Commits
-
Reviewing files that changed from the base of the PR and between 1a06801 and 995161f.
Files selected for processing: 4
-
pkgs/fleet/crates/fleet-queue/src/client.rs
pkgs/fleet/crates/fleet-queue/src/lib.rs
pkgs/fleet/crates/fleet-queue/src/needs_drew.rs
pkgs/fleet/crates/fleet-queue/src/queue_broker.rs
- 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
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-11T07:41:18.042992Z |
995161f |
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Merging over merely-QUEUED checks, per established practice: every check is still pending/queued (none red, none failed) and this change is verified locally on the laptop — cargo test -p fleet-queue --all-features: 257 lib tests passed (including the 7 new needs_drew tests) + 2 broker_bin_args, 0 failures; cargo test -p fleet-queue (default features): 30 passed; cargo build --release -p fleet clean. The change is additive and feature-contained in fleet-queue; no binary is deployed and queue-broker is not restarted by this merge — the staged binary at ~/tools/staging/fleet-8568/fleet awaits the coordinated switch.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 995161fca4
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+100
to
+103
|
|
"severity": "warning",
|
|
|
"title": block.question,
|
|
|
"body": body,
|
|
|
"needsDrew": needs_drew,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coordinate the needs-drew receiver before enabling emission
Against the aggregator included in this commit, these POSTs succeed without notifying Drew or preserving the actionable question. The /api/alerts handler in pm-stack/aggregator/src/server.ts:2348–2357 passes the body through validateNewIncident, whose projection in alerts.ts:319–327 discards needsDrew, including its ledger ID, options, and links. Furthermore, pendingDeliveries in alerts.ts:570–577 selects only critical incidents, so this warning never generates a push. Land the matching receiver support before enabling this producer; otherwise both CLI and broker report successful raises while escalated tasks remain without the intended notification.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+838
to
+840
|
|
if resp.get("ok").and_then(|v| v.as_bool()) != Some(true) {
|
|
|
return;
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require a transitioned task row before raising an alert
On the Postgres path, simple_rpc wraps any successful RPC response as ok: true, including a null row. The client explicitly treats that null row as an unsuccessful block in require_row (for example, when the task is no longer claimed by the requesting worker), but this hook checks only the envelope and still emits the question. Consequently a stale or repeated block request can raise an alert even though no task was blocked. Require a non-null response row before spawning the notification thread, matching the client's success criterion.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|