Skip to content

Name every session where the whole machine can see it - #7

Merged
jgfoster merged 1 commit into
mainfrom
feat/name-sessions
Aug 23, 2026
Merged

Name every session where the whole machine can see it#7
jgfoster merged 1 commit into
mainfrom
feat/name-sessions

Conversation

@jgfoster

Copy link
Copy Markdown
Member

sessionRegistry() answers "which notebook owns this session" only inside the extension host that opened it. From anywhere else — a second VS Code window, topaz, the administrator's dashboard we want next — GemDB's sessions are anonymous gems. That is exactly the situation in which someone asks the question.

What each session is called

Owner Name
Notebook gemdb nb analysis
GemDB Shell gemdb sh 41234
The extension's own gemdb ext
gemdb backfill.py gemdb run backfill

Readable by anything attached to the same cache, alongside the stock GcReclaim, SymbolGem and TopazL:

System cacheStatisticsForAllSlots  "rows of (name, pid, sessionId)"
System cacheStatisticsForSessionId: 7

The gemdb prefix earns its six characters on a database this extension did not install alone — it is the only thing saying which client a session belongs to. A shell reports its pid because a shell is its own process and that is what leads back to the terminal; only shells do, since in the extension host process.pid is one number for every notebook.

Two code paths, because file mode is not a GCI login

GciSession.login covers notebooks, the extension and the shell. File mode does not go through itgemdb file.py drives linked topaz — so gemdb-run.tpz carries its own copy and would otherwise show as TopazL. Yes, we generate that file: writeCliScripts rewrites the wrapper and the driver on every staging.

Why not a committed registry

System cacheName: writes shared memory, so it costs no commit, and the entry dies with the process — a window that crashes leaves nothing behind. A committed registry would leak a row on every crash and dirty a session to write one, which is the Transcript bug class this project already paid for once.

The price is a 31-character limit — 32 raises OutOfRange (2061, measured). So the name is a label and the sessionId stays the identifier. cacheNameFor strips .ipynb (the nb tag already said it), drops non-ASCII (the cache holds 8-bit code points) and truncates, rather than letting a long notebook title fail a login on the notebook the user just opened.

The GCI route does not exist for us

Worth recording, because it is the obvious place to look. gcits.hf: there is no GciInit equivalent in the thread-safe library at all. GciInitAppName: "Has no effect in remote GCI applications" — it only picks the .conf filename. GciSetCacheName_: "If GciIsRemote() returns TRUE, this function does nothing." The Smalltalk send is the only route that works. CLAUDE.md now says so, together with the descriptionOfSession: slots a dashboard wants: 5 last begin/commit/abort, 16 commits behind this session's view, 8 holding the oldest commit record, 21 the client's pid (RPC only).

This also corrects #5, which claimed GemStone offers no way to name a session.

Verification

  • 108 unit tests (6 new). The naming rule is tested without a database because it fails at login if it is wrong — the same reason sessionLimitMessage takes its sessions as an argument.
  • 45 integration tests (1 new), which reads the names back the long way round: from a different session, through cacheStatisticsForAllSlots, then joins each name to the sessionId this side recorded at login — the join a dashboard needs.
  • The generated Smalltalk was run in real linked topaz before it was committed; the cache accepted a truncated 31-character name and read it back unchanged.
  • Lint, format, both typechecks clean.

Not covered

Renames. The name is set at login, so a notebook saved under a new title keeps its old label until its session is reopened. Cheap to fix by re-sending on execute if it turns out to matter.

🤖 Generated with Claude Code

sessionRegistry() answers "which notebook owns this session" only inside
the extension host that opened it. From anywhere else -- a second VS Code
window, topaz, the dashboard we want next -- GemDB's sessions are
anonymous gems, which is exactly when the question gets asked.

So every login now publishes itself with System cacheName:, and file mode
does the same in gemdb-run.tpz, because linked topaz never reaches
session.ts and would otherwise sit in the cache as the stock 'TopazL'.
Names read gemdb nb <notebook>, gemdb sh <pid>, gemdb ext, gemdb run
<script>; a shell reports its pid because that is what leads back to the
terminal, and only shells do, since in the extension host process.pid is
the same number for every notebook.

Chosen over a committed registry on purpose: this costs no commit and the
entry dies with the process, where a registry would leak a row every time
a window crashed and dirty a session to write one -- the Transcript bug
class. The cost is a 31-character limit (32 raises OutOfRange, measured),
so the name is a label and the sessionId stays the identifier.
cacheNameFor truncates and strips non-ASCII rather than let a long
notebook title fail a login.

The GCI route does not exist for us and the headers say so: no GciInit
equivalent in the thread-safe library, GciInitAppName "has no effect in
remote GCI applications", GciSetCacheName_ does nothing when GciIsRemote.
Recorded in CLAUDE.md with the descriptionOfSession: slots a dashboard
needs, so nobody goes looking again.

Verified: 108 unit tests (6 new on the naming rule, which has to be right
without a database because it fails at login), and 45 integration tests
-- one new, reading the names back the long way round through the shared
cache from a different session and joining them to the sessionIds this
side recorded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jgfoster
jgfoster added this pull request to the merge queue Aug 23, 2026
Merged via the queue into main with commit 43dbef0 Aug 23, 2026
5 checks passed
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