Liking cljdoc? Tell your friends :D

co.multiply.remontoire.session

Session state: who is connected, when they last spoke, and the conversational state that belongs to one dialogue rather than to the JVM — the sticky namespace, the told-once ledger's audience, queued eviction news (§11).

A session is a handle the create-session tool mints and every other tool call names in its arguments, whichever MCP revision the client speaks. It lives in the model's context, not in the connection, so it outlasts a reconnect; it expires by silence, and a handle this server does not hold is refused, never adopted.

The earlier revisions' Mcp-Session-Id names no session. It is a connection: what a client said at initialize, and which tool list it last fetched — the last section here.

State lives behind defonce for the same reason the registry's does: library reloads must not end anyone's session.

The scratch namespaces themselves — naming, furnishing, reaping — also live here: a session's scratch family is conversational state exactly like its sticky namespace, created on demand and gone with the session. So is its upload directory, where files a client hands the JVM are staged: minted on the first upload, deleted with the session.

Session state: who is connected, when they last spoke, and the
conversational state that belongs to one dialogue rather than to the JVM —
the sticky namespace, the told-once ledger's audience, queued eviction
news (§11).

A session is a handle the `create-session` tool mints and every other
tool call names in its arguments, whichever MCP revision the client
speaks. It lives in the model's context, not in the connection, so it
outlasts a reconnect; it expires by silence, and a handle this server
does not hold is refused, never adopted.

The earlier revisions' `Mcp-Session-Id` names no session. It is a
connection: what a client said at `initialize`, and which tool list it
last fetched — the last section here.

State lives behind `defonce` for the same reason the registry's does:
library reloads must not end anyone's session.

The scratch namespaces themselves — naming, furnishing, reaping — also
live here: a session's scratch family is conversational state exactly
like its sticky namespace, created on demand and gone with the session.
So is its upload directory, where files a client hands the JVM are
staged: minted on the first upload, deleted with the session.
raw docstring

*session*clj

