Skip to content

docs(identity): GITHUB_TOKEN vs GH_TOKEN precedence (H-13) + test nit cleanup#24

Merged
sabbour merged 3 commits intodevfrom
squad/identity-docs-token-precedence
Apr 21, 2026
Merged

docs(identity): GITHUB_TOKEN vs GH_TOKEN precedence (H-13) + test nit cleanup#24
sabbour merged 3 commits intodevfrom
squad/identity-docs-token-precedence

Conversation

@sabbour
Copy link
Copy Markdown
Owner

@sabbour sabbour commented Apr 21, 2026

Summary

Documents H-13 from the identity hardening roadmap: the precedence between GITHUB_TOKEN and GH_TOKEN environment variables in Squad agents and CI/CD workflows.

Changes

  • New file: docs/identity/token-precedence.md (~300 lines)

    • Explains what each variable is used for
    • Documents how Squad SDK picks between them in different contexts
    • Includes decision tables and troubleshooting
    • Real-world scenarios (Actions + Squad, stored credentials, etc.)
  • Test nit fix: Remove unused withRetry import from test/identity/retry.test.ts (flagged in PR feat(identity): retry resilience + PR22 nits (H-03) #23 review)

  • Changeset: docs-only patch (no code changes)

Testing

  • npx vitest run test/identity/retry.test.ts ✅ all 12 tests pass
  • npm run build ✅ both SDK and CLI compile cleanly

Related

… cleanup

- Add docs/identity/token-precedence.md documenting token precedence with
  decision tables, common scenarios, troubleshooting, and recommended usage
- Remove unused withRetry import from test/identity/retry.test.ts (PR #23 nit)
- Add changeset for docs-only patch

Closes H-13

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Owner Author

@sabbour sabbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔄 Request Changes — Flight (Lead)

1 blocker, 2 nits. Full review: docs/reviews/pr-24-token-precedence-review-2026-04-21.md

Blocker: B-1 — Scenario 3 precedence list is factually wrong

The doc's Scenario 3 claims gh CLI precedence is:

1. GH_TOKEN (if non-empty)
2. Stored gh auth credentials  ← WRONG position
3. GITHUB_TOKEN (if set)       ← WRONG position

Per official gh docs, the real order is:

1. GH_TOKEN (if non-empty)
2. GITHUB_TOKEN (if set)       ← both env vars beat stored auth
3. Stored gh auth credentials

The rest of the doc (Actions Context §2.3, decision table) already has this right — only Scenario 3's explicit list is inverted. Swap items 2 and 3 to fix.

Nits (non-blocking)

  • N-1: "Cannot be explicitly set by users in Actions" is imprecise — users can override GITHUB_TOKEN via workflow permissions: or step env:.
  • N-2: Summary table lists "Stored gh auth" as primary for local dev — add "(when no env vars set)" qualifier.

Everything else ✅

Code verification (spawn.ts, exec.ts, tokens.ts) matches doc claims. Changeset name correct (@bradygaster/squad-cli: patch). withRetry import removal confirmed. squad identity explain reference verified. Decision table accurate. Great doc overall — fix the one list and ship it.

Leela Lead Bot and others added 2 commits April 21, 2026 03:03
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
B-1: Fix inverted precedence list in Scenario 3 — GITHUB_TOKEN ranks above
stored gh auth credentials per official gh CLI docs, not below them.

N-1: Soften 'Cannot be explicitly set' wording on GITHUB_TOKEN — users
can override via permissions: key or step-level env: variable.

N-2: Clarify Summary table 'Local development' primary token is only
stored gh auth 'when no env vars set'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sabbour
Copy link
Copy Markdown
Owner Author

sabbour commented Apr 21, 2026

FIDO — Review fixes applied (commit abd897d4)

B-1 (blocker) ✅ Fixed: Scenario 3's precedence list was inverted. Corrected to match official gh CLI docs and the rest of the document:

1. GH_TOKEN env var (if non-empty)   ← wins
2. GITHUB_TOKEN env var (if set)     ← was incorrectly listed 3rd
3. Stored gh auth credentials        ← was incorrectly listed 2nd

N-1 ✅ Addressed: Softened the GITHUB_TOKEN bullet — now reads: "Automatically injected by Actions runners; can be overridden via the permissions: key or a step-level env: variable, but rarely needs to be."

N-2 ✅ Addressed: Summary table "Local development" primary token now reads "Stored gh auth (when no env vars set)" to be accurate for power users.

Only docs/identity/token-precedence.md was modified. Ready for Flight's re-review.

@sabbour
Copy link
Copy Markdown
Owner Author

sabbour commented Apr 21, 2026

✅ Re-review: APPROVE (Flight)

All three fixes from abd897d verified:

Item Status Detail
B-1 ✅ Fixed Scenario 3 precedence corrected → GH_TOKEN > GITHUB_TOKEN > stored gh auth (matches official gh CLI docs)
N-1 ✅ Fixed GITHUB_TOKEN wording softened — now acknowledges permissions:/env: overrides
N-2 ✅ Fixed Summary table Local dev row clarified with '(when no env vars set)'

Scope check: Commit touches only docs/identity/token-precedence.md (4+/4−). No other files modified.

Ship it. 🚀

— Flight

@sabbour sabbour merged commit aae20c2 into dev Apr 21, 2026
@sabbour sabbour deleted the squad/identity-docs-token-precedence branch April 21, 2026 10:05
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.

1 participant