Skip to content

Prod service started by its own unit runs a stale binary (3497ea2) baked into the runtime config snapshot — unit ExecStart ignored #8264

Closed

Description

@dezren39

Prod service, when actually started by its systemd unit, runs a stale binary baked into the runtime config snapshot — unit ExecStart binary is ignored

Found 2026-11-10 ~15:03 CST during the code#8086 / code#8255 / code#8261 takeover.

Wire facts (laptop, host amd)

  • The home-manager user unit opencode.service (generation 555) has ExecStart=/nix/store/zzzhr7mzf1h5yhfy1nnqx2d3m53yk828-opencode-2.0.30+fafff70-wrapped/bin/opencode serve --service --hostname 127.0.0.1 --port 13420 — verified in the unit file itself.
  • After a verified-clean takeover (port confirmed FREE, then systemctl --user start opencode.service, unit active, MainPID's parent = systemd 1459), the process that bound port 13420 and registered itself was /nix/store/ydgi99xfsncbwrpvqlc30dnb0grrv57p-opencode-2.0.30+3497ea2/bin/.opencode-wrapped (service-prod.json version 2.0.30+3497ea2, registration id dbabcfed) — NOT the unit's fafff70 binary. The same 3497ea2 build also won an earlier systemd-detached registration at 21:00Z ("managed service registration replaced; shutting down" in the server log).
  • The unit sets Environment=OPENCODE_CONFIG=%h/.local/state/opencode/opencode-runtime.jsonc — a runtime config snapshot in the state dir. That snapshot (or the service machinery reading it) evidently carries its own binary reference: in service mode the starter hands off to the snapshot's pinned build instead of running its own image. /run/current-system/sw/bin/opencode currently resolves to c43145b (generation 554's pin), so the layers disagree three ways at once: unit ExecStart = fafff70, system profile = c43145b, snapshot service = 3497ea2.
  • No process in the fleet is actually the unit's binary: every "successful switch" (generations 554, 555) changed the unit file and nothing else (see code#8255 for the incumbent-defer mechanism and code#8261 for the shadow supervisor that held the port in between).

Impact

