Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
test(reasoning): harden checkpoint differential assertions
江俊杰130cdbddc455
diff --git a/docs/reference/truth_maintenance.md b/docs/reference/truth_maintenance.mdindex 6e27714f..8d05fb41 100644--- a/docs/reference/truth_maintenance.md+++ b/docs/reference/truth_maintenance.md@@ -169,11 +169,13 @@ The fixed v1 schema is:The top level and each rule/catalog record have exact field sets; missing andunknown fields are rejected. `format_version` must be integer `1`;-`session_version` must be a non-negative integer. Rules and catalog facts are-semantic values, so invalid atoms, variables in facts, recursive rules, and-arity conflicts are rejected with the same `ValidationError` used by-construction and `apply()`. Unsupported future formats are also rejected, and-restore never returns a partially reconstructed session.+`session_version` must be a non-negative integer, and a non-empty support+catalog requires a positive version because it represents at least one+committed update. Rules and catalog facts are semantic values, so invalid+atoms, variables in facts, recursive rules, and arity conflicts are rejected+with the same `ValidationError` used by construction and `apply()`.+Unsupported future formats are also rejected, and restore never returns a+partially reconstructed session.Applications choose where to store the JSON. The minimal example below isintended only to show the API; `Path.write_text()` does **not** provide adiff --git a/tests/reasoning/test_truth_maintenance_differential.py b/tests/reasoning/test_truth_maintenance_differential.pyindex 52e9f296..f823ff09 100644--- a/tests/reasoning/test_truth_maintenance_differential.py+++ b/tests/reasoning/test_truth_maintenance_differential.py@@ -414,7 +414,25 @@ def compare_continuation_pair()assert uninterrupted.snapshot() == resumed.snapshot(), contextassert uninterrupted.to_checkpoint() == resumed.to_checkpoint(), context- assert uninterrupted.to_checkpoint() == expected_payload, context+ actual_payload = uninterrupted.to_checkpoint()+ assert (+ actual_payload["format_version"] == expected_payload["format_version"]+ ), context+ assert (+ actual_payload["session_version"] == expected_payload["session_version"]+ ), context+ assert (+ actual_payload["support_catalog"] == expected_payload["support_catalog"]+ ), context+ assert (+ actual_payload["active_support_ids"] == expected_payload["active_support_ids"]+ ), context+ # Rule order comparison deliberately ignores serialization order: the+ # session exports rules in internal topological order, while condition+ # order inside each rule remains semantically significant and is preserved.+ assert sorted(actual_payload["rules"], key=lambda rule: rule["rule_id"]) == sorted(+ expected_payload["rules"], key=lambda rule: rule["rule_id"]+ ), contextrelevant_facts = set(uninterrupted.facts) | set(removed_facts)for fact in relevant_facts:@@ -576,7 +594,14 @@ def run_checkpoint_seed(seed):rng = random.Random(seed)rules = generate_rules(rng)uninterrupted = build_session(rules)- expected_rule_payload = build_session(rules).to_checkpoint()["rules"]+ expected_rule_payload = [+ {+ "rule_id": rule_id,+ "conditions": [atom_text(atom) for atom in body_atoms],+ "conclusion": atom_text(head_atom),+ }+ for rule_id, body_atoms, head_atom in rules+ ]supports = {}catalog = {}