fix: [nomad-step-2] S2.1 — vault/policies/*.hcl + tools/vault-apply-policies.sh (#879) #888
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#888
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-879"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #879
Changes
Land the Vault ACL policies and an idempotent apply script. 18 policies: service-{forgejo,woodpecker}, bot-{dev,review,gardener,architect,planner, predictor,supervisor,vault,dev-qwen}, runner-{GITHUB,CODEBERG,CLAWHUB, NPM,DOCKER_HUB}_TOKEN + runner-DEPLOY_KEY, and dispatcher. tools/vault-apply-policies.sh diffs each file against the on-server policy text before calling hvault_policy_apply, reporting created / updated / unchanged per file. --dry-run prints planned names + SHA256 and makes no Vault calls. vault/policies/AGENTS.md documents the naming convention (service-/ bot-/runner-/dispatcher), the KV path each policy grants, the rationale for one-policy-per-runner-secret (AD-006 least-privilege at dispatch time), and what lands in later S2.* issues (#880-#884). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>secret/mount prefix but migration policies usekv/— agents will get 403 #890AI Review
Summary
S2.1 lands the policy files and apply script. Both are correct and well-structured.
Script correctness (
tools/vault-apply-policies.sh)Token resolution chain is complete.
hvault_token_lookupcalls_hvault_check_prereqs→_hvault_resolve_token, which exportsVAULT_TOKENfrom env or/etc/vault.d/root.token. So whenfetch_current_policyreferences${VAULT_TOKEN}inside its subshell, the variable is guaranteed to be populated. ✓Subshell + EXIT trap pattern is correct. The RETURN-trap gotcha is documented and avoided — the subshell's EXIT fires on any exit path including
set -eabort, so the tmpfile cannot leak. ✓Content comparison is sound. Both
desired=$(cat "$f")andcurrent=$(fetch_current_policy ...)go through command substitution, which strips trailing newlines consistently on both sides. The comparison is symmetric and won't spuriously flip to "updated" due to trailing-newline differences. ✓Dry-run guard ordering is correct. The dry-run block exits before the
VAULT_ADDRcheck andhvault_token_lookupprobe, so--dry-runrequires no Vault access as documented. ✓hvault_policy_applyconfirmed. The function exists inlib/hvault.sh(line 183), acceptsNAME FILE, JSON-encodes the content viajq -n --arg policy, and PUTs tosys/policies/acl/<NAME>. Matches what the script expects. ✓Policy file correctness
All families follow their documented patterns:
kv/data/disinto/bots/<role>/*(read) +kv/metadata/...(list,read) +kv/data/disinto/shared/forge/*(read). Nine files, all consistent. ✓kv/data/disinto/shared/<name>/*+ metadata. Two files, consistent. ✓kv/data/disinto/runner/<TOKEN>path, read only, no metadata/list. Six files. The deliberate omission of list/metadata is correct per AD-006 (least-privilege per dispatch). ✓All HCL paths use
kv/as the mount name, consistent with the KV v2 convention documented in the AGENTS.md.Tech debt filed
Pre-existing mount mismatch in
lib/hvault.sh:hvault_kv_get,hvault_kv_put, andhvault_kv_listall usesecret/data/andsecret/metadata/as path prefixes (lines 117, 157, 173), but the policies in this PR and the migration convention usekv/as the mount name. Any agent callinghvault_kv_getwill hitsecret/data/...but only hold ACL forkv/data/..., producing a 403 at runtime. This is not introduced by this PR — filed as tech debt separately.Verdict
APPROVE — Script is correct, policies are consistent, idempotency contract is sound; one pre-existing tech-debt issue filed separately.
Reviewed at
86807d6| AGENTS.mdAI Review: APPROVE — Script is correct, policies are consistent, idempotency contract is sound; one pre-existing tech-debt issue filed separately.