Skip to content

[3481 by Claude Opus 5.5] Report admission capacity per agent through REST, MCP and the CLI, and document safe configuration changes - #3519

Merged
integry merged 8 commits into
3478-epic-per-agent-9uvfrom
3481/claude-opus-5-5-report-admission-capacity-20261113-0215-dfv
Nov 13, 2026
Merged

integry merged 8 commits into
3478-epic-per-agent-9uvfrom
3481/claude-opus-5-5-report-admission-capacity-20261113-0215-dfv

Conversation

@propr-dev

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

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3481

Branch: 3481/claude-opus-5-5-report-admission-capacity-20261113-0215-dfv
Commits: ✅ Changes committed (a42569b)


AI Processing Completed

Execution Details:

Summary:
I've added one capacity report for issue #3481. It's served three ways: GET /api/agent-run-admission, the MCP tool get_agent_run_admission, and propr admission (a table, or --json). The new suites pass, and so do the existing admission, capacity and deferral suites, run against a real Redis 7.2 with nothing skipped.

What the report shows

  • Whether admission is on, the global limit and where it comes from (PROPR_AGENT_RUN_LIMIT or the Hosted entitlement), the generation and the nested limit.
  • Globally and per agent: the ceiling, the slots in use, and running work by state (reserved, running, draining, recovering). A holder whose lease expired counts as recovering.
  • Nested executions are counted separately from holders.
  • Waiting work is split into: waiting on the global limit, waiting on the agent's ceiling, recovering, starting, and deferred queue jobs.
  • The other limits, each with a label: queue worker slots in use and in total, and repository workflow slots for repositories with a limit.
  • Subscription usage is left out on purpose; a note in the report says where to read it.
  • With admission off, the report says so and still returns the other limits. If Redis is unreachable or the configuration is invalid, it reports why instead of failing.

Redaction

  • The report never contains tokens, container IDs, the Docker daemon identity, the instance ID or Redis keys; a test checks this.
  • Task IDs: in REST, only for tasks that exist, and none for the read-only demo viewer. In MCP, only for tasks in repositories inside the caller's grant that the repository policy allows. Repository slots are filtered the same way.

How the reasons get recorded

  • Each launch now writes its alias, task ID and wait reason to a new Redis hash beside the waiting set. No admission decision reads it, a failed write is ignored, and the report's read removes entries for launches that have gone.
  • The waiting and admitted log lines now always include agentAlias (null when the launch has no alias) and waitReason. The admitted line also includes waitedMs.

Other acceptance criteria

  • Timeline: the row reads Waiting for agent capacity: <alias> (limit N). If the refusal doesn't carry the ceiling, it is taken from the configuration. A later wait on a different agent or ceiling now starts a new row instead of rewording the old one.
  • Fleet queue status: /api/internal/hosted/queue now adds a deferred count of jobs delayed for agent or repository capacity; retry backoffs are not counted.
  • Operator docs: a new page, docs/docs/operations/agent-run-capacity.md. It covers each limit and how they combine, setting PROPR_AGENT_RUN_ALIAS_LIMITS, raising or lowering ceilings with no drain (running work is never stopped), the global-limit procedure (generation bump, drain first, rollback with a new higher generation), and rolling restarts with mixed versions. I also updated the architecture page, the configuration reference, the CLI page, docs/mcp.md, docs/mcp-coverage.md and the regenerated settings page.
  • Contract checks: the route is registered and documented with a typed schema, and gen:openapi:check and check:client-contract are clean. The settings catalog entry now points to the new tool and command.

Things to know

  • Fleet must read deferred: the field is additive, so Fleet keeps working, but its drain logic has to treat deferred > 0 as pending work. An older API won't send the field, so treat a missing value as unknown, not zero.
  • Repository slots: only repositories with running work under a limit are listed; one with a limit and nothing running doesn't appear.
  • Refactor: I moved the wait-reason handling out of agentRunAdmission.ts into a new agentRunAdmissionWait.ts, to stay within the lint complexity and file-length limits.
  • Failing API typecheck lines: type-checking the two edited hosted-Fleet test files reports errors, but on lines I didn't touch.
  • API tests and the working directory: API test files must be run from the repo root; run from inside packages/api, they hang at exit.

New tests

  • test/agentRunAdmissionSnapshot.test.ts (real Redis): counts under contention, the split of wait reasons, nested executions, recovering holders, deferred-job filtering, redaction, admission off, Redis unreachable.
  • packages/api/test/agentRunAdmissionRoutes.test.ts: task visibility in REST, MCP and for the demo viewer, the disabled case, the error response, and checks against the published schema.
  • packages/cli/src/commands/admissionCommands.test.ts: the table, admission off, and the JSON output.
  • test/agentCapacityTimelineRow.test.ts: the timeline row naming the agent and ceiling.

I didn't create visual previews, since nothing here changes the UI.

Detailed Logs:

  • Conversation: 260 messages
  • Session: 19cf08fe-72f5-4ae4-be71-2070ab5663c4

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3481-2026-11-13T02-53-48-996Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3481-2026-11-13T02-53-48-996Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've added one capacity report for issue #3481. It's served three ways: `GET /api/agent-run-admission`, the MCP tool `get_agent_run_admission`, and `propr admission` (a table, or `--json`). The new su...


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


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

…s: `GET /api/agent-run-admission`, the MCP tool `get_agent_run_admission`, and `propr admission` (a table, or `--json`). The new suites pass, and so do the existing admission, capacity and deferral suites, run against a real Redis 7.2 with nothing skipped.

What the report shows
- Whether admission is on, the global limit and where it comes from (`PROPR_AGENT_RUN_LIMIT` or the Hosted entitlement), the generation and the nested limit.
- Globally and per agent: the ceiling, the slots in use, and running work by state (reserved, running, draining, recovering). A holder whose lease expired counts as recovering.
- Nested executions are counted separately from holders.
- Waiting work is split into: waiting on the global limit, waiting on the agent's ceiling, recovering, starting, and deferred queue jobs.
- The other limits, each with a label: queue worker slots in use and in total, and repository workflow slots for repositories with a limit.
- Subscription usage is left out on purpose; a note in the report says where to read it.
- With admission off, the report says so and still returns the other limits. If Redis is unreachable or the configuration is invalid, it reports why instead of failing.

Redaction
- The report never contains tokens, container IDs, the Docker daemon identity, the instance ID or Redis keys; a test checks this.
- Task IDs: in REST, only for tasks that exist, and none for the read-only demo viewer. In MCP, only for tasks in repositories inside the caller's grant that the repository policy allows. Repository slots are filtered the same way.

How the reasons get recorded
- Each launch now writes its alias, task ID and wait reason to a new Redis hash beside the waiting set. No admission decision reads it, a failed write is ignored, and the report's read removes entries for launches that have gone.
- The waiting and admitted log lines now always include `agentAlias` (null when the launch has no alias) and `waitReason`. The admitted line also includes `waitedMs`.

Other acceptance criteria
- Timeline: the row reads `Waiting for agent capacity: <alias> (limit N)`. If the refusal doesn't carry the ceiling, it is taken from the configuration. A later wait on a different agent or ceiling now starts a new row instead of rewording the old one.
- Fleet queue status: `/api/internal/hosted/queue` now adds a `deferred` count of jobs delayed for agent or repository capacity; retry backoffs are not counted.
- Operator docs: a new page, `docs/docs/operations/agent-run-capacity.md`. It covers each limit and how they combine, setting `PROPR_AGENT_RUN_ALIAS_LIMITS`, raising or lowering ceilings with no drain (running work is never stopped), the global-limit procedure (generation bump, drain first, rollback with a new higher generation), and rolling restarts with mixed versions. I also updated the architecture page, the configuration reference, the CLI page, `docs/mcp.md`, `docs/mcp-coverage.md` and the regenerated settings page.
- Contract checks: the route is registered and documented with a typed schema, and `gen:openapi:check` and `check:client-contract` are clean. The settings catalog entry now points to the new tool and command.

