Skip to content

Fix restore-snapshot bug and add make lifecycle commands#15

Open
ytoast wants to merge 2 commits into
Virtual-Protocol:mainfrom
ytoast:fix/virtuals-restore-snapshot
Open

Fix restore-snapshot bug and add make lifecycle commands#15
ytoast wants to merge 2 commits into
Virtual-Protocol:mainfrom
ytoast:fix/virtuals-restore-snapshot

Conversation

@ytoast

@ytoast ytoast commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Some improvements to the acp-builder setup tooling and docs.

The first commit adds a fallback to the restore command so it can recover from the .before-virtuals.bak baseline when no restore snapshot exists.

The second commit adds a Makefile that captures the full lifecycle of setting up (and tearing down) Claude and Codex routing through the Virtuals server, so the steps aren't manual anymore. The acp-builder-setup is useful in helping one get started, but the teardown steps still needs to be done manually at the moment.

ytoast added 2 commits June 17, 2026 19:46
The config helpers captured the restore snapshot before checking whether
the activation was a no-op, so a second `virtuals` run overwrote the
snapshot with the already-Virtuals config — silently discarding the path
back to the user's pre-Virtuals config even when nothing changed.

- Move the no-op detection ahead of captureRestoreState in both helpers so
  a repeat activation keeps the existing restore point intact, and print a
  message that says so.
- restore now falls back to the pristine `.before-virtuals.bak` baseline
  when no `.virtuals-state.json` snapshot exists, before erroring toward
  `default`. The baseline is kept after use as the only frozen original.
- Document the `.before-virtuals.bak` baseline and manual recovery in
  docs/agent-setup.md.

Applied to both configure-claude-virtuals.mjs and configure-codex-virtuals.mjs.
Teardown of Virtuals routing was manual and undocumented: Claude needs
`ccr restart` after every config change, and the Codex proxy must be
started and stopped by hand. These targets encode the full on/off
lifecycle and run in the user's shell, so the daemon and proxy inherit
VIRTUALS_API_KEY.

Targets (self-documenting via `make help`, which greps target comments):
- claude-on/off  configure + `ccr restart`; on prints how to launch `ccr code`
- claude-check   validate the active router config
- codex-on       start the proxy in the background, wait for /health, activate
- codex-off      restore config and stop the proxy it started
- codex-proxy    foreground proxy for watching logs live

claude-on runs `configure-claude-virtuals.mjs check` between activate and
`ccr restart`, so a missing VIRTUALS_API_KEY (or bad provider/transformer)
halts make with a precise message before the daemon reloads a broken config.
The Codex proxy lifecycle (key check, start, /health wait, pidfile-guarded
stop) lives in scripts/codex-proxy.sh so the Makefile recipes stay thin.
Models use the helper defaults; power users call the scripts directly. The
proxy pidfile/logfile are gitignored.

Calls the restore fixed in the previous commit.
@ytoast ytoast force-pushed the fix/virtuals-restore-snapshot branch from e73f936 to 14686ad Compare June 17, 2026 11:46
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