Skip to main content

Module resolution

Module resolution 

Source
Expand description

Detached/workspace-mode repo resolution: turn a filesystem path into a RepoBinding (via the path’s git remote + the server), and pick the effective binding for an event/command from the precedence chain (--path flag → subagent worktree override → session active → bound .tracevault/config.toml). See design §2/§3/§4.

Structs§

ProjectResolveInputs
Inputs for the effective-project precedence chain. project_flag and config_default are resolved by the caller; session/worktree_path come from the per-session state.
ResolveInputs
Inputs for the effective-binding precedence chain. repo_flag and bound are resolved by the caller (the --path override and the bound config.toml, respectively); session/worktree_path come from the per-session state.

Enums§

BindingSource
Which precedence tier produced the effective_binding result.
ProjectSource
Which precedence tier produced the effective_project result.

Functions§

binding_from_config
A RepoBinding from a pinned .tracevault/config.toml (bound mode), if it has both org_slug and repo_id. Pure — caller supplies the already-loaded config. Carries through the remote_id/codebase_name init persisted (best-effort, display-only) so bound-mode status can print the codebase without an extra network round-trip; git_url stays None here — bound mode has no live origin URL to hand back (that’s the older git_url fallback’s job, covering bindings that predate codebase_name).
effective_binding
The binding that applies, and which tier produced it: --path flag → subagent worktree override → session active → bound config → user default → none.
effective_project
The project that applies, and which tier produced it: --project flag → subagent worktree override → session active → config default → none. Pure; covers only the local tiers (flag → subagent → session.active_project → config_default). Server-side deduction and the user-level default are applied afterward by resolve_effective_project, which calls this function first and only falls through to those tiers when it returns None.
org_slug_for
Resolve the org slug for project_root: TRACEVAULT_ORG_SLUG (non-empty) → credentials.json org_slug → bound config.toml org_slug.
org_slug_from_slugs
Pick the org slug from the credential’s memberships when none is configured locally. The slugs are de-duplicated first (a credential can have more than one membership row for the same org, e.g. multiple roles), then: exactly one distinct org → that slug; zero or many → an error telling the user to set TRACEVAULT_ORG_SLUG. The empty case is not only “no memberships”: /me/orgs is also empty for an org-scoped API key (which has no user), so the message names that case explicitly. Sorting makes the multi-org message deterministic regardless of server ordering.
org_slug_precedence
Pure precedence for the org slug: first non-None of env, credentials, bound config. Callers pass None for an env value that was empty.
resolve_effective_project
Full project-attribution precedence chain: --project flag → subagent override → session active → config default (all pure, via effective_project; no network call) → server-side deduction from the repo’s git remote → user-level default. Deduction outranks the user-level default — this falls out of the ordering below: the user default is only consulted once deduction has returned None.
resolve_path_to_binding
Resolve a filesystem path to a registered-repo binding: read its origin remote URL and ask the server. Ok(None) when the path has no remote or the server has no matching codebase (pre-registered-only).