Name the subject a conflict is actually about

A shared verb is not a shared fact. 「客厅的恒温器调到 22 度」 and
「卧室的恒温器调到 24 度」 agree with each other; the store had been
recording them as one thermostat moving, and the older side then left the
answer page — asking about the living room returned the bedroom's reading
as the only evidence. A conflict now requires the two memories to lead
with the same subject, and the subject is the first content word rather
than the first word, so 「The router forwards 220 packets」 still leads
with its router behind the article.

The rule trades one error for another, and both directions are measured
and pinned: a qualifier on the subject reads as a different thing, and
the first number under a label is the value that gets compared. Neither
hides a memory — each leaves a disagreement unrecorded for a person to
supersede by hand.

Six review findings, all measured before being changed:
- the archive rule string hid that an unset importance archives too
- a never-archived id reported {"restored": 1} while nothing moved
- the suppression condition (both sides in the page) was undocumented
- a determinism claim had no reproducible path, two latency numbers were
  never committed, and one cited test name did not exist

Gates: 374 passed, six acceptance files 73 passed, ruff clean, mypy cold
cache 24 errors in 9 files (the recorded 9cb46c1 baseline, net 0),
pyright 0 on the touched files, go build/vet/test + gofmt clean, npm
bundle unchanged, product audit clean, MCP smoke passing across processes.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 09:49:25 -04:00
1 parent deabbf76b8
commit 3daface332
7 files changed
+185 -26

No files matched your search

+74
View File
@@ -147,3 +147,77 @@ def test_a_conflict_belongs_to_the_memory_it_was_found_in(tmp_path) -> None:
assert service.conflicts("wife") == [], (
"one side is gone, so there is nothing left to settle and no ghost row to list"
)
def _lane(tmp_path, texts: list[str], *, scenario: str = "home") -> tuple[MemoryService, Database]:
settings = Settings(home=tmp_path, default_holder="wife")
database = Database(settings)
database.init()
service = MemoryService(settings=settings, database=database)
for text in texts:
service.remember(text, holder_id="wife", origin=MemoryOrigin.self_, scenario=scenario)
return service, database
def _search(tmp_path, database: Database, query: str) -> list[str]:
retrieval = RetrievalService(settings=Settings(home=tmp_path, default_holder="wife"), database=database)
return [hit.atom.text for hit in retrieval.search(query, filters=SearchFilters(as_holder="wife")).hits]
def test_two_rooms_each_keep_their_own_number(tmp_path) -> None:
service, database = _lane(tmp_path, ["客厅的恒温器调到 22 度", "卧室的恒温器调到 24 度"])
assert service.conflicts("wife") == [], "they share the verb 调到 and disagree about nothing"
assert _search(tmp_path, database, "客厅") == ["客厅的恒温器调到 22 度"], (
"asking about the living room must not answer with the bedroom's reading"
)
def test_two_people_each_keep_their_own_count(tmp_path) -> None:
service, _ = _lane(tmp_path, ["她买了 3 本书", "他买了 5 本书"])
assert service.conflicts("wife") == [], "two buyers are two facts, not one moving count"
def test_one_router_moving_its_counter_is_a_conflict(tmp_path) -> None:
service, _ = _lane(tmp_path, ["The router forwards 220 packets", "The router forwards 240 packets"])
clashes = service.conflicts("wife")
assert len(clashes) == 1
assert clashes[0].terms == ["router"], "the subject both memories lead with is what the pair disagrees about"
assert (clashes[0].older_value, clashes[0].newer_value) == ("220", "240")
def test_the_same_subject_measuring_two_things_still_reads_as_one_quantity(tmp_path) -> None:
service, _ = _lane(tmp_path, ["恒温器设定 22 度", "恒温器功率 100 瓦"])
assert len(service.conflicts("wife")) == 1, (
"the store compares labels, not meanings: 设定 and 功率 both hang off 恒温, so this pair is "
"recorded as one moving quantity and the holder is the one who settles it"
)
def test_a_memory_that_leads_with_a_number_has_no_subject_to_conflict_on(tmp_path) -> None:
service, _ = _lane(tmp_path, ["22 度", "24 度"])
assert service.conflicts("wife") == [], "with no subject named the store cannot claim they are one thing"
def test_a_qualifier_on_the_subject_reads_as_a_different_thing(tmp_path) -> None:
service, _ = _lane(tmp_path, ["恒温器调到 22 度", "客厅的恒温器调到 24 度"])
assert service.conflicts("wife") == [], (
"the store compares labels, not meanings: adding 客厅 moves the subject, so the update is "
"kept as a second fact rather than noticed as a disagreement — nothing is hidden, and "
"supersede is still how the holder says which one stands"
)
def test_the_first_number_under_a_label_is_the_value_that_is_compared(tmp_path) -> None:
service, _ = _lane(tmp_path, ["2026 saw 3 releases", "2026 saw 5 releases"])
assert service.conflicts("wife") == [], (
"the year leads, so it is what the subject's value records; a count that moves behind it "
"is not noticed — the store names one quantity per label, not every quantity in a sentence"
)
+16
View File
@@ -204,3 +204,19 @@ def test_importance_is_a_stated_value_and_not_a_free_number(tmp_path) -> None:
holder_id="wife",
importance=1.5,
)
def test_a_restore_counts_the_memories_it_brought_back_and_only_those(tmp_path) -> None:
service, database = _service(tmp_path)
settings = Settings(home=tmp_path, default_holder="wife")
retrieval = RetrievalService(settings=settings, database=database)
archived = _remember(service, "我们的钥匙放在玄关抽屉里")
standing = _remember(service, "恒温器设定 22 度", importance=0.9)
service.archive_stale(older_than_days=0, at=NOW + timedelta(days=365), max_importance=0.5)
assert service.restore([archived]) == 1
assert [hit.atom.atom_id for hit in retrieval.search("钥匙", filters=SearchFilters(as_holder="wife")).hits] == [archived]
assert service.restore([standing, archived]) == 0, (
"a memory that was never archived, or came back already, changed nothing and says so"
)