Skip to content

backend-go: specify finalization and batch parity contracts - #25802

Merged
Git-on-my-level merged 3 commits into
mainfrom
agent/m1-studio-codex-astra/965ab2d41fcc
Nov 19, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
agent/m1-studio-codex-astra/965ab2d41fcc

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Document the Python behavior that the Go rewrite must preserve at admission, takeover, recovery, delivery and deletion. Each contract records Firestore field types and writers, known disagreements and limits of the source evidence. Python references are pinned to 66b026c19946.

The review revision covers both settings of the shard-spread flag (B09), record-seal repair (B28), and original WAL custody before decoding (B29). It also corrects five source citations.

Product invariants affected

none

How it was verified

Ran cd backend-go && make check with private Postgres 16 and a required Firestore emulator. The review revision passed the full check on M1 through bin/omi-heavy with a 12-minute timeout. All 259 source references resolve at the pinned commit. The five corrected citations were checked against the cited code.

Tests

The first combined run had two foundation test failures. The batchdocs erase test expected one matching Postgres guard session, and a concurrent queue test lost its connection. The test query at backend-go/internal/adapters/batchdocs/batchdocs_test.go:172 matches across databases on the private test server. An unchanged full rerun passed on a fresh private Postgres 16 server and Firestore emulator.

Twelve Python lifecycle-reducer cases exercised F02. Seven retained-audio tail cases exercised B05. The table lists the replay assertions proposed for the Go implementation. These documents add no runtime tests.

Finalization rules and replay assertions
Rule Replay assertion
F01 Disable task configuration and compare both documents before/after the failed REST request. Replay one event per trigger with the policy table.
F02 Race two end requests, then lose the winning response. Count one job, one revision and one creation. Try the same on completed, discarded and failed fixtures.
F03 Race new speech, a new session, an account wipe, a second backfill and a dead-letter binding against admission. Assert the losing request creates zero jobs.
F04 Disconnect before dispatch, replay, then advance the inactivity clock. Check no provider call with platform credentials and no secrets in jobs/tasks.
F05 Send malformed/extra fields, each prefix, priority wait and held lock. Count zero ordinary process calls on these paths.
F06 Kill after claim, advance past expiry, reclaim, attempt old completion and compare attempt_count to worker_claim_count. Deliver old generation and verify ACK.
F07 Interleave two reconcilers across cursor wrap, a deleted cursor doc, a missing marker and an undeliverable task. Compare generation, due time, outcome and oldest-overdue metric after each pass.
F08 Replay open, closed-empty, discarded and audio-present rows. Assert no paid summary and inspect both job and conversation at commit.
F09 Append a tail during the wait, delete during summarization, then advance sync revision before persist. Check included words and absence of stale writes.
F10 Count paid calls for unchanged input, edited notes, changed language/content and an unsuccessful prior extraction. Verify the recovery terminal/retry disposition under each configured mode.
F11 Race discard, deletion and revision replacement against claim. Count zero bundle/integration calls on the losing path and no recreation.
F12 Modify the survivor during claim and inject an embedding failure on a separate unchanged fixture. Assert no stale vector and successful downstream closure.
F13 Crash after persisted notes and compare memory, integration, receipt and keyframe call counts for normal, lazy and suppressed fixtures.
F14 Make receiver A succeed and B time out. Replay with the same header, then simulate final attempt. Observe created-webhook submission separately.
F15 Crash on each side of the two commits and replay. Assert one terminal success and no dead letter; distinguish websocket event from polling.
F16 Kill/reclaim with reset transport header, then exhaust twice. Assert one delay, durable count and terminal result even if the second exhausted task never returns.
F17 Run transient, deterministic, rebound and near-document-limit fixtures. Compare title, status, retry flag, attention and job terminal fields.
F18 Arm twice with later then earlier deadlines and compare generation, key flag and due time.
F19 Simulate reconnect, missing row, unknown lease, storage appearing before delete and admission failure after evaluation. Assert each current due check advances or retires.
F20 Inject both failure identities and insert an active writer before close. Compare check marker and conversation.
F21 Replay with fixed score on either side of threshold, changed revision, intervening discard and shadow mode. Compare model calls and both documents.
F22 Kill after absorb, after cleanup and after processing checkpoint. Verify one appended fragment, one redirect, and refusal of a stale owner's refresh.
F23 Race overlapping source sets, then delete or lock one before phase renewal. Compare every source and target id.
F24 Crash before and after phase commit. Expect only still-bound sources restored on rollback, and no second target on cleanup replay.
F25 Replay same close twice, close a non-tail member, delay notes, then finish. Compare episode membership, close reason and job budget.
F26 Replay intake then finalize for same clip, switch donor to survivor, timeout the episode collaborator. Assert membership identity and committed fanout independently.
F27 Replay title-only, gist-only, section-only, explicit keep after discard and manually edited rows. Compare indexed due marker and provider calls.
F28 Race two repair ticks with content change, test BYOK without keys and advance revisions across both rearms. Verify no new finalization job, no stale summary and a bounded empty-call budget.
F29 Seed a user-moved row, a fresh row and a classifier timeout. Compare folder_id, count and classifier calls.
F30 Replay a matched exported task, removed reminder, desktop suggestion and unchanged template. Compare durable IDs, markers, reminder/export submissions under each identity mode.
F31 Duplicate eager call within TTL and after expiry; repeat first-open with same key. Check model call count and progress history as well as the final absolute value.
F32 Place deletion marker before claim and between read/persist; delete the row during fanout admission. Assert no resurrection or integration delivery and distinguish stale from success.
F33 Replay dropped and orderly sockets with identical final speech; check job, quiet obligation or retained session as applicable. Repeat with an overlapping new session.
F34 Send each exact envelope, then a mixed envelope; assert HTTP response and which handler ran.
F35 Use a fake clock immediately before/at each boundary; replay a previous generation and verify it cannot acquire the parked work. Compare documented manual reset fields separately.
F36 Fail target retraction and assert sources remain bound. Kill halfway through source deletion, then remove the survivor before retry; remaining sources must survive.
F37 Replay an unplaced-only member twice; inject a notes outage and race stale close against new speech. Compare consumed IDs, last activity, and eventual notes.
F38 Race duplicate closure and add a legacy job; compare accepted, nonterminal, success, failure and stale counters to the stamped fixtures. Check absence of raw IDs or exception text in cause labels.
Batch rules and replay assertions
Rule Replay assertion
B01 Replace the object at the same name after admission; replay a cross-owner reference. Neither supplies replacement audio to the worker.
B02 Drop the response on both sides of commit, re-upload identical bytes and count authoritative jobs, stage receipts and legacy dispatches.
B03 Race duplicate uploads, missing last artifact and swapped sibling order. Expect all durable writes together, or none. Replay a legacy envelope with absent optional fields.
B04 Try zero, NaN, 7200, 7200 plus one sample; replay a capture span with source authority but no trusted target. Compare admission and selected target.
B05 Finalize with an open tail, then seal it. Flip policy after reservation, replay same seal, and attempt a stale partial continuation. Compare exactly which units release.
B06 Race two equivalent ranges, then change generation/range. Count paid enqueues and verify both original upload status views.
B07 Feed supported, unsupported, unknown and BYOK fixtures under the same frozen policy. Compare service, reason and route receipts and count vendor/GPU calls.
B08 Compare fresh and backfill uploads before/after owner grant or usage-period change, including duplicate release ticks. Count one eligible dispatch.
B09 With the flag unset, race two pulls and resume a paused holder after takeover; the loser and stale holder return busy. With the flag false, preoccupy the claim and verify a legacy pull can lease eligible work without reading or writing the claim. In both cases test mixed durations across owners and constrained shared capacity, and assert no duplicate job lease. Compare leased identities, tokens, deficit and queue links.
B10 Heartbeat just before/at expiry, reclaim, then try old heartbeat, failure and completion. Repeat with a different GPU/admission token.
B11 Complete twice, then vary token, URI and outcome separately. Assert one durable result, one completed-duration observation and no projection yet.
B12 Advance clock before/at due, kill instead of sending failure, test retry cap in observe and serve modes. Compare attempts, available_at and held state.
B13 Submit missing VAD, zero, positive followed by zero, and a receipt bound to different bytes. Compare held disposition, retained URI and absence of fabricated silence results.
B14 Crash before paid authorization, after paid start and after result persistence. Redeliver twice, run expiry concurrently, compare paid receipts and terminal/held state.
B15 Return late from vendor A after rotating intent; redrive a held vendor with no eligible next service. Compare attempt ledger, selected service and number of paid submissions.
B16 Present each retained dead shape to each redrive, then inject deletion. Check only its authorized transition can run and audio is preserved until privacy/retention owns cleanup.
B17 Complete B before A, then introduce an older C after B commits. Race two pumps. Compare log_tail, sequence, late flag, watermark and predecessor chain under strict and bounded-wait policy.
B18 Force a crash after first part and process a later segment. Reclaim and compare part IDs, assignment count, watermark and hold reason to uninterrupted replay.
B19 Put an invalid span or invalid authentication tag at chain head, then repeat with a retryable store failure and a newly active writer. Check head disposition and progress of next eligible segment.
B20 Kill after assignment, after enrichment mark and after usage commit. Repeat with one missing, held, erased or silent sibling. Compare conversation IDs, charged seconds and upload result at each point.
B21 Crash after claim, expire it and rotate the token. Try old settlement after hold, erasure and rearm. Assert no stale receipt and no count of successful repair on a failed wake.
B22 Poll at intake, result_ready, committed/pending, quarantine and final publication. Repeat as a different owner and after deletion.
B23 Pause before assignment, purge/recreate, resume with old generation; repeat with a deleted source alias and a live unrelated conversation. Assert no cross-generation write.
B24 Advance clocks past each deadline, replace an object at the same name, mark one unit held and one complete. Compare generation-specific delete requests and remaining receipts.
B25 Abort the first transaction, change a privacy or content owner before retry, and inject an ordinary application ValueError separately. Compare final writes, error classification and side-effect counts.
B26 Run a synthetic shadow with a recording reader, then exhaust its read budget and try another owner. Assert zero serving writes, notifications or usage mutations and compare projection decisions only where inputs match.
B27 Place a word at EOF, one just inside tolerance and one beyond it. Verify retained text, times, speaker grouping and invalid-input disposition.
B28 Race row claimants and coordinators for the same partition. Time out a child and interrupt repair before a deferred row; verify reaping, lease fencing and resumed discovery. Compare valid seal and intake wake, no-job registration races, refusal on stale proof, and the separate deadline dead letter.
B29 Test exact bounds and one over each, then mutate a file after inspection. Assert stored bytes match the inputs and the accepted receipt precedes decoder work. Replay after disabling handoff and fence privacy during archive and commit; check receipt and object cleanup.

