Skip to content

feat: snapshot-on-push + npm run rollback#21

Merged
dhruva-reddy merged 1 commit intomainfrom
dhruva-reddy/feat/snapshot-rollback
May 5, 2026
Merged

feat: snapshot-on-push + npm run rollback#21
dhruva-reddy merged 1 commit intomainfrom
dhruva-reddy/feat/snapshot-rollback

Conversation

@dhruva-reddy
Copy link
Copy Markdown
Contributor

ELI5

Problem. The README documented "rollback" as git revert + push.
That restores local content to a previous git state, but it does
not restore a known platform snapshot — the subsequent push has
all the same drift problems, so a "rollback" can clobber unrelated
dashboard edits made since the bad deploy. There's also no engine-
level record of what was on the dashboard before the push, so even
in principle you can't put the platform back exactly the way it was.

What this fix does. Before each PATCH, the engine writes both:

  • the outgoing payload (what we're about to send), AND
  • the current platform payload (what's there right now)

to a per-push directory:

.vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json

Snapshots are operator-local (gitignored) and recreated each push.
A single timestamped directory pins one push run, so rollback can
target an entire push, not individual PATCHes.

npm run rollback -- <env> --to <ISO-timestamp> re-applies each
platform payload from the snapshot as a PATCH. --list prints all
available timestamps.

Outcome you'll notice. Real undo. After a bad push, run
npm run rollback -- <env> --list to see your snapshots, pick the
one from before the bad push, and --to <timestamp> puts the
dashboard back to that state. No more "I hope git revert does
what I want."


Real undo. Before each PATCH, write the outgoing (local) payload AND
the current platform payload to a per-push directory. npm run rollback -- <env> --to <ISO-timestamp> re-applies each platform payload as a
PATCH, restoring the dashboard to its state at the moment of the
snapshot.

Snapshots are operator-local state (.vapi-state..snapshots/),
gitignored, and recreated on every push. Each push pins one timestamped
directory so rollback can target an entire push, not individual PATCHes.

Files:

  • src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps,
    loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir
    is idempotent within the process). Reuses sortedKeysReplacer so
    snapshot files have deterministic key order too.
  • src/rollback-cmd.ts (NEW): npm run rollback -- --to
    re-applies each platform payload as a PATCH. --list prints available
    snapshots.
  • src/push.ts: writeSnapshot call after drift check passes. Costs one
    extra GET per resource (acceptable for the safety guarantee — follow-
    up: plumb drift's GET result through to avoid the duplicate fetch).
    Snapshot failures don't block the push.
  • package.json: rollback script.
  • .gitignore: .vapi-state.*.snapshots/ already covered.
  • AGENTS.md: document npm run rollback / --list.
  • tests/snapshot.test.ts: writeSnapshot creates the right path,
    multi-resource snapshots share a timestamp, listSnapshotTimestamps
    sorted, loadSnapshot round-trips.

Closes improvements.md #3.

🤖 Generated with Claude Code

@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from fdf7bfb to c916a21 Compare May 1, 2026 22:56
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/push-drift-detection branch 2 times, most recently from 05675a0 to c1d9632 Compare May 2, 2026 01:23
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from c916a21 to 34ae2cb Compare May 2, 2026 01:24
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/push-drift-detection branch from c1d9632 to 09af67e Compare May 2, 2026 01:28
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from 34ae2cb to 9667011 Compare May 2, 2026 01:29
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/push-drift-detection branch from 09af67e to 4b8d8b8 Compare May 2, 2026 01:33
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from 9667011 to 866b910 Compare May 2, 2026 01:33
Copy link
Copy Markdown
Contributor Author

dhruva-reddy commented May 5, 2026

Merge activity

@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/push-drift-detection branch from 4b8d8b8 to 2eaf382 Compare May 5, 2026 02:14
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from 866b910 to 83242f3 Compare May 5, 2026 02:14
@dhruva-reddy dhruva-reddy changed the base branch from dhruva-reddy/feat/push-drift-detection to graphite-base/21 May 5, 2026 02:18
@dhruva-reddy dhruva-reddy changed the base branch from graphite-base/21 to main May 5, 2026 02:19
## ELI5

**Problem.** The README documented "rollback" as `git revert + push`.
That restores local *content* to a previous git state, but it does
**not** restore a known *platform* snapshot — the subsequent push has
all the same drift problems, so a "rollback" can clobber unrelated
dashboard edits made since the bad deploy. There's also no engine-
level record of *what was on the dashboard before the push*, so even
in principle you can't put the platform back exactly the way it was.

**What this fix does.** Before each PATCH, the engine writes both:

  - the *outgoing* payload (what we're about to send), AND
  - the *current platform* payload (what's there right now)

to a per-push directory:

```
.vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json
```

Snapshots are operator-local (gitignored) and recreated each push.
A single timestamped directory pins one push run, so rollback can
target an entire push, not individual PATCHes.

`npm run rollback -- <env> --to <ISO-timestamp>` re-applies each
`platform` payload from the snapshot as a PATCH. `--list` prints all
available timestamps.

**Outcome you'll notice.** Real undo. After a bad push, run
`npm run rollback -- <env> --list` to see your snapshots, pick the
one from before the bad push, and `--to <timestamp>` puts the
dashboard back to that state. No more "I hope `git revert` does
what I want."

---

Real undo. Before each PATCH, write the *outgoing* (local) payload AND
the *current platform* payload to a per-push directory. `npm run rollback
-- <env> --to <ISO-timestamp>` re-applies each platform payload as a
PATCH, restoring the dashboard to its state at the moment of the
snapshot.

Snapshots are operator-local state (.vapi-state.<env>.snapshots/),
gitignored, and recreated on every push. Each push pins one timestamped
directory so rollback can target an entire push, not individual PATCHes.

Files:
- src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps,
  loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir
  is idempotent within the process). Reuses sortedKeysReplacer so
  snapshot files have deterministic key order too.
- src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp>
  re-applies each platform payload as a PATCH. --list prints available
  snapshots.
- src/push.ts: writeSnapshot call after drift check passes. Costs one
  extra GET per resource (acceptable for the safety guarantee — follow-
  up: plumb drift's GET result through to avoid the duplicate fetch).
  Snapshot failures don't block the push.
- package.json: rollback script.
- .gitignore: .vapi-state.*.snapshots/ already covered.
- AGENTS.md: document npm run rollback / --list.
- tests/snapshot.test.ts: writeSnapshot creates the right path,
  multi-resource snapshots share a timestamp, listSnapshotTimestamps
  sorted, loadSnapshot round-trips.

Closes improvements.md #3.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@dhruva-reddy dhruva-reddy force-pushed the dhruva-reddy/feat/snapshot-rollback branch from 83242f3 to 1672ec0 Compare May 5, 2026 02:20
@dhruva-reddy dhruva-reddy merged commit e3ca040 into main May 5, 2026
dhruva-reddy added a commit that referenced this pull request May 8, 2026
…ree, name 40-char cap, PATCH semantics, ElevenLabs phoneme model compatibility

Six wiki additions + AGENTS.md and CLAUDE.md routing fix to surface them:

- yaml-conventions.md: 'Working with .vapi-ignore' — recovery flow
  ('was that not in the .vapi-ignore?'), cardinal rule against
  silent edits, anti-pattern of editing .vapi-ignore to suppress
  unexpected drift instead of resolving the cause.

- assistants.md: 'Choosing the right pronunciation layer' — symptom
  -> layer decision tree (word misheard = transcriber, word
  mispronounced = TTS), with diagnostic question and forward/back
  cross-links from Transcriber Configuration and Pronunciation
  dictionaries (TTS-level) sections.

- assistants.md: 'Assistant top-level name is limited to 1-40
  characters' — separate enforcement site from structuredOutput.name,
  not surfaced in the public schema reference.

- assistants.md: 'PATCH /assistant/:id semantics: shallow replacement
  at the top-level field' — wholesale replacement of object/array
  subtrees; safe-append pattern is GET -> mutate -> PATCH; explicit
  contrast with assistantOverrides which deep-merges per multilingual.md.

- voice-providers.md: 'Pronunciation dictionary support: per-provider
  field shapes' — Cartesia (pronunciationDictId, sonic-3 only),
  ElevenLabs (pronunciationDictionaryLocators, dictionaryName upstream
  field NOT name), Vapi voices (schema-level support; dashboard UI in
  active PRISM-474 rollout; runtime needs call-test verification).
  Public-docs out-of-date callout.

- voice-providers.md: 'ElevenLabs phoneme rule model compatibility' —
  alias rules universal; phoneme rules silently no-op'd on the default
  eleven_turbo_v2_5 and other current models. Customer impact: zero
  benefit, zero signal. Workarounds: alias-only authoring or pin to
  eleven_flash_v2.

- AGENTS.md + CLAUDE.md: add yaml-conventions.md to the Learnings &
  recipes routing table (was missing, making any yaml-conventions.md
  content invisible to agents).

Cross-checks performed:
- multilingual.md:148-160 deep-merge claim verified to be about
  assistantOverrides, NOT PATCH. No wiki contradiction.
- Customer-name + UUID scrubs clean against all additions.
- Engine state re-verified: candidates that were superseded by recent
  main commits (vapi sync scoping by org-scoping/dry-run/drift; non-
  transactional pushes by snapshot-on-push #21 + validate #17) were
  dropped. Active platform bug PRISM-641 dropped per user instruction.

Skipping code-reviewer per docs-only carve-out in the always-apply
rule. All cross-references manually verified; anchor slugs match
GitHub heading-to-slug conventions.
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