Repository navigation
placement P2: placement and placementNeeds setting contracts - #798
Conversation
LensVerdict: NOT SAFE. A bad Reviewed head Blocking
Major
Minor
Agent paths (focus): closed
State checks
|
Fix roundHead 1. Blocking: a bad
2. Major: a partial save over an unreadable
3. Major:
4. Label form. Done.
5. Minors
Tests
|
|
Seam fix (c7e9e83): option 2. Option 1 does not fit: no pinned line in
Seam check and its test pass; placement tests in contracts, shared and server pass. |
`placement` (mode off/advise/enforce, labels, factsCommand, never groups, weights per linked machine) and `placementNeeds` (server value, and a project override), added the way the fork's other settings are: fields, patch fields, patch rules and pin rows in forkSettings.ts/forkDefaults.ts. - An old or empty settings file reads as off with no needs. - A bad placement value reads as off with the reason in `problem`; the person's text is kept in `unreadable` and written back until the key is saved (as modelPolicy). The rest of the file still loads. - A save is strict (bad field or unknown key refused); a field left out keeps its value; a save over a kept unreadable value starts from off. - Both keys are person-only (derived); a project's needs are kept when an older client's save leaves them out, and only null clears them. - A managed policy locks placement as a whole value. Contracts only: nothing reads the settings yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r bad placement
- A bad placementNeeds (server or project) now reads as broken: the work fits
no machine (readPlacementNeeds gives the plain reason), the problem is kept,
and the person's text is written back unchanged by other saves until the
key is saved. A project save may send the kept text back only unchanged.
- Over an unreadable placement, a save that names only some fields is
refused ("placement is not valid; save the whole setting"); a whole save
replaces it.
- factsCommand must be a full path on the server's OS (playtest's check):
a save of another OS's path is refused, and one in the file reads as off,
kept, with its problem. Control characters are refused.
- Labels are stored trimmed, lower-cased and without repeats (so
["GPU", "gpu"] is no never group); weight keys with spaces are refused.
- Tests for each, a policy lock row for placementNeeds, and the docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The load and normalize lines added to upstream's serverSettings.ts are gone (no pinned seam line runs after a save's normalize, so the same result could not go through one). Placement code now reads placement through apps/server/src/fork/placementRead.ts (readPlacementForThisOs): a factsCommand this OS cannot run reads as off, kept as written, with its problem. The save check that refuses setting one stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main now names the fork settings that read null in one list (WHOLE_ONLY), and the pin test requires it to match exactly. Both placement settings read a bad value, null included, as off/unset, so both join the list: a policy locks placement as a whole, a path inside it is refused, and the manageable-settings list shows placement as one path instead of its fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c7e9e83 to
efe12f3
Compare
|
Rebased onto 5051 main
|
…ings hold it The web settings code builds a save from part of the settings, so a held placementNeeds value (a kept bad value included) must fit the patch type. The patch field was typed as plain labels, which broke the web typecheck. PlacementNeedsPatch is now typed as PlacementNeeds while its decode stays strict: only labels are taken, and a save replaces a kept bad value whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests
A webhook run is forked and reads the record file, and these tests give
forked work a fixed number of event-loop turns. On a loaded machine a read
on Node's thread pool can outlast them ("never: the owner's task ran"), on
main as well as on branches. The service in these tests now reads whole
files synchronously, so a run takes the same number of turns on any machine.
With the thread pool kept busy the test failed before and passes now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since the merge of main, a whole Partial<ServerSettings> no longer fits a patch (another field is nullable in settings only). The test checks the placementNeeds field it is about. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Placement design row P2.
What and why
Contracts for the placement settings (design section 4.1). Nothing reads them yet: no runner, engine, server wiring or UI (rows P4 to P9).
placement(server):mode(off|advise|enforce, defaultoff),labels(what this machine has),factsCommand(""or an absolute path),never(label groups that must not meet on one machine),weights(linked machine id toprefer|normal|less|manual).placementNeeds: a project override (projectSettingsOverrides.<id>.placementNeeds, for example["gpu"]). It is also a server key (default[], the needs of projects without their own). This is because the fork's project overrides must be project-scoped server keys: the seam testforkSettings.test.tsandPROJECT_SCOPED_SERVER_SETTING_KEYSrequire it.Added the way
waitFor,agentSlotsandmodelPolicyare: the schema in a new fork filepackages/contracts/src/placement.ts, and fields, patch fields, patch rules, the project key and pin rows inforkSettings.tsandforkDefaults.ts. Docs rows indocs/fork/README.mdandFORK_CHANGES.md.Value rules: labels are trimmed, one word without spaces or control characters, at most 64 characters, at most 64 per list, and a repeat is dropped.
factsCommandis empty or an absolute path (POSIX, drive or UNC; the settings do not know the OS). Anevergroup has at least 2 different labels, with at most 32 groups.weightskeys are environment ids, with at most 256 entries.placementNeedsfollows the label rules.Decoding:
off.agentSlotshas no tolerant decode. A bad value there fails the whole settings decode, so the load ignores the file (forkReport.test.tspinsagentSlots: {enabled: "yes"}as a parse warning). It also has no banner. SoplacementfollowsmodelPolicy, the fork's newer pattern for fail-closed settings. A bad value (bad field, wrong type or unknown key) reads asoff, with a log warning. The person's text is kept inunreadableand written back unchanged by saves of other settings. The reason goes inproblem, one line such asExpected "off" | "advise" | "enforce" at ["mode"]. That is the recorded problem a later UI row can show as a banner. The rest of the file still loads.placementNeedsreads as[]with a warning, ashandoffdoes. In a project it is never read as the server's value.merge-fields: a field left out keeps its stored value. A save over a kept unreadable value starts fromoffand drops the kept text (a 4-line change in the fork-ownedforkSettingsPatch.ts). A project save that leavesplacementNeedsout (an older client) keeps it; onlynullclears it, as forplaytest.placementandplacementNeedsare inFORK_PERSON_ONLY_KEYS, which is derived. They are not inFORK_AGENT_WRITABLE_KEYS.placementas a whole value. A lock on one field such asplacement.modeis refused, with "manage "placement" as a whole". The reason is that the tolerant decode readsnullas off, which makes the policy treat the key as nullable (same asmodelPolicy).Names match the plain types in the open P5 PR #787 (
PlacementMode,PlacementWeight,labels,neveras label groups,needsas labels). This PR does not depend on it.Tests
New:
packages/contracts/src/placement.test.ts,packages/shared/src/placementSettings.test.ts. Extended:personOnlySettings.test.ts,managedSettings.forkKeys.test.ts,forkSettings.test.ts,forkReport.test.ts(both keys marked as not a switch yet).[]).problem, the text kept, and the other settings unchanged. They include a bad mode, a relativefactsCommand, a bad weight word, a one-labelnevergroup, an unknown field, and wrong types (placement as text, array or null; labels, never, weights, factsCommand, mode).[],{},""). Every other setting stays the same.placementNeeds: decodes and defaults to[], and resolves the project's value over the server's. A hand-writtennullmeans not set. Kept when an older client's save leaves it out;nullclears it.placementorplacementNeeds, in any spelling or depth. Also checked at the end of a patch path (settings.placement,settings.projectSettingsOverrides.<id>.placementNeeds). A call tot3_environment_preferences_update,t3_project_updateort3_thread_configurethat sends them unnamed, at the top or inside the tool's own objects, has them dropped by the decodeMcpHttpServeruses.On old code (fix files stashed, tests kept) the new tests fail: placement.test.ts cannot load; forkSettings.test.ts 2 failures; placementSettings.test.ts 4; personOnlySettings and managedSettings.forkKeys 5.
Red check: with
placementtaken out of the person-only keys (put inFORK_AGENT_WRITABLE_KEYS), threepersonOnlySettings.test.tstests fail: "lists every fork setting but the agent-writable ones", "catches a tool whose input names one…" and "catches a person-only key at the end of a settings patch path".forkSettings.test.ts"gives every fork setting a patch field and a patch rule" fails too.Spot checks: each of 15 fix lines was removed one at a time, and each made a test fail:
>= 2never-group sizefactsCommandcaseplacementNeedskept when left outnullReadsAsUnset[]fallback for bad needsmerge-fields(set toreplace)placementRuns:
packages/contracts: 42 files, 462 tests, all pass.packages/sharedtargeted: 102 tests pass. The full suite has one failure,shell.test.ts(login shell on this Mac). It fails the same on origin/main.forkReport.test.tsWAL-timing tests. Those fail the same on origin/main on this Mac.pnpm fmt:checkand lint on the changed files are clean.node .github/scripts/fork-seam-check.cjs --config-ref origin/main origin/main HEADpasses.fork-seam-check.test.cjs: 114 of 114 pass.fork-changes-list.test.cjs: 10 of 10 pass.General vs project
General: a fork setting any T3 fork user with linked machines can set (labels, the never rule, per-machine weights, a project's needs). Nothing in it is about one project or one machine.
Upstream fit: fork-only. It changes no upstream file and no seam line (seam check green); upstream has no placement setting to align with, and the weight words are upstream's load-balancing words.
🤖 Generated with Claude Code