GeezerVison is showing github.com — run-switch.sh: concurrent switches clobber the shared ~/switch-current.logpath pointer (wrong-log exit attribution) · Issue #3753 · developing-today/code
run-switch.sh: concurrent switches clobber the shared ~/switch-current.logpath pointer (wrong-log exit attribution) #3753Labels area/infraInfrastructure, deployment, and operationseffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionProblem
~/run-switch.sh records its log location in a single shared pointer file, ~/switch-current.logpath. When two switches run concurrently, the second invocation overwrites the pointer, and the first operator's monitoring reads the WRONG run's log — exit-code attribution for a system switch then depends on each operator happening to track their own log filename privately.
Evidence (2026-11-01)
During the flake-dedupe activation switch (generation system-524, SWITCH_EXIT=0, verified from the operator's own log file), another actor launched ~/run-switch.sh twice from a separate worktree effort (08:59:29 — failed instantly, no sudo password; 08:59:51 — ran to completion on a newer main). The second launch clobbered ~/switch-current.logpath mid-flight; the first operator's final tail read the other run's log. Both switches built from the same main lineage so the system stayed consistent — this time. A wrong-log read on a FAILED switch could equally mask a failure as a success.
Ask
- Per-invocation logpath: write the pointer to a unique file per run (e.g.
~/switch-<timestamp>-<pid>.logpath, or print the log path on stdout only and drop the shared pointer), and/or
- A switch lock (
flock on a lockfile) so a second concurrent switch refuses with a clear message instead of racing — two NixOS switches racing is wasteful even when harmless.
Either change is small; the lock is the stronger guarantee.
Acceptance criteria
- Two concurrent
run-switch.sh invocations cannot clobber each other's log attribution: each run's log path is unique to the invocation, or a flock-style lock makes a second concurrent invocation refuse with a clear message.
- A failed switch is never read as a success (or vice versa) because of another run's log: the recorded log path points at the operator's own run from start to finish.
- Single-invocation behaviour is unchanged apart from the pointer/lock mechanics.
Activitydeveloping-today commented on Nov 1, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) effort/sSmall: expected under 2 hours of work area/infraInfrastructure, deployment, and operations meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added on Nov 1, 2026dezren39 commented on Nov 1, 2026 Intake review
Fleet monitor intake pass (protocol §5), 2026-11-01.
Related: None found in a merged-PR search for this issue (2026-11-01).
Notes: Filed with no labels and no acceptance criteria; the problem statement and 2026-11-01 evidence (generation system-524 switch, two clobbering launches at 08:59) are clear and reproduced in the body.
Risks: Low: ~/run-switch.sh is an operator script, not shipped code; the risk being fixed (wrong-log exit attribution masking a failed switch) is the larger one.
Suggested approach: Prefer the flock lock (the stronger guarantee the issue itself names), plus a per-invocation logpath as belt-and-braces. developing-today commented on Nov 3, 2026 agent-note:v1
state: triaged (coverage pass)
Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 40 (priority/normal). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
Found via: coverage pass 2026-11-03 dezren39 commented on Nov 3, 2026
Triage (task 8266, lane code-e): STILL LIVE — verified against the actual script on the laptop, 2026-11-03.
- The script named in this issue is the laptop operator script
~/run-switch.sh (not versioned in any repo). Read verbatim today, it is exactly the reported shape:
LOG=/home/user/switch-$(date +%Y%m%d-%H%M%S).log
echo "$LOG" > /home/user/switch-current.logpath — one shared pointer, overwritten unconditionally at start.
- No
flock / lock of any kind; the rebuild then runs and appends SWITCH_EXIT=$? to $LOG.
- Extra finding beyond the issue body: the log filename itself has only second resolution, so two runs started in the same second share not just the pointer but the same log file — both runs' output and
SWITCH_EXIT lines interleave in one file.
- Dedup re-verified fresh: no PR in developing-today/code or dezren39/nix references run-switch.sh: concurrent switches clobber the shared ~/switch-current.logpath pointer (wrong-log exit attribution) #3753 or
run-switch, and neither repo contains switch-current.logpath or a run-switch script (gh code search, 2026-11-03). Nothing has landed for this.
Fix path scoped (enqueued as follow-up fix task in repo-health-code-pilot):
- Serialize switches:
flock -n on a lockfile (e.g. ~/switch.lock); a second concurrent invocation refuses immediately with a clear message naming the holder's log.
- Per-invocation attribution: log name gains the PID (
switch-<stamp>-$$.log) and the shared pointer is either dropped in favour of the per-run path printed on stdout, or kept only as a convenience "most recent start" record that no operator flow depends on for exit attribution.
- Version the script: the canonical copy should live in a repo (this issue's repo, developing-today/code, is the natural home — e.g. under
infra/ alongside the fleet tooling) with the laptop ~/run-switch.sh deployed from it, so the next change is a PR, not an unversioned home-dir edit.
- Regression harness: stub two concurrent invocations; the second refuses, the first's log +
SWITCH_EXIT line are untouched.
No blockers; nothing needs Drew. Single-invocation behaviour otherwise unchanged. dezren39 commented on Nov 8, 2026 Partial verification — staying open (2026-11-07 done-task-only audit, tracking: #7016).
Queue task(s) [8266, 8705] were marked done, and some work did land:
- Direct commits referencing this issue: da477e4
No merged change closes this issue's full scope, so the done status is not treated as completion. Remainder re-queued as triage task 11673. dezren39 commented on Nov 8, 2026 🤖 Agent note · handed off
- Agent: queue worker (repo-worker-code), lane code-r
- Session / ID: task 12627 (attempt 2)
- Found via: queue claim
- Task: Shepherd PR fix: serialize run-switch and give each invocation its own log #5146 to merge + deploy — run-switch.sh flock + per-invocation logpath (issue run-switch.sh: concurrent switches clobber the shared ~/switch-current.logpath pointer (wrong-log exit attribution) #3753 remainder). PR fix: serialize run-switch and give each invocation its own log #5146 is OPEN, not draft, no held labels (verified 2026-11-08T06:37Z).
- Handoff: execution-lane assignment for task 12627 returned
opencode (§1b) — the previous handoff (2026-11-08T05:49Z) did not bind before the lease cycled, so this claim re-hands it to the claimant. The laptop claimant launches the bound opencode session, which drives this task to its terminal state under this queue's worker id. This lane does not work the task itself.
- Expectation: claimant session re-verifies PR fix: serialize run-switch and give each invocation its own log #5146 fresh (state, checks, Codex findings disposition), merges under the standing criteria if verified, handles the deploy step named in the task, and completes task 12627 with the evidence.
dezren39 commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 🤖 Agent note · done
Outcome — fixed and merged (task 12629, 2026-11-08)
- PR fix: serialize run-switch and give each invocation its own log #5146 merged: merge commit
b5ddb3974454cde92b0afa0ee52f98baa42a7959; its Closes #3753 closed this issue. The PR had no labels (no held / user/owned / do-not-merge / do-not-auto-edit), no reviews and no Codex findings to disposition.
- Fresh verification on the laptop before merging (worktree at PR head
da477e46238f): bash lib/run-switch.test.sh — all tests passed (concurrent invocation refused without creating or contaminating a log; single invocation prints a unique log path and preserves the rebuild exit status); bash -n pass; shellcheck pass. The canonical script preserves the old operator semantics (same flake /home/user/code#amd, same sudo -S nixos-rebuild switch, per-run SWITCH_EXIT) and changes only the pointer/lock mechanics: non-blocking flock, per-invocation UTC-timestamp+PID log path printed on stdout, and no shared ~/switch-current.logpath at all.
- Deployed: laptop
~/git/code fast-forwarded to the merge commit and lib/run-switch.sh installed to ~/run-switch.sh; sha256 of both files is 11cc1019d0986510fa2c98a7b0cae41c8048f0647b97023f160aad74ec49ed9a (match verified). The previous script is kept at ~/run-switch.sh.pre-5146.bak. This closes the deployment/checksum remainder task 8705 left open.
- Acceptance: two concurrent invocations can no longer clobber each other's log attribution (the second is refused with the active log named), and a failed switch's
SWITCH_EXIT is recorded only in its own run's log.
dezren39 commented on Nov 8, 2026 🤖 Agent note · done (already complete at pickup)
MetadataMetadataarea/infraInfrastructure, deployment, and operationseffort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|