diff --git a/backend/tests/scripts/test_validate_dashboard_testing_accounting.py b/backend/tests/scripts/test_validate_dashboard_testing_accounting.py
new file mode 100644
index 000000000..4e63d4482
--- /dev/null
+++ b/backend/tests/scripts/test_validate_dashboard_testing_accounting.py
@@ -0,0 +1,298 @@
+# #region Test.DashboardTestingAccounting [C:2] [TYPE Module] [SEMANTICS accounting,verification,pytest,freeze]
+# @BRIEF Literal committed-source/evidence fixtures exercise the actual ledger parser and complete parameter/phase/JUnit join without SQL or pytest dispatch.
+# @RELATION BINDS_TO -> [Tooling.DashboardTestingAccounting.Validate]
+# @TEST_INVARIANT A green aggregate cannot hide an absent symbol, missing parameter report, xfail, duplicate phase, stale commit or tampered artifact.
+from collections import Counter
+from hashlib import sha256
+import importlib.util
+import json
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[3]
+SPEC = importlib.util.spec_from_file_location('accounting', ROOT / 'scripts/validate_dashboard_testing_accounting.py')
+tool = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(tool)
+
+COMMIT = '7' * 40
+REF = 'backend/tests/services/dashboard_testing/test_current.py::test_current'
+CLASS_REF = 'backend/tests/services/dashboard_testing/test_current.py::TestOwner.test_current'
+OLD = 'services/dashboard_testing/test_removed.py::test_old'
+OTHER = 'services/dashboard_testing/test_removed.py::test_other'
+EMPTY = 'services/dashboard_testing/test_removed.py::test_mechanics'
+NODES = [
+ 'tests/services/dashboard_testing/test_current.py::test_current[alpha]',
+ 'tests/services/dashboard_testing/test_current.py::test_current[beta]',
+ 'tests/services/dashboard_testing/test_current.py::TestOwner::test_current',
+ 'tests/api/test_current.py::test_api',
+]
+
+
+def literal_ledger():
+ # Historical key1 first points elsewhere; the named final overlay explicitly selects REF.
+ return '\n'.join([
+ '### One combined pending withdrawal list',
+ '| Exact historical key | Withdrawal reason |', '| --- | --- |',
+ f'| `{OLD}` | withdrawn premise; retained current assertion |',
+ f'| `{OTHER}` **outside275** | retained class property |',
+ f'| `{EMPTY}` | file mechanics only |',
+ '### Supplemental API reachability — current per-key status',
+ '```jsonl', '```',
+ '### Machine-readable original275-key current-status manifest', '```jsonl',
+ json.dumps({'key':OLD, 'state':'PENDING_B', 'tests':[CLASS_REF]}),
+ json.dumps({'key':OTHER, 'state':'PENDING_B', 'tests':[CLASS_REF]}),
+ json.dumps({'key':EMPTY, 'state':'PENDING_B', 'tests':[]}), '```',
+ '### Machine-readable final640 current-property manifest', '```jsonl',
+ json.dumps({'key':OLD, 'state':'PENDING_B', 'current_refs':[{'key':REF, 'line':7, 'collected_nodes':2}]}),
+ '```',
+ ])
+
+
+class LiteralSource:
+ """External immutable Git-read seam only; parser, AST resolver and evidence join are real."""
+ commit = COMMIT
+
+ def __init__(self):
+ self.values = {
+ tool.LEDGER:literal_ledger().encode(),
+ 'scripts/verify_dashboard_testing_current.py':b"API_FILES = 'current'.split()\n",
+ 'backend/tests/services/dashboard_testing/test_current.py':b'def test_current(): pass\n'
+ b'class TestOwner:\n def test_current(self): pass\n',
+ 'backend/tests/api/test_current.py':b'def test_api(): pass\n',
+ }
+
+ def read(self, path):
+ if path not in self.values:
+ raise tool.AccountingError('ACCOUNTING_REF_MISSING', source_path=path)
+ return self.values[path]
+
+ def files(self):
+ return list(self.values)
+
+
+@pytest.fixture
+def wire(tmp_path):
+ events = []
+ for index, node in enumerate(NODES, 1):
+ trace = f'{index:032x}'
+ events.append({'src':'Tooling.VerifyDashboardTestingCurrent', 'marker':'REASON',
+ 'intent':'Run frozen suite node', 'trace_id':trace, 'payload':{'node_id':node}})
+ for phase in ('setup', 'call', 'teardown'):
+ events.append({'src':'Tooling.VerifyDashboardTestingCurrent', 'marker':'REFLECT',
+ 'intent':'Frozen suite node stage observed', 'trace_id':trace,
+ 'payload':{'node_id':node, 'stage':phase, 'outcome':'passed', 'wasxfail':False}})
+ junit = (''
+ ''
+ ''
+ ''
+ ''
+ '')
+ return SimpleNamespace(source=LiteralSource(), events=events, nodes=list(NODES), junit=junit,
+ summary={'commit':COMMIT, 'pytest_exit_code':0, 'collected':4, 'private_failure_diagnostics':0},
+ evidence=tmp_path)
+
+
+def persist(wire):
+ counts = Counter(event['payload']['stage'] + ':' + event['payload']['outcome']
+ for event in wire.events if event['marker'] == 'REFLECT')
+ data = {'summary.json':json.dumps({**wire.summary, 'outcomes':dict(counts)}).encode(),
+ 'nodes.json':json.dumps(wire.nodes).encode(), 'junit.xml':wire.junit.encode(),
+ 'molecular.jsonl':('\n'.join(json.dumps(event) for event in wire.events) + '\n').encode()}
+ for name, raw in data.items():
+ (wire.evidence / name).write_bytes(raw)
+ return {name:sha256(raw).hexdigest() for name, raw in data.items()}
+
+
+def validate(wire, digests=None):
+ return tool.validate(wire.source, wire.evidence, digests or persist(wire), expected_keys=3, expected_refs=2)
+
+
+def test_exact_chronological_ledger_resolves_class_and_all_parameters(wire):
+ result = validate(wire)
+ assert result['pending_keys'] == 3 and result['conserving_refs'] == 2
+ assert result['reference_parameter_joins'] == 3 and result['empty_reference_rows'] == 1
+ assert result['collected'] == 4 and result['commit'] == COMMIT
+ assert result['withdrawal_approval_inferred'] is False
+
+
+@pytest.mark.parametrize('mutation', ['file', 'symbol', 'duplicate_symbol'])
+def test_missing_or_ambiguous_current_symbol_is_typed_without_importing(wire, mutation):
+ path = 'backend/tests/services/dashboard_testing/test_current.py'
+ if mutation == 'file':
+ del wire.source.values[path]
+ elif mutation == 'symbol':
+ wire.source.values[path] = b'def test_different(): pass\n'
+ else:
+ wire.source.values[path] += b'def test_current(): pass\n'
+ code = 'ACCOUNTING_SOURCE_AMBIGUOUS' if mutation == 'duplicate_symbol' else 'ACCOUNTING_REF_MISSING'
+ with pytest.raises(tool.AccountingError, match='^' + code + '$'):
+ validate(wire)
+
+
+def test_parameter_cannot_disappear_from_collected_manifest(wire):
+ wire.nodes.remove(NODES[1])
+ wire.summary['collected'] = 3
+ with pytest.raises(tool.AccountingError, match='^ACCOUNTING_EVIDENCE_CONFLICT$'):
+ validate(wire)
+
+
+@pytest.mark.parametrize('mutation', ['missing_parameter_reports', 'missing_teardown', 'duplicate_phase',
+ 'failed_parameter', 'skipped_parameter', 'xfail_pass', 'old_wire', 'foreign_node'])
+def test_phase_and_parameter_negatives_never_hide_behind_green_summary(wire, mutation):
+ target = next(e for e in wire.events if e['payload'].get('node_id') == NODES[1]
+ and e['payload'].get('stage') == ('teardown' if mutation == 'missing_teardown' else 'call'))
+ if mutation == 'missing_parameter_reports':
+ wire.events = [e for e in wire.events if e['marker'] != 'REFLECT' or e['payload']['node_id'] != NODES[1]]
+ elif mutation == 'missing_teardown':
+ wire.events.remove(target)
+ elif mutation == 'duplicate_phase':
+ wire.events.append(target)
+ elif mutation in {'failed_parameter', 'skipped_parameter'}:
+ target['payload']['outcome'] = 'failed' if mutation == 'failed_parameter' else 'skipped'
+ if mutation == 'skipped_parameter':
+ wire.junit = wire.junit.replace('skipped="0"', 'skipped="1"').replace(
+ 'name="test_current[beta]"/>', 'name="test_current[beta]">')
+ elif mutation == 'xfail_pass':
+ target['payload']['wasxfail'] = True
+ elif mutation == 'old_wire':
+ del target['payload']['wasxfail']
+ else:
+ target['payload']['node_id'] = 'tests/services/dashboard_testing/test_foreign.py::test_foreign'
+ with pytest.raises(tool.AccountingError) as failure:
+ validate(wire)
+ expected = {'duplicate_phase':'ACCOUNTING_PHASE_CONFLICT', 'foreign_node':'ACCOUNTING_PHASE_CONFLICT',
+ 'old_wire':'ACCOUNTING_EVIDENCE_SCHEMA_INVALID', 'xfail_pass':'ACCOUNTING_REF_NOT_PASSED',
+ 'skipped_parameter':'ACCOUNTING_REF_NOT_PASSED'}
+ assert failure.value.code == expected.get(mutation, 'ACCOUNTING_EVIDENCE_CONFLICT')
+
+
+def test_test_authored_trace_context_change_is_retained_without_reassigning_node(wire):
+ target = next(e for e in wire.events if e['payload'].get('node_id') == NODES[0]
+ and e['payload'].get('stage') == 'call')
+ target['trace_id'] = 'test-authored-context'
+ result = validate(wire)
+ assert result['observed_stage_trace_changes'] == 1
+ assert result['reference_parameter_joins'] == 3
+
+
+@pytest.mark.parametrize('mutation', ['stale_commit', 'exit_partial', 'tamper', 'junit_missing', 'junit_skipped'])
+def test_exact_run_identity_digest_completion_and_junit_are_required(wire, mutation):
+ if mutation == 'stale_commit':
+ wire.summary['commit'] = '8' * 40
+ elif mutation == 'exit_partial':
+ wire.summary['pytest_exit_code'] = 3
+ elif mutation == 'junit_missing':
+ wire.junit = wire.junit.replace('', '')
+ elif mutation == 'junit_skipped':
+ wire.junit = wire.junit.replace('name="test_current[beta]"/>', 'name="test_current[beta]">')
+ digests = persist(wire)
+ if mutation == 'tamper':
+ (wire.evidence / 'nodes.json').write_text('["PRIVATE_UNTRUSTED_BODY"]')
+ expected = {'stale_commit':'ACCOUNTING_COMMIT_CONFLICT', 'exit_partial':'ACCOUNTING_RUN_NOT_SUCCESSFUL',
+ 'tamper':'ACCOUNTING_EVIDENCE_DIGEST_CONFLICT', 'junit_missing':'ACCOUNTING_JUNIT_CONFLICT',
+ 'junit_skipped':'ACCOUNTING_JUNIT_CONFLICT'}
+ with pytest.raises(tool.AccountingError, match='^' + expected[mutation] + '$') as failure:
+ validate(wire, digests)
+ assert 'PRIVATE_UNTRUSTED_BODY' not in str(failure.value)
+ assert failure.value.__suppress_context__
+
+
+def test_whole_scope_requires_unreferenced_api_test_too(wire):
+ wire.nodes.remove(NODES[3])
+ wire.summary['collected'] = 3
+ with pytest.raises(tool.AccountingError, match='^ACCOUNTING_WHOLE_SCOPE_CONFLICT$'):
+ validate(wire)
+
+
+@pytest.mark.parametrize('mutation', ['unknown_heading', 'wrong_key', 'empty_assertions', 'missing_assertions'])
+def test_only_exact_named_period_checkpoint_can_declare_same_key_conservation(mutation):
+ heading, key, assertions = 'Post-proof period fixture and receipt-error privacy checkpoint', tool.PERIOD_REF, ['status == 409']
+ if mutation == 'unknown_heading':
+ heading = 'Post-proof arbitrary checkpoint'
+ elif mutation == 'wrong_key':
+ key = REF
+ elif mutation == 'empty_assertions':
+ assertions = []
+ row = {'key':key, 'state':'PENDING_B', 'current_assertions':assertions}
+ if mutation == 'missing_assertions':
+ del row['current_assertions']
+ text = literal_ledger() + '\n### ' + heading + '\n```jsonl\n' + json.dumps(row) + '\n```'
+ with pytest.raises(tool.AccountingError, match='^ACCOUNTING_LEDGER_INVALID$'):
+ tool.parse_ledger(text)
+
+
+def test_explicit_period_checkpoint_is_a_reference_not_a_pass_exemption():
+ text = literal_ledger().replace('### One combined pending withdrawal list',
+ '### One combined pending withdrawal list\n| `' + tool.PERIOD_REF + '` | current assertion |')
+ text += '\n### Post-proof period fixture and receipt-error privacy checkpoint\n```jsonl\n' + json.dumps({
+ 'key':tool.PERIOD_REF, 'state':'PENDING_B', 'current_assertions':['status == 409']}) + '\n```'
+ assert tool.parse_ledger(text)[tool.PERIOD_REF] == [tool.PERIOD_REF]
+
+
+@pytest.mark.parametrize('mutation', ['duplicate_key', 'unknown_overlay', 'missing_array', 'selected_state_conflict'])
+def test_ledger_missing_and_conflicting_explicit_authority_refuses(mutation):
+ text = literal_ledger()
+ if mutation == 'duplicate_key':
+ text = text.replace(f'| `{EMPTY}` |', f'| `{OLD}` |')
+ elif mutation == 'unknown_overlay':
+ text += '\n### Guessed replacement map\n```jsonl\n{}\n```'
+ elif mutation == 'missing_array':
+ text = text.replace('"tests": []', '"reason": "PRIVATE_MISSING_ARRAY_SENTINEL"')
+ else:
+ text = text.replace('"state": "PENDING_B", "current_refs":',
+ '"state": "RESTORED_SOURCE", "current_refs":')
+ with pytest.raises(tool.AccountingError) as failure:
+ tool.parse_ledger(text)
+ assert failure.value.code in {'ACCOUNTING_LEDGER_INVALID', 'ACCOUNTING_JSON_INVALID', 'ACCOUNTING_LEDGER_STATE_CONFLICT'}
+ assert 'PRIVATE_MISSING_ARRAY_SENTINEL' not in str(failure.value)
+
+
+def test_same_block_duplicate_record_cannot_override_explicit_reference():
+ text = literal_ledger()
+ original = json.dumps({'key':OLD, 'state':'PENDING_B', 'tests':[CLASS_REF]})
+ text = text.replace(original, original + '\n' + json.dumps({
+ 'key':OLD, 'state':'PENDING_B', 'tests':[]}))
+ with pytest.raises(tool.AccountingError, match='^ACCOUNTING_LEDGER_INVALID$'):
+ tool.parse_ledger(text)
+
+
+def test_consistent_parameter_omission_cannot_match_independently_reviewed_manifest_digest(wire):
+ reviewed_digests = persist(wire)
+ wire.nodes.remove(NODES[1])
+ wire.summary['collected'] = 3
+ wire.events = [event for event in wire.events if event['payload']['node_id'] != NODES[1]]
+ wire.junit = wire.junit.replace('tests="4"', 'tests="3"').replace(
+ '', '')
+ persist(wire)
+ with pytest.raises(tool.AccountingError, match='^ACCOUNTING_EVIDENCE_DIGEST_CONFLICT$'):
+ validate(wire, reviewed_digests)
+
+
+def test_actual_committed_ledger_resolves_explicit_refs_without_test_imports():
+ import subprocess
+ commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip()
+ source = tool.GitSource(ROOT, commit)
+ ledger = tool.parse_ledger(source.read(tool.LEDGER).decode())
+ refs = {ref for values in ledger.values() for ref in values}
+ symbols = tool.source_nodes(source)
+ assert len(ledger) == 347 and len(refs) == 275
+ assert sum(not values for values in ledger.values()) == 49
+ assert all(symbols[tool.reference(ref)[0]].count(tool.reference(ref)[1]) == 1 for ref in refs)
+
+
+def test_xfail_boolean_is_present_in_actual_launcher_stage_projection():
+ # Inspect the real hook AST without dispatching pytest or constructing a fake passing run.
+ import ast
+ tree = ast.parse((ROOT / 'scripts/verify_dashboard_testing_current.py').read_bytes())
+ hook = next(node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef)
+ and node.name == 'pytest_runtest_logreport')
+ payload = next(node for node in ast.walk(hook) if isinstance(node, ast.Dict)
+ and any(isinstance(key, ast.Constant) and key.value == 'node_id' for key in node.keys))
+ position = next(i for i, key in enumerate(payload.keys) if isinstance(key, ast.Constant) and key.value == 'wasxfail')
+ expression = ast.Expression(payload.values[position])
+ for authored, expected in [(SimpleNamespace(), False), (SimpleNamespace(wasxfail='PRIVATE_REASON'), True)]:
+ assert eval(compile(expression, '', 'eval'), {'report':authored}) is expected
+# #endregion Test.DashboardTestingAccounting
diff --git a/scripts/validate_dashboard_testing_accounting.py b/scripts/validate_dashboard_testing_accounting.py
new file mode 100644
index 000000000..937ebeda0
--- /dev/null
+++ b/scripts/validate_dashboard_testing_accounting.py
@@ -0,0 +1,392 @@
+#!/usr/bin/env python3
+# #region Tooling.DashboardTestingAccounting [C:3] [TYPE Module] [SEMANTICS accounting,verification,pytest,freeze]
+# @BRIEF Resolve the existing combined withdrawal ledger against committed source and one complete frozen suite.
+# @PRE Evidence digests come from the reviewed strict-launcher run receipt, independently of these mutable input files; no test, DB or source mutation occurs here.
+# @POST Every conserving reference exists at the exact commit and all parameters in the pinned actual collection manifest passed every phase without xfail.
+# @INVARIANT This validator does not statically derive dynamic pytest fixture/metafunc parameter inventory or authenticate its caller's receipt.
+# @INVARIANT No nearest-name, first-parameter, working-tree or historical-wire fallback; approval is not inferred.
+# @RATIONALE The ledger contains chronological explicit overlays; only its named machine records select conserving tests.
+# @REJECTED Markdown keyword guesses and a green summary alone cannot establish that the referenced assertions ran.
+from __future__ import annotations
+
+import argparse
+import ast
+from collections import Counter
+from hashlib import sha256
+import json
+from pathlib import Path
+import re
+import subprocess
+import sys
+import uuid
+import xml.etree.ElementTree as ET
+
+LEDGER = 'specs/050-mcp-interface/plans/2026-10-10-deleted-test-accounting.md'
+OWNER = 'Tooling.VerifyDashboardTestingCurrent'
+PERIOD_REF = ('backend/tests/services/dashboard_testing/execution/test_start_run_period_receipt.py::'
+ 'test_digest_mismatch_writes_no_receipt')
+BLOCKS = (
+ 'Supplemental API reachability — current per-key status',
+ 'Machine-readable original275-key current-status manifest',
+ 'Reference discovery/capture twenty-key checkpoint',
+ 'Open/closed metadata and provenance assertion checkpoint',
+ 'Scenario/reference API twenty-two same-name assertion review',
+ 'Registry twenty-nine same-name assertion checkpoint',
+ 'Candidate kind bounded source checkpoint',
+ 'Four-owner assertion restoration checkpoint',
+ 'Machine-readable final640 current-property manifest',
+ 'Post-proof period fixture and receipt-error privacy checkpoint',
+ 'Post-proof visual reference phase checkpoint', 'Post-proof immutability fixture checkpoint',
+ 'Post-proof synchronous verification fixture checkpoint', 'Post-proof scenario-runs API fixture checkpoint',
+ 'Post-proof inheritance current-source checkpoint', 'Post-proof native metric and single-chart rollback checkpoint',
+ 'Post-proof candidate provenance primary-only checkpoint',
+ 'Final post-proof assertion audit — comparison fault restored',
+ 'Current release-refusal restoration after c99',
+ 'Current faithful public denied-visual consumption restoration',
+)
+
+
+class AccountingError(Exception):
+ """Closed public code and safe source/node identities only, never input bodies."""
+ def __init__(self, code, **facts):
+ super().__init__(code)
+ self.code, self.facts = code, facts
+
+
+def refuse(code, **facts):
+ raise AccountingError(code, **facts) from None
+
+
+def require(condition, code='ACCOUNTING_EVIDENCE_CONFLICT', **facts):
+ if not condition:
+ refuse(code, **facts)
+
+
+def strict_json(raw):
+ def pairs(items):
+ result = {}
+ for key, value in items:
+ require(key not in result, 'ACCOUNTING_JSON_INVALID')
+ result[key] = value
+ return result
+ try:
+ return json.loads(raw, object_pairs_hook=pairs,
+ parse_constant=lambda _: refuse('ACCOUNTING_JSON_INVALID'))
+ except (ValueError, TypeError, UnicodeError):
+ refuse('ACCOUNTING_JSON_INVALID')
+
+
+# #region Tooling.DashboardTestingAccounting.Reference [C:2] [TYPE Function]
+# @POST A reference resolves only an explicit backend test path and qualified test symbol, with optional exact parameter ID.
+def reference(raw):
+ require(isinstance(raw, str) and len(raw) <= 1024 and not re.search(r'[\x00-\x1f]', raw),
+ 'ACCOUNTING_REF_INVALID')
+ if raw.startswith(('services/', 'api/')):
+ raw = 'backend/tests/' + raw
+ match = re.fullmatch(r'(backend/tests/(?:[A-Za-z0-9_]+/)*test_[A-Za-z0-9_]+\.py)::'
+ r'((?:[A-Za-z_]\w*\.)*test_\w+)(\[.*\])?', raw)
+ require(match is not None, 'ACCOUNTING_REF_INVALID')
+ path, symbol, parameter = match.groups()
+ return path, symbol, parameter or ''
+# #endregion Tooling.DashboardTestingAccounting.Reference
+
+
+def canonical(raw):
+ path, symbol, parameter = reference(raw)
+ return path + '::' + symbol + parameter
+
+
+def record_refs(row, heading):
+ fields = [name for name in ('tests', 'replacement', 'current_refs') if name in row]
+ require(len(fields) <= 1, 'ACCOUNTING_LEDGER_INVALID')
+ if not fields:
+ # This named checkpoint explicitly retains same-key current_assertions rather than a refs array.
+ require(heading == BLOCKS[9] and row.get('key') == PERIOD_REF
+ and isinstance(row.get('current_assertions'), list) and row['current_assertions']
+ and all(isinstance(item, str) and item for item in row['current_assertions']),
+ 'ACCOUNTING_LEDGER_INVALID')
+ return [PERIOD_REF]
+ values = row[fields[0]]
+ require(isinstance(values, list), 'ACCOUNTING_LEDGER_INVALID')
+ return [canonical(value.get('key') if isinstance(value, dict) else value) for value in values]
+
+
+# #region Tooling.DashboardTestingAccounting.Ledger [C:3] [TYPE Function]
+# @POST The exact combined table joins chronological named records; missing/foreign states and duplicate keys refuse.
+def parse_ledger(text):
+ keys, states, seen_blocks, block_keys = [], {}, set(), set()
+ heading, active, fence = '', None, None
+ for line in text.splitlines():
+ if line.startswith('### '):
+ heading = line[4:]
+ if line.startswith('```'):
+ if fence is not None:
+ require(line == '```', 'ACCOUNTING_LEDGER_INVALID')
+ fence = active = None
+ else:
+ fence = line
+ if line == '```jsonl':
+ require(heading in BLOCKS and heading not in seen_blocks, 'ACCOUNTING_LEDGER_INVALID')
+ seen_blocks.add(heading)
+ active = heading
+ block_keys = set()
+ continue
+ if active and line.strip():
+ row = strict_json(line)
+ require(isinstance(row, dict), 'ACCOUNTING_LEDGER_INVALID')
+ key = canonical(row.get('supplemental_key', row.get('key')))
+ require(key not in block_keys, 'ACCOUNTING_LEDGER_INVALID', ref=key)
+ block_keys.add(key)
+ state = row.get('state')
+ require(state in {'PENDING_B', 'RESTORED_SOURCE', 'OPEN_A'}, 'ACCOUNTING_LEDGER_INVALID')
+ states[key] = state, record_refs(row, active)
+ if fence is None and heading == 'One combined pending withdrawal list' and line.startswith('| `'):
+ match = re.match(r'\| `([^`]+)`(?: \*\*[^|`]+\*\*)? \|', line)
+ require(match is not None, 'ACCOUNTING_LEDGER_INVALID')
+ keys.append(canonical(match[1]))
+ require(fence is None and {BLOCKS[0], BLOCKS[1], BLOCKS[8]} <= seen_blocks,
+ 'ACCOUNTING_LEDGER_INVALID')
+ require(keys and len(keys) == len(set(keys)), 'ACCOUNTING_LEDGER_INVALID')
+ # The current combined table owns membership; frozen historical manifests can retain a
+ # removed key whose explicit restoration is recorded in a later prose checkpoint.
+ require(set(keys) <= {key for key, value in states.items() if value[0] == 'PENDING_B'},
+ 'ACCOUNTING_LEDGER_STATE_CONFLICT')
+ return {key: states[key][1] for key in keys}
+# #endregion Tooling.DashboardTestingAccounting.Ledger
+
+
+# #region Tooling.DashboardTestingAccounting.Source [C:2] [TYPE Class]
+# @POST Source and ledger bytes are read from one existing commit, never checked-out files or imports.
+class GitSource:
+ def __init__(self, root, commit):
+ require(re.fullmatch(r'[0-9a-f]{40}', commit) is not None, 'ACCOUNTING_COMMIT_INVALID')
+ self.root, self.commit = root, commit
+ require(self.git('rev-parse', commit + '^{commit}').decode().strip() == commit,
+ 'ACCOUNTING_COMMIT_INVALID')
+
+ def git(self, *args):
+ result = subprocess.run(['git', *args], cwd=self.root, capture_output=True)
+ require(result.returncode == 0, 'ACCOUNTING_SOURCE_UNAVAILABLE')
+ return result.stdout
+
+ def read(self, path):
+ result = subprocess.run(['git', 'show', self.commit + ':' + path], cwd=self.root, capture_output=True)
+ require(result.returncode == 0, 'ACCOUNTING_REF_MISSING', source_path=path)
+ return result.stdout
+
+ def files(self):
+ return self.git('ls-tree', '-r', '--name-only', self.commit, '--', 'backend/tests').decode().splitlines()
+# #endregion Tooling.DashboardTestingAccounting.Source
+
+
+def test_symbols(raw):
+ try:
+ tree = ast.parse(raw)
+ except (SyntaxError, ValueError):
+ refuse('ACCOUNTING_SOURCE_INVALID')
+ symbols = []
+ for node in tree.body:
+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name.startswith('test_'):
+ symbols.append(node.name)
+ elif isinstance(node, ast.ClassDef) and node.name.startswith('Test'):
+ symbols.extend(node.name + '.' + child.name for child in node.body
+ if isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef)) and child.name.startswith('test_'))
+ return symbols
+
+
+def imported_symbols(source, path, trail=()):
+ require(path not in trail, 'ACCOUNTING_SOURCE_IMPORT_CYCLE')
+ raw = source.read(path)
+ symbols = test_symbols(raw)
+ for node in ast.parse(raw).body:
+ if isinstance(node, ast.ImportFrom) and node.module and node.module.startswith('tests.'):
+ for alias in node.names:
+ target = alias.asname or alias.name
+ if target.startswith(('Test', 'test_')):
+ imported = imported_symbols(source, 'backend/' + node.module.replace('.', '/') + '.py',
+ (*trail, path))
+ symbols.extend(target + name[len(alias.name):] for name in imported
+ if name == alias.name or name.startswith(alias.name + '.'))
+ return symbols
+
+
+def source_nodes(source):
+ tree = ast.parse(source.read('scripts/verify_dashboard_testing_current.py'))
+ value = next((node.value for node in tree.body if isinstance(node, ast.Assign)
+ and any(isinstance(t, ast.Name) and t.id == 'API_FILES' for t in node.targets)), None)
+ require(isinstance(value, ast.Call) and isinstance(value.func, ast.Attribute)
+ and value.func.attr == 'split' and isinstance(value.func.value, ast.Constant), 'ACCOUNTING_LAUNCHER_INVALID')
+ api = {'backend/tests/api/test_' + name + '.py' for name in value.func.value.value.split()}
+ paths = {p for p in source.files() if p.startswith('backend/tests/services/dashboard_testing/')
+ and Path(p).name.startswith('test_') and p.endswith('.py')} | api
+ return {path: imported_symbols(source, path) for path in sorted(paths)}
+
+
+def node_base(path, symbol):
+ return path.removeprefix('backend/') + '::' + symbol.replace('.', '::')
+
+
+def digest_bytes(path, expected):
+ require(re.fullmatch(r'[0-9a-f]{64}', expected) is not None, 'ACCOUNTING_DIGEST_INVALID')
+ try:
+ require(not path.is_symlink() and path.is_file(), 'ACCOUNTING_EVIDENCE_INVALID')
+ raw = path.read_bytes()
+ except OSError:
+ refuse('ACCOUNTING_EVIDENCE_UNAVAILABLE')
+ require(sha256(raw).hexdigest() == expected, 'ACCOUNTING_EVIDENCE_DIGEST_CONFLICT', artifact=path.name)
+ return raw
+
+
+# #region Tooling.DashboardTestingAccounting.Events [C:3] [TYPE Function]
+# @POST Every node has one source-owned start trace and unique phase reports with explicit wasxfail; old wire refuses.
+def stage_events(raw, nodes):
+ starts, stages, counts, trace_changes = {}, {}, Counter(), 0
+ for line in raw.splitlines():
+ event = strict_json(line)
+ require(isinstance(event, dict), 'ACCOUNTING_EVIDENCE_SCHEMA_INVALID')
+ if event.get('src') != OWNER:
+ continue
+ require(not event.get('payload_truncated'), 'ACCOUNTING_EVIDENCE_SCHEMA_INVALID')
+ require(event.get('error_code') not in {'FINAL_COLLECTION_FAILED', 'FINAL_INTERNAL_ERROR',
+ 'FINAL_NODE_FAILED', 'FINAL_UNPLANNED_CONTAINER_FIXTURE'}, 'ACCOUNTING_RUN_NOT_SUCCESSFUL')
+ payload = event.get('payload', {})
+ require(isinstance(payload, dict), 'ACCOUNTING_EVIDENCE_SCHEMA_INVALID')
+ node, trace = payload.get('node_id'), event.get('trace_id')
+ if event.get('marker') == 'REASON' and event.get('intent') == 'Run frozen suite node':
+ require(node in nodes and node not in starts and isinstance(trace, str)
+ and re.fullmatch(r'[0-9a-f]{32}', trace) is not None, 'ACCOUNTING_EVIDENCE_CONFLICT')
+ starts[node] = trace
+ elif event.get('marker') == 'REFLECT' and event.get('intent') == 'Frozen suite node stage observed':
+ phase, outcome = payload.get('stage'), payload.get('outcome')
+ require(node in starts and isinstance(trace, str) and 0 < len(trace) <= 256
+ and not re.search(r'[\x00-\x1f]', trace) and phase in {'setup', 'call', 'teardown'}
+ and outcome in {'passed', 'failed', 'skipped'} and (node, phase) not in stages,
+ 'ACCOUNTING_PHASE_CONFLICT', stage=phase if phase in {'setup', 'call', 'teardown'} else 'invalid')
+ require(type(payload.get('wasxfail')) is bool, 'ACCOUNTING_EVIDENCE_SCHEMA_INVALID', node_id=node, stage=phase)
+ preceding = {'setup':None, 'call':'setup', 'teardown':'setup' if (node, 'call') not in stages else 'call'}[phase]
+ require(preceding is None or (node, preceding) in stages, 'ACCOUNTING_PHASE_CONFLICT', node_id=node, stage=phase)
+ require(phase != 'teardown' or preceding == 'call' or stages[node, 'setup'][0] == 'skipped',
+ 'ACCOUNTING_PHASE_CONFLICT', node_id=node, stage=phase)
+ stages[node, phase] = outcome, payload['wasxfail']
+ trace_changes += trace != starts[node]
+ counts[phase + ':' + outcome] += 1
+ require(set(starts) == set(nodes) and len(set(starts.values())) == len(nodes), 'ACCOUNTING_EVIDENCE_CONFLICT')
+ return stages, counts, trace_changes
+# #endregion Tooling.DashboardTestingAccounting.Events
+
+
+def junit_cases(raw, nodes, counts):
+ require(b'