feat(stage-run): mounts and dry run, Phase 2 part 2 #17

Merged
neerdoc merged 57 commits from feat/phase-2-mounts-dry-run into main 2026-11-19 06:35:48 +00:00
Owner

Phase 2, part 2: mounts and dry run (scripts/stage-run.sh)

Computes the mounts of a stage from stages.yaml and prints them. No container, no network and no write: stage-run.sh STAGE [--dry-run] prints <mode>TAB<host>TAB<container> sorted. Part 3 starts the container. The project stays at effort level tool.

What the script does

  • Declaration checks: stages.yaml form, unknown or repeated keys, merge keys, a NUL in a path, the characters newline, tab, colon and comma, a path both mounted and in never, both modes, duplicates, a missing path.
  • Never mounted: .git, .env*, the folder runs and the review records docs/reviews, whatever the declaration says; names compared without regard to ASCII case, at any depth of a listed folder; an unreadable folder is refused and named.
  • Links: the runner follows none. A listed path that is a link, or has a link among its components, is refused (a listed path may not be a link or pass through one; list the real path). A link found inside a listed folder is left as it is, because it only resolves to what is mounted in the container. Files of a shared module are listed by their real paths. The comparison with never uses the real path of a never entry.
  • Order of checks fixed by class (arguments, tools, root, form of stages.yaml, filesystem), with tests/order-of-checks.bats.
  • scripts/lib.sh: STAGES, is_stage, join_list, resolve_real, an optional shown path for config_file_ok. README row and usage.

Changes in this PR (one bullet per logical change)

  • ADR-WULF-010 amended four times (the folder runs; a link resolved only into a listed path; the same inside a path a stage can write; a listed path is never a link) and ADR-WULF-004 once (common inputs by real paths).
  • Design docs/design/stage-runner.md (DE-S1 to DE-S7), rewritten in round 3.
  • Tests: tests/stage-run.bats (326), tests/order-of-checks.bats (20), helpers and acceptance criteria.
  • Code: the checks, the mounts, the walk, the dry run.
  • Audit and re-audit of the mounts (reports/audit-stage-runner-mounts*.md), issues 0069 to 0071 closed, 0072 to 0074 deferred.
  • Reviews 001 to 004 (docs/reviews/phase-2-mounts-dry-run/), each finding fixed on its own branch and commit; the roadmap ticks P2-2 to P2-5.

Review history

  • Round 1 (Opus): one High, two Medium and one Low, all fixed.
  • Rounds 1 to 3 each found one High on the same boundary, links that a stage could leave in a folder it writes. Each fix narrowed the rule and the next review found another position. In round 3 the owner removed the cause: no link is followed. The link machinery was deleted (448 lines to 312) and the tests for it with it.
  • Round 4 (Opus, latest): clean. No High or Medium finding, two Low: the wording "follows no link" does not say that a never path is resolved (deferred as 0075), and two points of 0074 are void (commented on 0074). Record: docs/reviews/phase-2-mounts-dry-run/review-004.

Verification

  • Full suite: 1556 bats tests, 4 skipped (three part-1 rollback tests that need root and the PR created test), 0 failed.
  • Review 004 ran stage-run.bats and order-of-checks.bats on an export of HEAD under bash 5.3 and the system bash 3.2: 346 passed. It mutated the script 16 ways; 14 are caught and the two that survive each fall back on the other check.

Not covered

  • Any container behaviour: whether links inside a mounted folder stay inert depends on the runtime (Part 3).
  • Deferred and tracked: 0072, 0073 (Unicode folding), 0074 (time of check to use, a NUL in image, case-variant double mounts, a read-only path inside a read-write folder, stages.yaml in a read-write mount) for the design of Part 3; 0075 (wording).
  • The two audit reports describe the code of their time (before the link rule was removed); the reviewer withdrew that as a finding.
  • Linux and GNU find were read, not run.

🤖 Generated with Claude Code

## Phase 2, part 2: mounts and dry run (`scripts/stage-run.sh`) Computes the mounts of a stage from `stages.yaml` and prints them. No container, no network and no write: `stage-run.sh STAGE [--dry-run]` prints `<mode>TAB<host>TAB<container>` sorted. Part 3 starts the container. The project stays at effort level `tool`. ### What the script does - **Declaration checks:** `stages.yaml` form, unknown or repeated keys, merge keys, a NUL in a path, the characters newline, tab, colon and comma, a path both mounted and in `never`, both modes, duplicates, a missing path. - **Never mounted:** `.git`, `.env*`, the folder `runs` and the review records `docs/reviews`, whatever the declaration says; names compared without regard to ASCII case, at any depth of a listed folder; an unreadable folder is refused and named. - **Links:** the runner follows none. A listed path that is a link, or has a link among its components, is refused (`a listed path may not be a link or pass through one; list the real path`). A link found inside a listed folder is left as it is, because it only resolves to what is mounted in the container. Files of a shared module are listed by their real paths. The comparison with `never` uses the real path of a `never` entry. - **Order of checks** fixed by class (arguments, tools, root, form of `stages.yaml`, filesystem), with `tests/order-of-checks.bats`. - `scripts/lib.sh`: `STAGES`, `is_stage`, `join_list`, `resolve_real`, an optional shown path for `config_file_ok`. README row and usage. ### Changes in this PR (one bullet per logical change) - ADR-WULF-010 amended four times (the folder `runs`; a link resolved only into a listed path; the same inside a path a stage can write; **a listed path is never a link**) and ADR-WULF-004 once (common inputs by real paths). - Design `docs/design/stage-runner.md` (DE-S1 to DE-S7), rewritten in round 3. - Tests: `tests/stage-run.bats` (326), `tests/order-of-checks.bats` (20), helpers and acceptance criteria. - Code: the checks, the mounts, the walk, the dry run. - Audit and re-audit of the mounts (`reports/audit-stage-runner-mounts*.md`), issues 0069 to 0071 closed, 0072 to 0074 deferred. - Reviews 001 to 004 (`docs/reviews/phase-2-mounts-dry-run/`), each finding fixed on its own branch and commit; the roadmap ticks P2-2 to P2-5. ### Review history - Round 1 (Opus): one High, two Medium and one Low, all fixed. - Rounds 1 to 3 each found one High on the same boundary, links that a stage could leave in a folder it writes. Each fix narrowed the rule and the next review found another position. In round 3 the owner removed the cause: no link is followed. The link machinery was deleted (448 lines to 312) and the tests for it with it. - **Round 4 (Opus, latest): clean.** No High or Medium finding, two Low: the wording "follows no link" does not say that a `never` path is resolved (deferred as 0075), and two points of 0074 are void (commented on 0074). Record: `docs/reviews/phase-2-mounts-dry-run/review-004`. ### Verification - Full suite: 1556 bats tests, 4 skipped (three part-1 rollback tests that need root and the `PR created` test), 0 failed. - Review 004 ran `stage-run.bats` and `order-of-checks.bats` on an export of HEAD under bash 5.3 and the system bash 3.2: 346 passed. It mutated the script 16 ways; 14 are caught and the two that survive each fall back on the other check. ### Not covered - Any container behaviour: whether links inside a mounted folder stay inert depends on the runtime (Part 3). - Deferred and tracked: 0072, 0073 (Unicode folding), 0074 (time of check to use, a NUL in `image`, case-variant double mounts, a read-only path inside a read-write folder, `stages.yaml` in a read-write mount) for the design of Part 3; 0075 (wording). - The two audit reports describe the code of their time (before the link rule was removed); the reviewer withdrew that as a finding. - Linux and GNU `find` were read, not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 001 of review 001 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 002 of review 001 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 003 of review 001 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 004 of review 001 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 001 of review 002 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 001 of review 003 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Resolves 001 and 002 of review 004 of phase-2-mounts-dry-run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
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
WulfScience-FOSS/wulf-dev!17
No description provided.