@mrciphersmith/roomyx 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,82 @@ patch and never a minor. The rule, the reason, and an audit of the four of seven
13
13
  releases that followed it are in
14
14
  [`docs/roomyx/versioning.md`](docs/roomyx/versioning.md) and decision D-13.
15
15
 
16
+ ## [0.8.2] — 2026-09-10
17
+
18
+ A patch. Closes the backlog's S3 and corrects two documents that described a
19
+ package this is not.
20
+
21
+ ### Fixed
22
+
23
+ - **The staged skill is synced, not copied once.** `roomyx init` copied
24
+ `.roomyx/skills/startup-room/SKILL.md` when it was absent and did nothing when
25
+ it was present, so after a package upgrade the staged copy kept the old text
26
+ forever — no hash, no backup, no warning. Guarded with `existsSync` it had
27
+ stopped clobbering hand edits and started going stale silently instead. It now
28
+ goes through `syncSkill`: the copy is refreshed when it is still ours,
29
+ left exactly as it is when it has been hand-edited or was never recorded, and
30
+ in that case `init` says so instead of staying quiet. A re-run that changes
31
+ nothing writes nothing — a backup of an identical file once per run would bury
32
+ the backups that matter.
33
+
34
+ ### Changed
35
+
36
+ - **`docs/roomyx/improvement-backlog.md` no longer prescribes `--force`.** Its
37
+ R3 definition of done still read "`--force` overrides", describing a flag
38
+ 0.8.0 removed. An amendment records what the refusal actually depends on now
39
+ — `dispatcherAttached`, the writer lease, and `--take-over` for a writer that
40
+ is provably gone — and marks the old sentence as history rather than
41
+ instruction. The backlog is the document an implementer works from.
42
+ - **`room.post_owner_command` is documented as implemented *and unreachable for
43
+ the consumer it was designed for*.** Both files now say it: the tool is
44
+ registered, tested and answers correctly, and its handler is a JS function
45
+ that the orchestrator spawning `serve` as a child process cannot attach, so a
46
+ bare `roomyx serve` answers `accepted: false`. "Implemented" without that
47
+ distinction reads as "this works for you", which is the misreading a status
48
+ field exists to prevent. D-18 item 6 closes the gap.
49
+
50
+ ## [0.8.1] — 2026-09-10
51
+
52
+ A patch. Found by triaging the action list against the code: this defect had
53
+ been sitting in the backlog, unscheduled, with a victim it names itself.
54
+
55
+ ### Fixed
56
+
57
+ - **A room that does not answer within the liveness probe's 500 ms is no longer
58
+ deleted from the registry.** The check returned `state | undefined`, and
59
+ `undefined` had to mean both "I could not reach it" and "the process is gone" —
60
+ so the caller resolved the ambiguity destructively: `undefined → false → prune`,
61
+ plus a history record claiming the room had ended. A room that was merely slow,
62
+ or `SIGSTOP`ped, or on a loaded machine, was silently removed while it was
63
+ still serving. The pid check does not catch it: `process.kill(pid, 0)` succeeds
64
+ for a stopped process.
65
+
66
+ Liveness now answers `live`, `gone` or `unknown`, and only `gone` deletes
67
+ anything. `gone` requires evidence about *this entry* — a registered pid that
68
+ is not running, or a server that answered and named a different log than the
69
+ entry claims.
70
+
71
+ ### Added
72
+
73
+ - **`roomyx rooms list` shows a room that did not answer instead of omitting it**,
74
+ marked `did not answer — still registered`. It used to print `No live rooms.`
75
+ about a registry that had one, which is how a serving room came to look like no
76
+ room at all. An empty registry still prints exactly that sentence.
77
+ - **`listRoomsWithLiveness()`** returns `{ live, unconfirmed }`. Everything that
78
+ decides *what to attach to* keeps reading the confirmed list, so a client never
79
+ auto-attaches to a room that did not answer.
80
+
81
+ ### Notes
82
+
83
+ - The known limit is stated in the code rather than left to be discovered: a pid
84
+ reused by an unrelated process keeps its entry in `unconfirmed` until something
85
+ answers on that port. That is why the pid is a pre-filter and not the assertion
86
+ — and it is strictly better than deleting a live room, which is the trade this
87
+ release makes deliberately.
88
+ - `prune: false` (the MCP surface) still prunes nothing. The load-sensitive half
89
+ of that argument is now structural: a probe that times out returns `unknown`,
90
+ and `unknown` is never pruned even when pruning is asked for.
91
+
16
92
  ## [0.8.0] — 2026-09-10
17
93
 
18
94
  A minor, because it is breaking: `roomyx room append --force` is gone. In `0.x`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/roomyx",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "MCP server + terminal UI for startup-room: live room status, chat, per-agent modal, an installable room registry, and skill-sync.",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/cli.ts CHANGED
@@ -4,7 +4,13 @@ import { join, resolve } from "node:path";
4
4
  import { serve } from "./server/serve";
5
5
  import { createServerShutdown } from "./server/shutdown";
6
6
  import { init } from "./installer/init";
7
- import { probeRoomState, registerRoom, deregisterRoom, listLiveRooms } from "./installer/registry";
7
+ import {
8
+ findRoomServing,
9
+ probeRoomState,
10
+ registerRoom,
11
+ deregisterRoom,
12
+ listRoomsWithLiveness,
13
+ } from "./installer/registry";
8
14
  import { archiveRoom, defaultHistoryPath, readHistory } from "./installer/history";
9
15
  import { syncSkill } from "./installer/skill-sync";
10
16
  import { appendMessages, createRoomLog, LEGAL_KINDS, parseRoster } from "./log/write";
@@ -228,6 +234,12 @@ const COMMANDS: Record<string, Command> = {
228
234
  const cwd = process.cwd();
229
235
  const result = init({ cwd, bundledSkillPath: bundledSkillPath() });
230
236
  console.log(result.created ? `Created ${result.roomyxDir}` : `${result.roomyxDir} already initialized`);
237
+ for (const warning of result.skillWarnings ?? []) {
238
+ // Said out loud rather than swallowed: the staged copy is now known to
239
+ // differ from the bundled skill, and whoever sees this decides what to
240
+ // do about it.
241
+ console.log(` ! ${warning}`);
242
+ }
231
243
 
232
244
  const { buildPlan, selectedItems } = await import("./installer/init-plan");
233
245
  const { applyPlan } = await import("./installer/init-apply");
@@ -335,7 +347,11 @@ const COMMANDS: Record<string, Command> = {
335
347
  const absoluteRegistry = resolve(typeof flags.registry === "string" ? flags.registry : defaultRegistryPath());
336
348
  const leasePath = writerLeasePathFor(absoluteRegistry, absolute);
337
349
 
338
- const serving = (await listLiveRooms(absoluteRegistry)).find((room) => room.logPath === absolute);
350
+ // Across BOTH lists: an entry whose first probe timed out is `unconfirmed`,
351
+ // and it may still have a dispatcher attached — which is the evidence this
352
+ // guard needs. Searching only the confirmed list is how "the machine was
353
+ // busy" turns into "nothing is writing into this log".
354
+ const serving = findRoomServing(absolute, await listRoomsWithLiveness(absoluteRegistry));
339
355
 
340
356
  // Read the lease BEFORE the probe, and independently of its outcome. A
341
357
  // liveness probe that times out says "could not reach it", which is not
@@ -477,14 +493,25 @@ const COMMANDS: Record<string, Command> = {
477
493
  // `rooms list --registry /nonexistent.json` printed "No live rooms"
478
494
  // about a different file.
479
495
  const registryPath = typeof flags.registry === "string" ? flags.registry : defaultRegistryPath();
480
- const rooms = await listLiveRooms(registryPath);
481
- if (rooms.length === 0) {
496
+ const { live, unconfirmed } = await listRoomsWithLiveness(registryPath);
497
+ if (live.length === 0 && unconfirmed.length === 0) {
498
+ // An empty registry and a registry whose rooms did not answer are
499
+ // different facts, and the second used to print this same sentence —
500
+ // which is how a serving room came to look like no room at all.
482
501
  console.log("No live rooms.");
483
502
  return;
484
503
  }
485
- for (const room of rooms) {
504
+ for (const room of live) {
486
505
  console.log(`${room.id} port=${room.port} log=${room.logPath} started=${room.startedAt}`);
487
506
  }
507
+ for (const room of unconfirmed) {
508
+ // Kept in the registry, not claimed live: the probe did not answer, and
509
+ // "did not answer" is not permission to delete a room that may be
510
+ // serving. Named so the reader knows what to re-check.
511
+ console.log(
512
+ `${room.id} port=${room.port} log=${room.logPath} started=${room.startedAt} did not answer — still registered`,
513
+ );
514
+ }
488
515
  },
489
516
  },
490
517
 
@@ -1,5 +1,6 @@
1
- import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
+ import { syncSkill } from "./skill-sync";
3
4
 
4
5
  export interface InitOptions {
5
6
  cwd: string;
@@ -14,6 +15,11 @@ export interface InitResult {
14
15
  */
15
16
  created: boolean;
16
17
  roomyxDir: string;
18
+ /**
19
+ * Why the staged skill was left as it was, when it was. Empty or absent means
20
+ * the sync had nothing to report — not that it did nothing.
21
+ */
22
+ skillWarnings?: string[];
17
23
  }
18
24
 
19
25
  const DEFAULT_CONFIG = {
@@ -45,13 +51,59 @@ export function init(options: InitOptions): InitResult {
45
51
  if (!existsSync(registryPath)) {
46
52
  writeFileSync(registryPath, JSON.stringify({ schemaVersion: 1, rooms: [] }, null, 2));
47
53
  }
48
- // Guarded like the config and the registry beside it. This copy used to be
54
+ // Staged through `syncSkill`, not copied.
55
+ //
56
+ // Three defects lived in the two lines this replaces. The copy was
49
57
  // unconditional — no hash check, no backup, no gate — which is the operation
50
- // `syncSkill` refuses outright, while this function's own comment promises
51
- // "explicit, never-clobbering". Re-running `roomyx init` silently discarded
52
- // hand edits to the staged copy.
58
+ // `syncSkill` refuses outright, while the comment above promises "explicit,
59
+ // never-clobbering": a second `roomyx init` silently discarded hand edits to
60
+ // the staged copy. Guarding it with `existsSync` fixed the clobber and created
61
+ // the opposite one: after a package upgrade the staged copy kept the old text
62
+ // forever, silently. And `.roomyx/skills/` is read by nothing (`skills sync`
63
+ // reads the bundled copy straight from the package), so a stale file there is
64
+ // pure misinformation — it looks like the skill the project uses.
65
+ //
66
+ // `syncSkill` is what this wanted all along: a recorded hash per target, a
67
+ // backup before any overwrite, and a refusal that says which target it is
68
+ // refusing. `init` supplies `yes` itself, because the gate below is about
69
+ // *when* to write, and the operator's consent to scaffolding was the command.
53
70
  const stagedSkill = join(skillDir, "SKILL.md");
54
- if (!existsSync(stagedSkill)) copyFileSync(options.bundledSkillPath, stagedSkill);
71
+ const syncOptions = {
72
+ bundledSkillPath: options.bundledSkillPath,
73
+ targetPath: stagedSkill,
74
+ configPath,
75
+ };
76
+
77
+ // Asked before writing, so the decision is made from `syncSkill`'s own
78
+ // verdict rather than from a second copy of its rules here.
79
+ const dryRun = syncSkill({ ...syncOptions, dryRun: true });
80
+ const bundledContent = readFileSync(options.bundledSkillPath, "utf8");
81
+ const stagedContent = existsSync(stagedSkill) ? readFileSync(stagedSkill, "utf8") : null;
82
+ const identical = stagedContent === bundledContent;
83
+
84
+ if (dryRun.warnings.length > 0 && !identical) {
85
+ // Ours to refresh only while it is still ours. A hand-edited or unrecorded
86
+ // staged copy is left exactly as it is, and the caller is told why — the
87
+ // silence was the defect, not the staleness.
88
+ return { created: !registryAlreadyHasRooms, roomyxDir, skillWarnings: dryRun.warnings };
89
+ }
90
+ if (dryRun.warnings.length > 0 && identical) {
91
+ // The refusal protects content, and byte-identical content cannot be lost —
92
+ // so there is nothing to refuse. Writing here is what records the hash, and
93
+ // the hash is what the next real upgrade needs: the sync keys its records by
94
+ // absolute path, so a moved project otherwise keeps this copy stale forever
95
+ // and says so on every run. One adoption, one backup, and refreshes work
96
+ // again.
97
+ syncSkill({ ...syncOptions, yes: true });
98
+ return { created: !registryAlreadyHasRooms, roomyxDir };
99
+ }
100
+
101
+ if (!identical) {
102
+ // Only when there is a difference: a write with identical content still
103
+ // takes a timestamped backup, so a no-op `init` would fill the directory
104
+ // with copies of the same file and make a real backup impossible to find.
105
+ syncSkill({ ...syncOptions, yes: true });
106
+ }
55
107
 
56
108
  return { created: !registryAlreadyHasRooms, roomyxDir };
57
109
  }
@@ -114,61 +114,144 @@ export function listRooms(registryPath: string): RoomRegistryEntry[] {
114
114
  * answers). Dead entries are pruned from the persisted file, not just
115
115
  * omitted from the returned list.
116
116
  */
117
- export async function listLiveRooms(
117
+ /**
118
+ * What a liveness probe established, which is not a yes/no.
119
+ *
120
+ * The defect this type replaces: `probeRoomState` returned `state | undefined`,
121
+ * and `undefined` had to carry both "I could not reach it" and "the process is
122
+ * gone". The caller resolved that ambiguity in the destructive direction —
123
+ * `undefined → false → prune` — so a room that was merely slow had its registry
124
+ * entry deleted and a history record written claiming it had ended. The 500 ms
125
+ * probe is load-sensitive, `process.kill(pid, 0)` succeeds for a `SIGSTOP`ped
126
+ * process, and the failure is silent: the room is serving, and the registry says
127
+ * it never existed.
128
+ *
129
+ * R7's rule, in its own words: **identity mismatch is the one case where
130
+ * deleting is correct — a timeout never is.** Three values is what makes that
131
+ * expressible.
132
+ */
133
+ export type Liveness = "live" | "gone" | "unknown";
134
+
135
+ /**
136
+ * Asks what this entry is, with the destructive answer reserved for evidence.
137
+ *
138
+ * - `gone` — the registered pid is not running, or a server answered and named a
139
+ * different log than this entry claims. Both are facts about *this entry*.
140
+ * - `unknown` — the probe did not reach it: a refused connection, a connect
141
+ * timeout, or a `tools/call` that did not answer in time. Nothing is known, so
142
+ * nothing may be deleted on the strength of it.
143
+ * - `live` — a server answered and named this entry's log, or answered without a
144
+ * `log_path` at all. The second case is an older server: it cannot be shown to
145
+ * be a different room, and failing toward keeping is the safe direction, since
146
+ * the cost of wrongly pruning is higher than that of keeping a stale entry.
147
+ *
148
+ * **Known limit.** A pid that has been reused by an unrelated process keeps its
149
+ * entry in `unknown` where it will stay until something answers on that port.
150
+ * That is why the pid is a pre-filter and not the assertion — and it is strictly
151
+ * better than deleting a live room, which is what the alternative buys.
152
+ */
153
+ export async function checkRoomLiveness(room: RoomRegistryEntry, timeoutMs = 500): Promise<Liveness> {
154
+ if (!isPidAlive(room.pid)) return "gone";
155
+ const state = await probeRoomState(room, timeoutMs);
156
+ if (state === undefined) return "unknown";
157
+ if (state.log_path === undefined) return "live";
158
+ return state.log_path === room.logPath ? "live" : "gone";
159
+ }
160
+
161
+ export interface LiveAndUnconfirmed {
162
+ live: RoomRegistryEntry[];
163
+ /**
164
+ * Registered, probed, and not answered. Returned apart from `live` rather than
165
+ * mixed in, because every consumer of the confirmed list decides *what to
166
+ * attach to* — and a room that did not answer is not a candidate for that.
167
+ */
168
+ unconfirmed: RoomRegistryEntry[];
169
+ }
170
+
171
+ /**
172
+ * The confirmed-live rooms, and the ones nothing is known about, as two lists.
173
+ *
174
+ * Only `gone` prunes and archives. A room pruned here died without
175
+ * deregistering — crashed, or was killed with a signal no handler runs for — and
176
+ * this is the only moment anything observes that it ended, so it is the only
177
+ * place its history entry can be written. An `unknown` room gets neither: the
178
+ * history line would be a claim it ended, and the prune would be a claim about
179
+ * the room made on evidence that is a claim about the network.
180
+ */
181
+ export async function listRoomsWithLiveness(
118
182
  registryPath: string,
119
- options: { prune?: boolean; historyPath?: string } = {},
120
- ): Promise<RoomRegistryEntry[]> {
183
+ options: { prune?: boolean; historyPath?: string; timeoutMs?: number } = {},
184
+ ): Promise<LiveAndUnconfirmed> {
121
185
  const prune = options.prune ?? true;
122
186
  const historyPath = options.historyPath ?? defaultHistoryPath(registryPath);
123
- if (hasNoRegistry(registryPath)) return [];
187
+ if (hasNoRegistry(registryPath)) return { live: [], unconfirmed: [] };
124
188
  const rooms = withLock(registryPath, () => readRegistryUnlocked(registryPath).rooms);
125
189
  const checks = await Promise.all(
126
- rooms.map(async (room) => {
127
- const alive = await isRoomLive(room);
128
- return { room, alive };
129
- }),
190
+ rooms.map(async (room) => ({ room, liveness: await checkRoomLiveness(room, options.timeoutMs ?? 500) })),
130
191
  );
131
- const live = checks.filter((c) => c.alive).map((c) => c.room);
192
+ const pick = (want: Liveness) => checks.filter((c) => c.liveness === want).map((c) => c.room);
193
+ const live = pick("live");
194
+ const unconfirmed = pick("unknown");
195
+ const gone = pick("gone");
196
+
132
197
  // The MCP surface passes `prune: false`. It is the one place a network caller
133
198
  // could cause a filesystem write, and the content is not caller-controlled —
134
199
  // but "the MCP surface only reads" is worth being exactly true rather than
135
200
  // nearly, and the 500ms probe is load-sensitive enough that a busy machine
136
201
  // could prune a live-but-slow room on someone else's call.
137
- if (prune && live.length !== rooms.length) {
202
+ //
203
+ // That reasoning is now structural rather than a convention: a load-sensitive
204
+ // probe returns `unknown`, and `unknown` is not pruned even when pruning is
205
+ // asked for. `prune: false` still matters — it stops the deletion of entries
206
+ // confirmed gone — but the load-sensitive half of the argument no longer
207
+ // depends on every caller remembering to pass it.
208
+ if (prune && gone.length > 0) {
138
209
  // Re-take the lock for the write: another process may have registered or
139
210
  // deregistered a room while the (network) liveness checks above were in
140
211
  // flight. Re-read under the lock and only remove entries this pass
141
- // actually confirmed dead, instead of blindly overwriting with the
142
- // stale `live` list computed before the re-read.
143
- const dead = checks.filter((c) => !c.alive).map((c) => c.room);
212
+ // actually confirmed gone, instead of blindly overwriting with the stale
213
+ // list computed before the re-read.
144
214
  withLock(registryPath, () => {
145
215
  const current = readRegistryUnlocked(registryPath).rooms;
146
- const deadIds = new Set(dead.map((r) => r.id));
216
+ const goneIds = new Set(gone.map((r) => r.id));
147
217
  writeRegistryUnlocked(
148
218
  registryPath,
149
- current.filter((r) => !deadIds.has(r.id)),
219
+ current.filter((r) => !goneIds.has(r.id)),
150
220
  );
151
221
  });
152
- // A room pruned here died without deregistering — crashed, or was killed
153
- // with a signal no handler runs for. This is the only moment anything
154
- // observes that it ended, so it is the only place its history entry can be
155
- // written. Without it the rooms that are most worth being able to reread
156
- // are exactly the ones that leave no trace.
157
- //
158
222
  // `closedAt` is now, not the moment it actually died, which is unknowable
159
223
  // — the entry records when it was found gone.
160
- for (const room of dead) archiveRoom(historyPath, room);
224
+ for (const room of gone) archiveRoom(historyPath, room);
161
225
  }
162
- return live;
226
+ return { live, unconfirmed };
163
227
  }
164
228
 
165
229
  /**
166
- * Is the process that registered this room still running?
230
+ * The registered entry serving a log, whether or not it was confirmed live.
167
231
  *
168
- * Signal 0 performs the permission and existence checks without delivering
169
- * anything. ESRCH means no such process; EPERM means it exists and belongs to
170
- * someone else, which is still "alive" for our purposes.
232
+ * For anything that must know *which room is this*, rather than *may I attach to
233
+ * it*. The distinction matters here because a first probe can time out while the
234
+ * room is alive: searching only the confirmed list made a slow machine's answer
235
+ * to "is anyone writing into this log?" come back "nothing is" — which is the
236
+ * same collapsed question this module's `Liveness` type was introduced to stop
237
+ * asking. An unconfirmed entry is still an entry, and its second probe may
238
+ * answer.
171
239
  */
240
+ export function findRoomServing(
241
+ logPath: string,
242
+ lists: { live: RoomRegistryEntry[]; unconfirmed: RoomRegistryEntry[] },
243
+ ): RoomRegistryEntry | undefined {
244
+ return [...lists.live, ...lists.unconfirmed].find((room) => room.logPath === logPath);
245
+ }
246
+
247
+ /** Confirmed live only — what anything that decides what to attach to must read. */
248
+ export async function listLiveRooms(
249
+ registryPath: string,
250
+ options: { prune?: boolean; historyPath?: string; timeoutMs?: number } = {},
251
+ ): Promise<RoomRegistryEntry[]> {
252
+ return (await listRoomsWithLiveness(registryPath, options)).live;
253
+ }
254
+
172
255
  function isPidAlive(pid: number): boolean {
173
256
  if (!Number.isInteger(pid) || pid <= 0) return true; // no pid recorded — fall back to the probe
174
257
  try {
@@ -223,21 +306,3 @@ export async function probeRoomState(
223
306
  }
224
307
  }
225
308
 
226
- async function isRoomLive(room: RoomRegistryEntry, timeoutMs = 500): Promise<boolean> {
227
- // The probe below proves that *something* MCP-speaking answers on that port,
228
- // never that it is this room. Every `roomyx serve` defaults to 4319, so a
229
- // room that died without deregistering was resurrected as live by the next
230
- // room to bind the port — and then `roomyx-client --room <dead-id>` silently
231
- // rendered a different room's transcript under the dead room's id, while
232
- // `room append` refused a log nothing was serving.
233
- //
234
- // The pid has been in the registry all along and was never read. Checking it
235
- // first also skips a 500 ms network probe per dead entry.
236
- const state = await probeRoomState(room, timeoutMs);
237
- if (state === undefined) return false;
238
- // An older server that predates `log_path` answers without it. Treat that
239
- // as "cannot be shown to be a different room" rather than as dead: failing
240
- // toward the previous behaviour is the safe direction here, because the
241
- // cost of wrongly pruning a live room is higher than of keeping a stale one.
242
- return state.log_path === undefined || state.log_path === room.logPath;
243
- }