Test doubles follow the corrected-nomination contract; local-lane golden records response_finish_reason; corrected nominations bind through the draft read context

This commit is contained in:
Ouroboros 2026-09-22 22:25:20 +03:00
parent 8efffce6f9
commit cd6467f4cd
4 changed files with 23 additions and 10 deletions

View file

@ -228,8 +228,8 @@ def summarize_source(
while pending:
start, end = pending.pop()
part, note = text[start:end], source_continuation_note(spans, start, end)
draft, usage, knowledge = call(draft_prompt(part, note), "Room summary", fixed_prompt=draft_prompt("", note),
input_limit=input_limit, call_type="memory_consolidation")
draft, usage, draft_knowledge = call(draft_prompt(part, note), "Room summary", fixed_prompt=draft_prompt("", note),
input_limit=input_limit, call_type="memory_consolidation")
usages.append(usage)
if draft.strip():
corrected, usage, knowledge = call(
@ -241,7 +241,10 @@ def summarize_source(
# only with its corrected text: a draft whose correction failed
# (and was then split) never entered the block, and a draft
# nomination the correction dropped was never source-checked.
corrected, found = _extract_nominations(corrected, knowledge)
# Bound through the DRAFT call's read context: that call held the
# knowledge instruction and read the notes it nominates against,
# so its recorded reads attest the corrected block's revisions.
corrected, found = _extract_nominations(corrected, draft_knowledge if draft_knowledge is not None else knowledge)
entries.extend(found)
summaries.append(corrected.strip())
continue

View file

@ -113,7 +113,8 @@
"cost": 0.0,
"cost_final": true,
"provider": "local",
"resolved_model": "local-model"
"resolved_model": "local-model",
"response_finish_reason": "stop"
},
"ledger_attempt_count": 1
},

View file

@ -127,7 +127,8 @@ def test_block_count_is_zero_when_nomination_retention_is_refused(tmp_path, fit,
class Nominating:
def chat(self, **kwargs):
if kwargs["messages"][0]["content"].startswith("Compare this draft memory"):
return {"content": "Episode, checked against its source."}, {"cost": 0.01}
return {"content": "Episode, checked against its source.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps(
[{"topic": "people/alex", "content": "A durable understanding."}])}, {"cost": 0.01}
return {"content": "Episode.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps(
[{"topic": "people/alex", "content": "A durable understanding."}])}, {"cost": 0.01}
@ -181,8 +182,10 @@ class _Nominating:
if prompt.startswith("Compress these older memory blocks"):
return {"content": "The full historical span remains represented."}, {"cost": 0.01}
if prompt.startswith("Compare this draft memory"):
# The correction returns the checked text; nominations were made by the draft.
return {"content": f"Episode {self.count}, checked against its source."}, {"cost": 0.01}
# The correction returns the checked text with the draft's nomination
# block carried through the same source check; that block is released.
return {"content": f"Episode {self.count}, checked against its source.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps(
[{"topic": self.topic, "content": f"Understanding {self.count}."}])}, {"cost": 0.01}
self.count += 1
return {"content": f"Episode {self.count}.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps(
[{"topic": self.topic, "content": f"Understanding {self.count}."}])}, {"cost": 0.01}

View file

@ -35,8 +35,13 @@ class MemoryLLM:
def chat(self, **kwargs):
self.calls.append(deepcopy(kwargs))
if kwargs["messages"][0]["content"].startswith("Compare this draft memory"):
# The correction pass answers with the checked memory text only.
return {"content": "Checked interpretation."}, {
# The correction answers with the checked memory text and carries the
# draft's nomination block through the same source check (the
# corrected block is the one released).
prompt = kwargs["messages"][0]["content"]
block = prompt.split("## Draft memory", 1)[1].split("\n\n", 1)[0] if "## Draft memory" in prompt else ""
nominations = block[block.index("KNOWLEDGE_ENTRIES_JSON:"):] if "KNOWLEDGE_ENTRIES_JSON:" in block else ""
return {"content": "Checked interpretation." + ("\n" + nominations if nominations else "")}, {
"prompt_tokens": 5, "completion_tokens": 5, "total_tokens": 10, "cost": 0.02}
if len(self.calls) == 1:
return {"content": "", "tool_calls": [_call()]}, {
@ -205,7 +210,8 @@ def test_era_compression_cannot_erase_unpublished_knowledge_proposals(tmp_path,
if prompt.startswith("Compress these older memory blocks"):
return {"content": "The full historical span remains represented."}, {"cost": 0.01}
if prompt.startswith("Compare this draft memory"):
return {"content": f"Episode {self.count}, checked."}, {"cost": 0.01}
return {"content": f"Episode {self.count}, checked.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps([
{"topic": "people/alex", "content": f"Unpublished complete proposal {self.count}."}])}, {"cost": 0.01}
self.count += 1
return {"content": f"Episode {self.count}.\nKNOWLEDGE_ENTRIES_JSON: " + json.dumps([
{"topic": "people/alex", "content": f"Unpublished complete proposal {self.count}."}])}, {"cost": 0.01}