threadsState gives one row per session with `session` and `legacy`; threadIdle
idles a run against its bound session. Each session gets its own store
(threads/<b>/<t>/sessions/<s>/, or the thread's old store for a legacy-3l
session) and its own workspace (session-workspaces/<b>/<i>/<s>/), held by an
O_EXCL <ws>.lock from before the clones to the run's proven exit. A legacy
session's workspace binds in-sandbox at the old instance path. sessions.json
is v2 and reads v1. New tests: cli session-launch.test.mjs, seat
session-workspace.test.mjs. Not yet run: tests wait for Sage's CLEAR.
Two old assertions change as exact updates:
- mos-1285: end-launch.test.mjs threadsState deepEqual. The old row shape was
{ thread: 'th-1', instance: 'coder', pending: 0, unread: 0, lastMessage: null,
lastOpen: '2026-10-15T00:00:01.000Z', lastClaim: null, holder: null }; the
row keeps every key and value and adds session: 'th-1', legacy: true.
- mos-1289: thread-launch.test.mjs:182, old line
`const store = join(f.dataRoot, "threads", "acme", A);`
now reads A's default session id from threadsState's `session` key; :183-185
unchanged; one added assert that threads/acme/<A>/session is absent.
19 lines
994 B
JavaScript
19 lines
994 B
JavaScript
// A stand-in harness turn for the session launch tests (row 269, #1774).
|
|
// thread-adapter.mjs's turn, plus the run's cwd and the names in it, so a
|
|
// test reads from the reply which workspace the session saw and at what
|
|
// in-sandbox path. It keeps a history in $MOSAIC_SESSION_DIR, the session's
|
|
// store.
|
|
|
|
import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
const request = process.env.MOSAIC_REQUEST ?? "";
|
|
const body = request.match(/^Message [^\n]*:\n\n([\s\S]*)$/m)?.[1] ?? "";
|
|
const historyFile = join(process.env.MOSAIC_SESSION_DIR, "history");
|
|
const before = existsSync(historyFile) ? readFileSync(historyFile, "utf8").split("\n").filter(Boolean) : [];
|
|
const cwd = process.cwd();
|
|
const entries = readdirSync(cwd).sort();
|
|
appendFileSync(historyFile, `${body}\n`);
|
|
process.stdout.write(`THREAD ${JSON.stringify({ body, before, cwd, entries })}\n`);
|
|
writeFileSync(process.env.MOSAIC_TURN_MARKER, "done\n");
|