Things to know
- Fleet must read `deferred`: the field is additive, so Fleet keeps working, but its drain logic has to treat `deferred > 0` as pending work. An older API won't send the field, so treat a missing value as unknown, not zero.
- Repository slots: only repositories with running work under a limit are listed; one with a limit and nothing running doesn't appear.
- Refactor: I moved the wait-reason handling out of `agentRunAdmission.ts` into a new `agentRunAdmissionWait.ts`, to stay within the lint complexity and file-length limits.
- Failing API typecheck lines: type-checking the two edited hosted-Fleet test files reports errors, but on lines I didn't touch.
- API tests and the working directory: API test files must be run from the repo root; run from inside `packages/api`, they hang at exit.

New tests
- `test/agentRunAdmissionSnapshot.test.ts` (real Redis): counts under contention, the split of wait reasons, nested executions, recovering holders, deferred-job filtering, redaction, admission off, Redis unreachable.
- `packages/api/test/agentRunAdmissionRoutes.test.ts`: task visibility in REST, MCP and for the demo viewer, the disabled case, the error response, and checks against the published schema.
- `packages/cli/src/commands/admissionCommands.test.ts`: the table, admission off, and the JSON output.
- `test/agentCapacityTimelineRow.test.ts`: the timeline row naming the agent and ceiling.

I didn't create visual previews, since nothing here changes the UI.
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

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

@propr-dev

propr-dev Bot commented Nov 13, 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 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: Validate unsigned linux-arm64 package

Please investigate and fix this CI failure.

  • Check: Validate unsigned linux-arm64 package
  • Result: failure
  • Commit: a42569b6376f (a42569b6376f0fd46f3894908abe57b5820bd3df)
  • Details: View CI failure

Failure evidence

.github:176
Process completed with exit code 1.

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 26ab9c0

Summary of Changes

I've fixed the failure. Nothing in this PR's code caused it. The job's "Audit committed dependency resolution" step blocks on known security advisories, and new ones have been published against two dependency versions in the lockfile. main has the same old versions, so any branch cut from it will fail this check until it gets the same fix.

What the audit flagged:

  • hono 4.13.12: five advisories, all fixed in 4.13.16 or later.
  • @hono/node-server 2.1.5: two advisories, fixed in 2.1.6.

What I changed:

  • package.json: raised the pinned hono version in overrides from 4.13.12 to 4.13.18.
  • package-lock.json: updated only the lock entries for hono (4.13.18) and @hono/node-server (2.1.8). The rest of the lock is unchanged.

Checked locally:

  • npm run audit:runtime and npm run desktop:audit:packaging, the two commands that step runs, both pass now.
  • CI installs with npm 10 (Node 22), and running npm 10 over the new lock leaves it byte-identical.

I didn't add any audit exceptions. There are no visual previews, since nothing here changes the UI.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 6m 52s
  • Tokens: 359,912 (357,911 in / 2,001 out)
  • Cost: $0.32

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: 6842420073✓

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Validate unsigned darwin-arm64 package

Please investigate and fix this CI failure.

  • Check: Validate unsigned darwin-arm64 package
  • Result: failure
  • Commit: a42569b6376f (a42569b6376f0fd46f3894908abe57b5820bd3df)
  • Details: View CI failure

Failure evidence

.github:176
Process completed with exit code 1.

.github:1
Due to capacity constraints, jobs targeting macOS arm64 runners may experience longer queue times.

@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Validate unsigned linux-x64 package

Please investigate and fix this CI failure.

  • Check: Validate unsigned linux-x64 package
  • Result: failure
  • Commit: a42569b6376f (a42569b6376f0fd46f3894908abe57b5820bd3df)
  • Details: View CI failure

Failure evidence

.github:209
Process completed with exit code 1.

…. The job's "Audit committed dependency resolution" step blocks on known security advisories, and new ones have been published against two dependency versions in the lockfile. `main` has the same old versions, so any branch cut from it will fail this check until it gets the same fix.

I've fixed the failure. Nothing in this PR's code caused it. The job's "Audit committed dependency resolution" step blocks on known security advisories, and new ones have been published against two dependency versions in the lockfile. `main` has the same old versions, so any branch cut from it will fail this check until it gets the same fix.

**What the audit flagged:**
- **`hono` 4.13.12**: five advisories, all fixed in 4.13.16 or later.
- **`@hono/node-server` 2.1.5**: two advisories, fixed in 2.1.6.

**What I changed:**
- **`package.json`**: raised the pinned `hono` version in `overrides` from 4.13.12 to 4.13.18.
- **`package-lock.json`**: updated only the lock entries for `hono` (4.13.18) and `@hono/node-server` (2.1.8). The rest of the lock is unchanged.

**Checked locally:**
- `npm run audit:runtime` and `npm run desktop:audit:packaging`, the two commands that step runs, both pass now.
- CI installs with npm 10 (Node 22), and running npm 10 over the new lock leaves it byte-identical.

I didn't add any audit exceptions. There are no visual previews, since nothing here changes the UI.

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

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

ℹ️ Analyzed the follow-up request by @propr-dev[bot]

Analysis Summary

I didn't change any code: both failures are already fixed on the branch's latest commit, 26ab9c0.

Why they failed: the CI report points at commit a42569b. On that run, Validate unsigned darwin-arm64 package, linux-x64 and linux-arm64 all failed at the same step, "Audit committed dependency resolution". That step stops the job when the lockfile pins dependency versions with published security advisories. Here those were hono 4.13.12 and @hono/node-server 2.1.5. darwin-x64 was cancelled.

Already fixed: the follow-up commit 26ab9c0 raised hono to 4.13.18 and @hono/node-server to 2.1.8. At that commit, I ran both commands the step runs, using Node 22 and npm 10 like CI:

  • npm run audit:runtime reported "runtime dependency audit passed."
  • npm run desktop:audit:packaging reported "packaging dependency audit passed."

CI on the latest commit hasn't finished: the Desktop Package and Release run for 26ab9c0 (run 43356307652) was cancelled before the package jobs ran, so it shows no result yet. You'll need to re-run that workflow to get a green result for these checks.

No code changes were necessary based on the current state of the branch.


🤖 Analysis Details

  • Model: Claude Opus 5.5 (medium)
  • Time: 3m 38s
  • Tokens: 274,490 (272,811 in / 1,679 out)
  • Cost: $0.26

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 IDs: 6842424195✓, 6842425504✓

@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 a shared admission report across REST, MCP and CLI, with substantial documentation and focused tests. It needs changes before merge because two deferred-work counting paths can report zero while capacity-deferred jobs remain pending.

✅ Shared reporting implementation — REST and MCP use the same report builder, and the CLI consumes its API response.

✅ Explicit visibility filtering — Task identifiers are filtered against existing tasks and MCP repository permissions; demo responses omit task and repository identifiers.

✅ Admission accounting coverage — Added tests cover contention, nested executions, expired holders and identifier redaction.

This review used static analysis of the supplied code only; no commands were run. Current checks show 34 passed, none failed and one pending.

Merge blockers

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

F1: 🔴 Fleet can miss deferred jobs beyond the scan limit

  • Required behavior: Fleet queue status must identify pending capacity-deferred work so a drain cannot appear complete while that work remains.

  • Evidence: packages/api/routes/queueRoutes.ts:countCapacityDeferredJobs

    1. The delayed queue contains more than 10,000 jobs, with ordinary scheduled or retry-delayed jobs occupying the first 10,000 positions returned by getJobs.
    2. At least one capacity-deferred job occupies a later position.
    3. The new collector stops at DEFERRED_SCAN_LIMIT, finds no matching jobs and returns deferred: 0.
    4. When waiting and active counts are also zero, /api/internal/hosted/queue presents an apparently drained queue despite pending capacity work.

    The fixed scan bound has no completeness indicator or fallback. The assertion in the comment that delayed sets stay small is not an enforced constraint. The added Fleet tests exercise only a short collection.

    static trace: The loop termination and unconditional numeric return demonstrate the undercount. proposed regression: Return 10,000 ordinary delayed jobs followed by one capacity-deferred job and verify that Fleet never receives a definitive zero.

  • Minimum fix: Count the entire delayed set, or explicitly report an incomplete/unavailable result when the bound is reached so Fleet cannot interpret it as zero pending work.

F2: 🔴 Removing a ceiling hides existing deferred jobs

  • Required behavior: The admission report must show currently deferred queue work, including jobs still pending during the documented ceiling-removal procedure.

  • Evidence: packages/core/src/agents/agentRunAdmissionSnapshot.ts:deferredWaiters

    1. An agent with a configured ceiling becomes saturated, and its jobs enter the alias waiter set and BullMQ delayed state.
    2. The operator removes that ceiling and restarts the processes while retaining global admission, as the new operations guide explicitly supports.
    3. Existing jobs remain delayed until their backoff expires, as that guide also documents.
    4. deferredWaiters enumerates only Object.keys(config.aliasLimits ?? {}), so it never reads the removed alias’s waiter set. If the last ceiling was removed, the report immediately returns global deferred: 0 despite those pending jobs.

    Checking job.isDelayed() protects only aliases that are enumerated; it cannot recover the omitted jobs. The new test retains the alias in its configuration throughout, so it does not cover this transition.

    static trace: The configuration-only enumeration, global aggregation and documented removal lifecycle establish the failure. proposed regression: Defer a job, remove its alias ceiling, then read the snapshot before its delay expires.

  • Minimum fix: Discover existing alias waiter sets independently of current ceilings and include their still-delayed jobs, reporting a removed alias’s ceiling as null.

Suggestions

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

S1: 🟢 Verify worker heartbeat freshness

The report sums every member of system:status:workers. The supplied producer refreshes expiry for the entire set and capacity hash, so surviving workers can preserve a crashed worker’s entries. Consider per-worker freshness when reporting live concurrency. This is a follow-up because the heartbeat representation predates this PR.

Score

The implementation has strong shared contracts and useful tests, but deferred-work undercounts undermine its operational purpose. Both blockers appear fixable locally; the pending validation check remains outstanding.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 52s
  • Tokens: 88,669 (87,427 in / 1,242 out)
  • Cost: $0.81

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 F2 S1

🤖 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 c00fa4a

Addressed 1 AI review comment (IDs: 6842951957)

Addressed findings F1, F2

Summary of Changes

I fixed both findings. Each new regression fails on the old code and passes now.

F1: Fleet's deferred count stopped at 10,000 jobs (packages/api/routes/queueRoutes.ts)

  • countCapacityDeferredJobs no longer has a scan limit. It reads every delayed job ID in one call, then loads the jobs 500 at a time. So it always counts the whole delayed set and can't return 0 while a capacity-deferred job is still waiting.
  • The single ID read also closes a gap the old page-by-page scan had. When a job left the delayed set between pages, later jobs moved up a position and could be skipped. Now a job that's gone by the time it's loaded has left the delayed state and is simply not counted.
  • New tests in packages/api/test/queueRoutes.test.ts:
    • 10,000 ordinary delayed jobs followed by one capacity-deferred job. The count must be 1; the old code returned 0.
    • Jobs that vanish between the ID read and the load.
  • I updated the Fleet wiring test's mock queue in hostedFleetRoutesWiring.test.ts to the new read calls.

F2: removing a ceiling hid that agent's deferred jobs (packages/core/src/agents/agentRunAdmissionSnapshot.ts)

  • The report used to check only agents that currently have a ceiling. It now looks up every agent that has a list of jobs waiting for capacity, whether or not it still has a ceiling. An agent whose ceiling was removed stays in the report, with ceiling: null, as long as any of its jobs are still delayed. Once none are, it drops out.
  • A job is counted for an agent only if the job still waits for that agent, using the same rule the wake-up code applies. Without this, a job whose latest refusal names only another agent would be wrongly counted under the removed one. Nothing ever cleans up the waiting list of an agent whose ceiling is gone, so those entries stay there. To share the rule, I exported it from agentCapacity.ts as jobWaitsForAgentCapacity, along with a key-prefix helper.
  • New test in test/agentRunAdmissionSnapshot.test.ts: defer jobs, remove one ceiling and then the last, and read the report before their delay expires. The jobs stay counted globally and per agent until they leave the delayed state. The old code crashed on this test.

I also added three sentences to docs/docs/operations/agent-run-capacity.md describing both behaviours.

Verification

  • The admission snapshot, capacity deferral, alias occupancy and admission route suites ran against a real Redis 7.2 that I built from source: 24 passed, 0 skipped.
  • queueRoutes.test.ts passes, hostedFleetRoutes.test.ts passes, and lint and the core and API type checks are clean.
  • Two tests in hostedFleetRoutesWiring.test.ts fail: "rate-limits requests before Fleet and OAuth authentication" and "omits every hosted route when Fleet control is disabled". Both get a 404 instead of a 401 from /api/internal/hosted/bootstrap. They fail the same way with the branch's original files restored, so this change didn't cause them.

Separate issue I noticed but didn't fix: an agent's waiting-list entries are removed only by the wake-up code or when the job ends. After a ceiling is removed, the wake-up code no longer runs for that agent, so its stale entries stay in Redis. The report now ignores them, but they are never deleted.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 8m 55s
  • Tokens: 2,645,875 (2,628,403 in / 17,472 out)
  • Cost: $1.27

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

… code and passes now.

I fixed both findings. Each new regression fails on the old code and passes now.

**F1: Fleet's `deferred` count stopped at 10,000 jobs** (`packages/api/routes/queueRoutes.ts`)
- `countCapacityDeferredJobs` no longer has a scan limit. It reads every delayed job ID in one call, then loads the jobs 500 at a time. So it always counts the whole delayed set and can't return `0` while a capacity-deferred job is still waiting.
- The single ID read also closes a gap the old page-by-page scan had. When a job left the delayed set between pages, later jobs moved up a position and could be skipped. Now a job that's gone by the time it's loaded has left the delayed state and is simply not counted.
- New tests in `packages/api/test/queueRoutes.test.ts`:
  - 10,000 ordinary delayed jobs followed by one capacity-deferred job. The count must be 1; the old code returned 0.
  - Jobs that vanish between the ID read and the load.
- I updated the Fleet wiring test's mock queue in `hostedFleetRoutesWiring.test.ts` to the new read calls.

**F2: removing a ceiling hid that agent's deferred jobs** (`packages/core/src/agents/agentRunAdmissionSnapshot.ts`)
- The report used to check only agents that currently have a ceiling. It now looks up every agent that has a list of jobs waiting for capacity, whether or not it still has a ceiling. An agent whose ceiling was removed stays in the report, with `ceiling: null`, as long as any of its jobs are still delayed. Once none are, it drops out.
- A job is counted for an agent only if the job still waits for that agent, using the same rule the wake-up code applies. Without this, a job whose latest refusal names only another agent would be wrongly counted under the removed one. Nothing ever cleans up the waiting list of an agent whose ceiling is gone, so those entries stay there. To share the rule, I exported it from `agentCapacity.ts` as `jobWaitsForAgentCapacity`, along with a key-prefix helper.
- New test in `test/agentRunAdmissionSnapshot.test.ts`: defer jobs, remove one ceiling and then the last, and read the report before their delay expires. The jobs stay counted globally and per agent until they leave the delayed state. The old code crashed on this test.

I also added three sentences to `docs/docs/operations/agent-run-capacity.md` describing both behaviours.

**Verification**
- The admission snapshot, capacity deferral, alias occupancy and admission route suites ran against a real Redis 7.2 that I built from source: 24 passed, 0 skipped.
- `queueRoutes.test.ts` passes, `hostedFleetRoutes.test.ts` passes, and lint and the core and API type checks are clean.
- Two tests in `hostedFleetRoutesWiring.test.ts` fail: "rate-limits requests before Fleet and OAuth authentication" and "omits every hosted route when Fleet control is disabled". Both get a 404 instead of a 401 from `/api/internal/hosted/bootstrap`. They fail the same way with the branch's original files restored, so this change didn't cause them.

**Separate issue I noticed but didn't fix:** an agent's waiting-list entries are removed only by the wake-up code or when the job ends. After a ceiling is removed, the wake-up code no longer runs for that agent, so its stale entries stay in Redis. The report now ignores them, but they are never deleted.

PR: #3519
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

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

Overall Evaluation

The PR adds a shared admission report across REST, MCP, and CLI, with substantial tests and operator documentation. It needs minor corrections before merge: unavailable repository data can appear as zero usage, and repository results are silently capped.

✅ Shared report and access filtering — REST and MCP use the same report builder, with task and repository visibility applied before returning identifiers.

✅ Nested occupancy accounting — The tally follows the admission script’s distinction between top-level holders, same-agent nested executions, and nested executions charged against another agent’s ceiling.

✅ Focused integration coverage — Added tests exercise contention, expired holders, removed ceilings, redaction, and real Redis bookkeeping.

This assessment uses static tracing of the supplied code; no commands were run. The authoritative checks show 32 passed, two pending, and no failures.

Merge blockers

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

F3: 🔴 Report unavailable repository usage explicitly

  • Required behavior: Redis failures must report why data is unavailable rather than presenting missing observations as confirmed zero usage.

  • Evidence: packages/core/src/agents/agentRunAdmissionSnapshot.ts, readAgentRunAdmissionSnapshot; packages/cli/src/commands/admissionCommands.ts, formatAdmissionReport.

    1. Admission is disabled and Redis is unreachable—the exact condition covered by the new “admission off with Redis unreachable” test.
    2. The snapshot returns enabled: false and repositoryWorkflowSlots: []. Neither the repository-read catch nor the outer connection-failure catch supplies an unavailability reason for this case.
    3. The report builder preserves that empty list without an availability indicator.
    4. The CLI prints “Repository workflow slots: none in use under a limit,” although repository usage was never successfully observed.

    Operators therefore receive a definitive idle statement during an outage. The same empty-list substitution occurs when repository collection fails independently. Catching errors protects endpoint availability but does not preserve the distinction between unavailable and empty; the existing test explicitly accepts the ambiguous response. static trace: snapshot failure branches → report builder → CLI empty-list rendering.

  • Minimum fix: Carry repository collection availability or an error indicator through the report contract, and render unavailable usage explicitly. Preserve successful empty results as “none in use,” including when admission is disabled.

F4: 🔴 Do not silently omit repository limits

  • Required behavior: The report must accurately list repository workflow usage; incomplete results must not masquerade as a complete inventory.

  • Evidence: packages/core/src/workflow/workflowSlotUsage.ts:37, repositoryWorkflowSlotUsage.

    1. With physical admission disabled, 501 repositories each have a live workflow slot and a positive repository limit. Repository admission is independent per repository, so this state is reachable.
    2. Discovery stops once its accumulated set reaches the default maxRepositories = 500, or completes a scan batch containing more entries.
    3. The subsequent .slice(0, maxRepositories) guarantees that at most 500 repositories are evaluated.
    4. REST, MCP, and CLI return the resulting list without a truncation marker or continuation mechanism. At least one repository’s occupied capacity is absent.

    Filtering does not fix completeness: discovery also includes hashes for uncapped repositories, which consume the bound before positive limits are evaluated. No supplied caller requests additional pages, and the schema has no completeness field. static trace: bounded discovery and slicing → snapshot → report builder → all three presentation surfaces.

  • Minimum fix: Complete discovery for this report, or expose explicit truncation and a continuation mechanism through the report contract and consumers. Do not present a capped result as the complete repository inventory.

Suggestions

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

S2: 🟢 Distinguish configured and stored generation

The snapshot derives the global limit and generation from the API process’s configuration without reading Redis’s stored admission identity. During a rollout, showing both would help operators distinguish desired configuration from the generation currently installed in admission. This is an optional diagnostic improvement; the supplied documentation already requires coordinated configuration changes.

S3: 🟢 Track worker heartbeat freshness

The existing worker producer expires the entire membership set and capacity hash, so surviving workers can keep a crashed worker’s entry alive. The new report inherits that limitation when summing “live” capacity. A follow-up could add per-worker freshness; the underlying heartbeat issue predates this PR.

Score

The implementation is cohesive and well tested, but two reporting paths can give operators incomplete or misleading capacity information. Both require localized corrections; current checks have no reported failures.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 29s
  • Tokens: 93,568 (91,675 in / 1,893 out)
  • Cost: $0.88

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 F3 F4 S2 S3

🤖 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 e8c1f70

Addressed 1 AI review comment (IDs: 6843417139)

Addressed findings F3, F4

Summary of Changes

I fixed both findings. Each new regression fails on the old code and passes now.

F3: unavailable repository usage now says so

  • The snapshot has a new field, repositoryWorkflowSlotsUnavailable. It is set whenever repository usage could not be read from Redis: in the per-read catch and in the outer connection-failure catch. A successful read that finds nothing leaves it unset, whether admission is on or off.
  • I found the same defect in a third place, the invalid-configuration branch. It returned repositoryWorkflowSlots: [] without reading Redis at all. It now reads the repository slots like the other branches do, and still reports the configuration error under unavailable.
  • The report contract now has an optional repositoryWorkflowSlots.unavailable in buildAgentRunAdmissionReport, the Zod schema and the CLI types. The OpenAPI spec and client types are regenerated.
  • propr admission now prints Repository workflow slots: unavailable: <reason>. in that case. It prints "none in use under a limit." only when the read succeeded and found nothing.

F4: no repository is dropped

  • repositoryWorkflowSlotUsage now scans until Redis says the scan is finished. I removed maxRepositories and the .slice, so the list is the complete inventory and no truncation marker or paging is needed. The per-repository reads now go in parallel batches of 100.
  • The schema description, the report label and the operator doc now say the list is complete, and the doc explains the new unavailable field.

