Skip to content

feat(core): Moirai F1 common contracts (judgment, context projection, persona schema, catalog/policy, store) - #14

Merged
thisisjun786 merged 47 commits into
devfrom
feat/moirai-f1-common-contracts
Sep 13, 2026
Merged

thisisjun786 merged 47 commits into
devfrom
feat/moirai-f1-common-contracts

Conversation

@thisisjun786

@thisisjun786 thisisjun786 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Summary

This PR defines the Moirai F1 common contracts in lina-core: judgment records and validation, context read projections, PersonaSchema derivation, the personal option catalog and arbitration policy, and an independent SQLite judgment ledger.

It is not an installed Moirai runtime or live-model qualification. The PR also contains separately scoped runtime test-fixture corrections; they are not evidence of F2 product integration.

Contract scope

  • Canonical options bind normalized arguments, actor/scope, preconditions and effect semantics. Generated keys fit the shared identifier bound.
  • Frozen snapshots identify objective profiles, policy, source revisions and scope. The judgment ledger verifies stored digests, indexed metadata and cross-record provenance.
  • Each logical source kind/ID has exactly one frozen revision; contradictory revisions are rejected.
  • One immutable objective ID/revision cannot occupy multiple module slots, even with different claimed digests. Snapshot and selection parsers enforce this independently of stored-profile lookup.
  • Action arbitration preserves module recommendations, exclusions, ordering and concessions. Selection specifications are replayed from frozen candidate inputs rather than trusted independently.
  • Context projections distinguish instruction revision from working-state revision and validate restored source references.
  • Persona derivation preserves LIFE sharing allowlists, manual/axis locks and participant ownership. Its builder does not allocate authoritative current schema revisions.

Review resolution

The current review pass verifies prior fixes and addresses the remaining defects with failing-first regressions:

  • Intention acceptance, deadline and transition timestamps use exact canonical UTC strings; invalid values are rejected without rewriting their evidence.
  • Intention history cannot run backward before acceptance or an earlier transition; equal timestamps remain valid.
  • Pure intention transitions validate the existing record before reading its status, revision, acceptance or history; malformed restored records cannot produce invalid next records.
  • insufficient_evidence is the initial declared unavailability code. Arbitrary reason text cannot remove an objective from ordering; detailed diagnosis remains in existing text/evidence fields.
  • Atropos commitment exclusions require nonempty attribution verified through the Host's intention owner. Unattributed claims retain ranked opposition; same-target suspend/cancel proposals keep their ranking exemption, not execution permission.
  • Clotho's infeasible label is not a hard veto. Factual prerequisite failures use Host eligibility.
  • An explicit Host rejection without a reason is distinguished from missing eligibility.
  • Raw option arguments are length-bounded before normalization or omission, including whitespace-only values; bounded empty values still omit.
  • New round/resolution writes check the owner's scoped intention revision; resolutions recheck active objective references. Historical receipts remain readable after legitimate later changes.
  • Objective activation cannot restore the full references of a stale open round in the same agent/scope. This blocks A→B→A revival without freezing all profile changes or changing serialized snapshots; a fresh objective revision can start a new round.
  • Per-agent/scope round sequences must increase; gaps are allowed.
  • Candidate-free dialogue has an explicit schema-v2 record and reconstructible DialogueJudgmentRef. It preserves the three original assessments, frozen objective/snapshot/policy references and textual synthesis. Store write and reopen validation reject action candidates/specifications on dialogue and incomplete or mismatched provenance.
  • Dialogue request/source hashes must match dialogueSource frozen by the Host in the round snapshot before assessment. Invented or rehashed record digests, and dialogue without those expected fingerprints, are rejected. Source owners retain the raw data; legacy action snapshots omit the optional field unchanged.
  • An incomplete dialogue may remain held or end deferred after budget exhaustion, but cannot be recorded as resolved or produce an accepted-dialogue reference.
  • Exact legacy action-v1 record bytes and digests remain unchanged. The physical schema is unchanged; older readers intentionally reject the new dialogue JSON capability rather than rewriting it.

Deliberate F1 boundaries

  • Projection continuity (3995355370): the pure builder accepts a validated previous projection. F2 context/source assembly must persist and restore it per logical conversation/source stream; no production continuity owner is installed by this PR.
  • Persona ownership (3995355387): AgentStore is the designated authoritative schema owner. F1 defines derivation/serialization; existing Behavior/projection migration is F4. The caller-supplied builder revision is not an authoritative allocator.
  • Decisions, RNG and outbox (3995956610): F1 persists policy inputs/results and selection specifications. It does not persist a sampled decision, RNG advance or dispatchable outbox. Those atomic execution and recovery boundaries belong to F2.
  • User cancellation authority (3999164940): F1 has no intention-bound, owner-verified cancellation approval path. New cancellation of adopted/active/suspended user commitments is therefore rejected; acceptance refs, catalog authority/confirmation strings and ranking results cannot authorize it. Historical v1 ledgers remain readable and terminal, and unadopted proposals may still be withdrawn. Real authority integration remains F2, not a caller-controlled approval flag.
  • Schema additions (3995355563): the ledger intentionally rejects undeclared tables, indexes, views and triggers. Future owner-controlled additions require recognized, versioned schema evolution.
  • Runtime fixture scope (3995355408): the archive-cap test seeds the first 256 terminal archive identities and exercises the real 257th boundary, reopening and replay. It does not claim to test 257 repeated archive writes.
  • Restart fixture collection (3998853110): the owner is closed correctly. Pinned Bun 1.4.0 node:sqlite defers native statement cleanup until collection; in-process test replacement therefore clears the old connection before the private-copy audit. The call-through close spy triggers that audit boundary deterministically. An independent cold child-process exit and fresh protected HTTP read succeeds without GC or a close spy. This does not establish in-process hot-replacement support, and no production GC or relaxed file-audit check is introduced.
  • Persona restart fixture: a hosted run exposed the default 5-second test timeout. The fixture now uses unchanged real prompt/preset bytes without unrelated shipped-avatar assets, removing repeated migration I/O. All three restarts and original assertions remain; no timeout increase or retry was added.

Phase authority: implementation roadmap and judgment contract.

Verification

  • Full bun test at ff241e6: 4526 passed, 47 existing opt-in skips, 0 failed, 556 files. No skip was added by this review pass.
  • Focused judgment scope: 606 tests passed; isolated Persona/runtime scope: 48 tests passed. Direct SQLite, real source-owner provenance and Fleet restart surfaces passed. Current-head aggregate results are shown in GitHub checks.
  • bun run typecheck: root and browser TypeScript passed.
  • bun run lint: passed. The one new optional-chain warning was fixed; 27 pre-existing warnings remain in untouched files.
  • bun run ci:build: actual runtime assets built and read-only CLI paths smoke passed without creating application state.
  • Independent public-API/SQLite runs proved unverified claims cannot veto, verified commitments remain protected, accepted target changes retain exemptions, stale writes and backward sequences reject, and resolved dialogue reopens with 3 assessments / 0 candidate rows / 0 selection specifications.
  • Independent child-process cold restart returned protected HTTP 200 with the exact persisted V2 binding, without GC or close instrumentation.

Review-fix commits:

  • 46b4b77 require canonical intention timestamps.
  • 7eac3fe verify arbitration evidence and currentness.
  • ebd7af9 persist candidate-free dialogue judgments.
  • 5484813 validate source intentions before transitions.
  • fb15519 close dialogue and snapshot boundary gaps.
  • ee47070 enforce intention chronology and raw argument bounds.
  • be29476 isolate Persona restart resources without increasing timeouts.
  • cf3a46e reject cross-module objective aliases.
  • fdce947 reject unverified live user cancellation while preserving historical records.
  • 0785eda prevent objective reactivation from reviving stale open rounds.
  • ff241e6 bind dialogue digests to Host-frozen source provenance.

Current-head GitHub results are available on the PR Checks tab.

No PR merge, release, deployment, paid model call or production-data operation is part of this review-resolution pass.

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 38bbb7a6-edc5-49dc-816e-82ccb60c65d9


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-13T09:27:01.087664Z ff241e6 New commits
🔒 Security Review Completed 2026-09-12T04:34:35.148187Z 8cf0198 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

thisisjun786 and others added 5 commits September 12, 2026 14:32
Keep private LIFE dimensions out of derived persona schemas while retaining source ID uniqueness and existing fingerprints.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Reject invalid source IDs, duplicate provenance, malformed instruction hashes and blank working items. Reject instruction revision overflow while preserving valid maximum revisions.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Bind option keys to execution semantics and scope. Freeze policy identity with snapshots, reject stale objectives and foreign candidates, verify stored snapshot digests, bound neural bias and require original acceptance on resume. Normalize geometric rank weights without underflow.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Model process-exit collection before replacement fleet storage validation. Force the delayed SQLite collection point in the real HTTP reopen test while preserving the private-copy audit and all approval assertions.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Prepare 256 real immutable archives with a durable manifest, exercise the 257th lifecycle normally, and retain every reopen/replay assertion. A temporary conversation-cap mutation fails at the boundary. Production durability and test timeouts remain unchanged.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

thisisjun786 and others added 3 commits September 12, 2026 15:24
Reject altered order, stance vocabulary, ratio or bias strength under personal.v1 revision one while accepting equivalent deserialized declarations.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Use the shared identifier validator in projection construction and restoration, rejecting embedded NUL and oversized IDs consistently.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Compare normalized objective, assessment, resolution, selection and intention records with their persisted digests before returning them or deriving writes. Cover valid JSON tampering, digest-column tampering, rollback and normalized reopen behavior using real SQLite.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

thisisjun786 and others added 3 commits September 13, 2026 15:00
Reject noncanonical, local, and impossible intention dates without rewriting digest-bearing evidence. Preserve exact UTC timestamps across acceptance, deadlines, and transitions.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Require owner-verified commitment attribution and Host eligibility for factual exclusions. Declare exact assessment unavailability, replay frozen evidence, and reject stale objective/intention snapshots or backward scope sequences.

Verified the isolated staged tree: 506 judgment tests pass and the public core barrel builds.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Add versioned dialogue synthesis and immutable judgment references without action candidates or selection specifications. Preserve exact action-v1 records and apply mode-aware provenance checks on writes and historical restore.

Verified 535 judgment tests, strict root/browser TypeScript, public core build, and real SQLite dialogue restoration with zero candidate and selection rows.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Parse restored intention records before reading status, acceptance, revision, or history. Reject invalid source evidence while preserving valid lifecycle transitions and input immutability. Clarify the retained legacy infeasible receipt stage.

Verified four failing-first malformed-source cases, 539 judgment tests, strict TypeScript, and direct public API use.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Allow incomplete dialogue to persist as deferred after budget exhaustion while still rejecting resolved incomplete records. Freeze only one revision per logical source kind and ID.

Verified RED-to-GREEN boundary cases, 541 judgment tests, strict TypeScript, and real SQLite deferred/reopen and contradictory-source rejection.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
chatgpt-codex-connector[bot]

This comment was marked as resolved.

thisisjun786 and others added 2 commits September 13, 2026 16:55
Reject intention transitions before acceptance or prior history while permitting equal timestamps. Bound raw option strings before normalization and omission, preserving bounded empty arguments.

Verified 12 failing-first boundary cases, 556 judgment tests, strict TypeScript, and actual SQLite chronology/argument scenarios.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Use unchanged real prompt and preset bytes without unrelated shipped-avatar assets in the personal-growth restart fixture. Preserve all three real restarts and existing assertions, and verify no avatar import or unintended provider/conversation work.

Removes repeated avatar migration I/O without increasing test timeouts. Verified 48 related tests, strict TypeScript, runtime build, and independent Fleet restart surface.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
chatgpt-codex-connector[bot]

This comment was marked as resolved.

thisisjun786 and others added 2 commits September 13, 2026 17:18
Reject reuse of one immutable objective profile revision across module slots in snapshots and selection specs, including conflicting digests. Preserve distinct stored revisions of a shared objective ID.

