Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .agents/skills/host-platform-context/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
name: host-platform-context
description: "Use when modifying cli/src/engine-native/exec.ts spawnHost, spawnProcess, capture, captureWithin, which; os/*.ts HostOs facts (invoke, executableSuffixes, installHint, bunInstaller) or os/targets.ts HOST_TARGETS; deps.ts DEPENDENCIES, findBun, resolveVersionReading; services.ts makeDependencyManager or the cli/src/services.ts Effect layers; atomicWrite.ts replaceFile, replaceTextIfChanged, or removeStaleTemporaries; processes.ts processExited; or logger.ts terminal lease. Covers Windows cmd-shim encoding, pathless-spawn refusal, bounded process-group kills, version-probe time limits, symlink-preserving atomic writes and the cleanup of their killed-write leftovers, and the host support matrix. Not for golden harness rules (use engine-native-context) or toolchain pins and the doctor table (use toolchain-context)."
description: "Use when modifying cli/src/engine-native/exec.ts spawnHost, spawnProcess, capture, captureWithin, which; os/*.ts HostOs facts (invoke, executableSuffixes, installHint, bunInstaller) or os/targets.ts HOST_TARGETS; deps.ts DEPENDENCIES, findBun, resolveVersion; services.ts makeDependencyManager or the cli/src/services.ts Effect layers; atomicWrite.ts replaceFile, replaceTextIfChanged, or removeStaleTemporaries; processes.ts processExited; or logger.ts terminal lease. Covers Windows cmd-shim encoding, pathless-spawn refusal, bounded process-group kills, version-probe time limits, symlink-preserving atomic writes and the cleanup of their killed-write leftovers, and the host support matrix. Not for golden harness rules (use engine-native-context) or toolchain pins and the doctor table (use toolchain-context)."
user-invocable: false
metadata:
pattern: tool-wrapper
source_files:
- path: cli/src/engine-native/exec.ts
lines: "1-351"
- path: cli/src/engine-native/deps.ts
lines: "1-224"
lines: "1-247"
- path: cli/src/engine-native/os/types.ts
lines: "1-40"
- path: cli/src/engine-native/os/index.ts
Expand All @@ -30,10 +30,10 @@ metadata:
- path: cli/src/engine-native/logger.ts
lines: "1-275"
- path: cli/src/engine-native/services.ts
lines: "1-88"
lines: "1-92"
- path: cli/src/services.ts
lines: "1-42"
updated: "2026-12-01"
updated: "2026-12-02"
---

# Host Platform Layer
Expand Down Expand Up @@ -68,8 +68,8 @@ Output channels, change detection, the missing-dependency warn shape, and the li
| Sync child | `spawnHost(cmd, args, overrides, host)` | `cli/src/engine-native/exec.ts` — `spawnHost` — resolves suffixes, applies `host.invoke`, and passes that invocation's `windowsVerbatimArguments`. Only a `.cmd`/`.bat` shim sets the flag (verify: `bunx vitest run cli/test/unit/os/windows.test.ts -t "normalizes and escapes the Windows command shim path"`; verify: `bunx vitest run cli/test/unit/os/windows.test.ts -t "invokes an executable directly with its arguments untouched"`). Unprobed: no unit test reads the options that `spawnHost` gives `spawnSync` (verify: `grep -n "windowsVerbatimArguments: invocation" cli/src/engine-native/exec.ts`) |
| Async child | `spawnProcess(cmd, args, { stdio, cwd, env, host, timeoutMs })` | `exec.ts` — `spawnProcess` — default stdio discards stderr; pass `["ignore","pipe","pipe"]` when the caller prints `processFailureSummary`; `env` replaces the child environment, else the child gets the environment of the process |
| Bounded probe | `captureWithin(cmd, args, ms)` → `output`/`failed`/`timed-out` | `exec.ts` — `captureWithin`, `killProcessTree` — POSIX children lead their own group (`detached`) and die by negative pid; Windows runs `taskkill /T /F` from `SystemRoot\System32` (`C:\Windows` when unset; unlike `commandInterpreter`, the value is not checked for an absolute path) |
| Version read | `deps.resolveVersionReading` | `cli/src/engine-native/deps.ts` — `VERSION_PROBE_LIMIT_MS` — keeps "no answer in time" apart from "no version" (verify: `grep -n VERSION_PROBE_LIMIT_MS cli/src/engine-native/deps.ts`) |
| Presence | `ctx.services.deps.probe(id)` | `deps.ts` — `pathProbe`, `findBun` — Bun must resolve to an absolute path because callers run it outside the sync working directory |
| Version read | `deps.resolveVersion` (an Effect) | `cli/src/engine-native/deps.ts` — `VERSION_PROBE_LIMIT_MS` — the default bounded reader (`<id> --version` through `captureWithin`) reads a failed command and a probe that does not answer in time as no version (""). A spec with its own `version` reader (Bun, omp) has no time limit. A throw or a rejection of an executor call is not a version: it fails the Effect with `LegacyStepFailed` (verify: `bunx vitest run cli/test/unit/deps.test.ts -t "does not answer within the limit"`) |
| Presence | `ctx.services.deps.probe(id)` (an Effect) | `deps.ts` — `pathProbe`, `findBun` — Bun must resolve to an absolute path because callers run it outside the sync working directory. `probe`, `version`, and `path` are Effects; their calls into the executor (`exec.ts`) and `home.ts engineHome` go through `bridge.ts bridgeSync` or `bridgePromise` until #297, so a throw or a rejection there is `LegacyStepFailed`. The `ProbeExecutor` test doubles keep the shapes of the `exec.ts` functions |
| Missing tool warning | `ctx.services.deps.warnMissing(id, logger, context)` | `cli/src/engine-native/services.ts` — `makeDependencyManager` — one warning per tool per manager |
| Host fact | `hostOs(ctx.services.platform.name())` | `cli/src/engine-native/os/types.ts` — `HostOs` — facts that cannot be probed only |
| Supported host | `HOST_TARGETS` | `cli/src/engine-native/os/targets.ts` — `HOST_TARGETS` — adding a row adds a host. `hostTargets.test.ts` checks the table against the host checks of the Bash and PowerShell launchers (verify: `bunx vitest run cli/test/unit/hostTargets.test.ts -t "keeps the Bash launcher aligned with every POSIX host target"`; verify: `bunx vitest run cli/test/unit/hostTargets.test.ts -t "keeps the PowerShell launcher aligned with every Windows host target"`) |
Expand Down
9 changes: 5 additions & 4 deletions .agents/skills/omp-sync-context/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
- path: cli/src/engine-native/ompFileDeploy.ts
lines: "1-131"
- path: cli/src/engine-native/ompPlugins.ts
lines: "1-436"
lines: "1-434"
- path: cli/src/engine-native/ompKitPlugin.ts
lines: "1-164"
- path: cli/src/engine-native/ompRemovals.ts
Expand Down Expand Up @@ -87,9 +87,10 @@ the run with `PluginFileRemoveFailed`, and a failed folder removal with
`FileSystem.remove` adapter of Bun 1.4.5 reports `EPERM` as `EFAULT`.

