Skip to content

feat(workers): dispatch one continuous task (M4-R7-01) - #340

Merged
mergify[bot] merged 6 commits into
mainfrom
codex/m4-r7-01-dispatch-once
Oct 4, 2026
Merged

mergify[bot] merged 6 commits into
mainfrom
codex/m4-r7-01-dispatch-once

Conversation

@Cuarroc

@Cuarroc Cuarroc commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Der Scheduler kann jetzt genau eine fällige Aufgabe sicher bis zum Worker-Start führen.
Ohne das nur in Tests erzeugbare Permit bleibt der Produktionspfad deaktiviert.
Die bestehenden Continuous-Schalter und Fähigkeiten bleiben unverändert aus.

Report

What changed

  • Added a production-compiled, non-looping dispatch_once core behind an opaque SchedulerPermit.
  • Selects one admitted due task, delegates dependency/attempt/capacity enforcement to the existing atomic claim admission, checks the assigned profile against the attested route, records one durable run intent and role-bound token reservation, then calls the trusted launcher exactly once.
  • Returns named refusal phases for snapshot, route, admission, intent and launch failures.
  • Added one FakeAgents success test proving one fake launch and one durable launched run intent. No store/, main.rs or api.rs seam was changed.

Evidence

  • Base observed after fetch at start: f48af09; PR feat(workers): persist fenced delivery results (W1-03f-a) #301 merge commit is an ancestor.
  • Red: cargo test --manifest-path src-tauri/Cargo.toml --bin projecta workers::tests::dispatch_once_launches_one_admitted_task_with_one_durable_intent -- --exact — exit 101 (NoDueTask stub).
  • Green: same targeted command — exit 0, 1 passed.
  • cargo test --manifest-path src-tauri/Cargo.toml --bin projecta workers::tests::dispatch_once_launches_one_admitted_task_with_one_durable_intent -- --list — exit 0, exact test name confirmed.
  • bash scripts/ci/red-first.sh --plan — exit 0; BASE=f48af09e48d26ec8ad27dcaa4bc21870e046a7d3, code HEAD=d9e0b85ad95361324eb6500ffcb5bb422bb661b9.
  • bash scripts/ci/gates.sh lane prepush at final HEAD — exit 0; 1741 Rust tests passed, 7 skipped; log: /tmp/projecta-m4-r7-01-prepush.log.
  • Final SHA: fa811dc; git ls-remote matched it.
  • Diff size from the recorded base: 150 added lines across three wk-lane files plus the required activity handoff.
  • Architecture drift: the gate reported no new occurrences; no allowlist change was needed.

NICHT ABGEDECKT

  • Linux does not compile or run the #[cfg(windows)] tests or Windows clippy arms; the Windows lane runs in the merge queue.
  • No GUI or live provider process was launched.
  • The production SchedulerPermit constructor and scheduler loop remain deferred to W4-03 after user approval.
  • The full refusal matrix remains M4-R7-02; this package intentionally includes only the positive dispatch path.

Review

Review: Stufe-B-Reviewer Claude (Sonnet 5.5) erledigt; Tier-A-Zweitreview durch den Orchestrator weiter ausstehend.

Open points

  • Coordinator must arrange the two independent Tier A reviews.
  • M4-R7-02 must add the negative FakeAgents matrix before matrix row 7 is complete.

Review disposition

Reviewer: Claude (Sonnet 5.5, Stufe B, andere Familie als Autor codex). Kandidat fa811dc, Fix-Kopf 187669e, Merge-Kopf 62bd1ea (main eingemerged, Konflikt gelöst, prepush exit 0, CI grün).

  • F1 mittel, accepted (187669e): scheduler.rs — scheitert die Token-Reservierung nach Claim und Intent, blieb der Run als unlaunchter intent mit laufendem Claim liegen (Launch-Fehler dagegen gehen über with_launch_reconciliation auf reconciling). Fix: Run wird auf reconciling gesetzt. Test-First: dispatch_once_retains_intent_for_reconciliation_when_token_reservation_fails (rot: left "intent", grün danach). Evidence: cargo test ... workers::tests::dispatch_once_ exit 0, 2 passed; gates.sh lane prepush exit 0; red-first.sh --plan exit 0.
  • F2 niedrig, follow-up (M4-R7-02): Auswahl nimmt die erste offene Aufgabe; hat sie unerfüllte Abhängigkeit oder anderes Profil, wird verweigert statt die nächste zu versuchen (Head-of-Line). Gehört zur Verweigerungsmatrix M4-R7-02; ohne Schleife/Permit in Produktion nicht erreichbar.
  • Architecture drift: kein zweites Muster; nutzt Store-Methoden und launch_worker, Drift-Gate ohne neuen Fund.

Test-First: src-tauri/src/workers.rs::dispatch_once_launches_one_admitted_task_with_one_durable_intent

Co-Authored-By: OpenAI Codex (GPT-5) <47299143+Cuarroc@users.noreply.github.com>
Test-First: src-tauri/src/workers.rs::dispatch_once_launches_one_admitted_task_with_one_durable_intent

Co-Authored-By: OpenAI Codex (GPT-5) <47299143+Cuarroc@users.noreply.github.com>
No-Test: session handoff journal only

Co-Authored-By: OpenAI Codex (GPT-5) <47299143+Cuarroc@users.noreply.github.com>
@Cuarroc
Cuarroc marked this pull request as ready for review October 4, 2026 17:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T18:00:37.255420Z fa811dc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa811dcc60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/workers/scheduler.rs Outdated
Comment on lines +80 to +82
.reserve_development_tokens(&task.goal_id, &run.id, purpose, tokens, Some(&run.id))
.await
.map_err(DispatchRefusal::Admission)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Roll back the claim when pre-launch admission fails

When token reservation is refused—for example because the root budget is exhausted or the estimate exceeds the 200,000-token limit—the claim and run intent above have already committed, so this returns with the task still running, an unresolved intent run, and no launch row. Subsequent dispatch_once calls only select open tasks, startup reconciliation only handles runs that have launch rows, and lease expiry cannot safely authorize reclaiming the task; make claim/intent/reservation atomic or explicitly resolve and release this known-not-started attempt before returning.

AGENTS.md reference: AGENTS.md:L128-L130

Useful? React with 👍 / 👎.

Comment on lines +43 to +47
task.status == "open"
&& context.goals.iter().any(|goal| {
goal.id == task.goal_id
&& goal.status == "open"
&& goal.admitted

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip blocked tasks when selecting the next dispatch

When the first open task has an incomplete dependency—for example, its prerequisite is already running—while a later independent task is runnable, this predicate still selects the blocked task. claim_continuous_task then returns dependency is not completed without changing its state, so every subsequent call selects the same task and the independent work is starved; if the dependency failed or was cancelled, the project stalls indefinitely. Select a task whose dependencies are complete or continue past task-local admission refusals.

Useful? React with 👍 / 👎.

@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

Cuarroc and others added 3 commits October 4, 2026 20:10
…rvation fails

Test-First: src-tauri/src/workers.rs::workers::tests::dispatch_once_retains_intent_for_reconciliation_when_token_reservation_fails

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
No-Test: generated documentation snapshot

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify mergify Bot added the queued label Oct 4, 2026
@mergify mergify Bot mentioned this pull request Oct 4, 2026
11 tasks done
@mergify
mergify Bot merged commit 939c7e9 into main Oct 4, 2026
11 checks passed
@mergify
mergify Bot deleted the codex/m4-r7-01-dispatch-once branch October 4, 2026 19:04
@mergify

mergify Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 26 minutes 45 seconds in the queue, including 14 minutes 38 seconds running CI.

Required conditions to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant