vomebook commited on
Commit ·
da9ec8b
1
Parent(s): 508c1f3
Share and strictly validate TAP coverage contracts
Browse filesFiles changed (17)
- Dockerfile+1
- scripts/check_document_loader_coverage.mjs+6-11
- scripts/check_reader_core_coverage.mjs+4-9
- scripts/check_request_manager_coverage.mjs+3-8
- scripts/check_search_file_types_coverage.mjs+3-8
- scripts/check_search_filter_equality_baseline.mjs+3-8
- scripts/check_search_folder_merge_baseline.mjs+3-8
- scripts/check_search_highlight_coverage.mjs+3-7
- scripts/check_search_record_path_coverage.mjs+4-6
- scripts/check_search_response_cache_coverage.mjs+3-10
- scripts/check_search_response_validation_coverage.mjs+3-8
- scripts/check_search_result_identity_coverage.mjs+3-8
- scripts/check_search_size_coverage.mjs+7-10
- scripts/check_tap_contracts.mjsAdded+18
- tests/test_static_checks.py+86-15
- tests/test_static_contract.py+1
- tests/test_tap_contracts.mjsAdded+50
47 unmodified lines48495051525347 unmodified lines&& node --test tests/test_search_stable_id_baseline.mjs \&& node scripts/check_search_filter_equality_baseline.mjs \&& node scripts/check_search_folder_merge_baseline.mjs \&& printf 'static gate tests passed\n' >/check/static-gate-test-okFROM node:26.11.1-bookworm-slim AS static-assets47 unmodified lines4849505152535447 unmodified lines&& node --test tests/test_search_stable_id_baseline.mjs \&& node scripts/check_search_filter_equality_baseline.mjs \&& node scripts/check_search_folder_merge_baseline.mjs \&& node --test tests/test_tap_contracts.mjs \&& printf 'static gate tests passed\n' >/check/static-gate-test-okFROM node:26.11.1-bookworm-slim AS static-assets
123413 unmodified lines181920212223242526272829303132333435363738394041import {spawnSync} from "node:child_process";// Node 26/V8 scope: only reader-document-loader.mjs and the named tests.// Baseline after adding failure-path contracts: 100% lines, 94.20% branches,13 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";const lines = text.split(/\r?\n/);const required = ["retry policy keeps bounded delay and never retries rate-limited or aborted work","proxy fallback respects response ownership, cancellation and bucket routing","preloads are single-owner and fall back on failure or mismatched identity","document preparation preserves failure and byte-limit ownership","script load releases timers, handlers and resources on success, error and close","image fallback is not used for budget failures or closed readers","tests/test_reader_pdf_rate_outer.mjs"];if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) || required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "") ||(name === "tests/test_reader_pdf_rate_outer.mjs" &&lines[index - 1] !== "# PDF rate-limit retry boundary and generic retry preserved");})) {console.error("Document loader coverage requires passing named tests and exactly one source row above each minimum");process.exitCode = 1;}1234513 unmodified lines192021222324252627282930313233343536import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: only reader-document-loader.mjs and the named tests.// Baseline after adding failure-path contracts: 100% lines, 94.20% branches,13 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";const required = ["retry policy keeps bounded delay and never retries rate-limited or aborted work","proxy fallback respects response ownership, cancellation and bucket routing","preloads are single-owner and fall back on failure or mismatched identity","document preparation preserves failure and byte-limit ownership","script load releases timers, handlers and resources on success, error and close","image fallback is not used for budget failures or closed readers"].map(name => ({name}));required.push({name: "tests/test_reader_pdf_rate_outer.mjs",marker: "PDF rate-limit retry boundary and generic retry preserved"});if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!hasPassingTapContracts(text, required)) {console.error("Document loader coverage requires passing named tests and exactly one source row above each minimum");process.exitCode = 1;}
123424 unmodified lines293031323334353637383940414243444546474849import { spawnSync } from "node:child_process";// Each run includes exactly one own-source file, so Node's aggregate// thresholds cannot hide a regression in another file or in an empty report.24 unmodified lines});const values = rows.length === 1 ? rows[0].split("|").slice(1,4).map(value=>Number(value.trim())) : [];const text = result.stdout || "";const lines = text.split(/\r?\n/);const skippedOrTodo = !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text);const expected = {"tests/test_reader_section_virtualizer.js": "reader section virtualizer contracts passed","tests/test_reader_chapter_repository.js": "reader chapter repository contracts passed","tests/test_reader_chapter_scheduler.js": "reader chapter scheduler contracts passed","tests/test_reader_chapter_preload.js": "chapter manifest preload validation, reuse, body deadline and disposal passed","tests/test_reader_scroll_anchor.js": "reader scroll anchor contracts passed"};const missingTests = gate.tests.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||lines[index - 1] !== `# ${expected[name]}` ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");});if (result.status !== 0 || rows.length !== 1 ||values.some((value,index)=>value < [gate.lines,gate.branches,gate.functions][index]) || skippedOrTodo || missingTests) {console.error(`Reader core coverage gate requires passing named tests and exactly one source coverage row: ${gate.source}`);process.exitCode = 1;}1234524 unmodified lines303132333435363738394041424344import { spawnSync } from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Each run includes exactly one own-source file, so Node's aggregate// thresholds cannot hide a regression in another file or in an empty report.24 unmodified lines});const values = rows.length === 1 ? rows[0].split("|").slice(1,4).map(value=>Number(value.trim())) : [];const text = result.stdout || "";const expected = {"tests/test_reader_section_virtualizer.js": "reader section virtualizer contracts passed","tests/test_reader_chapter_repository.js": "reader chapter repository contracts passed","tests/test_reader_chapter_scheduler.js": "reader chapter scheduler contracts passed","tests/test_reader_chapter_preload.js": "chapter manifest preload validation, reuse, body deadline and disposal passed","tests/test_reader_scroll_anchor.js": "reader scroll anchor contracts passed"};const missingTests = gate.tests.some(name => typeof expected[name] !== "string") ||!hasPassingTapContracts(text, gate.tests.map(name => ({name, marker: expected[name]})));if (result.status !== 0 || rows.length !== 1 ||values.some((value,index)=>value < [gate.lines,gate.branches,gate.functions][index]) || missingTests) {console.error(`Reader core coverage gate requires passing named tests and exactly one source coverage row: ${gate.source}`);process.exitCode = 1;}
123415 unmodified lines2021222324252627282930313233343536373839import {spawnSync} from "node:child_process";// Node 26 V8 report, one source only. Measured with the three named tests:// 100.00% lines, 95.24% branches, 95.12% functions after strict annotations.15 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";const lines = text.split(/\r?\n/);// Each test logs its completion marker only after its async contract finishes.const required = [["reader request manager behavior", "reader request manager contracts passed"],["reader initial response recovery", "reader initial response recovery contracts passed"],["reader request manager edge behavior", "reader request manager edge contracts passed"]];if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) || required.some(([name, marker]) => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||lines[index - 1] !== `# ${marker}` ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Request manager coverage gate requires passing named tests and exactly one source coverage row above each minimum");process.exitCode = 1;}1234515 unmodified lines2122232425262728293031323334import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26 V8 report, one source only. Measured with the three named tests:// 100.00% lines, 95.24% branches, 95.12% functions after strict annotations.15 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";// Each test logs its completion marker only after its async contract finishes.const required = [["reader request manager behavior", "reader request manager contracts passed"],["reader initial response recovery", "reader initial response recovery contracts passed"],["reader request manager edge behavior", "reader request manager edge contracts passed"]].map(([name, marker]) => ({name, marker}));if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!hasPassingTapContracts(text, required)) {console.error("Request manager coverage gate requires passing named tests and exactly one source coverage row above each minimum");process.exitCode = 1;}
12349 unmodified lines141516171819201 unmodified line22232425262728293031323334import {spawnSync} from "node:child_process";// Node 26/V8 scope: only the extracted inventory, not the host app.js.// This data-only source executes on load, so full coverage alone is vacuous:9 unmodified linesif (result.error) throw result.error;const rows = (result.stdout || "").split(/\r?\n/).filter(line =>/^\s*#\s*file-types\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const lines = (result.stdout || "").split(/\r?\n/);const required = ["all 67 ordered filter extensions are pinned, including case-sensitive lookup","all 77 icon mappings and their case-insensitive lookup are pinned",1 unmodified line"original lexical inventories cannot be reassigned or shadowed through global properties","const bindings retain their original mutable array and map contents","inventory data is isolated between script evaluations"];if (result.status !== 0 || rows.length !== 1 || !/^# skipped 0$/m.test(result.stdout || "") ||!/^# todo 0$/m.test(result.stdout || "") || required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search file types coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}123459 unmodified lines1516171819201 unmodified line2223242526272829import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: only the extracted inventory, not the host app.js.// This data-only source executes on load, so full coverage alone is vacuous:9 unmodified linesif (result.error) throw result.error;const rows = (result.stdout || "").split(/\r?\n/).filter(line =>/^\s*#\s*file-types\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = ["all 67 ordered filter extensions are pinned, including case-sensitive lookup","all 77 icon mappings and their case-insensitive lookup are pinned",1 unmodified line"original lexical inventories cannot be reassigned or shadowed through global properties","const bindings retain their original mutable array and map contents","inventory data is isolated between script evaluations"].map(name => ({name}));if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(result.stdout || "", required)) {console.error("Search file types coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}
12343 unmodified lines8910111213142 unmodified lines17181920212223242526272829import {spawnSync} from "node:child_process";// Require the original inline helper contracts to run, rather than merely load.const result = spawnSync(process.execPath, [3 unmodified linesif (result.stderr) process.stderr.write(result.stderr);if (result.error) throw result.error;const text = result.stdout || "";const lines = text.split(/\r?\n/);const required = ["falsy saved values short-circuit before inspecting current","length and elements use strict equality in order",2 unmodified lines"the current length is re-read after indexed getters mutate it","getter exceptions propagate without later property reads","the original global function binding remains writable but not deletable"];if (result.status !== 0 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search filter equality requires all named baseline contracts with no skips or todos");process.exitCode = 1;}123453 unmodified lines910111213142 unmodified lines1718192021222324import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Require the original inline helper contracts to run, rather than merely load.const result = spawnSync(process.execPath, [3 unmodified linesif (result.stderr) process.stderr.write(result.stderr);if (result.error) throw result.error;const text = result.stdout || "";const required = ["falsy saved values short-circuit before inspecting current","length and elements use strict equality in order",2 unmodified lines"the current length is re-read after indexed getters mutate it","getter exceptions propagate without later property reads","the original global function binding remains writable but not deletable"].map(name => ({name}));if (result.status !== 0 || !hasPassingTapContracts(text, required)) {console.error("Search filter equality requires all named baseline contracts with no skips or todos");process.exitCode = 1;}
12343 unmodified lines8910111213145 unmodified lines20212223242526272829303132import {spawnSync} from "node:child_process";// Require every original inline merge contract to finish without skips.const result = spawnSync(process.execPath, [3 unmodified linesif (result.stderr) process.stderr.write(result.stderr);if (result.error) throw result.error;const text = result.stdout || "";const lines = text.split(/\r?\n/);const required = ["self paths retain order and duplicates while matching subtree paths are excluded","falsy arguments use empty arrays without discarding truthy paths",5 unmodified lines"rebound Set receives the original iterable without an intermediate copy","custom filter can observe the original callback constructability","the original global function binding remains writable but not deletable"];if (result.status !== 0 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search folder merge requires all named baseline contracts with no skips or todos");process.exitCode = 1;}123453 unmodified lines910111213145 unmodified lines2021222324252627import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Require every original inline merge contract to finish without skips.const result = spawnSync(process.execPath, [3 unmodified linesif (result.stderr) process.stderr.write(result.stderr);if (result.error) throw result.error;const text = result.stdout || "";const required = ["self paths retain order and duplicates while matching subtree paths are excluded","falsy arguments use empty arrays without discarding truthy paths",5 unmodified lines"rebound Set receives the original iterable without an intermediate copy","custom filter can observe the original callback constructability","the original global function binding remains writable but not deletable"].map(name => ({name}));if (result.status !== 0 || !hasPassingTapContracts(text, required)) {console.error("Search folder merge requires all named baseline contracts with no skips or todos");process.exitCode = 1;}
123413 unmodified lines18192021222324252627282930313233343536import {spawnSync} from "node:child_process";// Node 26/V8 scope: search/highlight.js and its pinned behavior contracts.// The unhit branch guards an empty RegExp match, which ordinary escaped terms13 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";const lines = text.split(/\r?\n/);const required = ["HTML escaping preserves text and protects attribute and markup delimiters","highlighting matches raw text without marking tags or encoded entities","highlight regexp is case-insensitive, deduplicated, reusable and literal","highlight cache is bounded FIFO and a hit does not change insertion order"];if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) || required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search highlight coverage requires passing named contracts and exactly one source row above each minimum");process.exitCode = 1;}1234513 unmodified lines1920212223242526272829303132import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: search/highlight.js and its pinned behavior contracts.// The unhit branch guards an empty RegExp match, which ordinary escaped terms13 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const text = result.stdout || "";const required = ["HTML escaping preserves text and protects attribute and markup delimiters","highlighting matches raw text without marking tags or encoded entities","highlight regexp is case-insensitive, deduplicated, reusable and literal","highlight cache is bounded FIFO and a hit does not change insertion order"].map(name => ({name}));if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||!hasPassingTapContracts(text, required)) {console.error("Search highlight coverage requires passing named contracts and exactly one source row above each minimum");process.exitCode = 1;}
123410 unmodified lines151617181920212223242526import {spawnSync} from "node:child_process";// Node 26/V8: only the extracted path module and its compatibility vectors.// Require a real source row as well as passing tests and full coverage.10 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const name = "tests/test_search_record_path.js";const index = lines.indexOf(`# Subtest: ${name}`);if (result.status !== 0 || rows.length !== 1 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||lines[index - 1] !== "# search record paths preserve filenames, separators and URL encoding" ||!/^ok \d+ - tests\/test_search_record_path\.js$/.test(lines[index + 1] || "")) {console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}1234510 unmodified lines161718192021222324import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8: only the extracted path module and its compatibility vectors.// Require a real source row as well as passing tests and full coverage.10 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*record-path\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = [{name: "tests/test_search_record_path.js",marker: "search record paths preserve filenames, separators and URL encoding"}];if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search record path coverage gate requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}
123417 unmodified lines22232425262728293031323334353637import {spawnSync} from "node:child_process";// Node 26/V8 scope: the extracted response cache and its contract vectors.// A missing source row or a failed test must never pass as empty coverage.17 unmodified lines"replacement resets TTL, byte count and LRU position","oversize replacement and serialization errors retire the previous key","the independent one-MiB entry cap rejects larger entries even with a larger total budget"];const skipped = lines.filter(line => /^# skipped(?:\s|$)/.test(line));const todo = lines.filter(line => /^# todo(?:\s|$)/.test(line));if (result.status !== 0 || rows.length !== 1 || skipped.length !== 1 || skipped[0] !== "# skipped 0" ||todo.length !== 1 || todo[0] !== "# todo 0" ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search response cache coverage requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}1234517 unmodified lines2324252627282930import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: the extracted response cache and its contract vectors.// A missing source row or a failed test must never pass as empty coverage.17 unmodified lines"replacement resets TTL, byte count and LRU position","oversize replacement and serialization errors retire the previous key","the independent one-MiB entry cap rejects larger entries even with a larger total budget"].map(name => ({name}));if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search response cache coverage requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}
12348 unmodified lines1314151617181920212223242526272829303132import {spawnSync} from "node:child_process";// Node 26/V8 scope: extracted response validator only, excluding the host.const result = spawnSync(process.execPath, [8 unmodified linesconst text = result.stdout || "";const rows = text.split(/\r?\n/).filter(line =>/^\s*#\s*response-validation\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const lines = text.split(/\r?\n/);const required = ["complete, final, empty and past-end pages preserve exact cardinality","response shape, safe total and requested page fields are strictly checked","record elements accept objects only, preserving sparse-array every semantics","legacy boundary values and getter evaluation order remain unchanged","host function remains replaceable while forwarding the exact arguments and return value"];if (result.status !== 0 || rows.length !== 1 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search response validation coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}123458 unmodified lines1415161718192021222324252627import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: extracted response validator only, excluding the host.const result = spawnSync(process.execPath, [8 unmodified linesconst text = result.stdout || "";const rows = text.split(/\r?\n/).filter(line =>/^\s*#\s*response-validation\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = ["complete, final, empty and past-end pages preserve exact cardinality","response shape, safe total and requested page fields are strictly checked","record elements accept objects only, preserving sparse-array every semantics","legacy boundary values and getter evaluation order remain unchanged","host function remains replaceable while forwarding the exact arguments and return value"].map(name => ({name}));if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search response validation coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}
12348 unmodified lines131415161718191 unmodified line21222324252627282930313233import {spawnSync} from "node:child_process";// Node 26/V8 scope: extracted identity module only, excluding host and path helper.const result = spawnSync(process.execPath, [8 unmodified linesconst text = result.stdout || "";const rows = text.split(/\r?\n/).filter(line =>/^\s*#\s*result-identity\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const lines = text.split(/\r?\n/);const required = ["non-objects are empty while object fallbacks retain exact path spelling","truthy Id precedes id and both retain original String conversion",1 unmodified line"dependency lookup and exceptional values propagate unchanged","path lookup remains lazy through early returns and Repo conversion","host binding forwards the original result and uncoerced return value"];if (result.status !== 0 || rows.length !== 1 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "");})) {console.error("Search result identity coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}123458 unmodified lines1415161718191 unmodified line2122232425262728import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Node 26/V8 scope: extracted identity module only, excluding host and path helper.const result = spawnSync(process.execPath, [8 unmodified linesconst text = result.stdout || "";const rows = text.split(/\r?\n/).filter(line =>/^\s*#\s*result-identity\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = ["non-objects are empty while object fallbacks retain exact path spelling","truthy Id precedes id and both retain original String conversion",1 unmodified line"dependency lookup and exceptional values propagate unchanged","path lookup remains lazy through early returns and Repo conversion","host binding forwards the original result and uncoerced return value"].map(name => ({name}));if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search result identity coverage requires passing named contracts and exactly one fully covered source row");process.exitCode = 1;}
123410 unmodified lines15161718192021222324252627282930import {spawnSync} from "node:child_process";// Only the extracted size-format module, as exercised by the compatibility// vectors; an unloaded file must not be accepted as an empty 100% report.10 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*size-format\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = ["tests/test_search_size_format.js", "display preserves binary boundaries and historical precision","display retains original coercion and empty-value behavior", "display retains prototype and normalized cache behavior"];if (result.status !== 0 || rows.length !== 1 || !/^# skipped 0$/m.test(text) || !/^# todo 0$/m.test(text) ||required.some(name => {const index = lines.indexOf(`# Subtest: ${name}`);return index < 0 || lines.lastIndexOf(`# Subtest: ${name}`) !== index ||!new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || "") ||(name === "tests/test_search_size_format.js" &&lines[index - 1] !== "# search size formatting, parser compatibility and URL round trips passed");})) {console.error("Search size coverage gate requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}1234510 unmodified lines161718192021222324252627import {spawnSync} from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Only the extracted size-format module, as exercised by the compatibility// vectors; an unloaded file must not be accepted as an empty 100% report.10 unmodified linesconst lines = text.split(/\r?\n/);const rows = lines.filter(line =>/^\s*#\s*size-format\.js\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|\s*100(?:\.0+)?\s*\|/.test(line));const required = [{name: "tests/test_search_size_format.js", marker: "search size formatting, parser compatibility and URL round trips passed"},...["display preserves binary boundaries and historical precision", "display retains original coercion and empty-value behavior","display retains prototype and normalized cache behavior"].map(name => ({name}))];if (result.status !== 0 || rows.length !== 1 || !hasPassingTapContracts(text, required)) {console.error("Search size coverage gate requires passing named tests and exactly one fully covered source row");process.exitCode = 1;}
123456789101112131415161718// Shared TAP contract checks for coverage gates; percentages stay gate-owned./** @param {string} text @param {{name: string, marker?: string}[]} required */export function hasPassingTapContracts(text, required) { const lines = text.split(/\r?\n/); const skipped = lines.filter(line => /^# skipped(?:\s|$)/.test(line)); const todo = lines.filter(line => /^# todo(?:\s|$)/.test(line)); if (!(skipped.length === 1 && skipped[0] === "# skipped 0" && todo.length === 1 && todo[0] === "# todo 0")) return false; if (!Array.isArray(required) || required.length === 0 || required.some(contract => !contract || typeof contract !== "object" || typeof contract.name !== "string" || !contract.name || ("marker" in contract && typeof contract.marker !== "string"))) return false; if (new Set(required.map(contract => contract.name)).size !== required.length) return false; return required.every(({name, marker}) => { const index = lines.indexOf(`# Subtest: ${name}`); return index >= 0 && lines.lastIndexOf(`# Subtest: ${name}`) === index && (marker === undefined || lines[index - 1] === `# ${marker}`) && new RegExp(`^ok \\d+ - ${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`).test(lines[index + 1] || ""); });}219 unmodified lines22022122222322422522618 unmodified lines24524624724824925012 unmodified lines26326426526626726826927027127222 unmodified lines29529629729829930030165 unmodified lines3673683693703713723737 unmodified lines38138238338438538638 unmodified lines4254264274284294304317 unmodified lines43944044144244344450 unmodified lines49549649749849950050150250350450550650736 unmodified lines54454554654754854955013 unmodified lines5645655665675685695 unmodified lines57557657757857958058132 unmodified lines6146156166176186196209 unmodified lines63063163263363463529 unmodified lines66566666766866967067114 unmodified lines68668768868969069136 unmodified lines7287297307317327337349 unmodified lines74474574674774874952 unmodified lines802803804805806807808166 unmodified lines97597697797897998098114 unmodified lines99699799899910001001190 unmodified lines119211931194119511961197119811 unmodified lines1210121112121213121412156 unmodified lines122212231224122512261227122811 unmodified lines124012411242124312441245219 unmodified linesdef test_document_loader_coverage_gate_fails_closed(self):paths = ["static/reader/core/reader-document-loader.mjs", "scripts/check_document_loader_coverage.mjs","tests/test_reader_document_loader_contract.mjs", "tests/test_reader_pdf_rate_outer.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)18 unmodified lines'test.todo("extra todo");'):contract.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")contract.write_text(original)rate_test = self.root / paths[3]rate_source = rate_test.read_text()12 unmodified lines(self.root / paths[2]).write_text('import "../static/reader/core/reader-document-loader.mjs";\n')self.assert_check(self.run_check(*check), False, "coverage")def test_document_loader_coverage_checks_fractional_minimum(self):paths = ["static/reader/core/reader-document-loader.mjs", "scripts/check_document_loader_coverage.mjs","tests/test_reader_document_loader_contract.mjs", "tests/test_reader_pdf_rate_outer.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)22 unmodified linesdef test_search_response_cache_coverage_gate_fails_closed(self):paths = ["static/search/response-cache.js", "scripts/check_search_response_cache_coverage.mjs","tests/test_search_response_cache_contract.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)65 unmodified linesdef test_search_result_identity_coverage_gate_fails_closed(self):paths = ["static/search/result-identity.js", "static/search/record-path.js","scripts/check_search_result_identity_coverage.mjs", "tests/test_search_stable_id_baseline.mjs", "static/app.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)7 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "'", "test.skip('" + name + "'"))self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "', () => {", "test('" + name + "', () => { throw new Error('identity failure');"))self.assert_check(self.run_check(*check), False, "identity failure")test.unlink()38 unmodified linesdef test_search_response_validation_coverage_gate_fails_closed(self):paths = ["static/search/response-validation.js", "scripts/check_search_response_validation_coverage.mjs","tests/test_search_response_validation_baseline.mjs", "static/app.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)7 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "'", "test.skip('" + name + "'"))self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "', () => {","test('" + name + "', () => { throw new Error('contract failure');"))self.assert_check(self.run_check(*check), False, "contract failure")50 unmodified linesdef test_search_file_types_coverage_gate_fails_closed(self):paths = ["static/search/file-types.js", "scripts/check_search_file_types_coverage.mjs","tests/test_search_extension_inventory_baseline.mjs", "static/app.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "scripts/check_search_file_types_coverage.mjs"]self.assert_check(self.run_check(*check), True, "file-types.js")test = self.root / paths[2]test.write_text('import test from "node:test"; test("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "exactly one fully covered source row")test.write_text('throw new Error("failed file types test");\n')36 unmodified linesdef test_search_highlight_coverage_gate_fails_closed(self):paths = ["static/search/highlight.js", "scripts/check_search_highlight_coverage.mjs","tests/test_search_highlight_contract.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)13 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source + '\ntest.todo("unfinished contract");\n')self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text('require("node:test")("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "exactly one source row")test.write_text('throw new Error("failed highlight test");\n')5 unmodified linesdef test_search_highlight_coverage_checks_fractional_minimum(self):for path in ("static/search/highlight.js", "scripts/check_search_highlight_coverage.mjs","tests/test_search_highlight_contract.js"):target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)32 unmodified linesdef test_search_record_path_coverage_gate_fails_closed(self):paths = ["static/search/record-path.js", "scripts/check_search_record_path_coverage.mjs","tests/test_search_record_path.js", "static/app.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)9 unmodified lines'require("node:test").todo("extra todo");'):test.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")test.write_text(original + '\nrequire("node:test")("unexpected failure", () => { throw new Error("path assertion failure"); });\n')self.assert_check(self.run_check(*check), False, "path assertion failure")test.write_text('require("node:test")("empty", () => {});\n')29 unmodified linesdef test_search_size_coverage_gate_fails_closed(self):paths = ["static/search/size-format.js", "scripts/check_search_size_coverage.mjs","tests/test_search_size_format.js", "tests/test_search_size_render_contract.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)14 unmodified lines'test.todo("extra todo");'):render.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")render.write_text(original)formatted = self.root / paths[2]formatted_source = formatted.read_text()36 unmodified linespaths = ["static/reader/core/reader-request-manager.js", "scripts/check_request_manager_coverage.mjs","tests/test_reader_request_manager.js", "tests/test_reader_initial_recovery.js","tests/test_reader_request_manager_edges.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)9 unmodified linesself.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original + '\nrequire("node:test").todo("unfinished check");\n')self.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original + '\nrequire("node:test")("reader request manager behavior", () => {});\n')self.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original)52 unmodified linespaths = ["static/reader/core/reader-request-manager.js", "scripts/check_request_manager_coverage.mjs","tests/test_reader_request_manager.js", "tests/test_reader_initial_recovery.js","tests/test_reader_request_manager_edges.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)166 unmodified lines"tests/test_reader_section_virtualizer.js", "tests/test_reader_chapter_repository.js","tests/test_reader_chapter_scheduler.js", "tests/test_reader_chapter_preload.js","tests/test_reader_scroll_anchor.js"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)14 unmodified linesself.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test + '\nrequire("node:test").todo("unfinished check");\n')self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test.replace('reader chapter repository contracts passed', 'renamed success marker'))self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test)190 unmodified linesdef test_search_folder_merge_baseline_gate_fails_closed(self):paths = ["static/app.js", "scripts/check_search_folder_merge_baseline.mjs","tests/test_search_folder_merge_baseline.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)11 unmodified lines"test.todo('extra todo');"):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source.replace(anchor + ", () => {", anchor + ", () => { throw new Error('folder merge failed');"))self.assert_check(self.run_check(*check), False, "folder merge failed")test.unlink()6 unmodified linesdef test_search_filter_equality_baseline_gate_fails_closed(self):paths = ["static/app.js", "scripts/check_search_filter_equality_baseline.mjs","tests/test_search_filter_equality_baseline.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)11 unmodified linesself.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source + "\ntest.skip('additional skip', () => {});\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source.replace(anchor + ", () => {", anchor + ", () => { throw new Error('filter baseline failed');"))self.assert_check(self.run_check(*check), False, "filter baseline failed")test.unlink()219 unmodified lines22022122222322422522618 unmodified lines24524624724824925025125225325425512 unmodified lines26826927027127227327427527627727827928028128228328428528628728828929029129222 unmodified lines31531631731831932032165 unmodified lines3873883893903913923937 unmodified lines40140240340440540640740840941041138 unmodified lines4504514524534544554567 unmodified lines46446546646746846947047147247347450 unmodified lines52552652752852953053153253353453553653753853954054154254336 unmodified lines58058158258358458558613 unmodified lines6006016026036046056066076086096105 unmodified lines61661761861962062162232 unmodified lines6556566576586596606619 unmodified lines67167267367467567667767867968068129 unmodified lines71171271371471571671714 unmodified lines73273373473573673773873974074174236 unmodified lines7797807817827837847859 unmodified lines79579679779879980080180280380480552 unmodified lines858859860861862863864166 unmodified lines103110321033103410351036103714 unmodified lines10521053105410551056105710581059106010611062190 unmodified lines125312541255125612571258125911 unmodified lines127112721273127412751276127712781279128012816 unmodified lines128812891290129112921293129411 unmodified lines13061307130813091310131113121313131413151316219 unmodified linesdef test_document_loader_coverage_gate_fails_closed(self):paths = ["static/reader/core/reader-document-loader.mjs", "scripts/check_document_loader_coverage.mjs","tests/test_reader_document_loader_contract.mjs", "tests/test_reader_pdf_rate_outer.mjs"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)18 unmodified lines'test.todo("extra todo");'):contract.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):contract.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")contract.write_text(original)rate_test = self.root / paths[3]rate_source = rate_test.read_text()12 unmodified lines(self.root / paths[2]).write_text('import "../static/reader/core/reader-document-loader.mjs";\n')self.assert_check(self.run_check(*check), False, "coverage")def test_shared_tap_validator_tests_are_required(self):paths = ["scripts/check_tap_contracts.mjs", "tests/test_tap_contracts.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "--test", "--test-reporter=tap", paths[1]]self.assert_check(self.run_check(*check), True, "# pass 3")helper = self.root / paths[0]original = helper.read_text()anchor = 'todo[0] === "# todo 0"'self.assertEqual(original.count(anchor), 1)helper.write_text(original.replace(anchor, 'true'))self.assert_check(self.run_check(*check), False, "not ok")def test_document_loader_coverage_checks_fractional_minimum(self):paths = ["static/reader/core/reader-document-loader.mjs", "scripts/check_document_loader_coverage.mjs","tests/test_reader_document_loader_contract.mjs", "tests/test_reader_pdf_rate_outer.mjs"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)22 unmodified linesdef test_search_response_cache_coverage_gate_fails_closed(self):paths = ["static/search/response-cache.js", "scripts/check_search_response_cache_coverage.mjs","tests/test_search_response_cache_contract.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)65 unmodified linesdef test_search_result_identity_coverage_gate_fails_closed(self):paths = ["static/search/result-identity.js", "static/search/record-path.js","scripts/check_search_result_identity_coverage.mjs", "tests/test_search_stable_id_baseline.mjs", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)7 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "'", "test.skip('" + name + "'"))self.assert_check(self.run_check(*check), False, "passing named contracts")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "', () => {", "test('" + name + "', () => { throw new Error('identity failure');"))self.assert_check(self.run_check(*check), False, "identity failure")test.unlink()38 unmodified linesdef test_search_response_validation_coverage_gate_fails_closed(self):paths = ["static/search/response-validation.js", "scripts/check_search_response_validation_coverage.mjs","tests/test_search_response_validation_baseline.mjs", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)7 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "'", "test.skip('" + name + "'"))self.assert_check(self.run_check(*check), False, "passing named contracts")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source.replace("test('" + name + "', () => {","test('" + name + "', () => { throw new Error('contract failure');"))self.assert_check(self.run_check(*check), False, "contract failure")50 unmodified linesdef test_search_file_types_coverage_gate_fails_closed(self):paths = ["static/search/file-types.js", "scripts/check_search_file_types_coverage.mjs","tests/test_search_extension_inventory_baseline.mjs", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "scripts/check_search_file_types_coverage.mjs"]self.assert_check(self.run_check(*check), True, "file-types.js")test = self.root / paths[2]original = test.read_text()for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text('import test from "node:test"; test("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "exactly one fully covered source row")test.write_text('throw new Error("failed file types test");\n')36 unmodified linesdef test_search_highlight_coverage_gate_fails_closed(self):paths = ["static/search/highlight.js", "scripts/check_search_highlight_coverage.mjs","tests/test_search_highlight_contract.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)13 unmodified linesself.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text(source + '\ntest.todo("unfinished contract");\n')self.assert_check(self.run_check(*check), False, "passing named contracts")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named contracts")test.write_text('require("node:test")("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "exactly one source row")test.write_text('throw new Error("failed highlight test");\n')5 unmodified linesdef test_search_highlight_coverage_checks_fractional_minimum(self):for path in ("static/search/highlight.js", "scripts/check_search_highlight_coverage.mjs","tests/test_search_highlight_contract.js", "scripts/check_tap_contracts.mjs"):target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)32 unmodified linesdef test_search_record_path_coverage_gate_fails_closed(self):paths = ["static/search/record-path.js", "scripts/check_search_record_path_coverage.mjs","tests/test_search_record_path.js", "static/app.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)9 unmodified lines'require("node:test").todo("extra todo");'):test.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")for extra in ('console.log("skipped 0"); require("node:test").skip("extra skip", () => {});','console.log("todo 0"); require("node:test").todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")test.write_text(original + '\nrequire("node:test")("unexpected failure", () => { throw new Error("path assertion failure"); });\n')self.assert_check(self.run_check(*check), False, "path assertion failure")test.write_text('require("node:test")("empty", () => {});\n')29 unmodified linesdef test_search_size_coverage_gate_fails_closed(self):paths = ["static/search/size-format.js", "scripts/check_search_size_coverage.mjs","tests/test_search_size_format.js", "tests/test_search_size_render_contract.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)14 unmodified lines'test.todo("extra todo");'):render.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):render.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")render.write_text(original)formatted = self.root / paths[2]formatted_source = formatted.read_text()36 unmodified linespaths = ["static/reader/core/reader-request-manager.js", "scripts/check_request_manager_coverage.mjs","tests/test_reader_request_manager.js", "tests/test_reader_initial_recovery.js","tests/test_reader_request_manager_edges.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)9 unmodified linesself.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original + '\nrequire("node:test").todo("unfinished check");\n')self.assert_check(self.run_check(*check), False, "passing named tests")for extra in ('console.log("skipped 0"); require("node:test").skip("extra skip", () => {});','console.log("todo 0"); require("node:test").todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):source.write_text(original + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original + '\nrequire("node:test")("reader request manager behavior", () => {});\n')self.assert_check(self.run_check(*check), False, "passing named tests")source.write_text(original)52 unmodified linespaths = ["static/reader/core/reader-request-manager.js", "scripts/check_request_manager_coverage.mjs","tests/test_reader_request_manager.js", "tests/test_reader_initial_recovery.js","tests/test_reader_request_manager_edges.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)166 unmodified lines"tests/test_reader_section_virtualizer.js", "tests/test_reader_chapter_repository.js","tests/test_reader_chapter_scheduler.js", "tests/test_reader_chapter_preload.js","tests/test_reader_scroll_anchor.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)14 unmodified linesself.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test + '\nrequire("node:test").todo("unfinished check");\n')self.assert_check(self.run_check(*check), False, "passing named tests")for extra in ('console.log("skipped 0"); require("node:test").skip("extra skip", () => {});','console.log("todo 0"); require("node:test").todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):chapter_test.write_text(original_test + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test.replace('reader chapter repository contracts passed', 'renamed success marker'))self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test)190 unmodified linesdef test_search_folder_merge_baseline_gate_fails_closed(self):paths = ["static/app.js", "scripts/check_search_folder_merge_baseline.mjs","tests/test_search_folder_merge_baseline.mjs"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)11 unmodified lines"test.todo('extra todo');"):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source.replace(anchor + ", () => {", anchor + ", () => { throw new Error('folder merge failed');"))self.assert_check(self.run_check(*check), False, "folder merge failed")test.unlink()6 unmodified linesdef test_search_filter_equality_baseline_gate_fails_closed(self):paths = ["static/app.js", "scripts/check_search_filter_equality_baseline.mjs","tests/test_search_filter_equality_baseline.mjs"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)11 unmodified linesself.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source + "\ntest.skip('additional skip', () => {});\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")for extra in ('console.log("skipped 0"); test.skip("extra skip", () => {});','console.log("todo 0"); test.todo("extra todo");','console.log("skipped 0");', 'console.log("todo 0");'):test.write_text(source + "\n" + extra + "\n")self.assert_check(self.run_check(*check), False, "all named baseline contracts")test.write_text(source.replace(anchor + ", () => {", anchor + ", () => { throw new Error('filter baseline failed');"))self.assert_check(self.run_check(*check), False, "filter baseline failed")test.unlink()
450 unmodified lines451452453454455456450 unmodified linesself.assertIn("node scripts/check_search_file_types_coverage.mjs", dockerfile)self.assertIn("node scripts/check_search_response_validation_coverage.mjs", dockerfile)self.assertIn("node scripts/check_search_result_identity_coverage.mjs", dockerfile)self.assertIn("node scripts/check_search_filter_equality_baseline.mjs", dockerfile)self.assertIn("node scripts/check_search_folder_merge_baseline.mjs", dockerfile)self.assertIn("node --test tests/test_search_response_validation_baseline.mjs", dockerfile)450 unmodified lines451452453454455456457450 unmodified linesself.assertIn("node scripts/check_search_file_types_coverage.mjs", dockerfile)self.assertIn("node scripts/check_search_response_validation_coverage.mjs", dockerfile)self.assertIn("node scripts/check_search_result_identity_coverage.mjs", dockerfile)self.assertIn("node --test tests/test_tap_contracts.mjs", dockerfile)self.assertIn("node scripts/check_search_filter_equality_baseline.mjs", dockerfile)self.assertIn("node scripts/check_search_folder_merge_baseline.mjs", dockerfile)self.assertIn("node --test tests/test_search_response_validation_baseline.mjs", dockerfile)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import assert from "node:assert/strict";import test from "node:test";import {hasPassingTapContracts} from "../scripts/check_tap_contracts.mjs";
const required = [{name: "first (contract)"}, {name: "file/a.b", marker: "finished marker"}];const valid = ["TAP version 13", "# Subtest: first (contract)", "ok 1 - first (contract)", "# finished marker", "# Subtest: file/a.b", "ok 2 - file/a.b", "# skipped 0", "# todo 0", ""].join("\n");
test("requires passing named contracts and matching completion markers", () => { assert.equal(hasPassingTapContracts(valid, required), true); assert.equal(hasPassingTapContracts(valid.replaceAll("\n", "\r\n"), required), true); assert.equal(hasPassingTapContracts(valid.replace("# finished marker", "# wrong marker"), required), false); assert.equal(hasPassingTapContracts(valid.replace("# finished marker", "# null"), [{name: "file/a.b", marker: /** @type {any} */ (null)}]), false); assert.equal(hasPassingTapContracts(valid, []), false); assert.equal(hasPassingTapContracts(valid, /** @type {any} */ (null)), false); assert.equal(hasPassingTapContracts(valid, [/** @type {any} */ (null)]), false); assert.equal(hasPassingTapContracts(valid, [/** @type {any} */ (7)]), false); function fakeContract() {} const forgedFunction = valid + "# Subtest: fakeContract\nok 3 - fakeContract\n"; assert.equal(hasPassingTapContracts(forgedFunction, [/** @type {any} */ (fakeContract)]), false); assert.equal(hasPassingTapContracts(valid + "# Subtest: \nok 3 - \n", [{name: ""}]), false); assert.equal(hasPassingTapContracts(valid, [{name: "first (contract)"}, {name: "first (contract)"}]), false); const readerFile = [{name: "file/a.b", marker: "finished marker"}]; assert.equal(hasPassingTapContracts(valid, readerFile), true); assert.equal(hasPassingTapContracts(valid.replace("# finished marker", "# undefined"), [{name: "file/a.b", marker: /** @type {any} */ (undefined)}]), false); assert.equal(hasPassingTapContracts(valid.replace("# Subtest: first (contract)", "# Subtest: renamed"), required), false); assert.equal(hasPassingTapContracts(valid.replace("ok 1 - first (contract)", "not ok 1 - first (contract)"), required), false); assert.equal(hasPassingTapContracts(valid.replace("ok 2 - file/a.b", "ok 2 - file/aXb"), required), false);});
test("rejects absent or nonzero skip and todo summaries", () => { for (const line of ["# skipped 0", "# todo 0"]) { assert.equal(hasPassingTapContracts(valid.replace(line, ""), required), false); assert.equal(hasPassingTapContracts(valid.replace(line, line.replace("0", "1")), required), false); assert.equal(hasPassingTapContracts(valid.replace(line, line + "0"), required), false); assert.equal(hasPassingTapContracts(valid.replace(line, `${line}\n${line.replace("0", "1")}`), required), false); assert.equal(hasPassingTapContracts(valid.replace(line, `${line.replace("0", "1")}\n${line}`), required), false); assert.equal(hasPassingTapContracts(valid.replace(line, `${line}\n${line}`), required), false); }});
test("rejects duplicate names, directives and incomplete output", () => { assert.equal(hasPassingTapContracts(valid + "# Subtest: first (contract)\nok 3 - first (contract)\n", required), false); assert.equal(hasPassingTapContracts(valid.replace("ok 1 - first (contract)", "ok 1 - first (contract) # SKIP"), required), false); assert.equal(hasPassingTapContracts(valid.replace("ok 2 - file/a.b", "ok 2 - file/a.b # TODO"), required), false); assert.equal(hasPassingTapContracts(valid.replace("ok 2 - file/a.b\n", ""), required), false); assert.equal(hasPassingTapContracts("# skipped 0\n# todo 0\n# Subtest: first (contract)", required), false);});Dockerfile+1
scripts/check_document_loader_coverage.mjs+6-11
scripts/check_reader_core_coverage.mjs+4-9
scripts/check_request_manager_coverage.mjs+3-8
scripts/check_search_file_types_coverage.mjs+3-8
scripts/check_search_filter_equality_baseline.mjs+3-8
scripts/check_search_folder_merge_baseline.mjs+3-8
scripts/check_search_highlight_coverage.mjs+3-7
scripts/check_search_record_path_coverage.mjs+4-6
scripts/check_search_response_cache_coverage.mjs+3-10
scripts/check_search_response_validation_coverage.mjs+3-8
scripts/check_search_result_identity_coverage.mjs+3-8
scripts/check_search_size_coverage.mjs+7-10
scripts/check_tap_contracts.mjsAdded+18
tests/test_static_checks.py+86-15
tests/test_static_contract.py+1
tests/test_tap_contracts.mjsAdded+50