interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / docs / COMPOSE_PROPOSER_HOOK.md

232 lines · 15888 bytes Raw Blame History Source

Compose proposer hook (design note)

Scope: how an approved proposal from an upstream approval desk (INTERPLANE ComposeLedgerAuthority, interplane#77) enters the production compose path. Line numbers are for the commit that adds this note. Since 2026-10-15 the compose code cited as spine.rs lives in crates/aien-runtime/src/compose/bridge.rs (same function names).

Entry point

ProposerHook::submit (crates/aien-runtime/src/approved.rs:152) checks the proposal (verify, approved.rs:109), refuses duplicates, then calls ComposeBridge::run_approved_task (crates/aien-runtime/src/spine.rs:1362), which is run_task_inner (spine.rs:1371), the body RunComposeTask runs (server.rs:593 -> spine.rs:1351). The approved text is staged per task and the registered model Skill (spine.rs:1224) returns it instead of calling the ComposeProposer (spine.rs:1232); one attempt, the same template check, and edit = None (spine.rs:1245): an approved proposal never goes through merge_edit_reply, so an existing file is replaced byte-exact.

Path to J-Space and World commit

home.compose.run (spine.rs:1412) -> Compose::run (crates/aien-omega-compose/src/lib.rs:302) -> rxc_host_run in omega librx_compose.a (omega.lock c0369e67, archive sha256 dfe0ffb8...): the Skill result is staged on a J-Space branch, AEGIS calls the bridge's verify callback (spine.rs:1273: result handle equals the Skill's text and it parses as one file change), the winner commits through the World, Cortex records goal, candidates, evidence and promotion (cx_* in ComposeTaskReport). The hook returns Ok only if the run committed exactly the approved text.

What the ledger hands over (ApprovedProposal)

request_id, trace_id, approval_id, approver, path, content, approved_proposal_sha256, content_sha256, approval_mac, requirements, requirements_mac. requirements is the original goal text whose measurable requirements the approved bytes must meet; requirements_mac is the desk key's HMAC over the approval binding and that text (tag aien.requirements.v1), so a caller cannot swap or drop it. Some("") is a signed "no requirements"; a missing requirements is refused (RequirementsUnbound), a goal with an unreadable requirement is refused (RequirementsUncertain), and bytes that miss a requirement are refused (RequirementsUnmet), all before any claim or compose run. A count such as "add 2 lines to NOTES.md" is judged on the diff between the existing workspace file (empty when absent) and the approved bytes. Existing lines must all survive, so such an approval can only add. Such a goal also needs requirements_base: the sha256 (hex) of the existing file as the desk saw it, or absent, covered by requirements_mac (tag aien.requirements.v2; v1 when no requirement depends on the file). It is refused when missing (RequirementsUnbound) or when the file differs (BaseChanged), and it is checked again under the compose-home lock when the grant is written, so a file that changed after the check gets no grant. Limit: a file over 8192 bytes (or not UTF-8) cannot be measured and is refused. The hook returns ApprovedComposeReport: state (COMMITTED | ALREADY_COMMITTED), the same ids, compose_proposal_sha256, grant_links, desk_key_id, approval_key, replay_claim and the compose task report (None for ALREADY_COMMITTED); or ApprovedRefusal {refused_by, name, detail, request_id, trace_id, approval_id, replay_claim}.

