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 / spec / typed-result-constraints.md

187 lines · 10743 bytes Raw Blame History Source

Omega typed result constraints (OMEGA_TYPED_RESULT_CONSTRAINTS)

Code: src/runtime/rx_contract.{c,h}. Test: tests/runtime/rx_typed_results.c, make test-typed-results (TYPED_RESULTS_N, default 400 requests per kind and path). Receipt: evidence/TYPED_RESULTS/.

Purpose

When cognition is asked for a structured semantic object, an invalid answer must be impossible to generate, or be caught before it is published. The contract an answer must meet is typed Omega state. JSON is one way to write an object down; it is never the contract, and a JSON text is only accepted after it has been parsed back into typed state and checked.

Contracts

A contract (RcContract) is typed fields, a generation order, and a table of rules. Its identity is SHA-256 over a canonical binary encoding of kind, field types, derived flags, order, rules and the published object type. Field names are serialization keys and are not part of the identity.

ContractFieldsPublished as
PlanAIEN plan layout (seq, action, regime, condition, hypothesis, reason, goal)RX_OT_PLAN
HypothesisAIEN hypothesis layout (seq, kind, prediction, classes, expected, observed, state)RX_OT_HYPOTHESIS
CapabilityNeedprincipal, operation, resource, rights ceiling, effect classes, locality, latency budget, approvalcontract type
ActionGraphdigest, subject, node/effect/evidence counts, goal kind; the AgGraph is attachedcontract type
Skill invocationskill, arity, three arguments, attempts, principalcontract type
World mutationobject, generation, field, value, principal, resource (derived)contract type
Effect proposaleffect resource, value, verdict evidence, irreversible, approval, principal, kindcontract type
Generation candidatecandidate, parent, authority epoch, evidence, proofs, objects, proposer, lineagecontract type
Evidencesubject kind, subject, run, checks, failures, verdict, digest, producercontract type

CapabilityNeed follows the capability query's meaning (rx_capq.h, what AIEN needs done, not who does it). Its fields are the part of CqNeed a single semantic object carries; the query's type lists and trade-offs stay in the query.

Constraint types

TypeRuleExamples
typefield type (u32, bool, enum < 64, bits, object id, subject, resource)every field
rangef in [k, k2]plan regime, hypothesis expected, evidence checks
enumf in setplan reason, hypothesis state, effect kind
structuralnonzero, bits within a mask, attached graph validatesrights ceiling, evidence digest, ActionGraph
cross-fieldguarded comparison between fieldsreason GOAL needs a goal; PASS has no failures
authorityprincipal is the producer; principal holds rights now; no privileged rightsevery kind; mutation and effect targets
generationobject live at that generation; parent is the active generation; next; epochmutation, generation candidate
referentialcontext object field, next sequence, skill and arity, live object, resource of objectplan, hypothesis, skill, mutation
required evidencea published PASS evidence record names this subjecteffect verdict, generation evidence
effectforbidden resources, allowed effect resources, effect budget, approval for irreversible, graph clearcapability need, effect proposal, ActionGraph

Authority is checked through the world's authority view (validation, never mint). rx_contract.o is linked alone first and the build fails if it references an AIENOS admin operation.

Two paths

Constrained. rc_compile decides, per rule, whether it can become a per-field domain given the fields before it in the generation order. rc_domain then gives the allowed values of one field (interval, enum, bit mask, explicit set, exclusions, excluded interval) from the fields already chosen and the live context. A backend that decodes under a mask only chooses inside it. Rules that cannot become a domain (the attached graph's structure, the graph's forbidden requirements) are checked once the candidate is complete. An empty domain on the first field means nothing could be valid in this context: the request ends before anything is generated. An empty domain later is a dead end and costs a retry (there is no lookahead).

Free. rc_produce generates, checks, repairs what the contract marks repairable, otherwise rejects and generates again, up to a bound.

Both paths end in rc_check. Nothing is returned as publishable unless it passed.

Repair

Two repairs exist, both declared on the rule:

Nothing else is repaired. Stale generations, missing evidence, wrong principals, broken references and effect restrictions reject.

Generation order

Derived fields come after the fields they are derived from. The World mutation contract first chose its resource and then objects of that resource. A slip in the resource then steered the object, so it was published valid but wrong. It now chooses the object and derives the resource.

The publish gate

rc_gate_register adds one resident reaction per contract (faculty OMEGA). Its trigger is the draft object that cognition writes. It holds the only WRITE capability on the published object. It checks every draft again against the contract and the live World, applies only the repairs above, and either publishes all fields or records the rejection in its status object (verdict, first violated rule, violated constraint types, counts). A draft that produce accepted can still be rejected there: the World may have changed between generation and publication.

Cognition holds WRITE on drafts and READ on what is published. A publication around the gate is refused by the authority. So is a reaction of cognition that presents the gate's capability.

Serialization

What the test proves

ClaimHow
every constraint type is defined and caughteach type used by a contract; each type reported on a real violation
the checker is rightevery sweep candidate also judged by a hand-written reference per kind; zero disagreements; every single mistake reported under its own type
compiled domains are sounduniform draws inside every domain never violate a compiled rule
compiled domains are completeevery field of every intended answer lies inside its domain given its own prefix
impossible where fully compiledconstrained path: zero invalid candidates for every contract with no after-check rule
never publish invalidevery published object re-read from the World and re-checked by contract and reference
no bypasscognition's direct write and a stolen-capability reaction both blocked; every published field written by its gate
hostile draftsevery catalogued mistake written straight into the draft: rejected, or repaired only when repair is declared and restores the intended meaning
stale before publicationa mutation target retired after generation is rejected by the gate as a generation violation
unsatisfiable contexteffect budget exhausted: constrained path stops with zero draws; free path spends every retry
JSON is one serializationbinary and JSON round trips keep the identity; malformed texts refused; faulty JSON candidates caught

Measures (per path, per kind, in the receipt)

invalid candidate rate, repair rate, retries, draws and checks (compute), compute avoided (constrained against free), produce time and end-to-end latency (p50, p99), semantic failure rate (published objects whose meaning-bearing fields differ from the intended answer), rejected and unsatisfiable requests.

The backend

The backend is synthetic. It has an intended answer (valid by construction) and makes mistakes at a fixed rate (35 % of candidates, a quarter of those with a second mistake) from a catalogue per kind. Each mistake is labelled with the constraint type it breaks, or "valid but wrong". Both paths see the same mistakes for the same request and attempt. Under a mask, a backend whose preferred value is not allowed takes its intended value if allowed, otherwise the nearest allowed one. That is the model of masked decoding the measures rest on.

Findings

Limits