Repository navigation
[3478 by Claude Opus 5.5] Enforce optional per-agent ceilings atomically in the agent-run admission script - #3492
Conversation
…as the global limit, so the existing reserve / attach / fence / recover lifecycle covers them unchanged. The new suite (10 tests) passes against a real Redis 7.4.11 I built locally, three runs in a row. The existing `agentRunAdmission.test.ts` (27 tests) and the related suites pass too. Typecheck (root, core, API) and `eslint --max-warnings 0` (core, API, root `src/`) are clean. Nothing ran against real Docker; the tests use the existing Docker simulator. Admission script (`agentRunAdmission.ts`) - `acquire` now takes the alias and its ceiling. It counts that alias's holders in the loop that already decodes every record for the recovering check, so it's still one `EVAL`. - New holder records store `alias`. Every other operation decodes and re-encodes the whole record, so the field survives. - Records written before the upgrade (no alias) count toward the global limit only. - A recovering holder still blocks every acquire until its removal is confirmed, so alias capacity is never reused early. - `acquire` now replies with distinct codes: `global_limit`, `alias_limit` or `recovering`. The wait loop logs each change of reason, and callers can get it through a new `onWaiting` option. - Ceilings are not part of the fenced configuration identity. Each acquire passes the current value, so changing one needs no generation bump and no drain. Policy (`agentRunAliasLimits.ts`, `agentRunAdmissionPolicy.ts`) - Format is `PROPR_AGENT_RUN_ALIAS_LIMITS=local-llama=1,claude-prod=3`; unset or blank means no policy. - Rejected values: anything malformed, a duplicate alias, a value that isn't a positive integer, a ceiling above the global limit (it could never bind), and any policy while admission is off. - Worker and API startup refuse to start if the policy names a synthetic alias or one that isn't a configured direct agent. Disabled agents count as configured; `default` is accepted when no direct agents exist. - On `agents_update` / `synthetic_agents_update`, both processes re-check and log an error instead of crashing. - Because ceilings come from each process's environment, a change takes effect after restarting the processes. Carrying the alias to the boundary - All five agent implementations pass `agentAlias: config.alias` to `executeDockerCommand`. The three native goal paths pass it to `spawnWithNetworkPolicy`. - With a policy configured, a launch that names no agent fails before touching Redis. - The paths that launched without a registered alias, now listed in the architecture doc: | Path | Identity | | --- | --- | | Legacy Claude analysis (`executeClaudeCode`) | Exempt (`legacy-claude-analysis`): no registered agent runs, so it counts toward the global limit only. | | Health checks | The saved agent's alias. The probe always runs a saved configuration; I found no unsaved-config path. | | Implicit default agent | Alias `default`. | Tests (`test/agentRunAliasAdmission.test.ts`) - It uses a spawned `redis-server` if one exists, otherwise `REDIS_HOST`/`REDIS_PORT` with keys unique to the run (CI provides a Redis container rather than the binary). - With `PROPR_REQUIRE_REDIS_INTEGRATION=1` and no Redis it fails; without the flag it skips. I checked all three cases. - The multi-process test starts 7 processes across the standard and native entrypoints. It samples Redis throughout to confirm neither ceiling is ever exceeded. - Other cases cover: - a saturated alias not blocking another alias - the three wait reasons - no leak or early reuse after cancellation, create failure, crash, lease loss and repeated finish - changing a ceiling with no change to the stored identity - old records without an alias - unchanged holder data when no policy is set - To check the tests catch a real bug, I removed the alias-ceiling line from the script: four tests failed and the contention test hung until the timeout. The line is restored. - The existing worker fixture now accepts an optional `PROPR_TEST_AGENT_ALIAS`; when it's unset it behaves as before. Other changes - To keep `src/worker.ts` under the 400-line lint limit, I moved `refreshAgentRegistryForConfigUpdate` into `src/workerAgentPreparation.ts`. - `src/workerAgentPreparation.ts` and `packages/api/server.ts` import the new validation functions lazily. Some suites mock `@propr/core` with a fixed export list, and a static import would break them. - Docs: a "Per-agent ceilings" section in the architecture doc, including what to expect during a rolling restart. Processes still on the old version don't send an alias, so they can admit work on an alias that's already at its ceiling until every process is upgraded. - New `PROPR_AGENT_RUN_*` rows in the configuration reference, an `.env.example` entry, and a settings-catalog entry with the regenerated settings page. There are no visual changes, so I made no previews.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements per-agent ceilings at the existing physical admission boundary, with clear configuration validation and focused lifecycle coverage. It is merge-ready within the reviewed scope, conditional on the pending checks completing successfully. ✅ Atomic admission — The Lua acquire operation checks both global capacity and alias holders before inserting a reservation. ✅ Consistent attribution — Standard provider executions and all three native goal paths pass the direct agent alias; synthetic routing invokes the selected physical agent. ✅ Recovery coverage — The added tests cover retained alias capacity during recovery, cancellation, creation failure, lease loss, and multi-process contention. This assessment is based on static review of the supplied diff and context. No commands or tests were run. The authoritative check summary reports no failures and five pending checks. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Test provider alias forwardingConsider adding focused tests asserting that provider task, analysis, and native goal callers forward their configured alias. The contention fixture supplies its alias directly to the wrappers, so it verifies enforcement but would not catch a future omission in a provider caller. This is optional because the current forwarding is visible and consistent in the diff. ScoreThe implementation is cohesive and has substantial coverage of the changed admission behavior. Static review found no merge blockers; final readiness remains conditional on the pending checks. Score: 9/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3478
Branch:
3478/claude-opus-5-5-enforce-optional-per-agen-20261112-1222-anpCommits: ✅ Changes committed (5cfdaac)
AI Processing Completed
Execution Details:
Summary:
Per-agent ceilings are in. They're checked in the same Lua
acquireas the global limit, so the existing reserve / attach / fence / recover lifecycle covers them unchanged. The new suite (10 tests) passes against a real Redis 7.4.11 I built locally, three runs in a row. The existingagentRunAdmission.test.ts(27 tests) and the related suites pass too. Typecheck (root, core, API) andeslint --max-warnings 0(core, API, rootsrc/) are clean. Nothing ran against real Docker; the tests use the existing Docker simulator.Admission script (
agentRunAdmission.ts)acquirenow takes the alias and its ceiling. It counts that alias's holders in the loop that already decodes every record for the recovering check, so it's still oneEVAL.alias. Every other operation decodes and re-encodes the whole record, so the field survives.acquirenow replies with distinct codes:global_limit,alias_limitorrecovering. The wait loop logs each change of reason, and callers can get it through a newonWaitingoption.Policy (
agentRunAliasLimits.ts,agentRunAdmissionPolicy.ts)PROPR_AGENT_RUN_ALIAS_LIMITS=local-llama=1,claude-prod=3; unset or blank means no policy.defaultis accepted when no direct agents exist.agents_update/synthetic_agents_update, both processes re-check and log an error instead of crashing.Carrying the alias to the boundary
agentAlias: config.aliastoexecuteDockerCommand. The three native goal paths pass it tospawnWithNetworkPolicy.executeClaudeCode)legacy-claude-analysis): no registered agent runs, so it counts toward the global limit only.default.Tests (
test/agentRunAliasAdmission.test.ts)redis-serverif one exists, otherwiseREDIS_HOST/REDIS_PORTwith keys unique to the run (CI provides a Redis container rather than the binary).PROPR_REQUIRE_REDIS_INTEGRATION=1and no Redis it fails; without the flag it skips. I checked all three cases.PROPR_TEST_AGENT_ALIAS; when it's unset it behaves as before.Other changes
src/worker.tsunder the 400-line lint limit, I movedrefreshAgentRegistryForConfigUpdateintosrc/workerAgentPreparation.ts.src/workerAgentPreparation.tsandpackages/api/server.tsimport the new validation functions lazily. Some suites mock@propr/corewith a fixed export list, and a static import would break them.PROPR_AGENT_RUN_*rows in the configuration reference, an.env.exampleentry, and a settings-catalog entry with the regenerated settings page.There are no visual changes, so I made no previews.
Detailed Logs:
9085921b-853c-49ce-beb7-c9d01a2f5fdaLog files stored at:
/usr/src/app/logs/executions/issue-3478-2026-11-12T13-14-53-100Z-conversation.json/usr/src/app/logs/executions/issue-3478-2026-11-12T13-14-53-100Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3478.
💡 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!