Skip to content

fix(queue): make the #8176 claim-model stamp land on the real claim paths - #9025

Merged
dezren39 merged 1 commit into
mainfrom
fix/8176-claim-model-stamp
Nov 12, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/8176-claim-model-stamp

Conversation

@dezren39

@dezren39 dezren39 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #8176 (again — this time verified live; the issue was reopened 2026-11-12 with the evidence below).

Root cause

The #8176 machinery shipped 2026-11-10 was complete and correct — broker parse_claim_model/stamp_claim_model, CLI --model-provider/--model-id/--model-variant, DB columns — but no production claim surface ever passed the flags. Live evidence (fleet-queue DB, 2026-11-12): 12,684 claimed events since 2026-11-10, exactly 4 carrying a model stamp; 3 of the 4 were the implementer's own acceptance claims (worker literally named proof-8176). Of 3,820 tasks completed Nov 6–12 exactly one was stamped. The one wired production path was send_to_opencode.py's transfer claim — the lowest-volume path in the fleet. The paths that carry the volume named sessions but never models:

  • dispatch_batch.py::claim_batch — passes --session-id of the dispatching session, no model flags.
  • claimant.py::_collect_handed_offs — sink collection claim, no model flags.
  • launch_one.py::collect_sink_claim — sink by-id claim, no model flags.
  • Muse lane shift claims (runbook form) — no model flags.

Fix

  • fleet-queue client (client.rs): a claim that names --session-id with no explicit --model-* flags now derives the stamp from that session's own record on the OpenCode server (GET /api/session/<id> — the same record route_usage reads; Basic auth from the server's state file, claimant.py's route). Provider = the session's providerID, model = its id, variant only when the session carries a real effort variant (the server reports "default" when none was chosen — that is stamped as no variant, never as a literal). Fail-soft by design: any failure (no state file, server down, unknown session, malformed record) leaves the claim unstamped and otherwise untouched. Explicit flags always win. This one change covers dispatch_batch's batch claims (opencode + Muse targets both name the dispatching session) and every other --session-id claim form.
  • dispatch_batch.py: Muse-family batch claims additionally carry the design's non-session marker (muse-lane/muse-lane) for lane-attribution queries.
  • claimant.py: the sink handoff-collection claim stamps the launch model — the model every session this claimant creates runs (opencode-route/workhorse), now a named constant (LAUNCH_MODEL_*) shared with the session-create body so the stamp cannot drift from the launch.
  • launch_one.py: the sink by-id claim stamps the route the session will be created under (route_for on the row in hand — the same route the create step uses).
  • Companion (outside this PR): the lane runbook's canonical claim form gains --model-provider muse-lane --model-id muse-lane, activating Muse lane shift claims immediately (the deployed CLI already accepts the flags).

Paths deliberately unchanged: send_to_opencode.py transfers (already stamped), bind claims inside claimant.py (bind semantics — broker stamps at claim, not bind; the claim that created the holding already stamps), and claims that name no session and no dispatch context (they stay unstamped rather than fabricate a model).

Broker / deploy

Broker untouched — no broker restart needed or taken (the standing broker-restart boundary is respected; the running broker already stamps any claim that carries the fields). Activation per surface:

  • CLI derivation: live when the rebuilt client replaces ~/.local/bin/fleet on the laptop (user-owned file; the broker's libexec binary is a different file and is not touched).
  • Python surfaces: live when the primary checkout syncs this merge (scripts are invoked per pass; nothing restarted).
  • Muse lanes: live via the runbook edit — no deploy at all.

Tests

  • fleet-queue lib suite: 282 passed (--features queue-broker), incl. new oracles session_model_stamp_reads_the_session_record (enveloped/bare records, default-variant normalization, half-model rejection) and b64_encode_matches_the_standard_alphabet.
  • Claimant python suites: 143 passed (test_claimant, test_dispatch_batch, test_launch_one, test_send_to_opencode, test_poll), incl. new stamp-argv coverage in all three touched modules.

End-to-end verification

Performed against the production queue with the rebuilt client before merge (task ids + stamped values are in the closing comment on #8176): a dispatch-style claim (real queued task, --session-id of a live workhorse session, no model flags) read back stamped from the session's own record; a lane-style claim with the runbook form read back stamped muse-lane; both tasks released after read-back.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…aths

The broker + CLI stamp machinery shipped 2026-11-10 was complete,
but no production claim surface passed the flags: of 12,684 claimed
events since, exactly 4 carried a stamp (3 by the acceptance worker
proof-8176). The high-volume paths named sessions but never models.

- fleet-queue client: a claim that names --session-id with no
  explicit --model-* flags now derives the stamp from that
  session's own record on the OpenCode server (GET
  /api/session/<id>, Basic auth from the server state file),
  fail-soft — derivation failure never fails the claim. Variant
  stamps only when the session carries a real effort variant
  ("default" is the absence of one). Covers dispatch_batch
  batch claims and every other --session-id claim form.
- dispatch_batch: Muse-family batch claims carry the design's
  muse-lane marker stamp.
- claimant: the sink handoff-collection claim stamps the launch
  model (opencode-route/workhorse), now a named constant shared
  with the session-create body.
- launch_one: the sink by-id claim stamps the route the session
  will be created under (route_for on the row in hand).

Broker untouched — no broker restart needed or taken. The stamp
activates per surface: CLI derivation with the client binary swap,
python surfaces on the primary checkout's next sync, Muse lanes
via the runbook claim form (companion change, flags already
accepted by the deployed CLI).

Tests: fleet-queue lib 282 green (new session_model_stamp + b64
oracles); claimant python suites 143 green (new stamp argv
coverage in all three touched modules).
@dezren39
dezren39 requested a review from a team as a code owner November 12, 2026 20:55
@coderabbitai

coderabbitai Bot commented Nov 12, 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 13 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: a883da23-0880-4310-a460-788b51bc7f36
Commits

Reviewing files that changed from the base of the PR and between 8064969 and ea19e98.

Files selected for processing: 7

  • pkgs/fleet/crates/fleet-queue/src/client.rs
  • pm-stack/opencode-claimant/claimant.py
  • pm-stack/opencode-claimant/dispatch_batch.py
  • pm-stack/opencode-claimant/launch_one.py
  • pm-stack/opencode-claimant/test_claimant.py
  • pm-stack/opencode-claimant/test_dispatch_batch.py
  • pm-stack/opencode-claimant/test_launch_one.py
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
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-12T20:58:13.569099Z ea19e98 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 chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea19e981fd

ℹ️ 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".

Comment on lines +1356 to +1358
let model = inner.get("model")?;
let provider = model
.get("providerID")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Derive the stamp from the serving leaf rather than the route

For routed sessions such as opencode-route/workhorse, the session's model identifies the configured route, not the provider/model/effort that actually served the claim. Reading this field therefore permanently records the route alias and loses the serving-leaf attribution required by doc/fleet/queue-turso-cutover.md and pm-stack/opencode-claimant/prompt.md, which explicitly distinguishes route_usage.lastServing from the declared route. The new Python collection stamps have the same problem because they record the future session's route before it has served anything. Use the actual serving-leaf readout when available and leave the claim unstamped otherwise.

Useful? React with 👍 / 👎.

Comment on lines +1424 to +1428
let base = std::env::var("OPENCODE_SERVER_URL")
.ok()
.map(|s| s.trim().trim_end_matches('/').to_string())
.filter(|s| !s.is_empty())
.unwrap_or_else(|| "http://127.0.0.1:13420".to_string());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor the existing OpenCode connection overrides

When the claimant tooling is configured with OPENCODE_URL or OPENCODE_AUTH_FILE, this lookup ignores both overrides: it reads a different URL variable and always loads the production credential file. claimant.py and poll.py use those existing overrides for their session operations, so the new queue-client lookup can contact a different server or authenticate with the wrong credentials. Its fail-soft return then silently leaves claims unstamped despite the configured server being available. Resolve the URL and credential file consistently with those callers.

Useful? React with 👍 / 👎.

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.

queue: stamp the claiming session's own model on the task at claim time

1 participant