Skip to content

Speed up conversations v3 reconcile and pipeline lab day replay - #26849

Merged
Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/v3-reconcile-day-speed
Dec 1, 2026
Merged

Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/v3-reconcile-day-speed

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Reduce per-pass CPU in conversations v3 reconcile and speed up full-day lab replay. SCA-6045.

  • Compare validated inline JSON literals using their Firestore types, signed integer bounds, UTF-8 strings and exact double bits. Keep uncertain values on the SDK path and retain the transaction fence.
  • Reuse authenticated inline transcript data for the read path and reuse the snapshot dictionary for immutable inline fields. Sidecar validation and read-time privacy filtering still run. The size check already supplies the encoded document to the commit.
  • Narrow duplicate-capture candidates to the inclusive 20-second interval while visiting input segments in their original order.
  • Shorten the lab executor settle interval and save vectors as compact JSON. Document separate emulator projects and Redis databases for concurrent days.

Local checks passed 781 v3 tests and 843 pipeline lab tests. All 26 committed scenarios ran on base and head. Both passed 21 and reported the same five vendor-call budget failures with identical counts and expectations.

First day comparison matched all 40 cards across start, end, visibility, hidden reason, recording count and segment count. All 194 head calls replayed. Paired replay with the matching harness on each arm reduced driver time from 540.1 s to 375.9 s. CI passed all 26 scenarios across both repeats. On the larger day all 38 cards matched across the base recording and both replay arms. Driver time fell from 2013.8 s to 1052.7 s (860 tasks each). Base and head replay each missed one embedding call out of 225. Seven fresh interpreters on the unchanged base reproduced the recorded and replayed request variants from the same input. Hash-dependent tie selection at the 32-term cutoff explains the miss. Artifact comparison found 2 differences among 50 comparisons on the smaller day and 6 among 48 on the larger day. The larger vector file fell from 778,259,292 to 596,568,738 bytes.

Day Base mean seconds per task by quarter Head mean seconds per task by quarter
11-18 0.4281 / 0.5162 / 0.8128 / 0.9619 0.2991 / 0.3798 / 0.6976 / 0.6320
11-29 0.8385 / 0.7455 / 2.3129 / 4.7288 0.5026 / 0.7689 / 1.0473 / 2.2212

Serial head controls matched the concurrent head runs on every card on both days (40 and 38). Both concurrent runs shared one emulator with distinct Firestore projects and Redis databases.

Product invariants affected

none

@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.

3 issues found across 12 files

Confidence score: 3/5

  • In barrier.py, settle=0.005 can let ExecutorBarrier.wait return before completion callbacks submit follow-up work, so chain and v3 may export or read state while postprocessing is still running. Retain the 50 ms window or wait for postprocessing to finish.
  • In the pipeline lab README, the documented concurrency settings leave filesystem storage shared, so concurrent replays can overwrite or read each other’s data. Isolate <OMI_PIPELINE_LAB_ROOT>/stack/storage per replay.
  • In conversations_v3_row_codec.py, decode_row imports FIELD and reveal_segments locally despite the module-scope import rule. Move them to the module import block.
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/testing/pipeline_lab/README.md">

<violation number="1" location="backend/testing/pipeline_lab/README.md:657">
P2: The documented concurrency settings isolate Firestore and Redis, but not the lab's filesystem storage. Concurrent replays still install the same `<OMI_PIPELINE_LAB_ROOT>/stack/storage` and can overwrite or read each other's local objects; require a distinct lab/storage root per process or namespace storage by project before documenting this as safe.</violation>
</file>

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

<violation number="1" location="backend/database/conversations_v3_row_codec.py:54">
P3: This new backend production import is inside `decode_row`, contrary to the module-scope import rule. Move `FIELD` and `reveal_segments` to the module import block.</violation>
</file>

<file name="backend/testing/pipeline_lab/chain/barrier.py">

<violation number="1" location="backend/testing/pipeline_lab/chain/barrier.py:98">
P1: `settle=0.005` can let `ExecutorBarrier.wait` return before completion callbacks submit follow-up work. Chain and v3 then export or read state while postprocess work is still running; retain the 50 ms window or wait on a submission-generation/condition until the quiet interval is genuinely complete.</violation>
</file>

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

View guided diff | Re-trigger cubic

return len(self._pending)

def wait(self, timeout: float = 300.0, *, settle: float = 0.05) -> float:
def wait(self, timeout: float = 300.0, *, settle: float = 0.005) -> float:

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: settle=0.005 can let ExecutorBarrier.wait return before completion callbacks submit follow-up work. Chain and v3 then export or read state while postprocess work is still running; retain the 50 ms window or wait on a submission-generation/condition until the quiet interval is genuinely complete.

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/testing/pipeline_lab/chain/barrier.py, line 98:

<comment>`settle=0.005` can let `ExecutorBarrier.wait` return before completion callbacks submit follow-up work. Chain and v3 then export or read state while postprocess work is still running; retain the 50 ms window or wait on a submission-generation/condition until the quiet interval is genuinely complete.</comment>

<file context>
@@ -95,7 +95,7 @@ def pending(self) -> int:
             return len(self._pending)
 
-    def wait(self, timeout: float = 300.0, *, settle: float = 0.05) -> float:
+    def wait(self, timeout: float = 300.0, *, settle: float = 0.005) -> float:
         """Block until no tracked work is pending (stable for ``settle`` seconds)."""
         started = time.monotonic()
</file context>

Comment on lines +657 to 665
`OMI_PIPELINE_LAB_PROJECT_ID` (beginning with `demo-`) and
`OMI_PIPELINE_LAB_REDIS_DB` in each replay process. Both processes can use the
same Firestore and Redis ports. Each replay resets its lab user's state before
seeding the day, so reserve each project and database until its replay exits.
For a base/head timing comparison, launch each command from its own revision's
`backend/`: the launcher supplies the lab harness and `--ref` selects the
product code.

## Runbook: replay a real day (lead, on the lab host)

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 documented concurrency settings isolate Firestore and Redis, but not the lab's filesystem storage. Concurrent replays still install the same <OMI_PIPELINE_LAB_ROOT>/stack/storage and can overwrite or read each other's local objects; require a distinct lab/storage root per process or namespace storage by project before documenting this as safe.

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/testing/pipeline_lab/README.md, line 657:

<comment>The documented concurrency settings isolate Firestore and Redis, but not the lab's filesystem storage. Concurrent replays still install the same `<OMI_PIPELINE_LAB_ROOT>/stack/storage` and can overwrite or read each other's local objects; require a distinct lab/storage root per process or namespace storage by project before documenting this as safe.</comment>

<file context>
@@ -653,6 +653,15 @@ FS_PORT=8296 REDIS_PORT=6392 SMOKE_MODULE=testing.pipeline_lab.v3.smoke \
 the fake engine; the smoke runs the real product chain against a Firestore emulator.
 
+For concurrent day replays on one emulator stack, export a different
+`OMI_PIPELINE_LAB_PROJECT_ID` (beginning with `demo-`) and
+`OMI_PIPELINE_LAB_REDIS_DB` in each replay process. Both processes can use the
+same Firestore and Redis ports. Each replay resets its lab user's state before
</file context>
Suggested change
`OMI_PIPELINE_LAB_PROJECT_ID` (beginning with `demo-`) and
`OMI_PIPELINE_LAB_REDIS_DB` in each replay process. Both processes can use the
same Firestore and Redis ports. Each replay resets its lab user's state before
seeding the day, so reserve each project and database until its replay exits.
For a base/head timing comparison, launch each command from its own revision's
`backend/`: the launcher supplies the lab harness and `--ref` selects the
product code.
## Runbook: replay a real day (lead, on the lab host)
For concurrent day replays on one emulator stack, export a distinct
`OMI_PIPELINE_LAB_ROOT` (or storage root) as well as a different
`OMI_PIPELINE_LAB_PROJECT_ID` (beginning with `demo-`) and
`OMI_PIPELINE_LAB_REDIS_DB` in each replay process. Both processes can use the
same Firestore and Redis ports. Each replay resets its lab user's state before
seeding the day, so reserve each project, database and storage root until its
replay exits.
For a base/head timing comparison, launch each command from its own revision's
`backend/`: the launcher supplies the lab harness and `--ref` selects the
product code.

):
# Keep the authenticated, unrevealed JSON for the normal reader. Its timed sidecar and privacy
# filters must still run on the original segment fields. A strict read also reports rejected sidecars.
from utils.conversations.speaker_grouping_storage import FIELD, reveal_segments

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 new backend production import is inside decode_row, contrary to the module-scope import rule. Move FIELD and reveal_segments to the module import block.

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/conversations_v3_row_codec.py, line 54:

<comment>This new backend production import is inside `decode_row`, contrary to the module-scope import rule. Move `FIELD` and `reveal_segments` to the module import block.</comment>

<file context>
@@ -13,6 +21,62 @@
+    ):
+        # Keep the authenticated, unrevealed JSON for the normal reader. Its timed sidecar and privacy
+        # filters must still run on the original segment fields. A strict read also reports rejected sidecars.
+        from utils.conversations.speaker_grouping_storage import FIELD, reveal_segments
+
+        segments = conversations.decode_transcript_segments_blob(uid, raw_transcript, True, require_decryption=True)
</file context>

@Git-on-my-level
Git-on-my-level merged commit 3d1a5ea into BasedHardware:main Dec 1, 2026
72 of 73 checks passed
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