You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fb6798e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(push,pull): never take over same-named org resources without --adopt (#104)
* fix(push,pull): never take over same-named org resources without --adopt
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(adopt): delete the leftover alias file
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(push): plain-language stop messages with the fix for each file
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: dhruva <dhruva@vapi.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,8 +208,8 @@ More detail: [How the engine works](docs/guides/how-it-works.md).
208
208
|`npm run setup`| Connect an org: create `.env.<org>` and `resources/<org>/`|
209
209
|`npm run validate -- <org>`| Check resource files offline before deploying |
210
210
|`npm run apply -- <org>`| Deploy: pull, merge, then push (the default) |
211
-
|`npm run pull -- <org>`| Sync platform changes down without overwriting local edits |
212
-
|`npm run push -- <org>`| Push without pulling first (prefer `apply`) |
211
+
|`npm run pull -- <org>`| Sync platform changes down without overwriting local edits; unknown UUIDs get separate files, never name-linked|
212
+
|`npm run push -- <org>`| Push without pulling first (prefer `apply`); review `--dry-run` Name collisions, and use `--adopt <id>[=<uuid>]` only with explicit approval to take over a resource; unchanged alias files are removed, edited/unbaselined copies need review. Push/apply support `--json` for one grouped link-preflight report (exit 1 on blockers); see [Running in CI](docs/guides/commands.md#running-in-ci).|
213
213
|`npm run rollback -- <org>`| Restore a pre-deploy snapshot |
214
214
|`npm run cleanup -- <org>`| Find, and optionally delete, platform resources with no file |
215
215
|`npm run audit -- <org>`| Report drift between files, state and the platform |
Copy file name to clipboardExpand all lines: docs/guides/commands.md
+73-2Lines changed: 73 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ The other commands are direct only.
11
11
| --- | --- | --- |
12
12
|`npm run setup`|`npm run setup [-- <org>]`| Connect an org: creates `.env.<org>` and `resources/<org>/`. |
13
13
|`npm run validate`|`npm run validate -- <org>`| Check resource files offline: API shape rules, and that every reference names a file or a state entry. `apply` runs it first. On GitHub Actions, findings are also shown on the files in the pull request. |
14
-
|`npm run apply`|`npm run apply -- <org> [types or paths]`|**The default deploy:** pull, merge, then push. See [workflows](workflows.md). |
14
+
|`npm run apply`|`npm run apply -- <org> [types or paths] [--adopt <id>[=<uuid>]]`|**The default deploy:** pull, merge, then push. See [workflows](workflows.md). |
15
15
|`npm run pull`|`npm run pull -- <org> [--force] [--bootstrap]`| Sync platform changes down; never overwrites local edits unless `--force`. |
16
-
|`npm run push`|`npm run push -- <org> [--dry-run] [--strict]`| Push without pulling first. Prefer `apply`. `--strict` aborts before any API call if validation finds an error. |
16
+
|`npm run push`|`npm run push -- <org> [--dry-run] [--json] [--strict] [--adopt <id>[=<uuid>]]`| Push without pulling first. Prefer `apply`. `--strict` aborts before any API call if validation finds an error. |
17
17
|`npm run rollback`|`npm run rollback -- <org> --list` or `--to <ISO>`| Restore a pre-deploy snapshot from `.vapi-state.<org>.snapshots/`. |
18
18
|`npm run cleanup`|`npm run cleanup -- <org> [--force --confirm <org>]`| List platform resources with no file; delete them only with both flags. |
19
19
|`npm run audit`|`npm run audit -- <org> [--type <type>]`| Report drift between files, state and the platform. Exits 1 on any finding, so it can run in CI. |
@@ -24,6 +24,77 @@ The other commands are direct only.
24
24
|`npm run build`|`npm run build`| Type-check the code and tests. |
25
25
|`npm test`|`npm test`| Run the test suite. |
26
26
27
+
Pull and push never automatically rename UUID-suffixed state keys to match
28
+
local files. A local file without a UUID mapping remains subject to the
29
+
new-file gate even if the org has a same-name resource. The gate reports
30
+
same-name candidates without linking them. Existing mappings, including
31
+
legacy entries without provenance, remain linked. New pull mappings record
32
+
`origin: pulled`; push-created resources record `origin: pushed`.
33
+
34
+
Dry-run push/apply ends with **Name collisions**, listing same-name state and
35
+
live dashboard resources for every planned POST, including dependency creates.
36
+
Read-only GETs run in dry-run. No matches prints `Name collisions: none`;
37
+
unavailable inventories are reported as an incomplete check, not a clean result.
38
+
Check this list before deploying; taking over a resource requires explicit
39
+
human approval for `--adopt`, just as `--allow-new-files` requires approval.
40
+
41
+
### Running in CI
42
+
43
+
Push/apply link preflight reports all blocking files in one **Push stopped**
44
+
block and exits **1**, before API mutations, state writes or alias deletion.
45
+
"Not linked to any resource in <org> yet" means pushing would create a new
46
+
resource; the engine cannot infer new versus renamed/stale intent.
47
+
48
+
Each file has exact commands: approve `--allow-new-files` for genuinely new
49
+
resources, approve `--adopt <id>[=<uuid>]` for a takeover, or merge needed edits
50
+
and remove a renamed/stale file. A single ready-to-run combined command appears
51
+
only when every file has an unambiguous suggestion; otherwise the report lists
52
+
which files need human choice. Suggestions are not authorization to execute.
53
+
54
+
`--json` on push or apply prints one stdout array of
55
+
`{file, resourceType, problem, fix, command}`; ordinary logs go to stderr.
56
+
The exit code stays 1 for blockers. `[]` means no link-preflight blockers,
57
+
not a guarantee that later network/validation/deployment steps will succeed.
58
+
Use `--dry-run --json` for a read-only preview. When invoking through npm,
59
+
use `npm run -s push -- <org> --dry-run --json` to suppress npm's own
60
+
command banner on stdout.
61
+
62
+
Safe, unchanged leftover alias files are removed automatically, including
63
+
UUID-suffixed leftovers of an already-adopted mapping on a later plain push.
64
+
Edited/unbaselined files need per-file y/N approval in a terminal and stop CI.
65
+
The engine never auto-adopts, auto-passes the new-file flag or silently deletes
66
+
edited files.
67
+
68
+
### Explicit resource adoption
69
+
70
+
`--adopt <resourceId>` opts a local file into taking over an existing org
71
+
resource. It is repeatable; `--adopt=<resourceId>` also works. The file must
72
+
exist and have no state mapping. Candidates are same-base-slug state entries
73
+
and live resources of that type matching the file's name (or ID when unnamed).
74
+
One distinct candidate is required. If several exist, use
75
+
`--adopt <resourceId>=<uuid>`; that UUID must exist remotely for the file's type.
76
+
Missing files, already-linked files, and zero/ambiguous candidates are errors.
77
+
78
+
Adoption records `origin: adopted`, removes other state keys for that UUID, and
79
+
uses the normal PATCH path. Scoped saves include both sides of the re-key.
80
+
`--dry-run --adopt <id>` performs live GET lookups and prints
81
+
`would adopt <id> → <uuid>`, but does not write state or mutate the platform.
82
+
`apply` forwards adoption to its push stage; its preceding pull remains a
83
+
normal pull except in `--dry-run`, which skips pull to avoid local writes.
84
+
Adoption deletes leftover alias files only when they match the last-synced
85
+
baseline. Edited files or missing baselines need per-file y/N approval in a
86
+
terminal; headless runs stop before changing files, state or the platform.
87
+
Merge those edits into the adopted file or delete the alias manually and rerun.
88
+
Dry-run reports would-delete/would-fail without deleting. Baselines are keyed
89
+
by remote UUID, not alias; adoption drops the shared old baseline and the normal
90
+
PATCH records a fresh one for the adopted resource.
91
+
92
+
Dependencies are automatically reused by name only when an existing state
93
+
entry records `origin: pushed` or `origin: adopted`. Pulled and legacy entries,
94
+
and dashboard-only name matches, are not authorization: a missing dependency
95
+
is POST-created with a warning naming the existing resources. Use explicit
96
+
adoption before dependency resolution to take one over instead.
97
+
27
98
## Interactive Mode
28
99
29
100
When you run a command without arguments, you get a fully interactive experience:
-`.vapi-state.<org>.json` — resource ID ↔ UUID mappings and optional origin (committed)
9
9
-`.vapi-state-hash/<org>/<uuid>` — last-seen platform content hash per resource, used for drift detection (per-developer, gitignored)
10
10
-`resources/<org>/` — all resource files
11
11
@@ -42,7 +42,52 @@ files
42
42
43
43
**`push`** — reads local files and syncs them to the platform: creates and updates. It deletes platform resources whose files you removed only when you pass `--force`.
44
44
45
-
**`apply`** — runs `pull` then `push` in sequence.
45
+
**`apply`** — runs `pull` then `push` in sequence. With `--dry-run`, it skips
46
+
pull (which writes local files/state) and previews push with read-only GETs.
47
+
48
+
### Running in CI
49
+
50
+
Push/apply link preflight reports all blocking files in one **Push stopped**
51
+
block and exits **1**, before API mutations, state writes or alias deletion.
52
+
"Not linked to any resource in <org> yet" means pushing would create a new
53
+
resource; the engine cannot infer new versus renamed/stale intent.
54
+
55
+
Each file has exact commands: approve `--allow-new-files` for genuinely new
56
+
resources, approve `--adopt <id>[=<uuid>]` for a takeover, or merge needed edits
57
+
and remove a renamed/stale file. A single ready-to-run combined command appears
58
+
only when every file has an unambiguous suggestion; otherwise the report lists
59
+
which files need human choice. Suggestions are not authorization to execute.
60
+
61
+
`--json` on push or apply prints one stdout array of
62
+
`{file, resourceType, problem, fix, command}`; ordinary logs go to stderr.
63
+
The exit code stays 1 for blockers. `[]` means no link-preflight blockers,
64
+
not a guarantee that later network/validation/deployment steps will succeed.
65
+
Use `--dry-run --json` for a read-only preview. With npm, use
66
+
`npm run -s push -- <org> --dry-run --json` to suppress npm's banner.
67
+
68
+
Safe, unchanged leftover alias files are removed automatically, including
69
+
UUID-suffixed leftovers of an already-adopted mapping on a later plain push.
70
+
Edited/unbaselined files need per-file y/N approval in a terminal and stop CI.
71
+
The engine never auto-adopts, auto-passes the new-file flag or silently deletes
72
+
edited files.
73
+
74
+
### Names never authorize taking over org resources
75
+
76
+
Pull keeps existing UUID mappings and filenames stable. An unknown UUID always
77
+
gets a separate `<name-slug>-<uuid8>` ID, even if a same-named local file exists.
78
+
Neither pull nor push automatically collapses that key onto a local filename.
79
+
80
+
A file without a state mapping remains subject to the new-file gate. After
81
+
confirming it is genuinely new, preview `--dry-run --allow-new-files` and review
82
+
the final **Name collisions** list. It compares every planned POST, including
83
+
auto-created dependencies, with state and live dashboard names. Matching names
84
+
do not change the plan into a takeover. GETs run; platform mutations do not.
85
+
86
+
To take over a resource intentionally, obtain explicit human approval and use
87
+
`--adopt <id>[=<uuid>]`. Adoption links an untracked local file before the gate
88
+
and normal PATCH flow. Dependency alias reuse is restricted to state entries
89
+
with `origin: pushed` or `origin: adopted`; pulled and legacy entries do not
90
+
authorize new name-based links. Existing exact-key legacy links remain intact.
46
91
47
92
## Conflicts and the drift gate
48
93
@@ -53,7 +98,7 @@ Before updating a resource, push GETs its current dashboard payload, hashes it,
53
98
-**Hashes match** → your local edit is the natural next step in the change chain → pushed silently, and the baseline is refreshed from the PATCH **response** (what the platform actually stored).
54
99
-**Hashes differ** → someone else published changes since your last sync. In a terminal, push asks **for that resource only**: ① push my local version (take ownership) ② keep the dashboard version (skip, local untouched) ③ save the dashboard version as `<name>.<TIMESTAMP>.bkp.<ext>` beside your file and skip, for a manual merge. In CI / piped runs the resource is blocked instead (use `--overwrite` to push unconditionally).
55
100
56
-
Backup copies (`*.bkp.*`, gitignored) are merge reference material only — invisible to the loader, the orphan gate, audit, the interactive picker, and explicit CLI paths.
101
+
Backup copies (`*.bkp.*`, gitignored) are merge reference material only — invisible to the loader, the new-file check, audit, the interactive picker, and explicit CLI paths.
57
102
58
103
## Reading pull and push output
59
104
@@ -77,7 +122,7 @@ Mental model: `⬆️` flows UP (push), `⬇️` flows DOWN (pull), `📝` is th
77
122
78
123
## Listing completeness
79
124
80
-
Vapi list endpoints cap a response at 100 items and expose no page cursor — only `createdAt` comparison filters. The engine pages backwards through `createdAt` until it gets a short page, so pull, push's invalid-mapping detection, `delete`'s orphan sweep, `audit`, and the credential reverse-map all see the whole type instead of the first hundred. When completeness cannot be proven — an endpoint that ignores the cursor params, a payload with no `createdAt`, or the page-count backstop — the engine says so on stderr. Treat that warning as "do not infer deletion from absence for this type".
125
+
Vapi list endpoints cap a response at 100 items and expose no page cursor — only `createdAt` comparison filters. The engine pages backwards through `createdAt` until it gets a short page, so pull, push's invalid-mapping detection, `delete`'s missing-file sweep, `audit`, and the credential reverse-map all see the whole type instead of the first hundred. When completeness cannot be proven — an endpoint that ignores the cursor params, a payload with no `createdAt`, or the page-count backstop — the engine says so on stderr. Treat that warning as "do not infer deletion from absence for this type".
81
126
82
127
## Processing Order
83
128
@@ -144,6 +189,8 @@ Tracks resource ID ↔ Vapi UUID mappings per org:
144
189
```
145
190
146
191
Every resource type has a section. Keys are sorted, so diffs stay readable.
192
+
New entries record `origin: pushed`, `pulled`, or `adopted`. Updates preserve
193
+
that provenance, and legacy entries without an origin are not backfilled.
0 commit comments