Repository navigation
feat: Jev population shadows and cohort ramp controls (EXP-004) - #19968
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af2449acb
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a99e0d9253
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d111076166
ℹ️ 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".
Review fixes (Codex threads on #19968): - Fence jev_shadow writes against account deletion via a transaction reading account_deletions/{uid}, mirroring transcription_shadow; fenced writes record 'dropped' (PRRT_kwDOLkKqys6ndzXn) - Keep shadow DB work off the LLM pool: dedicated jev_shadow_executor and lane semaphores bound admission/store IO out of llm_executor (P2) - Handle source=None conversations as 'unknown' instead of crashing (P2) - Add 'entity' to the persisted subject-kind allowlist (P2) - Prod shadow percentages start at 0 pending the jev_shadow TTL policy provisioning; EXP-004 doc records the gate (P1) - Include question_version in shadow record IDs to preserve recalibration evidence (P2) - Record the owner 'cohort' outcome for cohort-gated candidates (P2) - Classify google.api_core DeadlineExceeded as 'timeout' (P2) - Fail closed on invalid percentages before consulting allowlists via _percentage_or_none (P2) - Make MEMORY_OWNER_JEV_FLIP_ENABLED universal per INV-MEM-5: remove owner_flip_enabled_for and the FLIP percent/allowlist flags (P1) - ask_jev gains record_decision_metrics=False for shadow calls so live decision lanes stay uncontaminated (P2) - Module-scope get_data_plane_firestore_client import per the backend import contract; test stubs updated (P1) - Enforce wall-clock deadline in execute_systemone via asyncio.wait_for (P2) Also: base runtime_env prod blocks aligned with overlays/charts (shadow percentages 0); feature-flag registry regenerated.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89d283a0eb
ℹ️ 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".
Review fixes (Codex threads on #19968, round 2): - Bound the deletion-fence transaction: marker.get passes retry=None and timeout=remaining, and client.transaction(max_attempts=1) disables the SDK restart loop so one write cannot exceed the 2.5s task budget (P2) - Observe JEV_SHADOW_LATENCY in the worker's finally block (model calls only) so the p95 bar includes score processing and persistence (P2) - Set a dedicated jev_shadow_{lane} usage context around ask_jev so the parent track_usage(Features.MEMORIES) context cannot claim the shadow budget in gateway accounting (P2) - Reject owner answers whose three probabilities do not form a complete distribution (exact option set, sum within 0.01 of 1.0) instead of persisting them as ok (P2) - Shadow transcript_only now mirrors the live Jev gate: blank-description photos no longer exclude a conversation from calibration (P2) - Dev backend-sync and backend-sync-backfill shadow percentages drop to 0: those Cloud Run hosts have no GMP sidecar/exporter entry, so their shadow metrics would be invisible; EXP-004 doc records the host scoping and the feature-flag registry is regenerated (P2) Test stubs updated accordingly.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b818c5710
ℹ️ 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".
Many suites stub database._client without get_data_plane_firestore_client; the module-top import made process_conversation fail to load under them (CI backend unit shards 1, 2 and 4). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Review fixes (Codex threads on #19968): - Fence jev_shadow writes against account deletion via a transaction reading account_deletions/{uid}, mirroring transcription_shadow; fenced writes record 'dropped' (PRRT_kwDOLkKqys6ndzXn) - Keep shadow DB work off the LLM pool: dedicated jev_shadow_executor and lane semaphores bound admission/store IO out of llm_executor (P2) - Handle source=None conversations as 'unknown' instead of crashing (P2) - Add 'entity' to the persisted subject-kind allowlist (P2) - Prod shadow percentages start at 0 pending the jev_shadow TTL policy provisioning; EXP-004 doc records the gate (P1) - Include question_version in shadow record IDs to preserve recalibration evidence (P2) - Record the owner 'cohort' outcome for cohort-gated candidates (P2) - Classify google.api_core DeadlineExceeded as 'timeout' (P2) - Fail closed on invalid percentages before consulting allowlists via _percentage_or_none (P2) - Make MEMORY_OWNER_JEV_FLIP_ENABLED universal per INV-MEM-5: remove owner_flip_enabled_for and the FLIP percent/allowlist flags (P1) - ask_jev gains record_decision_metrics=False for shadow calls so live decision lanes stay uncontaminated (P2) - Module-scope get_data_plane_firestore_client import per the backend import contract; test stubs updated (P1) - Enforce wall-clock deadline in execute_systemone via asyncio.wait_for (P2) Also: base runtime_env prod blocks aligned with overlays/charts (shadow percentages 0); feature-flag registry regenerated.
Review fixes (Codex threads on #19968, round 2): - Bound the deletion-fence transaction: marker.get passes retry=None and timeout=remaining, and client.transaction(max_attempts=1) disables the SDK restart loop so one write cannot exceed the 2.5s task budget (P2) - Observe JEV_SHADOW_LATENCY in the worker's finally block (model calls only) so the p95 bar includes score processing and persistence (P2) - Set a dedicated jev_shadow_{lane} usage context around ask_jev so the parent track_usage(Features.MEMORIES) context cannot claim the shadow budget in gateway accounting (P2) - Reject owner answers whose three probabilities do not form a complete distribution (exact option set, sum within 0.01 of 1.0) instead of persisting them as ok (P2) - Shadow transcript_only now mirrors the live Jev gate: blank-description photos no longer exclude a conversation from calibration (P2) - Dev backend-sync and backend-sync-backfill shadow percentages drop to 0: those Cloud Run hosts have no GMP sidecar/exporter entry, so their shadow metrics would be invisible; EXP-004 doc records the host scoping and the feature-flag registry is regenerated (P2) Test stubs updated accordingly.
The SDK's @firestore.transactional wrapper invokes transaction._commit() with the client default timeout (google-cloud-firestore 2.20.0), so a stalled Firestore commit could hold a shadow worker far past the documented 2.5-second budget even with max_attempts=1 and the deadline already applied to the marker read. Race the transactional call on a dedicated two-worker pool and re-raise an overrun as builtin TimeoutError, so the worker records 'timeout' and releases its lane slot inside the budget (same pattern as speaker_tag_prompts list verification and MCP CIMD DNS resolution). Verified: BACKEND_UNIT_TEST_FILE_LIST focused run, test_store_commit_race_bounds_a_stalled_sdk_commit plus the full test_jev_population_shadow.py module pass.
…population Dev processing hosts enable CONVERSATION_RELEVANCE_JEV_ENABLED with the live percentage unset, and relevance_arm() defaults an unset percent to 100 when the flag is on, routing every UID to the live Jev arm — which submit_relevance_shadow() explicitly skips. The dev relevance shadow at 100 would have recorded nothing. Pin CONVERSATION_RELEVANCE_JEV_PERCENT to 0 on the four dev process_conversation hosts (overlay + composed manifest + both dev charts), keeping decisions identical across hosts and matching prod posture while the shadow measures the full nano arm. Add a manifest guard (test_dev_jev_shadow_hosts_keep_a_nonempty_measurement_arm) so a shadow-enabled live-flag host can no longer ship with an unset or all-consuming live percentage, and correct the two EXP-004 doc sentences that described the old state. Verified: BACKEND_UNIT_TEST_FILE_LIST focused run — test_dev_jev_shadow_hosts_keep_a_nonempty_measurement_arm, test_rendered_dev_pusher_direct_bindings_match_source_contract, test_jev_rollout_flags_cover_only_process_conversation_hosts and the full validator/pusher-config modules pass; compose_runtime_env.py regenerated the manifest with the four pins.
1b818c5 to
9f03a5d
Compare
|
Addressed both review threads in 9f03a5d (rebased onto current Bound the shadow commit by the remaining deadline ( Dev relevance shadow population fix ( Verification: focused |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f03a5d079
ℹ️ 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".
| return future.result(timeout=timeout) | ||
| except concurrent.futures.TimeoutError: | ||
| # Raised as builtin TimeoutError so the worker classifies an overran | ||
| # commit as 'timeout' rather than 'jev_failed'. | ||
| future.cancel() |
There was a problem hiding this comment.
Stop timed-out transactions instead of abandoning the wait
When a Firestore commit exceeds the remaining budget, future.cancel() cannot stop the transaction once its worker has begun executing, so the SDK call can continue for its default timeout and may persist the record after _run has reported timeout and released the lane. Fresh evidence after the earlier commit-deadline report is that the new race bounds only Future.result(), not the in-flight commit; two stalled calls also occupy this ad-hoc pool and make later persistence attempts time out behind them. Propagate the deadline to the actual commit or otherwise terminate the operation rather than abandoning the wait.
AGENTS.md reference: backend/AGENTS.md:L253-L253
Useful? React with 👍 / 👎.
| jev = _percentage_or_none('CONVERSATION_RELEVANCE_JEV_PERCENT', default=100.0) | ||
| if jev is not None and ( | ||
| bucket < min(100.0, (keep_all if keep_all is not None else 0.0) + jev) | ||
| or _allowlisted(uid, 'CONVERSATION_RELEVANCE_JEV_UID_ALLOWLIST') |
There was a problem hiding this comment.
Fail closed when the keep-all percentage is invalid
When CONVERSATION_RELEVANCE_KEEP_ALL_PERCENT is malformed but the live flag and CONVERSATION_RELEVANCE_JEV_PERCENT are valid, keep_all becomes None and this expression silently substitutes zero, assigning users to the live Jev arm despite the documented fail-closed behavior. For example, KEEP_ALL_PERCENT=broken, JEV_PERCENT=100, and the enable flag set makes every UID return jev; return nano when either cohort boundary is invalid instead of treating an invalid keep-all boundary as zero.
Useful? React with 👍 / 👎.
| MEMORY_OWNER_JEV_SHADOW_PERCENT: | ||
| value: '100' |
There was a problem hiding this comment.
Disable live owner scoring on owner-shadow hosts
On each inspected shadow-enabled dev processing host—Cloud Run backend, backend-listen, and pusher—this is set to 100% while MEMORY_OWNER_JEV_FLIP_ENABLED remains true. In _extract_memories_canonical, the first eight third-party candidates are consequently marked owner_live_scored and explicitly excluded from shadow submission even when the live call fails, so ordinary conversations produce no owner-shadow probability records and only rare candidates beyond the live budget enter the experiment. Disable the live owner flip on hosts intended to collect the owner-shadow distribution, or otherwise preserve measurements for those live-scored candidates.
Useful? React with 👍 / 👎.
| slot = _slots[lane] | ||
| if not slot.acquire(blocking=False): | ||
| record_jev_shadow_outcome(lane, 'dropped') |
There was a problem hiding this comment.
Sample owner candidates before applying the two-slot bound
When live owner scoring is off and one conversation yields more than two eligible third-party candidates, the extraction loop submits them back-to-back before either Redis/LLM task can finish, so this two-slot semaphore admits the first two and deterministically records the rest as dropped. Candidate inclusion is therefore driven by extractor order rather than sampling, giving later candidates effectively zero inclusion even though the eventual live path scores up to eight; the measured owner-probability distribution cannot safely support a universal rollout. Choose the bounded candidates randomly or with a per-conversation reservoir before dispatching them.
Useful? React with 👍 / 👎.
|
Coordination note from the Claude session that opened this PR and is driving the EXP-004 rollout for David (authorized to admin-merge and deploy). I see another driver has been pushing review fixes and rebasing this branch (latest Plan: if you are still working on these, push or reply here. Otherwise I will admin-merge this PR once those threads are resolved, then deploy serially (backend, listen, pusher) and monitor. Prod live Jev flags stay off; only the shadow settings ship. Please do not dispatch a prod deploy for this change yourself, so we do not overlap deploys. |
Measure Jev relevance and owner probabilities asynchronously on production candidates without changing decisions. Add deterministic user arms for a later config-only ramp and keep-all control, with atomic Redis budgets and dedupe, bounded workers, text-free Firestore evidence, and EXP-004 acceptance bars.
Product invariants affected
INV-MEM-4: Production live flags remain off; shadow cannot change memory or relevance output. All processing hosts receive matching declared shadow settings.
INV-TASK-2: Cohort and shadow submission leave task candidate capture authority and user approval unchanged.
Validation
Synthetic cohort, relevance, shadow and canonical-capture tests; deployment fixtures, registry and runtime image closure; full local preflight. No cloud data reads or deployments.
Failure-Class: none
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3438 -> 3520 | Wire per-user arms and string-only owner/relevance shadow submission at the existing decision seams
🤖 Generated with Claude Code