Skip to content

feat(control-plane): resolve an async turn's credential at dequeue (#388 M1) - #713

Merged
cwiklik merged 6 commits into
rossoctl:mainfrom
cwiklik:feat/388-dequeue-credential-exchange
Nov 10, 2026
Merged

cwiklik merged 6 commits into
rossoctl:mainfrom
cwiklik:feat/388-dequeue-credential-exchange

Conversation

@cwiklik

@cwiklik cwiklik commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds POST /internal/turn-credentials, the dequeue-time credential exchange for async turns: a worker that has just taken a turn id off the Redis stream presents it plus the deployment-wide SH_EXCHANGE_TOKEN, and the control plane resolves the credential that turn spends from the turn record it itself wrote at the authenticated enqueue. MI1 §6.5 forbids any bearer token being stored in the work queue, and at dequeue there is no session token left to present.

This is the M1 interim slice of #388 (async spec §9.1, ADR-0047:126-128), not S2's full grant machinery. It is MOCA_TENANCY=single only — multi is refused with async_tenancy_unsupported — and there are no grants, no turn_exp and no refresh endpoint. Those are M2, and #388 stays open as their tracker, the same shape as #387.

The endpoint is a pure read. The queued → running transition stays with #389's consumer, which already holds deliveryCount. A shared-bearer caller must not be able to mutate turn state: since cancel accepts queued only, a write here would let any holder of the deployment secret make a turn permanently uncancellable. markRunning re-checks terminality itself, so no window opens by leaving it there.

Six checks, each failing closed, in order: the record exists (turn_not_found, 404) → its state is not terminal (turn_not_claimable, 409) → the session exists and the owner matches (session_not_found) → the session is not tombstoned (session_not_found) → tenancy is single (async_tenancy_unsupported, 501) → resolveInference(record), reusing the live exchange's existing codes. Unknown-session and owner-mismatch answer identically, with nothing to distinguish them. The audit write is deliberately not best-effort, unlike the submission routes: it is the only record that a credential left the control plane, so a failed write refuses the credential rather than issuing one off the books. The audit entry carries the credential's name, never its value.

Per §5.4 the state gate admits running, not just queued: the first claim writes running, so every redelivery — crash-reclaimed (§6.2), drained (§6.3), or retryable — arrives already running, and refusing those would ack and drop them. Attempt exhaustion stays the queue's call; deliveryCount is the single authority and the mint never tests attempts.

No boot contract changes — no new environment variable, no entrypoint, unit, env example or launcher touched. The only caller arrives in #389.

Satisfies 3 of #388's 4 acceptance criteria: no bearer token in the queue (the e2e test asserts the stream entry's fields are exactly ['turnId']), a tombstoned session's queued turn is refused, and the interim path is refused under multi. "Refresh refused after turn_exp" is left to M2 because there is no grant to refresh.

Closes nothing — #388 remains open for M2.

Checklist

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md).
  • Docs: make check-links passes if any Markdown changed.
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md.

Evidence: control-plane 1152 passed / 3 skipped, knative-server 438 passed, make typecheck clean,
make check-links clean (198 files, 0 broken links). openapi-contract.test.ts green at 16/16, so the
route, its operationId and both new error codes are documented without drift. make lint reports two
pre-existing failures only: the check-yaml parse error at docs/api/openapi.yaml:1501 (verified
byte-identical before this branch) and the second long-documented one. No spec or ADR is added here —
this implements existing ones.

Assisted-By: Claude Code

…record

The M1 interim of async spec §5.4: a worker holding only a turn id exchanges
it for the credential that turn spends, so no bearer token is ever stored in
the work queue (MI1 §6.5).

exchangeTurnCredential reads the turn record the control plane itself wrote at
the authenticated enqueue. There is no session token at dequeue, and minting
one for a worker would put a credential-bearing token in the queue, which is
the one thing §6.5 forbids. Everything after deciding which subject and
credential are in play is shared with the session exchange (resolveInference,
refuseMisdirectedSecret, placeholderFor, sessionTier), so an async turn spends
exactly the credential an interactive one would.

The checks, each failing closed: the record exists (turn_not_found); its state
is neither cancelled nor terminal (turn_not_claimable, admitting `running`
because every redelivery arrives on a record that already says it, and
ignoring `attempts` because the queue entry's deliveryCount is the only
authority on exhaustion); the session exists and its owner matches the
record's (session_not_found -- the owner compare is load-bearing, since
resolveInference reads the owner off the record it is handed); the session is
not tombstoned; tenancy is single, checked before anything resolves a secret.
The audit is not best-effort: it is the only record that a credential left the
control plane, so a failed write refuses the credential rather than issuing
one off the books. A thrown non-CpError from that audit write is normalized to
a bare internal_error locally (not re-mapped to redis_unavailable, which stays
OwnershipIndex.guard's job for a real outage) because this function is called
directly in tests rather than through server.ts's catch-all.

The call READS. queued -> running stays with rossoctl#389's consumer: a shared-bearer
write here would let any holder of SH_EXCHANGE_TOKEN flip an arbitrary turn
out of queued and -- since cancel accepts queued only -- make a caller's own
turn uncancellable. markRunning re-checks terminality itself, so a DELETE
landing in between is still refused there.

turn_exp, the moca-grant key ring and refresh are M2 (§9.1) and deliberately
absent.

Refs rossoctl#388, rossoctl#686

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
…n-credentials

The route beside /internal/credentials, on the same shared bearer, because it
is the same hop: the data plane asking the control plane for the credential a
turn spends. It differs only in what it presents -- a turn id instead of a
session token -- because at dequeue no session token exists, and minting one
into the queue is what MI1 §6.5 forbids.

The body is { turnId } and nothing else. Everything else the worker needs comes
from the record the control plane wrote at the authenticated enqueue, which is
what makes a queue entry carrying one id sufficient (§5.1).

Router auth is per-route data, so auth: 'exchange' is the whole authentication
change: the router runs checkExchangeAuth and marks the request before the body
is parsed, and the handler re-checks the mark because a handler reached without
it is a routing bug. The route-table test now pins the exchange-auth routes as
a list rather than a count -- a third route quietly joining this auth kind
would be reachable by anything in the harness pod, which is the one property
the shared bearer cannot defend on its own.

openapi-contract.test.ts fails on this commit by design: the drift test demands
documentation for every route in the table, and the docs land with the rest of
the surface in the next commit.

Refs rossoctl#388, rossoctl#686

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
The fake worker now gets its credential the way rossoctl#389's drain loop will: one
turn id off the stream, one shared bearer, one POST /internal/turn-credentials
against a control plane backed by real Redis. Nothing else is handed to it.

This is the half that makes the file's central assertion survivable rather
than merely true. "The queue carried a turn id and nothing else" is only a
workable design because the credential can be fetched from the record
afterwards, and until now no test performed that fetch.

Three refusals asserted over HTTP, each for a case the queue cannot express on
its own, because in all three the entry OUTLIVES the thing that should have
stopped it:

- a cancelled turn answers 409 turn_not_claimable, which is what makes §4.5's
  withdrawal effective at all -- cancel flips the record and never reaches
  into the stream;
- a turn whose session was DELETED answers 404 turn_not_found, so a cascade
  cannot be outrun by a worker that already holds the id (the record itself is
  gone, because deleteSession also reclaims the session's open turns);
- every claim under MOCA_TENANCY=multi answers 501, including for turns queued
  before the switch, which is the only way that state is reachable since
  submitTurn refuses multi outright (MI1 §6.6).

Each refusal is also asserted to carry no credential in its body.

The suite now configures an exchange bearer: makeDeps leaves exchangeToken
undefined and checkStaticBearer rejects every call when none is set, so
without it the route would 401 unconditionally and the tests would pass for
the wrong reason.

Refs rossoctl#388, rossoctl#686

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
…utes never got

POST /internal/turn-credentials in openapi.yaml with its five refusals, plus
turn_not_claimable and turn_not_found in the Error enum, which is what takes
openapi-contract.test.ts back to green: it compares the documented routes,
operationIds, security schemes and error codes against the server's own tables
in both directions.

The version goes to 1.3.0 and the changelog section covers rossoctl#387's three /v1
turn routes as well as this one. rossoctl#387 added them to the document and touched
neither info.version nor the changelog, so 1.2.0 currently describes three
routes it does not claim. Recording only the internal route here would leave
three public routes permanently absent from the version history, which is the
one thing a changelog exists to prevent.

The interim shape is documented as interim: a resolved credential rather than
MI1 S2 grants, no turn_exp, and MOCA_TENANCY=multi refused at both the
submission and the claim, with M2 named as what lifts the gate.

security-model.md gains the async credential path as its own numbered step,
because it differs from the interactive one in the premise rather than the
detail: there is no session token at dequeue, so the worker presents a turn id
and the control plane checks claimability and ownership before resolving the
name. It also says plainly what the shared bearer is: one deployment-wide
value, so any holder can resolve any credential whose turn id it can name.

Refs rossoctl#388, rossoctl#686

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
- Re-export exchangeTurnCredential and TurnExchangeResponse from
  packages/control-plane/src/index.ts so rossoctl#389's consumer in
  knative-server can import it instead of deep-importing or
  hand-copying the interface.
- Fix two turn-exchange.test.ts titles that claimed 503 where the
  assertion (and errors.ts) say internal_error maps to 500; reword
  the self-contradictory "rather than 500ing" phrasing.
- Add the missing '500' response (internal_error) to the
  /internal/turn-credentials path in docs/api/openapi.yaml, between
  '501' and '503' per the block's numeric ordering.
- Note in errors.ts that the harness's own turn_not_found (knative-
  server) is a distinct code at a distinct hop, not shared state.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
@cwiklik
cwiklik requested a review from pdettori as a code owner November 10, 2026 18:10
`refuseMisdirectedSecret` is shared with the session exchange, so every test
that covered it lived on the session path: deleting the call from
`exchangeTurnCredential` left the whole control-plane suite green at 1152.
The check is the one that stops direct mode sending a raw Anthropic key to a
gateway that cannot read it (spec §6.2, rossoctl#368), and rossoctl#389 is about to become
this function's first caller.

The new test seeds exactly that credential -- `sk-ant-api...` with a
litellm endpoint -- queues a turn on it and asserts the async path refuses
with `credential_required`, naming the credential and never the key.
Verified load-bearing: with the call removed it is the only failure in the
file, and with it restored the suite is 1153.

Also records why `sandboxTier` and `model` are read from the live session
while `credentialName` and `cfg` are pinned to the record, and what that
costs when a session is PATCHed between submission and dequeue.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
@cwiklik cwiklik added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 10, 2026

@clawgenti clawgenti 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.

Summary

Adds POST /internal/turn-credentials, the M1-interim dequeue-time credential exchange. It is a pure read that resolves the credential from the turn record. The checks closely mirror exchangeCredential: owner compare, tombstone, refuseMisdirectedSecret, placeholder-wins, and an audit write that must succeed. The multi tenancy gate correctly runs before resolveInference. Tests cover each refusal path, the running redelivery case and audit failure. No blocking issues; two small notes inline. All checks pass. Ready for human review.

Author: cwiklik (CONTRIBUTOR — returning external; every changed source file was read in full)
Areas reviewed: TypeScript (control-plane src + tests), Docs/OpenAPI, Security
Agent/IDE config (.claude/.vscode): none
Commits: 6 commits, all signed-off: yes
CI status: passing (17/17)

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

// `owner` and `credentialName` off the record it is HANDED, so a turn record whose owner does not
// match its session's would otherwise be a request for whichever subject's credential it names.
if (!rec || rec.owner !== turn.owner) {
throw new CpError('session_not_found', undefined, turn.sessionId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: The comment above says unknown-session and owner-mismatch are the same answer, and they are. But this refusal (and the one at L87 and the turn_not_claimable one at L70) passes turn.sessionId, so toBody echoes the turn's session id to the caller. Any SH_EXCHANGE_TOKEN holder can already resolve credentials, so this adds little exposure. If the goal is a body that leaks nothing beyond the code, though, drop the third argument on the refusal paths.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping the behavior, changing the doc — #714. A refused worker wants the session id in its log line to record which session it dropped an entry for, and as you note the caller already holds SH_EXCHANGE_TOKEN, so there is nothing here it could not get from a successful call. What was wrong was the claim above it, which @ingpaolodettori-dev pinned in the thread on openapi.yaml: the refusals are not indistinguishable and this is not spec §8.1's rule. Both openapi.yaml and the errors.ts comment now say the true, narrower thing.

Comment thread docs/api/openapi.yaml
'404':
description: |
`turn_not_found` for an id with no record, and `session_not_found` when the turn's session
is gone, tombstoned, or owned by someone else. Both are 404 and deliberately

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: "deliberately indistinguishable from each other in kind" reads as if a caller can't tell the two cases apart. The codes differ (turn_not_found vs session_not_found), so a caller can tell "no such turn" from "turn exists, session gone/not owned". Only the status matches. Consider saying "both are 404" without the indistinguishability claim, or noting that the code tells them apart.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Correct, and fixed in #714. The codes do tell the two cases apart, and the 409 goes further by naming the state in its message — only the status matches on two of the three. The description now says both are 404, drops the indistinguishability claim, and states what actually holds: no refusal reveals anything a successful call would not have given the same SH_EXCHANGE_TOKEN holder. The matching comment at errors.ts had the same wrong claim and got the same correction.

@ingpaolodettori-dev ingpaolodettori-dev 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.

No blocking issues. The new POST /internal/turn-credentials closely matches exchangeCredential: placeholder/direct mode, the misdirection check, a fail-closed audit that records only the credential name, and touchBundle. Its gates are fail-closed and correctly ordered. The multi refusal comes before resolveInference, running is admitted for redelivery, and the owner and tombstone checks are re-run against the live session. Tests cover each gate, the audit-failure path, and the e2e claim that only turnId travels in the queue.

Author: cwiklik (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane), OpenAPI/docs, security
Agent/IDE config (.claude/.vscode): none
Commits: 6, all signed-off: yes
CI status: passing

A few doc-accuracy and hardening notes inline, none blocking.

Comment thread docs/api/openapi.yaml
description: |
`turn_not_found` for an id with no record, and `session_not_found` when the turn's session
is gone, tombstoned, or owned by someone else. Both are 404 and deliberately
indistinguishable from each other in kind: a shared-bearer caller gets no existence

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: "deliberately indistinguishable … no existence oracle" doesn't hold as written. A holder of the exchange bearer can tell turn_not_found (no record) from session_not_found (record exists, and the body carries its sessionId) and from 409 turn_not_claimable (record exists, and the message names its state). The worker legitimately needs those distinctions (drop vs. drop vs. drop-with-reason), and the caller already holds a deployment-wide secret that returns the credential on success, so the behavior is fine. Please reword the doc (and the matching comment at errors.ts:115) to say what is actually true: the answers carry no information beyond what a successful call would give the same caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Taken as written, in #714. Your sentence is close to verbatim in both places: the answers carry no information beyond what a successful call would give the same caller. I added one thing to each — that this is explicitly not spec §8.1's 404-rather-than-403 rule, since that rule governs the owner-scoped /v1 routes a session token reaches and citing it here was the root of the confusion. openapi.yaml:310's §8.1 claim is about that rule and is correct, so it stays.

And agreed that the worker needs the three distinctions; the new text says so as the reason they are deliberately distinguishable rather than apologizing for it.

throw new CpError('unauthorized', 'exchange authentication failed');
}
const turnId = asRecord(ctx.body).turnId;
if (typeof turnId !== 'string' || turnId.length === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: submitTurn always mints t-${randomUUID()}, so this could refuse anything outside ^t-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ with invalid_request before it touches Redis. It's cheap hardening. As written, any string (including : segments that interact with keyTag) goes into an HGETALL sh:cp:turn:<input>. It's harmless today because get requires owner and only reads, but bounding the key space on a shared-bearer route is the safer default. UUID_RE already exists in sandbox-handlers.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in #714. isMintedTurnId refuses anything outside ^t-<uuid>$ with invalid_request before Redis is touched.

Two deviations from the suggestion, both deliberate. It lives in turn-record.ts beside turnKey rather than reusing sandbox-handlers.ts's UUID_RE, which is unexported and does not carry the t- prefix that is this module's own minting contract. And the owner-scoped /v1 turn routes deliberately do not get the gate: there a malformed id has to stay a 404, indistinguishable from another subject's turn, or the error code becomes the oracle assertOwner exists to deny. Only the shared-bearer dequeue route uses it.

Your reading that it is harmless today is why it is framed as bounding the key space rather than as a fix: get only reads, and the handler re-checks the record's owner against its session. Verified load-bearing by mutation — with the gate removed, exactly one test fails and it is the new one. Worth noting server.test.ts's unknown-turn case used t-nobody, so the gate would have answered first and silently stopped that case covering the 404; it now uses a well-formed id.

// model, which updateSession's own "a turn in flight keeps its model" does not cover because an async
// turn's exchange can be an hour after its submission. Pinning them means adding both to the record
// (M2/#389), not reading them from a different place here.
const tier = sessionTier(rec, deps.config.sandboxTiers);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: thanks for writing up the live-session read of model/sandboxTier so clearly. Could you make sure there's an explicit checkbox on #389 or the M2 tracker to pin both on the record? docs/reference/http-api.md still says "A turn already running keeps its model; the next turn uses the new one". For an async turn that is queued (not running), a PATCH now moves it onto the new model, so a short note there would also help users.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both done. #388 now has an explicit M2 remainder checklist, and pinning model/sandboxTier on the record is one of its four checkboxes — with the reason it is M2 rather than a different read here, since it means adding both fields to the record. It also gained an acceptance line: a turn queued before a PATCH still runs on the model it was submitted with. I put it on #388 rather than #389 for that reason; #389 is the consumer and cannot pin what the record does not carry.

The http-api.md note is in #714. That sentence now continues: a queued async turn is a next turn, not a running one, so it picks up the new model whenever a worker claims it, however long ago it was submitted — with a pointer to #388 for the pinning work.

`digest_mismatch`, `configRef_invalid`, `credential_required`, `credential_ambiguous`, `endpoint_unresolved`, `model_unavailable`), 401 (`token_required`,
`token_invalid`, `token_expired`, `unauthorized`), 403 `forbidden`, 404 (`session_not_found`, `config_bundle_not_found`,
`credential_not_found`), 410 `device_code_expired`, 428 `authorization_pending`, 429
`credential_not_found`, `turn_not_found`), 409 (`turn_not_cancellable`, `turn_not_claimable`), 410 `device_code_expired`, 428 `authorization_pending`, 429

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: since this line is being touched for the 1.3.0 codes, consider adding the other async codes the same changelog introduces: 429 async_quota_exhausted, 501 async_tenancy_unsupported (and workload_runs_unavailable). The list says it may be incomplete, but it's cheap to keep it in step.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in #714: 429 gains async_quota_exhausted beside bundle_quota_exceeded, and there is now a 501 group with async_tenancy_unsupported and workload_runs_unavailable — the list had no 501 entry at all, so all three were missing rather than just the one.

@cwiklik
cwiklik merged commit bb89a84 into rossoctl:main Nov 10, 2026
17 checks passed
@rubambiza

rubambiza commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

@cwiklik Did you intend to merge the PR without addressing any of the comments from @clawgenti and @ingpaolodettori-dev? 👀 I came here to insert a marker that the agent missed, and that's how I noticed the merge

@cwiklik

cwiklik commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@rubambiza Fair question, and the honest answer is that I merged on @ingpaolodettori-dev's approval without walking the inline threads first. Both reviews said no blocking issues, and I took that as the whole verdict. That was my miss, not the reviewers' — six useful notes went in unanswered.

I have now gone through all six against the code. None of them changes behavior on the claim path, but four are accurate corrections and one is worth hardening, so they are going into a follow-up PR rather than being folded into #389 — these are doc accuracy plus one guard clause, and burying them under the drain loop would make both harder to review.

What the follow-up carries:

  • The 404/409 descriptions are wrong, in two places. openapi.yaml and the comment at errors.ts:113-115 both claim the answers are "deliberately indistinguishable" and give "no existence oracle". They are not indistinguishable: turn_not_found, session_not_found and 409 turn_not_claimable are three different codes, and the 409's message names the state. Only the status matches on two of them. @ingpaolodettori-dev's rewording is the right one — the true claim is that the answers carry no information beyond what a successful call would give the same caller, which is a deployment-wide secret holder who gets the credential on success.
  • A turnId shape gate before Redis (@ingpaolodettori-dev on handlers.ts:1109). turn-handlers.ts:123 is the only minter and it is always t-${randomUUID()}, so anything else can be refused invalid_request before an HGETALL sh:cp:turn:<input>. Read-only and owner-checked today, so this is bounding the key space on a shared-bearer route rather than closing a hole. Reusing the UUID_RE already in sandbox-handlers.ts:34.
  • http-api.md code list gains 429 async_quota_exhausted and a 501 group (async_tenancy_unsupported, workload_runs_unavailable) — codes the same 1.3.0 changelog introduced.
  • http-api.md's "a turn already running keeps its model" gains the queued-async-turn caveat: a PATCH does move a queued turn onto the new model, which that sentence does not cover.

On @clawgenti's note about the refusal paths passing turn.sessionId into the error body: I am leaving that behavior as it is, and I think @ingpaolodettori-dev's read is the right one. A worker that gets refused wants the session id in its log line, and the caller already holds SH_EXCHANGE_TOKEN. The fix there is the doc, which is item 1.

The model/sandboxTier pinning checkbox @ingpaolodettori-dev asked for goes on #388's M2 list rather than #389, since pinning means adding both to the turn record.

Sorry about the review marker — let me know what it was meant to be and I will put it in the follow-up PR, or on #388 if it belongs on the tracker.

Assisted-By: Claude Code

@rubambiza

Copy link
Copy Markdown
Contributor

@cwiklik Addressing them in a follow-up PR sounds good to me. No worries about the review marker. I think it's a bug on repoman that I need to address, but it gives me evidence of it.

cwiklik added a commit that referenced this pull request Nov 10, 2026
…e list

Review follow-ups from #713, none of which changes behavior.

The 404 description in openapi.yaml and the comment at errors.ts both claimed
the claim refusals are "deliberately indistinguishable" and give "no existence
oracle". Neither holds as written: turn_not_found, session_not_found and 409
turn_not_claimable are three different codes, and the last one's message names
the state. Only the status matches on two of the three, and a worker needs them
apart to record why it dropped a queue entry.

What is actually true is narrower and enough: every caller on this route
authenticated with the deployment-wide SH_EXCHANGE_TOKEN, and a successful call
hands back the credential itself, so no refusal reveals anything the same caller
could not already obtain. Both places now say that, and both note this is NOT
spec §8.1's 404-rather-than-403 rule, which governs the owner-scoped /v1 routes
a session token reaches.

http-api.md's code list also missed codes the same 1.3.0 changelog introduced:
429 async_quota_exhausted and a 501 group (async_tenancy_unsupported,
workload_runs_unavailable).

Refs #713, #388

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
cwiklik added a commit that referenced this pull request Nov 10, 2026
Review follow-up from #713. POST /internal/turn-credentials took any string as
its turnId and built a Redis key from it -- HGETALL sh:cp:turn:<input>, with
TurnStore.tag free to append :${keyTag} besides. submitTurn is the only minter
and its ids are always t-${randomUUID()}, so the shape is knowable and anything
else can be refused before Redis is touched.

This closes no hole on its own: get only reads, and the handler re-checks the
record's owner against its session. It bounds the key space a shared-bearer
route can be made to address, which is the cheaper default there. 400 rather
than 404 because this caller holds the deployment-wide exchange token and gets
the credential on success, so a distinguishable "you sent nonsense" tells it
nothing new and names the actual bug.

isMintedTurnId lives in turn-record.ts beside turnKey rather than reusing
sandbox-handlers.ts's unexported UUID_RE, since the t- prefix is this module's
own minting contract. The owner-scoped /v1 turn routes deliberately do not use
it: there a malformed id must stay a 404, indistinguishable from another
subject's turn, or the code becomes the oracle assertOwner exists to deny.

Verified load-bearing by mutation: with the gate removed, exactly one test fails
and it is the new one. server.test.ts's unknown-turn case now uses a well-formed
id, or the gate would answer first and it would stop covering the 404 at all.

Refs #713, #388

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: cwiklik <[email protected]>
cwiklik added a commit that referenced this pull request Nov 10, 2026
fix(control-plane): #713 review follow-ups — correct the refusal docs, bound the dequeue turn id
pdettori added a commit to pdettori/moca that referenced this pull request Nov 16, 2026
Sixteen ADRs still said Proposed although their decisions are in code
on main. Each status line now names the merged PRs that implemented it
and the date the core landed (format of ADR-0042), and notes what is
still owed where only part is built:

- 0028 (rossoctl#170, rossoctl#201, rossoctl#340; its KEDA transport removed by ADR-0041)
- 0029 (rossoctl#171), 0030 (rossoctl#214), 0031 (rossoctl#214, rossoctl#225)
- 0032 (rossoctl#249, rossoctl#350, as amended by MI1)
- 0035 (rossoctl#251; ADR-0048 adds lease mode beside it)
- 0036 (rossoctl#347), 0038 (rossoctl#458), 0039 (rossoctl#467), 0040 (rossoctl#481)
- 0043 (rossoctl#560, rossoctl#588, rossoctl#600, rossoctl#615), 0044 (rossoctl#563), 0045 (rossoctl#620)
- 0046 (phase 1: rossoctl#630, rossoctl#641, rossoctl#646; phase 2 owed)
- 0047 (M1 and M3: rossoctl#704, rossoctl#713, rossoctl#717, rossoctl#765; M2 owed)
- 0048 (rossoctl#706, rossoctl#763, rossoctl#802, rossoctl#808, rossoctl#814; off by default until the
  security review's lease sections are signed off)

The README index follows, and its 0033 row, which still said Proposed
after rossoctl#249 accepted the ADR, is corrected.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants