From ae3e422e4230f5a04fad3b2ecc4fc0c590a6af46 Mon Sep 17 00:00:00 2001 From: Philip Z Date: Mon, 7 Sep 2026 17:54:32 +0800 Subject: [PATCH] test: retain cross-entity version isolation evidence (#21) --- examples/conformance/README.md | 2 +- examples/conformance/app/main.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/conformance/README.md b/examples/conformance/README.md index 86caef0..1cfd5c9 100644 --- a/examples/conformance/README.md +++ b/examples/conformance/README.md @@ -1,6 +1,6 @@ # Python runtime conformance example -This retained SQLite example is generated from `model.xml` and verifies the minimum runtime-owned contract: explicit `ensure_schema`, Create, Update, Delete, typed Q/SmartList, E loaded/null/not-loaded semantics, and Checker rejection before persistence. +This retained SQLite example is generated from `model.xml` and verifies the minimum runtime-owned contract: explicit `ensure_schema`, Create, Update, Delete, typed Q/SmartList, E loaded/null/not-loaded semantics, Checker rejection before persistence, and optimistic-version isolation for different entity types that share a numeric ID. ```bash python -m venv .venv diff --git a/examples/conformance/app/main.py b/examples/conformance/app/main.py index b16873d..df49be5 100644 --- a/examples/conformance/app/main.py +++ b/examples/conformance/app/main.py @@ -10,10 +10,23 @@ from models.work_item import WorkItem from runtime_module import GENERATED_RUNTIME_MODULE from teaql.data_service import SQLiteTeaQLClient +from teaql.core import EntityKey, EntityRoot from teaql.runtime import CheckException, UserContext async def main() -> None: + order_key = EntityKey("Order", 1) + execution_key = EntityKey("InferenceExecution", 1) + target_ledger = EntityRoot() + source_ledger = EntityRoot() + target_ledger.set_original_version(order_key, 3) + source_ledger.set_original_version(execution_key, 9) + source_ledger.set(execution_key, "execution_status", "COMPLETED") + target_ledger.merge_from(source_ledger) + assert target_ledger.original_version(order_key) == 3 + assert target_ledger.original_version(execution_key) == 9 + print("PASS Mutation ledger identity (same ID, different entity types keep versions 3/9)") + database = ROOT / ".local" / "conformance.sqlite" database.parent.mkdir(parents=True, exist_ok=True) database.unlink(missing_ok=True) @@ -81,7 +94,7 @@ async def main() -> None: assert len(remaining) == 0 print("PASS Delete (default Q excludes deleted rows)") await client.close() - print("PASS Python minimum runtime conformance: 7/7") + print("PASS Python minimum runtime conformance: 8/8") if __name__ == "__main__":