Skip to content

SCA-2190: reuse token-certified batch privacy decisions per owner - #25285

Merged
Git-on-my-level merged 7 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-zcode-glm-5-3/508f33ead0ff
Nov 14, 2026
Merged

Git-on-my-level merged 7 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-zcode-glm-5-3/508f33ead0ff

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Repeated batch privacy checks currently walk the same owner's authority rows even when the durable token has not changed. Add an owner memo with a bounded union of certified conversation IDs, preserving a fresh transactional token read on every reuse. New IDs still pay their tombstone, conversation and redirect checks. The uppercase token BLOCK names the privacy decision outcome; that outcome is never cached. It is not a release-status marker. Unreadable authority falls back to the live walk.

Projection guards now request decisions without exporting discarded rows. Retention/intake, orphan repair and enrichment custody explicitly fetch needed rows when a memo serves the decision. The projection refusal path preserves BatchPrivacyBlocked and the input/refusal ID budget.

bpp_owner_memo defaults to 100 per the SCA-2190 rollout-lead ruling. ops_kill_switches/privacy_decision_cache disables owner reuse (30-second poll, fail closed). Existing id-set attempt memo behavior is unchanged.

Shadow coverage (SCA-2214, fixes SCA-2212 blocker 1)

The sampled privacy_checks_shadow cohort always serves the live decision and then compares an owner-memo candidate, on every transactional path: attempt-scoped calls, the store/retention no_attempt mass, and the snapshots= callers (projection, intake). Shadow is no longer gated on an attempt scope and snapshot callers are no longer excluded, so a zero stale_allow on those paths is real evidence instead of a structural zero. The candidate receives a throwaway export dict and decides with the owner path on (owner_candidate), so a comparison can never publish rows or perturb the caller's export, and it computes exactly what the memo would serve after the window. Nontransactional provider-STT preflight stays live and never enforces the memo (no transaction) — live by construction in every stage, so no later lever or stage enforces the memo there. negative_shadow keeps its rule: with privacy_negative_lookup_cache on, no memo decision is served without a comparison.

The window is fleet-wide for the owner memo: while any privacy_checks_shadow percentage is set, the owner memo serves no one (owner_on requires the lever percentage to be 0 unless running as a shadow candidate). Sampled UIDs compare a candidate; unsampled UIDs serve plain live decisions at baseline reads with no memo saving. No UID can enforce a decision the comparison cohort has not validated. The already-shipped attempt-scoped id-set memo is not gated by the window; it keeps its existing levers and keying throughout.

Prepare-wide fence (SCA-2214, fixes SCA-2212 blocker 2)

assert_batch_write_allowed now reports every conversation document it actually verified, redirect survivors included, through a verified_out collector; the owner memo's new-id verification reports its hops the same way. ProjectionSession.guard adds the requested ids plus those verified ids to _privacy_fence_ids across every guard call in one prepare, so multiple redirect chains cannot exceed the old distinct-document ceiling. It refuses at 257 with conversation_fence_budget and still exports no rows.

Export contract (non-blocking finding)

A served decision exports no rows for ids it has already certified; unseen ids are walked live and their rows are exported, so a caller may receive a partial export and reads any remaining row itself. Docstring, runbook and tests now say so; test_privacy_ttl_cache.py covers the all-certified empty export and the partial export.

Validation

Python 3.11 via backend/test.sh (one process per file):

  • tests/unit/test_privacy_ttl_cache.py: 78/78 (includes the new shadow no_attempt, snapshot-caller, unsampled-window, partial-export and empty-export tests)
  • tests/unit/test_batch_pipeline_projection.py: 126/126 (includes the new two-chain prepare-fence test)
  • tests/unit/test_bpp_generation_memo.py: 40/40. Its record_drain parametrization was flaky at the base head too (the serving runtime's upload-coalescing loop interleaved its quota read into the test's shared read window); the test now neutralizes that unrelated loop.
  • tests/unit/test_sync_worker_execution.py: 19/19. test_worker_preflight_keeps_live_authority_and_privacy_shadow used to fail when its file ran alone (the unpatched kill-switch read fails closed without credentials, and the test silently relied on a clear read cached by another file's fixture); it now sets its kill switch explicitly.
  • Focused privacy/projection/retention/custody/sync batch list (17 files): 881 tests pass.
  • make preflight passes all selected checks on the branch.

Rollout

Separate serving this revision from enforcing the owner memo. Although bpp_owner_memo defaults to 100, while any batch caller has privacy_checks_shadow > 0 the fleet-wide gate makes the owner memo serve no decisions; callers continue using live authority. Before this revision serves, the release owner must verify effective nonzero privacy_checks_shadow on backend, backend-sync, backend-sync-backfill, and backend-integration (the repo configuration recorded at review is 10/10/100/10). If that fence is absent on any caller, hold serving until SCA-2196's rollout owner (M1 Studio ZCode) lands a scoped repo-config change and gets the cost lead's GO. Do not set shadow to 0 or otherwise enable enforcement as part of serving this revision.

After Train 2 serves and the cost lead has a clean hour of readings, the cost lead will request a separate repo-config change for the shadow window: set privacy_checks_shadow=10 and privacy_negative_lookup_cache=0 on all four batch caller services. During this window the owner memo still serves no one and saves nothing: the sampled 10% roughly doubles its reads (live walk plus candidate walk cold, live walk plus one candidate token read warm, plus one observation token read per sampled check); snapshot callers' candidates add per-new-id reads on misses; the unsampled 90% returns to baseline live reads. SCA-2196's rollout owner owns the config and one-day readings. Require candidate_source="owner_hit" comparisons on every path above and zero privacy_decision_mismatch_total{family="batch",reason="stale_allow"} plus zero privacy_negative_lookup_total{result="mismatch"}; a zero comparison count is not evidence — it means the negative cache is still on or the window is not set. Only after that evidence and an explicit cost-lead GO may the scoped config change restore privacy_negative_lookup_cache=100 and set privacy_checks_shadow=0, at which point the owner memo enforces everywhere. The runbook is backend/docs/runbooks/privacy-check-shadow.md.

SCA-2196 owns the owner-first/repeat counter, one-day readings, rollout and measured savings, assigned to M1 Studio ZCode (GLM 5.3), due 2026-11-20. Estimated savings are roughly $60/day at today's hit rate and up to $105/day in the owner-repeat scenario; these are overlapping estimates, not measured savings.

Product invariants affected

none

Failure-Class: none

Closes SCA-2190

Certification is unchanged: every served decision re-reads the durable
privacy token in the caller's transaction and requires token, server
revision and generation to match; BLOCK is never stored; an unreadable
token falls to the live walk. New conversation ids pay their own
tombstone/row reads. The owner memo is default on per the 09:08Z ruling
and consults ops_kill_switches/privacy_decision_cache on every check.

Also: the projection guard is decision-only (no full-row export) and
keeps its refusal path; retention/intake reads the two rows it needs on
a served decision; the trivial snapshots={} callers pass None.
…e (SCA-2214)

Luna FIX-FIRST (SCA-2212) on a1cd08f.

Shadow-before-enforce now covers the owner memo wherever it can enforce.
The sampled cohort always serves the live decision and compares an
owner-memo candidate afterwards, on attempt-scoped calls, on the
store/retention no_attempt mass and on the snapshots callers (projection,
intake). Shadow is no longer gated on current_attempt(); snapshot callers
are no longer excluded, and the candidate receives a throwaway export dict
so a comparison can never publish rows or perturb the caller's export.
Nontransactional preflight still cannot be compared, never enforces the
memo, and stays live. negative_shadow keeps its rule: with the negative
lookup cache on no memo is served without a comparison.

The projection prepare-wide 256 fence counts redirect survivors again:
assert_batch_write_allowed reports every conversation document it actually
verified through a new verified_out collector, the owner-memo new-id walk
reports its hops too, and ProjectionSession.guard adds requested ids plus
verified ids across every guard call in one prepare. It still refuses with
conversation_fence_budget above 256 distinct documents, with no full-row
export.

The export contract is corrected: a served decision exports no rows for
already-certified ids, while unseen ids are walked live and their rows are
exported, so a caller may receive a partial export. Docstrings, the
shadow runbook and the comparison-evidence table say so, and tests cover
the all-certified empty export, the partial export, shadow on the
no_attempt and snapshot paths, and the prepare fence across two redirect
chains.

The record_drain serving parametrization also stops the runtime's unrelated
upload-coalescing loop from interleaving its quota read into the test's
shared read window, which made that test flaky at the base head too.
… (SCA-2214)

Amends 0ed090d per the SCA-2214 prescription ('serve the live
decision on all paths'): while any privacy_checks_shadow percentage is
set, owner_on is off for every uid, not only the sampled cohort, so
unsampled uids serve plain live decisions at baseline reads instead of
enforcing the memo beside a comparison cohort that never validates
them. The shadow candidate bypasses the window (owner_candidate) so it
still computes exactly what the memo would serve after the window.

The runbook, the unsampled-window test and the worker preflight shadow
test follow: the window saves nothing, the unsampled cohort returns to
baseline live reads, and the preflight test now sets its kill switch
explicitly instead of relying on a clear read cached by another file's
fixture (it failed when its file ran alone, identically at the base
head).
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 14, 2026 17:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T18:43:19.311620Z aa2fb59 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…-glm-5-3/508f33ead0ff

# Conflicts:
#	backend/tests/unit/test_batch_pipeline_owner_chain_projection.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa2fb591ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +516 to +517
_verify_conversation_ids(
client, transaction, uid, new_ids, user_sync_enabled, snapshots, read, verified_out=verified_out

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce the fence limit on the complete requested ID set

When an owner has 256 certified conversation IDs, checking those IDs plus one new ID now returns ALLOW: _verify_conversation_ids sees only the new ID, and the later len(grown) condition merely prevents storing the oversized union. The same 257-ID request on a cold cache raises conversation_fence_budget. Callers such as utils/sync/completed_status.py pass the complete result-ID set without an independent limit, so authorization and shadow-comparison outcomes now depend on cache warmth. Apply the fence limit to the complete current check, including redirect closure, before serving a memo decision.

Useful? React with 👍 / 👎.

owner_on = (
transaction is not None
and lever_enabled('bpp_owner_memo', uid)
and not ttl_disabled()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep kill-switch polling inside the artifact read budget

On a cold or due kill-switch poll, budgeted artifact reads now call ttl_disabled() before performing any budgeted Firestore read. That helper's _read_kill_flag() uses .get() without the caller's timeout or retry bound, so retention.batch_artifact_authorize(..., read_budget=...) can wait past its ArtifactReadBudget.deadline during a slow Firestore request. The previous snapshots= live path did not perform this RPC. Bound the switch read by the remaining budget, or bypass memo reuse without starting an unbudgeted poll.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 3980a40 into BasedHardware:main Nov 14, 2026
66 of 68 checks passed
Git-on-my-level added a commit that referenced this pull request Nov 14, 2026
…wner (#25285)"

This reverts merge 3980a40 (mainline parent 1).

#25285 is not inert with privacy_checks_shadow at 0: the default bpp_owner_memo
at 100 lets the new owner memo serve decisions before its shadow window. The
release train is pinned to its parent for that reason, so no later main SHA is
deployable. Reverting makes main admissible again; the owner re-lands the
change once its serving prerequisites are met.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 14, 2026
…ight (#25338)

Reverts #25285 (merge `3980a409cb9b`, SCA-2190) so that main is
deployable tonight. No judgement on the change itself: it is to be
re-landed by its owner once its serving prerequisites are met.

## Why

- The cost lead's 20:46Z finding (binding per the release owner on
SCA-2283, 22:25Z): #25285 is not inert with `privacy_checks_shadow` at
0. With the default `bpp_owner_memo` at 100, the new owner memo serves
privacy decisions without the shadow window it was meant to have first.
- Because of that, tonight's backend train is pinned to `71c79e796a85`
(the parent of this merge) and no later main SHA is admissible. That
blocks every PR merged after it, including the fix for pendant
recordings that stopped sealing (#25335).
- The release owner recommended this reviewed revert as the way to make
later source trees admissible. The cost lead keeps ownership of the
privacy prerequisite and the re-land.

## What it does

`git revert -m 1 3980a40`, nothing else. The 24 files that #25285
changed are byte-identical to their content at `71c79e796a85`; nothing
merged after #25285 touches them. No flag, env, chart or index change
beyond what the revert restores
(`backend/deploy/firestore_read_levers_manifest.json` returns to its
previous content).

## Validation

- `git diff 71c79e7 HEAD -- <the 24 files>` is empty.
- Repository preflight and CI are reported on the PR. An independent
exact-head review is posted as a PR comment.

## Rollback

Re-land #25285 (revert this revert) once its prerequisites and GO are in
place.

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25338?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>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Nov 16, 2026
…shadow config (#25359)

The original #25285 owner memo could enforce on first serve when
existing configuration had shadow=0. This guarded SCA-2190 re-land
restores its reviewed implementation while requiring a new explicit
`bpp_owner_memo_enforce` admission lever, default 0. Comparison
candidates remain available; old, absent, invalid or empty config cannot
admit the new owner memo. A nonzero shadow percentage still suppresses
owner enforcement even with admission enabled.

The comparison packet travels with this candidate: shadow=10,
negative-cache=0, TTL60=0 and owner-enforce=0 for the four Cloud Run
batch callers and the existing next-train worker chart. Other levers
remain unchanged, including the worker's monthly-reader exception.
Listen, pusher, desktop, jobs and other consumers keep default-off owner
admission regardless of their existing shadow settings. This is source
preparation only; no live mutation, worker image roll, migration, or
enforcement GO.

Fresh transactional token/server-revision/generation certification,
never caching denial decisions, dry-run no-mint, the prepare-wide 256
fence including redirect chains, and the fail-closed privacy kill switch
are retained. Original exact-head review receipt: SCA-2291 at
aa2fb59. Independent review requested
for the new admission/config/telemetry delta, not a full third review of
unchanged restored code.

Positive comparison evidence is now measurable by closed
attempt/no_attempt/snapshots labels in `privacy_owner_comparison_total`.
Both this and the existing decision-comparison counter are retained
through the Cloud Run keep-lists, isolated sync-worker fold, and batch
worker registry. No identifiers appear in metric labels.

The complete prerequisite, surface, expiry, rollback, economics and
qualification packet is `backend/docs/sca-2190-reland-packet.md`.
SCA-2190 remains open through serving and independent production
verification.

## Validation

- Nov 16 bounded main merge at
`39c263a6e66aab7c67b04c108c1fdc848e33c298` (main `f6d69aefb5`): preserve
both privacy comparison counters plus main’s new WAL scrape series;
capture-source guard, prepare-wide fence and default-off
comparison/admission settings remain intact. Eleven affected files pass
**557 tests** through the Studio `omi-heavy` runner. Normal pre-push
passes **47 preflight checks**, type checking with **zero errors**, and
**1,508 tests across 40 selected backend files**. Exact-head CI is
green: **42 successful checks, 24 skipped, zero failures or pending
checks**; GitHub reports **MERGEABLE/CLEAN**. Release admission and
production gates remain separate.

- Earlier conflict repair at commit 579fa67 (main 9136bb5):
preserve main's capture-source conversation privacy guard in the
decision-only path, union both comparison counters with the added
finish/review-config scrape series, and regenerate the flag inventory.
Added synthetic allow/deletion/prepare-budget regressions. Nine affected
files pass **808 tests** (including the updated 75-test projection
suite); compose and generated read-lever manifest checks pass.
Admission, comparison packet, 14-day qualification and separate
production/enforcement gates remain unchanged. Normal pre-push passes
all 47 preflight checks, backend type checking with zero errors, and
1508 tests across 40 selected backend files. No hook bypass. Successor
CI is running; its result remains required for Release admission.

- Bounded integration repair at
`2e74612f73f517d62c4f19460c219d4f9c2cf12b`: refresh the exact keep-list
expectation for both comparison counters, eight exact lever-map hashes
(four callers in source/composed manifests), and the unapplied six-value
monthly proposal patch. No production code/config, monthly
scope/epoch/TTL, or budget ceiling changes. The four focused files pass
**345 tests**, in separate processes.
- Same-main receipts: on `65f46cce8306794cc7f2a5eff6cda7c285f4fe8b`, the
original three failing files pass **248 tests**. CI's old merge base
`9cc1565d383de4565b8bc492479b9d917731370b` independently reproduces the
exact flag count mismatch **289 != 291**. That mismatch does not
reproduce on the candidate or current main; the new push must acquire a
fresh merge result and CI. No budget guard was relaxed. New-head CI
remains required.

- SCA-2365 ruling: correct only the stale prod runtime contract
expectation without another review. Successor
`0d70f0c199ff1baa93f553096511f86257f5406c` changes that test and its
explanatory comments only; the complete file passes **97 tests**. All
monthly-reader, non-Cloud-Run and other service pins remain asserted.
Fresh successor CI must establish its own result.

- Cost-owner disposition, Nov 15: this is source preparation/future
savings only. No enforcement or comparison-configuration GO; shadow
deployment is neither a prerequisite nor a co-change for #25314.
Production HOLD remains through 10:18:30Z with existing privacy/release
gates.

- Python 3.11, `backend/test.sh`, one process per file: 640 passed
across nine focused privacy, repair, projection, runtime-manifest and
child-metric suites (552 in the eight-file pass, then 88 repair tests
after installing local test dependencies).
- New regressions warm actual owner candidates before testing
image-before-config and malformed admission; all three transactional
shapes emit positive owner_hit comparisons while admission stays off.
Existing token rotation, revision/schema failure, kill-switch, dry-run
no-mint and redirect-fence regressions remain.
- Runtime source compose, generated read-lever manifest check, prod
runtime validator, generated flag inventory and diff hygiene pass.
- Initial preflight found generated flag-inventory drift; the generated
document was refreshed. Final preflight passes 47 checks. The normal
bounded pre-push gate passes backend type checking with zero errors and
715 tests across 12 selected files. CI remains the full-suite authority
and must be green before release admission.
- All tests are synthetic/hermetic. No production read or write by this
change's author run.

## Ramp and rollback

Default-off admission is intentional under cost-lead source-preparation
GO (2026-11-15 04:24Z). Release owns canonical admission after SCA-2225
parser/protected-environment correction and installed source binding. It
must verify effective shadow >0 on every one of the four batch callers
before serving this candidate, even with the new defense-in-depth code
gate.

Preserve the checked-in runbook's at least **14 days of all-plane
shadow**, zero unexplained mismatches, positive owner_hit comparisons on
all three shapes, no shadow errors/scrape gaps, writer-matrix/privacy
proofs, and explicit cost-lead GO. The earlier one-day staging proposal
and a clean first hour do not shorten that longer qualification
requirement. The six-hour push can deliver comparison-only preparation
and review, not qualification or booked savings. Cost lead owns
acceptance; a newer explicit window ruling must be recorded before
changing this requirement.

Partial-value source expiry is **2026-11-17 UTC**; renew its dated
metadata through review before then to continue the required window.
Expiry is not an automatic live reset and must not enable enforcement.
Keep owner-enforce=0 throughout. A later separately reviewed config may
enable it only after qualification and cost-lead GO; neither clearing
shadow nor the arrival of this image grants that GO.

Rollback: Release keeps owner-enforce=0 and uses
`ops_kill_switches/privacy_decision_cache.disabled=true` (30-second
fail-closed poll), restores prior source/image, or restores the recorded
per-surface comparison settings while retaining owner-enforce=0 and
TTL60=0. No data migration is involved. Worker chart uptake belongs to
its existing next train; this PR does not request a worker roll.

## Tuning disclosure

OWNER_ID_CAP is restored at initial 256, preserving the existing
per-walk and prepare-wide distinct-conversation bound. No worker/process
capacity is retuned. New comparison shapes are bounded telemetry states
and exit with each check; they do not create a durable pipeline state.

Why isn't this a shared primitive instead? The admission fence is inside
the shared batch-privacy entry and inner memo path, covering every
consumer rather than adding service-specific rollout checks. Regression
incident: #25285 and its #25338 revert after shadow=0 first-serve
admission was identified.

## Product invariants affected

- INV-MEM-4

Failure-Class: FC-rollout-flag-absent-from-a-cohost-of-its-code-path

Related to SCA-2190. This source preparation does not complete the
production outcome.
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