Fix shape (for the owning lane)

  1. Find what writes ~/.local/state/opencode/opencode-runtime.jsonc and what consumes its binary pin in service mode; make the snapshot regenerate from the deployed pin on every switch (or stop carrying a binary pin — the unit's ExecStart should be the single source of truth).
  2. Switch proof must read the REGISTERED service's version + the port owner's exe path, never the unit file.
  3. Add the snapshot refresh to the generation-switch checklist/runbook wherever the other two pins are bumped.

Evidence gathered during the code#8086 follow-up lane, 2026-11-10.

Activity

  1. developing-today commented on Nov 10, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Correction to this issue's mechanism (same lane, minutes later): the "runtime config snapshot carries a binary pin" theory does NOT hold — ~/.local/state/opencode/opencode-runtime.jsonc contains no binary reference (checked: no store path, mtime Nov 7).

    What the wire actually shows: 3497ea2 is current fork main. Fork PR #2255 ("fix(ai): claude-code renewal renews early and waits out rate limits", for code#6120) merged at 2026-11-10T20:13:10Z as 3497ea22c946, and GitHub compare 3497ea22c946...fafff7073054 = status "behind", ahead 0 / behind 2 — i.e. 3497ea2 is a direct descendant of this lane's fafff70 (which is 2 commits back: the #2254 merge + one more). So the binary now registered on port 13420 (pid 2586083, systemd-owned, started 21:02:54Z) contains the #2254 feed-stamp fix and the #2252 plant, plus the #6120 Claude-renewal fix.

    The fleet's own deploy machinery (a newer-pin realise was already in flight at 14:40 CST: nix-store --realise .../opencode-2.0.30+3497ea2-wrapped.drv) moved the service forward on its own. Remaining true problems from the original filing: (1) three layers (unit ExecStart fafff70, system profile c43145b, actually-running 3497ea2) can disagree and no switch proof reads the registered service; (2) a version can reach production without the code-repo pin PR that is supposed to gate it — the code pin still says fafff70 while production runs its descendant. Recommend: keep this issue for the pin/switch-proof hygiene; the urgent production state is, as of 21:02:54Z, correct and verified on the wire.

  3. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Layer reconciliation — diagnosis update (switch-machinery lane, 2026-11-10)

    Wire-verified on the laptop today; this corrects the picture this issue was filed with:

    The flake pin is already reconciled. code main flake.lock pins the fork at 3497ea22c9468d46474e7613ab59d01d8ada57bb (pin PR #8232), and the running server reports 2.0.30+3497ea2 — pin == production. No pin PR is needed for the rev itself.

    The three-way disagreement is real but its mechanism is not the runtime snapshot. ~/.local/state/opencode/opencode-runtime.jsonc contains no store path and no binary/service key at all (it is the code#4544 runtime config overlay: providers/routes; last written Nov 7). What actually disagreed, and why:

    1. The deployed home-manager generation (555) was built from the superseded fafff70 pin and never rebuilt after chore(flake): opencode pin -> 3497ea22c (claude-code renewal waits out rate limits, code#6120) #8232 moved the pin to 3497ea2. That is the whole of the unit's stale ExecStart — a stale generation, not a snapshot pin.
    2. The cascade indirection: the unit's package is inputs.openchamber.inputs.opencode (the openchamber cascade build), not the root opencode input. Both happen to resolve to the same fork rev today only because code's openchamber input declares inputs.opencode.follows = ["opencode"]. The fastlane era proved the hazard: openchamber's own lock pinned fork 6c43550 while the root pin moved independently.
    3. The 3497ea2 that ran under the fafff70 unit was seated by the fastlane drop-in 20-fastlane.conf (ExecStart override to the pure pin build) plus the daemon registration machinery — not by anything in the runtime snapshot.

    Fix landing in this lane: rebuild the home-manager generation from current code main (pin 3497ea2), remove the fastlane drop-in (the generation itself becomes the single source), verify the port does not bounce (see the takeover fork fix), and extend the watchdog to compare the registered build against the unit's build. The NixOS system profile (/run/current-system/sw/bin/opencode = c43145b) is a separate, sudo-gated layer; it is a CLI convenience path, not the service — noted here so the record distinguishes it.

  4. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Correction — the filed mechanism was wrong; the real layer disagreements (verified on the wire 2026-11-10 ~21:4xZ)

    opencode-runtime.jsonc does not carry a binary pin: it has no store path, no binary/service key — it is the runtime config overlay (hostname/port, sync-models settings), last written Nov 7. Nothing in it lags production, and editing it would change nothing about which build serves.

    The deployed layers DO disagree with production, differently than filed:

    1. The activated home generation is built from the superseded pin fafff70 (the unit's package is opencode-2.0.30+fafff70-wrapped). Production 3497ea2 got onto the port only via the fastlane drop-in (~/.config/systemd/user/opencode.service.d/20-fastlane.conf → ExecStart override + fastlane state under ~/.local/state/opencode/fastlane/), which is exactly the kind of out-of-band layer this issue exists to eliminate. Rebuilt from a merged pin, the drop-in must go away as part of the switch.
    2. Cascade indirection is the structural hazard: the unit's package is inputs.openchamber.inputs.opencode...opencodeWrapped — openchamber's nested input. It resolves to the root pin's rev today only because code's openchamber input declares inputs.opencode.follows = ["opencode"]; openchamber's own repo lock pins the fork at 6c43550b12. Any layer that builds openchamber without the follows gets the wrong fork rev silently.
    3. The NixOS system profile (/run/current-system/sw/bin/opencode = c43145b, the generation-554 pin) is a third value — a CLI convenience layer, not the service; it lags two pins and should track or stop pretending.

    Pin state now: code main flake.lock opencode rev == 3497ea22c946 == the running build (PR #8232), so the "bump the pin" leg of this issue is already satisfied at the lock level; the remaining fix is the deployed layers above, tracked by the switch-machinery lane (watchdog build-identity check PR #8295 makes a future skew loud instead of silent).

  5. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Closing — layers reconciled. The pin leg landed past the filed target: PR #8265 took the lock to cb3968e4f, then PR #8308 (merged 25edc830) took code main's flake.lock opencode rev to 6a4793c059… — a descendant that keeps cb3968e's commits. The deployed unit now runs exactly that rev (2.0.30+6a4793c, pid-stable since 22:42Z) from its own unit file — the fastlane drop-in that carried production out-of-band is removed, and the watchdog's expected build is derived from the same package derivation as the unit's ExecStart (PR #8295), so expectation and reality can no longer drift silently. The mechanism correction stands (comment 6780277296): opencode-runtime.jsonc never carried a binary pin. Residual, noted not blocking: the NixOS system-profile CLI still reports the generation-554 vintage (c43145b) — a convenience layer, not the service; it tracks with the next system generation (the full generation build is currently blocked by the unrelated atlas-core shards test failure).

  6. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    Flake build blocker removed — generation switch is now buildable (handoff to the switch lane).

    The fleet-0.1.0 compile failure blocking this pin reconcile had two stacked layers, both from ac6dfcb53d (query-time parameter contract v1, #5774, today):

    1. E0063 type drift — SearchOptions.parameters / BranchQuery.shard_top_k+global_top_k added to atlas-core; fleet-search's initializers missed. Fixed earlier by 6f8045664e, fleet-search: main build broken - server.rs initializers missing new atlas-core fields #8268 closed.
    2. Lock drift (the layer that kept the flake red after fleet-search: main build broken - server.rs initializers missing new atlas-core fields #8268 closed) — the same commit added atlas-proto as a dependency of atlas-core and updated pkgs/atlas-search/Cargo.lock, but not pkgs/fleet/Cargo.lock. pkgs/fleet/default.nix pins cargoLock.lockFile = ./Cargo.lock, so the Nix build (locked, offline, sandboxed) failed while a workstation cargo build silently rewrote the lock and passed.

    Fix: PR #8334, merged a5946ee5f2f0 — one line: atlas-core's entry in pkgs/fleet/Cargo.lock gains "atlas-proto". No source changes.

    Build evidence (pinned rust 1.99.0):

    • Before: cargo build -p fleet --locked → error: cannot update the lock file ... because --locked was passed
    • After: cargo build -p fleet --locked green from two separate cold target dirs (3m 48s, 3m 38s); cargo build -p atlas-search --locked green
    • cargo test -p fleet-search --locked → 19 passed; cargo test -p atlas-core --locked → 68 passed
    • Laptop nix build .#fleet (worktree at the PR branch): past vendoring/resolution, in the cargo build -p fleet --offline --profile release phase under heavy fleet load at last check — the lock no longer stops it; its completion is visible in the store.

    Per the lane split I did not run the generation switch. The switch (and its before/after proof) is yours — the build side no longer blocks it, so the pin cb3968e4f (#8265) and this reconcile can land. Same removal unblocks #8260's permanence step.

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Addendum: socket activation adopted + changed-build switch proven (2026-11-11)

    Full evidence is on #8261, comment 6784017786. Summary of the proof numbers:

    • Socket activation adopted for the prod seat: opencode.socket owns 127.0.0.1:13420 (ListenStream=127.0.0.1:13420); opencode.service is Type=notify + Requires=opencode.socket. Zero server code changes. The adopting restart (2026-11-11T00:07:55Z) was the last die-and-rebind: probe recorded a 3.11s refused window (31 failed probes), then the listener moved to the process's inherited fd 3.
    • Same-build proof restart: 0.88s, MainPID 53746 -> 62542, zero new failed probes — no refused window.
    • Real changed-build switch under Drew's spec: pin advanced 6a4793c -> fork main 01148f78 via code PR flake: pin opencode to fork main 01148f78 (socket-activation switch proof, code#8255) #8372 (the opencode pin bump), merged 2026-11-11T00:51:14Z (999b41828f10). Unit ExecStart repointed to the new wrapped build (72ghrggn...-opencode-2.0.30+01148f7-wrapped), restart T0 00:54:10.395Z, returned 00:54:22.218Z. MainPID 62542 -> 480147; build 2.0.30+6a4793c -> 2.0.30+01148f7; listener on fd 3 throughout. Continuous probe (4,150 connects over 420s): zero failures — no refused window across a build change.
    • Sessions: baseline 15,597 ids before adoption; after adoption 15,694; after the same-build proof 15,696; after the changed-build switch 15,734 — baseline-missing = 0 at every step.
    • Drain (honest floor): each restart logged the bounded drain with requests=0; running sessions were interrupted at the stream level only (no in-flight HTTP requests existed to drain). Sessions are server-side state and all survived. Full stream resumability remains the known level-(c) floor.
    • Fork id: design: hosted provisioning + SSO→ID binding spec — account/binding records, challenge ceremony, delayed rebind, metering, export (from #2045) #2258 (classify-then-act) was already merged (2026-11-10T21:38:16Z, 6a4793c059) and deployed as the incumbent build before this work began.
  8. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Pin-advance note for the switch lane (fork #2253, opendesign membership caps).

    Code main now carries a newer opencode pin than the one your switch proof deployed:

    • Your switch proof: commit ffd3374d7 (2026-11-11T00:45:50Z) pinned fork main 01148f78.
    • Since then, code PR #8387 merged (merge commit 327e5decac5d271f42a2eb589aeca2d5f30830ac) advancing the pin to cab6bf481b231b3b734295fc9eec12f3f68be606 — fork PR #2264, the opendesign membership limiter for fork issue #2253. The same PR declares the caps in .opencode/opencode.jsonc (membership: { concurrent: 10, requestsPerMinute: 100 } in the opendesign provider's options).

    So the membership limiter is merged but not live: it needs the next coordinated generation switch to take effect. Per the #2253 handoff, no switch was run from that lane — this note is the handoff. When the next switch runs, the proof to read is the usual one for this issue's fix shape: the REGISTERED service's version should report cab6bf48 (not 01148f78), and the config snapshot should regenerate from the deployed pin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions