Repository navigation
feat(batch): add auto-language route receipts - #24458
Conversation
Persist content-free script and route counts for the marked mobile native auto-language cohort. Preserve legacy result and work-item serialization for non-cohort jobs during rollout.
There was a problem hiding this comment.
6 issues found across 19 files
Confidence score: 2/5
runner.pyrequiresWorkItem.to_dict(), which older extracted BASE snapshots do not provide, so baseline replay raisesAttributeError. Keep the adapter compatible with those snapshots.batch_pipeline_quarantine_recovery.pycompletes recovered units without alanguage_receipt, leaving the watcher to report UNKNOWN for language-guarded units. Preserve the receipt during recovery.test_batch_pipeline_worker_io.pycan pass even when serial execution produces a different language receipt, becauseWorkResultequality excludes it. Compare the receipt lists explicitly.test_batch_pipeline_language_receipt.pyandtest_batch_pipeline_live.pyomit supported platform and auto-language cases, so receipt-admission regressions may go undetected. Extend the cases to cover Android,auto, and empty language markers.
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/unit/test_batch_pipeline_worker_io.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_worker_io.py:138">
P2: This test does not verify that serial execution produces the same language receipt as overlapped execution because `WorkResult` excludes `language_receipt` from equality. Compare both receipt lists and validate metadata across both result sets so a regression in the serial path is caught.</violation>
</file>
<file name="backend/tests/unit/test_batch_pipeline_live.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_live.py:513">
P3: This integration assertion omits two supported auto-language declarations (`auto` and empty language), so receipt admission can regress for those records without failing the test. Extend the language matrix to include both values and derive the expectation from the full cohort set.</violation>
</file>
<file name="backend/database/batch_pipeline_quarantine_recovery.py">
<violation number="1" location="backend/database/batch_pipeline_quarantine_recovery.py:470">
P2: Recovered cohort units complete through `settle()` and `complete_silence()` without a `language_receipt`, so the watcher sees UNKNOWN for them. Those are the language-guarded units where the route matters most. Either thread a receipt through the recovery settle path or document this as an intentional rollout gap.</violation>
</file>
<file name="backend/tests/unit/test_batch_pipeline_language_receipt.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_language_receipt.py:54">
P2: This cohort test does not cover Android, the `auto`/empty language markers, or the native-record guard. Parameterize the positive cases across both platforms and all accepted markers, then add a `native_record=False` negative case.</violation>
</file>
<file name="backend/utils/batch_pipeline/contracts.py">
<violation number="1" location="backend/utils/batch_pipeline/contracts.py:88">
P3: Move these imports to the module-level import block. The new local imports violate the backend import rule and obscure the contracts module’s dependencies.</violation>
</file>
<file name="backend/testing/batch_replay/runner.py">
<violation number="1" location="backend/testing/batch_replay/runner.py:392">
P1: The fixed replay adapter now requires `WorkItem.to_dict()`, but the gate runs this adapter against older extracted BASE snapshots where that method does not exist. Baseline replay therefore raises `AttributeError`; retain a compatibility fallback to dataclass-field serialization for pre-receipt snapshots.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| lane = unit.get('lane') | ||
| log.jobs[sid] = { | ||
| **asdict(item), | ||
| **item.to_dict(), |
There was a problem hiding this comment.
P1: The fixed replay adapter now requires WorkItem.to_dict(), but the gate runs this adapter against older extracted BASE snapshots where that method does not exist. Baseline replay therefore raises AttributeError; retain a compatibility fallback to dataclass-field serialization for pre-receipt snapshots.
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/batch_replay/runner.py, line 392:
<comment>The fixed replay adapter now requires `WorkItem.to_dict()`, but the gate runs this adapter against older extracted BASE snapshots where that method does not exist. Baseline replay therefore raises `AttributeError`; retain a compatibility fallback to dataclass-field serialization for pre-receipt snapshots.</comment>
<file context>
@@ -390,7 +389,7 @@ def ready(self, sid, binding, now, **options):
lane = unit.get('lane')
log.jobs[sid] = {
- **asdict(item),
+ **item.to_dict(),
'policy_parts': log.policy_parts,
**({'fresh_capture': lane == 'fresh'} if lane in {'fresh', 'backfill'} else {}),
</file context>
| **item.to_dict(), | |
| **( | |
| item.to_dict() | |
| if hasattr(item, 'to_dict') | |
| else {name: getattr(item, name) for name in item.__dataclass_fields__} | |
| ), |
| assert all(r.language_receipt['route'] == 'parakeet' for r in results) | ||
| assert all(r.language_receipt['letters'] == 5 for r in results) |
There was a problem hiding this comment.
P2: This test does not verify that serial execution produces the same language receipt as overlapped execution because WorkResult excludes language_receipt from equality. Compare both receipt lists and validate metadata across both result sets so a regression in the serial path is caught.
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_pipeline_worker_io.py, line 138:
<comment>This test does not verify that serial execution produces the same language receipt as overlapped execution because `WorkResult` excludes `language_receipt` from equality. Compare both receipt lists and validate metadata across both result sets so a regression in the serial path is caught.</comment>
<file context>
@@ -127,11 +127,16 @@ def timed_flight(io_concurrency, *, scale=1.0, items=None):
assert results == serial_results
assert [r.segment_id for r in results] == [f's{i}' for i in range(7)]
assert all(isinstance(r, WorkResult) and r.outcome == 'success' for r in results)
+ assert all(r.language_receipt['route'] == 'parakeet' for r in results)
+ assert all(r.language_receipt['letters'] == 5 for r in results)
assert model.saved == serial_model.saved
</file context>
| assert all(r.language_receipt['route'] == 'parakeet' for r in results) | |
| assert all(r.language_receipt['letters'] == 5 for r in results) | |
| assert [r.language_receipt for r in results] == [r.language_receipt for r in serial_results] | |
| assert all(r.language_receipt['route'] == 'parakeet' for r in results + serial_results) | |
| assert all(r.language_receipt['letters'] == 5 for r in results + serial_results) |
| owner = tx.get('owners', owner_key(job['owner_id'])) | ||
| job.update( | ||
| result=asdict(WorkResult(segment_id, result_uri, outcome)), | ||
| result=WorkResult(segment_id, result_uri, outcome).to_dict(), |
There was a problem hiding this comment.
P2: Recovered cohort units complete through settle() and complete_silence() without a language_receipt, so the watcher sees UNKNOWN for them. Those are the language-guarded units where the route matters most. Either thread a receipt through the recovery settle path or document this as an intentional rollout gap.
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_quarantine_recovery.py, line 470:
<comment>Recovered cohort units complete through `settle()` and `complete_silence()` without a `language_receipt`, so the watcher sees UNKNOWN for them. Those are the language-guarded units where the route matters most. Either thread a receipt through the recovery settle path or document this as an intentional rollout gap.</comment>
<file context>
@@ -468,7 +467,7 @@ def commit(tx):
owner = tx.get('owners', owner_key(job['owner_id']))
job.update(
- result=asdict(WorkResult(segment_id, result_uri, outcome)),
+ result=WorkResult(segment_id, result_uri, outcome).to_dict(),
state='result_ready',
ready_at=now,
</file context>
|
|
||
|
|
||
| def test_receipts_are_limited_to_the_marked_mobile_native_auto_language_cohort(): | ||
| assert auto_language_cohort(server_batch_only=True, client_platform='ios', native_record=True, language='multi') |
There was a problem hiding this comment.
P2: This cohort test does not cover Android, the auto/empty language markers, or the native-record guard. Parameterize the positive cases across both platforms and all accepted markers, then add a native_record=False negative case.
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_pipeline_language_receipt.py, line 54:
<comment>This cohort test does not cover Android, the `auto`/empty language markers, or the native-record guard. Parameterize the positive cases across both platforms and all accepted markers, then add a `native_record=False` negative case.</comment>
<file context>
@@ -0,0 +1,78 @@
+
+
+def test_receipts_are_limited_to_the_marked_mobile_native_auto_language_cohort():
+ assert auto_language_cohort(server_batch_only=True, client_platform='ios', native_record=True, language='multi')
+ assert not auto_language_cohort(server_batch_only=True, client_platform='ios', native_record=True, language='en')
+ assert not auto_language_cohort(
</file context>
| assert auto_language_cohort(server_batch_only=True, client_platform='ios', native_record=True, language='multi') | |
| for platform in ('ios', 'android'): | |
| for language in ('multi', 'auto', ''): | |
| assert auto_language_cohort( | |
| server_batch_only=True, client_platform=platform, native_record=True, language=language | |
| ) | |
| assert not auto_language_cohort(server_batch_only=True, client_platform='ios', native_record=False, language='multi') |
| assert (store.rows['intakes', 'bp_' + content].get('server_batch_only') is True) is server_only | ||
| intake = store.rows['intakes', 'bp_' + content] | ||
| assert (intake.get('server_batch_only') is True) is server_only | ||
| receipt_enabled = server_only and language == 'multi' |
There was a problem hiding this comment.
P3: This integration assertion omits two supported auto-language declarations (auto and empty language), so receipt admission can regress for those records without failing the test. Extend the language matrix to include both values and derive the expectation from the full cohort set.
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_pipeline_live.py, line 513:
<comment>This integration assertion omits two supported auto-language declarations (`auto` and empty language), so receipt admission can regress for those records without failing the test. Extend the language matrix to include both values and derive the expectation from the full cohort set.</comment>
<file context>
@@ -507,7 +508,17 @@ def stage(item, body):
- assert (store.rows['intakes', 'bp_' + content].get('server_batch_only') is True) is server_only
+ intake = store.rows['intakes', 'bp_' + content]
+ assert (intake.get('server_batch_only') is True) is server_only
+ receipt_enabled = server_only and language == 'multi'
+ assert ('language_receipts' in intake) is receipt_enabled
+ assert (store.rows['jobs', intake['segment_ids'][0]].get('language_receipt_enabled') is True) is receipt_enabled
</file context>
|
|
||
| def to_dict(self): | ||
| """Serialize optional receipt state without widening legacy job documents.""" | ||
| from dataclasses import asdict |
There was a problem hiding this comment.
P3: Move these imports to the module-level import block. The new local imports violate the backend import rule and obscure the contracts module’s dependencies.
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/contracts.py, line 88:
<comment>Move these imports to the module-level import block. The new local imports violate the backend import rule and obscure the contracts module’s dependencies.</comment>
<file context>
@@ -81,6 +81,16 @@ class WorkItem:
+
+ def to_dict(self):
+ """Serialize optional receipt state without widening legacy job documents."""
+ from dataclasses import asdict
+
+ value = asdict(self)
</file context>
# Conflicts: # backend/tests/unit/test_batch_pipeline_live.py # backend/utils/batch_pipeline/contracts.py # backend/utils/batch_pipeline/provider_stt.py
Main's head (a5ccd17) fails two of its own checks, which every branch based on it inherits: the pl397 emulator-proof fixtures lack the time.monotonic clock the consumer's lease hold now reads, and the Soniox 503-at-submission test still asserts the pre-#24392 contract (5xx at the paid step now preserves paid uncertainty: submitted=True).
* feat(batch): add auto-language route receipts Persist content-free script and route counts for the marked mobile native auto-language cohort. Preserve legacy result and work-item serialization for non-cohort jobs during rollout. * test: align inherited main CI with its own current contracts Main's head (a5ccd17) fails two of its own checks, which every branch based on it inherits: the pl397 emulator-proof fixtures lack the time.monotonic clock the consumer's lease hold now reads, and the Soniox 503-at-submission test still asserts the pre-BasedHardware#24392 contract (5xx at the paid step now preserves paid uncertainty: submitted=True).
Adds content-free per-unit language and script receipts for the marked mobile native auto-language batch cohort. The watcher can now identify a completed conversation dominated by a disallowed script and a durable per-unit route that conflicts with the accepted language. Non-cohort jobs retain their prior serialized shape; missing receipts remain UNKNOWN during rollout.
Verification: 11 backend unit files passed; 24 watcher tests passed; selected hermetic listen/sync/batch e2e passed.