ADR-0072 ratified + implemented. Closes the register subsystem
inside-out arc (R1 ADR-0068 → R5 ADR-0072): the presentation axis is
now operator-visible, CI-falsifiable, and audit-traceable.
Telemetry extension
- TurnEvent + ChatResponse gain register_id + register_variant_id
(12-char SHA-256 prefix of selected (opening, closing) pair;
empty string for UNREGISTERED / no-decoration registers).
- serialize_turn_event surfaces both fields in every audit JSONL
line. Pre-R5 callers stay byte-identical (defaults are "").
Decoration result widened
- chat/register_variation.py: decorate_surface now returns
DecorationResult(surface, opening, closing, variant_id).
- decorate_surface_str alias preserves the pre-R5 string-only API
for off-runtime callers.
- chat/runtime.py updated at both call sites (stub + main).
Operator surface
- core chat --register REGISTER_ID threads into
RuntimeConfig.register_pack_id via _runtime_config_from_args.
- Invalid id ⇒ RegisterPackError caught at cmd_chat and surfaced
as a clean _die(...) before the REPL launches.
Narrative demo
- evals/register_tour/run_tour.py walks 4 prompts × 3 ratified
registers ({default_neutral_v1, terse_v1, convivial_v1}) and
asserts three load-bearing seam claims:
* all_grounding_sources_identical
* all_trace_hashes_identical (ADR-0069 invariant C, falsifiable)
* surfaces_vary_at_least_once (ADR-0071 seeded variation lift)
- core demo register-tour exit code = 0 iff every claim holds.
Tests
- tests/test_register_telemetry.py (6) — TurnEvent default,
serializer keys, runtime emits register_id/variant_id for
convivial/terse/unregistered, ChatResponse mirrors event fields.
- tests/test_register_cli.py (7) — _runtime_config_from_args
threading, invalid-id fail-fast, parser wires --register.
- tests/test_register_tour_demo.py (7) — three seam claims pinned
individually + all_claims_supported + per-cell register_id +
variant_id discipline (empty for neutral/terse, non-empty for
convivial).
- tests/test_register_variation.py extended (4 new) — DecorationResult
shape, decorate_surface_str alias, variant_id stability,
bijection between non-trivial marker pairs and variant_ids.
Lane evidence
- Full lane: 2632 passed / 4 skipped / 1 pre-existing failure
(tests/test_cli_demo.py::test_all_preamble_explains_combined_run,
unrelated to R5).
- Cognition eval byte-identical: public 100 / 100 / 91.7 / 100.
Trust boundaries (per CLAUDE.md)
- --register flag does not bypass ratification; loader validates the
pack id through _find_pack and the ratify gate at load time.
- variant_id is content-addressed; no raw markers leak into audit.
- Telemetry stays redact-safe — register_id and variant_id are
identifiers, not content, so include_content=False emits them
unconditionally.
- No new mutation surface; pack files on disk are not modified.
93 lines
3.1 KiB
Python
93 lines
3.1 KiB
Python
"""Register CLI — ``core chat --register <id>`` flag wiring
|
|
(ADR-0072 / Plan Phase R5).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
import pytest
|
|
|
|
from core.cli import _runtime_config_from_args
|
|
from core.config import DEFAULT_CONFIG
|
|
|
|
|
|
def _namespace(**overrides) -> argparse.Namespace:
|
|
"""Build a Namespace shaped like ``cmd_chat``'s args, allowing
|
|
targeted overrides for register / identity."""
|
|
defaults = dict(
|
|
output_language=DEFAULT_CONFIG.output_language,
|
|
frame_pack=None,
|
|
pack=None,
|
|
max_tokens=DEFAULT_CONFIG.max_tokens,
|
|
no_cross_language_recall=False,
|
|
allow_cross_language_generation=False,
|
|
vault_reproject_interval=DEFAULT_CONFIG.vault_reproject_interval,
|
|
no_salience=False,
|
|
salience_top_k=DEFAULT_CONFIG.salience_top_k,
|
|
inhibition_threshold=DEFAULT_CONFIG.inhibition_threshold,
|
|
inner_loop_admissibility=False,
|
|
admissibility_threshold=0.0,
|
|
identity="",
|
|
register=None,
|
|
)
|
|
defaults.update(overrides)
|
|
return argparse.Namespace(**defaults)
|
|
|
|
|
|
def test_runtime_config_default_register_is_none():
|
|
"""No --register on CLI ⇒ register_pack_id is None ⇒ unregistered."""
|
|
cfg = _runtime_config_from_args(_namespace())
|
|
assert cfg.register_pack_id is None
|
|
|
|
|
|
def test_runtime_config_threads_register_flag():
|
|
"""--register convivial_v1 ⇒ RuntimeConfig.register_pack_id set."""
|
|
cfg = _runtime_config_from_args(_namespace(register="convivial_v1"))
|
|
assert cfg.register_pack_id == "convivial_v1"
|
|
|
|
|
|
def test_runtime_config_empty_register_treated_as_none():
|
|
"""Empty-string --register (treated as unset) ⇒ None."""
|
|
cfg = _runtime_config_from_args(_namespace(register=""))
|
|
assert cfg.register_pack_id is None
|
|
|
|
|
|
def test_runtime_config_register_pack_id_threads_into_runtime():
|
|
"""Loading the runtime with a ratified register id wires
|
|
ChatRuntime.register_pack to a non-unregistered pack."""
|
|
from chat.runtime import ChatRuntime
|
|
|
|
cfg = _runtime_config_from_args(_namespace(register="convivial_v1"))
|
|
rt = ChatRuntime(config=cfg)
|
|
assert rt.register_pack_id == "convivial_v1"
|
|
assert rt.register_pack.register_id == "convivial_v1"
|
|
assert not rt.register_pack.is_unregistered()
|
|
|
|
|
|
def test_runtime_config_unratified_register_id_fails_fast():
|
|
"""An unratified / non-existent register id ⇒ RegisterPackError at
|
|
ChatRuntime init, not at first turn."""
|
|
from chat.runtime import ChatRuntime
|
|
from packs.register.loader import RegisterPackError
|
|
|
|
cfg = _runtime_config_from_args(_namespace(register="bogus_v999"))
|
|
with pytest.raises(RegisterPackError):
|
|
ChatRuntime(config=cfg)
|
|
|
|
|
|
def test_chat_parser_accepts_register_flag():
|
|
"""``core chat --register convivial_v1`` parses cleanly."""
|
|
from core.cli import build_parser
|
|
|
|
parser = build_parser()
|
|
ns = parser.parse_args(["chat", "--register", "convivial_v1"])
|
|
assert ns.register == "convivial_v1"
|
|
|
|
|
|
def test_chat_parser_register_defaults_none():
|
|
from core.cli import build_parser
|
|
|
|
parser = build_parser()
|
|
ns = parser.parse_args(["chat"])
|
|
assert ns.register is None
|