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 / runtime / rx_seq_reference.h

75 lines · 3596 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/*
18 * rx_seq_reference.h -- R15 sequential control. REFERENCE ORACLE ONLY.
19 *
20 * This is the central-orchestration pattern ADR 0016 retires, rebuilt on the
21 * same world so R15 can price it fairly (spec/r15-performance-proof.md ยง2.1):
22 * a master loop walks a fixed faculty order, polls each stage for new input
23 * the way a heartbeat scans pending tasks, and runs a ready stage to
24 * completion on its own thread before looking at the next. A graphics stage
25 * posts its claim and the loop waits for the completion.
26 *
27 * It runs the engine's own activation (validation, snapshot, reaction body,
28 * re-validation, atomic publication, causal crumb). Only who decides what
29 * runs next differs. It works only on a world made with
30 * rx_world_init_sequential_reference; a production world refuses it.
31 * Nothing in production links this file.
32 */
33#ifndef RX_SEQ_REFERENCE_H
34#define RX_SEQ_REFERENCE_H
35
36#include "rx_world.h"
37
38/* One attempt at moving graphics completions into the world (the caller's
39 * transport: the chip ring or the processor stand-in). 0 or a negative code. */
40typedef int (*RxSeqGpuStep)(void *ctx);
41
42typedef struct {
43 const uint32_t *order; /* reaction ids in the fixed faculty order */
44 uint32_t n;
45 RxSeqGpuStep gpu_step;
46 void *gpu_ctx;
47 uint32_t gpu_timeout_ms; /* give up waiting on one claim after this */
48} RxSeqPlan;
49
50/* Declared in rx_world.c; refused on any world that is not the reference. */
51int rx_world_init_sequential_reference(RxWorld *w, const void *auth_ctx,
52 RxAuthValidateFn validate, RxAuthInspectFn inspect,
53 uint64_t crumb_cap);
54int rx_world_seq_activate_locked(RxWorld *w, uint32_t rid, uint64_t cause);
55/* The same, carrying the readiness poll that found the stage ready (its
56 * wall start, wall and thread-CPU duration) into the activation's timing. */
57int rx_world_seq_activate_timed_locked(RxWorld *w, uint32_t rid, uint64_t cause,
58 uint64_t poll_start, uint64_t poll_wall,
59 uint64_t poll_cpu);
60struct AienosCapView;
61int rx_world_init_native_sequential_reference(RxWorld *w, const struct AienosCapView *view,
62 uint64_t crumb_cap);
63
64/* One pulse over the plan. *ran receives the number of stages run.
65 * Returns RX_OK, or RX_ERR_TIMEOUT if a graphics claim never completed.
66 * A pulse that runs nothing marks the world quiescent only when the plan
67 * covers every registered reaction (plan->n >= w->n_reactions); a stale
68 * plan must be rebuilt before the world can be called idle. */
69int rx_seq_pulse(RxWorld *w, const RxSeqPlan *plan, uint32_t *ran);
70
71/* The legacy loop shape: pulse until a pulse runs nothing or max_pulses. */
72int rx_seq_run_until_complete(RxWorld *w, const RxSeqPlan *plan, uint32_t max_pulses,
73 uint32_t *pulses);
74
75#endif