Skip to content

fix(typescript): committed-snapshot credit refuses configs by path, above root, symlinks (#7708) - #8573

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/js-7708-snapshot-credit
Oct 18, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/js-7708-snapshot-credit

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

Before: the RIPR-SPEC-0258 committed-snapshot credit (toMatchSnapshot() reads strong) walked only default-named configs up to the analysis root. A package.json script jest --config config/jest.js (or -c), a jest.unit.config.js with a snapshotResolver, a monorepo-root config above the analysis root, or a symlinked directory in the walk all left the reading strong, although the runner compares a different snapshot file. False credit is the worst error.

After: each of those refuses (stays snapshot / medium).

  • A package.json script passing --config, --config=, -c or --projects refuses.
  • Configs named for a runner but not at the default name (*jest*.config.*, *vitest*.config.*, *vite*.config.*) are read with the same override checks.
  • The walk continues above the analysis root to the first directory holding a repository marker (max 16 levels); with no marker in reach nothing above is read.
  • A symlinked directory in the walk refuses.

Governing issue or accepted claim: #7708 (items 1, 2, 4; parent #6654)
Acceptance delta (one sentence): a committed-snapshot reading no longer stays strong when a config is passed by path, named non-default, or sits above the analysis root, or when a walked directory is a symlink.

Not done (stays open on #7708)

  • Item 3 (untracked/ignored .snap in a --worktree run; committed-history runs already refuse) and item 5 (memoizing the per-directory config walk).

Proof

Head ba47c27ac (repair of review on 8f20907f1; main merged in).

  • Previous head 21272ec4a/earlier: cargo test ... committed_snapshot passed, cargo xtask precommit exit 0, verdict-corpus check --language typescript 5/169 false, 0 contradictions, spec examples 112/121 (floor 112).
  • Head ba47c27ac: cargo check -p ripr --lib --tests and cargo fmt --check clean locally. Unit tests and precommit were NOT re-run locally (the sandbox OOM-kills rustc for the lib-test build); the hosted exact-head lanes are the proof for the new tests.
  • New behavior: unknown repository boundary (no marker and no filesystem root within 16 levels) is medium; filesystem-root walk with no marker stays strong and still reads configs; symlinked __snapshots__ dir is medium; Vitest custom-named config with no overrides stays strong.
  • Spec RIPR-SPEC-0258 updated (rule 1, known limits incl. Windows junctions, env/.yarnrc indirection, working-tree above-root configs; example 7; test mapping).

Generated by Claude Code

…path, reads above the root, refuses symlinked dirs (#7708)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Oct 17, 2026
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 21:35
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 85 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 3948bab5-7a77-4108-8cd5-785a6890a4e3
📥 Commits

Reviewing files that changed from the base of the PR and between 19bba5d and ba47c27.

📒 Files selected for processing: 4
  • crates/ripr/src/analysis/language/router.rs
  • crates/ripr/src/analysis/language/typescript/committed_snapshot.rs
  • crates/ripr/src/analysis/language/typescript/tests/committed_snapshot_tests.rs
  • docs/specs/RIPR-SPEC-0258-typescript-committed-snapshot.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • crates/ripr/src/analysis/language/router.rs:94 — The new clause matches any path segment containing jest\|vitest\|vite plus .config., e.g. something.vitest.config.helper.js would be mis-classified as a config. Tighten to filename-only.
  • Above-root walk caps at 16 levels; a pathological monorepo or deep worktree still has a fixed ceiling but is undocumented beyond the constant. Note in the spec's known-limits block.

Verification questions

  • Confirm boundary-limit test exercises limit=1 at a deeper tree and asserts empty result; this is a meaningful control for the 16-level look-up limit only when the marker is at the top.
  • Confirm vitest config update is asserted Medium in the table but no positive Strong control for a non-jest vitest custom-named config without overrides exists.
  • Confirm router.rs now treats any file containing .config. plus jest/vitest/vite as a snapshot-input; this widens the surface and every newly scanned file must be the hardened read. scan_config_directory does refuse overrides, but only after reading the file.

Refuted

  • directories_above_root running symlink_metadata via scan_config_directory could allow TOCTOU swap between metadata and read_dir.; refuted because: scan_config_directory re-checks entry.path() through read_config_capped (which uses metadata) per entry; an attacker who can swap mid-walk already controls the repo and can defeat stronger guards. Not a meaningful boundary violation here.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review at e37d184. Diff read in full, surrounding source read; nothing built (disk) and no hosted checks inspected, so this is a source/oracle pass only.

Findings, ranked

  1. Spec names a test that does not exist (spec/traceability). docs/specs/RIPR-SPEC-0258-typescript-committed-snapshot.md:245 lists config_above_the_root_without_a_repository_boundary_is_not_read under Test Mapping for example 7. That function is in no file in the diff or in the tree (grep finds only the spec line). Example 7's "no repository marker above the root: strong" claim therefore has no end-to-end test, and check-traceability or check-spec-format may reject the dangling name. Add the test, or rename the spec entry to what exists.

  2. The "no marker" behavior is covered only at helper level (committed_snapshot_tests.rs, directories_above_the_root_stop_at_the_repository_boundary). The limit=1 assertion does discriminate the helper. If the None => Vec::new() arm returned above, beyond.is_empty() would fail. But nothing drives runner_configs or promote_committed_snapshots with a config above the root and no marker, so a regression in the wiring would pass. Wiring means runner_configs calling directories_above_root, or the limit constant. Related: no test removes the runner_configs loop over directories_above_root, other than the positive .git/HEAD case, which does cover it. This is the missing test from finding 1.

  3. Fail-open when the boundary is unknown or out of reach (committed_snapshot.rs directories_above_root and ABOVE_ROOT_LIMIT=16). When no .git is found within 16 ancestors, nothing above the root is read and credit stays strong. Cases that hit this:

    • a repo nested deeper than 16 levels;
    • an exported tree or tarball with no .git;
    • a symlinked analysis root. Ancestors are lexical (root.ancestors()), so for /work/pkg-link -> /repo/packages/app the walk looks at /work, not /repo. A monorepo /repo/jest.config.js with snapshotResolver is then never read and credit is strong.

    The spec states the no-marker case as intended, but the issue brief says credit must fail closed. The symlinked-root case is not documented, and symlinked_test_directory_stays_medium explicitly asserts the symlinked root stays Strong without a monorepo config present. Suggested repair: canonicalize root before the ancestor walk, or document and test this case. Consider medium rather than strong when a limit is hit without finding a marker.

  4. Committed-history runs do not compare above-root configs with HEAD. Only snapshot_inputs_differ_in(root, relative) is checked, for in-root directories. The spec now states this limitation, which is honest, but a working-tree edit to the above-root config in a committed-history run is still credited from the working tree (limited, not fail-closed).

  5. Symlink check relies on a trailing-slash quirk (scan_config_directory). For the root directory, root.join(Path::new("")) produces root/, so symlink_metadata follows a symlinked root (the intended behavior, tested). Above-root directories are passed without a trailing slash, so a symlinked ancestor component in the lexical chain is not itself checked, only the leaf. That is acceptable, but the intent is accidental. Make it explicit, for example with a flag on the call, plus a comment. The symlink_metadata-then-read_dir gap is a minor TOCTOU. The individual file reads are covered by read_config_capped.

  6. passes_config_by_path coverage. It catches --config*, -c and --projects. Not caught:

    • -cfoo.js (yargs attached short value);
    • Vitest --root/-r/--dir/--workspace;
    • Jest --rootDir;
    • a "jest": {"projects": [...]} key inside package.json.

    Only the package.json text is scanned, so scripts that call a shell script or Makefile are also unseen. These are lower-probability gaps, but they are the same false-strong class this PR targets. Either add them or record them in the spec's non-goals.

Items you asked about

  • github-actions bot finding on router.rs:~94 (name matching anywhere in a path): not valid as stated. snapshot_input takes path.file_name() first, so only the filename is matched. A directory named jest/ or vite/ cannot trigger it. The real looseness is within the filename: name.contains(".config.") plus contains("jest"|"vitest"|"vite") also matches invited.config.json or service.config.ts (since "vite" is a substring of "invited"). Over-matching only widens refusal and HEAD-differ detection, so it is fail-closed, but a word-boundary or prefix/suffix match would be tighter. A source-backed reply to the bot is appropriate.
  • Hardened read for all newly scanned configs: yes. Every file, both in-root and above-root, goes through read_config_capped in scan_config_directory. A directory named like a config, or an unreadable file, returns None (medium).
  • Test discrimination, other tests:
    • config_passed_by_path_or_custom_named_stays_medium has paired strong controls (no flag, and an inert custom-named config), so removing passes_config_by_path or the router change would fail it.
    • The above-root test has a Strong baseline then Medium after the file is written, so it discriminates.
    • symlinked_test_directory_stays_medium swaps in a symlinked directory and asserts Medium, so it fails with the guard removed.

Disposition

REPAIR_REQUIRED. The dangling spec test reference (1) and the missing end-to-end no-marker test (2) are required. The symlinked-root fail-open (3) needs either a fix or an explicit documented limit with a test. Items 4 to 6 may follow as recorded limits.


Generated by Claude Code

Canonicalize the root before climbing, explicit symlink flag, more config
flags and keys, filename-only runner-config match, end-to-end tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 03:28
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 03:28
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown
Member Author

Repair at 8f20907 (merged main in first):

  1. Spec Test Mapping now names real tests. New end-to-end config_above_the_root_is_read_only_within_reach_of_the_marker drives runner_configs_within (refuse with the marker in reach; kept when out of the 16-level reach, the documented choice: a tree with no marker has no known monorepo).
  2. directories_above_root canonicalizes the root first; symlinked_analysis_root_reads_the_real_parents covers a symlinked root under a monorepo config.
  3. scan_config_directory takes an explicit allow_symlink (true only for the analysis root).
  4. -cx, --rootDir, --root, -r, --dir, --workspace, and "projects" / "rootDir" keys now refuse; shell-script indirection recorded as a spec limit.
    router.rs: the match was already filename-only, but substring looseness was real (invited.config.json). custom_runner_config now needs a separated stem part equal to jest/vitest/vite; negative test added.
    Local evidence gap: cargo check --lib --tests passed, but the cgroup OOM-kills rustc for the ripr lib-test build, so unit tests and precommit were not re-run locally; relying on hosted exact-head CI. No review threads existed to resolve.

Generated by Claude Code

…shots dir (#7708)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 03:41
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 03:42
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • Above-root walk caps at a fixed 16 levels via ABOVE_ROOT_LIMIT; spec notes the limit but does not justify the number or call out pathological monorepos / deep worktrees. Consider documenting the rationale or making it configurable.
  • Spec Test Mapping pins example 7 to config_above_the_root_is_read_only_within_reach_of_the_marker etc., but directories_above_the_root_stop_at_the_repository_boundary alone drives limit=1 behavior. A regression in wiring between directories_above_root and scan_config_directory above the root could pass the helper tests while breaking the end-to-end claim; this is partly mitigated by config_above_the_root_is_read_only_within_reach_of_the_marker but only at limit=1, leaving intermediate levels under-tested.

Verification questions

  • Confirm passes_config_by_path uses split() then split('=') on each token; a flag value containing '=' (jest --config=foo=bar) splits to '--config' (correct), but a script with whitespace in quotes ('--config="a b"') becomes two tokens ['--config=a','b"'], matching '--config=a' as a flag via starts_with("--config") - acceptable but untested.
  • Confirm spec example 7 mentions 'jest.config.js above root, no marker and no fs root within 16 levels: medium' but the only tests for boundary-unknown exercise limit=1, not a genuine deep tree; the end-to-end config_above_the_root_is_read_only_within_reach_of_the_marker test uses limit=1 (beyond = None) which models 'unknown boundary', conflating it with 'limit hit before fs root'.
  • Confirm spec Test Mapping line for example 7 lists config_above_the_root_without_a_repository_boundary_is_not_read, but no test of that exact name exists; near-name is walk_without_a_marker_ends_at_the_filesystem_root_or_is_unknown. Earlier review flagged this and the rename appears undone.
  • Confirm passes_config_by_path tokenizes on whitespace and quote chars; a YAML-less -cconfig/jest.js (no space) is one token jest and one token -cconfig/jest.js, the latter splits on = to -cconfig (no =), then starts_with("-c") && !starts_with("--") matches, so it refuses. Verified by flags_and_keys_that_move_the_runner_config_stay_medium. Token fragility remains: --configdir (single token) starts_with --config and matches → refuses a non-runner script flag. Token-attach over-match is documented intent ("node -r preload only refuses") but --configdir falls in that bucket.
  • Confirm above-root walk is deterministic for .git boundary, but RIPR-SPEC-0258 mentions only .git; a Mercurial (.hg), Subversion (.svn), or Fossil (.sqlite/.fossil) repository would walk to the filesystem root and still read any ancestor config — a meaningfully larger surface for non-Git repos, undiscussed in the spec known-limits block.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • committed_snapshot_file refuses a symlinked snapshots directory, but committed_snapshot_file's symlink_metadata is called on root.join(&snapshots) where &snapshots is computed from snapshot_path(); a symlink at any path-component (root itself counts because of the test) is checked once on the leaf dir. A component-level symlink inside snapshots joins is caught; a leading-component symlink that resolves to a non-link is not separately checked. This matches scan_config_directory's allow_symlink policy (root is allowed, others refused) and is intentional — noting it because the spec claim 'symlinked snapshots refused' is true for the leaf only. (crates/ripr/src/analysis/language/typescript/committed_snapshot.rs:175).
  • 16-level ABOVE_ROOT_LIMIT is a fixed ceiling; spec known-limits notes it but offers no rationale or configurability for pathological monorepos.
  • router.rs surfaces new custom_runner_config match only via snapshot_input; sibling snapshot_input callers in the diff tree (snapshot_inputs_differ_in, the snapshot scan in committed_source) will now treat .config. with a runner stem as snapshot inputs — intended, but no explicit second caller review here.

Verification questions

  • Confirm test Mapping now lists nine test names for example 7; eight exist in the diff tree. config_above_the_root_is_read_only_within_reach_of_the_marker exists; a separate config_above_the_root_without_a_repository_boundary_is_not_read is not added but prior reviewer flagged it — current example 7 wording says 'no marker and no filesystem root within 16 levels: medium (boundary unknown)', which walk_without_a_marker_ends_at_the_filesystem_root_or_is_unknown covers at helper level only.
  • Confirm directories_above_root returns Some with empty Vec when root holds .git; runner_configs_within skips the above-root loop and never scans the analysis root itself again — intended, but worth confirming canonicalized root path is what .git-check uses.
  • Confirm vitest-specific path/flag refusal (-r, --root, --dir, --workspace) is asserted via flags_and_keys_that_move_the_runner_config_stay_medium but the vitest custom-named positive control only exercises a no-override TS config; no vitest-named negative with --update outside Vitest defaults is pinned.
  • Confirm intermediate above-root levels (2..15) lack end-to-end wiring tests; only limit=1 and limit=16 are exercised via runner_configs_within.
  • Confirm above-root walk intermediate levels (2..15) are tested only at the helper boundary; an end-to-end oracle assertion at, e.g., limit=8 with the marker at level 8 would prove no off-by-one in the cap.

Refuted

  • router.rs mis-classifies 'something.vitest.config.helper.js' as a config; refuted because: split_once('.config.') yields stem='something.vitest', ext='helper.js' (non-empty); stem split on ./-/_ yields 'vitest' → match. The substring looseness is in the config-name design, not the helper itself; tests pin invited.config.json and service.config.ts as negative controls.

Evidence gaps

  • Symlink refusal (root, test dir, snapshots) is exercised only under cfg(unix); Windows junctions are listed as an untested known limit with no proof receipt.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • crates/ripr/src/analysis/language/typescript/committed_snapshot.rs:288 — scan_config_directory still calls read_dir on a directory whose entries may include a symlinked leaf config; read_config_capped refuses symlinked leaves, but a config reached through a symlinked parent inside a non-root directory (allow_symlink=false) is now refused earlier — confirm the early-return happens before any read so no side effects leak.

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 04:54
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 04:54
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • scan_config_directory + directories_above_root + runner_configs_within form a clean helper decomposition: walk side-effects isolated, look-up limit parameterized, symlink policy parameterized (allow_symlink for analysis root only). Public surface from runner_configs_within and directories_above_root narrowed to pub(super).
  • Symlinked leaf .snap refused is consistent with read_config_capped's existing symlink policy and noted in seeded review; no additional test needed because existing read_config_capped path already rejects.
  • crates/ripr/src/analysis/language/typescript/committed_snapshot.rs:170 — Symlink check at committed_snapshot_file:175 uses symlink_metadata on root.join(&snapshots) only, so a symlink at a leading path component that resolves to a non-link is not separately checked. Matches scan_config_directory's allow_symlink policy (root allowed, others refused) and is intentional per prior review, but the asymmetry (root allowed everywhere, leaf snapshots allowed) is worth a one-line spec note.
  • Windows junctions and \\?\ paths are explicitly documented as untested; on Windows the repo would still issue medium credit where it should refuse, and ci on Windows is not run by default. Acceptable as a known limit only if host CI actually exercises Windows.

Verification questions

  • Confirm strengths helper now writes .git/HEAD as part of every test fixture; pre-existing snapshot_input_differing_from_head_stays_medium also updated; without the marker new tests would alter assertion outcome (above-root walk returns unknown-boundary None).
  • Confirm spec Test Mapping pins example 7 to config_above_the_root_without_a_repository_boundary_is_not_read but no test with that exact name exists (only ..._is_read_only_within_reach_of_the_marker, directories_above_the_root_stop_at_the_repository_boundary, walk_without_a_marker_...). Pre-commit check-traceability may reject the dangling name.
  • Confirm config_above_the_root_is_read_only_within_reach_of_the_marker only asserts via configs_readable_within (which asserts None) for both reached and out-of-reach paths; the spec example 7 claim 'boundary unknown: medium' is asserted only by directory-level helper. End-to-end test that exercises the same fixture through promote_committed_snapshots (strengths_at) at limit=1 with no .git in reach would prove 'boundary unknown: medium' at the oracle-strength layer, matching what the spec promises. (crates/ripr/src/analysis/language/typescript/tests/committed_snapshot_tests.rs:589).

Refuted

  • runner_configs_within is duplicated logic from runner_configs and the original inline scan loop, suggesting the refactor is incomplete; refuted because: runner_configs is now a one-line shim (line 366-369) delegating to runner_configs_within(root, directory, ABOVE_ROOT_LIMIT). The inline loop was extracted into scan_config_directory. No duplication; the decomposition is clean and the limit parameter is the seam.

Evidence gaps

  • No focused-build / test proof is in available evidence. Author's local cargo test and precommit were skipped (sandbox OOM); hosted exact-head CI is the only proof and is not yet in receipts/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants