@neuralnomads/codenomad-dev 0.20.1-dev-20261011-16706ade → 0.20.1-dev-20261012-b5aae84e

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.
Files changed (40) hide show
  1. package/dist/server/routes/pending-requests.js +62 -7
  2. package/dist/server/routes/pending-requests.js.map +1 -1
  3. package/dist/server/routes/pending-requests.test.js +69 -4
  4. package/dist/server/routes/pending-requests.test.js.map +1 -1
  5. package/package.json +1 -1
  6. package/public/assets/{App-DXukWgbP.js → App-mWk5pRKM.js} +9 -9
  7. package/public/assets/App-mWk5pRKM.js.map +1 -0
  8. package/public/assets/{FilesPanel-BFXGWj46.js → FilesPanel-CKt6A8d4.js} +2 -2
  9. package/public/assets/{FilesPanel-BFXGWj46.js.map → FilesPanel-CKt6A8d4.js.map} +1 -1
  10. package/public/assets/{StatusTab-CcOsH7Ry.js → StatusTab-wsJE6W5X.js} +2 -2
  11. package/public/assets/{StatusTab-CcOsH7Ry.js.map → StatusTab-wsJE6W5X.js.map} +1 -1
  12. package/public/assets/{client-state-CZh2ozR0.js → client-state-CMFkT8xc.js} +2 -2
  13. package/public/assets/{client-state-CZh2ozR0.js.map → client-state-CMFkT8xc.js.map} +1 -1
  14. package/public/assets/{client-state-DLXfY-6f.js → client-state-DK7GeuA7.js} +2 -2
  15. package/public/assets/{client-state-DLXfY-6f.js.map → client-state-DK7GeuA7.js.map} +1 -1
  16. package/public/assets/client-state-owner-commands-wZwv79nd.js +2 -0
  17. package/public/assets/{client-state-owner-commands-CLH4E_wA.js.map → client-state-owner-commands-wZwv79nd.js.map} +1 -1
  18. package/public/assets/{diff-viewer-D91_bLf2.js → diff-viewer-UeqCGDK4.js} +2 -2
  19. package/public/assets/{diff-viewer-D91_bLf2.js.map → diff-viewer-UeqCGDK4.js.map} +1 -1
  20. package/public/assets/{main-D3DfHz1A.js → main-sB0Dj3Em.js} +4 -4
  21. package/public/assets/{main-D3DfHz1A.js.map → main-sB0Dj3Em.js.map} +1 -1
  22. package/public/assets/{markdown-DdZxzH1l.js → markdown-DZtg6AXC.js} +2 -2
  23. package/public/assets/{markdown-DdZxzH1l.js.map → markdown-DZtg6AXC.js.map} +1 -1
  24. package/public/assets/{opener-startup-state-settings-card-jeyrbzBe.js → opener-startup-state-settings-card-nnvDIySl.js} +2 -2
  25. package/public/assets/{opener-startup-state-settings-card-jeyrbzBe.js.map → opener-startup-state-settings-card-nnvDIySl.js.map} +1 -1
  26. package/public/assets/{startup-state-settings-card-BF5T7J0u.js → startup-state-settings-card-BiTockI7.js} +2 -2
  27. package/public/assets/{startup-state-settings-card-BF5T7J0u.js.map → startup-state-settings-card-BiTockI7.js.map} +1 -1
  28. package/public/assets/{startup-state-settings-view-Co9p7nlM.js → startup-state-settings-view-Bzzc1_jS.js} +2 -2
  29. package/public/assets/{startup-state-settings-view-Co9p7nlM.js.map → startup-state-settings-view-Bzzc1_jS.js.map} +1 -1
  30. package/public/assets/{terminal-square-DYbO6r3r.js → terminal-square-D6wHG6-Y.js} +2 -2
  31. package/public/assets/{terminal-square-DYbO6r3r.js.map → terminal-square-D6wHG6-Y.js.map} +1 -1
  32. package/public/assets/{tool-call-Nk9InHUG.js → tool-call-BisTNLAU.js} +4 -4
  33. package/public/assets/{tool-call-Nk9InHUG.js.map → tool-call-BisTNLAU.js.map} +1 -1
  34. package/public/assets/{unified-picker-B3s6rqiv.js → unified-picker-DfBQpWb1.js} +2 -2
  35. package/public/assets/{unified-picker-B3s6rqiv.js.map → unified-picker-DfBQpWb1.js.map} +1 -1
  36. package/public/index.html +1 -1
  37. package/public/sw.js +1 -1
  38. package/public/sw.js.map +1 -1
  39. package/public/assets/App-DXukWgbP.js.map +0 -1
  40. package/public/assets/client-state-owner-commands-CLH4E_wA.js +0 -2
@@ -96,6 +96,9 @@ export function registerPendingRequestRoutes(app, deps) {
96
96
  // Optional history whose host directory is absent: authorized by its own owned
97
97
  // identity or by an existing, canonically owned ancestor, and revalidated after RPC.
98
98
  const missing = [];
99
+ // Negative scope evidence only: these hints never authorize a native read
100
+ // or an empty queue. Preserve errors when membership is merely unknown.
101
+ const outside = [];
99
102
  // A candidate whose ownership cannot be (re)established reports its own
100
103
  // non-authoritative error; it neither fails the batch nor counts as empty.
101
104
  const failed = new Set();
@@ -114,6 +117,30 @@ export function registerPendingRequestRoutes(app, deps) {
114
117
  };
115
118
  let common;
116
119
  const workspaceCommon = () => common ??= readCommon(workspace.path);
120
+ const outsideHistory = async (candidate, expectedCommon) => {
121
+ if (!nativePath.isAbsolute(candidate))
122
+ return undefined;
123
+ const host = await manager.getHostPathForServicePath(id, candidate);
124
+ if (!host || !path.isAbsolute(host))
125
+ return undefined;
126
+ if (await missingHost(host)) {
127
+ // An absent direct child of a canonical existing parent outside this
128
+ // checkout is obsolete history, not an unavailable owned checkout.
129
+ // Missing owned descendants retain the identity/fence path below.
130
+ const rootHost = await realpath(workspace.path);
131
+ const relative = path.relative(rootHost, host);
132
+ if (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative))
133
+ return undefined;
134
+ const parent = path.dirname(host);
135
+ if (await realpath(parent) !== parent)
136
+ return undefined;
137
+ return `missing\0${host}\0${parent}`;
138
+ }
139
+ const candidateCommon = await readCommon(host);
140
+ if (candidateCommon === await expectedCommon())
141
+ return undefined;
142
+ return `foreign\0${await realpath(host)}\0${candidateCommon}`;
143
+ };
117
144
  // Lazy: the expected identity is read only once an existing ancestor needs it.
