Skip to content

codex: add nightly refresh workflow and document rotation hazard - #500

Merged
max-sixty merged 2 commits into
mainfrom
codex-auth-refresh-improvements
May 15, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex-auth-refresh-improvements

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Two related changes that improve Codex CI support without flipping the harness for tend itself:

  1. codex-auth-refresh.yaml — a scheduled workflow that POSTs the current refresh token to https://auth.openai.com/oauth/token and updates the CODEX_AUTH_JSON secret nightly. Decouples refresh from consumer workflows so concurrent mention/review/triage/ci-fix runs never trigger a rotation. Requires a CODEX_REFRESH_PAT secret (fine-grained PAT, secrets: read and write).
  2. Doc updates — plugins/install-tend/skills/install-tend/SKILL.md and docs/security-model.md previously framed rotation as a calendar task ("rotate every ~7 days"). The real failure mode is more subtle: Codex rotates the refresh token on use, the rotated value lands in an ephemeral runner, the GitHub secret holds the invalidated value, and after ~8 days concurrent consumer workflows 401 permanently. OpenAI's CI/CD auth guide warns explicitly against sharing auth.json across concurrent jobs. Both docs now spell out the failure mode and offer two paths (manual rotation, automated refresher).

Cutover of tend's own CI to harness: codex is parked on a separate branch (cutover-to-codex) until the refresher proves out.

Test plan

  • Pre-commit + actionlint pass locally (verified before push)
  • After merge: mint CODEX_REFRESH_PAT (fine-grained PAT on max-sixty/tend, secrets: read and write), store as repo secret
  • Trigger codex-auth-refresh.yaml via workflow_dispatch and verify last_refresh updates on the CODEX_AUTH_JSON secret
  • Watch the nightly cron firing for a few days; confirm the refresher self-sustains

max-sixty and others added 2 commits May 15, 2026 08:34
Refreshes CODEX_AUTH_JSON outside the consumer workflows so concurrent
mention/review/triage/ci-fix runs never trigger a rotation. Each night
the workflow POSTs the current refresh_token to OpenAI's OAuth endpoint,
reconstructs auth.json, and pushes it back via a dedicated PAT
(CODEX_REFRESH_PAT, secrets:write only).

Decoupling refresh from runtime is what makes the static-secret pattern
safe for tend's concurrency model — see
https://developers.openai.com/codex/auth/ci-cd-auth which warns "Do not
share the same file across concurrent jobs or multiple machines."

Co-Authored-By: Claude <[email protected]>
The previous framing said "rotate every ~7 days" without explaining
why or what fails. The reality: Codex rotates the refresh token on
use, the rotated value lands in an ephemeral runner, and the GitHub
secret holds the invalidated value. OpenAI's guide explicitly warns
against sharing auth.json across concurrent jobs.

Rewrite SKILL.md §7b step 3 to list both paths (manual rotation,
automated refresher workflow) and add an operational-rotation section
to security-model.md walking through the day-8 rotation race.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 163fd6c into main May 15, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex-auth-refresh-improvements branch May 15, 2026 15:45
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