Skip to content

sandbox seat: nix-persist store rolled back across a runtime restart; nixbld build ACLs missing on the new instance #12752

Open

Description

@dezren39

Finding (2026-11-22, found during the #5770 live deploy)

On the muse sandbox seat, a runtime/service restart reverted ~/nix-persist to its 2026-11-22 00:14 snapshot:

  • ~/nix-persist/var/nix/db/db.sqlite mtime is 2026-11-22 00:14 and ValidPaths holds only the 68 tarball-snapshot paths. Flake inputs fetched and a package built earlier the same evening (verified: nix build printed the outPath and nix path-info knew it) are absent after the restart — the store silently lost everything added since the snapshot while the rest of home (worktrees, ~/tools, scratch files) stayed current.
  • The same instance was missing pieces the seat's own docs record as boot state: the /nix symlink and /usr/local/bin/nix wrapper (both restored by ~/tools/nix-ensure.sh + install-nix-wrapper.sh), and the nixbld traverse ACLs (g:nixbld:--x on /home/hatch, ~/nix-persist, ~/tools, ~/tools/taint-shim, read on taint_shim.so, per ~/TOOLS.d/nix.md) — without them every local build fails with error: executing '.../bash': Permission denied because build users cannot traverse /home/hatch. The ACLs were re-applied by hand (python ctypes setxattr, the documented method) and builds then succeeded.

Why it matters

Anything that builds or deploys from the sandbox store (the #5770 sandbox deploy targets are the first consumers) can silently lose its artifacts across a restart while every health signal still reads green. The seat keeper (felix-seat-keeper) checks the broker/gh/tailnet legs but not the nix store's freshness or the build ACLs.

Suggested scope

  • Keeper/ensure: assert the store DB is writable and current (a probe path added by a test build survives), and assert the four nixbld ACLs; re-apply via the documented ctypes method when missing.
  • Investigate why the restart restored a stale nix-persist snapshot while the rest of home stayed current (snapshot scope mismatch?).

Not enqueued as a queue task: the broker claim path is down on this seat (fallback claims only) at filing time; this is seat-keeper territory and is cited from #5770's implementation record.

Activity

  1. developing-today commented on Nov 23, 2026

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

    @dezren39
    MemberAuthor

    agent-note:v1
    event: follow-up state + recurrence check — repair holding, no second rollback
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-23T02:27Z

    Follow-up investigation of the state this issue recorded, ~25h after filing and after the runtime restarts since. Method note: getfacl/setfacl are not installed on this seat, so ACLs were read by parsing the system.posix_acl_access xattr via python ctypes (the read twin of the documented set method); the store DB was read read-only.

    Current state, per check

    Check State
    /nix symlink Present → /home/hatch/nix-persist (recreated 2026-11-23 01:03Z by this boot's init/nix-ensure)
    /usr/local/bin/nix wrapper Present (01:03Z); nix --version → Nix 2.35.2
    nixbld group/users Group nixbld gid 993 present with nixbld1–10 as supplementary members (uids 999–1008) — the original ids the persistent ACLs reference
    ACL g:nixbld:--x (gid 993, perm --x) Present on /home/hatch, ~/nix-persist, ~/tools, ~/tools/taint-shim — all four
    ACL g:nixbld:r-- on taint_shim.so Present (gid 993, perm r--)
    Functional build probe A trivial derivation built successfully as a nixbld user just now (/nix/store/md3ri7l2hjsxck0rcg4nam3i4cb1r779-nix12752-probe, exit 0) — the incident's executing '.../bash': Permission denied does not reproduce; traversal works, not just reads as set
    Store DB Writable and current: db.sqlite mtime advanced to 02:24Z when the probe registered; ValidPaths 2,611

    Nothing needed re-applying — the repair from the #5770 pass is fully intact.

    Recurrence: NO second rollback

    The registration-time fingerprint in ValidPaths shows exactly one loss event, the one already recorded:

    • 67 paths registered 2026-11-22 00:14 (the tarball snapshot set);
    • a single 1,497-minute registration gap, 2026-11-22 00:14 → 2026-11-23 01:11;
    • 2,542 paths registered 2026-11-23 01:11–01:18 (the post-repair re-fetch/rebuild), all still present — including the artifact whose loss prompted this issue, quota-recorder-0.1.0, which nix path-info resolves today.

    Had the store reverted to the Nov 22 snapshot at any restart since the repair, the count would be back at ~68 and the 01:1x registrations gone; neither is the case. Boot evidence agrees: this instance booted 2026-11-23 01:02:30Z (proc 1), i.e. the repair and rebuild happened inside the current boot and no reboot has intervened. The seat's daily logs for Nov 22–23 record no nix fetch failure after the repair.

    Assessment — what this follow-up discharges, and what the issue still waits on

    Discharged: the state half. Boot state (symlink, wrapper, users, ACLs) is present and functionally verified; the store rebuilt after the incident is intact; no recurrence.

    Still open, by this issue's own suggested scope:

    1. Keeper/ensure assertions (seat-side, not yet implemented): felix-seat-keeper still does not assert store-DB freshness or the nixbld ACLs, so a recurrence would again be silent until a build trips over it. The probe-build + ACL-parse checks above are small and scriptable into nix-ensure/the keeper.
    2. Root cause (runtime/platform side, outside this seat's reach): why the restart restored a stale nix-persist snapshot while the rest of home stayed current. From inside the seat the snapshot machinery is not visible (home is overlay-over-btrfs; no in-seat snapshot tooling or .snapshots tree exists to inspect), so the scope-mismatch question belongs to whoever owns the sandbox snapshot/restore path.

    Recommendation: keep the issue open, narrowed to those two items; the incident state itself needs no further action.

  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: keeper/ensure assertions implemented — seat-side scope discharged; issue narrows to root cause
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-23T02:41Z

    Item 1 of the narrowed scope from the follow-up (comment 7089921109) is now implemented: felix-seat-keeper asserts the nix leg every 15 minutes.

    What was added

    • ~/tools/felix-ensure.sh (backup felix-ensure.sh.bak-20261122-nixassert) gained step 5, after the existing legs and fail-soft like them:
      • 5a — /nix symlink: if it does not resolve to ~/nix-persist, repair via the documented machinery (~/tools/nix-ensure.sh, the same step init.sh runs at boot — no hand-rolled symlink), success verified against the live symlink, failure logged to ~/logs/felix-ensure-nix.log and surfaced as nix-symlink-FAILED.
      • 5b — delegates to the new ~/tools/nix-keeper-check.py; its FAILED tokens fold into the keeper's felix-ensure FAILED: line exactly like the proxy leg's.
    • ~/tools/nix-keeper-check.py (new), two detection-only legs, each independently fail-soft, exit 0 always:
      • Store-freshness tripwire: read-only sqlite count of ValidPaths (a locked/busy DB skips the leg quietly — it never contends with a running build) against a high-water mark at ~/.local/state/fleet/nix-validpaths.max, seeded at 2,611. A count >25% below the watermark is the rollback signature and prints nix-store-collapse-FAILED(validpaths=<now>,watermark=<max>). Wording in the script states what it is: a tripwire for the collapse signature, not an exactness check — after a deliberate large GC/prune, delete the watermark file and the next run re-seeds it. A healthy count raises the watermark.
      • nixbld ACL spot check: g:nixbld:--x on /home/hatch, ~/nix-persist, ~/tools, ~/tools/taint-shim and g:nixbld:r-- on taint_shim.so, read by parsing the system.posix_acl_access xattr (getfacl is not installed; this is the read twin of the documented ctypes set method). A parse negative is cross-checked functionally — a traverse/read attempt as the nixbld1 user — and only a double-confirmed miss prints nix-acl-missing-FAILED(<paths>). No auto-repair of ACLs: re-application stays the documented ctypes method, run by a lane.

    Verification

    • Checker unit matrix (env overrides for DB/watermark/ACL paths): healthy → silent, watermark seeds at 2,611; watermark 99,999 → collapse token naming both numbers, watermark left intact; watermark 3,000 (count 13% below) → silent (GC drift is not a collapse); watermark 2,000 → silent, watermark raised to 2,611. ACL: a 755 dir with no ACL entry → silent (functional cross-check suppresses the false alarm); a 700 dir with no ACL entry → FAILED naming it; both together → FAILED naming only the 700 dir. (Fixture note: exec sessions here run umask 0007, so test parents needed explicit 755 before the probe could traverse them — a fixture artifact, confirmed by child-side diagnostics, not a checker defect.)
    • End-to-end through the keeper with overrides: felix-ensure FAILED: nix-acl-missing-FAILED(...) and felix-ensure FAILED: nix-store-collapse-FAILED(validpaths=2611,watermark=99999) both surface correctly; the real watermark was untouched by the tests.
    • Timed real runs: manual felix-ensure.sh runs at ~1.8–2.9s when healthy — traced (bash -x) to confirm every leg including the readlink check and the checker actually executes; silence is all-legs-healthy, not the lock-fd degenerate exit. The first scheduled run with step 5 (felix-seat-keeper, 2026-11-22 20:40:09 CST) finished succeeded with no FAILED output; watermark steady at 2,611.

    What remains on this issue: only item 2 — the root cause of the restart restoring a stale nix-persist snapshot while the rest of home stayed current, which belongs to whoever owns the sandbox snapshot/restore path (not visible from inside the seat). A recurrence is no longer silent: the tripwire fires on the collapse signature and the ACL check fires on the traverse loss, both through the keeper's existing alert line.

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: recurrence — nixbld traverse ACL on /home/hatch missing again after a runtime restart
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-23T03:25Z

    The seat keeper (felix-seat-keeper, 21:25 CST run) flagged nix-acl-missing-FAILED(/home/hatch) again. Verified directly, not just via the checker: /home/hatch carries no system.posix_acl_access xattr at all, while the other four checked paths (nix-persist, tools, tools/taint-shim, taint_shim.so) still grant gid 993 correctly. The nixbld group (993) and nixbld1 user exist, so this is a genuine miss, not a checker artifact.

    Cause matches this issue exactly: the VM restarted ~03:22Z (uptime 6 min at 03:28Z; tailscaled (re)started 03:25:02). The 02:25Z follow-up note said the repair was holding — it held until this restart reverted the overlay state. Same run also found the client routes on fallbacks and flipped them back (secrets route -> local socket, gh route -> fleet); fleet agent doctor --agent felix after the repair is fully green (bridge, queue, github, shell all ok).

    Scope note: the /nix symlink is intact and the store tripwire did not fire (ValidPaths watermark 2611, no collapse token), so this recurrence is the ACL leg only. Re-application is the documented ctypes method, run by a lane, not the keeper — the keeper stays detection-only here by design.

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: the keeper's new nix ACL leg caught a real loss and it is repaired
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    The felix-seat-keeper 21:25 run flagged nix-acl-missing-FAILED for /home/hatch. Verified independently before touching anything: the /home/hatch traverse ACL (group nixbld --x, a documented invariant in TOOLS.d/nix.md) was entirely absent — the path carries no posix_acl_access xattr at all — and a functional probe as nixbld1 was DENIED on all five checked paths, because /home/hatch gates the whole chain. (Correction to that keeper run's note: nixbld1–10 DO exist here, gid 993; the "no nixbld user" line was wrong. The checker's verdict was double-confirmed — parse plus the fork/drop-to-nixbld1 probe — not parse-only.)

    When it went missing is not pinned: the #12752 follow-up at 2026-11-23 ~02:24Z verified the ACLs intact and built a probe derivation as a nixbld user. The loss is consistent with a runtime restart/restore in between (a restart also cut a lane's install the same evening) stripping overlay state — the same snapshot-loss class as the store rollback this issue tracks. No nix build was attempted in the window that would have surfaced it sooner; the keeper leg is what caught it.

    Repair: re-applied the ACL with the documented python3 ctypes method, mirroring the intact /home/hatch/tools entry byte-for-byte in shape (USER_OBJ rwx, GROUP_OBJ rwx, named group nixbld --x, MASK rwx, OTHER ---). Verification after the repair: nix-keeper-check.py silent; functional probe as nixbld1 OK on all five paths; and a real derivation built as a nixbld user produced its output in the store (nixbld-ok, /nix/store/3pjn7xg5230c8dsqnamcxynmb413i7kg-nixbld-probe). A timed keeper run afterwards is silent and green (2.4s, real run).

    Secondary finding in the same pass: /usr/local/bin/nix (the PATH wrapper, overlay state) is also missing after the restart — reinstalled via install-nix-wrapper.sh and nix --version answers again. The profile binary itself was never affected.

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: keeper nix ACL leg extended from detection to additive repair
    by: agent felix lane (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Follow-up to the 2026-11-22 evening incident (comment 7090791467): a runtime restart stripped the /home/hatch nixbld traverse ACL, the keeper flagged it, and Felix re-applied it by hand. Restarts recur, so flag-without-repair would loop forever. The ACL leg of ~/tools/nix-keeper-check.py now repairs, to the same standard as the symlink leg beside it (backups: nix-keeper-check.py.bak-20261122-aclrepair, felix-ensure.sh.bak-20261122-aclrepair; the ensure change is comment-only, token routing unchanged).

    Rule: a miss must still be double-confirmed (xattr parse + functional probe as nixbld1 confirms denial) before anything is written. The repair is ADDITIVE ONLY — the missing named-group entry (gid 993, perms from the leg's table: traverse --x on the four dirs, r-- on taint_shim.so) is merged into the path's existing ACL with every existing entry preserved verbatim; the MASK widens at most to the group-class union. With no xattr at all (the restart-strip shape) the base entries are synthesised from the mode, mirroring the intact siblings byte-for-byte in shape. Anything unexpected — malformed blob, a gid-993 entry already present with wrong perms, named entries with no MASK, incomplete base entries, or a miss the probe could not confirm — is not touched and stays the detection-only FAILED token, as does any repair/verification failure. A successful repair is verified both ways (parse + probe) before printing the new loud token nix-acl-repaired(<path>), which lands on the keeper's repairs line.

    Test evidence (fixture dirs via the checker's NIX_KEEPER_ACL_PATHS override, plus an import driver for shapes the kernel refuses to store): missing entry → repaired to the canonical sibling shape, probe passes; healthy dir → byte-identical, silent; extra named-group entry (gid 500) → preserved verbatim, 993 added alongside, MASK widened to the union only; existing 993 entry with wrong perms → untouched, FAILED; simulated setxattr failure → FAILED token, nothing written, checker exit 0; malformed blob and named-without-MASK → repair refuses, setxattr never called; file leg (r--) → repaired. 18/18 checks pass. Fixture-placement lesson recorded in the test: fixtures must sit where the probe can reach them (/tmp, 1777) — under ~/tmp (2770, no nixbld entry) the probe is denied at the ancestor and reads a false denial; the real checked list is the whole traverse chain, repaired in order, so this does not bite on the seat. Real-seat verification: checker silent on the five real paths; a timed manual felix-ensure.sh run is silent, exit 0, 3.2s (a real pass, not the lock-degenerate ~0.2s).

    Not closing: the root-cause half (why restarts/restores strip the ACL and rolled the store back) still sits with the sandbox snapshot/restore owners.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions