arborist-viz/arborist_viz/tests/test_schemas.py
russell@unturf.com 0cd96ab1d7
Initial commit: arborist VIZ — Merkle command center
Pyramid web app for inspecting arborist Merkle trees over sharded SQLite:
document roots, inclusion proofs, an interactive 3D Merkle lattice
(six.js / WebGL with graceful fallback), audit-chain linkage, and a live
SSE event stream.

Generated artifacts (env/, vendored static/six/ bundles, demo databases)
are gitignored and rebuilt via the Makefile (venv, six, init-db, serve).
2026-05-28 09:22:59 -04:00

85 lines
2.2 KiB
Python

"""Schema invariants — ticket hard rules baked into the dataclasses."""
from __future__ import annotations
from arborist_viz.schemas import (
ActivationHookpoint,
ActivationTrace,
CausalStatus,
DashboardConfig,
EdgeKind,
NodeKind,
NodeStatus,
PanelLayout,
ProofPath,
QuerySpec,
ViewSpec,
VizEdge,
VizNode,
WarrantLevel,
WidgetSpec,
WidgetType,
)
def test_proof_passed_property():
p = ProofPath(
root_hash="r",
leaf_index=0,
leaf_hash="l",
canonical_bytes_hash="c",
sibling_hashes=[],
left_right_flags=[],
computed_root="r",
expected_root="r",
domain_separator="d",
canonicalization_version="1",
chunking_version="1",
schema_version="1",
verifier_policy_hash="v",
)
assert p.passed is True
p.computed_root = "different"
assert p.passed is False
def test_causal_status_defaults_to_correlational():
"""Ticket §11 — never causal unless intervention or ablation evidence exists."""
trace = ActivationTrace(
trace_id="t1",
run_id="r1",
model_id="m1",
model_profile_hash="h1",
prompt_hash="p1",
token_span=(0, 1),
hookpoints=[],
trace_root="tr1",
)
assert trace.causal_status == CausalStatus.CORRELATIONAL_TRACE
def test_widget_spec_carries_source_roots():
"""§19.3 — every widget exposes the roots it derived from."""
w = WidgetSpec(
widget_id="w1",
type=WidgetType.ROOT_EXPLORER,
title="t",
data_source_id="ds1",
query=QuerySpec(select=["root_hash"], from_="roots"),
view=ViewSpec(renderer="table"),
source_roots=["abc"],
)
assert w.source_roots == ["abc"]
def test_node_status_includes_quarantine_states():
# arborist #000049 self-provenance quarantine must round-trip.
assert NodeStatus.SELF_PROVENANCE_QUARANTINED.value == "self_provenance_quarantined"
assert NodeStatus.QUARANTINED.value == "quarantined"
def test_warrant_ladder_is_ordered_strings():
levels = [w.value for w in WarrantLevel]
assert levels[0] == "UNGROUNDED"
assert levels[-1] == "FORMALLY_PROVED"