Skip to content

Simplify install-time secrets + scaffold render-time catalog#22

Merged
vaintrub merged 2 commits into
masterfrom
chore/secrets-architecture
May 17, 2026
Merged

Simplify install-time secrets + scaffold render-time catalog#22
vaintrub merged 2 commits into
masterfrom
chore/secrets-architecture

Conversation

@vaintrub
Copy link
Copy Markdown
Owner

Summary

Splits the previously-conflated GITHUB_TOKEN cascade into three distinct mechanisms, each fit for its concern:

  1. Install-time (GITHUB_TOKEN for mise rate limit) — drop op→gh→anon cascade; keep only gh auth token fallback (5 LOC). Anonymous 60/hr GH API limit usually fits a cold install; recovery if hit via existing mise_install_tools() warning.
  2. Render-time (target files that must contain credentials on disk, e.g. ~/.npmrc, ~/.aws/credentials) — scaffold .chezmoidata/secrets.yaml with an op_refs: catalog. Consumers reference via {{ onepasswordRead .op_refs.<key> }} in private_dot_<file>.tmpl templates (mode 0600). Catalog starts empty.
  3. Runtime CLI auth (gh / aws / npm CLIs themselves) — documented as 1Password Shell Plugins (op plugin init <cli>).

Breaking change

  • $DOTFILES_OP_GITHUB_REF env override is gone (was op-specific). Users who want op-based GITHUB_TOKEN now set it explicitly:
    export GITHUB_TOKEN=$(op read 'op://Personal/GitHub API Token/credential')
    Either one-off or in ~/.zshrc_local.

Why

  • Wrapper had a 15-line cascade that mixed install-time runtime + render-time concerns. After research (chezmoi-native onepasswordRead, 1Password 10-min session, Shell Plugins), the three-layer split is the cleanest model.
  • Anonymous 60/hr GH limit usually fits a cold install — automatic op cascade was solving a non-problem most of the time.
  • Render-time onepasswordRead is the right tool for files like .npmrc/.aws/credentials — these need the secret on disk anyway. Catalog avoids hardcoded op://... strings scattered across templates.

Test plan

  • bats tests/unit/install-packages.bats — 31 pass + 1 skip
  • Local chezmoi apply on Mac (workstation) — idempotent, rtk init still wires correctly
  • Rendered wrapper has 3-line gh fallback only (verified via chezmoi execute-template)
  • CI unit + apply-core + apply-dev — should pass; CI injects GITHUB_TOKEN via env directly, never used the cascade
  • Jetson re-apply: gh auth login (one-off) then chezmoi apply — wrapper picks up via gh auth token automatically

Files

File Change
.chezmoiscripts/run_onchange_after_50-install-packages.sh.tmpl Drop op cascade, keep gh fallback (~-13 LOC)
.chezmoidata/secrets.yaml NEW — empty catalog scaffolding with docs
lib/install-packages.sh Refine mise_install_tools() warning to three recovery options
README.md §"1Password integration" Rewrite — three-layer architecture with concrete recipes
README.md §"GitHub API rate limit" Trim — point at install-time recovery options instead of duplicating
AGENTS.md §"Bootstrap script split" Update to match new architecture

Out of scope

  • No render-time consumers added in this PR. Catalog is scaffolding; first consumer (e.g. private_dot_npmrc.tmpl) lands when actually needed.
  • 1Password Shell Plugins setup is documented but not auto-installed (per-CLI user opt-in).

vaintrub added 2 commits May 17, 2026 13:22
Three secret-handling concerns in this repo, previously conflated into one
GITHUB_TOKEN cascade in the install-packages wrapper. Split into three
distinct mechanisms, each appropriate for its use case:

1. **Install-time** (GITHUB_TOKEN for mise rate limit) — drop the op→gh→anon
   cascade. Keep ONLY `gh auth token` fallback (5 LOC, no disk persistence).
   Pre-exported env still wins. Anonymous 60/hr usually fits a cold install
   on a fast link; if hit, the existing partial-install warning in
   `mise_install_tools()` surfaces three recovery options (gh auth login,
   manual env, `op read`).

2. **Render-time** (target files like ~/.npmrc, ~/.aws/credentials that
   must contain credentials on disk) — scaffold `.chezmoidata/secrets.yaml`
   as the single source of truth for 1Password reference paths. Consumers
   reference via `{{ onepasswordRead .op_refs.<key> }}` in
   `private_dot_<file>.tmpl` templates (mode 0600). Catalog starts empty;
   add entries when the first render-time consumer appears.

3. **Runtime CLI auth** (gh, aws, npm CLIs themselves) — documented as
   1Password Shell Plugins (`op plugin init <cli>`). Not in any catalog;
   `op` manages auth per CLI internally.

Wrapper LOC: 22 → 9 (token block). Backward-compat break: drop
`$DOTFILES_OP_GITHUB_REF` env override — was op-specific, no longer
applies. Users who want op-based GITHUB_TOKEN now set it explicitly:
`export GITHUB_TOKEN=$(op read '...')` once or in ~/.zshrc_local.

README §"1Password integration" rewritten to enumerate the three layers
with concrete recipes for each. §"GitHub API rate limit" trimmed to
point at the new install-time recovery options instead of duplicating
them. AGENTS.md install-script-split section updated to match.

CI: unaffected (`GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}` is set via
env directly, never used the cascade).
…ions

Found in the secrets-architecture re-verification: README §"First-time
bootstrap checklist" still said `install-packages auto-reads via op read`,
and §"Recovery" mentioned `seed token in 1Password` as if that triggered
auto-read. The op cascade was removed in the previous commit on this
branch — those claims are now untrue.

Rewrite:
- §First-time bootstrap: drop the optional `gh auth login` / `op item create`
  pre-step. Anonymous works for cold install on a fast link; recovery is
  one command if rate-limited.
- §Recovery: point at §"1Password integration → Install-time" for the full
  three-option recovery menu instead of duplicating partial info inline.
- Drop the legacy `mac` reference from the chezmoi.toml stale-keys recipe
  (that translation was removed in commit ad604b9 last week).

Pure docs accuracy. No code changes.
@vaintrub vaintrub merged commit 2b3db57 into master May 17, 2026
3 checks passed
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