Skip to content

feat: bootstrap Atom actions via YAML config, remove imperative bootstrap-actions - #3561

Open
arvindh123 wants to merge 5 commits into
absmach:mainfrom
arvindh123:claude/magistrala-atom-bootstrap-yaml-vxg6n0
Open

feat: bootstrap Atom actions via YAML config, remove imperative bootstrap-actions#3561
arvindh123 wants to merge 5 commits into
absmach:mainfrom
arvindh123:claude/magistrala-atom-bootstrap-yaml-vxg6n0

Conversation

@arvindh123

Copy link
Copy Markdown
Contributor

Summary

  • Add docker/atom-bootstrap.yaml with all 14 capabilities (36 applicability entries) and 2 action assignment rules
  • Wire YAML into atom service via bind mount and ATOM_BOOTSTRAP_FILE env var
  • Remove bootstrap-actions subcommand from cmd/atom-bootstrap/main.go (provision-tokens preserved)
  • Delete pkg/atom/bootstrap.go and pkg/atom/bootstrap_test.go
  • Move atom-bootstrap compose service behind profiles: [tokens]
  • Retarget 6 services' depends_on from atom-bootstrap to atom

@arvindh123
arvindh123 force-pushed the claude/magistrala-atom-bootstrap-yaml-vxg6n0 branch from a9acc6b to 92068df Compare August 4, 2026 08:13
dborovcanin and others added 5 commits August 4, 2026 13:43
Signed-off-by: dusan <borovcanindusan1@gmail.com>
…trap-actions

Replace the Go-based imperative bootstrap-actions code path with Atom's
new declarative YAML bootstrap. Atom now reads capabilities and guardrail
rules directly from a config file at startup, eliminating the need for a
separate init container to call its HTTP API.

- Add docker/atom-bootstrap.yaml with all 14 capabilities (read, write,
  delete, manage, publish, subscribe, execute, list, alarm_*), their 36
  applicability entries, and 2 device pub/sub assignment rules
- Wire the YAML into the atom service via ATOM_BOOTSTRAP_FILE env var
  and a read-only bind mount
- Move atom-bootstrap compose service behind profiles: [tokens] so it
  no longer starts on docker compose up
- Retarget all downstream depends_on from atom-bootstrap to atom
- Remove bootstrap-actions subcommand and default fall-through from
  cmd/atom-bootstrap/main.go (provision-tokens remains)
- Delete pkg/atom/bootstrap.go and pkg/atom/bootstrap_test.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P79iLj4z6gygnCArG7AGyA
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
Replace the deleted `atom-bootstrap provision-tokens` Go binary with a
single shell script that produces both files consumed by docker compose
from the same random material:

- docker/atom-bootstrap.yaml (mounted into the atom container) — declares
  the service entity's access token credentials so Atom hashes them at
  first boot and stamps each row managed_by='config'. Once stamped, the
  Atom API refuses to revoke or list the credential (invisible to
  introspection) — see the companion atom PR.

- docker/.env.tokens (loaded by docker compose) — plain env file that
  supplies ${MG_ATOM_TOKEN_*} for the ATOM_SERVICE_TOKEN of each service.

Because both files are generated together from the same tokens, `docker
compose up` needs no init container: services come up already holding
credentials that Atom has already accepted.

- Rename docker/atom-bootstrap.yaml (capabilities + guardrails only) to
  docker/atom-bootstrap.template.yaml; script concatenates the credentials
  block onto it to produce the final file.
- New scripts/generate-atom-secrets.sh: mints 11 tokens with openssl,
  refuses to overwrite unless --force, writes both files with mode 0600.
- Makefile: atom-secrets target (one-shot), atom-secrets-rotate target
  (regenerate + restart atom + reminder), and a docker/.env.tokens
  prerequisite on run_latest / run_latest_ci so the stack cannot come up
  without tokens. Both compose invocations now pass --env-file
  docker/.env.tokens.
- Compose: strip the dead ATOM_ADMIN_TOKEN/USERNAME/SECRET and
  ATOM_SERVICE_USERNAME/SECRET fallbacks from fluxmq-auth (the only
  downstream service that still carried them); the pkg/atom loginAdmin
  fallback path is now unreachable from stack services.
- README: document the first-time setup and the rotation flow.
- .gitignore: docker/atom-bootstrap.yaml and docker/.env.tokens are
  generated per-deployment and carry live secrets.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
… exit 0 when idempotent

Two rough edges surfaced when bringing up the full compose stack against a
local Atom image:

1. The bootstrap YAML was chmod 0600, but Atom runs inside its container as
   uid 999 (`atom`) while the bind-mounted file preserves the host uid. Atom
   crash-looped with "failed to read bootstrap file: Permission denied". Bump
   the YAML to 0644 (the file is bind-mounted read-only and its contents are
   the same tokens already sitting in `.env.tokens` which docker compose
   reads on the host); leave `.env.tokens` at 0600 since nothing in a
   container ever reads it. In production, chown to the container uid and
   tighten to 0640.

2. The script exited 1 when both target files existed, which broke the
   Makefile `docker/.env.tokens:` prereq — every `make down` (or any other
   make invocation touching that rule) failed because the "files already
   present" case was treated as an error. Exit 0 in that case; the message
   is still printed and `--force` remains the way to actually rotate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Arvindh <arvindh91@gmail.com>
@arvindh123
arvindh123 force-pushed the claude/magistrala-atom-bootstrap-yaml-vxg6n0 branch from 92068df to 67250b3 Compare August 4, 2026 08:14
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.

3 participants