Skip to main content

Swift Advanced Data Operations

2026-10-27: 34/34 scenario assertions and all eight baseline SQLite checkpoints plus four isolated mutation databases PASS on the published runtime.

Shared School model, five-school fixture, expected results, coverage priorities, and dated receipt.

The excerpts below are synchronized from the complete executable application. Its imports, composition root and result-reporting helpers are in that file. Follow the shared setup and evidence contract before adapting these calls. Request current entity/action Assist, then scoped field Assist; keep generated domain libraries unchanged.

Use executeForRows for analytic TeaQLRecord values and executeForList for typed SmartList values. Facet options require the Swift label includeAllFacets:. Load a bounded list and require exactly one School before mutation.

Run from the site checkout with the native prerequisites in the seven-runtime baseline:

node scripts/school-examples.mjs --suite advanced --language swift

Filtered pagination​

Active schools with capacity at least 500 have total 3. Offset 1, limit 2 returns Riverside then West.

let page = try await Q.schoolsWithMinimalFields().selectName().whichAreActive()
.withStudentCapacityGreaterThanOrEqualTo(500)
.orderByStudentCapacityDescending().orderByIdAscending().offset(1).limit(2).count()
.comment("Page active schools by capacity").purpose("Review the School directory").executeForList(context)
try report("pagination", ["names": names(page), "total": required(page.totalCount)])

Two loaded relations​

Riverside resolves to PRIMARY and Campus Learning Platform through selected child requests.

let rows = try await Q.schoolsWithMinimalFields().selectName().withNameIs("Riverside Primary School")
.selectSchoolTypeWith(Q.schoolTypesWithMinimalFields().selectCode())
.selectPlatformWith(Q.platformsWithMinimalFields().selectName()).limit(2)
.comment("Load School type and platform").purpose("Review loaded School relations").executeForList(context)
precondition(rows.count == 1)
let one = rows[0]
try report("relations", ["school": required(E.school(one).name().eval()),
"type": required(E.schoolType(required(E.school(one).schoolType().eval())).code().eval()),
"platform": required(E.platform(required(E.school(one).platform().eval())).name().eval())])

Grouped analytics​

PRIMARY: count 3, sum 1600, average 533.3333333333334; SECONDARY: count 2, sum 1700, average 850.

let groups = try await Q.schools().groupBySchoolType().countAs("count")
.sumStudentCapacityAs("total").avgStudentCapacityAs("average").limit(10)
.comment("Group School capacity by type").purpose("Verify provider aggregation").executeForRows(context)
try report("groups", groups.map { row in ["type": try number(row, "schoolType"), "count": try number(row, "count"),
"total": try number(row, "total"), "average": try number(row, "average")] })

Relation metrics​

SchoolType parents return the same counts and sums without loading their child lists.

let cards = try await Q.schoolTypesWithMinimalFields().selectCode().countSchoolsAs("count")
.sumStudentCapacityOfSchoolsAs("total", Q.schools()).orderByCodeAscending().limit(10)
.comment("Calculate SchoolType relation metrics").purpose("Verify provider relation aggregation").executeForRows(context)
try report("relation-metrics", Dictionary(uniqueKeysWithValues: cards.map {
(try text($0, "code"), ["count": try number($0, "count"), "total": try number($0, "total")]) }))

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.

var results: [SmartList<School>] = []
for includeAll in [true, false] {
let rows = try await Q.schoolsWithMinimalFields().selectName().withNameIs("Riverside Primary School")
.facetBySchoolTypeAs("types", Q.schoolTypesWithMinimalFields().selectCode().countSchoolsAs("count"), includeAllFacets: includeAll)
.facetByPlatformAs("platforms", Q.platformsWithMinimalFields().selectName().countSchoolsAs("count"), includeAllFacets: false)
.orderByIdAscending().limit(2).comment("Facet the matching School set").purpose("Compare zero and matched buckets")
.executeForList(context)
results.append(rows)
}
try report("facets", ["includeAll": buckets(results[0], "types", "code"), "matchedOnly": buckets(results[1], "types", "code"),
"platforms": buckets(results[0], "platforms", "name"), "rows": names(results[0])])

Top-N for two parents​

PRIMARY returns Riverside and West; SECONDARY returns Lakeside and Hill. The child limit applies independently to each parent.

let types = try await Q.schoolTypesWithMinimalFields().selectCode()
.selectSchoolListWith(Q.schoolsWithMinimalFields().selectName()
.orderByStudentCapacityDescending().orderByIdAscending().limit(2))
.orderByCodeAscending().limit(10).comment("Load the two largest schools for each type").purpose("Verify Top-N across two parents")
.executeForList(context)
var top: [String: [String]] = [:]
for type in types {
let count = try required(E.schoolType(type).schoolList().size().eval())
let children = try (0..<count).map { try required(E.schoolType(type).schoolList().get($0).name().eval()) }
top[try required(E.schoolType(type).code().eval())] = children
}
try report("top-n", top)

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.

var pages: [[String]] = []; var totals: [Int64] = []
for offset in [0, 2, 4, 6] {
let page = try await Q.schoolsWithMinimalFields().selectName()
.orderByStudentCapacityDescending().orderByNameAscending().orderByIdAscending().offset(offset).limit(2).count()
.comment("Traverse School pages including an empty tail").purpose("Verify stable page boundaries").executeForList(context)
pages.append(try names(page)); totals.append(Int64(try required(page.totalCount)))
}
try report("page-boundaries", ["pages": pages, "totals": totals])

No-match page​

A filter matching no School returns an empty page and exact total 0, even with a nonzero offset.

let page = try await Q.schoolsWithMinimalFields().selectName().withNameIs("No such School")

.orderByStudentCapacityDescending().orderByIdAscending().offset(1).limit(2).count()
.comment("Read a School filter with no matches").purpose("Verify empty page count").executeForList(context)
try report("empty-page", ["names": names(page), "total": required(page.totalCount)])

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.

var results: [SmartList<School>] = []
for includeAll in [true, false] {
let rows = try await Q.schoolsWithMinimalFields().selectName().withNameIs("No such School")
.facetBySchoolTypeAs("types", Q.schoolTypesWithMinimalFields().selectCode().countSchoolsAs("count"), includeAllFacets: includeAll)
.facetByPlatformAs("platforms", Q.platformsWithMinimalFields().selectName().countSchoolsAs("count"), includeAllFacets: false)
.orderByIdAscending().limit(2).comment("Facet the matching School set").purpose("Compare zero and matched buckets")
.executeForList(context)
results.append(rows)
}
try report("empty-facets", ["includeAll": buckets(results[0], "types", "code"), "matchedOnly": buckets(results[1], "types", "code"),
"platforms": buckets(results[0], "platforms", "name"), "rows": names(results[0])])

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.

let matching = try await Q.schoolsWithMinimalFields().selectName()
.withSchoolTypeMatching(Q.schoolTypesWithMinimalFields().withCodeIs("PRIMARY"))
.orderByNameAscending().limit(10).comment("Match School type by child request")
.purpose("Verify relation predicate semantics").executeForList(context)
let excluding = try await Q.schoolsWithMinimalFields().selectName()
.withoutSchoolTypeMatching(Q.schoolTypesWithMinimalFields().withCodeIs("PRIMARY"))
.orderByNameAscending().limit(10).comment("Exclude School type by child request")
.purpose("Verify negative relation predicates").executeForList(context)
let nested = try await Q.schoolsWithMinimalFields().selectName()
.withSchoolTypeMatching(Q.schoolTypesWithMinimalFields().withCodeIs("PRIMARY")
.withPlatformMatching(Q.platformsWithMinimalFields().withNameIs("Campus Learning Platform")))
.orderByNameAscending().limit(10).comment("Match School through type and platform")
.purpose("Verify two-level relation predicates").executeForList(context)
try report("relation-predicates", ["matching": names(matching), "excluding": names(excluding), "nested": names(nested)])

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.

let types = try await Q.schoolTypesWithMinimalFields().selectCode()
.selectSchoolListWith(Q.schoolsWithMinimalFields().selectName().whichAreNotActive()
.orderByStudentCapacityDescending().orderByIdAscending().limit(2))
.orderByCodeAscending().limit(10).comment("Load inactive Schools for each type").purpose("Preserve parents with empty child lists")
.executeForList(context)
var top: [String: [String]] = [:]
for type in types {
let count = try required(E.schoolType(type).schoolList().size().eval())
let children = try (0..<count).map { try required(E.schoolType(type).schoolList().get($0).name().eval()) }
top[try required(E.schoolType(type).code().eval())] = children
}
try report("filtered-children", top)

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.

let groups = try await Q.schools().whichAreActive().withStudentCapacityGreaterThanOrEqualTo(500).groupBySchoolType().countAs("count")
.sumStudentCapacityAs("total").avgStudentCapacityAs("average").limit(10)
.comment("Aggregate active Schools with capacity at least 500").purpose("Verify provider aggregation").executeForRows(context)
try report("filtered-groups", groups.map { row in ["type": try number(row, "schoolType"), "count": try number(row, "count"),
"total": try number(row, "total"), "average": try number(row, "average")] })

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.

var rejected: [Bool] = []
for (comment, purpose) in [(" ", "Verify blank comment rejection"), ("Check blank purpose rejection", " ")] {
var denied = false
do { _ = try await Q.schoolsWithMinimalFields().limit(1).comment(comment).purpose(purpose).executeForList(context) }
catch {
let message = String(describing: error).lowercased()
guard ["comment", "purpose", "intent"].contains(where: { message.contains($0) }) else { throw error }
denied = true
}
rejected.append(denied)
}
try report("blank-intent", ["blankComment": rejected[0], "blankPurpose": rejected[1]])

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.

let groups = try await Q.schools().groupBySchoolType().countAs("count")
.sumStudentCapacityAs("total").avgStudentCapacityAs("average").limit(10)
.comment("Aggregate surviving Schools after deletion").purpose("Verify provider aggregation").executeForRows(context)
try report("deleted-groups", groups.map { row in ["type": try number(row, "schoolType"), "count": try number(row, "count"),
"total": try number(row, "total"), "average": try number(row, "average")] })

Relation metrics after deletion​

SchoolType relation counts and sums must agree with the surviving School rows: PRIMARY 3/1750, SECONDARY 1/1200.

let cards = try await Q.schoolTypesWithMinimalFields().selectCode().countSchoolsAs("count")
.sumStudentCapacityOfSchoolsAs("total", Q.schools()).orderByCodeAscending().limit(10)
.comment("Calculate relation metrics after School deletion").purpose("Verify provider relation aggregation").executeForRows(context)
try report("deleted-metrics", Dictionary(uniqueKeysWithValues: cards.map {
(try text($0, "code"), ["count": try number($0, "count"), "total": try number($0, "total")]) }))

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.

var results: [SmartList<School>] = []
for includeAll in [true, false] {
let rows = try await Q.schoolsWithMinimalFields().selectName()
.facetBySchoolTypeAs("types", Q.schoolTypesWithMinimalFields().selectCode().countSchoolsAs("count"), includeAllFacets: includeAll)
.facetByPlatformAs("platforms", Q.platformsWithMinimalFields().selectName().countSchoolsAs("count"), includeAllFacets: false)
.orderByStudentCapacityDescending().orderByIdAscending().limit(2).comment("Facet the matching School set").purpose("Compare zero and matched buckets")
.executeForList(context)
results.append(rows)
}
try report("deleted-facets", ["includeAll": buckets(results[0], "types", "code"), "matchedOnly": buckets(results[1], "types", "code"),
"platforms": buckets(results[0], "platforms", "name"), "rows": names(results[0])])

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.

