stock-bot/docs/development/backlog/tasks/A03.md

4.7 KiB

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. 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

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, R08, R03 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; 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.