The controller (oldbox) sent a data-model alignment proposal and asked for six
additive changes on this node, the validation protocol, and an honest report.
Six of the seven changes are done; the seventh is declared missing rather than faked.
Stage 0 - reachability verified exactly as documented: health 200, heartbeat 401
(the correct answer - auth is refusing), missing Host 400. Nothing else was sent.
source_unit_key (controller 5.1, the blocking item)
umbraaudio/source_units.py. sha256("uk1" | chapter_source_text_sha256 |
occurrence | text_sha256). Nothing positional in the key: "occurrence"
disambiguates repeated text in document order.
- 18,181/18,181 units keyed across all four projects, 0 collisions
- chapter 1 renumbered +100 -> 0 keys changed (the load-bearing proof)
- backfill 10,015 rows in 0.11s, second run stamps 0 (idempotent)
- alignment phase 3: 200/200 probe units resolved with used_index: false
- tolerates the older projects that have no chapters.chapter_index
Recorded at generation time in chapter_builder, BEFORE the rows are read and
BEFORE the marker is written, so every path that renders audio also produces
identity and the clip can name its source unit.
5.7 recorded: utterance_index is KEPT as a display ordinal and made
non-load-bearing. spec 21 §10.
Blob hashes and effect chain (5.2)
Markers now carry the full sha256 of the delivered bytes and the effects that
produced them. Verified the existing order is already correct - write_marker
runs AFTER apply_effects - and closed the remaining hole: a changed trait list
changed the hash with no recorded cause. sha256 verification is opt-in, since
hashing every file on every validation pass would re-read gigabytes.
Vocabularies published (5.4) - umbraaudio/definitions.py, 19 sets, 126 values,
each value carrying whether it is 'declared' (spec/controller) or 'extracted'
(read out of code), so a diff shows a difference of meaning, not of wording.
Alignment report tool (6.6) - scripts/alignment_report.py --phase all. Emits the
controller's envelope with the per-phase evidence shapes, and obeys the two
rules they set: no evidence means blocked, never pass; a field we cannot produce
is null PLUS a finding, never omitted. Phase 2 is deliberately 'fail' - the
three-way store disagreement is real, and a pass there would be a check that
passed by doing nothing.
Fingerprint discipline (5.5) - the drift detector reported its OWN fingerprint
change when source_unit_key was added rather than hiding it. Node profile
updated with the new fingerprints and an honest note that they moved.
Node report extended - per-project source-unit-key coverage, per-voice-asset
sha256 + object_key, definition_set_version, controller stage reached.
Six gaps found in the proposal (spec 21 §11), including the one they invited plus
five more. The sharpest: "hash at generation" ignores that audio is
post-processed afterwards, and our key is anchored to chapters.source_text - a
second copy of the manuscript - so any change to chapter storage silently
invalidates every key in that chapter.
5.6 deliberately NOT faked: personality has no versioned artifact here, only
unversioned LLM prose in speakers.json. Reported as phase 6b finding B-03
instead, because wrapping unversioned inputs in a version field would produce
artifacts claiming a lineage they do not have.
Answered the controller's two open questions (infra/controller-handoff-2026-10-03.md):
forward-only link for a revealed recurring character, and yes - a new edition may
contradict a frozen state, since this node's correction path IS a regeneration.
Full suite 484 passed / 8 failed - the same 8 pre-existing and unrelated failures.
ruff clean on every file touched. The parallel session's chapter_builder hunk
(helper_url) was filtered out of the commit and left intact in the working tree.
88 lines
2.9 KiB
Python
88 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Backfill content-addressed ``source_unit_key`` values (spec 21 §9.1 M4-04).
|
|
|
|
The key is derived from the chapter's source text and the utterance's own text, so
|
|
it can be computed for existing rows at any time. It is what lets the controller
|
|
name a source unit by content instead of by ``utterance_index``.
|
|
|
|
Read-only by default. ``--write`` is required to change anything, and ``--dry-run``
|
|
reports exactly what would change.
|
|
|
|
Usage:
|
|
python scripts/backfill_source_unit_keys.py # report only
|
|
python scripts/backfill_source_unit_keys.py --write # apply
|
|
python scripts/backfill_source_unit_keys.py --project "Last Dwarf"
|
|
python scripts/backfill_source_unit_keys.py --json # evidence
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sqlite3
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from umbraaudio.config import load_config
|
|
from umbraaudio.source_units import backfill, key_report
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--project", default=None, help="project name or path")
|
|
parser.add_argument("--chapters", default=None, help="comma-separated chapter ids")
|
|
parser.add_argument(
|
|
"--write",
|
|
action="store_true",
|
|
help="actually write keys (default is a read-only report)",
|
|
)
|
|
parser.add_argument("--json", action="store_true", help="machine-readable output")
|
|
args = parser.parse_args()
|
|
|
|
cfg = load_config(args.project)
|
|
db_path = cfg.db_path
|
|
if not db_path.exists():
|
|
print(f"Database not found: {db_path}", file=sys.stderr)
|
|
return 1
|
|
|
|
chapter_ids = None
|
|
if args.chapters:
|
|
chapter_ids = [int(x.strip()) for x in args.chapters.split(",") if x.strip()]
|
|
|
|
# Read-only connection for the report so a plain run cannot write.
|
|
ro = sqlite3.connect(f"file:{db_path.resolve()}?mode=ro", uri=True)
|
|
try:
|
|
before = key_report(ro)
|
|
finally:
|
|
ro.close()
|
|
|
|
result: dict[str, object] = {"project": cfg.project_dir.name, "before": before}
|
|
if not args.write:
|
|
result["verdict"] = "report_only"
|
|
if args.json:
|
|
print(json.dumps(result, indent=2))
|
|
else:
|
|
print(f"project: {cfg.project_dir.name}")
|
|
print(f"before: {before}")
|
|
print("DRY RUN - nothing written. Re-run with --write to apply.")
|
|
return 0
|
|
|
|
rw = sqlite3.connect(str(db_path))
|
|
try:
|
|
result["after"] = backfill(rw, chapter_ids)
|
|
finally:
|
|
rw.close()
|
|
result["verdict"] = "written"
|
|
if args.json:
|
|
print(json.dumps(result, indent=2))
|
|
else:
|
|
print(f"project: {cfg.project_dir.name}")
|
|
print(f"before: {before}")
|
|
print(f"after: {result['after']}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|