Operate

Secrets

cmd
hev secrets

kit runs a memory-only secrets cache inside the daemon (hevd). Write a secret as secret://NAME, for example secret://stripe-api-key. The reference names the secret and not the vault: each host sets its secret manager, 1Password or Azure Key Vault, and that decides where NAME is read from. The same reference works on every host, and moving a host to another manager changes no project file. A secret that must name its vault is written in the explicit form, op://vault/item/field for 1Password or azkv://vault/secret for Key Vault.

Every process on a host that needs the same value costs one request per TTL instead of one each. That matters because a 1Password service account’s daily quota is shared by every machine that uses it, and a vault throttles per request. This page is how to use the cache.

Everything below applies to both stores and to all three forms, and one command can mix them. Set the host’s secret manager says how a host chooses its store, Choose a provider compares the two, and Set up 1Password and Set up Azure Key Vault walk through each one. Replace a secret on disk shows a .env file before and after.

Why not a .env file

A .env file keeps the secret itself, in plain text, in the place a coding agent works. That causes four problems.

  • An agent can read it, and what an agent reads can leave the machine. An agent session can open any file its user can. A .env in the repo is one cat or grep away, and once the value is in the session it is in the model’s context and the session transcript. kit captures traces and, on Club Kit or Pro Kit, shares them with the team. Its scrubbing replaces the secrets it recognises, but it cannot catch every one.
  • It gets copied. A .env rides along in a worktree copy, an rsync to a host, a container build context, a backup and, when .gitignore misses it once, a commit. Each copy holds the real value and nobody tracks them.
  • Every host needs its own copy. A team dispatching to shared hosts ends up with the same key in a file on every machine and every teammate’s laptop. Rotating it means finding and editing all of them, so it doesn’t get rotated.
  • Nothing records who used it. A file read leaves no trace. You cannot tell which job or agent took the key, or whether anything did.

A reference such as secret://stripe-api-key is not a secret. It can sit in a script, a unit file, an order or a commit, and an agent can read it without learning anything. The value stays in the vault, is fetched when a program starts, and exists only in the daemon’s memory and that program’s environment. Rotation is one change in the vault, access is the vault’s own permissions, and every real request is in the read log with the caller’s name.

A reference does not hide the value from the program that uses it, or from an agent that runs that program and prints its environment. It removes the copy at rest, which is the one that leaks.

The one rule

Read through hev secrets. Don’t run op read, op inject or op run yourself, in a script, a wrapper, a shell profile or an agent session.

You needUse
One value in a shell variablex=$(hev secrets read --label NAME --ttl 1h secret://name)
Several variables in the current shelleval "$(hev secrets env --ttl A=1h --ref A=secret://a --ref B=secret://b)"
Values in a program’s environmenthev secrets run --ref A=secret://a --ttl A=1h -- program args
A .env file of references, in a program’s environmenthev secrets run --env-file .env -- program args
Values for a program, as JSON on a pipehev secrets env --format json --ref A=secret://a
What the host is spendinghev secrets status (--no-quota asks 1Password nothing)
Whether the cache is up, for freehev secrets ping (exit 0 up, 69 not)
Each value’s provenance, for a wrapper’s log--explain on stderr, or env --format json-detail

Values come back only through a pipe or the child’s environment. Nothing is written to disk, a log or a process argument; the reference is the only argument. --ttl is how long the daemon may reuse a value: five minutes by default, at most 24 hours, and 0s forces a fresh read. Choose the longest TTL your rotation allows. An hour suits most API keys.

Exit codes

ExitMeaning
0The value was delivered.
75Rate limited. The retry time is on stderr.
69--cache-only (or ping): no daemon serves this account.
78--direct-status: the value was delivered, but by a direct read, not the cache.

On exit 75, make one attempt and stop. Don’t loop, sleep and retry, or fall back to op. The cache already refuses to send another request before the retry time, and a second path around it is how one host empties the account for everyone.

Don’t put a loader that resolves many secrets in a shell profile. Source it in the job that needs the values.

Set the host’s secret manager

secret://NAME needs the host to say which store it uses. NAME is 1 to 127 lowercase letters, digits and hyphens, a name that is valid in both stores. Anything else, such as secret://STRIPE_API_KEY, is refused. Set the manager once per host, in the [secrets] table of kit’s config file ~/.hev/config.toml, the file hevd already reads:

# ~/.hev/config.toml
[secrets]
manager = "1password"
vault = "VAULT"
# field = "password"   # the field read from each item; password by default
# ~/.hev/config.toml
[secrets]
manager = "azure-key-vault"
vault = "VAULT"   # or VAULT.vault.usgovcloudapi.net for a sovereign cloud
Managersecret://stripe-api-key reads
1passwordop://VAULT/stripe-api-key/password: the item titled stripe-api-key in the vault, field password (or the field you set)
azure-key-vaultazkv://VAULT/stripe-api-key: the secret stripe-api-key in the vault, latest version

The reference becomes its explicit form in the process that reads it, before the cache. So on that host secret://stripe-api-key and its explicit form share one cache entry, one request, one cooldown and one read log label, and the daemon needs nothing new.

HEV_SECRETS_MANAGER, HEV_SECRETS_VAULT and HEV_SECRETS_FIELD set the same for one process. When HEV_SECRETS_MANAGER is set, the file’s table is not read. kit never picks a manager from the credentials it finds. With no manager set, a secret:// read fails with:

secret:// needs this host's secret manager, and none is set; set this host's secret manager in /home/you/.hev/config.toml: [secrets] manager = "1password" or "azure-key-vault" and vault = "VAULT" (or HEV_SECRETS_MANAGER and HEV_SECRETS_VAULT in the environment)

hev secrets status shows the manager and where it is set:

secret manager:  Azure Key Vault (vault VAULT; /home/you/.hev/config.toml [secrets])

Move a host to another manager

Moving is a host change only. No .env file, order, script or HEVLAYER_API_KEY_REF that uses secret:// changes.

  1. Store each secret in the new store under the same NAME: an item titled NAME with the field the host reads in 1Password, or a secret named NAME in Key Vault.
  2. Set up the new store’s credential on the host (see Set up 1Password or Set up Azure Key Vault).
  3. Change the host’s [secrets] table to the new manager and vault.
hev secrets status --no-quota | grep 'secret manager'
hev secrets read --label STRIPE_API_KEY --explain secret://stripe-api-key | wc -c

The status line names the new manager, and the read prints a byte count above zero. The daemon keeps running: callers read from the new store on their next read. With draft Kit #363, hevd loads its primary archive key separately at startup. Restart hevd after changing that key.

Choose a provider

The reference’s scheme picks the store. Both stores get the same cache, TTL limit, batching, one-attempt rule on rate limits, cooldown and read log.

ReferenceStore
secret://NAMEthe host’s secret manager, as one of the forms below
op://vault/item/field1Password, through a service account (op on PATH)
azkv://VAULT/SECRETAzure Key Vault at https://VAULT.vault.azure.net, latest version
azkv://VAULT/SECRET/VERSIONa pinned version (32 hex digits)
azkv://VAULT.vault.usgovcloudapi.net/SECRETa sovereign cloud’s vault (also vault.azure.cn). The token audience and sign-in host follow the suffix.

Use whichever store already holds the secret. A host needs nothing for a store it doesn’t use: a Key Vault-only host needs no op and no 1Password token, and a 1Password-only host needs no Azure settings. A vault behind a private endpoint keeps its ordinary name. Vault and secret names follow Key Vault’s own rules, and anything else in a reference (a port, a query, an extra path segment, a trailing slash) is refused.

The Key Vault role

The Azure identity kit signs in as needs to get secrets and nothing more. Give it the built-in role Key Vault Secrets User, scoped to the vault (Azure RBAC). On a vault that still uses access policies, grant only the secret permission Get. kit never lists, sets or deletes secrets.

Key Vault credentials

kit never signs in interactively: there is no browser or device-code prompt. With no credential configured, the error names what to set. Set one of these in the daemon’s environment:

CredentialSettings
Managed identity, Azure VMHEV_AZKV_CREDENTIAL=managed-identity (plus AZURE_CLIENT_ID for a user-assigned identity)
Managed identity, Azure Arc serverNothing. The Arc agent sets IDENTITY_ENDPOINT and IMDS_ENDPOINT; the user must be in the agent’s token group.
Managed identity, App ServiceNothing. The platform sets IDENTITY_ENDPOINT and IDENTITY_HEADER.
Workload identity (Kubernetes)AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_FEDERATED_TOKEN_FILE
Service principal with a certificateAZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_CERTIFICATE_PATH (a PEM with the certificate and an unencrypted RSA key, readable only by the user)
Service principal with a client secretAZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET_REF=op://… (read through the cache) or AZURE_CLIENT_SECRET
An existing az loginHEV_AZKV_CREDENTIAL=azure-cli. kit runs az account get-access-token, never az login. A convenience for a workstation.

Without HEV_AZKV_CREDENTIAL, kit picks a client secret, then a certificate, then workload identity, then a platform identity endpoint. The VM metadata endpoint and az are used only when named, so a host outside Azure never waits on a metadata probe and never borrows a developer’s login by accident. HEV_AZKV_CREDENTIAL accepts auto, client-secret, client-certificate, workload-identity, managed-identity and azure-cli.

Set the same variables in the environment of the callers that use the daemon. The daemon serves a Key Vault request only when the caller holds the same credential (see Switch the cache on).

For an Azure Stack Hub vault, list its DNS suffix in HEV_AZKV_DNS_SUFFIXES (comma separated) and set AZURE_AUTHORITY_HOST to its sign-in host, an https URL.

Prefer a credential with no secret: a managed identity (on an Azure VM or an Arc-connected server, Windows included) or workload identity. Otherwise use a certificate. Never put a client secret in a unit file, a scheduled task or a profile. Point AZURE_CLIENT_SECRET_REF at a reference instead, and the daemon reads it through its own cache. A reference back to azkv:// is a cycle and is refused, and so is secret:// on a host whose manager is Key Vault. Access tokens stay in the resolving process’s memory and are never written anywhere.

A Windows host with only Key Vault

Run hevd (or hev daemon --secrets-only) with one of:

  • on an Azure VM: HEV_AZKV_CREDENTIAL=managed-identity
  • on an Arc-connected server: nothing beyond Arc’s own variables
  • elsewhere: AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_CERTIFICATE_PATH

It needs no op, no OP_SERVICE_ACCOUNT_TOKEN and no token file. Callers use the same commands with azkv:// references:

$env:DB_PASSWORD = hev secrets read --label DB_PASSWORD --ttl 1h azkv://VAULT/SECRET
hev secrets run --ref DB_PASSWORD=azkv://VAULT/SECRET --ttl DB_PASSWORD=1h -- program.exe

See Windows for running the daemon there.

Switch the cache on

The cache serves a caller when both hold the same service-account token, taken from OP_SERVICE_ACCOUNT_TOKEN or else the token file HEV_OP_TOKEN_FILE (default ~/.config/op/token, which must be mode 0600). A host whose token is in that file needs no configuration: start or restart hevd. To use a different file, set it in the daemon’s service:

# ~/.config/systemd/user/hevd.service.d/secrets.conf
[Service]
Environment=HEV_OP_TOKEN_FILE=%h/.config/op/token

A host that doesn’t run hevd can run the endpoint on its own with hev daemon --secrets-only. The repository’s staged/host-secrets/ directory has a systemd unit and a launchd job for that. The Linux unit:

# ~/.config/systemd/user/hev-secrets.service
[Unit]
Description=hev Kit local secrets cache (memory only)

[Service]
Type=simple
ExecStart=%h/.local/bin/hev daemon --secrets-only
Environment=HEV_OP_TOKEN_FILE=%h/.config/op/token
Restart=on-failure
RestartSec=60
UMask=0077

[Install]
WantedBy=default.target

hev update restarts this unit, or the launchd job com.hev.secrets, onto the new build together with hevd, if it is running; a stopped one stays stopped. See Updating. Restarting the cache, by an update or by hand, sends no request: the cache is memory-only and fills again on demand, and a cooldown on disk still holds.

VariableEffect
HEV_SECRETS_ENDPOINTMoves the endpoint, for the daemon and its callers alike: an absolute socket path on Linux and macOS (its directory must be 0700), \\.\pipe\NAME on Windows. Unset, it is ~/.hev/secrets/agent.sock or \\.\pipe\hev-secrets-<SID>.
HEV_SECRETS_CACHE=offThis process skips the cache, for a test that uses a fixture op.
HEV_SECRETS_READ_LOGMoves the read log; off disables it.
HEV_SECRETS_COOLDOWNMoves the cooldown file; off disables it (tests only).

The daemon serves each store separately. It answers a request when, for every store the request names, the caller and the daemon hold the same credential: the same 1Password token, or the same Azure credential type, tenant, client and secret or certificate. Only SHA-256 fingerprints cross the endpoint. A caller whose Azure settings differ from the daemon’s still gets its 1Password reads served, and reads Key Vault directly. Upgrade hevd before callers start using azkv://, because an older daemon refuses those references. A secret:// reference reaches the daemon in its explicit form, so the same holds for a host whose manager is Key Vault.

With no endpoint, hev secrets still batches and logs, but each process pays for its own request, and hev secrets status says daemon: unavailable.

Set up 1Password

Prerequisites

  • A 1Password service account with read access to the vaults you need, and its token. kit never uses the 1Password desktop app or biometric unlock.
  • The op CLI on the PATH of the daemon and of every caller.
  • hev on the host with hevd running (Install), or the secrets-only endpoint from Switch the cache on.

1. Put the token in the token file

Keep the token in ~/.config/op/token, so the daemon and every caller use the same one without it appearing in a unit file or a profile. On Linux and macOS kit ignores the file if its mode grants anything to group or others.

mkdir -p ~/.config/op
chmod 700 ~/.config/op
touch ~/.config/op/token
chmod 600 ~/.config/op/token
# paste the service-account token into ~/.config/op/token with an editor

2. Restart the cache

With the token in the default file, restart hevd and check that it serves this account. For another file, add the drop-in in Switch the cache on first.

systemctl --user restart hevd   # Linux (systemd user service)
hev daemon stop && hev up       # macOS: stop unloads the launchd job, up loads it again
hev secrets ping

On Windows, restart the \hev\hevd scheduled task in PowerShell with hev daemon stop; hev daemon start, then run hev secrets ping.

3. Read a 1Password secret

DB_PASSWORD=$(hev secrets read --label DB_PASSWORD --ttl 1h --explain op://VAULT/ITEM/FIELD)

4. Verify 1Password

  • --explain prints one line per reference on stderr, such as hev secrets: DB_PASSWORD source=read via=daemon. source=read means the call made a real request, source=cache means it was served from memory, and via=direct means no daemon served it.
  • Run the same read again. It should say source=cache.
  • hev secrets status --no-quota shows a 1Password row with the credential service-account token (token file) or service-account token (environment).

1Password failures

Message or symptomCause and fix
1Password service-account token is required; desktop unlock disabledNo token in OP_SERVICE_ACCOUNT_TOKEN and no usable token file. Check HEV_OP_TOKEN_FILE or ~/.config/op/token, and that its mode is 0600.
hev secrets: notice: fallback to direct 1Password read on stderrNo daemon serves this account. Restart hevd, and check that the daemon and the caller use the same token.
hev secrets ping prints unavailableThe same cause as the notice above.
1Password secret resolution failed (service account required; desktop unlock disabled)op could not resolve a reference: a wrong vault, item or field, or a service account without access to that vault.
Exit 75The account is rate limited. Wait for the time on stderr. See After a rate limit.

Set up Azure Key Vault

Prerequisites

  • A vault, the names of the secrets you need, and an identity that has the role in The Key Vault role.
  • One credential for that identity from Key Vault credentials.
  • hev on the host with hevd running (Install), upgraded before any caller uses azkv://. Neither op nor the Azure CLI is needed, unless you choose HEV_AZKV_CREDENTIAL=azure-cli.

1. Configure the daemon

Put the credential’s variables in hevd’s environment. On Linux with a certificate, as a systemd drop-in:

# ~/.config/systemd/user/hevd.service.d/azkv.conf
[Service]
Environment=AZURE_TENANT_ID=TENANT_ID
Environment=AZURE_CLIENT_ID=CLIENT_ID
Environment=AZURE_CLIENT_CERTIFICATE_PATH=%h/.config/azkv/client.pem

On an Azure VM with a managed identity, the drop-in needs only Environment=HEV_AZKV_CREDENTIAL=managed-identity, plus AZURE_CLIENT_ID for a user-assigned identity. For Windows see A Windows host with only Key Vault.

2. Read a Key Vault secret

hev secrets ping
DB_PASSWORD=$(hev secrets read --label DB_PASSWORD --ttl 1h --explain azkv://VAULT/SECRET)

3. Verify Key Vault

  • --explain says via=daemon. via=direct means the daemon doesn’t hold the same Azure credential as the caller; compare their environments.
  • hev secrets status --no-quota shows an Azure Key Vault row with the credential type, whether the vault was reachable on the last real request, hits, misses, requests and any cooldown.

Key Vault failures

MessageCause and fix
hev secrets: notice: fallback to direct Azure Key Vault read on stderrNo daemon serves this Azure credential, so the read went straight to the vault. Restart hevd, and check that the daemon and the caller have the same AZURE_* and HEV_AZKV_CREDENTIAL settings.
Azure Key Vault has no credential configured; ...No credential is set. The message names every variable that would set one.
Azure Key Vault denied access (HTTP 403): the ... principal needs get on secrets for this vaultGive the identity the role in The Key Vault role.
Azure Key Vault refused the ... credential (HTTP 401)The vault refused the access token. Check the tenant and client IDs.
Azure Key Vault has no such secret or version (HTTP 404)Check the secret name and, for a pinned reference, the version.
Azure sign-in failed for the ... credential (HTTP ...)The sign-in endpoint refused the client secret, certificate or federated token.
Azure client certificate: the PEM file needs a certificate and an unencrypted RSA private keyConvert the certificate to that form. PFX and password-protected files are not read.
Azure CLI credential selected but az is not on PATHInstall the Azure CLI for the daemon’s user, or choose another credential.
Azure Key Vault managed identity: IDENTITY_ENDPOINT needs IDENTITY_HEADER (App Service) or IMDS_ENDPOINT (Azure Arc)A partial platform identity environment. Set the missing variable, or name a credential with HEV_AZKV_CREDENTIAL.
Azure Arc identity key file is unreadable (the user must be in the agent's token group)Add the daemon’s user to the Arc agent’s token group.
Azure Key Vault: AZURE_CLIENT_SECRET_REF cannot be an azkv:// reference, nor a secret:// reference on a Key Vault host (credential reference cycle); use another providerKeep the client secret in another store, such as 1Password, and write its explicit op:// reference.
set AZURE_AUTHORITY_HOST for a vault outside Azure's known cloudsAn Azure Stack Hub vault. Set AZURE_AUTHORITY_HOST and HEV_AZKV_DNS_SUFFIXES.
Exit 75The vault throttled the request (HTTP 429). See After a rate limit.

Replace a secret on disk

Keep the .env file and change what it holds. Comment out the line with the value, and put a reference under the same name:

# .env
# STRIPE_API_KEY=sk_live_EXAMPLE_VALUE
STRIPE_API_KEY=secret://stripe-api-key

The file names the secret, not the vault. Where stripe-api-key lives depends on the host’s secret manager (see Set the host’s secret manager):

Vault:     VAULT (the host's [secrets] vault)
Item:      stripe-api-key (the item's title)
Field:     password (or the host's [secrets] field)
Reference: op://VAULT/stripe-api-key/password
Vault:     VAULT (the host's [secrets] vault)
Secret:    stripe-api-key
Version:   latest
Reference: azkv://VAULT/stripe-api-key

Then start the program through hev secrets run, pointing it at the file:

hev secrets run --env-file .env -- ./server

hev secrets run reads the file, resolves every value that is a secret://, op:// or azkv:// reference through the cache in one batch, and starts the program with the results in its environment. Lines with ordinary values, such as a port or a hostname, pass through unchanged. Blank lines and # comments are ignored, export before a name is allowed, and a value may be unquoted, 'single quoted' or "double quoted". One file can mix all three forms. If a name appears twice, the later line wins, and --ref NAME=REF on the command line wins over the file. --ttl NAME=1h sets the TTL of a reference from either. eval "$(hev secrets env --env-file .env)" loads the same file into the current shell. The file is only read: values reach the program only through its environment.

Three things make the swap complete:

  1. Store the value first. kit only reads secrets, so put the value in the store with its own tools before you edit the file, under the name in the tabs above: in 1Password an item titled stripe-api-key that the service account can read, in Key Vault a secret named stripe-api-key.
  2. Check the reference. hev secrets read --label STRIPE_API_KEY --explain secret://stripe-api-key | wc -c prints a byte count above zero when the manager, the credential and the name are right, without showing the value.
  3. Delete the commented line and rotate the key. Once the program runs from the reference, remove the commented line. The old value sat in a file that agents, backups and copies could reach, so rotate it at its issuer and store the new value under the same name. Nothing else changes: the file keeps the same reference.

A .env file that holds only references and ordinary settings has no secret in it. It can be committed, copied to a host and read by an agent.

kit’s own reads

CLI and scoped secret consumers use the secrets resolver:

  • CLI Layer credentials. Commands that resolve HEVLAYER_API_KEY_REF (secret://, op:// or azkv://, with the older HEVLAYER_API_KEY_OP_REF also supported) use the resolver with a six-hour TTL.
  • Scoped credentials. Secondary capture targets and other scoped consumers keep their own configured sources and read limits. The primary archive key supplies no credential to the scoped resolver.
  • Primary capture. Before Kit #363, hevd could resolve a primary key reference at startup. With draft Kit #363, migrate a reference-only primary to a protected [layer].api_key_file. hevd reads the file directly on startup and CLI commands do not consume it.
  • The native gate. Its database references are resolved in one batch with a one-hour TTL. They may be secret:// or azkv:// references, read through hev, which must be on PATH.

With no daemon, each reads directly as before. A direct read is never silent. It prints one line on stderr starting hev secrets: notice: fallback to direct, then the stores it reads (1Password read, Azure Key Vault read, or 1Password and Azure Key Vault read), with the reason. Any answer from the daemon is final, a rate limit included, so kit never retries it directly.

The read log

Every real request appends one line to ~/.hev/secrets/op-reads.log (mode 0600; the name predates Key Vault). Cache hits add free cache events.

2026-11-11T21:31:02Z caller=bash[4121]>hev_secrets_read kind=inject refs=1 labels=DB_PASSWORD#9f2c11ab outcome=ok provider=op
2026-11-11T21:31:05Z caller=bash[4121]>hev_secrets_run kind=get refs=2 labels=DB_USER#04be71d2,DB_PASSWORD#5a1c9e30 outcome=ok provider=azkv

Each line has the time (UTC), the caller (--caller, HEV_SECRETS_CALLER, or the parent command), the kind of request (inject, read or ratelimit for 1Password, get for one Key Vault batch), how many references, the labels, the outcome and the provider. A label is the variable name plus the first eight hex digits of the reference’s SHA-256. Find a label with printf %s op://vault/item/field | sha256sum | cut -c1-8. The log never holds a value, a token or a reference, and it rotates at 4 MiB.

When the account runs out, find the heaviest callers:

hev secrets status
awk '{print $2}' ~/.hev/secrets/op-reads.log | sort | uniq -c | sort -rn | head
grep 'provider=azkv' ~/.hev/secrets/op-reads.log | grep -c rate_limited   # a throttled vault

After a rate limit

The first rate-limit answer starts a cooldown for the whole host. Its limit class and reset time, and nothing else, go to ~/.hev/secrets/op-cooldown.json beside the read log. Until the reset, every kit process on the host gets the same error and sends nothing. That covers the daemon, a restarted daemon, hev secrets with no daemon, the hev layer key and the native gate. hevd stays up and keeps serving cached secrets while its own key waits for the reset, instead of exiting into a restart loop. The first successful request after the reset deletes the file.

The cooldown is per store. Key Vault answers a throttled request with HTTP 429 and Retry-After. kit makes that one request, honours Retry-After, and records the cooldown in azkv-cooldown.json in the same directory. A throttled vault never holds back 1Password reads, and a spent 1Password account never holds back Key Vault. A request that mixes both fails as a whole, before asking either store, when either is in cooldown.

Status

hev secrets status (--json for programs) shows:

  • the host’s secret manager for secret:// and where it is set (manager in --json), or what to set when there is none
  • one row per store: credential type (never a value or identifier), reachability from its last real request, hits, misses, requests and any cooldown. An unconfigured store says what to set.
  • whether the daemon is up, and since when
  • cache hits and misses
  • real requests since start, and how many were rate limited
  • the active cooldown and its retry time
  • the read log’s 24-hour count
  • the 1Password account’s quota rows and their reset times, refreshed only explicitly with --refresh-quota or on the designated meter host, never during a cooldown. Ordinary status shows saved rows and their age. Key Vault has no quota endpoint, and status says so.

Quotas, budgets and recovery

1Password’s service-account limits share a daily allowance across every service account and machine: 1,000 for Individual and Families, 5,000 for Teams, and 50,000 for Business. Separate hourly limits apply per token. Creating another token does not increase the account’s daily allowance. Allocate host budgets so their sum leaves room for other software; a local guard cannot police a direct op call.

Every current kit resolver reserves a request in a locked, atomic ledger before contacting a provider. The host defaults to 200 requests in a rolling 24 hours, 40 in a rolling hour, and five per caller in a rolling minute. Scheduled account metering is off by default and costs zero requests. Host-budget warnings and cached status/attribution also cost zero requests. A caller loop stops before spending the host’s allowance. Cache hits cost nothing and bypass both brakes. A refused read says secrets budget: and exits 76, distinct from provider rate limits (75). The ledger survives service restarts and reboot. Failed attempts count; concurrent processes cannot reserve the same remaining slot. Corrupt or unwritable state fails closed, rather than resetting the count.

Set this host’s private ~/.hev/secrets/secrets-policy.json (0700 directory, 0600 file). No endpoint or dispatch request can supply a notification command or a policy. Omitted fields retain defaults; limits must be positive.

{
  "daily": 200,
  "hourly": 40,
  "caller_minute": 5,
  "meter_host": false,
  "meter_interval": "2h",
  "disable_stale": false,
  "thresholds": [50, 80],
  "notify": ["/usr/local/bin/secrets-notify"],
  "override_once": ""
}

Policy is reread on use. Raise an allowance after investigating, or set override_once to a new unique string to permit one otherwise refused operation; the ledger consumes that string once, even across restarts. Do not delete budget.json to reset spending. Keep the policy, ledger and lock together. HEV_SECRETS_POLICY selects another host-local policy path; otherwise these files sit beside the read log, even when cooldown persistence is disabled. Keep all resolvers on the same path. The read log’s existing columns remain; cache, stale and throttle kinds add free events.

Choose exactly one meter host by setting "meter_host": true in that host’s policy file only. It checks every two hours by default; set "meter_interval": "4h" to change this. All other hosts leave meter_host false (the default) and never poll, even with an interval set. The schedule checks once per minute, so checks can lag by up to a minute. Host-budget warnings continue independently on every host.

At one request per check, one designated host at two hours costs at most 12 requests/day: 1.2% of a 1,000-request shared account. Four hosts with the old 30-minute schedule would spend 4 × 48 = 192/day (19.2%) merely watching. Leaving metering off costs 0/day; a four-hour interval costs 6/day (0.6%). These are steady-state schedule costs; explicit refreshes add paid requests. hev secrets status shows the last saved reading and its age without contacting the provider. Use status --refresh-quota deliberately for a budgeted check, coalesced to at most one per five minutes. --no-quota remains a compatible spelling of free status. Sanitized readings persist beside the budget ledger in meter.json, scoped to the credential fingerprint. hev secrets attribution carries each host’s saved reading, timestamp and age alongside counts, without requesting a new meter reading. The provider’s CLI request-count rules say commands cost one request unless listed otherwise. service-account ratelimit is not an exception: kit budgets one request, including failures, and skips it during cooldown or when the host allowance is exhausted. op inject is one batch under these rules; the legacy direct op read path reserves three because names can require lookup requests. Counts are conservative reservations, not provider billing receipts. The fake CLI tests verify the guard without touching an account; no live meter experiment is required. status --no-quota never makes a provider request.

hev secrets status shows the host budget, last throttled caller, stale delivery count, notification failures, meter cost and last account/token allowances. Missing rows mean no successful meter answer yet (or unsupported CLI output); they are never guessed. At the configured percentages, the host invokes notify as argv, without a shell, appending an event such as account-read_write-80 or host-day-80. It runs once per observed threshold crossing, persisted across restart; falling below the threshold rearms it. A notification process receives PATH only, no secret-bearing environment, and has ten seconds to finish. Failed delivery is shown in status; it is not retried into a notification storm. Host-budget warnings are checked on reads; account warnings are checked on meter refreshes. No notification is sent unless the operator configures a command.

Shared account budget across a cluster

With [cluster] configured, every daemon publishes the numeric reservations from its durable ledger once a second and when reserving a request. No value, reference, token or caller label travels over gossip. Publishing and free status make no provider requests. Hosts without cluster configuration retain the local guard and existing warning behavior.

Set identical provider budgets in each host’s private policy, for example:

{
  "daily": 200,
  "hourly": 40,
  "caller_minute": 5,
  "account_daily": {"op": 900},
  "account_hourly": {"op": 120},
  "meter_host": false
}

op selects 1Password; azkv selects Azure Key Vault. Omitted account limits mean no account policy for that provider/window. Published account budgets must be positive; zero is not a way to block a provider. Host limits must always be positive and remain independent. Policy stays local rather than allowing a peer to raise another host’s spending permission. The fixed numeric policy heartbeat exposes mismatches in status; correct mismatches on every host before relying on a common budget. Neither account limit can be bypassed with override_once.

With fresh peer heartbeats, a new real request is refused when it would exceed the rolling account day or hour budget. Refusals retain secrets budget: and exit 76, say account and include spending per node. Cache hits remain free. Status shows each node’s rolling totals and heartbeat age in seconds; -1 means no ledger heartbeat has been received. Retained counts from stale or missing peers stay in the totals rather than silently becoming zero.

A host with no peer heartbeat newer than five seconds says cannot see cluster; using host budget and falls back to its mandatory host budgets. This includes a lone configured member and unavailable cluster startup. On reconnection the ledger buckets converge and account enforcement resumes. A heartbeat certifies ledger publication, not just membership. Peer counts are only RAM replicas; a restarting host republishes its durable ledger. Loss of every member can undercount until all hosts republish. Use synchronized clocks.

Gossip is eventually consistent, not a distributed transaction. Under normal bounded dissemination delay D, overshoot is at most the sum over hosts of requests admitted during D: conservatively sum(B_i + r_i * D), where B_i is the maximum in-flight batch reservation and r_i is that host’s admitted request rate. D includes the one-second publisher interval for direct local ledger writers and all gossip hops/retransmissions (500ms per gossip interval under healthy delivery), not just a single interval. With four hosts, five requests per caller per minute, one caller per host, batch size one and D=2s, the conservative bound is five extra requests after rounding up. Multiple callers multiply the rate; the hourly host cap bounds their aggregate burst. There is no fixed D under packet loss or overload, and a host may fall back after five seconds. During partitions the account limit is not guaranteed: the maximum remaining spending is bounded instead by the sum of remaining host budgets. Minute buckets retain the oldest boundary minute, conservatively overcounting by up to one minute of events instead of expiring reservations early.

For four hosts sharing a 1,000/day allowance, a 900/day account limit leaves 100 for external tools and dissemination slack. Four host limits of 200/day and 40/hour cap isolated kit use at 800/day, plus outside-kit spending. A busy host can use its full 200 without manually splitting the account’s 900 between hosts. Raising host limits allows more flexible connected use but increases the partition exposure; for example four 300/day caps permit 1,200 during a partition. Choose that tradeoff explicitly, never rely on gossip as a strict provider allowance.

Provider cooldowns propagate too. A peer-learned cooldown is named in status, errors and a free cooldown read-log event; no real request is sent before its retry time. The existing stale-value rule still applies. Exactly one host sets meter_host: true; only that host evaluates account threshold notifications, using its durable crossing ledger. Host warnings remain independent. This prevents one account crossing from notifying once on every machine; configuring two meter hosts forfeits that guarantee.

The meter host publishes its sanitized account reading. Every node shows its source node and age without a provider request. unexplained spending is max(0, provider used - cluster rolling-day reservations): spending the kit ledgers do not explain. For example provider used=750 and kit totals=620 shows 130 unexplained requests. Outside-kit tools are the expected source, but stale or missing ledgers, differing provider windows and clock skew can also cause a gap; inspect ages before attributing it conclusively. The figure is an operator signal, not an audit receipt. Account and token meter rows remain available on the meter host; the shared record carries the account row.

When a provider rate limits, kit serves a held value past TTL, with source=stale, a kind=stale read-log event and a status counter. It makes no refresh request during cooldown; the next read after reset refreshes it. Values remain only in RAM, retained at most 24 hours from their last fetch. Missing values still fail. Authentication, not-found and other non-rate errors evict held values and never serve stale. Set disable_stale to true for jobs that must refuse expired values.

Run an independent hev daemon --secrets-only service as the long-lived cache owner, before Capture starts. The staged Linux unit and Capture drop-in express this ordering; on other systems start the secrets-only service first. Capture may fail to bind the occupied endpoint harmlessly and uses that owner. A Capture or worker restart then costs zero requests for recently fetched values. Restarting the secrets owner itself, including an update that restarts it, or rebooting loses RAM values: the first subsequent batch costs one request again, subject to the surviving ledger and cooldown. There is no secret persistence, OS keychain dependency or plaintext secret on disk. Restarting a service alone never fetches a value.

For cross-host attribution run:

hev secrets attribution --config ~/.config/hev/dispatch.toml

It asks every configured dispatch host for the last day’s summary: host, caller, provider, reserved real requests, cache hits and throttles. Only the owner may request this; invited members are refused on the host even if request fields claim to be an owner. Values, references and tokens never cross this command. Unreachable or older hosts are reported as errors, not silently omitted. Free-event counts cover retained read-log generations; the paid ledger is independent of log rotation and log disabling. Native-gate cached resolution requires current hev on PATH, including for direct fallback, and never retries a budget refusal as a raw op read.

During exhaustion, keep the secrets owner running, inspect local status and attribution, stop the offending loop, and wait for the reported provider reset or the host’s rolling window. Raising a local budget does not clear a provider cooldown. Do not repeatedly restart services or delete cooldown state. Direct op calls, tools that invoke it themselves, old binaries and explicit native gate OPResolver use escape this guard. Find them by inspecting service and scheduler definitions, wrapper scripts and process command names; compare the account meter with attributed host spending. A difference suggests such callers or a host missing from the inventory. Do not log command environments or secret arguments to investigate them.

Wrapper and polling-worker rule: resolve once, hold the value in the process environment or memory, and reuse it. Never fetch per poll or per launch. Keep a long-lived worker where possible and use --caller with a stable job label so restarts remain attributable.

Windows: replace a per-launch credential fetch

Keep the wrapper’s engagement boundary: validate the intended account and store ACL, reject ambient credentials, allowlist nonsecret child settings, and select only that engagement’s references. The cache replaces fetching, not that boundary. A LocalMachine DPAPI blob can be decrypted by other accounts on the machine if they obtain it; its protected ACL is essential.

Configure a protected token

Both hevd and each caller use these settings, with no token in their task arguments or environment:

$env:HEV_OP_DPAPI_FILE = 'C:\Example\CredentialStore\token.dpapi'
$env:HEV_OP_DPAPI_SCOPE = 'LocalMachine'
$env:HEV_OP_DPAPI_ENTROPY = 'example-fixed-entropy'
Remove-Item Env:OP_SERVICE_ACCOUNT_TOKEN -ErrorAction SilentlyContinue
hev secrets token-store inspect

HEV_OP_DPAPI_FILE selects a raw binary blob written by .NET ProtectedData.Protect; kit does not wrap or rewrite it. Use LocalMachine for an existing machine-scoped store, CurrentUser for a user-scoped one (the default). HEV_OP_DPAPI_ENTROPY supplies the exact UTF-8 bytes of the original fixed entropy string; leave it unset when the original used no entropy. The decrypted token must be UTF-8 text. A store using different byte encoding or a base64/CLIXML envelope needs conversion by its operator; do not point kit at an envelope or guess the entropy. With those matching settings an existing raw store is used unchanged.

Every read checks the file and its immediate directory: both must have a protected DACL with no inherited entries, allow access only to the current user, SYSTEM and built-in Administrators, and have an owner from that same allowlist. Unknown ACE types and links are refused. An unexpected principal is named by SID. A configured store that is absent, unsafe or cannot decrypt fails closed; kit does not try the plaintext file. Environment tokens still have first priority, so the boundary wrapper must continue rejecting them. HEV_OP_TOKEN_FILE and its existing default continue to work when DPAPI is not configured. Keychain and Linux credential stores are left for future implementations of the credential-storage seam.

For a new store, pipe a token from an approved input source into stdin:

# Read-Host's secure input avoids echo/history; no token is a process argument.
$secure = Read-Host 'Service account token' -AsSecureString
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try {
  [Runtime.InteropServices.Marshal]::PtrToStringBSTR($ptr) |
    hev secrets token-store create
  if ($LASTEXITCODE -ne 0) { throw 'Token store creation failed' }
} finally {
  [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr)
  $secure.Dispose()
}
hev secrets token-store inspect

Creation makes a new dedicated directory private, refuses an unsafe existing directory or any existing destination file, and prints only path, scope and ACL reader SIDs. Do not enable PowerShell transcription for credential entry. Inspection checks ACLs without decrypting. Use an ASCII service-account token when piping from Windows PowerShell; PowerShell 7 uses UTF-8 by default.

Move the wrapper

Previously, after the wrapper’s account/ACL checks and environment cleanup, it decrypted its token and fetched each value separately:

# Before: token came from the wrapper's protected store, never ambient fallback.
$env:OP_SERVICE_ACCOUNT_TOKEN = $protectedToken
$env:BUILD_TOKEN = & op.exe read 'op://example/build/token'
$env:PACKAGE_TOKEN = & op.exe read 'op://example/package/token'
$env:REPORT_TOKEN = & op.exe read 'op://example/report/token'
& 'C:\Example\bin\worker.exe' @args

After, keep those boundary checks and the DPAPI configuration above. The wrapper does not decrypt the token itself or call op. It makes one resolution for all three references. Set the host’s manager in its kit config (the DPAPI credential is used when that manager is 1Password):

[secrets]
manager = "1password"
vault = "example"
field = "token"

Keep only references in C:\Example\config\worker.env:

BUILD_TOKEN=secret://build
PACKAGE_TOKEN=secret://package
REPORT_TOKEN=secret://report

Then launch with the reference file:

# Existing boundary checks run first; refuse any ambient service-account token.
if (Test-Path Env:OP_SERVICE_ACCOUNT_TOKEN) { throw 'Ambient token refused' }
# Set the HEV_OP_DPAPI_* settings above in this wrapper's resolver environment.
& 'C:\Example\bin\hev.exe' secrets run --cache-only --clean-env `
  --pass-env SystemRoot --pass-env TEMP --pass-env TMP `
  --env-file 'C:\Example\config\worker.env' `
  --ttl BUILD_TOKEN=1h --ttl PACKAGE_TOKEN=1h --ttl REPORT_TOKEN=1h `
  --explain -- 'C:\Example\bin\worker.exe' @args
exit $LASTEXITCODE

Use an absolute child executable path. --clean-env starts from an empty child environment; repeat --pass-env NAME only for approved nonsecret settings the child requires. Credentials and resolver settings are not implicitly forwarded. Without this flag the existing inherited-environment behavior remains. Any missing required reference aborts the whole resolution before starting the child; an ambient value cannot substitute for it. --cache-only also refuses direct reads when the daemon is unavailable; remove it only if the boundary deliberately permits a direct batched fetch. Values travel only through IPC and the child’s environment. Do not let the child dump its environment or echo secrets.

Enable the cache in the capture task and verify

  1. Install the reviewed binary at its permanent path on the Windows host. Inspect the existing store with the settings above, under the task’s own Windows identity. Do not recreate an existing matching store.
  2. Configure [secrets] in the task’s selected kit config as above. Put the same nonsecret HEV_OP_DPAPI_* settings in a task launcher script outside the repository, protected by the same private ACL. It must clear or reject OP_SERVICE_ACCOUNT_TOKEN, set those variables, then execute the permanent hev.exe daemon with the task’s existing config path. Keep HEV_SECRETS_CACHE unset (or remove a previous off). Never put the token in the script or the scheduled task.
  3. Stop the capture task with hev daemon stop. In Task Scheduler, preserve the installed \hev\hevd task’s identity, S4U logon, triggers and settings, and change its action to run the launcher using PowerShell -NoProfile -NonInteractive -File C:\Example\bin\start-capture.ps1. The launcher must run hev.exe daemon in the foreground, wait for it, and propagate its exit code. A later task reinstall may replace this custom action: inspect it again after reinstalling.
  4. Start with hev daemon start. From the boundary wrapper’s configured environment run hev secrets ping and hev secrets status --no-quota. Verify daemon: up and service-account token (DPAPI protected file). If only a cache is needed, run hev.exe daemon --secrets-only under the same launcher settings instead of capture; do not run two endpoints.
  5. Once the account’s cooldown has expired, launch the worker twice. Do not delete a cooldown or retry a failed fetch. Compare --explain, status and the read log. Use --no-quota to avoid a quota-inspection request.

Example observations (illustrative counts, no values):

Before: wrapper launched 10 times; 30 separate op read requests.
hev secrets status --no-quota
  daemon: unavailable
  host read log: 0 real requests (old wrapper bypassed kit's log)

After first launch:
hev secrets: BUILD_TOKEN source=read via=daemon
hev secrets: PACKAGE_TOKEN source=read via=daemon
hev secrets: REPORT_TOKEN source=read via=daemon
2026-11-13T10:00:00Z caller=wrapper kind=inject refs=3 labels=BUILD_TOKEN#12345678,PACKAGE_TOKEN#23456789,REPORT_TOKEN#34567890 outcome=ok provider=op

After ten launches within the one-hour TTL:
hev secrets status --no-quota
  daemon: up since 2026-11-13T09:59:00Z
  cache: 27 hits, 3 misses
  real requests: 1 since start
  1Password credential: service-account token (DPAPI protected file)
  host read log: 1 real requests
hev secrets: BUILD_TOKEN source=cache via=daemon
# No additional inject lines for cache hits.

The log is %USERPROFILE%\.hev\secrets\op-reads.log unless relocated by HEV_SECRETS_READ_LOG. The legacy wrapper’s requests are visible in its own safe request counts or provider quota, not retroactively in kit’s log. Log labels above use illustrative hashes. Only explicit status --refresh-quota can add a separate quota check. Restarts empty the cache; shorter TTLs, new references and TTL expiry cost another batch.

Windows CI exercises DPAPI and ACL checks using fake credentials. Actual engagement ACLs, existing file encoding, scheduled-task identity/profile, S4U DPAPI availability, reboot startup, and the engagement’s child behavior still require this on-host verification. No real provider account is needed by the tests.

esc