VIP-68: Experimental.Secrets: secrets a step uses without holding them
Status: accepted by Will, 2026-11-23 — standard library only (no compiler or language changes). Will: "58 I accept. I accept every other language proposal but ones that don't require a change to the language and are purely library functions that don't require compiler changes at all should be marked as such". Implementation in progress (Experimental.Secrets).
Will's words
Ok so give me a list of [the reference engine's] features. We need to figure out what the VIP should look like. Some of the features outside of durable execution likely should simply be in the standard library I'm guessing but we should enumerate all of them
Summary
One sentence. A step holds a placeholder, and Experimental.Secrets.egress swaps in the real value only on an outbound HTTPS request to a host that secret is bound to, then scrubs any echo of it from the answer.
One paragraph. An agent that can read its own environment can leak it. Effect's Redacted keeps a value out of logs, but the code still holds the value. The secrets package of the reference engine (an existing Effect durable-execution framework these built-ins are modelled on) goes further: the step never has it. The step builds its request with a placeholder string. The request leaves through an egress, which puts the value in the request's headers only when the request is for one of that secret's own hosts and methods, over HTTPS. The egress never follows a redirect, records each decision by name before it sends, and removes every echo of the value from the response before the step reads it. This VIP ports that as one layer over HttpClient. It is a mechanism for HTTP, and it says below what it cannot stop.
the step (or a sandbox, or model-written code) Secrets.egress the world
─────────────────────────────────────────── ────────────── ─────────
authorization: Bearer <prefix>-secret-3f… ──────────► host api.stripe.com? yes, HTTPS ─► Bearer sk_live_…
host evil.example? no ─✕ refused, recorded
response body ◄──── scrubbed: value → placeholder ◄─────────────────────────────────── … sk_live_… …Decision
// proposed
export effect function charges() {
provide Experimental.Secrets.egress([{ name: "STRIPE_KEY", hosts: ["api.stripe.com"], methods: ["GET", "POST"] }]) {
const key = try Experimental.Secrets.placeholder("STRIPE_KEY")
const http = try HttpClient.HttpClient
return try http.get("https://api.stripe.com/v1/charges", { headers: { authorization: `Bearer ${key}` } })
}
}key is a string such as <prefix>-secret-3f…, 64 hexadecimal characters after the prefix. It is safe to log, journal and hash.
Module
Experimental.Secrets, in scope with no import, as VIP-33 rules. Its code is vibelang-runtime/experimental/Secrets. It ports the reference engine's secrets package and its four modules: Binding, Placeholder, Egress and Scrub.
| Call | Meaning | Reference engine |
|---|---|---|
Secrets.egress(bindings, { allow? }) | A layer that replaces HttpClient with one that substitutes, refuses and scrubs | Egress.execute, Egress.Policy |
Secrets.placeholder(name) | The placeholder for name in this egress's scope. Fails for a name the egress does not bind | Placeholder.minter(key), derive(scope, name) |
Secrets.forward(request) | Answer a sandbox's intercepted request with an HttpServerResponse | Egress.forward |
Secrets.Vault | The service that reveals a value by name, for one request. The default reads Config.Redacted(name) | Egress.Vault |
Secrets.Audit | The service that records each decision. The default logs it | Egress.Audit |
A binding is { name, hosts, methods? }: a name matching ^[A-Z_][A-Z0-9_]{0,63}$, 1 to 16 hosts, and methods from GET, HEAD, POST, PUT, PATCH and DELETE.
Rules
- Exact audiences. The value replaces the placeholder only when the request's host is exactly one of the secret's
hosts, the method is one of itsmethods, the port is the scheme's own and the scheme is HTTPS. A host is a lowercase DNS name: no wildcard, IP address or single label. - Headers only. A placeholder in a URL or a body reaches the host as the placeholder.
- No redirects. A 3xx answer returns to the step with its
Locationscrubbed. The step's next request is checked again. - Echoes are scrubbed. Every value in the policy is removed from every answer's headers and body, whichever host answers: the value, and its percent, JSON and base64 encodings, across chunk boundaries as the body streams.
- Audited by name, before sending. Each decision records host, method, outcome and the secrets' names. A request that cannot be recorded is not sent. The value is never recorded.
- A host outside every binding is refused unless
allownames it. - Bounded. At most 16 placeholders a request and 64 KiB of headers after substitution. A value is 8 bytes to 16 KiB of text with no control character, so it cannot split a header.
- Placeholders are derived, not stored.
Placeholder.minterderives one with HMAC-SHA-256 from a key the host holds, a scope and the name. A new scope gets new placeholders, and the old ones are refused asunknown_placeholder. Inside a durable run the scope is the run, so a recorded step's placeholder still works when the run resumes. The key isConfig.Redacted("SECRETS_PLACEHOLDER_KEY"), at least 32 characters; with none, the layer makes one for the process. - The vault is injected. A test provides a vault that answers with fixtures. A deployment provides one over its secret manager.
Refusals are the reference engine's closed list: invalid_url, port_not_allowed, host_not_allowed, unknown_placeholder, secret_not_allowed, insecure_scheme, too_many_placeholders, headers_too_large.
What it does not stop
- Abuse of an allowed host. Anything holding a placeholder can use the secret against its own hosts. Bind few hosts and few methods.
- Transformed echoes. A host that returns the value hashed or reversed defeats scrubbing.
- A request that needs the value in its body. It cannot use a secret.
- A program that goes around the egress. A sandbox must route a guest's traffic through
Secrets.forwardand block the rest (std-sandbox). - A coding-agent CLI that needs a credential in its own environment. It holds the credential. Say so, and isolate it.
Where it sits
| Layer | Stops |
|---|---|
Redacted (Effect) | A value printed by accident |
| capabilities | A request to a host nobody allowed |
Experimental.Secrets.egress | A step that holds the value at all |
| std-sandbox | A process that reads another process's memory or files |
Model keys are a special case. std-model reads them from Config inside the host and never passes them to a step, so a model call needs no placeholder.
Host needs
HttpClient. The package "imports no Node built-in, so it runs in a browser, a Worker, Node and Bun". With Effect's Fetch client the egress sets redirect: "manual"; any other client must not follow redirects.
Maintainers' decisions
This record comes from the 2026-11-09 built-in set review. The Status line above records Will’s subsequent ruling.
keyis a string such as<prefix>-secret-3f…, 64 hexadecimal characters after the prefix. Design · Review.- It is safe to log, journal and hash. Design · Review.
Experimental.Secrets, in scope with no import, as VIP-33 rules. Design · Review.- Its code is
vibelang-runtime/experimental/Secrets. Design · Review. - It ports the reference engine's secrets package and its four modules:
Binding,Placeholder,EgressandScrub. Design · Review. - Call
Secrets.egress(bindings, { allow? }): Meaning: A layer that replacesHttpClientwith one that substitutes, refuses and scrubs; Reference engine:Egress.execute,Egress.Policy. Design · Review. - Call
Secrets.placeholder(name): Meaning: The placeholder fornamein this egress's scope. Fails for a name the egress does not bind; Reference engine:Placeholder.minter(key),derive(scope, name). Design · Review. - Fails for a name the egress does not bind |
Placeholder.minter(key),derive(scope, name)| Design · Review. - Call
Secrets.forward(request): Meaning: Answer a sandbox's intercepted request with anHttpServerResponse; Reference engine:Egress.forward. Design · Review. - Call
Secrets.Vault: Meaning: The service that reveals a value by name, for one request. The default readsConfig.Redacted(name); Reference engine:Egress.Vault. Design · Review. - The default reads
Config.Redacted(name)|Egress.Vault| Design · Review. - Call
Secrets.Audit: Meaning: The service that records each decision. The default logs it; Reference engine:Egress.Audit. Design · Review. - The default logs it |
Egress.Audit| Design · Review. - A binding is
{ name, hosts, methods? }: a name matching^[A-Z_][A-Z0-9_]{0,63}$, 1 to 16 hosts, and methods fromGET,HEAD,POST,PUT,PATCHandDELETE. Design · Review. - Exact audiences. The value replaces the placeholder only when the request's host is exactly one of the secret's
hosts, the method is one of itsmethods, the port is the scheme's own and the scheme is HTTPS. Design · Review. - A host is a lowercase DNS name: no wildcard, IP address or single label. Design · Review.
- Headers only. A placeholder in a URL or a body reaches the host as the placeholder. Design · Review.
- No redirects. A 3xx answer returns to the step with its
Locationscrubbed. Design · Review. - The step's next request is checked again. Design · Review.
- Echoes are scrubbed. Every value in the policy is removed from every answer's headers and body, whichever host answers: the value, and its percent, JSON and base64 encodings, across chunk boundaries as the body streams. Design · Review.
- Audited by name, before sending. Each decision records host, method, outcome and the secrets' names. Design · Review.
- A request that cannot be recorded is not sent. Design · Review.
- The value is never recorded. Design · Review.
- A host outside every binding is refused unless
allownames it. Design · Review. - Bounded. At most 16 placeholders a request and 64 KiB of headers after substitution. Design · Review.
- A value is 8 bytes to 16 KiB of text with no control character, so it cannot split a header. Design · Review.
- Placeholders are derived, not stored.
Placeholder.minterderives one with HMAC-SHA-256 from a key the host holds, a scope and the name. Design · Review. - A new scope gets new placeholders, and the old ones are refused as
unknown_placeholder. Design · Review. - Inside a durable run the scope is the run, so a recorded step's placeholder still works when the run resumes. Design · Review.
- The key is
Config.Redacted("SECRETS_PLACEHOLDER_KEY"), at least 32 characters; with none, the layer makes one for the process. Design · Review. - The vault is injected. A test provides a vault that answers with fixtures. Design · Review.
- A deployment provides one over its secret manager. Design · Review.
- Refusals are the reference engine's closed list:
invalid_url,port_not_allowed,host_not_allowed,unknown_placeholder,secret_not_allowed,insecure_scheme,too_many_placeholders,headers_too_large. Design · Review. - Abuse of an allowed host. Anything holding a placeholder can use the secret against its own hosts. Design · Review.
- Bind few hosts and few methods. Design · Review.
- Transformed echoes. A host that returns the value hashed or reversed defeats scrubbing. Design · Review.
- A request that needs the value in its body. It cannot use a secret. Design · Review.
- A program that goes around the egress. A sandbox must route a guest's traffic through
Secrets.forwardand block the rest (std-sandbox). Design · Review. - A coding-agent CLI that needs a credential in its own environment. It holds the credential. Design · Review.
- Say so, and isolate it. Design · Review.
- Layer
Redacted(Effect): Stops: A value printed by accident. Design · Review. - Layer capabilities: Stops: A request to a host nobody allowed. Design · Review.
- Layer
Experimental.Secrets.egress: Stops: A step that holds the value at all. Design · Review. - Layer std-sandbox: Stops: A process that reads another process's memory or files. Design · Review.
- Model keys are a special case. Design · Review.
- std-model reads them from
Configinside the host and never passes them to a step, so a model call needs no placeholder. Design · Review. HttpClient. Design · Review.- The package "imports no Node built-in, so it runs in a browser, a Worker, Node and Bun". Design · Review.
- With Effect's Fetch client the egress sets
redirect: "manual"; any other client must not follow redirects. Design · Review.
Adopted review answers
- Keep
Experimental.Xnames under VIP-33. Promotion to a bare module name requires a later decision. Review question 1.
Compared
The same request in the reference engine 1.x, from flows/secrets/README.md.
import { Egress } from "@smthrs/secrets"
import * as Effect from "effect/Effect"
import { FetchHttpClient, HttpClientRequest } from "effect/http"
import * as Layer from "effect/Layer"
import * as Redacted from "effect/Redacted"
const PLACEHOLDER = "<prefix>-secret-" + "0".repeat(64)
const policy: Egress.Policy = {
secrets: [{ name: "STRIPE_KEY", placeholder: PLACEHOLDER, hosts: ["api.stripe.com"], methods: ["GET", "POST"] }],
allow: []
}
const request = HttpClientRequest.get("https://api.stripe.com/v1/charges").pipe(
HttpClientRequest.setHeader("authorization", `Bearer ${PLACEHOLDER}`)
)
const host = Layer.mergeAll(
FetchHttpClient.layer,
Layer.succeed(Egress.Vault, Egress.Vault.of({ reveal: () => Effect.succeed(Redacted.make("sk_live_...")) })),
Layer.succeed(Egress.Audit, Egress.Audit.of({ record: (entry) => Effect.log("egress", entry.outcome) }))
)
export const charges = Egress.execute(request, policy).pipe(Effect.provide(host))| Program | Tokens (o200k_base) | Lines |
|---|---|---|
| Vibe, proposed | 97 | 7 |
| Reference engine 1.x | 261 | 24 |
Checked. The Vibe example uses only existing syntax and compiles under vibelang 0.0.13 against a declaration of Experimental.Secrets. The reference engine's program is the README's quickstart. It is not type-checked here: the reference engine's secrets package is private to its repository and is not on npm. Its guarantees and limits are read from flows/secrets/docs/README.md and docs/api.md.
Principles
- TypeScript-first. A layer and a string.
- Effect-second. The egress decorates Effect's
HttpClientin place, as the permission kernel does.RedactedandConfigstay the way a host holds a value. - Optimized for agentic programs. A model-written script can be handed a tool that calls Stripe without being handed Stripe's key.
- Highly forkable. The vault and the audit are services. A fork changes where values live without touching the egress.
- Factory-first. The factory's audit of which secret went to which host is public; the values are not.
What this changes
Experimental.Secretsis new. No grammar changes.- A recorded task input may contain a placeholder. It never contains a value.
Alternatives
Redactedalone. It protects logs. Code that holds aRedactedcan unwrap it.- One fixed placeholder for each name, the same in every run. It is simpler to record. A placeholder that leaked from one run would then work in every other; the reference engine derives them from a scope so it does not.
- A
secrettype the compiler tracks, so a value cannot flow to a log or a non-allowed call. Information-flow typing is a large language feature, and it stops at the first.tsimport. - Environment variables in the sandbox. That is the thing this removes: a process that has the variable has the secret.
- Fold it into
Capability. A capability decides whether a request may go. The egress changes the request. Two jobs.
Follow-up questions
- Placeholders in URLs and bodies. Some APIs take a key as a query parameter or a JSON field. The reference engine substitutes in headers only. Recommendation: keep headers only; a key in a URL is logged by every proxy on the way.
- Non-HTTP secrets. A database password or an SSH key has no HTTP request to rewrite. This VIP does not cover them. Recommendation: not in this set.
- The package is private. The reference engine's secrets package is not published. Porting it means publishing it or moving its code into the Vibe runtime. Recommendation: publish it with the reference engine's next release.
- Rotation and reuse. A rotated key does not change a recorded step. Should a cached result be reused across a rotation? Recommendation: yes; a binding's name and hosts are in the cache key, and its value never is.
Depends on
- capabilities: the allow decision that runs before the egress.
std-sandbox is the caller of Secrets.forward, and neither module needs the other to work.