Skip to content

Fail loudly when a probe is not staged - #109

Merged
kwsantiago merged 1 commit into
mainfrom
backport-probe-assertion
Aug 2, 2026
Merged

Fail loudly when a probe is not staged#109
kwsantiago merged 1 commit into
mainfrom
backport-probe-assertion

Conversation

@kwsantiago

@kwsantiago kwsantiago commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Backports the probe-staged assertion from privkeyio/keep-android#473 and privkeyio/keep#936, so the four copies of this harness do not diverge.

The gap

run_probe discards the errors from git read-tree and git add. The existing staged -lt 10 check does not cover a failed git add: HEAD's whole tree is still in the index, so the count sails past 10 while the probe itself is missing, and the guard is then judged on a file it never received.

A reject case surfaces that as a spurious BYPASS, which sends someone hunting a guard defect that does not exist. An accept case surfaces it as a silent pass.

Now asserted directly:

if ! GIT_INDEX_FILE="$TMPD/index" git ls-files --error-unmatch "$name" >/dev/null 2>&1; then
    echo "  HARNESS BROKEN: $name was not staged; the guard would never see it"

Test plan

  • Self-test passes unchanged on the current guard
  • Sabotage control: replacing the git add with a no-op makes every case report HARNESS BROKEN, with zero BYPASS lines. Before this change the same sabotage produced BYPASS, the misleading result
  • Restored afterwards and passing
  • CI

Worth recording how this landed: the first attempt at this backport spliced the block into the middle of an echo string, because the insertion anchored on fi and matched the fi inside the word file(s). The corrupted file still parsed under bash -n and the self-test still reported OK, so "it passes" was true and meaningless. The sabotage control is what caught it. Re-anchored on local rc=0 out, which appears once.

Summary by CodeRabbit

  • Bug Fixes
    • Improved test validation to detect when probe files are not successfully staged.
    • Tests now clearly report setup failures, track them correctly, and clean up before stopping.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37a25e2c-832a-4404-ac42-9d0a4e1a64be

📥 Commits

Reviewing files that changed from the base of the PR and between 4acf17d and f5d3393.

📒 Files selected for processing (1)
  • scripts/test-rng-hygiene.sh

Walkthrough

The RNG hygiene test harness now confirms that each probe exists in the temporary Git index before invoking the hygiene guard. Missing probes produce a harness failure, trigger cleanup, and skip the guard check.

Changes

RNG hygiene test harness

Layer / File(s) Summary
Validate staged probes
scripts/test-rng-hygiene.sh
The harness uses git ls-files --error-unmatch to verify each staged probe. It reports failures, cleans up, and skips invalid probes.

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

Poem

A rabbit checks each probe in place,
Then guards the index with care and grace.
If staging fails, cleanup starts,
No false results, no broken parts.
Hop, hop—the harness plays its part!

🚥 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 summarizes the main change: report an error when a probe is not staged before hygiene validation.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backport-probe-assertion

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.

@kwsantiago
kwsantiago merged commit c80d460 into main Aug 2, 2026
7 checks passed
@kwsantiago
kwsantiago deleted the backport-probe-assertion branch August 2, 2026 19:16
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