let types = try await Q.schoolTypesWithMinimalFields().selectCode()
.selectSchoolListWith(Q.schoolsWithMinimalFields().selectName()
.orderByStudentCapacityDescending().orderByIdAscending().limit(2))
.orderByCodeAscending().limit(10).comment("Load surviving Schools for each type").purpose("Exclude tombstones from ordinary child lists")
.executeForList(context)
var top: [String: [String]] = [:]
for type in types {
let count = try required(E.schoolType(type).schoolList().size().eval())
let children = try (0..<count).map { try required(E.schoolType(type).schoolList().get($0).name().eval()) }
top[try required(E.schoolType(type).code().eval())] = children
}
try report("deleted-children", top)

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.

let types = try await Q.schoolTypesWithMinimalFields().selectCode()
.selectSchoolListWith(Q.schoolsWithMinimalFields().selectName().deletedRowsOnly()
.orderByStudentCapacityDescending().orderByIdAscending().limit(2))
.orderByCodeAscending().limit(10).comment("Load retired Schools for each live type").purpose("Keep child deletion scope separate from parent visibility")
.executeForList(context)
var top: [String: [String]] = [:]
for type in types {
let count = try required(E.schoolType(type).schoolList().size().eval())
let children = try (0..<count).map { try required(E.schoolType(type).schoolList().get($0).name().eval()) }
top[try required(E.schoolType(type).code().eval())] = children
}
try report("deleted-child-tombstones", top)

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.

var pages: [[String]] = []; var plans: [String] = []

for (offset, threshold) in [(0, 0), (2, 0), (4, 0)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByIdAscending().offset(offset).limit(2).optimizeForContinuousPageFetch(namespace: "continuous-ascending", ttlSeconds: 60)
.comment("Browse School pagination").purpose("Verify continuous-ascending").executeForList(context)
pages.append(try names(page)); plans.append(await context.continuousPageObservation().plan)

}
try report("continuous-ascending", ["pages": pages, "plans": plans])

Continuous pages in descending ID order​

Traverse the same five Schools in reverse ID order and observe two CURSOR_SEEK plans.

var pages: [[String]] = []; var plans: [String] = []

for (offset, threshold) in [(0, 0), (2, 0), (4, 0)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByIdDescending().offset(offset).limit(2).optimizeForContinuousPageFetch(namespace: "continuous-descending", ttlSeconds: 60)
.comment("Browse School pagination").purpose("Verify continuous-descending").executeForList(context)
pages.append(try names(page)); plans.append(await context.continuousPageObservation().plan)

}
try report("continuous-descending", ["pages": pages, "plans": plans])

Continuous cursor miss and recovery​

Start at offset 2 without a cursor: observe CACHE_MISS, then reuse its boundary at offset 4.

var pages: [[String]] = []; var plans: [String] = []

for (offset, threshold) in [(2, 0), (4, 0)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByIdAscending().offset(offset).limit(2).optimizeForContinuousPageFetch(namespace: "continuous-cache-miss", ttlSeconds: 60)
.comment("Browse School pagination").purpose("Verify continuous-cache-miss").executeForList(context)
pages.append(try names(page)); plans.append(await context.continuousPageObservation().plan)

}
try report("continuous-cache-miss", ["pages": pages, "plans": plans])

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.

var pages: [[String]] = []; var plans: [String] = []
var totals: [Int] = []; var observedCounts: [Int] = []
for (offset, threshold) in [(4, 0), (0, 0), (2, 0), (6, 0)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByStudentCapacityDescending().orderByNameAscending().orderByIdAscending().offset(offset).limit(2).optimizePaginationWithIdSet(namespace: "id-set-jump", ttlSeconds: 60, maxIds: 100).count()
.comment("Browse School pagination").purpose("Verify id-set-jump").executeForList(context)
pages.append(try names(page)); plans.append(await context.idSetPaginationObservation().plan)
totals.append(Int(try required(page.totalCount))); observedCounts.append(try required(await context.idSetPaginationObservation().count))
}
try report("id-set-jump", ["pages": pages, "plans": plans, "totals": totals, "observedCounts": observedCounts])

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.

var pages: [[String]] = []; var plans: [String] = []
var totals: [Int] = []; var observedCounts: [Int] = []
for (offset, threshold) in [(0, 100000), (2, 100000)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByStudentCapacityDescending().orderByNameAscending().orderByIdAscending().offset(offset).limit(2).optimizePaginationWithIdSet(namespace: "id-set-empty", ttlSeconds: 60, maxIds: 100).count()
.comment("Browse School pagination").purpose("Verify id-set-empty").executeForList(context)
pages.append(try names(page)); plans.append(await context.idSetPaginationObservation().plan)
totals.append(Int(try required(page.totalCount))); observedCounts.append(try required(await context.idSetPaginationObservation().count))
}
try report("id-set-empty", ["pages": pages, "plans": plans, "totals": totals, "observedCounts": observedCounts])

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.

var pages: [[String]] = []; var plans: [String] = []
var totals: [Int] = []; var observedCounts: [Int] = []
for (offset, threshold) in [(2, 0)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByStudentCapacityDescending().orderByNameAscending().orderByIdAscending().offset(offset).limit(2).optimizePaginationWithIdSet(namespace: "id-set-overflow", ttlSeconds: 60, maxIds: 3).count()
.comment("Browse School pagination").purpose("Verify id-set-overflow").executeForList(context)
pages.append(try names(page)); plans.append(await context.idSetPaginationObservation().plan)
totals.append(Int(try required(page.totalCount))); observedCounts.append(try required(await context.idSetPaginationObservation().count))
}
try report("id-set-overflow", ["pages": pages, "plans": plans, "totals": totals, "observedCounts": observedCounts])

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.

var pages: [[String]] = []; var plans: [String] = []
var totals: [Int] = []; var observedCounts: [Int] = []
for (offset, threshold) in [(0, 500), (0, 1000), (0, 500)] {
let page = try await Q.schoolsWithMinimalFields().selectName().withStudentCapacityGreaterThanOrEqualTo(Int64(threshold))
.orderByStudentCapacityDescending().orderByNameAscending().orderByIdAscending().offset(offset).limit(2).optimizePaginationWithIdSet(namespace: "id-set-isolation", ttlSeconds: 60, maxIds: 100).count()
.comment("Browse School pagination").purpose("Verify id-set-isolation").executeForList(context)
pages.append(try names(page)); plans.append(await context.idSetPaginationObservation().plan)
totals.append(Int(try required(page.totalCount))); observedCounts.append(try required(await context.idSetPaginationObservation().count))
}
try report("id-set-isolation", ["pages": pages, "plans": plans, "totals": totals, "observedCounts": observedCounts])

Atomic Platform and School commit​

The commit control changes Platform to Transactional Campus and Riverside to capacity 810; both versions become 2. The runner clones the seeded database for each case. Rust uses one typed transaction capability for both audited saves; other runtimes save the loaded Platform graph and its School child.

let rollback = ProcessInfo.processInfo.environment["SCHOOL_SCENARIO"] == "transaction-rollback"
var root = try required(try await Q.platforms().selectSchoolListWith(Q.schools().withNameIs("Riverside Primary School").limit(2))
.limit(2).comment("Load the Platform and School transaction graph").purpose("Verify atomic graph writes").executeForList(context).first)
if rollback { var winner = try await load(context, "Riverside Primary School"); winner.updateStudentCapacity(801)
_ = try await winner.auditAs("Advance School before the stale graph").save(context) }
root.updateName("Transactional Campus"); root.schoolList[0].updateStudentCapacity(810)
print("SCHOOL_GRAPH_ATTEMPT")
var rejected = false
do { _ = try await root.auditAs("Revise Platform and School atomically").save(context) }
catch { let text = String(describing: error).lowercased()
guard rollback && ["version", "optimistic", "conflict", "stale"].contains(where: { text.contains($0) }) else { throw error }; rejected = true }
try report(required(ProcessInfo.processInfo.environment["SCHOOL_SCENARIO"]), ["rejected": rejected])

Multi-entity rollback​

The same block first commits an independent School revision to capacity 801/version 2, then attempts the stale Platform/School graph. Require an optimistic conflict. The SQL trace must show Platform UPDATE before the failing School UPDATE. The read-only database check requires the original Platform name, version and update time, and keeps the independently committed School revision. No compensating writes are used.

Concurrent writes to one School​

Two separate processes load version 1, write readiness records, then wait for the runner to release a shared barrier. Exactly one save commits and one reports an optimistic conflict. The final capacity must match the actual winner (811 or 822), at version 2. A locked/busy database error fails the test; it is never counted as an optimistic conflict.

let target = try required(ProcessInfo.processInfo.environment["SCHOOL_TARGET"])
let worker = try required(ProcessInfo.processInfo.environment["SCHOOL_WORKER"])
let barrier = try required(ProcessInfo.processInfo.environment["SCHOOL_BARRIER"])
var row = try await load(context, target); let observedVersion = try required(E.school(row).version().eval())
try JSONSerialization.data(withJSONObject: ["observedVersion": observedVersion]).write(to: URL(fileURLWithPath: "\(barrier)/\(worker).ready"), options: .atomic)
let deadline = Date().addingTimeInterval(30)
while !FileManager.default.fileExists(atPath: "\(barrier)/release") {
guard Date() < deadline else { throw VerificationError.missingValue("Barrier timeout") }; try await Task.sleep(nanoseconds: 10_000_000) }
row.updateStudentCapacity(worker == "a" ? 811 : 822)
var outcome = "committed"; var conflictReason = ""
do { _ = try await row.auditAs("Concurrent School capacity revision").save(context) }
catch { let text = String(describing: error).lowercased()
guard ["version", "optimistic", "conflict", "stale"].contains(where: { text.contains($0) }) else { throw error }; outcome = "conflict"; conflictReason = String(describing: error) }
let data = try JSONSerialization.data(withJSONObject: ["worker": worker, "target": target, "observedVersion": observedVersion, "outcome": outcome, "conflictReason": conflictReason])
print("SCHOOL_WORKER " + String(decoding: data, as: UTF8.self))

Concurrent writes to different Schools​

The same worker block targets Riverside for worker a and North for worker b. Both must commit, leaving capacities 811 and 822 at version 2. All other rows, relations, identity and creation time must be unchanged.

Audited update and stale version​

The complete program loads Riverside twice, changes the first copy from 800 to 950, and saves it with an audit reason. Its version must change from 1 to 2. Saving the independently loaded stale copy at 999 must fail; a fresh process must still read capacity 950 and version 2. The read-only SQLite checker verifies that no other School changed and that IDs and creation timestamps remain stable.

Soft deletion and restart​

The program marks Hill for deletion and saves with an audit reason. Normal queries must return zero rows; after restart, the deleted-only query must return exactly one tombstone. SQLite must retain Hill at version -2. The published TypeScript 0.3.1 pair fails that final query in the earlier receipt. The qualified TypeScript workspace fix passes it; the expected value remains 1.

Scope of this check​

These are local SQLite results for the exact recorded dependencies. They do not certify PostgreSQL/MySQL, sustained concurrency stress, browser or TFP execution, pagination TTL/invalidation, concurrent retained-set changes, provider/commit fault injection, the complete Null/NotLoaded projection contract, migrations, or deployment-specific access policies. See the prioritized remaining gaps. The older stale-write check uses sequential copies; the new concurrent cases use two synchronized native processes. This is not a sustained-write stress test. Runtime and generator release status remain separate in the receipt.