Skip to content

feat(conversations): historical-tier summary on open (T1+ open side, dark) - #25755

Merged
Git-on-my-level merged 12 commits into
mainfrom
t1plus-historical-open
Nov 19, 2026
Merged

Git-on-my-level merged 12 commits into
mainfrom
t1plus-historical-open

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

Customers who sync old pendant audio see those conversations stuck on "Writing notes" forever. Backfill older than 72 hours never gets a summary, because the 72 h enrichment age gate (ENRICHMENT_MAX_AGE_HOURS=72, backend/docs/runbooks/enrichment-age-gate.md) parks every enrichment wake for it. The intake minimum still stamps summary_due_at, though, so Home keeps showing the row as owed.

This is PR 1 of 4 for the historical processing tier (T1+). Old backfill is stored with a transcript, speakers and a deterministic title. Its one summary is generated only when the owner opens it. It never gets memories, tasks, apps, folders, webhooks or notifications. This PR is the open side, and it is dark: nothing stamps processing_tier yet, so no live row changes. PR 2 adds ingest stamping. PR 3 (mobile) and PR 4 (desktop) call the new endpoint.

  • Marker and projection. Conversation.processing_tier: Optional[Literal['historical']] is stored and wire-visible. A merge of any historical source stays historical. summary_on_open: true is a read projection on list and detail (utils/conversations/historical_projection.py, import-light so the router still loads bare). It is set when the row is historical, has no summary, is not locked or discarded, and the open switch is on. Both fields are omitted when unset.

  • Title. The historical deterministic title carries title_provenance='historical_minimum'. Title stability, Home's neutral-title and short-fragment rules, salience and the notes-minimum checks treat it as a stand-in, like server_minimum, so the open-time summary replaces it and short fragments stay hidden as before. Summary debt, is_server_minimum (apps, memories, vectors), Home's "Writing notes" step and the mobile hasProvisionalTitle ignore it.

  • Trigger. ProcessingTrigger.HISTORICAL_OPEN uses mode (run_now, reprocess, KEEP). It is in sync_hold_completion.EXPLICIT, member_notes.EXPLICIT and the relevance decision vocabulary.

  • process_conversation.

    • Historical rows join the existing historical (summary-only) seam.
    • Any trigger outside {HISTORICAL_OPEN, USER_REPROCESS, MERGE, BACKLOG_CHOICE} short-circuits before the funded-budget block, through utils/conversations/historical_minimum.py. The row is stored completed, with deferred=False, no _get_structured, its deterministic title or the existing open-time summary, terminal_no_derived_effects and summary_blocked_reason='historical_on_open'. The persist keeps the capture-group and smart-merge refresh write fences.
    • Inside the seam, complete_explicit settles an outstanding sync hold, and an explicitly chosen template app writes its result.
    • The DB writer (summary_delivery.merge_result) records an open-time summary as delivered (summary_completed_at, summary_title_provenance='generated', no block) and keeps historical_on_open on an empty write. It never arms summary_due_at on a historical row.
  • POST /v1/conversations/{id}/summary/open (utils/conversations/historical_summary.py). Refusals come in this order:

    • 404 when the row is gone.
    • 409 conversation_locked, conversation_discarded or not_historical.
    • 200 with X-Omi-Summary-Outcome: existing when a summary is already present. This path is idempotent, makes no model call and passes no gate.
    • 503 historical_summary_disabled when the switch is off.
    • 409 byok_keys_required when a BYOK account's request carries no validated LLM-provider key (a transcription-only key does not count).
    • 402 from require_generated_compute(uid, 'historical_summary_open').
    • 429 from the per-user 30/h and 100/day slots, the global daily slot, or the row's 3 attempts per day. The slots are reversible reservations. Redis outages fail open.
    • 409 conversation_processing_in_progress when the attention claim fails.

    No slot is taken before the free refusals, and every slot is returned on any later refusal. A store error during admission is a typed 503 that also returns them. After the claim the row is read again, so a racing open returns the summary it landed. Then it runs process_conversation(trigger=HISTORICAL_OPEN, first_party_only=True) under track_usage(Features.HISTORICAL_SUMMARY). It answers 200 generated, 502 summary_unavailable on empty output, or a typed retryable 503 historical_summary_retry, which also covers a write fenced by a newer append. The summary vector is written after the summary lands, behind a sub-switch.

  • Guards.

    • /reprocess on a historical row takes the same admission as the open endpoint: switch, BYOK, budget and every slot. It stays summary-only and only indexes the summary vector. Old builds' "Summarize" CTA lands here.
    • GET /summary/stream never generates for a historical row; it serves the stored row.
  • Switches. HISTORICAL_SUMMARY_ON_OPEN_ENABLED, HISTORICAL_SUMMARY_VECTOR_ENABLED and SYNC_HISTORICAL_TIER_ENABLED (read in PR 2) are ops kill switches, on unless set off. HISTORICAL_SUMMARY_GLOBAL_DAILY_LIMIT defaults to 10000 per day, and 0 disables it. The tier boundary is the enrichment age gate itself: config.historical_tier.min_age_seconds() parses ENRICHMENT_MAX_AGE_HOURS exactly as age_gate does, and a gate of 0 means no tier. There is no separate age setting. All env reads are in config/historical_tier.py, outside the flag_budget.json scope. They are registered in config/feature-flags.yaml, and the registry doc is re-rendered.

  • Metrics. omi_historical_summary_open_total{outcome} (labels through reason_label and HistoricalSummaryOpenOutcome) and omi_historical_summary_latency_seconds. Opens over PR 2's omi_historical_tier_rows_total give the open rate.

  • Notes reuse key. models/structured.py is a notes prompt source, so NOTES_PROMPT_VERSION moves to notes-8 with its digest pinned. The widened title_provenance is schema-hidden, so prompt, schema and output are unchanged, and notes-7 stays reusable (the notes-7 precedent): nothing is re-bought.

  • Clients. The app-client OpenAPI and the generated Dart, Swift and TypeScript DTOs are regenerated. The new fields are optional and additive. title_provenance is excluded from the schema; the plugin SDK Structured accepts the new value.

Line-Count-Exception: backend/routers/conversations.py | 2919 -> 2957 | the summary-on-open route, the list/detail projection and the /reprocess historical admission live with their sibling conversation routes; the logic is in utils/conversations/historical_summary.py and historical_projection.py
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3517 -> 3541 | the historical short-circuit must sit before the funded-budget block and reuse the fenced persist; the store payload lives in utils/conversations/historical_minimum.py

Review findings

An independent review returned FIX. Every finding is addressed on this branch, each with a test that fails on the previous head.

# Finding Fix Test
B1 CI red: trust boundary, lifecycle writers, reason labels, router bare-load Classify processing_tier/summary_on_open; pin the seam's apps-results dump; the terminal status is set by process_conversation, the lifecycle owner; new merge_result sites declared; outcome labels via reason_label; the router imports only historical_projection the four guard suites
B2 MERGE dropped the marker and ran full derived effects merge_conversations stamps processing_tier when any source is historical test_historical_tier_merge_and_persistence.py, through the real perform_merge_async
M1 The open-time summary kept the transcript-echo title title_provenance='historical_minimum', treated as provisional by title_for_stability test_the_open_time_summary_replaces_the_deterministic_title (real title path)
M2 /reprocess bypassed the switch, attempts, caps and BYOK historical_projection.admit_reprocess runs historical_summary.admit before the claim; refusals release test_reprocess_of_a_historical_row_*
m1 merge_result overwrote the block with local_only and never stamped delivery _merge_historical DB-layer tests through persist_processing_result_with_lifecycle
m2 A Firestore error in admission leaked reservations as a 500 catch every exception, release, typed 503 test_an_admission_store_error_releases_its_slots_and_is_a_typed_503
m3 Double generation via restart_succeeded re-read after the claim; a present summary returns existing test_a_summary_landed_by_a_racing_open_is_returned_not_regenerated
m4 A fenced persist answered 200 generated persistence_observer; fenced is a retryable 503 with no vector test_a_fenced_persist_is_a_retryable_503_with_no_vector
m5 Any validated header set (transcription-only) passed the BYOK gate generated_compute.validated_llm_byok requires an LLM-provider key test_byok_account_with_only_a_transcription_key_is_409
m6 The short-circuit persist dropped the refresh write fences shared persist_with_fences test_the_automatic_short_circuit_keeps_the_refresh_write_fences
m7 Hourly/daily slots were spent on refusals free refusals first; reversible slots released on refusal test_refusals_never_spend_the_owners_hourly_or_daily_slots
PR2-M4 Tier age could drift from the gate boundary derived from ENRICHMENT_MAX_AGE_HOURS; 0 is no tier; the separate setting is removed test_the_tier_boundary_is_the_enrichment_age_gate, test_gate_off_means_no_tier

Defaults decided by the coordinator (David can override): HISTORICAL_SUMMARY_GLOBAL_DAILY_LIMIT 10000 per day; short historical fragments keep the existing Home noise and neutral-title rules, which the historical_minimum stand-in provenance now reaches.

Product invariants affected

  • INV-MEM-4: no Long-term memory writer is added, and historical rows return from the summary-only seam before any memory extraction.
  • INV-TASK-2: no task writer is added, and historical rows take no action-item extraction on any trigger.

How it was verified

The branch was built on origin/main 9c88e7f and merged with origin/main twice (no rebase). Every command went through bin/omi-heavy on a host at load ~250-350.

  • BACKEND_UNIT_TEST_FILE_LIST=<228 files> bash test.sh: the select_backend_unit_tests.py --focused-output list for the fix diff, the earlier 94-file list, and the CI-red guard suites. All passed except two fast-unit CPU-guard trips: the merge-builder test, whose first call amortizes the merge_conversations import like its allowlisted siblings and is now allowlisted, and test_conversation_processing_retryable_timeout (1.13-1.53 s), which trips the same way on unmodified origin/main on this host.
  • Red proof: the new and changed tests run against the pre-fix head fail 55 cases across the open, processing, merge/persistence, config, lifecycle, reason-label and lock-bypass suites.
  • scripts/check_feature_flag_registry.py reports OK; the OpenAPI --check and DTO generators show no drift; check_conversation_readers.py passes.
  • Not run: a live serve-and-curl. The route is dark until PR 2 stamps rows.

Tests

  • tests/unit/test_historical_tier_config.py: the boundary is strictly older than the gate and moves with it; a gate of 0 means no tier; untrusted clocks, switch defaults, the global limit parse, and the trigger table.
  • tests/unit/test_historical_tier_processing.py: automatic triggers store without a model call before the funded block and keep the refresh write fences; owner triggers generate summary-only; the open-time summary replaces the stand-in title; non-historical rows are unchanged.
  • tests/unit/test_historical_summary_open.py: every endpoint outcome and refusal order, slot accounting on every refusal, store errors, the racing open, the fenced persist, BYOK LLM-key requirement, /reprocess admission, the projection and the stream guard.
  • tests/unit/test_historical_tier_merge_and_persistence.py: the merge builder keeps the marker; the DB writer records delivery and keeps the block.

UI-Evidence: none -- backend plus regenerated wire DTOs only; no client renders the new fields until PR 3/PR 4

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 6 commits November 19, 2026 00:16
…dark)

Adds the open side of the historical processing tier: the processing_tier
marker and summary_on_open projection, the HISTORICAL_OPEN trigger,
POST /v1/conversations/{id}/summary/open with its caps and gates, the
process_conversation short-circuit and summary-only seam, and guards on
/reprocess and /summary/stream. Nothing stamps the marker yet, so this
changes no live row; ingest stamping follows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ic summary debt

An empty or short transcript can return the provenance-stamped minimum from the
notes pipeline; the historical row must still owe nothing the age gate parks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	backend/routers/conversations.py
@mintlify

mintlify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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

Project Status Preview Updated
omi 🟢 Ready View Preview Nov 19, 2026, 5:35 AM

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

Git-on-my-level and others added 6 commits November 19, 2026 13:16
- Historical titles carry title_provenance='historical_minimum': a stand-in for
  title stability and Home's short-fragment rules, never summary debt, derived
  effects or the mobile provisional marker. The open-time summary now replaces it.
- Merging a historical source keeps the merged row historical (summary-only).
- /reprocess on a historical row takes the open endpoint's admission: switch,
  BYOK LLM key, budget, hourly/daily/global/attempt slots.
- Admission answers free refusals before taking slots, returns every slot on any
  refusal or store error (typed 503), re-reads after the claim so a racing open
  returns its summary, and reports a fenced persist as a retryable 503.
- BYOK requires a validated LLM-provider key (generated_compute.validated_llm_byok).
- The automatic short-circuit keeps the capture-group and smart-merge write fences.
- merge_result records an open-time summary as delivered and keeps the
  historical block on an empty write instead of local_only.
- The tier boundary is derived from ENRICHMENT_MAX_AGE_HOURS (0 means no tier);
  SYNC_HISTORICAL_TIER_MIN_AGE_SECONDS is removed.
- CI guards: classify processing_tier/summary_on_open, pin the seam's dump,
  route the terminal status through process_conversation, outcome labels via
  reason_label, and a light historical_projection module so the router loads bare.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 397ee1d into main Nov 19, 2026
72 checks passed
@Git-on-my-level
Git-on-my-level deleted the t1plus-historical-open branch November 19, 2026 09:44
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"
    ]
  }
]
```
Git-on-my-level added a commit that referenced this pull request Nov 20, 2026
## What changed and why

- Historical `/reprocess` rejects an explicit `app_id` with HTTP 400
before it validates an app or reserves historical-summary quota. The
processor also skips app execution and the app-results write for
historical rows.
- The revision-fenced summary write deletes
`structured.title_provenance` when generated notes replace the
historical stand-in. An empty write keeps the marker and leaves
automatic summary debt unset.

Fixes SCA-3427. Follow-up to #25755.

## Product invariants affected

- INV-MEM-4. Historical notes stay within first-party summary
processing.
- INV-TASK-2. Historical reprocessing continues to bypass task creation.

## How it was verified

- 210 tests passed across eight focused backend suites with
`backend/test.sh`. The regression exercises the actual FastAPI route
with an in-process client, synthetic conversation data, and stubbed
service boundaries.
- Confirmed the three regression cases fail against the original
implementation.
- `make preflight` passed all 41 checks. The pre-push hook also passed
Pyright and the 40-file backend selection.

## Tests

- `test_historical_summary_open.py` covers HTTP refusal before quota
reservation, app lookup, or processing.
- `test_historical_tier_processing.py` checks that even a direct
processor call with a resolved app cannot trigger it.
- `test_summary_delivery.py` checks the nested field deletion through
the persistence writer's leaf mask and retention on an empty summary.

## UI evidence

UI-Evidence: none -- backend-only change

## Failure class (fixes)

Failure-Class: none

Line-Count-Exception: backend/routers/conversations.py | 3014 -> 3015 |
Keep the historical app-selection guard at the request boundary before
admission.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25894?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25894?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25894&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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