repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Prove Codex CI review on the subscription (p37 harness) (#33)

20469b78727242a669088bfa1103e1f7c72d5a64

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

## What forced this
You chose Codex at both depths. The CI-reviewer depth can't be trusted
until its subscription auth in CI is proven — the same discipline p35
applied to Claude, since a metered OpenAI key is off the table.

## The call
A disposable harness (`p37`) that installs the Codex CLI + the official
`openai/codex-action@v1`, restores the ChatGPT `auth.json` from a
secret, and runs a trivial `codex exec` — every step
`continue-on-error`, so the run's log is the evidence.

## What we deliberately didn't do
Didn't wire `adw-codex-review.yml` yet — this prices and proves the path
first. It also does not touch the merge-gate (Codex review stays
advisory, per PR #31).

## Evidence
OpenAI's docs already surface two costs: `auth.json` goes stale ~every 8
days (a standing refresh burden), and headless runs share the ChatGPT
plan's 5-hour window (a per-PR reviewer competes with your own Codex
use). The harness confirms install + pins the exact auth requirement;
the auth half needs the `CODEX_AUTH_JSON` secret.

## Surface touched
`prototypes/p37-codex-review/` +
`.github/workflows/p37-codex-harness.yml`.

## If this ages badly
Delete the prototype and ship the contributor path only (#32); nothing
depends on it.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01LABEHeVpg74oyZNtWLUWpB)_

---------

Co-authored-by: Claude <noreply@anthropic.com>

Changed files (2)

+133 / −0 text lines

Diff layout

.github/workflows/p37-codex-harness.yml

Added
new file mode 100644

+76 / −0 text lines

1# p37 — prove Codex can run in CI on the ChatGPT *subscription* (no metered
2# OpenAI API key), the way p35 proved Claude's runner. Disposable evidence
3# (SPEC §18): push-triggered on this branch, path-scoped, every step
4# continue-on-error so the run always completes and the logs ARE the evidence —
5# a wrong flag or a missing-auth error is the finding, exactly like p35.
6name: p37-codex-harness
7
8on:
9 push:
10 branches: ["claude/**"]
11 paths:
12 - "prototypes/p37-codex-review/**"
13 - ".github/workflows/p37-codex-harness.yml"
14 workflow_dispatch: {}
16permissions:
17 contents: read
19jobs:
20 probe:
21 runs-on: ubuntu-latest
22 steps:
23 - uses: actions/checkout@v4
25 - name: Install the Codex CLI
26 continue-on-error: true
27 run: |
28 npm install -g @openai/codex
29 codex --version || echo "::warning::codex --version failed"
31 # Subscription auth: restore the ChatGPT-login auth.json from a secret.
32 # NB it goes stale ~every 8 days, so production would refresh + persist it.
33 - name: Restore ChatGPT subscription auth
34 continue-on-error: true
35 env:
36 CODEX_AUTH_JSON: ${{ secrets.CODEX_AUTH_JSON }}
37 run: |
38 mkdir -p "$HOME/.codex"
39 if [ -n "$CODEX_AUTH_JSON" ]; then
40 printf '%s' "$CODEX_AUTH_JSON" > "$HOME/.codex/auth.json"
41 echo "auth.json restored ($(wc -c < "$HOME/.codex/auth.json") bytes)"
42 else
43 echo "::warning::CODEX_AUTH_JSON secret absent — the exec below reveals the auth requirement (that IS the evidence)"
44 fi
46 - name: Codex exec — capture the JSONL stream
47 continue-on-error: true
48 run: |
49 set +e
50 codex exec --json --ephemeral "Reply with exactly: CODEX-HARNESS-OK" \
51 > codex.jsonl 2> codex.err
52 echo "codex exec exit=$?"
53 echo "::group::raw JSONL (last 80 lines)"; tail -80 codex.jsonl 2>/dev/null; echo "::endgroup::"
54 echo "::group::stderr"; cat codex.err 2>/dev/null; echo "::endgroup::"
56 # The number that should drive the cadence: which model ran, how many tokens
57 # one review costs, and how much of the 5-hour window it burned. Schema-agnostic
58 # jq (recursive descent) so it survives Codex's exact event shape; a grep
59 # fallback surfaces anything jq misses.
60 - name: Report model, token cost, and 5-hour window usage
61 continue-on-error: true
62 run: |
63 echo "### resolved model"
64 jq -rs '[.. | objects | (.model? // empty)] | map(select(. != "")) | last // "not found in stream"' codex.jsonl 2>/dev/null || echo "n/a"
65 echo "### token usage (this one review)"
66 jq -c '.. | objects | select(has("usage") or has("input_tokens") or has("total_tokens") or has("token_count"))' codex.jsonl 2>/dev/null | tail -3 || echo "n/a"
67 echo "### rate limits / 5-hour window cost"
68 jq -c '.. | objects | select(has("rate_limits") or has("used_percent") or has("primary_used_percent") or has("resets_in_seconds") or has("window_minutes"))' codex.jsonl 2>/dev/null | tail -5 || echo "n/a"
69 echo "### keyword fallback (raw)"
70 grep -ioE '"[a-z_]*(rate_limit|used_percent|resets|window|remaining|quota|tokens?)[a-z_]*"[^,}]*' codex.jsonl codex.err 2>/dev/null | sort -u | head -40 || echo "(no quota/token keywords surfaced)"
72 - name: Official action — the production path
73 continue-on-error: true
74 uses: openai/codex-action@v1
75 with:
76 prompt: "Reply with exactly: CODEX-HARNESS-OK"

prototypes/p37-codex-review/PLAN.md

Added
new file mode 100644

+57 / −0 text lines

1# p37 — Codex as a CI reviewer on the ChatGPT subscription
2
3Proves the mechanics the **cross-family CI reviewer** rides on (AGENTIC-DEVELOPMENT
4→ *Cross-family review*), which no local check can settle: can Codex run inside
5GitHub Actions authenticated by the owner's **ChatGPT subscription** — not a
6metered OpenAI API key — and post a review? Mirrors p35's proof for Claude.
7
8The harness is `.github/workflows/p37-codex-harness.yml`, push-triggered on this
9branch and path-scoped. Every step is `continue-on-error`, so the run completes and
10the logs are the evidence — a missing-auth or wrong-flag error *is* the finding.
12## Status
13blocked — needs the owner secret to complete the auth half (install/invocation
14half provable now)
16## Proved (from OpenAI's docs, to be confirmed by the run)
17- There is an official **`openai/codex-action@v1`** (the Codex analog of
18 `claude-code-action`) that installs the CLI and runs `codex exec`.
19- Non-interactive form is `codex exec --json --ephemeral` (JSONL to stdout, no
20 session files) — suitable for a CI reviewer.
21- Subscription auth in CI **is** possible: restore the ChatGPT-login `auth.json`
22 from a secret before the run.
24## Disproved / cautions (the two costs that shape the decision)
25- **`auth.json` goes stale ~every 8 days.** A CI reviewer would need the secret
26 refreshed and persisted back on a cadence — a standing maintenance burden that
27 cuts against "autonomous with near-zero owner input."
28- **Headless runs draw from the ChatGPT plan's shared 5-hour rolling window.** A
29 reviewer firing on every PR competes with the owner's own interactive Codex use
30 and can exhaust it. This is the load-bearing reason to keep Codex review
31 **advisory and rate-limited**, and the contributor path (Codex opens PRs the ADW
32 reviews) more attractive since it doesn't add per-PR CI cost.
34## Spec Issues
35- None against `docs/SPEC.md` (this validates the ADW's cross-family-review plan).
37## Prototype Artifacts
38- `.github/workflows/p37-codex-harness.yml`
39- `prototypes/p37-codex-review/PLAN.md`
41## Commands
42- Push this branch (or `workflow_dispatch`) to run the harness; read the run log.
43- Owner precondition for the auth half: `codex login` locally, then add the
44 contents of `~/.codex/auth.json` as the repo secret **`CODEX_AUTH_JSON`**.
45- The harness prints, per single review: the **resolved model**, the **token
46 usage**, and the **5-hour-window cost** (rate-limit `used_percent` / reset), so
47 the owner can price a cadence before wiring `adw-codex-review.yml`.
49## Next Steps
50- Owner: add `CODEX_AUTH_JSON` and re-run to confirm `codex exec` returns
51 `CODEX-HARNESS-OK` on subscription auth, and which of the CLI vs
52 `openai/codex-action@v1` path is cleaner.
53- If it passes and the owner accepts the refresh + shared-window costs, add
54 `adw-codex-review.yml` (advisory, on `pull_request`, rate-limited), feeding the
55 reviewers per PR #31 — never a gate label.
56- If the costs aren't worth it, ship the **contributor** path only (issue #32) and
57 delete this prototype. Disposable evidence (SPEC §18).