@smthrs/kernel 1.0.0-rc.5 → 1.0.0-rc.6

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 (99) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/ChildProcessSpawner.d.ts +4 -4
  3. package/dist/cjs/ChildProcessSpawner.d.ts.map +1 -1
  4. package/dist/cjs/ChildProcessSpawner.js +4 -4
  5. package/dist/cjs/ChildProcessSpawner.js.map +1 -1
  6. package/dist/cjs/CommandLine.d.ts +2 -2
  7. package/dist/cjs/CommandLine.d.ts.map +1 -1
  8. package/dist/cjs/CommandLine.js.map +1 -1
  9. package/dist/cjs/ContainedSpawner.d.ts +2 -2
  10. package/dist/cjs/ContainedSpawner.d.ts.map +1 -1
  11. package/dist/cjs/ContainedSpawner.js +2 -2
  12. package/dist/cjs/ContainedSpawner.js.map +2 -2
  13. package/dist/cjs/FileSystem.d.ts.map +1 -1
  14. package/dist/cjs/FileSystem.js +4 -3
  15. package/dist/cjs/FileSystem.js.map +2 -2
  16. package/dist/cjs/HostServices.d.ts +3 -3
  17. package/dist/cjs/HostServices.d.ts.map +1 -1
  18. package/dist/cjs/HostServices.js +2 -2
  19. package/dist/cjs/HostServices.js.map +1 -1
  20. package/dist/cjs/HttpClient.d.ts +5 -5
  21. package/dist/cjs/HttpClient.d.ts.map +1 -1
  22. package/dist/cjs/HttpClient.js +9 -9
  23. package/dist/cjs/HttpClient.js.map +1 -1
  24. package/dist/cjs/ProcessConfinement.d.ts +1 -1
  25. package/dist/cjs/ProcessConfinement.d.ts.map +1 -1
  26. package/dist/cjs/ProcessConfinement.js.map +1 -1
  27. package/dist/cjs/Rooted.d.ts +2 -2
  28. package/dist/cjs/Rooted.d.ts.map +1 -1
  29. package/dist/cjs/Rooted.js +2 -2
  30. package/dist/cjs/Rooted.js.map +1 -1
  31. package/dist/cjs/internal/Containment.d.ts +1 -1
  32. package/dist/cjs/internal/Containment.d.ts.map +1 -1
  33. package/dist/cjs/internal/Containment.js.map +1 -1
  34. package/dist/cjs/internal/Pipeline.d.ts +2 -2
  35. package/dist/cjs/internal/Pipeline.d.ts.map +1 -1
  36. package/dist/cjs/internal/Pipeline.js +2 -2
  37. package/dist/cjs/internal/Pipeline.js.map +2 -2
  38. package/dist/cjs/test/HostContract.d.ts +5 -5
  39. package/dist/cjs/test/HostContract.d.ts.map +1 -1
  40. package/dist/cjs/test/HostContract.js +4 -4
  41. package/dist/cjs/test/HostContract.js.map +1 -1
  42. package/dist/esm/ChildProcessSpawner.d.ts +4 -4
  43. package/dist/esm/ChildProcessSpawner.d.ts.map +1 -1
  44. package/dist/esm/ChildProcessSpawner.js +5 -5
  45. package/dist/esm/ChildProcessSpawner.js.map +1 -1
  46. package/dist/esm/CommandLine.d.ts +2 -2
  47. package/dist/esm/CommandLine.d.ts.map +1 -1
  48. package/dist/esm/CommandLine.js +1 -1
  49. package/dist/esm/CommandLine.js.map +1 -1
  50. package/dist/esm/ContainedSpawner.d.ts +2 -2
  51. package/dist/esm/ContainedSpawner.d.ts.map +1 -1
  52. package/dist/esm/ContainedSpawner.js +2 -2
  53. package/dist/esm/ContainedSpawner.js.map +1 -1
  54. package/dist/esm/FileSystem.d.ts.map +1 -1
  55. package/dist/esm/FileSystem.js +5 -4
  56. package/dist/esm/FileSystem.js.map +1 -1
  57. package/dist/esm/HostServices.d.ts +3 -3
  58. package/dist/esm/HostServices.d.ts.map +1 -1
  59. package/dist/esm/HostServices.js +2 -2
  60. package/dist/esm/HostServices.js.map +1 -1
  61. package/dist/esm/HttpClient.d.ts +5 -5
  62. package/dist/esm/HttpClient.d.ts.map +1 -1
  63. package/dist/esm/HttpClient.js +9 -9
  64. package/dist/esm/HttpClient.js.map +1 -1
  65. package/dist/esm/ProcessConfinement.d.ts +1 -1
  66. package/dist/esm/ProcessConfinement.d.ts.map +1 -1
  67. package/dist/esm/ProcessConfinement.js.map +1 -1
  68. package/dist/esm/Rooted.d.ts +2 -2
  69. package/dist/esm/Rooted.d.ts.map +1 -1
  70. package/dist/esm/Rooted.js +2 -2
  71. package/dist/esm/Rooted.js.map +1 -1
  72. package/dist/esm/internal/Containment.d.ts +1 -1
  73. package/dist/esm/internal/Containment.d.ts.map +1 -1
  74. package/dist/esm/internal/Containment.js.map +1 -1
  75. package/dist/esm/internal/Pipeline.d.ts +2 -2
  76. package/dist/esm/internal/Pipeline.d.ts.map +1 -1
  77. package/dist/esm/internal/Pipeline.js +2 -2
  78. package/dist/esm/internal/Pipeline.js.map +1 -1
  79. package/dist/esm/test/HostContract.d.ts +5 -5
  80. package/dist/esm/test/HostContract.d.ts.map +1 -1
  81. package/dist/esm/test/HostContract.js +4 -4
  82. package/dist/esm/test/HostContract.js.map +1 -1
  83. package/docs/api.md +2 -2
  84. package/docs/guides/adapt-a-new-host-platform.md +3 -3
  85. package/docs/installation.md +3 -3
  86. package/docs/quickstart.md +1 -1
  87. package/docs/testing.md +1 -1
  88. package/package.json +10 -11
  89. package/src/ChildProcessSpawner.ts +5 -5
  90. package/src/CommandLine.ts +2 -2
  91. package/src/ContainedSpawner.ts +2 -6
  92. package/src/FileSystem.ts +4 -4
  93. package/src/HostServices.ts +3 -3
  94. package/src/HttpClient.ts +9 -9
  95. package/src/ProcessConfinement.ts +1 -1
  96. package/src/Rooted.ts +2 -2
  97. package/src/internal/Containment.ts +1 -1
  98. package/src/internal/Pipeline.ts +2 -2
  99. package/src/test/HostContract.ts +5 -5
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/FileSystem.ts"],
4
- "sourcesContent": ["/**\n * Permission-aware filesystem operations.\n *\n * There is no kernel `FileSystem` interface and no kernel `FileSystem` tag.\n * Effect owns both, and its tag fixes the error channel to `PlatformError`, so\n * this module is only the middleware: a `Layer` over Effect's own tag that\n * reads the raw service out of context and returns a guarded one in its place.\n * Permission failures are projected into `PlatformError` by\n * `Permission.toPlatformError`, which keeps the structured kernel failure on\n * the error's `cause`.\n *\n * Governing design:\n * `docs/specs/Concepts/Permission Kernel.md`,\n * `docs/specs/Concepts/Effect Taxonomy.md`, and\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { permissionDenied, type PermissionError, toPlatformError } from \"@smthrs/capability/Permission\"\nimport {\n Effect,\n Encoding,\n FileSystem as EffectFileSystem,\n Layer,\n Option,\n Path as EffectPath,\n PlatformError,\n Result,\n Schema,\n Sink,\n Stream\n} from \"effect\"\nimport * as Batch from \"./FileSystemBatch.ts\"\nimport { GrantStore } from \"./GrantStore.ts\"\nimport { makeCapability } from \"./internal/makeCapability.ts\"\nimport { Workspace } from \"./Workspace.ts\"\n\nexport * from \"./FileSystemBatch.ts\"\n\n/**\n * The directory name that stands in for the host's system temporary directory\n * in a capability resource. `makeTempFile` and friends called without an\n * explicit `directory` are checked against this name resolved one level above\n * the workspace root, so an implicit system-temp write names a resource that\n * is always outside the workspace envelope and is never confusable with a real\n * workspace path.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport const systemTemporaryDirectoryName = \"<system-temp>\"\n\n/**\n * Host-private extension used for race-free, descriptor-relative filesystem\n * operations. A plain path-based `FileSystem` cannot provide confinement: an\n * attacker can replace any checked component before the delegate resolves it.\n * Platform adapters opt in only when they can pin a root handle and reject\n * symlinks while traversing from it. Hosts without this extension fail closed.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const AtomicFileSystemTypeId = Symbol.for(\"@smthrs/kernel/AtomicFileSystem\")\n\n/** The pinned root every atomic request is resolved against.\n *\n * The guarded layer fills these in at the boundary from the composed\n * workspace, so a caller that builds a request leaves them out.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicRoot {\n readonly boundaryRoot?: string | undefined\n readonly logicalRoot?: string | undefined\n readonly rootIdentity?: string | undefined\n}\n\n/** A serializable operation executed relative to a pinned filesystem root.\n *\n * One member per operation, discriminated by `operation`, so a request cannot\n * omit an operand its operation needs \u2014 a `rename` carries both endpoints or\n * does not compile \u2014 and an adapter cannot quietly leave an operation\n * unimplemented. Every member is the same flat JSON object the helper protocol\n * already framed, so the wire shape is unchanged.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicRequest =\n | (AtomicRoot & { readonly operation: \"exists\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"chmod\"; readonly path: string; readonly options: { readonly mode: number } })\n | (AtomicRoot & {\n readonly operation: \"chown\"\n readonly path: string\n readonly options: { readonly uid: number; readonly gid: number }\n })\n | (AtomicRoot & {\n readonly operation: \"glob\"\n readonly pattern: string\n readonly root: string\n readonly options?: { readonly exclude?: ReadonlyArray<string> | undefined } | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"makeDirectory\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined; readonly mode?: number | undefined } | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"readDirectory\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined } | undefined\n })\n | (AtomicRoot & { readonly operation: \"readFile\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"readFileString\"\n readonly path: string\n readonly encoding?: string | undefined\n })\n | (AtomicRoot & { readonly operation: \"readLink\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"realPath\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"resolve\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"remove\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined; readonly force?: boolean | undefined } | undefined\n })\n | (AtomicRoot & { readonly operation: \"rename\"; readonly from: string; readonly to: string })\n | (AtomicRoot & { readonly operation: \"stat\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"writeFile\"\n readonly path: string\n /** Base64 of the bytes, bounded by the host's `contentLimit`. */\n readonly data: string\n readonly options?:\n | { readonly flag?: EffectFileSystem.OpenFlag | undefined; readonly mode?: number | undefined }\n | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"writeFileString\"\n readonly path: string\n readonly data: string\n readonly options?:\n | { readonly flag?: EffectFileSystem.OpenFlag | undefined; readonly mode?: number | undefined }\n | undefined\n })\n | (AtomicRoot & { readonly operation: \"batch\"; readonly requests: ReadonlyArray<AtomicBatchRequest> })\n\n/** Where a no-follow executor's `resolve` walk stopped.\n *\n * `path` is the canonical path the walk reached below the pinned root, in\n * on-disk spelling for every existing component. When `target` is `null`,\n * `path` is the whole request, with a missing component and its descendants\n * kept as requested. Otherwise `path` names the first link or reparse point\n * on the way and `target` is its text, which the executor read without\n * opening what it names.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport interface Resolution {\n readonly path: string\n readonly target: string | null\n}\n\n/** One member of an executor batch: a public read, or authorization's `resolve`.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport type AtomicBatchRequest = Batch.BatchRequest | { readonly operation: \"resolve\"; readonly path: string }\n\n/** One member's value in an executor batch.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport type AtomicBatchValue = Batch.BatchValue | { readonly operation: \"resolve\"; readonly resolution: Resolution }\n\n/** An executor batch's answer: {@link Batch.BatchResponse} over {@link AtomicBatchValue}.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport interface AtomicBatchResponse {\n readonly rootIdentity: string\n readonly entries: ReadonlyArray<{\n readonly index: number\n readonly path: string\n readonly result: Result.Result<AtomicBatchValue, PlatformError.PlatformError>\n }>\n}\n\n/** The value each atomic operation resolves to.\n *\n * The executor no longer takes the result type from its caller: an operation\n * names its own result here, so a host that answers a `stat` with a boolean is\n * a compile error rather than a decode that succeeds and reads wrong.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicResults {\n readonly exists: boolean\n readonly chmod: void\n readonly chown: void\n readonly glob: Array<string>\n readonly makeDirectory: void\n readonly readDirectory: Array<string>\n readonly readFile: Uint8Array\n readonly readFileString: string\n readonly readLink: string\n readonly realPath: string\n readonly resolve: Resolution\n readonly remove: void\n readonly rename: void\n readonly stat: EffectFileSystem.File.Info\n readonly writeFile: void\n readonly writeFileString: void\n readonly batch: AtomicBatchResponse\n}\n\n/** The result of one request, read from the operation it names.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicResult<R extends AtomicRequest> = AtomicResults[R[\"operation\"]]\n\n/** One typed implementation per operation.\n *\n * A record of this type receives each operation's own request and returns that\n * operation's own result, and a record missing an operation does not compile,\n * which is the exhaustiveness a `string` operation could not give an adapter.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicHandlers = {\n readonly [K in keyof AtomicResults]: (\n request: Extract<AtomicRequest, { readonly operation: K }>\n ) => Effect.Effect<AtomicResults[K], PlatformError.PlatformError>\n}\n\n/** Trusted host extension implementing atomic path resolution and operation.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicFileSystem {\n /**\n * The executor refuses symlinks and hard links during every handle-relative\n * operation. Authorization still resolves the on-disk path spelling, but\n * does not need a separate hard-link stat before invoking the executor.\n */\n readonly noFollowAuthorization?: true | undefined\n /** Exact composition-time identity when native file IDs exceed numeric precision. */\n readonly identifyRoot?: ((path: string) => Effect.Effect<string, PlatformError.PlatformError>) | undefined\n readonly execute: <R extends AtomicRequest>(\n request: R\n ) => Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n /**\n * A filesystem already confined by an enforceable process/filesystem\n * boundary (for example an in-memory browser volume). Methods not expressible\n * as one descriptor-relative request may delegate only through this surface.\n */\n readonly isolated?: EffectFileSystem.FileSystem | undefined\n /** Advertised only by executors implementing the bounded batch protocol. */\n readonly batchLimits?: { readonly size: number; readonly response: number } | undefined\n /**\n * Advertised byte ceiling for one serialized `writeFile` payload. The kernel\n * refuses a larger payload with a typed `BadArgument` before base64-encoding\n * it, so an executor that frames requests across a serialized host boundary\n * never asks its runtime for a string it cannot represent. Hosts delegating\n * through `isolated` receive the bytes directly and advertise nothing.\n */\n readonly contentLimit?: number | undefined\n}\n\n/** An Effect filesystem carrying the atomic host extension.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicHostFileSystem = EffectFileSystem.FileSystem & {\n readonly [AtomicFileSystemTypeId]: AtomicFileSystem\n}\n\n/** Attaches a trusted platform's descriptor-relative executor to its service.\n *\n * The executor is attached to the supplied object, so a later attachment over\n * the same service replaces this one. A host attaches exactly once at its\n * boundary; a caller that deliberately layers over an existing executor must\n * read it first and delegate to it, which is what makes replacement its own\n * decision rather than an accident.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const withAtomicFileSystem = (\n fileSystem: EffectFileSystem.FileSystem,\n atomic: AtomicFileSystem\n): AtomicHostFileSystem => Object.assign(fileSystem, { [AtomicFileSystemTypeId]: atomic })\n\n/**\n * Why a filesystem composition or guarded batch refused.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport const FileSystemFaultCode = Schema.Literals([\n \"executor_already_present\",\n \"isolated_operation_unsupported\",\n \"workspace_identity_changed\"\n])\n\n/**\n * The stable code of a {@link FileSystemFault}.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport type FileSystemFaultCode = typeof FileSystemFaultCode.Type\n\n/**\n * A broken filesystem composition or a workspace whose descriptor identity\n * changed. `withIsolatedFileSystem` throws `executor_already_present`; an\n * attested volume reaching an operation it never advertises dies with\n * `isolated_operation_unsupported` (a bug); a batch whose root no longer names\n * the authorized descriptor is the `cause` of a `Busy` `PlatformError` with\n * `workspace_identity_changed`.\n *\n * @since 1.0.0-rc.0\n * @category errors\n */\nexport class FileSystemFault extends Schema.TaggedError<FileSystemFault>()(\"@smthrs/kernel/FileSystemFault\", {\n code: FileSystemFaultCode,\n message: Schema.String\n}) {\n override readonly name = \"FileSystemFault\"\n}\n\n/**\n * Attests that a host filesystem is already isolated as a whole. Intended for\n * browser/test volumes whose implementation cannot address the host\n * filesystem at all; native path-based adapters must not use this shortcut.\n *\n * The attestation is refused for a filesystem that already carries a\n * descriptor-relative executor. That executor is the stronger guarantee, and\n * replacing it with a path-delegating one would route `access`, `copy`,\n * `chmod`, `link`, `symlink`, `open`, `watch`, `sink`, `stream`, and every\n * `makeTemp*` back through pathnames after the capability check: the exact\n * symlink-swap window this module exists to close. The refusal is a throw at\n * composition time, so a host cannot be assembled that way.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const withIsolatedFileSystem = (\n fileSystem: EffectFileSystem.FileSystem\n): AtomicHostFileSystem => {\n if (AtomicFileSystemTypeId in fileSystem) {\n throw new FileSystemFault({\n code: \"executor_already_present\",\n message:\n \"filesystem already carries a descriptor-relative executor; attesting whole-filesystem isolation would replace it\"\n })\n }\n return withAtomicFileSystem(fileSystem, {\n isolated: fileSystem,\n execute: dispatch({\n exists: (request) => fileSystem.exists(request.path),\n chmod: (request) => fileSystem.chmod(request.path, request.options.mode),\n chown: (request) => fileSystem.chown(request.path, request.options.uid, request.options.gid),\n glob: (request) => fileSystem.glob(request.pattern, { ...request.options, root: request.root }),\n makeDirectory: (request) => fileSystem.makeDirectory(request.path, request.options),\n readDirectory: (request) => fileSystem.readDirectory(request.path, request.options),\n readFile: (request) => fileSystem.readFile(request.path),\n readFileString: (request) => fileSystem.readFileString(request.path, request.encoding),\n readLink: (request) => fileSystem.readLink(request.path),\n realPath: (request) => fileSystem.realPath(request.path),\n // Authorization asks `resolve` only of an executor that claims\n // `noFollowAuthorization`, which an attested volume never does.\n resolve: (request) => unsupportedIsolated(request.operation),\n remove: (request) => fileSystem.remove(request.path, request.options),\n rename: (request) => fileSystem.rename(request.from, request.to),\n stat: (request) => fileSystem.stat(request.path),\n writeFile: (request) =>\n Encoding.decodeBase64(request.data).pipe(\n Effect.fromResult,\n Effect.orDie,\n Effect.flatMap((data) => fileSystem.writeFile(request.path, data, request.options))\n ),\n writeFileString: (request) => fileSystem.writeFileString(request.path, request.data, request.options),\n // An attested volume advertises no `batchLimits`, so the guarded layer\n // never frames a batch for this executor.\n batch: (request) => unsupportedIsolated(request.operation)\n })\n })\n}\n\nconst unsupportedIsolated = (operation: string): Effect.Effect<never> =>\n Effect.die(\n new FileSystemFault({\n code: \"isolated_operation_unsupported\",\n message: `unsupported isolated filesystem operation: ${operation}`\n })\n )\n\n/**\n * Turns a typed handler record into the executor the host extension declares.\n *\n * The record is what carries the safety: every operation is implemented, each\n * handler reads its own operands, and each returns its own result. The lookup\n * itself is one assertion because TypeScript cannot correlate an index it\n * narrowed only on the key with the request and result types that key selects.\n * An operation no handler implements can only arrive from a serialized\n * boundary that framed an operation this build does not know, so it dies\n * rather than resolving to `undefined` and being called.\n */\nconst dispatch = (handlers: AtomicHandlers): AtomicFileSystem[\"execute\"] => {\n const table = handlers as unknown as Record<\n string,\n ((request: AtomicRequest) => Effect.Effect<unknown, PlatformError.PlatformError>) | undefined\n >\n return <R extends AtomicRequest>(request: R) => {\n const handler = table[request.operation]\n return (\n handler === undefined ? unsupportedIsolated(request.operation) : handler(request)\n ) as Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n }\n}\n\n/** Prefer the host's exact file ID over the public adapter's optional numeric inode. */\nconst identifyRoot = (\n atomic: AtomicFileSystem,\n fileSystem: EffectFileSystem.FileSystem,\n path: string\n): Effect.Effect<Option.Option<string>, PlatformError.PlatformError> =>\n atomic.identifyRoot === undefined\n ? Effect.map(fileSystem.stat(path), (info) => Option.map(info.ino, (ino) => `${info.dev}:${ino}`))\n : Effect.map(atomic.identifyRoot(path), Option.some)\n\n/** The root a descriptor-relative request is resolved against, captured once. */\ninterface PinnedRoot {\n readonly boundaryRoot: string\n readonly logicalRoot: string\n readonly rootIdentity: string | undefined\n}\n\n/**\n * Stamps a request with its pinned root and runs it through the executor. The\n * one place both the guarded layer and {@link confined} build the wire request,\n * so the two surfaces cannot drift apart.\n */\nconst pinned =\n (atomic: AtomicFileSystem, root: PinnedRoot) =>\n <R extends AtomicRequest>(request: R): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic.execute<R>({ ...request, ...root })\n\nconst unconfinedDescription = \"host does not provide descriptor-relative, no-follow filesystem isolation\"\n\nconst unconfined = (method: string, pathOrDescriptor: string): PlatformError.PlatformError =>\n PlatformError.systemError({\n _tag: \"PermissionDenied\",\n module: \"FileSystem\",\n method,\n pathOrDescriptor,\n description: unconfinedDescription\n })\n\n/**\n * Brands a {@link confined} view with the logical root it is pinned to, so a\n * caller handed an already-confined view does not wrap it a second time.\n */\nconst ConfinedFileSystemTypeId = Symbol.for(\"@smthrs/kernel/ConfinedFileSystem\")\n\n/**\n * Whether {@link confined} can build a view over this filesystem: it carries a\n * descriptor-relative executor, or a whole-filesystem isolation attestation.\n * A plain path-based host answers `false`.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const isConfinable = (fileSystem: EffectFileSystem.FileSystem): boolean =>\n ConfinedFileSystemTypeId in fileSystem || AtomicFileSystemTypeId in fileSystem\n\n/**\n * The logical root a filesystem is already confined to: a {@link confined}\n * view's pinned root, or the guarded {@link layer} service's workspace root.\n * `undefined` for any other filesystem, including a host that is merely\n * confinable. Machinery that shares a filesystem with its caller confines to\n * this root, so its paths resolve exactly where the caller's do.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const confinedRoot = (fileSystem: EffectFileSystem.FileSystem): string | undefined =>\n (fileSystem as { readonly [ConfinedFileSystemTypeId]?: string })[ConfinedFileSystemTypeId]\n\n/**\n * Fails with the typed `PermissionDenied` refusal unless {@link confined} can\n * build a view over this filesystem. Composition-time check for layers that\n * pin their root later, when it is known to exist.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const requireConfinable = (\n fileSystem: EffectFileSystem.FileSystem,\n root: string\n): Effect.Effect<void, PlatformError.PlatformError> =>\n isConfinable(fileSystem) ? Effect.void : Effect.fail(unconfined(\"confined\", root))\n\n/**\n * A filesystem view confined to `root` without capability checks: engine\n * machinery that must not ask a grant store for its own bookkeeping, but must\n * still never be redirected outside the workspace.\n *\n * Every operation is one descriptor-relative request against the root pinned\n * here (its canonical path and `device:inode` identity), resolved by the host\n * helper with `O_NOFOLLOW` at each component, so there is no window between a\n * check and a write for a symlink to be swapped into. A symlink anywhere on the\n * path, a hard-linked file, `..` traversal, or a root whose identity changed is\n * refused by the host, never followed. The requests are exactly the ones the\n * guarded {@link layer} sends, minus the grant check.\n *\n * A host carrying a whole-filesystem isolation attestation\n * ({@link withIsolatedFileSystem}) is returned as it is: its attestation is\n * the boundary. So is the guarded {@link layer}'s own service when it is\n * rooted at the same workspace, since each of its path operations is already\n * one such request. A plain path-based host is refused with `PermissionDenied`, so\n * there is no path-based fallback that claims confinement. Operations that\n * cannot be expressed as one atomic request (`open`, `stream`, `sink`, `copy`,\n * `link`, `symlink`, `watch`, `truncate`, `utimes`, `access`, and every\n * `makeTemp*`) fail with the same refusal.\n *\n * The root must exist when the view is built.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const confined = (\n fileSystem: EffectFileSystem.FileSystem,\n root: string\n): Effect.Effect<EffectFileSystem.FileSystem, PlatformError.PlatformError, EffectPath.Path> =>\n Effect.gen(function*() {\n const path = yield* EffectPath.Path\n const logicalRoot = path.resolve(root === \"\" ? \".\" : root)\n if (confinedRoot(fileSystem) === logicalRoot) return fileSystem\n const atomic = (fileSystem as Partial<AtomicHostFileSystem>)[AtomicFileSystemTypeId]\n if (atomic === undefined) return yield* Effect.fail(unconfined(\"confined\", logicalRoot))\n if (atomic.isolated !== undefined) return fileSystem\n const boundaryRoot = yield* fileSystem.realPath(logicalRoot)\n const rootIdentity = yield* identifyRoot(atomic, fileSystem, boundaryRoot)\n if (Option.isNone(rootIdentity)) return yield* Effect.fail(unconfined(\"confined\", logicalRoot))\n const run = pinned(atomic, { boundaryRoot, logicalRoot, rootIdentity: rootIdentity.value })\n const normalize = (value: string): string => path.resolve(logicalRoot, value)\n const refuse = (method: string, value: string): Effect.Effect<never, PlatformError.PlatformError> =>\n Effect.fail(unconfined(method, normalize(value)))\n const view: EffectFileSystem.FileSystem = {\n ...EffectFileSystem.make({\n access: (value) => refuse(\"access\", value),\n copy: (from) => refuse(\"copy\", from),\n copyFile: (from) => refuse(\"copyFile\", from),\n chmod: (value, mode) => run({ operation: \"chmod\", path: normalize(value), options: { mode } }),\n chown: (value, uid, gid) => run({ operation: \"chown\", path: normalize(value), options: { uid, gid } }),\n glob: (pattern, options) => {\n const base = options?.root === undefined ? logicalRoot : normalize(options.root)\n return run({\n operation: \"glob\",\n pattern: path.resolve(base, pattern),\n root: base,\n options: options === undefined ? undefined : { exclude: options.exclude ?? [] }\n })\n },\n link: (from) => refuse(\"link\", from),\n makeDirectory: (value, options) =>\n run({\n operation: \"makeDirectory\",\n path: normalize(value),\n options\n }),\n makeTempDirectory: () => refuse(\"makeTempDirectory\", logicalRoot),\n makeTempDirectoryScoped: () => refuse(\"makeTempDirectoryScoped\", logicalRoot),\n makeTempFile: () => refuse(\"makeTempFile\", logicalRoot),\n makeTempFileScoped: () => refuse(\"makeTempFileScoped\", logicalRoot),\n open: (value) => refuse(\"open\", value),\n readDirectory: (value, options) =>\n run({\n operation: \"readDirectory\",\n path: normalize(value),\n options\n }),\n readFile: (value) => run({ operation: \"readFile\", path: normalize(value) }),\n readLink: (value) => run({ operation: \"readLink\", path: normalize(value) }),\n realPath: (value) => run({ operation: \"realPath\", path: normalize(value) }),\n remove: (value, options) =>\n run({\n operation: \"remove\",\n path: normalize(value),\n options\n }),\n rename: (from, to) => run({ operation: \"rename\", from: normalize(from), to: normalize(to) }),\n stat: (value) => run({ operation: \"stat\", path: normalize(value) }),\n symlink: (_from, to) => refuse(\"symlink\", to),\n truncate: (value) => refuse(\"truncate\", value),\n utimes: (value) => refuse(\"utimes\", value),\n watch: (value) => Stream.fail(unconfined(\"watch\", normalize(value))),\n writeFile: (value, data, options) => {\n const limit = atomic.contentLimit\n if (limit !== undefined && data.byteLength > limit) {\n return Effect.fail(PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"writeFile\",\n description:\n `writeFile payload of ${data.byteLength} bytes exceeds the ${limit} byte limit advertised by the host`\n }))\n }\n return run({\n operation: \"writeFile\",\n path: normalize(value),\n data: Encoding.encodeBase64(data),\n options\n })\n }\n }),\n exists: (value) => run({ operation: \"exists\", path: normalize(value) }),\n readFileString: (value, encoding) => run({ operation: \"readFileString\", path: normalize(value), encoding }),\n writeFileString: (value, data, options) =>\n run({\n operation: \"writeFileString\",\n path: normalize(value),\n data,\n options\n })\n }\n return Object.assign(view, { [ConfinedFileSystemTypeId]: logicalRoot })\n })\n\nconst readableOpenFlags: ReadonlySet<EffectFileSystem.OpenFlag> = new Set([\n \"r\",\n \"r+\",\n \"w+\",\n \"wx+\",\n \"a+\",\n \"ax+\"\n])\n\nconst writableOpenFlags: ReadonlySet<EffectFileSystem.OpenFlag> = new Set([\n \"r+\",\n \"w\",\n \"wx\",\n \"w+\",\n \"wx+\",\n \"a\",\n \"ax\",\n \"a+\",\n \"ax+\"\n])\n\nconst isInside = (path: EffectPath.Path, root: string, candidate: string): boolean => {\n const relative = path.relative(root, candidate)\n return relative === \"\" ||\n (relative !== \"..\" && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))\n}\n\n/**\n * The `device:inode` identity a descriptor-bound authorization pins, or\n * `Option.none` when the entry is not a regular file or the host reports no\n * inode identity. A host without inode identity is an isolated volume, and its\n * isolation attestation \u2014 not inode evidence \u2014 is the confinement boundary.\n */\nconst identityOf = (info: EffectFileSystem.File.Info): Option.Option<string> =>\n info.type === \"File\"\n ? Option.map(info.ino, (ino) => `${info.dev}:${ino}`)\n : Option.none()\n\n/**\n * Resolves a path through every existing ancestor and maps paths inside the\n * canonical workspace back to the stable logical workspace root. Existing\n * symlinks therefore cannot turn an inside-workspace grant into outside\n * authority, while capability resources remain stable when the root itself is\n * a symlink. The host's `realPath` must return the on-disk spelling of existing\n * components, including on case-insensitive volumes. Native Node hosts use\n * the promise-based `realpath`, which uses the native implementation.\n *\n * @category security\n * @since 1.0.0-rc.0\n */\nexport const canonicalResource = (\n fileSystem: EffectFileSystem.FileSystem,\n path: EffectPath.Path,\n workspaceRoot: string,\n value: string\n): Effect.Effect<string, PlatformError.PlatformError> => {\n const normalizedRoot = path.normalize(workspaceRoot)\n const normalizedValue = path.normalize(\n path.isAbsolute(value) ? value : path.resolve(normalizedRoot, value)\n )\n const resolveExistingAncestor = (\n candidate: string,\n symlinkDepth = 0\n ): Effect.Effect<string, PlatformError.PlatformError> =>\n fileSystem.realPath(candidate).pipe(\n Effect.catch((error) => {\n const resolveParent = () => {\n const parent = path.dirname(candidate)\n if (parent === candidate) {\n return Effect.fail(error)\n }\n return resolveExistingAncestor(parent, symlinkDepth).pipe(\n Effect.map((resolvedParent) => path.join(resolvedParent, path.basename(candidate)))\n )\n }\n return fileSystem.readLink(candidate).pipe(\n Effect.matchEffect({\n onFailure: resolveParent,\n onSuccess: (target) =>\n symlinkDepth >= 40\n ? Effect.fail(error)\n : resolveExistingAncestor(\n path.isAbsolute(target) ? target : path.resolve(path.dirname(candidate), target),\n symlinkDepth + 1\n )\n })\n )\n })\n )\n\n return Effect.all([\n fileSystem.realPath(normalizedRoot),\n resolveExistingAncestor(normalizedValue)\n ]).pipe(\n Effect.map(([canonicalRoot, canonicalValue]) =>\n isInside(path, canonicalRoot, canonicalValue)\n ? path.normalize(path.join(normalizedRoot, path.relative(canonicalRoot, canonicalValue)))\n : path.normalize(canonicalValue)\n )\n )\n}\n\ntype PinnedRun = <R extends AtomicRequest>(\n request: R\n) => Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n\nconst uninspectable = \"path component could not be inspected without following it\"\n\n/** `value` spelled below the pinned boundary root, or `undefined` outside both roots. */\nconst pinnedPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string\n): string | undefined => {\n const base = isInside(path, root.logicalRoot, value)\n ? root.logicalRoot\n : isInside(path, root.boundaryRoot, value)\n ? root.boundaryRoot\n : undefined\n return base === undefined ? undefined : path.join(root.boundaryRoot, path.relative(base, value))\n}\n\nconst segmentsBelow = (path: EffectPath.Path, root: string, value: string): Array<string> =>\n path.relative(root, value).split(path.sep).filter((segment) => segment !== \"\")\n\n/** Resolve a glob's literal prefix, keeping pattern syntax out of filename lookups. */\nconst globAuthorizationPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string,\n glob: boolean\n): { readonly prefix: string; readonly suffix: ReadonlyArray<string> } => {\n const requested = glob ? pinnedPath(path, root, value) : undefined\n if (requested === undefined) return { prefix: value, suffix: [] }\n // The workspace's own name is literal even if it contains glob metacharacters.\n const parts = segmentsBelow(path, root.boundaryRoot, requested)\n const wildcard = parts.findIndex((part) => /[*?[{]|[@+!]\\(/.test(part))\n return wildcard < 0\n ? { prefix: value, suffix: [] }\n // Keep logical spelling so the executor mapping pins the prefix exactly once.\n : { prefix: path.join(root.logicalRoot, ...parts.slice(0, wildcard)), suffix: parts.slice(wildcard) }\n}\n\n/**\n * Resolves the resource a no-follow executor addresses without resolving any\n * pathname on the host. Windows `realpath` opens its argument through every\n * link, so asking the host about a planted link to `\\\\.\\pipe\\name` or\n * `\\\\host\\share\\x` connects to that pipe or share during authorization,\n * and a component swapped for a link between two host checks is followed\n * even when each check alone was safe (#2882).\n *\n * The executor answers one descriptor-relative `resolve` request from the\n * pinned root instead ({@link Resolution}): existing components in their\n * on-disk spelling, a missing component and its descendants as requested, or\n * the first link on the way with its text. Link text is resolved lexically\n * and asked again, and a result outside both roots is returned untouched for\n * the caller to deny. Any failure is refused.\n */\nconst confinedResource = <E>(\n run: PinnedRun,\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string,\n refuse: (resource: string, reason: string, cause?: PlatformError.PlatformError) => Effect.Effect<never, E>,\n symlinkDepth = 0\n): Effect.Effect<string, E> => {\n const requested = pinnedPath(path, root, value)\n if (requested === undefined) {\n return Effect.succeed(value)\n }\n return run({ operation: \"resolve\", path: requested }).pipe(\n Effect.matchEffect({\n onFailure: (cause) => refuse(logicalPath(path, root, requested), uninspectable, cause),\n onSuccess: (resolution) => followResolution(run, path, root, requested, resolution, refuse, symlinkDepth)\n })\n )\n}\n\nconst logicalPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n canonical: string\n): string => path.normalize(path.join(root.logicalRoot, path.relative(root.boundaryRoot, canonical)))\n\n/** Turns one executor {@link Resolution} of `requested` into the resource it names. */\nconst followResolution = <E>(\n run: PinnedRun,\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n requested: string,\n resolution: Resolution,\n refuse: (resource: string, reason: string, cause?: PlatformError.PlatformError) => Effect.Effect<never, E>,\n symlinkDepth: number\n): Effect.Effect<string, E> => {\n const resolved = path.normalize(resolution.path)\n if (!isInside(path, root.boundaryRoot, resolved)) {\n return refuse(logicalPath(path, root, requested), \"path resolves outside the pinned root\")\n }\n if (resolution.target === null) {\n return Effect.succeed(logicalPath(path, root, resolved))\n }\n if (symlinkDepth >= 40) {\n return refuse(logicalPath(path, root, resolved), \"too many levels of symbolic links\")\n }\n const rest = segmentsBelow(path, root.boundaryRoot, requested).slice(\n segmentsBelow(path, root.boundaryRoot, resolved).length\n )\n return confinedResource(\n run,\n path,\n root,\n path.resolve(path.dirname(resolved), resolution.target, ...rest),\n refuse,\n symlinkDepth + 1\n )\n}\n\n/** A public read's batch value; a `resolve` answer to a read is a host defect and fails closed. */\nconst publicValue = (\n resource: string,\n result: Result.Result<AtomicBatchValue, PlatformError.PlatformError>\n): Result.Result<Batch.BatchValue, PlatformError.PlatformError> =>\n Result.isFailure(result) || result.success.operation !== \"resolve\"\n ? result as Result.Result<Batch.BatchValue, PlatformError.PlatformError>\n : Result.fail(PlatformError.systemError({\n _tag: \"PermissionDenied\",\n module: \"FileSystem\",\n method: \"batch\",\n pathOrDescriptor: resource,\n description: \"executor answered a batch read with a resolution\"\n }))\n\n/**\n * Decorates Effect's filesystem service in place with workspace-normalized\n * capability checks. Every host resolves canonical path spelling before the\n * capability check and again after every grant decision. Descriptor-relative\n * executors enforce hard-link refusal themselves; other hosts also run the\n * hard-link guard here. A decision can\n * suspend (an attended request, a journal-backed store), and an operation\n * whose path no longer names the resource that was authorized is refused\n * rather than performed. Open file handles bind their authorization to the\n * `device:inode` identity fstat'd at open time and refuse any operation once\n * the authorized path names a different resource.\n *\n * The layer provides the tag it also requires: compose it over a host\n * filesystem layer with `Layer.provide` and every consumer of\n * `FileSystem.FileSystem` \u2014 including one that never heard of the kernel \u2014\n * resolves the guarded implementation. A denied request surfaces as a\n * `PlatformError` whose reason is `PermissionDenied` and whose `cause` is the\n * kernel's own `PermissionRequired`, `PermissionDenied`, or `GrantStoreError`;\n * `Permission.fromPlatformError` reads it back.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer: Layer.Layer<\n EffectFileSystem.FileSystem,\n PlatformError.PlatformError,\n EffectFileSystem.FileSystem | EffectPath.Path | Workspace | GrantStore\n> = Layer.effect(\n EffectFileSystem.FileSystem,\n Effect.gen(function*() {\n const fileSystem = yield* EffectFileSystem.FileSystem\n const path = yield* EffectPath.Path\n const workspace = yield* Workspace\n const grants = yield* GrantStore\n const atomic = (fileSystem as Partial<AtomicHostFileSystem>)[AtomicFileSystemTypeId]\n const normalizeFrom = (base: string, value: string): string =>\n path.normalize(path.isAbsolute(value) ? value : path.resolve(base, value))\n const logicalRoot = path.normalize(path.resolve(workspace.root))\n const normalize = (value: string): string => normalizeFrom(logicalRoot, value)\n const boundaryRoot = yield* fileSystem.realPath(logicalRoot)\n // Descriptor-relative hosts need the composition-time identity even when\n // they expose no batching. Already-isolated volumes need no native inode.\n const rootIdentity = atomic === undefined || (atomic.isolated !== undefined && atomic.batchLimits === undefined)\n ? Option.none<string>()\n : yield* identifyRoot(atomic, fileSystem, boundaryRoot)\n const root: PinnedRoot = { boundaryRoot, logicalRoot, rootIdentity: Option.getOrUndefined(rootIdentity) }\n const refuse = (method: string, resource: string) => (error: PermissionError): PlatformError.PlatformError =>\n toPlatformError({ module: \"FileSystem\", method, pathOrDescriptor: resource, error })\n const deny = (\n action: \"fs:read\" | \"fs:write\",\n method: string,\n resource: string,\n reason: string,\n cause?: PlatformError.PlatformError\n ) =>\n makeCapability(action, resource).pipe(\n Effect.flatMap((capability) => {\n const failure = permissionDenied(capability, reason)\n // Keep the permission identity and the typed inspection failure together.\n if (cause !== undefined) Object.defineProperty(failure, \"cause\", { value: cause })\n return Effect.fail(failure)\n }),\n Effect.mapError(refuse(method, resource)),\n Effect.mapError((failure) =>\n cause?.reason.description === undefined\n ? failure\n : PlatformError.systemError({\n ...failure.reason,\n _tag: \"PermissionDenied\",\n description: cause.reason.description,\n cause: failure.reason.cause\n })\n )\n )\n const insideWorkspace = (action: \"fs:read\" | \"fs:write\", method: string) => (resource: string) =>\n isInside(path, logicalRoot, resource)\n ? Effect.succeed(resource)\n : deny(action, method, resource, \"path is outside the workspace\")\n /**\n * Resolves the on-disk resource spelling even for no-follow executors:\n * a differently cased name can address the same file. No-follow executors\n * resolve through {@link confinedResource}, one executor request that\n * reads link text instead of following links. `guard` runs it twice \u2014 once\n * before the grant decision and once after \u2014 so the resolution must be a\n * pure question about the current filesystem state.\n */\n const resolvedResource = (\n action: \"fs:read\" | \"fs:write\",\n method: string,\n value: string,\n glob = false\n ): Effect.Effect<string, PlatformError.PlatformError> => {\n const normalized = normalize(value)\n if (atomic?.noFollowAuthorization === true) {\n const { prefix, suffix } = globAuthorizationPath(path, root, normalized, glob)\n return confinedResource(\n pinned(atomic, root),\n path,\n root,\n prefix,\n (resource, reason, cause) => deny(action, method, resource, reason, cause)\n ).pipe(\n Effect.map((resource) => suffix.length === 0 ? resource : path.join(resource, ...suffix)),\n Effect.flatMap(insideWorkspace(action, method))\n )\n }\n return canonicalResource(fileSystem, path, logicalRoot, normalized).pipe(\n Effect.flatMap((resource) =>\n fileSystem.stat(normalized).pipe(\n Effect.matchEffect({\n onFailure: () => Effect.succeed(resource),\n onSuccess: (info) => {\n const hardLinked = info.type === \"File\" && Option.isSome(info.nlink) && info.nlink.value > 1\n return hardLinked\n ? deny(action, method, resource, \"hard-linked files cannot be confined to the workspace\")\n : Effect.succeed(resource)\n }\n })\n )\n )\n )\n }\n /**\n * Resolves every read of one batch. A no-follow executor that batches\n * answers all of them in one `resolve` batch, so authorizing a batch\n * costs one executor request rather than one per member; only a member\n * that meets a link asks again, for its target. Other hosts resolve each\n * member with bounded concurrency.\n */\n const resolvedResources = (\n values: ReadonlyArray<Pick<Batch.BatchRequest, \"operation\" | \"path\">>\n ): Effect.Effect<Array<Result.Result<string, PlatformError.PlatformError>>, PlatformError.PlatformError> => {\n const refuseRead = (resource: string, reason: string, cause?: PlatformError.PlatformError) =>\n deny(\"fs:read\", \"read\", resource, reason, cause)\n if (atomic?.noFollowAuthorization !== true || atomic.batchLimits === undefined) {\n return Effect.forEach(\n values,\n (value) => Effect.result(resolvedResource(\"fs:read\", \"read\", value.path, value.operation === \"glob\")),\n {\n concurrency: Batch.fallbackConcurrency\n }\n )\n }\n const run = pinned(atomic, root)\n const parts = values.map((value) =>\n globAuthorizationPath(path, root, normalize(value.path), value.operation === \"glob\")\n )\n const requested = parts.map(({ prefix }) => pinnedPath(path, root, prefix))\n const members: Array<{ readonly operation: \"resolve\"; readonly path: string }> = []\n const memberOf = requested.map((value) =>\n value === undefined ? undefined : members.push({ operation: \"resolve\", path: value }) - 1\n )\n const answered = members.length === 0\n ? Effect.succeed<AtomicBatchResponse[\"entries\"]>([])\n : Effect.map(run({ operation: \"batch\", requests: members }), (response) => response.entries)\n return Effect.flatMap(answered, (entries) => {\n const results = new Map(entries.map((entry) => [entry.index, entry.result] as const))\n return Effect.forEach(values, (value, index) => {\n const member = memberOf[index]\n const resource = member === undefined\n ? Effect.succeed(normalize(value.path))\n : Effect.suspend(() => {\n const pinnedValue = members[member]!.path\n const result = results.get(member)\n // The executor's batch framing already requires one entry per\n // member; an answer of another shape is refused, not guessed.\n return result === undefined || Result.isFailure(result) || result.success.operation !== \"resolve\"\n ? refuseRead(\n logicalPath(path, root, pinnedValue),\n uninspectable,\n result !== undefined && Result.isFailure(result) ? result.failure : undefined\n )\n : followResolution(run, path, root, pinnedValue, result.success.resolution, refuseRead, 0)\n })\n return Effect.result(resource.pipe(\n Effect.map((resolved) =>\n parts[index]!.suffix.length === 0 ? resolved : path.join(resolved, ...parts[index]!.suffix)\n ),\n Effect.flatMap(insideWorkspace(\"fs:read\", \"read\"))\n ))\n }, { concurrency: Batch.fallbackConcurrency })\n })\n }\n const guard = (\n action: \"fs:read\" | \"fs:write\",\n value: string,\n glob = false\n ): Effect.Effect<void, PlatformError.PlatformError> => {\n const method = action === \"fs:read\" ? \"read\" : \"write\"\n return resolvedResource(action, method, value, glob).pipe(\n Effect.flatMap((resource) =>\n makeCapability(action, resource).pipe(\n Effect.flatMap((capability) => grants.check(capability)),\n Effect.mapError(refuse(method, resource)),\n // The grant decision can suspend \u2014 an attended request waiting for\n // a human, a journal-backed store doing IO. What was authorized is\n // the resource the path named at check time, so the path must\n // still name it when the decision arrives: a symlink or rename\n // swapped in during the wait is refused, never followed.\n Effect.andThen(resolvedResource(action, method, value, glob)),\n Effect.flatMap((settled) =>\n settled === resource\n ? Effect.void\n : deny(action, method, resource, \"path no longer names the resource that was authorized\")\n )\n )\n )\n )\n }\n const read = (value: string) => guard(\"fs:read\", value)\n const write = (value: string) => guard(\"fs:write\", value)\n const atomicUnavailable = (\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string\n ): Effect.Effect<never, PlatformError.PlatformError> =>\n deny(\n action,\n method,\n normalize(value),\n unconfinedDescription\n )\n const atomicOne = <R extends AtomicRequest>(\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string,\n request: R\n ): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic === undefined\n ? atomicUnavailable(action, value, method)\n : guard(action, value, request.operation === \"glob\").pipe(Effect.andThen(pinned(atomic, root)(request)))\n const atomicTwo = <R extends AtomicRequest>(\n first: readonly [\"fs:read\" | \"fs:write\", string],\n second: readonly [\"fs:read\" | \"fs:write\", string],\n method: string,\n request: R\n ): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic === undefined\n ? atomicUnavailable(first[0], first[1], method)\n : guard(first[0], first[1]).pipe(\n Effect.andThen(guard(second[0], second[1])),\n Effect.andThen(pinned(atomic, root)(request))\n )\n const isolatedOne = <A>(\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string,\n use: (isolated: EffectFileSystem.FileSystem) => Effect.Effect<A, PlatformError.PlatformError>\n ): Effect.Effect<A, PlatformError.PlatformError> =>\n atomic?.isolated === undefined\n ? atomicUnavailable(action, value, method)\n : guard(action, value).pipe(Effect.andThen(use(atomic.isolated)))\n const isolatedTwo = <A>(\n first: readonly [\"fs:read\" | \"fs:write\", string],\n second: readonly [\"fs:read\" | \"fs:write\", string],\n method: string,\n use: (isolated: EffectFileSystem.FileSystem) => Effect.Effect<A, PlatformError.PlatformError>\n ): Effect.Effect<A, PlatformError.PlatformError> =>\n atomic?.isolated === undefined\n ? atomicUnavailable(first[0], first[1], method)\n : guard(first[0], first[1]).pipe(\n Effect.andThen(guard(second[0], second[1])),\n Effect.andThen(use(atomic.isolated))\n )\n const temp = (directory: string | undefined) =>\n directory === undefined\n ? write(path.resolve(workspace.root, \"..\", systemTemporaryDirectoryName))\n : write(directory)\n const snapshotOptions = <T>(value: T): T => {\n if (Array.isArray(value)) return Object.freeze(value.map(snapshotOptions)) as T\n if (typeof value !== \"object\" || value === null) return value\n const snapshot: Record<string, unknown> = {}\n for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (!descriptor.enumerable) continue\n if (!(\"value\" in descriptor)) throw new TypeError(\"filesystem options must contain only data properties\")\n snapshot[name] = snapshotOptions(descriptor.value)\n }\n return Object.freeze(snapshot) as T\n }\n const normalizeTempOptions = <T extends { readonly directory?: string | undefined }>(options: T | undefined) =>\n options?.directory === undefined ? options : { ...options, directory: normalize(options.directory) }\n const openChecks = (value: string, flag: EffectFileSystem.OpenFlag) => {\n const readable = readableOpenFlags.has(flag)\n const writable = writableOpenFlags.has(flag)\n return readable && writable ?\n read(value).pipe(Effect.andThen(write(value))) :\n writable ?\n write(value) :\n read(value)\n }\n const descriptorRefusal = (action: \"fs:read\" | \"fs:write\", value: string) =>\n deny(\n action,\n action === \"fs:read\" ? \"read\" : \"write\",\n normalize(value),\n \"descriptor no longer names the resource at its authorized path\"\n )\n /**\n * Confirms an open descriptor still names the resource its authorization\n * bound: the `device:inode` identity fstat'd at open time must be what the\n * authorized path names right now. Rechecking the pathname alone would\n * re-authorize the CURRENT occupant of the path and then delegate to the\n * OLD descriptor \u2014 after a rename that descriptor can name an inode\n * outside the workspace even though the replacement path is still allowed.\n * A host that reports no inode identity is an isolated volume whose\n * attestation is the boundary; there is no descriptor evidence to verify.\n */\n const verifyDescriptor = (\n host: EffectFileSystem.FileSystem,\n action: \"fs:read\" | \"fs:write\",\n value: string,\n identity: Option.Option<string>\n ): Effect.Effect<void, PlatformError.PlatformError> =>\n Option.match(identity, {\n onNone: () => Effect.void,\n onSome: (bound) =>\n host.stat(normalize(value)).pipe(\n Effect.matchEffect({\n onFailure: () => descriptorRefusal(action, value),\n onSuccess: (info) =>\n Option.match(identityOf(info), {\n onNone: () => descriptorRefusal(action, value),\n onSome: (current) => current === bound ? Effect.void : descriptorRefusal(action, value)\n })\n })\n )\n })\n const wrapFile = (\n host: EffectFileSystem.FileSystem,\n file: EffectFileSystem.File,\n value: string,\n identity: Option.Option<string>\n ): EffectFileSystem.File => {\n const readable = Effect.suspend(() =>\n read(value).pipe(Effect.andThen(verifyDescriptor(host, \"fs:read\", value, identity)))\n )\n const writable = Effect.suspend(() =>\n write(value).pipe(Effect.andThen(verifyDescriptor(host, \"fs:write\", value, identity)))\n )\n return {\n [EffectFileSystem.FileTypeId]: EffectFileSystem.FileTypeId,\n stat: Effect.fn(\"FileSystem.File.stat\")(() => readable.pipe(Effect.andThen(file.stat)))(),\n seek: Effect.fn(\"FileSystem.File.seek\")(file.seek),\n sync: Effect.fn(\"FileSystem.File.sync\")(() => writable.pipe(Effect.andThen(file.sync)))(),\n read: Effect.fn(\"FileSystem.File.read\")((buffer) => readable.pipe(Effect.andThen(file.read(buffer)))),\n readAlloc: Effect.fn(\"FileSystem.File.readAlloc\")((size) =>\n readable.pipe(Effect.andThen(file.readAlloc(size)))\n ),\n truncate: Effect.fn(\"FileSystem.File.truncate\")((length) =>\n writable.pipe(Effect.andThen(file.truncate(length)))\n ),\n write: Effect.fn(\"FileSystem.File.write\")((buffer) => writable.pipe(Effect.andThen(file.write(buffer)))),\n writeAll: Effect.fn(\"FileSystem.File.writeAll\")((buffer) =>\n writable.pipe(Effect.andThen(file.writeAll(buffer)))\n )\n }\n }\n // `EffectFileSystem.make` brands the implementation with Effect's own\n // (non-exported) type id. The five operations `make` would derive from\n // the primitives are overridden below with guarded delegates to the host\n // implementation, so delegation semantics do not change.\n const guarded: EffectFileSystem.FileSystem = {\n ...EffectFileSystem.make({\n access: Effect.fn(\"FileSystem.access\")((value, options) => {\n const captured = snapshotOptions(options)\n return isolatedOne(\"fs:read\", value, \"access\", (host) => host.access(normalize(value), captured))\n }),\n copy: Effect.fn(\"FileSystem.copy\")((from, to, options) => {\n const captured = snapshotOptions(options)\n return (\n isolatedTwo(\n [\"fs:read\", from],\n [\"fs:write\", to],\n \"copy\",\n (host) => host.copy(normalize(from), normalize(to), captured)\n )\n )\n }),\n copyFile: Effect.fn(\"FileSystem.copyFile\")((from, to) =>\n isolatedTwo(\n [\"fs:read\", from],\n [\"fs:write\", to],\n \"copyFile\",\n (host) => host.copyFile(normalize(from), normalize(to))\n )\n ),\n chmod: Effect.fn(\"FileSystem.chmod\")((value, mode) =>\n atomicOne(\"fs:write\", value, \"chmod\", { operation: \"chmod\", path: normalize(value), options: { mode } })\n ),\n chown: Effect.fn(\"FileSystem.chown\")((value, uid, gid) =>\n atomicOne(\"fs:write\", value, \"chown\", {\n operation: \"chown\",\n path: normalize(value),\n options: { uid, gid }\n })\n ),\n glob: Effect.fn(\"FileSystem.glob\")((pattern, options) => {\n const captured = snapshotOptions(options)\n const root = captured?.root === undefined ? workspace.root : normalize(captured.root)\n const normalizedPattern = normalizeFrom(root, pattern)\n return atomicOne(\"fs:read\", normalizedPattern, \"glob\", {\n operation: \"glob\",\n pattern: normalizedPattern,\n root,\n options: captured === undefined ? undefined : { exclude: captured.exclude ?? [] }\n })\n }),\n link: Effect.fn(\"FileSystem.link\")((from, to) =>\n isolatedTwo([\"fs:read\", from], [\"fs:write\", to], \"link\", (host) => host.link(normalize(from), normalize(to)))\n ),\n makeDirectory: Effect.fn(\"FileSystem.makeDirectory\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"makeDirectory\", {\n operation: \"makeDirectory\",\n path: normalize(value),\n options: captured\n })\n }),\n makeTempDirectory: Effect.fn(\"FileSystem.makeTempDirectory\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempDirectory\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempDirectory(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempDirectoryScoped: Effect.fn(\"FileSystem.makeTempDirectoryScoped\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempDirectoryScoped\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempDirectoryScoped(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempFile: Effect.fn(\"FileSystem.makeTempFile\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempFile\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempFile(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempFileScoped: Effect.fn(\"FileSystem.makeTempFileScoped\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempFileScoped\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempFileScoped(normalizeTempOptions(captured)))\n )\n )\n }),\n open: Effect.fn(\"FileSystem.open\")((value, options) => {\n const captured = snapshotOptions(options)\n const flag = captured?.flag ?? \"r\"\n const isolated = atomic?.isolated\n return isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"open\")\n : openChecks(value, flag).pipe(\n Effect.andThen(isolated.open(normalize(value), captured)),\n // fstat the handle the moment it exists: the authorization the\n // open checks granted binds to THIS resource identity, and every\n // later handle operation verifies the authorized path still\n // names it before delegating to the descriptor.\n Effect.flatMap((file) =>\n file.stat.pipe(\n Effect.map((info) => wrapFile(isolated, file, value, identityOf(info)))\n )\n )\n )\n }),\n readDirectory: Effect.fn(\"FileSystem.readDirectory\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:read\", value, \"readDirectory\", {\n operation: \"readDirectory\",\n path: normalize(value),\n options: captured\n })\n }),\n readFile: Effect.fn(\"FileSystem.readFile\")((value) =>\n atomicOne(\"fs:read\", value, \"readFile\", {\n operation: \"readFile\",\n path: normalize(value)\n })\n ),\n readLink: Effect.fn(\"FileSystem.readLink\")((value) =>\n atomicOne(\"fs:read\", value, \"readLink\", {\n operation: \"readLink\",\n path: normalize(value)\n })\n ),\n realPath: Effect.fn(\"FileSystem.realPath\")((value) =>\n atomicOne(\"fs:read\", value, \"realPath\", {\n operation: \"realPath\",\n path: normalize(value)\n })\n ),\n remove: Effect.fn(\"FileSystem.remove\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"remove\", {\n operation: \"remove\",\n path: normalize(value),\n options: captured\n })\n }),\n rename: Effect.fn(\"FileSystem.rename\")((from, to) =>\n atomicTwo([\"fs:write\", from], [\"fs:write\", to], \"rename\", {\n operation: \"rename\",\n from: normalize(from),\n to: normalize(to)\n })\n ),\n stat: Effect.fn(\"FileSystem.stat\")((value) =>\n atomicOne(\"fs:read\", value, \"stat\", {\n operation: \"stat\",\n path: normalize(value)\n })\n ),\n symlink: Effect.fn(\"FileSystem.symlink\")((from, to) =>\n isolatedOne(\"fs:write\", to, \"symlink\", (host) => host.symlink(from, normalize(to)))\n ),\n truncate: Effect.fn(\"FileSystem.truncate\")((value, length) =>\n isolatedOne(\"fs:write\", value, \"truncate\", (host) => host.truncate(normalize(value), length))\n ),\n utimes: Effect.fn(\"FileSystem.utimes\")((value, atime, mtime) =>\n isolatedOne(\"fs:write\", value, \"utimes\", (host) => host.utimes(normalize(value), atime, mtime))\n ),\n watch: (value) =>\n Stream.unwrap(\n Effect.fn(\"FileSystem.watch\")(() =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"watch\")\n : read(value).pipe(Effect.map(() => atomic.isolated!.watch(normalize(value))))\n )\n )()\n ),\n writeFile: Effect.fn(\"FileSystem.writeFile\")((value, data, options) => {\n const captured = snapshotOptions(options)\n const bytes = data.slice()\n // An isolated host shares this address space, so the detached\n // snapshot crosses no serialization boundary: hand it straight to\n // the delegate rather than base64 round-tripping it through the\n // serializable request shape.\n if (atomic?.isolated !== undefined) {\n return isolatedOne(\n \"fs:write\",\n value,\n \"writeFile\",\n (host) => host.writeFile(normalize(value), bytes, captured)\n )\n }\n // A serialized executor frames the base64 payload as one JS string.\n // Refuse what its runtime cannot represent before encoding, so an\n // oversized artifact is a typed BadArgument and not a defect out of\n // the encoder.\n const limit = atomic?.contentLimit\n if (limit !== undefined && bytes.byteLength > limit) {\n return Effect.fail(PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"writeFile\",\n description:\n `writeFile payload of ${bytes.byteLength} bytes exceeds the ${limit} byte limit advertised by the host`\n }))\n }\n return atomicOne(\"fs:write\", value, \"writeFile\", {\n operation: \"writeFile\",\n path: normalize(value),\n data: Encoding.encodeBase64(bytes),\n options: captured\n })\n })\n }),\n exists: Effect.fn(\"FileSystem.exists\")((value) =>\n atomicOne(\"fs:read\", value, \"exists\", {\n operation: \"exists\",\n path: normalize(value)\n })\n ),\n readFileString: Effect.fn(\"FileSystem.readFileString\")((value, encoding) =>\n atomicOne(\"fs:read\", value, \"readFileString\", {\n operation: \"readFileString\",\n path: normalize(value),\n encoding\n })\n ),\n sink: (value, options) => {\n const captured = snapshotOptions(options)\n return (\n Sink.unwrap(\n Effect.fn(\"FileSystem.sink\")(\n () =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:write\", value, \"sink\")\n : write(value).pipe(Effect.map(() => atomic.isolated!.sink(normalize(value), captured)))\n )\n )()\n )\n )\n },\n stream: (value, options) => {\n const captured = snapshotOptions(options)\n return (\n Stream.unwrap(\n Effect.fn(\"FileSystem.stream\")(() =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"stream\")\n : read(value).pipe(Effect.map(() => atomic.isolated!.stream(normalize(value), captured)))\n )\n )()\n )\n )\n },\n writeFileString: Effect.fn(\"FileSystem.writeFileString\")((value, data, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"writeFileString\", {\n operation: \"writeFileString\",\n path: normalize(value),\n data,\n options: captured\n })\n })\n }\n // Every path operation of the guarded surface is already one\n // descriptor-relative request against this root (or refuses), so machinery\n // composed over it may use it as its confined view.\n Object.assign(guarded, { [ConfinedFileSystemTypeId]: logicalRoot })\n if (atomic === undefined || atomic.batchLimits === undefined) {\n return guarded\n } else {\n const limits = atomic.batchLimits\n const executeBatch: Batch.FileSystemBatch[\"execute\"] = Effect.fn(\"FileSystem.batch\")(function*(requests) {\n if (requests.length === 0 || requests.length > Math.min(limits.size, Batch.maxBatchSize)) {\n return yield* Effect.fail(\n PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"batch\",\n description: `batch must contain 1 to ${Math.min(limits.size, Batch.maxBatchSize)} operations`\n })\n )\n }\n if (Option.isNone(rootIdentity)) {\n return yield* atomicUnavailable(\"fs:read\", logicalRoot, \"batch\")\n }\n // Snapshot before any asynchronous root or permission checks.\n const captured = snapshotOptions(requests).map((request) => ({\n ...request,\n path: request.operation === \"glob\"\n ? normalizeFrom(normalize(request.root), request.path)\n : normalize(request.path),\n ...(request.operation === \"glob\" ? { root: normalize(request.root) } : {})\n }))\n const rootChanged = (cause: unknown) =>\n PlatformError.systemError({\n _tag: \"Busy\",\n module: \"FileSystem\",\n method: \"batch\",\n pathOrDescriptor: logicalRoot,\n description: \"batch root no longer names the authorized descriptor\",\n cause\n })\n // A vanished workspace is a lost boundary, not N absent files. Check\n // before canonical resource resolution could turn it into per-path\n // NotFound results. Check the logical path as well: a workspace alias\n // may be retargeted while its old canonical directory still exists.\n // The helper separately checks the canonical root through no-follow\n // handles, binding both names to the same captured descriptor.\n const expectedRoot = rootIdentity.value\n const verifyRoot = () =>\n identifyRoot(atomic, fileSystem, logicalRoot).pipe(\n Effect.mapError(rootChanged),\n Effect.flatMap((current) =>\n Option.isSome(current) && current.value === expectedRoot\n ? Effect.void\n : Effect.fail(rootChanged(\n new FileSystemFault({\n code: \"workspace_identity_changed\",\n message: \"workspace descriptor identity changed\"\n })\n ))\n )\n )\n yield* verifyRoot()\n // Resolve in bounded groups while retaining request-order grant\n // decisions. Quota/once grants therefore retain their ordering, and\n // native metadata latency need not serialize every member twice.\n const resources = yield* resolvedResources(captured)\n const admitted: Array<Batch.BatchRequest> = []\n const indexes: Array<number> = []\n const entries: Array<Batch.BatchEntry> = []\n const granted: Array<\n { readonly request: Batch.BatchRequest; readonly index: number; readonly resource: string }\n > = []\n for (const [index, request] of captured.entries()) {\n const resource = resources[index]!\n const checked = Result.isFailure(resource) ? Result.fail(resource.failure) : yield* Effect.result(\n makeCapability(\"fs:read\", resource.success).pipe(\n Effect.flatMap((capability) => grants.check(capability)),\n Effect.mapError(refuse(\"read\", resource.success))\n )\n )\n if (Result.isFailure(checked)) {\n entries.push({ index, path: request.path, result: Result.fail(checked.failure) })\n } else granted.push({ request, index, resource: Result.getOrThrow(resource) })\n }\n const current = granted.length === 0\n ? []\n : yield* resolvedResources(granted.map(({ request }) => request))\n const settled = yield* Effect.forEach(granted, ({ resource }, position) => {\n const now = current[position]!\n return Effect.result(\n Result.isFailure(now)\n ? Effect.fail(now.failure)\n : now.success === resource\n ? Effect.void\n : deny(\"fs:read\", \"read\", resource, \"path no longer names the resource that was authorized\")\n )\n })\n for (const [position, member] of granted.entries()) {\n const checked = settled[position]!\n if (Result.isFailure(checked)) {\n entries.push({ index: member.index, path: member.request.path, result: Result.fail(checked.failure) })\n } else {\n admitted.push(member.request)\n indexes.push(member.index)\n }\n }\n yield* verifyRoot()\n if (admitted.length > 0) {\n const measured = yield* atomic.execute({\n operation: \"batch\",\n boundaryRoot,\n logicalRoot,\n rootIdentity: rootIdentity.value,\n requests: admitted\n })\n for (const entry of measured.entries) {\n entries.push({\n index: indexes[entry.index]!,\n path: entry.path,\n result: publicValue(entry.path, entry.result)\n })\n }\n }\n entries.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.index - b.index)\n return { rootIdentity: rootIdentity.value, entries }\n })\n return Object.assign(guarded, {\n [Batch.FileSystemBatchTypeId]: {\n maxSize: Math.min(limits.size, Batch.maxBatchSize),\n maxResponseBytes: limits.response,\n execute: executeBatch\n }\n })\n }\n })\n)\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,wBAAwE;AACxE,oBAYO;AACP,YAAuB;AACvB,wBAA2B;AAC3B,4BAA+B;AAC/B,uB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AAM,UAAU,QAAQ,QAAQ;AAChC,cAAI,qBAAO,UAAU,OAAO,GAAG;AAC7B,oBAAQ,KAAK,EAAE,OAAO,OAAO,OAAO,MAAM,OAAO,QAAQ,MAAM,QAAQ,qBAAO,KAAK,QAAQ,OAAO,EAAE,CAAC;AAAA,UACvG,OAAO;AACL,qBAAS,KAAK,OAAO,OAAO;AAC5B,oBAAQ,KAAK,OAAO,KAAK;AAAA,UAC3B;AAAA,QACF;AACA,eAAO,WAAW;AAClB,YAAI,SAAS,SAAS,GAAG;AACvB,gBAAM,WAAW,OAAO,OAAO,QAAQ;AAAA,YACrC,WAAW;AAAA,YACX;AAAA,YACA;AAAA,YACA,cAAc,aAAa;AAAA,YAC3B,UAAU;AAAA,UACZ,CAAC;AACD,qBAAW,SAAS,SAAS,SAAS;AACpC,oBAAQ,KAAK;AAAA,cACX,OAAO,QAAQ,MAAM,KAAK;AAAA,cAC1B,MAAM,MAAM;AAAA,cACZ,QAAQ,YAAY,MAAM,MAAM,MAAM,MAAM;AAAA,YAC9C,CAAC;AAAA,UACH;AAAA,QACF;AACA,gBAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,QAAQ,EAAE,KAAK;AACrF,eAAO,EAAE,cAAc,aAAa,OAAO,QAAQ;AAAA,MACrD,CAAC;AACD,aAAO,OAAO,OAAO,SAAS;AAAA,QAC5B,CAAC,MAAM,qBAAqB,GAAG;AAAA,UAC7B,SAAS,KAAK,IAAI,OAAO,MAAM,MAAM,YAAY;AAAA,UACjD,kBAAkB,OAAO;AAAA,UACzB,SAAS;AAAA,QACX;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;",
4
+ "sourcesContent": ["/**\n * Permission-aware filesystem operations.\n *\n * There is no kernel `FileSystem` interface and no kernel `FileSystem` tag.\n * Effect owns both, and its tag fixes the error channel to `PlatformError`, so\n * this module is only the middleware: a `Layer` over Effect's own tag that\n * reads the raw service out of context and returns a guarded one in its place.\n * Permission failures are projected into `PlatformError` by\n * `Permission.toPlatformError`, which keeps the structured kernel failure on\n * the error's `cause`.\n *\n * Governing design:\n * `docs/specs/Concepts/Permission Kernel.md`,\n * `docs/specs/Concepts/Effect Taxonomy.md`, and\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { permissionDenied, type PermissionError, toPlatformError } from \"@smthrs/capability/Permission\"\nimport {\n Effect,\n FileSystem as EffectFileSystem,\n Layer,\n Option,\n Path as EffectPath,\n PlatformError,\n Result,\n Schema,\n Sink,\n Stream\n} from \"effect\"\nimport { Base64 } from \"effect/encoding\"\nimport * as Batch from \"./FileSystemBatch.ts\"\nimport { GrantStore } from \"./GrantStore.ts\"\nimport { makeCapability } from \"./internal/makeCapability.ts\"\nimport { Workspace } from \"./Workspace.ts\"\n\nexport * from \"./FileSystemBatch.ts\"\n\n/**\n * The directory name that stands in for the host's system temporary directory\n * in a capability resource. `makeTempFile` and friends called without an\n * explicit `directory` are checked against this name resolved one level above\n * the workspace root, so an implicit system-temp write names a resource that\n * is always outside the workspace envelope and is never confusable with a real\n * workspace path.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport const systemTemporaryDirectoryName = \"<system-temp>\"\n\n/**\n * Host-private extension used for race-free, descriptor-relative filesystem\n * operations. A plain path-based `FileSystem` cannot provide confinement: an\n * attacker can replace any checked component before the delegate resolves it.\n * Platform adapters opt in only when they can pin a root handle and reject\n * symlinks while traversing from it. Hosts without this extension fail closed.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const AtomicFileSystemTypeId = Symbol.for(\"@smthrs/kernel/AtomicFileSystem\")\n\n/** The pinned root every atomic request is resolved against.\n *\n * The guarded layer fills these in at the boundary from the composed\n * workspace, so a caller that builds a request leaves them out.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicRoot {\n readonly boundaryRoot?: string | undefined\n readonly logicalRoot?: string | undefined\n readonly rootIdentity?: string | undefined\n}\n\n/** A serializable operation executed relative to a pinned filesystem root.\n *\n * One member per operation, discriminated by `operation`, so a request cannot\n * omit an operand its operation needs \u2014 a `rename` carries both endpoints or\n * does not compile \u2014 and an adapter cannot quietly leave an operation\n * unimplemented. Every member is the same flat JSON object the helper protocol\n * already framed, so the wire shape is unchanged.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicRequest =\n | (AtomicRoot & { readonly operation: \"exists\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"chmod\"; readonly path: string; readonly options: { readonly mode: number } })\n | (AtomicRoot & {\n readonly operation: \"chown\"\n readonly path: string\n readonly options: { readonly uid: number; readonly gid: number }\n })\n | (AtomicRoot & {\n readonly operation: \"glob\"\n readonly pattern: string\n readonly root: string\n readonly options?: { readonly exclude?: ReadonlyArray<string> | undefined } | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"makeDirectory\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined; readonly mode?: number | undefined } | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"readDirectory\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined } | undefined\n })\n | (AtomicRoot & { readonly operation: \"readFile\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"readFileString\"\n readonly path: string\n readonly encoding?: string | undefined\n })\n | (AtomicRoot & { readonly operation: \"readLink\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"realPath\"; readonly path: string })\n | (AtomicRoot & { readonly operation: \"resolve\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"remove\"\n readonly path: string\n readonly options?: { readonly recursive?: boolean | undefined; readonly force?: boolean | undefined } | undefined\n })\n | (AtomicRoot & { readonly operation: \"rename\"; readonly from: string; readonly to: string })\n | (AtomicRoot & { readonly operation: \"stat\"; readonly path: string })\n | (AtomicRoot & {\n readonly operation: \"writeFile\"\n readonly path: string\n /** Base64 of the bytes, bounded by the host's `contentLimit`. */\n readonly data: string\n readonly options?:\n | { readonly flag?: EffectFileSystem.OpenFlag | undefined; readonly mode?: number | undefined }\n | undefined\n })\n | (AtomicRoot & {\n readonly operation: \"writeFileString\"\n readonly path: string\n readonly data: string\n readonly options?:\n | { readonly flag?: EffectFileSystem.OpenFlag | undefined; readonly mode?: number | undefined }\n | undefined\n })\n | (AtomicRoot & { readonly operation: \"batch\"; readonly requests: ReadonlyArray<AtomicBatchRequest> })\n\n/** Where a no-follow executor's `resolve` walk stopped.\n *\n * `path` is the canonical path the walk reached below the pinned root, in\n * on-disk spelling for every existing component. When `target` is `null`,\n * `path` is the whole request, with a missing component and its descendants\n * kept as requested. Otherwise `path` names the first link or reparse point\n * on the way and `target` is its text, which the executor read without\n * opening what it names.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport interface Resolution {\n readonly path: string\n readonly target: string | null\n}\n\n/** One member of an executor batch: a public read, or authorization's `resolve`.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport type AtomicBatchRequest = Batch.BatchRequest | { readonly operation: \"resolve\"; readonly path: string }\n\n/** One member's value in an executor batch.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport type AtomicBatchValue = Batch.BatchValue | { readonly operation: \"resolve\"; readonly resolution: Resolution }\n\n/** An executor batch's answer: {@link Batch.BatchResponse} over {@link AtomicBatchValue}.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport interface AtomicBatchResponse {\n readonly rootIdentity: string\n readonly entries: ReadonlyArray<{\n readonly index: number\n readonly path: string\n readonly result: Result.Result<AtomicBatchValue, PlatformError.PlatformError>\n }>\n}\n\n/** The value each atomic operation resolves to.\n *\n * The executor no longer takes the result type from its caller: an operation\n * names its own result here, so a host that answers a `stat` with a boolean is\n * a compile error rather than a decode that succeeds and reads wrong.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicResults {\n readonly exists: boolean\n readonly chmod: void\n readonly chown: void\n readonly glob: Array<string>\n readonly makeDirectory: void\n readonly readDirectory: Array<string>\n readonly readFile: Uint8Array\n readonly readFileString: string\n readonly readLink: string\n readonly realPath: string\n readonly resolve: Resolution\n readonly remove: void\n readonly rename: void\n readonly stat: EffectFileSystem.File.Info\n readonly writeFile: void\n readonly writeFileString: void\n readonly batch: AtomicBatchResponse\n}\n\n/** The result of one request, read from the operation it names.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicResult<R extends AtomicRequest> = AtomicResults[R[\"operation\"]]\n\n/** One typed implementation per operation.\n *\n * A record of this type receives each operation's own request and returns that\n * operation's own result, and a record missing an operation does not compile,\n * which is the exhaustiveness a `string` operation could not give an adapter.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicHandlers = {\n readonly [K in keyof AtomicResults]: (\n request: Extract<AtomicRequest, { readonly operation: K }>\n ) => Effect.Effect<AtomicResults[K], PlatformError.PlatformError>\n}\n\n/** Trusted host extension implementing atomic path resolution and operation.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport interface AtomicFileSystem {\n /**\n * The executor refuses symlinks and hard links during every handle-relative\n * operation. Authorization still resolves the on-disk path spelling, but\n * does not need a separate hard-link stat before invoking the executor.\n */\n readonly noFollowAuthorization?: true | undefined\n /** Exact composition-time identity when native file IDs exceed numeric precision. */\n readonly identifyRoot?: ((path: string) => Effect.Effect<string, PlatformError.PlatformError>) | undefined\n readonly execute: <R extends AtomicRequest>(\n request: R\n ) => Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n /**\n * A filesystem already confined by an enforceable process/filesystem\n * boundary (for example an in-memory browser volume). Methods not expressible\n * as one descriptor-relative request may delegate only through this surface.\n */\n readonly isolated?: EffectFileSystem.FileSystem | undefined\n /** Advertised only by executors implementing the bounded batch protocol. */\n readonly batchLimits?: { readonly size: number; readonly response: number } | undefined\n /**\n * Advertised byte ceiling for one serialized `writeFile` payload. The kernel\n * refuses a larger payload with a typed `BadArgument` before base64-encoding\n * it, so an executor that frames requests across a serialized host boundary\n * never asks its runtime for a string it cannot represent. Hosts delegating\n * through `isolated` receive the bytes directly and advertise nothing.\n */\n readonly contentLimit?: number | undefined\n}\n\n/** An Effect filesystem carrying the atomic host extension.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport type AtomicHostFileSystem = EffectFileSystem.FileSystem & {\n readonly [AtomicFileSystemTypeId]: AtomicFileSystem\n}\n\n/** Attaches a trusted platform's descriptor-relative executor to its service.\n *\n * The executor is attached to the supplied object, so a later attachment over\n * the same service replaces this one. A host attaches exactly once at its\n * boundary; a caller that deliberately layers over an existing executor must\n * read it first and delegate to it, which is what makes replacement its own\n * decision rather than an accident.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const withAtomicFileSystem = (\n fileSystem: EffectFileSystem.FileSystem,\n atomic: AtomicFileSystem\n): AtomicHostFileSystem => Object.assign(fileSystem, { [AtomicFileSystemTypeId]: atomic })\n\n/**\n * Why a filesystem composition or guarded batch refused.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport const FileSystemFaultCode = Schema.Literals([\n \"executor_already_present\",\n \"isolated_operation_unsupported\",\n \"workspace_identity_changed\"\n])\n\n/**\n * The stable code of a {@link FileSystemFault}.\n *\n * @since 1.0.0-rc.0\n * @category models\n */\nexport type FileSystemFaultCode = typeof FileSystemFaultCode.Type\n\n/**\n * A broken filesystem composition or a workspace whose descriptor identity\n * changed. `withIsolatedFileSystem` throws `executor_already_present`; an\n * attested volume reaching an operation it never advertises dies with\n * `isolated_operation_unsupported` (a bug); a batch whose root no longer names\n * the authorized descriptor is the `cause` of a `Busy` `PlatformError` with\n * `workspace_identity_changed`.\n *\n * @since 1.0.0-rc.0\n * @category errors\n */\nexport class FileSystemFault extends Schema.TaggedError<FileSystemFault>()(\"@smthrs/kernel/FileSystemFault\", {\n code: FileSystemFaultCode,\n message: Schema.String\n}) {\n override readonly name = \"FileSystemFault\"\n}\n\n/**\n * Attests that a host filesystem is already isolated as a whole. Intended for\n * browser/test volumes whose implementation cannot address the host\n * filesystem at all; native path-based adapters must not use this shortcut.\n *\n * The attestation is refused for a filesystem that already carries a\n * descriptor-relative executor. That executor is the stronger guarantee, and\n * replacing it with a path-delegating one would route `access`, `copy`,\n * `chmod`, `link`, `symlink`, `open`, `watch`, `sink`, `stream`, and every\n * `makeTemp*` back through pathnames after the capability check: the exact\n * symlink-swap window this module exists to close. The refusal is a throw at\n * composition time, so a host cannot be assembled that way.\n *\n * @since 1.0.0-rc.0\n * @category security\n */\nexport const withIsolatedFileSystem = (\n fileSystem: EffectFileSystem.FileSystem\n): AtomicHostFileSystem => {\n if (AtomicFileSystemTypeId in fileSystem) {\n throw new FileSystemFault({\n code: \"executor_already_present\",\n message:\n \"filesystem already carries a descriptor-relative executor; attesting whole-filesystem isolation would replace it\"\n })\n }\n return withAtomicFileSystem(fileSystem, {\n isolated: fileSystem,\n execute: dispatch({\n exists: (request) => fileSystem.exists(request.path),\n chmod: (request) => fileSystem.chmod(request.path, request.options.mode),\n chown: (request) => fileSystem.chown(request.path, request.options.uid, request.options.gid),\n glob: (request) => fileSystem.glob(request.pattern, { ...request.options, root: request.root }),\n makeDirectory: (request) => fileSystem.makeDirectory(request.path, request.options),\n readDirectory: (request) => fileSystem.readDirectory(request.path, request.options),\n readFile: (request) => fileSystem.readFile(request.path),\n readFileString: (request) => fileSystem.readFileString(request.path, request.encoding),\n readLink: (request) => fileSystem.readLink(request.path),\n realPath: (request) => fileSystem.realPath(request.path),\n // Authorization asks `resolve` only of an executor that claims\n // `noFollowAuthorization`, which an attested volume never does.\n resolve: (request) => unsupportedIsolated(request.operation),\n remove: (request) => fileSystem.remove(request.path, request.options),\n rename: (request) => fileSystem.rename(request.from, request.to),\n stat: (request) => fileSystem.stat(request.path),\n writeFile: (request) =>\n Base64.decode(request.data).pipe(\n Effect.fromResult,\n Effect.orDie,\n Effect.flatMap((data) => fileSystem.writeFile(request.path, data, request.options))\n ),\n writeFileString: (request) => fileSystem.writeFileString(request.path, request.data, request.options),\n // An attested volume advertises no `batchLimits`, so the guarded layer\n // never frames a batch for this executor.\n batch: (request) => unsupportedIsolated(request.operation)\n })\n })\n}\n\nconst unsupportedIsolated = (operation: string): Effect.Effect<never> =>\n Effect.die(\n new FileSystemFault({\n code: \"isolated_operation_unsupported\",\n message: `unsupported isolated filesystem operation: ${operation}`\n })\n )\n\n/**\n * Turns a typed handler record into the executor the host extension declares.\n *\n * The record is what carries the safety: every operation is implemented, each\n * handler reads its own operands, and each returns its own result. The lookup\n * itself is one assertion because TypeScript cannot correlate an index it\n * narrowed only on the key with the request and result types that key selects.\n * An operation no handler implements can only arrive from a serialized\n * boundary that framed an operation this build does not know, so it dies\n * rather than resolving to `undefined` and being called.\n */\nconst dispatch = (handlers: AtomicHandlers): AtomicFileSystem[\"execute\"] => {\n const table = handlers as unknown as Record<\n string,\n ((request: AtomicRequest) => Effect.Effect<unknown, PlatformError.PlatformError>) | undefined\n >\n return <R extends AtomicRequest>(request: R) => {\n const handler = table[request.operation]\n return (\n handler === undefined ? unsupportedIsolated(request.operation) : handler(request)\n ) as Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n }\n}\n\n/** Prefer the host's exact file ID over the public adapter's optional numeric inode. */\nconst identifyRoot = (\n atomic: AtomicFileSystem,\n fileSystem: EffectFileSystem.FileSystem,\n path: string\n): Effect.Effect<Option.Option<string>, PlatformError.PlatformError> =>\n atomic.identifyRoot === undefined\n ? Effect.map(fileSystem.stat(path), (info) => Option.map(info.ino, (ino) => `${info.dev}:${ino}`))\n : Effect.map(atomic.identifyRoot(path), Option.some)\n\n/** The root a descriptor-relative request is resolved against, captured once. */\ninterface PinnedRoot {\n readonly boundaryRoot: string\n readonly logicalRoot: string\n readonly rootIdentity: string | undefined\n}\n\n/**\n * Stamps a request with its pinned root and runs it through the executor. The\n * one place both the guarded layer and {@link confined} build the wire request,\n * so the two surfaces cannot drift apart.\n */\nconst pinned =\n (atomic: AtomicFileSystem, root: PinnedRoot) =>\n <R extends AtomicRequest>(request: R): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic.execute<R>({ ...request, ...root })\n\nconst unconfinedDescription = \"host does not provide descriptor-relative, no-follow filesystem isolation\"\n\nconst unconfined = (method: string, pathOrDescriptor: string): PlatformError.PlatformError =>\n PlatformError.systemError({\n _tag: \"PermissionDenied\",\n module: \"FileSystem\",\n method,\n pathOrDescriptor,\n description: unconfinedDescription\n })\n\n/**\n * Brands a {@link confined} view with the logical root it is pinned to, so a\n * caller handed an already-confined view does not wrap it a second time.\n */\nconst ConfinedFileSystemTypeId = Symbol.for(\"@smthrs/kernel/ConfinedFileSystem\")\n\n/**\n * Whether {@link confined} can build a view over this filesystem: it carries a\n * descriptor-relative executor, or a whole-filesystem isolation attestation.\n * A plain path-based host answers `false`.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const isConfinable = (fileSystem: EffectFileSystem.FileSystem): boolean =>\n ConfinedFileSystemTypeId in fileSystem || AtomicFileSystemTypeId in fileSystem\n\n/**\n * The logical root a filesystem is already confined to: a {@link confined}\n * view's pinned root, or the guarded {@link layer} service's workspace root.\n * `undefined` for any other filesystem, including a host that is merely\n * confinable. Machinery that shares a filesystem with its caller confines to\n * this root, so its paths resolve exactly where the caller's do.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const confinedRoot = (fileSystem: EffectFileSystem.FileSystem): string | undefined =>\n (fileSystem as { readonly [ConfinedFileSystemTypeId]?: string })[ConfinedFileSystemTypeId]\n\n/**\n * Fails with the typed `PermissionDenied` refusal unless {@link confined} can\n * build a view over this filesystem. Composition-time check for layers that\n * pin their root later, when it is known to exist.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const requireConfinable = (\n fileSystem: EffectFileSystem.FileSystem,\n root: string\n): Effect.Effect<void, PlatformError.PlatformError> =>\n isConfinable(fileSystem) ? Effect.void : Effect.fail(unconfined(\"confined\", root))\n\n/**\n * A filesystem view confined to `root` without capability checks: engine\n * machinery that must not ask a grant store for its own bookkeeping, but must\n * still never be redirected outside the workspace.\n *\n * Every operation is one descriptor-relative request against the root pinned\n * here (its canonical path and `device:inode` identity), resolved by the host\n * helper with `O_NOFOLLOW` at each component, so there is no window between a\n * check and a write for a symlink to be swapped into. A symlink anywhere on the\n * path, a hard-linked file, `..` traversal, or a root whose identity changed is\n * refused by the host, never followed. The requests are exactly the ones the\n * guarded {@link layer} sends, minus the grant check.\n *\n * A host carrying a whole-filesystem isolation attestation\n * ({@link withIsolatedFileSystem}) is returned as it is: its attestation is\n * the boundary. So is the guarded {@link layer}'s own service when it is\n * rooted at the same workspace, since each of its path operations is already\n * one such request. A plain path-based host is refused with `PermissionDenied`, so\n * there is no path-based fallback that claims confinement. Operations that\n * cannot be expressed as one atomic request (`open`, `stream`, `sink`, `copy`,\n * `link`, `symlink`, `watch`, `truncate`, `utimes`, `access`, and every\n * `makeTemp*`) fail with the same refusal.\n *\n * The root must exist when the view is built.\n *\n * @since 1.0.0-rc.1\n * @category security\n */\nexport const confined = (\n fileSystem: EffectFileSystem.FileSystem,\n root: string\n): Effect.Effect<EffectFileSystem.FileSystem, PlatformError.PlatformError, EffectPath.Path> =>\n Effect.gen(function*() {\n const path = yield* EffectPath.Path\n const logicalRoot = path.resolve(root === \"\" ? \".\" : root)\n if (confinedRoot(fileSystem) === logicalRoot) return fileSystem\n const atomic = (fileSystem as Partial<AtomicHostFileSystem>)[AtomicFileSystemTypeId]\n if (atomic === undefined) return yield* Effect.fail(unconfined(\"confined\", logicalRoot))\n if (atomic.isolated !== undefined) return fileSystem\n const boundaryRoot = yield* fileSystem.realPath(logicalRoot)\n const rootIdentity = yield* identifyRoot(atomic, fileSystem, boundaryRoot)\n if (Option.isNone(rootIdentity)) return yield* Effect.fail(unconfined(\"confined\", logicalRoot))\n const run = pinned(atomic, { boundaryRoot, logicalRoot, rootIdentity: rootIdentity.value })\n const normalize = (value: string): string => path.resolve(logicalRoot, value)\n const refuse = (method: string, value: string): Effect.Effect<never, PlatformError.PlatformError> =>\n Effect.fail(unconfined(method, normalize(value)))\n const view: EffectFileSystem.FileSystem = {\n ...EffectFileSystem.make({\n access: (value) => refuse(\"access\", value),\n copy: (from) => refuse(\"copy\", from),\n copyFile: (from) => refuse(\"copyFile\", from),\n chmod: (value, mode) => run({ operation: \"chmod\", path: normalize(value), options: { mode } }),\n chown: (value, uid, gid) => run({ operation: \"chown\", path: normalize(value), options: { uid, gid } }),\n glob: (pattern, options) => {\n const base = options?.root === undefined ? logicalRoot : normalize(options.root)\n return run({\n operation: \"glob\",\n pattern: path.resolve(base, pattern),\n root: base,\n options: options === undefined ? undefined : { exclude: options.exclude ?? [] }\n })\n },\n link: (from) => refuse(\"link\", from),\n makeDirectory: (value, options) =>\n run({\n operation: \"makeDirectory\",\n path: normalize(value),\n options\n }),\n makeTempDirectory: () => refuse(\"makeTempDirectory\", logicalRoot),\n makeTempDirectoryScoped: () => refuse(\"makeTempDirectoryScoped\", logicalRoot),\n makeTempFile: () => refuse(\"makeTempFile\", logicalRoot),\n makeTempFileScoped: () => refuse(\"makeTempFileScoped\", logicalRoot),\n open: (value) => refuse(\"open\", value),\n readDirectory: (value, options) =>\n run({\n operation: \"readDirectory\",\n path: normalize(value),\n options\n }),\n readFile: (value) => run({ operation: \"readFile\", path: normalize(value) }),\n readLink: (value) => run({ operation: \"readLink\", path: normalize(value) }),\n realPath: (value) => run({ operation: \"realPath\", path: normalize(value) }),\n remove: (value, options) =>\n run({\n operation: \"remove\",\n path: normalize(value),\n options\n }),\n rename: (from, to) => run({ operation: \"rename\", from: normalize(from), to: normalize(to) }),\n stat: (value) => run({ operation: \"stat\", path: normalize(value) }),\n symlink: (_from, to) => refuse(\"symlink\", to),\n truncate: (value) => refuse(\"truncate\", value),\n utimes: (value) => refuse(\"utimes\", value),\n watch: (value) => Stream.fail(unconfined(\"watch\", normalize(value))),\n writeFile: (value, data, options) => {\n const limit = atomic.contentLimit\n if (limit !== undefined && data.byteLength > limit) {\n return Effect.fail(PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"writeFile\",\n description:\n `writeFile payload of ${data.byteLength} bytes exceeds the ${limit} byte limit advertised by the host`\n }))\n }\n return run({\n operation: \"writeFile\",\n path: normalize(value),\n data: Base64.encode(data),\n options\n })\n }\n }),\n exists: (value) => run({ operation: \"exists\", path: normalize(value) }),\n readFileString: (value, encoding) => run({ operation: \"readFileString\", path: normalize(value), encoding }),\n writeFileString: (value, data, options) =>\n run({\n operation: \"writeFileString\",\n path: normalize(value),\n data,\n options\n })\n }\n return Object.assign(view, { [ConfinedFileSystemTypeId]: logicalRoot })\n })\n\nconst readableOpenFlags: ReadonlySet<EffectFileSystem.OpenFlag> = new Set([\n \"r\",\n \"r+\",\n \"w+\",\n \"wx+\",\n \"a+\",\n \"ax+\"\n])\n\nconst writableOpenFlags: ReadonlySet<EffectFileSystem.OpenFlag> = new Set([\n \"r+\",\n \"w\",\n \"wx\",\n \"w+\",\n \"wx+\",\n \"a\",\n \"ax\",\n \"a+\",\n \"ax+\"\n])\n\nconst isInside = (path: EffectPath.Path, root: string, candidate: string): boolean => {\n const relative = path.relative(root, candidate)\n return relative === \"\" ||\n (relative !== \"..\" && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative))\n}\n\n/**\n * The `device:inode` identity a descriptor-bound authorization pins, or\n * `Option.none` when the entry is not a regular file or the host reports no\n * inode identity. A host without inode identity is an isolated volume, and its\n * isolation attestation \u2014 not inode evidence \u2014 is the confinement boundary.\n */\nconst identityOf = (info: EffectFileSystem.File.Info): Option.Option<string> =>\n info.type === \"File\"\n ? Option.map(info.ino, (ino) => `${info.dev}:${ino}`)\n : Option.none()\n\n/**\n * Resolves a path through every existing ancestor and maps paths inside the\n * canonical workspace back to the stable logical workspace root. Existing\n * symlinks therefore cannot turn an inside-workspace grant into outside\n * authority, while capability resources remain stable when the root itself is\n * a symlink. The host's `realPath` must return the on-disk spelling of existing\n * components, including on case-insensitive volumes. Native Node hosts use\n * the promise-based `realpath`, which uses the native implementation.\n *\n * @category security\n * @since 1.0.0-rc.0\n */\nexport const canonicalResource = (\n fileSystem: EffectFileSystem.FileSystem,\n path: EffectPath.Path,\n workspaceRoot: string,\n value: string\n): Effect.Effect<string, PlatformError.PlatformError> => {\n const normalizedRoot = path.normalize(workspaceRoot)\n const normalizedValue = path.normalize(\n path.isAbsolute(value) ? value : path.resolve(normalizedRoot, value)\n )\n const resolveExistingAncestor = (\n candidate: string,\n symlinkDepth = 0\n ): Effect.Effect<string, PlatformError.PlatformError> =>\n fileSystem.realPath(candidate).pipe(\n Effect.catch((error) => {\n const resolveParent = () => {\n const parent = path.dirname(candidate)\n if (parent === candidate) {\n return Effect.fail(error)\n }\n return resolveExistingAncestor(parent, symlinkDepth).pipe(\n Effect.map((resolvedParent) => path.join(resolvedParent, path.basename(candidate)))\n )\n }\n return fileSystem.readLink(candidate).pipe(\n Effect.matchEffect({\n onFailure: resolveParent,\n onSuccess: (target) =>\n symlinkDepth >= 40\n ? Effect.fail(error)\n : resolveExistingAncestor(\n path.isAbsolute(target) ? target : path.resolve(path.dirname(candidate), target),\n symlinkDepth + 1\n )\n })\n )\n })\n )\n\n return Effect.all([\n fileSystem.realPath(normalizedRoot),\n resolveExistingAncestor(normalizedValue)\n ]).pipe(\n Effect.map(([canonicalRoot, canonicalValue]) =>\n isInside(path, canonicalRoot, canonicalValue)\n ? path.normalize(path.join(normalizedRoot, path.relative(canonicalRoot, canonicalValue)))\n : path.normalize(canonicalValue)\n )\n )\n}\n\ntype PinnedRun = <R extends AtomicRequest>(\n request: R\n) => Effect.Effect<AtomicResult<R>, PlatformError.PlatformError>\n\nconst uninspectable = \"path component could not be inspected without following it\"\n\n/** `value` spelled below the pinned boundary root, or `undefined` outside both roots. */\nconst pinnedPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string\n): string | undefined => {\n const base = isInside(path, root.logicalRoot, value)\n ? root.logicalRoot\n : isInside(path, root.boundaryRoot, value)\n ? root.boundaryRoot\n : undefined\n return base === undefined ? undefined : path.join(root.boundaryRoot, path.relative(base, value))\n}\n\nconst segmentsBelow = (path: EffectPath.Path, root: string, value: string): Array<string> =>\n path.relative(root, value).split(path.sep).filter((segment) => segment !== \"\")\n\n/** Resolve a glob's literal prefix, keeping pattern syntax out of filename lookups. */\nconst globAuthorizationPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string,\n glob: boolean\n): { readonly prefix: string; readonly suffix: ReadonlyArray<string> } => {\n const requested = glob ? pinnedPath(path, root, value) : undefined\n if (requested === undefined) return { prefix: value, suffix: [] }\n // The workspace's own name is literal even if it contains glob metacharacters.\n const parts = segmentsBelow(path, root.boundaryRoot, requested)\n const wildcard = parts.findIndex((part) => /[*?[{]|[@+!]\\(/.test(part))\n return wildcard < 0\n ? { prefix: value, suffix: [] }\n // Keep logical spelling so the executor mapping pins the prefix exactly once.\n : { prefix: path.join(root.logicalRoot, ...parts.slice(0, wildcard)), suffix: parts.slice(wildcard) }\n}\n\n/**\n * Resolves the resource a no-follow executor addresses without resolving any\n * pathname on the host. Windows `realpath` opens its argument through every\n * link, so asking the host about a planted link to `\\\\.\\pipe\\name` or\n * `\\\\host\\share\\x` connects to that pipe or share during authorization,\n * and a component swapped for a link between two host checks is followed\n * even when each check alone was safe (#2882).\n *\n * The executor answers one descriptor-relative `resolve` request from the\n * pinned root instead ({@link Resolution}): existing components in their\n * on-disk spelling, a missing component and its descendants as requested, or\n * the first link on the way with its text. Link text is resolved lexically\n * and asked again, and a result outside both roots is returned untouched for\n * the caller to deny. Any failure is refused.\n */\nconst confinedResource = <E>(\n run: PinnedRun,\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n value: string,\n refuse: (resource: string, reason: string, cause?: PlatformError.PlatformError) => Effect.Effect<never, E>,\n symlinkDepth = 0\n): Effect.Effect<string, E> => {\n const requested = pinnedPath(path, root, value)\n if (requested === undefined) {\n return Effect.succeed(value)\n }\n return run({ operation: \"resolve\", path: requested }).pipe(\n Effect.matchEffect({\n onFailure: (cause) => refuse(logicalPath(path, root, requested), uninspectable, cause),\n onSuccess: (resolution) => followResolution(run, path, root, requested, resolution, refuse, symlinkDepth)\n })\n )\n}\n\nconst logicalPath = (\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n canonical: string\n): string => path.normalize(path.join(root.logicalRoot, path.relative(root.boundaryRoot, canonical)))\n\n/** Turns one executor {@link Resolution} of `requested` into the resource it names. */\nconst followResolution = <E>(\n run: PinnedRun,\n path: EffectPath.Path,\n root: Pick<PinnedRoot, \"boundaryRoot\" | \"logicalRoot\">,\n requested: string,\n resolution: Resolution,\n refuse: (resource: string, reason: string, cause?: PlatformError.PlatformError) => Effect.Effect<never, E>,\n symlinkDepth: number\n): Effect.Effect<string, E> => {\n const resolved = path.normalize(resolution.path)\n if (!isInside(path, root.boundaryRoot, resolved)) {\n return refuse(logicalPath(path, root, requested), \"path resolves outside the pinned root\")\n }\n if (resolution.target === null) {\n return Effect.succeed(logicalPath(path, root, resolved))\n }\n if (symlinkDepth >= 40) {\n return refuse(logicalPath(path, root, resolved), \"too many levels of symbolic links\")\n }\n const rest = segmentsBelow(path, root.boundaryRoot, requested).slice(\n segmentsBelow(path, root.boundaryRoot, resolved).length\n )\n return confinedResource(\n run,\n path,\n root,\n path.resolve(path.dirname(resolved), resolution.target, ...rest),\n refuse,\n symlinkDepth + 1\n )\n}\n\n/** A public read's batch value; a `resolve` answer to a read is a host defect and fails closed. */\nconst publicValue = (\n resource: string,\n result: Result.Result<AtomicBatchValue, PlatformError.PlatformError>\n): Result.Result<Batch.BatchValue, PlatformError.PlatformError> =>\n Result.isFailure(result) || result.success.operation !== \"resolve\"\n ? result as Result.Result<Batch.BatchValue, PlatformError.PlatformError>\n : Result.fail(PlatformError.systemError({\n _tag: \"PermissionDenied\",\n module: \"FileSystem\",\n method: \"batch\",\n pathOrDescriptor: resource,\n description: \"executor answered a batch read with a resolution\"\n }))\n\n/**\n * Decorates Effect's filesystem service in place with workspace-normalized\n * capability checks. Every host resolves canonical path spelling before the\n * capability check and again after every grant decision. Descriptor-relative\n * executors enforce hard-link refusal themselves; other hosts also run the\n * hard-link guard here. A decision can\n * suspend (an attended request, a journal-backed store), and an operation\n * whose path no longer names the resource that was authorized is refused\n * rather than performed. Open file handles bind their authorization to the\n * `device:inode` identity fstat'd at open time and refuse any operation once\n * the authorized path names a different resource.\n *\n * The layer provides the tag it also requires: compose it over a host\n * filesystem layer with `Layer.provide` and every consumer of\n * `FileSystem.FileSystem` \u2014 including one that never heard of the kernel \u2014\n * resolves the guarded implementation. A denied request surfaces as a\n * `PlatformError` whose reason is `PermissionDenied` and whose `cause` is the\n * kernel's own `PermissionRequired`, `PermissionDenied`, or `GrantStoreError`;\n * `Permission.fromPlatformError` reads it back.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer: Layer.Layer<\n EffectFileSystem.FileSystem,\n PlatformError.PlatformError,\n EffectFileSystem.FileSystem | EffectPath.Path | Workspace | GrantStore\n> = Layer.effect(\n EffectFileSystem.FileSystem,\n Effect.gen(function*() {\n const fileSystem = yield* EffectFileSystem.FileSystem\n const path = yield* EffectPath.Path\n const workspace = yield* Workspace\n const grants = yield* GrantStore\n const atomic = (fileSystem as Partial<AtomicHostFileSystem>)[AtomicFileSystemTypeId]\n const normalizeFrom = (base: string, value: string): string =>\n path.normalize(path.isAbsolute(value) ? value : path.resolve(base, value))\n const logicalRoot = path.normalize(path.resolve(workspace.root))\n const normalize = (value: string): string => normalizeFrom(logicalRoot, value)\n const boundaryRoot = yield* fileSystem.realPath(logicalRoot)\n // Descriptor-relative hosts need the composition-time identity even when\n // they expose no batching. Already-isolated volumes need no native inode.\n const rootIdentity = atomic === undefined || (atomic.isolated !== undefined && atomic.batchLimits === undefined)\n ? Option.none<string>()\n : yield* identifyRoot(atomic, fileSystem, boundaryRoot)\n const root: PinnedRoot = { boundaryRoot, logicalRoot, rootIdentity: Option.getOrUndefined(rootIdentity) }\n const refuse = (method: string, resource: string) => (error: PermissionError): PlatformError.PlatformError =>\n toPlatformError({ module: \"FileSystem\", method, pathOrDescriptor: resource, error })\n const deny = (\n action: \"fs:read\" | \"fs:write\",\n method: string,\n resource: string,\n reason: string,\n cause?: PlatformError.PlatformError\n ) =>\n makeCapability(action, resource).pipe(\n Effect.flatMap((capability) => {\n const failure = permissionDenied(capability, reason)\n // Keep the permission identity and the typed inspection failure together.\n if (cause !== undefined) Object.defineProperty(failure, \"cause\", { value: cause })\n return Effect.fail(failure)\n }),\n Effect.mapError(refuse(method, resource)),\n Effect.mapError((failure) =>\n cause?.reason.description === undefined\n ? failure\n : PlatformError.systemError({\n ...failure.reason,\n _tag: \"PermissionDenied\",\n description: cause.reason.description,\n cause: failure.reason.cause\n })\n )\n )\n const insideWorkspace = (action: \"fs:read\" | \"fs:write\", method: string) => (resource: string) =>\n isInside(path, logicalRoot, resource)\n ? Effect.succeed(resource)\n : deny(action, method, resource, \"path is outside the workspace\")\n /**\n * Resolves the on-disk resource spelling even for no-follow executors:\n * a differently cased name can address the same file. No-follow executors\n * resolve through {@link confinedResource}, one executor request that\n * reads link text instead of following links. `guard` runs it twice \u2014 once\n * before the grant decision and once after \u2014 so the resolution must be a\n * pure question about the current filesystem state.\n */\n const resolvedResource = (\n action: \"fs:read\" | \"fs:write\",\n method: string,\n value: string,\n glob = false\n ): Effect.Effect<string, PlatformError.PlatformError> => {\n const normalized = normalize(value)\n if (atomic?.noFollowAuthorization === true) {\n const { prefix, suffix } = globAuthorizationPath(path, root, normalized, glob)\n return confinedResource(\n pinned(atomic, root),\n path,\n root,\n prefix,\n (resource, reason, cause) => deny(action, method, resource, reason, cause)\n ).pipe(\n Effect.map((resource) => suffix.length === 0 ? resource : path.join(resource, ...suffix)),\n Effect.flatMap(insideWorkspace(action, method))\n )\n }\n return canonicalResource(fileSystem, path, logicalRoot, normalized).pipe(\n Effect.flatMap((resource) =>\n fileSystem.stat(normalized).pipe(\n Effect.matchEffect({\n onFailure: () => Effect.succeed(resource),\n onSuccess: (info) => {\n const hardLinked = info.type === \"File\" && Option.isSome(info.nlink) && info.nlink.value > 1\n return hardLinked\n ? deny(action, method, resource, \"hard-linked files cannot be confined to the workspace\")\n : Effect.succeed(resource)\n }\n })\n )\n )\n )\n }\n /**\n * Resolves every read of one batch. A no-follow executor that batches\n * answers all of them in one `resolve` batch, so authorizing a batch\n * costs one executor request rather than one per member; only a member\n * that meets a link asks again, for its target. Other hosts resolve each\n * member with bounded concurrency.\n */\n const resolvedResources = (\n values: ReadonlyArray<Pick<Batch.BatchRequest, \"operation\" | \"path\">>\n ): Effect.Effect<Array<Result.Result<string, PlatformError.PlatformError>>, PlatformError.PlatformError> => {\n const refuseRead = (resource: string, reason: string, cause?: PlatformError.PlatformError) =>\n deny(\"fs:read\", \"read\", resource, reason, cause)\n if (atomic?.noFollowAuthorization !== true || atomic.batchLimits === undefined) {\n return Effect.forEach(\n values,\n (value) => Effect.result(resolvedResource(\"fs:read\", \"read\", value.path, value.operation === \"glob\")),\n {\n concurrency: Batch.fallbackConcurrency\n }\n )\n }\n const run = pinned(atomic, root)\n const parts = values.map((value) =>\n globAuthorizationPath(path, root, normalize(value.path), value.operation === \"glob\")\n )\n const requested = parts.map(({ prefix }) => pinnedPath(path, root, prefix))\n const members: Array<{ readonly operation: \"resolve\"; readonly path: string }> = []\n const memberOf = requested.map((value) =>\n value === undefined ? undefined : members.push({ operation: \"resolve\", path: value }) - 1\n )\n const answered = members.length === 0\n ? Effect.succeed<AtomicBatchResponse[\"entries\"]>([])\n : Effect.map(run({ operation: \"batch\", requests: members }), (response) => response.entries)\n return Effect.flatMap(answered, (entries) => {\n const results = new Map(entries.map((entry) => [entry.index, entry.result] as const))\n return Effect.forEach(values, (value, index) => {\n const member = memberOf[index]\n const resource = member === undefined\n ? Effect.succeed(normalize(value.path))\n : Effect.suspend(() => {\n const pinnedValue = members[member]!.path\n const result = results.get(member)\n // The executor's batch framing already requires one entry per\n // member; an answer of another shape is refused, not guessed.\n return result === undefined || Result.isFailure(result) || result.success.operation !== \"resolve\"\n ? refuseRead(\n logicalPath(path, root, pinnedValue),\n uninspectable,\n result !== undefined && Result.isFailure(result) ? result.failure : undefined\n )\n : followResolution(run, path, root, pinnedValue, result.success.resolution, refuseRead, 0)\n })\n return Effect.result(resource.pipe(\n Effect.map((resolved) =>\n parts[index]!.suffix.length === 0 ? resolved : path.join(resolved, ...parts[index]!.suffix)\n ),\n Effect.flatMap(insideWorkspace(\"fs:read\", \"read\"))\n ))\n }, { concurrency: Batch.fallbackConcurrency })\n })\n }\n const guard = (\n action: \"fs:read\" | \"fs:write\",\n value: string,\n glob = false\n ): Effect.Effect<void, PlatformError.PlatformError> => {\n const method = action === \"fs:read\" ? \"read\" : \"write\"\n return resolvedResource(action, method, value, glob).pipe(\n Effect.flatMap((resource) =>\n makeCapability(action, resource).pipe(\n Effect.flatMap((capability) => grants.check(capability)),\n Effect.mapError(refuse(method, resource)),\n // The grant decision can suspend \u2014 an attended request waiting for\n // a human, a journal-backed store doing IO. What was authorized is\n // the resource the path named at check time, so the path must\n // still name it when the decision arrives: a symlink or rename\n // swapped in during the wait is refused, never followed.\n Effect.andThen(resolvedResource(action, method, value, glob)),\n Effect.flatMap((settled) =>\n settled === resource\n ? Effect.void\n : deny(action, method, resource, \"path no longer names the resource that was authorized\")\n )\n )\n )\n )\n }\n const read = (value: string) => guard(\"fs:read\", value)\n const write = (value: string) => guard(\"fs:write\", value)\n const atomicUnavailable = (\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string\n ): Effect.Effect<never, PlatformError.PlatformError> =>\n deny(\n action,\n method,\n normalize(value),\n unconfinedDescription\n )\n const atomicOne = <R extends AtomicRequest>(\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string,\n request: R\n ): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic === undefined\n ? atomicUnavailable(action, value, method)\n : guard(action, value, request.operation === \"glob\").pipe(Effect.andThen(pinned(atomic, root)(request)))\n const atomicTwo = <R extends AtomicRequest>(\n first: readonly [\"fs:read\" | \"fs:write\", string],\n second: readonly [\"fs:read\" | \"fs:write\", string],\n method: string,\n request: R\n ): Effect.Effect<AtomicResult<R>, PlatformError.PlatformError> =>\n atomic === undefined\n ? atomicUnavailable(first[0], first[1], method)\n : guard(first[0], first[1]).pipe(\n Effect.andThen(guard(second[0], second[1])),\n Effect.andThen(pinned(atomic, root)(request))\n )\n const isolatedOne = <A>(\n action: \"fs:read\" | \"fs:write\",\n value: string,\n method: string,\n use: (isolated: EffectFileSystem.FileSystem) => Effect.Effect<A, PlatformError.PlatformError>\n ): Effect.Effect<A, PlatformError.PlatformError> =>\n atomic?.isolated === undefined\n ? atomicUnavailable(action, value, method)\n : guard(action, value).pipe(Effect.andThen(use(atomic.isolated)))\n const isolatedTwo = <A>(\n first: readonly [\"fs:read\" | \"fs:write\", string],\n second: readonly [\"fs:read\" | \"fs:write\", string],\n method: string,\n use: (isolated: EffectFileSystem.FileSystem) => Effect.Effect<A, PlatformError.PlatformError>\n ): Effect.Effect<A, PlatformError.PlatformError> =>\n atomic?.isolated === undefined\n ? atomicUnavailable(first[0], first[1], method)\n : guard(first[0], first[1]).pipe(\n Effect.andThen(guard(second[0], second[1])),\n Effect.andThen(use(atomic.isolated))\n )\n const temp = (directory: string | undefined) =>\n directory === undefined\n ? write(path.resolve(workspace.root, \"..\", systemTemporaryDirectoryName))\n : write(directory)\n const snapshotOptions = <T>(value: T): T => {\n if (Array.isArray(value)) return Object.freeze(value.map(snapshotOptions)) as T\n if (typeof value !== \"object\" || value === null) return value\n const snapshot: Record<string, unknown> = {}\n for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (!descriptor.enumerable) continue\n if (!(\"value\" in descriptor)) throw new TypeError(\"filesystem options must contain only data properties\")\n snapshot[name] = snapshotOptions(descriptor.value)\n }\n return Object.freeze(snapshot) as T\n }\n const normalizeTempOptions = <T extends { readonly directory?: string | undefined }>(options: T | undefined) =>\n options?.directory === undefined ? options : { ...options, directory: normalize(options.directory) }\n const openChecks = (value: string, flag: EffectFileSystem.OpenFlag) => {\n const readable = readableOpenFlags.has(flag)\n const writable = writableOpenFlags.has(flag)\n return readable && writable ?\n read(value).pipe(Effect.andThen(write(value))) :\n writable ?\n write(value) :\n read(value)\n }\n const descriptorRefusal = (action: \"fs:read\" | \"fs:write\", value: string) =>\n deny(\n action,\n action === \"fs:read\" ? \"read\" : \"write\",\n normalize(value),\n \"descriptor no longer names the resource at its authorized path\"\n )\n /**\n * Confirms an open descriptor still names the resource its authorization\n * bound: the `device:inode` identity fstat'd at open time must be what the\n * authorized path names right now. Rechecking the pathname alone would\n * re-authorize the CURRENT occupant of the path and then delegate to the\n * OLD descriptor \u2014 after a rename that descriptor can name an inode\n * outside the workspace even though the replacement path is still allowed.\n * A host that reports no inode identity is an isolated volume whose\n * attestation is the boundary; there is no descriptor evidence to verify.\n */\n const verifyDescriptor = (\n host: EffectFileSystem.FileSystem,\n action: \"fs:read\" | \"fs:write\",\n value: string,\n identity: Option.Option<string>\n ): Effect.Effect<void, PlatformError.PlatformError> =>\n Option.match(identity, {\n onNone: () => Effect.void,\n onSome: (bound) =>\n host.stat(normalize(value)).pipe(\n Effect.matchEffect({\n onFailure: () => descriptorRefusal(action, value),\n onSuccess: (info) =>\n Option.match(identityOf(info), {\n onNone: () => descriptorRefusal(action, value),\n onSome: (current) => current === bound ? Effect.void : descriptorRefusal(action, value)\n })\n })\n )\n })\n const wrapFile = (\n host: EffectFileSystem.FileSystem,\n file: EffectFileSystem.File,\n value: string,\n identity: Option.Option<string>\n ): EffectFileSystem.File => {\n const readable = Effect.suspend(() =>\n read(value).pipe(Effect.andThen(verifyDescriptor(host, \"fs:read\", value, identity)))\n )\n const writable = Effect.suspend(() =>\n write(value).pipe(Effect.andThen(verifyDescriptor(host, \"fs:write\", value, identity)))\n )\n return {\n [EffectFileSystem.FileTypeId]: EffectFileSystem.FileTypeId,\n stat: Effect.fn(\"FileSystem.File.stat\")(() => readable.pipe(Effect.andThen(file.stat)))(),\n seek: Effect.fn(\"FileSystem.File.seek\")(file.seek),\n sync: Effect.fn(\"FileSystem.File.sync\")(() => writable.pipe(Effect.andThen(file.sync)))(),\n read: Effect.fn(\"FileSystem.File.read\")((buffer) => readable.pipe(Effect.andThen(file.read(buffer)))),\n readAlloc: Effect.fn(\"FileSystem.File.readAlloc\")((size) =>\n readable.pipe(Effect.andThen(file.readAlloc(size)))\n ),\n truncate: Effect.fn(\"FileSystem.File.truncate\")((length) =>\n writable.pipe(Effect.andThen(file.truncate(length)))\n ),\n write: Effect.fn(\"FileSystem.File.write\")((buffer) => writable.pipe(Effect.andThen(file.write(buffer)))),\n writeAll: Effect.fn(\"FileSystem.File.writeAll\")((buffer) =>\n writable.pipe(Effect.andThen(file.writeAll(buffer)))\n )\n }\n }\n // `EffectFileSystem.make` brands the implementation with Effect's own\n // (non-exported) type id. The five operations `make` would derive from\n // the primitives are overridden below with guarded delegates to the host\n // implementation, so delegation semantics do not change.\n const guarded: EffectFileSystem.FileSystem = {\n ...EffectFileSystem.make({\n access: Effect.fn(\"FileSystem.access\")((value, options) => {\n const captured = snapshotOptions(options)\n return isolatedOne(\"fs:read\", value, \"access\", (host) => host.access(normalize(value), captured))\n }),\n copy: Effect.fn(\"FileSystem.copy\")((from, to, options) => {\n const captured = snapshotOptions(options)\n return (\n isolatedTwo(\n [\"fs:read\", from],\n [\"fs:write\", to],\n \"copy\",\n (host) => host.copy(normalize(from), normalize(to), captured)\n )\n )\n }),\n copyFile: Effect.fn(\"FileSystem.copyFile\")((from, to) =>\n isolatedTwo(\n [\"fs:read\", from],\n [\"fs:write\", to],\n \"copyFile\",\n (host) => host.copyFile(normalize(from), normalize(to))\n )\n ),\n chmod: Effect.fn(\"FileSystem.chmod\")((value, mode) =>\n atomicOne(\"fs:write\", value, \"chmod\", { operation: \"chmod\", path: normalize(value), options: { mode } })\n ),\n chown: Effect.fn(\"FileSystem.chown\")((value, uid, gid) =>\n atomicOne(\"fs:write\", value, \"chown\", {\n operation: \"chown\",\n path: normalize(value),\n options: { uid, gid }\n })\n ),\n glob: Effect.fn(\"FileSystem.glob\")((pattern, options) => {\n const captured = snapshotOptions(options)\n const root = captured?.root === undefined ? workspace.root : normalize(captured.root)\n const normalizedPattern = normalizeFrom(root, pattern)\n return atomicOne(\"fs:read\", normalizedPattern, \"glob\", {\n operation: \"glob\",\n pattern: normalizedPattern,\n root,\n options: captured === undefined ? undefined : { exclude: captured.exclude ?? [] }\n })\n }),\n link: Effect.fn(\"FileSystem.link\")((from, to) =>\n isolatedTwo([\"fs:read\", from], [\"fs:write\", to], \"link\", (host) => host.link(normalize(from), normalize(to)))\n ),\n makeDirectory: Effect.fn(\"FileSystem.makeDirectory\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"makeDirectory\", {\n operation: \"makeDirectory\",\n path: normalize(value),\n options: captured\n })\n }),\n makeTempDirectory: Effect.fn(\"FileSystem.makeTempDirectory\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempDirectory\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempDirectory(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempDirectoryScoped: Effect.fn(\"FileSystem.makeTempDirectoryScoped\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempDirectoryScoped\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempDirectoryScoped(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempFile: Effect.fn(\"FileSystem.makeTempFile\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempFile\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempFile(normalizeTempOptions(captured)))\n )\n )\n }),\n makeTempFileScoped: Effect.fn(\"FileSystem.makeTempFileScoped\")((options) => {\n const captured = snapshotOptions(options)\n return (\n atomic?.isolated === undefined\n ? atomicUnavailable(\n \"fs:write\",\n captured?.directory ?? `../${systemTemporaryDirectoryName}`,\n \"makeTempFileScoped\"\n )\n : temp(captured?.directory).pipe(\n Effect.andThen(atomic.isolated.makeTempFileScoped(normalizeTempOptions(captured)))\n )\n )\n }),\n open: Effect.fn(\"FileSystem.open\")((value, options) => {\n const captured = snapshotOptions(options)\n const flag = captured?.flag ?? \"r\"\n const isolated = atomic?.isolated\n return isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"open\")\n : openChecks(value, flag).pipe(\n Effect.andThen(isolated.open(normalize(value), captured)),\n // fstat the handle the moment it exists: the authorization the\n // open checks granted binds to THIS resource identity, and every\n // later handle operation verifies the authorized path still\n // names it before delegating to the descriptor.\n Effect.flatMap((file) =>\n file.stat.pipe(\n Effect.map((info) => wrapFile(isolated, file, value, identityOf(info)))\n )\n )\n )\n }),\n readDirectory: Effect.fn(\"FileSystem.readDirectory\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:read\", value, \"readDirectory\", {\n operation: \"readDirectory\",\n path: normalize(value),\n options: captured\n })\n }),\n readFile: Effect.fn(\"FileSystem.readFile\")((value) =>\n atomicOne(\"fs:read\", value, \"readFile\", {\n operation: \"readFile\",\n path: normalize(value)\n })\n ),\n readLink: Effect.fn(\"FileSystem.readLink\")((value) =>\n atomicOne(\"fs:read\", value, \"readLink\", {\n operation: \"readLink\",\n path: normalize(value)\n })\n ),\n realPath: Effect.fn(\"FileSystem.realPath\")((value) =>\n atomicOne(\"fs:read\", value, \"realPath\", {\n operation: \"realPath\",\n path: normalize(value)\n })\n ),\n remove: Effect.fn(\"FileSystem.remove\")((value, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"remove\", {\n operation: \"remove\",\n path: normalize(value),\n options: captured\n })\n }),\n rename: Effect.fn(\"FileSystem.rename\")((from, to) =>\n atomicTwo([\"fs:write\", from], [\"fs:write\", to], \"rename\", {\n operation: \"rename\",\n from: normalize(from),\n to: normalize(to)\n })\n ),\n stat: Effect.fn(\"FileSystem.stat\")((value) =>\n atomicOne(\"fs:read\", value, \"stat\", {\n operation: \"stat\",\n path: normalize(value)\n })\n ),\n symlink: Effect.fn(\"FileSystem.symlink\")((from, to) =>\n isolatedOne(\"fs:write\", to, \"symlink\", (host) => host.symlink(from, normalize(to)))\n ),\n truncate: Effect.fn(\"FileSystem.truncate\")((value, length) =>\n isolatedOne(\"fs:write\", value, \"truncate\", (host) => host.truncate(normalize(value), length))\n ),\n utimes: Effect.fn(\"FileSystem.utimes\")((value, atime, mtime) =>\n isolatedOne(\"fs:write\", value, \"utimes\", (host) => host.utimes(normalize(value), atime, mtime))\n ),\n watch: (value) =>\n Stream.unwrap(\n Effect.fn(\"FileSystem.watch\")(() =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"watch\")\n : read(value).pipe(Effect.map(() => atomic.isolated!.watch(normalize(value))))\n )\n )()\n ),\n writeFile: Effect.fn(\"FileSystem.writeFile\")((value, data, options) => {\n const captured = snapshotOptions(options)\n const bytes = data.slice()\n // An isolated host shares this address space, so the detached\n // snapshot crosses no serialization boundary: hand it straight to\n // the delegate rather than base64 round-tripping it through the\n // serializable request shape.\n if (atomic?.isolated !== undefined) {\n return isolatedOne(\n \"fs:write\",\n value,\n \"writeFile\",\n (host) => host.writeFile(normalize(value), bytes, captured)\n )\n }\n // A serialized executor frames the base64 payload as one JS string.\n // Refuse what its runtime cannot represent before encoding, so an\n // oversized artifact is a typed BadArgument and not a defect out of\n // the encoder.\n const limit = atomic?.contentLimit\n if (limit !== undefined && bytes.byteLength > limit) {\n return Effect.fail(PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"writeFile\",\n description:\n `writeFile payload of ${bytes.byteLength} bytes exceeds the ${limit} byte limit advertised by the host`\n }))\n }\n return atomicOne(\"fs:write\", value, \"writeFile\", {\n operation: \"writeFile\",\n path: normalize(value),\n data: Base64.encode(bytes),\n options: captured\n })\n })\n }),\n exists: Effect.fn(\"FileSystem.exists\")((value) =>\n atomicOne(\"fs:read\", value, \"exists\", {\n operation: \"exists\",\n path: normalize(value)\n })\n ),\n readFileString: Effect.fn(\"FileSystem.readFileString\")((value, encoding) =>\n atomicOne(\"fs:read\", value, \"readFileString\", {\n operation: \"readFileString\",\n path: normalize(value),\n encoding\n })\n ),\n sink: (value, options) => {\n const captured = snapshotOptions(options)\n return (\n Sink.unwrap(\n Effect.fn(\"FileSystem.sink\")(\n () =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:write\", value, \"sink\")\n : write(value).pipe(Effect.map(() => atomic.isolated!.sink(normalize(value), captured)))\n )\n )()\n )\n )\n },\n stream: (value, options) => {\n const captured = snapshotOptions(options)\n return (\n Stream.unwrap(\n Effect.fn(\"FileSystem.stream\")(() =>\n Effect.suspend(() =>\n atomic?.isolated === undefined\n ? atomicUnavailable(\"fs:read\", value, \"stream\")\n : read(value).pipe(Effect.map(() => atomic.isolated!.stream(normalize(value), captured)))\n )\n )()\n )\n )\n },\n writeFileString: Effect.fn(\"FileSystem.writeFileString\")((value, data, options) => {\n const captured = snapshotOptions(options)\n return atomicOne(\"fs:write\", value, \"writeFileString\", {\n operation: \"writeFileString\",\n path: normalize(value),\n data,\n options: captured\n })\n })\n }\n // Every path operation of the guarded surface is already one\n // descriptor-relative request against this root (or refuses), so machinery\n // composed over it may use it as its confined view.\n Object.assign(guarded, { [ConfinedFileSystemTypeId]: logicalRoot })\n if (atomic === undefined || atomic.batchLimits === undefined) {\n return guarded\n } else {\n const limits = atomic.batchLimits\n const executeBatch: Batch.FileSystemBatch[\"execute\"] = Effect.fn(\"FileSystem.batch\")(function*(requests) {\n if (requests.length === 0 || requests.length > Math.min(limits.size, Batch.maxBatchSize)) {\n return yield* Effect.fail(\n PlatformError.badArgument({\n module: \"FileSystem\",\n method: \"batch\",\n description: `batch must contain 1 to ${Math.min(limits.size, Batch.maxBatchSize)} operations`\n })\n )\n }\n if (Option.isNone(rootIdentity)) {\n return yield* atomicUnavailable(\"fs:read\", logicalRoot, \"batch\")\n }\n // Snapshot before any asynchronous root or permission checks.\n const captured = snapshotOptions(requests).map((request) => ({\n ...request,\n path: request.operation === \"glob\"\n ? normalizeFrom(normalize(request.root), request.path)\n : normalize(request.path),\n ...(request.operation === \"glob\" ? { root: normalize(request.root) } : {})\n }))\n const rootChanged = (cause: unknown) =>\n PlatformError.systemError({\n _tag: \"Busy\",\n module: \"FileSystem\",\n method: \"batch\",\n pathOrDescriptor: logicalRoot,\n description: \"batch root no longer names the authorized descriptor\",\n cause\n })\n // A vanished workspace is a lost boundary, not N absent files. Check\n // before canonical resource resolution could turn it into per-path\n // NotFound results. Check the logical path as well: a workspace alias\n // may be retargeted while its old canonical directory still exists.\n // The helper separately checks the canonical root through no-follow\n // handles, binding both names to the same captured descriptor.\n const expectedRoot = rootIdentity.value\n const verifyRoot = () =>\n identifyRoot(atomic, fileSystem, logicalRoot).pipe(\n Effect.mapError(rootChanged),\n Effect.flatMap((current) =>\n Option.isSome(current) && current.value === expectedRoot\n ? Effect.void\n : Effect.fail(rootChanged(\n new FileSystemFault({\n code: \"workspace_identity_changed\",\n message: \"workspace descriptor identity changed\"\n })\n ))\n )\n )\n yield* verifyRoot()\n // Resolve in bounded groups while retaining request-order grant\n // decisions. Quota/once grants therefore retain their ordering, and\n // native metadata latency need not serialize every member twice.\n const resources = yield* resolvedResources(captured)\n const admitted: Array<Batch.BatchRequest> = []\n const indexes: Array<number> = []\n const entries: Array<Batch.BatchEntry> = []\n const granted: Array<\n { readonly request: Batch.BatchRequest; readonly index: number; readonly resource: string }\n > = []\n for (const [index, request] of captured.entries()) {\n const resource = resources[index]!\n const checked = Result.isFailure(resource) ? Result.fail(resource.failure) : yield* Effect.result(\n makeCapability(\"fs:read\", resource.success).pipe(\n Effect.flatMap((capability) => grants.check(capability)),\n Effect.mapError(refuse(\"read\", resource.success))\n )\n )\n if (Result.isFailure(checked)) {\n entries.push({ index, path: request.path, result: Result.fail(checked.failure) })\n } else granted.push({ request, index, resource: Result.getOrThrow(resource) })\n }\n const current = granted.length === 0\n ? []\n : yield* resolvedResources(granted.map(({ request }) => request))\n const settled = yield* Effect.forEach(granted, ({ resource }, position) => {\n const now = current[position]!\n return Effect.result(\n Result.isFailure(now)\n ? Effect.fail(now.failure)\n : now.success === resource\n ? Effect.void\n : deny(\"fs:read\", \"read\", resource, \"path no longer names the resource that was authorized\")\n )\n })\n for (const [position, member] of granted.entries()) {\n const checked = settled[position]!\n if (Result.isFailure(checked)) {\n entries.push({ index: member.index, path: member.request.path, result: Result.fail(checked.failure) })\n } else {\n admitted.push(member.request)\n indexes.push(member.index)\n }\n }\n yield* verifyRoot()\n if (admitted.length > 0) {\n const measured = yield* atomic.execute({\n operation: \"batch\",\n boundaryRoot,\n logicalRoot,\n rootIdentity: rootIdentity.value,\n requests: admitted\n })\n for (const entry of measured.entries) {\n entries.push({\n index: indexes[entry.index]!,\n path: entry.path,\n result: publicValue(entry.path, entry.result)\n })\n }\n }\n entries.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : a.index - b.index)\n return { rootIdentity: rootIdentity.value, entries }\n })\n return Object.assign(guarded, {\n [Batch.FileSystemBatchTypeId]: {\n maxSize: Math.min(limits.size, Batch.maxBatchSize),\n maxResponseBytes: limits.response,\n execute: executeBatch\n }\n })\n }\n })\n)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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["EffectPath", "EffectFileSystem", "root", "current"]
7
7
  }
@@ -16,8 +16,8 @@
16
16
  */
17
17
  import { Jj as JjPort } from "@smthrs/jj";
18
18
  import { FileSystem as EffectFileSystem, Layer, Path as EffectPath } from "effect";
19
- import { HttpClient as HttpClientPort } from "effect/unstable/http/HttpClient";
20
- import { ChildProcessSpawner as ChildProcessSpawnerPort } from "effect/unstable/process/ChildProcessSpawner";
19
+ import { HttpClient as HttpClientPort } from "effect/http/HttpClient";
20
+ import { ChildProcessSpawner as ChildProcessSpawnerPort } from "effect/process/ChildProcessSpawner";
21
21
  /**
22
22
  * The CLOSED LIST of platform ports the kernel protects.
23
23
  * Optional filesystem batches belong to the existing FileSystem slot. The
@@ -53,7 +53,7 @@ import { ChildProcessSpawner as ChildProcessSpawnerPort } from "effect/unstable/
53
53
  * swappable via `Effect.provideService`, and never decorated here — a `Clock`
54
54
  * or a `Random` carries no host authority to guard, so they are not ours to
55
55
  * define. `ChildProcessSpawner` is the same story one layer out: process spawning is
56
- * `effect/unstable/process`, and the slot holds Effect's tag rather than a
56
+ * `effect/process`, and the slot holds Effect's tag rather than a
57
57
  * Smithers wrapper around it.
58
58
  *
59
59
  * @category models
@@ -1 +1 @@
1
- {"version":3,"file":"HostServices.d.ts","sourceRoot":"","sources":["../../src/HostServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAClF,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,6CAA6C,CAAA;AAO5G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,MAAM,WAAW,GACnB,gBAAgB,CAAC,UAAU,GAC3B,UAAU,CAAC,IAAI,GACf,uBAAuB,GACvB,MAAM,GACN,cAAc,CAAA;AAElB;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,+TAMlB,CAAA;AAEV;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,2HAMjB,CAAA;AAEV;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,6UAMjB,CAAA"}
1
+ {"version":3,"file":"HostServices.d.ts","sourceRoot":"","sources":["../../src/HostServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAClF,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAOnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,MAAM,WAAW,GACnB,gBAAgB,CAAC,UAAU,GAC3B,UAAU,CAAC,IAAI,GACf,uBAAuB,GACvB,MAAM,GACN,cAAc,CAAA;AAElB;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,+TAMlB,CAAA;AAEV;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,2HAMjB,CAAA;AAEV;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,6UAMjB,CAAA"}
@@ -35,8 +35,8 @@ __export(HostServices_exports, {
35
35
  module.exports = __toCommonJS(HostServices_exports);
36
36
  var import_jj = require("@smthrs/jj");
37
37
  var import_effect = require("effect");
38
- var import_HttpClient = require("effect/unstable/http/HttpClient");
39
- var import_ChildProcessSpawner = require("effect/unstable/process/ChildProcessSpawner");
38
+ var import_HttpClient = require("effect/http/HttpClient");
39
+ var import_ChildProcessSpawner = require("effect/process/ChildProcessSpawner");
40
40
  var ChildProcessSpawner = __toESM(require("./ChildProcessSpawner.js"), 1);
41
41
  var FileSystem = __toESM(require("./FileSystem.js"), 1);
42
42
  var HttpClient = __toESM(require("./HttpClient.js"), 1);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/HostServices.ts"],
4
- "sourcesContent": ["/**\n * The closed Host service list.\n *\n * One list, one set of tags. The kernel decorates each slot **in place** \u2014 a\n * middleware `Layer` over the very tag the platform adapter provides \u2014 so\n * there is no second, \"protected\" tag to keep in slot-order sync with this\n * one, and no cast to force a guarded implementation onto a narrower error\n * contract.\n *\n * Governing design:\n * `docs/specs/Concepts/Permission Kernel.md`,\n * `docs/specs/Concepts/Trust Granularity.md`, and\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { Jj as JjPort } from \"@smthrs/jj\"\nimport { FileSystem as EffectFileSystem, Layer, Path as EffectPath } from \"effect\"\nimport { HttpClient as HttpClientPort } from \"effect/unstable/http/HttpClient\"\nimport { ChildProcessSpawner as ChildProcessSpawnerPort } from \"effect/unstable/process/ChildProcessSpawner\"\nimport * as ChildProcessSpawner from \"./ChildProcessSpawner.ts\"\nimport * as FileSystem from \"./FileSystem.ts\"\nimport * as HttpClient from \"./HttpClient.ts\"\nimport * as Jj from \"./Jj.ts\"\nimport * as Path from \"./Path.ts\"\n\n/**\n * The CLOSED LIST of platform ports the kernel protects.\n * Optional filesystem batches belong to the existing FileSystem slot. The\n * decorator grants each member separately and exposes no additional tag or\n * unguarded executor to consumers; host slot identities remain unchanged.\n *\n * Everything that touches the outside world enters Smithers through exactly one\n * of these tags \u2014 there is no ambient `node:fs`, no bare `spawn`, no global\n * `Date.now()`. Two things depend on that closure:\n *\n * 1. The capability kernel wraps precisely this list. A service that is not\n * here cannot be attenuated, denied, or audited, so it must not exist.\n * 2. Step keys digest this list as their `layers` component. Which platform\n * implementations were in scope is part of a step's identity, so a replay\n * under different layers is a different step rather than a silent lie.\n *\n * Each slot's guarded implementation replaces the raw one under the same tag,\n * so a consumer that never heard of the kernel still cannot bypass it. Where\n * Effect owns the tag (`FileSystem`, `Path`, `ChildProcessSpawner`,\n * `HttpClient`) the error channel stays Effect's own \u2014 `PlatformError`, or\n * `HttpClientError` for the network \u2014 and permission failures are projected\n * into it by `Permission.toPlatformError` and `HttpClient.toHttpClientError`;\n * where Smithers owns the service (`Jj`) the interface names the kernel's\n * failures directly.\n *\n * `Path` is intentionally retained as an explicit decision: it checks nothing\n * and resolves relative paths against `Workspace.root`.\n * Network access is Effect's own `HttpClient`: there is no Smithers transport\n * port beneath it, because a raw port would be a second way to reach the\n * network whose contract never mentions permission.\n *\n * `Clock` and `Random` are Effect core built-ins: already port-shaped, already\n * swappable via `Effect.provideService`, and never decorated here \u2014 a `Clock`\n * or a `Random` carries no host authority to guard, so they are not ours to\n * define. `ChildProcessSpawner` is the same story one layer out: process spawning is\n * `effect/unstable/process`, and the slot holds Effect's tag rather than a\n * Smithers wrapper around it.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type HostService =\n | EffectFileSystem.FileSystem\n | EffectPath.Path\n | ChildProcessSpawnerPort\n | JjPort\n | HttpClientPort\n\n/**\n * The Host tags consumed by the kernel at runtime, decorated in place by\n * {@link layer}, and digested by the step-key planner.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const HostServiceTags = [\n EffectFileSystem.FileSystem,\n EffectPath.Path,\n ChildProcessSpawnerPort,\n JjPort,\n HttpClientPort\n] as const\n\n/**\n * Stable slot identifiers shared by host composition, kernel attenuation, and\n * step-layer resolution.\n *\n * Each id is the tag key of its slot's service \u2014 Effect's own key for the\n * services Effect ships, the defining module's path for ours. The ids are\n * digested into step keys, so a rename invalidates every cached step naming\n * the slot; rename only when the service itself changes, as when `Shell` was\n * replaced by Effect's `ChildProcessSpawner`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const HostServiceIds = [\n \"effect/FileSystem\",\n \"effect/Path\",\n \"effect/process/ChildProcessSpawner\",\n \"@smthrs/jj/Jj\",\n \"effect/HttpClient\"\n] as const\n\n/**\n * Builds the full protected Host surface over a host platform bundle and a\n * `GrantStore`. `Workspace` remains a requirement so the exact same root\n * service can be supplied to both the grant store and filesystem decorators.\n *\n * Every member both requires and provides its own slot's tag: provide this\n * layer over a raw platform bundle and the guarded implementation shadows the\n * raw one for everything downstream. There is no exception and no second tag\n * list \u2014 `HttpClient` decorates Effect's network tag exactly the way\n * `FileSystem` decorates Effect's filesystem tag. The host supplies\n * `ProcessConfinement` for approved processes; absence refuses spawning.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = Layer.mergeAll(\n FileSystem.layer,\n Path.layer,\n ChildProcessSpawner.layer,\n Jj.layer,\n HttpClient.layer\n)\n"],
4
+ "sourcesContent": ["/**\n * The closed Host service list.\n *\n * One list, one set of tags. The kernel decorates each slot **in place** \u2014 a\n * middleware `Layer` over the very tag the platform adapter provides \u2014 so\n * there is no second, \"protected\" tag to keep in slot-order sync with this\n * one, and no cast to force a guarded implementation onto a narrower error\n * contract.\n *\n * Governing design:\n * `docs/specs/Concepts/Permission Kernel.md`,\n * `docs/specs/Concepts/Trust Granularity.md`, and\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { Jj as JjPort } from \"@smthrs/jj\"\nimport { FileSystem as EffectFileSystem, Layer, Path as EffectPath } from \"effect\"\nimport { HttpClient as HttpClientPort } from \"effect/http/HttpClient\"\nimport { ChildProcessSpawner as ChildProcessSpawnerPort } from \"effect/process/ChildProcessSpawner\"\nimport * as ChildProcessSpawner from \"./ChildProcessSpawner.ts\"\nimport * as FileSystem from \"./FileSystem.ts\"\nimport * as HttpClient from \"./HttpClient.ts\"\nimport * as Jj from \"./Jj.ts\"\nimport * as Path from \"./Path.ts\"\n\n/**\n * The CLOSED LIST of platform ports the kernel protects.\n * Optional filesystem batches belong to the existing FileSystem slot. The\n * decorator grants each member separately and exposes no additional tag or\n * unguarded executor to consumers; host slot identities remain unchanged.\n *\n * Everything that touches the outside world enters Smithers through exactly one\n * of these tags \u2014 there is no ambient `node:fs`, no bare `spawn`, no global\n * `Date.now()`. Two things depend on that closure:\n *\n * 1. The capability kernel wraps precisely this list. A service that is not\n * here cannot be attenuated, denied, or audited, so it must not exist.\n * 2. Step keys digest this list as their `layers` component. Which platform\n * implementations were in scope is part of a step's identity, so a replay\n * under different layers is a different step rather than a silent lie.\n *\n * Each slot's guarded implementation replaces the raw one under the same tag,\n * so a consumer that never heard of the kernel still cannot bypass it. Where\n * Effect owns the tag (`FileSystem`, `Path`, `ChildProcessSpawner`,\n * `HttpClient`) the error channel stays Effect's own \u2014 `PlatformError`, or\n * `HttpClientError` for the network \u2014 and permission failures are projected\n * into it by `Permission.toPlatformError` and `HttpClient.toHttpClientError`;\n * where Smithers owns the service (`Jj`) the interface names the kernel's\n * failures directly.\n *\n * `Path` is intentionally retained as an explicit decision: it checks nothing\n * and resolves relative paths against `Workspace.root`.\n * Network access is Effect's own `HttpClient`: there is no Smithers transport\n * port beneath it, because a raw port would be a second way to reach the\n * network whose contract never mentions permission.\n *\n * `Clock` and `Random` are Effect core built-ins: already port-shaped, already\n * swappable via `Effect.provideService`, and never decorated here \u2014 a `Clock`\n * or a `Random` carries no host authority to guard, so they are not ours to\n * define. `ChildProcessSpawner` is the same story one layer out: process spawning is\n * `effect/process`, and the slot holds Effect's tag rather than a\n * Smithers wrapper around it.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type HostService =\n | EffectFileSystem.FileSystem\n | EffectPath.Path\n | ChildProcessSpawnerPort\n | JjPort\n | HttpClientPort\n\n/**\n * The Host tags consumed by the kernel at runtime, decorated in place by\n * {@link layer}, and digested by the step-key planner.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const HostServiceTags = [\n EffectFileSystem.FileSystem,\n EffectPath.Path,\n ChildProcessSpawnerPort,\n JjPort,\n HttpClientPort\n] as const\n\n/**\n * Stable slot identifiers shared by host composition, kernel attenuation, and\n * step-layer resolution.\n *\n * Each id is the tag key of its slot's service \u2014 Effect's own key for the\n * services Effect ships, the defining module's path for ours. The ids are\n * digested into step keys, so a rename invalidates every cached step naming\n * the slot; rename only when the service itself changes, as when `Shell` was\n * replaced by Effect's `ChildProcessSpawner`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const HostServiceIds = [\n \"effect/FileSystem\",\n \"effect/Path\",\n \"effect/process/ChildProcessSpawner\",\n \"@smthrs/jj/Jj\",\n \"effect/HttpClient\"\n] as const\n\n/**\n * Builds the full protected Host surface over a host platform bundle and a\n * `GrantStore`. `Workspace` remains a requirement so the exact same root\n * service can be supplied to both the grant store and filesystem decorators.\n *\n * Every member both requires and provides its own slot's tag: provide this\n * layer over a raw platform bundle and the guarded implementation shadows the\n * raw one for everything downstream. There is no exception and no second tag\n * list \u2014 `HttpClient` decorates Effect's network tag exactly the way\n * `FileSystem` decorates Effect's filesystem tag. The host supplies\n * `ProcessConfinement` for approved processes; absence refuses spawning.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = Layer.mergeAll(\n FileSystem.layer,\n Path.layer,\n ChildProcessSpawner.layer,\n Jj.layer,\n HttpClient.layer\n)\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,gBAA6B;AAC7B,oBAA0E;AAC1E,wBAA6C;AAC7C,iCAA+D;AAC/D,0BAAqC;AACrC,iBAA4B;AAC5B,iBAA4B;AAC5B,SAAoB;AACpB,WAAsB;AAyDf,MAAM,kBAAkB;AAAA,EAC7B,cAAAA,WAAiB;AAAA,EACjB,cAAAC,KAAW;AAAA,EACX,2BAAAC;AAAA,EACA,UAAAC;AAAA,EACA,kBAAAC;AACF;AAeO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAiBO,MAAM,QAAQ,oBAAM;AAAA,EACzB,WAAW;AAAA,EACX,KAAK;AAAA,EACL,oBAAoB;AAAA,EACpB,GAAG;AAAA,EACH,WAAW;AACb;",
6
6
  "names": ["EffectFileSystem", "EffectPath", "ChildProcessSpawnerPort", "JjPort", "HttpClientPort"]
7
7
  }