74 lines
4.8 KiB
Markdown
74 lines
4.8 KiB
Markdown
# CL06 — Use shared dataset response schemas and eligibility checks in the workbench
|
|
|
|
Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: Shared contracts and frontend validation.
|
|
|
|
Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). Implementation and validated commits were authorized after planning; scheduling and completion evidence live in the manifest.
|
|
|
|
## User story and outcome
|
|
|
|
As a researcher, I want the browser and API to interpret dataset responses consistently, so valid datasets do not fail because independent schema copies drift.
|
|
|
|
Expected benefit: Removes a large inline manifest schema and repeated eligibility rules from the backtest client.
|
|
|
|
## Verified evidence
|
|
|
|
- **Verified — CL-F05:** The client defines a second substantial dataset manifest schema and preparation-response validation. [apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts:113](../../../../apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts#L113).
|
|
- **Verified — CL-F05:** The server defines overlapping calendar, series, bounds and corporate-action structures. [apps/stock/orchestrator/src/data/historical-dataset-v2.ts:34](../../../../apps/stock/orchestrator/src/data/historical-dataset-v2.ts#L34).
|
|
- **Verified — CL-F05:** Workbench dataset eligibility is enforced separately at admission. [apps/stock/web-api/src/services/canonical-research.service.ts:51](../../../../apps/stock/web-api/src/services/canonical-research.service.ts#L51).
|
|
|
|
## Implementation scope
|
|
|
|
- Reuse the CL05 browser-safe structural schemas in dataset catalog/preparation response parsing.
|
|
- Centralize workbench-specific structural eligibility checks used by response consistency checks and admission, without broadening the single-asset/single-series policy.
|
|
- Keep expected-request/hash identity checks at the client boundary and full dataset-byte/hash validation at execution. Shared shape validation must not pretend to authenticate dataset content.
|
|
- Preserve existing prepared/stored-source response contracts, explicit unavailable reasons and immutable retained inputs.
|
|
|
|
Likely existing files/modules:
|
|
|
|
- `apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts`
|
|
- `apps/stock/web-api/src/services/canonical-research.service.ts`
|
|
- `apps/stock/config/src/contracts/canonical-research.ts`
|
|
- `test/integration/dataset-source-preparation-ui.test.tsx`
|
|
- `test/integration/canonical-workbench.test.tsx`
|
|
|
|
Prerequisite output: `libs/research/src/dataset-contracts.ts` is proposed by CL05 and must exist before this story begins; it is not present at this audit baseline.
|
|
|
|
## Exclusions
|
|
|
|
- No new datasets UI, automatic calendar assumptions, changed content hashes or wider execution eligibility.
|
|
- No browser hashing of full datasets, client-authoritative eligibility or weakened worker checks.
|
|
|
|
## Dependencies and ownership
|
|
|
|
Implementation prerequisites: [CL05](CL05.md).
|
|
|
|
Write locks: `dataset-response-contracts`, `web-backtest-api`.
|
|
|
|
Parallel execution: After CL05. Disjoint from CL07, which initially excludes backtestApiV2.ts; reserve this client file explicitly.
|
|
|
|
## Acceptance criteria
|
|
|
|
1. Calendar/series/bounds/action response structures have one shared schema definition used by the server and browser.
|
|
2. Valid server preparation and catalog fixtures are accepted by the browser; malformed or mismatched identities still fail.
|
|
3. Eligibility and unavailable-reason consistency match between UI response parsing and server admission for supported and unsupported fixtures.
|
|
4. A browser build of this client contains no native/file/database or Node hashing dependencies.
|
|
5. Stored snapshots, normalized bars, v1/v2 hash fixtures and exact run provenance remain unchanged.
|
|
|
|
## Mandatory verification
|
|
|
|
Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures.
|
|
|
|
```sh
|
|
bun test test/integration/dataset-source-preparation-ui.test.tsx test/integration/canonical-workbench.test.tsx
|
|
bun test test/integration/dataset-source-preparation.test.ts test/integration/historical-dataset-v2.test.ts
|
|
bun test scripts/test/architecture.test.ts
|
|
bun run typecheck
|
|
```
|
|
|
|
Required regression cases: eligible/unsupported series, missing calendars/actions, malformed fields, corrupt response hashes, expected-request mismatch and browser dependency boundaries.
|
|
|
|
## Risks and definition of done
|
|
|
|
Manifest validation and full content integrity are different boundaries. Consolidate shared structures without dropping contextual checks or treating a catalog entry as proof that retained bars are valid.
|
|
|
|
Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.
|