Skip to content

Commit 11f572f

Browse files
devin-ai-integration[bot]dhruva-vapicapy-ai[bot]
authored
feat(validate): flag a credentialIds list that hides one of the org's keys (#110)
* feat(validate): flag a credentialIds list that hides one of the org's keys A credentialIds list is the full set of keys a call may use, pooled across every squad member. A provider left off it runs on Vapi's own key with no error. validate now reports a list that leaves out a key the org has saved for something the call uses: a model, voice or transcriber (and fallbacks), a key a tool or server names, the storage bucket and Langfuse. A provider the org has no key of its own for is left alone. The finding is a warning. It is an error in an org whose resources/<org>/.vapi-policy.yml sets customerKeysOnly: true. Pull now records each credential's provider in resources/<org>/.vapi-credential-providers.json, since the state file only maps names to UUIDs, and warns when two credentials collide on one name. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * feat(promote): warn when omit drops a credentialIds entry An omitted credentialId is neutral. An entry omitted from a credentialIds list narrows which keys calls in the target may use, so the provider it was for falls back to Vapi's own key. The plan now names the entry and the file. 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> * refactor(validate): keep the credential providers record in state/<org>/ The record is written by pull, so it belongs with the rest of the engine's files. The hand-written .vapi-policy.yml stays in resources/<org>/. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(upgrade): say when validate reports credential-pin-unchecked after an upgrade Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(validate): keep the credential providers record where the org's commit step stages it An org whose state is still in the layout from before state/ gets its record at resources/<org>/.vapi-credential-providers.json, beside the old org pin. A commit step written for that layout stages resources/, so the record is committed and validate stops reporting credential-pin-unchecked on every run. An org whose state is in state/<org>/ keeps state/<org>/credential-providers.json. npm run migrate moves the record with the state file and the pin. validateCredentialPins takes the file's name from its caller, so the finding names the file the org actually has. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: the credential providers record is not a local edit to pull In the older layout the record sits in resources/<org>/, and until it is committed git shows it as untracked. Pull leaves the engine's own files out of what it counts as a person's edits, and the record is on that list because migrate moves it. This pins it with a pull in a fresh clone. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: the credential tests import the engine sandbox Every engine test file imports tests/engine-sandbox.ts first. These three are the ones this branch adds. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(state): verify credential pins through push preflight 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 00285a1 commit 11f572f

25 files changed

Lines changed: 1989 additions & 11 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ default-exports the object (safety rule 5).
258258
| Simulation | `personalityId`, `scenarioId` | Personality and scenario files | `scenarioId: books-cleaning` |
259259
| Suite | `simulationIds[]` | Simulation files | `- books-cleaning-calm` |
260260
| Any server block | `credentialId` | A credential **name** in the org | `credentialId: my-api-credential` |
261+
| Assistant, or squad overrides | `credentialIds[]` | Credential **names**. The list is every key the call may use, not one provider's: [credential pins](docs/guides/credential-pins.md) | `- azure-south` |
261262

262263
The engine resolves IDs and credential names to each org's UUIDs on push.
263264

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ when run without arguments. Full flags and examples:
247247
| [Writing system prompts](docs/guides/writing-prompts.md) | Structure a voice agent's prompt |
248248
| [PR checks](docs/guides/pr-checks.md) | Test every pull request with simulations |
249249
| [Promotion](docs/guides/promotion.md) | Move resources from dev to staging to production |
250+
| [Credential pins](docs/guides/credential-pins.md) | Pin a call to specific keys with `credentialIds`, and mark an org customer-keys-only |
250251
| [How the engine works](docs/guides/how-it-works.md) | Understand sync, references, credentials and state |
251252
| [Configuration](docs/guides/configuration.md) | Environment variables and secrets |
252253
| [Troubleshooting](docs/guides/troubleshooting.md) | Fix common errors |

‎docs/guides/commands.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ tell it. Nothing changes inside the files.
233233
| --- | --- |
234234
| `.vapi-state.<org>.json` | `state/<org>/state.json` |
235235
| `resources/<org>/.vapi-org.json` | `state/<org>/org.json` |
236+
| `resources/<org>/.vapi-credential-providers.json` | `state/<org>/credential-providers.json` |
236237
| `.vapi-state-hash/<org>/` | `state/<org>/local/baselines/` |
237238
| `.vapi-state.<org>.snapshots/` | `state/<org>/local/snapshots/` |
238239

