Repository navigation
feat(observability): count delivery terminal outcomes before alarm calibration - #24426
Conversation
There was a problem hiding this comment.
4 issues found across 14 files
Confidence score: 3/5
outbox.pyandconsumer.pycan count an already-committed summary asfailed, skewing the delivery baseline. Preserve and record the committed outcome whenrecord_empty_failurefinds the summary.delivery-outcomes.mdassigns baseline collection to Infracost, which conflicts with the stated rollout responsibility. Update the runbook to name the responsible team.delivery.pycan classify subclasses of deferred or fence exceptions asfailed. Match derived exceptions so they retain thedeferredoutcome.
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/utils/enrichment/outbox.py">
<violation number="1" location="backend/utils/enrichment/outbox.py:670">
P2: This records `summary/failed` even when `record_empty_failure` finds that a summary was already committed before the callback lost its acknowledgement. That inflates the failed baseline with an already-delivered terminal state; return the helper's enriched/blocked outcome or otherwise classify the already-enriched case as `no_op` before recording the metric.</violation>
</file>
<file name="backend/docs/runbooks/delivery-outcomes.md">
<violation number="1" location="backend/docs/runbooks/delivery-outcomes.md:28">
P2: This runbook assigns delivery-metric baseline collection to Infracost, which is unrelated to the GMP counter workflow and conflicts with the stated team/rollout-lead responsibility. Replace it with the actual observability or rollout owner so the required seven-day baseline is not left ownerless.</violation>
</file>
<file name="backend/utils/enrichment/consumer.py">
<violation number="1" location="backend/utils/enrichment/consumer.py:173">
P2: This records `failed` even when `record_empty_failure` finds that another writer already committed the summary and retires the row with `summary_seen=True`. Return the committed outcome from `record_empty_failure` (or otherwise distinguish the enriched case) before incrementing this counter, so baseline failure rates are not inflated by already-delivered summaries.</violation>
</file>
<file name="backend/utils/observability/delivery.py">
<violation number="1" location="backend/utils/observability/delivery.py:96">
P3: Subclassed deferred/fence exceptions are miscounted as `failed`. Match the exception MRO (or use `isinstance`) so derived terminal exceptions retain the `deferred` outcome.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| get_firestore_client(), COLLECTION, document_id, owner, task_token | ||
| ): | ||
| raise | ||
| record_delivery('summary', 'failed') |
There was a problem hiding this comment.
P2: This records summary/failed even when record_empty_failure finds that a summary was already committed before the callback lost its acknowledgement. That inflates the failed baseline with an already-delivered terminal state; return the helper's enriched/blocked outcome or otherwise classify the already-enriched case as no_op before recording the metric.
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/enrichment/outbox.py, line 670:
<comment>This records `summary/failed` even when `record_empty_failure` finds that a summary was already committed before the callback lost its acknowledgement. That inflates the failed baseline with an already-delivered terminal state; return the helper's enriched/blocked outcome or otherwise classify the already-enriched case as `no_op` before recording the metric.</comment>
<file context>
@@ -666,6 +667,7 @@ def claim(old: Row | None) -> tuple[Row | None, tuple[str, Row | None]]:
get_firestore_client(), COLLECTION, document_id, owner, task_token
):
raise
+ record_delivery('summary', 'failed')
empty_blocked = True
finally:
</file context>
| The no-op alarm is **unarmed**; this PR adds no alert rule. Infracost owns the | ||
| baseline after the lead deploys. Record the first serving release SHA, traffic |
There was a problem hiding this comment.
P2: This runbook assigns delivery-metric baseline collection to Infracost, which is unrelated to the GMP counter workflow and conflicts with the stated team/rollout-lead responsibility. Replace it with the actual observability or rollout owner so the required seven-day baseline is not left ownerless.
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/runbooks/delivery-outcomes.md, line 28:
<comment>This runbook assigns delivery-metric baseline collection to Infracost, which is unrelated to the GMP counter workflow and conflicts with the stated team/rollout-lead responsibility. Replace it with the actual observability or rollout owner so the required seven-day baseline is not left ownerless.</comment>
<file context>
@@ -0,0 +1,42 @@
+
+## Alarm admission
+
+The no-op alarm is **unarmed**; this PR adds no alert rule. Infracost owns the
+baseline after the lead deploys. Record the first serving release SHA, traffic
+percentages and first visible counter timestamp. For each kind and service,
</file context>
| The no-op alarm is **unarmed**; this PR adds no alert rule. Infracost owns the | |
| baseline after the lead deploys. Record the first serving release SHA, traffic | |
| The no-op alarm is **unarmed**; this PR adds no alert rule. The rollout lead owns | |
| baseline collection after deployment. Record the first serving release SHA, traffic |
| get_firestore_client(), rows.COLLECTION, claim.row_id, claim.lease_token, claim.wake_token | ||
| ): | ||
| return Result(Outcome.RETRY, RetryReason.CALLBACK_PENDING, available_at=now) | ||
| record_delivery('summary', 'failed') |
There was a problem hiding this comment.
P2: This records failed even when record_empty_failure finds that another writer already committed the summary and retires the row with summary_seen=True. Return the committed outcome from record_empty_failure (or otherwise distinguish the enriched case) before incrementing this counter, so baseline failure rates are not inflated by already-delivered summaries.
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/enrichment/consumer.py, line 173:
<comment>This records `failed` even when `record_empty_failure` finds that another writer already committed the summary and retires the row with `summary_seen=True`. Return the committed outcome from `record_empty_failure` (or otherwise distinguish the enriched case) before incrementing this counter, so baseline failure rates are not inflated by already-delivered summaries.</comment>
<file context>
@@ -169,6 +170,7 @@ def process(self, claim: Claim, heartbeat: Callable[[], bool]) -> Result:
get_firestore_client(), rows.COLLECTION, claim.row_id, claim.lease_token, claim.wake_token
):
return Result(Outcome.RETRY, RetryReason.CALLBACK_PENDING, available_at=now)
+ record_delivery('summary', 'failed')
empty_blocked = True
finally:
</file context>
| try: | ||
| return function(*args, **kwargs) | ||
| except Exception as error: | ||
| outcome = ( |
There was a problem hiding this comment.
P3: Subclassed deferred/fence exceptions are miscounted as failed. Match the exception MRO (or use isinstance) so derived terminal exceptions retain the deferred outcome.
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/observability/delivery.py, line 96:
<comment>Subclassed deferred/fence exceptions are miscounted as `failed`. Match the exception MRO (or use `isinstance`) so derived terminal exceptions retain the `deferred` outcome.</comment>
<file context>
@@ -0,0 +1,142 @@
+ try:
+ return function(*args, **kwargs)
+ except Exception as error:
+ outcome = (
+ 'deferred'
+ if type(error).__name__
</file context>
Add
omi_delivery_outcome_total{kind,outcome}at durable summary terminals, sync callback returns and action-item export boundaries. Labels use only the fixed kindssummary|sync|action_item_exportand outcomesdelivered|no_op|deferred|failed; unknown values are rejected before creating metric children. Outcomes use the shared closed enum and reason-label adapter without adding debt or allowlist exceptions.Summary observations emit after the existing transaction commits, once across retries, without changing existing first-summary receipts or business state. An open summary obligation is deferred; deliberately waived short-clip debt stays no-op. Sync holds, absent/redirected/open targets and fences are deferred; discarded results remain no-ops even if old summary text is retained. Deferred/locked processing results cannot become delivered. Export counters observe each public result without changing return values or provider calls; a device enqueue is deferred. The counters measure attempts, including retries, rather than unique deliveries. Helpers keep the existing oversized owner files from growing.
The no-op alarm remains unarmed. Infracost records serving release identities, traffic and visible counters, then collects seven full clean days per kind and service after all serving traffic runs the new code. Only then may a separate monitoring change propose a minimum-volume six-hour no-op ratio threshold from the baseline. First baseline progress decision is due within three days of deploy; it cannot shorten the seven-day hold. No alert rule or production action is part of this PR.
Both GMP keep-lists retain delivery/People counters, all existing metric families,
omi_firestore_billed_reads_by_*andomi_fsr_leader_lease_total. The inventory refresh uses ro-prod aggregate metric names, keeps observed names distinct from declarations and preserves admission holds and legacy debt. No production account data is read. Metrics ship on; lead-owned rollback is a later code-revert train. No savings are booked for this instrumentation.Validation: 1,086 unique unit cases passed across 20 selected files over the implementation. After R1's two classification findings, all 113 focused debt/transaction/sync/parity cases and 29 hermetic E2E cases passed again. Integration with the merged B/C main line then passed 241 combined unit cases, 29 E2E cases and monitoring lint. The label-contract/audio selection passed all 149 cases (36 delivery, 19 enum contract, 94 audio-outbox); the old CI worker's nonzero audio status did not reproduce locally. Targeted types report zero errors. All tests ran through
bin/omi-heavy run -- nice -n 19; units usebackend/test.sh, explicit file lists and four workers. Tests cover committed-only emission through retries, debt preparation/waivers, discard precedence, deferred/locked results, bounded labels, canonical/legacy parity, export results and both GMP profiles. Malformed observations preserve business results. The oversized owners retain their exact original line counts (4652 and 3965), with no exception.Main through
1708dc7859b0(including merged #24413/#24422) is integrated. The three GMP/inventory conflicts were resolved from the full incoming main configuration, preserving every existing family and admission/legacy-debt metadata. The fresh aggregate inventory contains 2,280 observed names and 17 declarations. Final CI and delta review remain required.Product invariants affected
none
Initiative: unit-economics
ANX: card:ic-reads-1102