Repository navigation
feat: operator fallback on the VM and a curl/git research-turn smoke (#368 phase 2) - #411
Conversation
…; SH_OPERATOR_INFERENCE_HEADER The operator fallback was Bearer-only, so a raw Anthropic operator key could never work, and any mismatch surfaced per turn as a 503 the caller could not act on. The fallback's token, header and endpoint are all deployment settings: check them at startup, naming settings, never values. Also refuses an api.anthropic.com default endpoint with a path (rossoctl#368 phase 1 known minor). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…e operator fallback createSession refused every subject with no inference credential, so the exchange's operator fallback (spec §6.4) was reachable only when a credential was deleted after its session was created. With SH_ALLOW_OPERATOR_FALLBACK=true and an operator token, such a subject now gets a session that records no credential name; the exchange spends the operator's key per turn, audited. An explicitly named credential never falls back. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ential when it exists setup-vm.sh installs a LoadCredential= drop-in for credentials/operator-inference-token when the file exists (0600, non-empty) and removes it when the file goes, since LoadCredential= on a missing file fails the unit. SH_ALLOW_OPERATOR_FALLBACK=true without the file, or the token as an env line, stops the script. The value is never read. control-plane.env.example documents the four settings. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…tainer sandbox One minted user, on its own stored credential or the operator fallback, runs a turn that must git clone rossoctl/moca and curl -o nodejs.org's release index in a container sandbox, then answer from them. Passes only if both commands appear in the SSE tool_use frames without error, the answer equals what the sandbox's own copy of the files says, and the audit shows the intended credential. Gated by VM_RESEARCH_SMOKE=1; a mock-driven test covers it offline (rossoctl#368). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… smoke Says plainly that sandbox egress (instance metadata included) is open in this round, gives the curl/git research prompt the demo runbook will reuse, and documents research-smoke.sh. A test holds the README's prompt equal to the script's (rossoctl#368). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…operator fallback) With no inference credential stored, mocactl blocked before ever calling POST /v1/sessions, so a user on a deployment with SH_ALLOW_OPERATOR_FALLBACK=true could not start a session from mocactl at all (rossoctl#368 review). The inference field now leaves the choice to the server when there is none; a credential_required refusal maps back to the same 'add an inference credential' hint and, in the interactive UI, the same route to the credentials overlay. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… plane The control plane now refuses to boot on an Anthropic API key as the operator token unless SH_OPERATOR_INFERENCE_HEADER=x-api-key, but compose lists the control plane's environment explicitly and never passed that setting, so a compose operator could not satisfy the check (rossoctl#368 review). The .env template and README show both fallback shapes. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…a fallback session later PUT /v1/credentials refuses the name the audit gives the operator's key, so an operator-fallback audit line is never a subject's own credential. A session started on the fallback keeps it (a session's credential is resolved at creation, spec §6.4): pinned by a test, documented, and with the fallback turned off its turns now say to start a new session instead of naming credential '' (rossoctl#368 review). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…env line and a dangling symlink Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ies the session delete A key file with a comment line was detected as one kind and sent as a multi-line secret; now it must be exactly one line. The session delete is retried while the turn's end is still being reported, and a failure to delete is said, not swallowed. The README says how to re-run the demo prompt, whose git clone refuses an existing directory (rossoctl#368 review). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Live results on the KVM rig (Amazon Linux 2023, static podman, systemd 252), 2026-10-01This branch @ The research smoke, real model (Anthropic API, raw
Refusals, live:
Hygiene: the key's prefix appears 0 times in the control-plane, supervisor and relay journals. Neither the smoke output nor its evidence contains it. The rig is restored to #409's setup: that branch is checked out again, |
Resolves deploy/vm/README.md (the egress bullet beside rossoctl#403's two isolation bullets) and deploy/vm/tests/setup-vm.test.sh (the operator-fallback section beside rossoctl#403's seed_control_plane_env section): both sides kept. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
huang195
left a comment
There was a problem hiding this comment.
Two must-fixes, both small:
- The new research-smoke test suite never runs in CI: it SKIPs on the deploy-scripts runner, which has no tsx.
- setup-vm.sh refuses every symlinked operator token, and the remedy it prints loops.
The control-plane and mocactl changes check out:
- The boot check and the exchange share
directModeMismatchon the same base URL. - A fallback session's
''round-trips through the ownership index. credential_requiredreaches mocactl with its message, and onlyPOST /v1/sessionscan raise it there.- The smoke's assumptions (SSE frame shapes, audit fields, pool record ids, Redis keys,
/v1/turn) match the code.
Not in the diff: deploy/knative/control-plane.yaml:228 still says the fallback needs SH_OPERATOR_INFERENCE_TOKEN. After this PR it also needs SH_DEFAULT_INFERENCE_ENDPOINT, or the control plane won't boot.
Checked locally at 3b22c92:
- The four touched control-plane vitest files pass (54 tests).
- research-smoke.test.sh and the setup-vm operator-token cases pass.
- shellcheck
-S warningis clean on the three scripts. - The symlink and named-credential findings have repros.
| fails=$((fails + 1)) | ||
| fi; } | ||
| command -v node >/dev/null || { echo "SKIP: node not installed"; exit 0; } | ||
| [[ -x "$REPO/packages/control-plane/node_modules/.bin/tsx" ]] || |
There was a problem hiding this comment.
must-fix — this suite never runs in CI. deploy-scripts runs make test-deploy with no pnpm install (by design: ci.yml says those tests need no node or pnpm), and check runs pnpm -r test, not make test. This PR's own run shows it: == deploy/vm/tests/research-smoke.test.sh then SKIP: packages/control-plane has no tsx (run pnpm install), exit 0.
So the argv/secret-hygiene checks, the cleanup checks, the failure scenarios and the README/script prompt parity ("A test holds it equal to the smoke's") are enforced only on a laptop with a built workspace. An edit to either prompt passes CI today.
Options: run this file from check after pnpm install, or install just tsx in deploy-scripts. Either way, the checks that need no tsx (the gate, gw-noep, multi, nokey, the prompt parity) could run above the skip, the way setup-vm.test.sh skips only its one real-genkeys check. Failing instead of skipping under CI=true would keep this from regressing silently.
There was a problem hiding this comment.
Fixed in e28f3f2.
- The checks that need neither node nor tsx now run above the skip, so they also run in
deploy-scripts: the gate, the no-key / multi-line / whitespace / gateway-without-endpoint refusals, an unreadable pool, and README/script prompt parity. That's 20 checks. - The mint-driven rest runs from a new
checkstep afterpnpm install, withMOCA_REQUIRE_WORKSPACE=1. There a missing tsx is a failure, not a skip, so it can't go quiet again. - Simulated locally by hiding
packages/control-plane/node_modules/.bin/tsx: plain, the early checks pass and the rest is SKIP; with the flag, it fails.
| } | ||
|
|
||
| # file_mode <file>: its permission bits in octal (GNU stat, then BSD stat for the macOS test run). | ||
| file_mode() { stat -c '%a' "$1" 2>/dev/null || stat -f '%Lp' "$1"; } |
There was a problem hiding this comment.
must-fix — stat -c '%a' and stat -f '%Lp' report the symlink's own mode (777 on Linux), not its target's. So a symlink to a 0600 key is always refused. The message's remedy, sudo chmod 0600 $f, changes the target, so every re-run fails the same way. The dangling-symlink message at :595 tells the operator to "Point it at the operator's inference key", which leads straight here.
Repro: source with SH_SOURCE_ONLY=1 and make the token path a symlink to a 0600 file. The function prints … is mode 755: … must be 0600 or 0400 with rc=1, does the same after the suggested chmod, and writes no drop-in.
LoadCredential= follows symlinks, so stat -L in both forms fixes it. A live-symlink case beside the dangling one in setup-vm.test.sh would hold it. If symlinks are meant to be refused, the :595 message should say so instead.
There was a problem hiding this comment.
Fixed in 0b97aa4. file_mode now uses stat -L in both forms, so a symlink is judged by its target, as LoadCredential= reads it.
New case beside the dangling one:
- a link to a 0600 key passes and gets the drop-in;
- a link to a 0644 key is refused, reporting
mode 644; - after the advised
chmod 0600, the re-run passes, so the remedy no longer loops.
| const credentialName = resolveInferenceName(descriptors, requested); | ||
| // The operator fallback (spec §6.4) is for a subject with no inference credential of its own: such | ||
| // a session records NO credential name, and the exchange resolves the operator's key per turn, | ||
| // attributably. An explicitly requested name never falls back -- a typo must 400, not spend the |
There was a problem hiding this comment.
suggestion — "An explicitly requested name never falls back" holds only at creation. At exchange time (exchange.ts:152), any session whose recorded credential is gone takes the operator's key.
A probe: create a session with credentials.inference: 'my-anthropic', delete that credential, exchange. The exchange returns op-gw-token, and the audit reads session_created/my-anthropic, then operator_fallback_used/operator-fallback.
That predates this PR, but it contradicts README.md:317 ("A session's credential is fixed when the session is created"). The case that matters is a user deleting a leaked key mid-session: their session carries on, on the operator's bill.
Now that fallback sessions record '', the exchange could fall back only when !rec.credentialName and refuse otherwise ("no usable inference credential 'X'"). That changes the tests that reach the fallback through delete-after-create (exchange-auth-header.test.ts, including the new x-api-key case). If the current behaviour is intended, it's worth a line next to README.md:317 and a narrower comment here.
There was a problem hiding this comment.
Took the stricter version, in d917999. The exchange now falls back only when !rec.credentialName, i.e. a session created on the fallback.
- A session that named a credential which has since been deleted is refused with
credential_required, naming the credential. That's the leaked-key case: the session stops instead of moving onto the operator's bill. - New test in
operator-fallback-session.test.ts: your probe, asserting nooperator_fallback_usedaudit entry. - The fallback tests that reached the fallback by delete-after-create (
exchange.test.ts, and three inexchange-auth-header.test.tsincluding the x-api-key case) now create the session with no credential at all, the way a user reaches it. - README.md now says the creation-time binding holds in both directions, and the comment here says so too.
| "re-run." >&2 | ||
| return 1 | ||
| fi | ||
| rm -f "$dropin_dir/$OPERATOR_DROPIN" |
There was a problem hiding this comment.
suggestion — until this PR, main's README (f1435e4, 2026-09-30) told operators to sudo systemctl edit sh-control-plane.service and add this same LoadCredential= line. That writes sh-control-plane.service.d/override.conf, and nothing here looks at it.
While the token exists, the unit carries the line twice. After the new "delete the file and re-run", this removes only 50-…conf, the rmdir below fails silently, and the stale override fails the unit on the missing file (the premise of the comment at :577).
The window is small, but a grep of the drop-in dir for any other SH_OPERATOR_INFERENCE_TOKEN LoadCredential= (refuse, naming the file) closes it.
There was a problem hiding this comment.
Fixed in 0b97aa4. ensure_operator_fallback now greps the drop-in dir for any other *.conf with a LoadCredential=SH_OPERATOR_INFERENCE_TOKEN: line, and refuses, naming the file, whether or not the token exists.
It's the operator's file, so the script names it and tells them to drop the line rather than editing it. The README's stop list mentions the old systemctl edit override.conf. Tested with the token both present and absent.
| fi | ||
| if [[ -s "$OUT/api.hdr" ]]; then | ||
| if [[ -n "$SID" ]]; then | ||
| # The worker may still be reporting the turn's end, and the control plane refuses to delete a |
There was a problem hiding this comment.
nit — deleteSession never refuses an in-flight session: it cascade-deletes and answers 202 (handlers.ts:333-344), which this loop already accepts. The retry is harmless for a 5xx or a network error. But this comment, and the test's 409 turn_in_flight mock (research-smoke.test.sh:115), describe a response the control plane doesn't have.
There was a problem hiding this comment.
Right, thanks. Fixed in e28f3f2. The comment now says deleteSession cascade-deletes mid-turn (202), so the retry only covers a 5xx or a dropped connection. The mock answers 503 instead of an invented 409 turn_in_flight (MOCK_SESSION_DELETE_FAIL).
| # One line, so the kind detected here and the secret node sends below are the same string. | ||
| [[ "$(grep -c . "$RESEARCH_CREDENTIAL_FILE")" == 1 ]] || | ||
| die "RESEARCH_CREDENTIAL_FILE must hold exactly one line: the key, and nothing else" | ||
| if grep -q '^sk-ant-api' "$RESEARCH_CREDENTIAL_FILE"; then |
There was a problem hiding this comment.
nit — bash detects the kind on the raw line, but node sends its .trim() (:193). A key file with leading whitespace is detected as bearer, so it demands RESEARCH_ENDPOINT, yet stored as api-key for api.anthropic.com. That is not the "same string" the comment at :141 promises. Either refuse surrounding whitespace in the one-line check, or normalise both sides the same way.
There was a problem hiding this comment.
Fixed in e28f3f2. The one-line check now also refuses leading or trailing whitespace on the key line, a CR from a Windows editor included. So bash's kind detection and node's trimmed value are the same string. Test: a key with a leading-space line is refused before any request.
| [[ "$boxes" -ge 1 ]] && ok "$boxes running sh-sandbox-* container(s)" || ko "no running sh-sandbox-* container" | ||
| # One tier per host (deploy/microvm/P4-ON-P6.md): with a microVM worker attached the turn may land in | ||
| # a guest with no network (#277), and this smoke would fail for a reason that is not the one it tests. | ||
| others="$(podman exec sh-redis redis-cli HKEYS sh:sandbox:records 2>/dev/null | grep -v '^sh-sandbox-' | grep -v '^$' || true)" |
There was a problem hiding this comment.
nit — this check fails open. If podman exec sh-redis redis-cli fails (stderr is discarded), others is empty and the run reports "every pool record is a container sandbox". The audit check at the end still fails, so this only costs diagnosis. Checking the exec's exit status separately would keep the message honest.
There was a problem hiding this comment.
Fixed in e28f3f2. The pool records are read first, checking the exec's exit status, and filtered second. A failed podman exec sh-redis redis-cli now reports "could not read the pool records from sh-redis: …" with its stderr, and no turn runs. Test: MOCK_REDIS_FAIL asserts that message, and asserts the all-container claim is absent.
| fi | ||
| return 0 | ||
| fi | ||
| if [[ "$(env_file_value SH_ALLOW_OPERATOR_FALLBACK "$cp")" == true ]]; then |
There was a problem hiding this comment.
nit — env_file_value matches ^KEY= only, while :588 accepts leading whitespace on purpose (systemd's EnvironmentFile= does). An indented SH_ALLOW_OPERATOR_FALLBACK=true with no token file passes here and removes the drop-in, and then the control plane refuses to boot. That's fail-safe thanks to checkInferenceConfig, just inconsistent with :588.
There was a problem hiding this comment.
Fixed in 0b97aa4. A new operator_fallback_value reads SH_ALLOW_OPERATOR_FALLBACK with leading whitespace allowed, matching the token-line guard. It strips a matched pair of quotes, as env_file_value does. An indented SH_ALLOW_OPERATOR_FALLBACK=true with no token file now refuses, naming the file. Tested.
rossoctl#411 review) deploy-scripts has no node or pnpm, so the whole suite skipped there and nothing in CI enforced it. Its checks that need neither (the gate, the key-file refusals, prompt parity, an unreadable pool) now run above the skip; the rest runs from the check job, after pnpm install, with MOCA_REQUIRE_WORKSPACE=1 turning a missing tsx into a failure. Also from the review: a key line with surrounding whitespace is refused (grep and node's trim disagreed on it); a failed read of the pool records says so instead of reporting an all-container pool; the session-delete retry's comment and mock describe the 202/5xx the control plane really answers. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…e a second drop-in (rossoctl#411 review) file_mode reported a symlink's own mode (777), so a link to a 0600 key was always refused and the printed remedy (chmod the path) looped. It now follows the link, as LoadCredential= does. Also from the review: another drop-in loading SH_OPERATOR_INFERENCE_TOKEN -- the systemctl edit override.conf the README described before -- is refused, naming it, since it doubles the line and outlives the token; and an indented SH_ALLOW_OPERATOR_FALLBACK line counts, as systemd's EnvironmentFile= reads it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…that named no credential (rossoctl#411 review) The exchange took the operator's key for ANY session whose recorded credential was gone, so a user who deleted a leaked key mid-session carried on on the operator's bill, contradicting 'a session's credential is fixed at creation'. Only a session created on the fallback (credentialName '') falls back now; one that named a credential is refused, naming it. The fallback tests reach it the way a user does -- no credential at all -- instead of by deleting one after creation. Also: control-plane.yaml's comment names everything a fallback-on control plane now needs to boot. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Thanks for the thorough review. All eight inline items and the out-of-diff note are addressed, in three commits: Must-fixes:
Suggestions:
Nits:
Not in the diff: The PR description's "Behaviour changes to note" gains the exchange change. |
- exchange.test.ts: 'refuses when the fallback is allowed but no operator key is configured' now tests that (a fallback session exchanged after the key is gone), not the named-credential gate. - A deleted named credential's refusal says what to do: store it again, or start a new session. - setup-vm.sh: the other-drop-in check matches as systemd parses units (whitespace around '=', LoadCredentialEncrypted=, the colon-less form); a trailing-spaced SH_ALLOW_OPERATOR_FALLBACK counts, as systemd drops the whitespace. - The key-file rule (one line, the key alone) is documented in the script header and README; the CI comment says deploy-scripts lacks a workspace install, not node. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
One more commit,
The PR description's Summary and Test plan are updated to match. Lint and every affected suite are green. |
Resolves .github/workflows/ci.yml: rossoctl#409's P4 authenticated-turn step and this PR's research-smoke step both run in the check job, after pnpm install. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
There was a problem hiding this comment.
Round 2, at fd3a9e6, plus c6c23b6's merge of main. All eight round-1 items and the knative note are fixed. Every fix but one is held by a test that fails when the fix is reverted. The exception, and two smaller items, are inline.
CI: none of the four fix commits had a run, because the PR conflicted with main in ci.yml. c6c23b6, which merged main while I was reviewing, keeps both check steps (#409's and this one) and is green. Its logs show research-smoke.test.sh running 59 checks in check and 20 in deploy-scripts, the rest skipped. Those are the counts I got locally, so the first round-1 must-fix holds on CI too.
Checked locally at fd3a9e6:
-
control-plane vitest: 441 passed.
-
research-smoke.test.sh:
- 59 checks with the workspace installed;
- 20 with no tsx, and the same 20 with node off PATH as well (deploy-scripts' shape);
- with
MOCA_REQUIRE_WORKSPACE=1and no tsx, it fails, as intended.
-
setup-vm.test.sh passes.
-
Each of these reversions makes a test fail:
!rec.credentialNamedropped from the exchange's fallback branch;statwithout-L;- no other-drop-in check, no
Encryptedform, no colon-less form; - no trailing-whitespace strip;
- no whitespace check on the key line;
- the pool read failing open.
The one that survives is the indented-fallback grep (inline).
-
The new rule ("only a session that recorded no credential falls back") has no other reader.
credentialNamehas been stored on every session record since the ownership index was added, so only sessions created on the fallback carry''.
| # An INDENTED fallback line counts too: systemd's EnvironmentFile= accepts it, so the control plane | ||
| # would see the fallback on (#411 review). | ||
| mv "$OP/credentials/operator-inference-token" "$OP/token.aside" | ||
| printf ' SH_ALLOW_OPERATOR_FALLBACK=true\n' >>"$OP/control-plane.env" |
There was a problem hiding this comment.
suggestion: this case passes without the fix. $OP/control-plane.env still holds the unindented SH_ALLOW_OPERATOR_FALLBACK=true appended at :1198, and nothing removes it before the sed at :1295. So the refusal comes from that line, and operator_fallback_value never has to read the indented one.
Mutation: anchor its grep (setup-vm.sh:581) back to ^SH_ALLOW_OPERATOR_FALLBACK=. setup-vm.test.sh still reports all passed. Copy the :1295 sed above this printf and the same mutation fails with an indented SH_ALLOW_OPERATOR_FALLBACK=true with no token file was accepted, while the real code passes. The trailing-spaces case below is sound, since that sed runs before it.
There was a problem hiding this comment.
Good catch, thanks. Fixed in 4a2ea9c. The block now deletes every SH_ALLOW_OPERATOR_FALLBACK line first, and checks that a missing token passes with none present. Then it tests each spelling alone: indented, trailing-spaced, =, and = "true".
Your mutation, the grep anchored back to ^SH_ALLOW_OPERATOR_FALLBACK=, now fails with ' SH_ALLOW_OPERATOR_FALLBACK=true' with no token file was accepted.
| return 1 | ||
| fi | ||
| # Leading whitespace too: systemd's EnvironmentFile= accepts it. | ||
| if grep -qE '^[[:space:]]*SH_OPERATOR_INFERENCE_TOKEN=' "$cp" 2>/dev/null; then |
There was a problem hiding this comment.
nit: fd3a9e6 made the drop-in check accept whitespace around =, as systemd does. The two control-plane.env reads still don't. systemd's EnvironmentFile= parser (parse_env_file_internal in env-file.c) trims trailing whitespace from the key and skips it after =, so SH_OPERATOR_INFERENCE_TOKEN = sk-… sets the variable.
This grep misses that form. With no token file, ensure_operator_fallback returns 0, and credentialValue falls back to the environment's value. The fallback then runs on a secret written in control-plane.env, which is the case this guard is there to refuse. The same miss in operator_fallback_value (:581) is fail-safe: the boot check refuses a fallback with no token.
Repro, sourced with SH_SOURCE_ONLY=1, no token file:
SH_OPERATOR_INFERENCE_TOKEN=x: rc=1.SH_OPERATOR_INFERENCE_TOKEN = x: rc=0.SH_ALLOW_OPERATOR_FALLBACK = true: rc=0.
Fix: use [[:space:]]*= after the key in both greps, and have operator_fallback_value strip leading whitespace after the = too.
There was a problem hiding this comment.
Fixed in 4a2ea9c. Both control-plane.env reads now allow whitespace before =:
- the token-line guard is now
^[[:space:]]*SH_OPERATOR_INFERENCE_TOKEN[[:space:]]*=; operator_fallback_valueuses the same form and also strips blanks after=.
Your three repros are now test cases: SH_OPERATOR_INFERENCE_TOKEN = x and =x are refused, and SH_ALLOW_OPERATOR_FALLBACK = true with no token file refuses, naming the file. Each fails when its part of the fix is reverted (the space before = in either grep, or the strip after =).
| - `SH_ALLOW_OPERATOR_FALLBACK=true` with no token file; | ||
| - a token file that is empty, a dangling symlink, or readable by anyone but its owner (not 0600 or | ||
| 0400; for a symlink, its target's mode); | ||
| - the token as a line in `control-plane.env`. |
There was a problem hiding this comment.
nit: this item still ends the list (.), but one now follows it. A ;, like the two items above, keeps the new item in the same list.
There was a problem hiding this comment.
Fixed in 4a2ea9c. The token-line item ends with ; and now also says it covers any spelling systemd accepts. The drop-in item ends the list, and its remedy moved into the paragraph after.
…aces around '=' (rossoctl#411 round 2) systemd's EnvironmentFile= parser trims the key and skips blanks after '=', so 'SH_OPERATOR_INFERENCE_TOKEN = sk-...' sets the variable; the token-line guard and operator_fallback_value missed that spelling. Both now match it. The indented-fallback test also tested nothing: an earlier unindented line stayed in the file and made it pass alone. Every spelling is now tested with no other fallback line present, and each test fails when its fix is reverted. README: the stop list ends where it should. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The epic's walkthrough: P6 and P4 on one VM, two GitHub users logging in with mocactl, a curl/git research turn on each user's own key, cross-user session refusals, then the host switched to the microVM tier. Folds in the B plan's runbook notes (login expiry and SH_API_TOKEN_TTL_SECONDS, device_flow_disabled, the tenancy caveat) and orders the acts around one-tier-per-host: container tier first, P4 last, because switching back needs a setup-vm.sh re-run that loses every session (rossoctl#410). Drafted, not yet performed end to end; Act 5 is the record to fill in. The research act uses deploy/vm/README.md's prompt and research-smoke.sh from rossoctl#411, which must merge first. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The research smoke and prompt are on main now, so drop the merge-first notes. The login step quotes mocactl's new operator-fix message (rossoctl#405), and the fix list marks it fixed. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Phase 2 of #368 (VM demo C, epic #370), after #366 and #369 merged. Phase 1 was #372.
Summary
The operator-key fallback works on the VM, and it can't be misconfigured silently.
Fixed: the fallback was unreachable.
createSessionrefused every subject with no inference credential, so the exchange's fallback branch ran only when a credential was deleted after its session was created. That's exactly what the existing tests did. That path is now closed too (see "Behaviour changes"), and the tests reach the fallback with no credential at all.SH_ALLOW_OPERATOR_FALLBACK=trueand an operator token set, such a subject now gets a session that records no credential name. The exchange spends the operator's key per turn, audited asoperator_fallback_used.mocactl used to block before ever calling
POST /v1/sessionswhen the user had no credential. Now it asks the server.credential_required, the user sees the same "add an inference credential" hint, and the interactive UI still routes to the credentials screen.New
SH_OPERATOR_INFERENCE_HEADER(authorization|x-api-key, defaultauthorization).sk-ant-api…operator key could never work.deploy/composeand thedeploy/vmenv example.The control plane refuses to boot on a fallback that can't work:
sk-ant-oat…token;https://api.anthropic.com.It also refuses an
api.anthropic.comdefault endpoint with a path (/v1). Messages name settings and key prefixes, never values. Before this, every one of these surfaced to users as "control plane returned 503", per turn.setup-vm.shloadscredentials/operator-inference-tokenwith aLoadCredential=drop-in when the file exists, and removes the drop-in when the file goes. A static line can't do this, becauseLoadCredential=on a missing file fails the unit.operator-fallbackis a reserved credential name, so an audit line naming it is always the operator's key.A live smoke for the research turn:
deploy/vm/research-smoke.sh(gated byVM_RESEARCH_SMOKE=1)./v1/turnwhose prompt makes the agentgit clone --depth 1rossoctl/moca andcurl -onodejs.org's 330 KB release index. That's past Pi's 50 KB tail, so it exercises the "curl -o, then grep" guidance.tool_useframes with non-error results;COMMIT/NODE_VERSION/NODE_DATEequal what the sandbox container's own copy of the files says, read withpodman exec;Docs:
deploy/vm/README.mdgains a "research turn" section.How MI1 S2 absorbs this
SH_OPERATOR_INFERENCE_HEADER, andmoca-egressinjects the token under it.directModeMismatchgoes away with direct mode.Behaviour changes to note
SH_ALLOW_OPERATOR_FALLBACK=truebut no token or no default endpoint, or with anapi.anthropic.com/v1default, now fails to start. Each such config could not serve a fallback or default-endpoint turn anyway.deploy/knative/control-plane.yamlships the fallbackfalse.createSessionwith the fallback on. A credential-less subject gets a session, as spec §6.4 intended.credential_required, naming the credential (feat: operator fallback on the VM and a curl/git research-turn smoke (#368 phase 2) #411 review).Known limits
mocactl doctor's "inference credential present" check still fails for a user relying on the fallback.SH_OPERATOR_INFERENCE_HEADERis not indeploy/knative/control-plane.yaml, where the fallback is off./workspaceper container (epic Epic: VM demo slice — P6 + P4 on one VM, multi-user mocactl login, sandbox research turns #370's note).Test plan
New unit tests:
operator-fallback-config.test.ts(the boot checks) andoperator-fallback-session.test.ts(credential-less sessions, a deleted named credential never falling back, the reserved name, the message once the fallback is off), plus an x-api-key fallback exchange case; the existing fallback tests now create the session with no credential instead of deleting one;run, and the New Session overlay.deploy/vm/tests/setup-vm.test.sh: the operator-token section, mutation-checked.deploy/vm/tests/research-smoke.test.sh: VM-free. It mockscurl/podman, mints tokens for real, and covers:Mutation-checked.
deploy/compose/tests/*: the header reaches the control plane.make lint,make typecheckandmake testare green.Live on the KVM rig with a real model: the smoke on a user's own raw Anthropic key (13/13), the smoke on the operator fallback (12/12),
mocactl runon the fallback, and the boot refusals, with no key in any journal. See the comment below.🤖 Generated with Claude Code