63 lines
4.7 KiB
Markdown
63 lines
4.7 KiB
Markdown
# A03 — Implement an evidence-linked AI research workflow client
|
|
|
|
Parent epic: E8. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: AI research integration.
|
|
|
|
Scheduling source of truth: [manifest entry A03](../manifest.json). No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness.
|
|
|
|
## Evidence and root cause
|
|
|
|
- **AI-01 — Verified:** Existing small operator auth has read/admin/service roles, not a research-only principal or arbitrary-code isolation boundary. [libs/core/di/src/http/security.ts:4](../../../../libs/core/di/src/http/security.ts#L4); [libs/core/di/src/http/security.ts:144](../../../../libs/core/di/src/http/security.ts#L144).
|
|
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
|
- **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107).
|
|
|
|
## Intended behavior and implementation scope
|
|
|
|
Implement a typed authorized research API client/example using backend R03/R06/R08 contracts, independent of whether project UI is complete. Propose hypothesis, register candidate, preview/submit bounded experiments, inspect all outcomes, request validation and save run-linked findings. No new AI service/framework or mandatory vendor/model SDK.
|
|
|
|
## Exclusions
|
|
|
|
No speculative distributed infrastructure or weakened correctness gates.
|
|
|
|
## Likely files and ownership
|
|
|
|
- apps/stock/web-api/src/routes/ (research API contracts)
|
|
- scripts/ (research client example)
|
|
- test/integration/ (AI research flow)
|
|
|
|
Write locks: ai-workflow-client. One agent owns this change. Lock names do not override actual overlapping files.
|
|
|
|
## Dependencies and blockers
|
|
|
|
Implementation requires [A02](A02.md), [R08](R08.md), [R03](R03.md) integrated.
|
|
|
|
Architecture decisions: ADR-007. Agents may not independently amend their policies.
|
|
|
|
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
|
|
|
## Acceptance criteria
|
|
|
|
- Every AI finding links immutable run/artifact IDs and distinguishes proposed hypotheses from validated evidence.
|
|
- An execution failure is returned as a diagnostic, not filtered out of candidate history.
|
|
- Client cannot promote itself to paper/live or alter operator account risk policy.
|
|
|
|
## Mandatory tests
|
|
|
|
- ai_hypothesis_to_validated_finding_contract, bounded_search_rejected, failed_trial_reported, evidence_mismatch_rejected.
|
|
- Replay the workflow with deterministic fake model suggestions; no paid model call required for CI.
|
|
|
|
Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist.
|
|
|
|
## Regression risks and rollback
|
|
|
|
Performance measurements can hide semantic changes; require economic hash equivalence.
|
|
Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics.
|
|
|
|
## Web/API contract and user states
|
|
|
|
- API: Reuse projects/hypotheses/versions/experiments/artifacts endpoints and diagnostics; publish typed request/response examples.
|
|
- Backend/data dependencies: No second task store or AI-only results database.
|
|
- Loading/error/empty behavior: Client handles202 polling,429 budgets,409 conflicts and terminal failures; UI shows AI authorship in existing workspace.
|
|
- User-facing completion is demonstrated by the acceptance criteria and interaction tests above; a backend-only implementation is insufficient where a UI is in scope.
|
|
## Handoff
|
|
|
|
Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.
|