From 0da874dd224300fa7e2215661d7346d8485309ae Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Sun, 22 Nov 2026 21:56:00 +0100 Subject: [PATCH 1/2] fix(fork): cleaner dedupe and playtest round-2 follow-ups - cleaner: dedupe.writtenInPlace is a 'picks' key (missing links nothing, [] turns linking on), not 'keeps more'; README: it has no default (missing gives exit 1, not a refused machine file), one upgrade note with one install order, and a part file stays while the key is missing (pinned in the half-way test). - cleaner tests: the machine-file kinds example uses *.sav. - playtest: the "read as off" warning names what is wrong, such as the unknown field. Co-Authored-By: Claude Opus 5.5 --- docs/fork/README.md | 4 +-- fork-kit/cleaner/README.md | 33 +++++++++++++------------ fork-kit/cleaner/lib/cleaner/config.py | 5 ++-- fork-kit/cleaner/lib/cleaner/dedupe.py | 5 ++-- fork-kit/cleaner/tests/dedupe.test.py | 9 ++++--- packages/contracts/src/playtest.test.ts | 12 ++++++--- packages/contracts/src/playtest.ts | 15 +++++++---- 7 files changed, 49 insertions(+), 34 deletions(-) diff --git a/docs/fork/README.md b/docs/fork/README.md index e5d67f301fdb9..63ebf842ddde7 100644 --- a/docs/fork/README.md +++ b/docs/fork/README.md @@ -283,8 +283,8 @@ Only the person can change it; agents cannot. A save that is on without all four push step's name (or names one `claim`, `renew` or `release`), names a program by anything but its full path on the server's OS, or has a field this build does not know is refused. A hand-edited value that is not valid, or has a field this build does not know (a newer build's limit, a typo), -reads as off (with a warning in the server log), and the next save of any setting writes the default -in its place. So after moving back to an older build, copy the playtest value first: the older +reads as off (with a warning in the server log that names what is wrong, such as the unknown +field), and the next save of any setting writes the default in its place. So after moving back to an older build, copy the playtest value first: the older build's next save replaces a newer build's value. Other fields: how often a claim is renewed (`renewMinutes`), when an idle session ends (`idleMinutes`) and the longest session (`maxHours`). diff --git a/fork-kit/cleaner/README.md b/fork-kit/cleaner/README.md index 476fd9a28152e..3027e24fc1f8e 100644 --- a/fork-kit/cleaner/README.md +++ b/fork-kit/cleaner/README.md @@ -619,7 +619,7 @@ stays, each reads the same bytes as before, and the disk holds them once. Withou | `dedupe.folders[].path` | required | a folder; files at any depth in it are looked at | | `dedupe.folders[].days` | required | days without a change (7 or more): newer files are not looked at | | `dedupe.folders[].layered` | false | the folder may be on a filesystem that is not local (as compress-cold) | -| `dedupe.writtenInPlace` | required | more name patterns (no `/`) never linked: one program's own kinds | +| `dedupe.writtenInPlace` | none | more name patterns (no `/`) never linked: one program's own kinds | **The risk it takes: read this before you name a folder.** Names of one hard-linked file are one file, so any write **into** one name changes every name, and the other names' old bytes are gone. Most ways of writing a file do @@ -634,7 +634,8 @@ images, no working copies. The rule refuses the kinds it knows are written in pl `*.log`, `*.log.*`, `*.jsonl`, `*.ndjson`, `*.journal`, `*.pid`; disk images `*.qcow2`, `*.img`, `*.raw`, `*.vmdk`, `*.vdi`, `*.vhd`, `*.vhdx`; swap `*.swp`, `*.swap`; mail boxes `mbox`, `*.mbox`; partial downloads a client resumes in place `*.part`, `*.crdownload`, `*.partial`, `*.!qb`), plus the name patterns in `dedupe.writtenInPlace` (one -program's own kinds, such as a game's save files; `[]` when the folders hold none), but such a list can never be +program's own kinds, such as a game's save files; `[]` when the folders hold none: while `dedupe.folders` names a +folder and this key is missing, the rule links nothing and the run exits 1, see below), but such a list can never be complete. Every plan and run that links says it again in one line (`dedupe: names of one file share every later write ...`). On btrfs or XFS a tool that shares blocks with a reflink (`FIDEDUPERANGE`) is the safer choice: later writes do not reach the other copies. This rule makes hard links because the hosts it was made @@ -713,11 +714,12 @@ the rename)`. The report has a class - **it stops half-way:** the duplicate is either as it was or a name of the kept file, never gone. Killed before the new name: nothing changed. Killed between the new name and the rename: the duplicate is as it was and the part `..<8 hex>.cleaner-link` stays; the next run removes that part (only while it is one the cleaner wrote - down and still a name of a file with other names) and links again. Killed right after a link or rename, before its - inode time was written down: the kept file looks changed and waits its `days`, then the run goes on. Killed while - the cache is written: the old cache stays, and the list of its own steps still holds what it did. A part that is - the last name of its bytes is kept and named (`part without its file`). A failed rename removes the part and keeps - the duplicate. No entry goes into the journal of half deletes: there is nothing half gone. + down and still a name of a file with other names) and links again. While `dedupe.writtenInPlace` is missing the + rule reads no folder, so the part stays (one more name of the kept file) until the key is added. Killed right + after a link or rename, before its inode time was written down: the kept file looks changed and waits its `days`, + then the run goes on. Killed while the cache is written: the old cache stays, and the list of its own steps still + holds what it did. A part that is the last name of its bytes is kept and named (`part without its file`). A + failed rename removes the part and keeps the duplicate. No entry goes into the journal of half deletes: there is nothing half gone. - **a file changes or is opened:** while the plan reads it: kept as `changed`. Between the plan and the run, or while it is compared or linked: refused or failed, both files stay as they are (the next run sees other bytes and joins nothing). A kept file replaced, or given, losing or moving a name, after the plan: refused. @@ -730,13 +732,12 @@ the rename)`. The report has a class links nothing. Each folder is kept with `could not read: dedupe.writtenInPlace is missing ...` and every run exits 1 until the key is there; the other rules run as usual. `[]` is the owner's word that no program writes its own kinds in place in these folders. -- **the cleaner is older than the machine file:** an older cleaner refuses the unknown `dedupe` key and every daily - run exits 2. Install this cleaner on a machine first, then add the key. -- **upgrading a machine whose `dedupe` section has no `writtenInPlace`:** add the key first (the kinds a program - there writes in place, or `[]`), then install this cleaner. Until the new cleaner is in, the older one refuses - the machine file (`unknown key 'writtenInPlace'`) and every rule stops, every daily run exits 2, nothing is - touched. The other order is safe too, only noisier: the new cleaner links nothing and exits 1 until the key is - added. +- **upgrading a machine:** install this cleaner first, then add `dedupe` or, to a `dedupe` section an older cleaner + read, `writtenInPlace` (the kinds a program there writes in place, or `[]`). In between, the rule does nothing + (no `dedupe`) or links nothing and exits 1 (no `writtenInPlace`, above); the other rules run. The other order + stops more: a cleaner older than the machine file refuses the unknown key (`unknown key 'dedupe'` or + `unknown key 'writtenInPlace'`), so every rule stops and every daily run exits 2, touching nothing, until this + cleaner is in. ## The machine file @@ -822,8 +823,8 @@ floor, a root folder that is `/`, the home folder or a folder above it: the comm exits 2 and does nothing. Every key can only pick what a rule looks at, raise a floor, or keep more (`KEY_KINDS` in `config.py`; a test -fails for a key that is not placed there). Two keys free more. `layered` (a cold or dedupe folder may be on a -filesystem that is not local: an overlay, FUSE or a share) is a yes or no, false by default. `regenerable` takes plain folder names +fails for a key that is not placed there). Two keys take a refusal away. `layered` (a cold or dedupe folder may be +on a filesystem that is not local: an overlay, FUSE or a share) is a yes or no, false by default. `regenerable` takes plain folder names only: no `/` and no wildcard, so `["*"]` is refused and can never take the `ignored files` refusal away. A name frees an ignored folder of that name (and what is in it), never a file, and never a credential-looking name. diff --git a/fork-kit/cleaner/lib/cleaner/config.py b/fork-kit/cleaner/lib/cleaner/config.py index 80bdb8cc9a81d..e0b2fcbdda86c 100644 --- a/fork-kit/cleaner/lib/cleaner/config.py +++ b/fork-kit/cleaner/lib/cleaner/config.py @@ -279,8 +279,9 @@ def _github(value): 'compressCold': 'picks', 'compressCold.folders': 'picks', 'compressCold.keepFreeGB': 'floor', 'folders.path': 'picks', 'folders.days': 'floor', 'folders.layered': 'loosens', # dedupe deletes no content either (every name keeps its bytes and metadata); its folders never are or hold a - # must-keep path, and every refusal holds in them (dedupe.py). - 'dedupe': 'picks', 'dedupe.folders': 'picks', 'dedupe.writtenInPlace': 'keeps more', + # must-keep path, and every refusal holds in them (dedupe.py). writtenInPlace picks too: its patterns keep more, + # but missing it links nothing and `[]` turns linking on. + 'dedupe': 'picks', 'dedupe.folders': 'picks', 'dedupe.writtenInPlace': 'picks', # agentScratch: on, its folder and its days pick what it looks at. keepFirst only adds a copy before a delete: # more patterns copy more; maxFileBytes has a floor; a session with more than maxSessionBytes to copy stays # whole, so the cap picks which sessions the rule may take at all (every refusal still holds for them). The diff --git a/fork-kit/cleaner/lib/cleaner/dedupe.py b/fork-kit/cleaner/lib/cleaner/dedupe.py index 20e9b09452c57..a6de8aeb23800 100644 --- a/fork-kit/cleaner/lib/cleaner/dedupe.py +++ b/fork-kit/cleaner/lib/cleaner/dedupe.py @@ -16,8 +16,9 @@ the kept file, never nothing. So a run killed between the two leaves the duplicate as it was and a part that is one more name of the kept file; -the next run removes that part (a name whose content another name still holds) and links again. A part whose other -names are all gone holds the only copy of its content and stays (named in the plan). +the next run that reads the folders (not one without `dedupe.writtenInPlace`) removes that part (a name whose +content another name still holds) and links again. A part whose other names are all gone holds the only copy of +its content and stays (named in the plan). What it never takes: links (never followed), other filesystems and mount points (a hard link cannot cross one either), other owners' files, credential and lock names, must-keep names, folders with a KEEP file and git folders, diff --git a/fork-kit/cleaner/tests/dedupe.test.py b/fork-kit/cleaner/tests/dedupe.test.py index 520d2f2f90c37..7895b1d0bab9b 100644 --- a/fork-kit/cleaner/tests/dedupe.test.py +++ b/fork-kit/cleaner/tests/dedupe.test.py @@ -274,6 +274,9 @@ def test_killed_between_the_link_and_the_rename_the_next_run_finishes(self): self.assertRegex(os.path.basename(part), r'^\.b\.bin\.[0-9a-f]{8}\.cleaner-link$') self.assertEqual((self.ino(b), self.read(b)), (dup, body())) # the duplicate as it was self.assertEqual(self.ino(part), self.ino(a)) # one more name of the kept file + # Without `dedupe.writtenInPlace` the rule reads no folder: the part stays until the key is back (README). + code, lines = self.run_cleaner(self.dd_cfg(in_place=None)) + self.assertEqual((code, self.files()), (1, names), lines) plan = self.plan(self.dd_cfg()) self.assertEqual(self.items(plan, 'link-part'), [part]) self.assertEqual(self.items(plan), [b]) @@ -722,14 +725,14 @@ def test_more_kinds_written_in_place(self): def test_the_machine_file_adds_kinds_written_in_place(self): """A program's own kinds (a game's save files) are named in the machine file, not in the code.""" - a, b = self.put('r.0.0.MCA', days=50), self.put('r.0.1.mca') + a, b = self.put('slot1.SAV', days=50), self.put('slot2.sav') c, d = self.put('x.bin', days=50), self.put('y.bin') kinds = lambda value: self.dd_cfg(in_place=value) - plan = self.plan(kinds(['*.mca', 'world.dat'])) + plan = self.plan(kinds(['*.sav', 'world.dat'])) for path in (a, b): self.assertKept(plan, path, 'written in place') self.assertEqual(self.items(plan), [d]) - for bad in (['saves/*.mca'], [''], ['..'], [5], '*.mca'): + for bad in (['saves/*.sav'], [''], ['..'], [5], '*.sav'): with self.subTest(bad=bad), self.assertRaises(machine_file.MachineFileError): kinds(bad) diff --git a/packages/contracts/src/playtest.test.ts b/packages/contracts/src/playtest.test.ts index 5efa9d82df3d3..ef80a97b164a8 100644 --- a/packages/contracts/src/playtest.test.ts +++ b/packages/contracts/src/playtest.test.ts @@ -200,14 +200,18 @@ describe("playtest settings in the settings file", () => { expect(settings.projectSettingsOverrides[PROJECT]?.playtest).toEqual(DEFAULT_PLAYTEST_SETTINGS); }); - it.effect("warns when it drops a bad value", () => + it.effect("warns when it drops a bad value, naming an unknown field", () => Effect.gen(function* () { const logged: Array = []; const logger = Logger.make(({ message }) => logged.push(message)); - yield* decodeFileEffect(without("claim")).pipe( - Effect.provide(Logger.layer([logger], { mergeWithExisting: false })), - ); + const drop = (bad: unknown) => + decodeFileEffect(bad).pipe( + Effect.provide(Logger.layer([logger], { mergeWithExisting: false })), + ); + yield* drop(without("claim")); expect(JSON.stringify(logged)).toContain("invalid playtest settings read as off"); + yield* drop({ ...ADAPTER, claim: { ...ADAPTER.claim, maxRuns: 1 } }); + expect(String(logged.at(-1))).toContain('["claim"]["maxRuns"]'); }), ); diff --git a/packages/contracts/src/playtest.ts b/packages/contracts/src/playtest.ts index d4208e68ec018..14134e395d359 100644 --- a/packages/contracts/src/playtest.ts +++ b/packages/contracts/src/playtest.ts @@ -4,6 +4,7 @@ * follows (environment, exit codes); docs/fork/playtest.md. Off by default. */ import * as Effect from "effect/Effect"; +import * as Result from "effect/Result"; import * as Schema from "effect/Schema"; import * as SchemaTransformation from "effect/SchemaTransformation"; @@ -139,10 +140,13 @@ export type PlaytestSettings = typeof PlaytestSettings.Type; /** Off, no steps, the default limits. */ export const DEFAULT_PLAYTEST_SETTINGS: PlaytestSettings = Schema.decodeSync(PlaytestSettings)({}); -const decodePlaytestSettingsOption = Schema.decodeUnknownOption(PlaytestSettings); +const decodePlaytestSettingsResult = Schema.decodeUnknownResult(PlaytestSettings); /** Also refuses an unknown field, nested ones too: it may be a newer build's limit. */ -const isStrictPlaytestSettings = (raw: unknown) => - decodePlaytestSettingsOption(raw, { onExcessProperty: "error" })._tag === "Some"; +const strictPlaytestSettingsProblem = (raw: unknown): string | undefined => { + const decoded = decodePlaytestSettingsResult(raw, { onExcessProperty: "error" }); + return Result.isFailure(decoded) ? decoded.failure.message : undefined; +}; +const isStrictPlaytestSettings = (raw: unknown) => strictPlaytestSettingsProblem(raw) === undefined; /** A save's value: refused when bad, also for a field this build does not know (never dropped). */ export const PlaytestSettingsPatch = Schema.Unknown.check( @@ -173,11 +177,12 @@ export const PlaytestSettingsFromSettingsFile = Schema.Unknown.pipe( PlaytestSettings, SchemaTransformation.transformEffect({ decode: Effect.fn("PlaytestSettingsFromSettingsFile.decode")(function* (raw: unknown) { - if (isStrictPlaytestSettings(raw)) { + const problem = strictPlaytestSettingsProblem(raw); + if (problem === undefined) { return raw as typeof PlaytestSettings.Encoded; } yield* Effect.logWarning( - "settings: invalid playtest settings read as off; the next settings save replaces them", + `settings: invalid playtest settings read as off (${problem.replaceAll("\n", " ")}); the next settings save replaces them`, ); return {}; }), From 239b5cdda658c181b495e52161607ef9ddda6043 Mon Sep 17 00:00:00 2001 From: scuttletoby <123843277+scuttletoby@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:04:02 +0100 Subject: [PATCH 2/2] fix(contracts): one-space playtest warning, pin that it carries no value Collapse every whitespace run in the dropped-settings warning to one space, and pin in the test that a bad argv value never reaches the log. Co-Authored-By: Claude Opus 5.5 --- packages/contracts/src/playtest.test.ts | 11 ++++++++++- packages/contracts/src/playtest.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/contracts/src/playtest.test.ts b/packages/contracts/src/playtest.test.ts index ef80a97b164a8..294267df19589 100644 --- a/packages/contracts/src/playtest.test.ts +++ b/packages/contracts/src/playtest.test.ts @@ -211,7 +211,16 @@ describe("playtest settings in the settings file", () => { yield* drop(without("claim")); expect(JSON.stringify(logged)).toContain("invalid playtest settings read as off"); yield* drop({ ...ADAPTER, claim: { ...ADAPTER.claim, maxRuns: 1 } }); - expect(String(logged.at(-1))).toContain('["claim"]["maxRuns"]'); + expect(String(logged.at(-1))).toContain( + 'Expected no excess property at ["claim"]["maxRuns"]', + ); + expect(String(logged.at(-1))).not.toMatch(/\s{2}/); + yield* drop({ + ...ADAPTER, + claim: step(["game", "--token=SECRETVALUE"]), + }); + expect(String(logged.at(-1))).toContain("invalid playtest settings read as off"); + expect(String(logged.at(-1))).not.toContain("SECRETVALUE"); }), ); diff --git a/packages/contracts/src/playtest.ts b/packages/contracts/src/playtest.ts index 14134e395d359..35af1dec7b0aa 100644 --- a/packages/contracts/src/playtest.ts +++ b/packages/contracts/src/playtest.ts @@ -182,7 +182,7 @@ export const PlaytestSettingsFromSettingsFile = Schema.Unknown.pipe( return raw as typeof PlaytestSettings.Encoded; } yield* Effect.logWarning( - `settings: invalid playtest settings read as off (${problem.replaceAll("\n", " ")}); the next settings save replaces them`, + `settings: invalid playtest settings read as off (${problem.replace(/\s+/g, " ").trim()}); the next settings save replaces them`, ); return {}; }),