Files
rune/scripts/gen_dependency_tracker_truth.py
Nick 795e429159 feat(dependency_tracker): close PARTIAL gaps — dichotomy wave
audit 2/5 PARTIAL -> 6/6 FULL (RUST side; the 5 oracle fns + the main_cli
mirror). Name-preserving port into src/rust/dependency_tracker: the W6-era
stub was semantically INVERTED (map KEYS collected for value-list hits, a
transitive BFS where the oracle classifies direct dependents) — replaced
wholesale (audit_ledger precedent, one chain one implementation). Kernels:
get_dependents (posix basename + map lookup), check_propagation,
propagate (the full classification matrix against SCRIPTS_DIR —
propagated-with-reference / not-found / no-direct-reference /
IsADirectoryError crash-parity '[Errno 21] Is a directory: <path>' with
errno mapping + Display-suffix stripping, dry_run would-update
short-circuit), get_full_map (dict INSERTION order — the warm_router
dict-literal overwrite quirk: first position, last value), main (CLI
mirror, pure fn over argv incl. the frozen argparse help text).

Kernel/facade split: the facade's 4 compute fns delegate via dt_loader
(DT_RUST_LIB override; RUNE_DEPENDENCY_TRACKER_CORE=python pins the
load-bearing Python bodies; kernel failure falls back); SCRIPTS_DIR stays
import-time on the Python side and rides the propagate payload; main()
stays Python argparse (process boundary, never delegates); main_cli is
the JSON-native stdout+rc capture mirror. Spine scope test constraints
preserved (harness SCRIPTS_DIR, inline os.path.join body, no spine
imports).

Frozen truth: 24-row corpus via the shared freeze_truth harness under
scripts/dt_freeze_seams (HOME='.' + cwd-is-the-rig + deterministic
fixture tree incl. the directory-named-as-file error fixture; COLUMNS=80
for the argparse help width). --verify byte-identical twice. Battery
gap_battery.rs replays the truth VERBATIM in order (serde to_string
equality pins insertion order, not just structure). Live parity
scripts/check_dependency_tracker_parity.py 72/72 (pinned facade / live
facade / kernel direct). clippy -D warnings + fmt clean. Python suite
both pins: failure set byte-identical across pins AND the stashed base
(244 pre-existing, none touching this module); ruff clean.

New quirk (docs/dichotomy-oracle-quirks.json): Python 3.14
OSError.__str__ QUOTES the filename — proved by frozen battery row 20.

Evidence: verification/dt-*.exit + dt-summary.md (logs gitignored).
2026-10-14 21:10:31 +01:00

92 lines
4.9 KiB
Python

#!/usr/bin/env python3
"""Freeze dependency_tracker oracle truth for the Rust gap-closing port
battery (dichotomy wave #2479, shared harness scripts/freeze_truth.py).
Exercises EVERY public function and branch of
src/rune/dependency_tracker.py under the scripts/dt_freeze_seams rig
(HOME="." + cwd-is-the-rig + deterministic fixture tree):
get_dependents (graph hit, basename derivation from a path,
the warm_router dict-literal overwrite quirk —
the 2-item reassigned value at its first
insertion position, missing key, empty string)
check_propagation (same input classes; dict shape + count)
propagate (full classification matrix: propagated with
reference detail / skipped not-found / skipped
no-direct-reference / errors via the
IsADirectoryError fixture; dry_run would-update
short-circuit BEFORE the content check; basename
derivation; empty dependents)
get_full_map (the graph with Python dict insertion order —
warm_router overwritten value in place)
main_cli (CLI mirror: no-cmd help + rc 1, check with
count/arrows, check on a path, check empty,
propagate with all three sections + unicode
glyphs, propagate --dry-run, propagate empty,
map with the full table)
Run from the repo root:
PYTHONPATH=scripts/dt_freeze_seams python3 scripts/gen_dependency_tracker_truth.py
Verify (byte-identical law):
PYTHONPATH=src:scripts/dt_freeze_seams python3 scripts/freeze_truth.py \
--verify src/rust/dependency_tracker/src/frozen_dt_truth.json \
--module rune.dependency_tracker
Output: src/rust/dependency_tracker/src/frozen_dt_truth.json
(harness array schema: [{fn, args, kwargs, expected}] — embedded VERBATIM
by src/rust/dependency_tracker/src/gap_battery.rs).
"""
from __future__ import annotations
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO / "scripts"))
from freeze_truth import freeze, write # noqa: E402
OUT = REPO / "src" / "rust" / "dependency_tracker" / "src" / "frozen_dt_truth.json"
CASES = [
# ── get_dependents ───────────────────────────────────────────────
("get_dependents", ("memory_store.py",), {}),
("get_dependents", ("/some/where/deep/memory_store.py",), {}),
("get_dependents", ("warm_router.py",), {}), # dict-overwrite quirk: 2-item value
("get_dependents", ("microkernel.py",), {}),
("get_dependents", ("nonexistent.py",), {}),
("get_dependents", ("",), {}),
# ── check_propagation ────────────────────────────────────────────
("check_propagation", ("memory_store.py",), {}),
("check_propagation", ("warm_router.py",), {}),
("check_propagation", ("a/b/microkernel.py",), {}),
("check_propagation", ("nonexistent.py",), {}),
# ── get_full_map ─────────────────────────────────────────────────
("get_full_map", (), {}),
# ── propagate ────────────────────────────────────────────────────
("propagate", ("memory_store.py",), {}), # all four classifications
("propagate", ("memory_store.py",), {"dry_run": True}), # would-update short-circuit
("propagate", ("/abs/path/to/memory_store.py",), {}), # basename derivation
("propagate", ("warm_router.py",), {}), # present-but-no-reference only
("propagate", ("nonexistent.py",), {}), # empty dependents
# ── main_cli (CLI mirror) ────────────────────────────────────────
("main_cli", (["dependency_tracker.py"],), {}), # help + rc 1
("main_cli", (["dependency_tracker.py", "check", "memory_store.py"],), {}),
("main_cli", (["dependency_tracker.py", "check", "/x/y/memory_store.py"],), {}),
("main_cli", (["dependency_tracker.py", "check", "nonexistent.py"],), {}),
("main_cli", (["dependency_tracker.py", "propagate", "memory_store.py"],), {}),
("main_cli", (["dependency_tracker.py", "propagate", "memory_store.py", "--dry-run"],), {}),
("main_cli", (["dependency_tracker.py", "propagate", "nonexistent.py"],), {}),
("main_cli", (["dependency_tracker.py", "map"],), {}),
]
def main() -> None:
truth = freeze("dependency_tracker", CASES, oracle_module="rune.dependency_tracker")
write(truth, OUT)
print(f"frozen: {OUT} ({len(truth)} rows)")
if __name__ == "__main__":
main()