Verified failing-first parser and direct arbitration cases, 563 judgment tests, strict TypeScript, and actual SQLite persistence/reopen.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Reject live cancellation of adopted, active and suspended user commitments while F1 lacks intention-bound owner-verified authority. Acceptance refs, ranked candidates and caller-claimed approval fields do not grant cancellation permission.

Preserve historical schema-v1 ledgers, proposed withdrawal and other lifecycle paths. Verified failing-first helper/store cases, 583 judgment tests, strict types, runtime build and actual SQLite mutation/reopen scenarios.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Reject an activation whose resulting references would restore a stale scoped open snapshot. Preserve no-ops, forward revisions, isolated scopes and replay of closed rounds without changing serialized contracts.

Verified four failing-first ABA cases, 590 judgment tests, strict TypeScript, build/lint and an actual reopened SQLite round that rejects stale work and resolves fresh objective inputs.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

if (!candidates || !set) {
if (resolution.status !== "held" || selection !== null)
throw Error(!set ? "incomplete assessment set" : "missing candidate set");

P1 Badge Persist budget-exhausted action rounds as deferred

In the action-v1 JudgmentStore path, when the evaluation budget expires before all three assessments or candidate closure, the Moirai contract requires a terminal deferred round without advancing selection RNG or outbox work, but this condition rejects every incomplete resolution unless its status is held. The caller therefore cannot durably record the required budget-exhaustion outcome and must either misclassify it or leave the round open; represent incomplete-assessment provenance and permit a validated deferred receipt.

AGENTS.md reference: AGENTS.md:L4-L4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Freeze Host source fingerprints in the snapshot before assessment and require dialogue records and references to match them. Reject invented or rehashed provenance while preserving action-v1 snapshots without the optional field.

Verified six failing-first provenance cases, 606 judgment tests, 4526 full-suite passes, clean source/test LSP diagnostics, strict types, build/lint and real DurableStore-to-JudgmentStore persistence/reopen with complete cleanup.

Ultraworked with [omo](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

completeText: boundedText(row["completeText"], "complete text"),

P1 Badge Preserve complete module opinions beyond 1,000 characters

When a module produces an opinion longer than 1,000 UTF-16 characters, this default boundedText call rejects the entire assessment because MAX_TEXT is only 1,000. The Moirai contract explicitly defines completeText as the untruncated module opinion (docs/plans/platform/016_neural_preference_contract.md:73), and ordinary model judgments can readily exceed this limit, preventing the Host from recording or synthesizing an otherwise valid round; use a dedicated bound sized for complete model output rather than the legacy agent-field cap.

AGENTS.md reference: AGENTS.md:L4-L4


if (!candidates || !set) {
if (resolution.status !== "held" || selection !== null)
throw Error(!set ? "incomplete assessment set" : "missing candidate set");

P2 Badge Allow exhausted action rounds to be recorded as deferred

For an action round whose deadline or evaluation budget expires before the candidate set or all three assessments are available, this branch accepts only held and rejects the required deferred terminal record. The declared contract says pre-selection budget exhaustion ends the round as deferred (docs/plans/platform/016_neural_preference_contract.md:89), so the Host cannot durably close such a round and instead leaves it open or misclassifies it as recoverably held; permit a deferred failure receipt when the missing evidence is attributed to exhausted budget.

AGENTS.md reference: AGENTS.md:L4-L4


if (identity === null) return null;
for (const profile of parseIdentityPolicy(identity).profiles)
if (profile.agentId === agentId) return profile;
return null;

P2 Badge Reject identity snapshots missing the selected agent

When a non-null identity snapshot contains policies only for other agents, this helper silently returns null, causing derivation to emit every projected dimension unlocked and omit sourceIdentity. The existing LIFE owner rejects exactly this mismatch as Missing LIFE identity policy in world/views.ts:251-252; accepting it here lets a stale or cross-agent snapshot erase manual/per-axis restrictions, so distinguish an intentionally absent identity input from a supplied snapshot that lacks the selected agent.

AGENTS.md reference: AGENTS.md:L4-L4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant