interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / src / allen / allen_bind.h

85 lines · 4090 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* allen_bind.h -- ALLEN inside the resident organism: the three bindings.
18 *
19 * ARCH-0035 (PROPOSED). ALLEN is the durable subject the AIEN organism
20 * sustains. Its state is an AIENOS continuity object (kind 24,
21 * aienos native/kernel/svc/continuity_subject.h; OS-0018 PROPOSED). This
22 * module is the omega side of that contract and nothing more:
23 *
24 * 1. identity : the subject object is read and its id recomputed; the
25 * World's external subject number is recorded against the
26 * LogicalAgentId the object carries (the binding record);
27 * 2. memory : the subject's Cortex lineage reference must equal the
28 * digest of record 1 of the Cortex journal it is run with,
29 * or nothing is published (fail closed);
30 * 3. intent : each ACTIVE standing intent of kind GOAL_LATENCY is
31 * turned into the goal mutation the resident AIEN faculty
32 * already reads (rx_aien.h: goal = {seq, regime, target ns});
33 * field 3 carries the intent id's first 64 bits so the
34 * EXTERNAL crumb names the intent it came from.
35 *
36 * ALLEN publishes state; it never calls a faculty. The World's dependency
37 * machinery wakes aien.assess because the goal object changed (ARCH-0016,
38 * R16). There is no loop, no wait, no thread, no clock, no capability mint
39 * and no scheduling symbol in this translation unit; tests/allen/run.sh
40 * checks its symbol table (ALLEN-G5). */
41#ifndef ALLEN_BIND_H
42#define ALLEN_BIND_H
43
44#include <stddef.h>
45#include <stdint.h>
46
47#include "continuity_subject.h"
48#include "runtime/rx_cortex.h"
49#include "runtime/rx_world.h"
50
51/* Read a subject object file, decode it (every OS-0018 rule) and recompute
52 * its logical ObjectId. 0, or -1 with *why set. */
53int allen_load(const char *path, struct cs_subject *s, uint8_t id[32], const char **why);
54
55/* Cortex lineage reference: the digest of journal record 1. 0 on success;
56 * -1 when the journal holds no record (unbound). */
57int allen_lineage(const CxStore *cx, uint8_t out[32]);
58
59/* Fail-closed memory binding: 0 when the subject's lineage reference equals
60 * the journal's; -1 (with *why) when the subject is unbound, the journal is
61 * empty, or they differ. */
62int allen_check_memory(const struct cs_subject *s, const CxStore *cx, const char **why);
63
64/* The identity binding record (v0, host table of one row). */
65typedef struct {
66 uint32_t external_subject; /* RxWorld.external_subject */
67 uint8_t agent[32]; /* LogicalAgentId from the subject object */
68 uint8_t subject_id[32]; /* ObjectId of the subject object */
69 uint64_t sequence; /* subject chain sequence */
70} AllenBinding;
71void allen_bind_identity(const RxWorld *w, const struct cs_subject *s, const uint8_t id[32],
72 AllenBinding *out);
73
74/* The goal mutation for one ACTIVE GOAL_LATENCY intent. `seq` is the goal
75 * object's next sequence number (the writer's monotone counter). Returns the
76 * number of mutations written into out (4), or 0 if the intent is not an
77 * active goal-latency intent. */
78uint32_t allen_goal_mutations(const struct cs_intent *a, RxObjRef goal, uint64_t seq,
79 RxMutation out[4]);
80
81/* Hex helpers for the tool and the gate script. */
82void allen_hex(const uint8_t *b, size_t n, char *out);
83int allen_unhex(const char *s, uint8_t *out, size_t n);
84
85#endif