Skip to content

[T-074b] Interaction confirmation orchestration: enqueue confirm runs and update mode #134

Closed

Description

@CodewithJha

Task T-074b · Milestone M6 — Analysis + risk · Size S · Priority P1 · Epic #6

Implements FR-ANA-005

Branch feat/t-074b-interaction-confirmation-orchestration-enqueue-runs — one task = one branch = one PR (doc 32 §6)

Summary

Application service runner/confirmations.py: on request (API :confirm-interaction) or automatically for top modes, enqueue planned scenarios as runs (phase=confirm, tag confirm, priority 10), wait for completion, call conclude, persist failure_modes.interaction.

Context / motivation

Confirmatory runs must be excluded from strategy comparison metrics (doc 09 §6) and must not disturb the strategy's history.

Scope

In scope

  • Confirm runs excluded from RunRepo.history used by strategies.
  • Event mode.discovered/campaign.updated on update.
  • Optional auto-confirm of the top-N modes after final analysis (analysis.interaction.auto_confirm_top_n, new, default 0 = off).

Implementation guidance

  • Application service roboprobe/runner/confirmations.py: class ConfirmationService: def request(self, campaign_id: UUID, mode_id: UUID) -> list[UUID] (enqueue, returns run ids) and def on_run_finished(self, run: RunRecord) -> None (called from the orchestrator tick; concludes when all confirm runs for a mode are terminal).
  • Enqueue via RunQueue.enqueue(..., phase=RunPhase.CONFIRM, priority=settings.runner.confirm_priority) (new key, default 10 — same mechanism as manual runs).
  • Exclusion: RunRepo.history(campaign_id, exclude_phases={CONFIRM, MANUAL}) is what strategies and metrics consume — add the parameter if T-011a lacks it (coordinate via its owner, append-only change).
  • Persist failure_modes.interaction JSON (verdict) and emit mode.discovered-style campaign.updated event through the outbox (T-011c).
  • Idempotency: a second request while confirmations are pending returns the existing run ids.
  • Budget: confirm runs do not count against the campaign budget (doc 09 §6) but do count in worker utilisation metrics.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • runner.confirm_priority (new)
  • analysis.interaction.auto_confirm_top_n (new)

Acceptance criteria

  • Integration test on k2d: GT-A canonical mode confirmed as interaction ×3.
  • Confirm runs excluded from strategy history and MET metrics (test with S-RANDOM campaign).
  • Duplicate request is idempotent.
  • Mode row updated and event emitted on conclusion.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/integration/analysis/test_confirmations.py.
  • Integration with Testcontainers Postgres + inline worker.

Dependencies

Blocked by: #133 (T-074a), #85 (T-041a)

Blocks: no other task (leaf)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/runner/confirmations.py

Independent module.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-074b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 09 §6 · doc 12 §2 · doc 11 §3 · doc 05 §9

Requirements: FR-ANA-005 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:analysisFailure clustering, SHAP, rules, interactionsarea:runnerQueue, workers, campaign orchestrationmilestone:M6M6 — Analysis + riskpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions