Skip to content

(CODUX-183) Execute gated wakeups - #2666

Merged
numnx merged 1 commit into
feature/CODUX-183-scheduler-wakeups-and-guidancefrom
task/feature-codux-183-scheduler-wakeups-and-guidance-t03-codex-mrap9bw4
Jul 7, 2026
Merged

(CODUX-183) Execute gated wakeups#2666
numnx merged 1 commit into
feature/CODUX-183-scheduler-wakeups-and-guidancefrom
task/feature-codux-183-scheduler-wakeups-and-guidance-t03-codex-mrap9bw4

Conversation

@numnx

@numnx numnx commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

🧩 Task: Execute gated wakeups

Automated task PR opened by Code UX for T03.

📋 Summary

Sprint: Sprint 183 · Scheduler Wakeups and Guidance · Task: T03

Extend scheduler wakeups so project-manager chat workers can schedule delayed follow-up messages that fire only after the originating invocation has completed, and update project-manager guidance to use that capability for sensible delayed follow-ups.

🤖 Model & Provider

Provider Codex CLI
Model gpt-5.5

⏱️ Timing

Started 2026-07-07 13:43:17 UTC
Finished 2026-07-07 13:49:20 UTC
Duration 6m 3s

📊 Token Usage

Metric Value
Input tokens 98,613
Cached input tokens 1,486,592
Output tokens 12,626
Total tokens 1,597,831
Invocations 1
Tool calls 49
Active time 4m 53s

Included usage estimate (subscription/local login): $1.62

✅ QA Review

⏳ QA review runs after this PR is opened. Check the task card in the dashboard for the outcome once it lands.

📝 Full Task Prompt
## Objective
Update scheduler execution so wakeup entries post through the chat runtime after their due time, but defer if they are gated on an invocation that has not completed yet.

## Scope
- src/services/scheduler-service.ts
- src/app/dependency-factory/dashboard-factory.ts
- tests/backend/services/scheduler-service.test.ts
- src/repositories/execution-repository.ts only if type imports or public methods are needed for existing `getExecutionInvocation`

## Implementation Requirements
1. Add `executionRepository?: ExecutionRepository` to `SchedulerServiceDeps` and wire `coreDeps.executionRepository` into the `SchedulerService` constructor in `dashboard-factory.ts`.
2. Before `markRunSucceeded` in `runDueEntries`, detect wakeup entries with `wakeupTarget.resumeAfterInvocationCompletion !== false` and a `sourceInvocationId`; if the execution repository reports the invocation is missing or has status other than `completed`, skip execution and leave the entry `scheduled` with its existing due `nextRunAt`.
3. For a source invocation with terminal non-completed status (`failed`, `cancelled`, or `paused` if treated as terminal by existing invocation contracts), mark the wakeup failed with a clear `lastError` instead of posting stale follow-up text.
4. Add wakeup execution to `executeEntry` so it calls `ChatThreadRuntimeService.postMessage` with `bodyMarkdown`, optional thread/title/connection fields, and metadata including `source: "scheduler"`, `schedulerEntryId`, `scheduledFor`, `targetType: "wakeup"`, and `sourceInvocationId` when present.
5. Keep the current in-flight guard, due-entry recheck, recurrence advancement, and one-time completion behavior intact for all target types.
6. Add service tests for immediate ungated wakeups, gated wakeups deferred while the source invocation is running, gated wakeups posting after completion, and failed/cancelled source invocations marking the wakeup failed.

## Constraints
- Do not mark a gated wakeup succeeded before it actually posts to chat.
- Do not busy-loop by creating new entries or mutating `nextRunAt` on every deferred tick.
- Do not block or delay unrelated due scheduler entries when one gated wakeup is waiting.
- Preserve current behavior that successful one-time entries become `completed` and recurring entries advance via `computeNextRunAfterOccurrence`.

## Verification
- `pnpm exec vitest run tests/backend/services/scheduler-service.test.ts`
- `pnpm run lint`
- Success means due wakeups post through the chat runtime only when allowed, deferred wakeups remain scheduled, and existing sprint/quicksprint/chat scheduler tests still pass.
🌿 Branch Info

Base: feature/CODUX-183-scheduler-wakeups-and-guidance
Head: task/feature-codux-183-scheduler-wakeups-and-guidance-t03-codex-mrap9bw4


🤖 Generated by Code UX

@numnx
numnx merged commit d5ae612 into feature/CODUX-183-scheduler-wakeups-and-guidance Jul 7, 2026
6 checks passed
@numnx
numnx deleted the task/feature-codux-183-scheduler-wakeups-and-guidance-t03-codex-mrap9bw4 branch July 7, 2026 13:51
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