@@ -109,7 +109,13 @@ The test-call CLI cleans its terminal output for the developer loop:
109109
110110## Upgrading from an older version
111111
112- ` npm run migrate ` brings an older repository up to date. It needs no org and
112+ Upgrading the engine does not change where your state is kept. A repository
113+ with ` .vapi-state.<org>.json ` at its root keeps it there: ` pull ` , ` push ` ,
114+ ` apply ` and ` promote ` read and write it in place, on your machine and in CI,
115+ for as long as you like. Each of those commands prints one line saying the
116+ newer layout exists.
117+
118+ ` npm run migrate ` is the only command that moves state. It needs no org and
113119no API key, and it's safe to run more than once:
114120
115121``` bash
@@ -118,10 +124,25 @@ git add -A -- state ':(glob).vapi-state.*.json' resources
118124git commit -m " chore: move engine state into state/"
119125```
120126
121- It does two things.
127+ It does three things.
128+
129+ ** Says what your commit step has to stage, before it moves anything.** A
130+ promotion or apply run in CI writes the state file and leaves committing it
131+ to a later step. If that step stages only the old file, moved state drops out
132+ of git: every run still passes, and the next one creates every resource
133+ again. Once state is in ` state/ ` , whatever commits state after a run has to
134+ stage both of these:
122135
123- ** Moves engine files into ` state/<org>/ ` .** They used to sit under dot-names
124- in three places. Nothing changes inside the files.
136+ ``` bash
137+ git add -A -- state # the new folder
138+ git add -A -- ' :(glob).vapi-state.*.json' # the old files, so their removal is committed
139+ ```
140+
141+ A commit action or a script needs the same two paths. Upstream's
142+ ` .github/workflows/promotion.yml ` has both.
143+
144+ ** Moves engine files into ` state/<org>/ ` ,** when it can see that step or you
145+ tell it. Nothing changes inside the files.
125146
126147| Before | Now |
127148| --- | --- |
@@ -130,38 +151,17 @@ in three places. Nothing changes inside the files.
130151| ` .vapi-state-hash/<org>/ ` | ` state/<org>/local/baselines/ ` |
131152| ` .vapi-state.<org>.snapshots/ ` | ` state/<org>/local/snapshots/ ` |
132153
133- You don't have to run it for this: the engine keeps reading the old places,
134- and the next ` pull ` , ` push ` or ` apply ` on your machine moves that org and
135- says so in one line. Either way, commit the removal of the old file together
136- with the new folder.
137-
138- ** State moves only when the engine can see it will still be committed.** A
139- promotion run in CI writes the state file and leaves committing it to a later
140- step. If that step stages only the old file, a move takes the UUID map out of
141- git: every run still passes, and the next one creates every resource again.
142- So the move is held back in three cases, and the command tells you which:
143-
144- - ** In a CI run.** State stays where it is and is updated in place. Run
145- ` npm run migrate ` on your machine and commit the result.
146- - ** When a workflow under ` .github/workflows/ ` stages ` .vapi-state.*.json ` but
147- not ` state/ ` .** That workflow would commit the old file's removal without
148- the new one. Take upstream's ` promotion.yml ` workflow, or add
149- ` git add -A -- state ` to your own commit step, then run ` npm run migrate ` .
150- - ** When something may commit state and the engine can't see it stage
151- ` state/ ` .** That is a workflow that can write to the repository and has no
152- ` git add ` line for ` state ` (it stages through a script, a commit action or
153- a variable), or a root ` promotion.yml ` with no workflow in the repository
154- that stages ` state/ ` (the pipeline runs somewhere the engine can't read).
155- ` npm run migrate ` then moves nothing and prints what the commit step has to
156- stage:
157-
158- ``` bash
159- git add -A -- state # the new folder
160- git add -A -- ' :(glob).vapi-state.*.json' # the old files, so their removal is committed
161- ```
154+ What it does depends on what it reads in ` .github/workflows/ ` :
162155
163- A commit action or a script needs the same two paths. When your step
164- stages both, say so:
156+ - ** Every commit step there stages ` state/ ` .** It moves every org.
157+ - ** A step stages ` .vapi-state.*.json ` and nothing that could be ` state/ ` .**
158+ It moves nothing and names the workflow. Take upstream's ` promotion.yml `
159+ workflow, or add ` git add -A -- state ` to your own commit step, then run
160+ ` npm run migrate ` again.
161+ - ** Anything else.** A step that stages through a script, a commit action or
162+ a variable, a repository with no workflow, or a pipeline in another CI
163+ system. It moves nothing and asks you. When your step stages both paths,
164+ say so:
165165
166166 ``` bash
167167 npm run migrate -- --commit-step-stages-state
@@ -170,49 +170,87 @@ So the move is held back in three cases, and the command tells you which:
170170 That writes ` state/commit-step.json ` and moves every org. Commit it with
171171 the move.
172172
173- What counts as seen: a ` git add ` line in a workflow file that names ` state `
174- (or ` state/ ` , ` state/** ` ), or one that stages everything (` git add -A ` ,
175- ` git add . ` ). A workflow whose ` permissions ` keep ` contents ` read-only, and
176- that never runs ` git commit ` or ` git push ` , is not a commit step, so
177- upstream's ` ci.yml ` and ` vapi-checks.yml ` hold nothing back.
178-
179- A CI run also stops, before it sends any request, when it would write state
180- in a place its commit step isn't seen to stage: state already in ` state/ `
181- under a step that stages only the old file or can't be read, or state still
182- at the root under a step that stages only ` state/ ` . In GitHub Actions the
183- engine checks the workflow that is running it. Anywhere else it checks every
184- workflow in the repository.
185-
186173> ** ` --commit-step-stages-state ` is your word, and the engine can't check
187174> it.** If you pass it and your commit step does not stage ` state/ ` ,
188175> promotion runs pass while ` state/<org>/state.json ` is never committed, and
189176> a later run creates the same resources again. The flag is refused only when
190177> a workflow is plainly seen to stage the old file alone. To take it back,
191178> delete ` state/commit-step.json ` .
192179
193- If both the old and the new file exist for an org and they disagree, every
194- writing command stops before it changes anything and names the two files.
195-
196180** Rewrites a legacy-format state file.** Repositories created before the
197181state-file format changed carry per-resource hashes in the state file, and
198182` pull ` , ` push ` and ` apply ` refuse to run until they're gone. ` migrate `
199183rewrites each file to the current ` { "name": { "uuid": … } } ` format and
200184seeds this machine's drift baselines from the old file.
201185
186+ ### What the engine reads as a commit step
187+
188+ The engine reads the workflow files in ` .github/workflows/ ` and nothing else.
189+ It counts a ` git add ` as staging ` state/ ` only where it can tell what the
190+ command stages:
191+
192+ - It is a command of its own in a ` run: ` step that runs ` bash ` or ` sh ` at
193+ the repository root.
194+ - It names ` state ` (also ` state/ ` or ` state/** ` ), or it stages everything:
195+ ` git add -A ` , ` git add --all ` , ` git add . ` .
196+ - An ` if ` around it is fine when it names ` state ` , because that is how a step
197+ guards a folder that may not exist yet.
198+
199+ Everything else counts for nothing: a ` git add ` after a ` cd ` , in a step with
200+ a ` working-directory ` , after ` || ` , inside a loop, a function or a quoted
201+ string, with ` -u ` , with a variable or an exclusion in its paths, or a
202+ ` git add -A ` inside an ` if ` . A step like that may well work. The engine just
203+ can't tell, so ` migrate ` asks for the flag.
204+
205+ Every job that shows a commit step has to pass, in every workflow file. A job
206+ shows none when its ` permissions ` keep ` contents ` read-only and it runs no
207+ ` git add ` , ` git commit ` or ` git push ` , so upstream's ` ci.yml ` and
208+ ` vapi-checks.yml ` don't get in the way.
209+
210+ A pipeline the engine has no file for is never read: another CI system, or a
211+ script that commits with its own token. Check it yourself against the two
212+ lines above before you run ` migrate ` .
213+
214+ ### When a CI run stops
215+
216+ A CI run stops, before it sends any request, when the workflow running it is
217+ seen not to commit what it would write:
218+
219+ - State is in ` state/ ` , and the commit step stages only the old file.
220+ - State is in ` state/ ` , the commit step can't be read, and there is no
221+ ` state/commit-step.json ` .
222+ - State is still at the root, and the commit step stages only ` state/ ` .
223+
224+ In GitHub Actions the engine checks the workflow that is running it. Anywhere
225+ else it checks every workflow in the repository.
226+
227+ If both the old and the new file exist for an org and they disagree, every
228+ writing command stops before it changes anything and names the two files. If
229+ they hold the same content, the engine reads the one in ` state/ ` , keeps the
230+ old copy identical, and says that ` npm run migrate ` removes it.
231+
202232### What you'll see after upgrading
203233
204- - ** ` 📦 Moved … into state/<org>/ ` ** , once per org, on the first ` pull ` ,
205- ` push ` or ` apply ` on your machine.
206- - ** ` 📦 1 locally modified file(s) will be preserved ` ** on the first ` pull `
207- after the move. The file is the old org pin,
234+ - ** ` ℹ️ Engine state here is in the older layout … ` ** , one line per writing
235+ command, until you run ` npm run migrate ` . Nothing else changes.
236+
237+ After ` npm run migrate ` :
238+
239+ - ** ` 📦 Moved … into state/<org>/ ` ** , once per org, from ` migrate ` itself.
240+ - ** ` 📦 1 locally modified file(s) will be preserved ` ** on a ` pull ` before you
241+ commit the move. The file is the old org pin,
208242 ` resources/<org>/.vapi-org.json ` . It moved to ` state/<org>/org.json ` , so git
209243 shows it as deleted until you commit. Pull does nothing differently because
210244 of it.
211- - ** ` … stays where it is: … ` ** on every writing command while the move is
212- held back. The line says why.
245+ - ** ` 📦 Moved .vapi-state-hash/<org>/ … into state/<org>/local/ ` ** , once, on
246+ each teammate's machine after they pull your commit. Those are that
247+ machine's own baselines and snapshots, which are not in git.
213248
214249### Going back to an older engine
215250
251+ A repository that never ran ` npm run migrate ` has nothing to move back: its
252+ state is where an older engine looks for it.
253+
216254An engine from before ` state/ ` doesn't read the folder. If you revert the
217255engine after state has moved, it finds no state file: ` pull ` adopts every
218256resource again under a new file name, and promotion creates each resource a
0 commit comments