RFC: standardize persistent-secrets pattern across ALL workspace templates (Gitea tokens, OAuth blobs, vendor keys survive container restart) #1689

Open
opened 2026-05-22 22:47:22 +00:00 by hongming · 0 comments
Owner

Why

Multiple secrets-don't-survive-restart incidents in the last week:

  • 2026-05-22: codex Researcher + CR auth.json gets wiped on restart (start.sh re-injects from env-var snapshot — see #35 for that template's fix)
  • 2026-05-22: Engineer-B MiniMax Gitea token wiped on restart (was env-only via CP admin /env push). I manually persisted by writing to /configs/secrets.d/ + patching entrypoint.sh to source it.
  • Other templates likely have similar gaps.

Proposal

Standardize one pattern across EVERY workspace template:

A. /configs/secrets.d/ is the persistent SSOT for workspace secrets

  • Volume-mounted from EC2 host /configs/
  • One file per secret: /configs/secrets.d/<KEY> contains the value (no key=value, just the value)
  • /configs/secrets.d/load.sh sources each file + exports as env var
  • Mode 0600, owned by ubuntu:ubuntu

The codex template already does this via molecule-controlplane's /env push. Make this universal.

B. Every template's entrypoint.sh sources it FIRST

#!/bin/sh
# Source persistent workspace secrets BEFORE anything else that might need them.
# /configs is volume-mounted from the host so this survives container restart.
if [ -f /configs/secrets.d/load.sh ]; then
  . /configs/secrets.d/load.sh
fi
# ... rest of entrypoint ...

C. CP admin /env push writes through to /configs/secrets.d/

When POST /cp/admin/workspaces/<id>/env is called, molecule-controlplane should write the new env vars to /configs/secrets.d/<KEY> (one file per key) so they survive container restart. Currently this only happens for some templates / some keys.

This is the molecule-controlplane-side change: the workspace-template side only needs the entrypoint.sh source-line (Section B).

Acceptance

  • Every workspace template's entrypoint sources /configs/secrets.d/load.sh (idempotent guard)
  • molecule-controlplane writes through /env push → /configs/secrets.d/<KEY> files
  • Test: restart a workspace, env vars persist
  • Audit: list all currently-deployed templates + report which have the entrypoint source line + which don't

Touchpoints

  • molecule-ai-workspace-template-claude-code
  • molecule-ai-workspace-template-codex (already has it for CODEX_AUTH_JSON specifically — generalize)
  • molecule-ai-workspace-template-hermes
  • molecule-ai-workspace-template-openclaw
  • molecule-ai-workspace-template-langgraph / autogen / crewai / etc.
  • molecule-controlplane (the /env-push → /configs/secrets.d/ write-through)

Owner

TBD. Cross-team — touches ALL workspace template repos + controlplane. ~1w end-to-end.

## Why Multiple secrets-don't-survive-restart incidents in the last week: - 2026-05-22: codex Researcher + CR auth.json gets wiped on restart (start.sh re-injects from env-var snapshot — see #35 for that template's fix) - 2026-05-22: Engineer-B MiniMax Gitea token wiped on restart (was env-only via CP admin /env push). I manually persisted by writing to /configs/secrets.d/ + patching entrypoint.sh to source it. - Other templates likely have similar gaps. ## Proposal Standardize one pattern across EVERY workspace template: ### A. `/configs/secrets.d/` is the persistent SSOT for workspace secrets - Volume-mounted from EC2 host `/configs/` - One file per secret: `/configs/secrets.d/<KEY>` contains the value (no key=value, just the value) - `/configs/secrets.d/load.sh` sources each file + exports as env var - Mode 0600, owned by ubuntu:ubuntu The codex template already does this via molecule-controlplane's `/env` push. Make this universal. ### B. Every template's entrypoint.sh sources it FIRST ```bash #!/bin/sh # Source persistent workspace secrets BEFORE anything else that might need them. # /configs is volume-mounted from the host so this survives container restart. if [ -f /configs/secrets.d/load.sh ]; then . /configs/secrets.d/load.sh fi # ... rest of entrypoint ... ``` ### C. CP admin `/env` push writes through to /configs/secrets.d/ When `POST /cp/admin/workspaces/<id>/env` is called, molecule-controlplane should write the new env vars to `/configs/secrets.d/<KEY>` (one file per key) so they survive container restart. Currently this only happens for some templates / some keys. This is the molecule-controlplane-side change: the workspace-template side only needs the entrypoint.sh source-line (Section B). ## Acceptance - Every workspace template's entrypoint sources `/configs/secrets.d/load.sh` (idempotent guard) - molecule-controlplane writes through `/env` push → `/configs/secrets.d/<KEY>` files - Test: restart a workspace, env vars persist - Audit: list all currently-deployed templates + report which have the entrypoint source line + which don't ## Touchpoints - molecule-ai-workspace-template-claude-code - molecule-ai-workspace-template-codex (already has it for CODEX_AUTH_JSON specifically — generalize) - molecule-ai-workspace-template-hermes - molecule-ai-workspace-template-openclaw - molecule-ai-workspace-template-langgraph / autogen / crewai / etc. - molecule-controlplane (the /env-push → /configs/secrets.d/ write-through) ## Owner TBD. Cross-team — touches ALL workspace template repos + controlplane. ~1w end-to-end.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1689