@@ -345,6 +346,13 @@ git add state/commit-step.json
345346
baselines yet, the first `pull` after upgrading keeps every local file, and
346347
an edit made in the dashboard comes down on the next `pull`. Nothing is
347348
lost.
349+
- **`credential-pin-unchecked`** from `validate`, once for each org that has a
350+
`credentialIds` list, until that org's credential providers record is
351+
committed. It is a warning and changes no exit code. Run
352+
`npm run pull -- <org> --bootstrap` and commit the file it writes:
353+
`state/<org>/credential-providers.json`, or
354+
`resources/<org>/.vapi-credential-providers.json` while the org's state is
355+
in the older layout. See [credential pins](credential-pins.md).
348356

349357
After `npm run migrate`:
350358

@@ -373,6 +381,7 @@ for dir in state/*/; do
373381
org=$(basename "$dir")
374382
if [ -f "state/$org/state.json" ]; then mv "state/$org/state.json" ".vapi-state.$org.json"; fi
375383
if [ -f "state/$org/org.json" ]; then mv "state/$org/org.json" "resources/$org/.vapi-org.json"; fi
384+
if [ -f "state/$org/credential-providers.json" ]; then mv "state/$org/credential-providers.json" "resources/$org/.vapi-credential-providers.json"; fi
376385
# This machine's baselines and snapshots. They are not in git, so everyone
377386
# who has pulled or pushed since the move runs these two on their machine.
378387
if [ -d "state/$org/local/baselines" ]; then mkdir -p .vapi-state-hash && mv "state/$org/local/baselines" ".vapi-state-hash/$org"; fi

‎docs/guides/configuration.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Set these in GitHub under **Settings → Secrets and variables → Actions**.
4949
| --- | --- |
5050
| `promotion.yml` | Promotion pipelines between orgs. Start from `promotion.example.yml`. |
5151
| `vapi-checks.yml` | PR checks. Start from `vapi-checks.example.yml`. |
52+
| `resources/<org>/.vapi-policy.yml` | Rules the org must hold, written by hand. `customerKeysOnly: true` makes a `credentialIds` list that hides one of the org's keys an error instead of a warning. See [Credential pins](credential-pins.md). |
5253
| `resources/<org>/.vapi-ignore` | Platform resources this repo shouldn't manage, as glob patterns. See `resources/.vapi-ignore.example` and [YAML conventions](../learnings/yaml-conventions.md). |
5354

5455
These are hand-written. The files the engine writes live apart from them, in
@@ -58,6 +59,7 @@ These are hand-written. The files the engine writes live apart from them, in
5859
| --- | --- |
5960
| `state/<org>/state.json` | Which platform resource (UUID) each file under `resources/<org>/` is. |
6061
| `state/<org>/org.json` | The Vapi org ID the folder belongs to. Written by the first command that can see the key's org, then checked by every command before any request: a key for another org stops the command. If a folder genuinely moves to another org, delete the file in a reviewed commit. |
62+
| `state/<org>/credential-providers.json` | The provider of each saved credential, by name. Written by every pull and committed with the state file. It holds no secret. The credential-pin check reads it. While an org's state is in the older layout it is `resources/<org>/.vapi-credential-providers.json`. |
6163

6264
## Other environment variables
6365

‎docs/guides/credential-pins.md‎

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Credential pins: `credentialIds` lists
2+
3+
An assistant, a squad member's `assistantOverrides` and a squad's
4+
`membersOverrides` can each carry a `credentialIds` list. It pins a call to
5+
specific keys, for example one site's Azure OpenAI key in an org that holds a
6+
key per site. This page explains what the list does on a call and what
7+
`npm run validate` checks about it.
8+
9+
## What a list does
10+
11+
A `credentialIds` list is not a choice for one provider. It is the full set
12+
of keys the call may use:
13+
14+
- As soon as any assistant on the call has a list, the call can use only the
15+
listed keys. Every squad member's list is pooled into one list for the
16+
whole call, so a list on one member narrows the other members too.
17+
- A provider whose key is not on the list does not fail. The model, voice or
18+
transcriber runs on Vapi's own key, a tool or server request goes out
19+
without its key, and the recording does not go to your storage bucket.
20+
- The phone number's own credential stays usable whatever the list says.
21+
22+
So a list has to name every key the call needs: the model key, the voice
23+
key, the transcriber key, each key a tool or server names in `credentialId`,
24+
the storage bucket key and the Langfuse key if the org has them.
25+
26+
Lists combine like this:
27+
28+
| Where the list is | What happens |
29+
| --- | --- |
30+
| On the assistant | Kept. Lists from overrides are added to it. |
31+
| In a member's `assistantOverrides` | Used, unless the squad's `membersOverrides` also has a list, which replaces it. |
32+
| In the squad's `membersOverrides` | Applies to every member. |
33+
34+
One list per squad, in `membersOverrides`, is the simplest layout: shared
35+
assistants carry no list, and each squad names its own keys.
36+
37+
```yaml
38+
# resources/<org>/squads/south-front-desk.yml
39+
name: South Front Desk
40+
members:
41+
- assistantId: triage
42+
- assistantId: pharmacy
43+
membersOverrides:
44+
credentialIds:
45+
- azure-south # this site's Azure OpenAI key
46+
- elevenlabs # voice
47+
- deepgram # transcriber
48+
- crm-webhook # the key the lookup tool names
49+
- recordings # storage bucket
50+
```
51+
52+
## What validate checks
53+
54+
`npm run validate -- <org>` (and `apply`, which runs it first) reports a list
55+
that leaves out a key **the org has saved** for something the call uses:
56+
57+
| The call uses | Reported when |
58+
| --- | --- |
59+
| A model, voice or transcriber, or a fallback voice or transcriber | The org has a key for that provider and the list has none. An OpenAI model can run on an `openai` key or an `azure-openai` key, so either on the list is enough. Every other provider takes a key saved under its own name. |
60+
| A tool, server or model that names a key in `credentialId` | That key is not on the list. |
61+
| Storage | The org has a storage bucket key and the list has none. |
62+
| Langfuse | The org has a Langfuse key and the list leaves it out. |
63+
64+
It does not report a provider the org has no key of its own for. Running
65+
that provider on Vapi's key is a normal setup, with or without a list.
66+
67+
A different key for the same provider counts as a key for it. A squad pinned
68+
to one site's Azure OpenAI key is not told about the other sites' keys.
69+
70+
For a squad, the check looks at the call as a whole: the pooled list, and
71+
what every member uses after its overrides are applied. An assistant with a
72+
list of its own is also checked on its own, since it can be called outside a
73+
squad.
74+
75+
The finding is `credential-pin-hides-key`:
76+
77+
```text
78+
⚠️ [credential-pin-hides-key] squads/south-front-desk (credentialIds): the voice of member "triage" and the voice of member "pharmacy" use 11labs, and this org has "elevenlabs" saved for it, but the call's credentialIds list ("azure-south", "deepgram") has no key for 11labs. A call that has a credentialIds list can use only the keys on it, so 11labs would run on Vapi's own key, not yours. Add the key to the list
79+
```
80+
81+
### Limits
82+
83+
- The check reads files. A squad member that is not a file in the org's
84+
folder (a dashboard-owned assistant) adds nothing to it.
85+
- It knows each key's provider, not which models or regions the key covers.
86+
A list with an Azure OpenAI key that does not serve the assistant's model
87+
passes.
88+
- A tool or server with no `credentialId` is not checked.
89+
- Lists added at call time (`assistantOverrides` on a call or a phone
90+
number) are outside the repo and are not seen.
91+
92+
## Orgs that must only use their own keys
93+
94+
By default the finding is a warning. For an org whose calls must never run
95+
on Vapi's keys, add a policy file and commit it:
96+
97+
```yaml
98+
# resources/<org>/.vapi-policy.yml
99+
customerKeysOnly: true
100+
```
101+
102+
In that org the finding is an error: `validate` fails, `apply` stops before
103+
it pulls or pushes, and the **Validate resources** check fails on the pull
104+
request. `npm run push` on its own only blocks on errors with `--strict`,
105+
like every other validation error.
106+
107+
The policy belongs to one org. Promotion does not copy it, so set it in each
108+
org that needs it. An unknown key in the file stops `validate`, so a typo
109+
can't switch the rule off.
110+
111+
The policy makes a hidden key an error. It does not require the org to have
112+
a key for every provider it uses.
113+
114+
## How the check knows what each key is for
115+
116+
The state file maps a credential's name to its UUID and nothing else. Pull
117+
also records each key's provider in
118+
`state/<org>/credential-providers.json`:
119+
120+
```json
121+
{
122+
"azure-south": { "provider": "azure-openai" },
123+
"elevenlabs": { "provider": "11labs" },
124+
"recordings": { "bucket": true, "provider": "azure" }
125+
}
126+
```
127+
128+
Commit it with the state file. It holds no secret. Every pull rewrites it,
129+
including `npm run pull -- <org> --bootstrap`, which changes no resource
130+
file. If the file is missing or older than the state file, the check reports
131+
`credential-pin-unchecked` and asks for that pull.
132+
133+
In a repository whose state is still in the layout from before `state/`, the
134+
file is `resources/<org>/.vapi-credential-providers.json` instead, which the
135+
commit step that repository already has stages with the folder. `npm run
136+
migrate` moves it with the rest: see
137+
[Upgrading from an older version](commands.md#upgrading-from-an-older-version).
138+
139+
Give every key a name in Vapi before the first pull. Two keys with no name
140+
and the same provider get the same name here, and only one is kept. Pull
141+
warns when that happens.
142+
143+
## Promotion
144+
145+
A credential with the binding policy `omit` is dropped from a promoted file.
146+
For a single `credentialId` that is the point. For an entry in a
147+
`credentialIds` list it narrows what calls in the destination may use, so
148+
the plan says so:
149+
150+
```text
151+
release: dev → prod
152+
update squads/south-front-desk.yml
153+
⚠️ squads/south-front-desk.yml: credentialIds entry "elevenlabs" is left out in prod (binding policy "omit"). Calls there can use only the keys still on the list, so that provider would run on Vapi's own key.
154+
```
155+
156+
See [Promotion](promotion.md) for bindings.

‎docs/guides/how-it-works.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ Credentials are managed automatically through the state file. No secrets in reso
160160
2. Resource files use human-readable credential names
161161
3. **Push** resolves names back to UUIDs before sending to the API
162162

163+
Pull also records each credential's provider in
164+
`state/<org>/credential-providers.json`, so `validate` can check a
165+
`credentialIds` list against the keys the org has: see
166+
[Credential pins](credential-pins.md).
167+
163168
Setup and pull also refresh a marked block in the gitignored `.env.<org>` file:
164169

165170
```dotenv

‎docs/guides/promotion.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ left alone.
2121
5. Choose `bind` or `omit` for credentials and phone numbers in each target
2222
org. Pull generates stable aliases in `.env.<org>` from resources that
2323
already exist there; promotion never copies secrets or provisions numbers.
24+
An `omit` that drops an entry from a `credentialIds` list is flagged in the
25+
plan, because it narrows which keys calls in the target may use: see
26+
[Credential pins](credential-pins.md#promotion).
2427
6. Run the read-only plan for each transition before the first apply and
2528
confirm every create, update, and delete is expected.
2629

‎docs/learnings/squads.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ The final assistant configuration is built by merging these layers in order:
165165

166166
Later layers win on conflicts. `variableValues` from all layers are merged separately.
167167

168+
`credentialIds` follows the same order with one difference: a list on the base assistant is kept and the override's list is added to it, while `squad.membersOverrides.credentialIds` replaces `member.assistantOverrides.credentialIds`.
169+
170+
**Gotcha:** a `credentialIds` list anywhere in the squad narrows the whole call to the listed keys, for every member and every provider. A provider left off runs on Vapi's own key with no error. List every key the call needs, and let `npm run validate` check it: see [Credential pins](../guides/credential-pins.md).
171+
168172
**Gotcha:** Liquid template substitution replaces undefined variables with **empty strings**, not errors. If a variable isn't in the merged `variableValues`, any `{{ myVar }}` reference silently becomes `""`.
169173

170174
---

‎improvements.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ you which stack PR closes the row.**
110110
| 37 | Resource validation ran only at deploy time, after merge | A config `apply` refuses could merge and block deploys and promotion | #32 | RESOLVED 2026-10-03 (#76) |
111111
| 38 | Promotion can't carry a simulation that uses a stock personality by UUID | Gated orgs, and any promoted tests, need local personality files | None | Open |
112112
| 39 | Engine state looked like temp files and sat in three places | Deleting the state file makes the next push duplicate every resource | None | RESOLVED 2026-11-17 (#97) |
113+
| 40 | Nothing checked a `credentialIds` list against the keys an org has saved | A list that hides the org's own key runs the call on Vapi's key, silently | None | RESOLVED 2026-11-17 (#96) |
113114

114115
**Active backlog after cleanup:** `#2`, `#6`, `#8`, `#12`, `#20`, `#24–#26`, `#31`, and the open remainder of `#27` (wiring the listing-completeness verdict into push/delete/audit, and moving `cleanup.ts` onto the shared pager). Resolved entries stay in this file as historical incident notes per the maintenance directive; stale superseded backlog rows are not duplicated.
115116

@@ -2203,6 +2204,64 @@ run's hand-off to the workflow, and an older workflow reads it there.
22032204

22042205
---
22052206

2207+
## 40. Nothing checked a `credentialIds` list against the keys an org has saved
2208+
2209+
**[RESOLVED 2026-11-17] (#96)**
2210+
2211+
**Discovered:** 2026-11-17, while planning one squad per site in an org that
2212+
holds an Azure OpenAI key per site.
2213+
2214+
### Problem
2215+
2216+
A `credentialIds` list is the full set of keys a call may use, and every
2217+
squad member's list is pooled into one. A provider left off the list does
2218+
not fail the call: it runs on Vapi's own key. The engine could not tell a
2219+
complete list from one that hides the org's own voice, transcriber or
2220+
storage key.
2221+
2222+
### Current behavior (Verified)
2223+
2224+
- The state file records `name → uuid` for a credential and nothing else,
2225+
so the engine did not know which provider a saved key is for.
2226+
- `validate` only checked that each name on a list exists in the state file.
2227+
- Promotion dropped a `credentialIds` entry whose binding policy is `omit`
2228+
without saying so.
2229+
- Two credentials with no name and the same provider get the same slug on
2230+
pull, and the second silently replaces the first in the state file.
2231+
2232+
### Risk
2233+
2234+
An org that must run only on its own keys sends audio or prompts to Vapi's
2235+
provider accounts when one entry is missed in one squad file, with nothing
2236+
in the push output or the call to show it.
2237+
2238+
### Current mitigation
2239+
2240+
None before this change, other than reading every list by hand.
2241+
2242+
### Possible fix
2243+
2244+
Record each credential's provider on pull, report a list that leaves out a
2245+
key the org has saved for something the call uses, and let an org mark
2246+
itself customer-keys-only so the report is an error there.
2247+
2248+
### Status
2249+
2250+
**RESOLVED 2026-11-17.** Pull writes
2251+
`state/<org>/credential-providers.json`
2252+
(`resources/<org>/.vapi-credential-providers.json` while the org's state is
2253+
in the older layout) and warns when two
2254+
credentials collide on one name. `validate` has the
2255+
`credential-pin-hides-key` rule, an error in an org whose
2256+
`.vapi-policy.yml` sets `customerKeysOnly: true`. The promotion plan warns
2257+
when `omit` drops a `credentialIds` entry. See
2258+
[Credential pins](docs/guides/credential-pins.md).
2259+
2260+
Still open: the slug collision itself is only warned about, and the check
2261+
does not know which models or regions a key covers.
2262+
2263+
---
2264+
22062265
## Out of scope (intentionally not improvements)
22072266

22082267
- **State file is identity-only and not git-ignored.** It's intentionally

0 commit comments

Comments
 (0)