Repository navigation
feat(app): add typed ApiResult and migrate the conversation list and detail - #14600
Conversation
Add strict Python/Dart pending contracts and introducing-commit protection. Reserve the live-session CLI, wire, ownership/attachment seams and failing builder acceptance tests. Add live attribution before freezing evidence v1. Verification: - bash scripts/dev-harness/run-tests.sh: 287 passed, 7 existing skips, 40 strict xfailed (24 pending V1 markers), Python 3.11.15. - make preflight: 16 checks passed, using supported PYTHON selection. - make mobile-verify fast --paths harness/session contract inputs with an absolute evidence directory: 20 executed, 20 passed, no failures/skips. - bash app/test.sh: 2014 passed, 5 skipped, one unchanged UTC+7 search_rank_grouping_test failure; affected baseline inputs match main. - Real module CLI refusals exit 2 without traceback; regression covered. - Dart SDK probe proves ext. prefix required; marker-removal formatter probe proves no incidental Dart diff. Runtime is intentionally unimplemented. App UI must repair current invalid VM extension names before live acceptance; unsupported journeys block. Simulator/emulator latency and detached-process acceptance remain V1 work. make setup installed hooks but full backend wheel sync stalled; isolated Python 3.11 harness dependencies ran the owner checks without any skip flag. Failure-Class: none
The check protects files under the spine roots and their registry, so it only needs to run when those change. A repo-wide trigger would run it, and its full-history requirement, on every unrelated contributor PR. Co-Authored-By: Claude Fable 5.1 <[email protected]>
V1 must refuse live journey execution until a shared executable adapter exists; B1 addressability alone cannot attach Dart integration tests. Pure admission contracts remain valid with injected supported IDs. Verification: harness 287 passed, 7 skipped, 40 strict xfailed; make preflight passed 20 checks.
Preserve auth results and existing endpoint protections while defining typed failures, partial row decoding, terminal locked/rejected states and bounded fallback telemetry. Verified UTC app (2058 passed), harness (287 passed, 7 skipped, 40 strict xfailed), 20 hermetic journeys and 21 preflight checks. Skeletons remain unreachable.
…lities Coordinator turn-4 review authorizes the V1 fixture correction. Exact before/after digests pin the revised oracle; immutable revision records do not permit builder assertion edits. Active tests reject missing/tampered records and prove the fake machine response. Verification: full harness 289 passed, 7 skipped, 40 strict xfailed; UTC app 2020 passed; spine 24 pending/7 protected; make preflight 16 passed. No live device acceptance claimed.
Track retained marker occurrences rather than counts so retiring a second test cannot restore the first test's retired marker. The active regression covers this swap and legitimate continued retirement. Verification: full harness 290 passed, 7 skipped, 40 strict xfailed; spine 24 pending/7 protected; make preflight 16 passed. Dart sources unchanged after the earlier UTC app 2020-pass run.
…rges A squash can introduce a corrected contract and its review records in the same commit. Absorb only the revision prefix ending at that introducing file's exact digest, preserving immutable records and later marker-only edits. Active temp-repo regression covers multiple corrections in one squash and rejects restoring old or altered assertions. Verification: harness 291 passed, 7 skipped, 40 strict xfailed; B1 make preflight 20 passed; final B1 journeys 20/20. Dart unchanged after UTC app 41 opt-in and 2051 ordinary passed.
…i-result # Conflicts: # scripts/dev-harness/PENDING_CONTRACTS.md
Use the actual PR base and immutable exact scaffolding snapshots to reject mixed revision/implementation diffs. Exercise a real squash and child merge. Correct local_dev wire spelling from the simulator RPC and add adversarial V1 conformance oracles after reviewing the first broker. Verification: UTC app 2064 passed; full harness 303 passed, 7 skipped, 55 strict xfailed; spine 37 pending/9 protected; preflight 16 checks passed. Isolated reviewed-broker probes failed 9/9 as documented in the conformance report. No real app/device launch.
Resolve spine registry and checks manifest as a union without changing owners or assertions. Keep the widget-contract guidance and main's hermetic runner guards. UTC app: 2135 passed. Harness: 308 passed, 7 skipped, 44 xfailed. Spine: 43 pending, 14 protected; final PR-scoped preflight follows the merge.
…ge orders Keep exact oracle digests and immutable revision records. Traverse full reachable history and match revision payloads by digest. Shared runner metadata requires direct fail-fast suite invocation instead of pinning shared file bytes. Both new regressions fail on the old checker. UTC app 2064 passed; final harness 306 passed, 7 skipped, 59 strict xfailed; spine 39 pending/10 protected; preflight 16 passed. No protected oracle bytes or legacy scope pins changed.
makeApiCall still returns null for the 28 existing conversations.dart callers; ConversationApi is the first path where 403, 503, and a missing row are distinct, and an injected outage renders error instead of the empty hero. Co-authored-by: Cursor <[email protected]>
…istory Rejected mixed proposals can be reverted without losing exact oracle protection. Scope is checked over the whole proposal; exact retired renderings require an immutable reviewed digest.\n\nVerified: full harness 309 passed, 7 skipped, 59 strict xfailed; Dart 2064 passed; spine check clean; make preflight 16 checks passed. Real chat tree 9f5548474f passes against its addressability contract target.
Preserve all eleven pending markers and the executable AST. Exact retired digests cover the builder's already-introduced unused-import cleanup without granting general edit permission. Full harness and preflight pass; AST evidence is recorded in .local/t11-v1-format-evidence.json.
Retain every generator instruction beside the existing table and free 180 bytes for the queued contract pointers. Do not change the guide budget. make preflight passed all 16 checks.
Resolve the registry as an owner-preserving union and retain widget runner guidance alongside the collection equality rule. Verified with C3 correction in the working tree: Dart 2135 passed; harness 316 passed, 7 skipped, 59 strict xfailed; preflight 21 checks passed.
Dart Record equality compares Map identity. Revision 017 keeps the pending marker and exact closed fields while checking cardinality, event name and Map separately. Flutter matcher reproduction: 3 passed; Dart owner suite: 2135 passed; harness: 316 passed, 7 skipped, 59 strict xfailed; preflight: 21 passed.
…d-result Co-authored-by: Cursor <[email protected]> # Conflicts: # contracts/spine/files.json # scripts/dev-harness/PENDING_CONTRACTS.md
The remote tip carried a merge of an older origin/main; this branch already contains current origin/main plus 20 commits. Merged to restore a fast-forward path without rewriting published history. Co-Authored-By: Claude Opus 5 <[email protected]>
Retain both main's singleton testing guidance and C3's HTTP contract pointer; preserve widget and record-equality guidance. app/AGENTS.md measures 11316 bytes against the unchanged 11411 budget. Harness: 335 passed, 7 skipped, 59 strict xfailed.
Take the spine PENDING_CONTRACTS wording from #14328, including the Map-identity expect rule, and retire the C3 fallback-map pending marker now that recordFallback is implemented. Co-authored-by: Cursor <[email protected]>
…ook like an empty account main.dart and hermetic boot now call createProductionConversationProvider, which always constructs ConversationApi. An unused import would satisfy the dead-code ratchet; the new test asserts the live call site and that a 503 on that factory-built provider renders the error surface on ConversationsPage. Co-authored-by: Cursor <[email protected]>
Six conflicts. Resolutions, and why each side rather than the other: - .github/checks-manifest.yaml: rebuilt from MAIN's text, then re-inserted this branch's api-result-boundaries block, so no edit of main's can be lost by construction. Two shared ids differed: product-invariants took main's, which is #14465's three-dot-from-base fix, and mobile-boundary-check-tests took the UNION of triggers, since main watches app/contracts/capture/** and this branch watches app/contracts/**/boundary-baseline.json and both are wanted. 226 unique ids. - contracts/spine/files.json: union to 33. Main has 17 C1 oracle entries, this branch 6 C3 ones, no key claimed by both with different content. - .github/scripts/dead_code/flutter.allowlist.json: union to 11 entries — this branch's four api_* files plus main's three capture_* files. - scripts/test_check_mobile_boundaries.py (add/add): took ours, verified a strict superset of main's (zero lines present only on main's side). - app/AGENTS.md: union of the pointer rows. Each side deliberately deleted one base line; honoured both deletions and both additions. 11309 of 11411. - docs/doc/developer/Contribution.mdx: aligned with main. This branch carries four spine revision records, and check_spine_contracts.py refuses a revision record riding with non-oracle paths, so the contributor-docs hunk cannot travel on it. Same call as on #14371. Co-Authored-By: Claude Opus 5 <[email protected]>
Split the four C3 revision records and the oracles they pin off #14328 so a revision no longer travels with flutter.allowlist.json. Co-authored-by: Cursor <[email protected]>
The contract PR must not introduce a revision record of its own. These records now come from task/msd-spine-c3-revisions.
Bring the C3 oracle-only revision split and the origin/main conflict resolutions forward so this published child still fast-forwards from the contract branch.
These four api_* files are unreachable from main.dart until the first consumer is wired, so the dead-code allowlist entries travel with the skeleton. No revision records, no spine tests. Co-authored-by: Cursor <[email protected]>
Base the C3 oracle tests on the compiling skeleton so the revision records stay oracle-only against this parent.
Bring the compiling skeleton and oracle-only revision records in as the new base so this published contract branch no longer introduces either.
Forward the three-way C3 split so this published child still fast-forwards from the contract branch.
|
Merge-forward complete against main |
1 similar comment
|
Merge-forward complete against main |
Add library directives to the two new doc-commented files, const the ApiFailure returns, and un-hide sendUncaughtApiCall from @VisibleForTesting — executeApi is a production entry point that must preserve the thrown cause, which the annotation wrongly flagged as test-only.
Summary
C3 PR1: typed
ApiResult<T>never null, one shared uncaught send, conversation list/detail as the first migrated file, old and new coexisting. Stacked ontask/msd-spine-a-api-result(#14328). Branchtask/msd-core-c3-typed-result. Not pushed.This closes the HTTP subset where
makeApiCallreturning null made an outage indistinguishable from an empty account, and wheregetConversationByIdreturned null identically for transport failure, 403, 503, and a missing row. 402 and 422 now have terminal kinds with no retry loop.What changed and why
ApiResult<T>—ApiSuccess(data, rejectedRows)orApiFailure(ApiProblem), never null. Taxonomy matchesapp/lib/backend/http/API_RESULTS.md. Programming errors (StateError,NoSuchMethodError) propagate fromexecuteApi; onlyFormatExceptioninside decoding becomesdecode.sendUncaughtApiCallis the oldmakeApiCalltry-body (headers, pool, timeouts, clock skew, 401 replay).makeApiCallis now the null-wrapping catch only.executeApidefaults to that uncaught path. It does not wrap nullablemakeApiCalland guess why it failed. Thesendseam is already-authenticated I/O;executioninjects transport + header builder +AuthServiceinto the same production request path with no global defaults.refreshAndReplayAfter401gainedonAuthRefreshsoexecuteApican see the observedAuthTokenResult. A transient refresh that returns the original 401 isauthTransient, not collapsed intoauthTerminal.ConversationApi.list/byIdlive inapp/lib/backend/http/api/conversations.dartnext to the legacy functions. Why this file: the note's evidence is conversation-detail conflation (getConversationById→ null for 403, 503, and missing) plus list empty-vs-outage (cfaaaf2fb9db,06597a0757cb). All 28 existingmakeApiCallcall sites in that file stay.getConversationById/getConversationsstay. ProductionConversationProvider()withoutconversationApiis unchanged.composeTypedConversationProviderreturns the realConversationProvider.apiViewState,ConversationApiStatus(keysomi.conversations.error/.locked/.terminal/.auth/.empty, retry only whenretryable, error is a Semantics liveRegion) precedes the empty hero onConversationsPage. 402/422 on typed detail leave Processing and do not poll.Widget tests drive
getInitialConversationsinsiderunAsync(as the spine test already does).ConversationsPage(requestInitialLoad: false)is a test-harness-only constructor defaulting to true in production, so initState does not queuefailNexton the fake-async clock where loopback I/O never completes. The page still mounts for real, and still uses the production status-before-hero branch.Product invariants affected
none (
scripts/pr-preflight --suggest)How it was verified
TZ=UTC bash app/test.shthenTZ=UTC flutter test: 2137 tests, all passed.python3 scripts/check_spine_contracts.py: pass. One remaining C3 marker (see below). 29 pending markers repo-wide (rest are V1).make preflight: 21 checks passed in 62.45s. No harness-port flake this run.dart format --line-length 120on the production/test files we own. Spine tests were restored to contract-branch originals then had markers removed only.make lane-bootstrap(this worktree had no venv) thenmake mobile-verify ARGS="fast --paths …": outcome passed, 20/20.Could not run: physical device. Production
ConversationProvider()withoutconversationApistill usesmakeApiCall(intentional coexistence).Tests
app/test/spine/c3_*: markers retired except one (below). Assertions untouched.app/test/unit/backend/http/api_send_extraction_test.dart:sendUncaughtApiCallthrows;makeApiCallreturns null on the same failure. 402/422: one send,retryable == false, decode not called.ConversationsPageviabuildTypedConversationScreen. Outage isApiViewPhase.error+omi.conversations.error, notEmptyConversationsWidget. Recovery afteroutage=falseis empty. 402/422 leave Processing with one GET and no retry on a 2-minute pump.Self-check: 28
makeApiCallcallersrg -c makeApiCall app/lib/backend/http/api/conversations.dart→ 28. None of those sites were migrated.git diffofshared.dart: the uncaught body is the previousmakeApiCalltry-block;makeApiCallnow only callssendUncaughtApiCalland applies the sameAuthTokenUnavailableException/ catch → null policy.makeApiCallnever passesexecutionoronAuthRefresh, so those seams cannot change legacy behavior. Extraction test proves throw vs null wrap, not a source-string assertion.TZ=UTC flutter testincludes the existing conversation provider/HTTP suites that still go throughmakeApiCall.Self-check: 402 / 422 terminal, no retry, never uploaded
executeApimaps 402 →paymentRequired, 422 →unprocessable, bothretryable == false, one send, decode not invoked (api_send_extraction_testthrows if decode runs). Typed detailrefreshTypedDetailremoves the row fromprocessingConversationsand does not schedule a timer. Spine pumps 2 minutes and asserts still one GET. WAL upload is not on this file; we did not add a 402/422 success path that could mark a recording uploaded.Self-check: injected outage renders error, not empty list
Spine
c3_conversation_testusesJourneyFixtureBackend.failNext(..., status: 503)(the journeys'fixture_backend.dart). Status widget and the realConversationsPageboth showomi.conversations.errorand notEmptyConversationsWidget/omi.conversations.empty. Retry /forceRefreshafter the fault is cleared renders empty.Pending marker kept on purpose
C3 fallback emitter uses shared closed fields and one eventstill haspendingContract('C3'). The implementation emits the exact closed fields (component/area=other,from/to=none,reason=other,outcome=degraded, eventfallback_triggered). DartRecord.==usesMap.==, which is identity, soexpect(emitted, [(name, map)])cannot pass even when the maps are key-for-key equal. I did not rewrite the spine assertion (markers only). Architect: changing that expect toexpect(emitted.single.$1, 'fallback_triggered'); expect(emitted.single.$2, map);would let DeepCollectionEquality apply to the map and we can retire the marker.Failure class (fixes)
Not declared. This commit is
feat(app):(new typed surface + first exemplar).scripts/pr-preflight --suggestsaid nofix:commit was detected. Ask before defining a failure class — if you want this labelled as afix:instance of outage-as-empty / detail-null-conflation, say whichFC-*(ornew) to use and I will add the declaration in a follow-up commit.Scoped notes
makeApiCallsiblings inshared.dartare untouched.contracts/**.makeApiCallsites inconversations.dart. C4 can batch those.🤖 Generated with Claude Code
Failure class (fixes)
Failure-Class: none
This is a new typed surface plus its first exemplar migration rather than a fix of a specific
instance, so the commit is
feat(app):andscripts/pr-preflight --suggestdetected nofix:commit. The defect class it exists to close — an outage rendering as an empty account, and
getConversationByIdreturning null identically for transport failure, 403, 503 and a missingrow — is the contract C3 itself records.
🤖 Generated with Claude Code
Line-Count-Exception: app/lib/providers/conversation_provider.dart | 1750 -> 1858 | typed ApiResult migration: the conversation detail/list state machine moves from ad-hoc http calls to the typed executeApi/decodeApiRows pipeline with explicit error and retry states; the +108 lines are the migration itself. Split deferred until the C3 chain completes.
Product invariants affected
INV-DATA-1 — the typed ApiResult migration keeps production-family routing continuity: the conversation list/detail still resolve through the same production data plane, now with explicit error/retry states instead of ad-hoc calls.