gestalt-mobile 0.78.2 → 0.78.3

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.
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
16
16
  <link rel="icon" href="/icons/gestalt-mobile-192.png" />
17
17
  <link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
18
18
  <title>Gestalt Mobile</title>
19
- <script type="module" crossorigin src="/assets/index-C6uq_I_x.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-jLy1t3Qp.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DRiZTklh.css">
21
21
  </head>
22
22
  <body>
@@ -29,6 +29,8 @@ export function registerForgetSession(app, deps) {
29
29
  });
30
30
  if (operation.phase !== 'completed')
31
31
  return reply.code(503).send({ code: 'SESSION_FORGET_FAILED', operation });
32
+ if (operation.scratchRetained && !operation.keepFilesRequested)
33
+ reply.header('x-gestalt-scratch-retained', 'true');
32
34
  return reply.code(204).send();
33
35
  }
34
36
  if (!deps.find(id))
@@ -43,7 +43,7 @@ async function prepareReadOnlyDirectories(root, directories) {
43
43
  }
44
44
  /** Only the managed namespace is traversed. There are no prefix/age/PID legacy recognizers. */
45
45
  export class FilesystemScratchCleanup {
46
- async cleanSession(session, authorized, protectedSessions) {
46
+ async cleanSession(session, authorized, protectedSessions, { retainBorrowed = false } = {}) {
47
47
  // A retained session can outlive its workspace (including Self DEBUG).
48
48
  // Only an absent workspace is already clean; existing links and invalid
49
49
  // paths must still pass the normal canonical-path checks below.
@@ -64,9 +64,20 @@ export class FilesystemScratchCleanup {
64
64
  throw error;
65
65
  }
66
66
  }
67
- const counts = await this.cleanWorkspace(session.workspacePath, protectedSessions, mobileScratchOwnerId(session.id), authorized);
68
- if (counts.skipped || counts.failed)
67
+ const ownerId = mobileScratchOwnerId(session.id);
68
+ const counts = await this.cleanWorkspace(session.workspacePath, protectedSessions, ownerId, authorized);
69
+ const borrowed = counts.leasedMobileSessions;
70
+ if (counts.failed ||
71
+ (counts.skipped && (!retainBorrowed || counts.skipped !== borrowed.length)))
69
72
  throw new Error('SESSION_CLEANUP_FAILED');
73
+ // A missing logical owner cannot prove that its external runtime was retired.
74
+ if (process.getuid &&
75
+ (await hasRuntimeOwner({ workspacePath: session.workspacePath, ownerId }, new Set(borrowed.flatMap(({ runtimeDirectory }) => runtimeDirectory ?? [])))))
76
+ throw new Error('SESSION_CLEANUP_FAILED');
77
+ if (!authorized())
78
+ throw new Error('SESSION_CLEANUP_FAILED');
79
+ if (borrowed.length)
80
+ return 'retained';
70
81
  }
71
82
  async canonicalWorkspace(path) {
72
83
  return canonicalScratchWorkspace(path);
@@ -22,7 +22,9 @@ export class FilesystemWorkspaceForget {
22
22
  const workspace = canonicalSessionWorkspace(session.workspacePath);
23
23
  const others = knownSessions().filter((other) => other.id !== session.id);
24
24
  if (others.some((other) => canonicalSessionWorkspace(other.workspacePath) === workspace))
25
- return 'retained';
25
+ return new FilesystemScratchCleanup().cleanSession(session, authorized, knownSessions, {
26
+ retainBorrowed: true,
27
+ });
26
28
  const temporary = join(workspace, 'tmp');
27
29
  for (const other of others) {
28
30
  if (workspaceContains(temporary, canonicalSessionWorkspace(other.workspacePath)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.78.2",
3
+ "version": "0.78.3",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",