Skip to content

fix(cli,deploy): harden hosts.json writes, scope operator RBAC, fix Tiltfile and tooling hygiene - #1853

Closed
nikhilunni wants to merge 4 commits into
mainfrom
audit/p1-cli-ops-hardening
Closed

nikhilunni wants to merge 4 commits into
mainfrom
audit/p1-cli-ops-hardening

Conversation

@nikhilunni

@nikhilunni nikhilunni commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Hardens CLI credential storage, host-fleet operator RBAC, and local development tooling:

  • engram-app-client (hosts.json): Tightens existing config directories to 0o700, writes hosts.json atomically (a 0o600 temp file in the same directory, opened with that mode before any data is written, fsynced, closed, renamed, then the directory is fsynced), and surfaces corrupt JSON/read errors instead of silently wiping stored logins. A corrupt hosts.json now fails every command that needs a stored login, with the path in the message; ENGRAMS_API_KEY still bypasses the file.
  • Host-fleet operator RBAC: Moves apps/daemonsets and pods permissions from ClusterRole into a namespace-scoped Role + RoleBinding in deploy/helm/engram-host-fleet/templates/operator.rbac.yaml. The operator reads these only in spec.daemonSet.namespace, and the chart always renders the DaemonSet and the HostFleet CR with the release namespace. hostfleets and nodes stay cluster-scoped.
  • Tooling & hygiene: Moves dev secrets from cmd= to env= in Tiltfile, enables errexit + pipefail in justfile, replaces fixed /tmp/seed-buckets.out with mktemp + trap in deploy/dev/seed-buckets.sh, and removes tracked .codex-review-*.md files.

Upgrade notes (host-fleet chart)

  • Deployer permissions. The upgrade creates a Role and RoleBinding named <release>-operator in the release namespace. A deployer that is not cluster-admin needs create on roles and rolebindings there, plus get/patch/update/delete/bind on that name. Kubernetes also refuses to create a Role with rules the writer does not hold through RBAC, so the deployer must hold daemonsets: get, list, watch, patch and pods: get, list, watch, delete in the namespace. Grant these before the upgrade.
  • Upgrade window. Helm patches the narrowed ClusterRole before it creates the Role. Between the two, the operator gets Forbidden on DaemonSet and pod calls; each reconcile is idempotent and requeues in 15 s, so a short window is harmless. If the Role creation fails, the operator cannot reconcile (no rolls, no autoscaling) until the deployer is fixed or the release is rolled back.
  • Out-of-band HostFleet CRs (operator.createHostFleet: false) must name a DaemonSet in the operator's release namespace.

Validation

  • cargo fmt --check, cargo clippy -p engram-app-client --all-targets -- -D warnings, cargo hakari generate --diff.
  • cargo test -p engram-app-client -p engram-cli: 51 passed (27 engram-app-client + 24 engram-cli).
  • bash -n, ShellCheck, and helm lint/helm template (with operator.enabled=true) passed.
  • justfile: no recipe evaluates a backtick, and no non-shebang recipe depends on a failing pipe stage. With pipefail, smoke-health, smoke-create, and dev-shell now fail when curl fails instead of printing nothing.

🤖 Generated with Claude Code

nikhilunni and others added 4 commits December 2, 2026 13:57
write_hosts now closes the temp file before the rename, keeps the write or
rename error when the cleanup also fails, and fsyncs the directory so the
rename is durable. The test directory guard no longer panics in drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikhilunni

Copy link
Copy Markdown
Contributor Author

Combined into #1860 with the other audit PRs, so they merge and deploy together.

@nikhilunni nikhilunni closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant