/* harakiri_agent.h — Harakiri agent-native kernel: core state structs
 *
 * Every agent in the system (Vera, Mira, Merlin, Gaven, Brood workers,
 * HiveMind nodes) is represented by an hk_agent. Telemetry flows through
 * hk_telemetry. Minnoe transports these between contexts.
 */
#ifndef _HARAKIRI_AGENT_H
#define _HARAKIRI_AGENT_H

#include <linux/types.h>

/* Agent roles — the crew */
enum hk_role {
	HK_VERA    = 0,  /* intent router: every intent passes through first */
	HK_MIRA    = 1,  /* gate: triages proposals, speaks for the system */
	HK_MERLIN  = 2,  /* executor: Gordon loop analyze→propose→approve→execute */
	HK_GAVEN   = 3,  /* sentinel: η-gate, refusal is absence */
	HK_BROOD   = 4,  /* worker: execution fabric thread */
	HK_HIVE    = 5,  /* coordinator: mesh node, owns the Minnoe rings */
	HK_PAINTR  = 6,  /* painter: agentic portrait renderer */
	HK_NROLES
};

/* Agent lifecycle states */
enum hk_state {
	HK_IDLE = 0,   /* waiting for work */
	HK_ARMED,      /* has intent, awaiting gate */
	HK_RUNNING,   /* executing */
	HK_HELD,      /* held at Mira's gate */
	HK_DONE,      /* completed, telemetry flushed */
};

/* One agent. 64 bytes — fits a cache line. */
struct hk_agent {
	u32		id;		/* unique agent id */
	u8		role;		/* enum hk_role */
	u8		state;		/* enum hk_state */
	u16		flags;
	u32		quanta;		/* work units assigned */
	u32		quanta_done;	/* work units completed */
	u32		eta_x1000;	/* gate confidence η × 1000 (Gaven's threshold: 500) */
	u64		last_run_ns;	/* last execution timestamp */
	u64		total_ns;	/* cumulative execution time */
	char		name[16];	/* human-readable, e.g. "brood-03" */
	u8		_reserved[12];	/* pad to 64 bytes: one cache line */
} __attribute__((packed));

/* Telemetry sample — what Minnoe carries */
struct hk_telemetry {
	u32		agent_id;
	u32		seq;		/* sequence number */
	u64		stamp_ns;
	u32		quanta_done;
	u32		eta_x1000;
	u8		state;
	u8		_role_pad[3];
	u64		extra[2];	/* role-specific payload */
};

/* Compile-time sanity: the agent struct must stay cache-line sized */
_Static_assert(sizeof(struct hk_agent) == 64, "hk_agent must be 64 bytes");

#endif /* _HARAKIRI_AGENT_H */
