← back to Gmc Titlefix
TK-10993: commit the read-only overnight verification harness (was untracked)
84e06d84f73dd6ebb496bf36c943c9a6067e127c · 2026-09-10 16:38:48 -0700 · Steve
The 33-field residual repair was applied and live-verified 2026-09-05, but the
harness that PROVES it held existed only in the working tree - one 'git checkout --'
from vanishing with zero signal. Read-only by construction: no feed writes, no
rollbacks, no ticket closure.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uZskkfeTZhLbtpqcCVm8d
Files touched
A test/tk10993-overnight-check.test.mjsA tk10993-overnight-check.mjs
Diff
commit 84e06d84f73dd6ebb496bf36c943c9a6067e127c
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Sep 10 16:38:48 2026 -0700
TK-10993: commit the read-only overnight verification harness (was untracked)
The 33-field residual repair was applied and live-verified 2026-09-05, but the
harness that PROVES it held existed only in the working tree - one 'git checkout --'
from vanishing with zero signal. Read-only by construction: no feed writes, no
rollbacks, no ticket closure.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uZskkfeTZhLbtpqcCVm8d
---
test/tk10993-overnight-check.test.mjs | 28 +++++++++++
tk10993-overnight-check.mjs | 95 +++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+)
diff --git a/test/tk10993-overnight-check.test.mjs b/test/tk10993-overnight-check.test.mjs
new file mode 100644
index 0000000..d145b06
--- /dev/null
+++ b/test/tk10993-overnight-check.test.mjs
@@ -0,0 +1,28 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { assess } from '../tk10993-overnight-check.mjs';
+const input = () => ({
+ residual: { total:33, applied_count:33, correct:33, errors:[], collateral:[] },
+ audit: { summary:{destamp:{PASS:40},protected_sample:{PASS:10},f3:{PASS:22},identity_policy_copy:{PASS:82}}, ledger:{target_count:4052,applied_count:4052,missing:[],extra:[],protected_samples_touched:[],applied_without_prior_intent:0,failed_records:0} },
+ canada:{errors:[],verdict:{state:'PASS'},markets:{ca:{enabled:true,active_catalogs:1}},shipping:{CA:[{active:true,currency:'CAD',ships_4lb:true}]},status:{CA:{active:1060,disapproved:22,codes:{}}}},
+ history:[{quality:'PASS'}], deadline:'2026-09-06T08:00:00Z', now:Date.parse('2026-09-05T08:00:00Z')
+});
+test('A passing live check cannot end the observation early',()=>assert.equal(assess(input()).terminal,false));
+test('Only completed window plus clear Canada shipping errors can pass',()=>{
+ const x=input(); x.now=Date.parse(x.deadline); assert.equal(assess(x).outcome,'OBSERVATION_COMPLETE');
+ x.canada.status.CA.codes.missing_shipping=1; assert.equal(assess(x).outcome,'ATTENTION');
+});
+test('Missing API evidence retries then requests attention, never succeeds',()=>{
+ const x=input(); x.residual=null; assert.equal(assess(x).quality,'UNKNOWN'); assert.equal(assess(x).terminal,false);
+ x.history=[{quality:'UNKNOWN'},{quality:'UNKNOWN'}]; assert.equal(assess(x).outcome,'ATTENTION');
+});
+test('Confirmed field or shipping regression terminates without any mutation',()=>{
+ const x=input(); x.residual.correct=32; const first=assess(x); assert.equal(first.terminal,false);
+ x.history=[first]; assert.equal(assess(x).outcome,'ATTENTION');
+ x.residual.correct=33; x.canada.shipping.CA[0].ships_4lb=false; const other=assess(x); assert.equal(other.terminal,false);
+ x.history=[other]; assert.equal(assess(x).outcome,'ATTENTION');
+});
+test('Truncated independent cohort and changed sample guard cannot pass',()=>{
+ const x=input(); x.audit.summary.f3.PASS=21; assert.equal(assess(x).quality,'UNKNOWN');
+ x.audit.summary.f3.PASS=22; x.audit.summary.protected_sample={PASS:9,CHANGED:1}; assert.equal(assess(x).quality,'REGRESSION');
+});
diff --git a/tk10993-overnight-check.mjs b/tk10993-overnight-check.mjs
new file mode 100644
index 0000000..bc1f63e
--- /dev/null
+++ b/tk10993-overnight-check.mjs
@@ -0,0 +1,95 @@
+// Persistent READ-ONLY observation. No feed writes, rollbacks, or ticket closure.
+import fs from 'node:fs';
+import path from 'node:path';
+import { execFile } from 'node:child_process';
+import { promisify } from 'node:util';
+import { pathToFileURL } from 'node:url';
+const exec = promisify(execFile);
+const ROOT = path.dirname(new URL(import.meta.url).pathname);
+const DIR = path.join(ROOT, 'data/tk10993-overnight-20260905');
+const CODE = 'missing_shipping_mismatch_of_shipping_method_and_offer_currency';
+const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
+const save = (file, value) => fs.writeFileSync(file, JSON.stringify(value, null, 2) + '\n', { flag: 'wx' });
+
+export function assess({ residual, audit, canada, failures = [], history = [], deadline, now = Date.now() }) {
+ const unknown = [...failures], regressions = [];
+ if (!residual || residual.total !== 33 || residual.applied_count !== 33 || !Array.isArray(residual.errors) || !Array.isArray(residual.collateral)) unknown.push('Residual evidence incomplete');
+ else {
+ if (residual.errors.length) unknown.push('Residual API reads failed');
+ else if (residual.correct !== 33) regressions.push('Approved field reverted or changed');
+ if (residual.collateral.length) regressions.push('Unrelated attributes or new disapprovals changed');
+ }
+ const expected = { destamp: 40, protected_sample: 10, f3: 22, identity_policy_copy: 82 };
+ for (const [group, count] of Object.entries(expected)) {
+ const counts = audit?.summary?.[group];
+ if (!counts || Object.values(counts).reduce((a, b) => a + b, 0) !== count || counts.UNKNOWN) unknown.push(`${group} evidence incomplete`);
+ else if (counts.PASS !== count) regressions.push(`${group} regression`);
+ }
+ const ledger = audit?.ledger;
+ if (!ledger || ledger.target_count !== 4052 || ledger.applied_count !== 4052) unknown.push('Destamp ledger incomplete');
+ else if (['missing', 'extra', 'protected_samples_touched'].some(k => !Array.isArray(ledger[k]))) unknown.push('Destamp ledger schema incomplete');
+ else if (ledger.missing.length || ledger.extra.length || ledger.protected_samples_touched.length || ledger.applied_without_prior_intent || ledger.failed_records) regressions.push('Destamp ledger integrity changed');
+ const ca = canada?.status?.CA;
+ if (!canada || canada.errors?.length || canada.verdict?.state === 'UNKNOWN' || !ca || !Number.isFinite(ca.active) || !ca.codes || !Array.isArray(canada.shipping?.CA) || !canada.markets?.ca) unknown.push('Canada evidence incomplete');
+ else {
+ if (!canada.markets.ca.enabled || canada.markets.ca.active_catalogs < 1) regressions.push('Canada market or catalog disabled');
+ if (!canada.shipping.CA.some(s => s.active && s.currency === 'CAD' && s.ships_4lb === true)) regressions.push('Canada CAD shipping no longer covers4lb');
+ if (ca.active < 823 * 0.95) regressions.push('Canada active offers fell more than5% below observation baseline');
+ }
+ const quality = regressions.length ? 'REGRESSION' : unknown.length ? 'UNKNOWN' : 'PASS';
+ const previous = history.at(-1);
+ const confirmed = quality === 'REGRESSION' && previous?.quality === 'REGRESSION' && regressions.some(r => previous.regressions?.includes(r));
+ const stale = quality === 'UNKNOWN' && history.slice(-2).length === 2 && history.slice(-2).every(h => h.quality === 'UNKNOWN');
+ const expired = now >= Date.parse(deadline);
+ const recovery = quality === 'PASS' && ca.active >= 823 && (ca.codes[CODE] || 0) === 0 && (ca.codes.missing_shipping || 0) === 0;
+ // Success means this observation window passed, never that full Canada coverage is restored.
+ const success = expired && recovery && previous?.quality === 'PASS';
+ const terminal = confirmed || stale || expired;
+ return { quality, regressions, unknown, terminal, outcome: terminal ? success ? 'OBSERVATION_COMPLETE' : 'ATTENTION' : 'PENDING',
+ reason: confirmed ? 'Same regression on two consecutive checks' : stale ? 'Three consecutive checks lack required evidence' : expired ? success ? '24-hour checks passed and existing Canada shipping errors cleared' : '24-hour deadline reached; review remaining recovery/evidence' : 'Continue 15-minute read-only observation',
+ canada: ca ? { active: ca.active, disapproved: ca.disapproved, currency_errors: ca.codes?.[CODE], missing_shipping: ca.codes?.missing_shipping } : null };
+}
+
+async function run() {
+ const config = read(path.join(DIR, 'config.json'));
+ if (config.ticket !== 'TK-10993' || config.read_only !== true || !Number.isFinite(Date.parse(config.deadline))) throw new Error('Invalid monitor configuration');
+ const terminalPath = path.join(DIR, 'terminal.json');
+ if (fs.existsSync(terminalPath)) { console.log(`TK10993_${read(terminalPath).outcome}`); return; }
+ const checkId = new Date().toISOString().replace(/[:.]/g, '-');
+ const evidenceDir = path.join(DIR, checkId);
+ fs.mkdirSync(evidenceDir);
+ async function runRead(args) {
+ try { const r = await exec(process.execPath, args, { cwd: ROOT, timeout: 210000, maxBuffer: 1024 * 1024 }); return { code: 0, stdout: r.stdout }; }
+ catch (e) { return { code: e.code, stdout: e.stdout || '', error: e.killed ? 'Read timed out' : `Read process exit ${e.code}` }; }
+ }
+ const auditFile = path.join(evidenceDir, 'audit.json'), caFile = path.join(evidenceDir, 'canada.json');
+ const results = await Promise.all([
+ runRead([path.join(ROOT, 'tk10993-residual-executor.mjs'), 'verify']),
+ runRead([path.join(ROOT, 'tk10993-remediation-audit.mjs'), `--output=${auditFile}`]),
+ runRead([path.join(ROOT, 'tk10993-ca-canary-verify.mjs'), `--output=${caFile}`])
+ ]);
+ let residual, audit, canada;
+ const failures = [];
+ try { residual = JSON.parse(results[0].stdout); } catch { failures.push(results[0].error || 'Residual summary unavailable'); }
+ try { audit = read(auditFile); } catch { failures.push(results[1].error || 'Independent audit unavailable'); }
+ try { canada = read(caFile); } catch { failures.push(results[2].error || 'Canada read unavailable'); }
+ save(path.join(evidenceDir, 'process-results.json'), results.map((r, i) => ({ check: ['residual', 'audit', 'canada'][i], code: r.code, error: r.error })));
+ const historyPath = path.join(DIR, 'history.jsonl');
+ const history = fs.existsSync(historyPath) ? fs.readFileSync(historyPath, 'utf8').trim().split('\n').filter(Boolean).map(JSON.parse) : [];
+ const result = { at: new Date().toISOString(), check_id: checkId, ...assess({ residual, audit, canada, failures, history, deadline: config.deadline }),
+ evidence: { residual: residual?.file, audit: auditFile, canada: caFile }, corrected: residual?.correct };
+ save(path.join(evidenceDir, 'result.json'), result);
+ fs.appendFileSync(historyPath, JSON.stringify(result) + '\n');
+ const latest = path.join(DIR, 'latest.json');
+ fs.writeFileSync(`${latest}.tmp`, JSON.stringify(result, null, 2) + '\n'); fs.renameSync(`${latest}.tmp`, latest);
+ const tk = path.join(process.env.HOME, 'Projects/ticket-system/tk');
+ const note = `Overnight ${result.outcome}/${result.quality}: fields ${result.corrected ?? '?'}/33; Canada ${JSON.stringify(result.canada)}. ${result.reason}. Evidence ${evidenceDir}. Full Canada coverage is a separate open work item.`;
+ try {
+ await exec(process.execPath, [tk, 'log', 'TK-10993', note], { env: { ...process.env, TK_AGENT: 'codex-run-10993' }, timeout: 20000 });
+ if (result.terminal) await exec(process.execPath, [tk, 'comment', 'TK-10993', note], { env: { ...process.env, TK_AGENT: 'codex-run-10993' }, timeout: 20000 });
+ } catch { console.error('Ticket logging failed; local evidence retained and scheduler will retry.'); process.exitCode = 1; return; }
+ if (result.terminal) save(terminalPath, result);
+ console.log(`TK10993_${result.outcome}`);
+ console.log(JSON.stringify(result));
+}
+if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) run().catch(e => { console.error(e.message); process.exitCode = 1; });
← 6963f42 TK-11405: archive the 34 WallQuest-discontinued Malibu produ
·
back to Gmc Titlefix
·
TK-11233: independent full-account scan confirms the feed is 22f346b →