Skip to content

Commit 40c0fec

Browse files
committed
wip(pm): drop the per-binding memo — the once-per-file blob read already bounds the reads
The memo changed no verdict and no read count (its ablation stayed green), so it goes; the two read-count cases keep pinning the per-file read. Claude-Session: https://claude.ai/code/session_01CB6W87z22K2yjUCDyVrJRk Co-authored-by: Claude <noreply@anthropic.com>
1 parent 121a3f3 commit 40c0fec

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

‎scripts/pm/check-widening-tells.mjs‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,10 +3090,8 @@ export function refusalOnlyReaders(source, name) {
30903090
* T2's verdict on one MEMBER line — `fires`, `silent` or `narrowing` — with the
30913091
* construct reading it rests on. `readSource` is a thunk answering the file's
30923092
* head blob (or `null`); it is called only for the one reading that needs it.
3093-
* `readers` caches {@link refusalOnlyReaders} per binding for one file, so a
3094-
* set gaining many members reads its file once rather than once per member.
30953093
*/
3096-
export function t2MemberVerdict(side, index, readSource = null, readers = null) {
3094+
export function t2MemberVerdict(side, index, readSource = null) {
30973095
const reading = enclosingConstruct(side, index);
30983096
const verdict = reading.construct === null ? 'fires' : (T2_CONSTRUCT_VERDICTS[reading.construct] ?? 'fires');
30993097
if (verdict !== 'fires') return { ...reading, verdict };
@@ -3103,13 +3101,10 @@ export function t2MemberVerdict(side, index, readSource = null, readers = null)
31033101
!reading.exported &&
31043102
typeof readSource === 'function'
31053103
) {
3106-
let narrows = readers instanceof Map ? readers.get(reading.binding) : undefined;
3107-
if (narrows === undefined) {
3108-
const source = readSource();
3109-
narrows = typeof source === 'string' && refusalOnlyReaders(source, reading.binding).narrowing;
3110-
if (readers instanceof Map) readers.set(reading.binding, narrows);
3104+
const source = readSource();
3105+
if (typeof source === 'string' && refusalOnlyReaders(source, reading.binding).narrowing) {
3106+
return { ...reading, verdict: 'narrowing' };
31113107
}
3112-
if (narrows) return { ...reading, verdict: 'narrowing' };
31133108
}
31143109
return { ...reading, verdict: 'fires' };
31153110
}
@@ -4515,7 +4510,6 @@ export function tellsInFile(
45154510
if (headSource === undefined) headSource = typeof readSource === 'function' ? readSource(file) : null;
45164511
return headSource;
45174512
};
4518-
const readersByBinding = new Map();
45194513
// #17300 — is THIS file the ADR-0087 ledger? A licence clears a row in the
45204514
// ledger table and nowhere else: the same string added to any other file on
45214515
// any other surface still tells, with its own file:line.
@@ -4600,7 +4594,7 @@ export function tellsInFile(
46004594
// #17955's reason: a line that is no member must neither FIRE nor SPEND a
46014595
// unit a real member in the same block is owed. `narrowing` is decided at
46024596
// the row, below — a member it is, of a set that loses a value.
4603-
const member = kind === 'T2' ? t2MemberVerdict(newFile, newAt.get(i), headSourceOnce, readersByBinding) : null;
4597+
const member = kind === 'T2' ? t2MemberVerdict(newFile, newAt.get(i), headSourceOnce) : null;
46044598
if (member?.verdict === 'silent') continue;
46054599
// #17955 — a `retiredKey()` tombstone DECLARES a key unwritable. It is read
46064600
// BEFORE the budget, and that ordering is the whole repair rather than a
@@ -5654,7 +5648,7 @@ export function selfTest() {
56545648
const rows = tellsInFile({ filename: CONSTRUCT_FILE, status: 'modified', patch: "@@ -1,2 +1,5 @@\n const SINGLE_SERIES_TYPES = [\n+ 'pie',\n+ 'donut',\n+ 'sankey',\n ] as const satisfies readonly ChartType[];" }, { readSource: () => { reads += 1; return DENY_SET_SOURCE; }, narrowing });
56555649
return reads === 1 && rows.length === 0 && narrowing.length === 3;
56565650
})());
5657-
t('…and TWO sets in one file still read it ONCE — the per-file read, not the per-set memo, is what holds this', (() => {
5651+
t('…and TWO sets in one file still read it ONCE — the read is per FILE, never per member or per set', (() => {
56585652
let reads = 0;
56595653
const narrowing = [];
56605654
const rows = tellsInFile({ filename: CONSTRUCT_FILE, status: 'modified', patch: "@@ -1,2 +1,6 @@\n const SINGLE_SERIES_TYPES = [\n+ 'sankey',\n ] as const satisfies readonly ChartType[];\n+const OTHER_TYPES = [\n+ 'other',\n+] as const;" }, { readSource: () => { reads += 1; return DENY_SET_SOURCE; }, narrowing });

0 commit comments

Comments
 (0)