omp-superagent 0.1.16 → 0.1.17

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.
@@ -325,9 +325,9 @@ bun --no-env-file "$PROBE" capture gateway "$GATEWAY_SOCKET" > "$EVIDENCE_DIR/ga
325
325
  `gateway: null`, or a failed probe. Do not wake a sleeping HEAD for evidence.
326
326
  - Do not run `stop` or `start` for an instance or lane already confirmed intentionally
327
327
  stopped. Use the known prior stop/exit and machine process inventory to establish
328
- this; a missing socket, saved state, or an unrelated receipt is not proof. An absent
329
- or unconfirmed owner, an in-progress wake/rotation, or a failed capture is a reason to
330
- resolve ownership before replacing files, not to mark it stopped or force a start.
328
+ this; a missing socket, saved state, or an unrelated receipt is not proof. If
329
+ capture fails for a previously running instance, follow the recovery path below
330
+ before attempting any replacement.
331
331
 
332
332
  For each affected resident lane, take `id`, `socketPath` and `sessionId` from the
333
333
  corresponding `lanes[]` entry and confirm `placement.target`. On the physical machine
@@ -357,6 +357,33 @@ HEADs, or cannot prove their ownership, leave that installation intact. A HEAD-o
357
357
  update does not replace worker files or require stopping lanes on unchanged
358
358
  installations.
359
359
 
360
+ #### Recover an unreachable Gateway before upgrading
361
+
362
+ An unreachable `gateway.sock` can outlive a crash. The last
363
+ `main.sock.exit.json` may describe an older Host that used the **same** session ID
364
+ and journal. It does not prove the exit of a later PID. Do not manufacture a
365
+ receipt or use that older one to authorize an update.
366
+
367
+ 1. Keep the old installation in place. Establish that the instance was running
368
+ before the incident, was not intentionally stopped, and that no other launch
369
+ or maintenance is in progress. Match the configured state directory to the
370
+ process inventory, including the native HEAD and adapter owner. For a dead
371
+ instance, take a private backup of the state directory before recovery,
372
+ including `coordination.sqlite` and any SQLite sidecars, the session journals,
373
+ and existing receipts. Unix socket files are not needed in the backup.
374
+ 2. Use the **old** CLI with the same account and config to run
375
+ `"$OLD_OMP_SA" start --config "$CONFIG"` once. This is recovery, not proof of
376
+ a clean exit. The native launcher checks recorded dead PIDs and socket
377
+ identities before reclaiming stale endpoints. It does not make a live or
378
+ unverified owner, PID reuse, or a pending restart handoff safe to override.
379
+ If it refuses, or HEAD cannot be identified, keep the old installation and
380
+ backup; do not delete sockets, edit ownership records, or force another start.
381
+ 3. Verify transport, intake, and HEAD readiness and compare the resumed native
382
+ session ID and journal path with the pre-crash records. Do not resubmit
383
+ uncertain inputs. Take a **new** status and physical-socket capture of the
384
+ recovered owners, re-inventory resident lanes, then follow the normal stop
385
+ procedure. Only the recovered owners' verified exit permits replacement.
386
+
360
387
  #### Stop, verify, and replace
361
388
 
362
389
  For a **local** lane, use the private status saved from its managing instance and
@@ -2221,7 +2248,17 @@ the repository by Git origin, not folder name; local edits and ignored files are
2221
2248
  not synchronized. Start with a clean, committed source tree. The worker reserves
2222
2249
  its checkout for one resident lane; it does not fetch, switch branches, or discard
2223
2250
  edits. Follow-ups stay on the same worker and native session; disconnecting SSH
2224
- does not stop that Host. A cold reopen is held if the checkout has changed.
2251
+ does not stop that Host. After a verified release, a lane can reopen its same
2252
+ session in its recorded worker checkout after ordinary file edits. The original
2253
+ Git revision and checkout identity must still match. Earlier lanes without a
2254
+ recorded physical checkout identity still need the clean checkout check.
2255
+
2256
+ If a worker leaves an untrusted journal, the next scoped probe, placement check,
2257
+ or open can release the checkout only after verifying the exact process exits
2258
+ and that no public socket remains. For a previously attached lane, this also
2259
+ requires proof that guarded shutdown confirmed no native work remained. The old
2260
+ lane stays held for inspection; its journal and permissions are unchanged.
2261
+ Missing proof is not permission to remove a stale-looking checkout claim.
2225
2262
  Chat replies and approval cards use the original route; messenger file transfer
2226
2263
  is not provided across SSH.
2227
2264
  Remote lanes require the normal stock OMP command without extra head-side flags:
@@ -272,9 +272,8 @@ bun --no-env-file "$PROBE" capture gateway "$GATEWAY_SOCKET" > "$EVIDENCE_DIR/ga
272
272
  증거를 얻으려고 절전 중인 HEAD를 깨우지 않는다.
273
273
  - 의도적으로 이미 중지됐음이 확인된 인스턴스나 레인에는 `stop`도 `start`도 실행하지 않는다.
274
274
  이전 정상 종료 증거와 머신의 프로세스 목록을 대조한다. 소켓 부재·저장된 상태·다른 종료
275
- 영수증으로는 충분하지 않다. 소유자가 보이지 않거나 확인되지 않거나, HEAD 복귀·교체가 진행
276
- 중이거나, 수집에 실패하면 소유 상태를 먼저 확인한다. 중지된 것으로 간주하거나 강제로
277
- 시작하지 않는다.
275
+ 영수증으로는 충분하지 않다. 이전에 실행 중이던 인스턴스의 수집에 실패했다면 파일을
276
+ 교체하기 전에 아래 복구 절차를 따른다.
278
277
 
279
278
  교체할 설치본을 쓰는 각 상주 레인은 해당 `lanes[]` 항목의 `id`, `socketPath`, `sessionId`를
280
279
  확인하고 `placement.target`을 확인한다. 소켓이 있는 실제 머신에서 현재 소유권을 기록한다.
@@ -301,6 +300,28 @@ bun --no-env-file "$PROBE" capture host "$LANE_SOCKET" "$LANE_SESSION" --worker
301
300
  설치본을 그대로 둔다. HEAD 쪽만 업데이트할 때는 바꾸지 않는 설치본의 파일을 교체하거나 그
302
301
  레인을 중지할 필요가 없다.
303
302
 
303
+ #### 응답하지 않는 Gateway부터 복구
304
+
305
+ 비정상 종료 뒤에는 `gateway.sock`이 남아 있어도 응답하지 않을 수 있다. 마지막
306
+ `main.sock.exit.json`이 **같은** 세션 ID와 저널 경로를 가리키더라도 PID가 다르면 이전
307
+ Host의 영수증이다. 기존 영수증을 재사용하거나 새로 만들어 업데이트를 정당화하지 않는다.
308
+
309
+ 1. 기존 설치를 유지한다. 장애 전 실행 중이었으며 의도적으로 중지된 인스턴스가 아닌지,
310
+ 다른 시작이나 점검이 진행 중이지 않은지 확인한다. 설정의 상태 디렉터리를 실제 프로세스
311
+ 목록과 대조하며 native HEAD와 어댑터 소유 프로세스도 확인한다. 모두 종료된
312
+ 인스턴스는 복구 전에 상태 디렉터리를 비공개로 백업한다. `coordination.sqlite`와 함께
313
+ 있는 SQLite 보조 파일, 세션 저널, 기존 영수증을 보존한다. Unix 소켓은 백업할 필요가 없다.
314
+ 2. **구버전** CLI에 동일 계정과 설정을 사용해 `"$OLD_OMP_SA" start --config "$CONFIG"`를
315
+ 한 번 실행한다. 이는 정상 종료 확인이 아니라 장애 복구다. 네이티브 실행기는 기록된 PID의
316
+ 부재와 소켓 식별자를 대조한 뒤 남은 소켓을 정리한다. 살아 있거나 확인되지 않은 소유자,
317
+ PID 재사용, 대기 중인 재시작 인계를 우회하지 않는다. 시작이 거부되거나 HEAD 소유권을
318
+ 확인할 수 없다면 기존 설치와 백업을 유지한다. 소켓을 지우거나 소유권 기록을 편집하거나
319
+ 강제로 다시 시작하지 않는다.
320
+ 3. 전송·접수·HEAD 준비 상태와 복구된 세션 ID·저널 경로가 장애 전 기록과 일치하는지 확인한다.
321
+ 결과가 불확실한 입력을 다시 보내지 않는다. 복구된 실제 소켓에서 상태와 소유권을 **새로**
322
+ 수집하고 상주 레인을 다시 확인한 뒤 아래 중지 절차를 따른다. 복구한 프로세스의 정상 종료가
323
+ 검증된 뒤에만 설치를 교체한다.
324
+
304
325
  #### 중지·검증·교체
305
326
 
306
327
  **로컬 레인**은 관리 인스턴스에서 비공개로 저장한 상태 파일과 해당 Host의 수집 파일을 함께
@@ -23,18 +23,52 @@ the worker launches the stock Host and owns its Unix socket, processes and nativ
23
23
  journal. An SSH disconnect is client detach, not cancellation, an exit receipt,
24
24
  or authority to reassign work. Open and attachment are separate from sending
25
25
  the first input. A pending or ambiguous launch must be reconciled on that
26
- worker, never retried on another machine. Remote PIDs and session paths do not
27
- identify local processes or files. See [worker enrollment](../OPERATIONS.en.md#add-a-remote-worker).
26
+ worker, never retried on another machine. If an already attached lane loses
27
+ only its connection, a verified clean exit for that exact generation and
28
+ session clears the connection hold. Reconnection itself never launches a
29
+ Host; new input can reopen the existing session through the ordinary queue.
30
+ The loss of transport and an earlier uncertain input are separate holds.
31
+ A verified exit can clear the transport hold without settling the input or
32
+ releasing its effects. Exact owner resolution then needs no second reconnect
33
+ command; no prior admission or approval is replayed.
34
+ Remote PIDs and session paths do not identify local processes or files.
35
+ See [worker enrollment](../OPERATIONS.en.md#add-a-remote-worker).
36
+
37
+ New worker journals retain stock OMP file modes in a newly created private
38
+ lane directory. The worker records the directory's identity in its private
39
+ ledger before session preparation and verifies it on attach and across
40
+ generations. An existing directory without that provenance keeps the original
41
+ file-permission checks; old journals are not automatically adopted.
28
42
 
29
43
  When several workers qualify, placement accounts for both reported free slots
30
44
  and head assignments waiting to start. Concurrent admissions reserve their
31
45
  selection before the next admission decides, without serializing SSH probes.
32
46
  On the target, a failure before native session preparation releases the slot;
33
47
  after preparation begins, an uncertain attempt keeps its reservation.
48
+ Worker inventory with a verified workspace, probes and new opens reconcile
49
+ existing reservations on demand. If the journal cannot be trusted, an attempt
50
+ that never admitted a remote attachment can release its checkout using a
51
+ matching private native exit receipt or the Rust owner's record of reaping
52
+ its own stock child. For a previously attached attempt, that record must also
53
+ confirm the exact session acknowledged guarded shutdown with no native owned
54
+ work outstanding. Both processes must be gone and no public socket may remain.
55
+ Checkout-only retirement restores capacity without granting session or
56
+ clean-exit proof. It fences reopening the original journal and does not repair
57
+ its permissions or delete any work. An attempt without sufficient proof stays
58
+ held, including an attached worker that crashed without a shutdown acknowledgement.
34
59
  An absent socket alone cannot resolve a pending open: an SSH request may
35
60
  still arrive. Explicit close or resume can seal that generation on the worker
36
61
  before proceeding. A later open for the sealed generation is refused.
37
62
 
63
+ A first placement still matches the exact clean commit on both machines.
64
+ An already released lane may reopen the same verified native session in its
65
+ original physical worker checkout even after ordinary file edits there. The
66
+ worker attests the same enrolled root, Git metadata directory, subdirectory,
67
+ origin and revision; checkout leases and startup restrictions still apply.
68
+ Older bindings with no recorded physical identity keep the clean preflight.
69
+ This does not transfer edits, adopt another checkout or substitute a new
70
+ session if the original cannot be verified.
71
+
38
72
  Only an operator-approved head checkout may use a default worker implicitly;
39
73
  Git origin and commit identify compatible contents, not permission to send a
40
74
  task. Worker verification must not execute checkout-configured Git filters.
@@ -404,10 +404,12 @@ See the [operations guide](../OPERATIONS.en.md#4-commands-and-daily-use) for com
404
404
  one placement notice; progress and final work reports use the work thread.
405
405
  - `/head <request>` explicitly addresses the shared coordination model (Slack:
406
406
  `!head` or `/superagent-head`). Manager handoffs keep HEAD's review path.
407
- When HEAD explicitly uses `lane_message` to continue an existing physical
408
- Discord work thread from its exact authorized guild parent, the controller
409
- records that thread as the handoff's progress and final report route. It
410
- does not change the original input or borrow its parent message as a thread
407
+ When HEAD selects an existing physical Discord work thread from its exact
408
+ authorized guild parent, that thread is the handoff's progress and final
409
+ report route. An opening `lane_start` requires its confirmed kickoff in
410
+ that thread; an explicit `lane_message` pins the route on admission.
411
+ This applies equally to local and enrolled SSH lanes. It does not
412
+ change the original input or borrow its parent message as a thread
411
413
  reply. Replays preserve the recorded destination and do not send a parent
412
414
  copy. Native approvals during HEAD's review still use the original parent
413
415
  route, not the report's destination. Other routes, logical topics and
@@ -432,12 +434,14 @@ See the [operations guide](../OPERATIONS.en.md#4-commands-and-daily-use) for com
432
434
  - Ordinary follow-ups default to native `steer` when their destination has an
433
435
  eligible active run: unbound requests and ordinary `/head` text go to HEAD;
434
436
  ordinary replies in a bound work thread go to its lane without `lane_message`.
437
+ This includes a lane on an enrolled SSH worker.
435
438
  If a follow-up arrives before the native start event, that event rechecks
436
- pending inputs. An idle destination receives a new prompt.
439
+ pending inputs. An idle destination receives a new prompt in the same native
440
+ session after its ownership and readiness are verified.
437
441
  Match the full route including account, authority, thread and topic. A bound
438
442
  reply can join a manager run initiated elsewhere only if its verified delivery
439
443
  route is this exact thread. When steering another manager handoff into or from
440
- a parent-origin thread follow-up, both source conversations and report routes
444
+ a parent-origin thread handoff, both source conversations and report routes
441
445
  must match. A manager handoff keeps its HEAD review mode, with the verified
442
446
  reply route fixed for the joined run, including logical topics backed by native
443
447
  threads. Keep each source and native receipt distinct
@@ -0,0 +1,10 @@
1
+ # omp-superagent 0.1.17
2
+
3
+ - Ordinary owner replies in an existing Discord work thread can reach its active local or SSH worker lane directly, without a HEAD model turn. Approvals and explicit manager handoffs still follow their original routes. [#74](https://github.com/dbc-hbin/omp-superagent/pull/74)
4
+ - After a verified clean exit clears a remote lane's connection hold, a new thread message can reopen the same native session on the same worker. Ordinary edits in the original verified checkout no longer prevent that reopen. Previously admitted input, approvals and uncertain effects are not replayed. [#72](https://github.com/dbc-hbin/omp-superagent/pull/72)
5
+ - New remote lane journals keep stock OMP's file modes inside a worker-verified private directory. Older unverified journals are not automatically adopted. A worker with an untrusted journal can release its checkout and capacity only with sufficient proof of process exit and, for a previously attached lane, guarded shutdown with no native owned work outstanding. Releasing the checkout does not make the journal resumable. [#72](https://github.com/dbc-hbin/omp-superagent/pull/72) · [#75](https://github.com/dbc-hbin/omp-superagent/pull/75)
6
+ - A remote Host owner exits unsuccessfully if it cannot verify persistence after reaping its native child, rather than keeping the socket open indefinitely. This is not proof of a clean exit and does not authorize session resume. [#73](https://github.com/dbc-hbin/omp-superagent/pull/73)
7
+
8
+ **Before upgrading**, follow the [upgrade procedure](https://github.com/dbc-hbin/omp-superagent/blob/v0.1.17/docs/OPERATIONS.en.md#update-an-existing-installation) ([한국어](https://github.com/dbc-hbin/omp-superagent/blob/v0.1.17/docs/OPERATIONS.md#기존-설치-업데이트)). Use the old installation to stop affected resident lanes and Gateway/HEAD and verify their exits. If an old Gateway is unreachable, recover it with the old installation first; a receipt for an earlier PID does not authorize replacement. Keep the original config and journals, install `omp-superagent@0.1.17`, and restart only previously running Gateways.
9
+
10
+ [Changes since 0.1.16](https://github.com/dbc-hbin/omp-superagent/compare/v0.1.16...v0.1.17)
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-superagent",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "One messenger-connected OMP head with independent work sessions",
5
5
  "license": "MIT",
6
6
  "author": "dbc-hbin",
package/src/contracts.ts CHANGED
@@ -421,7 +421,9 @@ export interface StorePort {
421
421
  laneRecoveryScope(reportId: string): LaneRecoveryScope | null;
422
422
  /** Original parent route for a redirected report or a handoff derived from that report. */
423
423
  reportApprovalSource(id: string): InputRecord | null;
424
- /** Manager handoff's verified reply route, pinned for a parent-origin thread follow-up or a joined bound reply. */
424
+ /** Exact existing Discord reply thread for a handoff by its authorized parent, if verified. */
425
+ parentThreadReply(input: InputRecord, source: InputRecord): Route | null;
426
+ /** Manager handoff's verified reply route, pinned for a parent-origin thread handoff or a joined bound reply. */
425
427
  laneReplyRoute(input: InputRecord, source: InputRecord): Route;
426
428
  /** Exact original owner and authorized delivery route for a topic-owned lane input. */
427
429
  topicDelivery(id: string): { readonly source: InputRecord; readonly route: Route; readonly outputSourceId: string } | null;
@@ -238,6 +238,7 @@ interface RemoteInspection {
238
238
  interface RemoteRetry {
239
239
  readonly after: number;
240
240
  readonly preflight?: boolean;
241
+ readonly lostAttachment?: { readonly generation: number; readonly sessionId: string; readonly pauseRevision?: number };
241
242
  }
242
243
 
243
244
  interface LanePlacementReceipt {
@@ -2091,6 +2092,14 @@ export class Superagent {
2091
2092
  return !!lane.remote && this.store.getMeta(this.remoteShutdownKey(lane)) === "pending";
2092
2093
  }
2093
2094
 
2095
+ private async workerLaneReady(lane: Lane, { probe, registration }: RemoteInspection): Promise<boolean> {
2096
+ // An authenticated, exact released lane may reuse its original checkout
2097
+ // after ordinary edits. A first placement still requires the clean preflight.
2098
+ return (lane.sessionId !== null && probe.sessionId === lane.sessionId && probe.sealedGeneration === lane.generation
2099
+ && probe.reopenActive !== undefined && probe.reopenActive < registration.description.capacity)
2100
+ || await this.adapters.workerPlacementReady(registration, workerRef(lane));
2101
+ }
2102
+
2094
2103
  private remoteOpenKey(lane: Pick<Lane, "id" | "generation">): string {
2095
2104
  return `worker-open:${lane.id}:${lane.generation}`;
2096
2105
  }
@@ -2264,7 +2273,7 @@ export class Superagent {
2264
2273
  for (const frame of buffered) this.observe(live, frame);
2265
2274
  if (recovery || live.headJobOwners?.size && state.isSettled) this.background(this.finish(live));
2266
2275
  const attached = live;
2267
- void connection.exited.then(() => this.disconnected(attached), () => this.disconnected(attached));
2276
+ void connection.exited.then(() => this.disconnected(attached, true), () => this.disconnected(attached, true));
2268
2277
  return live;
2269
2278
  } catch (error) {
2270
2279
  if (live && this.live.get(id) === live) this.live.delete(id);
@@ -2274,9 +2283,28 @@ export class Superagent {
2274
2283
  }
2275
2284
  }
2276
2285
 
2277
- private disconnected(live: Live): void {
2286
+ private remoteExitCanReleaseConnectionHold(lane: Lane): boolean {
2287
+ return lane.workState === "open" && this.store.getMeta(this.remoteOpenKey(lane)) === "attached"
2288
+ && !this.remoteShutdownPending(lane) && !this.modelHolds.has(lane.id)
2289
+ && !this.modelIntent(lane.id) && !this.modelIntent(lane.id, "apply")
2290
+ && !this.store.getMeta(`lane-quota-hold:${lane.id}`) && !this.kickoffHeld(lane.id)
2291
+ && !this.store.approvals(lane.id).length
2292
+ && ![...this.callbacks].some(id => this.store.approval(id)?.target === lane.id);
2293
+ }
2294
+
2295
+ private disconnected(live: Live, transportClosed = false): void {
2278
2296
  if (!this.current(live)) return;
2279
2297
  if (live.releasing) { live.lostDuringRelease = true; return; }
2298
+ const lane = live.id === "main" ? null : this.requireLane(live.id);
2299
+ const lostAttachment = transportClosed && lane?.remote && !this.blocked.has(live.id)
2300
+ && !this.connecting.has(lane.id) && !this.remoteAttaching.has(lane.id)
2301
+ && lane.generation === live.generation && lane.sessionId === live.sessionId && lane.pid !== null
2302
+ // Already-admitted prompts keep their own durable hold below. Do not
2303
+ // automatically run an older queued prompt that never belonged to this Host.
2304
+ && !live.preparing && !this.store.hasInput(lane.id, "pending")
2305
+ && (!live.input || live.admitted.size > 0)
2306
+ && this.remoteExitCanReleaseConnectionHold(lane)
2307
+ ? { generation: live.generation, sessionId: live.sessionId, pauseRevision: this.pauseRevisions.get(lane.id) } : undefined;
2280
2308
  live.unsubscribe();
2281
2309
  this.live.delete(live.id);
2282
2310
  this.blocked.add(live.id);
@@ -2296,8 +2324,8 @@ export class Superagent {
2296
2324
  }
2297
2325
  if (live.id !== "main") this.store.updateLane(live.id, live.generation, { runtimeState: "interrupted" });
2298
2326
  // Reconnect only, never launch or replay a prompt from a lost connection.
2299
- if (live.id !== "main" && this.requireLane(live.id).remote) {
2300
- this.remoteReconnect.set(live.id, { after: 0 });
2327
+ if (lane?.remote) {
2328
+ this.remoteReconnect.set(live.id, { after: 0, ...(lostAttachment && { lostAttachment }) });
2301
2329
  this.reconnectRemoteLane();
2302
2330
  return;
2303
2331
  }
@@ -2332,27 +2360,37 @@ export class Superagent {
2332
2360
  this.remoteReconnect.delete(id);
2333
2361
  continue;
2334
2362
  }
2335
- this.remoteReconnect.set(id, { ...retry, after: Date.now() + remoteReconnectIntervalMs });
2363
+ const ticket = { ...retry, after: Date.now() + remoteReconnectIntervalMs };
2364
+ this.remoteReconnect.set(id, ticket);
2336
2365
  this.connecting.add(id);
2337
2366
  this.background((async () => {
2338
2367
  let wake = false;
2339
2368
  try {
2340
2369
  const inspection = await this.inspectRemote(lane);
2341
- if (this.stopped || this.restartFence() || this.live.has(id)) return;
2370
+ if (this.stopped || this.restartFence() || this.live.has(id) || this.remoteReconnect.get(id) !== ticket) return;
2342
2371
  if (!inspection.probe.socket) {
2343
- const shutdownPending = this.remoteShutdownPending(lane);
2344
- if (this.recordRemoteExit(lane, inspection.probe)) {
2372
+ const { probe } = inspection;
2373
+ const current = this.requireLane(id);
2374
+ const shutdownPending = this.remoteShutdownPending(current);
2375
+ const detached = ticket.lostAttachment;
2376
+ const releaseConnection = detached !== undefined && detached.pauseRevision === this.pauseRevisions.get(id)
2377
+ && detached.generation === current.generation && detached.generation === probe.exitGeneration
2378
+ && detached.sessionId === current.sessionId && detached.sessionId === probe.sessionId
2379
+ && this.remoteExitCanReleaseConnectionHold(current);
2380
+ if (this.recordRemoteExit(lane, probe)) {
2345
2381
  if (retry.preflight) {
2346
- if (!await this.adapters.workerPlacementReady(inspection.registration, workerRef(lane))) return;
2382
+ if (!await this.workerLaneReady(lane, inspection)) return;
2347
2383
  if (this.stopped || this.restartFence() || this.live.has(id)
2348
- || this.requireLane(id).generation !== lane.generation) return;
2384
+ || this.requireLane(id).generation !== lane.generation || this.remoteReconnect.get(id) !== ticket) return;
2349
2385
  // Only a read-only preflight failed, so it remains safe for the
2350
2386
  // normal queue (not this reconciler) to authorize the first open.
2351
2387
  this.modelHolds.delete(id);
2352
2388
  this.blocked.delete(id);
2353
2389
  }
2354
2390
  this.remoteReconnect.delete(id);
2355
- if (shutdownPending) this.blocked.delete(id);
2391
+ // Only the lost transport hold is discharged by this exact exit.
2392
+ // Any new input uses the ordinary queue; never relaunch or replay here.
2393
+ if (shutdownPending || releaseConnection) this.blocked.delete(id);
2356
2394
  wake = true; // Other lanes can use the newly confirmed capacity.
2357
2395
  }
2358
2396
  return; // Never open a new generation during reconnect.
@@ -4893,7 +4931,7 @@ export class Superagent {
4893
4931
  if (remote ? !this.recordRemoteExit(lane, remote.probe) : !this.recordLocalExit(lane))
4894
4932
  throw new Error(`Lane ${lane.id} process is alive or ownership/transcript is unknown; refusing duplicate launch`);
4895
4933
  if (this.remoteOpenPending(lane) && authorizedResume === undefined) return null;
4896
- if (remote && !await this.adapters.workerPlacementReady(remote.registration, workerRef(lane)))
4934
+ if (remote && !await this.workerLaneReady(lane, remote))
4897
4935
  throw new Error(`Lane ${lane.id} remains queued: worker workspace or free capacity is not verified`);
4898
4936
  const hasTranscript = remote ? remote.probe.sessionFile : existsSync(lane.sessionFile);
4899
4937
  let pendingModelChange = this.modelIntent(lane.id);
@@ -7554,6 +7592,9 @@ export class Superagent {
7554
7592
  if (input.target !== "main") {
7555
7593
  const lane = this.store.lane(input.target);
7556
7594
  if (!lane || lane.workState !== "open") continue;
7595
+ // A released SSH transport is separate from the old admission's
7596
+ // effect fence. Do not start a replacement for an input still held.
7597
+ if (lane.remote && !live && heldTargets.has(input.target)) continue;
7557
7598
  live = await this.ensureLane(lane) ?? undefined;
7558
7599
  }
7559
7600
  if (!live || live.id === "main" && headWaitingForEvidence) continue;
@@ -7724,7 +7765,7 @@ export class Superagent {
7724
7765
  // A parent handoff and a thread-origin handoff can now report to the
7725
7766
  // same thread without belonging to the same manager conversation.
7726
7767
  return routeKey(activeSource.route) === routeKey(nextSource.route)
7727
- || this.store.getMeta(`handoff-reply:${owner.id}`) === null && this.store.getMeta(`handoff-reply:${input.id}`) === null;
7768
+ || !this.store.parentThreadReply(owner, activeSource) && !this.store.parentThreadReply(input, nextSource);
7728
7769
  }
7729
7770
  // A verified kickoff can originate in the parent conversation, but its
7730
7771
  // cohort must still answer on the exact thread of the ordinary followup.
@@ -1003,7 +1003,7 @@ export class Store implements StorePort {
1003
1003
  }
1004
1004
 
1005
1005
  private laneReportSources(receiptId: string, input: InputRecord, source: InputRecord): Readonly<Record<string, string>> {
1006
- const approvalSource = this.getMeta(`handoff-reply:${input.id}`) !== null ? source : this.reportApprovalSource(input.id);
1006
+ const approvalSource = this.parentThreadReply(input, source) ? source : this.reportApprovalSource(input.id);
1007
1007
  return {
1008
1008
  [`activity-source:${receiptId}`]: source.id,
1009
1009
  // Redirect the mediated report, not native approvals raised during review.
@@ -1409,21 +1409,33 @@ export class Store implements StorePort {
1409
1409
  if (scoped.sourceId !== source.id) throw new Error(`Invalid scoped Discord reply source: ${input.id}`);
1410
1410
  return input.route;
1411
1411
  }
1412
+ const parentReply = this.parentThreadReply(input, source);
1413
+ if (parentReply) return parentReply;
1414
+ const pinned = this.getMeta(`steering-topic-reply:${input.id}`);
1415
+ return pinned ? JSON.parse(pinned) : this.deliveryRoute(source);
1416
+ }
1417
+
1418
+ parentThreadReply(input: InputRecord, source: InputRecord): Route | null {
1412
1419
  const handoffReply = this.getMeta(`handoff-reply:${input.id}`);
1420
+ const kickoffId = `${source.id}:kickoff`;
1421
+ // Native thread creation has its own delivery binding; do not reinterpret
1422
+ // its approval routing as existing-thread placement.
1423
+ const opening = input.id === `handoff:${source.id}:lane` && this.getMeta(`kickoff-output:${input.id}`) === kickoffId
1424
+ && this.getMeta(`handoff-native:${source.id}`) !== "true";
1425
+ if (handoffReply === null && !opening) return null;
1426
+ const { route } = input;
1427
+ const fromExactParent = input.target && source.target === "main" && !source.pickerSelection
1428
+ && this.getMeta(`handoff-source:${input.id}`) === source.id && this.getMeta(`user-source:${source.id}`) === "true"
1429
+ && route.platform === "discord" && route.guildId && route.threadId && route.topicId === undefined
1430
+ && routeKey({ ...route, threadId: null }) === routeKey(source.route) && this.laneForRoute(route)?.id === input.target;
1413
1431
  if (handoffReply !== null) {
1414
- const { route } = input;
1415
- if (!input.target || input.id !== `handoff:${source.id}:${input.target}`
1416
- || this.getMeta(`handoff-source:${input.id}`) !== source.id
1417
- || source.target !== "main" || source.pickerSelection || this.getMeta(`user-source:${source.id}`) !== "true"
1418
- || route.platform !== "discord" || !route.guildId || !route.threadId || route.topicId !== undefined
1419
- || routeKey(route) !== handoffReply || routeKey({ ...route, threadId: null }) !== routeKey(source.route)
1420
- || this.laneForRoute(route)?.id !== input.target) {
1432
+ if (!fromExactParent || input.id !== `handoff:${source.id}:${input.target}` || routeKey(route) !== handoffReply)
1421
1433
  throw new Error(`Invalid existing-thread delivery binding: ${input.id}`);
1422
- }
1423
1434
  return route;
1424
1435
  }
1425
- const pinned = this.getMeta(`steering-topic-reply:${input.id}`);
1426
- return pinned ? JSON.parse(pinned) : this.deliveryRoute(source);
1436
+ if (!fromExactParent) return null;
1437
+ const kickoff = this.output(kickoffId);
1438
+ return kickoff?.state === "sent" && kickoff.sourceId === input.id && routeKey(kickoff.route) === routeKey(route) ? route : null;
1427
1439
  }
1428
1440
 
1429
1441
  private deliveryRoute(source: InputRecord, expectedLane?: string | null): Route {
@@ -1,7 +1,8 @@
1
1
  import { closeSync, constants, fstatSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
2
- import { isAbsolute, join, relative, sep } from "node:path";
3
- import { gitWorkerRepository, workerRepositoryHead, workerRepositoryIdentity } from "./worker-repository";
2
+ import { dirname, isAbsolute, join, relative, sep } from "node:path";
3
+ import { gitWorkerRepository, workerIndexHasOrdinaryFiles, workerMemoryRepositoryMatches, workerRepositoryHead, workerRepositoryIdentity } from "./worker-repository";
4
4
  import { WorkerRefusal } from "./worker-request";
5
+ import { trustedWorkerPath } from "./worker-trust";
5
6
  import type { WorkerLaneRef, WorkerPolicy, WorkerRepo } from "./worker-wire";
6
7
 
7
8
  export function privateWorkerDirectory(directory: string, create = false): boolean {
@@ -37,10 +38,43 @@ export async function enrolledRepo(policy: WorkerPolicy, repo: WorkerRepo): Prom
37
38
  return gitPath;
38
39
  }
39
40
 
40
- export async function boundWorkspace(repo: WorkerRepo, ref: Pick<WorkerLaneRef, "revision" | "subdir">): Promise<string> {
41
+ /** Durable identity of the enrolled physical checkout, not its mutable documents. */
42
+ export function workerCheckoutIdentity(repoRoot: string, gitDir: string, cwd: string): string | null {
43
+ const uid = process.getuid?.();
44
+ if (uid === undefined || !within(repoRoot, cwd)) return null;
45
+ try {
46
+ trustedWorkerPath(repoRoot, [], "directory");
47
+ for (let dir = cwd; dir !== repoRoot; dir = dirname(dir)) {
48
+ const stat = lstatSync(dir, { throwIfNoEntry: false });
49
+ if (!stat?.isDirectory() || stat.uid !== uid || (stat.mode & 0o022) !== 0) return null;
50
+ }
51
+ const identities = [repoRoot, gitDir, cwd].map(path => {
52
+ const stat = lstatSync(path, { bigint: true, throwIfNoEntry: false });
53
+ return stat?.isDirectory() && stat.uid === BigInt(uid) && (stat.mode & 0o022n) === 0n
54
+ && realpathSync(path) === path ? `${stat.dev}:${stat.ino}` : null;
55
+ });
56
+ return identities.includes(null) ? null : identities.join("/");
57
+ } catch (error) {
58
+ if (error instanceof WorkerRefusal || error instanceof Error && "code" in error
59
+ && ["ENOENT", "ENOTDIR", "EACCES", "ELOOP"].includes(String(error.code))) return null;
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ export async function boundWorkspace(repo: WorkerRepo, ref: Pick<WorkerLaneRef, "revision" | "subdir">,
65
+ continuation?: { readonly gitDir: string; readonly checkoutIdentity: string }): Promise<string> {
41
66
  const cwd = join(repo.cwd, ref.subdir);
42
67
  if (!lstatSync(cwd, { throwIfNoEntry: false })?.isDirectory() || realpathSync(cwd) !== cwd || !within(repo.cwd, cwd))
43
68
  throw new WorkerRefusal("Worker subdirectory is not a canonical directory inside its enrolled checkout");
69
+ if (continuation) {
70
+ const { gitDir, checkoutIdentity } = continuation;
71
+ const unchanged = () => workerCheckoutIdentity(repo.cwd, gitDir, cwd) === checkoutIdentity;
72
+ // Like the clean preflight, check the exact Git binding after the asynchronous index scan.
73
+ if (!unchanged() || !await workerIndexHasOrdinaryFiles(repo.cwd, gitDir)
74
+ || !await workerMemoryRepositoryMatches(cwd, { ...ref, repoId: repo.id, repoRoot: repo.cwd, gitDir }) || !unchanged())
75
+ throw new WorkerRefusal("Worker continuation no longer matches the original checkout and Git revision");
76
+ return cwd;
77
+ }
44
78
  const observed = await workerRepositoryHead(cwd);
45
79
  if (!observed || observed.repoId !== repo.id || observed.revision !== ref.revision || observed.subdir !== ref.subdir)
46
80
  throw new WorkerRefusal("Worker checkout must be clean at the exact requested Git revision and subdirectory");
@@ -65,7 +99,7 @@ function readClaim(gitDir: string) {
65
99
  } finally { closeSync(fd); }
66
100
  }
67
101
 
68
- function syncDirectory(path: string): void {
102
+ export function syncDirectory(path: string): void {
69
103
  const fd = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
70
104
  try { fsyncSync(fd); } finally { closeSync(fd); }
71
105
  }
@@ -1,11 +1,12 @@
1
- import { constants, closeSync, fstatSync, lstatSync, openSync, readFileSync, unlinkSync, type Stats } from "node:fs";
1
+ import { constants, closeSync, fstatSync, lstatSync, mkdirSync, openSync, readSync, unlinkSync, type Stats } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { Value } from "@sinclair/typebox/value";
4
4
  import { HostConnection } from "../omp/host";
5
5
  import { NativeJournalFormatError, readNativeSessionId } from "../omp/native-journal";
6
- import { ownsCheckout, privateWorkerDirectory } from "./worker-checkout";
7
- import { workerExit, type WorkerIdentity, type WorkerLedger, type WorkerReceipt } from "./worker-ledger";
6
+ import { ownsCheckout, privateWorkerDirectory, syncDirectory } from "./worker-checkout";
7
+ import { workerExit, workerReaped, type WorkerIdentity, type WorkerJournalDirectory, type WorkerLedger, type WorkerReceipt } from "./worker-ledger";
8
8
  import { WorkerRefusal } from "./worker-request";
9
+ import { trustedWorkerPath } from "./worker-trust";
9
10
  import { remoteLanePaths, type WorkerPolicy, type WorkerProbe } from "./worker-wire";
10
11
 
11
12
  export const WORKER_ATTEMPT_ENV = "OMP_SUPERAGENT_WORKER_ATTEMPT";
@@ -14,18 +15,51 @@ export const WORKER_SESSION_ENV = "OMP_SUPERAGENT_WORKER_EXPECTED_SESSION";
14
15
  export function workerPaths(policy: WorkerPolicy, laneId: string) {
15
16
  const { socketPath, sessionFile } = remoteLanePaths(policy, laneId);
16
17
  if (Buffer.byteLength(socketPath) > 100) throw new WorkerRefusal("Worker socket path exceeds 100 bytes");
17
- return { socketPath, sessionFile, exitPath: `${socketPath}.exit.json`, logPath: join(dirname(socketPath), `${laneId}.log`) };
18
+ return { socketPath, sessionFile, exitPath: `${socketPath}.exit.json`, reapedPath: `${socketPath}.reaped.json`,
19
+ logPath: join(dirname(socketPath), `${laneId}.log`) };
18
20
  }
19
21
  type WorkerPaths = ReturnType<typeof workerPaths>;
20
22
  type WorkerFiles = Awaited<ReturnType<typeof readWorkerFiles>>;
21
23
 
22
- function checkedFile(path: string): Stats | undefined {
24
+ function checkedFile(path: string, privateJournal = false): Stats | undefined {
23
25
  const stat = lstatSync(path, { throwIfNoEntry: false });
24
- if (stat && (!stat.isFile() || stat.uid !== process.getuid?.() || (stat.mode & 0o022) !== 0))
26
+ if (stat && (!stat.isFile() || stat.uid !== process.getuid?.()
27
+ || (privateJournal ? stat.nlink !== 1 || (stat.mode & 0o7111) !== 0 : (stat.mode & 0o022) !== 0)))
25
28
  throw new WorkerRefusal("Worker session or exit record is not an owned regular file");
26
29
  return stat;
27
30
  }
28
31
 
32
+ function checkedJournalDirectory(path: string, expected?: WorkerJournalDirectory): WorkerJournalDirectory {
33
+ if (!privateWorkerDirectory(path)) throw new WorkerRefusal("Private worker journal directory is missing");
34
+ trustedWorkerPath(path, [], "directory");
35
+ const { dev, ino } = lstatSync(path, { bigint: true });
36
+ const actual = { dev: dev.toString(), ino: ino.toString() };
37
+ if (expected && (actual.dev !== expected.dev || actual.ino !== expected.ino))
38
+ throw new WorkerRefusal("Private worker journal directory changed");
39
+ return actual;
40
+ }
41
+
42
+ /** An existing directory is not proof that the worker exclusively created it. */
43
+ export function prepareWorkerJournalDirectory(paths: WorkerPaths, expected?: WorkerJournalDirectory): WorkerJournalDirectory | undefined {
44
+ const path = dirname(paths.sessionFile);
45
+ if (expected) return checkedJournalDirectory(path, expected);
46
+ trustedWorkerPath(dirname(path), [], "directory");
47
+ try { mkdirSync(path, { mode: 0o700 }); }
48
+ catch (error) {
49
+ if (!(error instanceof Error && "code" in error && error.code === "EEXIST")) throw error;
50
+ if (!privateWorkerDirectory(path)) throw new WorkerRefusal("Worker journal directory changed during preparation");
51
+ return undefined; // Keep legacy file-permission checks; never adopt the namespace.
52
+ }
53
+ const directory = checkedJournalDirectory(path);
54
+ syncDirectory(dirname(path)); // Persist the new namespace before the ledger can attest it.
55
+ return directory;
56
+ }
57
+
58
+ function checkedJournal(paths: WorkerPaths, directory?: WorkerJournalDirectory): Stats | undefined {
59
+ if (directory) checkedJournalDirectory(dirname(paths.sessionFile), directory);
60
+ return checkedFile(paths.sessionFile, directory !== undefined);
61
+ }
62
+
29
63
  function checkedSocket(path: string): Stats | undefined {
30
64
  const stat = lstatSync(path, { throwIfNoEntry: false });
31
65
  if (stat && (!stat.isSocket() || stat.uid !== process.getuid?.() || (stat.mode & 0o777) !== 0o600))
@@ -37,6 +71,10 @@ function sameFile(expected: Pick<Stats, "dev" | "ino">, observed: Stats | undefi
37
71
  return observed !== undefined && expected.dev === observed.dev && expected.ino === observed.ino;
38
72
  }
39
73
 
74
+ function permissionDenied(error: unknown): boolean {
75
+ return error instanceof Error && "code" in error && (error.code === "EACCES" || error.code === "EPERM");
76
+ }
77
+
40
78
  function pidAlive(pid: number): boolean {
41
79
  try { process.kill(pid, 0); return true; }
42
80
  catch (error) {
@@ -46,45 +84,89 @@ function pidAlive(pid: number): boolean {
46
84
  }
47
85
  }
48
86
 
49
- export async function readWorkerFiles(paths: WorkerPaths) {
87
+ export async function readWorkerFiles(paths: WorkerPaths, directory?: WorkerJournalDirectory) {
50
88
  privateWorkerDirectory(dirname(paths.socketPath));
51
89
  privateWorkerDirectory(dirname(dirname(paths.sessionFile)));
52
90
  privateWorkerDirectory(dirname(paths.sessionFile));
53
91
  const socket = checkedSocket(paths.socketPath);
54
92
  const exit = checkedFile(paths.exitPath);
55
- const session = checkedFile(paths.sessionFile);
93
+ const session = checkedJournal(paths, directory);
56
94
  let sessionId: string | null = null;
57
95
  if (session) {
58
96
  try { sessionId = await readNativeSessionId(paths.sessionFile, session) ?? null; }
59
97
  catch (error) {
60
- if (!(error instanceof NativeJournalFormatError)) throw error;
61
98
  // A present but unrecognized journal is not an absent native session.
99
+ if (error instanceof NativeJournalFormatError) sessionId = null;
100
+ else if (permissionDenied(error))
101
+ throw new WorkerRefusal("Worker native journal cannot be read", { cause: error });
102
+ else throw error;
62
103
  }
63
- if (!sameFile(session, checkedFile(paths.sessionFile))) throw new WorkerRefusal("Worker journal changed while reading its identity");
104
+ if (!sameFile(session, checkedJournal(paths, directory))) throw new WorkerRefusal("Worker journal changed while reading its identity");
64
105
  }
65
106
  return { socket, exit, session, sessionId };
66
107
  }
67
108
 
68
- function provenExit(paths: WorkerPaths, files: WorkerFiles, receipt: WorkerReceipt) {
69
- if (!files.exit || !files.sessionId || files.exit.size > 4096 || (files.exit.mode & 0o077) !== 0) return null;
70
- const fd = openSync(paths.exitPath, constants.O_RDONLY | constants.O_NOFOLLOW);
109
+ function readExitRecord(path: string, expected: Stats | undefined): unknown {
110
+ if (!expected || expected.size > 4096 || (expected.mode & 0o477) !== 0o400) return null;
111
+ let fd: number;
112
+ try { fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK); }
113
+ catch (error) {
114
+ if (permissionDenied(error)) return null;
115
+ throw error;
116
+ }
71
117
  try {
72
118
  const stat = fstatSync(fd);
73
- if (!sameFile(files.exit, stat) || stat.size !== files.exit.size) return null;
74
- let exit: unknown;
75
- try { exit = JSON.parse(readFileSync(fd, "utf8")); }
119
+ if (!sameFile(expected, stat) || stat.size !== expected.size || stat.mode !== expected.mode) return null;
120
+ const bytes = Buffer.alloc(stat.size);
121
+ if (readSync(fd, bytes) !== bytes.length) return null;
122
+ const after = fstatSync(fd);
123
+ if (after.size !== stat.size || after.mtimeMs !== stat.mtimeMs || after.ctimeMs !== stat.ctimeMs) return null;
124
+ try { return JSON.parse(bytes.toString("utf8")); }
76
125
  catch (error) {
77
126
  if (error instanceof SyntaxError) return null;
78
127
  throw error;
79
128
  }
80
- if (!Value.Check(workerExit, exit) || exit.workerAttempt !== receipt.attempt || exit.sessionFile !== paths.sessionFile
81
- || exit.sessionId !== files.sessionId || receipt.sessionId !== null && exit.sessionId !== receipt.sessionId
82
- || receipt.phase === "live" && (exit.pid !== receipt.identity.pid || exit.ownerPid !== receipt.identity.ownerPid)
83
- || exit.pid === exit.ownerPid) return null;
84
- return exit;
85
129
  } finally { closeSync(fd); }
86
130
  }
87
131
 
132
+ function matchesExit(paths: WorkerPaths, receipt: WorkerReceipt, proof: {
133
+ readonly workerAttempt: string; readonly sessionFile: string; readonly pid: number; readonly ownerPid: number;
134
+ }): boolean {
135
+ return proof.workerAttempt === receipt.attempt && proof.sessionFile === paths.sessionFile && proof.pid !== proof.ownerPid
136
+ && (receipt.phase !== "live" || (proof.pid === receipt.identity.pid && proof.ownerPid === receipt.identity.ownerPid));
137
+ }
138
+
139
+ function readVerifiedExit(paths: WorkerPaths, receipt: WorkerReceipt, stat: Stats | undefined) {
140
+ const exit = readExitRecord(paths.exitPath, stat);
141
+ return Value.Check(workerExit, exit) && matchesExit(paths, receipt, exit)
142
+ && (receipt.sessionId === null || exit.sessionId === receipt.sessionId) ? exit : null;
143
+ }
144
+
145
+ function journalHeld() {
146
+ return new WorkerRefusal("Worker checkout was released after verified process exit; the original journal remains unverified and cannot reopen");
147
+ }
148
+
149
+ /** The private owner's receipt, not the damaged journal, decides checkout-only retirement. */
150
+ function retireWithoutJournal(ledger: WorkerLedger, paths: WorkerPaths, receipt: WorkerReceipt): boolean {
151
+ if (receipt.phase !== "launching" && receipt.phase !== "live") return false;
152
+ const proof = () => {
153
+ if (!privateWorkerDirectory(dirname(paths.socketPath)) || lstatSync(paths.socketPath, { throwIfNoEntry: false })) return null;
154
+ const reaped = readExitRecord(paths.reapedPath, checkedFile(paths.reapedPath));
155
+ if (Value.Check(workerReaped, reaped) && matchesExit(paths, receipt, reaped)
156
+ && (receipt.phase === "launching" || reaped.settledSessionId === receipt.identity.sessionId)) return reaped;
157
+ // Before attachment, no managed work could have been submitted. An old
158
+ // exit receipt proves process exit, but not settlement of an attached lane.
159
+ return receipt.phase === "launching" ? readVerifiedExit(paths, receipt, checkedFile(paths.exitPath)) : null;
160
+ };
161
+ const before = proof();
162
+ if (!before || pidAlive(before.pid) || pidAlive(before.ownerPid)) return false;
163
+ return ledger.retire(receipt, { journalHeld: true, cleanup: () => {
164
+ const current = proof();
165
+ if (!current || JSON.stringify(current) !== JSON.stringify(before) || pidAlive(before.pid) || pidAlive(before.ownerPid))
166
+ throw new WorkerRefusal("Worker process exit evidence changed before checkout retirement");
167
+ } });
168
+ }
169
+
88
170
  export function absentWorkerHost(files: WorkerFiles, receipt: WorkerReceipt | null): WorkerProbe {
89
171
  const expected = receipt?.sessionId ?? null;
90
172
  const uncertain = !!files.socket || files.sessionId !== expected || !!files.session !== (expected !== null)
@@ -111,7 +193,13 @@ export async function attestWorkerHost(paths: WorkerPaths, files: WorkerFiles, r
111
193
  }
112
194
 
113
195
  export async function inspectWorkerHost(ledger: WorkerLedger, paths: WorkerPaths, receipt: WorkerReceipt | null, attest = true): Promise<WorkerProbe> {
114
- const files = await readWorkerFiles(paths);
196
+ if (receipt?.phase === "checkout-released") throw journalHeld();
197
+ let files: WorkerFiles;
198
+ try { files = await readWorkerFiles(paths, receipt?.journalDirectory); }
199
+ catch (error) {
200
+ if (error instanceof WorkerRefusal && receipt && retireWithoutJournal(ledger, paths, receipt)) throw journalHeld();
201
+ throw error;
202
+ }
115
203
  if (!receipt || receipt.phase === "released") return absentWorkerHost(files, receipt);
116
204
  if (receipt.phase === "reserved") {
117
205
  const untouched = absentWorkerHost(files, receipt);
@@ -119,14 +207,15 @@ export async function inspectWorkerHost(ledger: WorkerLedger, paths: WorkerPaths
119
207
  return untouched;
120
208
  return { ...untouched, uncertain: true };
121
209
  }
122
- const exit = provenExit(paths, files, receipt);
210
+ const recorded = readVerifiedExit(paths, receipt, files.exit);
211
+ const exit = recorded && recorded.sessionId === files.sessionId ? recorded : null;
123
212
  const pid = receipt.phase === "live" ? receipt.identity.pid : exit?.pid ?? null;
124
213
  const owner = receipt.phase === "live" ? receipt.identity.ownerPid : exit?.ownerPid ?? null;
125
214
  const nativeAlive = pid !== null && pidAlive(pid);
126
215
  const ownerAlive = owner !== null && pidAlive(owner);
127
216
  if (exit && !nativeAlive && !ownerAlive && (!files.socket || receipt.phase === "live" && sameFile(receipt.identity, files.socket))) {
128
217
  const cleanup = () => {
129
- if (!files.session || !sameFile(files.session, checkedFile(paths.sessionFile))
218
+ if (!files.session || !sameFile(files.session, checkedJournal(paths, receipt.journalDirectory))
130
219
  || !files.exit || !sameFile(files.exit, checkedFile(paths.exitPath))
131
220
  || pidAlive(exit.pid) || pidAlive(exit.ownerPid)) throw new WorkerRefusal("Worker native exit evidence changed");
132
221
  const socket = checkedSocket(paths.socketPath);
@@ -139,6 +228,7 @@ export async function inspectWorkerHost(ledger: WorkerLedger, paths: WorkerPaths
139
228
  return { socket: false, sessionFile: true, sessionId: exit.sessionId, pid: null, pidAlive: false, ownerAlive: false,
140
229
  uncertain: false, ...(clean ? { exitGeneration: receipt.generation } : {}) };
141
230
  }
231
+ if (!exit && !files.socket && retireWithoutJournal(ledger, paths, receipt)) throw journalHeld();
142
232
  if (attest && files.socket && !exit) {
143
233
  try {
144
234
  const identity = await attestWorkerHost(paths, files, receipt);
@@ -30,6 +30,13 @@ export const workerExit = Type.Object({
30
30
  persisted: Type.Literal(true),
31
31
  observationsFlushed: Type.Literal(true),
32
32
  });
33
+ export const workerReaped = Type.Object({
34
+ pid: workerPid, ownerPid: workerPid, sessionFile: identityFields.sessionFile,
35
+ workerAttempt: Type.String(), settledSessionId: Type.Optional(sessionId),
36
+ });
37
+
38
+ const journalDirectory = Type.Object({ dev: Type.String({ pattern: "^[0-9]+$" }), ino: Type.String({ pattern: "^[0-9]+$" }) });
39
+ export type WorkerJournalDirectory = Readonly<Static<typeof journalDirectory>>;
33
40
  const receiptFields = {
34
41
  laneId: Type.String(),
35
42
  generation: Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
@@ -42,6 +49,8 @@ const receiptFields = {
42
49
  attempt: Type.String({ pattern: "^[0-9a-f-]{36}$" }),
43
50
  launcherPid: workerPid,
44
51
  sessionId: Type.Union([sessionId, Type.Null()]),
52
+ journalDirectory: Type.Optional(journalDirectory),
53
+ checkoutIdentity: Type.Optional(Type.String({ pattern: "^[0-9]+:[0-9]+/[0-9]+:[0-9]+/[0-9]+:[0-9]+$" })),
45
54
  memory: Type.Optional(workerMemoryBinding),
46
55
  privateMemoryPrepared: Type.Optional(Type.Literal(true)),
47
56
  };
@@ -50,11 +59,15 @@ const receipt = Type.Union([
50
59
  Type.Object({ ...receiptFields, phase: Type.Literal("launching") }),
51
60
  Type.Object({ ...receiptFields, phase: Type.Literal("live"), identity }),
52
61
  Type.Object({ ...receiptFields, phase: Type.Literal("released"), exitVerified: Type.Optional(Type.Literal(true)) }),
62
+ Type.Object({ ...receiptFields, phase: Type.Literal("checkout-released") }),
53
63
  ]);
54
64
  export type WorkerReceipt = Readonly<Static<typeof receipt>>;
55
65
  export type WorkerIdentity = Readonly<Static<typeof identity>>;
56
66
  type ReservedReceipt = Extract<WorkerReceipt, { phase: "reserved" }>;
67
+ type Retirement = { readonly sessionId: string; readonly clean: boolean; readonly cleanup: () => void }
68
+ | { readonly journalHeld: true; readonly cleanup: () => void };
57
69
  type WorkerSeal = Pick<WorkerLaneRef, "generation" | "repoId" | "revision" | "subdir"> & { readonly repoRoot: string };
70
+ const occupied = "phase NOT IN ('released', 'checkout-released')";
58
71
 
59
72
  function decode(row: { readonly data: string } | null): WorkerReceipt | null {
60
73
  if (!row) return null;
@@ -113,7 +126,7 @@ export class WorkerLedger {
113
126
  }
114
127
 
115
128
  active(): WorkerReceipt[] {
116
- return this.#db.query<{ data: string }, []>("SELECT data FROM worker_lanes WHERE phase != 'released'")
129
+ return this.#db.query<{ data: string }, []>(`SELECT data FROM worker_lanes WHERE ${occupied}`)
117
130
  .all().flatMap(row => decode(row) ?? []);
118
131
  }
119
132
 
@@ -161,10 +174,12 @@ export class WorkerLedger {
161
174
  if (current && (current.phase !== "released" || current.generation >= ref.generation)
162
175
  || current?.attempt !== previous?.attempt || current?.phase !== previous?.phase)
163
176
  throw new WorkerRefusal("Worker lane generation is already reserved or no longer current");
164
- const active = this.#db.query<{ count: number }, []>("SELECT count(*) AS count FROM worker_lanes WHERE phase != 'released'").get();
177
+ const active = this.#db.query<{ count: number }, []>(`SELECT count(*) AS count FROM worker_lanes WHERE ${occupied}`).get();
165
178
  if (!active || active.count >= this.#capacity) throw new WorkerRefusal("Worker Host capacity is occupied");
166
179
  const value: ReservedReceipt = { ...ref, ...binding, attempt: crypto.randomUUID(), launcherPid: process.pid,
167
- phase: "reserved", sessionId: current?.sessionId ?? null };
180
+ phase: "reserved", sessionId: current?.sessionId ?? null,
181
+ ...(current?.journalDirectory && { journalDirectory: current.journalDirectory }),
182
+ ...(current?.checkoutIdentity && { checkoutIdentity: current.checkoutIdentity }) };
168
183
  this.#write(value);
169
184
  return value;
170
185
  }).immediate();
@@ -183,15 +198,19 @@ export class WorkerLedger {
183
198
  return this.#replaceCurrent(current, () => next);
184
199
  }
185
200
 
186
- retire(current: WorkerReceipt, exit?: { readonly sessionId: string; readonly clean: boolean; readonly cleanup: () => void }): boolean {
201
+ retire(current: WorkerReceipt, exit?: Retirement): boolean {
187
202
  return this.#replaceCurrent(current, () => {
188
203
  exit?.cleanup();
189
204
  releaseCheckout(current);
190
- const { laneId, generation, repoId, revision, subdir, repoRoot, gitDir, attempt, launcherPid, launchDigest, memory } = current;
191
- const sessionId = exit?.sessionId ?? current.sessionId;
192
- return { laneId, generation, repoId, revision, subdir, repoRoot, gitDir, attempt, launcherPid, launchDigest,
193
- phase: "released", sessionId, ...(sessionId !== null && memory ? { memory } : {}),
194
- ...(exit?.clean && { exitVerified: true }) };
205
+ const { laneId, generation, repoId, revision, subdir, repoRoot, gitDir, attempt, launcherPid, launchDigest,
206
+ journalDirectory, checkoutIdentity, memory } = current;
207
+ const verified = exit && "sessionId" in exit ? exit : undefined;
208
+ const sessionId = verified?.sessionId ?? current.sessionId;
209
+ const binding = { laneId, generation, repoId, revision, subdir, repoRoot, gitDir, attempt, launcherPid, launchDigest,
210
+ sessionId, ...(journalDirectory && { journalDirectory }), ...(checkoutIdentity && { checkoutIdentity }),
211
+ ...(sessionId !== null && memory ? { memory } : {}) };
212
+ if (exit && "journalHeld" in exit) return { ...binding, phase: "checkout-released" };
213
+ return { ...binding, phase: "released", ...(verified?.clean && { exitVerified: true }) };
195
214
  });
196
215
  }
197
216
  }
@@ -272,6 +272,19 @@ async function* gitRecords(root: string, args: readonly string[]): AsyncGenerato
272
272
  }
273
273
  }
274
274
 
275
+ /** Keep the existing non-submodule boundary without comparing worktree or index contents to HEAD. */
276
+ export async function workerIndexHasOrdinaryFiles(root: string, gitDir: string): Promise<boolean> {
277
+ const records = gitRecords(root, [`--git-dir=${gitDir}`, `--work-tree=${root}`, "ls-files", "--stage", "-z"]);
278
+ try {
279
+ for (;;) {
280
+ const record = await records.next();
281
+ if (record.done) return record.value;
282
+ const tab = record.value.indexOf(9);
283
+ if (tab < 0 || !/^(100644|100755|120000) [0-9a-f]+ [0-3]$/.test(record.value.toString("latin1", 0, tab))) return false;
284
+ }
285
+ } finally { await records.return(false); }
286
+ }
287
+
275
288
  async function matchesCommit(root: string, gitArgs: readonly string[], revision: string): Promise<boolean> {
276
289
  const index = gitRecords(root, [...gitArgs, "ls-files", "--stage", "-v", "-z"]);
277
290
  const tree = gitRecords(root, [...gitArgs, "ls-tree", "-r", "-z", revision]);
@@ -1,12 +1,12 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { lstatSync, type Stats } from "node:fs";
3
- import { dirname } from "node:path";
3
+ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { startHost } from "../omp/host";
6
- import { boundWorkspace, enrolledRepo, privateWorkerDirectory, reserveCheckout } from "./worker-checkout";
7
- import { absentWorkerHost, attestWorkerHost, inspectWorkerHost, readWorkerFiles,
6
+ import { boundWorkspace, enrolledRepo, privateWorkerDirectory, reserveCheckout, workerCheckoutIdentity } from "./worker-checkout";
7
+ import { absentWorkerHost, attestWorkerHost, inspectWorkerHost, prepareWorkerJournalDirectory, readWorkerFiles,
8
8
  WORKER_ATTEMPT_ENV, WORKER_SESSION_ENV, workerPaths } from "./worker-host";
9
- import { WorkerLedger, type WorkerReceipt } from "./worker-ledger";
9
+ import { WorkerLedger, type WorkerJournalDirectory, type WorkerReceipt } from "./worker-ledger";
10
10
  import { WORKER_MEMORY_WIRE_ENV } from "./worker-memory-storage";
11
11
  import { assertWorkerGitStartup, requireWorkerStartupFlags, workerLaunchProfile, workerManagedUlwPath } from "./worker-profile";
12
12
  import { parseWorkerPolicy, parseWorkerRequest, WorkerRefusal } from "./worker-request";
@@ -25,6 +25,7 @@ type AttachPermit = {
25
25
  readonly pid: number; readonly ownerPid: number;
26
26
  readonly socket: { readonly dev: string; readonly ino: string };
27
27
  readonly journal: { readonly dev: string; readonly ino: string };
28
+ readonly journalDirectory?: WorkerJournalDirectory;
28
29
  };
29
30
  type WorkerReply = { readonly ok: true; readonly value: unknown } | { readonly ok: false; readonly error: string };
30
31
  type WorkerPreparation = { readonly kind: "reply"; readonly reply: WorkerReply } | ({ readonly kind: "attach" } & AttachPermit);
@@ -52,9 +53,19 @@ async function describeWorker(policy: WorkerPolicy, workspace?: Workspace): Prom
52
53
  const platform = process.platform;
53
54
  if (platform !== "linux" && platform !== "darwin") throw new WorkerRefusal("Unsupported worker platform");
54
55
  const { workerId, stateDir, repos, capacity } = policy;
55
- // Keep process/Git subprocess counts bounded even when the policy lists many repos.
56
- for (const repo of repos) await enrolledRepo(policy, repo);
57
- if (workspace) await boundWorkspace(findRepo(policy, workspace.repoId), workspace);
56
+ if (workspace) {
57
+ const repo = findRepo(policy, workspace.repoId);
58
+ const gitDir = await enrolledRepo(policy, repo);
59
+ await boundWorkspace(repo, workspace);
60
+ if (lstatSync(join(stateDir, "worker.sqlite"), { throwIfNoEntry: false })) {
61
+ const service = new WorkerService(policy);
62
+ try { await service.reap({ repoId: repo.id, repoRoot: repo.cwd, gitDir }); }
63
+ finally { service.close(); }
64
+ }
65
+ } else {
66
+ // Enrollment-wide inventory still validates all its registered checkouts.
67
+ for (const repo of repos) await enrolledRepo(policy, repo);
68
+ }
58
69
  return { workerId, platform, stateDir, repos, capacity, active: WorkerLedger.count(policy) };
59
70
  }
60
71
 
@@ -82,13 +93,15 @@ class WorkerService {
82
93
  return current;
83
94
  }
84
95
 
85
- async #reap(): Promise<void> {
96
+ async reap(scope?: Pick<WorkerReceipt, "repoId" | "repoRoot" | "gitDir">): Promise<void> {
86
97
  for (const receipt of this.#ledger.active()) {
98
+ if (scope && (scope.repoId !== receipt.repoId || scope.repoRoot !== receipt.repoRoot || scope.gitDir !== receipt.gitDir)) continue;
87
99
  if (!this.#policy.repos.some(repo => repo.id === receipt.repoId && repo.cwd === receipt.repoRoot)) continue;
88
100
  try { await inspectWorkerHost(this.#ledger, workerPaths(this.#policy, receipt.laneId), receipt, false); }
89
101
  catch (error) {
90
102
  if (!(error instanceof Error)) throw error;
91
- // Damaged or unobservable evidence still consumes capacity.
103
+ // A refused inspection does not free an unverified reservation.
104
+ // Checkout-only retirement may already have committed before refusal.
92
105
  }
93
106
  }
94
107
  }
@@ -104,9 +117,30 @@ class WorkerService {
104
117
  return { ...probe, uncertain: true, pid: null, sessionId: null };
105
118
  const absent = !probe.uncertain && !probe.socket && !probe.pidAlive && !probe.ownerAlive && probe.pid === null;
106
119
  const sealed = absent && this.#ledger.confirmRelease(ref, lane.repo.cwd, { observed, reconcile });
120
+ let reopenActive: number | undefined;
121
+ const released = this.#receipt(lane);
122
+ // Released with an exact readable session is also valid after an attempt
123
+ // that reached no Host. It does not manufacture an exitGeneration for it.
124
+ if (sealed && released?.phase === "released" && released.attempt === observed?.attempt
125
+ && probe.sessionId && released.sessionId === probe.sessionId
126
+ && released.checkoutIdentity) {
127
+ try {
128
+ if (await enrolledRepo(this.#policy, lane.repo) === released.gitDir) {
129
+ await boundWorkspace(lane.repo, ref, { gitDir: released.gitDir, checkoutIdentity: released.checkoutIdentity });
130
+ const current = this.#receipt(lane);
131
+ const active = this.#ledger.active().length;
132
+ if (current?.attempt === released.attempt && current.phase === "released" && active < this.#policy.capacity)
133
+ reopenActive = active;
134
+ }
135
+ } catch (error) {
136
+ if (!(error instanceof WorkerRefusal)) throw error;
137
+ // Exit is independent of checkout readiness; keep its proof intact.
138
+ }
139
+ }
107
140
  const memoryLaunch = process.env[WORKER_MEMORY_WIRE_ENV] === "1" && absent && !probe.sessionFile && !sealed;
108
141
  return { ...probe, ...(sealed && { sealedGeneration: ref.generation }),
109
142
  ...(sealed && exitGeneration === ref.generation && { exitGeneration }),
143
+ ...(reopenActive !== undefined && { reopenActive }),
110
144
  ...(memoryLaunch && { memoryLaunchVersion: 1 }),
111
145
  ...(!probe.uncertain && probe.socket && observed?.generation === ref.generation
112
146
  && observed.privateMemoryPrepared && observed.memory?.proof && { memoryPreparedVersion: 1 }),
@@ -128,15 +162,17 @@ class WorkerService {
128
162
  return { pid: probe.pid };
129
163
  throw new WorkerRefusal("Worker lane generation has no verified live Host; it cannot reopen");
130
164
  }
131
- await this.#reap();
165
+ await this.reap();
132
166
  const previous = this.#receipt(lane);
167
+ if (previous?.phase === "checkout-released")
168
+ throw new WorkerRefusal("Worker checkout was released, but the original journal remains unverified and cannot reopen");
133
169
  if (observed?.attempt !== previous?.attempt || (previous && previous.phase !== "released"))
134
170
  throw new WorkerRefusal("Worker lane has a resident or uncertain launch");
135
171
  if (previous && ref.generation <= previous.generation)
136
172
  throw new WorkerRefusal("Worker does not reopen a previous lane generation");
137
173
  const gitDir = await enrolledRepo(this.#policy, lane.repo);
138
174
  if (previous && previous.gitDir !== gitDir) throw new WorkerRefusal("Worker checkout metadata directory changed");
139
- const initial = await readWorkerFiles(lane.paths);
175
+ const initial = await readWorkerFiles(lane.paths, previous?.journalDirectory);
140
176
  if (absentWorkerHost(initial, previous).uncertain) throw new WorkerRefusal("Worker lane has an unverified socket or journal");
141
177
  if (launch.memorySync && process.env[WORKER_MEMORY_WIRE_ENV] !== "1")
142
178
  throw new WorkerRefusal("Worker memory is not supported by this transport");
@@ -145,23 +181,43 @@ class WorkerService {
145
181
  const memoryKey = previous?.memory?.key ?? (launch.memorySync ? crypto.randomUUID() : undefined);
146
182
  // Commit admission before reserving the checkout, publishing any session
147
183
  // artifacts, or starting the stock OMP process.
148
- const reservation = this.#ledger.reserve(ref, { repoRoot: lane.repo.cwd, gitDir, launchDigest,
184
+ let reservation = this.#ledger.reserve(ref, { repoRoot: lane.repo.cwd, gitDir, launchDigest,
149
185
  ...(previous?.memory && { memory: previous.memory }) }, previous);
186
+ const continuation = previous?.phase === "released" && previous.sessionId && previous.checkoutIdentity
187
+ ? { gitDir, checkoutIdentity: previous.checkoutIdentity } : undefined;
188
+ const selected = join(lane.repo.cwd, ref.subdir);
150
189
  let cwd: string;
151
190
  let target: ReturnType<typeof workerLaunchProfile>;
152
191
  let managedUlwPath: string;
153
192
  try {
154
193
  reserveCheckout(reservation);
155
- cwd = await boundWorkspace(lane.repo, ref);
194
+ const checkoutIdentity = workerCheckoutIdentity(lane.repo.cwd, gitDir, selected);
195
+ if (previous?.checkoutIdentity && previous.checkoutIdentity !== checkoutIdentity)
196
+ throw new WorkerRefusal("Worker continuation no longer matches the original checkout directories");
197
+ cwd = await boundWorkspace(lane.repo, ref, continuation);
156
198
  await assertWorkerGitStartup(lane.repo);
157
199
  target = workerLaunchProfile(this.#policy, cwd);
158
200
  managedUlwPath = await workerManagedUlwPath(this.#policy.repos);
159
201
  await requireWorkerStartupFlags(target.executable, this.#policy.stateDir, target.env);
160
- if (absentWorkerHost(await readWorkerFiles(lane.paths), reservation).uncertain)
202
+ if (absentWorkerHost(await readWorkerFiles(lane.paths, reservation.journalDirectory), reservation).uncertain)
161
203
  throw new WorkerRefusal("Worker socket or journal changed before launch");
162
204
  privateWorkerDirectory(dirname(lane.paths.socketPath), true);
163
205
  privateWorkerDirectory(dirname(dirname(lane.paths.sessionFile)), true);
164
- privateWorkerDirectory(dirname(lane.paths.sessionFile), true);
206
+ // Authorize stock-created modes only after establishing custody of a
207
+ // new private namespace, before either SDK preparation or OMP opens it.
208
+ const directory = prepareWorkerJournalDirectory(lane.paths, reservation.journalDirectory);
209
+ if (continuation) {
210
+ await assertWorkerGitStartup(lane.repo);
211
+ await boundWorkspace(lane.repo, ref, continuation);
212
+ }
213
+ const pin = checkoutIdentity && workerCheckoutIdentity(lane.repo.cwd, gitDir, cwd) === checkoutIdentity ? checkoutIdentity : null;
214
+ if (previous?.checkoutIdentity && pin !== previous.checkoutIdentity)
215
+ throw new WorkerRefusal("Worker checkout directories changed before launch");
216
+ if ((pin && pin !== reservation.checkoutIdentity) || (directory && !reservation.journalDirectory)) {
217
+ const prepared = { ...reservation, ...(pin && { checkoutIdentity: pin }), ...(directory && { journalDirectory: directory }) };
218
+ if (!this.#ledger.transition(reservation, prepared)) throw new WorkerRefusal("Worker launch reservation is no longer current");
219
+ reservation = prepared;
220
+ }
165
221
  } catch (error) {
166
222
  this.#ledger.retire(reservation);
167
223
  throw error;
@@ -209,7 +265,7 @@ class WorkerService {
209
265
  if (receipt?.attempt !== observed.attempt || receipt.phase !== "live" ||
210
266
  !probe.socket || !probe.pidAlive || !probe.ownerAlive)
211
267
  throw new WorkerRefusal("Worker lane does not have an attachable native Host");
212
- const files = await readWorkerFiles(lane.paths);
268
+ const files = await readWorkerFiles(lane.paths, receipt.journalDirectory);
213
269
  if (!files.session) throw new WorkerRefusal("No owned worker socket/journal/checkout");
214
270
  const { pid, ownerPid, sessionId, sessionFile, ...identity } = await attestWorkerHost(lane.paths, files, receipt);
215
271
  const { socketPath } = lane.paths;
@@ -219,7 +275,8 @@ class WorkerService {
219
275
  if (current?.phase !== "live" || current.generation !== ref.generation || current.attempt !== receipt.attempt)
220
276
  throw new WorkerRefusal("Worker lane changed before attach");
221
277
  return { generation: receipt.generation, workerAttempt: receipt.attempt,
222
- socketPath, sessionFile, sessionId, pid, ownerPid, socket, journal };
278
+ socketPath, sessionFile, sessionId, pid, ownerPid, socket, journal,
279
+ ...(receipt.journalDirectory && { journalDirectory: receipt.journalDirectory }) };
223
280
  }
224
281
  }
225
282
 
@@ -39,6 +39,8 @@ export interface WorkerProbe {
39
39
  readonly sealedGeneration?: number;
40
40
  /** Exact generation whose persisted native exit the worker verified. */
41
41
  readonly exitGeneration?: number;
42
+ /** An exact exited session can reopen in its original checkout; reported occupancy is read-only. */
43
+ readonly reopenActive?: number;
42
44
  /** The wire accepts opt-in on a fresh, absent, unsealed worker lane. */
43
45
  readonly memoryLaunchVersion?: 1;
44
46
  /** Private storage was prepared for this attempt; readiness can be checked after native init. */
@@ -62,7 +64,7 @@ export const WorkerDescriptionSchema = Type.Object({
62
64
  const probe = Type.Object({
63
65
  socket: Type.Boolean(), sessionFile: Type.Boolean(), pidAlive: Type.Boolean(), ownerAlive: Type.Boolean(),
64
66
  uncertain: Type.Boolean(), pid: Type.Union([positive, Type.Null()]), sessionId: Type.Union([text, Type.Null()]),
65
- sealedGeneration: Type.Optional(positive), exitGeneration: Type.Optional(positive),
67
+ sealedGeneration: Type.Optional(positive), exitGeneration: Type.Optional(positive), reopenActive: Type.Optional(natural),
66
68
  memoryLaunchVersion: Type.Optional(Type.Literal(1)), memoryPreparedVersion: Type.Optional(Type.Literal(1)),
67
69
  memorySyncVersion: Type.Optional(Type.Literal(1)),
68
70
  });