/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Harakiri SI Core — Sovereign Intelligence Core
 * The supervisory center. All 9 agents report here. All routes flow through here.
 *
 * This is the kernel-side manifestation of the SI Core:
 * the gold icosahedron at the center of the Deep Alchemy system.
 */

#ifndef _HARAKIRI_SICORE_H
#define _HARAKIRI_SICORE_H

#include <linux/types.h>

/* SI Core states */
#define SICORE_STATE_BOOTING     0
#define SICORE_STATE_SOVEREIGN   1
#define SICORE_STATE_DEGRADED    2

/* Agent registration */
#define SICORE_MAX_AGENTS 16

struct sicore_agent {
    char name[32];
    pid_t pid;
    u32 lane;           /* 0-3: execution lane */
    u64 quanta_used;
    u64 last_heartbeat; /* jiffies */
    bool alive;
};

struct sicore_state {
    int state;
    u64 boot_jiffies;
    /* Coherence metrics (Kuramoto order parameter) */
    u32 eta_coherence;  /* fixed-point: eta * 1000 */
    u32 integrity;      /* fixed-point: integrity * 1000 */
    /* Agents */
    struct sicore_agent agents[SICORE_MAX_AGENTS];
    int n_agents;
    /* Command queue (from userspace via /proc/harakiri/sicore) */
    spinlock_t lock;
};

/* API */
int sicore_init(void);
void sicore_exit(void);
int sicore_register_agent(const char *name, pid_t pid, u32 lane);
int sicore_heartbeat(const char *name);
int sicore_set_coherence(u32 eta_fp, u32 integrity_fp);
struct sicore_state *sicore_get_state(void);

#endif /* _HARAKIRI_SICORE_H */
