Skip to content

fix(server): restart the disk rate when the worktree volume changes - #797

Merged
lastobelus merged 2 commits into
lastcode/mainfrom
lastcode/capacity-volume-identity
Nov 20, 2026
Merged

lastobelus merged 2 commits into
lastcode/mainfrom
lastcode/capacity-volume-identity

Conversation

@lastobelus

Copy link
Copy Markdown
Owner

Replacing a mounted volume or symlink target under an unchanged worktree path made the next free-space reading come from a different volume. The advisory disk rate (freeBytesChangePerMinute) then compared unrelated values. This was follow-up F1 from #726.

What changed

  • Volume tracking: the native capacity source now records the device of the volume it measures. When a different device appears under the same path, that one sample reports free space as unreadable. The disk-rate logic already restarts its window on an unreadable reading, so the rate never spans two volumes.
  • Unchanged cases: same-volume readings, the first reading, failed reads, and the fallback to the nearest existing parent all behave as before.
  • Cost of a swap: the swap sample makes the agent verdict unknown, and the usual 60-second recovery follows. A volume swap is rare, and that is the conservative choice while the rate can't be trusted.

Validation

  • Native-source test: points a symlink at /dev (its own filesystem on macOS and Linux), retargets it to a temp directory, and reads three times. Free bytes come back as value, null, then value. The test fails without the fix.
  • Unit test: covers the comparison rule.
  • Real volume swap on macOS: from /System/Volumes/Preboot to the data volume under one path, the readings were value, null, then value.
  • Changed-file gate: vp run check:changed origin/lastcode/main passed format, lint, both knip passes, GraphQL, typecheck, and tests.

Local review: 1 round with GPT-6.1 Terra (xhigh), approved. It asked for a test through the native source, which this PR adds. It also noted a narrow race: stat and statfs can see different targets if the swap lands between them, within one sample. That is left as a follow-up.

Implemented with Claude Opus 5.5 through Claude Code.

lastobelus and others added 2 commits November 20, 2026 16:20
Replacing a mounted volume or symlink target under an unchanged worktree
path made the next free-space reading come from a different volume, so the
advisory disk rate compared unrelated values. The native source now tracks
the volume's device and reports free space unreadable for the one sample
where it changes, which restarts the disk-rate window.

Carry-Group: incubator
Carry-Observation: Advisory capacity evolves independently of the launch, environment, and CLI results that carry it.
Co-Authored-By: Claude <[email protected]>
Carry-Group: incubator
Carry-Observation: Advisory capacity evolves independently of the launch, environment, and CLI results that carry it.
Co-Authored-By: Claude <[email protected]>
@lastobelus
lastobelus marked this pull request as ready for review November 20, 2026 23:23
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T23:25:23.265722Z 1d06a91 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 1d06a91175

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lastobelus
lastobelus merged commit 984c0ef into lastcode/main Nov 20, 2026
23 of 41 checks passed
@lastobelus
lastobelus deleted the lastcode/capacity-volume-identity branch November 20, 2026 23:36
lastobelus added a commit that referenced this pull request Nov 21, 2026
…iew (#808)

Two independent reviewers, GPT-6.2 Astra (high) and Claude Fable 5.2 (high), re-reviewed the whole observe-only capacity system after [#793](#793), [#794](#794) and [#797](#797). This PR fixes what they found in verdicts, recovery and launch latency, before capacity step 2 starts acting on verdicts.

## What changed

- **A gap restarts recovery:** if sampling stalls for more than 30 seconds, both agent and background verdicts hold until they've had 60 healthy seconds again. Before, a background verdict that was open reopened on the first sample after the stall. The last sample time survives a worktree-directory change, so a gap across one is still seen. Resuming after Off still starts the way server start does.
- **Recovery needs new samples:** recovery time is measured between samples, not up to the read. Before, a read with no new sample could end recovery.
- **A real breach holds:** a verdict is `hold` when a fresh measurement breaches a rule, even if another signal can't be read. Before, one unreadable signal hid the breach as `unknown`. On Linux, memory pressure is always unreadable, so Linux could never report `hold`. A stale sample is still `unknown`, even if its last reading breached.
- **Launches don't wait on activity:** launch, task and Action results read capacity without counting turns, which needs a snapshot of every thread and could take up to 3 s. Only `t3_environment_read` counts turns, and that count now times out after 1 s, inside a peer's 2 s forwarded read.
- **The folder count can't delay verdicts:** the worktree folder count has its own 1 s timeout. No rule uses it.
- **Sampling survives a crash:** a crash in one sample is logged as `capacity.sample-failed`, and sampling continues. Before, it ended sampling silently, and every later read stayed stale until restart.

## Not changed

- **Remote `delegate_task` capacity:** still read with one bounded call to the peer. The remote launch starts asynchronously after `delegate_task` returns, so there's no launch result to reuse.
- **Left as follow-ups:**
  - an `enforced` field on the snapshot, for step 2;
  - a warm-up rule for the disk rate, plus a minimum window;
  - a guard against stuck volume reads piling up;
  - a slower schedule for the folder count;
  - smaller capacity blocks on launch results;
  - a wiring test through the route layer;
  - activity counting one turn per thread;
  - an Off interval that falls entirely between two samples;
  - a defect in the first sample after Off.

## Validation

- **Tests:** each new test fails on main and passes here:
  - the gap hold, including across a directory change;
  - recovery advancing only with new samples;
  - a breach beside an unreadable signal;
  - a stale sample with an old breach;
  - a defective sample.
- **Fake services:** launch-path fakes now fail the test if a launch reads activity.
- **Focused tests:** the capacity, capacity-read and environment tests pass (70).
- **Changed-file gate:** `vp run check:changed origin/lastcode/main` passed format, lint, both knip passes, GraphQL, typecheck and tests.
- **Model-backed MCP evals:** not run; this machine has no authorized eval proxy. No tool description or schema changed.

Local review: 3 rounds with GPT-6.1 Terra (xhigh), approved.
- **Round 1:** found that a stale sample with an old breach reported `hold`.
- **Round 2:** found that a directory change during a stall erased the gap. Both are fixed, with tests.
- **Round 3:** approved, with one nit left as a follow-up: a defect in the first sample after Off.

Implemented with Claude Opus 5.5 through Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Carry-Source-Ref: refs/lastcode/carry-sources/pr-808/53b03d4a05ec8427d5ec2a47c2e189a1c1fa8e3d
Carry-Source-Base: e2a195b
Carry-Source-Head: 53b03d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant