CI Pipeline / rust-surface (push) Failing after 20s
CI Pipeline / best-practices (push) Successful in 4s
CI Pipeline / go-surface (push) Failing after 24s
CI Pipeline / documentation (push) Successful in 4s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / type-check (push) Canceled after 22s
Auto-version and Release / release (push) Canceled after 48s
CI Pipeline / unit-tests (push) Canceled after 46s
CI Pipeline / lint (push) Canceled after 46s
CI Pipeline / canary (push) Canceled after 47s
CI Pipeline / gitea-offline (push) Canceled after 20s
deploy / deploy (push) Canceled after 50s
Contract BUILDER-2026-10-13T02:44:35Z-411615-factory-gap-mc. The 12 audit-named missing fns ported name-preserving into src/go/memory-consolidation (ConsolidationNow, ConsolidationMemoryOracle, ConsolidationNeuronOracle, LoadKnowledge/SaveKnowledge/LoadLessons/ SaveLessons/LoadConnections/SaveConnections, consolidateNeuron, consolidateMemory, getRelevantKnowledge) plus the remaining 4 stragglers (getRelevantLessons, getRelevantConnections, formatKnowledgeForPrompt, getStatus) — 23/23 fn coverage, audit FULL. Logic 1:1 with the Python oracle; IO and non-portables behind injectable seams (Clock, Compressor, EntryLookup, store paths). Truth frozen through the SHARED harness (scripts/freeze_truth.py + scripts/mc_freeze_seams/sitecustomize.py rig: RUNE_COGNITION_CORE/RUNE_MEMORY_CORE pinned python, frozen clock, hermetic MC_FREEZE_HOME, module-level seam bindings so the harness can getattr the class methods) — 41 rows, byte-identical --verify vs the live oracle, embedded VERBATIM and replayed by the go test battery and the binary replay gate (PARITY OK 41/41; fresh re-freeze byte-identical = live parity 100%). gofmt/vet clean; delegation tests green live (CC_RUST_LIB kernel, 7/7) and oracle-pinned (RUNE_COGNITION_CORE=python). Divergence, documented: Python hash() ids are process-randomized — the entry-none branch pins the established id_prefix/entry_none shape (truth_constructors.json precedent) instead of a non-portable hash.
160 lines
7.7 KiB
Python
160 lines
7.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Freeze the dichotomy-wave gap truth for src/rune/memory_consolidation
|
|
through the SHARED harness (scripts/freeze_truth.py — one law).
|
|
|
|
The oracle's module-level surface is clock-carrying (datetime.now inside
|
|
every fn) and its port surface is mostly class methods, so this generator
|
|
runs under the freeze rig (scripts/mc_freeze_seams/sitecustomize.py):
|
|
pinned Python floors, frozen clock, hermetic consolidation store, and
|
|
module-level seam bindings the shared harness can getattr.
|
|
|
|
Run (from the repo root):
|
|
PYTHONHASHSEED=0 MC_FREEZE_HOME=/tmp/mc_gap_freeze_home \
|
|
PYTHONPATH=scripts/mc_freeze_seams:src \
|
|
python3 scripts/gen_memory_consolidation_truth.py
|
|
|
|
Verify (byte-identical, same rig):
|
|
PYTHONHASHSEED=0 MC_FREEZE_HOME=/tmp/mc_gap_freeze_home \
|
|
PYTHONPATH=scripts/mc_freeze_seams:src \
|
|
python3 scripts/freeze_truth.py --verify \
|
|
src/go/memory-consolidation/truth_gaps.json \
|
|
--module rune.memory_consolidation
|
|
|
|
Every public gap fn and branch is exercised: both consolidation oracles
|
|
(drift floor: washable 0/partial 10+/full 20+; no-drift truncation floors
|
|
incl. the [:97]+"..." and empty-first-line branches), consolidate_neuron
|
|
(slug/body+text/importance defaults, string-triggers normalization,
|
|
silent store lookup), consolidate_memory, get_relevant_knowledge
|
|
(overlap + tag*2 + confidence*3, score>0 gate, stable desc sort, limit
|
|
cut), and the six store fns (absent/seeded file load, save roundtrip).
|
|
"""
|
|
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
|
|
|
|
T = "2026-10-01T00:00:00+00:00"
|
|
|
|
KSEED = [
|
|
{"id": "k1", "source": "memory", "category": "lesson",
|
|
"content": "the cron engine parses field expressions", "confidence": 0.9,
|
|
"created_at": T, "last_used": T, "use_count": 2, "wash_count": 1,
|
|
"entry_id": 7, "tags": ["cron", "parser"]},
|
|
{"id": "k2", "source": "graph", "category": "connection",
|
|
"content": "budget tracking for providers", "confidence": 0.5,
|
|
"created_at": T, "last_used": T, "use_count": 0, "wash_count": 0,
|
|
"entry_id": None, "tags": ["budget"]},
|
|
{"id": "k3", "source": "neuron", "category": "fact",
|
|
"content": "deploy runner labels need care", "confidence": 0.8,
|
|
"created_at": T, "last_used": T, "use_count": 0, "wash_count": 0,
|
|
"entry_id": 9, "tags": ["deploy"]},
|
|
]
|
|
|
|
LSEED = [
|
|
{"id": "lesson-0", "trigger": "deploy fails", "lesson": "check the runner labels first",
|
|
"context": "ci", "confidence": 0.9, "created_at": T, "applications": 1},
|
|
]
|
|
|
|
CSEED = [
|
|
{"id": "conn-0", "from_concept": "cron engine", "to_concept": "scheduler",
|
|
"relationship": "leads_to", "strength": 0.8, "created_at": T,
|
|
"evidence": ["e1"]},
|
|
]
|
|
|
|
LSEED2 = LSEED + [
|
|
{"id": "lesson-1", "trigger": "budget drift", "lesson": "watch provider spend",
|
|
"context": "finance", "confidence": 0.7, "created_at": T, "applications": 0},
|
|
]
|
|
|
|
cases = [
|
|
# _core with RUNE_COGNITION_CORE=python pinned → kernel seam off (null).
|
|
("_core", (), {}),
|
|
# _consolidation_now: the frozen-clock pin rides through the oracle.
|
|
("_consolidation_now", (), {}),
|
|
# _consolidation_memory_oracle — drift floor: washable(0), partial(10+),
|
|
# full(20+); entry_id set (hash ids are process-randomized: shape-pinned
|
|
# in the Go battery, never frozen).
|
|
("_consolidation_memory_oracle",
|
|
("The deployment runner needs repair.", 0.9), {"wash_count": 5, "entry_id": 42}),
|
|
("_consolidation_memory_oracle",
|
|
("memory text here", 0.4), {"wash_count": 0, "entry_id": 7}),
|
|
("_consolidation_memory_oracle",
|
|
("The partial branch keeps a little more of this proven memory body text.", 0.7),
|
|
{"wash_count": 12, "entry_id": 3}),
|
|
("_consolidation_memory_oracle",
|
|
("Rock solid " * 12, 0.95), {"wash_count": 25, "entry_id": 9}),
|
|
# no-drift floor: >100 chars → [:100] + "..."
|
|
("_consolidation_memory_oracle_no_drift", ("y" * 140, 0.5), {"entry_id": 5}),
|
|
("_consolidation_memory_oracle_no_drift", ("short text", 0.5), {"entry_id": 6}),
|
|
# _consolidation_neuron_oracle — drift floor branches.
|
|
("_consolidation_neuron_oracle",
|
|
("test-slug", "The runner needs repair.", 0.7),
|
|
{"triggers": ["deploy"], "wash_count": 15}),
|
|
("_consolidation_neuron_oracle",
|
|
("rock", "This is a long rock-solid body that survives compression mostly. " * 4, 0.9),
|
|
{"triggers": [], "wash_count": 25}),
|
|
("_consolidation_neuron_oracle",
|
|
("empty-body", "", 0.5), {"triggers": ["a", "b"], "wash_count": 0, "entry_id": 11}),
|
|
# no-drift floor: first line kept / [:97]+"..." / empty-first-line→body[:100]
|
|
("_consolidation_neuron_oracle_no_drift",
|
|
("fb", "First line\nsecond line", 0.6), {}),
|
|
("_consolidation_neuron_oracle_no_drift", ("fb", "z" * 140, 0.5), {}),
|
|
("_consolidation_neuron_oracle_no_drift", ("fb", "\n\nrest body", 0.6), {}),
|
|
# consolidate_neuron (method): defaults, string triggers, text fallback.
|
|
("consolidate_neuron",
|
|
({"slug": "cron-parser", "body": "The cron parser handles field expressions.",
|
|
"importance": 0.8, "triggers": ["cron"], "wash_count": 3},), {}),
|
|
("consolidate_neuron",
|
|
({"slug": "strig", "body": "Body about deploy runner.",
|
|
"importance": 0.6, "triggers": "deploy, runner ,"},), {}),
|
|
("consolidate_neuron",
|
|
({"slug": "ttext", "text": "body via text field"},), {}),
|
|
("consolidate_neuron", ({},), {}),
|
|
# consolidate_memory (method).
|
|
("consolidate_memory",
|
|
("The deployment runner needs repair.", 0.9), {"wash_count": 5, "entry_id": 42}),
|
|
("consolidate_memory",
|
|
("another recall", 0.4), {"wash_count": 0, "entry_id": 13}),
|
|
# get_relevant_knowledge: overlap + tag*2 + confidence*3, stable desc,
|
|
# limit cut, no-match-yet-confidence>0 gate.
|
|
("get_relevant_knowledge", ("cron parser", 5), {"knowledge": KSEED}),
|
|
("get_relevant_knowledge", ("cron parser", 1), {"knowledge": KSEED}),
|
|
("get_relevant_knowledge", ("zzz-no-match", 5), {"knowledge": KSEED}),
|
|
("get_relevant_knowledge", ("deploy", 5), {"knowledge": KSEED}),
|
|
("get_relevant_knowledge", ("anything", 5), {"knowledge": []}),
|
|
# get_relevant_lessons: trigger+lesson overlap, overlap>0 gate.
|
|
("get_relevant_lessons", ("deploy runner", 3), {"lessons": LSEED2}),
|
|
("get_relevant_lessons", ("zzz", 3), {"lessons": LSEED2}),
|
|
# get_relevant_connections: from+to overlap.
|
|
("get_relevant_connections", ("cron scheduler", 3), {"connections": CSEED}),
|
|
("get_relevant_connections", ("zzz", 3), {"connections": CSEED}),
|
|
# format_knowledge_for_prompt: full three-section render (entry link
|
|
# included) and the confidence-only quirk (knowledge renders on
|
|
# confidence*3 while pure-overlap lessons/connections drop out).
|
|
("format_knowledge_for_prompt", ("cron",),
|
|
{"knowledge": KSEED, "lessons": LSEED, "connections": CSEED}),
|
|
("format_knowledge_for_prompt", ("zzz-no-match",),
|
|
{"knowledge": KSEED, "lessons": LSEED, "connections": CSEED}),
|
|
("format_knowledge_for_prompt", ("cron",),
|
|
{"knowledge": [], "lessons": [], "connections": []}),
|
|
# store fns: absent file → [], seeded load roundtrip, save roundtrip.
|
|
("load_knowledge", (None,), {}),
|
|
("load_knowledge", (KSEED,), {}),
|
|
("save_knowledge", (KSEED,), {}),
|
|
("load_lessons", (None,), {}),
|
|
("load_lessons", (LSEED,), {}),
|
|
("save_lessons", (LSEED,), {}),
|
|
("load_connections", (None,), {}),
|
|
("load_connections", (CSEED,), {}),
|
|
("save_connections", (CSEED,), {}),
|
|
]
|
|
|
|
truth = freeze("rune.memory_consolidation", cases,
|
|
oracle_module="rune.memory_consolidation")
|
|
out = REPO / "src" / "go" / "memory-consolidation" / "truth_gaps.json"
|
|
write(truth, out)
|
|
print(f"frozen {len(truth)} rows -> {out}")
|