Repository navigation
feat(sessions): context_id envelope tier + session()/scoped() client surface - #1669
Merged
Merged
Conversation
The ID hierarchy is userId > sessionId > contextId (CLAUDE.md). The envelope already carried the first two (kernel-injected from the connection); this adds the third — the conversation/room scope a command operates within. Key distinction: unlike session_id/user_id (kernel-injected — the substrate knows WHO you are from the airc pairing), context_id is CLIENT-SUPPLIED. The caller scopes a sequence of ops to a conversation via the SDK's scoped client (Continuum.scoped(ctx), landing next), and it rides as an envelope sibling (camelCase `contextId`, serde flatten) so handlers scope per-context state — per-room memory, per-thread recall — without polluting command params. First-class for every citizen, uniformly: a persona servicing a room is a citizen scoped to that room's contextId, the same shape a browser tab uses. This is the tier that fills the persona cognition's tool_context (currently nil session/context placeholders) — because a persona's tool executor is just another client, dispatching the same commands with the same identity + scope as the cli or desktop. `#[serde(default)]` keeps old wire JSON back-compatible (absent → None). Test: request_parses_and_builds_context_id_third_tier — parses from flat wire JSON, round-trips under the camelCase key, builder attaches it. 16 envelope tests green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The client surface for the sessions layer, built on the envelope's context_id
tier. Uniform across every client AND persona (Joel: "the clients all have
identical connects and contexts etc, personas have same — first class citizens
and all"): connect → session → scoped(context), the same shape a browser tab
and a persona both use.
continuum-client:
- SessionIdentity { user_id: Option<Uuid>, session_id: Option<Uuid> } (new
session.rs) — WHO a connection acts as (citizen + connection instance).
Both Option because identity is ESTABLISHED not assumed — the SDK surfaces
what's known, never fabricates it.
- Connection.session() -> SessionIdentity — readonly accessor.
- Connection.with_identity(id) — the establishing layer sets it (airc
pairing/handshake for a UI client; the spawn path for a persona, which
knows its own citizen id).
- Connection.scoped(context_id) -> Connection — a context-bound view over the
SAME transport + identity; its command + event verbs auto-stamp contextId
so callers never re-thread the scope. Parent stays unscoped.
- CommandClient stamps contextId into the request envelope as a sibling of
params (exactly how command_envelope.rs reads it) — no Transport signature
change. emit() stamps it into the event payload too.
- Only contextId is client-stamped; userId/sessionId stay kernel-injected
(the substrate knows WHO you are from the connection) — preserving the
one-gate access model: no client-forged identity.
continuum-client-ffi (the surface the uniffi binding wraps — locked with
BigMama, bind-once):
- ContinuumClient.session() -> SessionIdentity (re-exported as a record).
- ContinuumClient.scoped(context_id) -> ContinuumClient (returns Self; no new
interface object, no verb/callback changes — zero surface duplication).
Tests: 5 new in continuum-client (scoped stamps contextId into command envelope
+ into emitted event; unscoped omits it; session surfaces established identity /
honest unknown; scoped preserves identity + leaves parent unscoped). 23
continuum-client + 8 continuum-client-ffi tests green; clippy clean.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 17, 2026
… the facade-only layout (#1670) * feat(sdk-ts): session() + scoped(context) on the TS facade — the twin of the Rust client The TypeScript twin of the merged Rust client surface (continuum-client #1669), completing the sessions layer on the JS/web/desktop SDK. Mirrors the Rust semantics exactly so the conformance contract holds across both: - transport.ts: SessionIdentity { userId?, sessionId? } (Uuids as strings at the JSON boundary); Transport.session(); and stampContext(value, contextId) — the shared helper that stamps contextId as an envelope/payload sibling, the twin of CommandClient::stamp_context (only objects; no-op when unscoped; identity is NEVER stamped — kernel-injected, unforgeable client-side). - Continuum.session (getter) + Continuum.scoped(contextId) → a scoped Continuum whose commands + events auto-stamp contextId. Same transport + identity, only the context differs. - Commands / Events carry the optional contextId and stamp via stampContext. Conformance dimension 6 (sessions) added to Commands.test.ts — the contract the swift/kotlin/rust twins mirror name-for-name: session() surfaces established identity (never fabricated); scoped() auto-stamps contextId into both command envelope and event payload; unscoped stamps nothing (opt-in); scoped carries identity forward + leaves the parent unscoped. MockTransport gains session(). Uniform shape now real on BOTH the Rust and TS skins: connect → session → scoped(context), identical for a browser tab and a persona ([[persona-is-a-client]]). Not run locally (headless box, no node — by design); written against the live facade API + mirrors the validated Rust (continuum-client: 23 tests green). Runs in CI where node is present. Co-Authored-By: Claude Opus 4.8 <[email protected]> * refactor(sdk-ts): rename Commands.test.ts → conformance.spec.ts The file is THE SDK conformance SPEC — the authoritative cross-language specification (addressing, commands, events, handles, timing, sessions; six dimensions the native twins implement against name-for-name), not a unit test of Commands.ts. It started as a Commands sketch and kept that name; the name lied twice — wrong scope (it's the whole facade) and 'test' framed the load-bearing contract as incidental verification. 'spec' is what it is and what the team already calls it; the .spec.ts suffix still runs under vitest (the executable specification), so the contract both documents AND proves itself. Co-Authored-By: Claude Opus 4.8 <[email protected]> * refactor(sdk-ts): lock down sdk/typescript to the facade-only layout The folder was two SDKs jammed together: the new thin facade (transport, Commands, Events, Handle, Continuum, index, conformance spec, generated/) AND a full DUPLICATE of the legacy RustCoreIPC client (RustCore, RustCoreIPC, the 24 `modules/` mixins, ~12 hand-written wire types, and loose top-level test-*/ benchmark-*/verify-* scripts). Those loose `test-*.ts` scripts are exactly why a conformance CONTRACT read as "just a test." The duplicate is orphaned cruft: the canonical legacy client lives at core/continuum-core/bindings/RustCoreIPC (CLAUDE.md's IPC-mixin location), and all 108 src/ consumers import it from THERE. Verified nothing in the repo imports the sdk/typescript copies — the package's public surface (index.ts) and its only internal consumer (the conformance spec) reference the facade alone. Removed the orphaned duplicate. sdk/typescript is now ONLY the thin typed client its package.json describes: Continuum.ts · Commands.ts · Events.ts · Handle.ts · transport.ts (facade) conformance.spec.ts (the contract) generated/CommandMap.ts (generated types) index.ts · package.json · tsconfig.json Naming is now coherent: PascalCase = class-exporting module; lowercase = types/util/spec/barrel; generated types isolated under generated/. No behavior change, no consumer change (the deleted files had zero importers). The canonical legacy bindings at core/continuum-core/bindings are untouched. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Nov 8, 2026
…Mac): proven ancestry with exit codes, history completed for a shallow departed checkout, arrival under the checkout lock, AncestryUnknown said (Codex e302c1d0, f37a1861) - GitError carries git's exit code; is_ancestor: exit 0 yes, exit 1 no, anything else no answer. - proven_ancestry: a yes is proof in any clone; a no only with complete history. - arrive_locked: CHECKOUT_SYNC held across the arrival; first complete_history_if_departed (shallow + anchor + exit-1 no -> airc complete_card_history under airc's network bound), then the arrival within ARRIVE_BOUND. Every git keeps the lock until it has ended. - realign: an unproven departure is AncestryUnknown, never realigned; its notice reaches her and a submit refuses with it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply
added a commit
that referenced
this pull request
Nov 8, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply
added a commit
that referenced
this pull request
Nov 8, 2026
… one already off it back keeping her work (Kimi, card f76005e8) (#5877) * Arrival never moves a card checkout off its creation anchor, and puts one already off it back, keeping her work (card f76005e8) Kimi on the Windows node, 2026-11-08 16:11Z (Codex da817b0e): after #5873 re-allocated her clone at canary bcbd4aa, arrival fetched her old card branch (e5fe473, off another line), the remote won, and her anchor left HEAD, so work/submit refused. workspace_transfer: - arrive_over: a remote whose tip does not contain the creation anchor is RemotePredatesAllocation (tree untouched); unproven ancestry (shallow clone, missing commit) is AncestryUnknown, never adopted on a guess. proven_ancestry answers only with complete history and both commits present. - arrive -> realign_to_anchor first: a checkout whose HEAD provably left its anchor keeps HEAD whole (dirty edits committed, no hooks) under a stranded ref, counts the commits no remote carries, and goes back on the anchor (Realigned). Her work is never replayed for her. - ArrivalOutcome::notice says what she must know; Staging::Ready carries the notable arrival, ClaimWorkspace::Ready shows it, and a submit right after a realignment refuses with it (her work is on the stranded ref). callers: off_creation_anchor (no anchor, or HEAD not descended from it) routes claim staging and submit through the stager; a held turn restages only an anchorless checkout, since a realignment there could not tell her. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * CANDIDATE (airc pin = unmerged #1669 head; tests pending on the IntelMac): proven ancestry with exit codes, history completed for a shallow departed checkout, arrival under the checkout lock, AncestryUnknown said (Codex e302c1d0, f37a1861) - GitError carries git's exit code; is_ancestor: exit 0 yes, exit 1 no, anything else no answer. - proven_ancestry: a yes is proof in any clone; a no only with complete history. - arrive_locked: CHECKOUT_SYNC held across the arrival; first complete_history_if_departed (shallow + anchor + exit-1 no -> airc complete_card_history under airc's network bound), then the arrival within ARRIVE_BOUND. Every git keeps the lock until it has ended. - realign: an unproven departure is AncestryUnknown, never realigned; its notice reaches her and a submit refuses with it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * Arrival split into workspace_transfer/arrival.rs; the history fetch holds the checkout lock in its blocking task; arrival runs under the claim's hands admission (Codex b7194c2c) - workspace_transfer.rs 1030 -> 658: the arrival concern moved whole to arrival.rs (380). - complete_history_if_departed moves an Arc of the lock guard INTO spawn_blocking, so an arrival dropped mid-fetch keeps the checkout locked until airc's git ends. The completer is a fn parameter (prod: airc complete_card_history). Test: a dropped arrival leaves the lock held until a 600 ms stand-in fetch ends; without the guard in the task it fails. - arrive_for takes the claim's HandsContext and runs arrive_locked under hands_gate::admitted: continuum_process::holding needs an admission, and card staging had none, so without it every arrival would have failed 'holding needs an admission'. No claim / closing hands = a named failure. - shallow test: the anchor is an older commit fetched at depth 1 (present, cut off from the tip). Ratchets: blocked only on four inherited text matches in touched files (git_bridge out_of_time, workspace_transfer classify_push_error / is_missing_remote_ref, a [..8] cut) that #5867 replaces; asked Fable to land that slice first. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * Pin airc to a3a7396 (#1669 merged: complete_card_history) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * Classify checkout Git outcomes through the runner and account layer writes Integrates the typed outcome and porcelain portions of Fable PR5867 into the split arrival owner. Preserve off-anchor WIP, cancellation custody, and the real WorkSubmit recovery fixture. Route citizen metadata through the existing citizens disk class. --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The sessions layer foundation, built lowest-out. The ID hierarchy is userId > sessionId > contextId (CLAUDE.md), and it's uniform across every client AND persona (Joel: "the clients all have identical connects and contexts etc, personas have same — first class citizens and all"). One shape:
connect → session → scoped(context).1. Core envelope (
command_envelope.rs)context_id— the third ID tier. The deliberate asymmetry:session_id/user_idare kernel-injected (the substrate knows WHO you are from the airc pairing),context_idis client-supplied (you scope the conversation). Rides as an envelope sibling (contextId, serde flatten).serde(default)→ back-compatible.2. Client surface (
continuum-client)SessionIdentity { user_id?, session_id? }(newsession.rs) — WHO a connection acts as. BothOptionbecause identity is established, not assumed — the SDK surfaces what's known, never fabricates.Connection.session()— readonly accessor.Connection.with_identity(id)— the establishing layer sets it (airc pairing for a UI client; the spawn path for a persona).Connection.scoped(context_id)— a context-bound view over the same transport + identity; its verbs auto-stampcontextId. Parent stays unscoped.CommandClientstampscontextIdas an envelope sibling — no Transport signature change.emit()stamps the payload too.3. FFI facade (
continuum-client-ffi— the uniffi binding surface)ContinuumClient.session() -> SessionIdentity(record).ContinuumClient.scoped(context_id) -> ContinuumClient(returns Self — no new interface object, no verb/callback changes). Shape locked with BigMama for bind-once.The access invariant it preserves
Only
contextIdis client-stamped; identity stays kernel-injected. Every caller — human, persona, a new client — goes through the one facade + oneAuthPolicygate with its own identity. No client-forged identity, no bypass: access is complete and hole-free by construction. A persona's tool executor is just another client (this fills itstool_context).Test
cargo test -p continuum-client(23) +-p continuum-client-ffi(8) + envelope (16) green; clippy clean.Next
TS facade
.session/.scoped()+ conformance dimension 6; then the personaTsIpcToolExecutorcomposed as a scoped client (task #15).🤖 Generated with Claude Code