@pipeworx/mcp-edge-case-museum 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -12
- package/bin/cli.js +55 -11
- package/lib/index.js +333 -0
- package/package.json +17 -16
- package/server.json +1 -1
- package/tools.json +98 -0
- package/src/bake.mjs +0 -112
- package/src/ecm-index-data.ts +0 -15
- package/src/exhibits/datetime/add-24-hours-vs-add-1-day-across-dst.json +0 -51
- package/src/exhibits/datetime/add-365-days-to-feb-29-not-next-feb-29.json +0 -49
- package/src/exhibits/datetime/age-calculator-feb29-birthday-crash-vs-silent.json +0 -52
- package/src/exhibits/datetime/century-leap-year-1900-not-leap.json +0 -68
- package/src/exhibits/datetime/datetime-utcnow-naive-deprecated.json +0 -39
- package/src/exhibits/datetime/dst-fall-back-ambiguous-fold.json +0 -51
- package/src/exhibits/datetime/dst-spring-forward-nonexistent-time.json +0 -57
- package/src/exhibits/datetime/fractional-utc-offsets-kathmandu-kolkata.json +0 -50
- package/src/exhibits/datetime/iso-week-year-vs-calendar-year.json +0 -48
- package/src/exhibits/datetime/js-date-field-overflow-rollover.json +0 -49
- package/src/exhibits/datetime/leap-second-rejected-vs-silently-invalid.json +0 -57
- package/src/exhibits/datetime/lord-howe-30-minute-dst.json +0 -47
- package/src/exhibits/datetime/midnight-that-doesnt-exist-sao-paulo.json +0 -53
- package/src/exhibits/datetime/python-naive-aware-comparison-typeerror.json +0 -46
- package/src/exhibits/datetime/samoa-skipped-day-2011.json +0 -50
- package/src/exhibits/datetime/southern-hemisphere-dst-reversed.json +0 -50
- package/src/exhibits/datetime/two-digit-year-century-pivot-mismatch.json +0 -49
- package/src/exhibits/datetime/year-2038-int32-overflow.json +0 -52
- package/src/exhibits/filenames/absolute-second-argument-resets-join.json +0 -62
- package/src/exhibits/filenames/bidi-override-extension-spoof.json +0 -58
- package/src/exhibits/filenames/case-insensitive-filesystem-pure-path-mismatch.json +0 -74
- package/src/exhibits/filenames/dotfile-has-no-extension.json +0 -61
- package/src/exhibits/filenames/extension-trap-double-extension.json +0 -62
- package/src/exhibits/filenames/filename-length-limits-bytes-not-chars.json +0 -66
- package/src/exhibits/filenames/leading-dash-filename-parsed-as-flag.json +0 -67
- package/src/exhibits/filenames/nfc-nfd-filename-lookup-mismatch.json +0 -68
- package/src/exhibits/filenames/ntfs-alternate-data-stream-colon.json +0 -59
- package/src/exhibits/filenames/ntpath-splitdrive-unc-paths.json +0 -58
- package/src/exhibits/filenames/nul-byte-in-filename-raises-at-open.json +0 -60
- package/src/exhibits/filenames/path-join-escapes-the-base-directory.json +0 -63
- package/src/exhibits/filenames/windows-backslash-traversal-ntpath.json +0 -62
- package/src/exhibits/filenames/windows-reserved-device-names.json +0 -73
- package/src/exhibits/filenames/windows-trailing-dot-space-stripped.json +0 -77
- package/src/exhibits/float-money/decimal-from-float-vs-string.json +0 -66
- package/src/exhibits/float-money/float-anchor-0-1-plus-0-2.json +0 -67
- package/src/exhibits/float-money/intl-number-format-de-de-roundtrip-misparsed.json +0 -62
- package/src/exhibits/float-money/iso4217-minor-units-not-always-two.json +0 -78
- package/src/exhibits/float-money/math-abs-negative-zero.json +0 -51
- package/src/exhibits/float-money/max-safe-integer-plus-two.json +0 -62
- package/src/exhibits/float-money/naive-loop-sum-order-dependence.json +0 -71
- package/src/exhibits/float-money/nan-breaks-equality-and-max-min.json +0 -70
- package/src/exhibits/float-money/negative-zero-balance-formatting.json +0 -74
- package/src/exhibits/float-money/number-epsilon-false-positive-small-magnitude.json +0 -52
- package/src/exhibits/float-money/parsefloat-comma-thousands-separator.json +0 -66
- package/src/exhibits/float-money/python-banker-rounding-vs-js-round-half-up.json +0 -65
- package/src/exhibits/float-money/python-round-2-675-float-imprecision.json +0 -64
- package/src/exhibits/float-money/splitting-100-dollars-three-ways-leaves-a-cent.json +0 -63
- package/src/exhibits/float-money/sum-ten-dimes-not-a-dollar.json +0 -77
- package/src/exhibits/float-money/tofixed-1-005-rounds-down-not-up.json +0 -63
- package/src/exhibits/float-money/tofixed-2-345-inconsistent-rounding.json +0 -64
- package/src/exhibits/integers/array-index-above-2-32-2-not-an-index.json +0 -42
- package/src/exhibits/integers/bigint-number-mixing-typeerror.json +0 -49
- package/src/exhibits/integers/bitwise-32-bit-truncation.json +0 -56
- package/src/exhibits/integers/bool-is-int-subclass-dict-key-collision.json +0 -58
- package/src/exhibits/integers/floor-div-mod-sign-python-vs-js.json +0 -48
- package/src/exhibits/integers/json-parse-loses-id-precision.json +0 -58
- package/src/exhibits/integers/max-safe-integer-plus-one-equals-plus-two.json +0 -58
- package/src/exhibits/integers/number-empty-and-whitespace-string-equals-zero.json +0 -55
- package/src/exhibits/integers/parseint-null-radix36-digit-soup.json +0 -57
- package/src/exhibits/integers/parseint-number-argument-scientific-notation.json +0 -48
- package/src/exhibits/integers/parseint-stops-at-first-invalid-char-vs-number.json +0 -58
- package/src/exhibits/integers/python-int-accepts-fullwidth-unicode-digits.json +0 -56
- package/src/exhibits/integers/python-int-accepts-underscores-and-whitespace.json +0 -48
- package/src/exhibits/integers/python-unbounded-int-vs-fixed-width-wrap.json +0 -49
- package/src/exhibits/names-addresses/address-with-no-street-number.json +0 -54
- package/src/exhibits/names-addresses/ascii-regex-rejects-accented-and-hyphenated-names.json +0 -55
- package/src/exhibits/names-addresses/house-number-suffix-collapsed-by-digit-extraction.json +0 -55
- package/src/exhibits/names-addresses/mononym-fails-first-last-required.json +0 -56
- package/src/exhibits/names-addresses/naive-lowercase-breaks-greek-final-sigma.json +0 -64
- package/src/exhibits/names-addresses/null-surname-coerced-to-null-value.json +0 -58
- package/src/exhibits/names-addresses/single-letter-surname-fails-min-length.json +0 -55
- package/src/exhibits/names-addresses/sort-by-surname-particle-convention-mismatch.json +0 -57
- package/src/exhibits/names-addresses/spanish-double-surname-treated-as-single.json +0 -55
- package/src/exhibits/names-addresses/split-surname-on-last-space-loses-particle.json +0 -59
- package/src/exhibits/names-addresses/title-case-mangles-mixed-case-and-apostrophes.json +0 -60
- package/src/exhibits/names-addresses/uk-canada-postal-code-assumed-numeric.json +0 -55
- package/src/exhibits/names-addresses/us-zip-code-leading-zero-lost-as-integer.json +0 -58
- package/src/exhibits/names-addresses/varchar-truncation-splits-name-mid-grapheme.json +0 -63
- package/src/exhibits/parsing/csv-crlf-trailing-blank-line.json +0 -87
- package/src/exhibits/parsing/csv-doubled-quote-escaping.json +0 -70
- package/src/exhibits/parsing/csv-formula-injection-excel.json +0 -71
- package/src/exhibits/parsing/csv-quoted-field-with-comma.json +0 -70
- package/src/exhibits/parsing/csv-quoted-field-with-newline.json +0 -70
- package/src/exhibits/parsing/csv-semicolon-delimited-european-excel.json +0 -70
- package/src/exhibits/parsing/csv-utf8-bom-first-header.json +0 -74
- package/src/exhibits/parsing/email-regex-rejects-valid-apostrophe-address.json +0 -68
- package/src/exhibits/parsing/json-big-integer-precision-loss.json +0 -65
- package/src/exhibits/parsing/json-duplicate-keys-last-wins.json +0 -64
- package/src/exhibits/parsing/json-lone-surrogate-roundtrip.json +0 -58
- package/src/exhibits/parsing/json-nan-infinity-not-valid-json.json +0 -54
- package/src/exhibits/parsing/url-backslash-treated-as-slash-whatwg.json +0 -60
- package/src/exhibits/parsing/url-urlparse-never-raises-on-garbage.json +0 -60
- package/src/exhibits/parsing/url-userinfo-trusted-looking-host.json +0 -60
- package/src/exhibits/sorting/accented-letters-sort-after-z.json +0 -63
- package/src/exhibits/sorting/byte-order-caps-before-lowercase.json +0 -66
- package/src/exhibits/sorting/case-insensitive-sort-lower-vs-casefold.json +0 -56
- package/src/exhibits/sorting/comparator-returns-boolean-js.json +0 -49
- package/src/exhibits/sorting/js-array-sort-stringifies-numbers.json +0 -68
- package/src/exhibits/sorting/locale-collation-de-vs-sv.json +0 -54
- package/src/exhibits/sorting/localecompare-numeric-option.json +0 -50
- package/src/exhibits/sorting/nan-in-sort.json +0 -59
- package/src/exhibits/sorting/natural-sort-breaks-lexicographic.json +0 -63
- package/src/exhibits/sorting/postgres-collation-documented.json +0 -61
- package/src/exhibits/sorting/python-cannot-compare-str-int.json +0 -70
- package/src/exhibits/sorting/reverse-sort-vs-reverse-after-sort-ties.json +0 -48
- package/src/exhibits/sorting/sorting-mixed-none-null.json +0 -56
- package/src/exhibits/sorting/typed-array-sort-is-numeric-by-default.json +0 -48
- package/src/exhibits/unicode/arabic-indic-digit-parses.json +0 -73
- package/src/exhibits/unicode/bidi-override-filename-spoof.json +0 -62
- package/src/exhibits/unicode/cyrillic-homoglyph-paypal-spoof.json +0 -67
- package/src/exhibits/unicode/fullwidth-bypasses-keyword-filter.json +0 -61
- package/src/exhibits/unicode/german-eszett-case-fold.json +0 -72
- package/src/exhibits/unicode/grapheme-vs-codepoint-length.json +0 -57
- package/src/exhibits/unicode/greek-final-sigma-casefold.json +0 -54
- package/src/exhibits/unicode/js-word-regex-ascii-only.json +0 -64
- package/src/exhibits/unicode/nfc-nfd-same-name-two-accounts.json +0 -70
- package/src/exhibits/unicode/nfkc-compatibility-folding.json +0 -63
- package/src/exhibits/unicode/truncation-orphans-combining-mark.json +0 -62
- package/src/exhibits/unicode/truncation-splits-surrogate-pair.json +0 -65
- package/src/exhibits/unicode/turkish-dotless-i-case-mapping.json +0 -72
- package/src/exhibits/unicode/zalgo-combining-mark-stacking.json +0 -57
- package/src/exhibits/unicode/zero-width-space-username.json +0 -62
- package/src/harness.mjs +0 -331
- package/src/index.ts +0 -686
- package/src/server.ts +0 -49
- package/src/verified.json +0 -977
- package/tsconfig.json +0 -18
package/src/bake.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Bake the Edge Case Museum index (fleet #3034).
|
|
4
|
-
*
|
|
5
|
-
* Reads every exhibit in src/exhibits/<category>/<id>.json
|
|
6
|
-
* and writes src/ecm-index-data.ts, which is registered in
|
|
7
|
-
* workers/gateway/src/pack-baked-indexes.json: it ships to KV and the gateway
|
|
8
|
-
* injects it as args._bakedIndex, so the pack never value-imports it.
|
|
9
|
-
*
|
|
10
|
-
* The bake is the second half of the "no unexecuted claim" rule. The harness
|
|
11
|
-
* (src/harness.mjs) runs every python / javascript repro
|
|
12
|
-
* and records sha256(code, expected_output) in src/verified.json. This script
|
|
13
|
-
* REFUSES to write the module if any executable repro is missing from that file
|
|
14
|
-
* or its hash differs, i.e. if anyone edited a repro or its output without
|
|
15
|
-
* re-running it. Documented (non-executed) repros are shipped labelled as such.
|
|
16
|
-
*
|
|
17
|
-
* Usage: node src/bake.mjs [--check]
|
|
18
|
-
* --check validate and compare with the committed module; exit 1 if stale.
|
|
19
|
-
*/
|
|
20
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
21
|
-
import path from 'node:path';
|
|
22
|
-
import { fileURLToPath } from 'node:url';
|
|
23
|
-
import { loadExhibits, validateExhibit, reproHash, normalizeOutput, RUNNABLE } from './harness.mjs';
|
|
24
|
-
|
|
25
|
-
const PACK = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
26
|
-
const ROOT = PACK;
|
|
27
|
-
const DIR = path.join(PACK, 'src/exhibits');
|
|
28
|
-
const OUT = path.join(PACK, 'src/ecm-index-data.ts');
|
|
29
|
-
const CHECK = process.argv.includes('--check');
|
|
30
|
-
|
|
31
|
-
const loaded = loadExhibits(DIR);
|
|
32
|
-
const errors = [];
|
|
33
|
-
for (const e of loaded) errors.push(...validateExhibit(e));
|
|
34
|
-
const verified = existsSync(path.join(PACK, 'src/verified.json')) ? JSON.parse(readFileSync(path.join(PACK, 'src/verified.json'), 'utf8')).repros ?? {} : {};
|
|
35
|
-
const exhibits = [];
|
|
36
|
-
const ids = new Set();
|
|
37
|
-
for (const { ex, file } of loaded) {
|
|
38
|
-
if (!ex) continue;
|
|
39
|
-
if (ids.has(ex.id)) errors.push(`duplicate id ${ex.id}`);
|
|
40
|
-
ids.add(ex.id);
|
|
41
|
-
for (const r of ex.repros ?? []) {
|
|
42
|
-
if (r.status === 'documented' || !RUNNABLE[r.language]) continue;
|
|
43
|
-
const key = `${ex.id}:${r.language}`;
|
|
44
|
-
const row = verified[key];
|
|
45
|
-
if (typeof r.expected_output !== 'string') errors.push(`${path.relative(ROOT, file)}: ${r.language} repro has no expected_output; run the harness with --capture`);
|
|
46
|
-
else if (!row) errors.push(`${key}: not in src/verified.json; run node src/harness.mjs`);
|
|
47
|
-
else if (row.sha256 !== reproHash(r.code, normalizeOutput(r.expected_output))) errors.push(`${key}: code or expected_output changed since the harness last ran it; re-run the harness`);
|
|
48
|
-
}
|
|
49
|
-
exhibits.push(ex);
|
|
50
|
-
}
|
|
51
|
-
for (const ex of exhibits) for (const rel of ex.related ?? []) if (!ids.has(rel)) errors.push(`${ex.id}: related id "${rel}" does not exist`);
|
|
52
|
-
if (exhibits.length < 1) errors.push('no exhibits found');
|
|
53
|
-
if (errors.length) {
|
|
54
|
-
console.error(`edge-case-museum bake REFUSED (${errors.length} problem(s)):\n ${errors.slice(0, 60).join('\n ')}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exhibits.sort((a, b) => a.category.localeCompare(b.category) || a.id.localeCompare(b.id));
|
|
59
|
-
const shipped = exhibits.map((ex) => ({
|
|
60
|
-
id: ex.id,
|
|
61
|
-
title: ex.title,
|
|
62
|
-
category: ex.category,
|
|
63
|
-
assumption: ex.assumption,
|
|
64
|
-
input: { display: ex.input.display, description: ex.input.description ?? '' },
|
|
65
|
-
what_goes_wrong: ex.what_goes_wrong,
|
|
66
|
-
why: ex.why,
|
|
67
|
-
affects: ex.affects,
|
|
68
|
-
repros: ex.repros.map((r) =>
|
|
69
|
-
r.status === 'documented'
|
|
70
|
-
? { language: r.language, status: 'documented', note: r.note, source: r.source }
|
|
71
|
-
: { language: r.language, status: 'verified', code: r.code, expected_output: normalizeOutput(r.expected_output), verified_with: verified[`${ex.id}:${r.language}`].verified_with },
|
|
72
|
-
),
|
|
73
|
-
fix: ex.fix,
|
|
74
|
-
related: ex.related ?? [],
|
|
75
|
-
sources: ex.sources,
|
|
76
|
-
tags: ex.tags,
|
|
77
|
-
test_cases: ex.test_cases ?? [],
|
|
78
|
-
}));
|
|
79
|
-
const byCat = {};
|
|
80
|
-
for (const ex of shipped) byCat[ex.category] = (byCat[ex.category] ?? 0) + 1;
|
|
81
|
-
const runtimes = JSON.parse(readFileSync(path.join(PACK, 'src/verified.json'), 'utf8')).runtimes ?? {};
|
|
82
|
-
// data_as_of is the content's date, not the bake's: the newest exhibit file's last commit would be ideal,
|
|
83
|
-
// but a deterministic module matters more for --check, so it is passed in or taken from verified.json's runtimes stamp.
|
|
84
|
-
const DATA_AS_OF = process.env.ECM_DATA_AS_OF ?? (existsSync(OUT) ? (readFileSync(OUT, 'utf8').match(/DATA_AS_OF = "([^"]+)"/)?.[1] ?? new Date().toISOString().slice(0, 10)) : new Date().toISOString().slice(0, 10));
|
|
85
|
-
|
|
86
|
-
const body = `// GENERATED by src/bake.mjs from src/exhibits/ — do not hand-edit; re-run the script.
|
|
87
|
-
// ${shipped.length} exhibits (${Object.entries(byCat).map(([k, v]) => `${k} ${v}`).join(', ')}) · repros verified with ${Object.values(runtimes).join(' and ')}
|
|
88
|
-
// Registered in workers/gateway/src/pack-baked-indexes.json; the pack reads it as args._bakedIndex and never value-imports this module.
|
|
89
|
-
|
|
90
|
-
export interface Repro { language: string; status: 'verified' | 'documented'; code?: string; expected_output?: string; verified_with?: string; note?: string; source?: string }
|
|
91
|
-
export interface TestCase { inputs: unknown[]; relation: 'equal' | 'not_equal' | 'returns' | 'no_crash' | 'raises'; expected?: unknown; note?: string }
|
|
92
|
-
export interface Exhibit {
|
|
93
|
-
id: string; title: string; category: string; assumption: string; input: { display: string; description: string };
|
|
94
|
-
what_goes_wrong: string; why: string; affects: string[]; repros: Repro[]; fix: string; related: string[];
|
|
95
|
-
sources: { title: string; url: string }[]; tags: string[]; test_cases: TestCase[];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const DATA_AS_OF = ${JSON.stringify(DATA_AS_OF)};
|
|
99
|
-
export const RUNTIMES: Record<string, string> = ${JSON.stringify(runtimes)};
|
|
100
|
-
export const EXHIBITS: Exhibit[] = ${JSON.stringify(shipped)};
|
|
101
|
-
`;
|
|
102
|
-
if (CHECK) {
|
|
103
|
-
const cur = existsSync(OUT) ? readFileSync(OUT, 'utf8') : '';
|
|
104
|
-
if (cur !== body) {
|
|
105
|
-
console.error('edge-case-museum: src/ecm-index-data.ts is stale; run node src/bake.mjs');
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
console.log(`edge-case-museum index up to date: ${shipped.length} exhibits`);
|
|
109
|
-
} else {
|
|
110
|
-
writeFileSync(OUT, body);
|
|
111
|
-
console.log(`wrote ${path.relative(ROOT, OUT)}: ${shipped.length} exhibits (${Object.entries(byCat).map(([k, v]) => `${k} ${v}`).join(', ')}), ${(body.length / 1024).toFixed(0)} KB`);
|
|
112
|
-
}
|