Skip to content

fix(dogfood): add an explicit one-time migration for legacy executables - #367

Merged
shingonoide merged 4 commits into
mainfrom
fix/dogfood-legacy-migration
Nov 18, 2026
Merged

shingonoide merged 4 commits into
mainfrom
fix/dogfood-legacy-migration

Conversation

@shingonoide

Copy link
Copy Markdown
Contributor

Summary

An installation whose executable predates the sidecar commit field cannot be adopted (adopt correctly refuses it), so its state-writer record can never be created and every start and restart is refused. This adds a narrow, explicit way to attest that legacy source boundary once.

  • supervise-dogfood.sh migrate-legacy COMMIT SHA256 (stopped instance only). It checks the executable's sha256, requires an embedded sidecar without a commit= field, requires exactly one embedded unverified:COMMIT build record equal to COMMIT, takes a verified state backup, and writes the writer with provenance=legacy-attested. It never replaces an existing writer and never writes provenance=verified-sidecar.
  • A legacy-attested writer is accepted only as the ancestry floor for a launch. The launching build must still carry its own verified sidecar, and the first verified start replaces the record.
  • Restart capture and recovery still require a verified running record. A legacy running executable is not restarted.
  • write_backup gained a keep argument so the migration does not prune older backups.
  • refresh-dogfood.sh --check reports the state-writer provenance, the running executable's sha256 (read through /proc), and the selected artifact. It exits 1 and names each apply blocker. --apply refuses the same blockers before any build or stop.

Testing

  • scripts/test-supervise-dogfood.sh: 209 passed (198 existing, 11 new migration cases).
  • scripts/test-refresh-dogfood.sh: 27 passed (23 existing, 4 new preflight cases).

Not covered by a dedicated case: a restart that refuses a legacy running executable before stopping it, and two concurrent migrations (the lifecycle lock covers migrate-legacy by code path only).

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: BarraDev/slashit
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 3d23039
  • Layers: Repository YAML (base), Repository UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 789c4037-c33a-411b-9bc0-0562c78ac9a2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

The supervisor adds migrate-legacy COMMIT SHA256 to validate eligible stopped installations, retain a backup, and create a legacy-attested state-writer record. Verified launches can later replace that record with verified-sidecar provenance. The refresh script reports state-writer provenance and the running executable hash. It collects preflight blockers and refuses to apply when blockers exist. Tests cover migration validation, writer-record behavior, and refresh preflight checks.

Possibly related PRs

  • BarraDev/slashit#363: Adds the --check and --apply contract that this change extends.
  • BarraDev/slashit#306: Introduces the supervisor’s verified-sidecar and identity checks extended by the new legacy-attested record.
  • BarraDev/slashit#362: Adds the state-writer ancestry check used by the legacy migration and verified-start behavior.

Change: Bug fix

Merge Risk: Low · previous review 75b52

The legacy-migration flow works as designed, but the migration backup can be deleted by later routine restarts, and refresh preflight can pass for a writer record the supervisor will refuse. One new test may also be flaky. These are bounded and worth fixing, but none put state at risk.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the dogfood fix and the one-time migration for legacy executables, which matches the main change: a new migrate-legacy command in supervise-dogfood.sh with a backup and a legacy-attest…
Description check Passed The description explains the problem (legacy executables cannot be adopted, so their state-writer record cannot be created) and the new migrate-legacy command. It also covers the ancestry-floor behavi…
Persistent State Integrity Passed The PR changes four shell scripts. The only new persistence write is cmd_migrate_legacy in scripts/supervise-dogfood.sh. Its write path meets the check's three failure conditions: 1. **No false su…
Recoverable Resource Lifecycle Passed The PR changes four dogfood shell scripts. The lifecycle-relevant changes are the new migrate-legacy path in scripts/supervise-dogfood.sh, the write_backup keep option, and read-only preflight b…
Platform Boundary Safety Passed The check is applicable only in part. The pull request changes four Bash scripts under scripts/ and no Rust, Tauri, or other shipped-target code. The changed build path does not compile for any plat…
Full details: Title check

Explanation

The title names the dogfood fix and the one-time migration for legacy executables, which matches the main change: a new migrate-legacy command in supervise-dogfood.sh with a backup and a legacy-attested writer record. The title is concise and states the primary change. It does not claim work that is absent. The title uses the conventional fix(dogfood) prefix.

Full details: Description check

Explanation

The description explains the problem (legacy executables cannot be adopted, so their state-writer record cannot be created) and the new migrate-legacy command. It also covers the ancestry-floor behavior, the write_backup keep argument, the refresh-dogfood.sh --check and --apply preflight changes, and test counts. It is directly related to the changeset.

Full details: Persistent State Integrity

Explanation

The PR changes four shell scripts. The only new persistence write is cmd_migrate_legacy in scripts/supervise-dogfood.sh. Its write path meets the check's three failure conditions: 1. No false success after a failed write. The script prints success and exits 0 only after ln -T "$tmp" "$STATE_WRITER" succeeds. Any failure in the printf, sync, or ln chain reaches fail "cannot create $STATE_WRITER; no record was written...". The one post-write failure, a failed sync -- "$SUP_DIR", is reported as a failure, not a success. 2. No unpersisted state published after failure. The state is not changed by the migration. The backup runs first through write_backup keep. If the backup fails, the script calls fail before any writer record exists. The record is created only after the backup verifies. 3. No stale read-modify-write overwrite. The record is written to a temp file and linked with ln -T, which never replaces an existing file. The explicit [ ! -e "$STATE_WRITER" ] check also refuses an existing record. migrate-legacy runs under lifecycle_lock. The PR notes that concurrent migration has no dedicated test, but the no-clobber link still stops an overwrite. The other changes are read-only or gate logic. In refresh-dogfood.sh, the new blockers and /proc hashing only report facts and refuse --apply before any build or stop. The state_writer_gate change only widens which provenance marker is accepted. It writes nothing. The write_backup change only skips pruning when keep is passed. Nothing in the diff adds a persisted-state write that reports success after a failure.

Full details: Recoverable Resource Lifecycle

Explanation

The PR changes four dogfood shell scripts. The lifecycle-relevant changes are the new migrate-legacy path in scripts/supervise-dogfood.sh, the write_backup keep option, and read-only preflight blockers in scripts/refresh-dogfood.sh. Checks on the migrate-legacy path: - It refuses when $STATE_WRITER already exists. It never clears or replaces an existing writer record. - It takes the state backup before it writes anything. If the backup fails, it stops with fail and writes no record. - The record is written to a temp file and then linked with ln -T, which does not replace an existing file. On failure, the script removes only the temp file and calls launch_discard, which removes only the private launch copy. - Each failure message reports the backup path. This gives an explicit recovery path. - write_backup skips the retention prune when called with keep. This reduces deletion of older backups. Other changes: - The state_writer_gate change only widens the accepted provenance. It does not delete anything. - The verified-sidecar write path is unchanged in the diff. It uses mv -f -T, so the record is replaced atomically. - The refresh-dogfood.sh changes add read-only checks and blockers. They do not delete any state, backup, or writer record. The PR does not clear the last persisted reference to a resource before cleanup is confirmed. It does not add a cleanup step with no recovery path.

Full details: Platform Boundary Safety

Explanation

The check is applicable only in part. The pull request changes four Bash scripts under scripts/ and no Rust, Tauri, or other shipped-target code. The changed build path does not compile for any platform, so no cross-platform compile failure is possible. Unix-specific usage in the diff is /proc/<pid>/exe reads, sha256sum, mktemp, flock, and setsid. These are Linux-only dogfood tooling. The supervisor gates its target explicitly: scripts/supervise-dogfood.sh line 178 tests uname -s and exits with "unsupported platform ... this supervisor is Linux only" on any other platform. The test harness scripts/test-supervise-dogfood.sh also enforces Linux at line 17 and includes a uname shim case at lines 393–400. scripts/refresh-dogfood.sh has no uname gate of its own. It reads /proc directly and invokes the supervisor through $sup. On a non-Linux host, the /proc read fails quietly into an "unreadable running executable" apply blocker, and the supervisor refuses the target platform. That is fail-closed behaviour, not a crash or silent success. The Rust crates in the repository gate their Unix and Windows code with #[cfg(...)], but this pull request does not touch them. The pull request therefore introduces no ungated platform-specific code on a supported target. Its Linux-only tooling is consistent with the existing gate.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review info

Run configuration

  • Source mode: Auto
  • Repository: BarraDev/slashit
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 3d23039
  • Layers: Repository YAML (base), Repository UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6b08564b-eaba-43d8-a356-09533c850f5a
Commits

Reviewing files that changed from the base of the PR and between 3d23039 and 75b5267.

Files selected for processing: 4

  • scripts/refresh-dogfood.sh
  • scripts/supervise-dogfood.sh
  • scripts/test-refresh-dogfood.sh
  • scripts/test-supervise-dogfood.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread scripts/refresh-dogfood.sh Resolved
Comment thread scripts/supervise-dogfood.sh Resolved
Comment thread scripts/test-refresh-dogfood.sh Resolved
The supervisor writes a complete marker after a state backup verifies, and
refresh-dogfood.sh reports the newest marked backup. A newer directory without
the marker is listed apart as not a verified recovery point, so an interrupted
or failed copy is never presented as one. Backups taken before this change
stay in place and unmarked.
…n refresh fixtures

Refresh preflight now blocks a state-writer record with no accepted provenance,
matching the supervisor gate, so --check and --apply agree. A migration backup
is marked retained and routine pruning never removes it. The deleted-executable
fixture waits until the child runs its copy before unlinking the path.

Adds regression cases for the unmarked writer, an override that selects an older
artifact, retained migration snapshots, and two simultaneous migrations.
…iter promotion

A start that promotes the state writer and then never answers leaves the writer
naming the verified build that exec'd, with no live child. Starting that same
verified build again succeeds and records it as verified. Adds the two cases.
@shingonoide

Copy link
Copy Markdown
Contributor Author

CodeRabbit review status for this PR: NOT REVIEWED at the final HEAD 9633949. CodeRabbit reviewed an earlier commit (75b5267) and its check on the final HEAD is skipped. It was not re-requested. The three original CodeRabbit findings were addressed in 4ab699f, and their review threads are resolved. All functional hosted CI checks passed on the final HEAD in run 44317005235, attempt 3.

@shingonoide
shingonoide merged commit 27df25f into main Nov 18, 2026
47 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant