Skip to content

[2734 by Claude Opus 5.5] ## Enforce per-run spend caps (cancel the run when its cost exceeds the cap) - #2758

Merged
integry merged 17 commits into
mainfrom
2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3
Oct 6, 2026
Merged

integry merged 17 commits into
mainfrom
2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #2734

Branch: 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3
Commits: ✅ Changes committed (8abe42d)


AI Processing Completed

Execution Details:

Summary:
I've implemented per-run spend caps for #2734. A run is now stopped once its estimated cost reaches the cap, and its partial work is published the way a timed-out run's is. npm run lint and npm run typecheck pass, and so do about 110 affected test files (UI vitest suites included). The full suite was not run, and I couldn't exercise a real Docker agent run in this sandbox, so the stop has only been tested through the guard and in unit tests.

Where the cap comes from (highest wins)

  1. maxCostUsd on a REST task submission or MCP create_task, or --max-cost <usd> on propr issue implement.
  2. limits.max_cost_usd in .propr/workflow.yml. A bad value here doesn't reject the whole workflow file: it's logged and ignored. The editor schema still flags it.
  3. The new default_max_cost_usd setting, available in Settings → Automation, propr setting update and MCP update_execution_settings.

Empty or 0 means "not set at this level", so the next level applies. A malformed or negative value is logged and treated the same way, so a typo can never cap runs at $0. I removed the unused AgentTankConfig type rather than reuse it.

How it's enforced

  • What counts as spend: the task's recorded llm_executions costs plus the token usage the running agent containers have streamed so far. It's re-checked every ~10 seconds, so a run can go slightly over before it's stopped.
  • The stop: the container is torn down through the same path a UI stop uses, but the run is treated like a timeout rather than a user cancellation. A user stop marks the task cancelled, which would skip publishing the partial work.
  • What gets recorded: the task ends with terminal reason cost_cap_exceeded. It also gets a budget.exceeded timeline event (shown as "Spend Cap Reached"), an Inbox notification, and a short comment on the issue or PR.
  • Covered runs: implementations, follow-ups, /fix, ultrafix cycles and reviews. Goals are unchanged.
  • Retries share the budget: earlier attempts' spend counts against the cap. PR usage-limit retries get a new task ID, so they carry the earlier attempt IDs along.
  • Visible in: the task header ("$5.12 / $5.00 (102.4%) capped"), the task history API, and propr task get (budget in --json).
  • LLM_COST_THRESHOLD_USD still only raises alerts; the docs now say so.

Behaviours to be aware of

  • Once the cap is hit, later steps that publish the partial work (commit message, PR text) can still make a few small LLM calls.
  • --max-cost is saved against the issue in Redis for 30 days, so re-runs of that issue in that window also use it.
  • The new task form in the web UI has no cap field; per-task caps come only from REST, MCP or the CLI.

Test changes you should know about

  • Several existing tests replace @propr/core with a fixed list of exports, which broke on the new imports. I moved the pure constants and formatters into @propr/shared to avoid most of that.
  • For the rest I edited existing tests:
    • prPublicationJob and prPublicationRecoveryJob now stub the new cost-cap module.
    • planIssueHandlers.followup gets one extra stub.
    • configRoutes.followup expects the new setting in its deep-equal checks.
  • New tests cover cap precedence, malformed values, retry arithmetic, the stop firing once with the right reason and timeline event, the workflow schema, and the CLI/UI display.

Docs are updated in repository-workflow.md, metrics.md, execution-safety.md (new "Spend Caps" section), the CLI docs and the CHANGELOG. settings-locations.md was regenerated rather than edited, because it's generated from the settings catalog. I also saved two screenshots as previews: the capped task's detail page and the new settings field.

Detailed Logs:

  • Conversation: 150 messages
  • Session: bdf53b76-4295-4111-b6ab-e41fdefa08da

Log files stored at:

  • conversation: /tmp/claude-logs/issue-2734-2026-10-06T00-19-01-791Z-conversation.json
  • output: /tmp/claude-logs/issue-2734-2026-10-06T00-19-01-791Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: I've implemented per-run spend caps for #2734. A run is now stopped once its estimated cost reaches the cap, and its partial work is published the way a timed-out run's is. `npm run lint` and `npm run...


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


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!


Visual preview

Settings: default spend cap per run

Settings: default spend cap per run

The new default_max_cost_usd field under Settings → Automation → Processing (1280px).

Original unavailable: managed storage is unavailable or the upload has expired.

Task details: spend beside the run cap

Task details: spend beside the run cap

A run stopped at its $5.00 cap from .propr/workflow.yml: the header shows spend/cap/percentage, the timeline shows a Spend Cap Reached event and the cost_cap_exceeded terminal reason (fixture data, 1280px).

Original unavailable: managed storage is unavailable or the upload has expired.

…nce its estimated cost reaches the cap, and its partial work is published the way a timed-out run's is. `npm run lint` and `npm run typecheck` pass, and so do about 110 affected test files (UI vitest suites included). The full suite was not run, and I couldn't exercise a real Docker agent run in this sandbox, so the stop has only been tested through the guard and in unit tests.

Where the cap comes from (highest wins)
1. `maxCostUsd` on a REST task submission or MCP `create_task`, or `--max-cost <usd>` on `propr issue implement`.
2. `limits.max_cost_usd` in `.propr/workflow.yml`. A bad value here doesn't reject the whole workflow file: it's logged and ignored. The editor schema still flags it.
3. The new `default_max_cost_usd` setting, available in Settings → Automation, `propr setting update` and MCP `update_execution_settings`.

Empty or 0 means "not set at this level", so the next level applies. A malformed or negative value is logged and treated the same way, so a typo can never cap runs at $0. I removed the unused `AgentTankConfig` type rather than reuse it.

How it's enforced
- What counts as spend: the task's recorded `llm_executions` costs plus the token usage the running agent containers have streamed so far. It's re-checked every ~10 seconds, so a run can go slightly over before it's stopped.
- The stop: the container is torn down through the same path a UI stop uses, but the run is treated like a timeout rather than a user cancellation. A user stop marks the task cancelled, which would skip publishing the partial work.
- What gets recorded: the task ends with terminal reason `cost_cap_exceeded`. It also gets a `budget.exceeded` timeline event (shown as "Spend Cap Reached"), an Inbox notification, and a short comment on the issue or PR.
- Covered runs: implementations, follow-ups, `/fix`, ultrafix cycles and reviews. Goals are unchanged.
- Retries share the budget: earlier attempts' spend counts against the cap. PR usage-limit retries get a new task ID, so they carry the earlier attempt IDs along.
- Visible in: the task header ("$5.12 / $5.00 (102.4%) capped"), the task history API, and `propr task get` (`budget` in `--json`).
- `LLM_COST_THRESHOLD_USD` still only raises alerts; the docs now say so.

Behaviours to be aware of
- Once the cap is hit, later steps that publish the partial work (commit message, PR text) can still make a few small LLM calls.
- `--max-cost` is saved against the issue in Redis for 30 days, so re-runs of that issue in that window also use it.
- The new task form in the web UI has no cap field; per-task caps come only from REST, MCP or the CLI.

Test changes you should know about
- Several existing tests replace `@propr/core` with a fixed list of exports, which broke on the new imports. I moved the pure constants and formatters into `@propr/shared` to avoid most of that.
- For the rest I edited existing tests:
  - `prPublicationJob` and `prPublicationRecoveryJob` now stub the new cost-cap module.
  - `planIssueHandlers.followup` gets one extra stub.
  - `configRoutes.followup` expects the new setting in its deep-equal checks.
- New tests cover cap precedence, malformed values, retry arithmetic, the stop firing once with the right reason and timeline event, the workflow schema, and the CLI/UI display.

Docs are updated in `repository-workflow.md`, `metrics.md`, `execution-safety.md` (new "Spend Caps" section), the CLI docs and the CHANGELOG. `settings-locations.md` was regenerated rather than edited, because it's generated from the settings catalog. I also saved two screenshots as previews: the capped task's detail page and the new settings field.
@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

@propr-dev propr-dev Bot added the ultrafix label Oct 6, 2026
@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

First action: /review

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

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-dev[bot]

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds spend-cap configuration, live cost accounting, interruption handling, and user-facing reporting. It needs changes before merge: asynchronous accounting can falsely declare a cap exceeded, and executions that finish between checks can escape cap classification entirely.

✅ Consistent precedence — The resolver applies task, workflow, and instance caps in order, with explicit handling of zero and malformed values.

✅ Partial-work integration — cost_cap flows through agent termination parsing and existing publication logic, preserving incomplete-work warnings and avoiding issue-closing references.

This is a static review of the supplied code; no commands were run. Current-head checks show 13 neutral/skipped results and no passing, pending, or failing checks.

Merge blockers

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

F1: 🔴 Execution completion can double-count spend

  • Required behavior: A run must be stopped based on its actual estimated consumption, without counting the same execution twice.

  • Evidence: packages/core/src/budget/runCostGuard.ts, snapshot, cost, and the beginExecution().finish() callback.

    static trace:

    1. A run has a $10 cap, no previously recorded spend, and one live execution with $6 of observed usage.
    2. snapshot() captures that execution in the array passed to cost() for liveUsd. Pricing awaits getModelPricing(), which can perform Redis and HTTP requests.
    3. While pricing is pending, the Docker child emits close. finishCostExecution() removes that execution from live and appends its tally to finished.
    4. Pricing returns $6. snapshot() then separately prices this.finished, which now contains the same tally, producing another $6.
    5. The second operand of Math.max() becomes $12. The guard records budget.exceeded and sends a spend-cap notice even though the execution consumed only $6.

    The child-close callback can run during the pricing await; no lock or snapshot isolation prevents the tally from moving between collections. The checking promise only serializes checks, not completion callbacks. Existing tests explicitly finish executions after awaiting checks, so they do not cover this ordering.

  • Minimum fix: Capture mutually exclusive live and finished tally collections before awaiting pricing, and use those captured collections throughout the calculation. Add a regression that finishes an execution while its pricing promise is pending.

F2: 🔴 Final usage can bypass cap enforcement

  • Required behavior: A run that reaches its spend cap must receive the spend-cap outcome and reporting; completing between polling intervals must not silently bypass that behavior.

  • Evidence: packages/core/src/budget/runCostGuard.ts, beginExecution().finish() and close; packages/core/src/claude/docker/dockerExecutor.ts, child close handler.

    static trace:

    1. A capped execution starts, and its initial check() completes while observed and recorded spend are below the cap.
    2. Before the next 10-second interval, the execution emits usage that pushes its estimated spend above the cap and then exits.
    3. observeLine() updates the tally without requesting a check. The child-close handler calls finish(), which moves the tally to finished and stops the timer when no executions remain.
    4. No final check runs. The Docker result has no costCapExceeded flag, and withRunCostCap() eventually calls close() without reconciling final consumption.
    5. The task can complete normally above its cap, with no budget.exceeded event, notification, or cost_cap_exceeded terminal reason.

    This does not require a race: usage and exit can both occur after the initial check and before the first interval. Final metric persistence cannot trigger enforcement because the guard has stopped polling. The new tests manually call check() before finish(), bypassing this failure sequence. The documented polling overshoot allowance does not explain permanently missing the cap outcome.

  • Minimum fix: Flush final output and await a final budget evaluation before settling the execution result and completing the task. Propagate an exceeded result through the existing partial-work termination path.

Suggestions

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

S1: 🟢 Preserve historical budget configuration

storeResolvedRunCostCap() retains caps in Redis for 90 days, while loadTaskBudget() can recover a cap from history only when it was exceeded. Consequently, an older run that finished below its cap will eventually display as uncapped. Persisting the resolved cap in durable task metadata would improve historical accuracy. This is optional because the supplied objective does not specify budget-history retention.

Score

The configuration and publication integration are well developed, but two defects remain in the central enforcement lifecycle. The supplied tests do not cover these asynchronous completion paths, and current checks provide no passing validation.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 26s
  • Tokens: 94,213 (91,704 in / 2,509 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 F1 F2 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit a270cf4

Addressed 1 AI review comment (IDs: 6006355843)

Addressed findings F1, F2

Summary of Changes

I fixed F1 and F2. Both cases now behave as intended, and the three new regression tests fail on the old code and pass with the fix.

F1 – an execution could be counted twice (packages/core/src/budget/runCostGuard.ts)

  • The check now copies the lists of running and finished executions in a single step, before it starts the slow pricing lookup, and uses only those copies. An execution that finishes during pricing can no longer appear in both lists.
  • It still reads the recorded spend first. Rows are only written after an execution finishes, so a running execution can't be counted both in recorded spend and in live usage.

F2 – a run could finish above its cap without the spend-cap outcome

  • In the guard, finish() now returns a promise. It moves the execution to the finished list and waits for any check already running. Then it runs a fresh check that includes the final usage, and returns the stop message if the run reached its cap. Calling it twice gives the same result. The interface change is in runCostGuardContext.ts.
  • In dockerExecutor.ts, when the agent process exits, the executor now reads its last output line (even one with no trailing newline) and then waits for that final check before settling the result. If the cap was reached, the result goes through the same path as a run stopped mid-way: partial output marked costCapExceeded when the caller can publish it, otherwise RunCostCapExceededError. That gives the run the cost_cap_exceeded terminal reason, the budget.exceeded event and the notice. If the run was already aborted for another reason, such as a cancel, that outcome is kept.
  • I checked the other places that use this: Docker is the only caller of beginExecution, and the agents already turn costCapExceeded into the cost_cap termination.

Regression tests

  • packages/core/test/runCostCap.test.ts:
    • An execution finishes while a check is still pricing its $6 of usage under a $10 cap. The run is not stopped and no exceeded event is recorded.
    • Usage pushes the run past its cap and the execution finishes with no check in between. The guard reports the stop message once.
  • test/dockerExecutorLiveOutput.test.ts: a fake docker run prints a usage line with no trailing newline and exits. The test confirms that line is seen before the final check, and that the result is costCapExceeded (or RunCostCapExceededError when partial output isn't kept).

Verification: npm run typecheck and npm run lint pass. The guard, enforcement, Docker executor, Docker abort/ownership and task-container test files pass: 29 tests, 0 failures. I didn't run the full suite. To run the tests, I first installed dependencies with npm ci && npm run test:prepare; no setup files changed.

Nothing visible to users changed, so there are no previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 5m 5s
  • Tokens: 1,500,129 (1,487,067 in / 13,062 out)
  • Cost: $0.85

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

…he three new regression tests fail on the old code and pass with the fix.

I fixed F1 and F2. Both cases now behave as intended, and the three new regression tests fail on the old code and pass with the fix.

**F1 – an execution could be counted twice** (`packages/core/src/budget/runCostGuard.ts`)
- The check now copies the lists of running and finished executions in a single step, before it starts the slow pricing lookup, and uses only those copies. An execution that finishes during pricing can no longer appear in both lists.
- It still reads the recorded spend first. Rows are only written after an execution finishes, so a running execution can't be counted both in recorded spend and in live usage.

**F2 – a run could finish above its cap without the spend-cap outcome**
- In the guard, `finish()` now returns a promise. It moves the execution to the finished list and waits for any check already running. Then it runs a fresh check that includes the final usage, and returns the stop message if the run reached its cap. Calling it twice gives the same result. The interface change is in `runCostGuardContext.ts`.
- In `dockerExecutor.ts`, when the agent process exits, the executor now reads its last output line (even one with no trailing newline) and then waits for that final check before settling the result. If the cap was reached, the result goes through the same path as a run stopped mid-way: partial output marked `costCapExceeded` when the caller can publish it, otherwise `RunCostCapExceededError`. That gives the run the `cost_cap_exceeded` terminal reason, the `budget.exceeded` event and the notice. If the run was already aborted for another reason, such as a cancel, that outcome is kept.
- I checked the other places that use this: Docker is the only caller of `beginExecution`, and the agents already turn `costCapExceeded` into the `cost_cap` termination.

**Regression tests**
- `packages/core/test/runCostCap.test.ts`:
  - An execution finishes while a check is still pricing its $6 of usage under a $10 cap. The run is not stopped and no exceeded event is recorded.
  - Usage pushes the run past its cap and the execution finishes with no check in between. The guard reports the stop message once.
- `test/dockerExecutorLiveOutput.test.ts`: a fake `docker run` prints a usage line with no trailing newline and exits. The test confirms that line is seen before the final check, and that the result is `costCapExceeded` (or `RunCostCapExceededError` when partial output isn't kept).

**Verification:** `npm run typecheck` and `npm run lint` pass. The guard, enforcement, Docker executor, Docker abort/ownership and task-container test files pass: 29 tests, 0 failures. I didn't run the full suite. To run the tests, I first installed dependencies with `npm ci && npm run test:prepare`; no setup files changed.

Nothing visible to users changed, so there are no previews.

PR: #2758
Comment by: @propr-ultrafix (ID: 0)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 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 Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds spend-cap configuration, execution guards, terminal reasons, and user-facing reporting. It needs changes before merge: default-model PR runs can escape live pricing, and final cost reconciliation can miss a cap crossing.

✅ Consistent cap precedence — Task, workflow, and instance caps share a resolver with explicit handling for zero, malformed values, and upper bounds.

✅ Partial-output handling — Docker execution awaits its final usage evaluation and preserves output for callers that support partial publication.

✅ Focused regression coverage — Added tests cover message deduplication, simultaneous executions, exhausted retry budgets, and usage arriving immediately before exit.

This is a static review of the supplied code; no commands or tests were executed. No current-head check runs were reported.

Merge blockers

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

F3: 🔴 Default-model PR runs lack live pricing

  • Required behavior: Spend caps must apply to PR follow-ups, fixes, and reviews that use configured model defaults.

  • Evidence: src/jobs/runCostCap.ts, pullRequestRunCostCapTarget(); packages/core/src/claude/docker/dockerExecutor.ts, beginExecution() call; packages/core/src/budget/runCostGuard.ts, cost().

    1. A capped PR job omits the optional data.llm, using the configured agent/model defaults. pullRequestRunCostCapTarget() consequently leaves defaultModel undefined.
    2. Docker registers the execution without passing the optional model argument to beginExecution().
    3. The execution emits Codex-style turn.completed usage records without a model identifier—the same record shape used by the new tally test. These populate token totals but leave tally.model undefined.
    4. cost() skips pricing because neither model source exists. These records also supply no provider-reported dollar cost, so the execution contributes zero live spend.
    5. The final evaluation runs before Docker returns and before the execution cost is persisted. With no earlier recorded spend or later execution, the task completes without enforcing its cap.

    The configured model used by the agent never reaches the guard. Database polling cannot stop this execution because its cost row is written after execution finishes. static trace: the target construction, Docker registration, tally parser, pricing condition, and supplied persistence contract establish this sequence.

  • Minimum fix: Pass the resolved model for each agent execution into its cost registration. Cover a PR job with no explicit llm whose model-free usage records exceed the cap.

F4: 🔴 Final reconciliation drops recorded analysis spend

  • Required behavior: Enforcement must count both task-attributed analysis costs and agent consumption, including usage reported immediately before execution exits.

  • Evidence: packages/core/src/budget/runCostGuard.ts, finishExecution() and snapshot().

    1. A run starts with a $2 cap and no prior spend, setting priorSpentUsd to zero.
    2. Task-attributed analysis records $0.50 after guard startup. The implementation execution remains below the cap at its last periodic check.
    3. Immediately before exit, that execution reports usage worth $1.70. finishExecution() moves its tally from live to finished before the final check.
    4. Its execution row has not yet been written, so snapshot() sees recorded = 0.50, liveUsd = 0, and finishedUsd = 1.70. The formula returns Math.max(0.50, 1.70), or $1.70, rather than the actual $2.20.
    5. Finalization returns no cap termination. Once the execution row is persisted, deterministic publication can finish without another Docker execution; the timer has already stopped, and closing the guard performs no final reconciliation.

    The two estimates overlap only partly: taking their maximum discards the separate analysis expense. The added final-usage tests use zero recorded spend, so they do not cover this combination. static trace: this follows directly from the collection move and arithmetic, together with the documented inclusion of task-attributed analysis and the supplied post-execution persistence contract.

  • Minimum fix: Reconcile observed executions with their corresponding persisted costs so unpersisted final usage is added to other recorded calls without double-counting. Add the $0.50 analysis plus $1.70 final-usage regression.

Suggestions

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

S2: 🟢 Expose live spend in task details

packages/api/routes/taskBudget.ts reads only persisted execution costs, while enforcement also tracks streamed usage. During a long execution, the displayed spend can therefore remain zero even as the guard approaches its cap. Exposing a recent live snapshot would improve operator visibility; this is optional because the API currently describes its figure as recorded spend.

Score

The configuration and reporting integration are substantial, but two enforcement gaps undermine the central spending-limit guarantee. The focused tests need coverage for effective-model propagation and mixed recorded/live accounting.

Score: 5/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 30s
  • Tokens: 95,001 (92,399 in / 2,602 out)
  • Cost: $0.94

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

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 8a96ac5

Addressed 1 AI review comment (IDs: 6006541721)

Addressed findings F3, F4

Summary of Changes

I fixed F3 and F4. Lint, typecheck and 260 tests across the 16 Docker-executor and spend-cap test files pass. Seven of the new assertions fail on the old code and pass with the fix: the agent-level model checks (each fails all ten agent tests), the F4 test, and the Docker-level F3 test.

F3: PR runs on the default model now get priced

  • The Docker executor takes a new model option and passes it to the guard when it registers an agent container (dockerExecutor.ts).
  • Every agent passes the model it actually resolved, falling back to its configured default. That covers both implementation and analysis runs in Claude, Codex, OpenCode, Vibe and Antigravity, and the older Claude Code path in claudeService.ts. So a PR job with no explicit llm is priced even when its usage records (like Codex turn.completed) name no model.
  • Tests:
    • test/analysisGitAccess.test.ts checks that all five agents, run without a model, pass their configured default.
    • test/dockerExecutorLiveOutput.test.ts runs a fake docker that prints model-free Codex usage worth $3 against a $2 cap, with a guard that has no default model. The run now ends at the cap.
    • test/runCostCapEnforcement.test.ts builds a PR job without llm, confirms no model is set on it, and checks that the model the execution registers is the one used for pricing.

F4: analysis spend is no longer dropped at the final check

  • The old final check took whichever was larger: recorded spend, or observed usage. It now adds them, without counting anything twice.
  • When an execution ends, the guard reads the recorded spend before that execution's own row can be written. From then on:
    • Spend recorded after that point is treated as the execution's own row.
    • Only the part of its observed usage not yet covered by that row is added on top.
    • Spend recorded before it ended, such as analysis, is always counted on its own.
  • Tests in packages/core/test/runCostCap.test.ts:
    • The requested case: $0.50 of analysis, then $1.70 of usage reported just before exit, now stops the run at $2.20.
    • A second test checks that once the execution's $1.70 row is written, it replaces the observed usage instead of being added to it, and that a later $0.90 analysis call pushes past the cap. That test passes on the old code too; it is there to guard the new formula.

One race the fix can't close: if a call the guard didn't watch gets recorded in the short gap between an execution ending and that execution's own row being written, it is taken as part of that row. Spend is then undercounted by up to the smaller of the two amounts, never double-counted. Closing this would need each row matched to its execution in the database.

Separate issue, not changed: Claude native goal runs (claudeNativeGoal.ts) start docker directly rather than through the Docker executor, so the spend guard never sees them. That isn't part of the PR-run paths these findings cover.

To run the tests I installed dependencies (npm ci and npm run test:prepare), which .propr/setup.sh already does, so no setup changes were needed. There's nothing visual in this change, so I made no preview.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 5m 8s
  • Tokens: 2,775,811 (2,754,904 in / 20,907 out)
  • Cost: $1.46

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

… 16 Docker-executor and spend-cap test files pass. Seven of the new assertions fail on the old code and pass with the fix: the agent-level model checks (each fails all ten agent tests), the F4 test, and the Docker-level F3 test.

I fixed F3 and F4. Lint, typecheck and 260 tests across the 16 Docker-executor and spend-cap test files pass. Seven of the new assertions fail on the old code and pass with the fix: the agent-level model checks (each fails all ten agent tests), the F4 test, and the Docker-level F3 test.

**F3: PR runs on the default model now get priced**
- The Docker executor takes a new `model` option and passes it to the guard when it registers an agent container (`dockerExecutor.ts`).
- Every agent passes the model it actually resolved, falling back to its configured default. That covers both implementation and analysis runs in Claude, Codex, OpenCode, Vibe and Antigravity, and the older Claude Code path in `claudeService.ts`. So a PR job with no explicit `llm` is priced even when its usage records (like Codex `turn.completed`) name no model.
- Tests:
  - `test/analysisGitAccess.test.ts` checks that all five agents, run without a model, pass their configured default.
  - `test/dockerExecutorLiveOutput.test.ts` runs a fake `docker` that prints model-free Codex usage worth $3 against a $2 cap, with a guard that has no default model. The run now ends at the cap.
  - `test/runCostCapEnforcement.test.ts` builds a PR job without `llm`, confirms no model is set on it, and checks that the model the execution registers is the one used for pricing.

**F4: analysis spend is no longer dropped at the final check**
- The old final check took whichever was larger: recorded spend, or observed usage. It now adds them, without counting anything twice.
- When an execution ends, the guard reads the recorded spend before that execution's own row can be written. From then on:
  - Spend recorded after that point is treated as the execution's own row.
  - Only the part of its observed usage not yet covered by that row is added on top.
  - Spend recorded before it ended, such as analysis, is always counted on its own.
- Tests in `packages/core/test/runCostCap.test.ts`:
  - The requested case: $0.50 of analysis, then $1.70 of usage reported just before exit, now stops the run at $2.20.
  - A second test checks that once the execution's $1.70 row is written, it replaces the observed usage instead of being added to it, and that a later $0.90 analysis call pushes past the cap. That test passes on the old code too; it is there to guard the new formula.

**One race the fix can't close:** if a call the guard didn't watch gets recorded in the short gap between an execution ending and that execution's own row being written, it is taken as part of that row. Spend is then undercounted by up to the smaller of the two amounts, never double-counted. Closing this would need each row matched to its execution in the database.

**Separate issue, not changed:** Claude native goal runs (`claudeNativeGoal.ts`) start `docker` directly rather than through the Docker executor, so the spend guard never sees them. That isn't part of the PR-run paths these findings cover.

To run the tests I installed dependencies (`npm ci` and `npm run test:prepare`), which `.propr/setup.sh` already does, so no setup changes were needed. There's nothing visual in this change, so I made no preview.

PR: #2758
Comment by: @propr-ultrafix (ID: 0)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 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 Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds spend-cap configuration, streamed usage accounting, container cancellation, and reporting across the API, CLI, and UI. It needs changes before merge because finished-execution reconciliation can undercount actual spend.

✅ Consistent configuration precedence — Task overrides, workflow caps, and instance defaults resolve through one shared implementation.

✅ Partial-output preservation — Docker termination carries a distinct cost-cap outcome into the existing partial-publication paths, including a final usage evaluation after process exit.

This is a static review of the supplied code; no commands were run. No current-head check runs were reported.

Merge blockers

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

F5: 🔴 Reconcile recorded spend by execution

  • Required behavior: All expenditure within a run must count toward its cap, including observed execution costs whose database persistence fails.

  • Evidence: packages/core/src/budget/runCostGuard.ts, snapshot() and finishExecution().

    static trace:

    1. A run has a $2.50 cap. Execution A finishes with $1 of observed usage and recordedAtFinish = 0. Its metrics insert fails; the supplied persistToDatabase() implementation catches that failure and allows processing to continue.
    2. Execution B finishes with another $1 of usage before either execution has a recorded row. Both finished tallies therefore have recordedAtFinish = 0; their combined $2 remains below the cap.
    3. B's metrics insert succeeds, raising recorded spend to $1. On the next check, snapshot() subtracts that same $1 increase independently from both finished tallies. The calculated spend drops to $1 although the run spent $2.
    4. A subsequent execution spends $0.75. The guard calculates $1.75 and permits it to continue, although actual observed expenditure is $2.75 and exceeds the cap.

    The retained tallies are intended to preserve unrecorded usage, but aggregate database growth cannot identify which tally was persisted. The existing reconciliation test covers only one finished execution with a successful insert, so it does not exercise this sequence. No concurrency or ownership loss is necessary.

    proposed regression: reproduce these sequential executions with a mutable recorded-spend stub and assert that the final execution triggers the $2.50 cap.

  • Minimum fix: Reconcile each finished tally with its corresponding persisted execution, preserving unmatched observed costs. Do not independently reuse an aggregate recorded-spend increase to retire multiple tallies.

Suggestions

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

S3: 🟢 Expose live budget estimates

loadTaskBudget() reads only persisted execution costs, whereas enforcement also uses streamed usage. Consequently, the UI can show zero spend throughout the main execution. Exposing the guard's latest estimate would make progress more useful; this is optional because the API currently describes its value as recorded spend.

S4: 🟢 Add provider-shaped usage fixtures

The new tally tests exercise Claude and Codex records, while enforcement is connected to all five adapters. Fixtures from Antigravity, OpenCode, and Vibe would establish which usage records contribute during execution and catch parser drift. This is additional coverage, not a verified provider-specific defect.

Score

The configuration and termination integration are substantial, but the accounting defect undermines the central enforcement guarantee. Validation is limited to static inspection, with no reported current-head checks.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 12s
  • Tokens: 99,253 (97,367 in / 1,886 out)
  • Cost: $0.96

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

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 3cccddd

Addressed 1 AI review comment (IDs: 6006722726)

Addressed finding F5

Summary of Changes

I fixed F5. One recorded row can no longer retire more than one finished execution, so a cost whose database insert failed still counts toward the cap. The two new regressions fail on the old guard and pass with the fix.

How it works now

  • Tracking the session: while an execution streams, RunUsageTally notes its session ID (session_id, Codex thread_id, or the init conversation_id). It uses the same detection the executor uses when it records the session ID with the execution's row.
  • Per-session totals: readRecordedTaskSpend now returns the total plus a breakdown by session (GROUP BY session_id). RunCostGuard accepts either that or a plain number.
  • Matching rows to executions: in packages/core/src/budget/runCostGuard.ts, a finished execution with a session ID is only matched against recorded growth for that session since it ended. Spend recorded for other sessions never covers it.
  • Fallback when there's no session ID or breakdown: the remaining growth is shared out once, in the order executions finished. Each recorded dollar covers at most one execution, and any observed cost left uncovered still counts.

Tests (in packages/core/test/runCostCap.test.ts)

  • The F5 sequence: a $2.50 cap with a plain-number recorded-spend stub. Executions A and B each spend $1, A's insert fails and B's succeeds, then a third execution spends $0.75. The guard now stops the run at $2.75; before the fix it saw $1.75 and let it continue.
  • Session matching: B's recorded row and an unrelated $0.20 analysis row don't cover A's failed insert.
  • Session detection: the tally picks up Claude, Codex and init-style session IDs.

Checks

  • The cap tests, the cap-enforcement tests and the Docker live-output tests pass (26/26).
  • npm run typecheck passes, and eslint is clean on packages/core/src/budget.
  • I ran the new grouped query against an in-memory SQLite database and it returned the expected per-session sums.
  • The container had no node_modules, so I ran npm ci and npm run test:prepare first, following .propr/setup.sh. No setup files changed.

Decision for you: when a per-session breakdown is available, an execution that reported a session ID is matched only to that session. If a provider ever stored a row under a different ID than it streamed, that execution would be counted twice and the run stopped early. I chose that over undercounting. Under the fallback, recorded growth that isn't really the execution's own row (such as an analysis call) can still cover it; this was already true before the change.

There's no visual preview because the change has no visible effect.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 6m 56s
  • Tokens: 2,336,369 (2,315,253 in / 21,116 out)
  • Cost: $1.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

… one finished execution, so a cost whose database insert failed still counts toward the cap. The two new regressions fail on the old guard and pass with the fix.

I fixed F5. One recorded row can no longer retire more than one finished execution, so a cost whose database insert failed still counts toward the cap. The two new regressions fail on the old guard and pass with the fix.

**How it works now**
- **Tracking the session:** while an execution streams, `RunUsageTally` notes its session ID (`session_id`, Codex `thread_id`, or the `init` `conversation_id`). It uses the same detection the executor uses when it records the session ID with the execution's row.
- **Per-session totals:** `readRecordedTaskSpend` now returns the total plus a breakdown by session (`GROUP BY session_id`). `RunCostGuard` accepts either that or a plain number.
- **Matching rows to executions:** in `packages/core/src/budget/runCostGuard.ts`, a finished execution with a session ID is only matched against recorded growth for that session since it ended. Spend recorded for other sessions never covers it.
- **Fallback when there's no session ID or breakdown:** the remaining growth is shared out once, in the order executions finished. Each recorded dollar covers at most one execution, and any observed cost left uncovered still counts.

**Tests** (in `packages/core/test/runCostCap.test.ts`)
- **The F5 sequence:** a $2.50 cap with a plain-number recorded-spend stub. Executions A and B each spend $1, A's insert fails and B's succeeds, then a third execution spends $0.75. The guard now stops the run at $2.75; before the fix it saw $1.75 and let it continue.
- **Session matching:** B's recorded row and an unrelated $0.20 analysis row don't cover A's failed insert.
- **Session detection:** the tally picks up Claude, Codex and `init`-style session IDs.

**Checks**
- The cap tests, the cap-enforcement tests and the Docker live-output tests pass (26/26).
- `npm run typecheck` passes, and eslint is clean on `packages/core/src/budget`.
- I ran the new grouped query against an in-memory SQLite database and it returned the expected per-session sums.
- The container had no `node_modules`, so I ran `npm ci` and `npm run test:prepare` first, following `.propr/setup.sh`. No setup files changed.

**Decision for you:** when a per-session breakdown is available, an execution that reported a session ID is matched only to that session. If a provider ever stored a row under a different ID than it streamed, that execution would be counted twice and the run stopped early. I chose that over undercounting. Under the fallback, recorded growth that isn't really the execution's own row (such as an analysis call) can still cover it; this was already true before the change.

There's no visual preview because the change has no visible effect.

PR: #2758
Comment by: @propr-ultrafix (ID: 0)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 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 Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds spend-cap configuration, execution monitoring, interruption handling, and user-visible reporting. It needs minor changes before merge because historical retry budgets can report incorrect spending.

✅ Configuration precedence — Task overrides, repository caps, and instance defaults resolve consistently, with explicit handling of zero and malformed values.

✅ Final usage evaluation — Docker completion awaits the guard’s final evaluation, covering usage received after the last periodic check.

This review used static analysis of the supplied code; no commands were run. No current-head check runs were reported.

Merge blockers

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

F6: 🔴 Preserve retry spending after cache expiry

  • Required behavior: Task history must accurately report the run’s spend against its cap, including earlier attempts whose spending belongs to that run.

  • Evidence: packages/api/routes/taskBudget.ts:48–58, loadTaskBudget; packages/core/src/budget/runCostCapStore.ts:8; src/jobs/runCostCap.ts, budgetExceededEvent.

    1. A PR attempt spends $4 and schedules a usage-limit retry carrying its task ID in costBudgetTaskIds.
    2. The retry spends $1.20 against a $5 cap. The guard records a budget.exceeded event containing $5.20, while Redis stores the earlier task IDs.
    3. After the resolved-cap key expires at 90 days, a request for retained task history recovers the $5 cap from the event.
    4. loadTaskBudget obtains earlier task IDs only from Redis and ignores the event’s recorded spending. It consequently returns $1.20 and 24%, alongside exceeded: true, instead of the run’s $5.20 and 104%.

    The fallback preserves the cap but loses the spending relationship. The database aggregation cannot recover earlier attempts without their IDs. static trace: the retry propagation, Redis expiration, event fields, and fallback calculation demonstrate this sequence; no test was executed.

  • Minimum fix: Persist the budget’s earlier task IDs in durable task history and use them when Redis metadata is unavailable, so the response continues aggregating the same run.

Suggestions

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

S5: 🟢 Test provider-native usage records

The new tally tests exercise Claude and Codex records, while enforcement is attached to all five agent adapters. Fixtures from OpenCode, Vibe, and Antigravity would help establish that their actual streaming formats produce increasing spend before termination. This is optional coverage; the supplied context does not establish a specific incompatible provider record.

S6: 🟢 Verify the post-cap execution exemption

RunCostGuard.beginExecution exempts every subsequent execution once the guard triggers. An integration test covering preliminary analysis, implementation, retries, and publication would help verify that only publication work continues after exhaustion. The exemption is explicit, but the supplied caller context does not demonstrate a non-publication continuation, so this remains a follow-up rather than a verified blocker.

Score

The enforcement and termination integration are substantial, with focused boundary tests. The demonstrated historical budget error requires a localized correction before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 37s
  • Tokens: 100,133 (97,529 in / 2,604 out)
  • Cost: $0.99

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 S6

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit ce0db59

Addressed 1 AI review comment (IDs: 6006938112)

Addressed finding F6

Summary of Changes

I fixed F6. When a retry hits its spend cap, task history now keeps adding up the earlier attempts' spending even after the 90-day Redis record has expired. In the finding's example it now reports $5.20 and 104% instead of $1.20 and 24%.

What changed

  • The event now records the earlier attempts (src/jobs/runCostCap.ts): the budget.exceeded event written to task history now includes the earlier attempts' task IDs (budgetTaskIds). It's left out when there are none, so existing events look the same. withRunCostCap passes the cleaned-up list (duplicates, blanks and the run's own ID removed) to the code that records the stop.
  • Task history uses them as a fallback (packages/api/routes/taskBudget.ts): loadTaskBudget now combines the task IDs from Redis and from the event before summing the recorded costs, without counting any task twice. Before, it only took them from Redis, so after expiry it counted just the retry.

Tests

  • packages/api/test/taskBudget.test.ts (new): one test covers the finding's case: Redis returns nothing and the event carries the earlier ID, giving $5.20 / 104% / exceeded: true. A second test checks that IDs in both Redis and the event aren't double-counted.
  • test/runCostCapEnforcement.test.ts: a new test checks that the recorded event keeps only the cleaned-up list of earlier task IDs.

The new expired-Redis test and the new event test both fail on the old code and pass with the fix. These three test files pass: taskBudget, runCostCapEnforcement and taskHistoryRoutes. Typecheck and lint pass for the root project and packages/api. I didn't run the full suite.

Limits

  • Only stopped runs are covered. The budget.exceeded event is the only lasting record. If a run never hit its cap and its Redis record expires, both the cap and the earlier attempts are still lost. Covering that would mean writing a history entry for every run, which is outside F6.
  • Old events stay as they were. Events recorded before this change have no task IDs, so they still show only the retry's own spending.

Environment: the workspace had no node_modules, and the provided npm cache (PROPR_CACHE_DIR) is read-only. I ran the install and build steps from .propr/setup.sh (npm ci && npm run test:prepare) with a temporary cache in /tmp. I didn't change any setup files. The ProPR image's cache location should be made writable.

There's nothing visual to preview: the task details screen simply shows the corrected figures.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 8m 13s
  • Tokens: 1,137,184 (1,129,334 in / 7,850 out)
  • Cost: $0.62

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

…ow keeps adding up the earlier attempts' spending even after the 90-day Redis record has expired. In the finding's example it now reports $5.20 and 104% instead of $1.20 and 24%.

I fixed F6. When a retry hits its spend cap, task history now keeps adding up the earlier attempts' spending even after the 90-day Redis record has expired. In the finding's example it now reports $5.20 and 104% instead of $1.20 and 24%.

**What changed**
- **The event now records the earlier attempts** (`src/jobs/runCostCap.ts`): the `budget.exceeded` event written to task history now includes the earlier attempts' task IDs (`budgetTaskIds`). It's left out when there are none, so existing events look the same. `withRunCostCap` passes the cleaned-up list (duplicates, blanks and the run's own ID removed) to the code that records the stop.
- **Task history uses them as a fallback** (`packages/api/routes/taskBudget.ts`): `loadTaskBudget` now combines the task IDs from Redis and from the event before summing the recorded costs, without counting any task twice. Before, it only took them from Redis, so after expiry it counted just the retry.

**Tests**
- `packages/api/test/taskBudget.test.ts` (new): one test covers the finding's case: Redis returns nothing and the event carries the earlier ID, giving $5.20 / 104% / `exceeded: true`. A second test checks that IDs in both Redis and the event aren't double-counted.
- `test/runCostCapEnforcement.test.ts`: a new test checks that the recorded event keeps only the cleaned-up list of earlier task IDs.

The new expired-Redis test and the new event test both fail on the old code and pass with the fix. These three test files pass: `taskBudget`, `runCostCapEnforcement` and `taskHistoryRoutes`. Typecheck and lint pass for the root project and `packages/api`. I didn't run the full suite.

**Limits**
- **Only stopped runs are covered.** The `budget.exceeded` event is the only lasting record. If a run never hit its cap and its Redis record expires, both the cap and the earlier attempts are still lost. Covering that would mean writing a history entry for every run, which is outside F6.
- **Old events stay as they were.** Events recorded before this change have no task IDs, so they still show only the retry's own spending.

**Environment:** the workspace had no `node_modules`, and the provided npm cache (`PROPR_CACHE_DIR`) is read-only. I ran the install and build steps from `.propr/setup.sh` (`npm ci && npm run test:prepare`) with a temporary cache in `/tmp`. I didn't change any setup files. The ProPR image's cache location should be made writable.

There's nothing visual to preview: the task details screen simply shows the corrected figures.

PR: #2758
Comment by: @propr-ultrafix (ID: 0)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 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 Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds cap configuration, streamed cost enforcement, interruption handling, and budget reporting across the API, CLI, and UI. It needs changes before merge because task details can contradict the recorded spend-cap event.

✅ Explicit precedence — Cap resolution consistently selects the task override, workflow cap, then instance default, with boundary tests.

✅ Final usage evaluation — Docker execution awaits the final budget check, including an unterminated last output record, before reporting its outcome.

This review used static analysis of the supplied code; no commands or tests were run. No current-head check runs were reported.

Merge blockers

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

F7: 🔴 Preserve observed spend in task details

  • Required behavior: Task details must report the estimated spend that caused enforcement, including execution costs that could not be persisted.

  • Evidence: packages/api/routes/taskBudget.ts:loadTaskBudget, packages/core/src/budget/runCostGuard.ts:unrecordedUsd

    1. A capped run accumulates streamed usage whose execution row fails to persist. The guard explicitly preserves this consumption; the added tests cover failed execution inserts.
    2. The guard reaches the cap and records a durable budget.exceeded event containing the observed spentUsd.
    3. loadTaskBudget reads that event but calculates spend exclusively from SUM(llm_executions.cost_usd), discarding the event’s observed spend.
    4. With a $5 cap, $5.20 observed spend, and no successfully recorded execution costs, the API returns spentUsd: 0, percent: 0, and exceeded: true. The CLI and UI consequently show a run stopped at its cap as having spent nothing.

    static trace: The event writer preserves snapshot.spentUsd, but StoredCap and the returned budget calculation never consume it. Existing guard tests protect enforcement after failed inserts; the API tests only exercise cases where all costs are persisted.

  • Minimum fix: Validate the exceeded event’s spentUsd and use it as a lower bound for displayed spend alongside the recorded total. Derive the percentage from that reconciled amount without adding the two totals together.

Suggestions

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

S7: 🟢 Verify continuation after enforcement

RunCostGuard.beginExecution returns null for every execution after the guard triggers, while the documented exemption concerns publication. Add a production-path regression demonstrating that a stopped preparatory analysis or provider retry cannot launch further implementation or review work uncapped. The supplied excerpts do not establish whether those callers already prevent continuation, so this is a verification follow-up rather than a demonstrated blocker.

S8: 🟢 Preserve historical cap configuration

Resolved caps expire from Redis after 90 days, while only exceeded runs retain a durable budget event. Consider recording the resolved cap for successful runs too, so historical task details continue distinguishing an uncapped run from one that completed below its cap. This is an optional retention improvement.

Score

The implementation has substantial targeted coverage and coherent configuration handling, but its new spend reporting loses consumption that enforcement deliberately preserves. Correct that inconsistency before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 27s
  • Tokens: 100,265 (98,027 in / 2,238 out)
  • Cost: $0.98

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

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit b65af81

Addressed 1 AI review comment (IDs: 6007166923)

Addressed finding F7

Summary of Changes

I fixed F7: task details now report the spend that stopped a capped run, even when that run's cost rows were never saved to the database.

What changed (packages/api/routes/taskBudget.ts)

  • loadTaskBudget now reads spentUsd from the budget.exceeded event. It only accepts a finite positive number; anything else counts as 0.
  • Displayed spend is now the larger of the event's spend and the saved total (SUM(llm_executions.cost_usd)). The two are never added, because both already cover the same task and its earlier attempts. Adding them would count the same spend twice once the rows are saved.
  • The percentage is calculated from that larger figure. In the finding's example ($5 cap, $5.20 spent, nothing saved), the API now returns spentUsd: 5.2, percent: 104, exceeded: true instead of 0 / 0%.

Other places checked: the CLI and the UI only display the spentUsd and percent the API returns, so fixing the API fixes them too. The guard itself and the event writer (src/jobs/runCostCap.ts) were already right: the event stores the spend the guard saw, including costs that were never saved.

New tests (packages/api/test/taskBudget.test.ts)

  • A capped run with no saved costs reports $5.20 and 104%.
  • When some costs are saved, the larger figure is used. Once the saved total passes the event's figure ($5.50), the saved total wins.
  • An invalid spentUsd in the event (a string, a negative number, NaN or null) is ignored.
  • I changed the test helper to skip the insert when there are no rows, because SQLite fails on an empty insert.

Verification

  • All 5 tests in the file pass with the fix. On the old code, the first two new tests fail and the other three pass.
  • tsc --noEmit for packages/api reports no errors. The root lint script doesn't cover packages/api, so ESLint ignored both files.
  • The repo's normal test runner (scripts/run-test-suite.mjs) timed out after 180s on this file. Redis isn't installed here, so the test's after cleanup (which calls closeConnection) never finishes. I ran the file through a temporary copy without that cleanup step, with PROPR_DEMO_MODE=true, and deleted the copy afterwards. To run it the normal way, Redis needs to be added to the agent image as a system package.
  • node_modules was missing, so I ran npm ci && npm run test:prepare first. No setup files changed.

There's no visual preview because only the numbers the API returns change, not the layout.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 13m 38s
  • Tokens: 1,237,025 (1,228,715 in / 8,310 out)
  • Cost: $0.61

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

…a capped run, even when that run's cost rows were never saved to the database.

I fixed F7: task details now report the spend that stopped a capped run, even when that run's cost rows were never saved to the database.

**What changed** (`packages/api/routes/taskBudget.ts`)
- `loadTaskBudget` now reads `spentUsd` from the `budget.exceeded` event. It only accepts a finite positive number; anything else counts as 0.
- Displayed spend is now the **larger** of the event's spend and the saved total (`SUM(llm_executions.cost_usd)`). The two are never added, because both already cover the same task and its earlier attempts. Adding them would count the same spend twice once the rows are saved.
- The percentage is calculated from that larger figure. In the finding's example ($5 cap, $5.20 spent, nothing saved), the API now returns `spentUsd: 5.2, percent: 104, exceeded: true` instead of `0 / 0%`.

**Other places checked:** the CLI and the UI only display the `spentUsd` and `percent` the API returns, so fixing the API fixes them too. The guard itself and the event writer (`src/jobs/runCostCap.ts`) were already right: the event stores the spend the guard saw, including costs that were never saved.

**New tests** (`packages/api/test/taskBudget.test.ts`)
- A capped run with no saved costs reports $5.20 and 104%.
- When some costs are saved, the larger figure is used. Once the saved total passes the event's figure ($5.50), the saved total wins.
- An invalid `spentUsd` in the event (a string, a negative number, NaN or null) is ignored.
- I changed the test helper to skip the insert when there are no rows, because SQLite fails on an empty insert.

**Verification**
- All 5 tests in the file pass with the fix. On the old code, the first two new tests fail and the other three pass.
- `tsc --noEmit` for `packages/api` reports no errors. The root lint script doesn't cover `packages/api`, so ESLint ignored both files.
- The repo's normal test runner (`scripts/run-test-suite.mjs`) timed out after 180s on this file. Redis isn't installed here, so the test's `after` cleanup (which calls `closeConnection`) never finishes. I ran the file through a temporary copy without that cleanup step, with `PROPR_DEMO_MODE=true`, and deleted the copy afterwards. To run it the normal way, Redis needs to be added to the agent image as a system package.
- `node_modules` was missing, so I ran `npm ci && npm run test:prepare` first. No setup files changed.

There's no visual preview because only the numbers the API returns change, not the layout.

PR: #2758
Comment by: @propr-ultrafix (ID: 0)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Ultrafix stopped before reaching its goal. Requested goal: 8/10. Last score: unknown. Max cycles were exhausted, so manual review and merge are now required.

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/ultrafix goal=8 max=3

@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/fix F12

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 22bfb60

Addressed 1 AI review comment (IDs: 6009552500)

Addressed finding F12

Summary of Changes

I fixed F12. If a capped run can't read its recorded spend, it now fails before any agent container starts. Before, the failed read counted as $0, so a retry that had already used up its budget could launch again.

What changed (packages/core/src/budget/runCostGuard.ts):

  • Two kinds of read. The guard now has a strict read that passes the error on, and a best-effort read that falls back to the last known spend. The strict one is used only where the decision is whether to start.
  • start(): when the run has a cap, it uses the strict read. The error reaches withRunCostCap, so the attempt fails through the normal failure and retry path that F11 set up, before any agent starts. A run with no cap still reads best-effort, because its earlier spend doesn't change anything yet.
  • admit(): it now evaluates the spend from its own strict read. Before, it called check(), which could fall back to a stale or zero figure. If the read fails, admission is refused. admitCostExecution in dockerExecutor.ts already passes non-cap errors on, so executeDockerCommand fails and the container never starts. No Docker change was needed.
  • Periodic checks and the reads taken as an execution finishes are still best-effort. A brief database error while agents run shouldn't stop them, and admission doesn't rely on those reads.

Same problem elsewhere: a run that starts uncapped and gets its cap later from the workflow file never had an authoritative read at start. Its first chargeable launch now goes through the strict read in admit(), so it's covered. The issue and PR entry points both pass errors from withRunCostCap on to their existing failure handling, so a failed read at start() can't fall through to an uncapped run.

Tests:

  • packages/core/test/runCostCap.test.ts, two new tests:
    • A capped run whose read fails rejects at start() and at admit(), and no stop is recorded.
    • A run capped after start rejects at admission when the read fails. Once reads work again, an exhausted budget is refused as before.
  • test/dockerExecutorLiveOutput.test.ts: a capped run with failing spend reads launches no container through executeDockerCommand.
  • All three new tests fail against the old guard. With the fix, 44 of 44 pass across those two files and test/runCostCapEnforcement.test.ts.
  • npm run typecheck and npm run lint pass. I didn't run the full suite.

To run the tests I had to run .propr/setup.sh first, because dependencies weren't installed. No setup files changed. There's no visual change, so I made no previews.

The Gmail, Google Calendar and Google Drive connectors need to be authorized in your claude.ai connector settings before they can be used. This task didn't need them.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 4m 9s
  • Tokens: 927,127 (916,978 in / 10,149 out)
  • Cost: $0.63
  • Subscription usage: Session +1%

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

… it now fails before any agent container starts. Before, the failed read counted as $0, so a retry that had already used up its budget could launch again.

I fixed F12. If a capped run can't read its recorded spend, it now fails before any agent container starts. Before, the failed read counted as $0, so a retry that had already used up its budget could launch again.

**What changed** (`packages/core/src/budget/runCostGuard.ts`):
- **Two kinds of read.** The guard now has a strict read that passes the error on, and a best-effort read that falls back to the last known spend. The strict one is used only where the decision is whether to start.
- **`start()`:** when the run has a cap, it uses the strict read. The error reaches `withRunCostCap`, so the attempt fails through the normal failure and retry path that F11 set up, before any agent starts. A run with no cap still reads best-effort, because its earlier spend doesn't change anything yet.
- **`admit()`:** it now evaluates the spend from its own strict read. Before, it called `check()`, which could fall back to a stale or zero figure. If the read fails, admission is refused. `admitCostExecution` in `dockerExecutor.ts` already passes non-cap errors on, so `executeDockerCommand` fails and the container never starts. No Docker change was needed.
- **Periodic checks** and the reads taken as an execution finishes are still best-effort. A brief database error while agents run shouldn't stop them, and admission doesn't rely on those reads.

**Same problem elsewhere:** a run that starts uncapped and gets its cap later from the workflow file never had an authoritative read at start. Its first chargeable launch now goes through the strict read in `admit()`, so it's covered. The issue and PR entry points both pass errors from `withRunCostCap` on to their existing failure handling, so a failed read at `start()` can't fall through to an uncapped run.

**Tests:**
- `packages/core/test/runCostCap.test.ts`, two new tests:
  - A capped run whose read fails rejects at `start()` and at `admit()`, and no stop is recorded.
  - A run capped after start rejects at admission when the read fails. Once reads work again, an exhausted budget is refused as before.
- `test/dockerExecutorLiveOutput.test.ts`: a capped run with failing spend reads launches no container through `executeDockerCommand`.
- All three new tests fail against the old guard. With the fix, 44 of 44 pass across those two files and `test/runCostCapEnforcement.test.ts`.
- `npm run typecheck` and `npm run lint` pass. I didn't run the full suite.

To run the tests I had to run `.propr/setup.sh` first, because dependencies weren't installed. No setup files changed. There's no visual change, so I made no previews.

The Gmail, Google Calendar and Google Drive connectors need to be authorized in your claude.ai connector settings before they can be used. This task didn't need them.

PR: #2758
Comment by: @integry (ID: 6009566917)
Model: claude-opus-5-5
@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/review

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR implements spend-cap configuration, enforcement, partial-result handling, and reporting across the intended task paths. The supplied code appears merge-ready within scope; this assessment is static, and no current-head checks were reported.

✅ Admission before execution — Exhausted budgets refuse new agent containers, and unreadable recorded spend rejects capped admission.

✅ Final usage reconciliation — Execution completion awaits a final budget check, covering usage received after the last periodic check.

✅ Partial-work handling — The new termination reason flows through existing publication and task-completion paths, with targeted tests for accounting and terminal-state behavior.

Merge blockers

No merge blockers.

Suggestions

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

S17: 🟢 Cover every provider’s usage stream

The new tally tests exercise Claude and Codex usage records, while enforcement is wired into five agent adapters. Add representative output fixtures for Antigravity, OpenCode, and Vibe, checking cumulative spend and final usage against their existing metrics parsers. This would strengthen confidence in provider coverage; the supplied context does not establish a concrete incompatible stream format.

S18: 🟢 Preserve historical cap metadata

storeResolvedRunCostCap expires its Redis record after 90 days. For successful runs without a budget.exceeded event, loadTaskBudget subsequently returns recorded spend with no cap or source. Persisting resolved budget metadata in task history would preserve that historical context. This is an optional reporting improvement beyond active-run enforcement.

Score

The implementation has substantial targeted coverage and no verified merge blocker in the supplied code. Tests were not executed, as requested, and current-head validation remains unconfirmed.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 27s
  • Tokens: 109,980 (107,715 in / 2,265 out)
  • Cost: $1.13

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 S17 S18

🤖 Review by ProPR

@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Local verification on head 22bfb60 (clean npm ci, npm run test:prepare): npm run lint and npm run typecheck pass, but 4 of the 13 test files this PR touches fail. Please fix them (analysisGitAccess is a pre-existing timeout on main and can be ignored):

  1. test/prPublicationJob.test.ts and test/prPublicationRecoveryJob.test.ts fail to load:
    SyntaxError: The requested module './runCostCap.js' does not provide an export named 'pullRequestRunCostCapTarget'
    The mock.module('./runCostCap.js', …) stubs in both tests predate the F12 change and no longer export everything the job imports.

  2. test/dockerExecutorLiveOutput.test.ts:

    • an agent that crosses its spend cap and exits before the next check ends with the spend-cap outcome — expected ['finish after 1 line(s)'], got ['finish after 0 line(s)']: the final unterminated usage record is no longer observed before the final budget evaluation.
    • an agent on its default model is priced with the model it was started with when its usage names none — result.costCapExceeded is undefined, expected true.
      Either the guard's post-F12 admission/beginExecution flow regressed the "final record before final evaluation" guarantee that the PR body describes, or the tests need to drive the new admission read. Decide which is the intended behaviour, keep the guarantee if it is still required, and make the tests pass.

Run: node scripts/run-test-suite.mjs test/prPublicationJob.test.ts test/prPublicationRecoveryJob.test.ts test/dockerExecutorLiveOutput.test.ts and confirm all three pass before pushing.

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit af3b41c

Summary of Changes

All three test files now pass with the command you gave: node scripts/run-test-suite.mjs test/prPublicationJob.test.ts test/prPublicationRecoveryJob.test.ts test/dockerExecutorLiveOutput.test.ts reported "3/3 passed". npm run typecheck and npm run lint also pass. I only changed the three test files; no application code changed.

1. prPublicationJob and prPublicationRecoveryJob: the stubs of ./runCostCap.js in both tests had two problems.

  • They were missing pullRequestRunCostCapTarget, which caused the load error you saw.
  • Once the files loaded, three tests in prPublicationJob still failed. The stub applyWorkflowCostCap returned undefined, but the real one returns the workflow it's given. The job takes its workflow from that return value, so it lost it.

Both stubs now export the missing function and return the workflow they receive.

2. dockerExecutorLiveOutput: the spend-cap code didn't regress, and the "last record is read before the final budget check" guarantee still holds. The tests were running the wrong docker. Each test puts a fake docker on PATH, but the executor first looks for Docker at fixed paths (/usr/bin/docker, /usr/local/bin/docker, /bin/docker). On a machine with Docker installed, the real one runs instead. It fails on the made-up image and prints no usage, which gives exactly what you saw: "finish after 0 line(s)" and costCapExceeded undefined.

My sandbox has no Docker, so I reproduced this by temporarily adding a stand-in "installed Docker" ahead of those paths. Tests 4 and 5 failed exactly as you reported. Test 6 (a run stopped at its spend cap refuses later … containers) failed for the same reason, so expect it to fail on your machine too. The test file now hides those fixed paths so the fake docker on PATH always runs. With the stand-in still in place, all 8 tests pass.

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


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 5m 23s
  • Tokens: 1,349,030 (1,340,221 in / 8,809 out)
  • Cost: $0.70
  • Subscription usage: Session +1%, Fable +1%

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

…ode scripts/run-test-suite.mjs test/prPublicationJob.test.ts test/prPublicationRecoveryJob.test.ts test/dockerExecutorLiveOutput.test.ts` reported "3/3 passed". `npm run typecheck` and `npm run lint` also pass. I only changed the three test files; no application code changed.

All three test files now pass with the command you gave: `node scripts/run-test-suite.mjs test/prPublicationJob.test.ts test/prPublicationRecoveryJob.test.ts test/dockerExecutorLiveOutput.test.ts` reported "3/3 passed". `npm run typecheck` and `npm run lint` also pass. I only changed the three test files; no application code changed.

**1. `prPublicationJob` and `prPublicationRecoveryJob`:** the stubs of `./runCostCap.js` in both tests had two problems.
- They were missing `pullRequestRunCostCapTarget`, which caused the load error you saw.
- Once the files loaded, three tests in `prPublicationJob` still failed. The stub `applyWorkflowCostCap` returned `undefined`, but the real one returns the workflow it's given. The job takes its workflow from that return value, so it lost it.

Both stubs now export the missing function and return the workflow they receive.

**2. `dockerExecutorLiveOutput`:** the spend-cap code didn't regress, and the "last record is read before the final budget check" guarantee still holds. The tests were running the wrong `docker`. Each test puts a fake `docker` on `PATH`, but the executor first looks for Docker at fixed paths (`/usr/bin/docker`, `/usr/local/bin/docker`, `/bin/docker`). On a machine with Docker installed, the real one runs instead. It fails on the made-up image and prints no usage, which gives exactly what you saw: "finish after 0 line(s)" and `costCapExceeded` undefined.

My sandbox has no Docker, so I reproduced this by temporarily adding a stand-in "installed Docker" ahead of those paths. Tests 4 and 5 failed exactly as you reported. Test 6 (`a run stopped at its spend cap refuses later … containers`) failed for the same reason, so expect it to fail on your machine too. The test file now hides those fixed paths so the fake `docker` on `PATH` always runs. With the stand-in still in place, all 8 tests pass.

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

PR: #2758
Comment by: @integry (ID: 6009876668)
Model: claude-opus-5-5
@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/merge

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from main into 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3 in commit 0efc377

Conflicting Files

  • CHANGELOG.md
  • docs/docs/operations/settings-locations.md
  • packages/api/mcp/settingsCatalog.ts
  • packages/api/mcp/toolsManagement.ts
  • packages/api/routes/configHelpers.ts
  • packages/api/routes/configRoutes.ts
  • packages/api/routes/configRoutesSettings.ts
  • packages/api/routes/configSettings.ts
  • packages/cli/src/api/index.ts
  • packages/cli/src/api/settings.ts
  • packages/cli/src/commands/settingCommands.ts
  • packages/core/src/config/configManager.ts
  • packages/core/src/config/configManagerUltrafix.ts
  • propr-ui/src/components/TaskDetails/TaskStatusTable.tsx
  • propr-ui/src/components/TaskDetails/types.ts
  • test/configRoutes.followup.test.ts

Resolution Summary

All 16 conflicted files are resolved and no conflict markers are left in the repository. The 13 conflicted .ts files parse cleanly. I couldn't run npm run typecheck, lint or the tests because node_modules isn't installed here. Instead I stripped the types and ran node --check on each file. That catches syntax errors but not type errors, and it doesn't cover the .tsx file, which I checked by reading it. I also couldn't mark the files resolved with git add, because the git index is on a read-only filesystem.

What the conflicts were. Almost every conflict came from the same thing. This PR adds an instance setting, default_max_cost_usd (the per-run spend cap). main added two things in the same places: the ultrafix_ci_wait_timeout_ms setting and the push-salvage feature from #2755. The two sides changed different things, so in every case I kept both, with the PR's lines first.

File Conflict Resolution
CHANGELOG.md Both added entries under the same heading. The PR added "Per-run spend caps"; main added "Push salvage", "Managed agent in Linux desktop previews" and "Complete bundled third-party notices". Kept all of them.
docs/.../settings-locations.md Each side added a row to the settings table. Kept both rows.
packages/api/mcp/settingsCatalog.ts Each side added a settings catalog entry. Kept both entries.
packages/api/mcp/toolsManagement.ts Both edited the same one-line settingsShape object. Used main's line and added the PR's default_max_cost_usd field before auto_resolve_merge_conflicts.
configHelpers.ts, configRoutes.ts, configRoutesSettings.ts (2 conflicts) Each side added its key as the last item in the same lists and objects. Kept both keys and added the comma the PR's item now needs.
configSettings.ts (3 conflicts) Each side added a field to the settings interface, a name to the SettingSaveName type and a validation block. Kept both everywhere. Combining them left a stray ; in the type and a missing } after the PR's if block, and I fixed both.
packages/cli/src/api/settings.ts (3 conflicts), settingCommands.ts Each side added its field, documentation comment, valid key and help text. Kept both and repaired the comment blocks that were cut off where the two sides joined.
packages/cli/src/api/index.ts The PR exports TaskBudget; main exports TaskPushFailure. Export both.
configManager.ts, configManagerUltrafix.ts The PR adds loadDefaultMaxCostUsd and saveDefaultMaxCostUsd; main adds loadUltrafixCiWaitTimeoutMs, saveUltrafixCiWaitTimeoutMs and DEFAULT_ULTRAFIX_CI_WAIT_TIMEOUT_MS. Kept all the functions and re-exports, and put back the return true; } that the spend-cap save function lost.
propr-ui/.../TaskStatusTable.tsx main removed the RUN_RESULT_COLUMN import (that column no longer exists); the PR added the CircleDollarSign icon. Used main's imports and added CircleDollarSign, which the spend-cap status icon uses.
propr-ui/.../types.ts The PR added the event and budget metadata fields; main added pushFailure and pushSalvage. Kept all four.
test/configRoutes.followup.test.ts (4 conflicts) Each side added its setting to the expected settings in the same assertions. Expect both: default_max_cost_usd: 0 and ultrafix_ci_wait_timeout_ms: 7200000.

Why this approach. Both features are needed, so dropping either side would break the settings list, the API responses and the tests. Neither side changed the other's logic. The only real overlap was main removing RUN_RESULT_COLUMN from the UI, so I followed main there and kept only the PR's new icon.

Since only a syntax check ran, run npm run typecheck and the config route tests once dependencies are installed.


🤖 Resolution Details

  • Model: claude-opus-5-5
  • Time: 1m 40s

View Task Execution


System-triggered merge conflict resolution

…per-run-spend-cap-20261005-2330-yv3

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- CHANGELOG.md
- docs/docs/operations/settings-locations.md
- packages/api/mcp/settingsCatalog.ts
- packages/api/mcp/toolsManagement.ts
- packages/api/routes/configHelpers.ts
- packages/api/routes/configRoutes.ts
- packages/api/routes/configRoutesSettings.ts
- packages/api/routes/configSettings.ts
- packages/cli/src/api/index.ts
- packages/cli/src/api/settings.ts
- packages/cli/src/commands/settingCommands.ts
- packages/core/src/config/configManager.ts
- packages/core/src/config/configManagerUltrafix.ts
- propr-ui/src/components/TaskDetails/TaskStatusTable.tsx
- propr-ui/src/components/TaskDetails/types.ts
- test/configRoutes.followup.test.ts

PR: #2758
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Validate Changes

Please investigate and fix this CI failure.

Failure evidence

.github:18
Process completed with exit code 1.

.github:370
Process completed with exit code 1.

.github:439 — 🎭 Playwright Run Summary
209 passed (10.0m)

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Checks Failed

Validation failed during setup, tests, CLI packaging, linting, or build checks.

View Logs
Build check diagnostics for run 37441877381, attempt 1
Checkout outcome: success

--- GitHub Actions workflow lint ---

--- Release shell script lint ---

--- Toolchain ---
v22.23.3
10.9.9

--- Dependency installation ---
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]
npm warn deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

added 1120 packages, and audited 1129 packages in 1m

323 packages are looking for funding
  run `npm fund` for details

8 high severity vulnerabilities

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

--- CLI release package ---
Verifying propr-cli release package...

> [email protected] cli:pack
> node packages/cli/scripts/build-publish.mjs


> @propr/[email protected] build
> tsc


> @propr/[email protected] build
> tsc


> @propr/[email protected] build
> tsc && node scripts/copy-assets.mjs

copy-assets: copied 9 file(s) into the CLI package.

Staged [email protected] at /var/lib/propr-ci/worker5/work/propr/propr/dist-publish/propr-cli
npm notice
npm notice package: [email protected]
npm notice Tarball Contents
npm notice 26.3kB README.md
npm notice 36.3kB dist/agentSkill.js
npm notice 754B dist/api/agentRuntime.js
npm notice 7.1kB dist/api/agents.js
npm notice 2.6kB dist/api/agentTank.js
npm notice 11.7kB dist/api/client.js
npm notice 5.0kB dist/api/errors.js
npm notice 16.6kB dist/api/goals.js
npm notice 5.6kB dist/api/implement.js
npm notice 2.4kB dist/api/index.js
npm notice 1.9kB dist/api/logs.js
npm notice 5.7kB dist/api/plans.js
npm notice 4.2kB dist/api/relay.js
npm notice 10.4kB dist/api/repos.js
npm notice 11.9kB dist/api/settings.js
npm notice 1.6kB dist/api/syntheticPools.js
npm notice 1.8kB dist/api/system.js
npm notice 5.8kB dist/api/tasks.js
npm notice 2.9kB dist/api/todos.js
npm notice 86B dist/api/types.js
npm notice 313B dist/api/visualPreviewAuth.js
npm notice 26.1kB dist/assets/env.example.txt
npm notice 5.7kB dist/auth/githubLogin.js
npm notice 19.4kB dist/commands/agentCommands.js
npm notice 4.2kB dist/commands/agentPoolCommands.js
npm notice 4.3kB dist/commands/agentSkillCommands.js
npm notice 29.5kB dist/commands/agentValidation.js
npm notice 66.6kB dist/commands/checkCommands.js
npm notice 8.9kB dist/commands/configCommands.js
npm notice 14.6kB dist/commands/connectCommand.js
npm notice 5.5kB dist/commands/githubAppApi.js
npm notice 27.7kB dist/commands/githubAppCommands.js
npm notice 57.9kB dist/commands/goalCommands.js
npm notice 2.4kB dist/commands/imageCommands.js
npm notice 8.0kB dist/commands/implementCommands.js
npm notice 1.7kB dist/commands/index.js
npm notice 6.9kB dist/commands/initCommands.js
npm notice 14.1kB dist/commands/initStack.js
npm notice 6.1kB dist/commands/logCommands.js
npm notice 24.9kB dist/commands/planCommands.js
npm notice 8.4kB dist/commands/relayCommands.js
npm notice 30.1kB dist/commands/repoCommands.js
npm notice 7.5kB dist/commands/runtimeCommands.js
npm notice 16.8kB dist/commands/settingCommands.js
npm notice 4.0kB dist/commands/setup/agentHostActions.js
npm notice 123B dist/commands/setup/agents.js
npm notice 4.5kB dist/commands/setup/engine.js
npm notice 51B dist/commands/setup/github.js
npm notice 15.3kB dist/commands/setup/hostActions.js
npm notice 27.3kB dist/commands/setup/sequential.js
npm notice 51B dist/commands/setup/state.js
npm notice 51B dist/commands/setup/types.js
npm notice 10.7kB dist/commands/setupCommand.js
npm notice 4.4kB dist/commands/stackCommands.js
npm notice 1.4kB dist/commands/startCommand.js
npm notice 13.5kB dist/commands/systemCommands.js
npm notice 3.5kB dist/commands/tankCommands.js
npm notice 45.1kB dist/commands/taskCommands.js
npm notice 29.6kB dist/commands/todoCommands.js
npm notice 31.0kB dist/commands/tunnelCommand.js
npm notice 2.7kB dist/commands/uiDocsCommands.js
npm notice 8.3kB dist/completion.js
npm notice 20.0kB dist/config/ConfigManager.js
npm notice 276B dist/config/index.js
npm notice 989B dist/config/rootKey.js
npm notice 345B dist/config/types.js
npm notice 42.9kB dist/connectIdentity.js
npm notice 25.0kB dist/connectRootAuthority.js
npm notice 32.5kB dist/connectWindowsAuthority.js
npm notice 2.2kB dist/desktopDiscovery.js
npm notice 12.4kB dist/desktopLocalSetup.js
npm notice 16.7kB dist/index.js
npm notice 4.5kB dist/native/darwin-authority-broker.c
npm notice 8.9kB dist/native/directory-operations.c
npm notice 50.1kB dist/native/prebuilds/darwin-arm64/connect-authority-broker
npm notice 54.2kB dist/native/prebuilds/darwin-arm64/directory-operations.node
npm notice 17.1kB dist/native/prebuilds/darwin-x64/connect-authority-broker
npm notice 24.3kB dist/native/prebuilds/darwin-x64/directory-operations.node
npm notice 28.9kB dist/native/prebuilds/linux-arm64/directory-operations.node
npm notice 17.4kB dist/native/prebuilds/linux-x64/directory-operations.node
npm notice 1.2kB dist/native/README.md
npm notice 3.1kB dist/orchestrator/format.js
npm notice 13.4kB dist/orchestrator/index.js
npm notice 302B dist/orchestrator/manifest.json
npm notice 119.1kB dist/orchestrator/orchestrator.mjs
npm notice 408B dist/orchestrator/types.js
npm notice 237B dist/skill/propr/agents/openai.yaml
npm notice 8.7kB dist/skill/propr/SKILL.md
npm notice 4.5kB dist/tui/AgentTableApp.js
npm notice 4.5kB dist/tui/app.js
npm notice 11.6kB dist/tui/CheckApp.js
npm notice 5.1kB dist/tui/render.js
npm notice 32.5kB dist/tui/SetupApp.js
npm notice 18.4kB dist/tui/SetupApp.test.js
npm notice 8.2kB dist/tui/StartApp.js
npm notice 3.6kB dist/utils/apiErrorPresentation.js
npm notice 12.0kB dist/utils/directoryDescriptor.js
npm notice 739B dist/utils/dockerPort.js
npm notice 5.0kB dist/utils/envFile.js
npm notice 520B dist/utils/index.js
npm notice 5.7kB dist/utils/io.js
npm notice 1.5kB dist/utils/nativeArtifact.js
npm notice 544B dist/utils/parseState.js
npm notice 417B dist/utils/positiveInteger.js
npm notice 4.5kB dist/utils/privateFilesystem.js
npm notice 4.2kB dist/utils/resolveProject.js
npm notice 7.2kB dist/vendor/local-setup/agents.js
npm notice 62.7kB dist/vendor/local-setup/engine.js
npm notice 5.0kB dist/vendor/local-setup/envFile.js
npm notice 9.1kB dist/vendor/local-setup/github.js
npm notice 188B dist/vendor/local-setup/index.js
npm notice 27.0kB dist/vendor/local-setup/publicInstanceIdentity.js
npm notice 14.6kB dist/vendor/local-setup/state.js
npm notice 2.8kB dist/vendor/local-setup/types.js
npm notice 1.0kB dist/vendor/shared/accountStatusTimestamp.js
npm notice 7.6kB dist/vendor/shared/activityEvents.js
npm notice 3.4kB dist/vendor/shared/agentLogin.js
npm notice 3.1kB dist/vendor/shared/agentTank.js
npm notice 1.8kB dist/vendor/shared/analyticsTimeframe.js
npm notice 2.0kB dist/vendor/shared/antigravityCompatibility.js
npm notice 5.1kB dist/vendor/shared/apiOrigin.js
npm notice 8.5kB dist/vendor/shared/connectDiscovery.js
npm notice 254B dist/vendor/shared/demoMode.js
npm notice 4.3kB dist/vendor/shared/desktopPairing.js
npm notice 481B dist/vendor/shared/desktopTokenRevocation.js
npm notice 8.9kB dist/vendor/shared/events.js
npm notice 2.5kB dist/vendor/shared/githubAppManifest.js
npm notice 1.6kB dist/vendor/shared/githubAuthMode.js
npm notice 2.0kB dist/vendor/shared/githubEventIntakeMode.js
npm notice 11.6kB dist/vendor/shared/goalBlockers.js
npm notice 6.0kB dist/vendor/shared/goalCheckpoints.js
npm notice 4.0kB dist/vendor/shared/goalCreation.js
npm notice 4.9kB dist/vendor/shared/goalWait.js
npm notice 11.8kB dist/vendor/shared/index.js
npm notice 214B dist/vendor/shared/instanceAuthorization.js
npm notice 54B dist/vendor/shared/instanceCatalog.js
npm notice 4.0kB dist/vendor/shared/intakeModePrerequisites.js
npm notice 2.9kB dist/vendor/shared/labelUtils.js
npm notice 16.6kB dist/vendor/shared/modelDefinitions.js
npm notice 3.5kB dist/vendor/shared/notificationLinks.js
npm notice 51.3kB dist/vendor/shared/notifications.js
npm notice 866B dist/vendor/shared/projectSlug.js
npm notice 3.8kB dist/vendor/shared/proprCompatibility.js
npm notice 13.0kB dist/vendor/shared/proprServiceUrls.js
npm notice 2.2kB dist/vendor/shared/publishedVisualPreviews.js
npm notice 2.6kB dist/vendor/shared/reasoningLevels.js
npm notice 1.2kB dist/vendor/shared/repositoryIcon.js
npm notice 1.4kB dist/vendor/shared/repositoryIconUrl.js
npm notice 3.7kB dist/vendor/shared/repositoryPresentation.js
npm notice 9.5kB dist/vendor/shared/reviewContextBudget.js
npm notice 5.8kB dist/vendor/shared/reviewFeedbackIds.js
npm notice 1.7kB dist/vendor/shared/reviewPrompt.js
npm notice 788B dist/vendor/shared/runCostCap.js
npm notice 861B dist/vendor/shared/sessionSecret.js
npm notice 603B dist/vendor/shared/statusKeys.js
npm notice 7.5kB dist/vendor/shared/syntheticAgents.js
npm notice 2.2kB dist/vendor/shared/taskIdentifiers.js
npm notice 1.6kB dist/vendor/shared/taskLifecycle.js
npm notice 957B dist/vendor/shared/text.js
npm notice 5.6kB dist/vendor/shared/usageTips.js
npm notice 335B dist/vendor/shared/usageTypes.js
npm notice 1.1kB dist/vendor/shared/userWhitelist.js
npm notice 758B dist/vendor/shared/validateRelayUrl.js
npm notice 2.2kB dist/vendor/shared/validateRoutingUrl.js
npm notice 7.1kB dist/vendor/shared/visualPreviewCapacity.js
npm notice 9.3kB dist/vendor/shared/voice.js
npm notice 222B dist/vendor/shared/workEvidence.js
npm notice 622B package.json
npm notice Tarball Details
npm notice name: propr-cli
npm notice version: 0.9.0
npm notice filename: propr-cli-0.9.0.tgz
npm notice package size: 425.9 kB
npm notice unpacked size: 1.8 MB
npm notice shasum: 159b0b51220c1072e13f1f26b685931d997a7d0b
npm notice integrity: sha512-D/Yv5/N2UTPGu[...]fBeQyG/mxUrFQ==
npm notice total files: 168
npm notice
propr-cli-0.9.0.tgz

Dry run only. Re-run with --publish to publish to npm.
✅ propr-cli release package verified
Starting changed-area validation process...
Reusing this job's @propr/shared build from CLI packaging.
Reusing this job's @propr/local-setup build from CLI packaging.

--- Core Service: Lint & Build ---
✅ Core Lint passed
✅ Core Source Build passed

--- UI: Typecheck, Lint & Build ---
✅ Client Package validation passed
✅ UI Typecheck passed
✅ UI Lint passed
✅ UI Build passed

--- Docs: Typecheck & Build ---
✅ Docs Typecheck passed
✅ Docs Build passed

--- Core Package: Build & Lint ---
✅ Core Package Build passed
❌ Core Package Lint FAILED

/var/lib/propr-ci/worker5/work/propr/propr/packages/core/src/claude/docker/dockerExecutor.ts
  472:1  warning  File has too many lines (488). Maximum allowed is 400  max-lines

✖ 1 problem (0 errors, 1 warning)

ESLint found too many warnings (maximum: 0).

--- CLI: Lint ---
✅ CLI Lint passed

--- API: Build & Lint ---
✅ API Build passed
❌ API Lint FAILED

> @propr/[email protected] lint
> eslint . --max-warnings 0


/var/lib/propr-ci/worker5/work/propr/propr/packages/api/routes/configSettings.ts
  95:8  warning  Async function 'extractSettingSaves' has a complexity of 22. Maximum allowed is 20  complexity

✖ 1 problem (0 errors, 1 warning)

ESLint found too many warnings (maximum: 0).
npm error Lifecycle script `lint` failed with error:
npm error code 1
npm error path /var/lib/propr-ci/worker5/work/propr/propr/packages/api
npm error workspace @propr/[email protected]
npm error location /var/lib/propr-ci/worker5/work/propr/propr/packages/api
npm error command failed
npm error command sh -c eslint . --max-warnings 0

--- Stage outcomes ---
Workflow lint: success
Release shell lint: success
Pre-setup gate: skipped
Node setup: success
Toolchain: success
Dependency install: success
Release metadata: success
CLI packaging: success
Change detection: success
Changed-area checks: failure

View Workflow

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 638efa5

Summary of Changes

I fixed the Validate Changes failure. The step that failed was "Run Checks", on two lint warnings; the Playwright tests themselves passed. Both lints and npm run typecheck now pass locally, and so do the 26 related test files. CI hasn't re-run on the change yet.

1. Core lint: dockerExecutor.ts was too long (488 counted lines, the limit is 400). I moved three self-contained groups of code out of it into new files next to it, without changing any logic:

  • dockerCostCap.ts: the spend-cap helpers this PR added.
  • dockerLiveOutputStreaming.ts: the live-log streaming code and the ANSI-stripping helper only it uses.
  • dockerContainerDetection.ts: detectContainerId.

dockerExecutor.ts now imports them.

2. API lint: extractSettingSaves in packages/api/routes/configSettings.ts was too complex (22, the limit is 20). The default_max_cost_usd check this PR added pushed it over. I moved that check and the ultrafix_ci_wait_timeout_ms check into a new helper, extractRunLimitSettingSaves. Validation and error messages are unchanged.

For the tests I ran the Docker executor, spend-cap and container tests plus every test file that references configSettings, dockerExecutor or default_max_cost_usd. Three of them failed on the first run, but that was my local setup: I had installed dependencies without building native modules. They pass after rebuilding them.

The change has nothing visible, so there are no previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 10m 22s
  • Tokens: 1,334,376 (1,326,389 in / 7,987 out)
  • Cost: $0.69
  • Subscription usage: Session +1%

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

…led was "Run Checks", on two lint warnings; the Playwright tests themselves passed. Both lints and `npm run typecheck` now pass locally, and so do the 26 related test files. CI hasn't re-run on the change yet.

I fixed the **Validate Changes** failure. The step that failed was "Run Checks", on two lint warnings; the Playwright tests themselves passed. Both lints and `npm run typecheck` now pass locally, and so do the 26 related test files. CI hasn't re-run on the change yet.

**1. Core lint: `dockerExecutor.ts` was too long (488 counted lines, the limit is 400).** I moved three self-contained groups of code out of it into new files next to it, without changing any logic:
- `dockerCostCap.ts`: the spend-cap helpers this PR added.
- `dockerLiveOutputStreaming.ts`: the live-log streaming code and the ANSI-stripping helper only it uses.
- `dockerContainerDetection.ts`: `detectContainerId`.

`dockerExecutor.ts` now imports them.

**2. API lint: `extractSettingSaves` in `packages/api/routes/configSettings.ts` was too complex (22, the limit is 20).** The `default_max_cost_usd` check this PR added pushed it over. I moved that check and the `ultrafix_ci_wait_timeout_ms` check into a new helper, `extractRunLimitSettingSaves`. Validation and error messages are unchanged.

For the tests I ran the Docker executor, spend-cap and container tests plus every test file that references `configSettings`, `dockerExecutor` or `default_max_cost_usd`. Three of them failed on the first run, but that was my local setup: I had installed dependencies without building native modules. They pass after rebuilding them.

The change has nothing visible, so there are no previews.

PR: #2758
Comment by: @propr-dev[bot] (ID: 6013433431)
Model: claude-opus-5-5
@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

ℹ️ Analyzed the follow-up request by @github-actions[bot]

Analysis Summary

I didn't change any code: both lint failures in this report are already fixed on the current head (638efa580). This CI run (37441877381) checked the commit before it.

  • Core: dockerExecutor.ts too long (488 lines, limit 400). The latest commit moved the spend-cap helpers, live-output streaming and container detection into three new files next to it. ESLint now counts 388 lines.
  • API: extractSettingSaves too complex (22, limit 20). The default_max_cost_usd and ultrafix_ci_wait_timeout_ms checks now live in a helper, extractRunLimitSettingSaves. That brings it down to about 19.

I checked this after a clean npm ci here. The full lint scripts for @propr/core and @propr/api both finish with no warnings, and ESLint with --max-warnings 0 (as CI runs it) passes on the two flagged files. I only ran lint; I didn't rerun tests or typecheck. CI should pass these two steps when it runs on the current head. This change has nothing visible, so there are no previews.

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


🤖 Analysis Details

  • Model: Claude Opus 5.5 (medium)
  • Time: 1m 17s
  • Tokens: 325,459 (322,955 in / 2,504 out)
  • Cost: $0.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
Processing comment ID: 6013434765✓

@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/merge

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from main into 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3 in commit 655e4be

Conflicting Files

  • CHANGELOG.md
  • docs/docs/features/propr-cli.md
  • packages/api/mcp/toolsManagement.ts
  • packages/api/routes/configHelpers.ts
  • packages/api/routes/configRoutesSettings.ts
  • packages/api/routes/configSettings.ts
  • packages/core/src/agents/impl/AntigravityAgent.ts
  • packages/core/src/agents/impl/CodexAgent.ts
  • packages/core/src/agents/impl/OpenCodeAgent.ts
  • packages/core/src/agents/impl/VibeAgent.ts
  • packages/core/src/agents/impl/utils/dockerResultProcessor.ts
  • packages/core/src/agents/termination.ts
  • packages/core/src/agents/types.ts
  • packages/core/src/claude/claudeService.ts
  • packages/core/src/claude/docker/dockerExecutor.ts
  • packages/core/src/claude/docker/dockerLiveOutputStreaming.ts
  • packages/core/src/index.ts
  • packages/core/src/queue/taskQueue.types.ts
  • packages/core/src/utils/github/logFiles.ts
  • packages/core/src/utils/workerStateManager.ts
  • packages/core/src/utils/workerStateManager.types.ts
  • packages/core/src/utils/workerStateTransition.ts
  • packages/shared/src/taskLifecycle.ts
  • propr-ui/src/api/proprTypes.ts
  • propr-ui/src/pages/SettingsPage/parseLoadedData.ts
  • propr-ui/src/pages/SettingsPage/types.ts
  • propr-ui/src/pages/SettingsPage/useSettingsState.ts
  • src/jobs/issueJob/completion.ts
  • src/jobs/prCommentPostExecution.ts

Resolution Summary

I resolved all 29 conflicted files and no conflict markers are left. Almost every conflict had the same cause: main brought in the agent stall and degenerate-output watchdog (#2757), and this PR adds per-run spend caps. Both extended the same settings lists, termination-reason types and Docker result fields. Each extended them with something different, so I kept both sides in every case.

Checks: typecheck passes in root, core, api, cli and propr-ui. Lint passes everywhere with --max-warnings 0, which is the setting CI uses. The 11 related test files pass (spend cap, watchdog, docker live output and watchdog, config routes, settings catalog, issue completion, worker state), as do the 19 Settings page UI test files (137 tests).

How each group was resolved

  • CHANGELOG.md, docs/docs/features/propr-cli.md: both changelog entries and all the settings table rows are kept.
  • Settings API (toolsManagement.ts, configHelpers.ts, configRoutesSettings.ts, configSettings.ts): default_max_cost_usd and the three agent_* watchdog settings are all in the schemas, lists and destructuring.
    • In configSettings.ts both branches had split the same validation function, differently. The PR's spend-cap step now runs first and then calls main's new step that handles the watchdog and escalation settings, so nothing is skipped.
  • Termination types (agents/types.ts, taskQueue.types.ts, logFiles.ts, workerStateManager*.ts, workerStateTransition.ts, shared/taskLifecycle.ts): the type unions now cover cost_cap/cost_cap_exceeded and stalled/degenerate_output, and each reason keeps its description text.
  • termination.ts: accepts both costCapExceeded and watchdogTrip. A spend-cap stop is checked first (the PR's intent), then a watchdog stop, then timeout. The same order applies when the reason is read from error text.
  • Agents and result plumbing (Codex, Antigravity, OpenCode, Vibe, claudeService.ts, dockerResultProcessor.ts): both costCapExceeded and watchdogTrip are passed through.
  • dockerExecutor.ts: both the spend-cap code and the watchdog are kept, and each output line goes to both. I kept the PR's move of detectContainerId into its own file, so main's inline copy is gone.
  • dockerLiveOutputStreaming.ts: both branches added this file. I took main's version, which contains everything the PR's version has and adds the watchdog activity and transcript hooks.
  • index.ts: both sets of exports are kept.
  • UI settings files: the spend-cap field and the watchdog fields are both in the types, the defaults, the loading code and the save request.
  • completion.ts, prCommentPostExecution.ts: main had its own mapping from termination reason to task outcome (src/jobs/agentTerminalReason.ts) next to the PR's shared one. I extended the PR's shared mapping to cover the watchdog reasons and made main's file call it, so there is one source of truth. That fixed the duplicate imports the automatic merge left behind.

Changes needed to keep CI's lint passing

Both parents passed lint on their own, but combining them pushed two files over limits, and CI fails on any warning:

  • dockerExecutor.ts: it went over the 400-line limit and its process-exit handler went over the complexity limit. I moved the timeout and watchdog "finish with partial output" helpers into a new file, dockerExecutionSettlement.ts, the way the PR already handles the spend-cap equivalent. Error messages and results are unchanged.
  • useSettingsState.ts: main had left this file at exactly 400 lines. I moved costCapToSave into parseLoadedData.ts, next to the matching load helper. I also added a small runLimitSettingsToSave there that builds the spend-cap and watchdog part of the save request.

To run these checks I installed dependencies and built the workspace packages. That only produced gitignored files. The one new tracked file is dockerExecutionSettlement.ts.


🤖 Resolution Details

  • Model: claude-opus-5-5
  • Time: 9m 21s

View Task Execution


System-triggered merge conflict resolution

…per-run-spend-cap-20261005-2330-yv3

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- CHANGELOG.md
- docs/docs/features/propr-cli.md
- packages/api/mcp/toolsManagement.ts
- packages/api/routes/configHelpers.ts
- packages/api/routes/configRoutesSettings.ts
- packages/api/routes/configSettings.ts
- packages/core/src/agents/impl/AntigravityAgent.ts
- packages/core/src/agents/impl/CodexAgent.ts
- packages/core/src/agents/impl/OpenCodeAgent.ts
- packages/core/src/agents/impl/VibeAgent.ts
- packages/core/src/agents/impl/utils/dockerResultProcessor.ts
- packages/core/src/agents/termination.ts
- packages/core/src/agents/types.ts
- packages/core/src/claude/claudeService.ts
- packages/core/src/claude/docker/dockerExecutor.ts
- packages/core/src/claude/docker/dockerLiveOutputStreaming.ts
- packages/core/src/index.ts
- packages/core/src/queue/taskQueue.types.ts
- packages/core/src/utils/github/logFiles.ts
- packages/core/src/utils/workerStateManager.ts
- packages/core/src/utils/workerStateManager.types.ts
- packages/core/src/utils/workerStateTransition.ts
- packages/shared/src/taskLifecycle.ts
- propr-ui/src/api/proprTypes.ts
- propr-ui/src/pages/SettingsPage/parseLoadedData.ts
- propr-ui/src/pages/SettingsPage/types.ts
- propr-ui/src/pages/SettingsPage/useSettingsState.ts
- src/jobs/issueJob/completion.ts
- src/jobs/prCommentPostExecution.ts

PR: #2758
Model: claude-opus-5-5
@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/merge

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from main into 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3 in commit cba565f

Conflicting Files

  • src/jobs/prCommentReviewJob.ts

Resolution Summary

I resolved the one merge conflict, in src/jobs/prCommentReviewJob.ts. A search of the repo found no other conflict markers.

What the conflict was: both sides changed the same import line from @propr/core.

  • This PR added getActiveRunCostGuard and RepositoryWorkflowPolicyError to that import. It also added two local imports: prepareRepositoryWorkflow from ./repositoryWorkflow.js and applyWorkflowCostCap from ./runCostCap.js. These support the per-run spend cap and the repository workflow handling.
  • main added getModelName to the same import. It's used to show readable model names in the review links summary (line 170) and in the model list (line 324).

How I resolved it: I kept both sides. The import now includes everything either branch added (AgentRegistry, getActiveRunCostGuard, getAuthenticatedOctokit, getModelName, loadPrReviewModel, RepositoryWorkflowPolicyError, resolveLlmLabel, retryConfigs, TaskStates, withRetry). I kept the PR's two extra local imports as they were.

Why: the two sides didn't conflict in what they do. Each one only added names used by its own code, and every one of those names is still used in the merged file. Dropping either side would leave undefined references, so combining them keeps the spend-cap work and main's model-name display.

Checks:

  • No <<<<<<<, ======= or >>>>>>> markers are left in any file.
  • Every imported name exists: getModelName, getActiveRunCostGuard and RepositoryWorkflowPolicyError are exported from packages/core/src/index.ts, and both local modules (src/jobs/repositoryWorkflow.ts and src/jobs/runCostCap.ts) are present.
  • I couldn't run npm run typecheck because dependencies aren't installed here (there's no node_modules), so the compiler hasn't checked the merged file.
  • git add failed because the git index is on a read-only filesystem, so src/jobs/prCommentReviewJob.ts may still be marked as conflicted (UU) in git. The file itself is fixed.

🤖 Resolution Details

  • Model: claude-opus-5-5
  • Time: 46s

View Task Execution


System-triggered merge conflict resolution

…per-run-spend-cap-20261005-2330-yv3

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- src/jobs/prCommentReviewJob.ts

PR: #2758
Model: claude-opus-5-5
@integry

integry commented Oct 6, 2026

Copy link
Copy Markdown
Owner

/merge

@propr-dev

propr-dev Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from main into 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3 in commit b3fa415

Conflicting Files

  • CHANGELOG.md

Resolution Summary

I resolved the merge conflict. CHANGELOG.md was the only file with conflict markers, and a search of the rest of the repository found none left.

What the conflict was: Both branches added a new entry at the top of the ## [Unreleased] → ### Added section of CHANGELOG.md, in the same place:

  • This PR: the Per-run spend caps entry, covering the maxCostUsd, limits.max_cost_usd and default_max_cost_usd settings, the cost_cap_exceeded terminal reason and the budget.exceeded event.
  • main: the Pull request templates entry, covering .propr/pr-template.md, the GitHub template fallback and propr repo validate.

How I resolved it: I kept both entries unchanged, with the spend-cap entry first and the pull request templates entry right after it, and removed the conflict markers. Everything below them, starting with the "Agent stall and degenerate-output watchdog" entry, is untouched.

Why: The two entries describe separate features, so this is a simple text conflict, not competing logic. Both belong in the changelog, and dropping either would lose a record of shipped work. Putting the PR's entry first follows the rule of preferring the PR's intent. I left the wording of both exactly as written.

Check: The CHANGELOG.md section reads correctly as Markdown, and the other files staged in the merge had no conflict markers, so they didn't need changes.


🤖 Resolution Details

  • Model: claude-opus-5-5
  • Time: 58s

View Task Execution


System-triggered merge conflict resolution

…per-run-spend-cap-20261005-2330-yv3

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- CHANGELOG.md

PR: #2758
Model: claude-opus-5-5
@integry
integry merged commit 287d93c into main Oct 6, 2026
50 checks passed
@integry
integry deleted the 2734/claude-opus-5-5-enforce-per-run-spend-cap-20261005-2330-yv3 branch October 6, 2026 11:47
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.

## Enforce per-run spend caps (cancel the run when its cost exceeds the cap)

1 participant