- EvidenceChainRail: the spine's seven stages rendered per subject with the honesty contract — lit/hollow/dim derive ONLY from carried fields (a trace hash lights 'replay' as RECORDED, never as verified); pure deriveStages() with meaningfully-fail tests (remove one field -> exactly its stage hollows). - Hash display standard: DigestBadge default 12-char + copy everywhere; CopyableHash consolidated away (2 call sites swapped, file deleted). - Typography: tabular-nums on MetadataTable values + eval metrics; text-wrap balance on Panel titles + EmptyState statements. - Selection unification: new --color-selected-bg/-border tokens; selected (persistent) vs focused (transient) now visually distinct across Proposals/Replay/Evals lists; focus-ring no longer doubles as selection. - EmptyState gains a deterministic monochrome inline-SVG glyph. - Panel adopted in Evals lane list + Proposals queue. - Doctrine-as-tests: hexScan (no palette literals outside tokens.css/ generated tokens.ts) + schemaDrift gate (scripts/dump-schemas.py AST walk -> schema-snapshot.json -> every dataclass field mirrored in types/api.ts; explicit shrink-only NOT_YET_MIRRORED debt list). The drift gate caught real drift on first run: ChatTurnResult.turn_id existed in Python, missing from TS — now mirrored. Verified: build green; vitest 36 files / 279 tests EXIT=0; playwright 12/12; dump-schemas.py runs clean.
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""Dump workbench API dataclass field names for UI schema-drift tests.
|
|
|
|
Read-only helper: parses workbench/schemas.py with Python AST and writes
|
|
JSON to stdout — {class_name: [own_field, ...]}. Inherited fields belong
|
|
to the parent class entry (the TS mirrors use `extends` the same way).
|
|
Same pattern as scripts/dump-enums.py (ADR-0162 enum coverage).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import ast
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SCHEMAS = ROOT / "workbench" / "schemas.py"
|
|
|
|
|
|
def is_dataclass_decorated(node: ast.ClassDef) -> bool:
|
|
for dec in node.decorator_list:
|
|
target = dec.func if isinstance(dec, ast.Call) else dec
|
|
if isinstance(target, ast.Name) and target.id == "dataclass":
|
|
return True
|
|
if isinstance(target, ast.Attribute) and target.attr == "dataclass":
|
|
return True
|
|
return False
|
|
|
|
|
|
def own_fields(node: ast.ClassDef) -> list[str]:
|
|
fields: list[str] = []
|
|
for statement in node.body:
|
|
if isinstance(statement, ast.AnnAssign) and isinstance(statement.target, ast.Name):
|
|
fields.append(statement.target.id)
|
|
return fields
|
|
|
|
|
|
def main() -> None:
|
|
module = ast.parse(SCHEMAS.read_text(encoding="utf-8"))
|
|
out: dict[str, list[str]] = {}
|
|
for node in module.body:
|
|
if isinstance(node, ast.ClassDef) and is_dataclass_decorated(node):
|
|
out[node.name] = own_fields(node)
|
|
if not out:
|
|
raise SystemExit("no dataclasses found in workbench/schemas.py")
|
|
print(json.dumps(out, indent=2, sort_keys=True))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|