Repository navigation
[3479 by Claude Opus 5.5] Defer jobs whose agent is at its ceiling instead of holding a worker, and charge the actual direct agent - #3497
Conversation
…had already finished. No test failed because of this change, so my earlier summary stands.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds early capacity checks, queue deferral, synthetic-member selection, and timeline reporting across the main job types. It needs changes before merge because the new pre-check can prevent recovery of abandoned capacity holders. ✅ Preserved retry budget — Deferrals use ✅ Separated capacity failures — Provider replacement and synthetic failover explicitly exclude capacity refusals. ✅ Useful waiting state — Repeated deferrals update one timeline entry with aliases, count, and retry time. The supplied current-head status has no failures and five pending checks. This review is static; no commands or tests were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Allow abandoned holders to reach recovery
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe implementation has substantial coverage and clear integration across job types, but the abandoned-holder recovery regression can indefinitely stall an alias. Correct that path before merge and confirm the pending checks complete successfully. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 2cf21c7
Summary of ChangesI fixed F1: a job whose agent's holder died is no longer deferred forever. It now gets through to admission, which recovers the dead holder and then runs the job. Cause. The capacity pre-check counted every holder record for the alias. A holder whose lease had expired, or one already marked Fix (in
New test in
With the old pre-check put back, this test fails while the other five in the file pass. Verification:
One unrelated flaky test: in one of three There's no visual preview because nothing in the UI changed. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ferred forever. It now gets through to admission, which recovers the dead holder and then runs the job. I fixed F1: a job whose agent's holder died is no longer deferred forever. It now gets through to admission, which recovers the dead holder and then runs the job. **Cause.** The capacity pre-check counted every holder record for the alias. A holder whose lease had expired, or one already marked `recovering`, still counted, so every job for that alias was deferred before it reached the admission loop. That loop is the only place recovery runs, so nothing could ever free the slot. **Fix** (in `packages/core/src/agents/agentCapacity.ts`): - **New read-only helper.** `agentAdmissionAliasOccupancy` splits each alias's holders into `live` and `recoverable` (lease expired, or `recovering`). It uses Redis server time, the same clock the admission script uses to expire leases. - **Pre-check counts only live holders.** If a job only meets recoverable holders, it goes on to the normal acquire. That calls `recover`, which removes the recorded container before releasing the holder, so a slot is still never reused until removal is confirmed. If removal fails, the slot stays held, as before. - **The two other callers get the same rule.** Synthetic routing goes through the same pre-check. The wake-up on release (`wakeAgentCapacityWaiters`) now counts only live holders when working out free slots, so a woken job can be the one that does the recovery. - **No change to the admission script.** `agentRunAdmission.ts` is untouched; I moved the helper out of it because it pushed the file over the 400-line lint limit. - **Docs.** `docs/docs/architecture/agent-run-admission.md` now explains the live-holder rule for the pre-check and the wake-up. **New test** in `test/agentCapacityDeferral.test.ts`, run against a real Redis 7.4.1 and BullMQ: 1. A holder on a ceiling-1 alias "dies": its lease renewal never completes and it never calls `finish()`. 2. A job for that alias is deferred while the holder is still live, and the wake-up finds no free slot. 3. After the lease expires, the holder record is still there, but the pre-check reports room and the wake-up promotes the waiting job. 4. The job runs. The dead container is removed before the job's own container is created, it used one attempt, and its deferral data is cleared. 5. A later job for the same alias runs without being deferred, and no holder records are left. With the old pre-check put back, this test fails while the other five in the file pass. **Verification:** - `agentCapacityDeferral` passed 6/6 three times in a row. - Related suites pass: `agentRunAliasAdmission` (10), `agentRunAdmission` (27), `reviewCapacityRouting` (2), and core's `syntheticRoutingCapacity` and `syntheticRoutingService` (19). - Typecheck (root and core) and `eslint --max-warnings 0` on the core agents directory are clean. One unrelated flaky test: in one of three `agentRunAdmission` runs, "caller deadline during create removes the ID without starting it" timed out at 15 s. It forks worker processes, doesn't depend on any file I changed, and passed 4 more times in a row both with and without this fix. There's no visual preview because nothing in the UI changed. PR: #3497 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Full Test Suite Shard 1/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 3c25389 Summary of ChangesI fixed the Shard 1/4 failure. It was a test mock that hadn't been updated for a new import on this branch, not a bug in the code. Cause. One test failed: Fix. I added simple stand-ins for those two functions to the mock. Verification.
I didn't run these two files with the old mock to watch them fail locally; the CI error is what points to the missing exports. I also ran eslint on both files, but it printed only an npm notice, so I can't confirm the lint check passed. There's no visual preview because nothing in the UI changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…'t been updated for a new import on this branch, not a bug in the code. I fixed the Shard 1/4 failure. It was a test mock that hadn't been updated for a new import on this branch, not a bug in the code. **Cause.** One test failed: `executor and native goal admission retain create and final argument secrets` in `packages/core/test/managedDiagnostics.test.ts`. It replaces `agentRunAdmission.ts` with a mock that only provides `prepareAdmittedAgent`. The last commit made `agentCapacity.ts` import `agentAdmissionKeys` and `resolveAgentRunAdmission` from that module. With the mock in place, the native-goal path failed to load with `does not provide an export named 'agentAdmissionKeys'`. **Fix.** I added simple stand-ins for those two functions to the mock. `agentAdmissionKeys` returns the three instance keys and `resolveAgentRunAdmission` returns `null`. `test/nativeGoalLaunchBoundary.test.ts` mocks the same module in the same partial way, so I added the same two stand-ins there too. No source code changed. **Verification.** - `packages/core/test/managedDiagnostics.test.ts`: all 33 tests pass, including the one that failed in CI. - `test/nativeGoalLaunchBoundary.test.ts`: all 11 tests pass. I didn't run these two files with the old mock to watch them fail locally; the CI error is what points to the missing exports. I also ran eslint on both files, but it printed only an npm notice, so I can't confirm the lint check passed. There's no visual preview because nothing in the UI changed. PR: #3497 Comment by: @propr-dev[bot] (ID: 6830744846) Model: Claude Opus 5.5
|
CI failed: Full Test Suite Shard 4/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 63a3ba5 Summary of ChangesI fixed the Shard 4/4 failure. Like the Shard 1 failure, it came from a test mock that didn't match a new import on this branch, not from a bug in the deferral logic. Cause. Two files failed before running any tests: Fix. I changed the source rather than the mocks. The wake-up code now uses Verification.
I didn't rerun the full shard locally, and nothing ran against real Docker. There's no visual preview because nothing in the UI changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
… came from a test mock that didn't match a new import on this branch, not from a bug in the deferral logic. I fixed the Shard 4/4 failure. Like the Shard 1 failure, it came from a test mock that didn't match a new import on this branch, not from a bug in the deferral logic. **Cause.** Two files failed before running any tests: `test/checkRunHandler.test.ts` and `test/followupAssignmentGate.test.ts`. Both replace `bullmq` with a mock that only provides `ErrorCode`, `Queue`, `QueueEvents` and `Worker`. This branch's `packages/core/src/agents/agentCapacity.ts` imports `Job` from `bullmq` to wake jobs waiting for capacity, so loading it failed with `The requested module 'bullmq' does not provide an export named 'Job'`. **Fix.** I changed the source rather than the mocks. The wake-up code now uses `queue.getJob(jobId)`, which returns the same job (or nothing) as `Job.fromId(queue, jobId)`, and the `Job` import is gone. Three more root suites (`commentEventHandler.ultrafix`, `mergeConflictDetector`, `deliveryInterestHandlerGuard`) mock `bullmq` the same way, so this covers all of them without editing five test files. Only `agentCapacity.ts` changed. **Verification.** - `checkRunHandler` (145 tests) and `followupAssignmentGate` (51 tests) both pass now, as do the other three suites with the same mock. Two of those first failed with read-only `/tmp/git-processor` errors, which this container is known for. With the clone paths moved to a writable directory, they pass. - I ran `agentCapacityDeferral` against a real Redis 7.4.1 I built locally, with Redis marked as required so it couldn't skip. Its 6 tests cover the `getJob`/`promote` wake path and pass. The related suites pass too: `syntheticRoutingCapacity`, `processAgentRunJob`, `processGoalJob`, `reviewCapacityRouting` and `taskSubmissionLifecycle`. - The core typecheck reports no errors, and `eslint --max-warnings 0` passes on the changed file. I didn't rerun the full shard locally, and nothing ran against real Docker. There's no visual preview because nothing in the UI changed. PR: #3497 Comment by: @propr-dev[bot] (ID: 6831323136) Model: Claude Opus 5.5
|
CI failed: Full Test Suite Shard 4/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit fe7c57b Summary of ChangesI fixed the Shard 4/4 failure. It was a test that left a database connection open, not a problem in the deferral logic. What failed. In Cause. Two of the tests this branch added, "a lost race at admission…" and the resumed run in "an import stopped while it waited…", call the real Fix. The test's Verification.
There's no visual preview because nothing in the UI changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
Full Test Suite ResultsValidation failed during: Test shard (shard 4).
View shard 4/4 outputDetails truncated; see the uploaded artifacts for complete failure rows and logs. |
|
CI failed: Run Full Test Suite Please investigate and fix this CI failure.
Failure evidence
|
…tabase connection open, not a problem in the deferral logic. I fixed the Shard 4/4 failure. It was a test that left a database connection open, not a problem in the deferral logic. **What failed.** In `test/processTaskImportJobRetry.test.ts`, all 10 tests passed, but the test process never exited. The runner killed it at its 180s limit and marked the file as failed. **Cause.** Two of the tests this branch added, "a lost race at admission…" and the resumed run in "an import stopped while it waited…", call the real `cleanupWorktree` and ask it to delete the worktree. Before deleting, it checks whether the worktree is still in use. It asks Docker first, and if Docker answers it then queries the database (`packages/core/src/db/connection.js`). Loading that module opens a SQLite connection, and nothing in this test closed it. In CI Docker answers, so the connection opened and kept the process alive. In this container there is no `docker`, so the check stopped before reaching the database, which is why the file passed when run here. **Fix.** The test's `after()` hook now closes the connection (`closeConnection()`) before removing its temp directory. Other suites (`followupHandoffWorktreeRestore.integration`, `llmLoggerPersist`) already do the same. Only that one test file changed. **Verification.** - **CI condition reproduced:** I put a stub `docker` on PATH that reports no running containers. Before the fix, the file hung until a 30s timeout killed it. After the fix it exits in about 3.5s with 10 passed and 0 failed, and the log shows the database query that CI ran. - **No Docker (this container's default):** still 10 passed and 0 failed, about 3.5s. - **Not run:** I didn't rerun the full shard. There's no visual preview because nothing in the UI changed. PR: #3497 Comment by: @propr-dev[bot] (ID: 6831943225) Model: Claude Opus 5.5
|
ℹ️ Analyzed the follow-up request by @propr-dev[bot], @github-actions[bot] Analysis SummaryI made no code changes. The failure was reported on commit What failed: In shard 4, Checked again here, with a stand-in
I didn't run the full shard locally. The next CI run on No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds queue-level capacity deferral while retaining atomic container admission as the enforcement boundary. It needs a localized correction before merge: changing a job’s refused aliases leaves stale waiter registrations that can repeatedly divert wakeups. ✅ Preserves retry budgets — Deferral moves the same job to delayed and throws ✅ Handles abandoned holders — The pre-check distinguishes live holders from recoverable holders, allowing admission recovery to reclaim abandoned capacity. ✅ Broad validation coverage — Tests cover worker release, claim boundaries, synthetic routing and timeline updates. All supplied current-head checks passed or were skipped. This review used static tracing only, as requested. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F2: 🔴 Remove obsolete alias waiter registrations
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Reuse capacity snapshotsCapacity-aware routing can open a Redis connection and scan the entire holder hash separately for each capped alias; direct reservations also perform a second check. Consider sharing a connection and occupancy snapshot within one advisory pre-check. This is an optional efficiency improvement because authoritative admission already handles changes after the snapshot. ScoreThe implementation has substantial coverage and green current-head checks, but the waiter-membership defect undermines the new release-triggered scheduling behavior. The correction is localized. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit f074fb7
Summary of ChangesI fixed F2. When a re-entered job's refusal stops naming an alias, the job now leaves that alias's waiting list, so released capacity goes to the jobs that still wait for it. Changes:
Tests: I added one integration test to
The test fails on the old code with either half of the fix reverted on its own, so each half is covered. Verification:
No visual preview, since nothing visible changed. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
… alias, the job now leaves that alias's waiting list, so released capacity goes to the jobs that still wait for it. I fixed F2. When a re-entered job's refusal stops naming an alias, the job now leaves that alias's waiting list, so released capacity goes to the jobs that still wait for it. **Changes:** - **`persistAgentCapacityDeferral`** (`src/jobs/agentCapacityDeferral.ts`): once the new refusal is saved, the job leaves the waiting lists of aliases its previous refusal named and this one doesn't. In the review example from the finding, the review now leaves A's list when only B blocks it. It keeps its original place on B's list. - **`wakeAgentCapacityWaiters`** (`packages/core/src/agents/agentCapacity.ts`): before a waiter uses up a wakeup slot, the wakeup checks which aliases the job's last saved refusal named. If the job is delayed and no longer waits for this alias, its entry is removed and the slot goes to the next waiter. This catches leftover entries, for example if the removal above failed, since that removal is best effort. - **The window you asked about:** a job that isn't delayed may still be in the middle of joining a new alias's list, with its saved data still naming the old aliases. The wakeup skips such a job without counting it but doesn't remove its entry, because removing it would wrongly take the job off a list it just joined. Nothing is missed: right after joining, the job checks capacity itself and schedules a quick retry if the alias has room. That window is avoidable, so I closed it. The remaining overlap between a release and a job joining a list is the race the existing capacity check already covers. - **Related bug, same mistake:** when saving the refusal failed, the old code removed the job from every alias the refusal named. That included lists the job was legitimately on from its previous refusal, whose data was still saved. Now it removes only the lists this attempt newly joined. **Tests:** I added one integration test to `test/agentCapacityDeferral.test.ts`, run against a real Redis and BullMQ queue. It enables a second ceiling, `remote-llama=1`, and covers: - a review blocked on both aliases joins both lists. - a failed save keeps both entries. - re-deferring on remote-llama alone leaves local-llama's list but keeps its place on remote-llama's. - a local-llama wakeup drops an older leftover review entry, keeps the entry of a job that isn't delayed (without counting it), and wakes the real local-llama waiter. The test fails on the old code with either half of the fix reverted on its own, so each half is covered. **Verification:** - The capacity suite passes 7/7. - The related suites pass: alias admission 10, review capacity routing 2, agent run 71, agent action 35, PR publication 30, merge conflict 24, task import retry 10, task submission lifecycle 30. - `tsc` is clean for the root and for `packages/core`, and `eslint --max-warnings 0` is clean on both changed source files. To clear a nesting-depth warning I moved the alias check into a small `waitsFor` helper. No visual preview, since nothing visible changed. PR: #3497 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds queue deferral, capacity-aware routing, and timeline visibility, but needs corrections before merge. ✅ Preserved retry budgets — Capacity refusals move the same BullMQ job to delayed and throw ✅ Pre-claim checks — Goal and automation processors check capacity before taking durable execution claims. ✅ Focused coverage — Added tests cover real Redis/BullMQ deferral, wake-ups, recovery, and synthetic selection. Current-head test suites pass; Validate Changes remains pending. This review uses static analysis of the supplied code; no commands were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F3: 🔴 Valid alias can become permanently saturated
F4: 🔴 Capacity checks prevent generation reconciliation
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe implementation has substantial focused coverage, but two capacity-precheck defects can prevent queued work from progressing. Both admit localized corrections. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 34ba12d
Summary of ChangesI fixed F3 and F4. Before the fix I ran a probe against the old code, and it reproduced both problems: an agent named F3: an alias named
|
| Command | Description | Example |
|---|---|---|
/merge |
Merge target branch into this PR and resolve conflicts | /merge |
/review |
Request an AI code review | /review or /review claude-sonnet |
/fix |
Address review blockers, or blockers and suggestions with /fix all |
/fix, /fix all, or /fix F3 S5 |
/switch |
Change the AI model for this PR | /switch claude-opus |
/use |
Override the model for a single follow-up run | /use claude-sonnet |
/ultrafix |
Loop review→fix cycles until score goal is met | /ultrafix or /ultrafix goal=8 max=10 |
🤖 Generated by ProPR
… old code, and it reproduced both problems: an agent named `constructor` stayed full after its holder released, and a newer-generation job was turned away by a live older holder. With the fix, both checks give the right answer.
I fixed F3 and F4. Before the fix I ran a probe against the old code, and it reproduced both problems: an agent named `constructor` stayed full after its holder released, and a newer-generation job was turned away by a live older holder. With the fix, both checks give the right answer.
### F3: an alias named `constructor`
- **Occupancy** is now a `Map`, so looking up `constructor` only finds what was actually stored there. The occupancy function also returns a different shape now: `{ aliases: Map, reconciliationPending }` (`packages/core/src/agents/agentCapacity.ts`).
- **Same bug elsewhere in this PR's code, fixed:**
- `agentAdmissionAliasHolders` counted holders in a plain `{}` and could produce a garbage value for `constructor`. It now counts in a `Map`.
- **Ceiling lookup:** a direct agent called `constructor` *without* a ceiling inherited `Object` as its ceiling, so the pre-check always said it was full. Both the pre-check and the admission script's lookup now go through a new `agentRunAliasCeiling` helper that only reads listed entries. The parser also builds the limits in a `Map`.
- **Refusal messages:** they printed `(limit function Object() { [native code] })`, including on the task timeline. Both message builders now only show ceilings that were actually set (`AgentCapacityError` and `refusalReason` in `src/jobs/agentCapacityDeferral.ts`).
### F4: a newer generation reaching reconciliation
- The occupancy script now reads the stored admission configuration in the same Redis call as the holders. It reports when the stored generation is older than the caller's.
- In that case the pre-check counts no holders, so the job gets through to the acquire. Fencing and draining stay where they were: the acquire's recovery step marks the old holders, removes their containers, and only then admits.
- The wake-up after a release uses the same rule. A newer-generation process now wakes a waiter even while older holders are still live.
- **Unchanged cases:**
- An older process whose generation has been superseded still counts holders normally.
- A different limit at the same generation still counts normally. The acquire rejects that mismatch anyway.
- An unreadable stored configuration counts normally and is left for the acquire to reject.
- **Callers covered:** direct-agent jobs, synthetic member selection and the deferral retry path all go through `agentAliasHasCapacity`, so the one fix covers them.
### Tests and docs
- **New test file** `test/agentCapacityAliasOccupancy.test.ts`, using a real Redis, real BullMQ and the real admission script. It has 3 tests:
- `constructor` with a ceiling of 1: full while held, free again after release; also checks that no shared prototype was changed.
- `constructor` without a ceiling: not capped, and refusal messages are clean.
- A newer-generation job meets a live, renewing older-generation holder: it isn't deferred, either in the pre-check or through `checkJobAgentCapacity`. An old-generation job is still deferred. The new acquire removes the old container before creating its own.
- A waiter is woken by a newer-generation release but not by an older one.
- **Results:** the 3 new tests fail on the old code and pass with the fix. Related suites (alias admission, global admission including the generation upgrade/downgrade cases, repository workflow admission, deferral, native goals, review routing, synthetic routing) also pass: 129 tests, 0 skipped.
- `tsc` passes for the root project and for `packages/core`, and `eslint --max-warnings 0` passes on the changed files.
- I updated `docs/docs/architecture/agent-run-admission.md` to describe the generation rule and the new occupancy signature.
There's no visual change, so I didn't create a preview.
PR: #3497
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds queue deferral for saturated agents, shared backoff and timeline handling, and capacity-aware synthetic routing. It needs a localized correction before merge. ✅ Preserved retry budget — Capacity refusals unwind through ✅ Recovery-aware checks — The occupancy check allows admission to recover expired holders and reconcile older generations, avoiding permanent deferral behind abandoned capacity. The supplied current-head status has no failures and two pending checks. This review used static analysis only; no commands or tests were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F5: 🔴 Fence paused goals before capacity checks
SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Exercise usage-based capacity selectionThe new synthetic-routing suite constructs round-robin pools throughout, although ScoreThe implementation has substantial targeted coverage and sound recovery handling, but paused-goal deliveries need to bypass capacity deferral. Current checks show no failures, with two still pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 9275199
Summary of ChangesI fixed F5. A paused or cancelled goal's delivery now goes straight to the claim fence and is retired at once, even while its agent is still full. It also leaves the agent's waiting list. The fix ( The finding names only paused goals; the same change also covers these other cases the claim would reject:
Regression tests ( Verification:
Similar code checked (no change needed): I looked at the other places that check capacity before starting work: agent report/action runs, task import, issue jobs, PR comment jobs and merge-conflict jobs. Each checks whether the work is still valid (run state, task cancellation or labels) before the capacity check, so none can be delayed indefinitely this way. Their early exits don't remove waiting-list entries either. That is harmless: when an agent frees up, the wake-up step drops entries for finished jobs without using up the wake-up. No visual preview: this change doesn't affect anything a user can see. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…straight to the claim fence and is retired at once, even while its agent is still full. It also leaves the agent's waiting list. I fixed F5. A paused or cancelled goal's delivery now goes straight to the claim fence and is retired at once, even while its agent is still full. It also leaves the agent's waiting list. **The fix** (`src/jobs/goalCapacity.ts`): before checking capacity, `checkGoalAgentCapacity` now applies the same conditions `claimGoalAttempt` uses. The goal must still match this attempt and have no result, have `desired_state === 'running'`, and have `claimed_at` unset. If any of these fails, it skips the capacity check and calls `admitAgentCapacity(job)`. That clears the stored wait counters and removes the job from every alias waiting list it joined. The claim then returns `goal_claim_fence` without another delay. The finding names only paused goals; the same change also covers these other cases the claim would reject: - **Cancelled goals:** they hit the same bug as paused ones and were delayed again. - **Already-claimed attempts:** the claim rejects these too, but the old code still delayed them. - **Superseded attempts:** the old code already returned early here, but it never removed the waiting-list entries. That is the cleanup part of the "minimum correction". **Regression tests** (`test/processGoalJob.test.ts`): one case each for paused, cancelled, superseded and already-claimed. Each uses a real database, the real `checkGoalAgentCapacity` and `claimGoalAttempt`, and a stub capacity Redis where `codex=1` stays fully held. The first delivery is delayed and joins the `codex` waiting list. After the goal changes, the next delivery returns `goal_claim_fence`, is not delayed again, leaves the list, and has its stored wait data cleared. **Verification:** - **Old code:** all four new tests fail. Paused, cancelled and already-claimed are delayed again; superseded hits the fence but stays on the waiting list. - **Fixed code:** the whole of `processGoalJob.test.ts` passes (23/23). - **Lint and typecheck:** `goalCapacity.ts` passes eslint with `--max-warnings 0`, and `tsc --noEmit` is clean. - **Not run:** the Redis-backed `agentCapacityDeferral.test.ts`, because this container has no `redis-server`. **Similar code checked (no change needed):** I looked at the other places that check capacity before starting work: agent report/action runs, task import, issue jobs, PR comment jobs and merge-conflict jobs. Each checks whether the work is still valid (run state, task cancellation or labels) before the capacity check, so none can be delayed indefinitely this way. Their early exits don't remove waiting-list entries either. That is harmless: when an agent frees up, the wake-up step drops entries for finished jobs without using up the wake-up. No visual preview: this change doesn't affect anything a user can see. PR: #3497 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds queue deferral for saturated agents, shared capacity-wait bookkeeping, synthetic routing support, and timeline visibility. It needs a localized correction before merge. ✅ Worker release — Capacity refusals unwind processing and use ✅ Recovery-aware checks — Expired holders and older admission generations can reach authoritative admission for recovery instead of remaining blocked by the pre-check. ✅ Current validation — The supplied current-head checks pass, including all four test shards; the earlier timeout is no longer a current failure. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F6: 🔴 Preserve import wait state through admission
SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Test consecutive import admission racesAdd a regression using the real capacity bookkeeping across two import deliveries. Assert that a second admission refusal preserves the pin and original waiting timestamp and increments the deferral count. This would strengthen coverage beyond the current mocked processor-path test. ScoreThe implementation has substantial coverage and passing current checks, but the import retry path loses durable routing and waiting state. A localized lifecycle correction should make it merge-ready. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 7232813
Summary of ChangesThe monitor timed out after the batch had already finished, so I don't need to restart it. All 28 related suites passed, and my summary above still holds. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
… so I don't need to restart it. All 28 related suites passed, and my summary above still holds. The monitor timed out after the batch had already finished, so I don't need to restart it. All 28 related suites passed, and my summary above still holds. PR: #3497 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR moves saturated-agent jobs back into the queue, preserves their retry budgets, and adds capacity-aware synthetic routing and timeline reporting. Merge-ready within the reviewed scope, conditional on the pending Validate Changes check. ✅ Preserved admission authority — Pre-checks remain advisory; physical admission still enforces capacity and recovers expired or older-generation holders. ✅ Durable deferral coverage — Added tests exercise real Redis/BullMQ deferrals, worker release, wake-ups, cancellation, and synthetic selection persistence. Review was limited to static analysis of the supplied code; no commands or tests were run. Current-head checks report no failures, including successful completion of all four test shards. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S4: 🟢 Exercise prompt-dependent synthetic eligibilityAdd coverage connecting S5: 🟢 Consolidate Redis test fixturesThe new integration suites repeat Redis startup, connection, and teardown helpers. A shared fixture would reduce maintenance and keep timeout and cleanup behavior consistent. This is optional test infrastructure cleanup. ScoreThe implementation has substantial targeted coverage and no verified merge blocker in the supplied code. Current-head test results are successful; one validation check remains pending. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3479
Branch:
3479/claude-opus-5-5-defer-jobs-whose-agent-is-20261112-1539-3bsCommits: ✅ Changes committed (0cfaca1)
AI Processing Completed
Execution Details:
Summary:
The monitor only expired; it doesn't need re-arming, since the batch had already finished. No test failed because of this change, so my earlier summary stands.
Detailed Logs:
ddd90f9b-7015-4a78-9bce-df6651bb8687Log files stored at:
/usr/src/app/logs/executions/issue-3479-2026-11-12T16-41-13-936Z-conversation.json/usr/src/app/logs/executions/issue-3479-2026-11-12T16-41-13-936Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3479.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!
Visual preview
Waiting for Agent Capacity timeline row
Task details at 1440px for an issue deferred four times because its direct agent local-llama is at its per-agent ceiling: one waiting row, updated in place, with the alias, the deferral count and the next retry time
Connect sign-in required. Original retained until 2027-02-10T16:41:19.293Z.
View the full-resolution original in ProPR Connect