Sync Botfiles Machines
Reconcile authored changes without committing machine state, secrets, private
information, or generated/vendor material. The botfiles GitHub repository is
public, so treat every pushed byte and commit as immediately internet-visible.
Treat research-cpu-01 as the canonical integration host and sourya-mac as a
synchronized client unless current instructions say otherwise.
Safety Contract
- Read each checkout's
AGENTS.md before changing it.
- Inspect every machine before fetching, cleaning, switching branches, or
updating remote
main.
- Never assume similarly named commits are identical; use
git cherry, patch
IDs, and final-tree diffs.
- Never force-push, rewrite a shared branch, or run the full setup script as
root.
- Never copy
secrets/local/, raw user configs, credentials, auth state,
plugin caches, marketplace materializations, or generated vendor trees
between machines or into Git-backed task artifacts.
- Never commit private messages, Calendar or Reminder contents, raw logs or
transcripts, non-public personal identifiers, customer information, private
infrastructure details, or machine-local values merely because no secret
scanner recognizes them.
- Keep scanner output redacted to finding class, path, and line number. Never
print a suspected value while deciding whether it is safe.
- Do not delete an untracked path until it is positively classified. Preserve
unknown or authored material for review.
- Keep original dirty checkouts untouched while integrating. Use an isolated
worktree when their state conflicts with branch operations.
- Require explicit approval before updating remote
main.
1. Resolve Hosts And Task Evidence
- Confirm canonical and client checkout paths.
- Resolve SSH aliases from
~/pro/personal_os/context/machine-ssh-aliases.md when needed.
- Use the active task folder's
task-progress-artifacts/scratchpad/ for raw,
redacted inventories and recovery evidence.
- Store raw config backups only in a private machine-local directory with mode
0700; keep that path out of Git.
- Record a curated reconciliation ledger under
task-progress-artifacts/.
2. Capture Every Git State
Run scripts/capture-state.sh locally on each host before mutation:
bash scripts/capture-state.sh \
--repo "$HOME/pro/botfiles" \
--output "<task-scratchpad>/snapshot-<host>-before"
Copy remote Git-only snapshots into the task folder when practical and verify
sha256sums.txt. The helper captures committed refs, a binary tracked patch,
status/history/divergence reports, and an untracked filename manifest; it does
not archive untracked contents.
Also verify live remote main with git ls-remote origin refs/heads/main.
3. Classify Differences
Classify every committed and worktree difference:
- portable authored source: retain and validate;
- machine-local configuration: preserve locally and keep out of Git;
- generated/vendor state: ignore narrowly and remove only when reproducible
and not required at runtime;
- unknown: preserve and review.
Keep Codex/Claude skill counterparts synchronized unless a capability is
explicitly product-managed and surface-specific. Treat codex/skills/.system/
and app-injected skills as machine-managed. Do not vendor upstream curated
skills merely because a symlink made them appear inside the repository.
For overlaps, compare final hashes or stable patch IDs. Auto-resolve only
byte-identical or patch-equivalent changes. Present one focused user decision
for authored conflicts, unknown files, destructive cleanup, or a change in
canonical intent; preserve and defer when no answer is available.
4. Reconcile History
- Fetch each checkout only after snapshots exist.
- Create
codex/<tracker>-botfiles-sync from current origin/main in an
isolated worktree.
- Run
git cherry -v origin/main <source-main> and
git log --left-right --cherry-mark.
- Replay unique commits in original order and skip patch-equivalent commits.
- Resolve conflicts by newest reviewed intent, not by choosing an entire side.
- Use
git range-diff and git diff --check to prove the replay.
Do not cherry-pick a temporary add/remove sequence out of order. Preserving
both commits is acceptable when provenance matters and the final net state is
correct.
5. Integrate Dirty Worktrees
Apply captured tracked patches with three-way context or import reviewed files
explicitly. Commit coherent groups such as wrappers, task helpers, paired
skills, instructions, layered configuration, and cleanup rules.
Before every commit:
- inspect staged filenames and the full staged diff;
- run
git diff --cached --check;
- scan staged content for private keys, common token shapes, and private
information inappropriate for a public repository;
- validate affected shell, Python, JSON, TOML, YAML, and skill files.
Restore ambiguous deletions unless evidence proves they were intentional.
6. Preserve The Codex Layer Boundary
Use native Codex configuration precedence:
/etc/codex/config.toml is a root-owned symlink to the checked-out
codex/config.system.toml;
~/.codex/config.toml is a regular mode-0600 machine-local file;
- the system base owns authored portable defaults, the accepted shared MCPs,
and no plugin installation/runtime state;
- the user file owns project trust, notice/migration state, desktop/runtime
tables, native plugin installation state, marketplace paths and timestamps,
credentials, and host-only integrations;
- local or plugin-injected MCP additions are allowed;
- an enumerated Mac notification override may shadow portable
notify.
Never union, copy, merge, delete, or compare local trust/runtime values as
content that should be identical. Never use a Git clean filter,
skip-worktree, assume-unchanged, a generated active config, implicit
profiles, or CODEX_HOME as production routing.
Ordinary setup.sh must not rewrite the active user config. Use
bin/install-codex-system-config --apply for the single elevated system-link
action.
7. Verify Layering And Runtime Support
Run the read-only verifier on each host:
python3 scripts/verify-config-layers.py \
--repo "$HOME/pro/botfiles" \
--machine "<machine-name>" \
--output "<task-scratchpad>/config-layers-<machine>.json"
On the Mac, add --allow-user-override notify when its Desktop notifier is
present.
The verifier reports names, layer origins, and status only. It checks:
- portable and user TOML parsing;
- root-owned system symlink target;
- regular mode-
0600 user config;
- prohibited system/local ownership categories;
- unapproved key collisions;
- app-server layer discovery and effective origins;
- the accepted six-MCP subset while allowing local additions;
- Zotero router, credential-mode, and server launch prerequisites;
- the evidence-backed Sites/Visualize subset in local config and native
installed-plugin discovery.
Install the required subset natively on each host:
codex plugin add sites@openai-bundled --json
codex plugin add visualize@openai-bundled --json
Use codex plugin list --json and marketplace discovery as runtime proof;
never copy runtime caches between hosts.
8. Migrate And Exercise Rollback
- Back up the exact legacy user symlink and dereferenced config contents in the
host's private mode-
0700 state directory.
- Install the system symlink while the legacy user symlink remains.
- Prove system-layer discovery before replacing either user config.
- Cut over the canonical GCP host first; validate, restore the exact legacy
arrangement, then reapply and validate again.
- Stop Mac Desktop, repeat the cutover/rollback/reapply sequence, then restart
and validate Desktop plus CLI.
- Compare only the accepted portable subset across hosts.
Keep rollback backups until the landed-state reviewer handoff is complete.
9. Validate And Request Landing
Run proportionate checks:
bash -n for shell files;
- Python compilation and focused tests;
- JSON/TOML/YAML parsing;
- Codex/Claude counterpart comparison;
- skill
quick_validate.py;
- setup idempotence and wrapper failure/success paths;
git diff --check, staged secret scans, and full final diff review.
Correct reasonable task-scoped defects and rerun affected gates. Stop before
landing for a material architecture/scope change, weakened security or
rollback, destructive ambiguity, or unresolved required capability.
Present compact redacted evidence and obtain explicit landing approval.
Public-repository disclosure gate
Immediately before requesting approval, and again immediately before pushing:
- Resolve the exact live push range as
<live-remote-main>..HEAD. Scan the
complete range, including intermediate commits, not only the staged diff or
final tree.
- Use an available secret scanner plus manual review. Check for credentials,
tokens, private keys, authorization material, copied config values, private
URLs or infrastructure, personal contact details, customer/company data,
message/Calendar/Reminder content, screenshots, logs, transcripts, and
machine-specific paths that disclose more than documented public
conventions.
- Treat placeholder fixtures and already-public identifiers as intentional
only after inspecting their context. Existing presence elsewhere in the
repository is evidence, not an automatic allowlist.
- Record only redacted finding classes and paths. Remove or replace unsafe
content and rerun the complete-range scan. If a finding is uncertain, stop
and ask rather than push it.
- Confirm no
secrets/local/, local user config, credential store, private
task artifact, cache, or generated runtime path occurs anywhere in the push
range.
10. Land, Synchronize, And Handoff
After approval:
- Confirm the candidate is clean and based on live remote
main.
- Fast-forward and push
main without force or a merge commit.
- Preserve post-snapshot changes and fast-forward every client checkout.
- Record each current system-link target, then repoint it to the canonical
landed checkout with
install-codex-system-config --replace-from <exact-old-target> --apply;
run setup only where needed.
- Run
scripts/verify-pair.sh and the layer verifier on every host.
- Confirm exact
HEAD == main == origin/main, the accepted config contract,
and only documented local state.
- Record SHAs, retained/skipped changes, cleanup, tests, exceptions, and
rollback locations.
- Move the tracker to
Review, not Done, with a reviewer-facing handoff.
1---2name: sync-botfiles-machines3description: Safely inventory, reconcile, clean, and synchronize divergent botfiles Git checkouts and layered Codex configuration across the canonical cloud host and client machines. Use for dirty Mac/VM botfiles trees, ahead/behind main histories, machine-local Codex runtime state, generated agent artifacts, or branch-to-main integration and verification.4---56# Sync Botfiles Machines78Reconcile authored changes without committing machine state, secrets, private9information, or generated/vendor material. The botfiles GitHub repository is10public, so treat every pushed byte and commit as immediately internet-visible.11Treat `research-cpu-01` as the canonical integration host and `sourya-mac` as a12synchronized client unless current instructions say otherwise.1314## Safety Contract1516- Read each checkout's `AGENTS.md` before changing it.17- Inspect every machine before fetching, cleaning, switching branches, or18 updating remote `main`.19- Never assume similarly named commits are identical; use `git cherry`, patch20 IDs, and final-tree diffs.21- Never force-push, rewrite a shared branch, or run the full setup script as22 root.23- Never copy `secrets/local/`, raw user configs, credentials, auth state,24 plugin caches, marketplace materializations, or generated vendor trees25 between machines or into Git-backed task artifacts.26- Never commit private messages, Calendar or Reminder contents, raw logs or27 transcripts, non-public personal identifiers, customer information, private28 infrastructure details, or machine-local values merely because no secret29 scanner recognizes them.30- Keep scanner output redacted to finding class, path, and line number. Never31 print a suspected value while deciding whether it is safe.32- Do not delete an untracked path until it is positively classified. Preserve33 unknown or authored material for review.34- Keep original dirty checkouts untouched while integrating. Use an isolated35 worktree when their state conflicts with branch operations.36- Require explicit approval before updating remote `main`.3738## 1. Resolve Hosts And Task Evidence39401. Confirm canonical and client checkout paths.412. Resolve SSH aliases from42 `~/pro/personal_os/context/machine-ssh-aliases.md` when needed.433. Use the active task folder's `task-progress-artifacts/scratchpad/` for raw,44 redacted inventories and recovery evidence.454. Store raw config backups only in a private machine-local directory with mode46 `0700`; keep that path out of Git.475. Record a curated reconciliation ledger under `task-progress-artifacts/`.4849## 2. Capture Every Git State5051Run `scripts/capture-state.sh` locally on each host before mutation:5253```bash54bash scripts/capture-state.sh \55 --repo "$HOME/pro/botfiles" \56 --output "<task-scratchpad>/snapshot-<host>-before"57```5859Copy remote Git-only snapshots into the task folder when practical and verify60`sha256sums.txt`. The helper captures committed refs, a binary tracked patch,61status/history/divergence reports, and an untracked filename manifest; it does62not archive untracked contents.6364Also verify live remote `main` with `git ls-remote origin refs/heads/main`.6566## 3. Classify Differences6768Classify every committed and worktree difference:6970- **portable authored source**: retain and validate;71- **machine-local configuration**: preserve locally and keep out of Git;72- **generated/vendor state**: ignore narrowly and remove only when reproducible73 and not required at runtime;74- **unknown**: preserve and review.7576Keep Codex/Claude skill counterparts synchronized unless a capability is77explicitly product-managed and surface-specific. Treat `codex/skills/.system/`78and app-injected skills as machine-managed. Do not vendor upstream curated79skills merely because a symlink made them appear inside the repository.8081For overlaps, compare final hashes or stable patch IDs. Auto-resolve only82byte-identical or patch-equivalent changes. Present one focused user decision83for authored conflicts, unknown files, destructive cleanup, or a change in84canonical intent; preserve and defer when no answer is available.8586## 4. Reconcile History87881. Fetch each checkout only after snapshots exist.892. Create `codex/<tracker>-botfiles-sync` from current `origin/main` in an90 isolated worktree.913. Run `git cherry -v origin/main <source-main>` and92 `git log --left-right --cherry-mark`.934. Replay unique commits in original order and skip patch-equivalent commits.945. Resolve conflicts by newest reviewed intent, not by choosing an entire side.956. Use `git range-diff` and `git diff --check` to prove the replay.9697Do not cherry-pick a temporary add/remove sequence out of order. Preserving98both commits is acceptable when provenance matters and the final net state is99correct.100101## 5. Integrate Dirty Worktrees102103Apply captured tracked patches with three-way context or import reviewed files104explicitly. Commit coherent groups such as wrappers, task helpers, paired105skills, instructions, layered configuration, and cleanup rules.106107Before every commit:108109- inspect staged filenames and the full staged diff;110- run `git diff --cached --check`;111- scan staged content for private keys, common token shapes, and private112 information inappropriate for a public repository;113- validate affected shell, Python, JSON, TOML, YAML, and skill files.114115Restore ambiguous deletions unless evidence proves they were intentional.116117## 6. Preserve The Codex Layer Boundary118119Use native Codex configuration precedence:120121- `/etc/codex/config.toml` is a root-owned symlink to the checked-out122 `codex/config.system.toml`;123- `~/.codex/config.toml` is a regular mode-`0600` machine-local file;124- the system base owns authored portable defaults, the accepted shared MCPs,125 and no plugin installation/runtime state;126- the user file owns project trust, notice/migration state, desktop/runtime127 tables, native plugin installation state, marketplace paths and timestamps,128 credentials, and host-only integrations;129- local or plugin-injected MCP additions are allowed;130- an enumerated Mac notification override may shadow portable `notify`.131132Never union, copy, merge, delete, or compare local trust/runtime values as133content that should be identical. Never use a Git clean filter,134`skip-worktree`, `assume-unchanged`, a generated active config, implicit135profiles, or `CODEX_HOME` as production routing.136137Ordinary `setup.sh` must not rewrite the active user config. Use138`bin/install-codex-system-config --apply` for the single elevated system-link139action.140141## 7. Verify Layering And Runtime Support142143Run the read-only verifier on each host:144145```bash146python3 scripts/verify-config-layers.py \147 --repo "$HOME/pro/botfiles" \148 --machine "<machine-name>" \149 --output "<task-scratchpad>/config-layers-<machine>.json"150```151152On the Mac, add `--allow-user-override notify` when its Desktop notifier is153present.154155The verifier reports names, layer origins, and status only. It checks:156157- portable and user TOML parsing;158- root-owned system symlink target;159- regular mode-`0600` user config;160- prohibited system/local ownership categories;161- unapproved key collisions;162- app-server layer discovery and effective origins;163- the accepted six-MCP subset while allowing local additions;164- Zotero router, credential-mode, and server launch prerequisites;165- the evidence-backed Sites/Visualize subset in local config and native166 installed-plugin discovery.167168Install the required subset natively on each host:169170```bash171codex plugin add sites@openai-bundled --json172codex plugin add visualize@openai-bundled --json173```174175Use `codex plugin list --json` and marketplace discovery as runtime proof;176never copy runtime caches between hosts.177178## 8. Migrate And Exercise Rollback1791801. Back up the exact legacy user symlink and dereferenced config contents in the181 host's private mode-`0700` state directory.1822. Install the system symlink while the legacy user symlink remains.1833. Prove system-layer discovery before replacing either user config.1844. Cut over the canonical GCP host first; validate, restore the exact legacy185 arrangement, then reapply and validate again.1865. Stop Mac Desktop, repeat the cutover/rollback/reapply sequence, then restart187 and validate Desktop plus CLI.1886. Compare only the accepted portable subset across hosts.189190Keep rollback backups until the landed-state reviewer handoff is complete.191192## 9. Validate And Request Landing193194Run proportionate checks:195196- `bash -n` for shell files;197- Python compilation and focused tests;198- JSON/TOML/YAML parsing;199- Codex/Claude counterpart comparison;200- skill `quick_validate.py`;201- setup idempotence and wrapper failure/success paths;202- `git diff --check`, staged secret scans, and full final diff review.203204Correct reasonable task-scoped defects and rerun affected gates. Stop before205landing for a material architecture/scope change, weakened security or206rollback, destructive ambiguity, or unresolved required capability.207208Present compact redacted evidence and obtain explicit landing approval.209210### Public-repository disclosure gate211212Immediately before requesting approval, and again immediately before pushing:2132141. Resolve the exact live push range as `<live-remote-main>..HEAD`. Scan the215 complete range, including intermediate commits, not only the staged diff or216 final tree.2172. Use an available secret scanner plus manual review. Check for credentials,218 tokens, private keys, authorization material, copied config values, private219 URLs or infrastructure, personal contact details, customer/company data,220 message/Calendar/Reminder content, screenshots, logs, transcripts, and221 machine-specific paths that disclose more than documented public222 conventions.2233. Treat placeholder fixtures and already-public identifiers as intentional224 only after inspecting their context. Existing presence elsewhere in the225 repository is evidence, not an automatic allowlist.2264. Record only redacted finding classes and paths. Remove or replace unsafe227 content and rerun the complete-range scan. If a finding is uncertain, stop228 and ask rather than push it.2295. Confirm no `secrets/local/`, local user config, credential store, private230 task artifact, cache, or generated runtime path occurs anywhere in the push231 range.232233## 10. Land, Synchronize, And Handoff234235After approval:2362371. Confirm the candidate is clean and based on live remote `main`.2382. Fast-forward and push `main` without force or a merge commit.2393. Preserve post-snapshot changes and fast-forward every client checkout.2404. Record each current system-link target, then repoint it to the canonical241 landed checkout with242 `install-codex-system-config --replace-from <exact-old-target> --apply`;243 run setup only where needed.2445. Run `scripts/verify-pair.sh` and the layer verifier on every host.2456. Confirm exact `HEAD == main == origin/main`, the accepted config contract,246 and only documented local state.2477. Record SHAs, retained/skipped changes, cleanup, tests, exceptions, and248 rollback locations.2498. Move the tracker to `Review`, not `Done`, with a reviewer-facing handoff.