@smthrs/kernel 1.0.0-rc.4 → 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 +1 @@
1
- {"version":3,"file":"ContainedSpawner.js","sourceRoot":"","sources":["../../src/ContainedSpawner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,QAAQ,MAAM,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W,EAAE,wDAAwD;IACrE,KAAK;CACN,CAAC,CAAA;AAEJ;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CACrB,MAA6B,EAC7B,MAAmC,EACd,EAAE,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CACzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACrB,MAAM,CAAC,UAAU,CAAC,mCAAmC,MAAM,CAAC,GAAG,6BAA6B,EAAE,KAAK,CAAC,CACrG,CACF,CAAA","sourcesContent":["/**\n * Process containment: prepared ownership, bounded cleanup and durable records.\n *\n * A host supplies a {@link Lifecycle} that owns launch and cleanup independently\n * of the command's exit status. The lifecycle first prepares a process identity;\n * this decorator commits that identity to {@link ProcessLedger.ProcessLedger}\n * before activating the caller's command. Failed or interrupted startup closes\n * its child scope immediately, including any earlier legs of a partial pipeline.\n *\n * Each command receives default termination and escalation options. The host\n * lifecycle validates that policy and verifies cleanup before the decorator\n * retires its record. Unverifiable cleanup retains the record for recovery;\n * a host that dies also leaves its committed records discoverable by the next\n * incarnation's reaper (`ProcessReaper` in `@smthrs/platform-node`).\n *\n * Every pipeline leg is prepared and recorded separately, including legs whose\n * pid the aggregate handle does not expose. The module remains platform-neutral.\n * A layer without a lifecycle provides only deadline defaults and bookkeeping;\n * it does not declare the verified-cleanup contract read by {@link isContained}.\n *\n * Governing design:\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Layer from \"effect/Layer\"\nimport * as PlatformError from \"effect/PlatformError\"\nimport * as Schedule from \"effect/Schedule\"\nimport * as Scope from \"effect/Scope\"\nimport * as ChildProcess from \"effect/unstable/process/ChildProcess\"\nimport {\n type ChildProcessHandle,\n ChildProcessSpawner,\n make as makeSpawner\n} from \"effect/unstable/process/ChildProcessSpawner\"\nimport * as CommandLine from \"./CommandLine.ts\"\nimport * as Containment from \"./internal/Containment.ts\"\nimport * as Pipeline from \"./internal/Pipeline.ts\"\nimport * as ProcessLedger from \"./ProcessLedger.ts\"\n\n/**\n * How long a contained child may take to honour `SIGTERM`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const defaultGraceMs = 2000\n\n/**\n * Containment configuration.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Options {\n /**\n * Milliseconds between the `SIGTERM` that asks a child to stop and the\n * `SIGKILL` that makes it. Default {@link defaultGraceMs}.\n */\n readonly graceMs?: number | undefined\n /**\n * The platform the host spawner runs on, as `process.platform` spells it.\n * Windows records no POSIX process group, including for detached children.\n * On POSIX, detachment determines whether the child leads its own group.\n * Default `\"linux\"`; host bundles pass their actual platform.\n */\n readonly platform?: string | undefined\n}\n\n/**\n * A platform's preparation, activation, and cleanup of a contained process.\n *\n * Preparation receives the underlying spawner and must own cleanup before it\n * can fail or be interrupted. It returns the process identity to record and an\n * idempotent `activate` effect. The decorator runs activation only after that\n * identity commits to the ledger. A platform can therefore prepare an owner\n * without executing the caller's command before it is durably discoverable.\n *\n * Failed startup closes its own scope immediately. A successful startup keeps\n * that scope attached to the caller's scope. `settled` must stay false on failed\n * or unverifiable cleanup; only verified cleanup permits ledger retirement.\n * The wrapped handle applies the same policy to an explicit `kill`.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Lifecycle = (\n command: ChildProcess.StandardCommand,\n spawn: (\n command: ChildProcess.StandardCommand\n ) => Effect.Effect<ChildProcessHandle, PlatformError.PlatformError, Scope.Scope>\n) => Effect.Effect<\n {\n readonly handle: ChildProcessHandle\n readonly activate: Effect.Effect<void, PlatformError.PlatformError, Scope.Scope>\n readonly settled: Effect.Effect<boolean>\n },\n PlatformError.PlatformError,\n Scope.Scope\n>\n\n/**\n * Whether a spawner declares the platform lifecycle required for containment.\n *\n * Only a layer with a {@link Lifecycle} declares this contract. A kill deadline\n * alone does not verify cleanup. The permission decorator preserves the\n * declaration when it wraps a contained service. The marker interoperates\n * across the package's ESM and CommonJS projections.\n *\n * This is a trusted composition check: a caller-supplied lifecycle remains\n * responsible for implementing its contract.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const isContained = (spawner: ChildProcessSpawner[\"Service\"]): boolean => Containment.isContained(spawner)\n\n/**\n * Supplies a command's default termination signal and escalation deadline.\n *\n * Both legs of a pipeline get the same policy — a pipeline is one action's\n * process tree and a surviving leg is as much of a leak as a surviving\n * child. Explicit `killSignal` and `forceKillAfter` values are preserved for\n * the host lifecycle to validate.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const withContainment = (\n command: ChildProcess.Command,\n options?: Options\n): ChildProcess.Command => {\n const graceMs = options?.graceMs ?? defaultGraceMs\n if (command._tag === \"PipedCommand\") {\n return ChildProcess.pipeTo(\n withContainment(command.left, options),\n withContainment(command.right, options),\n command.options\n )\n }\n return ChildProcess.make(command.command, [...command.args], {\n ...command.options,\n killSignal: command.options.killSignal ?? \"SIGTERM\",\n forceKillAfter: command.options.forceKillAfter ?? graceMs\n })\n}\n\n/**\n * The process group a started child leads, or `null` when it shares the\n * host's or the platform has no POSIX process groups.\n *\n * A detached POSIX child leads a group whose id is its own pid. A child in\n * the host's group must not record that group as its own cleanup target.\n * Windows detachment creates an independent console, not a POSIX group;\n * Windows records therefore always carry `null`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const groupOf = (command: ChildProcess.Command, pid: number, platform?: string): number | null => {\n if (platform === \"win32\") return null\n const options = command._tag === \"PipedCommand\" ? rightmost(command).options : command.options\n return (options.detached ?? true) ? pid : null\n}\n\nconst rightmost = (command: ChildProcess.Command): ChildProcess.StandardCommand =>\n command._tag === \"StandardCommand\" ? command : rightmost(command.right)\n\n/**\n * Decorates the process spawner in place with containment and bookkeeping.\n *\n * Compose it over a host spawner layer with `Layer.provide`. It provides the\n * tag it also requires. Compose the permission decorator over this layer to\n * authorize the caller's whole pipeline before its per-process expansion. A\n * lifecycle may use different commands during preparation; a decorator below\n * containment sees those platform commands instead of the caller's command.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (\n options?: Options,\n lifecycle?: Lifecycle\n): Layer.Layer<ChildProcessSpawner, never, ChildProcessSpawner | ProcessLedger.ProcessLedger> =>\n Layer.effect(\n ChildProcessSpawner,\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n const ledger = yield* ProcessLedger.ProcessLedger\n const service = makeSpawner(\n (command) =>\n Effect.uninterruptibleMask((restore) =>\n Effect.gen(function*() {\n // A failed startup must clean up even when its caller catches the\n // error and keeps the outer scope open. One child scope contains\n // the entire pipeline, so failure of a later leg also closes all\n // earlier legs. Successful spawns retain it until their caller closes.\n const processScope = yield* Scope.fork(yield* Scope.Scope)\n return yield* restore(\n Pipeline.spawn(\n command,\n Effect.fn(\"ContainedSpawner.spawn\")(function*(command) {\n // The release finalizer is registered BEFORE the spawn, so scope\n // closure runs it AFTER the spawn's own kill finalizer: finalizers\n // run last-registered-first, and a ledger that announced an exit\n // while the process was still being signalled would be telling the\n // next incarnation to stop looking for something still alive. The\n // slot is empty until the record exists, which is also what makes a\n // spawn that never got recorded a no-op to release.\n const slot: { current?: ProcessLedger.ProcessRecord; settled: Effect.Effect<boolean> } = {\n settled: Effect.succeed(true)\n }\n yield* Effect.addFinalizer(() =>\n Effect.gen(function*() {\n if (slot.current === undefined) return\n if (yield* slot.settled) return yield* releaseQuietly(ledger, slot.current)\n yield* Effect.logWarning(\n `process cleanup could not verify ${slot.current.pid}; retaining its ledger record`\n )\n })\n )\n const contained = withContainment(command, options) as ChildProcess.StandardCommand\n const watched = lifecycle === undefined ? undefined : yield* lifecycle(contained, spawner.spawn)\n const handle = watched?.handle ?? (yield* spawner.spawn(contained))\n slot.settled = watched?.settled ?? slot.settled\n const pid = handle.pid as number\n slot.current = yield* ledger.record({\n pid,\n pgid: groupOf(command, pid, options?.platform),\n commandDigest: CommandLine.executable(command)\n }).pipe(\n // A spawn whose record did not commit is precisely the child this\n // module exists to make discoverable, so it is not started: the\n // process is signalled and the caller is told, rather than left\n // running with nothing durable naming it.\n Effect.tapCause(() => Effect.ignore(handle.kill())),\n Effect.mapError(unrecorded)\n )\n if (watched !== undefined) yield* watched.activate\n return handle\n })\n ).pipe(Scope.provide(processScope))\n ).pipe(\n Effect.onError((cause) => Scope.close(processScope, Exit.failCause(cause)))\n )\n })\n )\n )\n return lifecycle === undefined ? service : Containment.mark(service)\n })\n )\n\n/** The spawn failure a caller sees when the ledger could not record a child. */\nconst unrecorded = (cause: unknown): PlatformError.PlatformError =>\n PlatformError.systemError({\n _tag: \"Unknown\",\n module: \"ChildProcess\",\n method: \"spawn\",\n description: \"the process ledger could not record this spawn durably\",\n cause\n })\n\n/**\n * Retires a record on scope close, retrying the durable write.\n *\n * A finalizer has nowhere to report a failure, so the retry is the report: an\n * exit that never commits leaves the record inherited, and the next\n * incarnation's reaper finds a pid that is already gone and retires it then.\n * That is the safe direction, and the reason this is the ONE place a ledger\n * failure is logged rather than propagated.\n */\nconst releaseQuietly = (\n ledger: ProcessLedger.Service,\n record: ProcessLedger.ProcessRecord\n): Effect.Effect<void> =>\n ledger.release(record).pipe(\n Effect.retry(Schedule.recurs(2)),\n Effect.catch((error) =>\n Effect.logWarning(`process ledger could not retire ${record.pid}; leaving it for the reaper`, error)\n )\n )\n"]}
1
+ {"version":3,"file":"ContainedSpawner.js","sourceRoot":"","sources":["../../src/ContainedSpawner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAA;AAC3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;IACrE,KAAK;CACN,CAAC,CAAA;AAEJ;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,CACrB,MAA6B,EAC7B,MAAmC,EACd,EAAE,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CACzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACrB,MAAM,CAAC,UAAU,CAAC,mCAAmC,MAAM,CAAC,GAAG,6BAA6B,EAAE,KAAK,CAAC,CACrG,CACF,CAAA","sourcesContent":["/**\n * Process containment: prepared ownership, bounded cleanup and durable records.\n *\n * A host supplies a {@link Lifecycle} that owns launch and cleanup independently\n * of the command's exit status. The lifecycle first prepares a process identity;\n * this decorator commits that identity to {@link ProcessLedger.ProcessLedger}\n * before activating the caller's command. Failed or interrupted startup closes\n * its child scope immediately, including any earlier legs of a partial pipeline.\n *\n * Each command receives default termination and escalation options. The host\n * lifecycle validates that policy and verifies cleanup before the decorator\n * retires its record. Unverifiable cleanup retains the record for recovery;\n * a host that dies also leaves its committed records discoverable by the next\n * incarnation's reaper (`ProcessReaper` in `@smthrs/platform-node`).\n *\n * Every pipeline leg is prepared and recorded separately, including legs whose\n * pid the aggregate handle does not expose. The module remains platform-neutral.\n * A layer without a lifecycle provides only deadline defaults and bookkeeping;\n * it does not declare the verified-cleanup contract read by {@link isContained}.\n *\n * Governing design:\n * `docs/specs/Concepts/Host Adapters.md`.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Layer from \"effect/Layer\"\nimport * as PlatformError from \"effect/PlatformError\"\nimport * as ChildProcess from \"effect/process/ChildProcess\"\nimport { type ChildProcessHandle, ChildProcessSpawner, make as makeSpawner } from \"effect/process/ChildProcessSpawner\"\nimport * as Schedule from \"effect/Schedule\"\nimport * as Scope from \"effect/Scope\"\nimport * as CommandLine from \"./CommandLine.ts\"\nimport * as Containment from \"./internal/Containment.ts\"\nimport * as Pipeline from \"./internal/Pipeline.ts\"\nimport * as ProcessLedger from \"./ProcessLedger.ts\"\n\n/**\n * How long a contained child may take to honour `SIGTERM`.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport const defaultGraceMs = 2000\n\n/**\n * Containment configuration.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Options {\n /**\n * Milliseconds between the `SIGTERM` that asks a child to stop and the\n * `SIGKILL` that makes it. Default {@link defaultGraceMs}.\n */\n readonly graceMs?: number | undefined\n /**\n * The platform the host spawner runs on, as `process.platform` spells it.\n * Windows records no POSIX process group, including for detached children.\n * On POSIX, detachment determines whether the child leads its own group.\n * Default `\"linux\"`; host bundles pass their actual platform.\n */\n readonly platform?: string | undefined\n}\n\n/**\n * A platform's preparation, activation, and cleanup of a contained process.\n *\n * Preparation receives the underlying spawner and must own cleanup before it\n * can fail or be interrupted. It returns the process identity to record and an\n * idempotent `activate` effect. The decorator runs activation only after that\n * identity commits to the ledger. A platform can therefore prepare an owner\n * without executing the caller's command before it is durably discoverable.\n *\n * Failed startup closes its own scope immediately. A successful startup keeps\n * that scope attached to the caller's scope. `settled` must stay false on failed\n * or unverifiable cleanup; only verified cleanup permits ledger retirement.\n * The wrapped handle applies the same policy to an explicit `kill`.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Lifecycle = (\n command: ChildProcess.StandardCommand,\n spawn: (\n command: ChildProcess.StandardCommand\n ) => Effect.Effect<ChildProcessHandle, PlatformError.PlatformError, Scope.Scope>\n) => Effect.Effect<\n {\n readonly handle: ChildProcessHandle\n readonly activate: Effect.Effect<void, PlatformError.PlatformError, Scope.Scope>\n readonly settled: Effect.Effect<boolean>\n },\n PlatformError.PlatformError,\n Scope.Scope\n>\n\n/**\n * Whether a spawner declares the platform lifecycle required for containment.\n *\n * Only a layer with a {@link Lifecycle} declares this contract. A kill deadline\n * alone does not verify cleanup. The permission decorator preserves the\n * declaration when it wraps a contained service. The marker interoperates\n * across the package's ESM and CommonJS projections.\n *\n * This is a trusted composition check: a caller-supplied lifecycle remains\n * responsible for implementing its contract.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const isContained = (spawner: ChildProcessSpawner[\"Service\"]): boolean => Containment.isContained(spawner)\n\n/**\n * Supplies a command's default termination signal and escalation deadline.\n *\n * Both legs of a pipeline get the same policy — a pipeline is one action's\n * process tree and a surviving leg is as much of a leak as a surviving\n * child. Explicit `killSignal` and `forceKillAfter` values are preserved for\n * the host lifecycle to validate.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const withContainment = (\n command: ChildProcess.Command,\n options?: Options\n): ChildProcess.Command => {\n const graceMs = options?.graceMs ?? defaultGraceMs\n if (command._tag === \"PipedCommand\") {\n return ChildProcess.pipeTo(\n withContainment(command.left, options),\n withContainment(command.right, options),\n command.options\n )\n }\n return ChildProcess.make(command.command, [...command.args], {\n ...command.options,\n killSignal: command.options.killSignal ?? \"SIGTERM\",\n forceKillAfter: command.options.forceKillAfter ?? graceMs\n })\n}\n\n/**\n * The process group a started child leads, or `null` when it shares the\n * host's or the platform has no POSIX process groups.\n *\n * A detached POSIX child leads a group whose id is its own pid. A child in\n * the host's group must not record that group as its own cleanup target.\n * Windows detachment creates an independent console, not a POSIX group;\n * Windows records therefore always carry `null`.\n *\n * @category constructors\n * @since 1.0.0-rc.0\n */\nexport const groupOf = (command: ChildProcess.Command, pid: number, platform?: string): number | null => {\n if (platform === \"win32\") return null\n const options = command._tag === \"PipedCommand\" ? rightmost(command).options : command.options\n return (options.detached ?? true) ? pid : null\n}\n\nconst rightmost = (command: ChildProcess.Command): ChildProcess.StandardCommand =>\n command._tag === \"StandardCommand\" ? command : rightmost(command.right)\n\n/**\n * Decorates the process spawner in place with containment and bookkeeping.\n *\n * Compose it over a host spawner layer with `Layer.provide`. It provides the\n * tag it also requires. Compose the permission decorator over this layer to\n * authorize the caller's whole pipeline before its per-process expansion. A\n * lifecycle may use different commands during preparation; a decorator below\n * containment sees those platform commands instead of the caller's command.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (\n options?: Options,\n lifecycle?: Lifecycle\n): Layer.Layer<ChildProcessSpawner, never, ChildProcessSpawner | ProcessLedger.ProcessLedger> =>\n Layer.effect(\n ChildProcessSpawner,\n Effect.gen(function*() {\n const spawner = yield* ChildProcessSpawner\n const ledger = yield* ProcessLedger.ProcessLedger\n const service = makeSpawner(\n (command) =>\n Effect.uninterruptibleMask((restore) =>\n Effect.gen(function*() {\n // A failed startup must clean up even when its caller catches the\n // error and keeps the outer scope open. One child scope contains\n // the entire pipeline, so failure of a later leg also closes all\n // earlier legs. Successful spawns retain it until their caller closes.\n const processScope = yield* Scope.fork(yield* Scope.Scope)\n return yield* restore(\n Pipeline.spawn(\n command,\n Effect.fn(\"ContainedSpawner.spawn\")(function*(command) {\n // The release finalizer is registered BEFORE the spawn, so scope\n // closure runs it AFTER the spawn's own kill finalizer: finalizers\n // run last-registered-first, and a ledger that announced an exit\n // while the process was still being signalled would be telling the\n // next incarnation to stop looking for something still alive. The\n // slot is empty until the record exists, which is also what makes a\n // spawn that never got recorded a no-op to release.\n const slot: { current?: ProcessLedger.ProcessRecord; settled: Effect.Effect<boolean> } = {\n settled: Effect.succeed(true)\n }\n yield* Effect.addFinalizer(() =>\n Effect.gen(function*() {\n if (slot.current === undefined) return\n if (yield* slot.settled) return yield* releaseQuietly(ledger, slot.current)\n yield* Effect.logWarning(\n `process cleanup could not verify ${slot.current.pid}; retaining its ledger record`\n )\n })\n )\n const contained = withContainment(command, options) as ChildProcess.StandardCommand\n const watched = lifecycle === undefined ? undefined : yield* lifecycle(contained, spawner.spawn)\n const handle = watched?.handle ?? (yield* spawner.spawn(contained))\n slot.settled = watched?.settled ?? slot.settled\n const pid = handle.pid as number\n slot.current = yield* ledger.record({\n pid,\n pgid: groupOf(command, pid, options?.platform),\n commandDigest: CommandLine.executable(command)\n }).pipe(\n // A spawn whose record did not commit is precisely the child this\n // module exists to make discoverable, so it is not started: the\n // process is signalled and the caller is told, rather than left\n // running with nothing durable naming it.\n Effect.tapCause(() => Effect.ignore(handle.kill())),\n Effect.mapError(unrecorded)\n )\n if (watched !== undefined) yield* watched.activate\n return handle\n })\n ).pipe(Scope.provide(processScope))\n ).pipe(\n Effect.onError((cause) => Scope.close(processScope, Exit.failCause(cause)))\n )\n })\n )\n )\n return lifecycle === undefined ? service : Containment.mark(service)\n })\n )\n\n/** The spawn failure a caller sees when the ledger could not record a child. */\nconst unrecorded = (cause: unknown): PlatformError.PlatformError =>\n PlatformError.systemError({\n _tag: \"Unknown\",\n module: \"ChildProcess\",\n method: \"spawn\",\n description: \"the process ledger could not record this spawn durably\",\n cause\n })\n\n/**\n * Retires a record on scope close, retrying the durable write.\n *\n * A finalizer has nowhere to report a failure, so the retry is the report: an\n * exit that never commits leaves the record inherited, and the next\n * incarnation's reaper finds a pid that is already gone and retires it then.\n * That is the safe direction, and the reason this is the ONE place a ledger\n * failure is logged rather than propagated.\n */\nconst releaseQuietly = (\n ledger: ProcessLedger.Service,\n record: ProcessLedger.ProcessRecord\n): Effect.Effect<void> =>\n ledger.release(record).pipe(\n Effect.retry(Schedule.recurs(2)),\n Effect.catch((error) =>\n Effect.logWarning(`process ledger could not retire ${record.pid}; leaving it for the reaper`, error)\n )\n )\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../src/FileSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,MAAM,EAEN,UAAU,IAAI,gBAAgB,EAC9B,KAAK,EAEL,IAAI,IAAI,UAAU,EAClB,aAAa,EACb,MAAM,EACN,MAAM,EAGP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,KAAK,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,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AAM,iBAAiB,GAC5B,YAAY,gBAAgB,CAAC,UAAU,EACvC,MAAM,UAAU,CAAC,IAAI,EACrB,eAAe,MAAM,EACrB,OAAO,MAAM,KACZ,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,aAAa,CA6CnD,CAAA;AAoID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAC7B,gBAAgB,CAAC,UAAU,EAC3B,aAAa,CAAC,aAAa,EAC3B,gBAAgB,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,GAAG,SAAS,GAAG,UAAU,CAkvBvE,CAAA"}
@@ -17,7 +17,8 @@
17
17
  * @since 1.0.0-rc.0
18
18
  */
19
19
  import { permissionDenied, toPlatformError } from "@smthrs/capability/Permission";
20
- import { Effect, Encoding, FileSystem as EffectFileSystem, Layer, Option, Path as EffectPath, PlatformError, Result, Schema, Sink, Stream } from "effect";
20
+ import { Effect, FileSystem as EffectFileSystem, Layer, Option, Path as EffectPath, PlatformError, Result, Schema, Sink, Stream } from "effect";
21
+ import { Base64 } from "effect/encoding";
21
22
  import * as Batch from "./FileSystemBatch.js";
22
23
  import { GrantStore } from "./GrantStore.js";
23
24
  import { makeCapability } from "./internal/makeCapability.js";
@@ -128,7 +129,7 @@ export const withIsolatedFileSystem = (fileSystem) => {
128
129
  remove: (request) => fileSystem.remove(request.path, request.options),
129
130
  rename: (request) => fileSystem.rename(request.from, request.to),
130
131
  stat: (request) => fileSystem.stat(request.path),
131
- writeFile: (request) => Encoding.decodeBase64(request.data).pipe(Effect.fromResult, Effect.orDie, Effect.flatMap((data) => fileSystem.writeFile(request.path, data, request.options))),
132
+ writeFile: (request) => Base64.decode(request.data).pipe(Effect.fromResult, Effect.orDie, Effect.flatMap((data) => fileSystem.writeFile(request.path, data, request.options))),
132
133
  writeFileString: (request) => fileSystem.writeFileString(request.path, request.data, request.options),
133
134
  // An attested volume advertises no `batchLimits`, so the guarded layer
134
135
  // never frames a batch for this executor.
@@ -313,7 +314,7 @@ export const confined = (fileSystem, root) => Effect.gen(function* () {
313
314
  return run({
314
315
  operation: "writeFile",
315
316
  path: normalize(value),
316
- data: Encoding.encodeBase64(data),
317
+ data: Base64.encode(data),
317
318
  options
318
319
  });
319
320
  }
@@ -833,7 +834,7 @@ export const layer = Layer.effect(EffectFileSystem.FileSystem, Effect.gen(functi
833
834
  return atomicOne("fs:write", value, "writeFile", {
834
835
  operation: "writeFile",
835
836
  path: normalize(value),
836
- data: Encoding.encodeBase64(bytes),
837
+ data: Base64.encode(bytes),
837
838
  options: captured
838
839
  });
839
840
  })