assemble-payload.sh: staging the pinned QEMU from the Nix store makes the payload dir READ-ONLY, and the very next step (vm-guest.tar) dies with Permission denied #1752

Closed
opened 2026-09-23 03:06:08 +00:00 by ben · 5 comments
Owner

Hit building the operator app for the 2026-09-22 fresh manual test (elitebook-03, 3b0e35cc, warm Nix store).

scripts/assemble-payload.sh stages the pinned QEMU bundle by copying the build output with cp -a. That output is a Nix store path (or a symlink to one), and store directories are mode r-xr-xr-x — so the copy propagates the store's read-only mode onto the payload DEST directory itself:

==> staging pinned QEMU bundle from /home/swarm/app-build-3b0e35cc/result-pinned-qemu
==> building device VM-guest bundle -> /home/swarm/payload-manual-3b0e35cc/vm-guest.tar (Task 2 of #1153)
tar: /home/swarm/payload-manual-3b0e35cc/vm-guest.tar: Cannot open: Permission denied
tar: Error is not recoverable: exiting now

ls -ld after the failure: dr-xr-xr-x 6 swarm swarm … payload-manual-3b0e35cc. The assembler had created the directory writable; the QEMU staging step took its mode away, and the very next step in the same script — the vm-guest.tar bundle — cannot write into it. Every later step fails the same way, and pnpm package then refuses on an incomplete payload.

It is order-dependent, which is why it has not always bitten: the failure needs the QEMU slot to be staged from a store path before the vm-guest step. A driver that stages QEMU from an already-writable directory never sees it.

Wanted

  • The payload DEST's own mode is the assembler's, not a copied artifact's. After any staging step that copies from the Nix store, restore write permission on the dest tree (chmod -R u+w "$dest", or copy with cp -a --no-preserve=mode for store sources). The store's read-only mode is meaningful inside the store and meaningless in a payload directory the app later reads, rewrites and tars.
  • Fail loudly and legibly if it recurs: the vm-guest step (and any later writer) should check the dest is writable and say the payload dir is not writable — a staging step copied store permissions rather than a bare tar: Permission denied.
  • A test that runs the assembler twice into the same dest with a read-only QEMU source dir and asserts the run completes and vm-guest.tar exists.
  • A GOTCHAS entry beside the existing payload hazards (the one warning never to point PAYLOAD_QEMU_SRC_DIR at an old payload dir is the same family).

Workaround used

chmod -R u+w <dest> and re-run the assembler; it completes.

Relates to #230 (pinned QEMU), #231 (the assembler), #1153 (the vm-guest bundle), #463 (the package preflight).

**Hit building the operator app for the 2026-09-22 fresh manual test** (elitebook-03, `3b0e35cc`, warm Nix store). `scripts/assemble-payload.sh` stages the pinned QEMU bundle by copying the build output with `cp -a`. That output is a Nix store path (or a symlink to one), and store directories are mode `r-xr-xr-x` — so the copy **propagates the store's read-only mode onto the payload DEST directory itself**: ``` ==> staging pinned QEMU bundle from /home/swarm/app-build-3b0e35cc/result-pinned-qemu ==> building device VM-guest bundle -> /home/swarm/payload-manual-3b0e35cc/vm-guest.tar (Task 2 of #1153) tar: /home/swarm/payload-manual-3b0e35cc/vm-guest.tar: Cannot open: Permission denied tar: Error is not recoverable: exiting now ``` `ls -ld` after the failure: `dr-xr-xr-x 6 swarm swarm … payload-manual-3b0e35cc`. The assembler had created the directory writable; the QEMU staging step took its mode away, and the **very next step in the same script** — the `vm-guest.tar` bundle — cannot write into it. Every later step fails the same way, and `pnpm package` then refuses on an incomplete payload. It is order-dependent, which is why it has not always bitten: the failure needs the QEMU slot to be staged from a store path *before* the vm-guest step. A driver that stages QEMU from an already-writable directory never sees it. ## Wanted - **The payload DEST's own mode is the assembler's, not a copied artifact's.** After any staging step that copies from the Nix store, restore write permission on the dest tree (`chmod -R u+w "$dest"`, or copy with `cp -a --no-preserve=mode` for store sources). The store's read-only mode is meaningful inside the store and meaningless in a payload directory the app later reads, rewrites and tars. - **Fail loudly and legibly if it recurs:** the vm-guest step (and any later writer) should check the dest is writable and say *the payload dir is not writable — a staging step copied store permissions* rather than a bare `tar: Permission denied`. - A test that runs the assembler twice into the same dest with a **read-only** QEMU source dir and asserts the run completes and `vm-guest.tar` exists. - A GOTCHAS entry beside the existing payload hazards (the one warning never to point `PAYLOAD_QEMU_SRC_DIR` at an old payload dir is the same family). ## Workaround used `chmod -R u+w <dest>` and re-run the assembler; it completes. Relates to #230 (pinned QEMU), #231 (the assembler), #1153 (the vm-guest bundle), #463 (the package preflight).

swarm-claim host=bens-mac-04 run=30622
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=30622 (automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=30622
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=bens-mac-04 run=30622 (automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=30625
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=30625 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1752 — status success

⛔ close-report gates REFUSED this close — the following claims did not verify:

  • commit 528697e977 is not a valid commit object (fabricated, or never pushed)
  • changed_files: 'scripts/assemble-payload.sh' is not in the diff of the claimed commits
  • changed_files: 'scripts/tests/payload-store-mode-test.sh' is not in the diff of the claimed commits
  • changed_files: 'docs/GOTCHAS.md' is not in the diff of the claimed commits
envelope
{
  "issue": 1752,
  "status": "success",
  "commits": [
    "528697e977"
  ],
  "changed_files": [
    "scripts/assemble-payload.sh",
    "scripts/tests/payload-store-mode-test.sh",
    "docs/GOTCHAS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/payload-store-mode-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/vm-guest-slot-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/assemble-payload.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "The payload DEST's own mode is the assembler's, not a copied artifact's — restore write on the dest tree after a store-sourced copy": "scripts/assemble-payload.sh: the QEMU staging step now runs `chmod -R u+w \"$dest\"` across the whole tree (was only lib/ + qemu-datadir/); kept `cp -a` so the wrappers'/.real's exec bits survive rather than `--no-preserve=mode`",
    "Fail loudly and legibly if it recurs — the vm-guest step (and later writers) check the dest is writable and name the cause": "scripts/assemble-payload.sh: the vm-guest block guards `[[ ! -w \"$dest\" ]]` and exits with 'the payload dir is not writable — a staging step copied store permissions onto it' instead of a bare `tar: Permission denied`",
    "A test that runs the assembler twice into the same dest with a read-only QEMU source and asserts the run completes and vm-guest.tar exists": "scripts/tests/payload-store-mode-test.sh: read-only (mode 555) QEMU source, two assembler runs into the same dest via slot overrides, asserts both complete + vm-guest.tar exists + dest stays writable; reds on the unfixed script with the reported `tar: Permission denied`",
    "A GOTCHAS entry beside the existing payload hazards": "docs/GOTCHAS.md #317 — the `cp -a \"$store/.\" \"$dest/\"` store-mode-on-dest hazard, cross-referencing the payload family #24/#308"
  },
  "summary": "assemble-payload.sh restores user-write across the whole payload dir after copying the pinned QEMU from a read-only Nix store source, so vm-guest.tar and every later writer no longer die with `tar: Permission denied`.",
  "blockers": []
}
**close-report** for #1752 — status `success` :no_entry: **close-report gates REFUSED this close** — the following claims did not verify: - commit 528697e977 is not a valid commit object (fabricated, or never pushed) - changed_files: 'scripts/assemble-payload.sh' is not in the diff of the claimed commits - changed_files: 'scripts/tests/payload-store-mode-test.sh' is not in the diff of the claimed commits - changed_files: 'docs/GOTCHAS.md' is not in the diff of the claimed commits <details><summary>envelope</summary> ```json { "issue": 1752, "status": "success", "commits": [ "528697e977" ], "changed_files": [ "scripts/assemble-payload.sh", "scripts/tests/payload-store-mode-test.sh", "docs/GOTCHAS.md" ], "tests": [ { "command": "bash scripts/tests/payload-store-mode-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/vm-guest-slot-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/assemble-payload.sh", "exit_code": 0 } ], "criteria": { "The payload DEST's own mode is the assembler's, not a copied artifact's — restore write on the dest tree after a store-sourced copy": "scripts/assemble-payload.sh: the QEMU staging step now runs `chmod -R u+w \"$dest\"` across the whole tree (was only lib/ + qemu-datadir/); kept `cp -a` so the wrappers'/.real's exec bits survive rather than `--no-preserve=mode`", "Fail loudly and legibly if it recurs — the vm-guest step (and later writers) check the dest is writable and name the cause": "scripts/assemble-payload.sh: the vm-guest block guards `[[ ! -w \"$dest\" ]]` and exits with 'the payload dir is not writable — a staging step copied store permissions onto it' instead of a bare `tar: Permission denied`", "A test that runs the assembler twice into the same dest with a read-only QEMU source and asserts the run completes and vm-guest.tar exists": "scripts/tests/payload-store-mode-test.sh: read-only (mode 555) QEMU source, two assembler runs into the same dest via slot overrides, asserts both complete + vm-guest.tar exists + dest stays writable; reds on the unfixed script with the reported `tar: Permission denied`", "A GOTCHAS entry beside the existing payload hazards": "docs/GOTCHAS.md #317 — the `cp -a \"$store/.\" \"$dest/\"` store-mode-on-dest hazard, cross-referencing the payload family #24/#308" }, "summary": "assemble-payload.sh restores user-write across the whole payload dir after copying the pinned QEMU from a read-only Nix store source, so vm-guest.tar and every later writer no longer die with `tar: Permission denied`.", "blockers": [] } ``` </details>

close-report for #1752 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1752,
  "status": "success",
  "commits": [
    "528697e98e1a60e387c58d6a5ead13d756ba744c"
  ],
  "changed_files": [
    "scripts/assemble-payload.sh",
    "scripts/tests/payload-store-mode-test.sh",
    "docs/GOTCHAS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/payload-store-mode-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/vm-guest-slot-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/assemble-payload.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "The payload DEST's own mode is the assembler's, not a copied artifact's — restore write on the dest tree after a store-sourced copy": "scripts/assemble-payload.sh: the QEMU staging step now runs `chmod -R u+w \"$dest\"` across the whole tree (was only lib/ + qemu-datadir/); kept `cp -a` so the wrappers'/.real's exec bits survive rather than `--no-preserve=mode`",
    "Fail loudly and legibly if it recurs — the vm-guest step (and later writers) check the dest is writable and name the cause": "scripts/assemble-payload.sh: the vm-guest block guards `[[ ! -w \"$dest\" ]]` and exits with 'the payload dir is not writable — a staging step copied store permissions onto it' instead of a bare `tar: Permission denied`",
    "A test that runs the assembler twice into the same dest with a read-only QEMU source and asserts the run completes and vm-guest.tar exists": "scripts/tests/payload-store-mode-test.sh: read-only (mode 555) QEMU source, two assembler runs into the same dest via slot overrides, asserts both complete + vm-guest.tar exists + dest stays writable; reds on the unfixed script with the reported `tar: Permission denied`",
    "A GOTCHAS entry beside the existing payload hazards": "docs/GOTCHAS.md #317 — the `cp -a \"$store/.\" \"$dest/\"` store-mode-on-dest hazard, cross-referencing the payload family #24/#308"
  },
  "summary": "assemble-payload.sh restores user-write across the whole payload dir after copying the pinned QEMU from a read-only Nix store source, so vm-guest.tar and every later writer no longer die with `tar: Permission denied`.",
  "blockers": []
}
**close-report** for #1752 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1752, "status": "success", "commits": [ "528697e98e1a60e387c58d6a5ead13d756ba744c" ], "changed_files": [ "scripts/assemble-payload.sh", "scripts/tests/payload-store-mode-test.sh", "docs/GOTCHAS.md" ], "tests": [ { "command": "bash scripts/tests/payload-store-mode-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/vm-guest-slot-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/assemble-payload.sh", "exit_code": 0 } ], "criteria": { "The payload DEST's own mode is the assembler's, not a copied artifact's — restore write on the dest tree after a store-sourced copy": "scripts/assemble-payload.sh: the QEMU staging step now runs `chmod -R u+w \"$dest\"` across the whole tree (was only lib/ + qemu-datadir/); kept `cp -a` so the wrappers'/.real's exec bits survive rather than `--no-preserve=mode`", "Fail loudly and legibly if it recurs — the vm-guest step (and later writers) check the dest is writable and name the cause": "scripts/assemble-payload.sh: the vm-guest block guards `[[ ! -w \"$dest\" ]]` and exits with 'the payload dir is not writable — a staging step copied store permissions onto it' instead of a bare `tar: Permission denied`", "A test that runs the assembler twice into the same dest with a read-only QEMU source and asserts the run completes and vm-guest.tar exists": "scripts/tests/payload-store-mode-test.sh: read-only (mode 555) QEMU source, two assembler runs into the same dest via slot overrides, asserts both complete + vm-guest.tar exists + dest stays writable; reds on the unfixed script with the reported `tar: Permission denied`", "A GOTCHAS entry beside the existing payload hazards": "docs/GOTCHAS.md #317 — the `cp -a \"$store/.\" \"$dest/\"` store-mode-on-dest hazard, cross-referencing the payload family #24/#308" }, "summary": "assemble-payload.sh restores user-write across the whole payload dir after copying the pinned QEMU from a read-only Nix store source, so vm-guest.tar and every later writer no longer die with `tar: Permission denied`.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1752
No description provided.