The session an eval runs for — bound by evaluate on both attribution rails exactly as tee/*bank* is (§11), so code like (evals) can tell the caller's entries from another session's. nil at the root means a sessionless in-process caller — a human at the actual REPL calling api functions directly; the wire never admits one.

The session an eval runs for — bound by `evaluate` on both attribution
rails exactly as `tee/*bank*` is (§11), so code like `(evals)` can tell
the caller's entries from another session's. nil at the root means a
sessionless in-process caller — a human at the actual REPL calling api
functions directly; the wire never admits one.
sourceraw docstring

addressclj

(address sid)
source

address!clj

(address! sid address)

How sid's client addressed its latest request — scheme and authority, http://host:port — kept as the best available guess at where the same client can reach this server's other doors. Guarded like note!: a request must not mint a session by being addressed somewhere.

How `sid`'s client addressed its latest request — scheme and authority,
`http://host:port` — kept as the best available guess at where the same
client can reach this server's other doors. Guarded like `note!`: a
request must not mint a session by being addressed somewhere.
sourceraw docstring

clear-evictions!clj

(clear-evictions! sid ids)

Called only once the response carrying the news has actually gone out — the same discipline as every delivery mark (§5).

Called only once the response carrying the news has actually gone out —
the same discipline as every delivery mark (§5).
sourceraw docstring

clientclj

(client sid)
source

client!clj

(client! sid m)

What the caller said about itself — protocol version, client name and version, capabilities — recorded as the session is created. Kept per session because clients keep teaching us their actual shape (§4), and knowing which client and version a measurement was made against keeps the measurements honest.

What the caller said about itself — protocol version, client name and
version, capabilities — recorded as the session is created. Kept per
session because clients keep teaching us their actual shape (§4), and
knowing which client and version a measurement was made against keeps
the measurements honest.
sourceraw docstring

connect!clj

(connect!)

A fresh connection id, for the initialize response's Mcp-Session-Id header. Connections silent for longer than expiry-ms are forgotten here: a client that reconnects abandons its old id without a goodbye (measured 2026-08-04), and every reconnect passes this way.

A fresh connection id, for the `initialize` response's `Mcp-Session-Id`
header. Connections silent for longer than `expiry-ms` are forgotten
here: a client that reconnects abandons its old id without a goodbye
(measured 2026-08-04), and every reconnect passes this way.
sourceraw docstring

connected!clj

(connected! cid)

Refresh cid's last-seen stamp, adopting an id never seen — a client that outlived a server restart keeps presenting its old one, and all it has lost is a record that refills. Returns cid.

Refresh `cid`'s last-seen stamp, adopting an id never seen — a client
that outlived a server restart keeps presenting its old one, and all it
has lost is a record that refills. Returns `cid`.
sourceraw docstring

connection-clientclj

(connection-client cid)
source

connection-client!clj

(connection-client! cid m)

What initialize said about the client on cid — protocol version, client name and version, capabilities. Copied onto each session created over the connection.

What `initialize` said about the client on `cid` — protocol version,
client name and version, capabilities. Copied onto each session created
over the connection.
sourceraw docstring

current-nsclj

(current-ns sid)
source

current-ns!clj

(current-ns! sid ns-sym)

Where sid's last eval ended — the sticky namespace is conversational state, so it lives and dies with the session (§11). Guarded like note!, and it matters most here: an eval outlives a session that is released under it, and its ending must not write the session back — a row is all it takes for a handle to be live.

Where `sid`'s last eval ended — the sticky namespace is conversational
state, so it lives and dies with the session (§11). Guarded like
`note!`, and it matters most here: an eval outlives a session that is
released under it, and its ending must not write the session back — a
row is all it takes for a handle to be live.
sourceraw docstring

disconnect!clj

(disconnect! cid)

Forget cid — the spec's DELETE goodbye. Sessions are untouched: they belong to conversations, and expire by silence.

Forget `cid` — the spec's DELETE goodbye. Sessions are untouched: they
belong to conversations, and expire by silence.
sourceraw docstring

drop!clj

(drop! sid)

Forget sid. The registry releases a session's entry claims before dropping it — see registry/release-session!, which owns that order. Its upload directory is deleted, staged files and all. The session's scratch family goes with it — compartments included: conversational state dies with the session — so an eval somehow still running there fails loudly at its next form (No namespace) rather than working on in a ghost. The sessionless in-process caller's shared scratch family is never removed — no session to die with.

Forget `sid`. The registry releases a session's entry claims before
dropping it — see `registry/release-session!`, which owns that order.
Its upload directory is deleted, staged files and all. The session's
scratch family goes with it — compartments included:
conversational state dies with the session — so an eval somehow still
running there fails loudly at its next form (`No namespace`) rather
than working on in a ghost. The sessionless in-process caller's shared
scratch family is never removed — no session to die with.
sourceraw docstring

expire!clj

(expire! sid)

drop!, if sid's silence still outlasts expiry-ms, and whether it went. expired lists and this decides: a session that was refreshed in between — by a call that has since been let in — must stay, or that call's work is left with an owner the server refuses.

`drop!`, if `sid`'s silence still outlasts `expiry-ms`, and whether it
went. `expired` lists and this decides: a session that was refreshed in
between — by a call that has since been let in — must stay, or that
call's work is left with an owner the server refuses.
sourceraw docstring

expiredclj

(expired)

Session ids whose silence has outlasted expiry-ms. Open streams keep their session fresh — every successful heartbeat write refreshes the stamp — so a session mid-await cannot expire under it (§11). A stampless entry counts as ancient: it can only arise from a write racing a drop, and releasing it again is harmless.

Session ids whose silence has outlasted `expiry-ms`. Open streams keep
their session fresh — every successful heartbeat write refreshes the
stamp — so a session mid-await cannot expire under it (§11). A stampless
entry counts as ancient: it can only arise from a write racing a drop,
and releasing it again is harmless.
sourceraw docstring

expiry-msclj

How long a session may stay silent before it is presumed gone and its claims released. Deliberately the await clamp's own value — mcp derefs this var for it, so the two cannot drift: any wait the protocol will grant, the session survives to collect. Generous over stingy until proven insufficient (2026-08-04); the cost is bounded — a dead session's unread entries ride above the capacity for at most a day.

How long a session may stay silent before it is presumed gone and its
claims released. Deliberately the await clamp's own value — `mcp` derefs
this var for it, so the two cannot drift: any wait the protocol will
grant, the session survives to collect. Generous over stingy until
proven insufficient (2026-08-04); the cost is bounded — a dead session's
unread entries ride above the capacity for at most a day.
sourceraw docstring

fetched-toolsclj

(fetched-tools cid)
source

fetched-tools!clj

(fetched-tools! cid decls)

The tool declarations as cid last actually fetched them. Per connection, because tools/list names no session and each client's cache is its own (§4): a lost announcement re-announces on the next stream.

The tool declarations as `cid` last actually fetched them. Per
connection, because `tools/list` names no session and each client's
cache is its own (§4): a lost announcement re-announces on the next
stream.
sourceraw docstring

furnish-for!clj

(furnish-for! sid ns-sym)

furnish-scratch! for a namespace of sid's scratch family — the namespace, or nil, nothing created, when sid is not live. An eval outlives a session that ends under it, and a scratch furnished for it then would belong to nobody and never be reaped; furnishing and drop!'s sweep exclude each other, so a scratch is either made before the sweep and taken by it, or not made. The sessionless caller (nil) has no session to end.

The namespace is returned for a reason: enter it as the object, never again by name — in-ns creates what it does not find, and would put back, bare, a scratch the sweep took in the meantime.

`furnish-scratch!` for a namespace of `sid`'s scratch family — the
namespace, or nil, nothing created, when `sid` is not live. An eval
outlives a session that ends under it, and a scratch furnished for it
then would belong to nobody and never be reaped; furnishing and
`drop!`'s sweep exclude each other, so a scratch is either made before
the sweep and taken by it, or not made. The sessionless caller (nil)
has no session to end.

The namespace is returned for a reason: enter it as the object, never
again by name — `in-ns` creates what it does not find, and would put
back, bare, a scratch the sweep took in the meantime.
sourceraw docstring

furnish-scratch!clj

(furnish-scratch! ns-sym)

Create-or-refresh the scratch namespace ns-sym, returning it. Bare create-ns gives a namespace in which + does not resolve, so the full wiring is applied: clojure.core referred, and the composition surface — clojure.core and Quiescent (§5) — spelled exactly as committed source spells it: the q alias plus the q-prefixed macros referred bare, correct precisely because a scratch is a namespace its session owns. Idioms thereby copy verbatim between evals, the Quiescent skill, and source files; outside the scratch family, aliasing Quiescent is the model's own act (§4). res is how an id in one response becomes a value in the next expression, and __r the API's one alias — so a scratch resolves them all from the start.

Idempotent, and re-applied in full on every call: create-ns returns the existing namespace, and re-referring keeps a scratch created by an older remontoire current with the refers a newer one expects. A name the caller has interned themselves is never replaced — their def wins, and Clojure notes the rejection on err.

Rewired first: after a reload of a namespace the wiring names, :as q would otherwise find q still naming the replaced object, and alias refuses to rebind — every eval in the scratch would throw.

Create-or-refresh the scratch namespace `ns-sym`, returning it. Bare
`create-ns` gives a namespace in which `+` does not resolve, so the
full wiring is applied: clojure.core referred, and the composition
surface — clojure.core *and* Quiescent (§5) — spelled exactly as
committed source spells it: the `q` alias plus the `q`-prefixed macros
referred bare, correct precisely because a scratch is a namespace its
session owns. Idioms thereby copy verbatim between evals, the Quiescent
skill, and source files; outside the scratch family, aliasing Quiescent
is the model's own act (§4). `res` is how an id in one response becomes
a value in the next expression, and `__r` the API's one alias — so a
scratch resolves them all from the start.

Idempotent, and re-applied in full on every call: `create-ns` returns
the existing namespace, and re-referring keeps a scratch created by an
older remontoire current with the refers a newer one expects. A name
the caller has interned themselves is never replaced — their def wins,
and Clojure notes the rejection on *err*.

Rewired first: after a reload of a namespace the wiring names, `:as q`
would otherwise find `q` still naming the replaced object, and `alias`
refuses to rebind — every eval in the scratch would throw.
sourceraw docstring

live-countclj

(live-count)

How many sessions are current — the n of the capacity formula (§11). Counted after the reap that precedes every admission, so the dead never inflate the pool.

How many sessions are current — the `n` of the capacity formula (§11).
Counted after the reap that precedes every admission, so the dead never
inflate the pool.
sourceraw docstring

live?clj

(live? sid)

Whether sid names a session this server holds. A handle is a tool argument, and an unknown one is a stale or mistyped one (§11).

Whether `sid` names a session this server holds. A handle is a tool
argument, and an unknown one is a stale or mistyped one (§11).
sourceraw docstring

manual-read!clj

(manual-read! sid)

Mark sid as having read the manual — set when api/manual runs on its rails. Until it is set, the session's first eval response carries a one-line note (§4): the keys stay in the model's hands, but a fresh session doesn't start silent. Doubles as the compliance measurement the lean-instructions design is smoke-tested by. Guarded like note! — a dead sid is not recreated — which also makes the sessionless in-process caller a no-op.

Mark `sid` as having read the manual — set when `api/manual` runs on its
rails. Until it is set, the session's first eval response carries a
one-line note (§4): the keys stay in the model's hands, but a fresh
session doesn't start silent. Doubles as the compliance measurement the
lean-instructions design is smoke-tested by. Guarded like `note!` — a
dead sid is not recreated — which also makes the sessionless in-process
caller a no-op.
sourceraw docstring

manual-read?clj

(manual-read? sid)
source

mint!clj

(mint!)

A fresh session (§11), born now, named by five random consonants that the model passes as an ordinary tool argument. Redrawn against every handle minted since the JVM started, not only the live ones: a handle names one session, and what an ended session left running — an eval, a task id in a client's hands — still speaks under it, so a second session by the same name would be written to by the first's leftovers. A collision is therefore only ever with a handle from a previous boot — and the space is sparse, so a typo or a stale handle almost always names nothing and is refused loudly, where a counter's dense space would land it silently in a neighbour.

A fresh session (§11), born now, named by five random consonants that
the model passes as an ordinary tool argument. Redrawn against every
handle minted since the JVM started, not only the live ones: a handle
names one session, and what an ended session left running — an eval, a
task id in a client's hands — still speaks under it, so a second
session by the same name would be written to by the first's leftovers.
A collision is therefore only ever with a handle from a previous boot —
and the space is sparse, so a typo or a stale handle almost always
names nothing and is refused loudly, where a counter's dense space
would land it silently in a neighbour.
sourceraw docstring

note!clj

(note! sid s)

A self-description for the roster — what this session is for, in its own words (§11). Conversational state like everything here: it dies with the session, which is right, because so does the purpose.

A self-description for the roster — what this session is for, in its own
words (§11). Conversational state like everything here: it dies with the
session, which is right, because so does the purpose.
sourceraw docstring

note-evictions!clj

(note-evictions! sid ids)

Queue eviction news for sid: its entries went under another session's admission, and an id that silently stops resolving is §5's nasty failure mode regardless of whose admission did it. Drained into the owner's next response. A sid no longer live is not recreated — its reader is gone.

Queue eviction news for `sid`: its entries went under another session's
admission, and an id that silently stops resolving is §5's nasty failure
mode regardless of whose admission did it. Drained into the owner's next
response. A sid no longer live is not recreated — its reader is gone.
sourceraw docstring

nudged!clj

(nudged! sid)

Mark sid as having been shown the manual note — set only once the response carrying it has actually gone out, the same discipline as every delivery mark (§5), so a response the client never received burns nothing. Once per session, deliberately: the server knows only session truth — the conversation may have read the manual through another server of the same build, or before a restart — and a note that repeats what the model already judged spends the footer's credibility, the channel evictions and truncations must be believed on. Guarded like note!.

Mark `sid` as having been shown the manual note — set only once the
response carrying it has actually gone out, the same discipline as every
delivery mark (§5), so a response the client never received burns
nothing. Once per session, deliberately: the server knows only session
truth — the conversation may have read the manual through another server
of the same build, or before a restart — and a note that repeats what
the model already judged spends the footer's credibility, the channel
evictions and truncations must be believed on. Guarded like `note!`.
sourceraw docstring

nudged?clj

(nudged? sid)
source

pending-evictionsclj

(pending-evictions sid)
source

refresh!clj

(refresh! sid)

Refresh sid's last-seen stamp if it is live, and say whether it was. Never mints: neither a call naming a handle nor liveness evidence that arrives beside one — a heartbeat write, a task poll, an upload — may create the session it names.

Refresh `sid`'s last-seen stamp if it is live, and say whether it was.
Never mints: neither a call naming a handle nor liveness evidence that
arrives beside one — a heartbeat write, a task poll, an upload — may
create the session it names.
sourceraw docstring

rosterclj

(roster)

Every live session as data — id, last-seen, client info, note — for the API layer's sessions listing, which adds what only other namespaces know (entry counts, who is asking).

Every live session as data — id, last-seen, client info, note — for the
API layer's `sessions` listing, which adds what only other namespaces
know (entry counts, who is asking).
sourceraw docstring

scratch-ns-symclj

(scratch-ns-sym sid)

The scratch namespace sid's evals start in. Per session, so two tenants' defs and requires cannot collide — named by the handle, behind an s. nil — the sessionless in-process caller, never the wire — keeps the shared scratch: no session to die with, nothing to reap.

The scratch namespace `sid`'s evals start in. Per session, so two
tenants' defs and requires cannot collide — named by the handle, behind
an `s`. nil — the sessionless in-process caller, never the wire — keeps
the shared scratch: no session to die with, nothing to reap.
sourceraw docstring

scratch-nsesclj

(scratch-nses sid)

sid's scratch family as it exists right now: the session's scratch first when present, compartments after, alphabetical. Only namespaces that exist — nothing here mints.

Output shape: [Symbol …]

`sid`'s scratch family as it exists right now: the session's scratch
first when present, compartments after, alphabetical. Only namespaces
that exist — nothing here mints.

Output shape:
[Symbol …]
sourceraw docstring

scratch-sub-ns-symclj

(scratch-sub-ns-sym sid label)

The namespace symbol for sid's scratch compartment named label — nested under the session's scratch, so uniqueness across sessions comes from the handle and the label stays whatever the caller chose. Within a session the same label always names the same namespace: the label is the compartment's identity. label is caller-chosen text, filtered to what a symbol segment can carry — - and _ kept, s-prefixed when the survivors don't open with a letter, hashed whole when nothing survives.

The namespace symbol for `sid`'s scratch compartment named `label` —
nested under the session's scratch, so uniqueness across sessions comes
from the handle and the label stays whatever the caller chose. Within
a session the same label always names the same namespace: the label is
the compartment's identity. `label` is caller-chosen text, filtered to
what a symbol segment can carry — `-` and `_` kept,
`s`-prefixed when the survivors don't open with a letter, hashed whole
when nothing survives.
sourceraw docstring

scratch?clj

(scratch? ns-sym)

Whether ns-sym belongs to a scratch family — any session's, the shared one included. Remontoire's own namespaces: no reloader ever touches them, which is why their mappings are rewired (§4) and a host's are not.

Whether `ns-sym` belongs to a scratch family — any session's, the shared
one included. Remontoire's own namespaces: no reloader ever touches them,
which is why their mappings are rewired (§4) and a host's are not.
sourceraw docstring

upload-dirclj

(upload-dir sid)

Where sid's uploaded files are staged, or nil when it has none yet.

Output shape: Path

Where `sid`'s uploaded files are staged, or nil when it has none yet.

Output shape:
Path
sourceraw docstring

upload-dir!clj

(upload-dir! sid)

sid's upload directory, minted on first use: a fresh directory named by the handle and a random suffix, so the path is never something a client constructs — it is asked for. nil for a sid that is not live: an upload must never mint the session it names.

`sid`'s upload directory, minted on first use: a fresh directory named
by the handle and a random suffix, so the path is never something a
client constructs — it is asked for. nil for a sid that is not live: an
upload must never mint the session it names.
sourceraw docstring

upload-dirsclj

(upload-dirs)

Every live session's upload directory, for those that have one.

Output shape: {sid Path}

Every live session's upload directory, for those that have one.

Output shape:
{sid Path}
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close