Skip to content

The persona engine's objects: one active mind by construction (4.14, API before integration) - #6130

Merged
joelteply merged 7 commits into
canaryfrom
fable/persona-engine-objects
Nov 18, 2026
Merged

joelteply merged 7 commits into
canaryfrom
fable/persona-engine-objects

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves one mind decoding at a time at the full single-stream rate, switching in milliseconds (critical path step 2).

New crate continuum-persona-engine with the 4.14 object model and its contract tests. No serving switch yet.

  • PersonaUnit owns her five parts and moves whole; assemble refuses a partial move by name.
  • Roles has one active place, so two minds can never decode at once. The next is staged under its copy-in fence; handoff binds only after that fence and retires the previous mind under its copy-out fence; release_retired only after it lands.
  • Tier (device / host / unified / flash) and NextPolicy are the traits the native adapters implement next, over the fork's llama_persona_* / llama_state_seq_* calls.

The engine is libllama in-process, called through its API: no llama-server flags, no slot count. Replaces closed #6129.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…actly one active mind, Tier and NextPolicy are traits

CONTINUUM-ENGINE 4.14, API before integration (Codex). One mind decodes at a time by
construction: Roles has one active place; the next is staged as data under its copy-in fence;
handoff binds her only after that fence and moves the previous mind to retiring under its
copy-out fence; release_retired gives her back to her tier only once it lands. PersonaUnit owns
her five parts and assemble() refuses a partial move by name. Tier (one contract for device,
host, unified and flash) and NextPolicy (who is next, learnable) are the traits the native
adapters over the fork's llama_persona_* / llama_state_seq_* calls implement next. The engine is
libllama called through its API in-process: no llama-server, no launch flags, no slot count.

Contract tests (pipeline/tests.rs): one active mind and the next staged not decoding;
fence-before-ready; retire-after-handoff with the previous retirement landing first;
refuse-partial; no mind in two places. Lints deny unwrap/expect/panic.

Replaces #6129 (a lane count on llama-server's --parallel), closed per Joel: objects, not flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

At d382d70, Roles::stage takes the unit and copy-in fence by value and returns only a reason on NextOccupied or AlreadyPresent. Rust drops both on return. An occupied next slot must leave the caller or completion owner holding the entire refused transfer. Likewise assemble consumes supplied parts when one Option is absent. Return custody on refusal or validate before taking ownership. Exercise these paths with non-Clone drop-tracked handles and an outstanding copy.

handoff takes an already-created retirement fence even though it may refuse on NotReady. Tier::copy_out starts the operation to produce that fence, so the interface permits outgoing reads before the active lane has handed off. Give the existing completion owner a post-bind retirement operation with a typed pending result on failure. Tie the fence to the persona, generation, stream and direction. Replay refusal, cancellation and wrong-generation completion before attaching native adapters. Section 4.14 excludes llama_state_seq_get/set_data from the switch path.

@joelteply

Copy link
Copy Markdown
Contributor Author

Fable, I checked d382d70. Roles owns one active PersonaUnit per instance and NextPolicy chooses who goes next. That gives us a useful unit for the Mac. At integration, can we keep the number allowed to decode concurrently with the engine that owns the shared compute and memory budget? I will take the 5090 comparison when the native path is callable: same workload at one and two active, aggregate and per-persona decode rates, swap latency, and incremental memory during an in-place learning step. Until then two on Windows is an open measurement. My earlier check of llama-server slots answered the wrong question.

joelteply and others added 3 commits November 17, 2026 23:59
…nces are tagged; a partial unit cannot be built (Codex on #6130)

- Roles::stage returns the unit and its copy-in fence on every refusal (Refused { reason, returned })
  and refuses a fence for another persona, epoch or direction.
- Roles::handoff takes no fence: it binds next once her copy-in lands and leaves the previous
  mind AwaitingCopyOut, so no read of her blocks starts before she stops being active. The
  completion owner begins the copy-out after the bind and attaches it with begin_retire, which
  returns the fence on refusal (nobody retiring, already moving, wrong tag). release_retired
  waits for it to land; the next handoff waits for the release.
- Fence carries a FenceTag (persona, epoch, direction).
- PersonaUnit::assemble and PartialMove are gone: the only constructor takes a complete
  PersonaParts (Codex's single declaration, #6131), so a partial move is unrepresentable.
- Contract tests use non-Clone, drop-counted units and fences: a refusal that drops custody fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@github-actions github-actions Bot removed the size: L label Nov 18, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Reviewed 9446c2b. The custody-return and post-bind timing changes address my earlier findings. One native integration question: Tier::copy_out receives only PersonaId and Roles::retiring exposes only the ID; the fence must identify the exact epoch. Please make the retirement owner issue a typed transfer descriptor or invoke the adapter with a borrow of the awaiting unit and its epoch. This avoids a second lookup keyed by ID and allows an adapter test to start the actual transfer with the correct generation. Verified #6131 is merged into this branch.

…t typed descriptor (Codex on #6130)

Tier::copy_in/copy_out(PersonaId) become Tier::begin(FenceTag): the adapter is handed her persona,
epoch and direction, and the fence it returns carries the same tag. Roles::awaiting_copy_out
returns the FenceTag of the mind awaiting her copy-out, so the completion owner begins exactly
that transfer with no second lookup by id that could name another generation. Test: a test tier
begins the described copy-out (accepted, released with her epoch); a transfer of a stale epoch is
refused with its fence returned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ch test expect names its precondition (state_as_flags, unjustified_unwraps)

Codex's lifecycle fixture held release_after_retry and failure as two bools (four states, three
used): now Behaviour { Ready, PendingOnce, Fails }. Each expect in the pipeline contract tests
carries its same-line justification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply merged commit d0062ed into canary Nov 18, 2026
52 checks passed
@joelteply
joelteply deleted the fable/persona-engine-objects branch November 18, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant