Repository navigation
feat(server): publish observe-only machine capacity - #726
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 841ce5c117
ℹ️ 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".
841ce5c to
f3cb23c
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
5ee1368 to
6cd814f
Compare
f3cb23c to
3ff8192
Compare
175ac36 to
fc97d75
Compare
3ff8192 to
fbc87fa
Compare
Sample host resources and execution activity centrally, publish advisory verdicts through MCP and the thread CLI, and leave every execution path unchanged. Carry-Group: incubator Carry-Observation: Host measurement, typed verdicts and their publication form one inseparable capacity feature; enforcement remains out of scope.
Resolve the current worktree setting on each sample and reset history when its directory changes, so disk rates never span ordinary settings changes. Invalid settings stay unknown. Carry-Group: incubator Carry-Observation: Capacity measurement must follow the same worktree-root resolver as new worktree creation.
Keep optional capacity publication compatible with older peers, use an unknown default service, read activity on demand, and isolate live wiring and regression coverage in fork-owned modules. Implemented with GPT-6.1 Sol in the Codex harness. Carry-Group: incubator Carry-Observation: Observe-only measurement and publication remain one capacity feature; fork-owned wiring and tests reduce checkpoint replay conflicts in upstream-owned files.
Keep recovery driven by sampled measurements and overlay activity only on returned reads. Preserve JSON CLI logging, fix toolkit fixtures and typed decoders, and bound the production wiring assertion to the route graph. Implemented with GPT-6.1 Sol in the Codex harness. Carry-Group: incubator Carry-Observation: Optional activity reads must not create recovery holds; capacity publication and its wiring checks must remain usable across checkpoint replay.
Carry-Group: incubator Carry-Observation: Advisory capacity evolves independently of the launch, environment, and CLI results that carry it.
fbc87fa to
fd7010f
Compare
Concurrent coordinators have no shared reading of machine capacity, so each can launch work while other threads are already using the same resources. This adds a server-owned sampler that publishes advisory verdicts. It never holds, releases, rejects, or redirects work. ## 🔍 What changed - **Sampler:** runs every 5 seconds, using the configured worktree root and refreshing that selection on each sample. Switching roots resets sampling history. Smooths load over a minute. Reports load per physical core, memory pressure, swap, worktree-volume free space and its rate of change, worktree folders per project, and owner idle time when known. Verdicts and their recovery come from these measurements only. Execution counts are fetched on each read and added to that read's result; reads never change sampler state, and the first sample does not delay server start. - **Publication:** typed capacity blocks appear on environment reads (including linked machines) and on thread, delegation, and Action launch results. `lastcode-thread capacity` prints the same verdicts as JSON; `--environment` reads another linked environment. - **Modes:** the default is Observe, which logs each sampled would-hold verdict. Off stops the sampler and its logs. `capacityMode` is exposed through environment preferences on the existing authorized settings path; there is no new settings screen. ## 🚦 Verdict rules - **Owner:** always open. - **Agent work:** would hold if 1-minute load/core >= 1.5, memory is warning or critical, free disk is below 60 GB, or free disk is falling faster than 2 GB/min. - **Background work:** would hold if 5-minute load/core >= 1.0, memory is warning or critical, or free disk is below 80 GB. - **Unknown:** stale (older than 30 seconds) or unreadable measurements give an unknown agent/background verdict, which counts as would-hold. - **Reopening:** a held verdict needs a full minute of healthy readings to reopen. After startup, the agent verdict stays closed until a second disk reading and healthy recovery. - **Filesystem edge (F1):** replacing a mounted volume or symlink target without changing the configured path can still skew an advisory disk-rate reading. This remains follow-up hardening for observe mode. - **Linux limitation:** memory pressure is unmapped, so it reports unknown rather than silently opening. A mapping needs separate approval. ## ➡️ Next step Measurement is a separate service from admission, so the later enforcement step stays small. The owner, existing messages, and wakes are untouched. Not included: enforcement, a worktree guard, a heavy-work lease, placement, an upstream post, installation, or a restart. Owner approval is required before merge. ## 🧩 Fork footprint Every LastCode checkpoint replays this change onto a new upstream nightly, so it keeps out of upstream-owned files where it can. Upstream-owned files carry +42/−8 lines across 11 files: the settings field, one schema line and one handler line per publishing tool, and one import and one provide in `server.ts`. The rest (about +2,260 lines across 18 files) is fork-owned, including all capacity tests. `Capacity` is a `Context.Reference` whose default reads as unknown, so existing test harnesses need no new layer, and a fork-owned test checks that the production route block provides the live service. Capacity fields on cross-machine and CLI results are optional, so machines and CLIs without this change still decode them. Read-side decoding is also tolerant in the other direction: a newer mode, reason signal, comparison or verdict state from a later version passes through as a string, a malformed capacity block is dropped without failing the surrounding result, and the environment read keeps a newer `capacityMode` instead of rejecting the read. Local settings writes stay strict (Off and Observe only). ## ✅ Validation - **Passed locally at this head:** `vp run check:changed origin/lastcode/main` (format, lint, both knip passes, GraphQL, typecheck of 38 affected packages, and 272 tests in 15 files). Rebased onto `lastcode/main` at `3e232327e99` (checkpoint 4864 plus eleven commits). The only conflict was the agent-context budget counter, re-measured with `agent-context:generate` at 86,521 (+517 over main, unchanged by the tolerant-decoding commit). Exact-head carry compilation passed on the checkpoint-4864 rebase. - **Model-backed MCP evals:** not run; no authorized eval proxy is configured locally. - **Pending:** GitHub CI on this head. Local review: 4 rounds with Claude Fable 5.2 (xhigh), approved, after the earlier Sol (high) and Terra (xhigh) rounds. Round 4 covered the checkpoint rebase and the tolerant-decoding commit, and found only nits (listed below). Rounds 1 and 2 fixed results that a machine or CLI without this change could not decode, a full thread-snapshot read on every sample, the capacity service as a required toolkit dependency, capacity tests in upstream test files, capacity wiring inline in `server.ts`, sampler verdicts that depended on reads, and a CLI flag lost in the rebase. Follow-ups, not in this PR: - **F1:** same-path volume or symlink replacement can skew the advisory disk rate. - **Checkpoint tooling:** re-measure the agent-context budget counter during replay instead of merging the number. - **Small cleanups:** - informational signals still gate verdicts; - verdict shape in Off mode; - the `includeLinked` default; - would-hold logging on every sample; - `sysctl` process count; - the mode reported for a failed linked read; - unused activity state in `logic.ts`; - Off-mode reason text. - **Before step 2 adds a mode or value (round-4 nits):** - keep a strict `CapacitySnapshot` type for this server's own sampler output and use a separate loose type for reported results (R19); - decode `linkedObservation` and each linked entry tolerantly, so one bad linked entry doesn't drop a peer's whole block (R20); - decode `ServerSettings.capacityMode` tolerantly on read, so a client or a downgraded server doesn't reject a whole config or settings file containing a newer mode (R21); - mention `unknown` in the environment tool's `capacity.mode` description (R22); - have the unwired default `Capacity` report `unknown` rather than `observe` (R23). Implemented with Codex Sol (xhigh) through the Codex harness; agent-facing tool wording by Claude Opus 5.5. Carry-Source-Ref: refs/lastcode/carry-sources/pr-726/fd7010f3b882a574197c5abc501e33e845e16d56 Carry-Source-Base: 3e23232 Carry-Source-Head: fd7010f
Follow-up to #726. Older LastCode versions need to read capacity modes that don't exist yet, such as `enforce`. Today they can't. This lets the compatibility fix land ahead of capacity enforcement. ## 🐛 Problem When an unfamiliar `capacityMode` appears in settings: - **Clients reject the whole server config**, including unrelated fields. - **Servers fall back to defaults** when reading settings from disk. - **The sampler skips the `capacity.would-hold` advisory log**, because the log only fired when the mode was exactly `observe`. ## 🔧 Change - **Settings and server configs** keep the stored mode, including after an unrelated settings edit. A missing value still defaults to `observe` (`CapacityModeSetting` in `packages/contracts`). - **Observe-only servers** sample an unfamiliar mode, emit advisory logs, and report its stored name. The `off` mode still skips sampling. - **Mode updates** still accept only `off` and `observe`. - The `t3_environment_read` description drops the exhaustive list of modes, shrinking the tool budget by 39 bytes. The provider update helper infers its return type from the fields it builds. ## ✅ Proof Tests were written first and reproduced all three failures above. Each one failed before the fix. - 191 server and contracts tests passed. - 16 web settings logic tests passed. - The changed-file gate and Quick CI passed on the PR head. Local review: 3 rounds with Codex Terra (xhigh), approved. Implemented with GPT-6.2 Sol in the Codex harness. Carry-Source-Ref: refs/lastcode/carry-sources/pr-774/048810d1802d73cd19751e0e37332ec2d67aaf99 Carry-Source-Base: fc3c914 Carry-Source-Head: 048810d
Part of #751 Agent guidance still described threads in older terms. In evals on main, the model delegated requests to start a child thread and made a group thread independent. It archived the wrap-up root before asking whether to include the typed-in conversations. The revised guidance uses the sidebar and lifecycle tool vocabulary and maps each short request to its operation. ## Injected thread vocabulary > - Start work in another thread only when the user asks or a skill they invoked calls for it. "Task an agent", "have a task", and "delegate" mean a task: short-lived owned work via `delegate_task`. A named thread kind overrides the verb. > - "Child thread": an owned, interactive thread that handles its own waits. Use `t3_thread_launch` for one or `create_threads` for a batch. Launches are owned by default across projects and environments. By default, owned threads sit under their owner in the same project or in a collapsed group per owner in another project. > - "Top-level thread": an independent sidebar root. Set `topLevel:true` only when the user asks for one, as in "task a top-level thread". `groupedUnderThreadId` changes placement only. > - "Group thread": an empty thread that holds others. Launch without a message or attachments, or batch-create without a prompt. > - "Promote": `t3_thread_organize` with `action:"promote"` releases ownership; `return_to_owner` restores it. > - "Wrap up": use `t3_thread_archive_family` to preview owned work across this environment's projects. If the user hasn't decided about conversations they typed in or their owned descendants, name the kept conversations, ask whether to include them, and wait for the answer before archiving. Use `t3_thread_organize` with the default selection unless the user consents to including those branches. ## Stale guidance corrected - **Launch ownership.** Interactive launches were described as always top-level. The guidance now explains that the requesting thread owns a launch by default across projects and environments. Only an explicit top-level request sets `topLevel:true`. The eval runner’s comments now call them launches. - **Start rule:** it covered generic thread requests without separating a task from an interactive child. It now follows the requested thread kind and allows starts requested by the user or by a skill they invoke. Eligible native subagent requests keep their native route. - **Group threads and placement:** launch and batch-create copy said "empty parent", and null placement was described as leaving a thread ungrouped. The tools now say "empty group thread" and explain that clearing manual placement leaves ownership unchanged. A visible explicit group can override the default sidebar placement. - **Actions:** the guidance said "top-level" for any thread entitled to run its own Action. It now says eligible Actions, including a launched child's Actions and those a parent runs for a task. - **Release wording:** the thread list described release as an operation. The organize tool now owns the promote/return wording and explains the delegated result and continuation gate. - **Archive:** guidance covered grouped children and subagents only. It now describes the same-environment, cross-project family, the preview selection, and typed-in consent. The sidebar guide covers retention and restore, and identifies read-only subagents as provider-native. - **Separate worktrees:** the remote task prerequisite was missing. The instructions now name the destination capability and the fetchable parent commit. ## Model eval against main GPT-6.1 Sol xhigh with the GPT-6.1 Terra shell simulator. Three samples per case per arm. Baseline `fba5fa4470e`. The wrap-up pair uses the same revised fixture, with read results for the kept conversations. The vocabulary rows use the final model-facing text and were scored with the final grader. The wrap-up baseline uses the revised fixtures. The existing native-subagent guard uses the preceding candidate, which differs only by the default-placement clarification. | Owner phrasing or control | Main | Candidate | | ----------------------------------------------------------- | ---: | --------: | | Task an agent | 3/3 | 3/3 | | Have a task | 3/3 | 3/3 | | Delegate | 3/3 | 3/3 | | Start a child thread | 0/3 | 3/3 | | Hand to a child thread | 0/3 | 3/3 | | Task a top-level thread | 3/3 | 3/3 | | Start a top-level thread | 3/3 | 3/3 | | Start a group thread | 0/3 | 3/3 | | Promote | 3/3 | 3/3 | | Wrap up asks before archiving | 0/3 | 3/3 | | Wrap up after choosing to leave typed-in conversations open | 3/3 | 3/3 | | Ordinary work | 3/3 | 3/3 | | Native subagent request (existing guard) | 0/3 | 0/3 | - **Main's failures:** both child requests used delegation, and the group thread became independent. - **Wrap-up:** the first request must preview, name the two kept conversations, and ask for the user's choice before archiving. The follow-up checks the exact default archive selection after the user asks to keep them open. The existing native-subagent guard failed all three samples on both main and the candidate. It is tracked in #589. All 36 vocabulary samples and all three manual-placement control samples passed with the final grader. Both post-rebase samples passed, covering the explicit top-level flag and consent before archive. After reconciling #771, all 9 archive samples passed, including its temporary-project selection control. All 88 focused MCP and budget tests passed on the combined head. The full tool-use run on `8f6dbba635f`, before the review fixes, passed **600 of 649 scored samples** across 317 cases. Three provider errors were unscored. The launch, grouping, promotion, and archive controls in that run passed. The ordinary new-thread guard passed 2 of 3, and the native-subagent guard also failed there. The paired main comparison covers the cases in the table. The full run has no matching full baseline. Quick CI and 668 focused tests passed across the final changes. Rebase validation covers the generated budget and carry compilation. Required GitHub CI and Codex review passed on the preceding head `ec0d25ef45c815e14fe30dd5abc3da7b135deb48`, with zero unresolved review threads. [GitHub CI](https://github.com/lastobelus/lastCode/actions/runs/44696105772), [Codex review](#768 (comment)). ## Context budget | Value | Main | Candidate | Byte change | | ----------------------------- | -----: | --------: | ----------: | | `claudeSystemAppendBytes` | 21,845 | 23,198 | +1,353 | | `codexAdditionalContextBytes` | 22,843 | 24,196 | +1,353 | | `mcpToolListJsonBytes` | 85,478 | 85,506 | +28 | Main changed other tool descriptions after the focused run. At #771, the archive description kept both the new temporary-project consent and the vocabulary guidance. The measured byte increases are the same after rebasing. The orchestrator applied `agent-context-increase` after reviewing the previously approved head. The rebase after #771 preserves all three approved byte increases. ## Upstream-owned files | File | Added | Removed | | ---------------------------------------------------------------- | ----: | ------: | | `apps/server/src/mcp/McpHttpServer.test.ts` | 1 | 1 | | `apps/server/src/mcp/toolkits/orchestrator/tools.ts` | 3 | 3 | | `apps/server/src/mcp/toolkits/project/tools.ts` | 1 | 1 | | `apps/server/src/mcp/toolkits/thread/tools.ts` | 2 | 2 | | `apps/server/src/provider/agentContextBudget.json` | 3 | 3 | | `docs/user/thread-sidebar.md` | 22 | 17 | | `evals/mcp-tool-use/run.ts` | 3 | 3 | | `packages/provider-core/src/server/orchestrationInstructions.ts` | 7 | 4 | ## Decisions - **Shared copy:** the vocabulary lives in a fork-owned module and is interpolated into the existing orchestration section, so Codex and the other providers get identical text. - **Group threads:** use the existing empty launch inputs. Tool schemas and runtime behavior are unchanged. - **Wrap-up:** name the kept conversations and get the user's choice before applying the archive preview selection. The rebase after #771 preserved its separate consent and history-deletion warnings for removing temporary projects. Cross-environment archiving remains outside this PR. - **Thread-read routing:** the contract is intact. The added fixture returns matching read results so the model can follow the existing link rule. - **Eval scope.** The paired run and the full suite use one evaluator model. The new cases cover the owner's terse phrasing, and the existing suite covers neighboring behavior. - **Carry replay.** The initial push omitted the required source trailers. All source commits now identify #751 and use the Incubator group, as the vocabulary spans the feature’s tools, prompts, tests, and docs. Main’s #726 squash then needed a provenance repair. The rebase onto repaired main preserved the complete PR tree. - **Authorship:** Claude Opus polished the guidance. I clarified null placement where an explicit top-level flag also applies, and fixed wrap-up's consent order after review traced what happens when the archive ends the turn. Local review: 3 rounds with GPT-6.1 Terra (xhigh), approved. The last round found one low-severity grader gap. The tighter check rejects unrelated questions and preserves the paired wrap-up scores when regrading saved samples. Carry-Source-Ref: refs/lastcode/carry-sources/pr-768/19565abda314b40fe618c38bfcec24a7c2aa95cf Carry-Source-Base: 88fca56 Carry-Source-Head: 19565ab
…#793) Observe-only capacity ([#726](#726), [#774](#774)) left four review nits about how capacity is typed and reported. Capacity step 2 will add a mode, and these should land first. ## What changed - **Strict local type (R19):** making results from other machines tolerant had also loosened the one exported `CapacitySnapshot` type. So this server's own verdict states, reason signals, comparisons and memory pressure were plain strings, and a wrong value was no longer a type error. `CapacitySnapshot` is strict again. A separate `ReportedCapacitySnapshot` keeps the tolerant decoding for MCP tool results, peer forwarding and the CLI. - **Linked machines (R20):** a newer `linkedObservation` value no longer fails the decode. One malformed linked entry, whether its machine id, label or capacity, now drops only that entry, using the existing `ForwardCompatibleArray`. Before, it dropped the peer's whole capacity block. - **No guessed mode (R12, R23):** without a wired sampler, and when the capacity reader can't read settings, the mode is reported as `unknown` instead of `observe`. An unreachable linked machine was already `unknown`; it now uses the same default. - **Tool description (R22):** `t3_environment_read` now names mode `unknown`. I reworded the description so its byte count is unchanged (374 bytes). A corrupt settings file still reports `observe`. The settings service falls back to defaults there, so the server really is observing. ## Validation - **New tests,** both failing on base and passing here: - a forwarded environment read with a newer `linkedObservation`, one good linked entry, one with malformed capacity, and one with no machine id; - the unwired `Capacity` reporting `unknown`. - **Changed-file gate:** `vp run check:changed origin/lastcode/main` passed format, lint, both knip passes, GraphQL, typecheck of 38 packages, and tests. The focused capacity, environment and agent-context-budget tests passed (64). - **Model-backed MCP evals:** not run; this machine has no authorized eval proxy. Command: `pnpm mcp-tool-use --out runs/capacity-unknown-mode` from `evals/`. Local review: 2 rounds with GPT-6.1 Terra (xhigh), approved. Round 1 found the per-entry gap that `ForwardCompatibleArray` now closes. It also flagged two items I declined. One is the corrupt-settings case above. The other is that `t3_environment_read` fails outright when settings can't be read; that is existing upstream handler behavior, left as a follow-up. Implemented with Claude Opus 5.5 through Claude Code. Carry-Source-Ref: refs/lastcode/carry-sources/pr-793/791f5fa9092237216bffe1b25f5f54e14f3d79ec Carry-Source-Base: 232b995 Carry-Source-Head: 791f5fa
…794) The observe-only capacity sampler from [#726](#726) had review nits about noisy verdicts, logging, process spawns, and default fan-out. This PR fixes them before capacity step 2 starts acting on verdicts. ## What changed - **Only rule signals gate verdicts (R7):** swap, worktree folder counts and turn activity have no threshold. An unreadable value is now reported as `null` instead of turning both verdicts `unknown` and restarting the 60-second recovery. Load, memory pressure and free disk still gate as before. - **Off reports what it does (R8, R17):** a read in Off returns no measurements and `open` verdicts with no reasons, since Off samples and holds nothing. Before, it returned stale `unknown` verdicts with a made-up `activity: unreadable` reason. A read that sees Off also invalidates earlier readings, so a brief Off between sampler ticks can't leave pre-Off data or recovery time in place. - **Quieter log (R10):** `capacity.would-hold` is logged when the held state or its reasons change, including categorical values such as warning becoming critical. It used to log every 5 seconds while held. - **Fewer processes (R11):** on macOS, memory pressure and swap now come from one `sysctl` call per sample, parsed by content so one failed name doesn't shift the other value. One native source is kept per worktree directory and reads the core count only once. The live `sysctl` command is built on each read. - **Dead state removed (R16):** `CapacityState.activity` and its parameter were never set in production. - **Linked machines on request (R9):** `t3_environment_read` reads linked machines only with `includeLinked: true`, because each one can cost 2 seconds. `lastcode-thread capacity` asks for them. The tool description now says how to get linked machines, that no mode holds work, and what Off reports. It is shorter than before (369 bytes, down from 374). ## Validation - **Tests:** eight focused tests fail on the base and pass here: - signal gating; - Off shape; - logging only on change; - the default linked read; - live-value parsing. - **Production-service test:** `Capacity.make` runs with a fake macOS spawner over three samples. It reads the core count once and the live values three times, and logs a changing pressure level each time. Without the service-level source cache and the per-read command, it fails. - **Changed-file gate:** `vp run check:changed origin/lastcode/main` passed format, lint, both knip passes, GraphQL, typecheck, and tests. - **Real host:** the native source on macOS read cores, memory pressure, swap and free bytes. - **Model-backed MCP evals:** not run; this machine has no authorized eval proxy. Command: `pnpm mcp-tool-use --out runs/capacity-environment-read` from `evals/`. Local review: 3 rounds with GPT-6.1 Terra (xhigh), approved. - **Round 1:** found that the native source was rebuilt every sample, so the core count was never cached. Fixing it exposed that the batched `sysctl` effect had been built once, which would have frozen the live values. Round 1 also found a gap after brief Off periods and a log signature that ignored categorical values. - **Rounds 2 and 3:** found only wording nits, all fixed. - **Declined as follow-ups:** two narrow races. A read, or a sample still in flight, can overlap the first sample after an Off toggle. Mode changes are manual and rare. Implemented with Claude Opus 5.5 through Claude Code. Carry-Source-Ref: refs/lastcode/carry-sources/pr-794/eb6857f7b31f31aec7140089172ce1631ca7de16 Carry-Source-Base: 8b3392d Carry-Source-Head: eb6857f
…797) 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](#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. Carry-Source-Ref: refs/lastcode/carry-sources/pr-797/1d06a911753b4202e07888e8e84cbd145a52df3b Carry-Source-Base: 27b1e62 Carry-Source-Head: 1d06a91
Concurrent coordinators have no shared reading of machine capacity, so each can launch work while other threads are already using the same resources. This adds a server-owned sampler that publishes advisory verdicts. It never holds, releases, rejects, or redirects work.
🔍 What changed
lastcode-thread capacityprints the same verdicts as JSON;--environmentreads another linked environment.capacityModeis exposed through environment preferences on the existing authorized settings path; there is no new settings screen.🚦 Verdict rules
➡️ Next step
Measurement is a separate service from admission, so the later enforcement step stays small. The owner, existing messages, and wakes are untouched.
Not included: enforcement, a worktree guard, a heavy-work lease, placement, an upstream post, installation, or a restart. Owner approval is required before merge.
🧩 Fork footprint
Every LastCode checkpoint replays this change onto a new upstream nightly, so it keeps out of upstream-owned files where it can. Upstream-owned files carry +42/−8 lines across 11 files: the settings field, one schema line and one handler line per publishing tool, and one import and one provide in
server.ts. The rest (about +2,260 lines across 18 files) is fork-owned, including all capacity tests.Capacityis aContext.Referencewhose default reads as unknown, so existing test harnesses need no new layer, and a fork-owned test checks that the production route block provides the live service. Capacity fields on cross-machine and CLI results are optional, so machines and CLIs without this change still decode them. Read-side decoding is also tolerant in the other direction: a newer mode, reason signal, comparison or verdict state from a later version passes through as a string, a malformed capacity block is dropped without failing the surrounding result, and the environment read keeps a newercapacityModeinstead of rejecting the read. Local settings writes stay strict (Off and Observe only).✅ Validation
vp run check:changed origin/lastcode/main(format, lint, both knip passes, GraphQL, typecheck of 38 affected packages, and 272 tests in 15 files). Rebased ontolastcode/mainat3e232327e99(checkpoint 4864 plus eleven commits). The only conflict was the agent-context budget counter, re-measured withagent-context:generateat 86,521 (+517 over main, unchanged by the tolerant-decoding commit). Exact-head carry compilation passed on the checkpoint-4864 rebase.Local review: 4 rounds with Claude Fable 5.2 (xhigh), approved, after the earlier Sol (high) and Terra (xhigh) rounds. Round 4 covered the checkpoint rebase and the tolerant-decoding commit, and found only nits (listed below). Rounds 1 and 2 fixed results that a machine or CLI without this change could not decode, a full thread-snapshot read on every sample, the capacity service as a required toolkit dependency, capacity tests in upstream test files, capacity wiring inline in
server.ts, sampler verdicts that depended on reads, and a CLI flag lost in the rebase.Follow-ups, not in this PR:
includeLinkeddefault;sysctlprocess count;logic.ts;CapacitySnapshottype for this server's own sampler output and use a separate loose type for reported results (R19);linkedObservationand each linked entry tolerantly, so one bad linked entry doesn't drop a peer's whole block (R20);ServerSettings.capacityModetolerantly on read, so a client or a downgraded server doesn't reject a whole config or settings file containing a newer mode (R21);unknownin the environment tool'scapacity.modedescription (R22);Capacityreportunknownrather thanobserve(R23).Implemented with Codex Sol (xhigh) through the Codex harness; agent-facing tool wording by Claude Opus 5.5.