Skip to content

gcp-sa-key-ratchet breaks manifest resolution for every PR, and has never passed its own baseline #12182

Closed

Description

@aryanorastar

gcp-sa-key-ratchet landed in #11125 with two defects that compound. The first hides the second, and fixing only the first makes things worse, so I am reporting both together rather than sending a one-line patch.

This is my own merged PR. It went in green because neither defect can fire until the check is actually reachable, and it was not.

Defect 1 — dead trigger paths break manifest resolution for every PR

The check declares two trigger paths that do not exist in the repo:

backend/agent-proxy/main.py
backend/agent-proxy/Dockerfile

run_checks.py:187 existence-checks any trigger pattern without glob magic and fails the entire resolution when one is missing:

elif pattern != "all" and not glob.has_magic(pattern) and not (root / pattern).exists():
    errors.append(f"{check.id}: explicit trigger path does not exist: {pattern}")

Resolution happens before any check runs, so this does not fail the GCP ratchet — it fails every consumer of the manifest. Observed on #12181, which touches three desktop Swift files and no backend at all:

FAIL: could not resolve manifest checks: gcp-sa-key-ratchet: explicit trigger path does not exist: backend/agent-proxy/main.py; gcp-sa-key-ratchet: explicit trigger path does not exist: backend/agent-proxy/Dockerfile

It took out Detect Desktop Swift Changes, Desktop Swift Build & Tests, Hygiene, and PR Metadata Preflight.

Reproduces on pristine main, no branch involved:

git archive origin/main | tar -x -C /tmp/mainmanifest
cd /tmp/mainmanifest && git init -q . && git add -A && git commit -qm base
python3 .github/scripts/run_checks.py --lane ci --list

A full audit of the manifest found these are the only two broken explicit triggers out of 152 checks.

Defect 2 — the ratchet has never passed against its own baseline

Defect 1 masks this completely: the check cannot run, so nobody saw that it does not pass. Collapsing the dead paths into backend/agent-proxy/** makes resolution succeed, the ratchet finally executes, and it fails:

backend/database/google_credentials.py:service-account-json-env: found 6, baseline allows 1
.github/workflows/desktop_qualify_beta.yml:credentials-json-gh-action: baseline still allows 1 but tree only has 0; shrink the baseline in this change
backend/agent-proxy/main.py:google-application-credentials-env: baseline still allows 1 but tree only has 0
backend/charts/agent-proxy/prod_omi_agent_proxy_values.yaml:google-credentials-json: baseline still allows 1 but tree only has 0
backend/utils/other/storage.py:service-account-json-env: baseline still allows 2 but tree only has 0
... 13 findings total

This also reproduces on pristine main — run python3 .github/scripts/check_gcp_sa_key_ratchet.py in the extracted tree above. So the baseline was never in agreement with the tree it shipped against.

Most entries are stale-shrink (baseline allows N, tree has 0), including several for backend/agent-proxy/* — paths that do not exist, which is the same root cause as defect 1: the baseline was generated against a tree containing an agent-proxy directory this repo does not have.

One is not a shrink. backend/database/google_credentials.py:service-account-json-env reports found 6, baseline allows 1, against a file main has not modified. That is the ratchet's real failure mode — new key paths — firing on pre-existing code, which means the cap was wrong when it was written rather than something having regressed since.

Why I have not sent a patch

I have the defect-1 fix ready (backend/agent-proxy/** in place of the two dead paths — the same run_checks.py:187 exempts globs from the existence check, so it preserves the coverage that deleting the paths would drop). I am holding it, because landing it alone converts a broken-manifest error into a red security check on every PR, which reads as a real credential finding and is worse than the current state.

Defect 2 cannot be fixed with the tool. --write-baseline "never raises existing caps" and explicitly refuses to add keys or raise counts:

FAIL: --write-baseline refuses to raise counts:

So found 6, allows 1 has exactly two honest resolutions, and both belong to someone who owns this area:

  1. Remove the key paths from backend/database/google_credentials.py — a real backend change toward ADC / Workload Identity, which is the ratchet's stated purpose.
  2. Correct the baseline by hand with security review, on the finding that the original cap was miscounted.

I am not going to edit a GCP service-account-key baseline unilaterally, and I do not think a contributor should.

Suggested ordering

Reverting #11125 from main restores green immediately and costs nothing that is currently working — the check has never run, so nothing is being protected by it today. It can then be re-landed with a baseline generated against this tree and with backend/agent-proxy/** as the trigger. Happy to do the revert and the re-land if that is the call, but the baseline decision needs an owner.

Meanwhile every open PR goes red as soon as it pushes or merges main. Only #12181 shows it so far, because it is the only one whose checks have run since #11125 landed.

cc @kodjima33 @Git-on-my-level @undivisible

Activity

  1. aryanorastar commented on Aug 25, 2026

    @aryanorastar
    CollaboratorAuthor

    Revert is up as #12183, per the suggested ordering above.

    It backs out the check, the baseline, the tests, and both manifest entries — 4 files, deletions only — and keeps the Backend_Setup.mdx change verbatim. That doc fix replaces cp ~/.config/gcloud/application_default_credentials.json ./google-credentials.json with ADC guidance and an explicit "do not copy a service-account JSON key into the repo". It has no CI dependency, and reverting it would put the copy-a-key-into-the-repo instructions back in the setup guide, which is the opposite of what #6800 is for.

    Verified on the revert branch: 0 broken explicit trigger paths, 0 missing command paths, 150 checks (was 152), 0 duplicate ids, 0 remaining references to gcp_sa_key_ratchet anywhere in the tree. scripts/pr-preflight passes 102 checks — up from 22 on a branch cut before the revert, because the manifest resolving again makes the previously-unreachable checks run.

    The baseline question is unchanged and still needs an owner. Whoever re-lands this wants a baseline generated against the current tree and backend/agent-proxy/** as the trigger, plus a decision on google_credentials.py:service-account-json-env reporting found 6 against a cap of 1. I'm happy to do the re-land once that call is made.

  2. aryanorastar commented on Sep 4, 2026

    @aryanorastar
    CollaboratorAuthor

    Resolved by
    #12183
    — the ratchet is out of the manifest, so neither defect is reachable. The setup-doc fix it carried was kept. Closing.

  3. moved this from Someday to In review in omi TODO / bountieson Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions