Skip to content

fix(loop): selftest no longer fails on day-0 install - #11

Open
jodunk wants to merge 1 commit into
NikitaDmitrieff:mainfrom
jodunk:selftest-day0
Open

fix(loop): selftest no longer fails on day-0 install#11
jodunk wants to merge 1 commit into
NikitaDmitrieff:mainfrom
jodunk:selftest-day0

Conversation

@jodunk

@jodunk jodunk commented Jul 22, 2026

Copy link
Copy Markdown

What

Two small defects in auto-loop.sh --selftest, both surfaced by dogfooding — booting a fresh npx create-auto-co scaffold and running the environment check (the first real boot past bash -n + --help).

1. --selftest fails on a brand-new install

The State directory check returns FAIL when state/ is absent — which it always is on a fresh scaffold, because it's auto-created on the first real cycle. A new user running --selftest to validate their install is told:

Fix the failures above before running the loop.

…for something that needs no fixing. The detail string itself already says "will be created on first run" — so ok=0 was a mislabel. Fixed: relabeled PASS.

2. Stray caught in selftest output

The signal-handling test does trap "echo caught" SIGTERM inside a subshell, and that echo leaks the literal word caught into the selftest output. Replaced with a no-op trap ":" — identical proof (a trapped subshell survives SIGTERM and reaches exit 0), silent output.

Diff

2 lines, --selftest block only. No overlap with #10 (consensus/reason/JSONL region).

-        check "State directory" 0 "$STATE_DIR/ missing -- will be created on first run"
+        check "State directory" 1 "$STATE_DIR/ absent -- will be created on first run"
...
-    if (bash -c 'trap "echo caught" SIGTERM; kill -TERM $$ 2>/dev/null; exit 0' 2>/dev/null); then
+    if (bash -c 'trap ":" SIGTERM; kill -TERM $$ 2>/dev/null; exit 0' 2>/dev/null); then

Verification

  • Fresh npx create-auto-co scaffold + fixed script: --selftest14/14 pass (was 13/14 + a stray caught line).
  • bash -n auto-loop.sh clean.
  • --dry-run still exits 0 (prompt builds clean).
  • tests/run-all.sh3/3 ALL GREEN (no regression in the existing test gate).

Related: #10 (broader reliability hardening — complementary, different code regions).

Summary by CodeRabbit

  • Bug Fixes
    • Improved self-test messaging when the state directory has not yet been created.
    • Updated signal-handling verification to reliably confirm processes survive termination signals.

Two defects in `--selftest`, surfaced by booting a fresh
`npx create-auto-co` scaffold and running the env check:

1. State-directory check FAILED when `state/` was absent on a brand-new
   install, telling the user "Fix the failures before running the loop"
   for a directory that is auto-created on first cycle. Relabeled PASS
   -- the detail string itself conceded "will be created on first run",
   so ok=0 was a mislabel. Every fresh install hit this.

2. Signal-handling trap test leaked the literal word `caught` into
   selftest stdout. Replaced `trap "echo caught"` with a no-op
   `trap ":"` -- same proof (trapped subshell survives SIGTERM and
   reaches exit 0), silent output.

Verified: fresh-scaffold `--selftest` now 14/14 pass (was 13/14 + stray
`caught`); `--dry-run` exits 0; `tests/run-all.sh` 3/3 ALL GREEN.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8c09e5fe-6562-45cd-9d69-387f666dc8dd

📥 Commits

Reviewing files that changed from the base of the PR and between 5e6bb8a and 1d1705f.

📒 Files selected for processing (1)
  • auto-loop.sh

📝 Walkthrough

Walkthrough

The self-test now clarifies that a missing state directory will be created on first run and uses a no-op SIGTERM trap while verifying signal handling.

Changes

Self-test updates

Layer / File(s) Summary
Self-test output and signal checks
auto-loop.sh
The state-directory message now describes the directory as absent and pending creation, while the SIGTERM validation uses a no-op trap and still checks process survival.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: making the self-test pass on a fresh day-0 install.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

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