Skip to content

Workspace deps refactor#240

Merged
nikomatsakis merged 9 commits into
symposium-dev:mainfrom
nikomatsakis:workspace-deps-refactor
Jun 12, 2026
Merged

Workspace deps refactor#240
nikomatsakis merged 9 commits into
symposium-dev:mainfrom
nikomatsakis:workspace-deps-refactor

Conversation

@nikomatsakis

Copy link
Copy Markdown
Member

What does this PR do?

Summary

  • Eliminate redundant cargo metadata calls during hook dispatch. Previously, a single SessionStart hook could invoke cargo metadata up to 3 times (~1-5s each). Now a single WorkspaceDeps instance is threaded through the entire hook pipeline — auto-sync, builtin dispatch, and plugin dispatch share one resolution.
  • Add cross-invocation disk caching keyed on Cargo.lock mtime. On the common hot path (PreToolUse with unchanged deps), the cost drops from 1-5s to ~10ms (one cargo locate-project + stat + JSON deserialize).
  • Introduce symposium-sdk crate providing WorkspaceDeps, WorkspaceCrate, LoadedWorkspace, and shared utilities (file_mtime, workspace_dir_name) so plugin binaries can access workspace dep resolution without reimplementing it.
Disclosure questions

AI disclosure.

  • I used an AI tool for research, autocomplete, or in other minimal ways
  • The AI tool authored small parts of the code (e.g., autocomplete, comments)
  • The AI tool authored large parts of the code
  • The AI tool authored and opened this PR autonomously
  • Other: (explain)

Questions for reviewers.

nikomatsakis and others added 5 commits June 10, 2026 18:31
Add a new `symposium-sdk` crate as the single SDK dependency for plugin
binaries (hooks, custom predicates, subcommands). It re-exports
`symposium-hook` as `hook` and adds:

- `predicate` module: `PredicateOutput` and `SelectedCrate` types for
  custom predicate witness output serialization
- `workspace` module: `WorkspaceCrate` struct for typed workspace
  dependency access

Refactor the main symposium crate to use these SDK types as the source
of truth:
- `crate_sources::WorkspaceCrate` is now a re-export from the SDK
- `predicate::WitnessCrate` is now an alias for `SelectedCrate`
- `parse_witness_stdout` deserializes via `PredicateOutput` directly

Co-authored-by: Claude <claude@anthropic.com>
Introduce `WorkspaceDeps` in the SDK to deduplicate `cargo metadata`
calls. A single instance is threaded through the hook pipeline so that
auto-sync, builtin dispatch, and plugin dispatch share one resolution.

Cross-invocation, a disk cache keyed on `Cargo.lock` mtime avoids
re-running `cargo metadata` entirely when deps haven't changed — the
common case for PreToolUse hooks.

Also: deduplicate `file_mtime`/`workspace_dir_name` (SDK is canonical),
add `Symposium::workspace_deps()` factory, fix collapsible_if clippy
lint in the binary.

Co-authored-by: Claude <claude@anthropic.com>
Plugin binaries (hooks, predicates, subcommands) need the same
directory resolution logic as the main binary to construct
WorkspaceDeps with the correct cargo override and cache path.

Extract a non_exhaustive SymposiumDirs struct into symposium-sdk
with from_environment() and workspace_deps() methods. Symposium
in the main crate now embeds SymposiumDirs and exposes it via
.dirs(), delegating all path/cache logic through it.

Co-authored-by: Claude <claude@anthropic.com>
WorkspaceDeps previously had separate cargo_path and cache_dir
fields configured via builder methods. Now it takes an optional
SymposiumDirs reference, keeping a single source of truth for
resolved paths.

Co-authored-by: Claude <claude@anthropic.com>
WorkspaceDeps::new now takes a mandatory &SymposiumDirs argument
instead of having an optional dirs field. This ensures all callers
provide proper cache/cargo configuration.

Co-authored-by: Claude <claude@anthropic.com>
Comment thread symposium-sdk/src/workspace.rs Outdated
Comment thread src/predicate.rs Outdated
Comment thread src/crate_sources/list.rs Outdated
Comment thread src/crate_sources/mod.rs Outdated
Remove the WorkspaceCrate and WorkspaceDeps re-exports from
crate_sources and the WitnessCrate alias from predicate.rs.
Callers now import directly from symposium_sdk::workspace and
symposium_sdk::predicate::SelectedCrate.

Also updates the workspace.rs module doc to reflect the current
design (SymposiumDirs-based construction).

Co-authored-by: Claude <claude@anthropic.com>
Comment thread src/hook.rs Outdated
Comment thread src/hook.rs Outdated
Comment thread src/workspace_state.rs Outdated
Comment thread src/workspace_state.rs Outdated
Comment thread symposium-install/src/git.rs Outdated
Comment thread symposium-sdk/src/lib.rs Outdated
nikomatsakis and others added 2 commits June 12, 2026 19:46
- Add WorkspaceDeps::cwd() accessor; run_auto_sync uses it instead of
  extracting cwd from the input event separately.
- Remove sync_with_deps; sync() now takes &mut WorkspaceDeps directly.
  CLI creates deps inline.
- Remove file_mtime/workspace_dir_name wrappers in workspace_state.rs;
  callers use symposium_sdk::workspace functions directly.
- Revert git source debounce from 5s back to 60s (accidental change).
- Inline symposium-hook crate into symposium-sdk as the `hook` module.
  The separate crate is removed from the workspace.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude <claude@anthropic.com>
Comment thread symposium-sdk/src/workspace.rs
Comment thread symposium-sdk/src/workspace.rs
Add constructors so external code can still create instances
without struct literal syntax.

Co-authored-by: Claude <claude@anthropic.com>
@nikomatsakis nikomatsakis marked this pull request as ready for review June 12, 2026 20:09
@nikomatsakis nikomatsakis added this pull request to the merge queue Jun 12, 2026
Merged via the queue into symposium-dev:main with commit 7763ce2 Jun 12, 2026
6 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.

1 participant