Expand description
Path resolution algorithm per ADR-021 §2.
Given a RouterConfig and a SecretPath, decide which
source serves the path and what context the source needs to
produce a reference. The decision is pure data — no source
plugin is invoked here. Turning the decision into an actual
(source, reference) pair is the next layer’s job (P5.4 wires
the cache + plugin lookup; P6 ships the concrete sources).
Splitting the resolver from the source-call layer lets tests
exercise the routing rules with TOML fixtures alone, without
standing up real backends. doctor (P7.2 / P10.1) reuses the
same pure function to pre-flight a project’s manifest against
the active config.
§Algorithm
Per ADR-021 §2:
- Per-secret override. If
[secret."<path>"]matches the queried path, returnRouteDecision::Explicitwith the user-supplied source + reference. Wins over everything else. - Longest prefix. Walk
[[route]]blocks; pick the one whoseprefixis the longest string that the queried path starts with. ReturnRouteDecision::Prefixwith the route’s source name + verbatim settings. Source-specific path-tail-to-reference mapping (Vault joins mount + tail, 1Password builds anop://URL, …) is delegated to the plugin. - Default route. No
[secret]and no[[route]]matched. ReturnRouteDecision::Defaultcarrying the default source + the optional fallback hint (used by the caller’sis_available() == NotInstalledretry — see ADR-021 §2 step 3). - No fall-through. No matching
[secret], no matching[[route]], and no[default]either: fail withResolveError::NoRoute.
Prefix [[route]] already enforces a trailing / at config
load (router_config::RouterConfigError::BadRoutePrefix), so
the resolver does not have to worry about partial-segment
matches like team/ vs teamfoo/x.
Ties between routes of equal length resolve by declaration
order — earlier [[route]] wins. That’s deterministic and
matches what the user sees when they read the file top to
bottom.
Structs§
- Path
Resolver - Read-only view over a
RouterConfigthat answers “which source serves this path?” without invoking any source plugin.
Enums§
- Resolve
Error - Failure modes for
PathResolver::resolve. - Route
Decision - Outcome of resolving a path against a
RouterConfig.