Skip to content

Agent core design ​

agent-core is a small-parts library, not a framework. Each capability lives in a separate package, each agent binary imports only what it needs, and an unused package is not compiled into the binary. The design goal is to add capture, devops, and future agents without duplicating registration, reporting, auditing, probing, or supervision semantics.

Design decisions ​

DecisionConsequence
No god object or core.AppThe agent main owns assembly and imports only required packages.
Business capabilities stay outside coreCapture CDC, devops sessions, and function routing remain role-specific.
Shared runtime semantics move into coreRegistration, heartbeat, reporting, metrics, probing, execution logs, and supervision contracts have one implementation.
Agents are supervised targetssupervisable.Main installs signals, exit-code discipline, and heartbeat context; the sidecar supervisor can manage any core-based agent.
Audit before risky executionCommand or mutation execution requires a persisted execution record before the operation starts.

Package responsibilities ​

PackageResponsibility
core/backoffShared retry/backoff policy wrapper.
core/logxStructured logging and rotation setup.
core/registerServer registration, heartbeat, re-registration, and reconnect behavior.
core/reportCommon upstream reporting; metrics first, with the alert wire added separately.
core/supervisableThe supervised-process contract and thin main entry point.
core/metricsProcess and host metric collection independent of the function channel.
core/configsyncVersion polling, fetch, and hot application of configuration.
core/healthprobeLiveness, readiness, heartbeat checks, failure thresholds, and fault windows.
core/execlogExecution audit records, local truth files, upload interface, and audit-first gate.
core/crashSnapshot profile handling and dump-directory management.

Task execution and the local SDK/provider gateway remain sidecar-agent responsibilities. Omitting them from core also removes those attack surfaces from capture and devops agents.

Health probes ​

SemanticQuestionTypical consumer
LivenessIs the agent process alive?Sidecar game-process supervision.
ReadinessAre dependencies ready?Database/replication, guacd, or whitelisted host ports.
HeartbeatWhen was the last live signal?Supervisor context and console freshness.

Built-in HTTP, TCP, and process checkers use consecutive-failure thresholds. A fault is modeled as a window with a start time, recovery time, duration, and last reason. The local timeline is the durable truth; snapshots and window events can be reported to the console and forwarded to notification orchestration.

Execution auditing ​

An execution record captures operator, agent type and instance, action, parameters, result, duration, timestamp, business scope, and task/command identity. Local rotating files preserve records when the server is unreachable. Server ingestion is an upload boundary, not a prerequisite for local truth.

The audit-first gate applies to command-like mutations: if the record cannot be persisted, the operation is refused. Read-only polling does not pay this gate.

Extraction batches ​

The initial extraction was split into independently shippable batches:

  1. Backoff, logging, and health probes.
  2. Registration and supervised-process contracts.
  3. Reporting, metrics, and execution auditing.
  4. Configuration synchronization and crash support.

Each batch kept the existing sidecar implementation compilable, so a batch could stop without leaving a half-migrated dependency.

Known boundaries ​

  • Some core packages were built before every sidecar consumer was switched; consumer wiring proceeds by role and batch.
  • The alert-report wire and server-side execution-log ingestion may trail the local implementation.
  • Health-probe reporting and console consumption can be enabled after the local timeline is stable.
  • Historical nesting under agents/<role>/cmd is not the current entry-point model; actual entry points remain under the repository root cmd/.
  • Core and legacy internal paths coexist during migration; the runtime layout page is authoritative for current boundaries.