rvlib-shipkit 2.25.0 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,10 @@ export type TranscriptEvent =
53
53
  /** the text block that ends the turn (stop_reason end_turn): the agent
54
54
  * stopped, and what follows is a wait until something wakes it */
55
55
  | { kind: 'end'; at: number }
56
+ /** a hook run the harness timed: written only when the hook printed
57
+ * something, so a silent hook leaves none. `tool` is '' on an event of no
58
+ * tool (a prompt, a turn end); `id` is the call it ran on, or the hook's own id */
59
+ | { kind: 'hook'; at: number; id: string; event: string; tool: string; command: string; ms: number; code: number | null; error: boolean }
56
60
 
57
61
  // wrappers the harness injects as user-role entries: none of them are typed
58
62
  const NOISE_PREFIXES = [
@@ -95,7 +99,7 @@ export type RawEntry = {
95
99
  * a plain turn in a main session, a meta turn in a sub-agent */
96
100
  origin?: { kind?: unknown }
97
101
  /** attachment entries: a notification delivered mid-turn is a `queued_command` */
98
- attachment?: { type?: unknown; prompt?: unknown }
102
+ attachment?: { type?: unknown; prompt?: unknown; hookName?: unknown; hookEvent?: unknown; command?: unknown; durationMs?: unknown; exitCode?: unknown; toolUseID?: unknown }
99
103
  /** queue-operation entries only */
100
104
  operation?: unknown
101
105
  content?: unknown
@@ -240,7 +244,7 @@ const resultText = (content: unknown): string => {
240
244
  // the entry types that carry nothing a reader wants and make most of the
241
245
  // bytes (api-request alone is about 80 percent of a long session): a line
242
246
  // that starts with one of these is skipped before JSON.parse
243
- const KEPT_TYPE_PREFIXES = ['{"type":"user"', '{"type":"assistant"', '{"type":"queue-operation"']
247
+ const KEPT_TYPE_PREFIXES = ['{"type":"user"', '{"type":"assistant"', '{"type":"queue-operation"', '{"type":"attachment"']
244
248
 
245
249
  /** every event one transcript line holds; [] for anything else, a truncated
246
250
  * tail line of a live session included */
@@ -263,7 +267,11 @@ export function eventsOf(entry: RawEntry): TranscriptEvent[] {
263
267
  }
264
268
  if (Number.isNaN(at) && entry.type !== 'user') return []
265
269
  // a notification that arrives while the agent works is attached to its next turn
266
- if (entry.type === 'attachment') return entry.attachment?.type === 'queued_command' && typeof entry.attachment.prompt === 'string' ? bgEndsOf(entry.attachment.prompt, at) : []
270
+ if (entry.type === 'attachment') {
271
+ const a = entry.attachment
272
+ if (a?.type === 'hook_success' || a?.type === 'hook_non_blocking_error') return hookOf(a, at)
273
+ return a?.type === 'queued_command' && typeof a.prompt === 'string' ? bgEndsOf(a.prompt, at) : []
274
+ }
267
275
  if (entry.type === 'assistant') {
268
276
  const blocks = Array.isArray(entry.message?.content) ? (entry.message.content as Block[]) : []
269
277
  const out: TranscriptEvent[] = []
@@ -301,6 +309,16 @@ export function eventsOf(entry: RawEntry): TranscriptEvent[] {
301
309
  return out
302
310
  }
303
311
 
312
+ /** a timed hook record: its event, the tool from `PostToolUse:Edit`, its
313
+ * command as the settings name it, its duration */
314
+ function hookOf(a: NonNullable<RawEntry['attachment']>, at: number): TranscriptEvent[] {
315
+ if (typeof a.durationMs !== 'number' || typeof a.hookEvent !== 'string' || typeof a.command !== 'string') return []
316
+ const name = typeof a.hookName === 'string' ? a.hookName : ''
317
+ const tool = name.startsWith(`${a.hookEvent}:`) ? name.slice(a.hookEvent.length + 1) : ''
318
+ const id = typeof a.toolUseID === 'string' ? a.toolUseID : ''
319
+ return [{ kind: 'hook', at, id, event: a.hookEvent, tool, command: a.command, ms: a.durationMs, code: typeof a.exitCode === 'number' ? a.exitCode : null, error: a.type === 'hook_non_blocking_error' }]
320
+ }
321
+
304
322
  const NOTICE = /<task-notification>([\s\S]*?)<\/task-notification>/g
305
323
  const tagOf = (body: string, name: string): string | null => new RegExp(`<${name}>([^<]*)</${name}>`).exec(body)?.[1]?.trim() ?? null
306
324
 
@@ -274,6 +274,24 @@ export const withoutCard = (r: Release, card: string): Release => ({
274
274
 
275
275
  export const changesOf = (r: Release): Change[] => r.categories.flatMap((c) => c.changes)
276
276
 
277
+ /** the changes a word names: by its card (the whole id, or the moment it starts with), else by its title, whole
278
+ * before a part of it */
279
+ export function changesNamed(r: Release, ref: string): Change[] {
280
+ const all = changesOf(r)
281
+ const w = ref.trim().toLowerCase()
282
+ if (w === '') return []
283
+ const byCard = all.filter((c) => c.card != null && (c.card.toLowerCase() === w || c.card.toLowerCase().startsWith(`${w}-`)))
284
+ if (byCard.length > 0) return byCard
285
+ const whole = all.filter((c) => c.title.toLowerCase() === w)
286
+ return whole.length > 0 ? whole : all.filter((c) => c.title.toLowerCase().includes(w))
287
+ }
288
+
289
+ /** the release without that one change; a category left empty goes with it */
290
+ export const withoutChange = (r: Release, change: Change): Release => ({
291
+ ...r,
292
+ categories: r.categories.map((c) => ({ ...c, changes: c.changes.filter((x) => x !== change) })).filter((c) => c.changes.length > 0),
293
+ })
294
+
277
295
  /** a change's key on a page: its card, else its title */
278
296
  export const changeKey = (ch: Pick<Change, 'card' | 'title'>): string => `${ch.card ?? ''}${ch.title}`
279
297
 
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:f
4
4
  import { join } from 'node:path'
5
5
  import { atomicWrite } from '../core/locked-write.ts'
6
6
  import { LAYOUT } from '../core/layout.ts'
7
- import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, withoutCard, type Change, type Release } from './model.ts'
7
+ import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, withoutCard, type Change, type Release, changesNamed, changesOf, withoutChange } from './model.ts'
8
8
 
9
9
  const FILE = /^(next|\d+\.\d+\.\d+)\.md$/
10
10
 
@@ -37,6 +37,18 @@ export function dropCardChange(root: string, card: string): string | null {
37
37
  return writeRelease(root, withoutCard(r, card))
38
38
  }
39
39
 
40
+ /** next without the one change `ref` names (its card id, or its title), written. Refused when it names none or
41
+ * several: a change is taken out by a name that is its own */
42
+ export function dropChange(root: string, ref: string): { file: string; title: string } {
43
+ const r = readRelease(root, NEXT)
44
+ if (r == null) throw new Error(`${LAYOUT.releases}/${fileOf(NEXT)} does not exist: there is no change to take out`)
45
+ const hits = changesNamed(r, ref)
46
+ const titles = (list: readonly { title: string }[]): string => list.map((c) => `« ${c.title} »`).join(', ')
47
+ if (hits.length === 0) throw new Error(`no change of ${fileOf(NEXT)} has « ${ref} » as its card or in its title; it holds ${titles(changesOf(r)) || 'none'}`)
48
+ if (hits.length > 1) throw new Error(`« ${ref} » names ${hits.length} changes (${titles(hits)}): give the card id or the whole title`)
49
+ return { file: writeRelease(root, withoutChange(r, hits[0]!)), title: hits[0]!.title }
50
+ }
51
+
40
52
  /** one release file, parsed; null when there is none */
41
53
  export function readRelease(root: string, version: string): Release | null {
42
54
  const f = releaseFile(root, version)
@@ -238,6 +238,12 @@ export type RepoConfig = {
238
238
  * for its kind (core/budget.ts). An id no check carries fails the run,
239
239
  * the same as an `off` entry. */
240
240
  budgets?: Record<string, number>
241
+ /** AGENT HOOKS THE GATE CANNOT TIME, each one's command exactly as
242
+ * `.claude/settings.json` writes it → why it answers at once. SK045 runs
243
+ * a hook on every tool call only when it takes a Bash call, so a hook on
244
+ * a save fails the gate unless it is named here; SK046 then warns on the
245
+ * runs the harness recorded. `defineRepo` throws on a blank reason */
246
+ instantHooks?: Record<string, string>
241
247
  /** RETIRED, read as `off` while SK029 ports it there: rule id → the reason
242
248
  * this repo breaks that invariant on purpose. An exempted rule does not
243
249
  * lint and prints a skip line carrying the reason. `defineRepo` throws on
@@ -384,7 +390,7 @@ export type RepoConfig = {
384
390
  logDir?: string
385
391
  }
386
392
 
387
- const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
393
+ const KNOWN_KEYS = new Set(['name', 'venues', 'social', 'speaksAs', 'backup', 'annex','docsBase', 'defaults', 'tasks', 'asks', 'creds', 'credsCommand', 'credsReadCommand', 'notifyCommand', 'contracts', 'gitignore', 'ignoredInputs', 'untrackGenerated', 'nested', 'off', 'when', 'budgets', 'instantHooks', 'ruleExempt', 'visibility', 'archived', 'reviewer', 'oneWayIn', 'rules', 'release', 'units', 'notReleasable', 'vendored', 'hooks', 'checkDefaults', 'tui', 'serve', 'recorder', 'identity', 'logDir', 'smoke', 'tests', 'browsers', 'start'])
388
394
 
389
395
  export function defineRepo(c: RepoConfig): RepoConfig {
390
396
  if (typeof c.name !== 'string' || c.name === '') throw new Error('defineRepo: name is required')
@@ -479,6 +485,10 @@ export function defineRepo(c: RepoConfig): RepoConfig {
479
485
  if (RULE_ID_RE.test(id) && !builtinCheckIds().includes(id) && !(c.rules ?? []).some((r) => r.id === id))
480
486
  throw new Error(`defineRepo: off.${id} names no rule, the ids are in \`shipkit checks\``)
481
487
  }
488
+ for (const [command, reason] of Object.entries(c.instantHooks ?? {})) {
489
+ if (command.trim() === '') throw new Error(`defineRepo: instantHooks has an entry with no command`)
490
+ if (typeof reason !== 'string' || reason.trim() === '') throw new Error(`defineRepo: instantHooks entry \`${command}\` needs a reason: why it answers at once`)
491
+ }
482
492
  // the retired `when`: only its `off:<why>` word still means something
483
493
  for (const [id, raw] of Object.entries(c.when ?? {})) {
484
494
  const w = parseWhen(raw)
@@ -0,0 +1,35 @@
1
+ // `sk review inbox --hook`: the inbox as a Claude Code hook, so the owner's answers reach a session that holds no
2
+ // watch. On a prompt (UserPromptSubmit) the unseen answers join the turn as context; at a turn's end (Stop) the turn
3
+ // is refused while one is unseen. An answer is seen once `sk review seen <id>` ran, after the session acted on it.
4
+ // the one constraint a reader breaks first: a Stop the hook already refused once (`stop_hook_active`) passes, else
5
+ // a session that cannot mark an answer seen never ends its turn
6
+
7
+ /** what Claude Code hands a hook on stdin, the two fields read here */
8
+ export type HookInput = { hook_event_name?: string; stop_hook_active?: boolean }
9
+
10
+ export function parseHookInput(text: string): HookInput {
11
+ try {
12
+ const v = JSON.parse(text === '' ? '{}' : text) as unknown
13
+ return typeof v === 'object' && v !== null ? (v as HookInput) : {}
14
+ } catch {
15
+ return {}
16
+ }
17
+ }
18
+
19
+ /** true when the hook answers nothing and the inbox need not be read at all */
20
+ export const hookPasses = (input: HookInput): boolean => input.hook_event_name === 'Stop' && input.stop_hook_active === true
21
+
22
+ /** the one json line the hook prints, or null for none. `unseen`: the answers not marked seen, as the inbox prints
23
+ * them; `owed`: the ids of the answers read and not closed */
24
+ export function hookAnswer(input: HookInput, unseen: string, owed: readonly string[], bin = 'sk'): string | null {
25
+ if (hookPasses(input)) return null
26
+ if (input.hook_event_name === 'Stop') {
27
+ if (unseen === '') return null
28
+ return JSON.stringify({ decision: 'block', reason: `Review answers of the owner are not marked seen. Read each, act on it (relay it to its lane, answer it), then \`${bin} review seen <id>\`:\n${unseen}` })
29
+ }
30
+ const parts = [
31
+ unseen === '' ? '' : `Unseen review answers of the owner (act on each, then \`${bin} review seen <id>\`):\n${unseen}`,
32
+ owed.length === 0 ? '' : `Answers read but not closed (done or wontfix): ${owed.join(', ')}`,
33
+ ].filter((p) => p !== '')
34
+ return parts.length === 0 ? null : JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: parts.join('\n\n') } })
35
+ }
@@ -658,7 +658,8 @@ export function stateOf(x: ReviewItem, superseded: boolean): ItemState {
658
658
  s = i.origin.by === 'agent' ? given : { ...keep, state: 'open' }
659
659
  break
660
660
  case 'blocked':
661
- s = { ...keep, state: 'blocked' }
661
+ // it keeps who blocked it: that worker takes it back or closes it once the owner answered elsewhere
662
+ s = { ...keep, state: 'blocked', worker: m.who }
662
663
  break
663
664
  case 'ready':
664
665
  if (s.state === 'draft') s = { ...keep, state: 'asks' }
@@ -702,12 +703,12 @@ const FROM: Record<Exclude<Op, 'seen'>, readonly State[]> = {
702
703
  answer: ['question'],
703
704
  reassign: ['open', 'claimed'],
704
705
  drop: ['new', 'question', 'open', 'blocked'],
705
- claim: ['open', 'claimed', 'closed'],
706
+ claim: ['open', 'claimed', 'closed', 'blocked'],
706
707
  release: ['claimed'],
707
708
  blocked: ['claimed'],
708
- fixed: ['open', 'claimed'],
709
+ fixed: ['open', 'claimed', 'blocked'],
709
710
  done: ['claimed'],
710
- wontfix: ['open', 'claimed'],
711
+ wontfix: ['open', 'claimed', 'blocked'],
711
712
  withdraw: ['draft', 'asks'],
712
713
  reopen: ['closed', 'claimed'],
713
714
  ready: ['draft'],
@@ -730,6 +731,7 @@ export function allowed(s: ItemState, op: Op, who: string, dispatcher: string |
730
731
  if (op === 'claim' && (who === 'owner' || who === dispatcher)) return `a worker claims, never ${who === 'owner' ? 'the owner' : 'the dispatcher'}`
731
732
  if (WORKER_OPS.has(op) && who !== 'owner' && s.worker !== undefined && s.worker !== who) return `claimed by ${s.worker}, not by ${who}`
732
733
  if (op === 'claim' && s.state === 'claimed' && s.since !== undefined && s.worker !== who) return `already claimed by ${s.worker}: release it first (--as ${s.worker})`
734
+ if (op === 'claim' && s.state === 'blocked' && s.worker !== undefined && s.worker !== who) return `blocked by ${s.worker}, who takes it back (--as ${s.worker}); the dispatcher routes it to another`
733
735
  if (op === 'claim' && s.state === 'closed' && s.why !== 'rejected' && s.why !== 'approved-with-fix')
734
736
  return `claim needs open, or a card he answered « fix » or « no », it is closed (${s.why})`
735
737
  if (!FROM[op].includes(s.state)) {
@@ -781,12 +783,16 @@ export const coversCard = (f: WatchFilter, x: ReviewItem): boolean =>
781
783
  /** who answers an agent's card, its reply or its seen: the worker of a live claim on it, else the lane that made it,
782
784
  * else (a card with no lane) the session that sent it. null when `me` is that one, else why not and the way out.
783
785
  * Another session hearing the verdict (a bare watch) is refused, so it never answers over the maker; a plain approval,
784
- * which owes nothing, anyone marks seen. An item he raised, a player's or an auto one: the claim rules decide */
785
- export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen'): string | null {
786
+ * which owes nothing, anyone marks seen. So does anyone once the maker stopped listening: `heardBy` is the live
787
+ * watches of the store, and when none of a lane or of a session covers the card (the lane ended), whoever reads the
788
+ * answer marks it seen; a reply stays the maker's. An item he raised, a player's or an auto one: the claim rules decide */
789
+ export function notAnswererOf(x: ReviewItem, me: { lane: string | null; session: string | null }, op: 'reply' | 'seen', heardBy?: readonly WatchFilter[]): string | null {
786
790
  const o = x.item.origin
787
791
  if (o.by !== 'agent') return null
788
792
  const s = stateOf(x, false)
789
793
  if (op === 'seen' && s.state === 'closed' && s.why === 'approved') return null
794
+ // a bare watch hears every card and is nobody's own: only a watch of a lane or of a session says the maker listens
795
+ if (op === 'seen' && heardBy !== undefined && !heardBy.some((w) => (w.lane !== null || w.session !== null) && coversCard(w, x))) return null
790
796
  const id = x.item.id
791
797
  // the way out names claim only where claim takes it
792
798
  const noClaim = allowed(s, 'claim', me.lane ?? 'agent', null, false)
@@ -193,7 +193,7 @@ export function judgeSuites(p: { timings: Record<string, number>; tests: TestsCo
193
193
  * performance core (coreMs), null where the counters are missing, and
194
194
  * childCpuMs and otherCpuMs the parts of it that are the CPU of its children
195
195
  * and of its process's other threads, charged as measured */
196
- export type AloneRun = { wallMs: number; cpuMs: number | null; coreMs?: number | null; childCpuMs?: number; otherCpuMs?: number }
196
+ export type AloneRun = { wallMs: number; cpuMs: number | null; coreMs?: number | null; childCpuMs?: number; otherCpuMs?: number; /** its main thread's instructions per ms on a performance core, where it ran OWN_RATE_MIN_MS there */ rate?: number }
197
197
  /** the 1 minute load average against the core count, read before a suspect runs */
198
198
  export type MachineLoad = { load1: number; cores: number }
199
199
  /** how far past the budget a suite must WAIT on an idle machine before its
@@ -255,7 +255,7 @@ export function coreMs(w: SuiteWork, instrPerMs: number | null): number | null {
255
255
 
256
256
  /** `ms` is the time the verdict used: the core figure, cpu, or wall for a
257
257
  * wait or when no cpu figure exists */
258
- export type Confirmed = { file: string; ms: number; wallMs: number; cpuMs: number | null; coreMs?: number | null; over: 'core' | 'cpu' | 'wait' | 'wall' | null }
258
+ export type Confirmed = { file: string; ms: number; wallMs: number; cpuMs: number | null; coreMs?: number | null; rate?: number; over: 'core' | 'cpu' | 'wait' | 'wall' | null }
259
259
 
260
260
  /** the verdict on each suspect once it ran alone, continuous in the load.
261
261
  * A wall time carries the load of every other process on the machine, so
@@ -274,9 +274,10 @@ export function confirmOver(suspects: Timed[], alone: Record<string, AloneRun>,
274
274
  const core = run?.coreMs ?? null
275
275
  if (core != null) {
276
276
  const charged = Math.min(core, wallMs)
277
- if (charged > cpuAllowance(budgetMs, load)) return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, over: 'core' }
278
- if (wallMs > waitAllowance(budgetMs, load)) return { file: t.file, ms: wallMs, wallMs, cpuMs, coreMs: core, over: 'wait' }
279
- return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, over: null }
277
+ const rate = run?.rate != null ? { rate: run.rate } : {}
278
+ if (charged > cpuAllowance(budgetMs, load)) return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, ...rate, over: 'core' }
279
+ if (wallMs > waitAllowance(budgetMs, load)) return { file: t.file, ms: wallMs, wallMs, cpuMs, coreMs: core, ...rate, over: 'wait' }
280
+ return { file: t.file, ms: charged, wallMs, cpuMs, coreMs: core, ...rate, over: null }
280
281
  }
281
282
  if (cpuMs == null) return { file: t.file, ms: wallMs, wallMs, cpuMs, over: wallMs > budgetMs ? 'wall' : null }
282
283
  const charged = Math.min(cpuMs, wallMs)
@@ -290,6 +291,17 @@ export function confirmOver(suspects: Timed[], alone: Record<string, AloneRun>,
290
291
  /** a core figure that is more than this share CPU charged as measured (children, other threads) moves with the load like CPU does */
291
292
  export const MEASURED_SHARE = 0.25
292
293
 
294
+ /** what a full tier run says of the quick tier's budget, never blocking: the suites the quick tier would run again
295
+ * alone, judged on this run's own CPU figures in a pool the slow suites shared, or that every suite it runs held */
296
+ export function quickTierWords(needAlone: Timed[], parallelCpu: Record<string, number>, parallelCore: Record<string, number>): string {
297
+ if (needAlone.length === 0) return "note: the quick tier's budget holds for every suite it runs, on this run's own CPU figures (never blocking in the full tier)"
298
+ const each = needAlone.map((t) => {
299
+ const own = parallelCore[t.file] ?? parallelCpu[t.file]
300
+ return `${t.file} ${secs(t.ms)} wall${own != null ? `, ${secs(own)} of its own CPU` : ', no CPU figure'}`
301
+ })
302
+ return `note: the quick tier's budget, on this run's own CPU figures in a pool the slow suites shared (never blocking in the full tier): ${needAlone.length} suite(s) the quick tier would run again alone before its verdict: ${each.join('; ')}`
303
+ }
304
+
293
305
  /** a lone run over the budget on CPU runs once more. Under load the
294
306
  * scheduler can spill a lone run onto the efficiency cores, where the same
295
307
  * retired instructions cost up to 4x the CPU time (measured on Apple
@@ -310,9 +322,15 @@ export const smallerRun = (a: AloneRun, b: AloneRun): AloneRun => {
310
322
 
311
323
  const secs = (ms: number): string => `${(ms / 1000).toFixed(1)}s`
312
324
 
313
- /** the line a confirmed suite fails with */
314
- export const overWords = (c: Confirmed, load: MachineLoad, budgetMs: number = DEFAULT_BUDGET_MS): string =>
315
- c.over === 'core' ? `${c.file} ${secs(c.coreMs ?? c.ms)} of CPU on a performance core (${c.cpuMs != null ? `${secs(c.cpuMs)} of process CPU, ` : ''}${secs(c.wallMs)} wall)`
325
+ const gps = (instrPerMs: number): string => `${(instrPerMs / 1e6).toFixed(1)} G/s`
326
+ /** how far the main thread's own rate on a performance core sat under the rate the charge converts at: a loaded
327
+ * machine slows a performance core too, so a reader sees the machine moved, not only the suite */
328
+ const rateWords = (rate: number | undefined, quietRate: number | null | undefined): string =>
329
+ rate == null || quietRate == null || quietRate <= 0 || rate >= quietRate ? '' : `, its main thread at ${gps(rate)} on a performance core, ${Math.round((1 - rate / quietRate) * 100)}% under the ${gps(quietRate)} it is charged at`
330
+
331
+ /** the line a confirmed suite fails with. `quietRate`: the instructions per ms the charge converts at (calibrate.ts conversionRate) */
332
+ export const overWords = (c: Confirmed, load: MachineLoad, budgetMs: number = DEFAULT_BUDGET_MS, quietRate: number | null = null): string =>
333
+ c.over === 'core' ? `${c.file} ${secs(c.coreMs ?? c.ms)} of CPU on a performance core (${c.cpuMs != null ? `${secs(c.cpuMs)} of process CPU, ` : ''}${secs(c.wallMs)} wall${rateWords(c.rate, quietRate)})`
316
334
  : c.over === 'cpu' ? `${c.file} ${secs(c.cpuMs ?? c.ms)} of CPU (${secs(c.wallMs)} wall)`
317
335
  : c.over === 'wait' ? `${c.file} ${secs(c.wallMs)} wall at load ${load.load1.toFixed(1)} on ${load.cores} cores, past its ${secs(waitAllowance(budgetMs, load))} wait allowance, with ${secs(c.coreMs ?? c.cpuMs ?? 0)} of CPU: it waits (a timer, a sleep, a poll)`
318
336
  : `${c.file} ${secs(c.wallMs)} wall (no CPU figure)`
@@ -379,6 +397,55 @@ export function aloneRunsNeeded(suspects: Timed[], parallelCpu: Record<string, n
379
397
  return { rerun, cleared }
380
398
  }
381
399
 
400
+ /** the load share from which a suite red in the pooled run runs again alone: every core already busy before the
401
+ * run's own workers. Under it each worker has a core of its own, so a failure is the suite's and stands */
402
+ export const LOADED_SHARE = 1
403
+ /** the most suites red in the pooled run that run again alone. The load flakes measured each turned one to three
404
+ * suites red; past that the tree is broken, and a lone run each would only delay the red */
405
+ export const RED_RERUN_CAP = 3
406
+ /** the least wall a red suite's lone run gets before it is killed and stays red. It gets twice its pooled wall
407
+ * when that is more (a pool runs a suite slower than a lone run does), and never more than the phase ceiling */
408
+ export const RED_RERUN_MIN_MS = 30_000
409
+ export const redRerunCeiling = (pooledMs: number | undefined, ceilingMs: number): number => Math.min(ceilingMs, Math.max(RED_RERUN_MIN_MS, 2 * (pooledMs ?? 0)))
410
+
411
+ /** which suites red in the pooled run run again alone before they can turn the run red, or the note that says
412
+ * why none does. Only a parallel phase that ran to its end qualifies (a kill or a stall has its own line), only on
413
+ * a loaded machine, and only up to the cap */
414
+ export function redRerunsNeeded(p: { red: string[]; load: MachineLoad; pooled: boolean; ended: boolean; cap?: number }): { rerun: string[]; note: string | null } {
415
+ const cap = p.cap ?? RED_RERUN_CAP
416
+ if (p.red.length === 0 || !p.pooled || !p.ended) return { rerun: [], note: null }
417
+ const at = `load ${p.load.load1.toFixed(1)} on ${p.load.cores} cores`
418
+ if (loadShare(p.load) < LOADED_SHARE) return { rerun: [], note: `note: ${p.red.length} suite(s) failed in the pooled run at ${at}, a machine quiet enough that the red stands (a red suite runs again alone from load ${(LOADED_SHARE * p.load.cores).toFixed(0)})` }
419
+ if (p.red.length > cap) return { rerun: [], note: `note: ${p.red.length} suites failed in the pooled run at ${at}, more than the ${cap} a loaded machine explains: none ran again alone` }
420
+ return { rerun: [...p.red], note: null }
421
+ }
422
+
423
+ /** a red suite's lone run passed: it ended on its own, ran a test, and bun named no failure */
424
+ export const passedAlone = (r: { code: number; signal: string | null; stalled: boolean; out: string }): boolean =>
425
+ r.code === 0 && r.signal == null && !r.stalled && failedSuites(r.out).length === 0 && /Ran [1-9]\d* tests?/.test(r.out)
426
+
427
+ /** the WARN a suite prints each run it failed in the pooled run and passed alone */
428
+ export const rescuedWords = (file: string, why: string, load: MachineLoad): string =>
429
+ `WARN ${file} failed in the pooled run (${why}) and passed alone, at load ${load.load1.toFixed(1)} on ${load.cores} cores: not red, but a test there depends on the machine's speed (a timeout, a sleep, a race), make it wait on the state it needs`
430
+
431
+ /** the failed tests and the errors outside any test that bun's report names under these files: what a phase's
432
+ * counts drop once those files passed alone */
433
+ export function failuresIn(output: string, files: Set<string>): { tests: number; errors: number } {
434
+ let tests = 0
435
+ let errors = 0
436
+ let cur: string | null = null
437
+ for (const line of output.split('\n')) {
438
+ const head = line.match(HEADER)
439
+ if (head != null) { cur = normSuitePath(head[1]!); continue }
440
+ if (BUN_RECAP.test(line)) { cur = null; continue }
441
+ if (cur == null || !files.has(cur)) continue
442
+ if (/^\(fail\) /.test(line)) tests++
443
+ else if (line.startsWith(BETWEEN_TESTS)) errors++
444
+ else if (/^\s*✗\s+\S+\s+\(worker crashed: /.test(line)) tests++
445
+ }
446
+ return { tests, errors }
447
+ }
448
+
382
449
  /** the recap bun prints after the last file, "3 tests failed:", repeats
383
450
  * every (fail) line under no header of its own: it closes the last file */
384
451
  export const BUN_RECAP = /^\s*\d+ tests? failed:\s*$/
@@ -457,8 +524,8 @@ const clip = (s: string): string => (s.length > 300 ? `${s.slice(0, 299)}…` :
457
524
  * summary (`N fail`, `N error`) and the report in `out`. bun can count an
458
525
  * error thrown outside any test as `0 fail`, so the errors lead, each with
459
526
  * the file that threw */
460
- export function redWords(o: { failedTests: number; errors: number; ran: number; slowest: string; out: string }): string {
461
- const thrown = [...failLines(o.out)].filter(([, w]) => w.startsWith(BETWEEN_WORDS))
527
+ export function redWords(o: { failedTests: number; errors: number; ran: number; slowest: string; out: string; passedAlone?: Set<string> }): string {
528
+ const thrown = [...failLines(o.out)].filter(([f, w]) => w.startsWith(BETWEEN_WORDS) && o.passedAlone?.has(f) !== true)
462
529
  const parts: string[] = []
463
530
  if (o.errors > 0 || thrown.length > 0) {
464
531
  const named = thrown.slice(0, 3).map(([file, w]) => `${file} threw ${w.slice(BETWEEN_WORDS.length + 2) || 'with no message'}`)
@@ -13,6 +13,7 @@ import { basename, join, posix } from 'path'
13
13
  import { FULL_TESTS_ENV } from '../ledger/gate-checks.ts'
14
14
  import { CHECK_ID_ENV, recordSuites, type SuitePhase } from '../ledger/suite-log.ts'
15
15
  import { killTree } from '../core/spawn-timeout.ts'
16
+ import { signalName } from '../core/signal-name.ts'
16
17
  import { parallelCap } from '../core/parallel.ts'
17
18
  import { poolDir, SLOT_CORES_ENV, SLOT_HELD_ENV, slotsLine, takeFreeSlots } from '../core/slots.ts'
18
19
  import { keptWorkMs, mostWorkers, workersFor, workersToStart } from './suite-cores.ts'
@@ -23,7 +24,7 @@ import { gitRoot } from '../core/git-root.ts'
23
24
  import { runReaches, type TestRun } from './test-units.ts'
24
25
  import { loadConfig } from '../ts/config.ts'
25
26
  import { conversionRate, machineRate } from './calibrate.ts'
26
- import { aloneRunsNeeded, bunfigTest, coreMs, cpuAllowance, loadShare, type SuiteWork, type BunfigTest, readPhaseCpu, SUITE_CPU_ENV, type AloneRun, type Confirmed, confirmOver, crashedWorkers, interruptedSuites, overWords, ranAs, retryAlone, smallerRun, stallWords, DEFAULT_BUDGET_MS, FULL_CEILING_MS, failedSuites, failLines, judgeSuites, normSuitePath, parseSuiteFlags, planPhases, QUICK_CEILING_MS, redWords } from './judge-suites.ts'
27
+ import { aloneRunsNeeded, bunfigTest, failuresIn, OWN_RATE_MIN_MS, quickTierWords, passedAlone, redRerunCeiling, redRerunsNeeded, rescuedWords, coreMs, cpuAllowance, loadShare, type SuiteWork, type BunfigTest, readPhaseCpu, SUITE_CPU_ENV, type AloneRun, type Confirmed, confirmOver, crashedWorkers, interruptedSuites, overWords, ranAs, retryAlone, smallerRun, stallWords, DEFAULT_BUDGET_MS, FULL_CEILING_MS, failedSuites, failLines, judgeSuites, normSuitePath, parseSuiteFlags, planPhases, QUICK_CEILING_MS, redWords } from './judge-suites.ts'
27
28
 
28
29
  type Phase = { code: number; signal: string | null; stalled: boolean; out: string; timings: Record<string, number>; cpuMs: number | null }
29
30
 
@@ -74,7 +75,7 @@ async function runPhase(args: string[], timingsFile: string | null, ceilingMs: n
74
75
  // bun test's workers and a suite's own subprocesses land
75
76
  const usage = proc.resourceUsage()
76
77
  const cpuMs = usage != null ? Number(usage.cpuTime.user + usage.cpuTime.system) / 1000 : null
77
- return { code, signal: stalled ? null : proc.signalCode ?? null, stalled, out, timings, cpuMs }
78
+ return { code, signal: stalled ? null : signalName(proc.signalCode), stalled, out, timings, cpuMs }
78
79
  }
79
80
 
80
81
  const CPU_PRELOAD = join(import.meta.dir, 'suite-cpu-preload.ts')
@@ -238,39 +239,76 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
238
239
  const p2Ms = p2 == null ? null : Date.now() - p2At
239
240
  const phases = [p1, ...(p2 != null ? [p2] : [])]
240
241
  const ran = phases.reduce((n, p) => n + lastCount(p.out, /Ran (\d+) tests?/g), 0)
241
- const failedTests = phases.reduce((n, p) => n + lastCount(p.out, /^\s*(\d+) fail$/gm), 0)
242
- const errors = phases.reduce((n, p) => n + lastCount(p.out, /^\s*(\d+) errors?$/gm), 0)
243
- const timings = Object.assign({}, ...phases.map((p) => p.timings)) as Record<string, number>
244
242
  const crashed = crashedWorkers(p1.out)
245
- const red = new Set([...phases.flatMap((p) => failedSuites(p.out)), ...crashed.map((c) => c.file)])
246
- const judged = judgeSuites({ timings, tests, tier, red: [...red] })
247
- const slowest = judged.slowest.length > 0 ? ` (slowest: ${judged.slowest.map((t) => `${t.file} ${secs(t.ms)}`).join(', ')})` : ''
248
243
 
249
- // a parallel timing carries every other suite's load, so a suspect
250
- // runs again alone, one process per suspect so its CPU is its own,
251
- // before it can fail the task. One at a time: four alone runs side by
252
- // side each burned about 40% more CPU than one alone (8 cores)
244
+ // a lone run of one suite, in its own process so its CPU is its own. One at a time: four alone runs side
245
+ // by side each burned about 40% more CPU than one alone (8 cores)
253
246
  const aloneRuns: Record<string, AloneRun> = {}
254
- const parallelCpu = phaseCpu.cpu
255
- const parallelCore = Object.fromEntries(judged.over.map((t) => [t.file, toCore(t.file, phaseCpu.work[t.file])]).filter(([, ms]) => ms != null)) as Record<string, number>
256
- const { rerun, cleared: clearedInPhase } = aloneRunsNeeded(judged.over, parallelCpu, budget, load, parallelCore)
257
247
  const aloneAt = Date.now()
258
- const runAlone = async (t: { file: string }, name: string): Promise<AloneRun | null> => {
248
+ const runAlone = async (file: string, name: string, ceiling = ceilingMs): Promise<{ alone: AloneRun | null; phase: Phase }> => {
259
249
  const lines = counted ? join(dir, `${name}.tsv`) : null
260
- const run = await runPhase([...plan.alone, t.file], join(dir, `${name}.json`), ceilingMs, tmp, false, lines, rec)
261
- const wallMs = Object.entries(run.timings).find(([f]) => normSuitePath(f) === t.file)?.[1]
262
- if (wallMs == null) return null
263
- const work = lines != null && existsSync(lines) ? readPhaseCpu(readFileSync(lines, 'utf8'), process.cwd()).work[t.file] : undefined
264
- if (counted && work == null) fallbacks.set(t.file, 'its lone run wrote no counts (a child still alive when it ended, or no line at all)')
265
- const core = toCore(t.file, work)
266
- return { wallMs, cpuMs: run.cpuMs, ...(core != null ? { coreMs: core, childCpuMs: work!.childCpuMs, otherCpuMs: work!.otherCpuMs } : {}) }
250
+ const run = await runPhase([...plan.alone, file], join(dir, `${name}.json`), ceiling, tmp, false, lines, rec)
251
+ const wallMs = Object.entries(run.timings).find(([f]) => normSuitePath(f) === file)?.[1]
252
+ if (wallMs == null) return { alone: null, phase: run }
253
+ const work = lines != null && existsSync(lines) ? readPhaseCpu(readFileSync(lines, 'utf8'), process.cwd()).work[file] : undefined
254
+ if (counted && work == null) fallbacks.set(file, 'its lone run wrote no counts (a child still alive when it ended, or no line at all)')
255
+ const core = toCore(file, work)
256
+ const rate = work != null && work.pCpuMs >= OWN_RATE_MIN_MS ? { rate: work.pInstructions / work.pCpuMs } : {}
257
+ return { alone: { wallMs, cpuMs: run.cpuMs, ...(core != null ? { coreMs: core, childCpuMs: work!.childCpuMs, otherCpuMs: work!.otherCpuMs, ...rate } : {}) }, phase: run }
258
+ }
259
+
260
+ // a suite red in the pooled run of a loaded machine runs again alone, and stays red only when it fails
261
+ // there too: the load read before the run, or after the pool when the machine got busier meanwhile
262
+ const pooledRed = [...new Set([...failedSuites(p1.out), ...crashed.map((c) => c.file)])]
263
+ const during = { load1: Math.max(load.load1, machineLoad().load1), cores: load.cores }
264
+ const asked = redRerunsNeeded({ red: pooledRed, load: during, pooled: parallel && !parallelEmpty, ended: !p1.stalled && p1.signal == null })
265
+ if (asked.note != null) notes.push(asked.note)
266
+ const pooledWhy = failLines(p1.out)
267
+ for (const c of crashed) if (!pooledWhy.has(c.file)) pooledWhy.set(c.file, `its worker crashed: ${c.signal}`)
268
+ const rescued = new Set<string>()
269
+ const rescuedWarns: string[] = []
270
+ for (const [i, file] of asked.rerun.entries()) {
271
+ const ceiling = redRerunCeiling(Object.entries(p1.timings).find(([f]) => normSuitePath(f) === file)?.[1], ceilingMs)
272
+ const { alone, phase } = await runAlone(file, `red-${i}`, ceiling)
273
+ if (!passedAlone(phase)) {
274
+ const again = failLines(phase.out).get(file) ?? (phase.stalled ? `killed at its ${secs(ceiling)} ceiling` : phase.signal != null ? `killed by ${phase.signal}` : `bun exited ${phase.code}`)
275
+ notes.push(`note: ${file} failed in the pooled run and again alone (${again}): its failure stands`)
276
+ continue
277
+ }
278
+ rescued.add(file)
279
+ if (alone != null) aloneRuns[file] = alone
280
+ rescuedWarns.push(rescuedWords(file, pooledWhy.get(file) ?? 'bun named no failure', during))
267
281
  }
282
+ // what the pool counted for the suites that passed alone is not the run's failure
283
+ const off = failuresIn(p1.out, rescued)
284
+ const failedTests = phases.reduce((n, p) => n + lastCount(p.out, /^\s*(\d+) fail$/gm), 0) - off.tests
285
+ const errors = phases.reduce((n, p) => n + lastCount(p.out, /^\s*(\d+) errors?$/gm), 0) - off.errors
286
+ const p1Clean = p1.code === 0 || (rescued.size > 0 && pooledRed.every((f) => rescued.has(f))
287
+ && lastCount(p1.out, /^\s*(\d+) fail$/gm) === off.tests && lastCount(p1.out, /^\s*(\d+) errors?$/gm) === off.errors)
288
+ const timings = Object.assign({}, ...phases.map((p) => p.timings)) as Record<string, number>
289
+ // a crashed worker left no timing: its lone run's stands
290
+ for (const f of rescued) if (!Object.keys(timings).some((k) => normSuitePath(k) === f) && aloneRuns[f] != null) timings[f] = aloneRuns[f]!.wallMs
291
+ const red = new Set([...phases.flatMap((p) => failedSuites(p.out)), ...crashed.map((c) => c.file)].filter((f) => !rescued.has(f)))
292
+ const judged = judgeSuites({ timings, tests, tier, red: [...red] })
293
+ const slowest = judged.slowest.length > 0 ? ` (slowest: ${judged.slowest.map((t) => `${t.file} ${secs(t.ms)}`).join(', ')})` : ''
294
+
295
+ // a parallel timing carries every other suite's load, so a suspect
296
+ // runs again alone before it can fail the task; a suite that already
297
+ // ran alone after a red keeps that run
298
+ // the full tier fails nothing on time, and says what the quick tier's budget would make of this run
299
+ const parallelCpu = phaseCpu.cpu
300
+ const suspects = tier === 'full' ? judgeSuites({ timings, tests, tier: 'quick', red: [...red] }).over : judged.over
301
+ const parallelCore = Object.fromEntries(suspects.map((t) => [t.file, toCore(t.file, phaseCpu.work[t.file])]).filter(([, ms]) => ms != null)) as Record<string, number>
302
+ const need = aloneRunsNeeded(suspects, parallelCpu, budget, load, parallelCore)
303
+ const rerun = tier === 'quick' ? need.rerun : []
304
+ const clearedInPhase = tier === 'quick' ? need.cleared : []
305
+ if (tier === 'full' && cpuFile != null) notes.push(quickTierWords(need.rerun, parallelCpu, parallelCore))
268
306
  for (const [i, t] of rerun.entries()) {
269
- const first = await runAlone(t, `alone-${i}`)
307
+ const first = aloneRuns[t.file] ?? (await runAlone(t.file, `alone-${i}`)).alone
270
308
  if (first == null) continue
271
309
  aloneRuns[t.file] = first
272
310
  if (!retryAlone(t, first, budget, load)) continue
273
- const second = await runAlone(t, `alone-${i}-again`)
311
+ const second = (await runAlone(t.file, `alone-${i}-again`)).alone
274
312
  if (second == null) continue
275
313
  aloneRuns[t.file] = smallerRun(first, second)
276
314
  const charge = (r: AloneRun): string => secs(r.coreMs ?? r.cpuMs ?? r.wallMs)
@@ -290,7 +328,7 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
290
328
  // those are the suites that never finished, not an outside kill
291
329
  const stalledIn = (name: string, p: Phase | null, files: string[]): string | null =>
292
330
  p?.stalled === true ? stallWords(name, ceilingMs, [...new Set([...files, ...interruptedSuites(p.out)])]) : null
293
- const killed = p1.stalled ? [] : crashed.map((c) => `killed by ${c.signal} while running ${c.file} (out of memory, or killed from outside)`)
331
+ const killed = p1.stalled ? [] : crashed.filter((c) => !rescued.has(c.file)).map((c) => `killed by ${c.signal} while running ${c.file} (out of memory, or killed from outside)`)
294
332
  const stalls = [stalledIn('the parallel phase', p1, crashed.map((c) => c.file)), stalledIn('the serial phase', p2, phaseFiles(serialArgs ?? [], rawArgs).filter((a) => p2?.timings[normSuitePath(a)] == null).map(normSuitePath))]
295
333
  for (const line of stalls) if (line != null) killed.unshift(line)
296
334
  if (p1.signal != null) killed.push(`killed by ${p1.signal} during the parallel run (out of memory, or killed from outside)`)
@@ -320,12 +358,14 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
320
358
  const f = normSuitePath(file)
321
359
  return {
322
360
  at, file: f, ms: alone.get(f) ?? ms, status: red.has(f) ? 'fail' as const : 'pass' as const, tier, budgetMs: budget, check, unit,
323
- cpuMs: cpuOf(f), phase: phaseOf(f), phaseMs: ms, failLine: red.has(f) ? why.get(f) ?? '' : '',
361
+ cpuMs: cpuOf(f), phase: phaseOf(f), phaseMs: ms,
362
+ // a pass that failed in the pool keeps that failure: a suite that needs its lone run again and again shows as such
363
+ failLine: red.has(f) ? why.get(f) ?? '' : rescued.has(f) ? `passed alone at load ${during.load1.toFixed(1)} on ${during.cores} cores after failing in the pooled run: ${pooledWhy.get(f) ?? ''}` : '',
324
364
  }
325
365
  }), {
326
366
  at, check, unit, tier, wallMs: Date.now() - t0, setupMs, workers: parallel ? workers ?? 0 : 0, files: Object.keys(timings).length,
327
367
  parallelMs: p1Ms, parallelCpuMs: p1.cpuMs, serialMs: p2Ms, serialCpuMs: p2?.cpuMs ?? null, serialFiles,
328
- aloneMs, aloneFiles: rerun.length, load1: load.load1, cores: load.cores,
368
+ aloneMs, aloneFiles: new Set([...asked.rerun, ...rerun.map((t) => t.file)]).size, load1: load.load1, cores: load.cores,
329
369
  })
330
370
  if (unrecorded != null) notes.push(unrecorded)
331
371
  // never blocking: a suite that got faster must not stop a release
@@ -333,6 +373,7 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
333
373
 
334
374
  for (const n of notes) console.log(n)
335
375
  for (const s of stale) console.log(s)
376
+ for (const w of rescuedWarns) console.log(w)
336
377
  // the root of a repo with units leaves every unit dir to its own check,
337
378
  // so finding no file of its own is a finding, not a failure
338
379
  if (unit === 'root' && ran === 0 && failedTests === 0 && killed.length === 0 && /\b0 test files matching\b|did not match any test files/.test(p1.out)) {
@@ -345,10 +386,10 @@ async function runSuites(argv: string[], ctx: SelectCtx): Promise<number> {
345
386
  const fails: string[] = [
346
387
  ...killed.map((k) => `FAIL: ${k}`),
347
388
  ...(vacuous ? ['FAIL: ran 0 tests: a suite with no test in it proves nothing, write a real one'] : []),
348
- ...(!vacuous && (failedTests > 0 || (phases.some((p) => p.code !== 0 && p.signal == null) && killed.length === 0))
349
- ? [`FAIL: ${redWords({ failedTests, errors, ran, slowest, out: phases.map((p) => p.out).join('\n') })}`] : []),
389
+ ...(!vacuous && (failedTests > 0 || (phases.some((p) => p.code !== 0 && p.signal == null && !(p === p1 && p1Clean)) && killed.length === 0))
390
+ ? [`FAIL: ${redWords({ failedTests, errors, ran, slowest, out: phases.map((p) => p.out).join('\n'), passedAlone: rescued })}`] : []),
350
391
  ...(over.length > 0
351
- ? [`FAIL: ${over.length} suite(s) over the ${budget}ms budget: ${over.map((c) => overWords(c, load, budget)).join(', ')} (run alone, load ${load.load1.toFixed(1)} on ${load.cores} cores before the run). Make each fast, or declare it in ${declaredIn}.slow with what it catches and why it cannot be fast`]
392
+ ? [`FAIL: ${over.length} suite(s) over the ${budget}ms budget: ${over.map((c) => overWords(c, load, budget, instrPerMs)).join(', ')} (run alone, load ${load.load1.toFixed(1)} on ${load.cores} cores before the run). Make each fast, or declare it in ${declaredIn}.slow with what it catches and why it cannot be fast`]
352
393
  : []),
353
394
  ]
354
395
  // the most actionable failure prints LAST, where the gate reads its headline
@@ -70,7 +70,8 @@ export function runWikiLint(o: WikiScanOpts): number {
70
70
  return 1
71
71
  }
72
72
  // a changelog or a journal names what was true then: a path that is gone holds when git once had it
73
- const dangling = r.dangling.filter((d) => !(isHistoryFile(d.from) && onceAPath(cfg.root, d.token)))
73
+ // a heading it names may have been renamed since: the page is judged by its own ref, the anchor is left as written
74
+ const dangling = r.dangling.filter((d) => !(isHistoryFile(d.from) && (d.token.includes('#') || onceAPath(cfg.root, d.token))))
74
75
  const held = r.dangling.length - dangling.length
75
76
  for (const f of r.orphans) say(`FAIL orphan: ${f} — unreachable from ${r.index}; link it or delete it`)
76
77
  for (const d of dangling) say(`FAIL dangling: ${d.from} → ${d.token} — target not found`)