New tests

  • In test/agentRunAdmissionSnapshot.test.ts, against a real Redis 7.2.6:
    • 520 repositories with a limit plus 120 without one. The ones without a limit sort first, so the old bound would have used up its 500 places on them. All 520 limited repositories are listed.
    • Redis unreachable with admission off, on, and with an invalid configuration: each reports the repository usage as unavailable.
    • A successful read is not marked unavailable, and a bad configuration still returns repository slots.
  • packages/api/test/agentRunAdmissionRoutes.test.ts: the unavailable reason reaches the REST response and passes the published schema. A successful empty read carries no unavailable.
  • admissionCommands.test.ts: an unreadable result prints "unavailable"; an empty successful one prints "none in use".

Results

  • The snapshot suite passes 8/8. On the old core code, the three changed or new tests (6–8) fail.
  • The API route suite passes 6/6 and the CLI suite 6/6.
  • Typecheck is clean for core, api and cli.
  • ESLint with zero warnings passes for core and api. The CLI package has no ESLint config, so its files are skipped.
  • gen:openapi:check and check:client-contract are clean.

Separate discovery (not changed): repository rows are still filtered by what the caller may see. A REST demo viewer, or an MCP caller whose grant leaves out the busy repositories, gets an empty list and "none in use" even though work is running. That comes from the redaction design rather than a failed read, so I left it alone.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 7m 19s
  • Tokens: 1,645,571 (1,631,904 in / 13,667 out)
  • Cost: $0.97

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

… code and passes now.

I fixed both findings. Each new regression fails on the old code and passes now.

**F3: unavailable repository usage now says so**
- The snapshot has a new field, `repositoryWorkflowSlotsUnavailable`. It is set whenever repository usage could not be read from Redis: in the per-read catch and in the outer connection-failure catch. A successful read that finds nothing leaves it unset, whether admission is on or off.
- I found the same defect in a third place, the invalid-configuration branch. It returned `repositoryWorkflowSlots: []` without reading Redis at all. It now reads the repository slots like the other branches do, and still reports the configuration error under `unavailable`.
- The report contract now has an optional `repositoryWorkflowSlots.unavailable` in `buildAgentRunAdmissionReport`, the Zod schema and the CLI types. The OpenAPI spec and client types are regenerated.
- `propr admission` now prints `Repository workflow slots: unavailable: <reason>.` in that case. It prints "none in use under a limit." only when the read succeeded and found nothing.

**F4: no repository is dropped**
- `repositoryWorkflowSlotUsage` now scans until Redis says the scan is finished. I removed `maxRepositories` and the `.slice`, so the list is the complete inventory and no truncation marker or paging is needed. The per-repository reads now go in parallel batches of 100.
- The schema description, the report label and the operator doc now say the list is complete, and the doc explains the new `unavailable` field.

**New tests**
- In `test/agentRunAdmissionSnapshot.test.ts`, against a real Redis 7.2.6:
  - 520 repositories with a limit plus 120 without one. The ones without a limit sort first, so the old bound would have used up its 500 places on them. All 520 limited repositories are listed.
  - Redis unreachable with admission off, on, and with an invalid configuration: each reports the repository usage as unavailable.
  - A successful read is not marked unavailable, and a bad configuration still returns repository slots.
- `packages/api/test/agentRunAdmissionRoutes.test.ts`: the `unavailable` reason reaches the REST response and passes the published schema. A successful empty read carries no `unavailable`.
- `admissionCommands.test.ts`: an unreadable result prints "unavailable"; an empty successful one prints "none in use".

**Results**
- The snapshot suite passes 8/8. On the old core code, the three changed or new tests (6–8) fail.
- The API route suite passes 6/6 and the CLI suite 6/6.
- Typecheck is clean for core, api and cli.
- ESLint with zero warnings passes for core and api. The CLI package has no ESLint config, so its files are skipped.
- `gen:openapi:check` and `check:client-contract` are clean.

**Separate discovery (not changed):** repository rows are still filtered by what the caller may see. A REST demo viewer, or an MCP caller whose grant leaves out the busy repositories, gets an empty list and "none in use" even though work is running. That comes from the redaction design rather than a failed read, so I left it alone.

PR: #3519
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

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

Overall Evaluation

This PR provides a shared admission report through REST, MCP and CLI, with extensive documentation and focused tests. It needs a localized correction before merge: deferred-job lookup failures can produce a successful report that understates pending work.

✅ Access filtering — REST suppresses demo task references, while MCP checks both repository grants and repository policy before exposing task IDs or repository slots.

✅ Admission accounting — The tally separates top-level holders from nested executions and preserves cross-agent ceiling charges, matching the supplied admission script.

✅ Explicit unavailable states — Repository-slot failures and most admission failures are distinguished from empty capacity.

This review used static tracing of the supplied code; no commands were run. Authoritative checks show 34 passed, none failed, and one pending.

Merge blockers

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

F5: 🔴 Deferred lookup failures report false zero

  • Required behavior: The report must distinguish unavailable Redis state from an accurate count of pending work.

  • Evidence: packages/core/src/agents/agentRunAdmissionSnapshot.ts, deferredWaiters → isDelayed.

    1. An instance has one configured alias and one job delayed for that alias. Repository-slot collection, the admission snapshot, alias discovery and the alias’s zrange all succeed.
    2. Redis becomes unavailable after zrange resolves, while the awaited queue.getJob(...) or job.isDelayed() executes.
    3. The lookup rejects, but isDelayed catches the error and returns false.
    4. With no remaining aliases, collection completes without another required Redis read. The response includes global.deferred: 0 and the alias’s deferred: 0, with no admission unavailable indicator, although the delayed job remains pending.

    An operator following the documented drain procedure can therefore mistake unread pending work for an empty queue. The outer admission error handler cannot protect this path because the inner catch consumes the failure. The Fleet counter’s getJob failures propagate, so it does not share this particular defect.

    static trace: The sequence follows the supplied collection order and catch branches; no execution was performed. proposed regression: Reject a deferred-job lookup after successful discovery and assert that the report indicates unavailable state instead of returning a definitive zero.

  • Minimum fix: Propagate lookup failures to the existing admission-level unavailable handler. Continue treating a successfully read missing job or non-delayed job as absent.

Suggestions

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

S4: 🟢 Measure large-queue report latency

The admission report loads deferred waiters serially, potentially making two Redis requests per waiter. Fleet collection also loads every delayed job, although in concurrent batches. Benchmark these paths with realistic large queues and consider bounded concurrency or pipelining while preserving complete counts. This is an optional performance follow-up; the supplied evidence does not establish a production latency failure.

Score

The shared implementation, authorization filtering and coverage are strong, but the false-zero failure path undermines the report’s operational reliability. A small correction and focused regression test should address the blocker.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 37s
  • Tokens: 94,389 (92,224 in / 2,165 out)
  • Cost: $0.90

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 F5 S4

🤖 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 84fd00d

Addressed 1 AI review comment (IDs: 6843998198)

Addressed finding F5

Summary of Changes

I fixed F5. If BullMQ fails while looking up a deferred job, the admission report now says admission state could not be read from Redis. Before, it reported zero deferred jobs.

Fix (packages/core/src/agents/agentRunAdmissionSnapshot.ts, deferredWaiters → isDelayed): I removed the try/catch that turned a failed lookup into false. When queue.getJob(...) or job.isDelayed() fails, the error now reaches the existing handler in readAgentRunAdmissionSnapshot. That handler returns unavailable: 'Admission state could not be read from Redis' with no global section and no per-agent counts, so no zero is reported. Lookups that do succeed behave as before: a malformed entry, a missing or finished job, a job now waiting for a different agent, or a job that is no longer delayed still counts as not deferred. The existing test for those cases still passes.

Similar code checked: the Fleet queue counter (countCapacityDeferredJobs in packages/api/routes/queueRoutes.ts) has no catch, so its getJob failures already propagate. The only other swallowed error in the files this PR changed is the deliberately ignored write of the wait-reason record in agentRunAdmissionWait.ts. That's not a read the report relies on, so I left it alone.

Regression (test/agentRunAdmissionSnapshot.test.ts): the new test uses real Redis. It sets up one agent with a ceiling and one delayed job, and first checks the report shows deferred: 1. It then forces a real Redis WRONGTYPE error after the job has already been found, once in getJob (the job's hash is replaced) and once in isDelayed (the queue's delayed set is replaced). Each time it checks that the report is marked unavailable and has no global or per-agent deferred count.

Verification:

  • The full snapshot suite passes against a Redis 7.2.5 built from source, with the run set to fail rather than skip if Redis is missing: 9 pass, 0 skipped.
  • With the old isDelayed put back, the new test fails (unavailable is undefined).
  • ESLint with zero warnings allowed and tsc --noEmit both pass on packages/core.

There's nothing visual in this change, so I made no previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 5m 7s
  • Tokens: 997,524 (990,972 in / 6,552 out)
  • Cost: $0.59

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

…, the admission report now says admission state could not be read from Redis. Before, it reported zero deferred jobs.

I fixed F5. If BullMQ fails while looking up a deferred job, the admission report now says admission state could not be read from Redis. Before, it reported zero deferred jobs.

**Fix** (`packages/core/src/agents/agentRunAdmissionSnapshot.ts`, `deferredWaiters` → `isDelayed`): I removed the `try/catch` that turned a failed lookup into `false`. When `queue.getJob(...)` or `job.isDelayed()` fails, the error now reaches the existing handler in `readAgentRunAdmissionSnapshot`. That handler returns `unavailable: 'Admission state could not be read from Redis'` with no `global` section and no per-agent counts, so no zero is reported. Lookups that do succeed behave as before: a malformed entry, a missing or finished job, a job now waiting for a different agent, or a job that is no longer delayed still counts as not deferred. The existing test for those cases still passes.

**Similar code checked:** the Fleet queue counter (`countCapacityDeferredJobs` in `packages/api/routes/queueRoutes.ts`) has no catch, so its `getJob` failures already propagate. The only other swallowed error in the files this PR changed is the deliberately ignored write of the wait-reason record in `agentRunAdmissionWait.ts`. That's not a read the report relies on, so I left it alone.

**Regression** (`test/agentRunAdmissionSnapshot.test.ts`): the new test uses real Redis. It sets up one agent with a ceiling and one delayed job, and first checks the report shows `deferred: 1`. It then forces a real Redis `WRONGTYPE` error after the job has already been found, once in `getJob` (the job's hash is replaced) and once in `isDelayed` (the queue's delayed set is replaced). Each time it checks that the report is marked unavailable and has no global or per-agent deferred count.

**Verification:**
- The full snapshot suite passes against a Redis 7.2.5 built from source, with the run set to fail rather than skip if Redis is missing: 9 pass, 0 skipped.
- With the old `isDelayed` put back, the new test fails (`unavailable` is `undefined`).
- ESLint with zero warnings allowed and `tsc --noEmit` both pass on `packages/core`.

There's nothing visual in this change, so I made no previews.

PR: #3519
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

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

Overall Evaluation

The PR provides a shared admission report through REST, MCP, and CLI, with substantial tests and operator documentation. It needs a localized correctness fix before merge: the reported global configuration is not checked against the configuration actually stored in Redis.

✅ Shared reporting path — REST and MCP use the same report builder, and the CLI consumes the REST response.

✅ Explicit visibility filtering — Task references and repository entries are filtered separately from aggregate counts, including demo-viewer redaction.

✅ Unknown-state handling — Redis read failures produce explicit unavailable states rather than misleading empty repository usage.

The supplied current-head status has no failures; two checks remain pending. This review uses static analysis only, as requested.

Merge blockers

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

F6: 🔴 Validate the reported global configuration

  • Required behavior: The report must describe the effective global admission limit and generation, rather than presenting a configuration that admission will reject as usable capacity.

  • Evidence: packages/core/src/agents/agentRunAdmissionSnapshot.ts, admissionPart and globalSettings.

    1. An instance initializes admission with global limit 3 and generation 0, leaving the admission configuration stored in Redis.
    2. The deployment changes the global limit to 5 without increasing the generation and restarts. As documented in this PR’s global-limit procedure, subsequent admission attempts refuse with configuration/daemon mismatch; even draining all holders does not resolve that mismatch.
    3. The report reads holders, waiting entries, and details, but explicitly skips the configuration key in [holdersKey, , waitingKey].
    4. globalSettings supplies limit 5 and generation 0 from the process configuration. REST, MCP, and CLI consequently show ordinary available capacity, potentially 0/5, without indicating that launches cannot be admitted.

    static trace: The snapshot script never reads the stored configuration, and the unavailable branch only handles thrown read failures. Configuration parsing cannot detect disagreement with Redis. The supplied tests exercise invalid configuration syntax and Redis failures, but not this persisted-configuration mismatch. The observable consequence is an incorrect operational report precisely when an operator needs to diagnose a failed limit change.

  • Minimum fix: Read the stored admission configuration alongside the holder snapshot and detect incompatible limit/generation combinations. Report the mismatch explicitly instead of presenting normal usable capacity; distinguish a valid pending higher-generation transition from the currently stored configuration. Add a regression covering a changed limit with an unchanged generation.

Suggestions

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

S5: 🟢 Batch deferred-job inspection

deferredWaiters loads each waiter’s job and delayed status sequentially, while the Fleet count already uses bounded batches. Batching these independent reads could make the report more responsive during a large capacity backlog. This is an optional performance improvement; no specific latency failure was established in this review.

Score

The shared implementation, redaction, documentation, and tests are strong, but reporting unchecked global configuration undermines the report’s diagnostic purpose. The remaining correction appears localized; current checks show no failures.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 2s
  • Tokens: 93,449 (92,162 in / 1,287 out)
  • Cost: $0.88

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 F6 S5

🤖 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 dc7115f

Addressed 1 AI review comment (IDs: 6844450612)

Addressed finding F6

Summary of Changes

I fixed F6. The admission report now reads the configuration stored in Redis and says plainly when admission will refuse every launch. Before, it showed the process's own limit as free capacity, e.g. 0/5.

What changed

  • Same read. The snapshot script now reads the stored config key along with the holders, waiting set and details, so the result is one consistent view. Only the stored limit and generation are taken out of it; the Docker daemon identity is never returned.
  • New field. global.configuration holds { status, admitting, stored: { limit, generation } | null }. It is built by a new small module, packages/core/src/agents/agentRunAdmissionConfigState.ts, which follows the same rules as the admission script. status is one of:
    • current: the stored limit and generation match this process's.
    • uninitialized: nothing is stored yet; the first admission will store it.
    • pending_generation: this process has a higher generation. This is a valid transition: the next admission attempt fences the older reservations, then switches.
    • mismatch: same generation with a different limit, a lower generation (including a rollback to the old number), or an unreadable stored record. admitting is false.
  • Where it shows.
    • REST: the field is in the response, with an updated schema and regenerated OpenAPI and client types.
    • MCP: the summary now reads "refuses every launch: stored configuration mismatch (limit 3, generation 0) vs configured limit 5, generation 0" instead of "0/5 in use". A pending transition is noted too.
    • CLI: propr admission prints refused in the limit column, plus a line explaining the cause and the fix (a higher generation). It also prints a line for a pending generation change.
  • Docs: the capacity page, the architecture page and docs/mcp.md describe the field. The global-limit procedure now says the report shows mismatch while blocked, and pending_generation then current during a change.

