Skip to content

fix(notes): bump prompt version without re-buying stored work - #25108

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/notes-3-prompt-pin
Nov 11, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/notes-3-prompt-pin

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

957b91d changed pinned notes prompt/schema sources without a prompt version bump, leaving main's notes digest guard red. Bump notes-2 to notes-3 and append the current notes digest. Extend the historical-alias window through notes-3 and include dependency-qualified aliases so the version bump preserves already-computed notes. Existing pins, raw legacy digests, routing and dependency identities, and l1-1 remain unchanged.

Head: 1367bc2

Cost effect: There is no fleet re-buy from this bump: raw, version:routing, and version:routing:deps notes checkpoints stay reusable through the historical-alias window, so unchanged-input conversations keep their already-computed notes; only new or changed inputs compute under notes-3; L1 reuse keys are unaffected (l1-1 unchanged), while routing and installed pydantic/langchain-core identity changes invalidate reuse independently.

Grounding: backend/utils/conversations/llm_input_dedupe.py implementation_digest, stable_implementation and _matches; backend/config/llm_input_versions.py PROMPT_VERSIONS; backend/config/llm_input_legacy.py LEGACY_PROMPT_VERSIONS. Historical aliases remain gated by the recorded routing and dependency identities.

INV-MEM-4: canonical memory admission authority is unchanged; the notes version bump preserves successful work without altering admission or output validation.
Failure-Class: none

Validation:

  • make setup passed.
  • File-isolated backend/test.sh: 238 passed across test_conversation_llm_input_dedupe.py (50), test_llm_input_prompt_version.py (6), test_notes_gist.py, test_episode_evidence.py, test_wave2_action_items.py, test_meeting_notes_rich_context.py and test_action_item_extraction_policy.py (182 combined).
  • New regression seeds the pre-bump notes-2:routing:deps checkpoint and verifies unchanged-input reuse in both EPISODE_COMPOSER_REUSE modes, plus changed-input recomputation. Existing dedupe tests are unchanged.
  • make preflight passed all 36 selected checks (51.73s).
  • The single approved full-hook push passed with GOOGLE_APPLICATION_CREDENTIALS, CLOUDSDK_CONFIG and CLOUDSDK_CORE_ACCOUNT unset, OMI_PR_BODY_FILE supplied, and BACKEND_UNIT_FILE_BUDGET_SECONDS=3600. No bypass flags or force-push.

Scope and single full-hook push approved by refactor-lead: lead2 db98f3 and option B d966a1. No merge requested.

View guided diff Turn on auto-fix

@Git-on-my-level
Git-on-my-level merged commit 8fa2cbd into main Nov 11, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/notes-3-prompt-pin branch November 11, 2026 10:03
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 11, 2026
Picks up BasedHardware#25108 (notes prompt version bump) which fixes the main-wide
notes prompt-pin test failure.
Git-on-my-level added a commit that referenced this pull request Nov 11, 2026
… (C2) (#25084)

# C2: operator ledger census, stuck gauges and explain read

Failure-Class: FC-state-deadline-without-reader-exit

## Base and head

- Base: `75dc53a81df78643cf74c7638350fecc9082ebfc` (`origin/main` at
branch creation; still the merge base).
- Head: `5b4969d40427accbf5f36f0407b85427389ce204` (merge of
`origin/main` `8fa2cbd36487b171bf63c98201a8240d38f31b37` into
`85f491a617f1b10106b82b493818ceb35b94b9b5`).
- Branch: `lane/pipeline-c2-census`.
- Merge-main resolution under lead2 `1c606e`: the two JSON conflicts
(`alert-rules.json`, `gmp-query-migration-inventory.json`) keep both
sides — main's record-token-lease rules plus this PR's three ledger
rules, `query_consumers` 271 + 2 + 3 = 276 — with no change to the
reviewed behavior.
- Second merge-main (`5b4969d40427`) picks up `#25108` (`8fa2cbd36487`,
notes prompt version bump) which fixes the main-wide notes prompt-pin
failure. Clean merge, no conflicts; the reviewed patch is unchanged (18
files, +1417 / -4 vs `origin/main`).

## What this is

The C1 in-flight ledger is now readable by an operator-only,
aggregate-only
census, plus a one-conversation explain read.

- `GET /v2/pipeline-ledger/census?start=<epoch>&end=<epoch>` reads the
ledger's
`admitted_at` collection-group window (the index the C1 PR retained for
the
global aggregate), joins each row to its conversation row for the
product
  `home_step.classify` predicate, and returns exact counts by stage,
  stuck-past-deadline counts, the Home-visible share on the real-speech
denominator, per-end-type counts and Kaplan-Meier p50/p90, coverage and
the
ledger retention start. It never returns a uid, conversation id, title,
  transcript or audio path.
- `GET /v2/pipeline-ledger/explain/{conversation_id}?uid=<owner>`
returns one
operator-supplied conversation's ledger transition list. It is an
operator
  capability (the service-OIDC gate authenticates the invoker SA, not an
individual owner); the owner is an explicit required binding and the
audit log
  records only a hash of it.
- Both routes use the same service-OIDC gate as the batch worker RPC,
with
`PIPELINE_LEDGER_CENSUS_AUDIENCE` and
`PIPELINE_LEDGER_CENSUS_INVOKER_SA`.
  Unset env means the service is not a census target.
- The census fails closed on a schema mismatch or a truncated window.
- Bounded-label gauges: `omi_pipeline_ledger_stuck_rows`,
`_stuck_users`,
  `_oldest_stuck_age_seconds`, `_new_stuck_per_hour`,
  `_unknown_end_type_share`, `_refreshed_at_seconds`.
- Three alert rules: stuck rows, a stale census sample and a stale gate
  receipt. A missing sample is `Alerting`, never a healthy zero. The
  gate-receipt rule is agent-tier (muted for humans), not a page.

The C1 read helper gains one field in its projection (`schema_version`)
so the
census can fail closed on a mismatch, plus a documented fleet-global
`iter_global_window` and a bounded `retention_start`. The C1 write path,
stage
table and transition rules are unchanged. The Home classifier is the
product
`home_step.classify`; this PR does not fork it.

## Review resolution (C2 pre-reviews)

Correctness P0:

- **P0-1 lookback unreachable.** The census now reports
  `retention.earliest_admitted_at` from a bounded global-min read
(`pipeline_ledger.retention_start`), and the gate compares that to the
window
start. The window's own minimum is no longer the test. The `pass.json`
fixture
  now carries a retention start the producer can emit.

Correctness P1:

- **P1-1 denominator double count.** Each row lands in exactly one
bucket:
known real speech, or unknown. `has_speech=True` +
`speech_basis='unknown'`
  counts once.
- **P1-2 in-flight unknown end type.** Only terminal rows count in
  `end_types`; `unknown_share` divides by `terminal_rows`.
- **P1-3 canary fail-open.** A canary with no `generated_at` is
`unavailable`
  (UNKNOWN), never fresh.
- **P1-4 null fields crash.** Every required sub-source is coerced with
`_num`;
  a missing or `null` value is UNKNOWN, never a `TypeError`.
- **P1-5 clock_unknown.** `clock_unknown_count / rows > 0.01` is
PENDING.
- **P1-6 coverage.** The census reports `coverage` from an exact
conversation-created count; the gate enforces `>= 0.995`, `> 1` is a
schema
  mismatch, a small denominator is PENDING, and a missing block is
  `UNKNOWN coverage_unknown`.
- **P1-7 late appends.** Not implemented in C2; the receipt has no
late-append
field. This remains a G3 item for the seal-ramp source, not a C2 claim.
- **P1-8 canary floor.** The gate requires 8 arrivals, not 1.
- **P1-9 sampled-census window.** The gate selects the census row for
its own
lookback; a different window is `PENDING census_window_mismatch`, never
PASS.
- **P1-10 C1 helper fork.** The census reads through
`pipeline_ledger.iter_global_window`, the documented fleet-global
exception.
- **P1-11 router docstring.** The docstring now says fleet-global and
names the
  helper.
- **P1-12 per-end-type latency.** `end_types[type]` carries
`p50_seconds`,
  `p90_seconds` and their statuses.
- **P1-13 NO_WORK unreachable.** A zero-row window returns NO_WORK
before the
ledger-freshness check; the fixture uses the real `ledger_updated_at:
null`
  shape.
- **P1-14 receipt-stale alert.** The rule is agent-tier and the metric
is
declared in the inventory. The textfile is still written by the
workspace
  gate; wiring it into the prod scrape is a separate ops step.

Custody P1:

- **P1-1 canary timestamp.** Same as correctness P1-3.
- **P1-2 census freshness.** The gate enforces `generated_at` age
  (`--census-max-age`, default 5400s) as well as `valid_until`.
- **P1-3 fixture PASS.** The receipt carries `source.fixture: true` and
a
  fixture run refuses to write `--textfile`.
- **P1-4 full conversation read.** The census reads through
`get_conversation_raw_snapshot(..., field_paths=CONVERSATION_FIELDS)`
and
  reduces `transcript_segments` to a boolean immediately.
- **P1-5 C1 helper bypass.** Same as correctness P1-10.
- **P1-6 canary floor.** Same as correctness P1-8.
- **P1-7 coverage.** Same as correctness P1-6.
- **P1-8 explain scope.** The docstring states the operator capability,
the
owner is an explicit required binding, and the log records a hash of the
uid.

## C2 delta review (fix 2)

- **P1 coverage cohort.** `coverage.ratio` divided ledger rows admitted
in the
window by conversations created in it, two different cohorts. Both sides
now
  count conversations created in the settled window
(`COVERAGE_SETTLE_SECONDS = 300`), so a row admitted here but created
before
the window no longer inflates the numerator and a conversation created
at the
edge has time to be admitted. The residual is reported as
`excluded_admits`
  and `unmatched_creates`, never folded into the ratio; `basis` is
  `conversations_created_in_window`.
- **P1 latency clock basis.** The end-to-Home quantiles fell back to
  `admitted_at` when `end_at` was missing while still reporting
  `clock_start: end_at`. Rows without `end_at` are now excluded from the
quantiles and counted as `clock_fallback_count` (aggregate and per end
type);
  `clock_basis` is `end_at_only`.

Tests P0 (CI red at the reviewed head):

- `omi-pipeline-ledger-gate-receipt-stale` is now `audience: agent` with
  `mute_time_intervals: ["omi-tier-silent"]` and warning timing.
- The `_gauge` declaration pattern is recognized for
`pipeline_ledger_metrics.py`, and the two workspace-emitted gate metrics
are
  allowlisted as external emitters.
- The stuck rule drops `or vector(0)` and uses `noDataState: Alerting`.

P2 fixed because trivial: non-finite windows return 422;
`uid`/`conversation_id`
reject `/`; a `gcloud` failure returns UNKNOWN instead of a traceback;
`omi_pipeline_ledger_gate_verdict` is declared in the metric inventory.

## Gate contract

The workspace gate runner (`infra/metrics/pipeline-census/gate.py`,
separate
workspace PR) calls this endpoint, reads the independent sampled Home
census and
the C3 canary receipt, and emits one versioned receipt plus a terminal
`GATE_*`
line. PASS only when every required source is fresh, exact and inside
threshold;
`PENDING`, `STALE`, `UNKNOWN` and `NO_WORK` are never PASS. Exit codes
match
`fleet_gate.sh` (0 PASS, 1 FAIL, 2 NO_WORK, 3 PENDING); `UNKNOWN` prints
`GATE_FAIL unknown` and exits 1 for `ramp_controller.py`.

The metric is: **gate output under 1 hour old; agrees with the sampled
census
inside its interval for the same window.** The receipt carries
`schema_version: 1`, `receipt_id`, `generated_at`, `fresh_at`, `ramp`,
`lookback`, `source`, `verdict`, `reasons`, `warnings`,
`data_freshness`,
`coverage`, `home_visible`, `stuck`, `new_stuck_per_hour`, `latency`,
`end_types`, `canary`, `sampled_census` and `redaction`.

## Size

`git diff --numstat 75dc53a..HEAD`
outside
`backend/tests/**`:

```
424   0  backend/database/pipeline_ledger_census.py
116   0  backend/routers/pipeline_ledger.py
 53   0  backend/database/pipeline_ledger.py
 40   0  backend/utils/conversations/pipeline_ledger_metrics.py
 40   1  backend/charts/monitoring/gmp-query-migration-inventory.json
 29   0  backend/docs/listen_pusher_pipeline/changes/2026-11-11-pipeline-census-gate.md
  8   0  backend/charts/monitoring/metric-inventory.prod.json
  5   0  backend/charts/monitoring/alerts/pipeline-ledger.json
  4   1  backend/charts/monitoring/alert-rules.json
  2   0  backend/app_roles.py
  2   0  backend/route_policy_manifest.yaml
  1   0  backend/main.py
```

**726 changed non-test lines** (724 additions, 2 deletions). This fix
batch
(`3f1baced51c3..HEAD`) is **50 changed lines** in
`backend/database/pipeline_ledger_census.py` (44 additions, 6
deletions), under
the 60-line delta cap. Tests are separate and not counted.

Fix 3 (`95500ea64e26..165fb68`) changes **0 non-test lines**: it
updates
only the lifecycle field-site declaration in
`backend/tests/support/lifecycle_writer_inventory.py` (4 added lines) so
the
declared census coverage siblings match the actual payload
(`cohort_admits`, `excluded_admits`, `settle_seconds`,
`unmatched_creates`).
The guard test is unchanged.

## Tests

Run with GCP credentials unset, through `bin/omi-heavy run --`:

- Exact failing node

`test_lifecycle_state_table_writers.py::test_no_undeclared_or_stale_lifecycle_field_builder[database/pipeline_ledger_census.py]`:
  **1 passed**.
- `test_pipeline_ledger_census.py`, `test_pipeline_ledger_routes.py`,
  `test_pipeline_ledger_metrics.py`, `test_pipeline_ledger.py`,
`test_lifecycle_state_table_writers.py`,
`test_firestore_query_shapes.py`,
  `test_route_policy_inventory.py`, `test_route_policy_preflight.py`:
  **2411 passed**.
- Full local pre-push (`.github/scripts/run-pre-push.sh`): **passed**;
the
  bounded gate passed and CI remains the full test authority.

Merge-main resolution (`5b4969d40427`) re-ran, with GCP credentials
unset
through `bin/omi-heavy run --`:

-
`test_llm_input_prompt_version.py::test_prompt_sources_match_the_pinned_digest[notes]`:
  **1 passed** (fixed on main by `#25108`).
- Census / routes / metrics / ledger + `test_app_roles_route_census.py`:
  **83 passed**.
- Query shapes (`test_firestore_query_shapes.py`): **572 passed**.
- Route policy and monitoring contract
(`test_route_policy_inventory.py`,
`test_route_policy_preflight.py`,
`test_monitoring_alert_rule_contract.py`,
`test_monitoring_alert_backtest.py`,
`test_provision_monitoring_alerts.py`):
  **168 passed**.
- Full local pre-push gate: **passed** (61 checks, 0 failed; 75 changed
  backend unit tests passed).

## Rollback

Remove the two routes and the three alert rules. The ledger write path
is
unchanged; no flag, no deploy, no data migration.

## Not in this PR

- The workspace gate runner, fixtures and tests (separate workspace PR).
- A late-append source and a G3 seal-ramp check.
- A fleet-wide coverage denominator from
`omi_pipeline_ledger_admit_total`; the
  endpoint reports an exact conversation-created count with
`basis: conversations_created_in_window` until the C1a2 live hooks land.
- Any UI, model, credential, IAM or `.github/` workflow change.
Git-on-my-level added a commit that referenced this pull request Nov 11, 2026
…25055) (#25070)

## What changed and why

Head: `672d873b5aa2322b1e47a112e5e57fe412e5d1e4`

Replacement for #25055 (which replaced #25028) on current `origin/main`
`7ebd8450b6e023474cfe3275cf3446b28f3a710f`, carrying the reviewed
attention-expiry patch plus the independent-review FIX-FIRST corrections
at `Earlier head:` `e1c309b3e047cbfb15933fb0d2246af8829cd459`.

Supersedes #25055 because that PR is at its two-push limit and its exact
head carries two independent-review FIX-FIRST findings. This replacement
starts a fresh branch from current main, carries the same reviewed
commits, and fixes both findings:

- **Scan bound (finding `77a43d`).** `list_items` no longer streams a
user's whole active attention collection. Each query is bounded to
`SCAN_LIMIT = 500` documents, and an optional `start_after` cursor lets
a caller start from a known document. Expiry transactions therefore run
only inside a bounded scan.
- **Zero limit (finding `34c935`).** `list_items(limit=0)` (and any
non-positive limit) returns an empty list before iterating or appending,
instead of returning one item.
- **Scan cursor (finding `3d2d9d`).** A full read now pages internally
on the last **scanned** document, not the last returned one, so
filtering (resolved or expired rows) cannot repeat a window or omit
later items. The 500-row query bound and the non-positive-limit early
return are unchanged.

Carried non-merge commits from the reviewed head:

- `329a8b8fa5d` — expiry predicate and initial tests.
- `3e0e6f98de1` — transaction fencing, tests, config, registry and
documentation.
- `7d75d6a5980` — pusher literal config snapshot.

The carried patch is otherwise behavior-identical: attention expiry,
banked/completed/live-debt guards, and the flag registry. No new product
behavior beyond the two fixes. No `.github/`, UI, credentials/IAM,
production data/config, or model changes.

### Test-only follow-up (push 3)

`1252bca525de` is a test-only assertion under the driver's third-push
allowance. The 620-item pagination regression previously ended its first
500-row page on an item that was returned, so a cursor based on the last
*returned* item would have passed it too. The test now resolves the last
document of the first page and asserts the second page's `start_after`
is that document, protecting the last-scanned cursor in
`processing_attention._scan_pages`. No product code changed.

### Firestore client seam (Codex P1 `4529060103`, lead2 `f66b9e`)

`672d873b5aa2` fixes the review finding that the new expiry path used
the legacy module-level `db` proxy, contrary to `backend/AGENTS.md`.
`items_ref`, `_scan_pages`, and `list_items` now resolve
`get_firestore_client()` at call time and expose an optional
keyword-only `firestore_client` parameter; the bounded scan, the
conversation/claim reads, and the expiry transaction use that single
resolved client. The new expiry tests inject `firestore_client` instead
of monkeypatching `store.db` (the module fixture now supplies the same
fake client through `get_firestore_client` so the unconverted
claim/finish helpers and HTTP route keep working). `db` remains only in
the unconverted claim/finish helpers and `pending_conversations`.
Pagination, cursor, and expiry-predicate behavior are unchanged; the
delta is 15 non-test changed lines in one file plus the test seam.
Merge-main resolutions under `1c606e` are unchanged from
`71aff3e888f4e`.

### Merge-main resolutions (lead2 `1c606e`)

This head is a merge-main resolution under lead2 `1c606e`.

`71aff3e888f4e` merges current `origin/main` (`a73632ce0ec9`, which
carries C2's operator-ledger census read from #25084) into the branch.
Six files conflicted, all additive on both sides and resolved by keeping
both: `config/feature-flags.yaml`,
`backend/tests/unit/test_verify_pusher_config_references.py`, and all
four `backend/charts` listen/pusher values (this PR's
`PROCESSING_ATTENTION_NON_RETRYABLE_EXPIRY_ENABLED` and main's
`SYNC_RECORD_COVERAGE_WAIT_MEMO`), plus
`backend/config/flag_budget.json`, where `count` is reconciled to
**271**, equal to the 271 names on the merged head.
`backend/tests/support/firestore_query_driver_registry.py` auto-merged
and was then checked against both parents: this PR's attention cursor
entries (`list_items` with `start_after`, `_scan_pages` covered-by) and
C2's census entries (`pipeline_ledger.iter_global_window`,
`pipeline_ledger.retention_start`,
`pipeline_ledger_census._capture_creates`,
`pipeline_ledger_census.census`) are both preserved, and the delta
against `origin/main` is exactly this PR's patch (19 files). No product
behavior changed; the reviewed patch is unchanged.

`Earlier head:` `5ad54d2f0d8f2` merged `origin/main` (`8fa2cbd36487b`,
the main-wide notes prompt-pin fix from #25108); that merge was clean
and `flag_budget.count` was 270 there.

`Earlier head:` `bf6efab1c7bf6` merged `origin/main` (`8659de6ee98d9`,
which carries the main-wide messaging flake fix from #25018) into the
branch, so the previously red messaging check ran against the fix. Five
files conflicted: `config/feature-flags.yaml` and both
`backend/charts/backend-listen` listen values (additive env/flag entries
on each side, kept both), `backend/config/flag_budget.json` (`count`
reconciled to 270, equal to the 270 names on the merged head), and
`backend/docs/pending-work.md` (narrative paragraphs from both sides
merged, keeping the `HOME_STEP_PROJECTION` text and the
bounded-attention text). No product behavior changed; the reviewed patch
is unchanged.

`Earlier head:` `047de1b18fb7` merged the prior `origin/main`
(`75dc53a81df7`) under the same ruling; its only conflict was
`config/feature-flags.yaml`.

## Product invariants affected

- INV-MEM-4: the runtime change only adds attention expiry
configuration; canonical memory consolidation and promotion authority
retain their existing configuration. Attention expiry is distinct from
Short-term memory disposition.

## Tuning and rollback

- `PROCESSING_ATTENTION_NON_RETRYABLE_EXPIRY_ENABLED`: default on.
Setting the declared value to `false` and recomposing runtime
configuration disables new expiry writes. All backend services and
matching listen/pusher charts carry the binding.
- `NON_RETRYABLE_ITEM_TTL`: seven days from `created_at`, exclusively
for `recovery_structure_unavailable` after retry reconciliation.
- `SCAN_LIMIT`: 500 active attention documents examined per query; a
full read pages internally on the last scanned document.
- Bundle kill switch: `HOME_STEP_PROJECTION` (existing, default on).
Turning it off is the L4 rollback.
- Rollback is the flag off; no data migration. Expiry is terminal:
already-expired documents remain inactive after disabling the switch,
and no automatic data restoration is claimed.
- L4 success metric: **no processing rows on past days**.

## Verification

Fresh checks of head `672d873b5aa2` on m5 through
`/Users/dazheng/workspace/omi/bin/omi-heavy run -- ...`, with GCP
credential environment variables unset and worktree-local Python 3.11
dependencies:

- Attention/pending-work set (13 files, including
`test_batch_pipeline_scheduler.py`): **360 passed** across the 13 files
run; `test_pending_work.py` alone: **76 passed**, including the
strengthened 620-item pagination regression and all expiry tests, now
with `firestore_client` injection.
- Full query-shape battery `test_firestore_query_shapes.py` (now
covering both driver sets): **572 passed**.
- Flag budget: **24 passed** (`flag_budget.count` 271 equals the 271
names on the merged head). `test_verify_pusher_config_references.py`:
**31 passed**. Runtime-env validator: **206 passed**. Notes
prompt-version node `test_llm_input_prompt_version.py`: **6 passed**
(including `test_prompt_sources_match_the_pinned_digest[notes]`).
Combined five-file run: **839 passed**.
- Normal full pre-push hook: **PASS**, 0 failures.
- The new cursor assertion was confirmed load-bearing: mutating
`_scan_pages` to advance on the second-to-last page item fails it with
`[None, 'item-0498'] != [None, 'item-0499']`.

Evidence is hermetic; real Firestore contention/SDK retries and deployed
behavior are not claimed.

## UI evidence

UI-Evidence: none -- backend-only expiry on existing API reads; no
client or UI change.

## Failure class

Failure-Class: FC-stale-selection-used-as-write-authority
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