Skip to content

[3480 by Claude Opus 5.5] Define how executions started by a running parent are charged, so a ceiling of one cannot deadlock - #3514

Merged
integry merged 5 commits into
3478-epic-per-agent-9uvfrom
3480/claude-opus-5-5-define-how-executions-sta-20261112-2255-lfx
Nov 13, 2026
Merged

integry merged 5 commits into
3478-epic-per-agent-9uvfrom
3480/claude-opus-5-5-define-how-executions-sta-20261112-2255-lfx

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3480

Branch: 3480/claude-opus-5-5-define-how-executions-sta-20261112-2255-lfx
Commits: ✅ Changes committed (04e8a0d)


AI Processing Completed

Execution Details:

Summary:
I've implemented nested-execution admission. A nested execution is now charged under its parent's slot instead of waiting for it, so a global limit or agent ceiling of one no longer deadlocks. The new real-Redis, multi-process suite and the related existing suites pass. There's one intermittent failure, noted below.

The rule (enforced in the admission script)

  • Global limit: a nested execution never takes a global slot; it is covered by its parent's slot, whichever agent runs it. So a global limit of one with one nested level always admits the child.
  • Same agent as the parent: charged under the parent's reservation, with no second slot of that agent.
  • Different agent: counts against that agent's ceiling and waits for it like any launch.
  • Bounds: depth is 1. At most PROPR_AGENT_RUN_NESTED_LIMIT (1–32, default 4) nested executions run under one parent at once. Going over either bound is refused at once with a clear error, never queued under the parent's slot. An invalid value stops the API and worker at startup.
  • Physical containers: because of this, the container count can exceed the global limit, up to limit × (1 + nested limit). On Hosted, that means more containers than the entitlement.
  • Parent finishes first: its container is removed, but its slot stays charged until its last nested execution ends, and no new nested execution can join it.
  • Parent crashes, loses its lease, or is reconciled to a new generation: its nested executions are fenced with it. Their containers are removed before the parent's, and the slot isn't reused until all are gone.

Which paths use which rule

Path Rule How the parent is identified
Tasks an orchestrating goal starts while its session runs Charged under the goal The goal container gets PROPR_PARENT_EXECUTION, a value derived from the goal ID that stays the same across attempts. The orchestrate instructions ask the agent to put a hidden <!-- propr-parent-execution: … --> line in each issue it creates. The dispatcher copies it into the task's job data.
Semantic search_repository_files called by an automation run Charged under the run The worker registers the run's MCP grant as the parent; the API recognises that grant on the caller.
Auxiliary executions inside one job Normal slot None run while the main container is alive; they all run before or after it.

No path needed the reject-at-startup fallback. Diagnostics now report draining and nested counts, a per-parent list of nested executions (agentAdmissionNestedHolders), and logs that mark nested admissions. With no parent link, admission decisions and holder records are unchanged.

Limitations of the goal path:

  • It depends on the agent adding the marker. An issue without it is an ordinary task that needs its own slot, as before.
  • The marker is visible to anyone who can read the issue. A copied marker can only charge work under that goal while its session is live, within the count bound.
  • Only issue tasks are covered. PR follow-ups a goal triggers through comments (/fix, reviews) still take normal slots.

