Skip to content

fix(server): preserve newer capacity modes in settings - #774

Merged
lastobelus merged 1 commit into
lastcode/mainfrom
lastcode/capacity-settings-tolerant-read
Nov 20, 2026
Merged

lastobelus merged 1 commit into
lastcode/mainfrom
lastcode/capacity-settings-tolerant-read

Conversation

@lastobelus

@lastobelus lastobelus commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

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.

@lastobelus
lastobelus marked this pull request as ready for review November 20, 2026 06:23
@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-20T06:47:05.408221Z 048810d 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.

@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: f4e5624d2f

ℹ️ 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".

Read and save newer capacity modes without rejecting the rest of the settings or config. Sample unfamiliar modes as advisory and report their stored values. Settings patches still accept only the modes this server supports.

Implemented with GPT-6.2 Sol in the Codex harness.

Carry-Group: incubator
Carry-Observation: Capacity settings need tolerant reads before enforcement can add a new mode.
@lastobelus
lastobelus force-pushed the lastcode/capacity-settings-tolerant-read branch from f4e5624 to 048810d Compare November 20, 2026 06:38
@lastobelus

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 048810d180

ℹ️ 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 bbb0bd0 into lastcode/main Nov 20, 2026
32 checks passed
@lastobelus
lastobelus deleted the lastcode/capacity-settings-tolerant-read branch November 20, 2026 07:03
lastobelus added a commit that referenced this pull request Nov 20, 2026
…#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
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