Repository navigation
fix(typescript): committed-snapshot credit refuses configs by path, above root, symlinks (#7708) - #8573
Conversation
…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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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\|viteplus.config., e.g.something.vitest.config.helper.jswould 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
left a comment
There was a problem hiding this comment.
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
-
Spec names a test that does not exist (spec/traceability).
docs/specs/RIPR-SPEC-0258-typescript-committed-snapshot.md:245listsconfig_above_the_root_without_a_repository_boundary_is_not_readunder Test Mapping for example 7. That function is in no file in the diff or in the tree (grepfinds only the spec line). Example 7's "no repository marker above the root: strong" claim therefore has no end-to-end test, andcheck-traceabilityorcheck-spec-formatmay reject the dangling name. Add the test, or rename the spec entry to what exists. -
The "no marker" behavior is covered only at helper level (
committed_snapshot_tests.rs,directories_above_the_root_stop_at_the_repository_boundary). Thelimit=1assertion does discriminate the helper. If theNone => Vec::new()arm returnedabove,beyond.is_empty()would fail. But nothing drivesrunner_configsorpromote_committed_snapshotswith a config above the root and no marker, so a regression in the wiring would pass. Wiring meansrunner_configscallingdirectories_above_root, or the limit constant. Related: no test removes therunner_configsloop overdirectories_above_root, other than the positive.git/HEADcase, which does cover it. This is the missing test from finding 1. -
Fail-open when the boundary is unknown or out of reach (
committed_snapshot.rsdirectories_above_rootandABOVE_ROOT_LIMIT=16). When no.gitis 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/appthe walk looks at/work, not/repo. A monorepo/repo/jest.config.jswithsnapshotResolveris 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_mediumexplicitly asserts the symlinked root stays Strong without a monorepo config present. Suggested repair: canonicalizerootbefore the ancestor walk, or document and test this case. Consider medium rather than strong when a limit is hit without finding a marker. -
Committed-history runs do not compare above-root configs with
HEAD. Onlysnapshot_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). -
Symlink check relies on a trailing-slash quirk (
scan_config_directory). For the root directory,root.join(Path::new(""))producesroot/, sosymlink_metadatafollows 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. Thesymlink_metadata-then-read_dirgap is a minor TOCTOU. The individual file reads are covered byread_config_capped. -
passes_config_by_pathcoverage. It catches--config*,-cand--projects. Not caught:-cfoo.js(yargs attached short value);- Vitest
--root/-r/--dir/--workspace; - Jest
--rootDir; - a
"jest": {"projects": [...]}key insidepackage.json.
Only the
package.jsontext 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_inputtakespath.file_name()first, so only the filename is matched. A directory namedjest/orvite/cannot trigger it. The real looseness is within the filename:name.contains(".config.")pluscontains("jest"|"vitest"|"vite")also matchesinvited.config.jsonorservice.config.ts(since "vite" is a substring of "invited"). Over-matching only widens refusal andHEAD-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_cappedinscan_config_directory. A directory named like a config, or an unreadable file, returnsNone(medium). - Test discrimination, other tests:
config_passed_by_path_or_custom_named_stays_mediumhas paired strong controls (no flag, and an inert custom-named config), so removingpasses_config_by_pathor 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_mediumswaps 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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Repair at 8f20907 (merged main in first):
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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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 iswalk_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 tokenjestand one token-cconfig/jest.js, the latter splits on=to-cconfig(no=), thenstarts_with("-c") && !starts_with("--")matches, so it refuses. Verified byflags_and_keys_that_move_the_runner_config_stay_medium. Token fragility remains:--configdir(single token) starts_with--configand matches → refuses a non-runner script flag. Token-attach over-match is documented intent ("node -rpreload only refuses") but--configdirfalls in that bucket. - Confirm above-root walk is deterministic for
.gitboundary, 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.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
There was a problem hiding this comment.
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.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
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_readbut 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 testandprecommitwere skipped (sandbox OOM); hosted exact-head CI is the only proof and is not yet inreceipts/.
#7708) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018waZYroArgiNqfVvpNJa8b
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. Apackage.jsonscriptjest --config config/jest.js(or-c), ajest.unit.config.jswith asnapshotResolver, 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).package.jsonscript passing--config,--config=,-cor--projectsrefuses.*jest*.config.*,*vitest*.config.*,*vite*.config.*) are read with the same override checks.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)
.snapin a--worktreerun; committed-history runs already refuse) and item 5 (memoizing the per-directory config walk).Proof
Head
ba47c27ac(repair of review on8f20907f1; main merged in).21272ec4a/earlier:cargo test ... committed_snapshotpassed,cargo xtask precommitexit 0,verdict-corpus check --language typescript5/169 false, 0 contradictions, spec examples 112/121 (floor 112).ba47c27ac:cargo check -p ripr --lib --testsandcargo fmt --checkclean locally. Unit tests andprecommitwere 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.__snapshots__dir is medium; Vitest custom-named config with no overrides stays strong.Generated by Claude Code