feat(path/resolver): populate retrieval state#1153
Draft
lidel wants to merge 2 commits into
Draft
Conversation
ResolveToLastNode, ResolvePath, and ResolvePathComponents now advance retrieval.State on the request context (when one is attached) into PhasePathResolution and record both the root and terminal CIDs. Until now only the gateway backends populated these fields, which left non-gateway callers (CLIs, custom tools) without phase or CID diagnostics on retrieval errors. - path/resolver/resolver.go: add enterPathResolution and setTerminalCid helpers, call them from each public entry point. Idempotent with the existing gateway-side calls, so behavior on the gateway path is unchanged. - path/resolver/resolver_test.go: TestRetrievalStatePropagation covers the three entry points, the CID-only path, and the no-state-on-ctx case. - CHANGELOG.md: entry under [Unreleased] / Changed.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1153 +/- ##
==========================================
+ Coverage 63.11% 63.29% +0.18%
==========================================
Files 267 267
Lines 26777 26841 +64
==========================================
+ Hits 16899 16989 +90
+ Misses 8158 8134 -24
+ Partials 1720 1718 -2
... and 8 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Adds Snapshot/Apply/Notify so consumers outside boxo can observe a retrieval State as it evolves. CLI tools like Kubo can use this to stream State from a running daemon and drive a live progress bar during commands like cat, get, or dag export. - Snapshot is an immutable point-in-time copy; State.Snapshot returns one. JSON encodes via Go default field naming with Phase as the underlying int. - State.Apply mirrors a Snapshot back onto a State. Phase progression stays monotonic via a CAS loop, so concurrent SetPhase callers cannot regress phase through Apply. - State.Notify returns a size-1 coalescing channel that wakes subscribers on each change. Single-subscriber by design; channel never closes, observers stop via ctx cancellation. Existing setters signal after the write, gated on actual change so no-op writes do not wake subscribers. Read-only callers (gateway error wrapping, log output) are unchanged. Package godoc rewritten to point at the two motivating consumers: boxo/gateway timeout error decoration and external CLI tools driving live progress.
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.
Populate
retrieval.State(phase + root/terminal CIDs) insidepath/resolverso non-gateway callers (CLIs, custom tools) get the same diagnostics gateway backends already populate.guarded on
if rs := retrieval.StateFromContext(ctx); rs != nil {so if state tracker is not in context, this is noop