Skip to content

Lint: flag path-dependent negative greps in test scripts - #2327

Closed
remigiusz-antczak wants to merge 2 commits into
mainfrom
lint/path-hermetic-4
Closed

remigiusz-antczak wants to merge 2 commits into
mainfrom
lint/path-hermetic-4

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Adds scripts/path_hermetic_lint.py, wired via scripts/ci-tests.d/path-hermetic-lint.sh. It flags a ! grep in scripts/test-*.sh for a path-segment word (worktrees, home, tmp, ...) over a log that holds absolute paths, unless a sed using $ROOT/$PWD writes exactly the grep's input file on that line or the line before. Such a test passes in CI but fails in a lane worktree, because the checkout path contains the word.

Stacked on #2326, which fixes the one real offender. Merge #2326 first.

  • Two reviewed false positives are frozen in scripts/path-hermetic-baseline.tsv, keyed by path plus line text. A stale row fails the lint, so the baseline can only shrink.
  • Two independent review rounds; all findings fixed: per-segment checks, no fail-open on parse errors, flag-glue forms, and an exact-target exemption.

Tests: 25/25 (6 lint unit + 19 scan-summary); repo lint rc 0.

🤖 Generated with Claude Code

remigiusz-antczak and others added 2 commits November 12, 2026 21:33
Root cause: the "default excludes" assertion in test-review-checks-scan-summary.sh grepped the raw scanner argv for "worktrees", which the absolute --config path contains whenever the checkout is .claude/worktrees/<lane>. Not the host semgrep cache. It failed in review-checks-scan-summary, -hermetic and -registry-env, and passed in CI (plain checkout path). Fix strips the checkout path before the grep, assertion otherwise unchanged. The hermetic suite now also runs the test from a worktrees-style path (fails pre-fix).

Tests: 3/3 suites (19 + 19 + 2 checks)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A test that runs `! grep` for a path-segment word (worktrees, home, tmp, ...)
over a log holding absolute paths passes in CI but fails in a lane worktree,
because the checkout path contains the word. path_hermetic_lint.py flags that
in scripts/test-*.sh.

Each line is split on ; && || | outside quotes. In every segment starting with
`! grep`, any listed word appearing as a whole word in the literal (non-$var)
text is a hit, so a second grep on a line, unbalanced quotes, -e/-eX/--regexp=,
and -m N/-A N all flag. A hit is exempt only when the grep's input file (its
last arg) is written on that line or the previous one by a sed/replace that
uses $ROOT/$PWD. The baseline is keyed on `path<TAB>stripped line text` and
messages print path:line, so a new offender in a baselined file fails. Two
reviewed offenders are baselined. Regression test covers each reviewer case.

Tests: 25/25 (6 path-hermetic lint unit tests + 19 scan-summary checks); path_hermetic_lint over repo clean, no stale rows
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@remigiusz-antczak

Copy link
Copy Markdown
Collaborator Author

Superseded by a single-commit recut on current main.

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