4.9 KiB
4.9 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec | |
|---|---|---|---|---|---|---|---|
| 03-resolve-and-auto-start | Resolve dependencies and auto-start on unblock | done | 3 |
|
plan.md | ../../specs/tasks/system-design/task-dependencies.md |
Task 03: Resolve Dependencies and Auto-Start on Unblock
Acceptance
- A subscriber reacts to the task-state changes and workflow-step moves that can
make a predecessor resolved, looks up dependents with
ListTasksBlockedBy, and re-evaluates all predecessors of each dependent. - When the last unresolved predecessor of a task resolves successfully,
task.dependencies_resolvedis published with{task_id, resolved_by_task_id}and the dependent is handed toautoStartTaskForStep. No bespoke launch call is added. - A dependent with no
deferred_launchintent unblocks and starts nothing. - A dependent that is not WIP-admitted starts nothing on resolution; its intent survives and the existing WIP promotion path launches it once, later.
- A dependent whose step has no
on_enter: auto_start_agentand no intent unblocks and starts nothing. - Removing the last blocking edge unblocks the task and does not consume its intent or launch it.
- A chain A → B → C, each with an intent, launches each task exactly once in order and never restarts an earlier task.
- Exactly one session is created when dependency resolution and WIP promotion race, guaranteed by the existing atomic deferred-launch/auto-start claim. A claim loser logs and stops; a failed launch restores the claim so the task stays retryable and visibly unstarted.
- Startup reconciliation, running after the existing WIP queue reconciler,
sweeps non-archived tasks that hold a
deferred_launchintent and have edges, and launches those whose predecessors are all resolved. It is bounded and batched so a large graph does not delay readiness, and it is idempotent across repeated runs. - A restart between a predecessor's completion and the dependent's launch yields exactly one session after startup.
cascadeBlockersResolved, Office assignment, andTriggerOnBlockerResolvedwiring are unchanged. WithFeatures.Officetrue and a task eligible under both reactions, exactly one session is created.- Any goroutine this task starts has a single owner with idempotent
Start/Stop, cancels onctx.Done(), and is covered by the package'sgoleakTestMain.
TDD sequence
- Failing test: last-predecessor-resolves publishes
task.dependencies_resolvedonce and launches the dependent exactly once with the intent's recorded agent profile, executor, executor profile, prompt, and plan-mode choice. - Failing test: a non-last resolution publishes nothing and launches nothing.
- Failing test: resolution via a move into a final
Donestep counts, not juststate = COMPLETED. - Failing test: a dependent without an intent unblocks and starts nothing.
- Failing test: a queued (not WIP-admitted) dependent starts nothing on resolution and starts exactly once on later promotion.
- Failing test: removing the last edge unblocks without launching.
- Failing test: A → B → C chain launches each once, in order.
- Failing test: simultaneous resolution and promotion produce one session; the loser logs; a launch failure restores the claim.
- Failing test: restart between completion and launch yields one session after startup reconciliation; a second reconciliation run launches nothing more.
- Failing test: with Office enabled, a task eligible under both reactions gets one session.
- Implement the subscriber, the event, and the startup reconciliation.
Verification
cd apps/backend
go test -tags fts5 ./internal/orchestrator ./internal/task/service ./internal/office/scheduler -run 'Test.*(DependenciesResolved|DependencyChain|AutoStartUnblock|StartupReconcil)' -count=1
go test -tags fts5 -race ./internal/orchestrator ./internal/task/service -count=1
golangci-lint run ./... --new-from-rev=origin/main --timeout=5m
Files likely touched
apps/backend/internal/orchestrator/event_handlers_workflow.goapps/backend/internal/orchestrator/event_handlers_task.goor the equivalent state-change subscriberapps/backend/internal/task/events/(new event type)apps/backend/internal/task/service/service_events.goapps/backend/internal/backendapp/main.go(startup reconciliation ordering)- focused orchestrator and task-service tests
Dependencies
Task 02 — the gate must exist first, otherwise resolution-driven launches would bypass it and the WIP interaction could not be asserted.
Parallelism
sequential
Output contract
Mark this task in_progress before the RED tests and done only after the
listed commands pass. Record which events the subscriber listens to, where
startup reconciliation runs relative to the WIP queue reconciler, its batch
bound, and the race-test mechanism in this file and plan.md.