UI evidence

UI-Evidence: none -- documentation only

Failure-Class: none

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 19, 2026 22:12
@Git-on-my-level
Git-on-my-level merged commit 97b4059 into main Nov 19, 2026
56 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m1-studio-codex-astra/965ab2d41fcc branch November 19, 2026 22:16
Git-on-my-level added a commit that referenced this pull request Nov 19, 2026
## Summary

Generate port task drafts when a merged Python PR changes finalization
or batch behavior. The map covers all 34 finalization and 41 batch
runtime Python sources cited by the [landed
contracts](#25802), plus
imported family policy and implementation. The [scope
document](https://github.com/BasedHardware/omi/blob/9554967bf78fab4d18b1504a7ef19b31e46141af/backend-go/docs/port-map-scope.md)
records the boundaries and exclusions. The PR branch includes `main` at
contracts merge `97b4059861a7`. The batch map includes the projection
kill-switch defaults introduced upstream in #25791.

The Backend Go Checks workflow runs the Python suite when these files
change in a PR. On each main push, it walks the pushed first-parent
merge commits, looks up their merged main PRs, and checks the complete
paginated file list against GitHub's `changed_files` count before
drafting. The CLI also rejects duplicate filenames in a counted input
and uses both sides of renames. The job prints JSON and uses read-only
permissions. Tracker writes are outside this change. [Commit-to-PR
API](https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit)
· [PR files
API](https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files)

## Verification

- Nine focused tests exercise family matching, renames, duplicate or
truncated file lists, malformed inputs, task text, existence of every
mapped file, and coverage of the checked-in batch contract. Run `python3
-m unittest discover -s .github/scripts -p test_go_port_tasks.py -v`.
- `actionlint .github/workflows/backend-go-checks.yml` passed. Ran the
workflow's push steps locally over three real first-parent merges and
verified Go test selection on Go and Python-only ranges.
- `cd backend-go && TEST_FIRESTORE_REQUIRED=1 make check` passed with
Postgres 16 and the Firestore emulator.
- Compared both map families to every runtime Python citation in the
landed contracts. Replaying merged PR #25791 also matched the new batch
projection kill switch.
- Repository preflight and `gh pr checks 25810 --watch` passed at head
`9554967bf7`. Local preflight skipped the 90-day failure-class ratchet
because the checkout is shallow. [Backend Go
Checks](https://github.com/BasedHardware/omi/actions/runs/44627579785)

## Product invariants affected

none

## Examples from merged PRs

```bash
count=$(gh api "repos/BasedHardware/omi/pulls/$PR" --jq .changed_files)
gh api --paginate --slurp "repos/BasedHardware/omi/pulls/$PR/files?per_page=100" |
  jq 'add' | python3 .github/scripts/go_port_tasks.py --pr "$PR" --changed-files "$count"
```

### PR #25771

```json
[
  {
    "family": "finalization",
    "title": "Port Python PR #25771 to Go finalization",
    "body": "Python PR [#25771](#25771) changed `backend/database/conversations.py`, `backend/models/conversation.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/render.py`, `backend/utils/conversations/v3/policy.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.",
    "matched_paths": [
      "backend/database/conversations.py",
      "backend/models/conversation.py",
      "backend/utils/conversations/process_conversation.py",
      "backend/utils/conversations/render.py",
      "backend/utils/conversations/v3/policy.py"
    ]
  }
]
```

### PR #25755

```json
[
  {
    "family": "finalization",
    "title": "Port Python PR #25755 to Go finalization",
    "body": "Python PR [#25755](#25755) changed `backend/config/merge_before_processing.py`, `backend/models/conversation.py`, `backend/models/structured.py`, `backend/utils/conversations/deterministic_minimum.py`, `backend/utils/conversations/empty_structure_minimum.py`, `backend/utils/conversations/fragment_visibility.py`, `backend/utils/conversations/historical_minimum.py`, `backend/utils/conversations/home_titles.py`, `backend/utils/conversations/merge_conversations.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/processing_trigger.py`, `backend/utils/conversations/relevance_salience.py`, `backend/utils/conversations/summary_delivery.py`, `backend/utils/conversations/sync_hold_completion.py`, `backend/utils/episodes/member_notes.py`, `backend/utils/llm/notes_short_clip_policy.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.",
    "matched_paths": [
      "backend/config/merge_before_processing.py",
      "backend/models/conversation.py",
      "backend/models/structured.py",
      "backend/utils/conversations/deterministic_minimum.py",
      "backend/utils/conversations/empty_structure_minimum.py",
      "backend/utils/conversations/fragment_visibility.py",
      "backend/utils/conversations/historical_minimum.py",
      "backend/utils/conversations/home_titles.py",
      "backend/utils/conversations/merge_conversations.py",
      "backend/utils/conversations/process_conversation.py",
      "backend/utils/conversations/processing_trigger.py",
      "backend/utils/conversations/relevance_salience.py",
      "backend/utils/conversations/summary_delivery.py",
      "backend/utils/conversations/sync_hold_completion.py",
      "backend/utils/episodes/member_notes.py",
      "backend/utils/llm/notes_short_clip_policy.py"
    ]
  }
]
```

### PR #25686

```json
[
  {
    "family": "finalization",
    "title": "Port Python PR #25686 to Go finalization",
    "body": "Python PR [#25686](#25686) changed `backend/utils/conversations/lifecycle.py`, `backend/utils/conversations/process_conversation.py`, `backend/utils/conversations/v3/policy.py`, `backend/utils/conversations/v3/service.py`, `backend/utils/conversations/v3/triggers.py`. Review the merged diff and port any behavior changes to the Go finalization family under `backend-go/`. Add or update parity coverage for the changed behavior, or record why the Go port needs no change.",
    "matched_paths": [
      "backend/utils/conversations/lifecycle.py",
      "backend/utils/conversations/process_conversation.py",
      "backend/utils/conversations/v3/policy.py",
      "backend/utils/conversations/v3/service.py",
      "backend/utils/conversations/v3/triggers.py"
    ]
  }
]
```
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