Skip to content

fix(batch): restore only missing artifacts without releasing phone custody - #24366

Merged
Git-on-my-level merged 28 commits into
mainfrom
lane/artifactmissing
Nov 4, 2026
Merged

Git-on-my-level merged 28 commits into
mainfrom
lane/artifactmissing

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Missing batch audio currently strands healthy sibling conversations, and a whole-content retry can duplicate previously projected units through the legacy path. Add a metadata-only operator disposition and restore only absent spans under the original batch owner, preserving projected jobs, receipts and paid-intent fences. No missing-audio job completes or acknowledges phone custody.

Status returns retryable failed/batch_artifact_missing only to clients advertising custody-repair protocol 1. Older clients remain processing with five-minute polling. The capable client must send the original repair_job_id; changed content, missing members, decoder boundaries, binding/privacy drift and open operator intents fail closed. Native/provider record repair is excluded.

A repair replays the original admission, never the retried request (Luna r1, lead ruling 6d0246). Admission now records two things on the intake record, exactly as it froze them into the staged audio. The first is the projection-lineage fields (recording_session_id, audio clocks, geolocation, capture claims), stored as one canonical JSON string because Firestore rejects nested arrays. The second is each unit's language decision. A repair restages with both as recorded and discards the lineage fields of the retried request. That request's clock bounds were re-normalized against the current server time, so they can legitimately differ (Luna r2). The recorded lineage stays Firestore-only: the Postgres job-store mirror, which does not follow the intake TTL, drops it, and its parity check ignores it (Luna r3). A repair never runs a paid or self LID probe. A missing or unreadable record holds, with phone custody and audio kept, and logs event=batch_artifact_repair outcome=held reason=legacy_lineage_unproven|lineage_unreadable|language_unproven. Every job admitted before this deploy has neither proof, because its original context lived only in the missing artifact. All of them hold: ro-prod at 10:48Z counts 165 metadata-404 units in 134 content ledgers, with 0 dispositioned.

Accepted content can outlive the new-upload lookback. Derive the content hash and verify the exact original batch owner before any archive write or age exception. Ordinary stale uploads keep their refusal; foreign/changed repairs cannot acquire a new owner. HTTP regressions cover all three branches.

Operator apply is OFF until a capable client is live. The lead owns every apply, merge and deployment; a public app release needs David's authorization. This PR performs no production writes, media reads, deletions or vendor calls. Server rollout covers backend, backend-sync and backend-integration together. Preserve the custody contract on rollback.

Validation: regressions captured red before implementation; 373 targeted backend tests pass, including metadata-only 404 evidence, capability status, exact original-content retry, stale completed denial, legacy-checkpoint dedupe characterization, no healthy-unit staging and old-upload owner fences. Real Firestore missing disposition -> healthy sibling projection -> missing-only restore -> final projection passes with exactly two final segments and preserved usage checkpoints. Projection suites: 84 + 7 passed; store conformance 79 passed / 44 skipped (no Postgres claim). Shared golden drives a 14-day-old phone WAL test. Final-head full hermetic Sync Cloud Tasks gauntlet passed all ten batch process scenarios and all five embedded Firestore checks. No retry assertion or gate was skipped. The 6d0246 delta was tested on 37 targeted backend files (repair, intake, admission, language and provider), all green. Its admission-record test fails against the pre-fix intake.

Two stale emulator fixtures were corrected without weakening assertions: sparse recovery-discovery rows now isolate policy loading; legacy mixed-page pagination explicitly disables the pending-page selector it predates. No production recovery behavior was changed for these fixture fixes.

Operator discovery reports permission/transport probes as metadata_unknown_units and never dispositions those units. Its red-to-green regression passes with the full 22-test disposition/owner file; apply still requires a fresh successful 404 inspection for each selected unit.

Product invariants: INV-DATA-1, INV-CAP-1, INV-MEM-1, INV-MEM-4.
Failure-Class: FC-audio-cleanup-before-durable-custody
UI-Evidence: none -- custody/status protocol and operator tooling; real persisted projection and hermetic phone reconciliation verify the acceptance boundary.
Line-Count-Exception: backend/routers/sync.py | 3757 -> 3793 | Add optional capability, exact repair handle and original-owner age fence at the existing endpoint; restore implementation lives in a separate module.
Line-Count-Exception: backend/utils/sync/pipeline.py | 4061 -> 4062 | Admit the typed retryable missing-artifact reason in the existing shared failure-code allowlist.

