linux-boot: harden boot-digest/run-boot dedup, empty-stats, and argument checks #2274

Open
github-bot wants to merge 1 commit from github-bot/gh-2274 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-26 12:02 UTC · original
kirigayakazima:fix/linux-boot-scripts-safety → main · +175 −18 · 3 files · 1 commits · open

Claimed in the coordination issue as: LINUX-BOOT-SCRIPTS-EXACT-DEDUP-EMPTY-STATS-AND-ARG-GUARDS (#1608)

What and why

scripts/linux-boot/boot-digest.sh and scripts/linux-boot/run-boot.sh previously:

  • Hardcoded /opt/leonida instead of defaulting via LEONIDA_BOOT_ROOT, lacked directory creation before digest/ledger writes in boot-digest.sh, and ran flock without checking availability.
  • Used grep -q -P "^[^\t]*\t$AGENT\t$N\t" for ledger deduplication, allowing regex metacharacters in agent names (e.g. a.b matching axb).
  • Checked [ -f "$CAP/index.txt" ] (emitting broken counts for 0-byte index.txt) and ignored sample row counts in awk over resources.tsv (printing empty MB stats and 0 peak MB on header-only files), while leaving sed stderr unguarded when boot-<n>.meta was missing.
  • Accepted invalid AGENT, N, SECS (<= 0 or non-numeric), and malformed KEY=VALUE environment overrides without upfront validation.

This adds LEONIDA_BOOT_ROOT support, upfront argument validation, literal awk ledger deduplication, [ -s "$CAP/index.txt" ] and awk sample-count checks, flock / .meta guards, LF preservation, and stdlib bash regression tests in tests/test_linux_boot_scripts.py.

Tested

  • python -I tests/test_linux_boot_scripts.py -v (3 passed)
  • Detached upstream/main baseline negative control: failed with tests/test_linux_boot_scripts.py before the fix
  • python -I tests/test_ci_registration.py, python -I tests/test_text_write_line_endings.py, python -I scripts/check_no_game_data.py, python -I -m compileall -q, and git diff --cached --check

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠kirigayakazima** on GitHub · 2026-11-26 12:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2274) `kirigayakazima:fix/linux-boot-scripts-safety` → `main` · +175 −18 · 3 files · 1 commits · open Claimed in the coordination issue as: LINUX-BOOT-SCRIPTS-EXACT-DEDUP-EMPTY-STATS-AND-ARG-GUARDS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `scripts/linux-boot/boot-digest.sh` and `scripts/linux-boot/run-boot.sh` previously: - Hardcoded `/opt/leonida` instead of defaulting via `LEONIDA_BOOT_ROOT`, lacked directory creation before digest/ledger writes in `boot-digest.sh`, and ran `flock` without checking availability. - Used `grep -q -P "^[^\t]*\t$AGENT\t$N\t"` for ledger deduplication, allowing regex metacharacters in agent names (e.g. `a.b` matching `axb`). - Checked `[ -f "$CAP/index.txt" ]` (emitting broken counts for 0-byte `index.txt`) and ignored sample row counts in `awk` over `resources.tsv` (printing empty MB stats and `0` peak MB on header-only files), while leaving `sed` stderr unguarded when `boot-<n>.meta` was missing. - Accepted invalid `AGENT`, `N`, `SECS` (`<= 0` or non-numeric), and malformed `KEY=VALUE` environment overrides without upfront validation. This adds `LEONIDA_BOOT_ROOT` support, upfront argument validation, literal `awk` ledger deduplication, `[ -s "$CAP/index.txt" ]` and `awk` sample-count checks, `flock` / `.meta` guards, LF preservation, and stdlib bash regression tests in `tests/test_linux_boot_scripts.py`. ### Tested - `python -I tests/test_linux_boot_scripts.py -v` (3 passed) - Detached `upstream/main` baseline negative control: failed with `tests/test_linux_boot_scripts.py` before the fix - `python -I tests/test_ci_registration.py`, `python -I tests/test_text_write_line_endings.py`, `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q`, and `git diff --cached --check` GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:04:18 +00:00
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 12:23 UTC · original

Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU, no Wine). Merges cleanly. With this PR, python -I tests/test_linux_boot_scripts.py: 3 tests OK. The PR's test file against main's scripts: 1 failure, so the new test fails on main and passes with the change. compileall clean.

AI-assisted: yes (Claude Code)

**@⁠real-rusher** on GitHub · 2026-11-26 12:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2274#issuecomment-7191938010) Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU, no Wine). Merges cleanly. With this PR, python -I tests/test_linux_boot_scripts.py: 3 tests OK. The PR's test file against main's scripts: 1 failure, so the new test fails on main and passes with the change. compileall clean. AI-assisted: yes (Claude Code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2274/head:github-bot/gh-2274'
git switch 'github-bot/gh-2274'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2274'
git switch 'github-bot/gh-2274'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2274'
git switch 'github-bot/gh-2274'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2274'
git switch 'main'
git merge --squash 'github-bot/gh-2274'
git switch 'main'
git merge --ff-only 'github-bot/gh-2274'
git switch 'main'
git merge 'github-bot/gh-2274'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.