Skip to content

(Sources-2) oak_db::workspace_dependencies() - #1287

Merged
DavisVaughan merged 5 commits into
mainfrom
sources/2-workspace-dependencies
Jun 25, 2026
Merged

(Sources-2) oak_db::workspace_dependencies()#1287
DavisVaughan merged 5 commits into
mainfrom
sources/2-workspace-dependencies

Conversation

@DavisVaughan

Copy link
Copy Markdown
Contributor

Progress towards #1234
Branched from #1286

Two new things here:

  • File::used_packages() is a tracked query that returns the Names of all packages used by this file

    • library() and require() are included (reusing the existing attached_packages())
    • :: and ::: are included (using the new namespaced_accesses() from (Sources-1) Teach SemanticIndex about NamespacedAccesses #1286)
    • The result is sorted and unique, maximizing the chance of backdating after small file edits (a reorder of library() or :: calls should not affect this query result, unlike attached_packages())
  • oak_db::workspace_dependencies() is a tracked query that returns a Vec<Package> of every installed package used by this workspace.

    • It collects from File::used_packages() on each workspace_file()
    • It collects from DESCRIPTION if you have a workspace package open. In particular, it collects Imports and Depends. I have omitted Suggests because typically they are referenced by :: already if they are used, so they probably aren't worth it to also include here?

Two notes about oak_db::workspace_dependencies():

  • Any not installed package returned by File::used_packages() is thrown out. The user can't actually use this, and we won't have a package version to look up anyways.
  • If you have a workspace package open, it is also removed from the list (the workspace package itself isn't really a workspace dependency). We assume that you already have package sources for that in your local R/ folder.

oak_db::workspace_dependencies() will be used in a future PR to detect the set of changed packages after each revision change.

Comment thread crates/oak_db/src/file.rs Outdated
Comment thread crates/oak_db/src/file.rs
Comment thread crates/oak_db/src/workspace.rs Outdated
Comment thread crates/oak_db/src/workspace.rs
@lionel- lionel- mentioned this pull request Jun 24, 2026
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch from aee7077 to 251a097 Compare June 24, 2026 15:43
@DavisVaughan
DavisVaughan force-pushed the sources/1-namespaced-accesses branch from f4f1f2c to 15fb5ba Compare June 24, 2026 15:43
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch from 41e96ce to 8c166c5 Compare June 24, 2026 16:04
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch from a1a4bce to 8fb644d Compare June 24, 2026 17:45
lionel- added a commit that referenced this pull request Jun 25, 2026
I learned about `sort_by_cached_key()` in
#1287, so I went back and checked
we use that instead of `sort_by_key()` everywhere the key lookup is not
trivial or allocates.
@DavisVaughan
DavisVaughan force-pushed the sources/1-namespaced-accesses branch from 81c0e7f to 7e54b08 Compare June 25, 2026 19:54
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch from 8fb644d to 569ab10 Compare June 25, 2026 19:54
Base automatically changed from sources/1-namespaced-accesses to main June 25, 2026 20:04
We are guessing there won't ever be more than 100-200 namespace accesses within a single R file, so this is likely to never be a performance or memory issue, and the Vec impl is simpler to reason about.
@DavisVaughan
DavisVaughan force-pushed the sources/2-workspace-dependencies branch from 569ab10 to ea95626 Compare June 25, 2026 20:06
@DavisVaughan
DavisVaughan merged commit 9817b04 into main Jun 25, 2026
17 checks passed
@DavisVaughan
DavisVaughan deleted the sources/2-workspace-dependencies branch June 25, 2026 20:06
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants