Skip to content

feat(path/resolver): populate retrieval state#1153

Draft
lidel wants to merge 2 commits into
mainfrom
feat/cli-progress-state
Draft

feat(path/resolver): populate retrieval state#1153
lidel wants to merge 2 commits into
mainfrom
feat/cli-progress-state

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented May 6, 2026

Populate retrieval.State (phase + root/terminal CIDs) inside path/resolver so 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

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
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 91.78082% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.29%. Comparing base (95ad7a5) to head (5b21cdc).

Files with missing lines Patch % Lines
path/resolver/resolver.go 70.00% 5 Missing and 1 partial ⚠️

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
retrieval/state.go 95.93% <100.00%> (+15.61%) ⬆️
path/resolver/resolver.go 74.79% <70.00%> (-0.21%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant