core/docs/decisions/ADR-0078-phase1-implementation-note.md
Shay 8e96728009 feat(telemetry): ADR-0078 Phase 1 — composer/graph atom equivalence (observational)
Wires observational telemetry on the composer-vs-graph atom-set
relationship.  Phase 1 is strictly observational: no enforcement,
no surface mutation, no grounding-source change, no trace-hash impact.

New telemetry fields on TurnEvent + ChatResponse:
  composer_graph_atom_status         ∈ {equivalent, divergent,
                                         graph_unconstrained,
                                         composer_no_atoms,
                                         not_applicable, ""}
  composer_atom_set_hash             SHA-256 over sorted unique atoms
  graph_atom_set_hash                SHA-256 over sorted unique atoms
  composer_graph_atom_overlap_count  int

Composer atoms come from existing pack candidate metadata
(pack_semantic_domains channel through _maybe_pack_grounded_surface).
Graph atoms come from build_graph_from_input + resolve_lemma on
node.subject/predicate/obj — no prose parsing.  When a grounded
composer path lacks explicit atom provenance, status is
'composer_no_atoms'.

New pure helper:
  chat/atom_equivalence.py — normalize_atoms, hash_atoms,
  atoms_for_graph_nodes, compare_atom_sets

Tests (tests/test_composer_graph_atom_equivalence.py):
  - Pack DEFINITION path produces observable equivalence
  - Divergent atom sets produce distinct hashes
  - Register invariance: atom hashes + status identical across
    {neutral, terse, convivial}; trace_hash also constant (R5 axis)
  - Anchor lens engaged case still ASCII-only on surface
  - No prose-parsing helper symbols introduced in runtime.py
    (extract_candidate_surface_lemmas, surface_lemma,
    parse_surface_atoms) — enforces Phase 1 boundary

Performance note: build_graph_from_input now runs on every warm
English turn (previously only when forward_graph_constraint=True).
Phase 1 accepts this cost to make the telemetry universally
available; Phase 2+ can introduce a feature flag if needed.

Validation:
  - Cognition eval byte-identical: 100/100/91.7/100
  - Full lane: 2864 passed, 3 skipped, 0 failed (+5 over baseline)
  - Targeted lane: 72 passed in tests/test_{graph_constraint,
    pack_grounding,register_tour_demo,anchor_lens_tour_demo,
    orthogonality_tour_demo,realizer_guard_holdout,
    composer_graph_atom_equivalence}.py
2026-05-20 06:14:25 -07:00

2.7 KiB

ADR-0078 Phase 1 — Pre-Implementation Planning Note

  1. Where composer atoms come from.
  • On DEFINITION/RECALL pack-grounded paths, composer provenance is available from existing pack candidate metadata (build_pack_surface_candidate(...).semantic_domains) and from the existing _maybe_pack_grounded_surface(...)->pack_semantic_domains return channel.
  • Other composer paths do not always expose explicit atom provenance today; those will report composer_no_atoms when telemetry is applicable and grounded but atom provenance is absent.
  1. Where graph-side atoms/indices are derived.
  • Graph topology comes from build_graph_from_input(text, articulation) and forward constraints from build_graph_constraint(graph, vocab).
  • Phase 1 graph atom telemetry will be observational and derived by resolving graph node surfaces (subject/predicate/obj) through chat.pack_resolver.resolve_lemma, unioning resolved semantic domains.
  • If no graph nodes resolve to atoms (or graph constraint is unconstrained), graph hash remains empty and status can become graph_unconstrained.
  1. Exact telemetry hook location.
  • Hook in chat/runtime.py after final composer surface / grounding source are known (cold/stub and warm paths) and after pre-generation graph context is known, but before TurnEvent and ChatResponse are finalized.
  • Keep this observational only: compute status/hash/overlap and attach fields; do not alter surface selection, guard outcomes, grounding source, or trace behavior.
  1. Why register variation does not affect atom hashes.
  • Register decoration/substantive transforms operate on rendered surface layers (register_canonical_surface -> pre-decoration -> decorated surface).
  • Composer atom provenance and graph atoms come from pack/graph structures, not register text transforms; therefore register changes should not perturb atom-set hashes/status for same prompt/lens/runtime state.
  1. Why anchor-lens engagement may affect substantive/proposition telemetry.
  • Anchor-lens changes composer proposition selection by engaging substrate-aligned semantic preferences (ADR-0073c/0073d), so resulting semantic domains and graph realization can legitimately differ when lens changes.
  • This is substantive-axis movement, not register-style presentation variation; telemetry must allow divergence/equivalence outcomes without forcing false invariants.
  1. Confirmation that no final surface prose parsing will be added.
  • No parsing of ChatResponse.surface/final prose will be introduced for atom inference.
  • No helpers like extract_candidate_surface_lemmas, surface_lemma, or parse_surface_atoms will be added.
  • If a grounded composer path lacks explicit atom provenance, status will be composer_no_atoms.