Workspace deps refactor#240
Merged
nikomatsakis merged 9 commits intoJun 12, 2026
Merged
Conversation
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>
nikomatsakis
commented
Jun 11, 2026
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>
nikomatsakis
commented
Jun 12, 2026
- 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>
nikomatsakis
commented
Jun 12, 2026
Add constructors so external code can still create instances without struct literal syntax. Co-authored-by: Claude <claude@anthropic.com>
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.
What does this PR do?
Summary
cargo metadatacalls during hook dispatch. Previously, a singleSessionStarthook could invokecargo metadataup to 3 times (~1-5s each). Now a singleWorkspaceDepsinstance is threaded through the entire hook pipeline — auto-sync, builtin dispatch, and plugin dispatch share one resolution.Cargo.lockmtime. On the common hot path (PreToolUsewith unchanged deps), the cost drops from 1-5s to ~10ms (onecargo locate-project+ stat + JSON deserialize).symposium-sdkcrate providingWorkspaceDeps,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.
Questions for reviewers.