Repository navigation
Move the engine seam and the sync orchestration to Effect - #301
Merged
DocksDocks merged 11 commits intoDec 2, 2026
Merged
DocksDocks merged 11 commits into
DocksDocks merged 11 commits into
Conversation
- bridgeSync and bridgePromise run a legacy call as Effect.uninterruptible over Effect.try or Effect.tryPromise, with the typed LegacyStepFailed (step, message, cause), so an interrupt waits until the legacy work settles and no scope closes under it (#290, bridge rule D1). - Tests: an interrupt during a bridged Promise ends only after it settles; a rejection or a throw becomes LegacyStepFailed with its step and message. Verified: bun x --no-install vitest run (unit and toggles rows of plan #294); bun run check:types; bun cli/scripts/verify-ci-tools.ts; bun run golden:dryrun --prove-red; bun run golden:mutation --prove-red; bun run smoke:package; ./docks-kit sync --dry-run; bun run check
Steps lease and seam of #294 (one commit: syncDispatch consumes the new lease API): - logger.ts: acquireTerminal is a scoped resource (LeaseHeld); withExclusive takes an Effect under a one-permit Semaphore and fails with LeaseReentered before it waits. The write rethrows stay. - runEngineNative returns an Effect over the engine layers and FileSystem; help, usage refusals, and an invalid lock wait are typed failures turned into their exit codes; ExitError is gone. - engineSync takes the home lock, resolves the folders under it, then takes the folder locks, in one scope, with the current sync poll (wall clock, deadline before preparation, last attempt). - ompSync and modeToolchain are Effects; every call into later-owned code goes through bridge.ts. - engine.ts and main.ts map each failure and defect to the same failure text as before. - Tests move to the Effect run; a new case shows that an interrupt during a bridged pass keeps the home and folder locks until the pass settles. Verified: bun x --no-install vitest run (unit and toggles rows of plan #294); bun run check:types; bun cli/scripts/verify-ci-tools.ts; bun run golden:dryrun --prove-red; bun run golden:mutation --prove-red; bun run smoke:package; ./docks-kit sync --dry-run; bun run check
- The ExitError, dispatch, lock-release, and failure-path rules, the run signature, the ompSync anchor, the lock of sync in tidy-context, and the parser and service-wiring entries of DESIGN.md. Verified: bun x --no-install vitest run (unit and toggles rows of plan #294); bun run check:types; bun cli/scripts/verify-ci-tools.ts; bun run golden:dryrun --prove-red; bun run golden:mutation --prove-red; bun run smoke:package; ./docks-kit sync --dry-run; bun run check
- Signals: while an engine run is active, SIGINT or SIGTERM exits at once (public 130; raw 130 and 143 as before); in-process interrupts still wait for bridged work. Spawned tests on POSIX. - The seams report the later cleanup error when a finalizer throws after a failure, as finally did. - Logger: atomic lease claim published after the first draw; per-section exclusive markers across loggers; a nullish buffered-write throw stays a failure. - Bridge: failure text without coercion (unknown error); kitHome() through bridgeSync as KitHomeInvalid. - Tests: both folder locks and no AGENTS.md write in the interrupt case, gated fibers settled in finally, TestClock deadline cases, the ledger before a failed pass, a public env-globals dry run, tryAcquireKitLock in the lock fixtures. - Guidance: dispatch pointers, interrupt-only ledger skip, HelpShown, withExclusive usage. Verified: bun x --no-install vitest run (unit, toggles, signals rows and syncPipelineFailure.test.ts); bun run check:types; bun run golden:dryrun; bun run golden:mutation; bun run check
- The engine-run signal listeners run first (prependListener), so a delivered signal exits 130. - The signal test runs the CLI in its own process group, kills only that group in teardown, watches exit and spawn errors from launch, and runs a second sync to its end after the signal. - failureText reads an Error message at most once and falls back to unknown error on any throw. - acquireTerminal reserves the lease before the first draw, so a reentrant acquire gets LeaseHeld. - The verbose dry-run test clears PI_CONFIG_DIR, OMP_PROFILE, and PI_PROFILE. - Guidance: the mode-selection anchor, and the failed-pipeline ledger conditions in DESIGN.md, the sync-orchestration skill, and dispatch-flow.md. Verified: bun x --no-install vitest run (unit, toggles, signals rows, syncPipelineFailure.test.ts, skillMetadata.test.ts); bun run check:types; bun run golden:dryrun; bun run golden:mutation; bun run check
Repairs of code-review round 3 of #294: - Teardown signals a saved group only while its leader CLI still runs, so a reused id is never hit. - The waiting stub omp exits when its parent is gone or after 90 s, so a cancelled worker leaves no stub that holds the CLI and its locks. - One case deadline; each phase gets only the time left. - The reentry fixture sets its one-shot guard before the nested acquire runs. Verified: bun x --no-install vitest run (unit, toggles, signals rows); bun run check:types; bun run check
Repairs of code-review round 4 of #294: - A fixture supervisor leads its own process group, runs the CLI as its child, relays its pid and exit, and on control-pipe close stops the CLI and then its group; the worker signals no saved id. - The stub captures its parent and arms its timers before readiness; a relative 90 s limit exits 1. - One performance.now() case deadline. - A spawned public run under BunRuntime.runMain with a failing logger finalizer, waiting at an interruptible lock sleep, exits 130 on one signal; it exits 1 when the listeners are appended. - engineFailureDetail prints the message that LegacyStepFailed and KitHomeInvalid captured. Verified: bun x --no-install vitest run (unit, toggles, signals rows, skillMetadata.test.ts); bun run check:types; bun run check
Repairs of code-review round 5 of #294 (stall rule: new approach for process identity): - The waiting stub signals its own verified parent CLI, and the listener-order entry signals itself, on a request file; the worker and the supervisor send no signal to any pid. - The supervisor checks that it leads its group, kills only that group, and ends it on a failed report write or a stdout error as on stdin EOF. - Fixture PATH holds only the stubs and Bun; graceful worker cancellation stops the supervisors before the temporary folders go (goldenResources registerBeforeTemporaryDirRemoval). - Supervisor completion comes from close, which also follows a failed spawn. Verified: bun x --no-install vitest run (unit, toggles, signals rows, skillMetadata.test.ts); bun run check:types; bun run lint; bun run check
Repairs of code-review round 6 of #294, after the second stall (user: Continue yolo): - A test-only preload in the CLI raises the requested signal on its own process; no fixture process signals another pid or group. Cleanup asks the CLI the same way. - One fixture root per case (docks-kit-signal-fixture-, matched by no sweep) with its home, caches, stubs, launch folders, and a working folder with no .env; bun runs with --no-env-file; the CLI PATH holds only stubs. - Stubs take a ticket in active/ and drop it as their last act; teardown removes the root only after every launch is confirmed and a non-recursive rmdir of active/ succeeds. - goldenResources: stop callbacks run inside the promise boundary; stub folders can be placed. Verified: bun x --no-install vitest run (unit, toggles, signals rows, skillMetadata.test.ts); bun run check:types; bun run lint; bun run check
Repairs of code-review round 7 of #294: - The supervisor publishes cli.pid atomically; the waiting stub waits for a valid record. - Teardown handles only the fixtures of the current case; a kept root leaves tracking. - A stub whose ticket create fails exits 1; ticket release is armed right after the create. - Stubs write started and stub-exited records by invocation id; confirmation needs both. - Ticket code is generated only for supervised stub folders (no ambient variable). - A partial fixture root is removed on setup failure; cancellation prints its diagnostics. Verified: bun x --no-install vitest run (unit, toggles, signals rows, skillMetadata.test.ts); bun run check:types; bun run lint; bun run check
Repairs of code-review round 8 of #294: - A stub releases its ticket by renaming it to its stub-exited record; a failed rename keeps it. - A failed cli.pid publication asks the CLI to end and blocks confirmation; the waiting stub also stops when its parent changes. - Overlapping teardown paths recheck tracking before retries and reports. - Lifecycle comments list startup and exit actions in their real order. Verified: bun x --no-install vitest run (unit, toggles, signals rows, skillMetadata.test.ts); bun run check:types; bun run lint; bun run check
DocksDocks
marked this pull request as ready for review
December 2, 2026 01:28
DocksDocks
deleted the
294-move-the-engine-seam-and-the-sync-orchestration-to-effect
branch
December 2, 2026 01:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan run: #294 Move the engine seam and the sync orchestration to Effect
Child of #290 (step
seam). Reviewed head:fe26962c. Checks: see the pull request.What changed
cli/src/engine-native/bridge.ts:bridgeSyncandbridgePromiserun code that is not Effect yet asEffect.uninterruptibleoverEffect.tryandEffect.tryPromise, with the typed failureLegacyStepFailed. Move the process layer, the file helpers, and the kit store to Effect #297 removes the file.runEngineNativereturns an Effect with the typed failuresLegacyStepFailed,LockAcquireError,KitHomeInvalid, andLeaseHeld.cli/src/engine.tsmaps each failure and each defect to the same user text as before.EngineContextis aContext.Servicethat holds the plain run context. The terminal lease is a scoped resource, andwithExclusiveuses a one-permit semaphore.syncDispatch.ts: the home lock and the folder locks are scoped resources in one scope.ompSync.tsandmodes.tsrun as Effect code with bridges.EPIPEstill throws at once.DESIGN.mdand the engine, sync, omp, host, and tidy skills describe the Effect seam.bridge.test.ts,syncPipelineFailure.test.ts,syncSignals.test.ts(POSIX), and largerlogger,syncLock, andenginesuites. The signal suite runs the CLI under a supervisor in a fixture root that no sweep removes. No fixture process sends a signal to another process.Delegated decisions
bridge.ts). Rejected: inline bridges. Reversibility: Move the process layer, the file helpers, and the kit store to Effect #297 deletes it. Record: Research "One bridge module".recordFailurestays a synchronous append until Move the omp passes and the kit store to Effect #296. Record: Research "The ledger".rmdir; an unconfirmed root stays in the system temporary folder. Rejected: kills of saved process ids or group ids. Record: Research "Signal test fixture", after the second stall and the user answerContinue yolo.Reviews
Verification (on
fe26962c)unit(14 files): exit 0, 247 passed.toggles: exit 0, 91 passed.signals: exit 0, 6 passed.goldens: both suites OK, no golden change.red-dry,red-mut: exit 1 withprove-red OK.dry(./docks-kit sync --dry-run),types(bun run check:types),ci-tools,smoke(bun run smoke:package): exit 0.gate(bun run check): exit 0, 6493 passed, 12 skipped.Limits and failures
Full CIcovers Ubuntu, macOS, and Windows. The signal suite is POSIX only.Continue yoloonce.bun run checkruns of the implementer failed once under load (talk/transport.test.ts, a vitest cache file); each file passed alone, and the rerun passed.Kept resources
Merge now: none.Leave pull request open: the worktreeissue-294and the local and remote branch294-move-the-engine-seam-and-the-sync-orchestration-to-effect.After merge
seamto done. The next child is Move tidy to Effect #295.Checklist
bun run checkpassesCloses #294