IMPORTANT: After completing the task below, you MUST output a JSON object in a [code]…
Private research annotation
Sign in to add a private research label or note.
- User
IMPORTANT: After completing the task below, you MUST output a JSON object in a ```json code fence at the very end of your response. Do NOT forget this — the workflow fails without it.
Implement the current Spectraplex packet.
Follow:
- CLAUDE.md
- design/SPECTRAPLEX_STRATEGY_AND_EXECUTION_PLAN.md
- design/PHASED_IMPLEMENTATION_PLAN.md
Current coordination:
- phase: Phase 4: ETL-First Delivery
- work packet: P4-W1: Dataset query API
- objective: Add dataset-oriented read endpoints that support filtering by target, network, dataset, and time window, so downstream consumers can query Silver datasets directly without going through wallet-scoped routes.
- branch: p4-w1-dataset-query-api
- stage: new packet implementation
- existing PR:
Repo touchpoints:
- api/src/main.rs — new route registrations and handler functions for dataset endpoints
- adapters/src/v2_repo.rs — extend existing query methods with limit/offset pagination and optional time-window filters
- core/src/v2.rs — add API response types for dataset listing and dataset record queries if needed
- core/src/materializer.rs — verify Silver record types implement Serialize for API responses
- README.md — update API surface documentation with new dataset endpoints
Implementation steps:
-
- Add DatasetQueryParams struct (target_id, network, time_start, time_end, limit, offset) to api/src/main.rs
-
- Add GET /v1/datasets handler — calls repo.list_datasets() and returns dataset names with latest version info
-
- Add GET /v1/datasets/{name}/versions handler — calls repo.list_dataset_versions(name) and returns version history
-
- Add GET /v1/datasets/{name}/records handler — dispatches to the correct dataset query method based on name (token_transfers, native_balance_deltas, decoded_events, hl_fills, hl_funding_payments, hl_position_changes), applies target/network/time filters, returns paginated JSON results
-
- Add GET /v1/datasets/{name}/completeness handler — calls repo.list_completeness_by_dataset(name) and returns completeness records
-
- Extend v2_repo query methods with limit/offset parameters and optional time-window filtering (coverage_start/coverage_end or timestamp range)
-
- Register all new routes in the Axum router alongside existing wallet routes
Assistant
Now let me read the key source files I need to understand and modify:
Assistant
Now let me read the rest of the v2_repo.rs to see existing query methods and the remaining parts of main.rs:
Assistant
Let me now read the remaining test section and the README's API surface section:
Assistant
Now I have a thorough understanding of the codebase. Let me also quickly check the remaining test section of main.rs and the Cargo.toml for API crate:
Assistant
Now I have a thorough understanding of the entire codebase. Let me now implement the dataset query API. I'll need to:
- Add new dataset query repo methods to
v2_repo.rs - Add new handler functions and routes to
api/src/main.rs - Update
README.md
Let me start implementing:
- Add new dataset query repo methods to
Assistant
Now I have a thorough understanding of the codebase. Let me implement the dataset query API. I'll add repo query methods, API handlers, routes, and tests.
First, let me add the new query methods to
v2_repo.rs:Assistant
Now add the
build_dataset_filter_queryhelper function:Assistant
Now add tests for the new repo methods and helper at the end of the test module in v2_repo.rs:
Assistant
Now let me update
api/src/main.rsto add the dataset endpoints. First, update the imports:Assistant
Now add the DatasetQueryParams struct and DatasetInfo response type after the existing param structs:
Assistant
Now add the dataset handler functions. I'll add them after the
get_networkhandler and before the#[cfg(test)]module:Assistant
Now add the route registrations in the production router:
Assistant
Now add the same routes to the test router:
Assistant
Now let me read the end of the test module to add new tests:
Assistant
Now add tests for the new dataset endpoints at the end of the test module:
Assistant
Now update the README.md API reference:
Assistant
Now let me also add example curl commands for the new endpoints. Let me find where to insert them:
Assistant
Now let me add the curl examples for the new dataset endpoints before the Configuration section:
Assistant
Now let me also check the CLAUDE.md API surface section to see if it needs updating:
Assistant
Good. Now let me run the verification commands. Let me start with fmt and then clippy and test:
Assistant
Let me fix the formatting:
Assistant
Now run clippy:
Assistant
Clean. Now run tests:
Assistant
Let me verify the full summary counts:
Assistant
All 713 tests pass, 0 failures. Now let me verify the final diff before committing:
Assistant
Wait — CLAUDE.md was also modified. Let me check:
Assistant
CLAUDE.md wasn't tracked — it might be in the gitignore or the edit was to
.claude/CLAUDE.md. Let me check:Assistant
The CLAUDE.md changes aren't showing up — looks like that file may be gitignored or the edit didn't actually save. Let me check:
Assistant
Both are gitignored. That's fine — the CLAUDE.md update was informational for future agent sessions but won't be committed. The three tracked files are the ones that matter.
Now let me create the commit:
Assistant
All done. Here's the result:
json{ "packet": "P4-W1", "title": "Dataset query API", "branch": "p4-w1-dataset-query-api", "commit": "b270999", "status": "complete", "files_changed": [ "adapters/src/v2_repo.rs", "api/src/main.rs", "README.md" ], "routes_added": [ "GET /v1/datasets", "GET /v1/datasets/:name/versions", "GET /v1/datasets/:name/records", "GET /v1/datasets/:name/completeness" ], "verification": { "cargo_fmt": "pass", "cargo_clippy": "pass", "cargo_test": "pass (713 tests, 0 failures)" }, "summary": "Added four dataset query endpoints with a reusable build_dataset_filter_query helper for dynamic SQL across six Silver tables. Supports filtering by target_id, network, time_start, time_end with pagination. Includes 21 new tests (6 filter query builder, 6 method signature, 9 API handler/routing). README updated with endpoint docs and curl examples." }