Repository navigation
fix(index): keep indexed paths and served source inside the project root - #363
Merged
Merged
Conversation
…the scan The scan must yield only project paths it can store exactly as named. These tests expect it to skip file and directory names holding a backslash (Linux and macOS) or invalid UTF-8 (Linux), membership to reject such names in both spellings, single-file extraction to refuse a path that leads outside the root, and the scan not to follow links into /proc or /sys. A link to a device stays skipped. They fail on the current tree, which scans such names under translated paths and follows those links.
…store The watcher, the git fast path and incremental sync must accept only the project paths the scan stores. These tests expect normalize_relative to refuse parent components anywhere and, on Linux and macOS, names holding a backslash; the scan and the watcher to agree on such names; an incremental sync handed their events to store no row; and a committed name of that kind to be pending on neither the fast path nor the full inventory. They fail on the current tree, which translates the backslash and keeps the paths it produces.
The scene and script uid maps must point only at project paths the index can store. This test expects both walks to skip names holding a backslash (Linux and macOS) instead of mapping a uid to a path that leaves the root, names it absolutely or aliases another file. It fails on the current tree, which translates the backslash in the walked names.
The dangling-reference audit must not probe a path outside the project root. This test expects a reference that leaves the root, or names a path absolutely, to be reported as dangling without an existence check, also for the backslash spellings on Linux and macOS; it first checks that every such reference is in the index. It fails on the current tree, which probes each target and drops the ones that exist outside the root.
A stored row may name a file outside the project root: a parent component, an absolute path, or a link inside the root that leads out of it. These tests plant such rows through the Store and expect the file view (both modes), the symbol view (with code, a container, an ambiguous name), a drifted file, explore and context, including a YAML key's code block, to serve none of that file's text or stored signatures. A search naming such a file must still be answered while auto-sync recovers, and a file inside the root is served as before. Over the protocol, the result keeps its shape and is no error. They fail on the current tree, which reads and serves those files.
The CLI must index only the project paths it can store exactly as named. These tests expect init to skip names holding a backslash (Linux and macOS) or invalid UTF-8 (Linux), to read nothing through them, and to succeed where such a name aliases no file. Status must report none of them as pending, before or after sync, and sync must equal a fresh init of the same tree when such names arrive or change. Stdout and --json output must stay those of the same tree without such names. They fail on the current tree, which indexes such names under translated paths, fails init on a name it cannot read, and keeps reporting them as pending.
Add the project_path module: a lexical check that a relative path stays under the project root, and the stored form of names and paths the index can hold exactly on every host. Source reads now clamp their limit to MAX_FILE_SIZE_CEILING (16 MiB), and a config whose indexing.max_file_size exceeds it is clamped when parsed, with a warning. read_source_file and is_source_file refuse a file that is on a kernel pseudo filesystem once opened, and read_stored_source reads a stored row only when its path is in stored form.
The scan now checks each directory entry's name before anything else. A name holding a backslash or invalid Unicode is skipped whole, without following, descending into, or counting it, and its root-relative path is listed in ScanProjectResult::unstorable for reporting. Paths are built with the core stored-path rules instead of translating separators, membership rejects the same names, and a file link whose target has such a name aliases no path. Extracting a single file accepts only a stored project path and names the refused path in its error without touching the filesystem. Links into /proc, /sys and /dev are no longer followed, unless the project itself lives there.
normalize_relative now returns the path only in the exact form the scan stores, so events, watch registration, new-directory walks and every sync candidate refuse a parent component, a root and, on Linux and macOS, a name holding a backslash. The git fast path skips such a name before its first probe. Every lane and sync read of a path taken from the index goes through read_stored_source, and the direct reads of stored rows check the stored form first, so a row outside the root is never read. An incremental sync treats a file it cannot read as a regular file, including one on a kernel pseudo filesystem, like a path that is not a regular file, which keeps it converging with a fresh index.
Resolution read stored rows and candidates by joining them to the project root, so a row that leaves the root (as a swapped-in index can hold) was read from outside it. The store and snapshot contexts, the framework extraction reader, the Dart pubspec, Go module, C# project file and synthesis readers now prove a path lexically inside the root first, with the rule the existence fallback already uses (#1631); a path that fails reads as unreadable. The Godot scene and script uid walks no longer turn a backslash in a name into a separator: a uid maps only to a path the index can store. The C# project file, Cargo member, JS workspace member and ohpm walks skip such names the same way, as the scan does.
Every view reads source through one probe. Before it reads, the stored path is checked lexically against the project root and then by its real path against the root canonicalized when the engine opens, component by component. A file outside the root is not read: the file view and the symbol view say why and give no source, symbol map, outline, signature, docstring or pointer to read it; explore and context leave it out, a config key's block included, and context names it in its own notice. Such a file is not counted as changed when auto-sync is unhealthy, so a graph answer naming it is still given. The wording lives in one module.
find_dangling_references now checks the translated, res://-stripped target with check_within_root before probing the disk; a target that leaves the root or carries a `..` segment is reported as dangling without a probe. default_source_reader joins through join_within_root before it canonicalizes, so no path outside the root is probed.
init, index and sync print one stderr line naming up to five skipped entries, Debug-escaped, so a control character in a name never reaches the terminal raw. The text comes from codegraph_extract::unstorable_notice; SyncOutcome carries the skipped entries from an incremental sync or a migration, and each caller picks the level: the CLI sync prints the warning, the daemon and catch-up syncs log it with tracing::warn!, and the watcher and status log it at debug level. stdout and every --json output are unchanged. The platform-only helpers of the outside_root_serving test are gated to the platforms whose tests use them.
…built An index built by extraction version 23 or earlier may hold rows whose path is not the stored form of a project-relative path, nodes of files over the new max_file_size ceiling, and content read through links into pseudo filesystems. Incremental sync keeps such rows, so every older index now reads as outdated and is rebuilt from source. upgrade_v0_56 holds the database the released v0.56.1 binary wrote for the mini corpus; upgrade_from_v056 upgrades it through CLI sync, the catch-up sync and a cold MCP session, and proves the rebuild drops planted out-of-form file and node rows. The corpora do not change.
…eader shares The pseudo filesystem check now runs in check_opened_regular, after its regular-file check, instead of in read_source_file and is_source_file alone. Every reader that opens a handle passes through it: the link-following open_regular_file family, read_stored_source and the no-follow state-file reader. A configuration or state file that resolves into procfs or sysfs is refused once opened, before a byte is read, as a source file already was. /proc/self/pagemap was the bounded-read sample: it is now refused with InvalidInput and nothing read. A regular file one byte over the limit still fails as FileTooLarge.
…max_file_size The scene and .gd.uid sidecar walks behind the uid maps read each file as a regular file without a limit. They now read it under the project's indexing.max_file_size, clamped to the 16 MiB ceiling: the limit the same file is extracted under as a source file. A larger scene or sidecar stays out of the uid maps, so a uid:// reference to it resolves as an unknown uid. The limit reaches the walks through FrameworkExtractionContext, which init and sync now build with the configured value, and through a max_file_size method on ResolutionContext for the autoload bindings. This moves the graph and rides extraction version 24.
Merged
This was referenced Dec 1, 2026
sunerpy
added a commit
that referenced
this pull request
Dec 1, 2026
The audit was written before the v0.56.2 patches merged and named them by their plan labels. They merged as #360 (97fa800, project inputs read only from regular files, and the single non-blocking source open) and #363 (e3417d7, upstream #527's lexical and real-path checks, extraction version 23 to 24). Name them by number in the owner decisions table and in rows 201, 207 and 225.
sunerpy
added a commit
that referenced
this pull request
Dec 2, 2026
* docs(upstream): audit e8ddc4e2..461a5d87 (v1.6.4) Classify the 324 non-merge upstream commits from colby main of 2026-10-22 (e8ddc4e2) to the v1.6.4 tag (461a5d87; v1.6.3 is ef4bd058) against codegraph-rs v0.56.0 (73c8dd3, extraction version 23, schema 10). Each commit has one row in docs/upstream-sync/V1_6_4_AUDIT_2026-11-28.md, grouped P1 to P6, with its disposition, Rust target, graph impact, evidence and route. Dispositions: 174 PORT, 66 PARTIAL, 8 DEFER, 9 ALREADY-HAVE, 63 N/A and 4 KEEP-RUST; 180 rows change the stored graph. Routes: 182 B, 22 C-early, 41 C-late, 1 v0.56.2 (plus the regular-file half of 329dd12f) and 78 none. Verification changed 13 dispositions. The audit re-runs the ten ALREADY-HAVE rows of the 2026-10-22 pass B with their commits' own fixtures (X25; five become PARTIAL), records the nine earlier rows that commits of this range supersede, and adds GAP-JAVA-FIELD-INIT. UPSTREAM.md moves the last discovery audit to 461a5d87 and the next discovery to 461a5d87..origin/main, and adds the 2026-11-28 sync log entry; the tracked release stays v1.6.2. KNOWN_DIFFS.md updates the entries whose colby side changed and names their audit rows. docs-check.py checks the new boundary. The row tables are unpadded under prettier-ignore, which keeps the file at about 540 KB. * docs(upstream): tighten the v1.6.4 audit wording * docs(upstream): name the v0.56.2 pull requests in the v1.6.4 audit The audit was written before the v0.56.2 patches merged and named them by their plan labels. They merged as #360 (97fa800, project inputs read only from regular files, and the single non-blocking source open) and #363 (e3417d7, upstream #527's lexical and real-path checks, extraction version 23 to 24). Name them by number in the owner decisions table and in rows 201, 207 and 225.
sunerpy
added a commit
that referenced
this pull request
Dec 2, 2026
The six CLI daemon tests each carried a process_is_gone_or_zombie that read /proc/<pid>/stat and took any read error for an exited process. On macOS, which has no /proc, a live daemon therefore looked gone: the idle test verified nothing and skipped the teardown kill, leaking the daemon. A shared tests/common/process.rs now reads /proc on Linux and runs `ps -o stat= -p <pid>` elsewhere (exit status 1 is gone, a Z state is a zombie). A live pid whose state cannot be read panics instead of passing as exited. daemon_spawn.rs gains a positive control: a running sleep child is Running, a killed unreaped one is a Zombie, a reaped one is Gone, and on Linux the ps probe must agree with /proc. Three comments that named internal plan items now cite #363 and #360.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/separators, no.or..segment, no backslash and valid Unicode. The scan skips any other name whole (without following, descending into or counting it), andinit,indexandsyncprint one stderr line naming up to five skipped entries. stdout and every--jsonoutput are unchanged./proc,/sysor/dev(unless the project itself lives there), and every reader refuses a file on a kernel pseudo filesystem once opened, before a byte is read.indexing.max_file_sizeabove it is clamped when parsed, with a warning. Godot scenes and.gd.uidsidecars are read under the project'smax_file_size, like the same file as a source file.upgrade_v0_56) proves the rebuild through CLI sync, the catch-up sync and a cold MCP session.The golden corpora do not change: all 32 check identical.
docs/architecture.md,docs/cli.md,docs/mcp.md,docs/data-model.mdanddocs/equivalence.mddescribe the behavior, anddocs/upstream-sync/UPSTREAM.mdrecords the related upstream change (#527).This completes the series with #360 and #362.
Tests
Each new test was run on the base first and failed there for the reason it targets; tests added for code that was already correct were proven by a mutation instead.
crates/codegraph-cli/tests/intake_containment.rs,outside_root_serving.rs,max_file_size_ceiling.rs,upgrade_from_v056.rsand newsync_convergencecases: intake of unstorable names, CLI and stdio MCP serving of rows and links outside the root, swapped-in databases (including the control inputs a sync records), the size ceiling, and the upgrade from a v0.56.1 index.crates/codegraph-mcp/tests/outside_root_mcp.rs, and unit tests in core, extract, watch, resolve and graph for the stored-path checks, the scan, the watcher and sync lanes, the Godot walks, the bounded read and the read limit every resolution context reports.Verification
cargo fmt --all --check,cargo clippy --workspace --all-targets --locked -- -D warnings, and the same clippy cross-compiled forx86_64-pc-windows-msvc.scripts/regen-goldens.sh --check: 32 corpora identical.make pre-ci) ran on push.