| /** | |
| * intent_schema.h | |
| * ูุธุงู ุงูููุงูุง ุงูุณูุงุฏู - ูููู ุงูุจูุงูุงุช ุงูุฃุณุงุณู | |
| * Sovereign Intent Schema - Core Data Structures | |
| * | |
| * Author: Ahmad Ali Parr | |
| * License: Sovereign Source | |
| */ | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Intent Type Constants | ุซูุงุจุช ุฃููุงุน ุงูููุงูุง | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /* Priority Levels | ู ุณุชููุงุช ุงูุฃููููุฉ */ | |
| /* Trust Nonce Size (Blake3 256-bit) */ | |
| /* Maximum Intent Payload Size (16KB) */ | |
| /* Maximum Goal Schema String (1KB) */ | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Intent Payload Structure | ูููู ุญู ููุฉ ุงูููุฉ | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /** | |
| * SystemIntent - User-submitted intent payload | |
| * | |
| * Instead of imperative syscalls, applications construct an intent | |
| * describing WHAT they want (goal) with constraints (trust nonce, | |
| * priority) and let the Kernel Agent Runtime (KAR) resolve HOW. | |
| * | |
| * Memory Layout: | |
| * - Fixed header (64 bytes) | |
| * - Variable payload (up to 16KB) | |
| * - Trust nonce (32 bytes Blake3) | |
| * | |
| * All fields are validated at the kernel boundary. | |
| */ | |
| struct SystemIntent { | |
| /* โโโ Core Intent Fields โโโ */ | |
| uint32_t intent_type; /* One of INTENT_* constants */ | |
| uint32_t priority; /* Execution urgency (0-3) */ | |
| uint32_t flags; /* Reserved for future extensions */ | |
| uint32_t payload_len; /* Length of payload_data in bytes */ | |
| /* โโโ Goal Description โโโ */ | |
| /** | |
| * goal_schema: Symbolic or serialized description of the desired outcome. | |
| * | |
| * Examples: | |
| * - "persist:durability=WORM,replication=3" | |
| * - "allocate:memory=4MB,alignment=4K,zone=DMA" | |
| * - "compute:model=classifier,input=tensor[224,224,3]" | |
| * | |
| * This is NOT Turing-complete code โ it's a structured constraint language | |
| * parsed by the KAR policy engine. | |
| */ | |
| char goal_schema[MAX_GOAL_SCHEMA]; | |
| /* โโโ Payload Data โโโ */ | |
| /** | |
| * payload_data: Pointer to working memory (user-space address). | |
| * | |
| * Kernel will copy_from_user() this safely. For zero-copy intents, | |
| * this can be a ring buffer descriptor instead. | |
| */ | |
| void *payload_data; | |
| /* โโโ Cryptographic Trust โโโ */ | |
| /** | |
| * trust_nonce: Blake3 hash of (intent_type || priority || goal_schema || timestamp) | |
| * | |
| * Verified by KAR before execution. Prevents: | |
| * - Intent replay attacks | |
| * - Privilege escalation via modified intents | |
| * - TOCTOU races (time-of-check to time-of-use) | |
| * | |
| * Generated by libasos in user space, validated in kernel. | |
| */ | |
| uint8_t trust_nonce[TRUST_NONCE_SIZE]; | |
| /* โโโ Execution Context โโโ */ | |
| uint64_t timestamp_ns; /* Monotonic clock at submission */ | |
| uint32_t source_pid; /* Process ID (set by kernel, not user) */ | |
| uint32_t source_uid; /* User ID (set by kernel, not user) */ | |
| } __attribute__((packed)); | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Intent Result Structure | ูููู ูุชูุฌุฉ ุงูููุฉ | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /** | |
| * IntentResult - Kernel's resolved outcome | |
| * | |
| * Returned to user space after KAR processes the intent. | |
| * Contains execution status, resolved resource handles, and | |
| * cryptographic seal for audit trail. | |
| */ | |
| struct IntentResult { | |
| /* โโโ Status Code โโโ */ | |
| int32_t status; /* 0 = success, negative = error code */ | |
| uint32_t kar_action; /* What the KAR actually did */ | |
| /* โโโ Resolved Resources โโโ */ | |
| uint64_t resource_handle; /* Opaque handle to kernel resource */ | |
| size_t bytes_transferred; /* For I/O operations */ | |
| /* โโโ Cryptographic Seal โโโ */ | |
| /** | |
| * worm_seal: Blake3(intent || result || timestamp) | |
| * | |
| * Immutable audit record. Can be verified against WORM chain | |
| * to prove this intent was executed with this outcome at this time. | |
| */ | |
| uint8_t worm_seal[TRUST_NONCE_SIZE]; | |
| /* โโโ Execution Metadata โโโ */ | |
| uint64_t execution_time_ns; /* Time spent in KAR */ | |
| uint32_t kar_agent_id; /* Which agent processed this */ | |
| } __attribute__((packed)); | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Ring Buffer Entry | ุฅุฏุฎุงู ุงูู ุฎุฒู ุงูู ุคูุช ุงูุญููู | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /** | |
| * RingBufferEntry - Single slot in the zero-copy ring | |
| * | |
| * User space writes intents here, kernel reads and marks consumed. | |
| * Lock-free single-producer single-consumer (SPSC) queue. | |
| */ | |
| struct RingBufferEntry { | |
| uint32_t sequence; /* Monotonic sequence number */ | |
| uint32_t state; /* 0=empty, 1=submitted, 2=processing, 3=done */ | |
| struct SystemIntent intent; /* The intent payload */ | |
| struct IntentResult result; /* Filled by kernel */ | |
| } __attribute__((aligned(64))); /* Cache-line aligned */ | |
| /* Ring buffer states */ | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Error Codes | ุฃููุงุฏ ุงูุฃุฎุทุงุก | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| * Compile-Time Assertions | ุชุฃููุฏุงุช ููุช ุงูุชุฑุฌู ุฉ | |
| * โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */ | |
| /* Ensure structures are properly sized for efficient copying */ | |
| _Static_assert(sizeof(struct SystemIntent) <= 2048, | |
| "SystemIntent too large - exceeds efficient copy threshold"); | |
| _Static_assert(sizeof(struct IntentResult) <= 256, | |
| "IntentResult too large - should fit in 4 cache lines"); | |
| _Static_assert(sizeof(struct RingBufferEntry) % 64 == 0, | |
| "RingBufferEntry not cache-aligned"); | |