Skip to content

feat(cli): --parent-dir scoped sync and query - #136

Merged
benbaarber merged 2 commits into
mainfrom
ben/sync-4-parent-dir
Aug 6, 2026
Merged

feat(cli): --parent-dir scoped sync and query#136
benbaarber merged 2 commits into
mainfrom
ben/sync-4-parent-dir

Conversation

@benbaarber

@benbaarber benbaarber commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Top of the stack. --parent-dir <dir> / -d on p cache sync and path query restricts ingestion — and the query's reads — to artifacts under a directory (subtree match).

The stat gate always runs first: unchanged+cached artifacts skip before any scope check, so only artifacts that would cost a derive pay for the constraint. Providers whose cwd lives inside the session file (codex, copilot) get a one-line bounded peek, memoized into the manifest record so it happens at most once per artifact — and a later derive never clobbers the memoized cwd. Claude and pi compare in their lossy encoded key spaces (claude in slug space where //_/. all became -; pi in its dir-encoded space so hyphenated paths match). Out-of-scope artifacts are recorded as known-but-uncached, tallied separately (N out of scope), and never touch a materialized record's stamp — so staleness is never masked from the next in-scope sync.

The ArtifactSource trait grows its two scoping hooks here: peek_dir (defaulted to None) and in_scope (defaulted to real-path subtree matching), overridden only by the providers that need them.

With this PR the stack's tree is identical to ben/cache-sync (#131) apart from the CHANGELOG retelling, so the series fully supersedes it. Tests: cargo clippy -D warnings clean; 478 tests pass; the full branch also passed the whole workspace suite (1,837 tests) and workspace clippy.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Stack (review bottom-up): #133 types/imports → #134 cache sync → #135 query auto-sync → #136 parent-dir. Supersedes #131.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

🔍 Preview deployed: https://494d88c3.toolpath.pages.dev

Base automatically changed from ben/sync-3-query-autosync to main July 27, 2026 18:33
Comment thread crates/path-cli/src/query/mod.rs Outdated
pub project: Option<PathBuf>,
/// `--parent-dir`: keep only paths whose `base` lives under this
/// directory (subtree match).
pub parent_dir: Option<PathBuf>,

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.

Maybe "--project-under"? Unsure the right name, but "--parent-dir" freestanding doesn't seem clear enough. I don't know that users understand the implications of project director restriction like this and we need to communicate that in the flag name / documentation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

agree, now changed to --project-under

@akesling akesling assigned benbaarber and unassigned akesling Aug 3, 2026
--parent-dir <dir> / -d on p cache sync and path query restricts
ingestion (and the query's reads) to artifacts under a directory. The
stat gate always runs first; only artifacts that would cost a derive
get the scope check, with one-line cwd peeks for codex/copilot memoized
into the manifest record. Claude and pi compare in their lossy encoded
key spaces. Out-of-scope artifacts are recorded as known-but-uncached
and tallied separately, never touching a materialized record's stamp.
Review feedback on #136: "--parent-dir" names the argument, not the
filter — it doesn't say what the directory is a parent *of*.
"--project-under" reuses the established --project vocabulary (the
session's recorded project/working directory) and reads as its subtree
relaxation. The -d short goes away with it; help text now spells out
that the match is on the session's project directory, not the files it
touched.
@ben-emp
ben-emp force-pushed the ben/sync-4-parent-dir branch from bd50b8a to f42e398 Compare August 3, 2026 15:18
@benbaarber
benbaarber requested a review from akesling August 3, 2026 15:24
@benbaarber benbaarber assigned akesling and unassigned benbaarber Aug 3, 2026

@akesling akesling 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.

LGTM

@benbaarber
benbaarber merged commit 7a68918 into main Aug 6, 2026
3 checks passed
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.

2 participants