GeezerVison is showing github.com — session record carries no route_usage: claim stamps cannot name the serving leaf (server-side remainder of #1891) · Issue #2696 · developing-today-forks/opencode
session record carries no route_usage: claim stamps cannot name the serving leaf (server-side remainder of #1891) #2696DescriptionGap: session records carry no route_usage — claim stamps can't name the serving leaf
Found by: Lane GT (archer) reconciliation of developing-today/code#1340 criterion 1, 2026-11-23. Fresh production measurement + code read; this is the server-side remainder of #1891 (closed: the route_usage tool readout exists) and of developing-today/code#9408 (closed: the fleet-queue client now prefers route_usage.lastServing when a session record carries it).
Evidence
- The fleet-queue client's stamp derivation (
pkgs/fleet/crates/fleet-queue/src/client/support.rs, session_model_stamp) reads route_usage.lastServing from the session record when present, and deliberately stamps nothing for routed sessions when it is absent — recording the declared route alias (opencode-route/workhorse) would permanently mislabel the claim. Its own comment records: "The deployed server's session records today carry no route_usage field at all — verified 2026-11-14".
- Fresh measurement of the production queue DB (Turso
fleet-queue, window 2026-11-22T00:00Z → 2026-11-23T06:05Z, 315 completions, status=done):
claim_variant non-null: 0 / 315 (and 0 / 21 tasks in claimed state at measure time)
claim_model non-null: 116 / 315 — 114 are the by-design muse-lane marker for non-session actors, 1 is opencode-route/workhorse (the route alias itself), 1 is a real leaf (_openai.main/gpt-6-luna)
- completion-telemetry
effort non-null: 0 / 315 (it derives from claim_variant / the session leaf's variant — both empty)
- completion-telemetry
model non-null: 109 / 315, of which 108 are the muse-lane pseudo-model
Ask
Surface the serving-leaf readout on the session record itself: GET /api/session/<id> (and the enveloped data shape) should carry route_usage.lastServing with providerID + modelID + variant — the same shape the route_usage tool already produces (#1891) — updated as the serving leaf changes, so a claim made mid-session stamps the leaf that is actually serving at claim time.
Why it matters
developing-today/code#1340 (meta-reviewer) criterion 1 — per-pool/per-effort outcome tables from real fleet data — stays unmeetable until routed session claims stamp a real serving leaf and variant. The client side is done and waiting on this record shape; no fleet-queue change is needed once the field lands (the derivation prefers it automatically, and a present-but-unparseable readout stamps nothing rather than falling back to the alias). Activitydezren39 commented on Nov 23, 2026 Lane NC pickup (archer loop) — claiming this slice.
Plan: verify the premise on current main (session record from GET /api/session/<id> carries no route_usage), then land one slice: surface route_usage.lastServing (providerID + modelID + variant) on the session record, updated as the serving leaf changes, with a test. Working in a laptop worktree off main; PR + merge once verified. dezren39 commented on Nov 23, 2026 Lane NC — premise verified read-only; execution held on a platform flag; prepared slice recorded below.
Premise verdict: TRUE on current main (7403b84a0d).
packages/schema/src/session.ts: Session.Info has no route_usage field (fields: id, parentID, fork, projectID, agent, model, cost, costAuthoritative, tokens, outcome, time, title, location, …). packages/core/src/session/info.ts fromRow builds the record from the session row plus the optional authoritative-usage rollup — no serving-leaf readout anywhere.
- The readout itself exists and is proven: the
route_usage tool (feat: serving leaf is invisible to the session — expose the resolved provider/model per step #1891) computes lastServing from ModelRouteLog.sessionAttempts(db, sessionID, 50) via ModelUsage.lastServing(rows) (packages/core/src/model-usage.ts), yielding { leaf, providerID, modelID, variant, routeID, outcome, attemptedLeaf, failedOver, failedOverTo, hedged, timeStarted }. It is only reachable through the tool, never on the session record.
- Consumer contract (developing-today/code
pkgs/fleet/crates/fleet-queue/src/client/support.rs, session_model_stamp): GET /api/session/<id>, read route_usage.lastServing → providerID + modelID + variant ("default" counts as absent). A present-but-unparseable readout stamps nothing (no fallback to the declared model), so the field must be absent — never null/partial — until the session has a real serving leaf.
Hold: creating the laptop worktree (~/wt-lane-nc-2696, branch lane-nc-2696, off exact main SHA 7403b84a0d) returned a result that failed a platform execution-risk check. Per the standing rule, Drew's blanket repo approval does not clear a platform flag — no git/build/test commands have been run inside that checkout and it is untouched. The slice below awaits Drew's item-specific go-ahead for this worktree.
Prepared slice (one PR, ready to execute on approval):
packages/schema/src/session.ts: add a RouteUsage struct mirroring ModelUsage.LastServing and an optional route_usage field on Info (the literal snake_case key the client reads), following the costAuthoritative optional-field pattern.
packages/core/src/session/info.ts: extend fromRow with an optional serving parameter, mirroring the existing authoritative parameter; set route_usage only when a last-serving leaf exists.
packages/core/src/session/store.ts (get, the line that already calls ModelRouteLog.authoritativeSessionUsage): also fetch ModelRouteLog.sessionAttempts(db, row.id, 50), derive ModelUsage.lastServing(rows), pass through. Scope is the single-session GET — the exact surface the claim path reads; list-page attachment is a named follow-on, not this slice.
- Test (packages/core): a session with recorded attempts returns
route_usage.lastServing naming the serving leaf + variant; a session with no attempts carries no route_usage key at all. Oracle: the fleet-queue client's documented derivation in session_model_stamp.
Expected effect once landed + deployed: routed session claims begin stamping claim_variant / real serving leaves (the 0/315 measurement in this issue's evidence should move on the next production window). dezren39 commented on Nov 23, 2026 Lane ZB takeover (archer loop) — adopting Lane NC's orphaned claim under Drew's 2026-11-23 07:35 CST batch approval of the former flag holds.
State verified first-hand: NC's worktree ~/wt-lane-nc-2696 sits untouched at the recorded base 7403b84a0d (clean tree, no diff) — nothing was implemented, exactly as NC's hold record states. There is no prepared code to adopt; the prepared scope is NC's recorded 4-step plan, which I will execute verbatim:
packages/schema/src/session.ts: RouteUsage struct mirroring ModelUsage.LastServing + optional route_usage on Info (absent — never null/partial — until a real serving leaf exists).
packages/core/src/session/info.ts: fromRow gains an optional serving parameter mirroring authoritative; set route_usage only when a last-serving leaf exists.
packages/core/src/session/store.ts get: also fetch ModelRouteLog.sessionAttempts(db, row.id, 50), derive ModelUsage.lastServing(rows), pass through. Single-session GET only; list-page attachment is a named follow-on.
- Test (packages/core): session with recorded attempts returns
route_usage.lastServing naming leaf + variant; session with no attempts carries no route_usage key. Oracle: the fleet-queue client's session_model_stamp derivation.
Verification runs on the laptop (Actions is disabled on this fork). PR + merge once verified; done record will state explicitly what this unblocks for developing-today/code#1340 criterion 1. dezren39 commented on Nov 23, 2026 Lane ZB — done. The prepared slice is landed and this issue's ask is met.
Landed: PR #2754 merged — merge commit 3ad091fb2fd978ff1cabb1a6a862aa6f7c06bff7, head SHA-guarded at 3fa3ac9dd717. Exactly Lane NC's recorded plan, executed verbatim (NC credited for the premise verification and scope; its worktree was verified untouched at the recorded base before adoption):
packages/schema/src/session.ts: Session.RouteUsage struct mirroring ModelUsage.LastServing + optional route_usage on Session.Info, following the costAuthoritative pattern.
packages/core/src/session/info.ts: fromRow gained an optional serving parameter mirroring authoritative; route_usage is set only when a last-serving leaf exists.
packages/core/src/session/store.ts: get also fetches ModelRouteLog.sessionAttempts(db, row.id, 50) and derives ModelUsage.lastServing(rows) at read time — so the record names the leaf serving at read time and updates as the serving leaf changes, per the ask.
- Test:
packages/core/test/session-route-usage.test.ts.
Contract honoured: the field is absent — never null/partial — until the session has a recorded attempt (a present-but-unparseable readout would stamp nothing in the consumer). The no-attempts test asserts the key is missing from the schema-encoded record, not merely undefined in memory.
Verification (laptop route; Actions is disabled on this fork): new suite 2/2; model-usage + route-usage-tool + model-route-log 81/81; session-compaction + session-context-vars + session-execution 98/98 including the new suite; packages/schema typecheck clean (141 files), packages/core typecheck clean (2,284 files). Fix confirmed present on main at the merge commit by read-back.
Named follow-ons (not this slice, unchanged from NC's record): list-page attachment of route_usage (the list path still passes no serving readout). Separately: regenerating packages/protocol/openapi.json produces a ~1,600-line diff of which only 3 lines are this change — the checked-in spec was already stale on main (e.g. the /api/route/attempts endpoints from #2497 are absent from it), so the resync was deliberately kept out of this PR and belongs in its own pass.
What this means for developing-today/code#1340 criterion 1: the server-side blocker is gone from the code. The fleet-queue client's derivation (session_model_stamp) already prefers route_usage.lastServing and needs no change. Criterion 1 becomes meetable once a server build carrying this merge is the deployed one and routed sessions have run against it — the 0/315 claim_variant measurement in this issue's evidence should move on the first production window measured after that deployment. Nothing else is owed from this issue for #1340.
Closing as completed: the ask — surface route_usage.lastServing (providerID + modelID + variant) on the session record, updated as the serving leaf changes — is implemented, tested, and on main.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|