stock-bot/docs/development/agents/integration.md

3 KiB

Reusable integration-agent brief

One integrator owns the shared integration branch and canonical contract sequencing. No two agents modify tightly coupled canonical financial contracts concurrently. The first-wave Rust legacy terminal fix and TS legacy fee guard are disjoint corrections, not concurrent design of the new contract.

Isolation and claim rules

After owner approval, planner atomically assigns one task and write locks in the canonical manifest on the coordination branch. Create a branch/worktree from the recorded integration commit, for example plan/C01-terminal-equity and a sibling worktree. These are examples for later execution, not commands run by this planning task.

Each implementation worktree edits only its code scope, never task status. The planner alone writes status/assignment changes; implementation PRs cannot overwrite a stale manifest. Acquire both symbolic locks and concrete-file ownership. SQL migration numbering/registry is assigned by the integrator.

Integration sequence

  1. Require dependencies merged and ADRs approved. Shared contract tasks merge before their consumers; no “probably compatible” simultaneous F01/F02/F04 changes.
  2. Require independent review and exact task acceptance evidence.
  3. Rebase/merge onto current integration base in dependency order; handle textual and semantic conflicts together. For contract overlap, pause a branch and let the contract owner resolve the design—never choose a side blindly.
  4. Run relevant combined native/TS/SQL/browser gates, plus economic/decision hash fixtures. Test mixed old/new stored data where compatibility is claimed.
  5. Update task completion through planning owner only after tests pass on the integrated commit. Record commit, review and gate references.
  6. Recompute readiness and release locks. Do not unlock downstream implementation merely because a PR exists.

PR creation, commits and merges require explicit execution authorization; this plan does not grant it. No force-reset of user work. Rollback uses a deliberate compatible deployment/commit, not destructive rewriting of historical financial state.

Safe concurrency

Recommend 3 implementation agents maximum, with one of them holding the single financial-core lane. A fourth concurrent slot can be a read-only reviewer when available; otherwise rotate review between implementation batches. Do not independently spawn nested implementation teams.

Typical parallel lanes: Rust financial owner; web/product owner; data/tests/benchmark or metadata owner. See FIRST-WAVE.md for the four exact independent assignments; rotate the fourth through the three implementation slots. Shared API DTOs, libs/core/types, worker protocol, run service and SQL registry serialize when they overlap—even if task lock names differ.

Failed integration

Leave task in review/blocked with explicit failing combined test and owner. Preserve worktree and artifacts. No status “done except integration.” Paper/live state is never used as an integration fixture.