Skip to content

harden(app): typed analytics event registry contract (C7) - #14371

Merged
Git-on-my-level merged 27 commits into
mainfrom
task/msd-spine-a-event-registry
Sep 18, 2026
Merged

Git-on-my-level merged 27 commits into
mainfrom
task/msd-spine-a-event-registry

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Define C7's typed event source, generated API/tracking plan, executable consumer references and protected queue/parity contracts. Four real events illustrate the migration; TypedEvents remains an uncalled throwing skeleton. Fresh main is merged normally on this branch to reuse build provenance and the replay fixes.

Product invariants affected

none

How it was verified

TZ=UTC bash app/test.sh: 2069 passed (three visible pending C7 contracts); harness: 308 passed, 7 skipped, 44 strict xfailed; spine: 31 pending, 10 protected; targeted Dart analyzer clean. make preflight: 19 checks passed (.local/t6-c7-preflight-delivery.log). mobile-verify fast for the registry: 20/20 journeys passed (.local/t6-c7-journeys/verify-receipt.json). Real-commit scanner replay passes fc38608 (5 app files), d324a95 (7), 8f747a5 (8). No telemetry server, device or production contact. Real PostHog presence and dashboard deployment are not claimed.

Tests

A reference bridge passed the revised complete-payload parity oracle; an active matcher regression covers the record/map equality pitfall. Protected Dart tests reject arbitrary text/identity values and mutable property bags, and compare all four event emissions, true/false properties, actual queue use, exactly-once flush, existing provenance and missing-key no-op. Active Python probes allow exactly one manager bridge, ignore unrelated camera/counter calls, and reject absent consumers, identity/free-text properties, wire mutation/removal and raw calls after adoption; legacy growth remains allowed.

Failure class (fixes)

Failure-Class: none

New guards (only when adding a check or ratchet)

The #12271 missing-instrumentation incident motivates retained wire identities and executable consumers. The generator and queue-facing typed seam are shared primitives; TypedEvents.emit alone may bridge once to AnalyticsManager.track; the small lexical scanner only prevents regression in adopted files and the single typed bridge, not growth in legacy files. It does not claim whole-program taint analysis or deployed-query verification.

Three most likely wrong assumptions:

  1. SQLite's event projection will remain a useful portable test oracle for the eventual PostHog query deployment.
  2. Whole-file adoption may lag substantially while the central legacy manager remains mixed.
  3. Real feature triggers may disappear despite intact event definitions; each migrated batch still needs platform/input-path trigger coverage.

Part of the mobile self-driving program (Spine A). Stacked on #14310. Designed and written by Codex gpt-6-astra. Draft until the lane that will build on it has reviewed it for buildability.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 15 commits September 17, 2026 13:42
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.
…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.
C7 keeps legacy wire names and queue behavior, requires executable consumers, and constrains raw calls only after adoption or in new files. Four example events remain behind a pending dispatch skeleton. Verified UTC app 2067, harness 306 passed/7 skipped/44 xfailed, spine 31 pending/9 protected, preflight 19 checks, and 20 hermetic journeys.
Preserve wire property spelling independently from Dart identifiers and restrict raw-call enforcement to adopted files and the one typed bridge. Revise the protected payload oracle after a Flutter matcher probe exposed map identity inside records.

Verified: TZ=UTC bash app/test.sh (2069 passed); full harness (308 passed, 7 skipped, 44 strict xfailed); spine (31 pending, 10 protected); make preflight (19 passed); fast journeys (20/20); three historical commits passed scanner replay.
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.
# Conflicts:
#	.github/checks-manifest.yaml
#	contracts/spine/files.json
@mintlify

mintlify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Sep 18, 2026, 4:51 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

…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.
Add strict pending C7 oracles for initialized and pre-init queue payloads. Legacy event privacy remains C8 scope. Verification: UTC app 2071 passed; harness 320 passed, 7 skipped, 59 strict xfailed; spine 43 pending / 13 protected; preflight 19 passed.
Preserve C7 oracles and main's analytics privacy and mechanism fixes. UTC app suite: 2119 passed. Harness: 342 passed, 7 skipped, 59 strict xfailed.
C7's unchanged export plus main's accepted analytics privacy fix no longer matches the old whole-file scaffold pin. Declare the exact existing prefix and require all remaining bytes to equal the accepted target. Oracle and owned skeleton pins stay unchanged; no filename exception or implementation edits are permitted.

Verified: 15 mechanism tests, including both merge orders and rejection of proposed shared-body edits, weakened assertions, and declaration changes/removal. Full harness/preflight passes on the final oracle correction tree; original scope policy and analyzer baseline unchanged.
Restrict AnalyticsManager imports so existing TypedEvents.emit assertions resolve through typed_events.dart itself. Removing that direct import now fails analysis. Exact revision019 pins preserve every pending marker and runtime assertion; no analyzer baseline change.

Verified: analyzer ratchet passed; positive import probe exit 0, negative probe exit 3. UTC app owner rerun 2119 passed after an unchanged WAL test timed out under host load. Final preflight 19 checks passed; registry 4 events current; full harness 343 passed, 7 skipped, 59 strict xfailed.
Main advanced to 83f5428 during verification. Preserve both the accepted revision-payload correction and the shared-prefix scope correction. Resolve the sole conflict as a union of mechanism regression functions; every function from both parents is AST-identical. No Dart or app implementation change.
Pin the reviewed shared prefix directly rather than requiring a superseded whole-file payload to remain reachable. Add a real squash regression alongside both parent orders and negative oracle/body/declaration checks. Mechanism suite: 16 passed; before-correction reproduction fails with frozen scaffold payload missing.
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review September 18, 2026 02:57
Three conflicts, all genuine unions rather than a side to pick:

- contracts/spine/files.json: main added 17 C1 oracle entries via #14327, this
  branch adds 3 C7 entries, and neither side's are on the other. Unioned to 30;
  both belong, since the C1 oracles are live on main and the C7 ones are this
  contract's own.
- .github/checks-manifest.yaml: unioned to 226 unique ids — this branch's
  mobile-event-registry plus main's capture-ownership-boundaries and
  mobile-boundary-check-tests.
- app/AGENTS.md: each side deliberately deleted one base line and added a
  pointer row. Honoured both deletions and both additions, which also happens to
  be the smallest result: 11271 of the 11411 budget.

Worth recording because it nearly went wrong: my resolver appended the two
main-only manifest blocks at end-of-file, which put them inside the trailing
'exempt:' key instead of 'checks:'. The ids were present as text and absent from
the parsed checks list, so two checks would have been silently dropped. Moved
them into the list and verified by parsing: 226 unique ids, all three named
checks present, 'exempt' intact.

Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level and others added 2 commits September 18, 2026 11:41
scripts/check_spine_contracts.py refuses a change set that carries a spine
revision record alongside non-oracle paths, and after merging main forward it
named exactly one offender: docs/doc/developer/Contribution.mdx. This branch
carries revisions 009 and 019, so the seven-line contributor paragraph about
adding typed events had to come off it.

Aligned the file with origin/main. Spine checker then exits 0 at 82 pending
markers and 30 protected files, with no mixed-path error.

The paragraph is not lost: it is preserved verbatim and goes out as its own
docs-only PR, which is where the rule wants it. Nothing about the contract, the
oracles, or the generator changed here.

Co-Authored-By: Claude Opus 5 <[email protected]>
My first resolution of this file preserved main-only check IDs but not main's
EDITS to shared IDs, and that silently reverted #14465. One shared id differed:

  product-invariants
    ours: --changed-files {changed_files} --pr-body-file {pr_body_file}
    main: --base {base} --head {head} --pr-body-file {pr_body_file}

Main's is #14465's fix — compute the change set as a three-dot diff from the live
base instead of consuming a changed-files list. Keeping ours would have undone a
gate fix that merged tonight, and #14465's own invariance test caught it:
test_product_invariants_diffs_three_dot_from_base_not_a_changed_files_list failed
in check-manifest-contract.

Rebuilt from main's text and re-inserted this branch's single addition
(mobile-event-registry), so no edit of main's can be lost by construction.
Verified: 226 unique ids, all of mobile-event-registry,
capture-ownership-boundaries and mobile-boundary-check-tests present,
product-invariants carrying main's command, and the trailing 'exempt' key intact.

Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
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]>
@Git-on-my-level
Git-on-my-level merged commit 8f03c02 into main Sep 18, 2026
38 checks passed
@Git-on-my-level
Git-on-my-level deleted the task/msd-spine-a-event-registry branch September 18, 2026 08:17
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
* harden(dev-harness): define V1 live-session and V8 spine contracts

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

* harden(dev-harness): scope the spine-contracts check to spine paths

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]>

* docs(dev-harness): clarify the live journey adapter boundary

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.

* harden(dev-harness): pin reviewed spine revisions and align B0 capabilities

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.

* harden(dev-harness): preserve marker retirement across spine revisions

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.

* harden(dev-harness): retain corrected spine oracles through squash merges

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.

* test(dev-harness): revise live session acceptance after builder review

* test(dev-harness): bind machine fixture to actual child identity

* test(app): define typed analytics registry and consumer contracts

C7 keeps legacy wire names and queue behavior, requires executable consumers, and constrains raw calls only after adoption or in new files. Four example events remain behind a pending dispatch skeleton. Verified UTC app 2067, harness 306 passed/7 skipped/44 xfailed, spine 31 pending/9 protected, preflight 19 checks, and 20 hermetic journeys.

* harden(app): make typed event contracts satisfiable and adoption scoped

Preserve wire property spelling independently from Dart identifiers and restrict raw-call enforcement to adopted files and the one typed bridge. Revise the protected payload oracle after a Flutter matcher probe exposed map identity inside records.

Verified: TZ=UTC bash app/test.sh (2069 passed); full harness (308 passed, 7 skipped, 44 strict xfailed); spine (31 pending, 10 protected); make preflight (19 passed); fast journeys (20/20); three historical commits passed scanner replay.

* harden(dev-harness): separate oracle revisions from implementations

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.

* harden(dev-harness): retain pinned corrections after older parent merges

* harden(dev-harness): pin oracle content across shared runners and merge 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.

* test(app): require analytics privacy at the emission boundary

Add strict pending C7 oracles for initialized and pre-init queue payloads. Legacy event privacy remains C8 scope. Verification: UTC app 2071 passed; harness 320 passed, 7 skipped, 59 strict xfailed; spine 43 pending / 13 protected; preflight 19 passed.

* harden(dev-harness): freeze shared scaffold additions separately

C7's unchanged export plus main's accepted analytics privacy fix no longer matches the old whole-file scaffold pin. Declare the exact existing prefix and require all remaining bytes to equal the accepted target. Oracle and owned skeleton pins stay unchanged; no filename exception or implementation edits are permitted.

Verified: 15 mechanism tests, including both merge orders and rejection of proposed shared-body edits, weakened assertions, and declaration changes/removal. Full harness/preflight passes on the final oracle correction tree; original scope policy and analyzer baseline unchanged.

* test(app): require the direct C7 registry API

Restrict AnalyticsManager imports so existing TypedEvents.emit assertions resolve through typed_events.dart itself. Removing that direct import now fails analysis. Exact revision019 pins preserve every pending marker and runtime assertion; no analyzer baseline change.

Verified: analyzer ratchet passed; positive import probe exit 0, negative probe exit 3. UTC app owner rerun 2119 passed after an unchanged WAL test timed out under host load. Final preflight 19 checks passed; registry 4 events current; full harness 343 passed, 7 skipped, 59 strict xfailed.

* test(dev-harness): preserve shared prefix contracts through squash

Pin the reviewed shared prefix directly rather than requiring a superseded whole-file payload to remain reachable. Add a real squash regression alongside both parent orders and negative oracle/body/declaration checks. Mechanism suite: 16 passed; before-correction reproduction fails with frozen scaffold payload missing.

* Move the typed-analytics contributor docs out of the contract branch

scripts/check_spine_contracts.py refuses a change set that carries a spine
revision record alongside non-oracle paths, and after merging main forward it
named exactly one offender: docs/doc/developer/Contribution.mdx. This branch
carries revisions 009 and 019, so the seven-line contributor paragraph about
adding typed events had to come off it.

Aligned the file with origin/main. Spine checker then exits 0 at 82 pending
markers and 30 protected files, with no mixed-path error.

The paragraph is not lost: it is preserved verbatim and goes out as its own
docs-only PR, which is where the rule wants it. Nothing about the contract, the
oracles, or the generator changed here.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Rebuild the checks manifest from main's side, not ours

My first resolution of this file preserved main-only check IDs but not main's
EDITS to shared IDs, and that silently reverted #14465. One shared id differed:

  product-invariants
    ours: --changed-files {changed_files} --pr-body-file {pr_body_file}
    main: --base {base} --head {head} --pr-body-file {pr_body_file}

Main's is #14465's fix — compute the change set as a three-dot diff from the live
base instead of consuming a changed-files list. Keeping ours would have undone a
gate fix that merged tonight, and #14465's own invariance test caught it:
test_product_invariants_diffs_three_dot_from_base_not_a_changed_files_list failed
in check-manifest-contract.

Rebuilt from main's text and re-inserted this branch's single addition
(mobile-event-registry), so no edit of main's can be lost by construction.
Verified: 226 unique ids, all of mobile-event-registry,
capture-ownership-boundaries and mobile-boundary-check-tests present,
product-invariants carrying main's command, and the trailing 'exempt' key intact.

Co-Authored-By: Claude Opus 5 <[email protected]>

* docs(contributing): how to add a typed mobile analytics event

This paragraph was written as part of the C7 event-registry contract and had to
come off that branch: check_spine_contracts.py refuses a change set that carries
a spine revision record alongside non-oracle paths, and #14371 carries revisions
009 and 019.

Stacked on #14371 rather than cut from main on purpose. It references
scripts/check_event_registry.py and app/lib/utils/analytics/registry/REGISTRY.md,
neither of which exists on main yet — both arrive with #14371. Based on main this
would document tooling a reader cannot run.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>

This branch was successfully deployed

1 active deployment
staging - docs — c069172f Deployed Sep 18, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant