Breaking: Mut<T> is nominal and a value is lent with mut(x); tsc refuses covariant loans, new rules missing-mut and aliased-mut #116

Merged
sionzee merged 79 commits from nominal-mut into main 2026-11-21 23:34:11 +01:00
Owner

Based on return-types (#123), and contains the pieces below it: the diff shown is this piece alone. The open pieces above #118 form one chain, each branch containing the ones below it: #119, #120, #121, #123, then #116 and #122. Merge them in that order, and merge #122 together with this one: it fixes a false refusal in this PR's Mut type (a value could not be lent where a union containing its type is asked) and adds mutEach, the way to lend a list's elements without an array copy.

Adoption cost, corrected. An earlier version of this description gave 71 type errors left on an adopter's project after safe-ts migrate mut. That copy could not resolve the project's workspace packages, so calls across them were not type-checked. With them resolved the number is 339, and 201 at 52 places once #122 is in; the table of what is left, and how many declarations each kind takes, is in #122 and in docs/guide/adoption.md there.

This is a breaking change. Every call that passes a value to a Mut parameter changes, and it should ship as its own release with the migration below.

The problem

Mut<T> is SAFE-TS's &mut T, but std said type Mut<T> = T, so TypeScript saw nothing. All of these passed tsc in strict mode and safe-ts check, with no cast:

function pushCat(xs: Mut<Animal[]>): void { xs.push({ kind: "cat" }); }
pushCat(dogs);                                // dogs[1].bark() then throws

const visit: (a: Account) => void = drain;    // drain takes Mut<Account>: a changing function in a slot that promises not to
transfer(account, account, 5);                // one object as both Mut parameters

And nothing at a call site showed which arguments would be changed.

What changes

Mut<T> is nominal, and a value is lent by writing mut(x), like Rust's &mut x. mut returns its argument, and the build transform erases the call.

addItem(mut(cart), item);

tsc itself now refuses the first two programs above. The mark on Mut<T> compares the two types property by property:

  • a property the callee may write must have the same type on both sides, so a Dog[] is not lent as Mut<Animal[]>;
  • what a property holds is lent with the loan and checked by the same rule at any depth, so { readonly dogs: Dog[] } is not lent where { readonly dogs: Animal[] } is asked;
  • a value with more properties than asked, a subclass, and a union narrowed to one member are lent as they are.

New rules

  • missing-mut (error): a value given to a Mut parameter, field, default or return without mut(...). tsc refuses the same, but the editor and lint paths don't run tsc. Its quick fix is the migration.
  • aliased-mut (error): one call in which mut(x) appears and another argument is x or a part of it. Rust's E0499 and E0502.
  • mut(p) of a parameter not declared Mut, or of module state, is where no-param-mutation and no-mutable-global now report.
  • The failure rules follow methods on a receiver declared Mut<C>.

Upgrading

npx safe-ts migrate mut apps packages scripts            # review the diff and the "Needs a decision" list
npx safe-ts migrate mut apps packages scripts --write
npx tsc -p . && npx safe-ts check apps packages scripts

Measured on a real project

On a copy of an adopter's project (744 files), with its own tsc over its ten projects:

Migration 2.7 s; 439 files changed; 14,846 values lent
tsc errors before, with today's std 11, unrelated
tsc errors after migration, caused by Mut 71 on this copy, whose workspace packages did not resolve; 339 with them resolved (see the note at the top)
tsc time and peak memory 8.0 s → 8.3 s; 1,210 MB → 1,295 MB
New checker findings after migration 58 aliased-mut, 97 no-param-mutation

The 71 this copy showed, by kind (the same kinds, in other proportions, make up the 339; two of them, the union and the list of loans, are removed by #122):

Kind Count What to write
A subtype lent where a supertype is asked 17 most are real: a required field where the callee may clear an optional one
A union widened (Mut<A> where Mut<A | B> is asked) 14 nothing, once #122 is in: a member is lent where its union is asked
Mut inside another type (readonly Mut<Unit>[]) 11 mutEach(units), from #122 (the .map form copies the array at run time)
A call the migration couldn't follow 9 add mut(...)
A value into a Mut place whose type is inferred 8 lend it by hand
A Mut function in a read-only callback slot 8 the intended refusal
Other 4

The first version of the type gave 251 errors on the same code, about 180 of them safe. Three rounds of review brought it to 71 while closing holes that the looser versions opened.

A decision for the maintainer

missing-mut asks for mut(x) at every call that passes to a Mut parameter, even when x is already a Mut. Of the 14,846 wrappers on the adopter, 5,081 are of that kind; tsc would accept those calls without them. The alternative is Rust's rule: write mut only where a loan starts. That would remove about a third of the wrappers, and each remaining one would mark a new loan. The type is the same either way; only the rule and the migration differ.

Two holes left open, each a listed class in the soundness corpus

  • A writable property that holds a function is treated like a method, so a callee can replace it with one that needs more. Closing it adds 97 errors on the adopter, none of them hazards (71 subclasses that override a method, 26 typed arrays). Make a handler property readonly where nothing should replace it.
  • A write through a property shared by the members of a readonly union.

Not in this PR: a borrowed value stored and changed later, a getter that changes its object, and a mutable part of a borrowed value handed out.

How it was checked

  • The Rust suite (335 tests), test:std (381), typecheck, the docs examples (867 compile), test:vite, the docs site build, bench:check and the soundness corpus pass.
  • Reviewed against three sets of programs the implementation had not seen: hazards that must be refused, ordinary code that must compile (a recursive tree, a world with a Map and a typed array in readonly fields, a subclass, a spread with one more field), and programs written to break the type. Four of the latter compiled against the third version and failed at run time; three are now refused, at any depth, and the fourth is the first hole above.
  • The corpus goes from 21 to 20 escaping classes: three close, and the two holes above are added as classes that escape.

Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review, acceptance and attack programs, and the per-property mark) in Claude Code.

Based on `return-types` (#123), and contains the pieces below it: the diff shown is this piece alone. The open pieces above #118 form one chain, each branch containing the ones below it: #119, #120, #121, #123, then #116 and #122. Merge them in that order, and merge #122 together with this one: it fixes a false refusal in this PR's `Mut` type (a value could not be lent where a union containing its type is asked) and adds `mutEach`, the way to lend a list's elements without an array copy. **Adoption cost, corrected.** An earlier version of this description gave 71 type errors left on an adopter's project after `safe-ts migrate mut`. That copy could not resolve the project's workspace packages, so calls across them were not type-checked. With them resolved the number is 339, and 201 at 52 places once #122 is in; the table of what is left, and how many declarations each kind takes, is in #122 and in `docs/guide/adoption.md` there. **This is a breaking change.** Every call that passes a value to a `Mut` parameter changes, and it should ship as its own release with the migration below. ## The problem `Mut<T>` is SAFE-TS's `&mut T`, but std said `type Mut<T> = T`, so TypeScript saw nothing. All of these passed `tsc` in strict mode and `safe-ts check`, with no cast: ```ts function pushCat(xs: Mut<Animal[]>): void { xs.push({ kind: "cat" }); } pushCat(dogs); // dogs[1].bark() then throws const visit: (a: Account) => void = drain; // drain takes Mut<Account>: a changing function in a slot that promises not to transfer(account, account, 5); // one object as both Mut parameters ``` And nothing at a call site showed which arguments would be changed. ## What changes **`Mut<T>` is nominal, and a value is lent by writing `mut(x)`**, like Rust's `&mut x`. `mut` returns its argument, and the build transform erases the call. ```ts addItem(mut(cart), item); ``` `tsc` itself now refuses the first two programs above. The mark on `Mut<T>` compares the two types property by property: - a property the callee may write must have the same type on both sides, so a `Dog[]` is not lent as `Mut<Animal[]>`; - what a property holds is lent with the loan and checked by the same rule at any depth, so `{ readonly dogs: Dog[] }` is not lent where `{ readonly dogs: Animal[] }` is asked; - a value with more properties than asked, a subclass, and a union narrowed to one member are lent as they are. **New rules** - `missing-mut` (error): a value given to a `Mut` parameter, field, default or return without `mut(...)`. `tsc` refuses the same, but the editor and lint paths don't run `tsc`. Its quick fix is the migration. - `aliased-mut` (error): one call in which `mut(x)` appears and another argument is `x` or a part of it. Rust's E0499 and E0502. - `mut(p)` of a parameter not declared `Mut`, or of module state, is where `no-param-mutation` and `no-mutable-global` now report. - The failure rules follow methods on a receiver declared `Mut<C>`. ## Upgrading ```sh npx safe-ts migrate mut apps packages scripts # review the diff and the "Needs a decision" list npx safe-ts migrate mut apps packages scripts --write npx tsc -p . && npx safe-ts check apps packages scripts ``` ## Measured on a real project On a copy of an adopter's project (744 files), with its own `tsc` over its ten projects: | | | |---|---| | Migration | 2.7 s; 439 files changed; 14,846 values lent | | `tsc` errors before, with today's std | 11, unrelated | | `tsc` errors after migration, caused by `Mut` | 71 on this copy, whose workspace packages did not resolve; 339 with them resolved (see the note at the top) | | `tsc` time and peak memory | 8.0 s → 8.3 s; 1,210 MB → 1,295 MB | | New checker findings after migration | 58 `aliased-mut`, 97 `no-param-mutation` | The 71 this copy showed, by kind (the same kinds, in other proportions, make up the 339; two of them, the union and the list of loans, are removed by #122): | Kind | Count | What to write | |---|---|---| | A subtype lent where a supertype is asked | 17 | most are real: a required field where the callee may clear an optional one | | A union widened (`Mut<A>` where `Mut<A \| B>` is asked) | 14 | nothing, once #122 is in: a member is lent where its union is asked | | `Mut` inside another type (`readonly Mut<Unit>[]`) | 11 | `mutEach(units)`, from #122 (the `.map` form copies the array at run time) | | A call the migration couldn't follow | 9 | add `mut(...)` | | A value into a `Mut` place whose type is inferred | 8 | lend it by hand | | A `Mut` function in a read-only callback slot | 8 | the intended refusal | | Other | 4 | | The first version of the type gave 251 errors on the same code, about 180 of them safe. Three rounds of review brought it to 71 while closing holes that the looser versions opened. ## A decision for the maintainer `missing-mut` asks for `mut(x)` at every call that passes to a `Mut` parameter, even when `x` is already a `Mut`. Of the 14,846 wrappers on the adopter, 5,081 are of that kind; `tsc` would accept those calls without them. The alternative is Rust's rule: write `mut` only where a loan starts. That would remove about a third of the wrappers, and each remaining one would mark a new loan. The type is the same either way; only the rule and the migration differ. ## Two holes left open, each a listed class in the soundness corpus - A writable property that holds a function is treated like a method, so a callee can replace it with one that needs more. Closing it adds 97 errors on the adopter, none of them hazards (71 subclasses that override a method, 26 typed arrays). Make a handler property `readonly` where nothing should replace it. - A write through a property shared by the members of a `readonly` union. Not in this PR: a borrowed value stored and changed later, a getter that changes its object, and a mutable part of a borrowed value handed out. ## How it was checked - The Rust suite (335 tests), `test:std` (381), `typecheck`, the docs examples (867 compile), `test:vite`, the docs site build, `bench:check` and the soundness corpus pass. - Reviewed against three sets of programs the implementation had not seen: hazards that must be refused, ordinary code that must compile (a recursive tree, a world with a `Map` and a typed array in `readonly` fields, a subclass, a spread with one more field), and programs written to break the type. Four of the latter compiled against the third version and failed at run time; three are now refused, at any depth, and the fourth is the first hole above. - The corpus goes from 21 to 20 escaping classes: three close, and the two holes above are added as classes that escape. Created with Claude Opus 5.5 (implementation) and Claude Fable 5.2 (review, acceptance and attack programs, and the per-property mark) in Claude Code.
Open: `Mut<T> = T`, so TypeScript saw nothing. A `Dog[]` passed as
`Mut<Animal[]>` got a cat pushed into it, a function taking `Mut<T>` fitted a
`(value: T) => void` slot that only lends to read, and no call showed which
arguments it changes. All of it passed strict tsc with no cast or `any`.

Closes it at the type level: `Mut<T>` is `T` with a mark only `mut(value)`
adds, checked in both directions. tsc now refuses a value passed to a `Mut`
parameter without `mut(...)`, `Mut<Dog[]>` as `Mut<Animal[]>`, and a `Mut`
function in a read-only callback slot; it still accepts a `Mut<T>` read as `T`,
`Readonly<T>` or a readonly view, passed on to another `Mut<T>`, and array and
Map methods on it. `mut` is the identity, overloaded so `mut(maybe)` stays
`Mut<T> | undefined`. `mut` joins the prelude. packages/std/test/mut.check.ts
pins each refusal and acceptance with tsc; std's own `updateEach` callers lend
their arrays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: with `Mut<T>` nominal, the editor and lint paths (which don't run tsc)
said nothing about a missing loan, nothing refused two loans of one object in
one call, `mut(x)` would reach the build as a call, and an adopter had no way
to move thousands of call sites.

- `missing-mut` (new, error): an argument at a parameter or prop declared
  `Mut<...>` without `mut(...)`, across files: functions, nested functions,
  methods, callback types, JSX props, Vue template props. Also a `Mut` value
  passed on, which tsc accepts, so every lending call shows it. Quick fix wraps
  it and imports `mut` (no fix for a fresh literal).
- `aliased-mut` (new, error): one call lends `x` and also gets `x`, a part of
  it or what holds it (Rust's E0499 / E0502), through `const` aliases. A part
  declared primitive (followed across files) is a copy and isn't reported; an
  unsettled type isn't either.
- Where a loan starts: `mut(p)` of a borrowed parameter is `no-param-mutation`,
  `mut(state)` in a function `no-mutable-global`, `mut(items)` in a loop over
  `items` `no-mutation-while-iterating`, `mut<T>(x)` of a non-fresh value
  `no-unchecked-cast`, `mut(x)` at a non-`Mut` parameter `unneeded-mut`.
  borrow.rs, lifetime.rs follow through `mut(...)`.
- The transform erases `mut(x)` to `x` on its line in scripts and Vue
  templates, so every path (Vite, Node, Bun, `safe-ts emit`) gets it.
- `safe-ts migrate mut <dirs> --write`: `missing-mut`'s fix over a whole
  program in one pass, `Mut<Option<T>>` -> `Option<Mut<T>>`, notes for what it
  can't decide; lines under `@ts-expect-error` stay.
- api-diff: `T` -> `Mut<T>` breaking (callers must lend), `Mut<A>` ->
  `Mut<B>` breaking (invariant), `Mut<T>` -> `T` compatible for parameters.
- Fixtures migrated with the codemod; new `loans` fixture, codemod cases (with
  tsc and vue-tsc on output, probes), meaning.rs entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the guides said `Mut<T>` is a checker-only type TypeScript sees as `T`,
examples passed values to `Mut` parameters without a loan (no longer valid
TypeScript), and the corpus listed `aliased-mut-borrow`,
`covariant-mutable-array-param` and `mut-callback-smuggle` as escaping.

Closes: rule pages for `missing-mut` and `aliased-mut`; `no-param-mutation`,
`unneeded-mut`, `no-mutable-global`, `no-mutation-while-iterating`,
`no-unchecked-cast`, the state, quick-start, proof-types, api-diff, Vue state
and adoption guides (a `mut` codemod section, checked against its output)
rewritten for loans; examples migrated with `safe-ts migrate mut`; README
tables and known gaps; the migration skill's upgrade step, pattern and tool
gap; CHANGELOG under Added and, as a breaking change with the upgrade steps,
Changed. The corpus generators write the new call form, and the three classes
come off scripts/soundness/escaping.txt: tsc refuses the covariant loan and
the callback, `aliased-mut` the double loan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: a parameter, local, field or return type declared `Mut<Service>` was read
as the class `Mut`, so the failure rules (uncaught-propagation, floating-rejection,
must-use-result, unhandled-failure) didn't follow `service.load()` on it. With
`Mut` nominal, every function that changes a service takes `Mut<Service>`, so
the receiver following was off exactly there.

Closes it: `annotated_class` unwraps `Mut<...>` and `Option<...>` (parameters,
locals), and `type_ty` follows `Mut<T>` and `Option<T>` (fields, unions, return
types), as it follows `T | undefined`. Fixture receivers/lent.ts writes each
case on a `C` and on a `Mut<C>`: propagating, rejecting and Result-returning
methods are reported the same; a caught call and a safe one stay silent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the mark `(invariant: T) => T` refused every narrowed loan. A `Mut<Unit>`
narrowed to its `Builder` member by a tag test, `is`, a `match` handler or
`variant` couldn't be passed on or lent again to a `Mut<Builder>` parameter, so
a `Mut` of an enum could never reach a function that changes one variant.

Closes it: the mark is `(value: T) => void`. A `Mut<A>` still fits a `Mut<B>`
only when the types fit both ways, so every refusal stays (a Dog[] lent as
Mut<Animal[]>, Box<Dog> as Mut<Box<Animal>>, no mut(), a Mut function in a
read-only slot, Mut<Builder> passed on as Mut<Unit>); narrowing keeps the loan's
mark, so the narrowed member is accepted, and whatever the callee writes keeps
it a valid member of what was lent. No program was found that the new mark
accepts and that ends in a wrong state. mut.check.ts pins the narrowed forms,
width (generic `T extends Entity`) and typed arrays (`<ArrayBuffer>` or generic).

Docs: the type's comment says why the mark isn't invariant; the state guide,
CHANGELOG, README, skill and rule pages describe the mark, the generic form for
a value with more fields than asked for, and typed arrays; the upgrade steps
no longer name a version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the mark `(value: T) => void` compared whole types, so a value with more
properties than asked for (a Tree where Mut<Entity> is asked, a Sprite for
Mut<Container>), a writable list where Mut<readonly T[]> is asked and a typed
array made with `new` were refused, though the callee can't break any of them:
134 + 27 + 3 of 251 tsc errors on a migrated adopter. And the advice to make
such callees generic was unsound: TypeScript lets a generic body write the
bound's type into a narrower `T["x"]`.

Closes it: the mark lists, per property of T, a slot: invariant where the
callee may write it, covariant where it can only read it (`readonly`) or calls
it (a method, rebuilt as a plain function type so its parameters count one
way, which keeps `Map<string, 1>` out of `Mut<Map<string, number>>`). Every
hazard stays refused (Dog[] as Mut<Animal[]>, { x: 0 | 1 } as
Mut<{ x: number }>, a Map of a narrower value, Mut<Builder> as Mut<Unit>, a
narrower override); width, subclasses, readonly views, typed arrays and
narrowed unions are accepted. What it newly accepts (a delete through a Record
target, Object.assign through Mut<object>) is reachable under the old mark by a
plain assignment first. mut.check.ts pins each case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: a value put into a place declared Mut<...> without a call (an
initializer or assignment, a parameter's default, a field, a `return`, an
array literal where readonly Mut<T>[] is asked) wasn't reported or migrated,
and a fresh literal at a Mut slot got no fix: 30 + 17 tsc errors after the
migration on an adopter, all mechanical.

Closes it: `missing-mut` reports those places (per file, as Slot), and its
fix, which `safe-ts migrate mut` applies, lends them; a fresh literal is lent
with the place's type (`mut<Cost>({ ... })`, `mut<number[]>([])`) where the
file can name it, else only `[]`/`{}` are left as notes. Returns count through
Promise<Mut<T>> and Generator<Y, Mut<T>, N>. Fixtures, the codemod case (tsc on
its output) and meaning.rs cover it. Docs: the state guide's table and "what to
write" for the new mark, missing-mut, adoption, README, CHANGELOG, skill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the prelude declared `type Mut<T> = lending.Mut<T>`, a second alias. TypeScript infers
`T` of a generic `f<T>(child: Mut<T>)` from the type arguments only when the argument and the
parameter name the same alias; from a `mut(sprite)` (std's `Mut`) at a parameter written with
the prelude's `Mut` it inferred `T` as the whole `Mut<Sprite>`, and asked for a
`Mut<Mut<Sprite>>`. The mark let that through only by comparing two `Shared<...>` by the
variance TypeScript measures for the alias; compared property by property, a class whose
method returns `this` doesn't lend as `Mut<Mut<...>>`, and every such call failed (16 of an
adopter's errors at the round-3 mark were this inference, typed arrays among them).

Closes it: `export import Mut = lending.Mut` names std's own type in the global scope (the
namespace import is no longer `import type`, which an import alias can't reference). The
prelude test pins the generic call; the table test reads `export import` lines as types.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mut lends what a readonly property holds: the same rule, as deep as it goes
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m24s
Tests / test (pull_request) Successful in 9m27s
48b76f39da
Open: the mark compared a `readonly` property one way, as covariant, but `readonly` is shallow.
A `{ readonly dogs: Dog[] }` lent as `Mut<{ readonly dogs: Animal[] }>` was accepted and the
callee pushed a cat into the list (`Dog[]` as `Animal[]` one property down); also a
`{ readonly state: { on: 0 | 1 } }` lent where `on: number` is written, a subclass narrowing a
`readonly` field that holds a list, a `Map` of a narrower value in a `readonly` field. And two
`Shared<...>` were compared by the variance TypeScript measures for the alias, which ignores
`readonly`: a `{ readonly n: number }` was lent where the callee writes `n`.

Closes them: each property's slot is `{ w, r }`: `w` whether the callee may replace it
(the same type both ways, or never), `r` what it holds, an object lent as a loan of its own
(`Lent<X>`: each member of the value lendable as some member asked, so a typed array's
`ArrayBuffer` fits `ArrayBufferLike`). `Shared` and the slots are written so TypeScript
compares them structurally. Recursive types (nodes with `readonly children`) check, and an
adopter's ten projects reach no depth limit; tsc takes 8.3 s and 1,295 MB where the round-3
mark took 8.0 s and 1,210 MB (minimum of three interleaved rounds).

Left open, documented on `Mut`, in the guide and as escaping corpus classes: a function in a
writable property replaced by one that needs more (compared one way like a method: compared
both ways, 97 more of the adopter's errors, subclasses lent as their base and typed arrays),
and a write through a member shared by a `readonly` property's union.

Corpus: mut-readonly-field-list, -object, -subclass (refused; each escapes with the round-3
mark), mut-function-field-replaced and mut-readonly-union-field-write (escaping.txt).
mut.check.ts pins the refusals, the recursive tree and the two open holes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sionzee changed target branch from fail-closed-integration to sentinel-values 2026-11-21 12:57:07 +01:00
Merge origin/sentinel-values: the nominal Mut on top of failure contracts, the built-ins map and the sentinel rules
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m29s
Tests / test (pull_request) Successful in 7m16s
5a38e979db
Conflicts: both sides appended to CHANGELOG.md (Added and Changed: both kept), README.md (the
prelude's names: `Throws`, `Throwing` and `mut` together; the known gaps: both entries), the
docs sidebar (`failure-contract` under Failures, `missing-mut` and `aliased-mut` under State),
the prelude's compile-time test (both blocks), `mod contracts` and `mod loans` in project.rs,
and escaping.txt (neither side's removed classes; my two open Mut holes added).

In meaning: a receiver declared `Mut<C>` is now read as `C` by failure-contract too, so
`port.onmessage = f` with `port: Mut<Port>` gets the `failure-contract` a plain `Port` gets
(entry_points fixture), and a call through a `Mut` of an interface whose slot declares
`Throws` propagates what the slot declares (pinned in receivers/lent.ts, also through
`Option<Mut<C>>`). One call that lends a value twice and passes a failing callback kept for
later reports `aliased-mut` and `failure-contract` once each (pinned). The migration changes
none of the other branches' fixtures; their docs, skill examples and corpus programs only
declare `Mut` parameters and compile with the nominal type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Entry points fixture: a platform handler and a declared slot, one finding each
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m30s
Tests / test (pull_request) Successful in 7m11s
7c4a3e211e
With one finding per handler slot, a function assigned to an `on…` member of the
project's own type is a `failure-contract`, and a platform object's handler stays an
`uncaught-propagation`. The fixture now holds both, by name and as an arrow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Open: each rule that asks "did A happen before B on some path" had its own walker with
its own idea of branches, loops and exits (number-parse-nan and not-found-index took source
order, stale-read an ancestor walk, holders and bounds their own exits).

Closes the first step: flow.rs builds a graph per function body on request (if, ?:, &&/||/??
as jumping code, optional chains, loops with back edges, switch fall-through, labelled
break/continue, return/throw, try/catch/finally with a finally copy per way out; nested
functions are one point; await/yield end their block) and a bitset forward data-flow driver
(Meet::Any / Meet::Every, replay). number-parse-nan decides "used before a check" on it:
identical on the adopter; three fixture cases the source-order walk got wrong (a check in the
other branch, a use on the next loop round, a new value assigned).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the rules that judge a value by its type went by the type written on it. A function
without a declared return type gave them nothing (`const n = count(items); if (n)` was silent
while `const n: number` was reported), and must-use-result didn't follow a Result through a
return type written as an alias, nor through `err(...)` in a `?:` branch.

Closed:
- shape.rs reads a function's result off its `return`s when every one is plain (literals,
  `.length`, arithmetic, comparisons, calls of functions whose result is known, `err(...)`,
  `validate<T>`, declared locals, built-in methods of plain values), for declarations, arrows,
  function expressions and methods of `this`, local and imported. Anything else stops the
  reading: unknown, never a union with an unknown part. Generic, recursive (any function met
  again while read), overloaded and reassigned functions stay unknown. Read once per function
  and file. A parameter typed with a function type gives its declared result; `a * f()` with
  a number on one side is a number.
- written.rs: one opener for written types (aliases of aliases, imported, generic aliases with
  their arguments bound where they are written, stopping visibly at conditional / mapped /
  `typeof` / indexed types and at std's own names). must-use-result, catch-on-result and the
  other callee checks use it (`FnInfo::returns_named`, cached per pass); json::value's alias
  shortcut goes through it.
- New rule undeclared-return-type (idiomatic, off unless named): a function whose result can't
  be read off and isn't declared. Exempt: typed by where it is written, returns nothing, a
  single test (TypeScript infers its predicate), a component, test files. Quick fix where every
  return names a type the file can write.

Fixture change: failures/stringify.ts `JSON.stringify(untyped(n))` is no longer reported
(`untyped` returns `[n + 1]`, now read off as number[]); a `new` of a project class keeps the
case reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was open: each of these passed tsc strict, `safe-ts check --idiomatic --deny-warnings`
and oxlint with the preset, and none was counted or ratcheted.

- `// @safe-ts std` / `// @safe-ts legacy`: one comment turned every rule off for a file (and
  `std` made its functions count as never failing for callers), and nothing said who may write
  it. Now a marker counts only in files the nearest "safe-ts" package.json lists under
  "trustedFiles" / "legacyFiles" (patterns as in "overrides", relative to it). Anywhere else it
  is an `unlisted-marker` error at the marker and the file is checked, transformed and followed
  as if it weren't there: check, the editor, the oxlint plugin, the Vite plugin and the loader
  all go through `Project::markers_allowed` (part of the analysis cache key). Library code in
  node_modules keeps its markers. `safe-ts check` prints, per package.json, the lines that list
  every marked file it found. The repository's packages, the demo, the fixtures and the docs
  examples list theirs.
- `eslint-disable*` / `oxlint-disable*` comments were counted nowhere, and silenced the oxlint
  plugin. Now all are counted; a blanket one or one naming a `safe-ts/` rule is reported by the
  new `no-lint-suppression`, on the directive's name inside the comment, where oxlint's own
  directive ranges don't reach (measured: a block directive applies from its comment's end, a
  `-line` one to the code before the comment). A named rule of another linter is only counted.
- `declare const | let | var | function | class | enum | namespace`, `declare global`,
  `declare module "..."` and the project's own .d.ts files were casts with no `as`. Now they
  are counted, the CLI checks the .d.ts files under the entries' directories (as the editor and
  oxlint already did), and the new `no-unchecked-declare` reports what asserts a value nothing
  checks (a type other than `unknown` or one admitting `undefined`, functions, classes, enums,
  required members added to a built-in or in a package augmentation, values added to a project
  module, `declare module "x";` with no body).
- `defineSanitizer(...)` was not counted; now it is, also through `export *` and renamed
  re-exports in project modules (and so are re-exported `trust()` and `panic()`).

The three counts are in the summary line, `--json --summary` and the baseline, and a test holds
the three together. An old baseline without the new keys loads; a missing count is 0, so the
gate fails once with a note until it is written again.

Soundness corpus: four new classes (unlisted std marker, unlisted legacy marker, a declared
value, a member declared on Array) that escaped before and are rejected now; the corpus project
lists no marker files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: a value used again after an operation used it up passed every gate (a generator or an
array's iterator iterated twice, an ArrayBuffer used after transfer() or a transfer list, a
Response body read twice, a locked stream, a closed WebSocket, MessagePort, FileHandle or
readline interface), and must-use-result only saw a Result dropped as a statement, not one kept
in a local and only logged.

Closes:
- use-after-consume (an error, on by default), on the flow layer: a fact per operation site,
  set where it runs, cleared by a new value or releaseLock(); a second solve on every path
  words "on one path". Which operations consume, what state they leave and which uses fail is
  data: a `consumes` section in ecmascript-api.json, browser-api.json and node-api.json
  (compiled in; a platform's findings kept where its pack is on), demonstrated on Node
  (ecmascript/consumes.test.ts, packages/feature-*/test/consumes.test.ts) and, for Worker and
  the global postMessage, in Chromium, Firefox and WebKit (test:browsers). The packs' safe
  versions count as the member they stand for. A view made on a buffer before the transfer
  reads the detached buffer (reported); one made after throws where it is made.
- must-use-result: a call kept in a local (kept.rs) that, on some path to an end after the
  last code that looks at it, nothing looks at, or that a new value replaces first; the
  whole-program pass reports the ones whose function returns a Result. Logging and string
  conversion aren't looking; handing it on, storing it, capturing it, returning it are. An
  exception and an early return before the look aren't drops; a short-circuit test of several
  counts for each.
- Soundness corpus: one-shot-generator-reused and use-after-consume-arraybuffer come off
  escaping.txt; new classes response-body-read-twice and result-kept-only-logged (both escape
  at the starting commit, both rejected now).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: the new rule, the kept-Result part of must-use-result, the consumes format and the paths
number-parse-nan now follows were undocumented, and two pages said number-parse-nan takes source
order.

Closes: docs/rules/use-after-consume.md (idiomatic forms first, what it can't see),
must-use-result's "A Result kept in a local", docs/guide/flow.md, the `consumes` format in the
libraries guide (and a pointer from the built-ins guide), number-parse-nan's and
not-found-index's pages, README (rules table, known gaps), docs index and sidebar, the errors
guide, CHANGELOG (Added: the rule and the flow layer; Changed: must-use-result and
number-parse-nan, with what to write instead), and the migration skill's patterns and tool gaps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: `Result<T, E>` is `T | Err<E>`, so a `Promise<Result<T, E>>` is a `Result` too. `q`,
`isErr`, `isSome`, `unwrapOr`, ... accepted a promise nobody awaited and answered "no error";
TypeScript and the checker let a promise through as text, under `!`, `||`, `??`, in a
comparison with `undefined`; an async predicate handed to `filter` (or to a project function
declared `(x: T) => unknown`) kept every item; and an async call that can't reject, dropped as
a statement, let the caller go on with nothing reporting it.

Closed:
- std: the functions that read a value refuse a promise in their types (`PromiseCheck`,
  `AwaitFirst`: "this is a promise: `await` it, then pass the value"), via a last type
  parameter whose undecidable default falls back to its constraint, so generic code and a
  `Result<Promise<T>, E>` written on purpose still compile. Checked under TypeScript 7 and 5.9,
  and over an adopter copy: nothing new stops compiling.
- `promise-as-value` (error): those calls, the places TypeScript lets a promise through, an
  async callback handed to a built-in that reads its answer right away (the map's new
  `callbacks`, tested on Node; the ones lib types are left to tsc), and to a project function
  whose parameter type lets one through and whose body reads it. Quick fix: Add await.
- `floating-promise` (warning): a dropped promise that can't reject; never the same call as
  `floating-rejection`; not the last statement of an event handler or timer.
- Soundness corpus: five classes (promise-read-as-result, promise-read-as-text,
  floating-promise-ordering, async-callback-read-right-away,
  async-callback-read-by-project-function), all escaping at e8029782, all rejected now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: npm run typecheck failed on packages/pack-kit/consumes.ts (a DOM-only type name, and a
check TypeScript took for always true). Closes: a structural type for the read result, and the
demonstration typed as possibly missing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open (review of 10f1e996): the read-off result reached only some rules and only bare-name
callees; literals were widened where TypeScript keeps them; q-needs-result-return, sentinel-error
and misplaced-axios-check didn't open aliases; the rule was off unless named.

Closed:
- tests/pairs.rs: one body written twice, with the type TypeScript infers declared (tsc checks it
  is) and without; six uses each; the two must get the same findings. 67 pairs, 0 differ.
- Calls followed however they are spelled: object-literal members, class methods, getters,
  statics and fields (this file's and imported, also through a field typed with the class),
  namespace imports, `export * as`, default exports; `new` of any class.
- Literals keep their literal type in a `const` and a union of returns, widen in a `let`, a
  property and a lone return (`Shape::Fresh`, `Shape::Widen`).
- no-null-check-for-undefined asks the shared shape where its own model can't tell
  (`Want::NoNull`; `null` literals kept apart as `Prim::Null`).
- q-needs-result-return (`Root::Written`), sentinel-error (`SentinelFn::named`) and
  misplaced-axios-check open aliases through written.rs.
- std's `Result` opened as `T | Err<E>` in the evaluator, Vue's `Ref<T>.value`, declared `void`,
  `codePointAt`, a parameter default, `console.*`, `Date` methods, `reduce` with a start,
  `unwrapOr`, Vue's `ref` family with type arguments, `reactive`, `toRef`, a block-bodied
  `computed`, React's `useState` / `useRef` / `useMemo` / `useCallback`; `filter` / `find` over a
  union only where the callback can't be an inferred predicate (or is `x !== undefined`).
- undeclared-return-type: idiomatic, a warning; not in JavaScript files; a component returning
  `items.map(...)` of JSX is exempt. Five doc examples get the type written (package calls the
  checker doesn't read); two idiomatic_rules fixture composables of `useTask` now expect the rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was open after 25d3ef37, and what closes it:

- A hatch was counted only when called by its imported name: `r.trust(x)`, `const t = trust;
  t(x)`, `(0, trust)(x)`, `trust.call(...)`, `r.unsafe(...)`, `stop = panic` counted nothing, so
  `export const forged = r.trust<T>("no")` passed the baseline uncounted. Now one pass over the
  semantic references of every binding that may hold one (named and namespace imports,
  destructuring, dynamic `import()`, prelude names; hatch_refs.rs) classifies each use: a call,
  `.call` / `.apply` / `.bind`, a copy followed to its own uses (an exported copy counts once),
  and any other use counted (handed on, re-exported, a std namespace used whole: fail closed).
  Types (`typeof trust`) don't count. The whole program decides which imports are hatches,
  through re-exports, and counts `export { x as y } from` of one.
- With std or the Vue package linked into a workspace, `defineSanitizer` counted 0: the
  resolver calls those files the project's. Now the package.json that owns the defining file
  says what it is, and a SAFE-TS package's own files aren't counted as uses.
- vue-tsc's `<!-- @vue-ignore -->`, `<!-- @vue-skip -->` and `<!-- @vue-expect-error -->` were
  neither reported nor counted. Now `no-ts-suppression` reports ignore, skip and a reasonless
  expect-error; ignore counts with @ts-ignore, expect-error with @ts-expect-error, skip as the
  new `vueSkips`.
- A disable of an oxlint rule the preset makes an error (`no-eval`, `no-proto`, ...) passed
  silently: those rules are how SAFE-TS bans the constructs. Now one without `-- reason` is
  reported by `no-lint-suppression`. The same at config level: `.oxlintrc.json` next to the
  package.json (JSON with comments) is read, and a config not extending the preset, a preset
  rule turned off or down in "rules" or "overrides", and "ignorePatterns" are named as weakened
  settings, which the baseline ratchets.
- `declare value: string` in a class was silent while `value!: string` is a cast. Now it is
  reported by `no-unchecked-declare` and counted with the ambient declarations.
- Docs that teach a `declare` form are checked with the rule on (`declares` fence word), and
  say what the rule asks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open (review): a buffer transferred through its view (`[pixels.buffer]`, `pixels.buffer.transfer()`)
left the views unreported; `maybe?.transfer()` wasn't seen; `const same = buf` was a stranger;
and the browser and Node `consumes` were compiled into the checker, so a third-party pack (or a
project's own) couldn't declare one, and a pack's version could disagree with the checker's.

Closes:
- A pack's `consumes` is read from its safe-ts.json with the rest of the pack (Manifest::consumes;
  the browser and Node packs copy theirs from their API maps when safe-ts.json is generated, and
  the manifest tests keep the two equal). Only the language's map stays compiled in. A pack's
  safe versions come from its manifest's `safe` refs. What a pack gets wrong (an entry described
  differently from an earlier pack, an operation on a state nobody describes, a section that
  isn't one) is a setup warning and that entry is left out (consumed::for_packs, unit tests).
  Fixture consume_pack: a tiny third-party pack with a one-shot cursor.
- Groups (Cx::group): a second name (`const same = buf`, neither reassigned) is the same value;
  a typed array or DataView is a view on a buffer (the one it was made on, `x.buffer`, or its
  own); `x.buffer` in a transfer list or `x.buffer.transfer()` uses up every view of the group.
  `x.buffer.detached` is asking, not using. A reassigned `let`, a property or a destructuring
  isn't followed.
- The flow layer keyed points by span alone, so a call inside an optional chain shared its key
  with the chain (`a?.b()`), and an expression statement without `;` with its expression: points
  are keyed by span and kind now (flow::PointKey). That is what hid `maybe?.transfer()`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Weakened lint settings are named by .oxlintrc.json, the file that sets them
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m54s
Tests / test (pull_request) Successful in 7m48s
6577df1a9a
The check listed `oxlint.rules no-eval off (package.json)`: the setting lives in the
`.oxlintrc.json` beside it, and that is where a reader has to look.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Open (review of dff89f13): the failure rules stopped at the first generic alias or utility type
in a receiver's or slot's declared type (`deps: Services<Repo>`, `Readonly<Deps>`,
`ReadonlyMap<string, Repo>`, `pair[0]`, `await p`, `Partial<Port>`, `Record<string, Plain>`), an
optional call's dropped `Result` wasn't one, and an awaited undeclared `async` result was unknown.

Closed:
- project/receivers.rs resolves a declared type through written.rs (generic aliases and
  interfaces with their arguments bound, `Ty::Shape` keeps the binding), the utility types that
  keep members, a `Map`'s `get`, a tuple's item, a `Record`'s and an index signature's value,
  `await` / `.then` of a promise (`Value::Awaited`); cached per pass by type. The analysis records
  a parameter or local with any written type that has type arguments (also a destructured one),
  and follows it by that type rather than its name.
- contracts: slots see through `Partial` / `Pick` / `Required` / `Omit` / `NonNullable`,
  `Record<K, V>` (`Slot::Record`), a generic alias given its arguments (`Slot::Generic`, bound in
  `bound_slot`); `new Map([[k, f]])` / `new Set([f])` are checked against a collection slot.
- `repo?.check(id);` is a dropped `Result`.
- cache.rs (`@cache` through `Held<Catalog>`, `Partial`) and vue.rs's alias table (a generic
  alias's fields) bind type arguments too; both had the same hole.
- shape.rs: an `async` function read off is a promise of its result, `await` opens it (and a
  declared `Promise<T>`).
- tests/receivers.rs: 28 rows (receiver forms, slot forms, written-out cases), each against the
  plain declared form. tests/pairs.rs: 69 pairs (awaited async results added).

Fixture change: entry_points `listen(port: Mut<Port>)` now reads `Mut<Port>` as `Port`, so its two
handlers are `failure-contract` (a slot whose type declares no failure), as with `port: Port`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kept Results beyond a bare call; the cheap test before any graph; the layer's path table
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m57s
Tests / test (pull_request) Successful in 8m6s
9a540ef57e
Open (review): `const r = flag ? save(1) : save(2)` and `const [a, b] = await Promise.all([...])`
weren't seen as kept Results; the kept-Result analysis built a graph for one function in five on
the adopter's largest entry (2,561 of ~10,500) and use-after-consume for 539, mostly for calls
that can't matter; and the layer was held only by ten unit tests and the rules' fixtures.

Closes:
- Kept: each call of a `?:` / `??` / `||` / `&&` / parenthesised / awaited initialiser, and each
  element of an array destructuring of `Promise.all` / `allSettled` over a list written in
  place, in the binding at its place (fixtures). `const { result } = pair()` isn't (only
  `pair`'s return type says what `result` is).
- The cheap test first. Kept Results: the local pass only lists the kept calls (no graph),
  after two syntactic tests (a const looked at unconditionally by the very next statement; a
  call whose callee the file shows returns a plain type, or a method of a value declared with
  one); the whole-program pass keeps those whose function returns a Result and only then
  parses the file again and builds graphs for them (`unsafe(...)` / `parseJson` stay local).
  use-after-consume: a function gets a graph only if an operation there would use a binding
  up (`Array.from(list)` of an array doesn't); the generator walk runs only in a file with a
  `function*`. On the adopter's `apps/client/src/start.ts`: 3,119 graphs before (2,561 kept,
  539 consumed, 19 number-parse-nan), 40 after (21, 0, 19).
- flow::tests::path_cases: 39 shapes with their answers on some / every path, independent of
  any rule (labelled break and continue, do...while, a loop's update clause, for await,
  continue in try/finally, finally after a return, nested finally, switch with default in the
  middle and falling into it, && / || in a statement and a test, ?:, ??, ||=, optional calls,
  yield and await between, reset, an exception into catch, nested functions, unreachable code).
- Docs: the libraries guide says a pack's `consumes` is read from its safe-ts.json (and the
  manifest example shows it); use-after-consume's page covers views, second names and optional
  calls; must-use-result's covers branches and Promise.all; README gaps, CHANGELOG, tool gaps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open after f10ffd50:
- `promise-as-value` took any `filter` or `forEach` for the built-in's, also on a receiver whose
  type says otherwise (Node's `Readable`, whose `filter` awaits; a class of the project).
- `floating-promise` exempted the last statement of a timer or listener but not of a hook, so
  the verdict depended on which callers the checker knew.
- Missed: an optional call dropped (`hooks?.flush()`), a call through a declared function type
  (`flush: () => Promise<void>`), `const flags = ids.map(async ...)` read through the `const`,
  an assertion on a promise (`expect(p).toBeTruthy()`, `assert.ok(p)`); a receiver declared
  `Option<C>` wasn't followed to `C`'s methods by any rule.
- std's ten `@ts-expect-error` (TS2344) directives were held by one compiler only.

Closed:
- A method is the built-in's by the receiver's written type (array, typed array, Map, Set,
  iterator, DOM list; through an alias, a declared return type, a chain, across files); another
  written type isn't; an unwritten one is taken for the built-in (policy on the rule page).
- `floating-promise` reports a statement wherever it is; an arrow's value, a function passed by
  name and a Vue template's handler aren't statements.
- The misses above; `Option` / `Readonly` / `Mut` / `NonNullable` receivers are followed
  (entry_points: `port: Mut<Port>` now gets `Port`'s verdict, failure-contract).
- `typescript-versions.test.ts` compiles std, a consumer project and awaited.check.ts with
  TypeScript 7 and 5.9 (the one vue-tsc-tools installs); explicit type arguments that are type
  parameters are documented with the message users see and the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mapped promises read as values: a plain arrow that returns one counts like an async one
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m38s
Tests / test (pull_request) Successful in 12m49s
4eed7ea98b
`ids.map(async (id) => allowed(id))` read through `.some(Boolean)` was reported;
`ids.map((id) => allowed(id))` was not, although the list holds the same promises.
The callback forms the other checks already know (async, by name, an arrow whose body
is a call) now all apply here.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Open after 71e155cc: a method reached through an item of a typed
collection was silent: `repos[0]?.check()`, a local holding `repos[0]`
checked against `undefined`, `const [head] = repos`, `for...of` over a
`Map` or `Set` and over their `values()` / `entries()` / `keys()`, and a
receiver declared `Repo | null`. An element is now resolved to the
collection's item type (an array's or `ReadonlyArray`'s item, a `Set`'s
value, a `Map`'s `[key, value]` pair), an array pattern holds each item
by its index, and `null` leaves a union like `undefined` does. The
receivers fixture's `element` function now propagates `NotFound`, which
was a recorded gap.

Also open: 71e155cc made the pass on an adopter's entry about 100 ms
slower than its start. The pass now builds once the set of member names
any program function or object member can be reached by and answers no
for any other name before resolving the receiver, and memoises a
resolved member per (file, value, name, access). A `Record` slot no
longer makes every member name a slot (a call through `table.a()`
propagates nothing, as through `handlers[name]()`); a function's
declared return type is shared instead of cloned; a class reached
through `Ref` is read without cloning its declaration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A call propagates what its callee's written function type declares, however the callee is reached
All checks were successful
Benchmarks / bench (pull_request) Successful in 3m33s
Tests / test (pull_request) Successful in 7m41s
bac47a019c
Open after 98443f43: removing the Record name wildcard to save time
silenced a call the starting commit reported (`jobs.a?.()` with
`jobs: Record<string, Job>` and `type Job = Throwing<[], void,
JobError>`), and next to it calls through a declared function type
were silent wherever the callee was reached other than by a member
name some declared type writes: `jobs[name]?.()`, a local taken out by
a key and checked, `table[key]()` on an object type,
`byName.get(name)?.()`, `list[0]?.()`, a module-level `const job: Job`
called by name.

What closes it: the analysis records a call of a value no name is
written for (an item read by a key, what a call hands back) as a call
through that value, and holds a local taken out by a key. The
whole-program pass asks the slot reading, without a name filter, for
every call it can't tie to a body: a record's or index signature's
value by any name or key, an array's item by index or key, a Map's
`get`, an array's `at` / `find` / `pop` / `shift`, a tuple's position,
a computed key of an object type whose members declare the same
contract. A tuple slot checks what is put into it item by item; an
interface or object type that is only an index signature is a record.
A plain function type still propagates nothing; a mapped type stays
unknown. A new table test (24 rows) holds each form, by name and in an
arrow, in the whole-program run and on the editor's path, to the plain
`job: Job`.

The name filter is replaced by two exact gates: the fallback from a
receiver's class runs only for a member some class declares with a
function type, and an interface's members are read without cloning
the list each time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts, all kept from both sides: `analyze_file_with` / `analyze_vue_with` / `analyze`
take both the `consumes` table and the `MarkerPermission`; `Project::analyze_text` passes
both; `FeatureSet` has `consumes` and the marker lists / oxlint weakenings; the rule list,
the sidebar (no-lint-suppression, unlisted-marker and no-unchecked-declare under Ignore
comments, use-after-consume under Correctness), the module list and the CHANGELOG's Added
and Changed entries hold both pieces'. `kept_results` and the hatch-counting functions of
project.rs sit side by side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts, all kept from both sides: ecmascript-api.json gets both new sections (`callbacks`
and `consumes`, merged as JSON: each side only added its own key); package.json takes
`test:std` from this side (vue-tsc tools for the TypeScript-versions test) and `test:browsers`
from the other (the browsers' consumes test); the soundness class list imports both new
groups; the migration skill has both sections ("A promise used as its value", "A value used
after it was used up") and census.mjs both pointers; the CHANGELOG's Added and Changed keep
every entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: with no-unchecked-declare (escape-hatches-2) in the chain, `declare function
openStream(): Readable;` in the receivers fixture is reported, as every other fixture stub's
`declare` is. Closes: the expectation written on it, as on the other fixtures' stubs; the
stub stays, since what the fixture shows is a call returning a package's Readable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts, kept from both sides: `FnInfo` gets `returns_promise` and `returns_named` (both
computed where the function is declared; `names_a_type` and `is_promise_type` side by side),
the rule list, `.gitignore`'s fixture node_modules (consume_pack and return_types), the
meaning tests (one entry for `undeclared-return-type`, one for `floating-promise`), the
migration skill's tool gaps (the hatch counts and no-unchecked-declare from one side, the
strict-truthiness wording that names undeclared-return-type from the other), and the
CHANGELOG. must-use-result's page keeps the new "A Result kept in a local" section and the
rewritten "What the rule can't see" (aliases are opened now; the kept-Result sentences after
it stay). entry_points: both sides made the same expectation change; this side's comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open after the merge: three mechanisms read a receiver through `Option<C>`, `Readonly<C>`,
`Mut<C>`: the whole-program opener (`written_ty`, which knew `Readonly`, `Mut` and the
utility types, but not std's `Option`), and two analysis-side unwraps from the promise rules
(`named_class` in `annotated_class`, an early return in `receiver_type`), which only the
receivers of imported classes reached. And "an optional call is a call" was written three
times: the failure rules' and the promise rules' statement walkers each unwrapped
`repo?.check(id)` themselves, and the kept-Result collector didn't, so `const r =
repo?.check(id); console.log(r)` dropped the error unseen.

Closes:
- The opener reads std's `Option<C>` as `C` (as `C | undefined` already was), and a std name
  is see-through also where std is code of the project (`written::is_std`); a project type of
  that name still isn't. The two analysis-side unwraps are gone: a binding written with type
  arguments is followed by its written type (`record_receiver_binding`), and the two places
  that asked `instance_of` alone now ask that first too: a call through a second name
  (`const same = fixed; same.run()`, spelling.rs) and a binding handed to a slot
  (`given_of`). Receiver table: two rows, `Option<Repo>` and `Option<Deps>`; spellings
  fixture: `Readonly<Handlers>` and `Option<Handlers>` through a second name.
- `analyze::as_call`: the call an expression is, also optional; the statement walkers of
  the failure rules and of floating-promise, and kept.rs, all ask it. kept_results fixture: an
  optional call kept and only logged (reported), and one checked (silent).
- Docs: must-use-result (optional calls kept; `Option` and `Mut` in the written forms),
  uncaught-propagation, the CHANGELOG entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts:
- Receivers: this side read `Mut<C>` and `Option<C>` as `C` in two places, `annotated_class`
  (the analysis) and `type_ty` (the whole-program pass); the other side has one opener for
  every written type (`written_ty`), which reads `Mut` and std's `Option` as what they wrap.
  Kept the opener: `annotated_class` is the plain class reference again, and a binding
  written `Mut<C>` / `Option<Mut<C>>` is followed by its written type.
- `member_primitive` (aliased-mut: is a part declared primitive?) was written against the
  old `type_ty`; it now reads the member through the same opener (`Ty::Shape` holds a
  `Written`, aliases opened with their arguments bound) instead of its own alias step.
- escaping.txt: neither side's closed classes (aliased-mut-borrow, covariant-mutable-array-param,
  mut-callback-smuggle; one-shot-generator-reused, use-after-consume-arraybuffer), this
  side's two open Mut holes.
- entry_points: this side's split (a platform handler, a project slot) kept.
- Kept from both: the README's known gaps (the Mut paragraph, the sentinel line saying
  number-parse-nan follows paths), the sidebar (floating-promise and promise-as-value under
  Failures, missing-mut and aliased-mut under State), `mod loans` and `mod promises`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open: with the nominal `Mut<T>` and the one opener in one chain, nothing held a receiver
written `Mut<Repo>`, `Mut<Deps>` or `Option<Mut<Repo>>` to the plain form, nor a result read
off a function of a lent list.

Closes: three receiver rows (each against the plain `Repo` / `Deps` / `Repo | undefined`;
the harness passes a `Mut` parameter on as `mut(name)`, as missing-mut asks of every call
that passes a loan on), and two pairs (a lent list's `length` and element, called with
`mut([n])`). 42 rows and 71 pairs, none differs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ambient declarations test: a neutral member name in the sample
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m9s
Tests / test (pull_request) Successful in 9m13s
6e1cc600bc
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merge the chain below: a neutral member name in the ambient declarations test
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m19s
Tests / test (pull_request) Successful in 9m56s
259c12be10
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A dropped promise that holds a Result gets one finding, not two
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m14s
Tests / test (pull_request) Successful in 9m10s
7c841c8442
`load();` with `load(): Promise<Result<...>>` was both `floating-promise` and
`must-use-result`. The dropped `Result` is the finding; awaiting it and looking at it
answers both, so `floating-promise` leaves the call to that rule, as it already does
for the rules about failures.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merge the chain below: one finding for a dropped promise that holds a Result
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m29s
Tests / test (pull_request) Successful in 10m37s
c539bc1dfe
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Merge the chain below: one finding for a dropped promise that holds a Result
All checks were successful
Benchmarks / bench (pull_request) Successful in 4m31s
Tests / test (pull_request) Successful in 10m43s
25cb75b732
Co-Authored-By: Claude Fable 5.2 <[email protected]>
sionzee changed target branch from sentinel-values to return-types 2026-11-21 20:38:48 +01:00
sionzee changed target branch from return-types to main 2026-11-21 23:32:36 +01:00
Merge main
All checks were successful
Benchmarks / bench (pull_request) Successful in 2m47s
Tests / test (pull_request) Successful in 8m52s
4e6c2d623d
Co-Authored-By: Claude Fable 5.2 <[email protected]>
sionzee deleted branch nominal-mut 2026-11-21 23:34:12 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Evobug/Safe-Ts!116
No description provided.