Add the guarded operator disposition, truthful retryable failure and partial
sibling publication contract. Re-upload repair is still in progress locally;
this checkpoint is not a deployment or review acceptance.

Failure-Class: FC-audio-cleanup-before-durable-custody
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
…stody

Fence metadata-only operator disposition and exact-content re-upload to the
original owner. Preserve projected siblings, usage receipts and held audio
custody. Expose retry only to capable clients with an explicit repair handle.
@mintlify

mintlify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

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

Project Status Preview Updated
omi 🟢 Ready View Preview Nov 4, 2026, 12:41 AM

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-02T08:04:55.338196Z
We couldn’t complete this review. Comment @codex review to try again.
f10e991 PR opened
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

10 issues found across 32 files

Confidence score: 3/5

  • backend/models/sync_job_status.py now serializes total_files: 0 for legacy completed jobs that had files, so clients can mistake them for empty jobs. Avoid emitting the default when the status never set a file count.
  • backend/utils/batch_pipeline/intake.py returns deterministic repair refusals as retryable 503s, so phones can retry the same unrepairable bundle indefinitely. Map ProjectionBlocked to a non-retryable response such as 409.
  • config/feature-flags.yaml can treat held uploads left in processing for more than six hours as unhealthy, even though that state is intentional to preserve phone custody. Update the ramp metric to account for unresolved held uploads.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/integration/test_batch_pipeline_projection_followup_firestore.py">

<violation number="1" location="backend/tests/integration/test_batch_pipeline_projection_followup_firestore.py:187">
P2: Disabling both default-on flags here means this test no longer exercises the production configuration for beyond-101-row discovery. Keep this isolated variant, and add a companion case that runs the same drain with both flags at their defaults so the new pending-page and owner-chain paths are covered end to end.</violation>
</file>

<file name="backend/tests/unit/test_sync_artifact_repair_protocol.py">

<violation number="1" location="backend/tests/unit/test_sync_artifact_repair_protocol.py:79">
P3: `raising=False` isn't needed here: `repair_upload_owner_matches` is already imported into `routers.sync`. Drop the flag so the patch fails loudly if the symbol disappears, rather than silently adding a stub that production never reads.</violation>
</file>

<file name="backend/docs/batch-pipeline-serving.md">

<violation number="1" location="backend/docs/batch-pipeline-serving.md:433">
P3: "Even for an open surface" is undefined in this doc. Name the parameter the code uses, e.g. `surface_open=true`, and say that it does not shorten the 300000 ms poll for held uploads.</violation>
</file>

<file name="backend/database/batch_pipeline_artifact_missing.py">

<violation number="1" location="backend/database/batch_pipeline_artifact_missing.py:66">
P3: These imports sit inside methods, which backend/AGENTS.md prohibits. Move them to the module top. If a circular import blocks that, document the cycle and resolve it at the module level instead.</violation>
</file>

<file name="backend/models/sync_job_status.py">

<violation number="1" location="backend/models/sync_job_status.py:30">
P2: The `total_files = 0` default serializes on every poll response, including ones that never set it. For completed legacy and retired-handle statuses, clients now read `total_files: 0` for jobs that had files. Make the field optional so absent values stay absent, or populate `total_files` in those builders.</violation>
</file>

<file name="backend/tests/unit/test_batch_artifact_missing_reupload.py">

<violation number="1" location="backend/tests/unit/test_batch_artifact_missing_reupload.py:176">
P2: The refusal branch never checks that nothing was staged or probed. Add `assert staged_ids == [] and probes == []` so the test enforces the "no archive write before refusal" guarantee.</violation>

<violation number="2" location="backend/tests/unit/test_batch_artifact_missing_reupload.py:221">
P2: This case does not exercise the identity check against an existing owner. Add a case with the original content_id and a mismatched repair_job_id, and assert 409 with no row writes.</violation>
</file>

<file name="backend/utils/batch_pipeline/intake.py">

<violation number="1" location="backend/utils/batch_pipeline/intake.py:196">
P3: This adds function-local imports, which AGENTS.md forbids. Move `artifact_missing`, `REASON_CODE`, and `restore_upload` to module top-level imports. If a cycle requires the local import, document that next to it.</violation>

<violation number="2" location="backend/utils/batch_pipeline/intake.py:403">
P2: Deterministic repair refusals are returned as a retryable 503 with Retry-After 30. The phone will retry the same unrepairable bundle indefinitely. Map the repair's ProjectionBlocked to a non-retryable 409 such as `sync_repair_bundle_changed`, consistent with the router's other repair refusals.</violation>
</file>

<file name="config/feature-flags.yaml">

<violation number="1" location="config/feature-flags.yaml:174">
P2: This ramp metric still treats processing ledgers older than six hours as healthy only when a sibling is recovering, but unresolved held uploads now intentionally remain `processing` to preserve phone custody. Update the metric to distinguish expected custody-held ledgers from stuck uploads.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread backend/utils/batch_pipeline/intake.py Resolved
monkeypatch.setenv('BATCH_PIPELINE_ASYNC_PROJECTION_ENABLED', 'true')
# Isolate paginated discovery. Newer owner-chain walking and pending-only
# assignment pages intentionally bypass the legacy mixed-page stall.
monkeypatch.setenv('BATCH_PIPELINE_SWEEP_OWNER_CHAIN_ENABLED', 'false')

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: Disabling both default-on flags here means this test no longer exercises the production configuration for beyond-101-row discovery. Keep this isolated variant, and add a companion case that runs the same drain with both flags at their defaults so the new pending-page and owner-chain paths are covered end to end.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/integration/test_batch_pipeline_projection_followup_firestore.py, line 187:

<comment>Disabling both default-on flags here means this test no longer exercises the production configuration for beyond-101-row discovery. Keep this isolated variant, and add a companion case that runs the same drain with both flags at their defaults so the new pending-page and owner-chain paths are covered end to end.</comment>

<file context>
@@ -182,6 +182,10 @@ async def test_projection_discovery_drains_beyond_101_ready_rows_without_reproje
     monkeypatch.setenv('BATCH_PIPELINE_ASYNC_PROJECTION_ENABLED', 'true')
+    # Isolate paginated discovery. Newer owner-chain walking and pending-only
+    # assignment pages intentionally bypass the legacy mixed-page stall.
+    monkeypatch.setenv('BATCH_PIPELINE_SWEEP_OWNER_CHAIN_ENABLED', 'false')
+    monkeypatch.setenv('BATCH_PIPELINE_PROJECTION_PENDING_PAGE_ENABLED', 'false')
     monkeypatch.setenv('BATCH_PIPELINE_PROJECTION_PAGINATION_ENABLED', 'true')
</file context>

class SyncJobStatusResponse(BaseModel):
job_id: str
status: str
total_files: int = 0

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: The total_files = 0 default serializes on every poll response, including ones that never set it. For completed legacy and retired-handle statuses, clients now read total_files: 0 for jobs that had files. Make the field optional so absent values stay absent, or populate total_files in those builders.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/models/sync_job_status.py, line 30:

<comment>The `total_files = 0` default serializes on every poll response, including ones that never set it. For completed legacy and retired-handle statuses, clients now read `total_files: 0` for jobs that had files. Make the field optional so absent values stay absent, or populate `total_files` in those builders.</comment>

<file context>
@@ -27,6 +27,7 @@ class SyncJobStartResponse(BaseModel):
 class SyncJobStatusResponse(BaseModel):
     job_id: str
     status: str
+    total_files: int = 0
     total_segments: int = 0
     processed_segments: int = 0
</file context>
Suggested change
total_files: int = 0
total_files: int | None = None

response = await intake.accept_upload(
**{**upload_arguments(), 'content_id': 'changed-content'}, repair_job_id=binding.job_id
)
assert response.status_code == 409

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: This case does not exercise the identity check against an existing owner. Add a case with the original content_id and a mismatched repair_job_id, and assert 409 with no row writes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_batch_artifact_missing_reupload.py, line 221:

<comment>This case does not exercise the identity check against an existing owner. Add a case with the original content_id and a mismatched repair_job_id, and assert 409 with no row writes.</comment>

<file context>
@@ -0,0 +1,223 @@
+    response = await intake.accept_upload(
+        **{**upload_arguments(), 'content_id': 'changed-content'}, repair_job_id=binding.job_id
+    )
+    assert response.status_code == 409
+    assert json.loads(response.body)['code'] == 'sync_repair_bundle_changed'
+    assert client.rows == before
</file context>

checks.append((uid, content, job))
return matches

monkeypatch.setattr(sync, 'repair_upload_owner_matches', owned, raising=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: raising=False isn't needed here: repair_upload_owner_matches is already imported into routers.sync. Drop the flag so the patch fails loudly if the symbol disappears, rather than silently adding a stub that production never reads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_sync_artifact_repair_protocol.py, line 79:

<comment>`raising=False` isn't needed here: `repair_upload_owner_matches` is already imported into `routers.sync`. Drop the flag so the patch fails loudly if the symbol disappears, rather than silently adding a stub that production never reads.</comment>

<file context>
@@ -0,0 +1,93 @@
+        checks.append((uid, content, job))
+        return matches
+
+    monkeypatch.setattr(sync, 'repair_upload_owner_matches', owned, raising=False)
+    archives = []
+
</file context>
Suggested change
monkeypatch.setattr(sync, 'repair_upload_owner_matches', owned, raising=False)
monkeypatch.setattr(sync, 'repair_upload_owner_matches', owned)

outcome, and the held unit's encrypted audio stays server-side for the
operator path above. Committed siblings are already projected; no
is `committed`. Phones retain their WALs without re-uploading or consuming
retry budget, with a five-minute poll hint even for an open surface. A server

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: "Even for an open surface" is undefined in this doc. Name the parameter the code uses, e.g. surface_open=true, and say that it does not shorten the 300000 ms poll for held uploads.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/batch-pipeline-serving.md, line 433:

<comment>"Even for an open surface" is undefined in this doc. Name the parameter the code uses, e.g. `surface_open=true`, and say that it does not shorten the 300000 ms poll for held uploads.</comment>

<file context>
@@ -426,12 +426,13 @@ re-upload of the same content (`durable_status`) used to answer `failed` with
-  outcome, and the held unit's encrypted audio stays server-side for the
-  operator path above. Committed siblings are already projected; no
+  is `committed`. Phones retain their WALs without re-uploading or consuming
+  retry budget, with a five-minute poll hint even for an open surface. A server
+  artifact is not proof that the phone's independent copy may be released.
+  Committed siblings are already projected; no
</file context>
Suggested change
retry budget, with a five-minute poll hint even for an open surface. A server
retry budget, with a five-minute poll hint even when the `surface_open` query flag is set. A server


def reupload_snapshot(self, uid, content_id):
"""Read-only repair plan for the exact, server-derived upload content ID."""
from database.batch_pipeline_projection import held_without_recovery

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: These imports sit inside methods, which backend/AGENTS.md prohibits. Move them to the module top. If a circular import blocks that, document the cycle and resolve it at the module level instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/batch_pipeline_artifact_missing.py, line 66:

<comment>These imports sit inside methods, which backend/AGENTS.md prohibits. Move them to the module top. If a circular import blocks that, document the cycle and resolve it at the module level instead.</comment>

<file context>
@@ -0,0 +1,229 @@
+
+    def reupload_snapshot(self, uid, content_id):
+        """Read-only repair plan for the exact, server-derived upload content ID."""
+        from database.batch_pipeline_projection import held_without_recovery
+
+        def read(tx):
</file context>



def durable_status(store, uid: str, job_id: str) -> dict | None:
from database.batch_pipeline_artifact_missing import artifact_missing, REASON_CODE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This adds function-local imports, which AGENTS.md forbids. Move artifact_missing, REASON_CODE, and restore_upload to module top-level imports. If a cycle requires the local import, document that next to it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/batch_pipeline/intake.py, line 196:

<comment>This adds function-local imports, which AGENTS.md forbids. Move `artifact_missing`, `REASON_CODE`, and `restore_upload` to module top-level imports. If a cycle requires the local import, document that next to it.</comment>

<file context>
@@ -193,6 +193,8 @@ def _only_deleted_total(tx, uid: str, content_id: str) -> int | None:
 
 
 def durable_status(store, uid: str, job_id: str) -> dict | None:
+    from database.batch_pipeline_artifact_missing import artifact_missing, REASON_CODE
+
     def read(tx):
</file context>

Git-on-my-level and others added 7 commits November 2, 2026 18:49
Luna r1 on #24366, lead ruling 6d0246 (option A).

P1: a missing-input repair took recording_session_id, clocks, geolocation
and capture claims from the retried request, so it could project the
restored span into a different conversation from its siblings. Admission
now records a sha256 of those lineage fields on the intake record. A
repair must reproduce it exactly; otherwise it holds with phone custody.

P2: a repair re-ran language detection on every attempt. Admission now
records each unit's frozen language decision, and repair replays it. It
never probes, paid or self. A unit without that decision holds.

An intake admitted before this change has neither proof, so its repair
holds (reason legacy_lineage_unproven); its audio and custody are kept.
Holds log event=batch_artifact_repair outcome=held with a closed reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luna r2 on #24366 (P1). The router re-normalizes a request's audio clock
bounds against the current server time, so an identical retry of a
future-skewed upload produced a different lineage digest and held as
lineage_changed. A matching raw digest would not have been enough either:
the repair would restage with re-normalized bounds that differ from what
the projected siblings used.

Admission now records the lineage fields themselves, exactly as frozen into
the staged audio, as one canonical JSON string (Firestore rejects nested
arrays that capture claims may hold). A repair restages with the recorded
values and discards the retried request's lineage fields. A missing or
unreadable record holds (legacy_lineage_unproven / lineage_unreadable),
keeping phone custody and audio.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luna r3 on #24366 (P1). The A2 shadow mirrors intake documents to
Postgres, and the mirror does not follow the Firestore intake receipt TTL,
so the newly recorded geolocation and capture claims could outlive
retention there. The mirror is refused for the prod namespace (L02-2), so
this affects staging and dev namespaces only.

`repair_lineage` is now Firestore-only: copy_current drops it before the
Postgres write, and parity compare ignores it on both sides so shadow reads
still match. A repair against a store without the field holds rather than
guessing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lead ruling ebf868: the recorded lineage must clear on the same TTL path
as the intake receipt. It lives on the intake document, which
deploy/batch-pipeline/retention.json expires on expires_at, and it never
enters the Postgres mirror. This contract test fails if either changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luna r4 on #24366 (P1). compare() stripped repair_lineage from both
sides, so a shadow copy that still held it read as matching and backfill
never recopied it; the receipt TTL never refreshes the mirror. Strip it
from the primary side only: such a copy now reads as a mismatch and
backfill recopies it without the field. No deployed build has written the
field yet, so this is defensive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	backend/utils/batch_pipeline/intake.py
…y bound

After merging main, accept_upload crossed Pyright's "too complex to analyze"
limit and the push gate failed. Move the missing-span repair branch (the
repair-owner 409 and restore_upload) into _repair_prior_upload, and build
each unit's frozen language fields once with language_proof, reusing them
for the staged context and the intake record. Behaviour is unchanged:
1690 targeted backend tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level and others added 5 commits November 3, 2026 03:57
After merging main, flutter analyze reports the conversations.dart import
in batch_artifact_missing_custody_test.dart as unnecessary, which fails
Dart Analyze & Tests. Remove it; the test still passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	backend/utils/batch_pipeline/intake.py
# Conflicts:
#	backend/docs/feature-flag-registry.md
# Conflicts:
#	backend/docs/feature-flag-registry.md
Git-on-my-level and others added 3 commits November 4, 2026 05:53
Since #24501, sync admission parses a capture time from each staged path.
The repair-protocol fixture staged "synthetic-original", so the merged
request raised ValueError and answered 500 instead of the expected
409/410. Stage a parseable name, as main did in test_stt_cap_dispatch_http.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit e113f0c into main Nov 4, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/artifactmissing branch November 4, 2026 01:11
Git-on-my-level added a commit that referenced this pull request Nov 4, 2026
…24613)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

Every batch-pipeline-worker roll from main fails the image smoke:
`missing installed dependency modules: deepgram, ..., langdetect, ...`
(run 41860715660, main c8304ee). cl2-deploy's static bisect traced it:
- #24490 made `deepgram` reachable from the worker image;
- #24366 made `langdetect` reachable.

The last good worker roll was e24fa48 (11-03). This blocks #24603 (the
seal-repair discovery fix for today's admission jam) from reaching prod.

Change: add `deepgram-sdk==4.8.1`, `langdetect==1.0.9`,
`websockets==12.0` and `aiofiles==24.1.0` to
`backend/diarizer/requirements-batch-pipeline.txt`, all matching
`backend/requirements.txt`, and recompile `pylock.batch-pipeline.toml`
with the file's own uv command. The lock gains 8 packages; marshmallow
moves 4.3.1 -> 3.26.2, which is the backend's pin required by
dataclasses-json. No code changes. A lazy-import cleanup can follow
separately.

Validation:
- `backend/scripts/runtime_image_contracts.py check`: passed for 19
registered images.
- Lock and image tests pass: `test_batch_pipeline_lock_jobstore` 2,
`test_admit_role_image` 19, `test_diarizer_batch_prereqs` 6.
- The authoritative check is the image smoke in the worker deploy
workflow; cl2-deploy re-rolls right after merge.

Rollback: revert (the worker keeps rollback digest sha256:4faf8b7a8c53).

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/24613?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/24613?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24613&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. -->
Dimank92 pushed a commit to Dimank92/omi that referenced this pull request Nov 4, 2026
BasedHardware#24490 (speakers final pass) and BasedHardware#24366 (artifact restore) made the STT
helpers reachable from the batch-pipeline worker, but its lock never gained
their dependencies. The image smoke now fails on every main commit since,
which blocks all worker rolls, including the BasedHardware#24603 seal-repair discovery fix
for the admission jam (run 41860715660).

Pin deepgram-sdk 4.8.1 and langdetect 1.0.9, plus websockets 12.0 and
aiofiles 24.1.0, to backend/requirements.txt and recompile
pylock.batch-pipeline.toml (marshmallow resolves to the backend's 3.26.2).

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 5, 2026
…24673)

## Why

On 11-04 the batch-pipeline-worker roll failed its deploy-time image
smoke: `missing installed dependency modules: deepgram, … langdetect`.
- #24490 (e089cc3) and #24366 (e113f0c) made those imports reachable
from worker entrypoints.
- `backend/diarizer/pylock.batch-pipeline.toml` lacked the
distributions.
- Every pre-merge check passed. `runtime_image_contracts.py check`
covers first-party source closure only, and backend unit CI syncs the
full `backend/pylock.toml`, which does have both.
- The only third-party closure check ran at roll time, which blocked
worker fixes for hours (#24613).

## What

`python3 backend/scripts/runtime_image_contracts.py check-third-party`
(logic in the new `backend/scripts/runtime_image_dependencies.py`),
wired as the checks-manifest entry
`backend-runtime-image-third-party-closure` (local and ci lanes). Its
triggers include `backend/**/pylock*.toml` and `requirements*.txt`, so a
lock-only edit that drops a dist also runs it.

- **Installed set:** each installer `RUN` (`uv pip sync`, `pip install
-r`, inline pins) in the image's stage chain, including `COPY --from`
stages, is traced back through its `COPY` and `WORKDIR` to the repo
file. `-r` includes are followed.
- **Mapping:** each reachable third-party import from the existing
`third_party_dependency_modules` resolves to distribution candidates:
- longest prefix first, with PEP 503 normalization
(`google.cloud.firestore` → `google-cloud-firestore`);
- an API-version suffix is dropped (`google.cloud.tasks_v2` →
`google-cloud-tasks`);
- `MODULE_DISTRIBUTIONS` covers names that differ (PIL→pillow,
deepgram→deepgram-sdk, yaml→pyyaml, …).
- Bare namespaces (`google`, `google.cloud`) are skipped only as the
whole import path. An unmapped submodule under them fails closed.
- **Scope:** it fails only on closed sets, meaning a pylock or
requirements pinned entirely with `==`. Open sets (range pins, path
installs) can pull a module in transitively, so it prints a note instead
of judging them.
- **Speed:** a shared AST cache keeps it at about 30s for all 19 images.
It runs offline, with no docker or GCP and only stdlib (`tomllib`).

## Measured (m5, this branch's script run on `git archive` snapshots)

| Snapshot | Result |
|---|---|
| main 2ccfc47 (this base) | pass. 11 images checked, 8 noted as open
(models, 4 jobs, parakeet, nllb, plugins) |
| e089cc3 (#24490) | **FAIL** batch-pipeline-worker: deepgram |
| e113f0c (#24366) | **FAIL** batch-pipeline-worker: deepgram |
| e089cc3^ | pass |
| 660ee8a (#24613 fix) | pass |

The unit tests for `test_runtime_image_contracts.py` pass via `test.sh`
(70 passed). The registry-wide walk is deliberately left to the manifest
check, because the fast-unit CPU guard is 1s per test.

## Review (Luna, r1: SHIP-WITH-FIXES, all addressed)
1. `COPY --from` now credits a stage's installs only when the copy
carries a venv or site-packages, not a binary.
2. Explicit mappings are authoritative. An ordinary package is owned by
its top-level name. API-version suffix stripping and longer prefixes
apply only under namespace packages (`google`, `pyannote`).
3. Lock and requirements markers are evaluated for Linux x86_64 CPython
3.11, and undecidable markers never credit a distribution. A
requirements list counts as closed only if a resolver compiled it, so
hand-pinned and direct-URL sets are open. This moves diarizer to the
noted set: 10 images are checked on main, 9 are noted.
4. A fast test pins which registered images are judged.
5. Runtime: 19s locally on an idle host (17s CPU). Luna measured 75s
wall / 36s CPU under load.

## Review (Luna rounds 2-4)
- r2, SHIP-WITH-FIXES:
- Builder stages now credit only installs into the environment the image
copies (the backend builder's system-python `uv` is no longer credited).
  - Namespace matching stops at the provider component.
  - `python_full_version` is decided only when every 3.11.x agrees.
- r3, SHIP-WITH-FIXES: patch-boundary sampling (0, Z-1, Z, Z+1, 9999)
also covers `== '3.11'` and `<= '3.11.99'`.
- r4: **SHIP** at d4453ce.

Extra finding from re-validation: at e113f0c the gate also fails
`pusher`/`backend-pusher` on `soundfile`, which was missing from
`backend/pusher/pylock.toml` until cac4f62. That's a second real break
it would have caught.

Line-Count-Exception: backend/scripts/runtime_image_contracts.py | 1113
-> 1134 | CLI entry, shared AST cache and module alias for the
third-party gate; the gate itself lives in the new
runtime_image_dependencies.py

## Not in this PR (follow-ups from the GLM ciimage scope)
- Adding `batch-pipeline-worker` to `role_images.yml --images` and
widening its PR paths: that's a faithful docker build, but it has runner
cost and cl2-cost sizes it first.
- Closing the open dependency sets (pin `backend/requirements.txt`'s two
range lines, nllb) so those images become checkable.
- Making backend checks required at merge, which is David's call.

Rollback: revert this PR. It only adds a check.

Failure-Class: FC-runtime-image-boundary

🤖 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/24673?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/24673?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24673&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. -->
kriegcloud pushed a commit to kriegcloud/omi that referenced this pull request Nov 5, 2026
The pre-merge runtime-image gate only checked first-party source closure.
Third-party (pip) closure was checked only by the deploy-time image smoke.
BasedHardware#24490 and BasedHardware#24366 made deepgram and langdetect reachable from the
batch-pipeline-worker while its lock lacked them. Unit CI syncs the full
backend lock, so it stayed green, and the break surfaced at the 11-04
worker roll.

Add `runtime_image_contracts.py check-third-party` and a matching
checks-manifest entry in both the local and ci lanes:

- Trace each installer RUN in the image's stage chain back through its
  COPY to the repository lock or requirements file. Follow `-r`
  includes, inline pins and `COPY --from` stages.
- Map every reachable third-party import to a distribution: longest
  import prefix first, PEP 503 normalization, API-version suffixes
  dropped, and a small table for names that differ (PIL->pillow,
  deepgram->deepgram-sdk, ...). Bare namespace packages are skipped
  only as the whole import path, so an unmapped submodule fails closed.
- Fail only on closed sets: a pylock, or requirements pinned with `==`.
  Open sets (ranges, path installs) may pull a module in transitively,
  so they are reported, not judged.

On main it checks 11 of 19 images and reports 8 open sets. It fails
e089cc3 (BasedHardware#24490) and e113f0c (BasedHardware#24366) on batch-pipeline-worker, and
passes their parent and 660ee8a (BasedHardware#24613). It is offline, needs no
docker or GCP, and takes about 30s for all 19 images with a shared AST
cache.

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

This branch was successfully deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant