Skip to content

SCA-4146: Continue keyed iOS notes after the from-segments deadline - #26306

Merged
Git-on-my-level merged 17 commits into
mainfrom
agent/multica-worker-1-codex-sol/bff31eb40388-sca-4146
Nov 27, 2026
Merged

Git-on-my-level merged 17 commits into
mainfrom
agent/multica-worker-1-codex-sol/bff31eb40388-sca-4146

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

SCA-4146. Use the existing 25-second deadline for Firebase-authenticated intake and for keyed uploads waiting on enrichment. Resolve completed replays before admitting work to the bounded enrichment pool.

For the keyed iOS rollout cohort, an async coordinator continues the same notes attempt after the HTTP waiter returns its existing retryable 503. It keeps the processing lease, uses a separate enrichment budget, and releases executor slots while awaiting agentic or one-shot notes. An active replay returns the same retryable 503 body and headers so iOS keeps its local audio. A completed replay returns the existing 200 response for the same conversation. Reclaiming an aged lease uses the stored transcript and compares the observed lease in the existing claim transaction.

The new mode defaults off. Before enabling the cohort, Release needs to verify that the Backend candidate can finish admitted work after its HTTP response with no other request active.

Verification

  • Worker 1 verified the starvation correction at 4235309e0fd4. With eight keyed iOS continuations paused in the real notes loop at a synthetic provider, the shared test pool had zero occupied workers. A separate keyed Android upload started in 4 ms and returned HTTP 200 in 6 ms against the 25-second deadline. The retry tests verified claim retention and same-conversation replay.
  • Worker 1 verified the late-projection follow-up at a24fe70d849a. BACKEND_PYTEST_WORKERS=1 bash backend/test.sh test_client_processing_acceptance.py test_developer_from_segments_idempotency.py test_client_processing_trust_boundary.py test_client_segment_continuation.py test_from_segments_503_attribution.py passed all 231 tests. The race tests cover the retryable 503, preservation of the newer projection after the first request completes, and a replay returning 200 for the same completed conversation.
  • 342 focused Backend tests passed. The route regression also passed with the production 25-second deadline and synthetic slow notes. It returned a tagged 503, retained the claim, and returned 200 on the same conversation after exactly one processing invocation. Coverage includes slow intake, provider timeout readmission, stale-claim fencing, chunk continuation, and display-projection isolation.
  • Production acceptance is pending Release and Health. Health should use the candidate revision and one 30-minute window for the route counts and attribution read below. Record the trace for a previously cut retry returning 200 and two consecutive route ticks at 8 or fewer with failed: [], SERVING, and READBACK in SCA-3846.
resource.type="cloud_run_revision"
resource.labels.service_name="backend"
resource.labels.revision_name="<serving revision>"
log_id("run.googleapis.com/requests")
httpRequest.requestMethod="POST"
httpRequest.requestUrl=~"/v1/conversations/from-segments([?]|$)"
timestamp>="<window start UTC>"
timestamp<"<window end UTC>"

Use the same resource and time filters with log_id("run.googleapis.com/stderr") and (jsonPayload.event="from_segments_503" OR textPayload:"from_segments_503") for the attribution read.

Product invariants affected

  • INV-MEM-4
  • INV-TASK-2

Failure-Class: FC-per-hop-timeout

Line-Count-Exception: backend/routers/developer.py | 2907 -> 3032 | Keep validation, replay and claim authority together while isolating the HTTP deadline from continued processing.
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3622 -> 3701 | Share enrichment and persistence stages between synchronous processing and the async continuation, and release workers during notes model waits.

View guided diff Turn on auto-fix

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

lambda: run_blocking(from_segments_executor, _run_from_segments_processing, prepared, continue_processing)

P1 Badge Coordinate continued processing without holding a worker slot

With continued processing enabled, this dispatch holds one of only eight from_segments_executor workers for the entire enrichment pipeline, including asynchronous model waits, under the new 300-second budget. Eight slow iOS attempts therefore prevent other keyed uploads—including Android and desktop requests outside the rollout—from starting processing; queued requests exhaust their 25-second HTTP budgets instead. Keep the long-lived coordinator asynchronous and borrow workers for individual blocking steps rather than wrapping the whole pipeline in run_blocking. This violates the explicit long-running pipeline requirement in backend/AGENTS.md.

AGENTS.md reference: backend/AGENTS.md:L279-L279

ℹ️ 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".

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent review of implementation at e2d5c56 and current head (docstring-only follow-up): no blocking code findings. The admitted worker runs in the bounded executor with a lease heartbeat; enabled-mode active keyed replays return retryable 503, and completed replays return the stored conversation. Existing regression coverage exercises timeout, pending replay, and same-row completion. Release still needs to verify post-response worker completion on the candidate with no other request active.

Preserve both request-deadline and v3 backfill exception propagation. Update continuation tests for split staging and give the deadline integration tests a runner-safe budget.

Co-authored-by: multica-agent <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 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-27T17:17:37.638775Z d338cc6 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.

Preserve deadline and V3 conflict propagation in notes processing.

Co-authored-by: multica-agent <[email protected]>

@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: 2ba1cf8658

ℹ️ 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 thread backend/routers/developer.py Outdated
Comment on lines +2322 to +2325
if continue_processing and existing_conversation.get('status') == ConversationStatus.processing:
# iOS acknowledges uploads by HTTP status alone. Keep its local copy
# until the admitted worker has persisted the completed conversation.
raise retryable_processing_response('from_segments_processing_in_flight')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep active replays retryable outside the continuation cohort

For keyed uploads outside the rollout cohort (including iOS with the default-off flag), the new HTTP waiter can return 503 at 25 seconds while its synchronous worker is still running. A retry during that interval reaches this branch with continue_processing=False and receives 200 for the unfinished processing row. The worker can subsequently hit require_request_budget() and roll the row back to in_progress, leaving no active processor. This prematurely acknowledges the upload: uploadOnDeviceSegments accepts the returned ID without checking status, and macOS ConversationFinalizationService marks the upload completed. Return the retryable in-flight response for these active keyed claims too, so clients keep retrying until processing actually completes.

Useful? React with 👍 / 👎.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

REQUEST CHANGES — P1: keyed retries can acknowledge a conversation that the worker later leaves in progress.

create_conversation_from_segments_user dispatches every keyed request to from_segments_executor and bounds only the HTTP wait. With the default-off or non-selected flag, the worker still runs under the 25-second request deadline. If that wait expires during a blocking processing step, a same-session retry can arrive while the stored row is processing. _replay_from_segments returns the stored response unless continue_processing is true, so this retry gets HTTP 200 with status processing. The iOS client treats 2xx as acknowledgment; when the original worker reaches its deadline it rolls the row back to in_progress, leaving no client retry and no active worker to finish it.

Please either keep non-cohort keyed work on the synchronous path, or return the retryable in-flight response for keyed iOS rows whenever status is processing, independent of the continuation flag. Relevant locations: backend/routers/developer.py:2322-2325 and 2541-2542.

Git-on-my-level and others added 7 commits November 26, 2026 23:11
Keep the continued iOS pipeline asynchronous through agentic and one-shot notes. Keep the HTTP waiter on its 25-second deadline and use executor slots for individual blocking stages.

Co-authored-by: multica-agent <[email protected]>

@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: 3927510fc1

ℹ️ 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".

**notes_agent_inputs(main_conv, desktop_capture),
)
if async_notes:
from utils.llm.conversation_processing import conversation_notes_steps

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the new notes-step import to module scope

backend/AGENTS.md explicitly requires “All imports at module top level — never inside functions.” This newly added import violates that backend-specific requirement. Add conversation_notes_steps to the existing module-level imports from utils.llm.conversation_processing, alongside get_conversation_notes, rather than importing it inside the processing branch.

AGENTS.md reference: backend/AGENTS.md:L166-L168

Useful? React with 👍 / 👎.

@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: ceb2d783cf

ℹ️ 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 thread backend/tests/unit/test_notes_agent.py Outdated
Comment on lines +720 to +721
from utils.conversations.processing_steps import run_async
from utils.executors import postprocess_executor

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the new test imports to module scope

backend/AGENTS.md explicitly requires all imports at module top level, never inside functions, and this requirement also applies to backend tests. Move these newly added imports into the module-level import block; the newly added run_inline import in test_episodes_finalizer_hook.py needs the same adjustment.

AGENTS.md reference: backend/AGENTS.md:L166-L168

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Nov 27, 2026
## What changed and why

Regenerated the GMP query migration inventory after #26474 added the Omi
Core Features upload panels. The stale generated file fails the Backend
Unit Tests on main and also blocks #26306. Tracked in SCA-4753.

## Product invariants affected

none

## How it was verified

- Ran `python3 backend/scripts/monitoring_gmp_shadow.py --inventory
--output backend/charts/monitoring/gmp-query-migration-inventory.json`.
Compared the generated entries with the dashboard at the #26474 merge.
Only the four query consumers for panels 101, 102, and 103 and the total
(326 to 330) changed.
- Ran the 35 tests in `backend/tests/unit/test_monitoring_gmp_shadow.py`
with the local test environment and with pytest on Python 3.11. Both
runs passed.
- Ran `make preflight` and validated the PR metadata. The shallow
checkout skips the history-dependent failure-class ratchet.

## Tests

The existing `test_committed_inventory_is_current` compares the
committed file with the generator output and covers this repair.

UI-Evidence: none -- generated inventory only

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26517?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/26517?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26517&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. -->
@Git-on-my-level
Git-on-my-level merged commit 12eda38 into main Nov 27, 2026
70 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/multica-worker-1-codex-sol/bff31eb40388-sca-4146 branch November 27, 2026 17:55
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