Skip to content

[T-041a] Scheduler + CampaignLoop.step: propose → enqueue runs (seeds, repeats, budget, idempotent ticks) #85

Closed

Description

@CodewithJha

Task T-041a · Milestone M3 — Oracles + runner + store · Size M · Priority P0 · Epic #3

Implements FR-RUN-001 · FR-RUN-005 · FR-SEL-006 · FR-SEL-007

Branch feat/t-041a-scheduler-campaignloop-step-propose-enqueue — one task = one branch = one PR (doc 32 §6)

Summary

Implement runner/scheduler.py (target_inflight = ceil(min(batch_size, workers) · inflight_factor)) and runner/loop.py CampaignLoop.step() per doc 05 §5.1: load history, strategy.propose(q=free), insert runs in one transaction with seed = derive_seed(campaign_seed, 'run', ordinal, repeat).

Context / motivation

The orchestrator side of the intelligent loop (doc 04 §6, doc 14 §2).

Scope

In scope

  • Budget accounting (runner.count_invalid_in_budget), repeats ≥ 1 with distinct derived seeds, pins applied.
  • History excludes INVALID for learning (FR-SEL-007) but counts them for stop rules.
  • Proposals' rationale persisted into runs.proposal/phase.
  • strategy.proposed log + roboprobe_selector_propose_seconds metric; propose timeout → Sobol fallback + selector.fallback.

Out of scope

  • Checkpointing/leader lock (T-041b)
  • Reaper/stop rules (T-042a/b)
  • Multi-campaign service (T-048)

Implementation guidance

  • Ticks must be idempotent: re-running a tick after a crash never double-enqueues (unique (campaign_id, ordinal, repeat_index), doc 34 §8). Use the in-memory fakes for unit tests and a RandomStrategy fake if T-051a isn't merged yet.
  • 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.tick_interval_s
  • runner.inflight_factor
  • runner.max_batch_size
  • runner.count_invalid_in_budget
  • selection.propose_timeout_s

Acceptance criteria

  • Unit tests with fakes: correct number enqueued for various worker counts/budgets.
  • Two identical campaigns (same seed) enqueue identical scenario sequences (FR-SEL-005).
  • Repeated tick after simulated crash enqueues nothing new.
  • 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/unit/runner/test_scheduler.py, test_campaign_loop.py.

Dependencies

Blocked by: #61 (T-011a), #79 (T-041c), #84 (T-050a)

Blocks: #86 (T-041b), #87 (T-042b), #94 (T-046), #134 (T-074b)

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/scheduler.py
  • backend/src/roboprobe/runner/loop.py

Parallel with worker tasks (different modules).

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-041a (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 05 §5.1 · doc 14 §2 · doc 04 §6 · doc 21 §3 · doc 34 §8

Requirements: FR-RUN-001 · FR-RUN-005 · FR-SEL-006 · FR-SEL-007 (traceability: doc 28)

Activity

  1. added
    area:runnerQueue, workers, campaign orchestration
    priority:P0Critical path / blocks others
    milestone:M3M3 — Oracles + runner + store
    taskChild task of a milestone epic
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:runnerQueue, workers, campaign orchestrationmilestone:M3M3 — Oracles + runner + storepriority:P0Critical path / blocks otherssize:M1-3 daystaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions