Python School Scenarios
Start with the Python Order tutorial for an ordered read/edit/page walkthrough, the Order API usage guide for native return shapes, and Python Order troubleshooting for failure recovery. Continue with Python advanced Order mutations for explicit deletion, status transitions and stale-version recovery. For export, retained-ID jumps and provider totals, follow the Python Order query tutorials. For model upgrades, trusted sessions and authorization boundaries, use Python Order Isolation. The coverage matrix tracks remaining writing gaps.
For the new Order teaching path, see Order Workflows Across Seven Runtimes. Its seventeen native Order scenarios now pass across all seven languages (119/119, SQLite 7/7). Retained ID-set pagination and filtered order summaries join bounded search, continuous export and all P1 cases: explicit line removal, status transitions, expired versions and two-process writes to the same or different orders. Use the Python Order P2 executable and P2 retained-ID and summary receipt. Each language has 106 independent database checkpoints, including unchanged rows after every page and summary sequence. That core stage used only local evidence: the unchanged model, retained evaluation and locally rendered Assist; no fresh online evaluation was claimed. The complete Order suite keeps Go, TypeScript, Rust, Python and .NET pending release; nullable generation and pagination Assist repairs remain pending generator deployment. The evaluated isolation model revision adds buyer/tenant enforcement (7/7) with 350 new SQLite checkpoints. Use the Python isolation executable and isolation receipt for scoped reads, counts, caches and audited writes. Its generator intent/session and Assist repairs remain pending deployment. The evaluated stock model revision 1.2.0 adds atomic reservation, late-insert rollback and scoped idempotency (7/7). Its 392 SQLite checkpoints include 42 synchronized oversell/duplicate race rounds across seven runtimes. Use the Python stock executable and stock receipt. Java and Rust use one native explicit transaction; the other five use an audited aggregate save. The tenant version gate serializes participating reservation writers; multi-SKU fulfillment and sustained throughput are outside this fixture. The stock stage also uses local evidence only, with existing runtime and new generator deployment qualifications retained. The lifecycle stage adds request cancellation, provider statement and real COMMIT faults (7/7), with 315 SQLite checkpoints, 147 lock probes and recovery using the same provider. Use the Python lifecycle executable and lifecycle receipt. Java 1.555-RELEASE fails COMMIT cleanup in this new scope; its JDBC workspace repair is RELEASE PENDING. Earlier Java published passes remain attached to their narrower core/isolation/stock and School scopes. Cancellation is cooperative at an awaited checkpoint; external event delivery remains outside this evidence. A separate sustained-load stage now passes 7/7, using four retained native workers per language for 120 seconds. Its 13,951 requests include rollback, native resource gauges, drain, cooldown, same-provider recovery and close; 77 read-only SQLite snapshots and 49 writer probes remain distinct from business request counts. Use the Python sustained-load executable, resource verification scope and sustained-load receipt. Java, Go, TypeScript, Rust, Python and .NET retain the lifecycle workspace pending-release markers; Swift uses the same published 0.3.1. This finite SQLite soak does not establish maximum throughput or absence of all heap leaks. School qualifications and the earlier Order receipts remain unchanged. This page retains the executable School regression baseline below.
Every runtime now uses the same School model and five-school dataset for these advanced scenarios. 2026-10-27: 34/34 scenario assertions and all eight baseline SQLite checkpoints plus four isolated mutation databases PASS on the qualified workspace runtime — RELEASE PENDING.
Shared School model, five-school fixture, expected results, coverage priorities, and dated receipt.
| Scenario | Same acceptance result in every language |
|---|---|
| Filtered pagination | Active schools with capacity at least 500 have total 3. Offset 1, limit 2 returns Riverside then West. |
| Two loaded relations | Riverside resolves to PRIMARY and Campus Learning Platform through selected child requests. |
| Grouped analytics | PRIMARY: count 3, sum 1600, average 533.3333333333334; SECONDARY: count 2, sum 1700, average 850. |
| Relation metrics | SchoolType parents return the same counts and sums without loading their child lists. |
| Two Facets and zero buckets | Filtering to Riverside yields PRIMARY: 1 and SECONDARY: 0 with include-all, only PRIMARY: 1 with matched-only, and platform count 1. |
| Top-N for two parents | PRIMARY returns Riverside and West; SECONDARY returns Lakeside and Hill. The child limit applies independently to each parent. |
| Multiple pages and stable ties | Traverse all five Schools with page size 2 and a final empty page. Capacity descending, name ascending and ID ascending order the two capacity-500 rows as Hill then West. Every page, including the empty tail, reports total 5. This is offset paging, not a continuous cursor. |
| No-match page | A filter matching no School returns an empty page and exact total 0, even with a nonzero offset. |
| Facets with no matching rows | A no-match query retains both zero-count SchoolType buckets with include-all. Matched-only type and platform Facets are empty, and the result page is empty. |
| Positive, negative and nested relation predicates | Matching PRIMARY yields North, Riverside and West; excluding it yields Hill and Lakeside. A two-level School → SchoolType → Platform predicate returns the same three primary Schools. Predicates do not require loading the relation. |
| Filtered children and an empty parent bucket | Select only inactive child Schools. Both SchoolType parents remain present: PRIMARY has a loaded empty list and SECONDARY contains Hill. Filtering a selected child list must not filter out its parent. |
| Filtered aggregates | Active Schools with capacity at least 500 produce PRIMARY: count 2, sum 1300, average 650; SECONDARY: count 1, sum 1200, average 1200. The aggregate request carries the filters itself. |
| Reject blank query intent | Separate bounded queries supply a blank comment or a blank purpose. Both must reject execution with an intent-related diagnostic; a successful query or an unrelated error fails this case. |
| Group analytics after deletion | After Riverside is updated and Hill is deleted, PRIMARY has count 3 and sum 1750; SECONDARY has count 1 and sum 1200. Tombstones must not inflate ordinary aggregates. |
| Relation metrics after deletion | SchoolType relation counts and sums must agree with the surviving School rows: PRIMARY 3/1750, SECONDARY 1/1200. |
| Facet totals after deletion | Ordinary type Facets count PRIMARY: 3 and SECONDARY: 1; platform count is 4. The two-row page is Lakeside then Riverside, so facet totals must ignore the page limit and exclude the tombstone. |
| Ordinary children after deletion | After restart, PRIMARY returns Riverside and West; SECONDARY returns only Lakeside. A deleted child cannot appear in an ordinary selected relation. |
| Deleted-only children preserve live parents | Explicit deleted-only child selection yields an empty PRIMARY list and Hill under SECONDARY. Both live parents remain visible; the child version filter cannot change parent visibility. |
| Continuous pages in ascending ID order | Read offsets 0, 2 and 4 in one trusted context. The first page uses OFFSET; the next two report CURSOR_SEEK without duplicates or omissions. |
| Continuous pages in descending ID order | Traverse the same five Schools in reverse ID order and observe two CURSOR_SEEK plans. |
| Continuous cursor miss and recovery | Start at offset 2 without a cursor: observe CACHE_MISS, then reuse its boundary at offset 4. |
| Retained ID-set random page jumps | Build at offset 4, then jump to 0, 2 and 6. Preserve capacity/name/ID order, exact total 5 and ID_SET_HIT even for the empty tail. |
| Retained empty ID set | Run the same unmatched predicate twice. Retain the empty set, report total 0 and transition from ID_SET_BUILD to ID_SET_HIT. |
| ID-set safety-limit fallback | Set maxIds to 3 for five matching Schools. Observe LIMIT_EXCEEDED with a retained-count lower bound of 4; ordinary counted pagination still returns the correct page and exact total 5. |
| ID-set predicate isolation | Use one namespace with capacity thresholds 500, 1000 and 500. Distinct predicates build separate sets; returning to 500 hits its original set with exact total 4. |
| Atomic Platform and School commit | Commit Platform name and School capacity 810 together, both at version 2. |
| Rollback an earlier Platform write | Advance School to capacity 801/version 2; reject its stale graph and restore the earlier Platform write, including version and timestamp. |
| Concurrent writes to one School | Two processes read version 1 before one release barrier. Exactly one commits; the other reports an optimistic conflict. |
| Concurrent writes to different Schools | Two processes update Riverside and North from version 1. Both persist their own values with no lost update. |
| Update and stale version | Save capacity 950 at version 2; reject the old copy at 999; read the saved state after restart. |
| Soft deletion | Hide Hill from normal reads, retain version -2, and read one tombstone after restart. |
Execute the scenarios
Use the shared runner instructions and native prerequisites from the basic School check.
node scripts/school-examples.mjs --suite advanced --language python --python-runtime ../teaql-python-pagination
The complete Python application contains all phases, native imports, query intent and audited saves. The advanced guide shows source-synchronized excerpts and expected values. Both query failures and database failures return a nonzero runner exit code.
Language-specific result handling
Analytic rows are dictionaries from execute_for_rows; the native group key is school_type. Version 0.3.1 reports a rejected stale update as missing authoritative persisted state; the example also checks that capacity remains 950 in SQLite. Continuous cursor execution and counted fallback observations require the recorded workspace repair: WORKSPACE PASS — RELEASE PENDING.
The cross-language query contract describes the broader capability catalog. The common data-operations guide explains typed lists, analytic records and Facet sidecars. Capabilities outside this executable fixture need their own provider-specific evidence.