Skip to content

codex-auth-refresh: write CODEX_AUTH_JSON as a repo secret, not env-scoped - #514

Merged
max-sixty merged 1 commit into
mainfrom
fix-codex-auth-repo-scope
May 15, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix-codex-auth-repo-scope

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

#513 over-reached: while correctly moving CLOUDFLARE_API_TOKEN to the cloudflare-deploy environment, it also changed the codex refresher's gh secret set to --repo "$REPO" --env codex-auth-refresh, scoping CODEX_AUTH_JSON into the codex-auth-refresh environment.

CODEX_AUTH_JSON is the runtime Codex auth that every consumer workflow reads (tend-review, tend-mention, tend-triage, tend-nightly, tend-review-runs). None of them declare environment: codex-auth-refresh, so ${{ secrets.CODEX_AUTH_JSON }} resolved to an empty string and the codex action failed its auth preflight (No Codex auth configured) on every consumer run. Verified on a workflow_dispatch of tend-review-runs against the codex-harness branch.

Only CODEX_REFRESH_PAT (the secrets-write credential) should be env-scoped. This drops the --env flag so the refresher writes CODEX_AUTH_JSON back at repo scope, and adds a comment so it doesn't regress. The job keeps environment: codex-auth-refresh to read the env-scoped PAT — env-scoped jobs still see repo secrets, so it reads/writes CODEX_AUTH_JSON at repo scope.

The worker-deploy → cloudflare-deploy parts of #513 are correct and untouched.

Test plan

  • Pre-commit + actionlint pass (verified locally)
  • After merge: trigger codex-auth-refresh — it reads the still-env-scoped valid token, writes a repo-level CODEX_AUTH_JSON
  • Confirm CODEX_AUTH_JSON appears as a repo secret
  • Delete the now-redundant env-scoped CODEX_AUTH_JSON
  • Re-run tend-review-runs on the codex branch — codex authenticates

…coped

#513 changed the refresher's `gh secret set` to `--env
codex-auth-refresh`, scoping CODEX_AUTH_JSON to that environment.
But CODEX_AUTH_JSON is the runtime auth every consumer workflow
reads (review, mention, triage, nightly, review-runs); none of them
declare that environment, so `${{ secrets.CODEX_AUTH_JSON }}`
resolved to empty and codex failed its auth check on every consumer
run.

Only CODEX_REFRESH_PAT (the secrets-write credential) should be
env-scoped. CODEX_AUTH_JSON must be a repo secret. Drop the `--env`
flag and add a comment so it doesn't get re-scoped.

The job keeps `environment: codex-auth-refresh` to read the
env-scoped PAT; it reads CODEX_AUTH_JSON from repo scope (env-scoped
jobs still see repo secrets) and writes it back at repo scope.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit fba319e into main May 15, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix-codex-auth-repo-scope branch May 15, 2026 22:41
max-sixty added a commit that referenced this pull request May 16, 2026
## Summary

Flips tend's own CI from the Claude harness to the Codex harness by
setting `harness: codex` in `.config/tend.yaml` and regenerating the
eight `tend-*.yaml` workflows. Each now invokes
`max-sixty/tend/[email protected]` with `CODEX_AUTH_JSON` instead of
`max-sixty/tend@<v>` with `CLAUDE_CODE_OAUTH_TOKEN`.

Motivation is cost: API billing scales per token; a flat-rate ChatGPT
subscription funds unlimited runs. tend dogfoods its own setup, so it
should run the harness we recommend for cost-sensitive adopters.

The net diff is small — config (+ `harness: codex`, + `secrets.allowed:
[CODEX_AUTH_JSON]`) and the regenerated workflow files (action ref, auth
secret, model, skill-invocation syntax). Supporting infrastructure
landed separately on main:

- `codex-auth-refresh.yaml` + env-scoped `CODEX_REFRESH_PAT` rotation
(#500, #510)
- `CODEX_AUTH_JSON` as a repo secret, refresher writes it back at repo
scope (#514)
- Codex-on-GHA fixes, all in release 0.0.22: sandbox
`danger-full-access` (#519), npm prebuilt install (#522), base64
`final_message` capture (#525)

## Validation

The original "do not merge until…" prerequisite is **satisfied**:

- `tend-review-runs` `workflow_dispatch` on this branch (pinned
`[email protected]`) ran **green end-to-end** — codex authenticated,
installed via npm, ran without the `bwrap` block, executed the full
agent (real review-runs work: posted evidence to the tracking issue,
commented on the outage issue), and the action exited 0.
- Deterministic CI (`test`, `test-worker`, `lint`) green; `tend-review`
(Claude harness via `pull_request_target`) approved.

Each codex blocker found during stabilization was fixed and released:
auth scoping → sandbox → install → output framing. The smoke test going
green on 0.0.22 confirms convergence.

## Post-merge follow-up

Watch the first unattended nightly `codex-auth-refresh` cron (`17 3 * *
*`) succeed. Manual dispatches (incl. the post-#514 recovery) have all
succeeded; this just confirms the scheduled path runs without a human.
Failure degrades gracefully over the ~8-day refresh window, with manual
rotation as fallback.

---------

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 16, 2026
## Summary

Flips tend's own CI from the Claude harness to the Codex harness by
setting `harness: codex` in `.config/tend.yaml` and regenerating the
eight `tend-*.yaml` workflows. Each now invokes
`max-sixty/tend/[email protected]` with `CODEX_AUTH_JSON` instead of
`max-sixty/tend@<v>` with `CLAUDE_CODE_OAUTH_TOKEN`.

Motivation is cost: API billing scales per token; a flat-rate ChatGPT
subscription funds unlimited runs. tend dogfoods its own setup, so it
should run the harness we recommend for cost-sensitive adopters.

The net diff is small — config (+ `harness: codex`, + `secrets.allowed:
[CODEX_AUTH_JSON]`) and the regenerated workflow files (action ref, auth
secret, model, skill-invocation syntax). Supporting infrastructure
landed separately on main:

- `codex-auth-refresh.yaml` + env-scoped `CODEX_REFRESH_PAT` rotation
(#500, #510)
- `CODEX_AUTH_JSON` as a repo secret, refresher writes it back at repo
scope (#514)
- Codex-on-GHA fixes, all in release 0.0.22: sandbox
`danger-full-access` (#519), npm prebuilt install (#522), base64
`final_message` capture (#525)

## Validation

The original "do not merge until…" prerequisite is **satisfied**:

- `tend-review-runs` `workflow_dispatch` on this branch (pinned
`[email protected]`) ran **green end-to-end** — codex authenticated,
installed via npm, ran without the `bwrap` block, executed the full
agent (real review-runs work: posted evidence to the tracking issue,
commented on the outage issue), and the action exited 0.
- Deterministic CI (`test`, `test-worker`, `lint`) green; `tend-review`
(Claude harness via `pull_request_target`) approved.

Each codex blocker found during stabilization was fixed and released:
auth scoping → sandbox → install → output framing. The smoke test going
green on 0.0.22 confirms convergence.

## Post-merge follow-up

Watch the first unattended nightly `codex-auth-refresh` cron (`17 3 * *
*`) succeed. Manual dispatches (incl. the post-#514 recovery) have all
succeeded; this just confirms the scheduled path runs without a human.
Failure degrades gracefully over the ~8-day refresh window, with manual
rotation as fallback.

---------

Co-authored-by: Claude <[email protected]>
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.

2 participants