Skip to main content

Swift Debugging and Observability

Pass one SQLExecutionEvidenceStore into the trusted UserContext as its telemetry sink. The store retains parameters; publish only the bounded safeSQLEvidence(from:) projection supplied by generated Debug Assist.

await evidence.enableSelect()

let rows = try await Q.schools().limit(20)
.comment("Diagnose the school search")
.purpose("Verify filters, facets, and relation loading")
.executeForList(context)

let safe = await safeSQLEvidence(from: evidence)

Use enableAll(), enableSelect(), enableMutation(), and disable(); each mode change clears previous entries. diagnosticSQLLogSink, debugSQL, and raw parameters stay in the operator boundary. Toggle querySQLLogEnabled and mutationSQLLogEnabled independently.

Run the exact Facet, grouped aggregate, relation statistic, staged relation, Top-N, and audited save examples from Swift advanced data operations. Use the typed trace to distinguish each staged relation level; do not infer that one plan hydrates an arbitrary-depth graph.

Pass OpenTelemetry through the runtimeTelemetry: initializer of UserContext, FederalClient, or LocalCache. The injected AuditSink is independent from telemetry sampling. Swift Request Policy currently modifies queries; mutation tenant authorization must additionally be enforced and tested at the application/provider/TFP boundary.

Finish with the shared checklist.

Order troubleshooting​

For the full operation and recovery sequence, use the Swift mutation recipes: deletion, state changes and version conflicts.

Start with the Swift Order tutorial and API usage guide. Diagnose the first native error before changing a dependency or rerunning a suite. Compare the failing runtime, model and fixture against the authority for that operation.

SymptomWhat to inspectNext action
ORDER_OK is printed but the wrong Order is visibleAbsolute database path, model revision and selected fixture.The first-edit fixture has three Orders; pagination and insights use separate nine-/ten-order fixtures. Keep each in its own database and use business keys, not copied numeric IDs.
Empty result or duplicate business identityQuery cardinality and scoped predicates.Keep the expected-one check. An empty result is distinct from a provider exception. A buyer filter alone does not authorize a tenant.
Wrong total or omitted item after editFull scalar/relation loading, item bounds and money validation.Reload the complete bounded collection before calculating totals; a preview is not a full edit graph and omission is not deletion.
Changed child is absent after a successful parent saveA local entity copy was changed rather than the child inside the saved parent value.Mutate order.orderItemList[index] in the parent that will be saved, following the retained edit function.
Field evaluation throws despite a default valueNotLoaded is distinct from a selected nil.Select the field first; orElse only defaults a selected null and still exposes an omitted field.
Retained-ID invalidation seems to do nothingThe public store boundary and the application’s key/delegate adapter are different layers.Follow the recorded adapter and its observed key. Preserve its qualification rather than claiming an unverified public invalidate method.
Task cancellation leaves the provider retainedA child Task or captured owner may still hold the SQLite actor.Await child Task completion/cancellation and end the owning scope. The soak uses weak actor release and independent writer probes; it does not call an invented UserContext.close().
A Node or console result is used to explain Apple UI behaviorNative SQLite console and application UI lifecycle are separate integration scopes.Keep this tutorial’s console evidence; label SwiftUI/Apple UI lifecycle work as a separate planned integration until demonstrated.

Order query troubleshooting​

Use Swift Order Queries with the matching export/insights fixture and recorded workspace. Diagnose the native plan and result carrier before changing an optimizer, cache or numeric conversion.

SymptomWhat to inspectNext action
Export count is 9 instead of 8Export uses a buyer-only predicate; the ten-order fixture adds an export-buyer EUR control.Use the nine-order export database. Retained-ID and summary recipes deliberately use the ten-order database and a currency predicate.
Empty export tail looks like failureThe ascending export's final offset 9 reports CACHE_MISS, zero rows and exact total 8.Stop on the empty tail normally. For retained IDs an empty tail can instead be an ID_SET_HIT.
ID overflow shows 5 while total is 8Capacity 4, lower-bound scan and exact provider COUNT.Keep observedCount separate from the matching total; do not retain a partial set or present 5 as the exact count.
Grand total equals a page/preview sumParent page size, child preview size and predicates on every aggregate/Facet request.Aggregate the whole filtered set in the provider. In the all-USD fixture it is 8/35350, even though only three parents are visible.
Empty sum or zero buckets are unexpectedEmpty groups, the one-row overall aggregate, and include-all versus matched-only Facets.Preserve overall count 0/sum null; keep zero status buckets only for the requested all-status variant.
An invalidate method cannot be found on the native store/contextThe public protocol exposes obtain; explicit invalidation belongs to the example adapter.Use the actor’s recorded-key delegate removal, awaited before the next request. Do not invent a public context.invalidate(...) call.
Page reporting or aggregate casts failThe page is a typed SmartList; analytic rows are TeaQLRecord with native orderStatus.Use the source’s explicit Array(page) report-helper adaptation and .decimalValue handling for analytic values; preserve optional overall sum.
Optimizer or Facet labels do not compileSwift uses argument labels for namespace/TTL/max IDs and includeAllFacets:.Copy the qualified native excerpt rather than translating TypeScript’s positional arguments; preserve the published 0.3.1 scope and application adapter qualifications.

Read the plan immediately after its request; a namespace string or stale observation from another request is not proof of reuse. The existing query cases record actual provider SQL, keys, builds/hits, elapsed expiry/invalidation events and unchanged database snapshots. Use that evidence first. Fixed-data reads do not supply a concurrent-write snapshot or a distributed-cache guarantee. All original runtime pending-release and generator-deployment qualifications remain.

Order isolation troubleshooting​

Use Swift Order Isolation with the v1.1 model/library and fresh eight-order database. Inspect the facade boundary and actual provider predicates before broadening access or changing a cache namespace.

Symptom / codeWhat to inspectNext action
Wrong model or missing tenant-key APIv1.0 core/query workspace versus the v1.1 isolation library, manifest and database.Use the retained regenerated isolation set; this is a fresh-database tutorial, not a live migration. Do not hand-edit generated files.
UNAUTHENTICATED / FORGED_SCOPEServer-owned session resolution and identity/policy fields in business JSON.Keep client fields out of the session tuple; the fixture key is not a production credential.
INVALID_TRUSTED_SCOPEZero/multiple tenant roots for the resolved key.Fail closed and repair provisioning; never choose an arbitrary root.
Foreign ID gives NOT_FOUNDRoot + buyer predicates and parent-owned item resolution.Preserve the common missing/foreign response; do not make a public unscoped lookup to distinguish them.
INVALID_BOUNDS, FORBIDDEN_FIELD, FORBIDDEN_OPERATIONNative numeric type, exact patch keys and read-only actor.Use integer 1–2 and the exact note/label patch. Do not coerce identity, strip extra fields or partially save.
List is scoped but summary/cache is notSame trusted predicates on every aggregate and retained request.Expect count 2/7700 cents; cache a,b,c,a must BUILD,BUILD,BUILD,HIT on one context with distinct scope identities.
Child edit reads a partial graph or changes unrelated versionsThree-child sentinel, two-child supported bound and native save path.Detail/edit overflow returns ITEM_LIMIT; preserve scoped complete-state loading and compare unrelated rows.
Context tenant/actor is assumed to enforce each sessionThe console context has fixed isolation-server/server-scope values and an identity RequestPolicy.Keep explicit root/buyer predicates in handle; implement authenticated principal/audit mapping separately at the real service seam.
Audit actor or HTTP authorization is assumed from response metadataThe example tuple is separate from native context principal and transport authentication.Wire real authenticated membership/principal mapping at the service boundary. JSON actor metadata and an audit reason do not prove that integration.

The isolation receipt checks the named console requests with SQL and SQLite snapshots. It does not certify arbitrary raw Q/database access, exhaustive hostile JSON, production migration or authorization revocation during a save. Keep runtime and generator release marks from the API scope guide.

Read the evidence in order​

QuestionExisting authority
Query shape, null state, edit, page or analytic resultCore Order receipt, this language’s native source, and the selected fixture.
Stale winner or atomic child failureConcurrent writes and the stored unchanged/authoritative database snapshots. Busy/locked and timeout errors do not qualify as version conflicts.
Request cancellation, provider statement failure or real COMMIT failureLifecycle evidence. Preserve the native error and verify rollback before retry.
Transaction, connection or task ownership after drain/closeFinite soak evidence. Separate active leases from idle owned connections and verify the final native close/lifetime end.
Published package differs from a recorded workspace PASSRelease qualifications. Keep the pending-release marker and exact runtime source/package identity.

Collect the failing phase, native error type/message, model and fixture revision, resolved runtime/package identity, and parameterized SQL shape/affected rows. Keep raw parameters and rendered SQL in the trusted operator boundary. Runtime telemetry sampling is not proof that an audit event was delivered or a transaction committed.

Reuse the existing failure and successful recovery evidence first. If a specific claim still has no authority, isolate that one operation on a disposable database and record the minimal result. Keep that reproduction scoped to the failing operation. Preserve School, every historical Order receipt, all six lifecycle/soak workspace pending-release qualifications, and the generator repairs pending deployment.

Swift retains the recorded published 0.3.1 result. That does not remove the other six runtimes’ RELEASE PENDING qualifications.