@descent-vtt/spec-harness 0.10.1 → 0.11.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAoC,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAyB,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EACL,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,IAAI,EACJ,UAAU,EACV,OAAO,EAIP,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAE9B,iIAAiI;AACjI,MAAM,CAAC,KA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E,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACxK,QAAQ;SACT,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AACrD,CAAC","sourcesContent":["/**\n * The commands that read a round: context, audit, escalate, rule, rulings\n * and probe. Each resolves the brief, asks `round.ts` for the facts and\n * prints them; exit codes follow the family contract.\n */\n\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\nimport { describeMeasured } from './audit.js';\nimport { briefIdFromBranch } from './branch.js';\nimport { findActive } from './briefs.js';\nimport { formatFindings } from './formats.js';\nimport { readJUnit } from './junit.js';\nimport { classify, readProbes, renderEvidence, verdictOf, type ProbeResult, type ProbeSpec } from './probe.js';\nimport { createReader } from './reader.js';\nimport {\n buildContext,\n checkRulings,\n briefText,\n listEscalations,\n raiseEscalation,\n recordRuling,\n resolveBase,\n runAudit,\n} from './round.js';\nimport { renderMemo, type EscalationOption } from './rulings.js';\nimport { runCommand, withWorktree } from './sandbox.js';\nimport type { BriefRow, Finding } from './types.js';\nimport {\n describeActive,\n EXIT_ERROR,\n EXIT_FAILED,\n EXIT_OK,\n json,\n UsageError,\n version,\n type CliIO,\n type Options,\n type Workspace,\n openWorkspace,\n} from './workspace.js';\n\nconst reader = createReader();\n\n/** The brief a command acts on: a positional id, else the active one. A command that needs one and has none is a usage error. */\nexport async function targetBrief(workspace: Workspace, options: Options, io: CliIO, positional: string | undefined): Promise<{ brief: BriefRow; briefs: BriefRow[] }> {\n const briefs = await workspace.siblings.briefs();\n const fromBranch = briefIdFromBranch(workspace.config.branches, workspace.branch);\n const active = findActive(briefs, { flag: positional ?? options.brief, environment: io.env['SPEC_BRIEF'], branch: fromBranch });\n const { brief, note, problem } = describeActive(active);\n if (problem !== null) throw new UsageError(problem);\n if (brief === null) throw new UsageError(note);\n return { brief, briefs };\n}\n\nconst MARK: Record<Finding['severity'], string> = { error: 'error ', warning: 'warning', note: 'note ' };\n\nfunction printFindings(io: CliIO, findings: readonly Finding[]): void {\n for (const finding of findings) {\n const where = finding.file === undefined ? '' : `${finding.file}${finding.line === undefined ? '' : `:${finding.line}`} `;\n io.stdout.write(`${MARK[finding.severity]} ${where}${finding.message} ${finding.rule}\\n ${finding.hint}\\n`);\n }\n}\n\n/* ----------------------------------------------------------------- context */\n\nexport async function contextCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief, briefs } = await targetBrief(workspace, options, io, options.positionals[0]);\n const packet = await buildContext(workspace, brief, briefs, reader, options.base);\n if (options.format === 'json') {\n io.stdout.write(\n json('context', {\n brief: brief.id,\n markdown: packet.markdown,\n included: packet.included,\n omitted: packet.omitted,\n unresolved: packet.unresolved,\n unclosedFrontMatter: packet.unclosedFrontMatter,\n unreadableFrontMatter: packet.unreadableFrontMatter,\n unreadableScope: packet.unreadableScope,\n unreadableProtections: packet.unreadableProtections,\n unreadableRulingPaths: packet.unreadableRulingPaths,\n }),\n );\n } else {\n io.stdout.write(packet.markdown);\n }\n return EXIT_OK;\n}\n\n/* ------------------------------------------------------------------- audit */\n\nexport async function auditCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const result = await runAudit(workspace, brief, reader, options.base);\n const { counts, findings, measured } = result.report;\n if (options.format === 'json') {\n io.stdout.write(\n json('audit', {\n ok: counts.error === 0 && (!options.strict || counts.warning === 0),\n brief: brief.id,\n base: result.base.kind === 'resolved' ? { ref: result.base.ref, mergeBase: result.base.mergeBase, head: result.base.head } : null,\n counts,\n measured,\n findings,\n dependencies: result.dependencies,\n installScripts: result.installScripts,\n }),\n );\n } else if (options.format === 'pretty') {\n io.stdout.write(`audit of brief ${brief.id}${result.base.kind === 'resolved' ? ` from ${result.base.ref} (${result.base.mergeBase.slice(0, 12)})` : ''}\\n\\n`);\n printFindings(io, findings);\n // The counts stay the last line, where a script reads them.\n io.stdout.write(`\\n${describeMeasured(measured)}\\n${counts.error} error(s), ${counts.warning} warning(s), ${counts.note} note(s)\\n`);\n } else {\n io.stdout.write(formatFindings(options.format, findings, { file: brief.file, version: version(), summary: describeMeasured(measured) }));\n }\n return counts.error > 0 || (options.strict && counts.warning > 0) ? EXIT_FAILED : EXIT_OK;\n}\n\n/* -------------------------------------------------------------- escalation */\n\nfunction parseOption(raw: string): EscalationOption {\n const colon = raw.indexOf(':');\n return colon < 0 ? { label: raw.trim(), consequence: '' } : { label: raw.slice(0, colon).trim(), consequence: raw.slice(colon + 1).trim() };\n}\n\nexport async function escalateCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n if (options.list) {\n const waiting = await listEscalations(workspace);\n if (options.format === 'json') io.stdout.write(json('escalate', { waiting }));\n else if (waiting.length === 0) io.stdout.write('no escalation is waiting\\n');\n else for (const request of waiting) io.stdout.write(`${request.id} brief ${request.brief} ${request.paths.join(', ')} ${request.reason.split('\\n')[0]}\\n`);\n return EXIT_OK;\n }\n if (options.show !== undefined) {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === options.show);\n if (request === undefined) throw new UsageError(`no escalation \"${options.show}\" is waiting`);\n io.stdout.write(options.format === 'json' ? json('escalate', { request }) : renderMemo(request));\n return EXIT_OK;\n }\n if (options.paths.length === 0 || options.reason === undefined) {\n throw new UsageError('escalate needs --path <file> (repeatable) and --reason <why>; or --list, or --show <id>');\n }\n const { brief } = await targetBrief(workspace, options, io, undefined);\n const { request, memo } = await raiseEscalation(workspace, brief, {\n paths: options.paths,\n reason: options.reason,\n options: options.options.map(parseOption),\n recommendation: options.recommend ?? null,\n });\n io.stdout.write(options.format === 'json' ? json('escalate', { request, memo }) : memo);\n // Exit 1: the round is waiting on a person, which a caller must not read as done.\n return EXIT_FAILED;\n}\n\nexport async function ruleCommand(options: Options, io: CliIO): Promise<number> {\n const id = options.positionals[0];\n if (id === undefined) throw new UsageError('rule needs the escalation id, such as E-012-1');\n if (options.allow === options.deny) throw new UsageError('rule needs exactly one of --allow or --deny');\n if (options.note === undefined || options.note.trim() === '') throw new UsageError('rule needs --note: what exactly is allowed, or why not');\n const workspace = await openWorkspace(options, io);\n const recorded = await recordRuling(workspace, id, options.allow ? 'allow' : 'deny', options.note, reader);\n const command = `git commit -S -m \"ruling ${recorded.id}: ${options.allow ? 'allow' : 'deny'}\" -- ${recorded.file}`;\n if (options.format === 'json') {\n io.stdout.write(json('rule', { ruling: recorded.id, file: recorded.file, row: recorded.row, commit: command }));\n } else {\n io.stdout.write(`${recorded.file} now holds ruling ${recorded.id}:\\n\\n ${recorded.row}\\n\\nIt counts once you commit it signed, with a key the base branch's allowed signers list:\\n\\n ${command}\\n`);\n }\n return EXIT_OK;\n}\n\nexport async function rulingsCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const base = await resolveBase(workspace, options.base);\n const check = await checkRulings(workspace, brief, await briefText(workspace, brief), reader, base);\n if (options.format === 'json') {\n io.stdout.write(json('rulings', { brief: brief.id, rows: check.rows, verified: check.verified, unverified: check.unverified, problems: check.problems }));\n } else {\n if (check.rows.length === 0) io.stdout.write(`brief ${brief.id} holds no ruling\\n`);\n for (const row of check.rows) {\n const verified = check.verified.find((ruling) => ruling.id === row.id);\n const unverified = check.unverified.find((ruling) => ruling.id === row.id);\n // An allow row that does not verify is among the unverified, with its\n // reason, so the fallback for none is equivalent to its mutants.\n const state = row.decision === 'deny' ? 'refused' : verified !== undefined ? `signed by ${verified.signer}` : `not verified: ${unverified?.reason ?? ''}`;\n io.stdout.write(`${row.id} ${row.decision} ${row.paths.join(', ')} ${state}\\n`);\n }\n printFindings(io, check.problems);\n }\n return check.unverified.length > 0 || check.problems.length > 0 ? EXIT_FAILED : EXIT_OK;\n}\n\n/* ------------------------------------------------------------------- probe */\n\nasync function runProbe(directory: string, probe: ProbeSpec, runs: number, timeout: number): Promise<ProbeResult['runs']> {\n const classified = [];\n for (let i = 0; i < runs; i += 1) {\n const report = probe.junit === null ? null : join(directory, probe.junit);\n if (report !== null) await rm(report, { force: true });\n const run = await runCommand(probe.run, directory, timeout);\n // existsSync answers false for null, so the null check is there for the\n // type, and its mutant is equivalent.\n const junit = report === null || !existsSync(report) ? null : readJUnit(await readFile(report, 'utf8'));\n classified.push(classify(probe, { exitCode: run.exitCode, output: run.output, junit }));\n }\n return classified;\n}\n\nexport async function probeCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const text = await briefText(workspace, brief);\n const set = readProbes(reader.codeBlocks(text));\n if (set.problems.length > 0) {\n for (const problem of set.problems) io.stderr.write(`spec-harness: ${brief.file}:${problem.line}: ${problem.message}\\n`);\n return EXIT_ERROR;\n }\n const probes = set.probes.filter((probe) => options.id === undefined || probe.id === options.id);\n if (probes.length === 0) {\n io.stdout.write(`brief ${brief.id} declares no probe${options.id === undefined ? '' : ` named ${options.id}`}\\n`);\n return options.id === undefined ? EXIT_OK : EXIT_ERROR;\n }\n const base = await resolveBase(workspace, options.base);\n if (base.kind === 'unresolved') throw new UsageError(base.reason);\n const at = options.at ?? (base.mergeBase === base.head ? 'base' : 'both');\n const results: ProbeResult[] = [];\n const measure = async (label: 'base' | 'head', commit: string, expected: 'red' | 'green'): Promise<void> => {\n await withWorktree(workspace.root, commit, async (directory) => {\n for (const file of set.files) {\n await mkdir(dirname(join(directory, file.path)), { recursive: true });\n await writeFile(join(directory, file.path), file.content.endsWith('\\n') ? file.content : `${file.content}\\n`);\n }\n const setups = [...new Set(probes.map((probe) => probe.setup).filter((setup): setup is string => setup !== null))];\n for (const setup of setups) {\n const run = await runCommand(setup, directory, workspace.config.probes.timeout);\n if (run.exitCode !== 0) throw new UsageError(`the probe setup \"${setup}\" failed at ${label}:\\n${run.output.slice(-2000)}`);\n }\n for (const probe of probes) {\n const runs = await runProbe(directory, probe, probe.runs ?? workspace.config.probes.runs, probe.timeout ?? workspace.config.probes.timeout);\n results.push({ probe, at: label, commit, expected, runs, verdict: verdictOf(expected, runs) });\n }\n });\n };\n if (at === 'base' || at === 'both') await measure('base', base.mergeBase, 'red');\n if (at === 'head' || at === 'both') await measure('head', base.head, 'green');\n const evidence = renderEvidence(results, set.hash, new Date().toISOString().slice(0, 10));\n const failed = results.filter((result) => result.verdict !== (result.expected === 'red' ? 'measured' : 'fixed'));\n if (options.format === 'json') {\n io.stdout.write(\n json('probe', {\n ok: failed.length === 0,\n brief: brief.id,\n hash: set.hash,\n results: results.map((result) => ({ id: result.probe.id, at: result.at, commit: result.commit, expected: result.expected, verdict: result.verdict, runs: result.runs })),\n evidence,\n }),\n );\n } else {\n io.stdout.write(`${evidence}\\n`);\n }\n return failed.length === 0 ? EXIT_OK : EXIT_FAILED;\n}\n"]}
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAA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AAC,IAAI;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;YACxK,QAAQ;SACT,CAAC,CACH,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,IAAI,CAAC,CAAC;QACjC,wEAAwE;QACxE,qEAAqE;QACrE,8DAA8D;QAC9D,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;AACrD,CAAC","sourcesContent":["/**\n * The commands that read a round: context, audit, escalate, rule, rulings\n * and probe. Each resolves the brief, asks `round.ts` for the facts and\n * prints them; exit codes follow the family contract.\n */\n\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\n\nimport { describeMeasured } from './audit.js';\nimport { briefIdFromBranch } from './branch.js';\nimport { findActive } from './briefs.js';\nimport { formatFindings } from './formats.js';\nimport { readJUnit } from './junit.js';\nimport { classify, endOfOutput, readProbes, renderEvidence, renderUnexplained, verdictOf, type ProbeResult, type ProbeSpec } from './probe.js';\nimport { createReader } from './reader.js';\nimport {\n buildContext,\n checkRulings,\n briefText,\n listEscalations,\n raiseEscalation,\n recordRuling,\n resolveBase,\n runAudit,\n} from './round.js';\nimport { renderMemo, type EscalationOption } from './rulings.js';\nimport { runCommand, withWorktree } from './sandbox.js';\nimport type { BriefRow, Finding } from './types.js';\nimport {\n describeActive,\n EXIT_ERROR,\n EXIT_FAILED,\n EXIT_OK,\n json,\n UsageError,\n version,\n type CliIO,\n type Options,\n type Workspace,\n openWorkspace,\n} from './workspace.js';\n\nconst reader = createReader();\n\n/** The brief a command acts on: a positional id, else the active one. A command that needs one and has none is a usage error. */\nexport async function targetBrief(workspace: Workspace, options: Options, io: CliIO, positional: string | undefined): Promise<{ brief: BriefRow; briefs: BriefRow[] }> {\n const briefs = await workspace.siblings.briefs();\n const fromBranch = briefIdFromBranch(workspace.config.branches, workspace.branch);\n const active = findActive(briefs, { flag: positional ?? options.brief, environment: io.env['SPEC_BRIEF'], branch: fromBranch });\n const { brief, note, problem } = describeActive(active);\n if (problem !== null) throw new UsageError(problem);\n if (brief === null) throw new UsageError(note);\n return { brief, briefs };\n}\n\nconst MARK: Record<Finding['severity'], string> = { error: 'error ', warning: 'warning', note: 'note ' };\n\nfunction printFindings(io: CliIO, findings: readonly Finding[]): void {\n for (const finding of findings) {\n const where = finding.file === undefined ? '' : `${finding.file}${finding.line === undefined ? '' : `:${finding.line}`} `;\n io.stdout.write(`${MARK[finding.severity]} ${where}${finding.message} ${finding.rule}\\n ${finding.hint}\\n`);\n }\n}\n\n/* ----------------------------------------------------------------- context */\n\nexport async function contextCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief, briefs } = await targetBrief(workspace, options, io, options.positionals[0]);\n const packet = await buildContext(workspace, brief, briefs, reader, options.base);\n if (options.format === 'json') {\n io.stdout.write(\n json('context', {\n brief: brief.id,\n markdown: packet.markdown,\n included: packet.included,\n omitted: packet.omitted,\n unresolved: packet.unresolved,\n unclosedFrontMatter: packet.unclosedFrontMatter,\n unreadableFrontMatter: packet.unreadableFrontMatter,\n unreadableScope: packet.unreadableScope,\n unreadableProtections: packet.unreadableProtections,\n unreadableRulingPaths: packet.unreadableRulingPaths,\n }),\n );\n } else {\n io.stdout.write(packet.markdown);\n }\n return EXIT_OK;\n}\n\n/* ------------------------------------------------------------------- audit */\n\nexport async function auditCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const result = await runAudit(workspace, brief, reader, options.base);\n const { counts, findings, measured } = result.report;\n if (options.format === 'json') {\n io.stdout.write(\n json('audit', {\n ok: counts.error === 0 && (!options.strict || counts.warning === 0),\n brief: brief.id,\n base: result.base.kind === 'resolved' ? { ref: result.base.ref, mergeBase: result.base.mergeBase, head: result.base.head } : null,\n counts,\n measured,\n findings,\n dependencies: result.dependencies,\n installScripts: result.installScripts,\n }),\n );\n } else if (options.format === 'pretty') {\n io.stdout.write(`audit of brief ${brief.id}${result.base.kind === 'resolved' ? ` from ${result.base.ref} (${result.base.mergeBase.slice(0, 12)})` : ''}\\n\\n`);\n printFindings(io, findings);\n // The counts stay the last line, where a script reads them.\n io.stdout.write(`\\n${describeMeasured(measured)}\\n${counts.error} error(s), ${counts.warning} warning(s), ${counts.note} note(s)\\n`);\n } else {\n io.stdout.write(formatFindings(options.format, findings, { file: brief.file, version: version(), summary: describeMeasured(measured) }));\n }\n return counts.error > 0 || (options.strict && counts.warning > 0) ? EXIT_FAILED : EXIT_OK;\n}\n\n/* -------------------------------------------------------------- escalation */\n\nfunction parseOption(raw: string): EscalationOption {\n const colon = raw.indexOf(':');\n return colon < 0 ? { label: raw.trim(), consequence: '' } : { label: raw.slice(0, colon).trim(), consequence: raw.slice(colon + 1).trim() };\n}\n\nexport async function escalateCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n if (options.list) {\n const waiting = await listEscalations(workspace);\n if (options.format === 'json') io.stdout.write(json('escalate', { waiting }));\n else if (waiting.length === 0) io.stdout.write('no escalation is waiting\\n');\n else for (const request of waiting) io.stdout.write(`${request.id} brief ${request.brief} ${request.paths.join(', ')} ${request.reason.split('\\n')[0]}\\n`);\n return EXIT_OK;\n }\n if (options.show !== undefined) {\n const request = (await listEscalations(workspace)).find((candidate) => candidate.id === options.show);\n if (request === undefined) throw new UsageError(`no escalation \"${options.show}\" is waiting`);\n io.stdout.write(options.format === 'json' ? json('escalate', { request }) : renderMemo(request));\n return EXIT_OK;\n }\n if (options.paths.length === 0 || options.reason === undefined) {\n throw new UsageError('escalate needs --path <file> (repeatable) and --reason <why>; or --list, or --show <id>');\n }\n const { brief } = await targetBrief(workspace, options, io, undefined);\n const { request, memo } = await raiseEscalation(workspace, brief, {\n paths: options.paths,\n reason: options.reason,\n options: options.options.map(parseOption),\n recommendation: options.recommend ?? null,\n });\n io.stdout.write(options.format === 'json' ? json('escalate', { request, memo }) : memo);\n // Exit 1: the round is waiting on a person, which a caller must not read as done.\n return EXIT_FAILED;\n}\n\nexport async function ruleCommand(options: Options, io: CliIO): Promise<number> {\n const id = options.positionals[0];\n if (id === undefined) throw new UsageError('rule needs the escalation id, such as E-012-1');\n if (options.allow === options.deny) throw new UsageError('rule needs exactly one of --allow or --deny');\n if (options.note === undefined || options.note.trim() === '') throw new UsageError('rule needs --note: what exactly is allowed, or why not');\n const workspace = await openWorkspace(options, io);\n const recorded = await recordRuling(workspace, id, options.allow ? 'allow' : 'deny', options.note, reader);\n const command = `git commit -S -m \"ruling ${recorded.id}: ${options.allow ? 'allow' : 'deny'}\" -- ${recorded.file}`;\n if (options.format === 'json') {\n io.stdout.write(json('rule', { ruling: recorded.id, file: recorded.file, row: recorded.row, commit: command }));\n } else {\n io.stdout.write(`${recorded.file} now holds ruling ${recorded.id}:\\n\\n ${recorded.row}\\n\\nIt counts once you commit it signed, with a key the base branch's allowed signers list:\\n\\n ${command}\\n`);\n }\n return EXIT_OK;\n}\n\nexport async function rulingsCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const base = await resolveBase(workspace, options.base);\n const check = await checkRulings(workspace, brief, await briefText(workspace, brief), reader, base);\n if (options.format === 'json') {\n io.stdout.write(json('rulings', { brief: brief.id, rows: check.rows, verified: check.verified, unverified: check.unverified, problems: check.problems }));\n } else {\n if (check.rows.length === 0) io.stdout.write(`brief ${brief.id} holds no ruling\\n`);\n for (const row of check.rows) {\n const verified = check.verified.find((ruling) => ruling.id === row.id);\n const unverified = check.unverified.find((ruling) => ruling.id === row.id);\n // An allow row that does not verify is among the unverified, with its\n // reason, so the fallback for none is equivalent to its mutants.\n const state = row.decision === 'deny' ? 'refused' : verified !== undefined ? `signed by ${verified.signer}` : `not verified: ${unverified?.reason ?? ''}`;\n io.stdout.write(`${row.id} ${row.decision} ${row.paths.join(', ')} ${state}\\n`);\n }\n printFindings(io, check.problems);\n }\n return check.unverified.length > 0 || check.problems.length > 0 ? EXIT_FAILED : EXIT_OK;\n}\n\n/* ------------------------------------------------------------------- probe */\n\n/**\n * What is said of a command answered at its timeout with its output still\n * held: of a run, in its evidence, and of a `setup`, in why the probe\n * stopped. The timeout stopped what it could reach, and what holds the\n * output is not that: it runs on until it ends or a person ends it, and the\n * person is the one who can find it (ADR-0003).\n */\nconst LEFT_RUNNING = ', and something it started was left running, holding its output';\n\nasync function runProbe(directory: string, probe: ProbeSpec, runs: number, timeout: number): Promise<ProbeResult['runs']> {\n const classified = [];\n for (let i = 0; i < runs; i += 1) {\n const report = probe.junit === null ? null : join(directory, probe.junit);\n if (report !== null) await rm(report, { force: true });\n const run = await runCommand(probe.run, directory, timeout);\n // existsSync answers false for null, so the null check is there for the\n // type, and its mutant is equivalent.\n const junit = report === null || !existsSync(report) ? null : readJUnit(await readFile(report, 'utf8'));\n const judged = classify(probe, { exitCode: run.exitCode, output: run.output, junit });\n // Only a run stopped at its timeout is answered so, and this follows\n // what `classify` says of one.\n classified.push(run.outputHeld ? { ...judged, detail: `${judged.detail}${LEFT_RUNNING}` } : judged);\n }\n return classified;\n}\n\nexport async function probeCommand(options: Options, io: CliIO): Promise<number> {\n const workspace = await openWorkspace(options, io);\n const { brief } = await targetBrief(workspace, options, io, options.positionals[0]);\n const text = await briefText(workspace, brief);\n const set = readProbes(reader.codeBlocks(text));\n if (set.problems.length > 0) {\n for (const problem of set.problems) io.stderr.write(`spec-harness: ${brief.file}:${problem.line}: ${problem.message}\\n`);\n return EXIT_ERROR;\n }\n const probes = set.probes.filter((probe) => options.id === undefined || probe.id === options.id);\n if (probes.length === 0) {\n io.stdout.write(`brief ${brief.id} declares no probe${options.id === undefined ? '' : ` named ${options.id}`}\\n`);\n return options.id === undefined ? EXIT_OK : EXIT_ERROR;\n }\n const base = await resolveBase(workspace, options.base);\n if (base.kind === 'unresolved') throw new UsageError(base.reason);\n const at = options.at ?? (base.mergeBase === base.head ? 'base' : 'both');\n const results: ProbeResult[] = [];\n const measure = async (label: 'base' | 'head', commit: string, expected: 'red' | 'green'): Promise<void> => {\n await withWorktree(workspace.root, commit, async (directory) => {\n for (const file of set.files) {\n await mkdir(dirname(join(directory, file.path)), { recursive: true });\n await writeFile(join(directory, file.path), file.content.endsWith('\\n') ? file.content : `${file.content}\\n`);\n }\n const setups = [...new Set(probes.map((probe) => probe.setup).filter((setup): setup is string => setup !== null))];\n for (const setup of setups) {\n const timeout = workspace.config.probes.timeout;\n const run = await runCommand(setup, directory, timeout);\n // A setup stopped at its timeout has no exit code to have failed by,\n // and may have printed nothing: how long it was given is the reason.\n const how = run.exitCode === null ? `was stopped after ${timeout} seconds` : 'failed';\n if (run.exitCode !== 0) throw new UsageError(`the probe setup \"${setup}\" ${how} at ${label}${run.outputHeld ? LEFT_RUNNING : ''}:\\n${endOfOutput(run.output)}`);\n }\n for (const probe of probes) {\n const runs = await runProbe(directory, probe, probe.runs ?? workspace.config.probes.runs, probe.timeout ?? workspace.config.probes.timeout);\n results.push({ probe, at: label, commit, expected, runs, verdict: verdictOf(expected, runs) });\n }\n });\n };\n if (at === 'base' || at === 'both') await measure('base', base.mergeBase, 'red');\n if (at === 'head' || at === 'both') await measure('head', base.head, 'green');\n const evidence = renderEvidence(results, set.hash, new Date().toISOString().slice(0, 10));\n const failed = results.filter((result) => result.verdict !== (result.expected === 'red' ? 'measured' : 'fixed'));\n if (options.format === 'json') {\n io.stdout.write(\n json('probe', {\n ok: failed.length === 0,\n brief: brief.id,\n hash: set.hash,\n results: results.map((result) => ({ id: result.probe.id, at: result.at, commit: result.commit, expected: result.expected, verdict: result.verdict, runs: result.runs })),\n evidence,\n }),\n );\n } else {\n io.stdout.write(`${evidence}\\n`);\n // On the standard error, beside the table and never in it: the table is\n // what a brief records and a script reads. The JSON document has the\n // same as a field of each such run, and so says nothing here.\n io.stderr.write(renderUnexplained(results));\n }\n return failed.length === 0 ? EXIT_OK : EXIT_FAILED;\n}\n"]}
package/dist/probe.d.ts CHANGED
@@ -78,8 +78,55 @@ export interface Classified {
78
78
  readonly outcome: RunOutcome;
79
79
  /** The evidence: the line or the message that matched, or what was missing. */
80
80
  readonly detail: string;
81
+ /**
82
+ * The end of what the command printed, as {@link endOfOutput} gives it, on
83
+ * a run that proves nothing: it failed for another reason, was stopped at
84
+ * its timeout, or left no report that can be read. `detail` says only that
85
+ * the reason was not the probe's; the reason itself is the command's to
86
+ * give, and this is where it gave it. A red or a green run has none.
87
+ */
88
+ readonly output?: string;
81
89
  }
82
- /** What one run showed, against what the probe declares. */
90
+ /**
91
+ * The environment a probe's commands run in: the person's own, with `CI` set
92
+ * as a pipeline sets it, and with npm told to fetch nothing for a command
93
+ * unless the person's environment already says what npm may fetch.
94
+ *
95
+ * A probe's command runs where nothing is installed until its `setup`
96
+ * installs it, with no terminal to be asked on. There `npx <name>` fetches
97
+ * the registry's package of that name and runs it, unasked, and with
98
+ * `npm_config_yes=false` it stops and names the package instead (ADR-0007).
99
+ * A person who set the variable, in any case, has said what they want, and
100
+ * it is left as they set it. Set and empty says nothing: npm fetched with it
101
+ * as with no variable, so the setting is made. The empty one is taken out
102
+ * first and not left beside it: on Windows a name is one variable whatever
103
+ * its case, and of two spellings a command is handed one, the upper case
104
+ * before the lower, which would be the empty one.
105
+ */
106
+ export declare function probeEnvironment(own: Readonly<Record<string, string | undefined>>): Record<string, string | undefined>;
107
+ /**
108
+ * The end of what a command printed, as a person is shown it: the last 2,000
109
+ * characters, less what is there for a terminal to obey rather than for a
110
+ * person to read. Written out as it came, an escape sequence in it moves the
111
+ * cursor, clears lines already written or renames the window.
112
+ *
113
+ * - A carriage return ends a line as a line feed does, alone or in front of
114
+ * one: alone it would have the next line written over the last.
115
+ * - A colour is dropped. A command told to colour what it prints, as
116
+ * `npm_config_color=always` tells npm, does so with nobody at a terminal
117
+ * to see it, and a colour says nothing in a report.
118
+ * - Every other control character but the line feed and the tab is written
119
+ * as its escape, as JSON writes it, so that it shows and does nothing.
120
+ *
121
+ * Space at the end is dropped before the 2,000 are counted, so that blank
122
+ * lines do not take the place of the reason above them. Blank lines at the
123
+ * start of what is left are dropped after: `npm run` opens with one.
124
+ */
125
+ export declare function endOfOutput(output: string): string;
126
+ /**
127
+ * What one run showed, against what the probe declares, with the end of the
128
+ * command's output on a run that is neither red nor green.
129
+ */
83
130
  export declare function classify(spec: ProbeSpec, run: ProbeRun): Classified;
84
131
  export type Verdict =
85
132
  /** Red at every run where red was expected: the defect is measured. */
@@ -106,3 +153,14 @@ export interface ProbeResult {
106
153
  }
107
154
  /** The evidence a brief records: a table a reader can check, and what it was measured with. */
108
155
  export declare function renderEvidence(results: readonly ProbeResult[], hash: string, date: string): string;
156
+ /**
157
+ * What a person is told, beside the table, of each result with a run that
158
+ * proves nothing: which run, what it showed, and the end of what its command
159
+ * printed, where the reason is. The first such run of a result speaks for the
160
+ * rest, as the first run's evidence fills the table's cell. A result whose
161
+ * runs are all red or green has nothing to add to its verdict.
162
+ *
163
+ * It is for the standard error: the table is what a brief records and what a
164
+ * script reads, and a command's output is no part of either.
165
+ */
166
+ export declare function renderUnexplained(results: readonly ProbeResult[]): string;
package/dist/probe.js CHANGED
@@ -137,12 +137,77 @@ export function readProbes(blocks) {
137
137
  }
138
138
  return { probes, files, problems, hash: `sha256-${hash.digest('hex')}` };
139
139
  }
140
+ /**
141
+ * npm's `yes` setting as an environment spells it. npm reads the name in any
142
+ * case: `NPM_CONFIG_YES` and `Npm_Config_Yes` did what `npm_config_yes` does
143
+ * under npm 10.9.9, 11.16.0, 11.20.0 and 12.2.0 (ADR-0007).
144
+ */
145
+ const NPM_YES = /^npm_config_yes$/i;
146
+ /**
147
+ * The environment a probe's commands run in: the person's own, with `CI` set
148
+ * as a pipeline sets it, and with npm told to fetch nothing for a command
149
+ * unless the person's environment already says what npm may fetch.
150
+ *
151
+ * A probe's command runs where nothing is installed until its `setup`
152
+ * installs it, with no terminal to be asked on. There `npx <name>` fetches
153
+ * the registry's package of that name and runs it, unasked, and with
154
+ * `npm_config_yes=false` it stops and names the package instead (ADR-0007).
155
+ * A person who set the variable, in any case, has said what they want, and
156
+ * it is left as they set it. Set and empty says nothing: npm fetched with it
157
+ * as with no variable, so the setting is made. The empty one is taken out
158
+ * first and not left beside it: on Windows a name is one variable whatever
159
+ * its case, and of two spellings a command is handed one, the upper case
160
+ * before the lower, which would be the empty one.
161
+ */
162
+ export function probeEnvironment(own) {
163
+ const spelled = Object.keys(own).filter((name) => NPM_YES.test(name));
164
+ if (spelled.some((name) => Boolean(own[name])))
165
+ return { ...own, CI: '1' };
166
+ const rest = Object.fromEntries(Object.entries(own).filter(([name]) => !spelled.includes(name)));
167
+ return { ...rest, CI: '1', npm_config_yes: 'false' };
168
+ }
169
+ /** How many characters of the end of a command's output a person is shown. */
170
+ const SHOWN = 2000;
171
+ /**
172
+ * The end of what a command printed, as a person is shown it: the last 2,000
173
+ * characters, less what is there for a terminal to obey rather than for a
174
+ * person to read. Written out as it came, an escape sequence in it moves the
175
+ * cursor, clears lines already written or renames the window.
176
+ *
177
+ * - A carriage return ends a line as a line feed does, alone or in front of
178
+ * one: alone it would have the next line written over the last.
179
+ * - A colour is dropped. A command told to colour what it prints, as
180
+ * `npm_config_color=always` tells npm, does so with nobody at a terminal
181
+ * to see it, and a colour says nothing in a report.
182
+ * - Every other control character but the line feed and the tab is written
183
+ * as its escape, as JSON writes it, so that it shows and does nothing.
184
+ *
185
+ * Space at the end is dropped before the 2,000 are counted, so that blank
186
+ * lines do not take the place of the reason above them. Blank lines at the
187
+ * start of what is left are dropped after: `npm run` opens with one.
188
+ */
189
+ export function endOfOutput(output) {
190
+ return output
191
+ .replace(/\r\n?/g, '\n')
192
+ .replace(/\u001b\[[\d;]*m/g, '')
193
+ .replace(/[^\P{Cc}\n\t]/gu, (control) => `\\u${control.charCodeAt(0).toString(16).padStart(4, '0')}`)
194
+ .trimEnd()
195
+ .slice(-SHOWN)
196
+ .replace(/^\n+/, '');
197
+ }
140
198
  function firstLineWith(text, needle) {
141
199
  const line = text.split(/\r?\n/).find((candidate) => candidate.includes(needle));
142
200
  return (line ?? needle).trim().slice(0, 200);
143
201
  }
144
- /** What one run showed, against what the probe declares. */
202
+ /**
203
+ * What one run showed, against what the probe declares, with the end of the
204
+ * command's output on a run that is neither red nor green.
205
+ */
145
206
  export function classify(spec, run) {
207
+ const judged = judge(spec, run);
208
+ return judged.outcome === 'red' || judged.outcome === 'green' ? judged : { ...judged, output: endOfOutput(run.output) };
209
+ }
210
+ function judge(spec, run) {
146
211
  if (run.exitCode === null)
147
212
  return { outcome: 'timeout', detail: `stopped after ${spec.timeout ?? 'the configured'} seconds` };
148
213
  if (spec.junit !== null) {
@@ -200,4 +265,26 @@ export function renderEvidence(results, hash, date) {
200
265
  lines.push('', `Measured ${date} by spec-harness with probes \`${hash}\`.`);
201
266
  return lines.join('\n');
202
267
  }
268
+ /**
269
+ * What a person is told, beside the table, of each result with a run that
270
+ * proves nothing: which run, what it showed, and the end of what its command
271
+ * printed, where the reason is. The first such run of a result speaks for the
272
+ * rest, as the first run's evidence fills the table's cell. A result whose
273
+ * runs are all red or green has nothing to add to its verdict.
274
+ *
275
+ * It is for the standard error: the table is what a brief records and what a
276
+ * script reads, and a command's output is no part of either.
277
+ */
278
+ export function renderUnexplained(results) {
279
+ return results
280
+ .map((result) => {
281
+ const at = result.runs.findIndex((run) => run.output !== undefined);
282
+ const run = result.runs[at];
283
+ if (run?.output === undefined)
284
+ return '';
285
+ const printed = run.output === '' ? 'it printed nothing' : `its output ended:\n${run.output}`;
286
+ return `spec-harness: probe ${result.probe.id} is ${result.verdict} at ${result.at}: run ${at + 1} of ${result.runs.length}: ${run.detail}; ${printed}\n`;
287
+ })
288
+ .join('');
289
+ }
203
290
  //# sourceMappingURL=probe.js.map
package/dist/probe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"probe.js","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4CzC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAErF,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvH,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAA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AC,IAAI,CAChL,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,IAAI,kCAAkC,IAAI,KAAK,CAAC,CAAC;IAC5E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Probes: a defect, measured before anyone is sent to fix it.\n *\n * A brief that claims a defect proves it with a probe - a test that fails at\n * the base commit, for the reason the brief states, every time it runs - and\n * the round is done when the same probe passes at the head. The probe lives\n * in the brief, as fenced blocks, so the evidence and the claim are one\n * record:\n *\n * ````markdown\n * ```probe\n * id: old-token-still-accepted\n * run: npm test -- tests/probes/rotate.test.ts\n * signature: expected 401, got 200\n * ```\n *\n * ```probe-file tests/probes/rotate.test.ts\n * ...the test...\n * ```\n * ````\n *\n * What \"for the reason the brief states\" means is declared, never inferred\n * from prose: a `signature` the failing output must contain, or a `test` name\n * the JUnit report must show failing (ADR-0007). Without one, a probe could be\n * red because it did not compile, and a red that proves nothing is refused.\n */\n\nimport { createHash } from 'node:crypto';\n\nimport type { JUnitRead } from './junit.js';\n\nexport interface ProbeSpec {\n readonly id: string;\n /** The command, as a line a shell would run. */\n readonly run: string;\n /** A command to prepare a fresh checkout, such as `npm ci`. */\n readonly setup: string | null;\n /** Text the failing output, or the failing test's message, must contain. */\n readonly signature: string | null;\n /** A JUnit report the command writes, relative to the checkout. */\n readonly junit: string | null;\n /** The failing test's name, or part of it, in the JUnit report. */\n readonly test: string | null;\n readonly runs: number | null;\n readonly timeout: number | null;\n /** 1-based line of the probe block in the brief. */\n readonly line: number;\n}\n\nexport interface ProbeFile {\n readonly path: string;\n readonly content: string;\n readonly line: number;\n}\n\n/** A fenced block as the scanner found it. */\nexport interface CodeBlock {\n readonly info: string;\n readonly content: string;\n /** 1-based line of the opening fence. */\n readonly line: number;\n}\n\nexport interface ProbeSet {\n readonly probes: readonly ProbeSpec[];\n readonly files: readonly ProbeFile[];\n readonly problems: readonly { readonly line: number; readonly message: string }[];\n /** SHA-256 over every probe block and probe file, in order: what the evidence was measured with. */\n readonly hash: string;\n}\n\nconst KEYS = ['id', 'run', 'setup', 'signature', 'junit', 'test', 'runs', 'timeout'];\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * A probe line without its trailing `# comment`. A `#` counts only after\n * whitespace and outside quotes, so `run: npm test -- -t \"issue #12\"` keeps\n * its argument; a quote counts only where a word starts, so the apostrophe in\n * `it's` opens nothing.\n */\nfunction withoutComment(raw: string): string {\n let quote: string | null = null;\n for (let i = 0; i < raw.length; i += 1) {\n const ch = raw.charAt(i);\n const after = i === 0 ? ' ' : raw.charAt(i - 1);\n if (quote !== null) {\n if (ch === quote) quote = null;\n } else if ((ch === '\"' || ch === \"'\") && /[\\s:=]/.test(after)) {\n quote = ch;\n } else if (ch === '#' && /\\s/.test(after)) {\n return raw.slice(0, i);\n }\n }\n return raw;\n}\n\n/** Reads the probes and probe files among a brief's fenced blocks. */\nexport function readProbes(blocks: readonly CodeBlock[]): ProbeSet {\n const probes: ProbeSpec[] = [];\n const files: ProbeFile[] = [];\n const problems: { line: number; message: string }[] = [];\n const hash = createHash('sha256');\n for (const block of blocks) {\n const [word, ...rest] = block.info.trim().split(/\\s+/);\n if (word === 'probe-file') {\n const path = rest.join(' ').trim();\n // A backslash is a separator where the probe is written to disk on Windows.\n if (path === '' || /^[\\\\/]/.test(path) || path.split(/[\\\\/]/).includes('..') || /^[A-Za-z]:/.test(path)) {\n problems.push({ line: block.line, message: `a probe-file names \"${path}\"; it must be a path inside the repository` });\n continue;\n }\n files.push({ path, content: block.content, line: block.line });\n hash.update(`probe-file ${path}\\n${block.content}\\n`);\n continue;\n }\n if (word !== 'probe') continue;\n hash.update(`probe\\n${block.content}\\n`);\n const fields = new Map<string, string>();\n let bad = false;\n for (const raw of block.content.split(/\\r?\\n/)) {\n const line = withoutComment(raw).trim();\n if (line === '' || line.startsWith('#')) continue;\n const colon = line.indexOf(':');\n const key = colon < 0 ? '' : line.slice(0, colon).trim();\n if (!KEYS.includes(key)) {\n problems.push({ line: block.line, message: `a probe says \"${line}\"; its keys are ${KEYS.join(', ')}` });\n bad = true;\n continue;\n }\n fields.set(key, unquote(line.slice(colon + 1)));\n }\n if (bad) continue;\n const id = fields.get('id') ?? '';\n const run = fields.get('run') ?? '';\n if (id === '' || run === '') {\n problems.push({ line: block.line, message: 'a probe needs an id and a run command' });\n continue;\n }\n const signature = fields.get('signature') || null;\n const test = fields.get('test') || null;\n const junit = fields.get('junit') || null;\n if (signature === null && test === null) {\n problems.push({\n line: block.line,\n message: `probe ${id} does not say how it fails; give a signature, or a JUnit test name, so that a failure to compile is not taken for the defect`,\n });\n continue;\n }\n if (test !== null && junit === null) {\n problems.push({ line: block.line, message: `probe ${id} names a test but no junit report to find it in` });\n continue;\n }\n const count = (key: string): number | null | string => {\n const value = fields.get(key);\n if (value === undefined) return null;\n const n = Number(value);\n return Number.isInteger(n) && n >= 1 ? n : `probe ${id}: \"${key}\" must be a whole number of at least 1`;\n };\n const runs = count('runs');\n const timeout = count('timeout');\n if (typeof runs === 'string' || typeof timeout === 'string') {\n problems.push({ line: block.line, message: (typeof runs === 'string' ? runs : timeout) as string });\n continue;\n }\n if (probes.some((probe) => probe.id === id)) {\n problems.push({ line: block.line, message: `probe ${id} is declared twice` });\n continue;\n }\n probes.push({ id, run, setup: fields.get('setup') || null, signature, junit, test, runs, timeout, line: block.line });\n }\n return { probes, files, problems, hash: `sha256-${hash.digest('hex')}` };\n}\n\n/** What one run of a probe did. `exitCode` is `null` when it was stopped at its timeout. */\nexport interface ProbeRun {\n readonly exitCode: number | null;\n readonly output: string;\n /** The report when the probe names one: read, unreadable, or `null` when the file was not written. */\n readonly junit: JUnitRead | null;\n}\n\nexport type RunOutcome = 'red' | 'green' | 'wrong-failure' | 'timeout' | 'no-report';\n\nexport interface Classified {\n readonly outcome: RunOutcome;\n /** The evidence: the line or the message that matched, or what was missing. */\n readonly detail: string;\n}\n\nfunction firstLineWith(text: string, needle: string): string {\n const line = text.split(/\\r?\\n/).find((candidate) => candidate.includes(needle));\n return (line ?? needle).trim().slice(0, 200);\n}\n\n/** What one run showed, against what the probe declares. */\nexport function classify(spec: ProbeSpec, run: ProbeRun): Classified {\n if (run.exitCode === null) return { outcome: 'timeout', detail: `stopped after ${spec.timeout ?? 'the configured'} seconds` };\n if (spec.junit !== null) {\n if (run.junit === null) {\n return run.exitCode === 0\n ? { outcome: 'no-report', detail: `the command passed and wrote no ${spec.junit}` }\n : { outcome: 'wrong-failure', detail: `the command failed before writing ${spec.junit}` };\n }\n if (!run.junit.ok) return { outcome: 'no-report', detail: `${spec.junit} cannot be read: ${run.junit.error}` };\n const failing = run.junit.cases.filter((c) => c.outcome === 'failed' || c.outcome === 'errored');\n const matching = failing.filter(\n (c) =>\n (spec.test === null || `${c.classname} ${c.name}`.includes(spec.test)) &&\n (spec.signature === null || c.message.includes(spec.signature) || c.name.includes(spec.signature)),\n );\n const first = matching[0];\n if (first !== undefined) {\n return { outcome: 'red', detail: `${first.name} failed${spec.signature === null ? '' : `: ${firstLineWith(first.message, spec.signature)}`}` };\n }\n if (failing.length === 0 && run.exitCode === 0) return { outcome: 'green', detail: 'every test passed' };\n const other = failing[0];\n return {\n outcome: 'wrong-failure',\n detail: other === undefined ? `the command exited ${run.exitCode} with no failing test` : `${other.name} failed, which is not what the probe declares`,\n };\n }\n if (run.exitCode === 0) return { outcome: 'green', detail: 'the command passed' };\n const signature = spec.signature as string;\n return run.output.includes(signature)\n ? { outcome: 'red', detail: firstLineWith(run.output, signature) }\n : { outcome: 'wrong-failure', detail: `the command exited ${run.exitCode} and its output does not contain \"${signature}\"` };\n}\n\nexport type Verdict =\n /** Red at every run where red was expected: the defect is measured. */\n | 'measured'\n /** Green at every run where green was expected: the defect is gone. */\n | 'fixed'\n /** Green where red was expected: the probe finds no defect. */\n | 'vacuous'\n /** Red where green was expected: the round did not fix it. */\n | 'still-failing'\n /** Runs disagreed with each other. */\n | 'flaky'\n /** It failed for another reason, timed out, or wrote no report: it proves nothing. */\n | 'invalid';\n\n/** The verdict over every run of one probe, at the base (`red` expected) or the head (`green`). */\nexport function verdictOf(expected: 'red' | 'green', runs: readonly Classified[]): Verdict {\n const outcomes = new Set(runs.map((run) => run.outcome));\n if (outcomes.size > 1) return 'flaky';\n const only = runs[0]?.outcome;\n if (only === 'red') return expected === 'red' ? 'measured' : 'still-failing';\n if (only === 'green') return expected === 'green' ? 'fixed' : 'vacuous';\n return 'invalid';\n}\n\nexport interface ProbeResult {\n readonly probe: ProbeSpec;\n readonly at: string;\n readonly commit: string;\n readonly expected: 'red' | 'green';\n readonly runs: readonly Classified[];\n readonly verdict: Verdict;\n}\n\nfunction cell(text: string): string {\n return text.replace(/\\|/g, '\\\\|').replace(/\\r?\\n/g, ' ').trim();\n}\n\n/** The evidence a brief records: a table a reader can check, and what it was measured with. */\nexport function renderEvidence(results: readonly ProbeResult[], hash: string, date: string): string {\n const lines = ['| Probe | At | Runs | Verdict | Evidence |', '| --- | --- | ---: | --- | --- |'];\n for (const result of results) {\n const agreeing = result.runs.filter((run) => run.outcome === result.runs[0]?.outcome).length;\n lines.push(\n `| ${cell(result.probe.id)} | ${result.at} \\`${result.commit.slice(0, 12)}\\` | ${agreeing}/${result.runs.length} | ${result.verdict} | ${cell(result.runs[0]?.detail ?? '')} |`,\n );\n }\n lines.push('', `Measured ${date} by spec-harness with probes \\`${hash}\\`.`);\n return lines.join('\\n');\n}\n"]}
1
+ {"version":3,"file":"probe.js","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4CzC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,KAA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AI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA+B;IAC/D,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,GAAG,EAAE,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,sBAAsB,GAAG,CAAC,MAAM,EAAE,CAAC;QAC9F,OAAO,uBAAuB,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,MAAM,CAAC,OAAO,OAAO,MAAM,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC;IAC5J,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["/**\n * Probes: a defect, measured before anyone is sent to fix it.\n *\n * A brief that claims a defect proves it with a probe - a test that fails at\n * the base commit, for the reason the brief states, every time it runs - and\n * the round is done when the same probe passes at the head. The probe lives\n * in the brief, as fenced blocks, so the evidence and the claim are one\n * record:\n *\n * ````markdown\n * ```probe\n * id: old-token-still-accepted\n * run: npm test -- tests/probes/rotate.test.ts\n * signature: expected 401, got 200\n * ```\n *\n * ```probe-file tests/probes/rotate.test.ts\n * ...the test...\n * ```\n * ````\n *\n * What \"for the reason the brief states\" means is declared, never inferred\n * from prose: a `signature` the failing output must contain, or a `test` name\n * the JUnit report must show failing (ADR-0007). Without one, a probe could be\n * red because it did not compile, and a red that proves nothing is refused.\n */\n\nimport { createHash } from 'node:crypto';\n\nimport type { JUnitRead } from './junit.js';\n\nexport interface ProbeSpec {\n readonly id: string;\n /** The command, as a line a shell would run. */\n readonly run: string;\n /** A command to prepare a fresh checkout, such as `npm ci`. */\n readonly setup: string | null;\n /** Text the failing output, or the failing test's message, must contain. */\n readonly signature: string | null;\n /** A JUnit report the command writes, relative to the checkout. */\n readonly junit: string | null;\n /** The failing test's name, or part of it, in the JUnit report. */\n readonly test: string | null;\n readonly runs: number | null;\n readonly timeout: number | null;\n /** 1-based line of the probe block in the brief. */\n readonly line: number;\n}\n\nexport interface ProbeFile {\n readonly path: string;\n readonly content: string;\n readonly line: number;\n}\n\n/** A fenced block as the scanner found it. */\nexport interface CodeBlock {\n readonly info: string;\n readonly content: string;\n /** 1-based line of the opening fence. */\n readonly line: number;\n}\n\nexport interface ProbeSet {\n readonly probes: readonly ProbeSpec[];\n readonly files: readonly ProbeFile[];\n readonly problems: readonly { readonly line: number; readonly message: string }[];\n /** SHA-256 over every probe block and probe file, in order: what the evidence was measured with. */\n readonly hash: string;\n}\n\nconst KEYS = ['id', 'run', 'setup', 'signature', 'junit', 'test', 'runs', 'timeout'];\n\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && (trimmed.startsWith('\"') || trimmed.startsWith(\"'\")) && trimmed.endsWith(trimmed.charAt(0))) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n}\n\n/**\n * A probe line without its trailing `# comment`. A `#` counts only after\n * whitespace and outside quotes, so `run: npm test -- -t \"issue #12\"` keeps\n * its argument; a quote counts only where a word starts, so the apostrophe in\n * `it's` opens nothing.\n */\nfunction withoutComment(raw: string): string {\n let quote: string | null = null;\n for (let i = 0; i < raw.length; i += 1) {\n const ch = raw.charAt(i);\n const after = i === 0 ? ' ' : raw.charAt(i - 1);\n if (quote !== null) {\n if (ch === quote) quote = null;\n } else if ((ch === '\"' || ch === \"'\") && /[\\s:=]/.test(after)) {\n quote = ch;\n } else if (ch === '#' && /\\s/.test(after)) {\n return raw.slice(0, i);\n }\n }\n return raw;\n}\n\n/** Reads the probes and probe files among a brief's fenced blocks. */\nexport function readProbes(blocks: readonly CodeBlock[]): ProbeSet {\n const probes: ProbeSpec[] = [];\n const files: ProbeFile[] = [];\n const problems: { line: number; message: string }[] = [];\n const hash = createHash('sha256');\n for (const block of blocks) {\n const [word, ...rest] = block.info.trim().split(/\\s+/);\n if (word === 'probe-file') {\n const path = rest.join(' ').trim();\n // A backslash is a separator where the probe is written to disk on Windows.\n if (path === '' || /^[\\\\/]/.test(path) || path.split(/[\\\\/]/).includes('..') || /^[A-Za-z]:/.test(path)) {\n problems.push({ line: block.line, message: `a probe-file names \"${path}\"; it must be a path inside the repository` });\n continue;\n }\n files.push({ path, content: block.content, line: block.line });\n hash.update(`probe-file ${path}\\n${block.content}\\n`);\n continue;\n }\n if (word !== 'probe') continue;\n hash.update(`probe\\n${block.content}\\n`);\n const fields = new Map<string, string>();\n let bad = false;\n for (const raw of block.content.split(/\\r?\\n/)) {\n const line = withoutComment(raw).trim();\n if (line === '' || line.startsWith('#')) continue;\n const colon = line.indexOf(':');\n const key = colon < 0 ? '' : line.slice(0, colon).trim();\n if (!KEYS.includes(key)) {\n problems.push({ line: block.line, message: `a probe says \"${line}\"; its keys are ${KEYS.join(', ')}` });\n bad = true;\n continue;\n }\n fields.set(key, unquote(line.slice(colon + 1)));\n }\n if (bad) continue;\n const id = fields.get('id') ?? '';\n const run = fields.get('run') ?? '';\n if (id === '' || run === '') {\n problems.push({ line: block.line, message: 'a probe needs an id and a run command' });\n continue;\n }\n const signature = fields.get('signature') || null;\n const test = fields.get('test') || null;\n const junit = fields.get('junit') || null;\n if (signature === null && test === null) {\n problems.push({\n line: block.line,\n message: `probe ${id} does not say how it fails; give a signature, or a JUnit test name, so that a failure to compile is not taken for the defect`,\n });\n continue;\n }\n if (test !== null && junit === null) {\n problems.push({ line: block.line, message: `probe ${id} names a test but no junit report to find it in` });\n continue;\n }\n const count = (key: string): number | null | string => {\n const value = fields.get(key);\n if (value === undefined) return null;\n const n = Number(value);\n return Number.isInteger(n) && n >= 1 ? n : `probe ${id}: \"${key}\" must be a whole number of at least 1`;\n };\n const runs = count('runs');\n const timeout = count('timeout');\n if (typeof runs === 'string' || typeof timeout === 'string') {\n problems.push({ line: block.line, message: (typeof runs === 'string' ? runs : timeout) as string });\n continue;\n }\n if (probes.some((probe) => probe.id === id)) {\n problems.push({ line: block.line, message: `probe ${id} is declared twice` });\n continue;\n }\n probes.push({ id, run, setup: fields.get('setup') || null, signature, junit, test, runs, timeout, line: block.line });\n }\n return { probes, files, problems, hash: `sha256-${hash.digest('hex')}` };\n}\n\n/** What one run of a probe did. `exitCode` is `null` when it was stopped at its timeout. */\nexport interface ProbeRun {\n readonly exitCode: number | null;\n readonly output: string;\n /** The report when the probe names one: read, unreadable, or `null` when the file was not written. */\n readonly junit: JUnitRead | null;\n}\n\nexport type RunOutcome = 'red' | 'green' | 'wrong-failure' | 'timeout' | 'no-report';\n\nexport interface Classified {\n readonly outcome: RunOutcome;\n /** The evidence: the line or the message that matched, or what was missing. */\n readonly detail: string;\n /**\n * The end of what the command printed, as {@link endOfOutput} gives it, on\n * a run that proves nothing: it failed for another reason, was stopped at\n * its timeout, or left no report that can be read. `detail` says only that\n * the reason was not the probe's; the reason itself is the command's to\n * give, and this is where it gave it. A red or a green run has none.\n */\n readonly output?: string;\n}\n\n/**\n * npm's `yes` setting as an environment spells it. npm reads the name in any\n * case: `NPM_CONFIG_YES` and `Npm_Config_Yes` did what `npm_config_yes` does\n * under npm 10.9.9, 11.16.0, 11.20.0 and 12.2.0 (ADR-0007).\n */\nconst NPM_YES = /^npm_config_yes$/i;\n\n/**\n * The environment a probe's commands run in: the person's own, with `CI` set\n * as a pipeline sets it, and with npm told to fetch nothing for a command\n * unless the person's environment already says what npm may fetch.\n *\n * A probe's command runs where nothing is installed until its `setup`\n * installs it, with no terminal to be asked on. There `npx <name>` fetches\n * the registry's package of that name and runs it, unasked, and with\n * `npm_config_yes=false` it stops and names the package instead (ADR-0007).\n * A person who set the variable, in any case, has said what they want, and\n * it is left as they set it. Set and empty says nothing: npm fetched with it\n * as with no variable, so the setting is made. The empty one is taken out\n * first and not left beside it: on Windows a name is one variable whatever\n * its case, and of two spellings a command is handed one, the upper case\n * before the lower, which would be the empty one.\n */\nexport function probeEnvironment(own: Readonly<Record<string, string | undefined>>): Record<string, string | undefined> {\n const spelled = Object.keys(own).filter((name) => NPM_YES.test(name));\n if (spelled.some((name) => Boolean(own[name]))) return { ...own, CI: '1' };\n const rest = Object.fromEntries(Object.entries(own).filter(([name]) => !spelled.includes(name)));\n return { ...rest, CI: '1', npm_config_yes: 'false' };\n}\n\n/** How many characters of the end of a command's output a person is shown. */\nconst SHOWN = 2000;\n\n/**\n * The end of what a command printed, as a person is shown it: the last 2,000\n * characters, less what is there for a terminal to obey rather than for a\n * person to read. Written out as it came, an escape sequence in it moves the\n * cursor, clears lines already written or renames the window.\n *\n * - A carriage return ends a line as a line feed does, alone or in front of\n * one: alone it would have the next line written over the last.\n * - A colour is dropped. A command told to colour what it prints, as\n * `npm_config_color=always` tells npm, does so with nobody at a terminal\n * to see it, and a colour says nothing in a report.\n * - Every other control character but the line feed and the tab is written\n * as its escape, as JSON writes it, so that it shows and does nothing.\n *\n * Space at the end is dropped before the 2,000 are counted, so that blank\n * lines do not take the place of the reason above them. Blank lines at the\n * start of what is left are dropped after: `npm run` opens with one.\n */\nexport function endOfOutput(output: string): string {\n return output\n .replace(/\\r\\n?/g, '\\n')\n .replace(/\\u001b\\[[\\d;]*m/g, '')\n .replace(/[^\\P{Cc}\\n\\t]/gu, (control) => `\\\\u${control.charCodeAt(0).toString(16).padStart(4, '0')}`)\n .trimEnd()\n .slice(-SHOWN)\n .replace(/^\\n+/, '');\n}\n\nfunction firstLineWith(text: string, needle: string): string {\n const line = text.split(/\\r?\\n/).find((candidate) => candidate.includes(needle));\n return (line ?? needle).trim().slice(0, 200);\n}\n\n/**\n * What one run showed, against what the probe declares, with the end of the\n * command's output on a run that is neither red nor green.\n */\nexport function classify(spec: ProbeSpec, run: ProbeRun): Classified {\n const judged = judge(spec, run);\n return judged.outcome === 'red' || judged.outcome === 'green' ? judged : { ...judged, output: endOfOutput(run.output) };\n}\n\nfunction judge(spec: ProbeSpec, run: ProbeRun): Classified {\n if (run.exitCode === null) return { outcome: 'timeout', detail: `stopped after ${spec.timeout ?? 'the configured'} seconds` };\n if (spec.junit !== null) {\n if (run.junit === null) {\n return run.exitCode === 0\n ? { outcome: 'no-report', detail: `the command passed and wrote no ${spec.junit}` }\n : { outcome: 'wrong-failure', detail: `the command failed before writing ${spec.junit}` };\n }\n if (!run.junit.ok) return { outcome: 'no-report', detail: `${spec.junit} cannot be read: ${run.junit.error}` };\n const failing = run.junit.cases.filter((c) => c.outcome === 'failed' || c.outcome === 'errored');\n const matching = failing.filter(\n (c) =>\n (spec.test === null || `${c.classname} ${c.name}`.includes(spec.test)) &&\n (spec.signature === null || c.message.includes(spec.signature) || c.name.includes(spec.signature)),\n );\n const first = matching[0];\n if (first !== undefined) {\n return { outcome: 'red', detail: `${first.name} failed${spec.signature === null ? '' : `: ${firstLineWith(first.message, spec.signature)}`}` };\n }\n if (failing.length === 0 && run.exitCode === 0) return { outcome: 'green', detail: 'every test passed' };\n const other = failing[0];\n return {\n outcome: 'wrong-failure',\n detail: other === undefined ? `the command exited ${run.exitCode} with no failing test` : `${other.name} failed, which is not what the probe declares`,\n };\n }\n if (run.exitCode === 0) return { outcome: 'green', detail: 'the command passed' };\n const signature = spec.signature as string;\n return run.output.includes(signature)\n ? { outcome: 'red', detail: firstLineWith(run.output, signature) }\n : { outcome: 'wrong-failure', detail: `the command exited ${run.exitCode} and its output does not contain \"${signature}\"` };\n}\n\nexport type Verdict =\n /** Red at every run where red was expected: the defect is measured. */\n | 'measured'\n /** Green at every run where green was expected: the defect is gone. */\n | 'fixed'\n /** Green where red was expected: the probe finds no defect. */\n | 'vacuous'\n /** Red where green was expected: the round did not fix it. */\n | 'still-failing'\n /** Runs disagreed with each other. */\n | 'flaky'\n /** It failed for another reason, timed out, or wrote no report: it proves nothing. */\n | 'invalid';\n\n/** The verdict over every run of one probe, at the base (`red` expected) or the head (`green`). */\nexport function verdictOf(expected: 'red' | 'green', runs: readonly Classified[]): Verdict {\n const outcomes = new Set(runs.map((run) => run.outcome));\n if (outcomes.size > 1) return 'flaky';\n const only = runs[0]?.outcome;\n if (only === 'red') return expected === 'red' ? 'measured' : 'still-failing';\n if (only === 'green') return expected === 'green' ? 'fixed' : 'vacuous';\n return 'invalid';\n}\n\nexport interface ProbeResult {\n readonly probe: ProbeSpec;\n readonly at: string;\n readonly commit: string;\n readonly expected: 'red' | 'green';\n readonly runs: readonly Classified[];\n readonly verdict: Verdict;\n}\n\nfunction cell(text: string): string {\n return text.replace(/\\|/g, '\\\\|').replace(/\\r?\\n/g, ' ').trim();\n}\n\n/** The evidence a brief records: a table a reader can check, and what it was measured with. */\nexport function renderEvidence(results: readonly ProbeResult[], hash: string, date: string): string {\n const lines = ['| Probe | At | Runs | Verdict | Evidence |', '| --- | --- | ---: | --- | --- |'];\n for (const result of results) {\n const agreeing = result.runs.filter((run) => run.outcome === result.runs[0]?.outcome).length;\n lines.push(\n `| ${cell(result.probe.id)} | ${result.at} \\`${result.commit.slice(0, 12)}\\` | ${agreeing}/${result.runs.length} | ${result.verdict} | ${cell(result.runs[0]?.detail ?? '')} |`,\n );\n }\n lines.push('', `Measured ${date} by spec-harness with probes \\`${hash}\\`.`);\n return lines.join('\\n');\n}\n\n/**\n * What a person is told, beside the table, of each result with a run that\n * proves nothing: which run, what it showed, and the end of what its command\n * printed, where the reason is. The first such run of a result speaks for the\n * rest, as the first run's evidence fills the table's cell. A result whose\n * runs are all red or green has nothing to add to its verdict.\n *\n * It is for the standard error: the table is what a brief records and what a\n * script reads, and a command's output is no part of either.\n */\nexport function renderUnexplained(results: readonly ProbeResult[]): string {\n return results\n .map((result) => {\n const at = result.runs.findIndex((run) => run.output !== undefined);\n const run = result.runs[at];\n if (run?.output === undefined) return '';\n const printed = run.output === '' ? 'it printed nothing' : `its output ended:\\n${run.output}`;\n return `spec-harness: probe ${result.probe.id} is ${result.verdict} at ${result.at}: run ${at + 1} of ${result.runs.length}: ${run.detail}; ${printed}\\n`;\n })\n .join('');\n}\n"]}
package/dist/sandbox.d.ts CHANGED
@@ -33,17 +33,39 @@ export declare function withWorktree<T>(repository: string, revision: string, wo
33
33
  export interface CommandRun {
34
34
  /** `null` when the command was stopped at its timeout. */
35
35
  readonly exitCode: number | null;
36
+ /** What the command had printed by the time it was answered. */
36
37
  readonly output: string;
38
+ /**
39
+ * Set on a command that was stopped at its timeout and answered with its
40
+ * output still open: something it started holds the output where the stop
41
+ * did not reach it, and runs on (ADR-0003).
42
+ */
43
+ readonly outputHeld?: true;
37
44
  }
38
45
  /**
39
- * Runs a command line in a directory, output and errors interleaved, stopped
40
- * with everything it started when it outlives `timeoutSeconds` or the process
46
+ * Runs a command line in a directory, output and errors interleaved, until
47
+ * its output closes. A command that outlives `timeoutSeconds` is stopped
48
+ * with what `stop` reaches of it, as is one still running when the process
41
49
  * is interrupted or exits. Once the process is interrupted it never answers:
42
50
  * the job waiting on it would otherwise carry on in a worktree being removed.
43
51
  *
52
+ * The timeout bounds the wait as well as the command. What the stop reached
53
+ * lets go of the output in the time the system takes to end it, and the
54
+ * command answers then. What still holds the output `SETTLE_MS` later is
55
+ * what `stop` does not reach, and no wait would end it: the sandbox lets go
56
+ * of the output instead, and answers with what was printed and with
57
+ * `outputHeld`. Letting go is what the end of this process would do to
58
+ * whatever holds the output, only sooner, and without it the open output
59
+ * keeps this process from ending once its work is done.
60
+ *
44
61
  * Through the shell, on purpose: a probe's command is a line from the
45
62
  * repository's own brief - `npm test -- x` - which the person approved with
46
63
  * the brief, exactly as CI runs the repository's own scripts. Nothing from
47
64
  * outside the repository reaches it.
65
+ *
66
+ * The line is run as it is written. Its environment is the person's own as
67
+ * `probeEnvironment` hands it on: `CI` set, and npm told to fetch nothing for
68
+ * a command where neither that environment nor the line says what it may
69
+ * fetch (ADR-0007).
48
70
  */
49
71
  export declare function runCommand(line: string, cwd: string, timeoutSeconds: number): Promise<CommandRun>;