vault-api
Typed read API over an Obsidian vault working tree. It serves typed tasks and goals from an in-memory index instead of one Markdown read per file, using vault-cli's domain types rather than a parallel model.
Endpoints
| Endpoint |
Purpose |
GET /api/v1/tasks |
List tasks; filters vault, assignee, status, phase, goal, cluster, task_type, short_id, updated_since, flag, due — status, phase and task_type accept repeated or CSV values, unioned |
GET /api/v1/tasks/{id} |
One task by task_identifier or filename slug; 422 when its frontmatter is invalid |
GET /api/v1/assignees |
Every distinct assignee across the served vaults, plus whether any task is unassigned; filter vault (repeated or CSV) |
GET /api/v1/goals |
List goals |
GET /api/v1/goals/{id} |
One goal by goal_identifier or filename slug |
GET /api/v1/claims |
List claims; filter holder |
GET/POST/DELETE /api/v1/tasks/{id}/claim |
Read, acquire or release a task claim |
GET/POST/DELETE /api/v1/repos/{owner}/{repo}/claim |
Read, acquire or release a repository claim |
GET/POST/DELETE /api/v1/repos/{owner}/{repo}/pulls/{number}/claim |
Read, acquire or release a per-pull-request claim |
GET /readiness |
200 with vault, index_age_seconds, tree_age_seconds, head, warnings; 503 until the first index build, and again whenever either freshness signal leaves --stale-after |
GET /healthz, /metrics, /setloglevel/{level}, /gc |
Fleet admin endpoints |
List responses carry items, total, warnings, index_age_seconds and vaults. A file whose frontmatter does not parse, or whose status/phase is present but not a known value, is excluded from list results and counted in warnings — never coerced.
vaults names every vault this instance serves — the primary first, then each attached vault. It exists because a list query cannot express coverage: a vault this instance does not index and a vault it does index but which has no matching rows both answer with items: []. A consumer joining its own configured set against vaults is the only way to tell "no source for that vault" from "nothing in that vault". It is the configured set, not a liveness claim — an attached vault whose last build failed still appears, so read /readiness's unavailable_vaults for the freshness half.
GET /api/v1/claims is the one list that reads live rather than from the index, so its envelope is items, total and skipped instead: there is no index whose age could describe a claim, and reporting one would be a number a caller might gate on. skipped counts refs under the claims/ prefix that are not addressable claims — the redrive streak keys are counters, never acquired or released. A claim carries scope, id, holder, task_id, lease_until, renew_before and lease_token, and never the transport key: a caller addresses a claim by scope and id, which is what the renew and release routes accept.
Readiness
GET /readiness answers 200 only while all three hold, and 503 otherwise:
- the last build succeeded — a failed rebuild leaves the previous index serving but clears the flag, and the next good build restores it;
index_age_seconds — how long since the index was last confirmed to match the tree — is inside --stale-after. Every refresh tick that finds the HEAD unmoved counts as a confirmation, so a steady tree does not age the index;
tree_age_seconds — how long since .git/FETCH_HEAD was written, i.e. since the tree was last fetched from its remote — is inside --stale-after. Every git fetch rewrites that file, including one that brings nothing new, so its age is the puller's heartbeat. null when the tree carries no FETCH_HEAD (a clone that was never fetched), in which case this signal is skipped.
The two ages are separate because they fail independently: a rebuild can fail on a live tree, and a tree can freeze under a perfectly healthy loop. The second is what catches a tree nothing advances — a frozen tree and a quiet one both leave the HEAD unmoved, so a pod comparing HEAD to HEAD sees nothing wrong while the tree falls arbitrarily far behind the remote.
--stale-after defaults to 5m, ten times the 30 s --refresh-interval; 0 disables the rule, which is what a local run against a tree nothing fetches wants. Because /readiness is the readinessProbe on every deployment, a pod whose tree stops being fetched leaves its Service endpoints rather than serving stale data — /healthz is untouched, so it is never restarted for it.
When GATEWAY_SECRET is set, every /api/v1/* request must carry it in X-Gateway-Secret.
Run
go run . \
--vault-path /path/to/vault \
--vault-name private-personal \
--event-vault-name personal \
--tasks-dir "25 Tasks" \
--goals-dir "24 Goals"
--vault-name is the display name the read API reports. --event-vault-name is the
routing slug stamped on task change events as lib.Task.Vault, and it must equal the
agent-task-controller's VAULT_NAME and the agent-task-executor's TASK_VAULT for
the same vault. A consumer owns a task only when the event's value equals its own, so a
mismatch drops every task this instance publishes as foreign vault and nothing is
spawned. Omitted, it falls back to --vault-name — correct only where the two names are
the same.
Build
make test
make precommit
The image is docker.io/bborbe/vault-api; make build upload publishes it from a tagged tree.
Building on a cluster
make build BUILD_TARGET=<cluster> builds the image as a BuildKit Job inside a
Kubernetes cluster instead of on the local Docker daemon, so a machine with no
Docker installed can still publish. REF is the git ref the Job clones and
VERSION is the tag it pushes; both are required, and VERSION has no usable
default because the default resolves to the newest release tag.
make build BUILD_TARGET=sun REF=$(git rev-parse HEAD) VERSION=<tag>
<tag> is pushed to docker.io/bborbe/vault-api, so it replaces an existing
tag of the same name — use a scratch tag such as scratch-vault-api-20261103-1
unless you are deliberately publishing a release.
BUILD_TARGET accepts sun, nukedev, nukeprod, or any kubectl context in
the default kubeconfig. The Job clones the repository with a GitHub App
installation token minted from the git-app secret in the build namespace and
pushes with the buildkit-push secret there; override them with
BUILD_GIT_SECRET and BUILD_PUSH_SECRET. BUILD_TARGET left at its default
of local keeps the plain docker build path unchanged.