ouroboros/tests/test_delegate_owner_facades.py
Ouroboros 1b4a8da957 v7next F2: D07 finisher - terminal-evidence leaf, strict worktree registry, sdn facade stands
Owner forks resolved (batch 5, 31.08): 5.9A renamed the deferred terminal
leaf of tools/delegate.py to tools/delegate_terminal_evidence.py (upstream
owns ouroboros/delegate_terminal.py; F5 rename recorded); 5.10A carried the
subagent_worktrees.py strict-registry delta in place with its 11-test pin
suite (tip==merge-base for the module; landed bytes == the reference blob);
5.11A left the subagent_dispatch_notes facade standing.

Ledger rows 3468-3476 cut from tip bytes (drift-probe: 7/9 byte-true,
2 re-emitted; ast=tokens=byte-roundtrip=True on all 9 spans, exit 0) with
the MAXIMAL declared set - every parent-scope call-time read goes through
_delegate() (12 names, LEAVES-pinned). tools/delegate.py 1600 -> 1263
leaves the hard cap and enters the 1001-1500 band; subagent_worktrees.py
1000 -> 1082 enters the band under the owner-sanctioned delta; manifest
regenerated by the official tool. domains.toml untouched (coordinator
seam).

(cherry picked from commit c32e0cd6b304d90e63504e829ff5ee5ebcd1f0fe)
2026-08-31 10:38:31 +00:00

97 lines
4.4 KiB
Python

"""Facade-identity contract for the v7 DEL1 delegate-family leaf owners.
Every member the DEL1 split moved out of the delegate family —
``ouroboros/delegate_custody.py``, ``ouroboros/tools/delegate_integration.py``,
``ouroboros/tools/subagent_integration.py`` — and the route-health family moved
out of ``ouroboros/subagents.py`` keeps a parent re-export under its historical
name for the DURATION of the v7 stream, so existing callers and monkeypatching
tests keep working unchanged while the split lands. This pins the facade
identity — the parent binding IS the leaf's object — and the hot-code label
parity for the leaves, the same way the queue and loop splits pin both for
theirs.
One reference row is deliberately absent: ``_capture_stranded_patch`` was
re-homed by upstream itself (public ``capture_stranded_patch`` in
``tools/delegate_integration.py``). The ``tools/delegate.py`` terminal leaf
landed as ``delegate_terminal_evidence.py`` — the ledger's
``tools/delegate_terminal.py`` name collided with upstream's own
``ouroboros/delegate_terminal.py`` (owner fork F-2=A rename).
"""
from __future__ import annotations
import importlib
# parent module -> {leaf module -> every member the leaf owns (parent re-exports each name)}.
DELEGATE_LEAF_OWNERS: dict[str, dict[str, str]] = {
"ouroboros.delegate_custody": {
"ouroboros.delegate_custody_reconcile": (
"open_runs pending_invocations release_task_runs reconcile_task_runs "
"reconcile_orphaned_runs _reconcile_each _recover_pending_invocation "
"_retire_recovered_registration _reconcile_one"
),
},
"ouroboros.tools.delegate": {
"ouroboros.tools.delegate_terminal_evidence": (
"_containment_breach _NESTED_HOME_NOTE _NO_BOUNDARY_NOTE _containment_evidence "
"_terminal_payload _access_evidence _record_containment _reported_cost "
"_delivered_terminal_payload"
),
},
"ouroboros.tools.delegate_integration": {
"ouroboros.tools.delegate_payload_patch": (
"_reserved_payload_rel_path _snapshot_head_textual _write_payload_patch_artifacts "
"_payload_reserved_paths _candidate_symlink_escapes _finalize_payload_apply "
"integrate_payload_patch"
),
},
"ouroboros.tools.subagent_integration": {
"ouroboros.tools.subagent_integration_delegated": (
"_READY_CAPTURE_STATUSES _drift_refusal _locked_apply _manifest_capture_status "
"_capture_failed_refusal _capture_at_disposition _delegated_disposition_refusal "
"_unwritten_disposition_text _dispose_delegated _resolve_acknowledged_intent "
"_integrate_delegated_patch"
),
},
"ouroboros.subagents": {
"ouroboros.subagent_route_health": (
"route_health _exhausted_window _model_scope_matches _cooldown_active"
),
},
}
def test_delegate_owner_facades_preserve_identity() -> None:
for parent_name, leaves in DELEGATE_LEAF_OWNERS.items():
parent = importlib.import_module(parent_name)
for leaf_name, members in leaves.items():
leaf = importlib.import_module(leaf_name)
for member in members.split():
assert getattr(parent, member) is getattr(leaf, member), (
f"{parent_name}.{member} is not the {leaf_name} object"
)
def test_delegate_leaves_share_their_parents_hot_code_label_parity() -> None:
"""The delegate family is UNLABELED in the managed-update conflict policy at
the DEL1 base, so its leaves inherit that — parity, not blanket labelling
(the queue split pins the same property from the labeled side, and the
D07 control leaves are pinned hot by tests/test_control_extraction.py)."""
from supervisor.update_merge_policy import HOT_CODE_PATHS
parents = (
"ouroboros/delegate_custody.py",
"ouroboros/tools/delegate.py",
"ouroboros/tools/delegate_integration.py",
"ouroboros/tools/subagent_integration.py",
"ouroboros/subagents.py",
)
leaves = tuple(
leaf.replace(".", "/") + ".py"
for owners in DELEGATE_LEAF_OWNERS.values()
for leaf in owners
)
for path in parents:
assert path not in HOT_CODE_PATHS, f"{path} gained a hot-code label; relabel its leaves too"
for path in leaves:
assert path not in HOT_CODE_PATHS, f"{path} must keep parity with its unlabeled parent"