118
145
  const ownedMissingAncestor = async (candidate, expectedCommon) => {
119
146
  if (!nativePath.isAbsolute(candidate))
@@ -157,8 +184,12 @@ export function registerPendingRequestRoutes(app, deps) {
157
184
  if (!directory && optional.has(candidate)) {
158
185
  const host = await manager.getHostPathForServicePath(id, candidate);
159
186
  const owned = host && path.isAbsolute(host) && await missingHost(host) ? await ownedMissingAncestor(candidate, workspaceCommon) : undefined;
160
- if (!host || !owned)
161
- return { candidate, status: "error" };
187
+ if (!host || !owned) {
188
+ const proof = await outsideHistory(candidate, workspaceCommon);
189
+ return proof
190
+ ? { candidate, status: "excluded", outside: { submitted: candidate, proof } }
191
+ : { candidate, status: "error" };
192
+ }
162
193
  return { candidate, status: "excluded", missing: { submitted: candidate, host, ...owned } };
163
194
  }
164
195
  const identity = directory === root ? rootIdentity : directory && await manager.getWorktreeIdentityForPath(id, directory);
@@ -173,8 +204,12 @@ export function registerPendingRequestRoutes(app, deps) {
173
204
  // Containment alone cannot authorize a nested independent clone.
174
205
  const sameRepository = directory === root || await Promise.all([workspaceCommon(), readCommon(host)])
175
206
  .then(([left, right]) => left === right, () => false);
176
- if (!sameRepository)
177
- return { candidate, status: "error" };
207
+ if (!sameRepository) {
208
+ const proof = optional.has(candidate) ? await outsideHistory(candidate, workspaceCommon) : undefined;
209
+ return proof
210
+ ? { candidate, status: "excluded", outside: { submitted: candidate, directory, identity, proof } }
211
+ : { candidate, status: "error" };
212
+ }
178
213
  return { candidate, status: "ok", owned: { submitted: candidate, directory, identity } };
179
214
  }
180
215
  catch (error) {
@@ -186,8 +221,12 @@ export function registerPendingRequestRoutes(app, deps) {
186
221
  if (entry.status === "ok")
187
222
  resolved.push(entry.owned);
188
223
  else {
189
- if (entry.status === "excluded")
190
- missing.push(entry.missing);
224
+ if (entry.status === "excluded") {
225
+ if (entry.outside)
226
+ outside.push(entry.outside);
227
+ else
228
+ missing.push(entry.missing);
229
+ }
191
230
  result.directories.push({ directory: entry.candidate, status: entry.status });
192
231
  }
193
232
  }
@@ -212,7 +251,7 @@ export function registerPendingRequestRoutes(app, deps) {
212
251
  assertCurrent();
213
252
  };
214
253
  const revalidateCandidates = async () => {
215
- const currentCommon = resolved.some((candidate) => candidate.directory !== root) || missing.some((entry) => entry.ancestor)
254
+ const currentCommon = resolved.some((candidate) => candidate.directory !== root) || missing.some((entry) => entry.ancestor) || outside.length > 0
216
255
  ? await readCommon(workspace.path) : undefined;
217
256
  for (let offset = 0; offset < resolved.length; offset += 8) {
218
257
  await drainOwnershipReads(resolved.slice(offset, offset + 8).map(async (candidate) => {
@@ -253,10 +292,26 @@ export function registerPendingRequestRoutes(app, deps) {
253
292
  }
254
293
  }));
255
294
  }
295
+ for (const entry of outside) {
296
+ try {
297
+ if (await manager.getServiceDirectoryForPath(id, entry.submitted) !== entry.directory
298
+ || (entry.identity && (deps.worktreeDeletionFence.isBlocked(entry.identity)
299
+ || await manager.getWorktreeIdentityForPath(id, entry.directory) !== entry.identity))
300
+ || await outsideHistory(entry.submitted, async () => currentCommon) !== entry.proof)
301
+ failed.add(entry.submitted);
302
+ }
303
+ catch (error) {
304
+ isolate(error);
305
+ failed.add(entry.submitted);
306
+ }
307
+ }
256
308
  // A deletion that began during the awaits above still fences publication.
257
309
  for (const candidate of [...resolved, ...missing])
258
310
  if (deps.worktreeDeletionFence.isBlocked(candidate.identity))
259
311
  failed.add(candidate.submitted);
312
+ for (const candidate of outside)
313
+ if (candidate.identity && deps.worktreeDeletionFence.isBlocked(candidate.identity))
314
+ failed.add(candidate.submitted);
260
315
  assertCurrent();
261
316
  };
262
317
  assertCurrent();
@@ -1 +1 @@
1
- {"version":3,"file":"pending-requests.js","sourceRoot":"","sources":["../../../src/server/routes/pending-requests.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAA;AAGrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAA;AAElI,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACnD,MAAM,mBAAmB,GAAG,CAAC,CAAC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,KAAK,CAAC,UAAU,CAAA;YACxB,IAAI,IAAI,GAAG,kBAAkB;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YACjF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { FastifyInstance } from \"fastify\"\nimport path from \"node:path\"\nimport { lstat, realpath } from \"node:fs/promises\"\nimport { z } from \"zod\"\nimport type { FormInfo, PermissionRequest } from \"@opencode/client\"\nimport type { WorkspacePendingRequestLocation, WorkspacePendingRequestsResponse } from \"../../api-types\"\nimport { PENDING_REQUEST_SNAPSHOT_TIMEOUT_MS } from \"../../api-types\"\nimport type { WorkspaceManager } from \"../../workspaces/manager\"\nimport type { WorktreeDeletionFence } from \"../../workspaces/worktree-session-evacuation\"\nimport { readGitCommonDirectory } from \"../../workspaces/git-common-directory\"\nimport { deferPendingDiscovery, markLoadedPendingSupported, PENDING_DISCOVERY_DEFERRED } from \"../../workspaces/pending-discovery\"\n\nconst directorySchema = z.string().min(1).max(4096)\nconst directoryListSchema = z.union([directorySchema, z.array(directorySchema).min(1).max(64)])\nconst querySchema = z.object({ directories: directoryListSchema, optionalDirectories: directoryListSchema.optional() }).strict()\nconst permissionSchema = z.object({\n id: z.string(), sessionID: z.string(), action: z.string(), resources: z.array(z.string()),\n save: z.array(z.string()).optional(), metadata: z.record(z.unknown()).optional(), message: z.string().optional(),\n source: z.object({ type: z.literal(\"tool\"), messageID: z.string(), id: z.string() }).optional(),\n})\nconst numeric = z.union([z.number(), z.enum([\"Infinity\", \"-Infinity\", \"NaN\"])])\nconst option = z.object({ value: z.string(), label: z.string(), description: z.string().optional() })\nconst field = z.object({\n key: z.string(), title: z.string().optional(), description: z.string().optional(),\n required: z.boolean().optional(), hidden: z.boolean().optional(),\n when: z.array(z.object({ key: z.string(), op: z.enum([\"eq\", \"neq\"]), value: z.union([z.string(), numeric, z.boolean()]) })).optional(),\n})\nconst fieldSchema = z.discriminatedUnion(\"type\", [\n field.extend({ type: z.literal(\"string\"), format: z.enum([\"email\", \"uri\", \"date\", \"date-time\"]).optional(),\n minLength: z.number().optional(), maxLength: z.number().optional(), pattern: z.string().optional(),\n placeholder: z.string().optional(), default: z.string().optional(), options: z.array(option).optional(), custom: z.boolean().optional() }),\n field.extend({ type: z.literal(\"number\"), minimum: numeric.optional(), maximum: numeric.optional(), default: numeric.optional() }),\n field.extend({ type: z.literal(\"integer\"), minimum: numeric.optional(), maximum: numeric.optional(), default: numeric.optional() }),\n field.extend({ type: z.literal(\"boolean\"), default: z.boolean().optional() }),\n field.extend({ type: z.literal(\"multiselect\"), options: z.array(option), minItems: z.number().optional(),\n maxItems: z.number().optional(), custom: z.boolean().optional(), default: z.array(z.string()).optional() }),\n field.extend({ type: z.literal(\"external\"), url: z.string() }),\n])\nconst formSchema = z.object({\n id: z.string(), sessionID: z.string(), title: z.string(), metadata: z.record(z.unknown()).optional(),\n fields: z.array(fieldSchema).min(1),\n})\n// One backend-owned RPC; never exposed by the generic instance proxy.\nconst snapshotSchema = z.object({ originDirectory: directorySchema, data: z.array(\n z.object({ directory: directorySchema, status: z.literal(\"complete\"), locations: z.array(z.object({\n location: z.object({ directory: directorySchema, workspaceID: z.string().optional() }).strict(),\n permissions: z.array(permissionSchema).max(1024), forms: z.array(formSchema).max(1024),\n })).max(64) }),\n).max(64) }).strict()\nconst nativeSchema = z.object({ output: snapshotSchema }).strict()\nconst unavailableSchema = z.object({\n _tag: z.literal(\"RpcError\"), type: z.enum([\"rpc.unavailable\", \"rpc.method_not_found\"]),\n message: z.string().min(1).max(4096),\n}).strict()\nconst MAX_RESPONSE_BYTES = 4 * 1024 * 1024\n\nasync function drainOwnershipReads<T>(reads: Promise<T>[]): Promise<T[]> {\n try { return await Promise.all(reads) }\n catch (error) {\n // Keep custody of this batch's admitted reads before returning the first failure.\n await Promise.allSettled(reads)\n throw error\n }\n}\n\nconst missingHost = (host: string) => lstat(host).then(() => false, error => (error as NodeJS.ErrnoException).code === \"ENOENT\")\n\nexport interface PendingRequestsRouteDeps {\n workspaceManager: Pick<WorkspaceManager, \"get\" | \"getSharedServiceConnection\" | \"getServiceLocation\" | \"getServicePathStyle\" | \"getServiceDirectoryForPath\" | \"getWorktreeIdentityForPath\" | \"getHostPathForServicePath\" | \"ownsLocation\">\n worktreeDeletionFence: Pick<WorktreeDeletionFence, \"isBlocked\">\n /** Test seam only; production always uses the real Git common-directory reader. */\n readGitCommonDirectory?: typeof readGitCommonDirectory\n}\n\nexport function registerPendingRequestRoutes(app: FastifyInstance, deps: PendingRequestsRouteDeps): void {\n const readCommon = deps.readGitCommonDirectory ?? readGitCommonDirectory\n app.get<{ Params: { id: string } }>(\"/api/workspaces/:id/pending-requests\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\")\n const query = querySchema.safeParse(request.query)\n if (!query.success) return reply.code(400).send({ error: \"Invalid pending request directories\" })\n const manager = deps.workspaceManager, id = request.params.id\n const workspace = manager.get(id)\n if (!workspace) return reply.code(404).send({ error: \"Workspace not found\" })\n // Includes bounded Git ownership reads before/after the native reader's independent two-second deadline.\n const signal = AbortSignal.timeout(PENDING_REQUEST_SNAPSHOT_TIMEOUT_MS)\n const started = Date.now()\n let phase = \"ownership\"\n let nativeStatus: number | undefined\n // Phase durations only; never paths or queue contents.\n const timing: string[] = []\n let lap = started\n const record = (name: string) => {\n const now = Date.now()\n timing.push(`${name};dur=${now - lap}`)\n lap = now\n reply.header(\"Server-Timing\", timing.join(\", \"))\n }\n try {\n const connection = await manager.getSharedServiceConnection(id)\n if (!connection) return reply.code(503).send({ error: \"Pending requests unavailable\" })\n if (deferPendingDiscovery(connection, { loadedOnly: true })) return reply.header(\"Retry-After\", \"30\").code(503).send({ error: PENDING_DISCOVERY_DEFERRED })\n const submitted = [...new Set(typeof query.data.directories === \"string\" ? [query.data.directories] : query.data.directories)]\n const optional = new Set(typeof query.data.optionalDirectories === \"string\" ? [query.data.optionalDirectories] : query.data.optionalDirectories ?? [])\n if ([...optional].some((directory) => !submitted.includes(directory))) return reply.code(400).send({ error: \"Invalid optional pending request directories\" })\n const result: Extract<WorkspacePendingRequestsResponse, { supported: true }> = { supported: true, directories: [] }\n const resolved: Array<{ submitted: string; directory: string; identity: string }> = []\n // Optional history whose host directory is absent: authorized by its own owned\n // identity or by an existing, canonically owned ancestor, and revalidated after RPC.\n const missing: Array<{ submitted: string; directory?: string; identity: string; host: string; ancestor?: string }> = []\n // A candidate whose ownership cannot be (re)established reports its own\n // non-authoritative error; it neither fails the batch nor counts as empty.\n const failed = new Set<string>()\n const bootstrap = manager.getServiceLocation(id)\n const style = manager.getServicePathStyle(id)\n const nativePath = style === \"win32\" ? path.win32 : style === \"posix\" ? path.posix : undefined\n const root = await manager.getServiceDirectoryForPath(id, workspace.path)\n const rootIdentity = bootstrap && await manager.getWorktreeIdentityForPath(id, bootstrap.directory)\n if (!bootstrap || bootstrap.workspaceID !== undefined || !root || !rootIdentity || !nativePath?.isAbsolute(bootstrap.directory)\n || await manager.getServiceDirectoryForPath(id, bootstrap.directory) !== root) throw new Error(\"Pending bootstrap unavailable\")\n const bootstrapDirectory = bootstrap.directory\n const isolate = (error: unknown) => {\n if (signal.aborted) throw error\n }\n let common: Promise<string> | undefined\n const workspaceCommon = () => common ??= readCommon(workspace.path)\n // Lazy: the expected identity is read only once an existing ancestor needs it.\n const ownedMissingAncestor = async (candidate: string, expectedCommon: () => Promise<string>) => {\n if (!nativePath.isAbsolute(candidate)) return undefined\n let ancestor = candidate\n // Only an existing, canonically owned ancestor can authorize an absent hint.\n for (let depth = 0; depth < 64; depth++) {\n signal.throwIfAborted()\n const host = await manager.getHostPathForServicePath(id, ancestor)\n if (!host || !path.isAbsolute(host)) return undefined\n if (!await missingHost(host)) {\n const directory = await manager.getServiceDirectoryForPath(id, ancestor)\n const identity = directory && await manager.getWorktreeIdentityForPath(id, directory)\n const canonical = directory && await manager.getHostPathForServicePath(id, directory)\n if (!identity || !canonical || deps.worktreeDeletionFence.isBlocked(identity)) return undefined\n try {\n if (await realpath(host) !== await realpath(canonical)\n || await readCommon(host) !== await expectedCommon()) return undefined\n } catch { return undefined }\n return { ancestor, identity }\n }\n const parent = nativePath.dirname(ancestor)\n if (parent === ancestor) break\n ancestor = parent\n }\n return undefined\n }\n // ponytail: eight ownership checks at a time keep bounded Windows Git reads inside the request deadline.\n for (let offset = 0; offset < submitted.length; offset += 8) {\n const candidates = await drainOwnershipReads(submitted.slice(offset, offset + 8).map(async (candidate) => {\n signal.throwIfAborted()\n try {\n const directory = await manager.getServiceDirectoryForPath(id, candidate)\n if (!directory && optional.has(candidate)) {\n const host = await manager.getHostPathForServicePath(id, candidate)\n const owned = host && path.isAbsolute(host) && await missingHost(host) ? await ownedMissingAncestor(candidate, workspaceCommon) : undefined\n if (!host || !owned) return { candidate, status: \"error\" as const }\n return { candidate, status: \"excluded\" as const, missing: { submitted: candidate, host, ...owned } }\n }\n const identity = directory === root ? rootIdentity : directory && await manager.getWorktreeIdentityForPath(id, directory)\n const host = directory && await manager.getHostPathForServicePath(id, directory)\n if (!directory || !identity || !host || deps.worktreeDeletionFence.isBlocked(identity)) return { candidate, status: \"error\" as const }\n // An owned optional path whose checkout is already gone is excluded history,\n // still fenced by its identity and revalidated as absent after RPC.\n if (directory !== root && optional.has(candidate) && await missingHost(host)) {\n return { candidate, status: \"excluded\" as const, missing: { submitted: candidate, directory, identity, host } }\n }\n // Containment alone cannot authorize a nested independent clone.\n const sameRepository = directory === root || await Promise.all([workspaceCommon(), readCommon(host)])\n .then(([left, right]) => left === right, () => false)\n if (!sameRepository) return { candidate, status: \"error\" as const }\n return { candidate, status: \"ok\" as const, owned: { submitted: candidate, directory, identity } }\n } catch (error) {\n isolate(error)\n return { candidate, status: \"error\" as const }\n }\n }))\n for (const entry of candidates) {\n if (entry.status === \"ok\") resolved.push(entry.owned)\n else {\n if (entry.status === \"excluded\") missing.push(entry.missing)\n result.directories.push({ directory: entry.candidate, status: entry.status })\n }\n }\n }\n if (!resolved.length && result.directories.some((entry) => entry.status !== \"excluded\")) return reply.code(403).send({ error: \"Directory does not belong to workspace\" })\n const assertCurrent = () => {\n signal.throwIfAborted()\n connection.assertCurrent()\n const currentRoot = manager.getServiceLocation(id)\n if (manager.get(id) !== workspace || currentRoot?.directory !== bootstrapDirectory || currentRoot.workspaceID !== undefined\n || deps.worktreeDeletionFence.isBlocked(rootIdentity)) {\n throw new Error(\"Pending request ownership changed\")\n }\n }\n const assertOrigin = async (directory: string) => {\n // Resolve spelling/realpath aliases through existing ownership, but never accept a host alias as WSL-native provenance.\n if (!nativePath.isAbsolute(directory) || await manager.getServiceDirectoryForPath(id, directory) !== root\n || await manager.getServiceDirectoryForPath(id, workspace.path) !== root\n || await manager.getWorktreeIdentityForPath(id, bootstrapDirectory) !== rootIdentity) throw new Error(\"Invalid pending origin\")\n assertCurrent()\n }\n const revalidateCandidates = async () => {\n const currentCommon = resolved.some((candidate) => candidate.directory !== root) || missing.some((entry) => entry.ancestor)\n ? await readCommon(workspace.path) : undefined\n for (let offset = 0; offset < resolved.length; offset += 8) {\n await drainOwnershipReads(resolved.slice(offset, offset + 8).map(async (candidate) => {\n if (failed.has(candidate.submitted)) return\n try {\n const host = candidate.directory === root ? undefined : await manager.getHostPathForServicePath(id, candidate.directory)\n const owned = !deps.worktreeDeletionFence.isBlocked(candidate.identity)\n && await manager.getServiceDirectoryForPath(id, candidate.submitted) === candidate.directory\n && (candidate.directory === root || (await manager.getWorktreeIdentityForPath(id, candidate.directory) === candidate.identity\n && Boolean(host) && await readCommon(host!) === currentCommon))\n if (!owned) failed.add(candidate.submitted)\n } catch (error) {\n isolate(error)\n failed.add(candidate.submitted)\n }\n }))\n }\n // An exclusion stays valid only while its path is still absent and owned\n // by the same identity; a reappearing checkout becomes this directory's error.\n for (let offset = 0; offset < missing.length; offset += 8) {\n await drainOwnershipReads(missing.slice(offset, offset + 8).map(async ({ submitted, directory, identity, host, ancestor }) => {\n try {\n const owned = !deps.worktreeDeletionFence.isBlocked(identity)\n && await manager.getServiceDirectoryForPath(id, submitted) === directory\n && (!directory || await manager.getWorktreeIdentityForPath(id, directory) === identity)\n && await manager.getHostPathForServicePath(id, directory ?? submitted) === host\n && await missingHost(host)\n && (!ancestor || (await ownedMissingAncestor(submitted, async () => currentCommon!))?.identity === identity)\n if (!owned) failed.add(submitted)\n } catch (error) {\n isolate(error)\n failed.add(submitted)\n }\n }))\n }\n // A deletion that began during the awaits above still fences publication.\n for (const candidate of [...resolved, ...missing]) if (deps.worktreeDeletionFence.isBlocked(candidate.identity)) failed.add(candidate.submitted)\n assertCurrent()\n }\n assertCurrent()\n record(\"ownership\")\n // Initial resolution above admits this read. Revalidate after all native\n // and placement IO, not repeatedly within the same pre/post-read phase.\n if (deferPendingDiscovery(connection, { loadedOnly: true })) return reply.header(\"Retry-After\", \"30\").code(503).send({ error: PENDING_DISCOVERY_DEFERRED })\n // Even an all-excluded historical batch must negotiate real RPC capability.\n // The established root is the only bootstrap, never an inactive candidate.\n const expected = new Set(resolved.length ? resolved.map((entry) => entry.directory) : [root])\n const url = new URL(\"/api/rpc/codenomad.pending-requests/snapshot\", connection.endpoint.url)\n url.searchParams.set(\"location[directory]\", bootstrapDirectory)\n phase = \"native-read\"\n const response = await connection.fetch(url, { method: \"POST\", signal, redirect: \"error\",\n headers: { \"content-type\": \"application/json\" }, body: JSON.stringify({ input: { directories: [...expected] } }) })\n nativeStatus = response.status\n phase = \"response-validation\"\n assertCurrent()\n if (response.status === 400 && unavailableSchema.safeParse(await readBoundedJson(response)).success) {\n record(\"native\")\n phase = \"ownership-revalidation\"\n await assertOrigin(bootstrapDirectory)\n await revalidateCandidates()\n record(\"revalidation\")\n markLoadedPendingSupported(connection, false)\n return { supported: false } satisfies WorkspacePendingRequestsResponse\n }\n if (!response.ok) { await response.body?.cancel(); throw new Error(\"Native pending requests unavailable\") }\n const native = nativeSchema.parse(await readBoundedJson(response)).output\n record(\"native\")\n if (native.data.length !== expected.size || new Set(native.data.map((entry) => entry.directory)).size !== expected.size\n || native.data.some((entry) => !expected.has(entry.directory))\n || native.data.reduce((count, entry) => count + entry.locations.length, 0) > 64) throw new Error(\"Invalid pending coverage\")\n let placementRejected = false\n const readLocations = async (entry: (typeof native.data)[number]) => {\n const locations: WorkspacePendingRequestLocation[] = []\n if (new Set(entry.locations.map((snapshot) => snapshot.location.directory)).size !== entry.locations.length) throw new Error(\"Duplicate pending placement\")\n if (entry.locations.reduce((count, snapshot) => count + snapshot.permissions.length, 0) > 1024\n || entry.locations.reduce((count, snapshot) => count + snapshot.forms.length, 0) > 1024) {\n throw new Error(\"Invalid pending request count\")\n }\n for (const snapshot of entry.locations) {\n // A rejected placement withholds only its own directory's coverage and\n // capability verification; malformed native data above fails the batch.\n const owned = await (async () => snapshot.location.workspaceID === undefined && nativePath.isAbsolute(snapshot.location.directory)\n && await manager.getServiceDirectoryForPath(id, snapshot.location.directory) === entry.directory\n && await manager.ownsLocation(id, snapshot.location, connection.client, signal))().catch((error) => {\n isolate(error)\n return false\n })\n if (!owned) {\n placementRejected = true\n return undefined\n }\n locations.push({ location: { directory: snapshot.location.directory },\n permissions: snapshot.permissions as PermissionRequest[], forms: snapshot.forms as FormInfo[] })\n }\n if (!locations.length) locations.push({ location: { directory: entry.directory }, permissions: [], forms: [] })\n return locations\n }\n for (const entry of native.data) {\n const locations = await readLocations(entry)\n assertCurrent()\n for (const original of resolved.filter((candidate) => candidate.directory === entry.directory)) {\n if (locations) result.directories.push({ directory: original.submitted, status: \"ok\", locations })\n else failed.add(original.submitted)\n }\n }\n record(\"placement\")\n phase = \"ownership-revalidation\"\n // Includes every admitted candidate, even empty/cold coverage. The root\n // identity is rechecked by assertOrigin; aliases still need their own check.\n await assertOrigin(native.originDirectory)\n await revalidateCandidates()\n record(\"revalidation\")\n // Any admitted candidate (resolved or excluded) that failed revalidation also\n // withholds capability: a changed or fenced directory cannot verify the RPC.\n if (!placementRejected && !failed.size) markLoadedPendingSupported(connection, true)\n result.directories = [\n ...result.directories.filter((entry) => !failed.has(entry.directory)),\n ...[...failed].map((directory) => ({ directory, status: \"error\" as const })),\n ]\n return result\n } catch {\n record(phase)\n // Keep queue contents/paths and native payloads out of diagnostic logs.\n request.log.warn({ workspaceId: id, phase, nativeStatus, timedOut: signal.aborted, elapsedMs: Date.now() - started }, \"Pending request recovery failed\")\n // Never convert transport, malformed coverage or ownership errors to empty.\n return reply.code(503).send({ error: \"Pending requests unavailable; retain existing queues\" })\n }\n })\n}\n\nasync function readBoundedJson(response: Response): Promise<unknown> {\n if (!response.body || !response.headers.get(\"content-type\")?.includes(\"application/json\")) throw new Error(\"Invalid pending response\")\n const reader = response.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n try {\n for (;;) {\n const { value, done } = await reader.read()\n if (done) return JSON.parse(Buffer.concat(chunks).toString(\"utf8\"), (_key, value) => {\n if (typeof value === \"number\" && !Number.isFinite(value)) throw new Error(\"Invalid pending JSON number\")\n return value\n })\n size += value.byteLength\n if (size > MAX_RESPONSE_BYTES) throw new Error(\"Pending response exceeded bound\")\n chunks.push(value)\n }\n } finally { await reader.cancel().catch(() => {}); reader.releaseLock() }\n}\n"]}
1
+ {"version":3,"file":"pending-requests.js","sourceRoot":"","sources":["../../../src/server/routes/pending-requests.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,mCAAmC,EAAE,MAAM,iBAAiB,CAAA;AAGrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,qBAAq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AC,EAAE,QAAQ,CAAC,kBAAkB,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;IACtI,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,CAAA;IACxC,MAAM,MAAM,GAAiB,EAAE,CAAA;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,IAAI,CAAC;QACH,SAAS,CAAC;YACR,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;YAC3C,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oBAClF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;wBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;oBACxG,OAAO,KAAK,CAAA;gBACd,CAAC,CAAC,CAAA;YACF,IAAI,IAAI,KAAK,CAAC,UAAU,CAAA;YACxB,IAAI,IAAI,GAAG,kBAAkB;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YACjF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;YAAS,CAAC;QAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { FastifyInstance } from \"fastify\"\nimport path from \"node:path\"\nimport { lstat, realpath } from \"node:fs/promises\"\nimport { z } from \"zod\"\nimport type { FormInfo, PermissionRequest } from \"@opencode/client\"\nimport type { WorkspacePendingRequestLocation, WorkspacePendingRequestsResponse } from \"../../api-types\"\nimport { PENDING_REQUEST_SNAPSHOT_TIMEOUT_MS } from \"../../api-types\"\nimport type { WorkspaceManager } from \"../../workspaces/manager\"\nimport type { WorktreeDeletionFence } from \"../../workspaces/worktree-session-evacuation\"\nimport { readGitCommonDirectory } from \"../../workspaces/git-common-directory\"\nimport { deferPendingDiscovery, markLoadedPendingSupported, PENDING_DISCOVERY_DEFERRED } from \"../../workspaces/pending-discovery\"\n\nconst directorySchema = z.string().min(1).max(4096)\nconst directoryListSchema = z.union([directorySchema, z.array(directorySchema).min(1).max(64)])\nconst querySchema = z.object({ directories: directoryListSchema, optionalDirectories: directoryListSchema.optional() }).strict()\nconst permissionSchema = z.object({\n id: z.string(), sessionID: z.string(), action: z.string(), resources: z.array(z.string()),\n save: z.array(z.string()).optional(), metadata: z.record(z.unknown()).optional(), message: z.string().optional(),\n source: z.object({ type: z.literal(\"tool\"), messageID: z.string(), id: z.string() }).optional(),\n})\nconst numeric = z.union([z.number(), z.enum([\"Infinity\", \"-Infinity\", \"NaN\"])])\nconst option = z.object({ value: z.string(), label: z.string(), description: z.string().optional() })\nconst field = z.object({\n key: z.string(), title: z.string().optional(), description: z.string().optional(),\n required: z.boolean().optional(), hidden: z.boolean().optional(),\n when: z.array(z.object({ key: z.string(), op: z.enum([\"eq\", \"neq\"]), value: z.union([z.string(), numeric, z.boolean()]) })).optional(),\n})\nconst fieldSchema = z.discriminatedUnion(\"type\", [\n field.extend({ type: z.literal(\"string\"), format: z.enum([\"email\", \"uri\", \"date\", \"date-time\"]).optional(),\n minLength: z.number().optional(), maxLength: z.number().optional(), pattern: z.string().optional(),\n placeholder: z.string().optional(), default: z.string().optional(), options: z.array(option).optional(), custom: z.boolean().optional() }),\n field.extend({ type: z.literal(\"number\"), minimum: numeric.optional(), maximum: numeric.optional(), default: numeric.optional() }),\n field.extend({ type: z.literal(\"integer\"), minimum: numeric.optional(), maximum: numeric.optional(), default: numeric.optional() }),\n field.extend({ type: z.literal(\"boolean\"), default: z.boolean().optional() }),\n field.extend({ type: z.literal(\"multiselect\"), options: z.array(option), minItems: z.number().optional(),\n maxItems: z.number().optional(), custom: z.boolean().optional(), default: z.array(z.string()).optional() }),\n field.extend({ type: z.literal(\"external\"), url: z.string() }),\n])\nconst formSchema = z.object({\n id: z.string(), sessionID: z.string(), title: z.string(), metadata: z.record(z.unknown()).optional(),\n fields: z.array(fieldSchema).min(1),\n})\n// One backend-owned RPC; never exposed by the generic instance proxy.\nconst snapshotSchema = z.object({ originDirectory: directorySchema, data: z.array(\n z.object({ directory: directorySchema, status: z.literal(\"complete\"), locations: z.array(z.object({\n location: z.object({ directory: directorySchema, workspaceID: z.string().optional() }).strict(),\n permissions: z.array(permissionSchema).max(1024), forms: z.array(formSchema).max(1024),\n })).max(64) }),\n).max(64) }).strict()\nconst nativeSchema = z.object({ output: snapshotSchema }).strict()\nconst unavailableSchema = z.object({\n _tag: z.literal(\"RpcError\"), type: z.enum([\"rpc.unavailable\", \"rpc.method_not_found\"]),\n message: z.string().min(1).max(4096),\n}).strict()\nconst MAX_RESPONSE_BYTES = 4 * 1024 * 1024\n\nasync function drainOwnershipReads<T>(reads: Promise<T>[]): Promise<T[]> {\n try { return await Promise.all(reads) }\n catch (error) {\n // Keep custody of this batch's admitted reads before returning the first failure.\n await Promise.allSettled(reads)\n throw error\n }\n}\n\nconst missingHost = (host: string) => lstat(host).then(() => false, error => (error as NodeJS.ErrnoException).code === \"ENOENT\")\n\nexport interface PendingRequestsRouteDeps {\n workspaceManager: Pick<WorkspaceManager, \"get\" | \"getSharedServiceConnection\" | \"getServiceLocation\" | \"getServicePathStyle\" | \"getServiceDirectoryForPath\" | \"getWorktreeIdentityForPath\" | \"getHostPathForServicePath\" | \"ownsLocation\">\n worktreeDeletionFence: Pick<WorktreeDeletionFence, \"isBlocked\">\n /** Test seam only; production always uses the real Git common-directory reader. */\n readGitCommonDirectory?: typeof readGitCommonDirectory\n}\n\nexport function registerPendingRequestRoutes(app: FastifyInstance, deps: PendingRequestsRouteDeps): void {\n const readCommon = deps.readGitCommonDirectory ?? readGitCommonDirectory\n app.get<{ Params: { id: string } }>(\"/api/workspaces/:id/pending-requests\", async (request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\")\n const query = querySchema.safeParse(request.query)\n if (!query.success) return reply.code(400).send({ error: \"Invalid pending request directories\" })\n const manager = deps.workspaceManager, id = request.params.id\n const workspace = manager.get(id)\n if (!workspace) return reply.code(404).send({ error: \"Workspace not found\" })\n // Includes bounded Git ownership reads before/after the native reader's independent two-second deadline.\n const signal = AbortSignal.timeout(PENDING_REQUEST_SNAPSHOT_TIMEOUT_MS)\n const started = Date.now()\n let phase = \"ownership\"\n let nativeStatus: number | undefined\n // Phase durations only; never paths or queue contents.\n const timing: string[] = []\n let lap = started\n const record = (name: string) => {\n const now = Date.now()\n timing.push(`${name};dur=${now - lap}`)\n lap = now\n reply.header(\"Server-Timing\", timing.join(\", \"))\n }\n try {\n const connection = await manager.getSharedServiceConnection(id)\n if (!connection) return reply.code(503).send({ error: \"Pending requests unavailable\" })\n if (deferPendingDiscovery(connection, { loadedOnly: true })) return reply.header(\"Retry-After\", \"30\").code(503).send({ error: PENDING_DISCOVERY_DEFERRED })\n const submitted = [...new Set(typeof query.data.directories === \"string\" ? [query.data.directories] : query.data.directories)]\n const optional = new Set(typeof query.data.optionalDirectories === \"string\" ? [query.data.optionalDirectories] : query.data.optionalDirectories ?? [])\n if ([...optional].some((directory) => !submitted.includes(directory))) return reply.code(400).send({ error: \"Invalid optional pending request directories\" })\n const result: Extract<WorkspacePendingRequestsResponse, { supported: true }> = { supported: true, directories: [] }\n const resolved: Array<{ submitted: string; directory: string; identity: string }> = []\n // Optional history whose host directory is absent: authorized by its own owned\n // identity or by an existing, canonically owned ancestor, and revalidated after RPC.\n const missing: Array<{ submitted: string; directory?: string; identity: string; host: string; ancestor?: string }> = []\n // Negative scope evidence only: these hints never authorize a native read\n // or an empty queue. Preserve errors when membership is merely unknown.\n const outside: Array<{ submitted: string; directory?: string; identity?: string; proof: string }> = []\n // A candidate whose ownership cannot be (re)established reports its own\n // non-authoritative error; it neither fails the batch nor counts as empty.\n const failed = new Set<string>()\n const bootstrap = manager.getServiceLocation(id)\n const style = manager.getServicePathStyle(id)\n const nativePath = style === \"win32\" ? path.win32 : style === \"posix\" ? path.posix : undefined\n const root = await manager.getServiceDirectoryForPath(id, workspace.path)\n const rootIdentity = bootstrap && await manager.getWorktreeIdentityForPath(id, bootstrap.directory)\n if (!bootstrap || bootstrap.workspaceID !== undefined || !root || !rootIdentity || !nativePath?.isAbsolute(bootstrap.directory)\n || await manager.getServiceDirectoryForPath(id, bootstrap.directory) !== root) throw new Error(\"Pending bootstrap unavailable\")\n const bootstrapDirectory = bootstrap.directory\n const isolate = (error: unknown) => {\n if (signal.aborted) throw error\n }\n let common: Promise<string> | undefined\n const workspaceCommon = () => common ??= readCommon(workspace.path)\n const outsideHistory = async (candidate: string, expectedCommon: () => Promise<string>) => {\n if (!nativePath.isAbsolute(candidate)) return undefined\n const host = await manager.getHostPathForServicePath(id, candidate)\n if (!host || !path.isAbsolute(host)) return undefined\n if (await missingHost(host)) {\n // An absent direct child of a canonical existing parent outside this\n // checkout is obsolete history, not an unavailable owned checkout.\n // Missing owned descendants retain the identity/fence path below.\n const rootHost = await realpath(workspace.path)\n const relative = path.relative(rootHost, host)\n if (!relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative)) return undefined\n const parent = path.dirname(host)\n if (await realpath(parent) !== parent) return undefined\n return `missing\\0${host}\\0${parent}`\n }\n const candidateCommon = await readCommon(host)\n if (candidateCommon === await expectedCommon()) return undefined\n return `foreign\\0${await realpath(host)}\\0${candidateCommon}`\n }\n // Lazy: the expected identity is read only once an existing ancestor needs it.\n const ownedMissingAncestor = async (candidate: string, expectedCommon: () => Promise<string>) => {\n if (!nativePath.isAbsolute(candidate)) return undefined\n let ancestor = candidate\n // Only an existing, canonically owned ancestor can authorize an absent hint.\n for (let depth = 0; depth < 64; depth++) {\n signal.throwIfAborted()\n const host = await manager.getHostPathForServicePath(id, ancestor)\n if (!host || !path.isAbsolute(host)) return undefined\n if (!await missingHost(host)) {\n const directory = await manager.getServiceDirectoryForPath(id, ancestor)\n const identity = directory && await manager.getWorktreeIdentityForPath(id, directory)\n const canonical = directory && await manager.getHostPathForServicePath(id, directory)\n if (!identity || !canonical || deps.worktreeDeletionFence.isBlocked(identity)) return undefined\n try {\n if (await realpath(host) !== await realpath(canonical)\n || await readCommon(host) !== await expectedCommon()) return undefined\n } catch { return undefined }\n return { ancestor, identity }\n }\n const parent = nativePath.dirname(ancestor)\n if (parent === ancestor) break\n ancestor = parent\n }\n return undefined\n }\n // ponytail: eight ownership checks at a time keep bounded Windows Git reads inside the request deadline.\n for (let offset = 0; offset < submitted.length; offset += 8) {\n const candidates = await drainOwnershipReads(submitted.slice(offset, offset + 8).map(async (candidate) => {\n signal.throwIfAborted()\n try {\n const directory = await manager.getServiceDirectoryForPath(id, candidate)\n if (!directory && optional.has(candidate)) {\n const host = await manager.getHostPathForServicePath(id, candidate)\n const owned = host && path.isAbsolute(host) && await missingHost(host) ? await ownedMissingAncestor(candidate, workspaceCommon) : undefined\n if (!host || !owned) {\n const proof = await outsideHistory(candidate, workspaceCommon)\n return proof\n ? { candidate, status: \"excluded\" as const, outside: { submitted: candidate, proof } }\n : { candidate, status: \"error\" as const }\n }\n return { candidate, status: \"excluded\" as const, missing: { submitted: candidate, host, ...owned } }\n }\n const identity = directory === root ? rootIdentity : directory && await manager.getWorktreeIdentityForPath(id, directory)\n const host = directory && await manager.getHostPathForServicePath(id, directory)\n if (!directory || !identity || !host || deps.worktreeDeletionFence.isBlocked(identity)) return { candidate, status: \"error\" as const }\n // An owned optional path whose checkout is already gone is excluded history,\n // still fenced by its identity and revalidated as absent after RPC.\n if (directory !== root && optional.has(candidate) && await missingHost(host)) {\n return { candidate, status: \"excluded\" as const, missing: { submitted: candidate, directory, identity, host } }\n }\n // Containment alone cannot authorize a nested independent clone.\n const sameRepository = directory === root || await Promise.all([workspaceCommon(), readCommon(host)])\n .then(([left, right]) => left === right, () => false)\n if (!sameRepository) {\n const proof = optional.has(candidate) ? await outsideHistory(candidate, workspaceCommon) : undefined\n return proof\n ? { candidate, status: \"excluded\" as const, outside: { submitted: candidate, directory, identity, proof } }\n : { candidate, status: \"error\" as const }\n }\n return { candidate, status: \"ok\" as const, owned: { submitted: candidate, directory, identity } }\n } catch (error) {\n isolate(error)\n return { candidate, status: \"error\" as const }\n }\n }))\n for (const entry of candidates) {\n if (entry.status === \"ok\") resolved.push(entry.owned)\n else {\n if (entry.status === \"excluded\") {\n if (entry.outside) outside.push(entry.outside)\n else missing.push(entry.missing)\n }\n result.directories.push({ directory: entry.candidate, status: entry.status })\n }\n }\n }\n if (!resolved.length && result.directories.some((entry) => entry.status !== \"excluded\")) return reply.code(403).send({ error: \"Directory does not belong to workspace\" })\n const assertCurrent = () => {\n signal.throwIfAborted()\n connection.assertCurrent()\n const currentRoot = manager.getServiceLocation(id)\n if (manager.get(id) !== workspace || currentRoot?.directory !== bootstrapDirectory || currentRoot.workspaceID !== undefined\n || deps.worktreeDeletionFence.isBlocked(rootIdentity)) {\n throw new Error(\"Pending request ownership changed\")\n }\n }\n const assertOrigin = async (directory: string) => {\n // Resolve spelling/realpath aliases through existing ownership, but never accept a host alias as WSL-native provenance.\n if (!nativePath.isAbsolute(directory) || await manager.getServiceDirectoryForPath(id, directory) !== root\n || await manager.getServiceDirectoryForPath(id, workspace.path) !== root\n || await manager.getWorktreeIdentityForPath(id, bootstrapDirectory) !== rootIdentity) throw new Error(\"Invalid pending origin\")\n assertCurrent()\n }\n const revalidateCandidates = async () => {\n const currentCommon = resolved.some((candidate) => candidate.directory !== root) || missing.some((entry) => entry.ancestor) || outside.length > 0\n ? await readCommon(workspace.path) : undefined\n for (let offset = 0; offset < resolved.length; offset += 8) {\n await drainOwnershipReads(resolved.slice(offset, offset + 8).map(async (candidate) => {\n if (failed.has(candidate.submitted)) return\n try {\n const host = candidate.directory === root ? undefined : await manager.getHostPathForServicePath(id, candidate.directory)\n const owned = !deps.worktreeDeletionFence.isBlocked(candidate.identity)\n && await manager.getServiceDirectoryForPath(id, candidate.submitted) === candidate.directory\n && (candidate.directory === root || (await manager.getWorktreeIdentityForPath(id, candidate.directory) === candidate.identity\n && Boolean(host) && await readCommon(host!) === currentCommon))\n if (!owned) failed.add(candidate.submitted)\n } catch (error) {\n isolate(error)\n failed.add(candidate.submitted)\n }\n }))\n }\n // An exclusion stays valid only while its path is still absent and owned\n // by the same identity; a reappearing checkout becomes this directory's error.\n for (let offset = 0; offset < missing.length; offset += 8) {\n await drainOwnershipReads(missing.slice(offset, offset + 8).map(async ({ submitted, directory, identity, host, ancestor }) => {\n try {\n const owned = !deps.worktreeDeletionFence.isBlocked(identity)\n && await manager.getServiceDirectoryForPath(id, submitted) === directory\n && (!directory || await manager.getWorktreeIdentityForPath(id, directory) === identity)\n && await manager.getHostPathForServicePath(id, directory ?? submitted) === host\n && await missingHost(host)\n && (!ancestor || (await ownedMissingAncestor(submitted, async () => currentCommon!))?.identity === identity)\n if (!owned) failed.add(submitted)\n } catch (error) {\n isolate(error)\n failed.add(submitted)\n }\n }))\n }\n for (const entry of outside) {\n try {\n if (await manager.getServiceDirectoryForPath(id, entry.submitted) !== entry.directory\n || (entry.identity && (deps.worktreeDeletionFence.isBlocked(entry.identity)\n || await manager.getWorktreeIdentityForPath(id, entry.directory!) !== entry.identity))\n || await outsideHistory(entry.submitted, async () => currentCommon!) !== entry.proof) failed.add(entry.submitted)\n } catch (error) { isolate(error); failed.add(entry.submitted) }\n }\n // A deletion that began during the awaits above still fences publication.\n for (const candidate of [...resolved, ...missing]) if (deps.worktreeDeletionFence.isBlocked(candidate.identity)) failed.add(candidate.submitted)\n for (const candidate of outside) if (candidate.identity && deps.worktreeDeletionFence.isBlocked(candidate.identity)) failed.add(candidate.submitted)\n assertCurrent()\n }\n assertCurrent()\n record(\"ownership\")\n // Initial resolution above admits this read. Revalidate after all native\n // and placement IO, not repeatedly within the same pre/post-read phase.\n if (deferPendingDiscovery(connection, { loadedOnly: true })) return reply.header(\"Retry-After\", \"30\").code(503).send({ error: PENDING_DISCOVERY_DEFERRED })\n // Even an all-excluded historical batch must negotiate real RPC capability.\n // The established root is the only bootstrap, never an inactive candidate.\n const expected = new Set(resolved.length ? resolved.map((entry) => entry.directory) : [root])\n const url = new URL(\"/api/rpc/codenomad.pending-requests/snapshot\", connection.endpoint.url)\n url.searchParams.set(\"location[directory]\", bootstrapDirectory)\n phase = \"native-read\"\n const response = await connection.fetch(url, { method: \"POST\", signal, redirect: \"error\",\n headers: { \"content-type\": \"application/json\" }, body: JSON.stringify({ input: { directories: [...expected] } }) })\n nativeStatus = response.status\n phase = \"response-validation\"\n assertCurrent()\n if (response.status === 400 && unavailableSchema.safeParse(await readBoundedJson(response)).success) {\n record(\"native\")\n phase = \"ownership-revalidation\"\n await assertOrigin(bootstrapDirectory)\n await revalidateCandidates()\n record(\"revalidation\")\n markLoadedPendingSupported(connection, false)\n return { supported: false } satisfies WorkspacePendingRequestsResponse\n }\n if (!response.ok) { await response.body?.cancel(); throw new Error(\"Native pending requests unavailable\") }\n const native = nativeSchema.parse(await readBoundedJson(response)).output\n record(\"native\")\n if (native.data.length !== expected.size || new Set(native.data.map((entry) => entry.directory)).size !== expected.size\n || native.data.some((entry) => !expected.has(entry.directory))\n || native.data.reduce((count, entry) => count + entry.locations.length, 0) > 64) throw new Error(\"Invalid pending coverage\")\n let placementRejected = false\n const readLocations = async (entry: (typeof native.data)[number]) => {\n const locations: WorkspacePendingRequestLocation[] = []\n if (new Set(entry.locations.map((snapshot) => snapshot.location.directory)).size !== entry.locations.length) throw new Error(\"Duplicate pending placement\")\n if (entry.locations.reduce((count, snapshot) => count + snapshot.permissions.length, 0) > 1024\n || entry.locations.reduce((count, snapshot) => count + snapshot.forms.length, 0) > 1024) {\n throw new Error(\"Invalid pending request count\")\n }\n for (const snapshot of entry.locations) {\n // A rejected placement withholds only its own directory's coverage and\n // capability verification; malformed native data above fails the batch.\n const owned = await (async () => snapshot.location.workspaceID === undefined && nativePath.isAbsolute(snapshot.location.directory)\n && await manager.getServiceDirectoryForPath(id, snapshot.location.directory) === entry.directory\n && await manager.ownsLocation(id, snapshot.location, connection.client, signal))().catch((error) => {\n isolate(error)\n return false\n })\n if (!owned) {\n placementRejected = true\n return undefined\n }\n locations.push({ location: { directory: snapshot.location.directory },\n permissions: snapshot.permissions as PermissionRequest[], forms: snapshot.forms as FormInfo[] })\n }\n if (!locations.length) locations.push({ location: { directory: entry.directory }, permissions: [], forms: [] })\n return locations\n }\n for (const entry of native.data) {\n const locations = await readLocations(entry)\n assertCurrent()\n for (const original of resolved.filter((candidate) => candidate.directory === entry.directory)) {\n if (locations) result.directories.push({ directory: original.submitted, status: \"ok\", locations })\n else failed.add(original.submitted)\n }\n }\n record(\"placement\")\n phase = \"ownership-revalidation\"\n // Includes every admitted candidate, even empty/cold coverage. The root\n // identity is rechecked by assertOrigin; aliases still need their own check.\n await assertOrigin(native.originDirectory)\n await revalidateCandidates()\n record(\"revalidation\")\n // Any admitted candidate (resolved or excluded) that failed revalidation also\n // withholds capability: a changed or fenced directory cannot verify the RPC.\n if (!placementRejected && !failed.size) markLoadedPendingSupported(connection, true)\n result.directories = [\n ...result.directories.filter((entry) => !failed.has(entry.directory)),\n ...[...failed].map((directory) => ({ directory, status: \"error\" as const })),\n ]\n return result\n } catch {\n record(phase)\n // Keep queue contents/paths and native payloads out of diagnostic logs.\n request.log.warn({ workspaceId: id, phase, nativeStatus, timedOut: signal.aborted, elapsedMs: Date.now() - started }, \"Pending request recovery failed\")\n // Never convert transport, malformed coverage or ownership errors to empty.\n return reply.code(503).send({ error: \"Pending requests unavailable; retain existing queues\" })\n }\n })\n}\n\nasync function readBoundedJson(response: Response): Promise<unknown> {\n if (!response.body || !response.headers.get(\"content-type\")?.includes(\"application/json\")) throw new Error(\"Invalid pending response\")\n const reader = response.body.getReader()\n const chunks: Uint8Array[] = []\n let size = 0\n try {\n for (;;) {\n const { value, done } = await reader.read()\n if (done) return JSON.parse(Buffer.concat(chunks).toString(\"utf8\"), (_key, value) => {\n if (typeof value === \"number\" && !Number.isFinite(value)) throw new Error(\"Invalid pending JSON number\")\n return value\n })\n size += value.byteLength\n if (size > MAX_RESPONSE_BYTES) throw new Error(\"Pending response exceeded bound\")\n chunks.push(value)\n }\n } finally { await reader.cancel().catch(() => {}); reader.releaseLock() }\n}\n"]}
@@ -438,7 +438,7 @@ test("undefined ownership for an existing optional path never excludes it", asyn
438
438
  await h.cleanup();
439
439
  }
440
440
  });
441
- test("undefined ownership excludes only missing paths with an owned existing ancestor", async () => {
441
+ test("missing optional history outside the checkout is excluded without claiming coverage", async () => {
442
442
  const h = await harness();
443
443
  try {
444
444
  const owned = join(h.root, "deleted-parent", "session");
@@ -446,16 +446,81 @@ test("undefined ownership excludes only missing paths with an owned existing anc
446
446
  const response = await h.app.inject({ url: h.url([h.root, owned, foreign], [owned, foreign]) });
447
447
  assert.equal(response.statusCode, 200, response.body);
448
448
  assert.deepEqual(response.json().directories.find((entry) => entry.directory === owned), { directory: owned, status: "excluded" });
449
- assert.deepEqual(response.json().directories.find((entry) => entry.directory === foreign), { directory: foreign, status: "error" });
449
+ assert.deepEqual(response.json().directories.find((entry) => entry.directory === foreign), { directory: foreign, status: "excluded" });
450
450
  assert.deepEqual(h.state.batches, [[h.root]]);
451
451
  h.state.calls.length = 0;
452
- assert.equal((await h.app.inject({ url: h.url([foreign], [foreign]) })).statusCode, 403);
453
- assert.deepEqual(h.state.calls, [], "missing foreign history cannot negotiate root capability alone");
452
+ assert.deepEqual((await h.app.inject({ url: h.url([foreign], [foreign]) })).json(), {
453
+ supported: true, directories: [{ directory: foreign, status: "excluded" }],
454
+ });
455
+ assert.deepEqual(h.state.batches.at(-1), [h.root], "capability still comes from the owned root, never the excluded path");
456
+ }
457
+ finally {
458
+ await h.cleanup();
459
+ }
460
+ });
461
+ test("optional historical clones are excluded by actual Git identity while valid idle locations remain scanned", async () => {
462
+ const h = await harness();
463
+ try {
464
+ const foreign = join(h.root, "old-fixture-checkout");
465
+ await git("git", ["init", "--quiet", foreign]);
466
+ h.state.result = { data: [complete(h.root), complete(h.subdirectory, [{
467
+ location: { directory: h.subdirectory }, permissions: [permission], forms: [form],
468
+ }])] };
469
+ for (const resolverClaimsOwnership of [false, true]) {
470
+ if (resolverClaimsOwnership)
471
+ h.state.allowed.add(foreign);
472
+ const response = await h.app.inject({ url: h.url([h.root, foreign, h.subdirectory], [foreign, h.subdirectory]) });
473
+ assert.equal(response.statusCode, 200, response.body);
474
+ assert.deepEqual(response.json().directories.find((entry) => entry.directory === foreign), { directory: foreign, status: "excluded" });
475
+ assert.deepEqual(h.state.batches.at(-1), [h.root, h.subdirectory], "never query or warm the unrelated repository");
476
+ assert.deepEqual(response.json().directories.find((entry) => entry.directory === h.subdirectory).locations[0].forms, [form]);
477
+ }
478
+ const required = await h.app.inject({ url: h.url([h.root, foreign, h.subdirectory]) });
479
+ assert.deepEqual(required.json().directories.find((entry) => entry.directory === foreign), { directory: foreign, status: "error" }, "required locations still fail visibly");
454
480
  }
455
481
  finally {
456
482
  await h.cleanup();
457
483
  }
458
484
  });
485
+ test("negative scope evidence must survive native IO and does not swallow uncertain ownership", async () => {
486
+ for (const fault of ["becomes-owned", "reappears", "identity-blocked", "lookup-error"]) {
487
+ const h = await harness();
488
+ const foreign = fault === "reappears" ? `${h.root}-old-history` : join(h.root, "other-repository");
489
+ try {
490
+ if (fault !== "reappears")
491
+ await git("git", ["init", "--quiet", foreign]);
492
+ if (fault === "identity-blocked") {
493
+ h.state.allowed.add(foreign);
494
+ h.manager.getWorktreeIdentityForPath = async (_id, directory) => directory === foreign ? "foreign-identity" : h.root;
495
+ }
496
+ if (fault === "lookup-error") {
497
+ const resolve = h.manager.getServiceDirectoryForPath;
498
+ h.manager.getServiceDirectoryForPath = async (id, directory) => {
499
+ if (directory === foreign)
500
+ throw Object.assign(new Error("Access denied"), { code: "EACCES" });
501
+ return resolve(id, directory);
502
+ };
503
+ }
504
+ h.state.onFetch = () => {
505
+ if (fault === "becomes-owned")
506
+ h.state.allowed.add(foreign);
507
+ if (fault === "reappears")
508
+ execFileSync("git", ["init", "--quiet", foreign], { windowsHide: true });
509
+ if (fault === "identity-blocked")
510
+ h.state.blockedIdentities.add("foreign-identity");
511
+ };
512
+ const response = await h.app.inject({ url: h.url([h.root, foreign], [foreign]) });
513
+ assert.equal(response.statusCode, 200, response.body);
514
+ assert.deepEqual(response.json().directories.find((entry) => entry.directory === foreign), { directory: foreign, status: "error" }, fault);
515
+ assert.deepEqual(h.state.batches, [[h.root]]);
516
+ }
517
+ finally {
518
+ await h.cleanup();
519
+ if (fault === "reappears")
520
+ await rm(foreign, { recursive: true, force: true });
521
+ }
522
+ }
523
+ });
459
524
  test("a missing path through a symlink outside the owned root is not excluded", async () => {
460
525
  const h = await harness();
461
526
  const foreign = await mkdtemp(join(tmpdir(), "codenomad-foreign-"));