Skip to content

ci: add failure-class diagnostics to candidate acceptance runner - #14525

Merged
Git-on-my-level merged 6 commits into
BasedHardware:mainfrom
Git-on-my-level:ci/candidate-mint-diagnostics
Sep 18, 2026
Merged

Git-on-my-level merged 6 commits into
BasedHardware:mainfrom
Git-on-my-level:ci/candidate-mint-diagnostics

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

ci: add failure-class diagnostics to candidate acceptance runner

Context

Slice-2 WIF re-land (ci/slice2-wif-reland, bake run 35309620748) failed the
desktop/backend candidate gate on contract what_matters_now three times.
Manual replays of the same probe from the coordinator session returned HTTP
200, but the acceptance runner (backend/scripts/run_dev_candidate_acceptance.py)
swallows the failure stage and HTTP status by design, so the CI failures were
undiagnosable from logs. Evidence: KB record
2026-09-18-slice2-wif-blocked.md (omi-knowledge-base).

What this PR adds

Bounded, failure-class-only diagnostics on the existing runner:

  1. Mint stage (mint_cloud_run_identity_token): on failure (nonzero rc,
    empty token, or token length > 8192) the raised error carries
    {'stage': 'mint', 'rc': <int>, 'class': <enum>} where class is one of
    auth_no_credentials, federated_token_error, timeout,
    token_oversized, unknown.
  2. Probe stage (run_check): on a nonzero child exit, the outcome carries
    {'stage': 'probe', 'service': <service>, 'http_status': <int|None>, 'class': <enum>} where class is one of http_failure, timeout,
    conn_error (connection-level exception, http_status: None), unknown.
    The status integer is parsed from the bounded received HTTP <n> marker
    the smoke scripts already print on failure; no new surface is scraped.
  3. Artifact: each failed check in the acceptance JSON evidence gains a
    diagnostics object with the fields above.

Sanitization preserved

The runner's docstring promises hold: candidate URLs, identity tokens, request
data, and subprocess output never enter the report or workflow logs. The new
diagnostics carry only the stage name, an integer rc/HTTP status, a service
name, and a class enum — raw stderr, token material, and URLs are never
attached, and tests assert non-leakage explicitly.

Backward-compatible artifact schema

schema_version stays 1; the checks/status schema is unchanged. The
diagnostics key is additive and appears only on failed checks — passing runs
emit exactly the prior shape (guarded by test).

Tests

backend/tests/unit/test_run_dev_candidate_acceptance.py (extended):
mint failure classes incl. non-leakage assertions; probe non-2xx status
capture and conn_error classification; schema backward-compat (passing run
has no diagnostics key); oversized token counts as failure with class
token_oversized.

All 16 tests green (9 in this file + 7 in test_smoke_what_matters_now.py),
run with the pinned 3.11 interpreter via
PATH="/tmp/py311bin:$PATH" backend/.venv/bin/python3 -m pytest.

Review in cubic

@Git-on-my-level
Git-on-my-level merged commit 0412125 into BasedHardware:main Sep 18, 2026
36 checks passed
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
… diagnostics) (#14541)

## Failure-Class
Failure-Class: FC-fixture-mock-signature-drift

## Summary
Reverts #14509: `gcp_backend_auto_dev` returns to the JSON bridge secret
after three consecutive bake failures at the candidate gate
(`what_matters_now` FAIL, sub-second gate duration, others NOT_RUN).
Committed per the PR's own rollback contract. Traffic safety held all
three attempts: candidates stayed 0%, serving never moved
(`backend-8a5c388-35307543774-1`=100%).

## Evidence (three attempts)
1. Attempt 1 (35309620748#1, 05:35Z): gate FAIL 981ms after probe
invocation.
2. Attempt 2 (#2, 05:56Z): identical FAIL.
3. Attempt 3 (#3, 06:54Z): identical FAIL — **after**
`roles/run.invoker` (verified live) AND a self
`serviceAccountTokenCreator` grant on the deployer.
Manual control, same window: coordinator replayed the exact probe
(deployer identity token via impersonation, audience = service URL,
ADMIN_KEY+uid auth, X-Serverless-Authorization) against the candidate
URL → **HTTP 200** at 05:38Z and again post-attempt-3. Discriminator:
manual mint uses human impersonation; the CI mint (`gcloud auth
print-identity-token` with no impersonation flag) runs in a
WIF-federated session — the remaining untested variable. The acceptance
runner intentionally swallows the failure stage/HTTP status (981ms gate
≈ mint-stage failure, not a service round-trip), so the next slice needs
the mint step instrumented or a one-off diagnostic run before
re-landing.

## What this revert does NOT do
- Does not touch #14516 (JSON-free desktop-backend probe — baked green
on main).
- Does not change any IAM grant; the deployer's role set stays as
audited.
- Auto-dev auth returns to `secrets.GCP_CREDENTIALS` (bridge key
`a3dd0875`), the exact pre-#14509 state.

## Next slice (before any re-land)
1. Add a bounded diagnostic to the mint step (or a dispatch-only probe
workflow) that prints the mint subprocess return code class + HTTP
status of the candidate call — no token material.
2. Reproduce the federated mint locally (`gcloud auth login
--update-adc` federated → `print-identity-token` without impersonation)
or via a one-off CI run with the diagnostic.
3. Re-land #14509 content once the mint path is proven green in CI.

## Product invariants affected

- INV-DATA-1

Preserved: this revert only changes the deploy authentication identity
of the development lane back to the pre-#14509 JSON bridge (no routing
authority, endpoint, or project binding changes; `based-hardware-dev`
target unchanged; fail-closed traffic gate unchanged).

## v2 note (diagnostics landed first)

This re-land follows #14525: the candidate acceptance runner now records
failure-class diagnostics (mint rc/class, probe HTTP status) in the
acceptance artifact. If this re-land's bake fails again, the artifact
names the exact stage and class — no more blind attempts. Rollback
contract unchanged: gate FAIL keeps traffic on the prior revision.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/14541?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="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…nostics (#14557)

## Failure-Class
Failure-Class: FC-acceptance-probe-unreachable-by-own-ingress-policy

## Summary
Follow-up to #14525's diagnostics, informed by the first diagnostic bake
(35330545334): the candidate gate failed with `class=conn_error,
http_status=null` — the probe subprocess could not reach the candidate
URL at all (not a 401, not a mint failure). This PR splits the coarse
`conn_error` into actionable sub-classes (refused / DNS / reset / TLS /
unreachable) so the next red bake names the network layer precisely.

Existing test suite green; classification-only change, no behavior
change to pass/fail semantics.

## Product invariants affected

- INV-DATA-1

Preserved: diagnostics-only; no routing, endpoint, or project-binding
change; sanitization guarantees unchanged (classes only, no stderr text
or tokens).


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/14557?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="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Sep 18, 2026
…ptance (slice-2 root-cause fix) (#14564)

## Failure-Class
Failure-Class: FC-fixture-mock-signature-drift

## Summary
Root-cause fix for the slice-2 WIF candidate-gate failures. The
#14525/#14557 diagnostics finally named it: **`stage=mint, rc=1`** —
`gcloud auth print-identity-token` cannot mint under a WIF-federated
session because the federated credential holds **no private key** for
the self-signing mint (bake 35340203517 artifact; manual
impersonation-based replays succeeded, which is why every manual control
passed while CI failed).

## Fix
- `run_dev_candidate_acceptance.py`: `mint_cloud_run_identity_token`
gains `--impersonate-service-account` support; new `--mint-impersonate`
CLI flag (env fallback `CLOUD_RUN_IDENTITY_MINT_IMPERSONATE`).
Impersonated mint routes through the IAM `signJwt` API, which the
federated credential CAN call when it holds
`roles/iam.serviceAccountTokenCreator` on the target SA (already
granted: audit-verified 2026-09-16, KB evidence
2026-09-18-iam-grants-and-rows-2-3).
- `deploy-backend-stack/action.yml`: passes `--mint-impersonate ${{
inputs.workload_identity_service_account }}` only when WIF auth is in
play — JSON lane behavior byte-identical.

## Test plan
- Unit suite 9/9 (two fixtures updated for the new kwarg — the very
failure class registered in #14528)
- Behavioral proof: impersonation flag flows into the gcloud command
- JSON lane: flag absent → command unchanged → deploy lanes on
`gcp_backend.yml`/desktop unaffected
- Success signature on the next WIF bake: `Candidate acceptance PASS`
×4, then traffic shift

## Product invariants affected

- INV-DATA-1

Preserved: diagnostics/authentication-only; no routing authority,
endpoint, or project-binding change; JSON lanes untouched.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/14564?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="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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