Use Kubernetes for workload truth and the pod-local Herdr server for terminal truth.
When the current runtime and intended target are the same Pod, container,
identity and tool environment, invoke the native command there directly. When
the target differs, or an explicit isolation or identity boundary requires the
target runtime, use native kubectl exec with the resolved context, namespace,
Pod and container. Neither path is a global preference: an exec into the
current Pod can still be deliberate, but it should not be an accidental hop
caused by forgetting where the caller already runs.
Use this only after the owning Mate has committed a downward Inbox row. The
doorbell is not a second message body and is not the normal delivery path for a
persistent Mate.
Run these commands through the target Pod's own Herdr CLI. From outside the
cluster, reach it with native kubectl and an explicit context. From a Mate,
invoke Herdr locally when it owns the target Pod, or use its in-cluster
Kubernetes credentials when the target is remote. Do not add an AgentOS
wrapper CLI for this sequence.
-
Load $agentos-delegation, $agentos-database and $agentos-harnesses.
Provision the Agent, Task, Assignment, database login and approved pgpass
Secret before Kubernetes mutation.
-
Resolve the owning Mate's namespace, Pod and serviceAccountName from
Kubernetes. Require its standard projected ServiceAccount token, CA and
namespace mounts and native in-cluster kubectl; never create, copy or
persist a bearer token or generated kubeconfig for steady-state child
supervision.
-
Create $HOME/.local/state/agentos/workloads/<handle>/kustomization.yaml.
Reference the released child base and patch every placeholder: resource
names, Agent labels and UUID, Herdr session, database URL and Secret, Task
and Assignment UUIDs where applicable, storage, selected image and image
pull policy. Published images require an immutable digest. In the managed
child's namespace, add one reviewed Role and RoleBinding that bind the
owning Mate's exact ServiceAccount and select only the child's stable Pod
name. Grant core pods get, list and watch; grant pods/exec
create only when the approved launch, attach, doorbell or recovery path
requires it. The RoleBinding subject must use the owning ServiceAccount's
exact name and namespace. Every rule must use resourceNames; never grant
sibling, label-wide or wildcard access. Remove a retired child name rather
than accumulating access.
-
Render a review artifact with native kubectl:
kubectl kustomize --load-restrictor LoadRestrictionsNone \
"$HOME/.local/state/agentos/workloads/<handle>" \
--output "$HOME/.local/state/agentos/workloads/<handle>/rendered.yaml"
-
Inspect the complete rendered resources. Require exactly one dedicated
ServiceAccount, headless Service and retained one-replica StatefulSet. The
child Pod must explicitly enable its projected ServiceAccount identity when
it is a persistent Mate that will supervise its own children. Require only
the exact-parent Role and RoleBinding selected in step 3; reject placeholder
values, any other or broader RBAC, public endpoints, mutable remote images
and ownership conflicts.
-
Ask for any installation, cost or RBAC approval not already recorded. Then
validate against the API server and inspect the diff:
kubectl --namespace <namespace> apply --server-side --dry-run=server \
--filename "$HOME/.local/state/agentos/workloads/<handle>/rendered.yaml"
kubectl --namespace <namespace> diff --server-side \
--filename "$HOME/.local/state/agentos/workloads/<handle>/rendered.yaml"
kubectl diff exit status 1 means a diff exists; other non-zero statuses
are failures.
-
Apply synchronously and retain the native result:
kubectl --namespace <namespace> apply --server-side \
--filename "$HOME/.local/state/agentos/workloads/<handle>/rendered.yaml"
kubectl --namespace <namespace> rollout status statefulset/<name>
-
Verify observed image IDs, ServiceAccount, Pod, PVC, Secret mount, Agent
environment and Herdr status; for a persistent Mate, also verify the
projected token mount. From the owning Mate identity, use
kubectl auth can-i to verify exact named-Pod get and watch; an external
reviewer may use --as only when its current identity already has
impersonation authority. Verify any selected pods/exec grant through the
already-approved native launch or attach action. A denial blocks unattended
supervision; a network or API failure remains a visible failure rather than
a reason to mint another token. For a Crewmate, create or recover the
project and Treehouse lease inside that pod. Copy the
PostgreSQL-authoritative brief's rendered harness view with native kubectl
and verify its digest inside the pod:
kubectl --namespace <namespace> cp \
"$HOME/.local/state/agentos/workloads/<handle>/brief.md" \
"<pod>:/home/agent/brief.md" --container crewmate
kubectl --namespace <namespace> exec pod/<pod> --container crewmate -- \
sha256sum /home/agent/brief.md
The destination must match the workload's AGENTOS_BRIEF_PATH. Then use
$agentos-harnesses to invoke
herdr agent start ... -- <native-harness-argv> <brief> through
kubectl exec.
-
Record verified Kubernetes and Herdr locators in Fleet state. Treat launch
as successful only after the native harness is processing the complete brief
without a trust or routine command-approval dialog. The owning Mate must use
$agentos-harnesses to reconcile a missing unattended launch or reviewed
repository-trust preflight instead of repeatedly pressing through ordinary
commands. On partial failure, preserve the identity, PVC and rendered
evidence for reconciliation; never create a replacement Agent to hide the
error.
Use only released Kustomize assets and native tool interfaces. Fail closed on ambiguous ownership or missing runtime assets.