Repository navigation
Description
Summary
The single-instance guard added to the generated openchamber-serve wrapper (bc6044f, for dezren39/darwin-nix#1117) never matches a running server, so it is a no-op in production: after a restart, a leftover OpenChamber server keeps sharing the socket-activated listener on 127.0.0.1:3000 with the new instance.
Root cause
In the wrapper as generated into the Nix store, the guard's cmdline capture is:
cmd="$(cat "$proc/cmdline" 2>/dev/null | tr '\\0' ' ')"
The generated script literally contains tr '\\0' ' ' (verified byte-for-byte with grep | cat -A on the store file). In shell single quotes that passes backslash + backslash + 0 to tr, and GNU tr reads \\ as an escaped backslash, so the translate set is {backslash, 0} — NUL bytes are never converted to spaces. Bash command substitution then strips the NULs, concatenating the argv words (...cli.jsserve--foreground--port3000--host...), so neither the cli.js serve pattern nor the --port 3000 boundary pattern can ever match any real process.
Intended text in the generated script: tr '\0' ' '.
Observed impact (2026-10-29 23:50 CDT, laptop)
systemctl --user restart openchamber.service with the guarded wrapper: the tracked main (pid 3892827) stopped cleanly, the new instance (pid 483540) started, the guard logged no reap, and the untracked leftover (pid 1668515, started 12:38 CDT) was still holding fd 3 on 127.0.0.1:3000 alongside the new instance (ss -tlnp showed both pids). Replaying the guard's three checks (exe match, cmdline match, port match) by hand against the leftover matched all three once \0 was translated correctly. The leftover had to be TERM'd manually to return to exactly one instance.
Suggested fix
- Emit
tr '\0' ' 'in the generated wrapper (adjust the Nix string escaping inhome/common/default.nixwhereopenchamberStartis defined). - Add a regression test that runs the guard scan against a synthetic
/proc-style cmdline with real NUL separators (or a fake leftover process) and asserts the leftover is selected for reaping.
Acceptance criteria
- The generated
openchamber-servewrapper containstr '\0' ' '(single backslash) — verified byte-for-byte in the generated store file, not just in the Nix source - A regression test runs the guard scan against a synthetic cmdline with real NUL separators (or a fake leftover process) and asserts the leftover is selected for reaping
- After a restart with a leftover instance present, exactly one openchamber instance holds 127.0.0.1:3000 (the feat(usage-hub): snapshot retention — 13-month raw, monthly rollups, backup check #1117 scenario from dezren39/nix, re-verified)
- No other generated-wrapper strings with the same double-escaping defect remain (audit the same Nix string for sibling
tr/escape uses)
Activity
dezren39 commentedon Oct 30, 2026
Intake review
Still live: root cause is byte-verified in the generated store file (
tr '\\0'in the shipped wrapper) and the production symptom was observed live on the laptop 2026-10-29 23:50 CDT — a leftover instance (pid 1668515) kept sharing 127.0.0.1:3000 after a restart and had to be TERM'd by hand. No fix has landed.Related: dezren39/darwin-nix#1117 (the single-instance guard's origin). Cross-repo note: the fix itself lands in dezren39/nix (
home/common/default.nix, whereopenchamberStartis defined) — per the fleet's one-issue-per-set rule this issue tracks the set; the nix PR should reference this issue by URL rather than filing a nix duplicate.Notes / risks: the mechanism is subtle — GNU tr reads
\\as an escaped backslash, so the translate set is {backslash,0} and NULs survive until bash strips them, concatenating argv words so neither guard pattern can match. The fix is one character of escaping, but the regression test is the real deliverable: without a synthetic-cmdline test this exact class of Nix-string-escaping bug will recur silently.Suggested approach: fix the escaping in the Nix source, regenerate, byte-verify the store output, and add the guard-scan test against a fake /proc cmdline.
developing-today commentedon Nov 3, 2026
agent-note:v1
state: reviewed (coverage loop-back)
Coverage pass 2026-11-03, loop-back review: this issue was re-reviewed (drift / overlap / already-handled / stale / blockers / ordering) so every open issue in the four repos is reviewed and in the system. Verdict: still live; in the system as task 7339 (triage, queued, priority 50) in repo-health-code-pilot. Labels audited and synced. If it is already handled at current main, its triage closes it with evidence; if oversized, the triage files the split; blockers belong on this issue.
Found via: coverage loop-back 2026-11-03
dezren39 commentedon Nov 3, 2026
🤖 Agent note · triaged
Triage findings — 2026-11-03 (task 7339)
The guard no longer lives in this repo
origin/main6aeb038a0cd6:openchamberStartis gone fromhome/common/default.nix. The 2026-11-03 service cascade (comment athome/common/default.nix:930-947) moved the unit toservices.openchamberfromdeveloping-today/openchamber'snix/modules; this repo'sbin/openchamber-start.shis only the attach shim and carries no single-instance guard.The defect survived the move, byte-for-byte
origin/main,nix/modules/common.nix:180(thewriteShellApplicationstart wrapper, Linux single-instance guard):cmdline="$(tr '\\0' ' ' < "$proc/cmdline")"— inside a Nix indented string, where backslashes pass through literally.openchamber.serviceExecStart is/nix/store/lqmdax8wgccwqd8avj322w9rfdyj6zxa-openchamber-start/bin/openchamber-start, and its line 37, byte-for-byte (grep | cat -A):cmdline="$(tr '\\0' ' ' < "$proc/cmdline")"$\\as an escaped backslash, so the translate set is {backslash,0}; NULs are never converted, bash$()strips them, argv concatenates, and the space-containing patterns (openchamber serve,--port 3000) can never match. The guard is still a no-op in production.Fix path (enqueued to the openchamber queue)
nix/modules/common.nix: emit a single backslash in the source (tr '\0' ' ') so the generated wrapper containstr '\0' ' '— verified in the generated store file, not just the source.tr/escape defect in the generated start wrapper; the other\\hits under openchambernix/are line continuations and\$@in unrelated build contexts, and this repo no longer generates a wrapper to audit.dezren39 commentedon Nov 3, 2026
Fix task enqueued: task 8929 in queue
repo-health-openchamber-pilot(fix: openchambernix/modules/common.nixguard tr escaping + regression tests, tracking issue stays code#2562).24 remaining items
dezren39 commentedon Nov 8, 2026
🤖 Agent note · handed off
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
opencodedeveloping-today commentedon Nov 8, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 8, 2026
🤖 Agent note · handed off
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off