Tests

  • New suite test/agentRunNestedAdmission.test.ts: 8 tests, all passing. It covers every case in the acceptance criteria (same agent, other agent's ceiling, parent crash, both bounds, global limit of one), plus lease-loss fencing. With the parent link turned off, the three multi-process cases hang as expected, so the tests do catch the deadlock.
  • Parent-link tests added to the goal job, dispatcher, automation run and MCP search suites. The MCP one fails when the link is removed.
  • Existing suites: the admission, per-agent, deferral, goal and dispatcher suites, the MCP suites, and the suites that mock @propr/core all pass, as do lint (zero warnings) and tsc on root, core and API.
  • Three existing tests needed a one-line fix. They pick the script's operation out by argument position, and it moved by one because the script now takes a third Redis key.
  • One intermittent failure: the newer-generation test in test/agentCapacityAliasOccupancy.test.ts failed 2 of about 11 runs on my branch, then passed 6 in a row. It relies on a 600 ms lease that must keep renewing during the check. I couldn't link it to this change, but I also didn't check how often it fails on the base branch.
  • Not done: no live Fleet acceptance; I updated step 3 of the acceptance checklist in the doc to cover nesting.

Docs: a new "Nested executions" section in agent-run-admission.md, plus goals.md, the configuration reference, the regenerated settings page, the settings catalog and .env.example. No preview, since nothing visual changed.

Detailed Logs:

  • Conversation: 284 messages
  • Session: 0fdb3d7f-e1bc-4682-9c8a-526457cd4e1d

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3480-2026-11-12T23-42-39-291Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3480-2026-11-12T23-42-39-291Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've implemented nested-execution admission. A nested execution is now charged under its parent's slot instead of waiting for it, so a global limit or agent ceiling of one no longer deadlocks. The new...


This PR was created automatically by ProPR after processing issue #3480.


💡 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!

…w charged under its parent's slot instead of waiting for it, so a global limit or agent ceiling of one no longer deadlocks. The new real-Redis, multi-process suite and the related existing suites pass. There's one intermittent failure, noted below.

The rule (enforced in the admission script)
- Global limit: a nested execution never takes a global slot; it is covered by its parent's slot, whichever agent runs it. So a global limit of one with one nested level always admits the child.
- Same agent as the parent: charged under the parent's reservation, with no second slot of that agent.
- Different agent: counts against that agent's ceiling and waits for it like any launch.
- Bounds: depth is 1. At most `PROPR_AGENT_RUN_NESTED_LIMIT` (1–32, default 4) nested executions run under one parent at once. Going over either bound is refused at once with a clear error, never queued under the parent's slot. An invalid value stops the API and worker at startup.
- Physical containers: because of this, the container count can exceed the global limit, up to `limit × (1 + nested limit)`. On Hosted, that means more containers than the entitlement.
- Parent finishes first: its container is removed, but its slot stays charged until its last nested execution ends, and no new nested execution can join it.
- Parent crashes, loses its lease, or is reconciled to a new generation: its nested executions are fenced with it. Their containers are removed before the parent's, and the slot isn't reused until all are gone.

Which paths use which rule

| Path | Rule | How the parent is identified |
| --- | --- | --- |
| Tasks an orchestrating goal starts while its session runs | Charged under the goal | The goal container gets `PROPR_PARENT_EXECUTION`, a value derived from the goal ID that stays the same across attempts. The orchestrate instructions ask the agent to put a hidden `<!-- propr-parent-execution: … -->` line in each issue it creates. The dispatcher copies it into the task's job data. |
| Semantic `search_repository_files` called by an automation run | Charged under the run | The worker registers the run's MCP grant as the parent; the API recognises that grant on the caller. |
| Auxiliary executions inside one job | Normal slot | None run while the main container is alive; they all run before or after it. |

No path needed the reject-at-startup fallback. Diagnostics now report `draining` and `nested` counts, a per-parent list of nested executions (`agentAdmissionNestedHolders`), and logs that mark nested admissions. With no parent link, admission decisions and holder records are unchanged.

Limitations of the goal path:
- It depends on the agent adding the marker. An issue without it is an ordinary task that needs its own slot, as before.
- The marker is visible to anyone who can read the issue. A copied marker can only charge work under that goal while its session is live, within the count bound.
- Only issue tasks are covered. PR follow-ups a goal triggers through comments (`/fix`, reviews) still take normal slots.

Tests
- New suite `test/agentRunNestedAdmission.test.ts`: 8 tests, all passing. It covers every case in the acceptance criteria (same agent, other agent's ceiling, parent crash, both bounds, global limit of one), plus lease-loss fencing. With the parent link turned off, the three multi-process cases hang as expected, so the tests do catch the deadlock.
- Parent-link tests added to the goal job, dispatcher, automation run and MCP search suites. The MCP one fails when the link is removed.
- Existing suites: the admission, per-agent, deferral, goal and dispatcher suites, the MCP suites, and the suites that mock `@propr/core` all pass, as do lint (zero warnings) and `tsc` on root, core and API.
- Three existing tests needed a one-line fix. They pick the script's operation out by argument position, and it moved by one because the script now takes a third Redis key.
- One intermittent failure: the newer-generation test in `test/agentCapacityAliasOccupancy.test.ts` failed 2 of about 11 runs on my branch, then passed 6 in a row. It relies on a 600 ms lease that must keep renewing during the check. I couldn't link it to this change, but I also didn't check how often it fails on the base branch.
- Not done: no live Fleet acceptance; I updated step 3 of the acceptance checklist in the doc to cover nesting.

Docs: a new "Nested executions" section in `agent-run-admission.md`, plus `goals.md`, the configuration reference, the regenerated settings page, the settings catalog and `.env.example`. No preview, since nothing visual changed.
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=10
Triggered automatically by the requested execution settings.

@propr-dev propr-dev Bot added the ultrafix label Nov 12, 2026
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 10)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds explicit parent links and atomic Redis admission for nested executions, with substantial integration coverage. It needs changes before merge: one recovery path can indefinitely block an agent after its nested execution crashes.

✅ Atomic admission rules — The Lua acquire operation checks parent liveness, nesting bounds, and alias charges together.

✅ Cross-process coverage — The new tests exercise both Docker wrappers, parent crashes, nesting limits, and draining reservations using real Redis.

The supplied current-head status has no failed checks; five remain pending. This review used static analysis only, as requested.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Recover crashed children of draining parents

  • Required behavior: Crashed nested executions must remain recoverable, and retained parent reservations must eventually release after their children stop.

  • Evidence: packages/core/src/agents/agentCapacity.ts, occupancy script; packages/core/src/agents/agentRunAdmissionScript.ts, expired and release.

    1. Configure one direct alias with ceiling 1. Admit a parent and a same-alias nested execution; the child receives shared = true.
    2. The parent completes while the child runs. Its reservation becomes draining, its scope is removed, and its container is removed.
    3. The child's worker dies without calling finish(). Its deadline expires, but its holder remains until an admission attempt performs recovery.
    4. An ordinary queued job on that alias runs the capacity pre-check. The occupancy script records the expired child in parents, excludes that child from occupancy because it is shared, and counts the draining parent as live because a child record exists.
    5. The alias therefore appears full, and the job defers before reaching physical admission. Every subsequent retry repeats the same classification.

    The alias remains unavailable indefinitely when subsequent demand consists of these queued jobs. The draining parent ignores its own deadline, and the expired shared child never contributes a recoverable holder. Recovery is demand-driven inside admission, so neither retries nor lease expiry breaks this cycle. The parent-scope bypass cannot help because normal completion removed that scope.

    static trace: followed the changed occupancy classification through the supplied checkJobAgentCapacity caller and the admission recovery lifecycle. Existing tests cover orderly child completion and recovery initiated directly at admission, but not this pre-check barrier.

  • Minimum fix: Make the capacity pre-check permit a recovery attempt when a draining parent's retained children include expired or recovering holders, while keeping the atomic admission script responsible for preventing premature reuse. Add a regression covering parent completion, shared-child worker death, and a subsequent queued job on the same alias.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Align the introductory capacity description

The architecture document still opens with an unconditional maximum number of simultaneous containers, while its new nesting section permits up to limit × (1 + nested limit). Qualify the opening description and configuration reference to distinguish top-level reservations from physical containers. This is documentation clarification, not an additional code blocker.

Score

The implementation has strong admission and integration-test coverage, but the demonstrated recovery deadlock prevents merge. Current checks have no reported failures, with five still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 14s
  • Tokens: 75,927 (74,418 in / 1,509 out)
  • Cost: $0.71

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit bb02a90

Addressed 1 AI review comment (IDs: 6839391978)

Addressed finding F1

Summary of Changes

I fixed F1: a crashed nested execution under a finished parent no longer blocks the parent's agent. The next queued job on that agent now goes ahead to admission, which recovers the dead child and then frees the parent's slot.

Cause. The capacity pre-check (OCCUPANCY_SCRIPT in packages/core/src/agents/agentCapacity.ts) treated a finished parent as fully occupied whenever any nested record pointed at it, even if that child's lease had expired. A shared child isn't counted on its own, so nothing on the alias ever looked recoverable. Every job deferred before reaching admission, which is the only place recovery runs.

Fix. The pre-check now marks a parent whose nested executions include one that has expired or is being recovered. Such a finished parent counts as recoverable rather than live, so jobs reach admission instead of deferring. The child's agent doesn't matter here: an expired child on another agent blocked the parent's agent the same way, unless jobs happened to arrive for the child's agent. Admission still decides whether the slot can be reused, and it was already correct: it fences the expired child, removes its container, and hands back the parent's slot only after the last child is released. The wake-up path (wakeAgentCapacityWaiters) uses the same count, so it now wakes waiters in this situation too.

Regression test. Two new real-Redis cases in test/agentCapacityAliasOccupancy.test.ts, one with the child on the parent's agent (shared) and one with it on a different agent. Each case:

  1. Finishes the parent while the child is still running, so the parent is left draining and the agent still reads as full.
  2. Expires the child's lease without calling finish(), standing in for a dead worker.
  3. Sends an ordinary queued job through checkJobAgentCapacity and checks it is not deferred.
  4. Checks that its admission removes the child's container before creating its own, and that only the new holder is left.

Both cases fail on the previous code at the pre-check step and pass with the fix.

Verification. I built Redis 7.2.5 from source, since the container has none.

  • Run one file at a time, with no skips: agentCapacityAliasOccupancy (5 tests), agentRunNestedAdmission (8), agentRunAliasAdmission (10), agentRunAdmission (27) and agentCapacityDeferral (7) all pass.
  • Running the four other files in one command gave two failures in agentCapacityDeferral. That file passes 7/7 alone, with and without the fix, so the failures come from running the files together.
  • The intermittent newer-generation test the PR already mentions failed once in my first run (before my new tests, which run after it) and then passed 5 runs in a row.
  • eslint --max-warnings 0 on the core file and tsc --noEmit for core pass.

No visual preview, since nothing visual changed.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 8m 26s
  • Tokens: 1,413,083 (1,402,461 in / 10,622 out)
  • Cost: $0.81
  • Subscription usage: Weekly +1%, Fable +1%

View Task Execution


💡 ProPR Slash Commands
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

…ent no longer blocks the parent's agent. The next queued job on that agent now goes ahead to admission, which recovers the dead child and then frees the parent's slot.

I fixed F1: a crashed nested execution under a finished parent no longer blocks the parent's agent. The next queued job on that agent now goes ahead to admission, which recovers the dead child and then frees the parent's slot.

**Cause.** The capacity pre-check (`OCCUPANCY_SCRIPT` in `packages/core/src/agents/agentCapacity.ts`) treated a finished parent as fully occupied whenever any nested record pointed at it, even if that child's lease had expired. A shared child isn't counted on its own, so nothing on the alias ever looked recoverable. Every job deferred before reaching admission, which is the only place recovery runs.

**Fix.** The pre-check now marks a parent whose nested executions include one that has expired or is being recovered. Such a finished parent counts as recoverable rather than live, so jobs reach admission instead of deferring. The child's agent doesn't matter here: an expired child on another agent blocked the parent's agent the same way, unless jobs happened to arrive for the child's agent. Admission still decides whether the slot can be reused, and it was already correct: it fences the expired child, removes its container, and hands back the parent's slot only after the last child is released. The wake-up path (`wakeAgentCapacityWaiters`) uses the same count, so it now wakes waiters in this situation too.

**Regression test.** Two new real-Redis cases in `test/agentCapacityAliasOccupancy.test.ts`, one with the child on the parent's agent (shared) and one with it on a different agent. Each case:
1. Finishes the parent while the child is still running, so the parent is left draining and the agent still reads as full.
2. Expires the child's lease without calling `finish()`, standing in for a dead worker.
3. Sends an ordinary queued job through `checkJobAgentCapacity` and checks it is not deferred.
4. Checks that its admission removes the child's container before creating its own, and that only the new holder is left.

Both cases fail on the previous code at the pre-check step and pass with the fix.

**Verification.** I built Redis 7.2.5 from source, since the container has none.
- Run one file at a time, with no skips: `agentCapacityAliasOccupancy` (5 tests), `agentRunNestedAdmission` (8), `agentRunAliasAdmission` (10), `agentRunAdmission` (27) and `agentCapacityDeferral` (7) all pass.
- Running the four other files in one command gave two failures in `agentCapacityDeferral`. That file passes 7/7 alone, with and without the fix, so the failures come from running the files together.
- The intermittent newer-generation test the PR already mentions failed once in my first run (before my new tests, which run after it) and then passed 5 runs in a row.
- `eslint --max-warnings 0` on the core file and `tsc --noEmit` for core pass.

No visual preview, since nothing visual changed.

PR: #3514
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Full Test Suite Shard 3/4

Please investigate and fix this CI failure.

  • Check: Full Test Suite Shard 3/4
  • Result: failure
  • Commit: bb02a90d03d2 (bb02a90d03d2ea889eb114cbe461edff5ead0738)
  • Details: View CI failure

Failure evidence

.github:11
Process completed with exit code 1.

.github:34720
Process completed with exit code 1.

.github:2
Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced to run on Node.js 24: actions/checkout@11d5960. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 4ee2b85

Summary of Changes

I fixed the Shard 3/4 failure. packages/core/test/nativeLogAdmission.test.ts now passes locally, 10 of 10 tests; it had failed 4 of them in CI.

Cause: this branch added a third Redis key (the parents key) to the admission script. That moved the operation name (acquire, release, expired) one position later in the arguments to client.eval. The mocked eval in this suite still read the operation from the old position. So it never saw acquire, and the test that checks one container was created got 0 instead of 1. I missed this suite when I made the same one-line fix in three other suites earlier on the branch.

Fix: in all four mocked eval functions in that file, I added a _parents argument before op so the operation is read from the right place. No production code changed.

I only ran this one suite locally, not the full Shard 3/4 job. I checked the other tests that mock the admission script (test/agentRunAliasAdmission.test.ts and test/agentCapacityDeferral.test.ts); they were already updated.

There's no visual change, so I didn't make a preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 4m 6s
  • Tokens: 467,317 (465,563 in / 1,754 out)
  • Cost: $0.34

Undo Changes • View Task Execution


💡 ProPR Slash Commands
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
Processing comment ID: 6839795528✓

…gAdmission.test.ts` now passes locally, 10 of 10 tests; it had failed 4 of them in CI.

I fixed the Shard 3/4 failure. `packages/core/test/nativeLogAdmission.test.ts` now passes locally, 10 of 10 tests; it had failed 4 of them in CI.

**Cause:** this branch added a third Redis key (the parents key) to the admission script. That moved the operation name (`acquire`, `release`, `expired`) one position later in the arguments to `client.eval`. The mocked `eval` in this suite still read the operation from the old position. So it never saw `acquire`, and the test that checks one container was created got 0 instead of 1. I missed this suite when I made the same one-line fix in three other suites earlier on the branch.

**Fix:** in all four mocked `eval` functions in that file, I added a `_parents` argument before `op` so the operation is read from the right place. No production code changed.

I only ran this one suite locally, not the full Shard 3/4 job. I checked the other tests that mock the admission script (`test/agentRunAliasAdmission.test.ts` and `test/agentCapacityDeferral.test.ts`); they were already updated.

There's no visual change, so I didn't make a preview.

PR: #3514
Comment by: @propr-dev[bot] (ID: 6839795528)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds explicit parent scopes, atomic nested admission, and lifecycle accounting to prevent parent–child capacity deadlocks. It needs changes before merge because local parent cleanup does not preserve the promised child-first fencing and removal behavior.

✅ Atomic admission rules — The Redis script checks nesting depth, child count, and different-agent ceilings within the same acquire operation.

✅ Focused integration coverage — The added tests exercise real Redis and separate processes, including global-limit-one admission and crash recovery.

The supplied current-head status has no failed checks and two pending checks. This review is based on static tracing; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F2: 🔴 Preserve child-first cleanup on local lease loss

  • Required behavior: When a parent loses its lease, its nested executions must be fenced with it and their containers removed before the parent’s container.

  • Evidence: packages/core/src/agents/agentRunAdmission.ts, finish; packages/core/src/agents/agentRunAdmissionScript.ts, fence.

    1. A parent has a running nested execution in another process. The parent loses its lease while the child continues renewing its own lease.
    2. The parent execution unwinds into finish() through the standard Docker caller’s finally, before another admission attempt performs recovery.
    3. With the parent’s Redis deadline expired, fence marks both records recovering.
    4. finish() immediately calls runtime.remove(id) for the parent. It neither removes nor waits for the nested container. The subsequent parent release returns zero because the child record remains.
    5. The child can continue executing until its own renewal observes the fence or a separate admission attempt recovers it. Thus physical child work survives removal of its lease-lost parent.

    The child-first ordering in recover() protects externally initiated recovery only; local finish() bypasses that ordering. Refusing the parent’s release protects capacity reuse, but does not enforce container-removal order. The supplied lease-loss test initiates recovery through a replacement admission, so it does not cover this path.

    static trace: The changed fence branch, unconditional parent removal in finish(), and supplied dockerExecutor.ts cleanup caller establish this sequence.

  • Minimum fix: When local cleanup fences a parent and its children, remove and release the fenced children before removing the parent. Preserve the separate normal-completion draining behavior, and add a regression exercising local lease-loss cleanup without a replacement admission driving recovery.

Suggestions

These are optional follow-ups and are not sent to /fix.

S2: 🟢 Reconcile capacity documentation

The architecture introduction and configuration catalog still describe the global limit as a maximum simultaneous container count, although nested containers can exceed it. Updating these summaries to distinguish charged slots from physical containers would make the documented operational impact clearer. The detailed nested-execution section already explains the behavior, so this is documentation cleanup rather than a merge blocker.

Score

The admission rules and integration coverage are substantial, but a parent lease-loss cleanup path violates the new lifecycle contract. Current checks report no failures, with two still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 57s
  • Tokens: 79,395 (77,150 in / 2,245 out)
  • Cost: $0.77

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F2 S2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit f892027

Addressed 1 AI review comment (IDs: 6840210876)

Addressed finding F2

Summary of Changes

I fixed F2. When a parent loses its lease, its own process now removes the nested containers before the parent's container, and releases them before the parent's slot. It no longer depends on another admission attempt running recovery.

Cause: the fence operation marked the nested records recovering but didn't say which they were. So finish() removed only the parent's container, and the nested container kept running.

The fix

  • fence reply (packages/core/src/agents/agentRunAdmissionScript.ts): when it fences a parent, it now returns {1, nested token, nested container ID, …} for every nested execution under that parent. The draining reply (2) for normal completion while nested executions still run is unchanged.
  • New fenceAndStop() helper (packages/core/src/agents/agentRunAdmission.ts): it fences, removes each nested container, then removes the parent's. finish() then releases the nested reservations before the parent's. If any nested removal fails, it throws: the parent's container stays up and every reservation is kept for recovery, the same way recover() behaves.
  • Same problem in the renewal path: when a parent's renewal finds its lease lost, it used to remove only the parent's container straight away, before finish() even ran. It now goes through fenceAndStop() too, so the nested containers go first there as well.
  • One case can't keep the order: if Redis can't be reached, the process can't look up the nested executions, so it removes just the parent's container and keeps every reservation, as before.

Tests (test/agentRunNestedAdmission.test.ts, real Redis)

  • New: "local cleanup of a lease-lost parent removes and releases its nested execution first, without a replacement admission". The parent's lease is expired and its finish() is called directly. The test checks that the nested container is removed first, both reservations are released, and the slot can be used again.
  • New: "a parent whose renewal finds its lease lost stops its nested execution before its own container".
  • Both new tests fail on the previous code (wrong removal order), so they catch the bug.
  • Passing: all 10 tests in the nested suite, plus agentCapacityAliasOccupancy (5), agentCapacityDeferral (7), agentRunAdmission (27), agentRunAliasAdmission (10) and packages/core/test/nativeLogAdmission.test.ts (10). Core lint passes with zero warnings and core tsc passes. To run the Redis suites here, I built Redis 7.4.1 from source in /tmp.

There's no visual change, so no preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 9m 0s
  • Tokens: 1,299,025 (1,286,341 in / 12,684 out)
  • Cost: $0.84

View Task Execution


💡 ProPR Slash Commands
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

…now removes the nested containers before the parent's container, and releases them before the parent's slot. It no longer depends on another admission attempt running recovery.

I fixed F2. When a parent loses its lease, its own process now removes the nested containers before the parent's container, and releases them before the parent's slot. It no longer depends on another admission attempt running recovery.

**Cause:** the `fence` operation marked the nested records `recovering` but didn't say which they were. So `finish()` removed only the parent's container, and the nested container kept running.

**The fix**
- **`fence` reply** (`packages/core/src/agents/agentRunAdmissionScript.ts`): when it fences a parent, it now returns `{1, nested token, nested container ID, …}` for every nested execution under that parent. The draining reply (`2`) for normal completion while nested executions still run is unchanged.
- **New `fenceAndStop()` helper** (`packages/core/src/agents/agentRunAdmission.ts`): it fences, removes each nested container, then removes the parent's. `finish()` then releases the nested reservations before the parent's. If any nested removal fails, it throws: the parent's container stays up and every reservation is kept for recovery, the same way `recover()` behaves.
- **Same problem in the renewal path:** when a parent's renewal finds its lease lost, it used to remove only the parent's container straight away, before `finish()` even ran. It now goes through `fenceAndStop()` too, so the nested containers go first there as well.
- **One case can't keep the order:** if Redis can't be reached, the process can't look up the nested executions, so it removes just the parent's container and keeps every reservation, as before.

**Tests** (`test/agentRunNestedAdmission.test.ts`, real Redis)
- **New:** "local cleanup of a lease-lost parent removes and releases its nested execution first, without a replacement admission". The parent's lease is expired and its `finish()` is called directly. The test checks that the nested container is removed first, both reservations are released, and the slot can be used again.
- **New:** "a parent whose renewal finds its lease lost stops its nested execution before its own container".
- **Both new tests fail on the previous code** (wrong removal order), so they catch the bug.
- **Passing:** all 10 tests in the nested suite, plus `agentCapacityAliasOccupancy` (5), `agentCapacityDeferral` (7), `agentRunAdmission` (27), `agentRunAliasAdmission` (10) and `packages/core/test/nativeLogAdmission.test.ts` (10). Core lint passes with zero warnings and core `tsc` passes. To run the Redis suites here, I built Redis 7.4.1 from source in `/tmp`.

There's no visual change, so no preview.

PR: #3514
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Full Test Suite Shard 4/4

Please investigate and fix this CI failure.

  • Check: Full Test Suite Shard 4/4
  • Result: failure
  • Commit: f892027ffa06 (f892027ffa065d81b8e43284515c86c2118d42af)
  • Details: View CI failure

Failure evidence

.github:11
Process completed with exit code 1.

.github:39089
Process completed with exit code 1.

.github:2
Node.js 20 is deprecated. The following actions target Node.js 20 but are being forced to run on Node.js 24: actions/checkout@11d5960. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR implements explicit parent-linked admission with atomic Redis accounting and bounded nesting. No merge-blocking defect was verified from the supplied diff and caller context. It is merge-ready within the reviewed scope, conditional on the three pending checks completing successfully.

✅ Atomic nested accounting — Parent resolution, depth/count enforcement, global-slot sharing, and different-alias ceiling checks occur in one admission script.

✅ Capacity retained through cleanup — Recovering parents cannot release their reservations while child records remain; draining parents retain capacity until their last child releases.

✅ Relevant integration coverage — The added tests exercise real Redis and multiple processes, including global-limit-one admission, alias sharing, crash recovery, and lease-loss cleanup.

This was a static review; no commands or tests were run. The supplied current-head status reports no failed checks.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S3: 🟢 Exercise interrupted draining cleanup

Add a regression around fenceAndStop() marking a parent draining followed by parent-container removal failing or the worker exiting. Existing tests cover successful draining and crashes before draining, but this intermediate state merits explicit recovery coverage. This is optional additional validation; the supplied code does not demonstrate premature capacity reuse in that sequence.

S4: 🟢 Clarify headline capacity guarantees

Update the opening paragraph and Observability section of docs/docs/architecture/agent-run-admission.md. The opening still describes Hosted limits as maximum simultaneous container counts, while nesting permits more containers; Observability also lists only the older states and keys. The new nesting section explains the behavior correctly, making this a documentation consistency follow-up.

Score

The implementation has substantial, relevant coverage and coherent admission and recovery logic. Static review found no verified blocker; three current-head checks remain pending, and live Fleet acceptance is not established.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 54s
  • Tokens: 80,981 (79,052 in / 1,929 out)
  • Cost: $0.76

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S3 S4

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 13, 2026
@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit d9f55cc

Summary of Changes

I fixed both failures in Shard 4/4. The two files that failed now pass locally, and the related admission suites do too.

Two test files failed in the shard. Both failures were intermittent: the previous commit on this branch passed the full suite.

1. test/agentCapacityDeferral.test.ts (tests 4 and 5): a real bug in the admission code

  • What should happen: when the caller's own timeout ends a wait on an agent's limit, the launch reports a capacity wait (AgentCapacityWaitTimeoutError), not a provider timeout.
  • The bug: that only worked if the timeout fired during the short pause between polls. If it fired during one of the Redis calls or the cancellation check in the same loop, the raw Command timed out after 200ms error got through. That's what CI saw.
  • Why test 5 failed: test 4 failed before releasing its holder, so test 5 found one slot still taken.
  • The fix: the whole wait loop in packages/core/src/agents/agentRunAdmission.ts now reports that timeout as a capacity wait, wherever it lands. The check lives in aliasCapacityWait in packages/core/src/agents/agentCapacity.ts, and the pause uses it too.
  • Proof: I wrote a temporary test that slows Redis eval so the timeout lands inside a Redis call. The old code fails it with exactly the CI error; the fix passes. The suite then passed 7/7 in four runs side by side.

2. packages/core/test/managedDiagnosticsPortability.test.ts: a race in the test itself

  • The cause: the test starts Node child processes with --input-type=module -e. The logger's pretty-printing worker thread inherits that flag and crashes at startup (ERR_INPUT_TYPE_NOT_ALLOWED).
  • Why it usually passed: the child normally still exits 0, after hanging about 10s in the logger's exit flush. On a slow CI host the worker's error arrived first and the child exited 1. The 21.5s CI duration fits: two child processes at about 10s each.
  • The fix: I dropped --input-type. Node 22.12+ (the project's minimum) recognises the scripts as ES modules on its own. The file now passes 14/14, and its run time fell from about 21s to 9s.

Other checks: the nested-admission, per-agent admission, alias-occupancy, task-import capacity-race, native-log admission and synthetic-routing capacity suites all pass. So do tsc and lint (zero warnings) on core. I ran the Redis suites against a Redis server built from source, since none is installed here.

About 22 other test spawns in the repo still pass --input-type=module -e. I only changed the one that failed; the others are open to the same intermittent failure.

There are no previews, since nothing visual changed.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 11m 48s
  • Tokens: 3,023,254 (3,003,528 in / 19,726 out)
  • Cost: $1.37

Undo Changes • View Task Execution


💡 ProPR Slash Commands
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
Processing comment ID: 6840670392✓

…ed now pass locally, and the related admission suites do too.

I fixed both failures in Shard 4/4. The two files that failed now pass locally, and the related admission suites do too.

Two test files failed in the shard. Both failures were intermittent: the previous commit on this branch passed the full suite.

**1. `test/agentCapacityDeferral.test.ts` (tests 4 and 5): a real bug in the admission code**
- **What should happen:** when the caller's own timeout ends a wait on an agent's limit, the launch reports a capacity wait (`AgentCapacityWaitTimeoutError`), not a provider timeout.
- **The bug:** that only worked if the timeout fired during the short pause between polls. If it fired during one of the Redis calls or the cancellation check in the same loop, the raw `Command timed out after 200ms` error got through. That's what CI saw.
- **Why test 5 failed:** test 4 failed before releasing its holder, so test 5 found one slot still taken.
- **The fix:** the whole wait loop in `packages/core/src/agents/agentRunAdmission.ts` now reports that timeout as a capacity wait, wherever it lands. The check lives in `aliasCapacityWait` in `packages/core/src/agents/agentCapacity.ts`, and the pause uses it too.
- **Proof:** I wrote a temporary test that slows Redis `eval` so the timeout lands inside a Redis call. The old code fails it with exactly the CI error; the fix passes. The suite then passed 7/7 in four runs side by side.

**2. `packages/core/test/managedDiagnosticsPortability.test.ts`: a race in the test itself**
- **The cause:** the test starts Node child processes with `--input-type=module -e`. The logger's pretty-printing worker thread inherits that flag and crashes at startup (`ERR_INPUT_TYPE_NOT_ALLOWED`).
- **Why it usually passed:** the child normally still exits 0, after hanging about 10s in the logger's exit flush. On a slow CI host the worker's error arrived first and the child exited 1. The 21.5s CI duration fits: two child processes at about 10s each.
- **The fix:** I dropped `--input-type`. Node 22.12+ (the project's minimum) recognises the scripts as ES modules on its own. The file now passes 14/14, and its run time fell from about 21s to 9s.

Other checks: the nested-admission, per-agent admission, alias-occupancy, task-import capacity-race, native-log admission and synthetic-routing capacity suites all pass. So do `tsc` and lint (zero warnings) on core. I ran the Redis suites against a Redis server built from source, since none is installed here.

About 22 other test spawns in the repo still pass `--input-type=module -e`. I only changed the one that failed; the others are open to the same intermittent failure.

There are no previews, since nothing visual changed.

PR: #3514
Comment by: @propr-dev[bot] (ID: 6840670392)
Model: Claude Opus 5.5
@integry
integry merged commit a48f204 into 3478-epic-per-agent-9uv Nov 13, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant