Repository navigation
fix(cli): capture the model gateway's store in snapshots and restore - #3979
Conversation
The gateway's SQLite store in llm-gateway-data (admin account, provider keys, virtual keys with their spend, request log) was never snapshotted, yet a newer gateway migrates it forward-only on first start (Bifrost 1.6 to 2.2 since #3961). A pre-upgrade restore therefore left the migrated store in place for the older gateway. - Snapshots capture llm-gateway-data under its stable name, archived whole (database, WAL and shared-memory files) while its container is paused; restore and verification accept it through the allowlist. - Restore warns when a snapshot has no gateway archive and the listing marks it "without gateway"; such snapshots still restore the rest. - A managed apply refuses to change an existing gateway's runtime when its recovery snapshot, retained or new, lacks the present gateway volume. The refusal comes before any write, so a superseding bundle's takeover is recorded only after the recovery point holds; an unchanged runtime proceeds with a warning. - Docs (EN/DE/FR) list the volume in the inventory, correct the rollback scope (tale rollback swaps application images only and restores no volume) and describe the managed refusal. Closes #3978
|
Release-blocking review finding at
I tested the existing managed-apply fixture with an old retained snapshot lacking
Please make this safety decision fail closed: only a successful, authoritative check proving the gateway volume absent may take the compatibility path. Daemon/transport/permission/invalid-response errors must abort before runtime mutation or recording a takeover, preserving the original pending and runtime receipts. Reuse the existing strict runtime inventory if suitable rather than treating every failed inspect as absence. Add this failure regression alongside present/absent controls. Do not replace the original snapshot to resolve it. The original focused suite passes 93/93 separately. This is a local synthetic control-flow proof, not real Docker or production execution; the separate real-binary recovery proof and complete normal CI remain required. No merge or approval from this review. Evidence correction retained: the first harness changed PATH inside Bun and did not establish shim invocation; its attribution was withdrawn publicly. Those initial logs remain marked superseded. The results above come from the corrected startup-PATH harness with verified executable, boundary response and call records. |
CI ran the retry case after a suite that leaves the shared reporter silenced (--json mode), so the warning never reached the stdout spy and the case failed although the warning was logged. Spy on the CLI logger instead, which sees the call whatever the reporter state is; the case passes with the reporter silenced as well.
Follow-up to an independent review of the managed-apply check. - The runtime preview reports the gateway store: whether its volume exists, read from the project volume listing it already takes, so a Docker error fails the preview rather than reading as "no gateway"; and whether the rollout starts another gateway image than its container runs, compared the way converged() compares every service. - The apply refuses only that image change on a store its recovery point does not hold. That now covers a pending receipt with no snapshot at all (a re-run of a ready bundle) taken over by a bundle that moves the gateway, which rolled out with no recovery point. A rollout that keeps the gateway image completes and warns: a retry after the new gateway already started, or a takeover that keeps it. That takeover is the documented way on from a refusal; the next rollout snapshots the gateway store. - Hints claim only what the CLI can verify and name that way on; the restore warning carries the docs' condition. - Docs (EN/DE/FR) match the rule, say "a default deploy (without --services)", restore with the current CLI, and state the overview's blob condition; .env.example no longer advises wiping the gateway volume.
|
Follow-up review of 2c426bc (previous evidence and its correction remain intact). The original nonzero-exit bypass is repaired: the runtime inventory uses One fail-closed gap remains: Please validate the complete successful response before deriving absence (or use a strict structured inventory), preserving legitimate empty/foreign-project inventories. Add boundary regressions for malformed success as well as nonzero/throw failures, with present/absent controls and receipt immutability for both intent paths. Proof scope: these are local source-bound tests of the real |
Second review follow-up. - The preview reads, before anything changes, whether the store has run the target gateway image: a ready runtime receipt that lists it, or a gateway container on it that has started (an adoption compares the digests it inspects). A gateway stopped or removed after a ready runtime no longer reads as a new image. - A pending receipt that recorded no snapshot changed nothing since the ready deployment, so a retry or takeover that would change the runtime takes its snapshot first and records it, instead of being refused. One an older CLI took over without a snapshot is still refused when the store would meet a new gateway image. - Messages name the image the rollout starts and the one that runs; the hint names the way on only while no runtime rollout is pending, and says when there is none. - Docs (EN/DE/FR) match; .env.example follows the environment reference.
|
Exact-head follow-up for
Both are controlled malformed-output tests, not a claim that ordinary Docker emits these values. Neither probe proves real gateway migration or native restore compatibility. The original PATH erratum and all prior evidence remain preserved. Focused authored tests pass 141/141, and docs checks 28/28. GitHub’s exact-head Unit job shows a real CLI test cache miss and execution, including the new gateway cases; green authored checks do not cover these two parser boundaries. Source acceptance remains withheld pending the guards and regression tests; binary/native proof stays separate. |
Third review follow-up. - A takeover of a receipt an older CLI took over without a snapshot no longer logs a kept recovery snapshot; the CLI warns that the rollout has none. - The snapshot a changed-nothing receipt takes stays with the pending deployment through an interruption, for a takeover and a same-bundle retry alike (now tested); such a receipt must also name the ready bundle. - Messages say nothing shows the store has run the image and name the gateway container's image; the hint points at the gateway image the deployment last ran; a retake no longer says no pending deployment was recorded when one was. - A container counts as started only with a start time after year 1. - Docs (EN/DE/FR) match.
|
Focused verification at
Inventory checks use the real runtimeCommand/exec path with startup-PATH executable selection, raw result and call logs verified. Timestamp checks use actual parsed container metadata and apply/runtime source with fixture Docker I/O. Neither claims ordinary Docker emits malformed values or proves gateway binary/native restore behavior. Affected authored apply/runtime tests pass 87/87; docs checks 28/28. The new no-recovery-point warnings and snapshot-less receipt preservation tests are appropriate. Source acceptance remains blocked by the two validation boundaries above. |
|
Independent archive review accepts the measured Linux-binary/copied-store compatibility evidence. Root also completed and independently reviewed one actual local Docker snapshot/list/verify/default-restore proof at frozen CLI source Snapshot Scope: an inert read-only volume user, direct existing source helpers/default action, retained dependencies and Docker29 arm64 with Alpine3.22's unchanged pinned digest. No live gateway/concurrent SQLite writer, compiled CLI entry, full platform snapshot, image-wrapper, populated OAuth migration, large-history or real-provider proof. Final source changes still require engine/call-graph reconciliation, normal full checks and independent acceptance. The two parser refusals in the preceding review still hold full PR/release acceptance. Recovery decision remains (c): preserve the incomplete original recovery point and keep that deployment blocked for manual resolution; no override or replacement snapshot. Tale's newest reply/restart has not been confirmed saved. All schedules/grants/Ops/release actions remain held. |
Fourth review follow-up. - A successful `docker volume ls` whose output was not a list of volume names was filtered as one: JSON, a table or a stray space read every volume, the gateway store's included, as absent, and a retry or a superseding bundle started a new gateway image on a store its recovery snapshot lacks. Every line must now match Moby's name rule before any is read; an empty listing is still a host without volumes, and a transport failure or a throw still fails closed. - A stopped gateway container counted as having run its image whenever Date.parse read its start time after 1970, which "1", a date alone or an impossible date all satisfy. Only a start time in Moby's RFC3339Nano contract that the calendar has now counts. - The fixed-container check and the listing share the name rule.
|
Independent exact-head review at da7a8da: the earlier malformed-success inventory and numeric/calendar timestamp counterexamples are corrected. Existing actual-helper controls pass 46/46 and your two affected suites pass 119/119. P2 compatibility hold: the whole-host DOCKER_NAME check rejects valid unrelated plugin volumes. A successful inventory with either foreign/plugin-data or the one-character name x, with the gateway genuinely absent, previously completed both retained and superseding lanes (4/4). At da7 all four refuse with “Docker returned invalid volume names.” Pending/runtime/ready receipts remain byte-identical and no pull/up/native effect occurs: this is unnecessary unavailability, not observed state loss. A documented fail-closed limitation does not satisfy the existing legitimate-foreign-volume compatibility requirement. Validate the complete structured formatter records before project filtering instead: volume ls --format '{{json .}}', existing parseJson for every line, then the existing schema library requiring object records with a nonempty string Name. Keep unrelated plugin names opaque; preserve managed-project suffix/custody checks and the fixed-container naming rule in their own scopes. Include foreign/plugin-data and x in both lanes with gateway absent/present, later malformed records, empty inventory and transport/permission failures, with unchanged receipts and no effects on refusal. Primary wire contract: https://docs.docker.com/engine/extend/plugins_volume/ ; Moby Linux validation delegates volume names to drivers and the plugin List adapter preserves Name. These are source/inert-command controls; no native plugin test was run. A separate P3 edge in this same timestamp repair: startInstant discards fractions. Valid 1970-01-01T00:00:00.001Z and equivalent offset/fraction inputs completed on f699 (4/4), but da7 treats them as epoch zero and refuses all four. This is limited to positive fractions of the first epoch second, not another release blocker or evidence that current-era timestamps fail. Preserve the admitted instant when simplifying the parser; prefer existing Zod ISO/calendar/offset validation with required seconds and <=9 fractional digits rather than maintaining a second date parser. No broader clock-policy change is requested. The reviewed local five-file JSON preparation based on older f699 has SHA256 082726b2efdff88cc7843cc0ddf8f25d70535074162d4db6a295741e123a2605; it is guidance, not a blind replacement for your new source. It passed 127 affected tests, 54 helper controls and 4 plugin controls, with separate inventory review 52/52 plus 30/30 custody tests. Its earlier author is disclosed; the current da7 review does not certify that candidate. The bounded compatibility archive and direct-source actual Docker createSnapshot/list/verify/default-restore proof remain separately accepted for their measured scopes, with original data and failures retained. No repeat campaign is needed. Continue on this same PR/task with the small structured-inventory correction, regression evidence and exact final normal CI. Recovery decision (c), existing receipts, all paused schedules/new grants and held release/Ops actions remain unchanged. |
Fifth review follow-up.
- The runtime preview reads `docker volume ls --format '{{json .}}'`.
Before any name is read, every line must parse as JSON and be an
object with a nonempty string Name. Names stay opaque: Moby leaves
the name rule to each volume driver, so a plugin volume such as
`foreign/plugin-data` or `x` no longer refuses a deployment. A
listing that is not a list of records still refuses before anything
changes, and an empty one is still a host without volumes. The
fixed-container name rule keeps its own scope.
- A stopped gateway container's start time is validated by Zod's ISO
datetime (calendar, ranges, offset), with seconds and at most nine
fraction digits. It keeps its fraction, so a start within the
epoch's first second counts again.
|
Independent final review accepts Independent actual-helper subprocess controls passed 40/40 across retained and superseding deployment paths: 24 inventory and 16 timestamp cases. Refusals preserved all three receipts and produced no pull/up/native effect. These use an inert Docker command boundary, not a native plugin. The 19 original actual-Docker backup/restore source bindings and the additional unchanged call-path files match the accepted f699 proof; its scope and the separately accepted 740a compatibility archive remain as recorded in the earlier review. No new live-provider, populated-OAuth, large-history or compiled-CLI/Docker campaign is inferred. Five normal workflows at this exact head completed successfully on attempt 1: Checks 36723560087, Build 36723559896, CLI 36723560199, SAST 36723559771 and Commitlint 36723560077. The rollup has 35 successes and 14 source-explained conditional skips. Unit job 109915770026 freshly executed CLI cache hash d2d62ac085a48115: 1553 passed, 19 skipped, 0 failed; the affected apply/runtime-apply suites passed 67 + 71 with no skips. The 19 are 18 TALE_BINARY-gated compiled smoke tests and one Windows-only source test on Ubuntu. Actual tested merge 29b988d has parents ea7de2e + 03071c6; all four revised files independently match the reviewed head. Backend integration was correctly unselected; Build selected docs only, with CI tests enabled and no scannable service. Candidate-only, release-only, fork-only and unrelated-service jobs are not claimed as executions. The author separately reports 1534 local CLI passes and 14 sandbox failures reproduced on clean main. That is not relabelled a local full-suite pass; the observed hosted result above supplies the current complete normal CLI outcome. Main has since added the separate Gemini configuration and crawler-limit changes; no backup/restore engine, dependency lock or CLI admission source changed in that delta. The actual squash source will be checked before closing the board prerequisite. The source/recovery prerequisite is accepted within these boundaries. Fresh candidate validation, complete publication, existing Ops deployment, serving-version confirmation and paused workflow installation remain separate gates; nothing is activated by this review. |
Why
Since #3961 a deploy moves the model gateway from Bifrost 1.6.11 to 2.2.4. The new gateway migrates its SQLite store in
llm-gateway-datain place and forward-only: upstream dropsoauth_configs.token_id, and neither binary has a down-migration.No CLI snapshot captured that volume.
SNAPSHOT_VOLUMESintools/cli/src/lib/backup/constants.tsomitted it, and so did everything built on that list:RESTORABLE_ARCHIVES,verifySnapshotand the managed recovery-snapshot schema. The consequences:deploy applythat reused a retained pending snapshot from an older CLI migrated the gateway with no recovery point. Its ready receipt still named that snapshot.Closes #3978.
What changes
backup/constants.ts):GATEWAY_VOLUME = 'llm-gateway-data'joinsSNAPSHOT_VOLUMESunder its stable name.createSnapshotarchives the volume through the existingpauseGroups/withVolumeContainersPaused. The gateway container is paused while its archive is taken. The archive covers the whole volume root read-only:config.db,logs.dband their-wal/-shmfiles together.actions/restore.ts): a snapshot without the gateway archive still restores everything it holds.tale restorelists such snapshots aswithout gateway.deployment/apply.ts, withRuntimeResult.gatewayfromruntime-apply.ts): the check compares gateway images.Rule. Before anything is written, the apply refuses a rollout that meets both conditions:
Evidence. The runtime preview reads it once, before anything changes, and validates every Docker record it reads:
docker volume ls --format '{{json .}}'.runtimeCommand, so a nonzero exit or a throw refuses.Name. A successful but malformed listing therefore refuses too, instead of reading as "no gateway".foreign/plugin-dataorxreads as it is.StartedAtin Moby's RFC3339Nano contract, after the Unix epoch.Recovery path: keep the same gateway image. While no runtime rollout is pending, a reviewed bundle that still resolves the gateway image the deployment last ran can take the pending deployment over (
supersedesPendingBundle). The rollout after it takes a snapshot that holds the gateway store. The refusal's hint names this path.Named operator blocker. One state stays refused:
In that state the hint says the CLI has no way forward. The original pending receipt, its recovery point and the gateway volume stay as they are, for the operator to resolve by hand. There is no acknowledgement override. No snapshot is amended or replaced, and no gateway-only archive is written into the receipt, because a snapshot taken now could already hold a migrated store.
What a refusal leaves untouched:
Messages name both images and claim only what the evidence shows ("nothing shows the store has run it").
Snapshot taken first. One kind of pending receipt changed nothing since the ready deployment: it recorded no snapshot, names the ready bundle and was never taken over. A takeover of it, or a retry that would change the runtime, now takes its snapshot first. The snapshot is written into the pending receipt before the rollout.
Warnings instead of refusals:
Unaffected: fresh installations, and deployments without a gateway volume.
without gatewaymarker, the pause note, restoring with the current CLI, and restore step 4.--skip-backup.tale rollbackstarts the old gateway. The command swaps onlyplatform,backend-apiandbackend-worker.compose.yml,create-sandbox-llm-gateway-service.tsand.env.exampleno longer call the store a derived cache to wipe.Rollback scope (read from source)
tale rollback(actions/rollback.ts): swaps the application colour's images only, within the samemajor.minor. It restores no volume. The database, stores, proxy, sandbox services and gateway stay as they are.tale deploy(actions/deploy.ts): rolls the always-roll tier (sandbox-llm-gateway,sandbox,sandbox-egress) in place before it starts the new colour. If a default deploy then fails its health checks, the old colour keeps serving, but the gateway is already replaced and its store possibly migrated.tale restore <id>, with consent, puts volumes back.How I verified
Regression tests first. Before/after logs are in the task box.
14fa3f23b. The look-alike-name and no-gateway-volume controls also pass there.apply.ts: 4 of the first 6 cases failed. Unfixed, a retry wrote a ready receipt withruntimeChanged: truethat named the gateway-less snapshot.cc66f23e2guard: that guard refused a rollout whose new gateway had already started, and refused the image-keeping takeover. It let a snapshot-less receipt be taken over.2c426bc1cguard: that guard refused the snapshot-less takeover that can now snapshot first. It also refused the retry with the gateway container gone after a ready runtime.f69905141: 12 of the new cases fail there. Atda7a8daf0, the apply and runtime-apply suites pass 119/119.[{"Name":"tale_llm-gateway-data"}]let both a retry and a superseding bundle complete their rollout on the gateway-less snapshot.StartedAtvalues"1","2026-09-30","2026-02-30T00:00:00Z"and"2026-09-30T24:00:00Z"counted as a start. With"1", the apply finished withruntimeChanged: trueon that snapshot.da7a8daf0(root's review): 25 of the new cases fail there (113 pass). At03071c657, the apply and runtime-apply suites pass 138/138.da7a8daf0, a listing withforeign/plugin-dataandxrefused with "Docker returned invalid volume names.", in the preview and in both lanes, gateway present or absent. The gateway check was never reached.da7a8daf0,1970-01-01T00:00:00.001Z,1970-01-01T01:00:00.001+01:00,1969-12-31T23:00:00.5-01:00and1970-01-01T00:00:00.000000001Zdid not count as a start. In apply, the first two refused with "nothing shows the store has run it".{{json .}}contract, soda7a8daf0reads them as names or refuses them with its own message.f69905141: 22 fail (116 pass). That head read every malformed listing as a listing (the round-4 finding) and tookDate.parse-accepted times, but it read plugin names and millisecond fractions as the fix does.r5-before-classification.txtin the task box lists every failure by kind.Final focused suites: 194/194 across
backup/,actions/restore.test.ts,deployment/apply.test.tsanddeployment/runtime-apply.test.ts.Tests on genuine states:
Mutation checks. Each guard condition has a named test that turns red when the condition is removed:
Round 4 added seven mutants, and all seven were killed:
Date.parserestored, no calendar check, no offset bounds, and the zero time counted.One first-attempt mutant was malformed by operator precedence and was redone. Both runs are in the log.
Round 5 added ten mutants, and all ten were killed:
Whole
@tale/clisuite: 1534 pass and 19 skip, with the same 14 failures as clean14fa3f23bin this sandbox and no others. The 14 are environmental:ssh-keygen;archive --mtime;Other checks: CLI
tsc --noEmitis clean,oxlintreports 0 warnings and 0 errors, andoxfmt, the conflict-marker check and opengrep (0 findings) are clean. The docs structural suite passes 200/200 at this head; rounds 4 and 5 changed no docs.Review: three internal read-only rounds, then root's exact-head reviews of
eb3d2709d,2c426bc1c,6ba0220e7,f69905141andda7a8daf0. Every finding and what was done with it is inTALE-384-review-disposition.mdin the task box.CI: Unit first failed on
eb3d2709d: one apply case read the warning from stdout, and CI ran a--jsonsuite first that leaves the shared reporter silenced.cc66f23e2reads the warning at the logger, and CI has been green on every head since. The final head03071c657has 35 checks passing and 14 skipped, including the smoke test and image validation. CI tests the PR merged with current main (29b988d98). There, Unit executed the CLI suite as a cache miss: 1553 pass, 19 skip, 0 fail over 1572 tests (main adds five), every round-5 case among them. The docs and platform suites were cache misses too (25/25 tasks).Real-binary compatibility proof (no Docker), 75/75 checks. The upstream
linux/amd64binaries were verified by manifest and final-layer digest, then driven by the platform's ownllm_gateway_admin.ts.TALE-384-compat-proof.mdin the task box (archive SHA256740a0f42e03daec1498487cbb7fd0c3e33445b2694302b956d9521d520a1aed1).Root's Docker snapshot/restore proof (not mine; see root's comment). At
f69905141, root ran one actual local Docker snapshot, list, verify and default restore ofllm-gateway-data. It went through the unmodified helper and action path, including a real pause, archive and unpause. All seven config/SQLite/WAL/SHM files matched.f69905141, onlydeployment/runtime-apply.ts, its test helper and tests changed (da7a8daf0,03071c657). The snapshot, list, verify and restore code does not import that file.Known limits
llm-gateway-data, so it fails closed. An older CLI'stale restorewould skip that archive, so the docs say to restore with the current CLI.deploy applypath ran against the test fixture only, and the compatibility proof used file copies and the CLI's command strings. Root's Docker proof covers snapshot, list, verify and default restore, with the scope above.