Skip to content

[M1.6] Agent self-reconciliation and host facts - #155

Merged
samuelmbabhazi merged 4 commits into
mainfrom
feat/m1.6-reconcile
Nov 5, 2026
Merged

samuelmbabhazi merged 4 commits into
mainfrom
feat/m1.6-reconcile

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Part of #18.

What changed

M1.6: the agent keeps workloads in their recorded state on its own (CLAUDE.md rule 10).

  • Journal. A new intent table (container name, should-run flag) with SetIntent, ClearIntent and Intents.
  • Lifecycle handlers keep the intent:
    • start sets it after starting;
    • stop clears it before stopping, so the reconciler never restarts a container that is shutting down;
    • remove clears it, then forgets it.
  • agent/internal/reconcile. Every 30 s, with or without the control plane, the reconciler:
    • starts each managed container that should run but is not running (crash, docker kill, daemon restart);
    • records each observation as a ContainerStatus in the journal's actual state;
    • never touches unmanaged containers, and leaves missing containers to the control plane, since secrets are not stored on the node.
    • It runs in its own goroutine owned by Agent.Run and stops before the journal closes.
  • collect_facts. It reports hostname, OS, kernel (uname), architecture, CPU count, memory (/proc/meminfo), state-directory disk size and free space (statfs), the Docker version (GET /version, 2 s timeout) and the agent version. No command is ever run.
  • Docs. The SPEC describes reconciliation. M1.6 stays open in the PLAN for:
    • StateReport delivery to the control plane;
    • Caddy --resume in the installer (M8.3), so routes survive a Caddy restart;
    • the end-to-end acceptance on a VM.

How it was tested

  • Reconciler with the real journal:
    • only the crashed managed container that should run is restarted; a stopped-on-purpose, missing, unmanaged or healthy container is not;
    • the observation is recorded as running;
    • an intent is cleared on removal, and an invalid name is refused.
  • Facts are complete, an unreachable daemon leaves the version empty, and the collect_facts result is produced.
  • Existing lifecycle tests are updated.
  • go test -race ./agent/..., golangci-lint (0 issues) and the local gate pass.
  • Not run locally: a real Docker daemon.

Security considerations

  • The reconciler only starts containers Shipkeep manages and that an authorized action asked to run.
  • Facts collection runs no command.

@samuelmbabhazi
samuelmbabhazi merged commit eb41e15 into main Nov 5, 2026
1 of 10 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m1.6-reconcile branch November 5, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant