Repository navigation
Commit 00285a1
feat(state): keep engine state in state/<org>/ (#109)
* feat(state): keep engine state in state/<org>/
Everything the engine generates and tracks sat under dot-names in three
places: .vapi-state.<org>.json, .vapi-state.<org>.snapshots/ and
.vapi-state-hash/ at the repository root, and .vapi-org.json inside
resources/<org>/. It now lives in state/<org>/: state.json and org.json are
committed, local/baselines and local/snapshots stay on the machine.
An older repository keeps working. Every command reads the old places. The
next pull, push or apply on a person's machine moves the org, one rename
per file, and prints one line. The move is held back in a CI run and while
a workflow stages .vapi-state.*.json but not state/, because either would
commit the old file's removal without the new file. The promotion workflow
stages both places.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs: describe the state/ folder and how an older repository moves into it
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* docs(improvements): point entry 39 at its pull request
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test: leave state/ as it was after a test run
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(state): move state only under a commit step seen to stage state/
The guard that holds the move back looked for one known-bad pattern: a
"git add" line naming .vapi-state. with none naming state. A commit step
it couldn't read (a helper script, a commit action with a file pattern, a
pipeline outside GitHub Actions) passed as safe. A command on a person's
machine then moved state, and every later promotion run passed while
state/<org>/state.json was never committed, so resources were created
again as duplicates.
The move now fails closed. State moves by itself only when a workflow is
seen to stage state/, or when nothing in the repository commits state
after a run: no workflow that can write to the repository, and no root
promotion.yml. A CI run stops before any request when it would write
state in a place its commit step isn't seen to stage. In GitHub Actions
it reads the workflow that is running it.
npm run migrate, where nothing is seen to stage state/, prints the two
paths the commit step has to stage and moves nothing. A person who has
updated their step says so with --commit-step-stages-state, which is
recorded in state/commit-step.json. The engine can't check that word.
Docs: what counts as seen, the limit of the flag, what a customer sees
after upgrading, and how to go back to an older engine without creating
duplicates.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(state): only migrate moves committed state
An org is in one layout, decided by where its committed state file is.
Pull, push, apply and promote read and write the layout they find, on a
person's machine and in CI, and print one line saying the newer one
exists. npm run migrate is the only command that moves state, after
saying what the commit step has to stage.
The commit-step reader fails closed: a git add counts only as a plain
command at the repository root that names state or stages everything.
With nothing seen, migrate asks for --commit-step-stages-state.
Pull no longer reads "edited since the last sync" off the state file's
timestamp, which in a fresh clone is the order git wrote the files in.
It compares against the moment this machine's engine last saved state,
and a clone with no such save keeps every file.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix: keep the test suite out of the repository it runs in, and engine files out of pull's local edits
Running the test suite in a repository with a state file at its root removed
the repository: two tests cleaned up two folders above the engine's
baselines folder, and in the older layout that is the repository root.
The engine's directory now comes from one place, src/base-dir.ts. The test
preload points it at a temporary directory, makes every node:fs change
inside the repository throw, and the engine refuses a test started without
the preload. A new test runs the whole suite inside a copy of a
customer-shaped repository in the older layout, in state/, and with no
state, and compares every tracked, untracked and ignored file before and
after. That run found one more writer, tests/org-connection.test.ts, which
created tmp/ in the repository.
Pull's keep rule for a file with no baseline is off whenever git shows a
change under resources/<org>/. The engine's own files there (the org pin in
the older layout, also shown as deleted between migrate and its commit) are
no longer counted.
A repository with no state whose commit step can't be read still gets its
first state file at the root, and the command now says where the file goes,
why, and what has to stage it.
The upgrade guide gains one line: on a machine with no baselines, the first
pull after upgrading can bring a dashboard edit down one pull late.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix: the test sandbox travels with each engine test, and the engine ignores the test runner
The engine refused to start when NODE_TEST_CONTEXT was in its environment
without a sandbox, and the preload npm test adds sandboxed every test file.
Node's test runner sets that variable for every process it starts, so an
engine command started from a repository's own test exited 1, and such a
test could no longer run the engine on its repository or write a file into
it. Both worked before the sandbox existed.
The sandbox is now a module, tests/engine-sandbox.ts, that every engine
test file imports first: the temporary directory for the engine and the
node:fs guard on the repository. It holds however the file is started, by
hand without the preload included. tests/no-vapi-api.ts is what it was
before the sandbox, and src/base-dir.ts never looks at the test runner's
environment. A test file that doesn't import the module is left alone: the
commands it starts and the engine modules it imports work in its
repository, and it writes where it likes.
In the engine's own repository (a runner whose GITHUB_REPOSITORY is
VapiAI/gitops, or a clone whose origin is) a test file without the import
fails the suite. In any other repository that check is skipped.
tests/base-dir.test.ts fails when a module under src/ works out the
repository's directory for itself.
npm test no longer starts a test runner inside a test. The suite run
inside copies of a customer-shaped repository, and the other tests that
start a runner of their own, move to tests/repository/ and run with
npm run test:repository, one file at a time, and as a CI job in the
engine's own repository. A suite inside a suite tripled the time npm test
took and reached the twenty-second limits some tests give a command
sooner on a slow machine. Each copy now holds a test of the customer's
own and runs the engine's test files only.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* test: ask for the sandbox import only in CI for the engine's own repository
The check that every test file imports tests/engine-sandbox.ts first was
also asked on a person's machine, wherever origin pointed at VapiAI/gitops.
A repository cloned straight from the engine's keeps that origin, so a test
of its owner's under tests/ made one engine test fail in npm test. Before
the sandbox existed it passed.
The check is now asked only where GITHUB_REPOSITORY is VapiAI/gitops, which
is CI for the engine's own repository. A contributor who leaves the import
out finds out on the pull request. GITHUB_REPOSITORY=VapiAI/gitops npm test
asks it on a machine.
Tests and docs only.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
* fix(state): integrate rebased state layout with main
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: Dhruva Reddy <dhruva@vapi.ai>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 4f41c23 commit 00285a1
137 files changed
Lines changed: 6375 additions & 584 deletions
File tree
- .conductor
- .github/workflows
- docs
- guides
- learnings
- examples
- cross-org-promotion
- state
- example-dev
- example-production
- example-staging
- starter/state/starter
- src
- state
- tests
- fixtures/check-parity/state/parity
- repository
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
42 | 64 | | |
43 | 65 | | |
44 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
114 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
118 | | - | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | | - | |
| 129 | + | |
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
| |||
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
148 | | - | |
| 151 | + | |
149 | 152 | | |
150 | 153 | | |
151 | 154 | | |
| |||
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
158 | | - | |
| 161 | + | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
| |||
372 | 375 | | |
373 | 376 | | |
374 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
375 | 386 | | |
376 | 387 | | |
377 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
209 | 211 | | |
210 | | - | |
211 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
| |||
286 | 290 | | |
287 | 291 | | |
288 | 292 | | |
289 | | - | |
| 293 | + | |
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
| |||
300 | 304 | | |
301 | 305 | | |
302 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
303 | 310 | | |
304 | 311 | | |
305 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
0 commit comments