Daemon command (#249 C)

ControlCommand::ComposeApprovedProposal { proposal, workspace } on the daemon socket (same-user peer check, 0600 socket, like every compose command). Answered ComposeApprovedResult(report) or ComposeApprovedRefused(refusal). It runs ProposerHook::submit; there is no unauthenticated variant. It writes nothing to the workspace. After the replay commit the daemon itself writes the one grant for the approval (approved_grant below) and returns its id (approved_grant) and target; the caller then needs only ComposeEffectIntent and ComposeEffectAck, both naming compose_proposal_sha256. A caller never writes its own grant for an approved write.

Daemon-written grant and workspace confinement (476ca4 A1/A1b)

Authentication design (#249 A)

Reused primitive: none of the existing grant records can carry it. A ComposeNote authorization grant is written by any same-user socket caller, so binding the approval to one would be caller text in two steps; the aien-mcp ApprovalGrant lives in the INTERPLANE process memory and the daemon cannot check it. So the smallest verifiable evidence is used: approval_mac = HMAC-SHA256 (RFC 2104 over the existing sha2 crate, no new dependency) keyed by the approval desk key, over the canonical binding (approved_auth::binding_bytes): compact JSON, keys sorted, of approval_id, approved_proposal_sha256, approver, content_sha256, desk_key_id, path, request_id, trace_id, workspace and "v":"aien.approval.v2". workspace is the canonical absolute path (symlinks resolved): the daemon canonicalises the command's workspace and binds that, so a valid approval presented with another workspace fails the MAC (Unauthenticated, nothing consumed; 476ca4 c17), and the daemon's grant target is derived only from the bound workspace plus path. v2 because the binding gained a field (nothing was released under v1). The daemon recomputes it with its copy of the key and compares in constant time; anything else is PROPOSAL_REFUSED Unauthenticated.

Replay (#249 B, crate::approved_replay, session 476ca4)

approval_key = sha256 of the binding above; the claim keys are the approval key, the request id and the approval id, each on its own. Order in ProposerHook::submit: verify -> reconcile gate -> desk key -> confinement -> MAC -> claim (durable accepted) -> mark_in_flight -> one run_approved_task -> commit | fail (ran, not committed) | uncertain (run error, or committed but not the approved text). A refused claim is returned with its state; a retry of the very same approval (all keys equal) whose claim committed gets the original result back as ALREADY_COMMITTED, never a second run. Daemon start runs approved_replay::reconcile_at_start after the effect reconcile (accepted -> not_executed, in_flight -> uncertain); a failure gates effect commands and approved proposals.

Hash semantics (fix)

Refusals (never silent)

PROPOSAL_REFUSED Unverified (hash, ids, path, template round trip), ReconcileFailed, NoDesk, Confinement, Unauthenticated (nothing appended for any of these); REPLAY_REFUSED <Name> from the claim (AlreadyCommitted, AlreadyFailed, AlreadyConsumed, Uncertain, InFlight, ...); after a claim: ComposeError and Mismatch (claim UNCERTAIN), NotCommitted (claim FAILED); after the replay commit: GrantNotWritten (the approval is spent, no grant, no effect). At the intent: EFFECT_REFUSED OutsideWorkspace, and NotAuthorized for a grant with no workspace or an approved grant without its committed backing. At ack and reconcile the confinement runs again (476ca4 c28/c28b: a parent directory swapped for a symlink after the intent): if it refuses, the state recorded is UNRESOLVED with disk_error OutsideWorkspace: ..., never DONE, and an operator declaration of DONE is refused.

Deferred

Correlation for retained records (#76, design note only)

Today trace_id and request_id survive in: the command's report and refusal (request_id, trace_id), the replay accepted record (Cortex host record, kind effect, fields request_id, trace_id, approval_id, approval_key), and the compose goal text (request only). Since the A1 fix the daemon's approved grant carries request_id, trace_id and approval_id and links the replay claim; the intent and ack records and record_effect_receipt still carry neither. Recommended: option B, bind rather than re-version: a verifier walks ack -> intent (authorization) -> approved grant (replay_claim, Cortex link) -> claim and reads trace_id/request_id from the immutable claim record (and the grant text). Receipt files stay version 1. Done by the A1 fix: the grant links the claim; a grant whose claim is not COMMITTED with matching evidence is refused at intent; the approved grant cannot be forged. Tests still to add: walk from an ack recovers trace_id and request_id; record_effect_receipt for approved writes names the grant.

Native vs stub in the recall reply (VAC M3a)

ComposeRecallReport (reply to ComposeRecall) carries compose_native: bool (the native Omega composition library is linked, not the stub) and omega_sha: String (the pinned omega commit, 40 hex; empty for the stub). Both are #[serde(default)], so older replies still read as stub. The daemon also prints Compose: native (omega <sha>) or Compose: STUB (...) at startup. An offline verifier uses these to refuse a "native" claim from a stub daemon.