import pathlib,json,collections,base64,html,re
OUT=pathlib.Path('/Users/dave/.codex/visualizations/2026/11/03/01a1a265-9427-78c2-bf09-badd95feb9ea'); ROOT=pathlib.Path('/Users/dave/Code/pom-vault')
rows=[]
for part in ['frontend','backend-app','backend-core','sql','scripts','cli']:
 for a in json.load(open('/tmp/pom-tests-'+part+'.json')):
  a['framework']=a.get('framework') or ('Playwright' if '.spec.' in a['file'] else 'Vitest') if part=='frontend' else a.get('framework','Go')
  a['confidence']=a.get('confidence') or a.get('classification_confidence','heuristic')
  a['purpose']=a['purpose'].replace('—','-')
  a['reason']=a['reason'].replace('—','-')
  a['evidence']=str(a.get('evidence') or a.get('assertion_summary') or a['reason'])[:2400]
  rows.append(a)
rows.sort(key=lambda a:(a['file'],a['line']))
counts=dict(collections.Counter(a['framework'] for a in rows))
metadata={'repository':str(ROOT),'commit':'4d11364e0388fe9b00d1085331747e73736d13e5','date':'2026-11-03','execution':'Static inventory only; no product test suites run.','granularity':'TS test declaration, Go top-level Test function, pgTAP assertion call, procedural SQL exception guard, Python test function or monolithic harness, shell self-test case. Parameterized cases and Go subtests are grouped. Two conditional SQL skip declarations are included. Counts are not executed case totals.','classification':'behavior = observable boundary results, including pure helpers/HTTP/DB effects; internals = private structure/source/metadata; mixed = both.','restates':'yes = source/structure restatement detected; partial = some assertions restate implementation; no = no restatement identified, not proof of absence; unknown = insufficient semantic review. Static architectural, schema and archival contracts may be intentional.','review':'Three lower-cost gpt-6-luna subagents gathered TS and Go inventories. Primary agent covered scripts/SQL, reconciled classifications, checked file coverage, and reviewed highlighted findings. Confidence is per row; SQL bulk classification is rule-based, not individual manual review.','counts':counts,'total':len(rows),'files':len(set(a['file'] for a in rows))}
OUT.mkdir(parents=True,exist_ok=True)
(OUT/'test-inventory.json').write_text(json.dumps({'metadata':metadata,'tests':rows},indent=2))
findings=[
('Copied SQL branches','server/internal/extracttyped/beneficiary_identity_test.go',182,'The test embeds a multi-line CASE fragment and requires identical text in two migrations. It also has useful runtime identity/slot assertions.','Keep the runtime cases; replace verbatim-source parity with migration behavior fixtures.'),
('Exact sourceCopy implementation','src/lib/acceptedNameSource310.test.ts',37,'Slices the function source and checks exact strings such as From ${memberPaperTitle. Earlier tests in the same file already call sourceCopy.','Keep independent input/output examples; add visible credit/privacy scenarios where needed.'),
('Duplicated pronoun regex and comment','src/lib/stepInNames320.test.ts',36,'Requires an identical token string and a keep-in-sync comment in seven TS, Go and SQL files. Equivalent implementations can fail; matching dead code can pass.','Share a language-neutral contract fixture and run it against each implementation.'),
('Private caller text and count','src/lib/acceptedNameSource310.test.ts',77,'Counts exactly two private helper calls and two exact argument strings inside migration text.','Assert accepted records retain the correct source item and document through the real database operation.'),
('Lock syntax instead of concurrency outcome','supabase/tests/pgtap/g6_relation_lifecycle.sql',82,'Inspects pg_get_functiondef for lock ordering. This verifies source shape, not whether a real competing transaction is handled correctly.','Keep as an intentional implementation guard if desired; rely on concurrent-session tests for correctness.'),
('Fake implements the persistence claim','scripts/test_rematerialize_user_files.py',364,'The injected attacher itself deduplicates blobs and creates item rows. The count assertions therefore partly test the fake. Real orchestration still runs.','Keep orchestration assertions; test same-hash, different-path persistence with the real SQL attacher.'),
('Generated SQL contains expected fragments','scripts/test_rematerialize_user_files.py',476,'Checks for create_item_mine, INSERT fragments, and forbidden strings without executing the generated SQL.','Execute generated SQL against a disposable fixture and assert quoting, visibility, and deduplication effects.'),
('Startup helper is named in main','server/main_step_in_test.go',12,'AST inspection requires a particular startup call. A separate assertion genuinely checks configured secret hashing.','Retain the hashing case; use a startup integration check if the goal is proving the running server is configured.'),
]
fonts=''
for fam,path in [('Inter','node_modules/@fontsource-variable/inter/files/inter-latin-wght-normal.woff2'),('Poppins','node_modules/@fontsource/poppins/files/poppins-latin-600-normal.woff2')]:
 fonts+=f"@font-face{{font-family:{fam};src:url(data:font/woff2;base64,{base64.b64encode((ROOT/path).read_bytes()).decode()}) format('woff2');font-weight:{'100 900' if fam=='Inter' else '600'};font-display:swap}}"
htmltext='''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Persynl automated test inventory</title><style>FONTS
:root{--navy:#0a1d3d;--gold:#eea330;--action:#185fa5;--canvas:#f1eee6;--border:#e8e6e1;--muted:#4a4a46}*{box-sizing:border-box}body{margin:0;background:var(--canvas);color:#1a1a1a;font:16px/1.6 Inter,system-ui,sans-serif}header{background:var(--navy);color:white;padding:40px max(24px,calc((100vw - 1400px)/2));border-bottom:5px solid var(--gold)}h1,h2,h3{font-family:Poppins,system-ui,sans-serif;line-height:1.3}h1{font-size:30px;margin:6px 0 16px}h2{font-size:23px;margin-top:0}h3{font-size:18px;margin:0 0 12px}header p{max-width:900px;margin:8px 0}.eyebrow{color:#eea330;font-size:14px}main{max-width:1450px;margin:auto;padding:28px 24px 64px}section,.card{background:white;border:1px solid var(--border);border-radius:14px;padding:24px;margin-bottom:24px}.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.stat{padding:20px;background:white;border:1px solid var(--border);border-radius:14px;min-width:0}.stat strong{display:block;font-size:28px;color:var(--navy)}.stat span{font-size:14px;color:var(--muted)}.stats{margin-bottom:24px}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.grid>*{min-width:0}.finding{border-left:4px solid var(--gold);padding:18px 20px;background:#f7f5ef;border-radius:8px}.finding p{margin:8px 0}.source,small{font-size:13px;color:var(--muted);overflow-wrap:anywhere}.source{font-family:monospace}button,input,select{font:inherit;min-height:46px;border:1px solid #d8d5ce;border-radius:8px;padding:10px 14px;max-width:100%}button{cursor:pointer;background:var(--action);color:white;border-color:var(--action)}button.secondary{background:white;color:var(--action)}button:disabled{opacity:.45;cursor:default}input:focus,select:focus,button:focus-visible{outline:3px solid #eea330;outline-offset:2px}.filters{display:grid;grid-template-columns:minmax(220px,2fr) repeat(3,minmax(130px,1fr));gap:14px;margin:20px 0}.filters>label{min-width:0;font-size:14px}.filters input,.filters select{width:100%;margin-top:6px}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin:18px 0}.toolbar p{margin:0;flex:1}.tablebox{overflow:auto}table{width:100%;table-layout:fixed;border-collapse:collapse}th{text-align:left;background:#f7f5ef;font-size:14px}th,td{padding:16px 12px;border-bottom:1px solid var(--border);vertical-align:top;overflow-wrap:anywhere}th:nth-child(1){width:34%}th:nth-child(2){width:38%}th:nth-child(3){width:14%}th:nth-child(4){width:14%}td{font-size:15px}td strong{font-weight:600}.pill{display:inline-block;padding:3px 8px;border-radius:6px;font-size:13px;background:#e6f1fb;color:#185fa5}.pill.flag{background:#faeeda;color:#854f0b}.pill.internal{background:#eeedfe;color:#534ab7}.pill.muted{background:#f1eee6;color:#4a4a46}details{margin-top:10px}summary{cursor:pointer;color:var(--action);font-size:14px}pre{font:13px/1.5 monospace;white-space:pre-wrap;overflow-wrap:anywhere;background:#f7f5ef;padding:12px;border-radius:8px}code{overflow-wrap:anywhere}.note{border-left:4px solid var(--action);padding-left:16px}.methods{margin-top:24px}.legend{display:flex;flex-wrap:wrap;gap:20px}.legend p{flex:1;min-width:210px}a{color:var(--action)}@media(max-width:800px){.stats{grid-template-columns:repeat(2,minmax(0,1fr))}.grid{grid-template-columns:minmax(0,1fr)}.filters{grid-template-columns:repeat(2,minmax(0,1fr))}header{padding:28px 20px}main{padding:20px 12px}section{padding:18px}.tablebox table{min-width:740px}}@media print{header{background:white;color:black}.filters,.toolbar button{display:none}.tablebox{overflow:visible}section{break-inside:auto}.finding{break-inside:avoid}}</style>
<header><div class="eyebrow">Persynl / engineering review / November 3, 2026</div><h1>What do the automated tests actually prove?</h1><p>A searchable inventory of test purposes, behavior versus internal checks, and implementation-restatement candidates.</p><p style="font-size:14px">Read-only analysis of /Users/dave/Code/pom-vault at 4d11364. No test suites executed.</p></header><main>
<div class="stats"><div class="stat"><strong id="total"></strong><span>Inventory entries, not executed cases</span></div><div class="stat"><strong id="files"></strong><span>Files containing inventoried checks</span></div><div class="stat"><strong id="flagged"></strong><span>Full or partial restatement candidates</span></div><div class="stat"><strong>3</strong><span>Lower-cost gathering subagents</span></div></div>
<section><h2>Start with source-shape checks</h2><p>The clearest candidates require exact code fragments, private call spellings, or duplicated SQL. They can fail after a harmless refactor and can pass without proving the promised runtime result. Some are intentional architecture guards. Keep that intent separate from behavior coverage.</p><p class="note">A hard-coded expected result is usually good testing. A pure helper test, a mocked HTTP contract, or a database-effects assertion can test behavior. Those are not labeled restatements merely because they are small or use mocks.</p><div class="grid">FINDINGS</div></section>
<section><h2>Full inventory</h2><div class="legend"><p><b>Behavior</b><br>Checks an observable output or effect at the chosen boundary.</p><p><b>Internals</b><br>Checks source, private structure, metadata, or packaging.</p><p><b>Mixed</b><br>Contains both behavior and internal assertions.</p></div><div class="filters"><label>Search purpose, name or file<input id="search" type="search" placeholder="e.g. onboarding, deduplication, sourceCopy"></label><label>Suite<select id="suite"><option value="">All suites</option></select></label><label>What it tests<select id="kind"><option value="">All classifications</option><option>behavior</option><option>internals</option><option>mixed</option></select></label><label>Restates implementation<select id="rest"><option value="">All entries</option><option value="flagged">Yes or partial</option><option value="yes">Yes</option><option value="partial">Partial</option><option value="no">Not identified</option><option value="unknown">Unresolved</option></select></label></div><div class="toolbar"><button id="showflags">Show restatement candidates</button><button id="reset" class="secondary">Reset filters</button><button id="download" class="secondary">Download full JSON</button></div><div class="toolbar"><p id="result" role="status" aria-live="polite"></p><button id="prev" class="secondary">Previous</button><button id="next" class="secondary">Next</button></div><div class="tablebox"><table><thead><tr><th>Test / source</th><th>Concise purpose / evidence</th><th>What it tests</th><th>Restates code</th></tr></thead><tbody id="body"></tbody></table></div></section>
<section><h2>What runs where</h2><div class="grid"><div><h3>Frontend and browser</h3><p><code>npm test</code> includes src, staff, and tests/utils Vitest files. Playwright defaults to <code>g6-*.spec.ts</code>; <code>npm run test:e2e:g6</code> narrows this further to 11 explicitly listed files. Historical non-g6 specs are excluded by the default testMatch even when a path is supplied. Signup has a separate config.</p></div><div><h3>Backend and database</h3><p><code>go test ./...</code> can skip integration fixtures. The serial race script and pgTAP runner require the applicable local fixtures and opt-in environment. Upgrade SQL has its own historical-fixture harness. A green unit-only run does not establish database or browser coverage.</p></div><div><h3>Scripts and catalogs</h3><p>The proof script runs the seed-contract Python tests, but other Python and catalog-generation harnesses need separate invocations. Shell TAP checks are exposed through <code>--self-test</code>.</p></div><div><h3>Counts need context</h3><p>Go subtests and TS parameterized cases are grouped under their declarations. SQL is finer-grained: one entry per pgTAP call or procedural failure guard. Two conditional skip declarations are retained. Do not compare these totals as equivalent units of coverage.</p></div></div></section>
<section><h2>Method and limits</h2><p id="method"></p><p>All matching TS/Go/Python test files were reconciled against the inventory. Four Go files contain only fixtures/helpers or TestMain, so have no test rows. The CLI suite was added during reconciliation. Benchmarks, lint/typechecking, fixture setup, migrations themselves, and manual acceptance documents are not counted as product test cases.</p><p>The database inventory labels most result/effect assertions using extraction rules and retains their SQL for inspection. The 56 procedural SQL failure guards were inspected separately, including historical smoke checks and mutation-test guards. Confidence and execution notes are visible in each row. “Not identified” means no restatement was found in this review, not proof that none exists.</p><p>Design source: the repository’s approved Persynl tokens, including navy/gold, warm canvas, Poppins and Inter. Fonts are embedded. Repository files were not modified.</p></section></main>
<script id="dataset" type="application/json">DATA</script><script>
const payload=JSON.parse(document.getElementById('dataset').textContent), data=payload.tests,meta=payload.metadata;const $=id=>document.getElementById(id);let page=0,filtered=[];const size=60;const escapeHTML=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
$('total').textContent=data.length.toLocaleString();$('files').textContent=meta.files.toLocaleString();$('flagged').textContent=data.filter(r=>['yes','partial'].includes(r.restates)).length.toLocaleString();$('method').textContent=meta.review;
for(const [name,count] of Object.entries(meta.counts)){let o=document.createElement('option');o.value=name;o.textContent=name+' ('+count.toLocaleString()+')';$('suite').append(o)}
function render(){const q=$('search').value.toLowerCase().trim();filtered=data.filter(r=>(!q||[r.file,r.name,r.purpose,r.reason].join(' ').toLowerCase().includes(q))&&(!$('suite').value||r.framework===$('suite').value)&&(!$('kind').value||r.classification===$('kind').value)&&(!$('rest').value||($('rest').value==='flagged'?['yes','partial'].includes(r.restates):r.restates===$('rest').value)));page=Math.min(page,Math.max(0,Math.ceil(filtered.length/size)-1));$('body').innerHTML=filtered.slice(page*size,(page+1)*size).map(r=>`<tr><td><strong>${escapeHTML(r.name)}</strong><div class="source">${escapeHTML(r.file)}:${r.line}</div><small>${escapeHTML(r.framework)}</small></td><td>${escapeHTML(r.purpose)}<details><summary>Rationale, evidence and run notes</summary><p>${escapeHTML(r.reason)}</p><p><b>Review:</b> ${escapeHTML(r.confidence)}</p><p>${escapeHTML(r.execution_notes)}</p><p><small>Extracted assertion evidence is retained in the downloadable JSON. Use the source location above to inspect the complete test.</small></p></details></td><td><span class="pill ${r.classification==='internals'?'internal':''}">${escapeHTML(r.classification)}</span></td><td><span class="pill ${['yes','partial'].includes(r.restates)?'flag':'muted'}">${r.restates==='no'?'Not identified':escapeHTML(r.restates)}</span></td></tr>`).join('');$('result').textContent=filtered.length?`${filtered.length.toLocaleString()} matches · showing ${page*size+1}-${Math.min(filtered.length,(page+1)*size)}`:'No matches';$('prev').disabled=page===0;$('next').disabled=(page+1)*size>=filtered.length}
for(const id of ['search','suite','kind','rest'])$(id).addEventListener(id==='search'?'input':'change',()=>{page=0;render()});$('showflags').onclick=()=>{$('rest').value='flagged';page=0;render()};$('reset').onclick=()=>{for(const id of ['search','suite','kind','rest'])$(id).value='';page=0;render()};$('prev').onclick=()=>{page--;render()};$('next').onclick=()=>{page++;render()};$('download').onclick=()=>{let a=document.createElement('a');a.href=URL.createObjectURL(new Blob([JSON.stringify(payload,null,2)],{type:'application/json'}));a.download='test-inventory.json';a.click();setTimeout(()=>URL.revokeObjectURL(a.href),1000)};render();
</script></html>'''
findhtml=''.join('<article class="finding"><h3>'+html.escape(title)+'</h3><div class="source">'+html.escape(file)+':'+str(line)+'</div><p>'+html.escape(desc)+'</p><p><b>Suggested change:</b> '+html.escape(rec)+'</p></article>' for title,file,line,desc,rec in findings)
htmltext=htmltext.replace('FONTS',fonts).replace('FINDINGS',findhtml).replace('DATA',json.dumps({'metadata':metadata,'tests':rows}).replace('<','\\u003c'))
(OUT/'test-inventory.html').write_text(htmltext)
print(json.dumps(metadata,indent=2));print('restates',collections.Counter(a['restates'] for a in rows))
