diff --git a/CHANGELOG.md b/CHANGELOG.md index ebdb0b02..aa12e9a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Technical principles: a function keeps a copy of an argument it retains, and a size limit counts every cell the code allocates, empty ones too. - larv-review's security pass and stability-reviewer now check that the doc beside a new secret or token names what the credential can reach, such as the other repositories its owning account can use, not only what the change uses it for. - `chunk-pr` and `chunk-preflight` find a Gitea pull request however many newer ones exist, so `chunk-pr clean` and `chunk-pr merge` no longer miss an old one. - task-bench leaves out of a fix a change Haiku makes to a Rust test kept in a file of its own, `#[cfg(test)] mod name;` and the file it names, and plants no bug in that file. diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 086697c5..aa79ff19 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -3805,3 +3805,13 @@ Read most (opens and searches): - `bin/run-tests` 1 - `ci.sh` 1 - `todo.md` 1 + +## Reading cost, chunk b54e19271a0f, finished 2026-11-27T19:26:50Z + +40918 new input tokens before the first commit. + +Read most (opens and searches): + +- `skills/larv-review/SKILL.md` 5 +- `agents/stability-reviewer.md` 4 +- `README.md` 1 diff --git a/principles/technical-principles.md b/principles/technical-principles.md index 50bcdedd..6053f99e 100644 --- a/principles/technical-principles.md +++ b/principles/technical-principles.md @@ -46,6 +46,8 @@ - A cast (`x as Foo`) asserts what the compiler could not check and stops it checking — so when the type later changes, nothing tells you. Derive the real type instead: infer it, name the return type, or parse the input once into a typed shape. Where a value genuinely arrives untyped (HTTP body, `JSON.parse`, DB row), the boundary owes a **type guard validating the fields it claims**; past that boundary everything is typed. `as unknown as T` and non-null `!` are the same defect wearing a hat. BANNED: `const user = body as User` — one rename and it is a silent lie. GOOD: `function isUser(v: unknown): v is User` checking each field, then `if (!isUser(body)) return { error: … }`. - DTOs, enums, and value objects are pure data — no logic. They stand in for the structs/records a language lacks. - Don't loosen a type when refactoring. A function that returned a concrete type keeps returning it when its implementation changes, never `object`, `array`, `mixed` or `any`; introduce a DTO or value object instead. BANNED: `totals(): Totals` becomes `totals(): array` once it reads from two sources. GOOD: `totals(): Totals` stays, and a new `SourceTotals` value object holds what each source returns. + - A function that keeps an argument after it returns keeps its own copy, so a change the caller makes later doesn't reach it. BANNED: `this.rows = rows`, which keeps the caller's array. BANNED: `this.bytes = bytes.slice()`, since on a Node `Buffer` `slice()` shares the storage, as `subarray()` does on every typed array. GOOD: `this.rows = [...rows]`, copying each row too where a row is an object the caller can change, and `this.bytes = new Uint8Array(bytes)` for a typed array, which copies it. + - A size limit counts every cell the code allocates, empty ones too, not only the bytes of its output, and the check runs before the allocation. BANNED: a limit on a returned table that sums the bytes of its cells, so a million rows of a thousand empty cells make a billion cells that add zero bytes, and the program runs out of memory before it reports the limit. GOOD: the limit counts each cell, empty or not, before the code allocates it. * Always use explicit state machines. * Most, if not all, code should have automated tests, and each test earns its keep. - A valuable test checks behaviour through the unit's interface, fails when that behaviour breaks, and still passes after a refactor that keeps that behaviour. diff --git a/todo.md b/todo.md index 45616d27..2a1ade2f 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,6 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 477 | 0.17.0 | | question | **Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.claude`.** | 1 | 1 | 2 | 2 | 2 | | 0.0 | | 478 | 0.17.0 | | question | **Name the project, its repo and its two commands, today proposed as `do-release` and `do-epic`.** | 1 | 1 | 2 | 2 | 1 | | 0.0 | -| 553 | 0.17.0 | | | **Add to the technical principles that a function keeps a copy of what its caller passes, and that a limit counts every entry the code retains, empty ones too.** | 1 | 1 | 2 | 2 | 1 | 1.1 by 2 | 0.9 | | 545 | 0.17.0 | | | **Have chunk-preflight name each next-release item with no `Touches:` list while others wait, and have loop-claude launch a subagent that writes the lists before it starts the next chunk.** | 3 | 2 | 3 | 6 | 6 | 1.1 by 4 | 0.6 | | 544 | 0.17.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a PHP or JavaScript test that PHPUnit or `node --test` finds by a name `is_test` does not know.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 | | 480 | 0.18.0 | | owner | **Resolve every path the tools use in one module: the release root (the folder the running code ships in), the config folder, the state folder and the Claude home. Then only that module names `~/.claude`, and the loop still runs from `~/.claude`.** | 3 | 2 | 3 | 6 | 6 | 1.6 by 3, code health by 3 | 2.4 | @@ -115,19 +114,6 @@ Part of the standalone-install plan lilleman approved on 2026-11-20. `do-release Part of the standalone-install plan lilleman approved on 2026-11-20. Later items say `do-release` and `do-epic` for the names this item picks. The names set the install folders, such as `~/.config/do-release/`, so items 482, 485 and 496, and every item they block, wait for them. -### 553. Add to the technical principles that a function keeps a copy of what its caller passes, and that a limit counts every entry the code retains, empty ones too. - -An outside reviewer (CodeRabbit) found two faults on a client project's PR that neither stability-reviewer's two rounds nor the tests raised. - -1. A function that keeps a caller's bytes made its copy with `Uint8Array.slice()`. On a Node `Buffer`, `slice()` shares the storage, so changing the Buffer after the call changed later results. The same PR had earlier kept a caller's array by reference. Where a function keeps an argument, it keeps a copy that the caller's later change cannot reach: `[...array]`, `new Uint8Array(bytes)`, never `slice` or `subarray` of a typed array. -2. A limit on a returned table counted bytes, so a record of a thousand null or empty columns, repeated a million times, added a billion entries that counted zero, and the program ran out of memory before it returned the limit error. A limit counts what the code allocates, every entry and every cell, not only the bytes of what it prints. - -Add both to `technical-principles.md` as one bullet each, with a BANNED and a GOOD example, in the section that holds the input rules. Check `stability-reviewer`'s agent text names the principles file's input rules, so a reviewer reads them. - -Touches: - -- `principles/technical-principles.md` - ### 545. Have chunk-preflight name each next-release item with no `Touches:` list while others wait, and have loop-claude launch a subagent that writes the lists before it starts the next chunk. In fejkdata on 2026-11-27 the loop ran one chunk for hours beside seven waiting items, because five items of the next release (one filed by the reading-cost report, four older) had no `Touches:` list, and `chunk-preflight` says only "No item may start a chunk beside item X's: its detail has no `Touches:` list". Nothing makes a session write the lists, and `rank_todo.py --check` refuses only a list it cannot read.