10 KiB
Store Dump Server-Owned Export Plan
Summary
Align fabro store dump with the intended architecture by making it a pure server-backed export command.
- The CLI should resolve runs from server summaries only.
- It should fetch hydrated run state, hydrated event history, and artifacts over HTTP.
- It should stop creating a temporary
Database. - It should stop reading local scratch directories or local storage/object-store paths.
- It can keep the current export-style output layout on disk, except blob storage should stay transparent:
- top-level metadata files
nodes/**retro/**events.jsonlcheckpoints/**artifacts/**
This is a debugging export, not a strict snapshot mechanism. Best-effort consistency is acceptable.
Problem Frame
fabro store dump is still implemented as a local store reconstruction flow:
- it resolves the run through local-storage-aware helpers
- it fetches events over HTTP but replays them into an in-memory
fabro_store::Database - it reads artifacts from local storage directly
- it assumes the CLI can see the same storage and scratch directories as the server
That is now the wrong boundary. The server should own store access; the CLI should only export server-provided run data to disk.
Key Decisions
-
store dumpbecomes server-only.- Use
ServerTargetArgs, notStorageDirArgs. - Resolve selectors through
ServerSummaryLookup, notServerRunLookup. - Do not scan local scratch directories or orphan runs.
- Use
-
Keep the current export layout.
- It is fine that the command still writes
events.jsonl,checkpoints/, andartifacts/. - It should not write a
blobs/directory. - Blob storage is an internal offload mechanism, not part of the user-facing export model.
- It is fine that the command still writes
-
Do not add blob enumeration.
- Blob-backed values should be hydrated server-side before the CLI receives run state or events.
- The CLI should not need to understand blob pointer conventions.
- The exported files should look as if offloading had never happened.
-
Best-effort race handling is acceptable.
- If a blob or artifact is listed/referenced but disappears before download, skip it and continue.
- Fail on transport or server errors other than
404.
-
Event pagination should use the server's
meta.has_morecontract.- Do not stop paging based on "returned fewer than page size".
- The client should retain and use pagination metadata from the API response.
-
Artifact downloads should be concurrent with a fixed upper bound.
- Use a bounded concurrency strategy such as
JoinSetorFuturesUnorderedwith a small limit. - Recommended default:
8concurrent artifact downloads.
- Use a bounded concurrency strategy such as
Implementation Changes
1. Convert store dump to standard server targeting
In fabro-cli:
- change
StoreDumpArgsto flattenServerTargetArgs - remove
StorageDirArgsfrom this command - update help text, docs, and snapshots to show
--server/FABRO_SERVER
Run resolution should follow the same contract as other server-backed inspection commands:
- explicit
--server - configured
[server].target - default local server instance if no server target is configured
The command should no longer derive behavior from a local storage dir.
2. Resolve the run from server summaries only
- replace
ServerRunLookupusage withServerSummaryLookup - resolve
<RUN>from server-provided summaries only - remove any dependence on local scratch-path scanning during selector resolution
This ensures store dump works even when the server runs on a different host.
3. Add server/API support for paginated hydrated reads
The CLI path depends on the server returning enough information to page correctly and to keep blob handling transparent.
Add or update the server/API contract for:
GET /runs/{id}/state?hydrate_blobs=trueGET /runs/{id}/events?...&hydrate_blobs=true
Follow the existing OpenAPI-first workflow for these API changes:
- update
docs/api-reference/fabro-api.yaml - rebuild Rust API types/client via
cargo build -p fabro-api - regenerate the TypeScript client in
lib/packages/fabro-api-client
Also update the CLI client shape for event listing so pagination metadata is preserved instead of discarded:
- add a new paginated event-list helper for
store dumpthat returns bothdataandmeta.has_more - keep the existing
list_run_events(...) -> Vec<EventEnvelope>convenience method in place for current callers unless there is a strong reason to migrate them in the same change store dumpmust consume the metadata-bearing form
The existing artifact APIs are already sufficient for this plan:
list_run_artifacts(run_id)download_stage_artifact(run_id, stage_id, filename)
No new artifact endpoint work is required here.
4. Add server-side blob hydration for state and events
Blob storage is intended to be transparent. store dump should not detect, enumerate, or hydrate blob pointers in the CLI.
Recommended API shape:
- add
hydrate_blobs=trueas an optional query parameter on both endpoints - when omitted or
false, preserve current behavior - when
true, the server resolves blob-backed references before serializing the response - reflect those query parameters in the OpenAPI schema and generated clients
Hydration scope:
- all blob-backed values inside
RunProjection - all blob-backed values inside returned event payloads
- this includes values that ultimately flow into exported checkpoint JSON because checkpoints come from
RunProjection.checkpoints
Hydration mechanism:
- implement a shared server-side JSON hydrator that walks
serde_json::Value, detects blob-backed pointer values, reads the referenced blobs from the run store, and replaces the pointer string with the parsed JSON payload - reuse the same helper for both state and event responses so blob resolution rules stay identical
- keep the helper server-owned rather than attaching it only to
RunProjection, because event payloads need the same treatment
If a referenced blob cannot be resolved during hydrated fetch:
- treat
404as a race-tolerant miss - preserve the original pointer value in the hydrated response
- fail on non-
404server/store errors
This keeps blob knowledge server-owned, which matches the architecture this plan is trying to enforce.
5. Refactor RunDump to accept fetched export data instead of store handles
RunDump::store_export currently assumes:
- a
RunDatabase - an
ArtifactStore - store enumeration for blobs and artifacts
Refactor this into a store-agnostic export builder with a concrete constructor:
RunDump::from_export(
state: &RunProjection,
events: &[EventEnvelope],
artifacts: &HashMap<(StageId, String), Bytes>,
) -> Result<Self>
Notes:
stateis already hydratedeventsare already hydrated- blobs are not a separate constructor parameter
artifactsare the only binary payloads the CLI still fetches explicitly
The new builder should preserve the current file layout and validation rules:
- top-level metadata files from
RunProjection - node files under
nodes/<node>/visit-<n>/ retro/prompt.mdandretro/response.mdevents.jsonlcheckpoints/<seq>.jsonsourced directly fromRunProjection.checkpointsartifacts/nodes/<node>/visit-<n>/<relative_path>
Keep the existing staged-directory write behavior:
- reject non-empty output dirs
- write into a temp dir under the output parent
- rename into place when complete
6. Replace local store reconstruction with HTTP-backed export collection
In dump_command, fetch the export inputs directly from the server:
- hydrated current run state via
get_run_state(run_id, hydrate_blobs = true) - full hydrated event history via paginated
list_run_events(run_id, since_seq, limit, hydrate_blobs = true)- use an explicit page size of
1000 - continue paging based on
meta.has_more
- use an explicit page size of
- run artifacts via
list_run_artifacts(run_id) - artifact contents via
download_stage_artifact(run_id, stage_id, filename)using bounded concurrency
Do not:
- create a
Database - call
rebuild_run_store - open a local
ArtifactStore - read anything under local
storage/or scratch paths
7. Leave shared event-rebuild helpers for other commands
rebuild_run_store is still used by other commands such as fork, rewind, and pr create.
- remove it from
store dump - do not delete it in this change unless those other commands are migrated too
This plan is specific to aligning store dump with server-owned export.
Test Plan
- update the
store dump --helpsnapshot for the CLI arg change from--storage-dirto--server - re-enable the disabled
store dumpintegration coverage and make it exercise the server-backed path only - add a regression test for a run with more than 100 events to prove pagination exports the full
events.jsonl - add a regression test for a run with exactly
1000events to prove the client performs the additional page fetch and stops onhas_more = false, not on page-size heuristics - add server/API coverage for hydrated fetches:
- hydrated
get_run_state(..., hydrate_blobs = true)replaces blob-backed pointers with original JSON values - hydrated
list_run_events(..., hydrate_blobs = true)replaces blob-backed pointers in event payloads - blob
404during hydration preserves the original pointer value
- hydrated
- add coverage that no
blobs/directory is emitted - add
RunDumpcoverage for the new store-agnostic constructor to verify the exported file layout remains unchanged for representative state/events/blobs/artifacts - keep or restore the non-empty output-dir rejection test
- add a race-tolerance test where a referenced artifact returns
404and the export completes without that artifact file - add coverage that artifact downloads run through the bounded-concurrency path without changing output order or file paths
Assumptions and Defaults
store dumpshould use the standard server-target contract, not--storage-dir- the current export file layout is intentionally preserved
- blob handling is transparent and server-owned; there is no
blobs/export directory and no need for a blob-list API - best-effort consistency is sufficient because this command exists for debugging and inspection
- the server remains the only component allowed to access the underlying run store in this architecture