@@ -193,7 +193,13 @@ The test-call CLI cleans its terminal output for the developer loop:
193193
194194## Upgrading from an older version
195195
196- ` npm run migrate ` brings an older repository up to date. It needs no org and
196+ Upgrading the engine does not change where your state is kept. A repository
197+ with ` .vapi-state.<org>.json ` at its root keeps it there: ` pull ` , ` push ` ,
198+ ` apply ` and ` promote ` read and write it in place, on your machine and in CI,
199+ for as long as you like. Each of those commands prints one line saying the
200+ newer layout exists.
201+
202+ ` npm run migrate ` is the only command that moves state. It needs no org and
197203no API key, and it's safe to run more than once:
198204
199205``` bash
@@ -202,10 +208,25 @@ git add -A -- state ':(glob).vapi-state.*.json' resources
202208git commit -m " chore: move engine state into state/"
203209```
204210
205- It does two things.
211+ It does three things.
212+
213+ ** Says what your commit step has to stage, before it moves anything.** A
214+ promotion or apply run in CI writes the state file and leaves committing it
215+ to a later step. If that step stages only the old file, moved state drops out
216+ of git: every run still passes, and the next one creates every resource
217+ again. Once state is in ` state/ ` , whatever commits state after a run has to
218+ stage both of these:
206219
207- ** Moves engine files into ` state/<org>/ ` .** They used to sit under dot-names
208- in three places. Nothing changes inside the files.
220+ ``` bash
221+ git add -A -- state # the new folder
222+ git add -A -- ' :(glob).vapi-state.*.json' # the old files, so their removal is committed
223+ ```
224+
225+ A commit action or a script needs the same two paths. Upstream's
226+ ` .github/workflows/promotion.yml ` has both.
227+
228+ ** Moves engine files into ` state/<org>/ ` ,** when it can see that step or you
229+ tell it. Nothing changes inside the files.
209230
210231| Before | Now |
211232| --- | --- |
@@ -214,38 +235,17 @@ in three places. Nothing changes inside the files.
214235| ` .vapi-state-hash/<org>/ ` | ` state/<org>/local/baselines/ ` |
215236| ` .vapi-state.<org>.snapshots/ ` | ` state/<org>/local/snapshots/ ` |
216237
217- You don't have to run it for this: the engine keeps reading the old places,
218- and the next ` pull ` , ` push ` or ` apply ` on your machine moves that org and
219- says so in one line. Either way, commit the removal of the old file together
220- with the new folder.
221-
222- ** State moves only when the engine can see it will still be committed.** A
223- promotion run in CI writes the state file and leaves committing it to a later
224- step. If that step stages only the old file, a move takes the UUID map out of
225- git: every run still passes, and the next one creates every resource again.
226- So the move is held back in three cases, and the command tells you which:
227-
228- - ** In a CI run.** State stays where it is and is updated in place. Run
229- ` npm run migrate ` on your machine and commit the result.
230- - ** When a workflow under ` .github/workflows/ ` stages ` .vapi-state.*.json ` but
231- not ` state/ ` .** That workflow would commit the old file's removal without
232- the new one. Take upstream's ` promotion.yml ` workflow, or add
233- ` git add -A -- state ` to your own commit step, then run ` npm run migrate ` .
234- - ** When something may commit state and the engine can't see it stage
235- ` state/ ` .** That is a workflow that can write to the repository and has no
236- ` git add ` line for ` state ` (it stages through a script, a commit action or
237- a variable), or a root ` promotion.yml ` with no workflow in the repository
238- that stages ` state/ ` (the pipeline runs somewhere the engine can't read).
239- ` npm run migrate ` then moves nothing and prints what the commit step has to
240- stage:
241-
242- ``` bash
243- git add -A -- state # the new folder
244- git add -A -- ' :(glob).vapi-state.*.json' # the old files, so their removal is committed
245- ```
238+ What it does depends on what it reads in ` .github/workflows/ ` :
246239
247- A commit action or a script needs the same two paths. When your step
248- stages both, say so:
240+ - ** Every commit step there stages ` state/ ` .** It moves every org.
241+ - ** A step stages ` .vapi-state.*.json ` and nothing that could be ` state/ ` .**
242+ It moves nothing and names the workflow. Take upstream's ` promotion.yml `
243+ workflow, or add ` git add -A -- state ` to your own commit step, then run
244+ ` npm run migrate ` again.
245+ - ** Anything else.** A step that stages through a script, a commit action or
246+ a variable, a repository with no workflow, or a pipeline in another CI
247+ system. It moves nothing and asks you. When your step stages both paths,
248+ say so:
249249
250250 ``` bash
251251 npm run migrate -- --commit-step-stages-state
@@ -254,49 +254,87 @@ So the move is held back in three cases, and the command tells you which:
254254 That writes ` state/commit-step.json ` and moves every org. Commit it with
255255 the move.
256256
257- What counts as seen: a ` git add ` line in a workflow file that names ` state `
258- (or ` state/ ` , ` state/** ` ), or one that stages everything (` git add -A ` ,
259- ` git add . ` ). A workflow whose ` permissions ` keep ` contents ` read-only, and
260- that never runs ` git commit ` or ` git push ` , is not a commit step, so
261- upstream's ` ci.yml ` and ` vapi-checks.yml ` hold nothing back.
262-
263- A CI run also stops, before it sends any request, when it would write state
264- in a place its commit step isn't seen to stage: state already in ` state/ `
265- under a step that stages only the old file or can't be read, or state still
266- at the root under a step that stages only ` state/ ` . In GitHub Actions the
267- engine checks the workflow that is running it. Anywhere else it checks every
268- workflow in the repository.
269-
270257> ** ` --commit-step-stages-state ` is your word, and the engine can't check
271258> it.** If you pass it and your commit step does not stage ` state/ ` ,
272259> promotion runs pass while ` state/<org>/state.json ` is never committed, and
273260> a later run creates the same resources again. The flag is refused only when
274261> a workflow is plainly seen to stage the old file alone. To take it back,
275262> delete ` state/commit-step.json ` .
276263
277- If both the old and the new file exist for an org and they disagree, every
278- writing command stops before it changes anything and names the two files.
279-
280264** Rewrites a legacy-format state file.** Repositories created before the
281265state-file format changed carry per-resource hashes in the state file, and
282266` pull ` , ` push ` and ` apply ` refuse to run until they're gone. ` migrate `
283267rewrites each file to the current ` { "name": { "uuid": … } } ` format and
284268seeds this machine's drift baselines from the old file.
285269
270+ ### What the engine reads as a commit step
271+
272+ The engine reads the workflow files in ` .github/workflows/ ` and nothing else.
273+ It counts a ` git add ` as staging ` state/ ` only where it can tell what the
274+ command stages:
275+
276+ - It is a command of its own in a ` run: ` step that runs ` bash ` or ` sh ` at
277+ the repository root.
278+ - It names ` state ` (also ` state/ ` or ` state/** ` ), or it stages everything:
279+ ` git add -A ` , ` git add --all ` , ` git add . ` .
280+ - An ` if ` around it is fine when it names ` state ` , because that is how a step
281+ guards a folder that may not exist yet.
282+
283+ Everything else counts for nothing: a ` git add ` after a ` cd ` , in a step with
284+ a ` working-directory ` , after ` || ` , inside a loop, a function or a quoted
285+ string, with ` -u ` , with a variable or an exclusion in its paths, or a
286+ ` git add -A ` inside an ` if ` . A step like that may well work. The engine just
287+ can't tell, so ` migrate ` asks for the flag.
288+
289+ Every job that shows a commit step has to pass, in every workflow file. A job
290+ shows none when its ` permissions ` keep ` contents ` read-only and it runs no
291+ ` git add ` , ` git commit ` or ` git push ` , so upstream's ` ci.yml ` and
292+ ` vapi-checks.yml ` don't get in the way.
293+
294+ A pipeline the engine has no file for is never read: another CI system, or a
295+ script that commits with its own token. Check it yourself against the two
296+ lines above before you run ` migrate ` .
297+
298+ ### When a CI run stops
299+
300+ A CI run stops, before it sends any request, when the workflow running it is
301+ seen not to commit what it would write:
302+
303+ - State is in ` state/ ` , and the commit step stages only the old file.
304+ - State is in ` state/ ` , the commit step can't be read, and there is no
305+ ` state/commit-step.json ` .
306+ - State is still at the root, and the commit step stages only ` state/ ` .
307+
308+ In GitHub Actions the engine checks the workflow that is running it. Anywhere
309+ else it checks every workflow in the repository.
310+
311+ If both the old and the new file exist for an org and they disagree, every
312+ writing command stops before it changes anything and names the two files. If
313+ they hold the same content, the engine reads the one in ` state/ ` , keeps the
314+ old copy identical, and says that ` npm run migrate ` removes it.
315+
286316### What you'll see after upgrading
287317
288- - ** ` 📦 Moved … into state/<org>/ ` ** , once per org, on the first ` pull ` ,
289- ` push ` or ` apply ` on your machine.
290- - ** ` 📦 1 locally modified file(s) will be preserved ` ** on the first ` pull `
291- after the move. The file is the old org pin,
318+ - ** ` ℹ️ Engine state here is in the older layout … ` ** , one line per writing
319+ command, until you run ` npm run migrate ` . Nothing else changes.
320+
321+ After ` npm run migrate ` :
322+
323+ - ** ` 📦 Moved … into state/<org>/ ` ** , once per org, from ` migrate ` itself.
324+ - ** ` 📦 1 locally modified file(s) will be preserved ` ** on a ` pull ` before you
325+ commit the move. The file is the old org pin,
292326 ` resources/<org>/.vapi-org.json ` . It moved to ` state/<org>/org.json ` , so git
293327 shows it as deleted until you commit. Pull does nothing differently because
294328 of it.
295- - ** ` … stays where it is: … ` ** on every writing command while the move is
296- held back. The line says why.
329+ - ** ` 📦 Moved .vapi-state-hash/<org>/ … into state/<org>/local/ ` ** , once, on
330+ each teammate's machine after they pull your commit. Those are that
331+ machine's own baselines and snapshots, which are not in git.
297332
298333### Going back to an older engine
299334
335+ A repository that never ran ` npm run migrate ` has nothing to move back: its
336+ state is where an older engine looks for it.
337+
300338An engine from before ` state/ ` doesn't read the folder. If you revert the
301339engine after state has moved, it finds no state file: ` pull ` adopts every
302340resource again under a new file name, and promotion creates each resource a
0 commit comments