The calls of the passes into `atomicWrite.ts`, `exec.ts` (through
`ompChild.ts spawnOmp`), the dependency probes, and the logger (also through
`recordFailure` and `deps.warnMissing`) stay behind `bridge.ts bridgeSync` or
`bridgePromise` until #297 and #298.
`ompChild.ts spawnOmp`), and the logger (also through `recordFailure` and
`deps.warnMissing`) stay behind `bridge.ts bridgeSync` or `bridgePromise`
until #297. The dependency probes are Effects since #298, so the plugin pass
calls them directly.
Every text read that a comparison or a parser uses goes through
`fileText.ts readTextKeepingBom`, which keeps a leading byte order mark, as
`readFileSync(path, "utf8")` did; `FileSystem.readFileString` drops it.
Expand Down
59 changes: 35 additions & 24 deletions .agents/skills/sync-orchestration-context/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ metadata:
- path: cli/src/engine-native/parseHelp.ts
lines: "1-31"
- path: cli/src/engine-native/modes.ts
lines: "1-69"
lines: "1-66"
- path: cli/src/engine-native/ompSync.ts
lines: "1-151"
- path: cli/src/engine-native/ompPlugins.ts
lines: "1-436"
lines: "1-434"
- path: cli/src/engine-native/bun.ts
lines: "1-120"
- path: cli/src/engine-native/toolchain.ts
Expand Down Expand Up @@ -222,18 +222,20 @@ writing sync runs `lockedSync` in one lock scope (see § Sync Lock):
Each call into a module that a later child of plan #290 moves runs through
`bridge.ts bridgeSync` or `bridgePromise`, so an interrupt waits until that
step settles (`references/dispatch-flow.md`). The omp passes are Effect code
(#296): only their calls into the logger, `atomicWrite.ts`, `exec.ts`, and
the dependency probes are bridged. The bridge text of a failure is
`bridge.ts failureText`, which never coerces the thrown value. `kitHome()`
(`cli/src/kitHome.ts`, #297) is bridged the same way, and `makeCtx` maps its
`LegacyStepFailed` to `KitHomeInvalid` with the original message and cause.
A failed `FileSystem` operation of a pass fails the run with its
`PlatformError`, a YAML merge or prune with `OmpYamlInvalid`, and a removal of
the kit plugin prune with `PluginFileRemoveFailed` or
`PluginFolderRemoveFailed`; `engine.ts engineFailureDetail` prints the
message of the Node error or of the YAML failure, as the bridge did. An
existence probe, the marketplace registry read, and the removal of the retired
upgrade log do not fail the run (`omp-sync-context`).
(#296): only their calls into the logger, `atomicWrite.ts`, and `exec.ts` are
bridged. The toolchain passes and the dependency probes are Effect code too
(#298), and the Bun bootstrap runs as one uninterruptible region. The bridge
text of a failure is `bridge.ts failureText`, which never coerces the thrown
value. `kitHome()` (`cli/src/kitHome.ts`, #297) is bridged the same way, and
`makeCtx` maps its `LegacyStepFailed` to `KitHomeInvalid` with the original
message and cause. A failed `FileSystem` operation of a pass fails the run
with its `PlatformError`, a YAML merge or prune with `OmpYamlInvalid`, a
removal of the kit plugin prune with `PluginFileRemoveFailed` or
`PluginFolderRemoveFailed`, and the temporary installer folder of the Bun
bootstrap with `BunInstallFolderFailed`; `engine.ts engineFailureDetail`
prints the message of the Node error or of the YAML failure, as the bridge
did. An existence probe, the marketplace registry read, and the removal of
the retired upgrade log do not fail the run (`omp-sync-context`).

While an engine run is active, a SIGINT or SIGTERM ends the process at once,
as before the Effect seam, because a bridged pass cannot stop its `omp` or
Expand All @@ -242,10 +244,16 @@ exitOnSignal(PUBLIC_SIGNAL_EXIT_CODES)` in `engine.ts`, installed only for the
run) and 130 or 143 on the raw channel (`exitOnSignal(RAW_SIGNAL_EXIT_CODES)`
in `main.ts`). The exception is a started mutation of a pass (a write or copy
with its chmod, a directory creation with its chmod, a removal, or a
`replaceFile` call): it runs in `signalGuard.ts mutationRegion`, which is
uninterruptible and inside `deferSignalExit`, so a signal during it is
recorded and the process exits with that code once the mutation settled. The
OS releases the locks with the process.
`replaceFile` call) that runs in `signalGuard.ts mutationRegion`, which is
uninterruptible and inside `deferSignalExit`: a signal during it is recorded
and the process exits with that code once the mutation settled. Only
`mutationRegion` defers a signal. The Bun bootstrap runs under a fiber
interruption mask, not in `mutationRegion`, and that mask does not defer the
signal handler: the handler ends the process as soon as it runs, also during
the installer or the folder creation. A synchronous call blocks the handler
until it returns: a signal during the `rmSync` removal of the installer folder
runs the handler only after the removal ends. The OS releases the locks with
the process.
(verify: `bunx vitest run cli/test/unit/syncSignals.test.ts`)

The omp pipeline reads SoT from the embedded payload.
Expand Down Expand Up @@ -282,12 +290,15 @@ lock module).
returns 1 before the pipeline.
- Every lock of a sync is an `Effect.acquireRelease` in one scope, so it goes
when the scope closes: after the run, a failure, or an interrupt. An
in-process interrupt during a bridged pass or a started mutation waits until
it settles, and the locks stay held until then. A SIGINT or SIGTERM ends the
process at once, except inside a started mutation, which `deferSignalExit`
lets settle first (see § Dispatch Order), and the OS releases the locks with
it.
(verify: `bunx vitest run cli/test/unit/syncLock.test.ts -t "keeps the sync lock and the omp folder locks until an interrupted bridged pass settles"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "finishes a started deploy write with its chmod"`, and `bunx vitest run cli/test/unit/syncLock.test.ts -t "lock wait deadline"`)
in-process interrupt during a bridged pass, the Bun bootstrap, or a started
mutation waits until it settles, and the locks stay held until then. A
SIGINT or SIGTERM ends the process at once, except inside a started mutation
in `mutationRegion`, which `deferSignalExit` lets settle first (see
§ Dispatch Order), and the OS releases the locks with it. The interruption
mask of the Bun bootstrap does not defer the signal handler, but a
synchronous call, such as the removal of the installer folder, delays the
handler until that call returns.
(verify: `bunx vitest run cli/test/unit/syncLock.test.ts -t "keeps the sync lock and the omp folder locks until an interrupted Bun bootstrap settles"`, `bunx vitest run cli/test/unit/bridge.test.ts -t "ends an interrupted run only after the bridged Promise settles"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "finishes a started deploy write with its chmod"`, and `bunx vitest run cli/test/unit/syncLock.test.ts -t "lock wait deadline"`)

(verify: `bunx vitest run cli/test/unit/syncLock.test.ts -t "exits 1 with the held line and leaves HOME unchanged"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "takes no lock in a dry run"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "rejects an unknown argument with exit 2 before it takes the lock"`, `bunx vitest run cli/test/unit/engine-di.test.ts -t "with exit 2 before it takes a lock or writes an omp file"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "exits 2 when the lock wait is not a non-negative safe integer"`, `bunx vitest run cli/test/unit/syncLock.test.ts -t "DRY_RUN env global"`, and `bunx vitest run cli/test/unit/syncLock.test.ts -t "prints the help with -h and --help while another sync holds the lock"`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ runEngineNative(argv, options?) index.ts; an Effect
```

Each call from this Effect code into a module that a later child of plan
#290 moves (`bun.ts`, `toolchain.ts`, `home.ts`, `../kitHome.ts`, and the
logger, the atomic writer, the `exec.ts` spawns, and the dependency probes
that the omp passes call) goes through `bridge.ts bridgeSync` or
#290 moves (`home.ts`, `../kitHome.ts`, the logger, the atomic writer, and
the `exec.ts` spawns) goes through `bridge.ts bridgeSync` or
`bridgePromise`. A bridged step runs without interruption, so an interrupt
of a sync waits until it settles, and the scope keeps the sync lock and the
folder locks until then; a throw or a rejection is `LegacyStepFailed`.
Expand All @@ -110,14 +109,25 @@ and `ompFileDeploy.ts syncMergedYaml` converts that result with
`deferSignalExit`. The ledger stays a plain append (`failures.ts
recordFailure`); the plugin pass and `ompSync` call it through `bridgeSync`
until #297, because its warning goes through the logger.
(verify: `bunx vitest run cli/test/unit/syncLock.test.ts -t "keeps the sync lock and the omp folder locks until an interrupted bridged pass settles"`)
The toolchain passes are Effect code since #298 and are not bridged:
`toolchain.ts`, `deps.ts` (the dependency probes), and `bun.ts` (not bridged).
The Bun bootstrap runs as one uninterruptible region, so an in-process
interrupt of a sync also waits until it ends. That region is a fiber
interruption mask only, not a `mutationRegion`, and it does not defer the
signal handler: a SIGINT or SIGTERM during the bootstrap ends the process as
soon as the handler runs. A synchronous call blocks the handler until it
returns, so a signal during the `rmSync` removal of the installer folder ends
the process only after the removal ends.
(verify: `bunx vitest run cli/test/unit/syncLock.test.ts -t "keeps the sync lock and the omp folder locks until an interrupted Bun bootstrap settles"`
for the Bun bootstrap, and `bunx vitest run cli/test/unit/bridge.test.ts -t "ends an interrupted run only after the bridged Promise settles"`
for a bridged step)

`ompSync` owns its step order. Read the function body, not a copy here
(verify: `sed -n '/^export const ompSync/,/^});/p' cli/src/engine-native/ompSync.ts`).
The order rules that matter:

- `ompSync` starts with `bun.ts bunBootstrap`, which is memoized on
`ctx.bunRuntime` for the engine run.
- `ompSync` starts with `bun.ts bunBootstrap`. The run-owned `Deferred`
`ctx.bunRuntime` keeps its outcome, so the engine run bootstraps Bun once.
- A writing sync runs under the sync lock and the folder locks, so two syncs
never run the read-modify-write of one file at the same time. `SKILL.md`
§ Sync Lock owns the lock rules.
Expand Down
Loading
Loading