Refactor flake-status to process repos in parallel #72

Merged
vnprc merged 2 commits from agent/parallel-flake-status into master 2026-06-24 22:51:08 +01:00
Contributor

Closes #61

Refactor flake-status to process repos in parallel instead of serially.

Changes

  • Add _parallel_for bounded concurrency loop using wait -n, controlled by FLAKE_STATUS_JOBS env var (default 4)
  • Split per-repo data collection into _collect_named and _collect_all functions that write results to indexed temp files
  • Replace in-process _LS_REMOTE_CACHE associative array with _resolve_all_upstreams which deduplicates URLs via sort -u and resolves each unique URL in parallel
  • Render from temp files in workspace index order so output stays deterministic
  • No new dependencies beyond Bash, Git, and jq

Validation

  • All 21 existing tests/flake-status.sh tests pass
  • Output order is deterministic (temp files indexed by repo position, read back in workspace order)
  • flake-status, flake-status <input>, and both --upstream modes produce identical output to the serial version
  • FLAKE_STATUS_JOBS overrides the default parallelism bound
  • Duplicate upstream URLs are resolved exactly once via deduplication before the parallel resolve phase
Closes #61 Refactor `flake-status` to process repos in parallel instead of serially. ## Changes - Add `_parallel_for` bounded concurrency loop using `wait -n`, controlled by `FLAKE_STATUS_JOBS` env var (default 4) - Split per-repo data collection into `_collect_named` and `_collect_all` functions that write results to indexed temp files - Replace in-process `_LS_REMOTE_CACHE` associative array with `_resolve_all_upstreams` which deduplicates URLs via `sort -u` and resolves each unique URL in parallel - Render from temp files in workspace index order so output stays deterministic - No new dependencies beyond Bash, Git, and jq ## Validation - All 21 existing `tests/flake-status.sh` tests pass - Output order is deterministic (temp files indexed by repo position, read back in workspace order) - `flake-status`, `flake-status <input>`, and both `--upstream` modes produce identical output to the serial version - `FLAKE_STATUS_JOBS` overrides the default parallelism bound - Duplicate upstream URLs are resolved exactly once via deduplication before the parallel resolve phase
vnprc force-pushed agent/parallel-flake-status from 6e7a681222 to 55c863602b 2026-06-24 22:17:49 +01:00 Compare
Author
Contributor

Review findings (subagent)

Numbered by severity. Fixes incoming for the legitimate ones.

Fix (real bugs)

  1. Regex injection in grep (line 444)grep -m1 "^${name}"$'\t' injects $name raw into a regex. If an input name contained . or * it could match wrong entries. Should use awk with string equality instead.

  2. No validation of FLAKE_STATUS_JOBS — Non-integer values cause an arithmetic error and confusing exit. Add a guard.

  3. Fragile glob when urls/ is empty (line 186)cat "$_PTMP"/urls/* with no matching files relies on error suppression to work. Use explicit nullglob guard for clarity.

Not fixing (reviewer errors)

  1. Trap single-quote evaluation — Reviewer claims single quotes cause $_PTMP to be evaluated at registration time. This is backwards: single quotes defer evaluation to trap execution time. The code is correct as written.

  2. wait -n portability — Reviewer says bash 5.1+; wait -n was actually added in bash 4.3 (2014). NixOS ships bash 5.x. Not a concern for this codebase.

  3. wait (no args) exit status — Reviewer worries this triggers set -e. Per the bash manual, wait without arguments returns 0. Not an issue.

## Review findings (subagent) Numbered by severity. Fixes incoming for the legitimate ones. ### Fix (real bugs) 1. **Regex injection in grep (line 444)** — `grep -m1 "^${name}"$'\t'` injects `$name` raw into a regex. If an input name contained `.` or `*` it could match wrong entries. Should use `awk` with string equality instead. 2. **No validation of `FLAKE_STATUS_JOBS`** — Non-integer values cause an arithmetic error and confusing exit. Add a guard. 3. **Fragile glob when `urls/` is empty (line 186)** — `cat "$_PTMP"/urls/*` with no matching files relies on error suppression to work. Use explicit nullglob guard for clarity. ### Not fixing (reviewer errors) 4. **Trap single-quote evaluation** — Reviewer claims single quotes cause `$_PTMP` to be evaluated at *registration* time. This is backwards: single quotes *defer* evaluation to trap execution time. The code is correct as written. 5. **`wait -n` portability** — Reviewer says bash 5.1+; `wait -n` was actually added in bash 4.3 (2014). NixOS ships bash 5.x. Not a concern for this codebase. 6. **`wait` (no args) exit status** — Reviewer worries this triggers `set -e`. Per the bash manual, `wait` without arguments returns 0. Not an issue.
vnprc approved these changes 2026-06-24 22:51:02 +01:00
vnprc merged commit 6be045d8b1 into master 2026-06-24 22:51:08 +01:00
vnprc deleted branch agent/parallel-flake-status 2026-06-24 22:51:08 +01:00
Sign in to join this conversation.
No reviewers
No labels
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
allod/tools!72
No description provided.