Comment 27191 on #1543, correction 27192. Candidate afb2ae0e. Co-Authored-By: Claude Opus 5.5 <[email protected]>
71 lines
5.6 KiB
Python
71 lines
5.6 KiB
Python
# Row 54 round 2 mutants: D01 to D31 from round 1 (D07 on the new redactor), E01 on for round 2's changes: exact text, must match once. Run from the worktree root.
|
|
import sys
|
|
A = "packages/webui/src/public/app.js"
|
|
B = "packages/webui/src/public/bus.js"
|
|
R = "packages/webui/src/reads.mjs"
|
|
V = "packages/webui/src/serve.mjs"
|
|
C = "packages/webui/src/cli.mjs"
|
|
Q = "packages/queue/src/store.mjs"
|
|
QR = "packages/webui/src/queue-read.mjs"
|
|
M = {
|
|
# my four items
|
|
"D01": [(B, " clearTimeout(timer);\n const route = routeOf()", " const route = routeOf()")],
|
|
"D02": [(B, ", h1: view.contains(a) && a.tagName === 'H1'", "")],
|
|
"D03": [(B, " else if (k.h1) $('bus-view').querySelector('h1')?.focus({ preventScroll: true });\n", "")],
|
|
"D04": [(A, " $('conv-pick').replaceChildren();", "")],
|
|
"D05": [(A, " if (focused && document.activeElement === document.body) $('main').focus();\n", "")],
|
|
"D06": [(A, "if (focused && document.activeElement === document.body)", "if (document.activeElement === document.body)")],
|
|
# redaction and projection
|
|
"D07": [(R, r"""return s.replace(/(^|[\s('"`=,[{<]|:(?!\/\/[^/]))~?\/[^\s'"`),;\]}>]+/g, '$1<path>').replace(""", "return s.replace(")],
|
|
"D08": [(R, r""".replace(/(?<![\w.-])\d{17,20}(?![\w.-])/g, '<id>')""", "")],
|
|
"D09": [(R, "let s = unquote(String(text));", "let s = String(text);")],
|
|
"D10": [(R, "for (const [re, label] of known) s = s.replace(re, label);", "")],
|
|
"D11": [(R, "return scrub({ rows: doc.rows.map(queueSummary), notes: doc.notes, at: new Date(now()).toISOString() }, redact);", "return { rows: doc.rows.map(queueSummary), notes: doc.notes, at: new Date(now()).toISOString() };")],
|
|
"D12": [(R, "return scrub({ row, notes: doc.notes, at: new Date(now()).toISOString() }, redact);", "return { row, notes: doc.notes, at: new Date(now()).toISOString() };")],
|
|
"D13": [(R, "vars: pick(b.vars, VAR_KEYS)", "vars: b.vars")],
|
|
"D14": [(R, "vars: pick(r.vars, AGENT_KEYS)", "vars: r.vars")],
|
|
"D15": [(R, "return { service, account, role, dateKind, date, state: credentialState(service, date, now) };", "return { ...ref, service, account, role, dateKind, date, state: credentialState(service, date, now) };")],
|
|
"D16": [(R, "const fail = (code, message) => new ReadError(code, redact(message));", "const fail = (code, message) => new ReadError(code, message);")],
|
|
"D17": [(R, "return scrub({ release, business: id, notifier, at: new Date(now()).toISOString() }, redact);", "return { release, business: id, notifier, at: new Date(now()).toISOString() };")],
|
|
"D18": [(C, "(${redactor({ configDir: configDir() })(err.message)})", "(${err.message})")],
|
|
# queue child
|
|
"D19": [(R, "if (status === 2) return", "if (status === 3) return")],
|
|
"D20": [(R, "if (size > maxBytes) {", "if (false) {")],
|
|
"D21": [(R, "}, timeoutMs);", "}, timeoutMs * 1000);")],
|
|
"D22": [(R, "if (!state?.live) throw", "if (!state) throw")],
|
|
# routes
|
|
"D23": [(V, " if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' });\n const a = server.address()", " const a = server.address()")],
|
|
"D24": [(V, r"const QUEUE_ID = /^[1-9]\d{0,5}$/;", r"const QUEUE_ID = /^\d+$/;")],
|
|
"D25": [(V, " if (!reads) return json(res, 503, { error: 'not-configured', message: 'the Console has no reads configured' });\n", "")],
|
|
# views
|
|
"D26": [(B, "['not-configured', 'no-bus-host', 'queue-refused'].includes(err.code)", "['not-configured', 'no-bus-host'].includes(err.code)")],
|
|
"D27": [(B, "html = failedView(err) + (path === '/settings' ? appearance() : '');", "html = failedView(err);")],
|
|
"D28": [(B, "...decisions, ...tasks, ...rows];", "...decisions, ...tasks];")],
|
|
"D29": [(B, ", mirror: view.contains(a) ? a.dataset?.mirror : null", "")],
|
|
"D30": [(B, "if (m) { const src = $(m.dataset.mirror); src.value = m.value; src.dispatchEvent(new Event('change')); return; }", "if (m) return;")],
|
|
# store
|
|
"D31": [(Q, "return { rows: rowsArray(r.state), err: r.notes, code: 0 };", "return { rows: rowsArray(r.state), err: [], code: 0 };")],
|
|
# round 2 changes
|
|
"E01": [(QR, "let QueueError = null;\n", "import { rows } from '../../queue/src/store.mjs';\nimport { QueueError as QE } from '../../queue/src/errors.mjs';\nlet QueueError = QE;\n"),
|
|
(QR, " ({ QueueError } = await import('../../queue/src/errors.mjs'));\n const { rows } = await import('../../queue/src/store.mjs');\n", "")],
|
|
"E02": [(R, "new ReadError('read-failed', `the queue read failed (exit ${status})`)", "new ReadError('read-failed', said || `the queue read failed (exit ${status})`)")],
|
|
"E03": [(R, r"""|:(?!\/\/[^/]))~?\/""", r""")~?\/""")],
|
|
"E04": [(R, r""":(?!\/\/[^/])""", ":")],
|
|
"E05": [(R, r"""~?\/[^\s'""", r"""\/[^\s'""")],
|
|
"E06": [(R, r"""[\s('"`=,[{<]|""", r"""[\s('"`=,[{]|""")],
|
|
"E07": [(B, "<dd>${arbiterRefs(b.arbiters)}</dd>", "<dd>${names(b.arbiters)}</dd>")],
|
|
"E08": [(B, "r.after.map(afterRef)", "r.after.map(qLink)")],
|
|
"E09": [(B, "<dd>yes${Number.isFinite", "<dd>${txt(r.required)}${Number.isFinite")],
|
|
"E10": [(B, "Number.isFinite(Date.parse(r.requiredSince))", "r.requiredSince")],
|
|
"E11": [(R, " if (!dataRoot) throw new ReadError('not-configured', 'the Console has no system config, so it knows no notifier config');\n", "")],
|
|
"E12": [(QR, "const refused = QueueError !== null && err instanceof QueueError;", "const refused = err instanceof QueueError;")],
|
|
"E13": [(B, ".join(', ') || none : names(a);", ".join(', ') : names(a);")],
|
|
"E14": [(B, "${a.when ? ` ${txt(a.when)}` : ''}", "")],
|
|
}
|
|
for f, old, new in M[sys.argv[1]]:
|
|
s = open(f).read()
|
|
n = s.count(old)
|
|
if n != 1: sys.exit(f"{sys.argv[1]}: {n} matches in {f}")
|
|
open(f, "w").write(s.replace(old, new))
|
|
print(sys.argv[1], "applied")
|