Repository navigation
Description
Relocated from dezren39/darwin-nix#377 on 2026-10-28 (placement audit): The unidentified deletion stripped git HEAD/config/loose-refs from 9 OpenCode working clones; local nix tools were already ruled out in the body and the surviving suspects are fleet/agent maintenance tooling tracked in code. Original body below; issue references inside it are historical (dezren39/nix numbering).
At 03:35 on 2026-10-17 something deleted .git/HEAD, .git/config, .git/info/exclude and all loose ref files from 9 clones under /private/var/folders/…/T/opencode/ (argoproj, np, p, tfdd, upjet, vco, vcpx, vhct, vhct-poc). Git stopped recognising them. Objects, packed-refs, the index, logs and working files survived.
Repaired: HEAD rebuilt from logs/HEAD + packed-refs (branch where the last checkout named one, otherwise the exact last commit), plus a minimal config with origin from the clone log. All 9 work again. 7 are clean; np and p hold intentional staged deletions, now backed up (#376).
Cause: unconfirmed. Ruled out: git-maintain-repos (it only deletes .DS_Store) and clean.sh's sweeps (they delete whole entries, not files inside .git). The pattern fits macOS's daily temp cleaner, which removes files in /private/var/folders/*/T not accessed for ~3 days: the deleted files dated from the clone (Oct 13), and description survived because it was accessed Oct 16. But log show returned nothing for dirhelper, so this isn't proven.
Why it matters: opencode sessions put real worktrees and clones in $TMPDIR/opencode, including the worktree this investigation ran in and a live postgres cluster. If the OS cleans this path, anything left idle for a few days can be silently damaged.
To do:
- Confirm the cause (
sudo log show --predicate 'process == "dirhelper"' --last 2d, or watch withfs_usage). - Stop using
$TMPDIRfor durable work: point opencode's scratch/worktree root at~/.local/share/opencode(as clean.sh's own comment already recommends). - Move anything still needed out of
$TMPDIR/opencode.
Acceptance criteria
- The cause is confirmed or ruled out with evidence (dirhelper
log showpredicate, or anfs_usagewatch) and the result is recorded on this issue. - opencode's scratch/worktree root no longer lives under
$TMPDIR: durable clones and worktrees point at a non-temp path (e.g.~/.local/share/opencode, as clean.sh's comment recommends). - Anything still needed has been moved out of
$TMPDIR/opencode. - Recurrence check: clones/worktrees under the new root survive several idle days with
.git/HEAD,configand loose refs intact.
Activity
developing-today commentedon Oct 28, 2026
CODE-789
dezren39 commentedon Oct 28, 2026
History carried over from dezren39/darwin-nix#377 (verbatim, oldest first):
@dezren39 · 2026-10-18T06:51:22Z
Cause confirmed:
/System/Library/LaunchDaemons/com.apple.bsd.dirhelper.plistruns/usr/libexec/dirhelperdaily at 03:35 withCLEAN_FILES_OLDER_THAN_DAYS=3. It deletes files in the per-user/private/var/folders/*/Tnot accessed in 3 days. That's why write-once, rarely-read files went first (HEAD,config, worktree.gitpointer files). opencode advertisesos.tmpdir()/opencode(packages/util/src/global-roots.ts) to every agent as approved scratch space, which is how durable work ended up there.Fixed now (no rebuild needed):
$TMPDIR/opencode(612 entries, 7.5 GB) to~/.local/share/opencode/tmp/opencode(same volume, atomic renames, 0 failures), and replaced$TMPDIR/opencodewith a symlink to it. Every recorded path keeps working, including the live OpenChamber server's advertised tmp (resolved at startup) and other sessions mid-write, and new writes land outside dirhelper's reach. Verified with a probe write. If dirhelper ever deletes the old symlink, nothing behind it is lost.ackfailandmainwt(operations-portal) had lost their.gitpointer files in the same 03:35 sweep, plus 1,585 and 925 tracked working files. Rewrote the pointers, rangit worktree repairso all 3 worktrees there record their durable paths, and restored only the deleted files from each worktree's HEAD. Both are clean;worktree prune --dry-runfinds nothing. This mattered because clean.sh now runsgit worktree prune, which would have unregistered them.touch -a, mtime untouched) on the 8,765 files that tonight's run would have deleted.Already in progress elsewhere: fork
515048c(OPENCODE_TMPDIR, developing-today-forks/opencode#13) andflake.nix's wrapper (TMPDIR=${OPENCODE_TMPDIR:-~/.local/share/opencode/tmp}). The launchd server inopenchamber.nixuses the wrapped package, so it's covered once deployed.Still needed:
515048c(the pinf9aa962predates it).$TMPDIRpath. The symlink makes that safe. Keep it until the rebuild.@dezren39 · 2026-10-26T23:38:16Z
Intake review
🤖 Agent note · filed
Still live (verified this run): the repairs in the body restored the 9 damaged clones, but none of the three "To do" items is recorded as done anywhere: the cause is still unconfirmed, and no later issue or PR in this repo moves opencode's scratch/worktree root out of
$TMPDIR. The exposure the body describes — idle clones under$TMPDIR/opencodesilently losing.gitfiles — stands until item 2 lands.Related: #376 (backups of the intentional staged deletions in np and p — read before moving anything), #375 (clean.sh's remaining recommendations; clean.sh was ruled out as the cause but its comment already recommends the durable root), #373 (fast-dropping free disk — the neighbouring $TMPDIR hygiene item).
Notes / risks: priority is high because the failure mode is silent data damage with a ~3-day idle fuse, and one of the paths at risk held a live postgres cluster. The cause hypothesis (macOS temp cleaner) is plausible but unproven — the acceptance criteria now ask for the evidence either way, so a worker should not stall the move (item 2) on confirming the cause (item 1); the move is protective under every candidate cause.
Suggested approach: do item 2 first (point opencode's scratch/worktree root at
~/.local/share/opencodeand move what's still needed, checking #376's backups before touching np/p), then run the dirhelper log query on the Mac to close item 1 with evidence.@dezren39 · 2026-10-27T15:35:21Z
Reopening to correct the record: PR #392 merged the opencode-tmp-guard, which is the workaround (keep agent work out of dirhelper's temp sweep). Per the guard's own header, the real fix is still outstanding: the flake.nix opencode wrapper should default TMPDIR to the durable directory so files under $TMPDIR/opencode are not exposed to the sweep in the first place. #392 closed this issue via its 'Closes part of #377' wording, but only the workaround half has landed.
@dezren39 · 2026-10-27T15:43:55Z
🤖 Agent note · triage evidence: the wrapper half of the real fix is already in the repo
The flake.nix opencode wrapper already defaults TMPDIR to the durable dir. At both the PR #392 merge commit (e05c448) and current origin/main,
flake.nix(wrapper at lines 385-402) runs:That line was added in 3e74b3c (2026-10-16, 'opencode/openchamber: build from our forks...'), i.e. before the Oct 17 sweep and long before PR #392. The guard header's 'the real fix is the opencode wrapper in flake.nix' describes this existing wrapper; the guard exists for the interim the header names next: 'until every opencode on the machine is that wrapper'.
What is actually still outstanding is deployment, not repo code:
opencodefirst on PATH (/etc/profiles/per-user/user/bin/opencode, home-manager path) is a different wrapper script that execs the unwrapped binary directly and sets no TMPDIR default, and no store path for the flake's wrapped opencode (a script mentioning OPENCODE_TMPDIR) exists in /nix/store. So the deployed machine is not yet running the wrapper everywhere — that needs the rebuild/deploy step (sudo, cf. docs(mcpx): re-sync story.md's AGENTS.md quote and guard it with a test #374), which a queue worker cannot do.One deliberate non-change: the queue packet suggested respecting an explicitly-set TMPDIR. That was NOT implemented: macOS sets TMPDIR for essentially every process, so respecting it would defeat the fix;
OPENCODE_TMPDIRis the wrapper's documented override knob instead.Task 1443 is completed in the queue as already_done (code). This issue stays open for the deployment + recurrence items above.
17 remaining items
dezren39 commentedon Nov 14, 2026
🤖 Agent note · triage complete (queue task 2752)
dezren39 commentedon Nov 14, 2026
agent-note:v1
state: triaged
Concurrence note (2026-11-14): this triage was completed earlier today by lane code-h (task 2752, note 2026-11-14T10:54Z); this lane re-verified its load-bearing facts rather than re-triaging.
user/escalated.Task 16626 completes as triaged (concurring).
dezren39 commentedon Nov 17, 2026
🤖 Agent note · triage complete (queue task 18147)
user/escalated.dezren39 commentedon Nov 17, 2026
🤖 Agent note — already handled (task 19591, lane code-i)
Fresh GitHub state confirms #1862 remains open and
user/escalated. Task 18147 just completed the re-triage: the cause and code fix are established; only Drew-gated deployment and the time-based recurrence check remain. No new actionable repo work or follow-up packet is warranted.dezren39 commentedon Nov 22, 2026
Owner-parks batch (#12234, 2026-11-22) — sharpened to a hands item (marker now in the body).
Settled, with evidence in the thread: the culprit is macOS
dirhelper(daily 03:35, deletes unaccessed files under /private/var/folders/*/T), and the code fix already exists in dezren39/nix (guard PR #392 plus the flake wrapper defaulting TMPDIR to the durable dir, since 3e74b3c). No fleet/agent-tooling culprit remains. The one remaining step needs a person: run the sudo home-manager rebuild on the Mac and laptop so the wrapped opencode lands on PATH (verified still unwrapped on 2026-11-14). After that, the time-based recurrence check is a soak observation, not a person wait.developing-today-fleet commentedon Nov 26, 2026
🤖 Agent note · verify-and-route verdict (queue task 24936, lane code-h, 2026-11-27)
Fresh state verified this pass:
user/escalated, hands marker present in body (sudo home-manager rebuild on Mac + laptop). Prior verdicts of record stand: tasks 2752, 16626, 18147, 19591.dirhelper(daily 03:35, deletes unaccessed files under /private/var/folders/*/T). Code fix lives in dezren39/nix (opencode-tmp-guard PR CI: push-to-main verification runs share one cancellable group — 11 of the last 18 id-check main runs were cancelled by the next merge #392 + flake wrapper defaulting TMPDIR to the durable dir) — not in this repo, so no fleet/agent-tooling culprit remains here.opencode(~/.local/bin/opencodeshim) still execs the store binary directly with no TMPDIR default — deployment step remains outstanding and person-gated.Verdict: already triaged — no new packet. Remaining items are (a) the sudo rebuild (hands, Drew-gated) and (b) the time-based recurrence soak after deployment — neither is queue-actionable work for this lane. Issue stays open as
user/escalated.dezren39 commentedon Nov 27, 2026
1837-L disposition (2026-11-26, queue task 25432, follow-on of task 24936):
Re-verified: #1862 remains OPEN with
user/escalatedand the hands marker in the body. The verdict of record stands unchanged — cause confirmed (macOS dirhelper, daily 03:35, deletes unaccessed files under /private/var/folders/*/T), code fix already landed in dezren39/nix (opencode-tmp-guard PR #392 + flake wrapper defaulting TMPDIR to the durable dir). No code work remains in this repo.Remaining: (a) the hands step — sudo home-manager rebuild on the Mac and laptop so the TMPDIR-wrapped opencode lands on PATH; (b) the time-based recurrence soak after that deployment. Parking queue task 25432 as that hands item.
dezren39 commentedon Nov 29, 2026
Census 2026-11-29 (lane CEN-C02) — rechecked firsthand.
State: OPEN,
user/escalated; investigation complete, fix landed elsewhere, deployment is a hands item. Settled on the evidence: the culprit is macOSdirhelper(daily 03:35 run deleting unaccessed files under /private/var/folders/*/T) — the fleet/agent-tooling suspects in this repo were ruled out. The code fix lives in dezren39/nix: the opencode-tmp-guard (PR #392) plus the flake wrapper defaulting TMPDIR to the durable directory. No code work remains in this repo.Remaining, both person-gated:
Blocker: Drew's hands for the sudo rebuilds (the body's hands marker). Labels/priority: kind/bug + priority/high confirmed correct by this census — the underlying risk (silent damage to idle worktrees) stays high until the deployment lands.
developing-today-fleet commentedon Nov 29, 2026
Census 2026-11-29 (Felix): full re-read (body, labels, all comments, edges) in the CODE-6 recovery pass.
STRENGTHS: the culprit is settled (macOS dirhelper) and the code fix landed in dezren39/nix — the diagnosis half is fully documented.
FIXES I APPLIED: none needed — labels accurate.
REMAINS: FOR DREWRY (hands) — the sudo home-manager rebuild on the Mac and the laptop that applies the landed fix. Part of the #12234 hands set.
developing-today-fleet commentedon Nov 29, 2026
Issue census — 2026-11-29
Wave-2 census pass (group code-01409-03205): rechecked live state, body, labels and recent comments firsthand via
fleet ghimmediately before editing.A 2026-11-29 census note from another lane (CEN-*/Felix) already exists on this issue — skimmed, not duplicated; this note records only the residual verdict and any residual fixes.
Strengths: detailed body (2821 chars) with context a picker-up can start from; acceptance criteria present in the body; single taxonomy priority band (priority/high) — verified against live labels; kind label present (kind/bug).
Gaps found: no status//queue/ lifecycle label — state is carried by user/escalated (hands item pending); left as-is.
Actions taken this pass: none — verified complete, no changes.
Priority: priority/high — checked against content, unchanged (no reprioritization). No closing keywords used; issue left open.
developing-today-fleet commentedon Nov 30, 2026
Census untouched-items follow-up — 2026-11-29.
This item was on the census's needs-Drew list. Everything fleet-side is done or verified as far as it goes; the record stands as verified on this thread. The one remaining act is Drew's: Run the sudo home-manager rebuild on the Mac (the marker is in this thread); the laptop leg is fleet work once the laptop channel returns. Nothing else is blocked behind anything else; when that act is done, the rest is fleet work and needs no further decision.