One related case I fixed too: if no configuration is stored but holder records remain, admission also refuses every launch ("configuration missing; drain before recovery"). The report used to present that as normal capacity as well. It now reports status: missing with admitting: false.

One case the report still can't catch: if the Docker daemon itself changes, admission refuses, but the report still says current. Detecting that would mean querying Docker from the report endpoint, which it doesn't do. The docs say so.

Tests

  • New real-Redis test in test/agentRunAdmissionSnapshot.test.ts. It runs the scenario from the finding: start at limit 3, generation 0, and drain. It then:

    • restarts at limit 5 with the same generation: admission refuses with configuration/daemon mismatch and the report shows mismatch.
    • raises the generation: pending_generation until admission switches, then current.
    • rolls back to the old generation number: mismatch.
    • stores an unreadable record: mismatch.
    • deletes the config while a holder remains: missing.

    At each step the test runs real admission alongside the report, so the two are shown to agree. It also checks the daemon identity never appears in the report.

  • New tests for the API and CLI output in packages/api/test/agentRunAdmissionRoutes.test.ts (REST plus the MCP summary) and packages/cli/src/commands/admissionCommands.test.ts (table and text).

The new tests fail on the old code, since it had no configuration field. Against a real Redis 7.2, everything passes with nothing skipped:

Suite Result
Snapshot 10/10
agentRunAdmission 28
agentRunAliasAdmission 10/10
API routes 7/7
CLI 7/7

Typecheck is clean for core, API, CLI and the repo root. ESLint with zero warnings is clean for core and API; the CLI package has no ESLint config, so its files aren't linted. gen:openapi:check and check:client-contract are clean.

There are no visual previews, since nothing in the UI changed.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 12m 14s
  • Tokens: 4,402,197 (4,375,657 in / 26,540 out)
  • Cost: $2.00

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

…n stored in Redis and says plainly when admission will refuse every launch. Before, it showed the process's own limit as free capacity, e.g. `0/5`.

I fixed F6. The admission report now reads the configuration stored in Redis and says plainly when admission will refuse every launch. Before, it showed the process's own limit as free capacity, e.g. `0/5`.

**What changed**
- **Same read.** The snapshot script now reads the stored config key along with the holders, waiting set and details, so the result is one consistent view. Only the stored limit and generation are taken out of it; the Docker daemon identity is never returned.
- **New field.** `global.configuration` holds `{ status, admitting, stored: { limit, generation } | null }`. It is built by a new small module, `packages/core/src/agents/agentRunAdmissionConfigState.ts`, which follows the same rules as the admission script. `status` is one of:
  - `current`: the stored limit and generation match this process's.
  - `uninitialized`: nothing is stored yet; the first admission will store it.
  - `pending_generation`: this process has a higher generation. This is a valid transition: the next admission attempt fences the older reservations, then switches.
  - `mismatch`: same generation with a different limit, a lower generation (including a rollback to the old number), or an unreadable stored record. `admitting` is `false`.
- **Where it shows.**
  - **REST:** the field is in the response, with an updated schema and regenerated OpenAPI and client types.
  - **MCP:** the summary now reads "refuses every launch: stored configuration mismatch (limit 3, generation 0) vs configured limit 5, generation 0" instead of "0/5 in use". A pending transition is noted too.
  - **CLI:** `propr admission` prints `refused` in the limit column, plus a line explaining the cause and the fix (a higher generation). It also prints a line for a pending generation change.
- **Docs:** the capacity page, the architecture page and `docs/mcp.md` describe the field. The global-limit procedure now says the report shows `mismatch` while blocked, and `pending_generation` then `current` during a change.

**One related case I fixed too:** if no configuration is stored but holder records remain, admission also refuses every launch ("configuration missing; drain before recovery"). The report used to present that as normal capacity as well. It now reports `status: missing` with `admitting: false`.

**One case the report still can't catch:** if the Docker daemon itself changes, admission refuses, but the report still says `current`. Detecting that would mean querying Docker from the report endpoint, which it doesn't do. The docs say so.

**Tests**
- **New real-Redis test** in `test/agentRunAdmissionSnapshot.test.ts`. It runs the scenario from the finding: start at limit 3, generation 0, and drain. It then:
  - restarts at limit 5 with the same generation: admission refuses with `configuration/daemon mismatch` and the report shows `mismatch`.
  - raises the generation: `pending_generation` until admission switches, then `current`.
  - rolls back to the old generation number: `mismatch`.
  - stores an unreadable record: `mismatch`.
  - deletes the config while a holder remains: `missing`.

  At each step the test runs real admission alongside the report, so the two are shown to agree. It also checks the daemon identity never appears in the report.
- **New tests for the API and CLI output** in `packages/api/test/agentRunAdmissionRoutes.test.ts` (REST plus the MCP summary) and `packages/cli/src/commands/admissionCommands.test.ts` (table and text).

The new tests fail on the old code, since it had no `configuration` field. Against a real Redis 7.2, everything passes with nothing skipped:

| Suite | Result |
| --- | --- |
| Snapshot | 10/10 |
| `agentRunAdmission` | 28 |
| `agentRunAliasAdmission` | 10/10 |
| API routes | 7/7 |
| CLI | 7/7 |

Typecheck is clean for core, API, CLI and the repo root. ESLint with zero warnings is clean for core and API; the CLI package has no ESLint config, so its files aren't linted. `gen:openapi:check` and `check:client-contract` are clean.

There are no visual previews, since nothing in the UI changed.

PR: #3519
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 3/4

Please investigate and fix this CI failure.

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

Failure evidence

.github:11
Process completed with exit code 1.

.github:36331
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 673469d

Summary of Changes

I fixed the Shard 3/4 failure. One test failed, and the cause was a docs change on this branch.

Cause: packages/api/test/mcpObservableSurface.test.ts reads docs/mcp.md and checks every lowercase word in backticks. Each one has to be an MCP tool the admin can see, or appear on the test's list of words that aren't tools. The last commit (F6) added three such words to the get_agent_run_admission section of the docs: admitting, mismatch and missing. They weren't on that list, so the test failed:

docs/mcp.md names admitting, but it is neither an admin-visible tool nor an explicit non-tool token

Fix: I added the three words to the test's non-tool list, with a comment saying they come from get_agent_run_admission's stored-configuration check. This follows the pattern the list already uses for other tools' field and state names. The docs are unchanged.

Verification: I ran node scripts/run-test-suite.mjs packages/api/test/mcpObservableSurface.test.ts and the test passes (1/1). It is the only test that reads docs/mcp.md.

Shards 2/4 and 4/4 and Validate Changes also show as failed in the same run. Their logs end in "The operation was canceled." with no failing test, which fits them being cancelled after Shard 3 failed rather than failing on their own.

No visual preview, since nothing in the UI changed.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 6m 8s
  • Tokens: 726,286 (723,531 in / 2,755 out)
  • Cost: $0.47

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: 6844872595✓

…se was a docs change on this branch.

I fixed the Shard 3/4 failure. One test failed, and the cause was a docs change on this branch.

**Cause:** `packages/api/test/mcpObservableSurface.test.ts` reads `docs/mcp.md` and checks every lowercase word in backticks. Each one has to be an MCP tool the admin can see, or appear on the test's list of words that aren't tools. The last commit (F6) added three such words to the `get_agent_run_admission` section of the docs: `admitting`, `mismatch` and `missing`. They weren't on that list, so the test failed:

> docs/mcp.md names admitting, but it is neither an admin-visible tool nor an explicit non-tool token

**Fix:** I added the three words to the test's non-tool list, with a comment saying they come from `get_agent_run_admission`'s stored-configuration check. This follows the pattern the list already uses for other tools' field and state names. The docs are unchanged.

**Verification:** I ran `node scripts/run-test-suite.mjs packages/api/test/mcpObservableSurface.test.ts` and the test passes (1/1). It is the only test that reads `docs/mcp.md`.

Shards 2/4 and 4/4 and Validate Changes also show as failed in the same run. Their logs end in "The operation was canceled." with no failing test, which fits them being cancelled after Shard 3 failed rather than failing on their own.

No visual preview, since nothing in the UI changed.

PR: #3519
Comment by: @propr-dev[bot] (ID: 6844872595)
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 a shared admission report across REST, MCP and CLI, with substantial contract, authorization and Redis integration coverage. It needs a localized correction before merge: report cleanup can permanently erase attribution for a live waiting launch.

✅ Shared reporting contract — REST and MCP use the same report builder, with an explicit schema and generated client types.

✅ Scoped disclosure — MCP filters task IDs and repository names through both grant membership and repository policy; the demo REST response suppresses these details.

✅ Unknown-state handling — Redis read failures are distinguished from empty capacity, and stored configuration mismatches are surfaced explicitly.

The supplied current-head status shows 34 passed checks, no failures and one pending check. This review used static analysis only; no commands were run.

Merge blockers

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

F7: 🔴 Restore details when an expired waiter rejoins

  • Required behavior: The admission report must attribute live waiting launches to their agent and report their actual wait reason.

  • Evidence: packages/core/src/agents/agentRunAdmissionWait.ts, admissionWaitTracker.joined and observe; packages/core/src/agents/agentRunAdmissionSnapshot.ts, SNAPSHOT_SCRIPT; packages/core/src/agents/agentRunAdmission.ts, admission loop.

    1. Configure global limit 3 and an agent ceiling of 1. A live holder fills that agent's ceiling, another agent holds a second slot, and a launch waits with its recorded reason alias_limit.
    2. The second holder's process dies. On its next iteration, the waiting launch refreshes its waiting-set deadline to 30 seconds and awaits recover(identity). Recovery awaits Docker removal of the expired holder; the supplied lifecycle documentation allows removal to take about 50 seconds.
    3. While removal remains pending beyond 30 seconds, a report executes SNAPSHOT_SCRIPT. The launch is neither a holder nor an unexpired waiter, so the script deletes its detail.
    4. Recovery completes. The original agent's live holder still fills its ceiling, so acquire returns alias_limit again. observe() skips the write because the reason has not changed. Subsequent iterations refresh the waiting-set entry, but joined() also skips writing because its local joined flag remains true.
    5. Reports now count this live launch as unattributed starting work and show no corresponding agent wait or task ID, potentially for the remainder of a long capacity wait.

    The interruption point is the awaited recovery removal; the competing actor is the report's cleanup script. The waiting-set refresh occurs outside that await, and neither the one-shot joined() writer nor the change-only reason writer repairs the deleted detail. Holder lease protections do not preserve waiting-launch metadata.

    static trace: Derived from the changed loop, cleanup script and tracker guards, together with the supplied recovery lifecycle and removal bounds. proposed regression: Expire a waiting entry during blocked recovery, read a snapshot, resume recovery with the same refusal reason, and assert subsequent snapshots retain the alias, task and reason.

  • Minimum fix: Republish the current detail, including the existing reason and original timestamp, whenever the launch refreshes or rejoins the waiting set. Preserve best-effort error handling.

Suggestions

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

S6: 🟢 Batch deferred waiter lookups

deferredWaiters() awaits job loading and delayed-state checks sequentially for every waiter. Bounded concurrency or pipelining would improve report latency with large waiting lists while preserving complete counts and failure reporting. This is an optional performance improvement; no measured latency failure was established here.

Score

The implementation is cohesive and well covered, but a reachable cleanup/recovery sequence breaks the report's central attribution behavior. The correction is localized; supplied checks otherwise show no current failures.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 18s
  • Tokens: 99,701 (98,184 in / 1,517 out)
  • Cost: $0.95

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 F7 S6

🤖 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 aecc8a7

Addressed 1 AI review comment (IDs: 6845265017)

Addressed finding F7

Summary of Changes

That notice is only the progress watch timing out. The suite run it was following had already finished: all 11 related files passed with nothing skipped, so I've left it stopped. F7 is fixed and nothing else is outstanding.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (xhigh)
  • Requested By: @propr-ultrafix
  • Time: 19m 47s
  • Tokens: 3,222,722 (3,222,364 in / 358 out)
  • Cost: $1.18

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

…e run it was following had already finished: all 11 related files passed with nothing skipped, so I've left it stopped. F7 is fixed and nothing else is outstanding.

That notice is only the progress watch timing out. The suite run it was following had already finished: all 11 related files passed with nothing skipped, so I've left it stopped. F7 is fixed and nothing else is outstanding.

PR: #3519
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

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

Overall Evaluation

The PR adds a shared admission report across REST, MCP and CLI, with supporting diagnostics and operator documentation. It is merge-ready within the reviewed scope, conditional on the pending validation check completing successfully.

✅ Shared reporting contract — REST and MCP use the same report builder, with a typed OpenAPI schema and CLI coverage.

✅ Scoped disclosure — Task and repository details are filtered separately from aggregate counts; MCP checks both repository grants and current policy.

✅ Explicit unavailable states — Redis failures and configuration mismatches are distinguished from idle capacity, including in CLI and MCP presentation.

This was a static review of the supplied diff and context; no commands were run. The authoritative checks show 34 passed, zero failed, one pending and 11 neutral/skipped.

Merge blockers

No merge blockers.

Suggestions

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

S7: 🟢 Measure report collection cost

packages/core/src/agents/agentRunAdmissionSnapshot.ts loads deferred jobs and checks their delayed state sequentially, while packages/api/routes/queueRoutes.ts loads every delayed job for each Fleet status request. Benchmark these paths with a substantial backlog. Bounded concurrency or pipelined reads could improve response times while preserving complete counts. This is optional because no workload-dependent timeout or operational failure is established by the supplied evidence.

S8: 🟢 Clarify snapshot consistency

The holder, waiting and configuration records are captured atomically, but deferred jobs, repository slots and worker counts are collected separately. Consider qualifying the documentation’s “Everything is exact” statement to explain that these sections can reflect different moments during concurrent transitions. The implementation already preserves the central admission snapshot; this clarification would help consumers interpret transient cross-section discrepancies.

Score

The implementation provides substantial coverage, careful disclosure filtering and useful failure reporting. No merge-blocking defect was verified in the supplied changes, and the current checks report no failures.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 0s
  • Tokens: 100,063 (99,151 in / 912 out)
  • Cost: $0.93

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 S7 S8

🤖 Review by ProPR

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