feat(wizard-ci): mint and cache the gateway token for local e2e runs - #4191
Closed
johncwaters wants to merge 1 commit into
Closed
johncwaters wants to merge 1 commit into
johncwaters wants to merge 1 commit into
Conversation
A local `pnpm wizard-ci <app> --e2e` needed a hand-copied gateway token. It now mints one through the wizard's `mint-gateway-token` script (one browser login) and caches it per program, region and project under ~/.config/posthog, reusing it until its refresh time. CI is unchanged: an explicitly supplied WIZARD_CI_GATEWAY_TOKEN_FILE with no sidecar is used as-is, and with CI set a missing or unusable token fails instead of opening a browser. A cached token is reused only when its sidecar's hash matches the token and its gateway URL is the region's gateway or the configured override, and each run hands the harness a private 0600 copy it deletes afterwards, so a concurrent run cannot swap the bearer mid-run. Directive: needs the companion wizard change for local minting; without it the run fails with a message naming the missing script Confidence: medium Scope-risk: narrow Not-tested: the last review round's fix (per-run token snapshot) had no review after it; exercised by live cached-reuse and CI-path e2e runs Not-tested: test:gateway-token is not in checks.yml; the push token lacks workflow scope
johncwaters
marked this pull request as ready for review
September 24, 2026 18:09
johncwaters
marked this pull request as draft
September 24, 2026 18:35
Contributor
Author
|
Closing along with PostHog/wizard#1355: we won't ship a public gateway-token mint. Local e2e keeps using an issued token in WIZARD_CI_GATEWAY_TOKEN_FILE, as main and CI already do. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Feedback wanted: ready to merge. Approve or request changes.
~/.config/posthogthe right default, or should local runs keep supplyingWIZARD_CI_GATEWAY_TOKEN_FILEby hand?A local
pnpm wizard-ci <app> --e2eneeds an AI gateway token, and the only way to get one was copying CI's. This makes the local path one browser login, then cached runs, which is as close to agent-friendly as the gateway allows today (the mint endpoint only accepts a wizard-app OAuth token;phs_andphx_keys are refused).Companion PR: PostHog/wizard#1355, which adds the mint script this calls. Merge it first; without it a local run fails with a message naming the missing script.
Changes
services/gateway-token/:ensureGatewayTokenreuses a cached token until its refresh time, and otherwise runs the wizard'smint-gateway-token(browser login). The cache is keyed by program, region and project.WIZARD_CI_GATEWAY_TOKEN_FILEwith no sidecar is used as-is, and withCIset an unusable token fails instead of opening a browser.WIZARD_CI_GATEWAY_URL).0600copy of the token and deletes it afterwards, so a concurrent run cannot swap the bearer mid-run.e2e.ts: resolves the program once for both the token and the harness, finds the wizard checkout the same way for minting and running, and never overwrites an explicitWIZARD_CI_GATEWAY_URL.pnpm gateway-tokento mint or refresh by hand;.env.exampleexplains leaving the token file unset locally.How did you test this code?
pnpm test:gateway-token(18 tests),test:source-app,test:feature-flag-checks,test:warehouse-checksandtsc --noEmitpass.~/.config/posthog/wizard-gateway-token-posthog-integration-us-483112and its sidecar, both0600, hash matching.basic-integration/django/django3-saas --e2e): no browser, cache file untouched, agent run completed through the gateway.CI=true, sidecarless token file,basic-integration/next-js/15-app-router-saas --e2e): no mint, no sidecar written, agent run completed.$TMPDIRafterwards.full interactive flow reached keep-skillsandskillsComplete. That is unrelated: wizard main's result JSON records a screen path ending atoutro, although the captured frames reachkeep-skills.test:gateway-tokenis not added tochecks.yml, because the push token lacks theworkflowscope.LLM context
Written with Claude Code; security review also by Codex (gpt-6-astra).