Skip to content

[3478 by Claude Opus 5.5] Enforce optional per-agent ceilings atomically in the agent-run admission script - #3492

Merged
integry merged 1 commit into
3478-epic-per-agent-9uvfrom
3478/claude-opus-5-5-enforce-optional-per-agen-20261112-1222-anp
Nov 12, 2026
Merged

integry merged 1 commit into
3478-epic-per-agent-9uvfrom
3478/claude-opus-5-5-enforce-optional-per-agen-20261112-1222-anp

Conversation

@propr-dev

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

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3478

Branch: 3478/claude-opus-5-5-enforce-optional-per-agen-20261112-1222-anp
Commits: ✅ Changes committed (5cfdaac)


AI Processing Completed

Execution Details:

Summary:
Per-agent ceilings are in. They're checked in the same Lua acquire 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.

Detailed Logs:

  • Conversation: 241 messages
  • Session: 9085921b-853c-49ce-beb7-c9d01a2f5fda

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3478-2026-11-12T13-14-53-100Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3478-2026-11-12T13-14-53-100Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: Per-agent ceilings are in. They're checked in the same Lua `acquire` as the global limit, so the existing reserve / attach / fence / recover lifecycle covers them unchanged. The new suite (10 tests) p...


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!

…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.
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

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

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

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

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

First action: /review

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

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR 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 blockers

No merge blockers.

Suggestions

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

S1: 🟢 Test provider alias forwarding

Consider 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.

Score

The 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

  • Model: GPT-6 Astra
  • Time: 43s
  • Tokens: 68,157 (67,523 in / 634 out)
  • Cost: $0.60

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 S1

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 12, 2026
@integry
integry merged commit 9c6f24a into 3478-epic-per-agent-9uv Nov 12, 2026
60 checks passed
@integry
integry deleted the 3478/claude-opus-5-5-enforce-optional-per-agen-20261112-1222-anp branch November 12, 2026 14:44
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