Skip to content

Move tidy to Effect #295

Done
Done

Description

@DocksDocks

Goal

Child of #290. Move tidy to Effect: engine-native/tidy.ts, tidyReport.ts, syncConcurrency.ts, and cli/src/commands/tidy.ts (no Effect.promise). Keep one bounded runner that stops taking queued work after the first failure, lets started work finish, and reports the failure with the lowest index; move its tests to cli/test/unit/syncConcurrency.test.ts with the cases of the first comment of #290. Calls into scratch, the process layer, and the file helpers, which the last child of #290 moves, go through the bridge rule of the #290 Research. Keep the tidy plan, the report, the output, and the exit codes unchanged.

Yolo: the user delegated every decision except the merge to the agent.

Mode: plan-and-implement

Research

Repository facts (main at c8024b5, after #294):

  • cli/src/engine-native/syncConcurrency.ts runBounded(tasks, concurrency) runs () => Promise tasks with at most 1 to 3 in flight. After the first rejection it starts no queued task, lets started tasks settle, and rethrows the rejection with the lowest input index (PoolState, drainAfterFailure). Callers: tidy.ts planTidy (worktree inspections, concurrency 3) and tidyReport.ts sizeLines and temporarySection (concurrency 3). cli/src/engine-native/index.ts re-exports runBounded, SyncConcurrency, and SyncTask; the only importer of that re-export is cli/test/unit/engine-di.test.ts, which holds the four runner cases ("caps overlap and returns results in selection order", "runs the next pipeline only after the prior one settles at cap one", "drains started pipelines, stops queued work, and reports the first input failure", "keeps an undefined rejection when a later input fails during drain").
  • cli/src/engine-native/tidy.ts (1276 lines) and tidyReport.ts (509 lines) are async code. TidyHost (git, docker, dockerEndpoint, run, processes, now) returns Promises; defaultTidyHost runs tools through exec.ts spawnProcess (runTool). DockerRunner returns a Promise. Direct synchronous node:fs calls: realpathSync (normalizePath), readlinkSync (readLinuxCwd), lstatSync (lstatOrUndefined, lstatIfPresent), readdirSync (sortedEntries, entryActivity), readFileSync (adminDirectory, the report's /proc/meminfo and .trashinfo reads), statSync, renameSync, and appendFileSync (appendLog). The Stats fields that tidy reads: the file type, mtimeMs, uid, and blocks.
  • Throws: lstatIfPresent and entryActivity throw cannot check <path>: <code>, and appendLog rethrows a rotation error; the report throws in sizeKb and dockerSection, and section turns any throw into unavailable: <errorMessage(cause)>.
  • Calls into modules of later children: exec.ts spawnProcess, processes.ts processExited (macOS cwd probe), scratch.ts removeTemporaryPath (deletes a scratch entry), ompFileDeploy.ts ensureDirectory (the log folder), home.ts engineHome (commands/tidy.ts). scratch.ts kitCacheDir, scratchRoot, tidyApplyLockPath, and isSameOrInside are pure path functions.
  • cli/src/commands/tidy.ts wraps planTidy, applyTidy, acquireKitLock, buildTidyReport, and mainRepository in Effect.promise. The apply lock calls acquireKitLock(path, { waitMs: 0 }), which makes exactly one BEGIN IMMEDIATE try, the same as the synchronous primitive tryAcquireKitLock(path, { privateDirectory: true }) (kitLock.ts). A failure count above 0 sets process.exitCode = 1; a held lock prints another docks-kit tidy run holds <path> and leaves the exit code unset.
  • Untested paths: the tidy-context Gotcha "Untested paths" requires a should-fail case for a change to network removal, log rotation, the --repo listing, the apply-time scratch recheck, and the tidyCommand input resolution; this child changes each of them.
  • Tests: cli/test/unit/tidy.test.ts awaits planTidy and applyTidy with a stub host whose six fields are replaced, runs runTidy through Effect.runPromise, and has one spawned case (tidy --apply while the lock is held). cli/test/unit/tidyReport.test.ts awaits buildTidyReport with a stub host. No spawned case covers a plain tidy or tidy --report.
  • Guidance: .agents/skills/tidy-context/SKILL.md names acquireKitLock for the apply lock, Effect.acquireUseRelease in runTidy, and "a throw becomes unavailable: <message>" in the Report section. cli/src/engine-native/DESIGN.md says only that runBounded stays for the tidy probes, which stays true.

Effect 4.1.7 facts:

  • effect/FileSystem has lstat, stat, readDirectory, readFileString, readLink, realPath, rename, makeDirectory, chmod, and writeFileString with a flag (node_modules/effect/src/FileSystem.ts); File.Info has type ("File", "Directory", "SymbolicLink", ...), mtime, uid, and blocks as Option values. cli/tsconfig.json already allows effect/FileSystem#FileSystem and effect/PlatformError#PlatformError. cli/src/main.ts provides BunServices.layer, which supplies FileSystem, to every command.
  • The Node and Bun file systems map ENOENT to the reason NotFound and both ENOTDIR and EISDIR to BadResource, and keep the original error as cause (node_modules/@effect/platform-node-shared/src/internal/utils.ts handleErrnoException). So the errno code of a failure is read from that cause, not from the reason tag.
  • Effect.forEach with concurrency interrupts started siblings when one effect fails (the first comment of Move the engine-native layer to Effect #290). bridge.ts bridgeSync and bridgePromise run legacy code uninterruptibly and turn a throw or rejection into LegacyStepFailed with the original message.

Decisions:

  • The runner (parent D3 (b), delegated, one line): runBounded(tasks, concurrency) takes ReadonlyArray<Effect<A, E, R>> and returns Effect<Array<A>, E, R>. It starts min(concurrency, tasks.length) worker fibers that cannot fail: each worker takes the next index while the pool accepts, runs the task with Effect.exit, and on a failure (a typed failure or a defect) records the cause with the lowest index and stops the pool from accepting. After every worker ends, the runner fails with the recorded cause, else returns the results in input order. A caller interrupt interrupts every worker; a bridged task ends only when it settles. Rejected: Effect.forEach with concurrency, which interrupts the started siblings.
  • The host (delegated, one line): every TidyHost method and DockerRunner returns an Effect; the default host bridges spawnProcess with bridgePromise, and now stays a plain function. Rejected: keeping the Promise host behind one bridge in commands/tidy.ts, which leaves the legacy code that the Goal moves.
  • Files (delegated, one line): every direct node:fs call of the three engine files goes through FileSystem, and each call keeps its base outcome: lstatIfPresent treats only the errno codes ENOENT and ENOTDIR of the failure's cause as absent and fails with cannot check <path>: <code> otherwise; a failed directory read in entryActivity stays unknown with its base text (also on ENOTDIR); lstatOrUndefined, sortedEntries, adminDirectory, and normalizePath keep their catch-all fallbacks; readLinuxCwd keeps ENOENT and ESRCH as exited; a File.Info without mtime is an unknown state that keeps the candidate (fail closed). A failure that the base printed (the log rotation and append, the report read of /proc/meminfo) keeps the message of the original Node error, the cause of the PlatformError; an unreadable .trashinfo entry stays skipped on its own, as in the base trashSection. The log folder still comes from ensureDirectory through bridgeSync. Rejected: bridging the node:fs calls, which the parent bridges row forbids for calls that FileSystem covers.
  • Signals and interruption (delegated, one line): the base tidy command ended at once on SIGINT or SIGTERM with exit 130: BunRuntime.runMain interrupted the fiber, the Effect.promise waits gave way, the lock release ran, and a running tool call was left behind (node_modules/effect/src/Runtime.ts, 130 for an interrupt-only exit); its log rotation and append were synchronous, so no signal ran between them. Bridged calls are uninterruptible (D1), so tidyCommand keeps that behavior with the signal exit of engine runs: it runs inside exitOnSignal of cli/src/engine.ts (exported for this caller), which exits 130 at once on either signal, and the OS releases the SQLite lock. In the base apply, a signal could act only at an awaited tool call (git or docker); every other step (signals, scratch rechecks and removals, the log rotation and append) ran without a signal turn, and the result was printed when the Promise resumed. The new apply keeps exactly those signal points: two new helpers in cli/src/engine.ts work with exitOnSignal: the scoped deferSignalExit, which applyTidy acquires at its start in a nested scope that runTidy opens around the apply and the printing of its result and closes right after that printing, before --report starts, records a signal instead of exiting until that scope closes, and then exits 130 when a signal was recorded; exitOnSignal stays active for the whole command, so the report keeps the prompt exit; and signalExitPoint(effect), which applyTidy wraps around each of its git and docker calls, exits 130 at once for a recorded or a new signal while the call waits, as the base interrupt at an await did. The apply and the printing of its result run as one uninterruptible region inside the lock scope, so the interrupt that BunRuntime.runMain raises on a signal also waits; the plan, the dry run, and the report stay read-only and keep the prompt exit. Move the process layer, the file helpers, and the kit store to Effect #297 removes the hard exit and the deferral in favor of fiber interruption through its process service, narrows the region, and updates the tidy signal case (recorded in the Move the process layer, the file helpers, and the kit store to Effect #297 Goal). Rejected: no signal exit, which would keep the command and its lock behind a hung docker or git call, a user-visible change.
  • Typed errors (delegated, one line): each base throw becomes a Schema.TaggedError failure with the same message (TidyCheckFailed for a path or activity check and a log rotation, ReportSectionFailed for the report). A report section turns every failure and every defect, but not an interruption, into unavailable: <message> with the text that errorMessage gave before. The report runs its ten sections concurrently, in their fixed order, as Promise.all did.
  • The apply lock (delegated, one line): commands/tidy.ts takes tidyApplyLockPath(home) with Effect.acquireRelease over Effect.try of tryAcquireKitLock(path, { privateDirectory: true }) and releases it with releaseKitLock (parent D4 keeps these primitives synchronous). This makes the same single try as acquireKitLock with waitMs: 0, so tidy no longer calls the Promise poll that Move the process layer, the file helpers, and the kit store to Effect #297 moves. The lock is still released before --report runs.
  • The command (delegated, one line): tidyCommand reads the home through bridgeSync(engineHome) and runs mainRepository as an Effect. Every typed failure of this child keeps the original thrown value as its cause when one exists (the kitLock.ts primitive errors through Effect.try included), and at the command boundary a typed failure becomes a defect of that cause, else of an Error with the failure's message, so BunRuntime.runMain prints the same diagnostic and exits 1, as the base defect from Effect.promise did.
  • The re-export (delegated, one line): index.ts keeps its exports runBounded, SyncConcurrency, and SyncTask (cli/AGENTS.md: orchestrators keep prior exports); SyncTask becomes the Effect task type, and the moved tests import through index.ts.
  • Version: no bump; the output, the exit codes, and the signal behavior do not change.

Steps

# Id Task Files Depends Effect Status Done when
1 tidy Move runBounded to the runner decision with its three callers; move tidy.ts, tidyReport.ts, and commands/tidy.ts as the host, files, apply, typed errors, apply lock, and command decisions say; move the four runner cases of engine-di.test.ts to cli/test/unit/syncConcurrency.test.ts as Effect cases and add the two error-order cases of the first comment of #290 with explicit synchronization (Deferred); port tidy.test.ts and tidyReport.test.ts to Effect stubs run with BunServices.layer; add the should-fail cases of the untested row and the spawned cases of the commands row. Red baseline: both error-order cases fail against an Effect.forEach runner with the same signature cli/src/engine-native/syncConcurrency.ts, cli/src/engine-native/index.ts, cli/src/engine-native/tidy.ts, cli/src/engine-native/tidyReport.ts, cli/src/commands/tidy.ts, cli/src/engine.ts, cli/test/unit/syncConcurrency.test.ts, cli/test/unit/engine-di.test.ts, cli/test/unit/tidy.test.ts, cli/test/unit/tidyReport.test.ts - local done the runner, tidy, untested, commands, scan, and bridges rows pass
2 guidance Update tidy-context: the apply-lock call, the runTidy lock scope, the Report failure rule (a failure or a defect of a section), a Gotcha that runBounded must not become Effect.forEach, the "Untested paths" Gotcha (only the paths that stay untested), and the source_files line ranges .agents/skills/tidy-context/SKILL.md 1 local done the guidance row passes

Acceptance

ID Command Expected
deps bun install --frozen-lockfile in the linked worktree Exit 0
runner bun x --no-install vitest run --reporter=verbose cli/test/unit/syncConcurrency.test.ts cli/test/unit/engine-di.test.ts Exit 0, with the four moved runner cases and the two error-order cases: with concurrency 2, tasks 0 and 1 start and task 2 stays queued; task 1 fails first, task 2 never starts, task 0 is not interrupted, and the run stays pending until task 0 ends; then the failure of task 0 wins, and in the companion case, when task 0 succeeds, the failure of task 1 wins
tidy bun x --no-install vitest run --reporter=verbose cli/test/unit/tidy.test.ts cli/test/unit/tidyReport.test.ts cli/test/unit/kitLock.test.ts cli/test/unit/scratch.test.ts cli/test/unit/skillMetadata.test.ts Exit 0, with every base case of tidy.test.ts and tidyReport.test.ts kept with its reason strings
untested bun x --no-install vitest run --reporter=verbose cli/test/unit/tidy.test.ts Exit 0, with a case for each path of the Untested paths fact, each failing when its branch is removed: removing a worktree with containers runs network ls and network rm for its compose project through --host <endpoint>; a tidy.log past LOG_ROTATE_BYTES moves to tidy.log.1 before the append; --repo lists a linked worktree outside the worktree root; a scratch entry refreshed after the plan stays at apply with its keep line; and the spawned tidy --repo <folder that is not a git repository> prints --repo <folder> is not a git repository and exits 2
commands bun x --no-install vitest run --reporter=verbose cli/test/unit/tidy.test.ts -t "spawned docks-kit tidy" Exit 0, with spawned CLI cases in isolated homes whose child PATH holds only stubs for ps, which print valid rows for their parent process (the tidy CLI, which joinRows drops as its own process), and for lsof, which exits 0 with no output, and links to the real tools that a case needs (such as du), with no docker: tidy lists a seeded idle scratch folder (a remove line on Linux and macOS, a keep line with the process-list reason on Windows), and tidy --report prints, inside its Package and tool caches section, the measured entry of a seeded .npm folder on Linux and macOS, and the support notice on Windows; and on Linux and macOS, a tidy --report whose du stub asks the CLI to signal itself (through the test preload cli/test/lib/signalSelfPreload.ts and a request file) and then waits exits 130 within a short bound; the stub ends on its own once its parent is gone or after a hard lifetime longer than that bound, writes its exit marker on every exit path, and the test removes the fixture only after both the CLI exit and that marker; and, on Linux and macOS only (Windows has no tidy process list, so no apply runs): a spawned tidy --apply that removes two seeded idle scratch entries, with a tidy.log past LOG_ROTATE_BYTES, gets SIGTERM during the recheck of the second entry, and in a second run between the rename of tidy.log and the append (for example through a test preload that wraps those file operations); each run exits 130 after it prints every removed line, with the old log in tidy.log.1 and every new line in tidy.log, and both cases fail when the deferral is removed (red baseline); and a spawned tidy --apply whose PATH (its own, with the ps and lsof stubs and a docker stub, never the real docker) reports a local endpoint and a container of a gone folder in the worktree root and then hangs on rm exits 130 within a short bound after one SIGTERM, with the same stub lifetime and cleanup rules as the du stub; and a spawned tidy --apply --report with one seeded idle scratch entry and a seeded .npm folder removes the entry, prints its removed line, and then, after one SIGTERM while the du stub waits on .npm, exits 130 within that bound
scan git grep -nE -e '^[[:space:]]*([^/*[:space:]].*)?Promise<' -e '^[[:space:]]*([^/*[:space:]].*)?async ' -e '^[[:space:]]*([^/*[:space:]].*)?\bthrow\b' -e 'Effect\.promise\(' -e 'Effect\.run[A-Za-z]*\(' -e 'Effect\.tryPromise\(' -e 'from "node:fs"' -- cli/src/engine-native/tidy.ts cli/src/engine-native/tidyReport.ts cli/src/engine-native/syncConcurrency.ts cli/src/commands/tidy.ts Exit 1, no match
bridges git grep -n -e 'Effect.try(' -e 'bridgeSync(' -e 'bridgePromise(' -- cli/src/engine-native/tidy.ts cli/src/engine-native/tidyReport.ts cli/src/engine-native/syncConcurrency.ts cli/src/commands/tidy.ts Each bridgeSync or bridgePromise match wraps a call into exec.ts, processes.ts, scratch.ts, ompFileDeploy.ts, or home.ts; each Effect.try match wraps a kitLock.ts primitive (parent D4) or process.kill
goldens On the reviewed commit with git status --porcelain empty: bun run golden:dryrun && bun run golden:mutation && git diff --exit-code --merge-base origin/main HEAD -- cli/test/goldens Both suites OK; no golden changed
red-dry bun run golden:dryrun --prove-red Exit 1; prints prove-red OK: golden-dryrun
red-mut bun run golden:mutation --prove-red Exit 1; prints prove-red OK: golden-mutation
guidance git grep -n -e 'a throw becomes' -e 'acquireUseRelease' -e 'Network removal, log rotation' -- .agents/skills/tidy-context; git grep -n 'Effect.forEach' -- .agents/skills/tidy-context/SKILL.md The first command exits 1; the second prints the runner Gotcha; skillMetadata.test.ts in the tidy row passes
dry ./docks-kit sync --dry-run Exit 0
types bun run check:types Exit 0
ci-tools bun cli/scripts/verify-ci-tools.ts Exit 0
smoke bun run smoke:package Exit 0
gate bun run check Exit 0

Do not touch

Open questions

Verification Results

On reviewed head 9939bb6 (Linux x64):

  • deps: exit 0.
  • runner: exit 0, 8 passed (6 in syncConcurrency.test.ts, with both error-order cases; 2 in engine-di.test.ts). Red baseline: with an Effect.forEach runner, both error-order cases failed (task 0 interrupted).
  • tidy and untested: exit 0, 92 passed, 1 skipped (the Windows-only report case).
  • commands: exit 0, 9 passed. Red baseline: with the deferral disabled, both deferral cases failed (the removed scratch lines were missing).
  • scan: exit 1, no match.
  • bridges: 7 matches: Effect.try over tryAcquireKitLock and over process.kill; bridgeSync over engineHome, processExited, ensureDirectory, and removeTemporaryPath; bridgePromise over spawnProcess.
  • goldens: both suites OK; the golden diff exits 0.
  • red-dry, red-mut: exit 1 with prove-red OK.
  • guidance: the first command exits 1; the second prints the runner Gotcha; skillMetadata.test.ts passes.
  • dry, types, ci-tools, smoke: exit 0.
  • gate: exit 0, 6507 passed, 12 skipped.

Activity

  1. self-assigned this
    on Dec 1, 2026
  2. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Delegation grant: yolo: "now start #290 please, use yolo, also fix open findings in a follow up"
    Parent event: 7326116204

  3. changed the title [-]Move tidy and scratch to Effect[/-] [+]Move tidy to Effect[/+] on Dec 1, 2026
  4. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 1

    Plan-review: repair

    • security_risk - Research, Files decision (line 33); Steps tidy - The plan treats ENOENT and ENOTDIR as absence across filesystem calls, but tidy.ts:716-753 only does that for lstatIfPresent; entryActivity treats every directory-read failure as unknown. Inference: if a scratch directory is replaced by a fresh file between lstat and readDirectory during apply, the current code keeps it with cannot check …: ENOTDIR. Under the plan's absence rule, applyTidy can receive undefined and proceed to delete the replacement through scratch.ts:165-206. The blanket rule also conflicts with the original log and /proc/meminfo diagnostics in tidy.ts:1118-1126,1270-1274 and tidyReport.ts:130-138,464-472 - Specify error handling per operation. Keep directory-read failures fail-closed, and preserve the original log and report messages from the underlying cause - class: filesystem error policy applied outside its original operation
    • goal_fit - Research, Files and apply-lock decisions (lines 33, 35); Steps tidy - The current appendLog rotates and appends synchronously under the apply lock. The Effect 4.1.7 filesystem adapter uses a non-cancellable callback for rename and an abortable write whose interrupt handler does not wait for the write callback (effect/src/internal/effect.ts:1223-1286). Inference: interrupting apply during rotation or append can close the lock scope while I/O is pending, or leave completed removals without their log lines - Keep the rotate-and-append sequence uninterruptible inside the apply lock so it settles before the lock is released - class: interruptible file mutation outlives its lock
    • goal_fit - Steps runner and tidy (lines 44–45) - Step 1 changes the runner signature, but tidy.ts:904-907 and tidyReport.ts:115-118,201-204 still pass Promise thunks until step 2. The focused runner tests can pass on that intermediate tree, but the per-step type check required by plan-manager/references/practices.md:238-243 cannot - Land the runner signature and all three production caller migrations in the same step and commit - class: incompatible API cutover split across steps
    • goal_fit - Research, re-export decision (line 37); Steps runner - The plan deliberately removes runBounded, SyncConcurrency, and SyncTask from index.ts:24-25. Moving the only current importer makes that removal invisible to the tests, but cli/AGENTS.md:40 explicitly requires index.ts to keep prior exports - Keep the three exports on the existing import path, with the migrated tests using that path and the types describing the Effect runner - class: export removal conflicts with repository instructions
    • goal_fit - Research, typed-errors, apply-lock, and command decisions (lines 34–36); Do not touch - Exit 1 alone does not preserve output. A file in place of the private lock directory makes kitLock.ts:74-85 throw a native error, which commands/tidy.ts:91-93 currently forwards as a defect. The Effect runtime logs the uncaught cause, and Effect's Schema.TaggedError and cause formatter preserve the wrapper's error name. Inference: letting the new tagged failure escape prints the wrapper instead of the original diagnostic even though both runs exit 1 - Keep the failure typed internally and preserve the original diagnostic at the tidy CLI boundary - class: typed error changes the CLI diagnostic
    • goal_fit - Acceptance scan and bridges (lines 56–57) - scan misses the actual Effect.promise( calls in commands/tidy.ts:117,133 because its regex requires a space after promise; it likewise misses ordinary Effect.run* calls. The unescaped pipe also splits the command into separate table cells in cli/src/plan/records.ts:216-229. Separately, bridges accepts a bare Effect.tryPromise around spawnProcess even though parent D1 and bridge.ts require that legacy call to drain before an interrupt releases the lock - Use separate grep expressions for Effect.promise( and Effect.run*(. Require the approved bridge helpers for legacy callees and reserve direct adapters for the allowed synchronous calls - class: migration scan accepts forbidden Effect interop
    • research_gap - Acceptance commands (line 55) - An isolated home does not isolate the POSIX process probe. tidy.ts:245-264,295-323,795-798,1072-1077 returns process list unavailable when an unrelated same-user process has an unreadable cwd. Inference: on such a Linux or macOS runner, a correct CLI prints keep instead of the required remove line for the seeded folder - Control the POSIX process-list command results in the spawned fixture so the scratch assertion does not depend on unrelated host processes - class: end-to-end fixture relies on uncontrolled host state
    • goal_fit - Steps tidy; Acceptance tidy and commands (lines 45, 54–55) - .agents/skills/tidy-context/SKILL.md:229 requires a should-fail case when changing network removal, log rotation, --repo listing, the apply-time scratch recheck, or tidyCommand input resolution. The new plain and report cases do not cover those branches. For example, deleting the recheck in tidy.ts:1255-1264 would still pass the planned cases while allowing apply to delete a scratch entry refreshed after planning - Extend the existing acceptance rows to cover the affected branches required by the skill. Leave the untouched session_start spawn out - class: required regression coverage missing for a changed path
    • goal_fit - Steps guidance; Acceptance guidance (lines 46, 61) - The hash check's default root is SoT/.omp/plugin/skills (cli/scripts/skill-content-hash.ts:16-17, cli/src/skills/config.json:2). It exits 0 whether the hash in .agents/skills/tidy-context/SKILL.md is missing, stale, or correct. That project skill has no hash today - Drop the project-skill hash refresh and its unrelated plugin hash check from this row. Keep the project metadata and guidance checks - class: acceptance command checks a different file tree
  5. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 2, delta

    Plan-review: repair

    • research_gap - Acceptance commands, line 57 - Empty ps output means the process list is unavailable, not that no process uses the scratch folder. Both parsers return undefined on empty input, and both POSIX probes propagate it (cli/src/engine-native/tidy.ts:156–186,271–281,295–323). On Linux and macOS a correct CLI therefore prints keep …: process list unavailable instead of the expected remove line (tidy.ts:795–798,1072–1077) - Have both ps stubs emit valid rows for the tidy CLI's own PID, which joinRows excludes. Keep lsof successful and empty - class: end-to-end fixture supplies an unavailable process list
    • goal_fit - Research apply-lock and command decisions, lines 37–38; Do not touch - A file in place of the private lock directory makes kitLock.ts:74–85 throw a native error. The old commands/tidy.ts:85–100 passes that error to the runtime. The repaired rule unwraps only LegacyStepFailed and PlatformError, so a typed lock-acquisition error still falls back to a new Error with the same message. Inference: exit 1 and the message remain, but the diagnostic loses the original error's name, stack, or cause, which the Effect formatter renders - Preserve the native cause in the typed lock-acquisition error and explicitly pass it through at the CLI boundary - class: typed error changes the CLI diagnostic
    • research_gap - Research Files and Typed errors decisions, lines 34 and 36 - The Files decision lists unreadable .trashinfo files among failures the base report prints. cli/src/engine-native/tidyReport.ts:293–319 instead skips each unreadable entry and keeps the measured trash size, dates from other entries, and any settings hint. Inference: forwarding that read failure to section replaces those lines with unavailable: … - Keep .trashinfo failures silent per entry. Preserve the underlying error text for /proc/meminfo and log failures, where the base actually prints it - class: filesystem failure assigned to the wrong reporting policy
    • research_gap - Research Apply without interruption decision, line 35 - The old Effect.promise left the underlying Promise running, but it did not make the waiting fiber uninterruptible. cli/src/commands/tidy.ts:59,91–100 used it in the interruptible use phase, and the Effect Promise adapter does not wait for settlement on interrupt. Inference: with docker rm hung and a signal delivered to the CLI, the old runtime can exit after releasing the lock. The new region stays pending and holds the lock because tidy.ts:122–123,1206 waits for a child with no timeout. Leaving that region in place at the final cutover also defeats parent Move the engine-native layer to Effect #290 D2's interruptible process service - Record the changed signal behavior while the bridges remain. Have Move the process layer, the file helpers, and the kit store to Effect #297 restore interruption at the process calls while keeping log I/O protected by the lock - class: interruption policy misstates the baseline and final cutover

    Previous findings:

    • Round-1 finding on Research Files and Steps tidy: resolved - Line 34 limits absence handling to lstatIfPresent and keeps failed entryActivity directory reads unknown.
    • Round-1 finding on Research Files and apply lock and Steps tidy: resolved - Lines 35 and 46 keep log rotation and append uninterruptible inside the apply lock.
    • Round-1 finding on Steps runner and tidy: resolved - Step tidy now moves the runner and all three production callers together.
    • Round-1 finding on Research re-export and Steps runner: resolved - Lines 39 and 46 retain the three exports and move the tests through index.ts.
    • Round-1 finding on Research typed errors, apply lock, and command and Do not touch: open - repeated above.
    • Round-1 finding on Acceptance scan and bridges: resolved - Lines 58–59 use separate expressions without a table delimiter, reject direct Effect.tryPromise, and restrict the remaining adapters by callee.
    • Round-1 finding on Acceptance commands: open - repeated above.
    • Round-1 finding on Steps tidy and Acceptance tidy and commands: resolved - Lines 46 and 56 specify a should-fail case for each of the five changed paths.
    • Round-1 finding on Steps and Acceptance guidance: resolved - Lines 47, 55, and 63 drop the unrelated hash refresh and check, and retain the project skill metadata check.

    Manager response to round 1

    Repaired:

    • Error policy per operation: the Files decision lists each call with its base outcome; only lstatIfPresent treats ENOENT and ENOTDIR as absent, a failed directory read in entryActivity stays unknown, and printed failures keep the message of the original Node error.
    • Interruptible log write: new decision "Apply without interruption": applyTidy runs as one uninterruptible region inside the lock scope, as the base Effect.promise did.
    • Split API cutover: the runner and its three callers move in one step (step 1 tidy).
    • Re-export: index.ts keeps runBounded, SyncConcurrency, and SyncTask; the moved tests import through it.
    • CLI diagnostic: at the command boundary a typed failure becomes a defect of its original error, so runMain prints the same diagnostic and exits 1.
    • Scan and bridges: separate expressions for Effect.promise(, Effect.run*(, and Effect.tryPromise(, with no pipe in the cell; bridges requires the bridge helpers for legacy callees and Effect.try only for kitLock.ts primitives and process.kill.
    • Process probe in the spawned fixture: the child PATH holds ps and lsof stubs that print no rows, links to the real tools a case needs, and no docker.
    • Untested paths: new untested row with a should-fail case for network removal, log rotation, the --repo listing, the apply-time scratch recheck, and the tidyCommand input resolution; step 2 updates that Gotcha.
    • Hash check: dropped; guidance relies on the greps and skillMetadata.test.ts.

    Rejected: none.

    Redesigned: none.

  6. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 3, delta

    Plan-review: repair

    • goal_fit - Research “Apply without interruption” and “Version” (lines 35 and 40); Steps tidy - The revised plan records a user-visible change but still says not to bump the version. Inference: if docker rm hangs during tidy --apply, Ctrl+C could previously release the lock and exit; the planned command stays running with the lock held until the tool settles (cli/src/commands/tidy.ts:59,91–100, cli/src/engine-native/tidy.ts:1199–1214, Effect runtime). AGENTS.md:52–53 requires a version bump and payload regeneration for this change - Keep the recorded signal behavior, add package.json and cli/src/generated/sotPayload.ts to the step, and bump the version and regenerate the payload - class: user-visible behavior change without the required version bump

    Previous findings:

    • Round-2 finding on Acceptance commands, line 57: resolved - The ps stubs emit valid rows for the CLI’s own PID, which joinRows drops. The lsof stub exits successfully with no output.
    • Round-2 finding on Research apply-lock and command decisions, lines 37–38; Do not touch: resolved - Line 38 preserves native lock errors as causes and passes the original error to the runtime.
    • Round-2 finding on Research Files and Typed errors decisions, lines 34 and 36: resolved - Line 34 skips unreadable .trashinfo entries individually and preserves native error messages where the base printed them.
    • Round-2 finding on Research Apply without interruption decision, line 35: resolved - Line 35 distinguishes the old and new signal behavior, and Move the process layer, the file helpers, and the kit store to Effect #297’s Goal explicitly restores interruption at process calls while keeping log I/O protected.

    Manager response to round 2

    Repaired:

    • ps stubs: they print valid rows for their parent process, the tidy CLI, which joinRows drops; lsof exits 0 with no output.
    • Lock diagnostic: every typed failure keeps the original thrown value as its cause (the kitLock.ts primitive errors included), and the command boundary dies with that cause.
    • .trashinfo: an unreadable entry stays skipped on its own; only the log and /proc/meminfo failures keep the Node error text.
    • Interruption: the decision now records the changed signal behavior (an interrupt waits until the apply ends, also behind a hung tool call), and the Move the process layer, the file helpers, and the kit store to Effect #297 Goal now says that Move the process layer, the file helpers, and the kit store to Effect #297 narrows the region while the log I/O stays protected.

    Rejected: none.

    Redesigned: none.

  7. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 4, delta

    Plan-review: repair

    • goal_fit - Research “Files,” “Signals and interruption,” and “Version” (lines 34–35, 40); Steps tidy (line 46) - The redesign restores prompt exit while a tool hangs, but introduces a new interruption window during log rotation. tidy.ts:1118–1126 currently renames and appends synchronously, with no signal callback between them. Effect’s pinned filesystem implementation uses asynchronous rename, and engine.ts:62–67 calls process.exit(130) before Effect can honor the uninterruptible region. Inference: a signal after the rename but before the append can leave only tidy.log.1 and lose the current run’s log lines. AGENTS.md:52–53 does not allow the no-bump claim if that change stays - Defer the signal exit during the log rotation and append under the lock, while keeping prompt exit during a hung tool call - class: user-visible behavior change without the required version bump
    • goal_fit - Acceptance commands (line 57) - The new signal case specifies a deadline for the assertion but no independent way to end the waiting stub. If the regression occurs, the CLI waits for du to close (tidyReport.ts:95–100, exec.ts:178–201), while du waits for the CLI to exit. The preload raises the signal only once (signalSelfPreload.ts:15–21). The assertion can time out with both processes still running and no exit marker for cleanup. The existing sync fixture avoids that cycle with a hard stub lifetime (syncSignals.test.ts:69–89) - Give the waiting stub a hard lifetime longer than the assertion bound and wait for both processes to finish before removing the fixture - class: signal regression fixture cannot clean up on failure
    • goal_fit - Research “Signals and interruption” (line 35); Acceptance commands (line 57) - The Move the process layer, the file helpers, and the kit store to Effect #297 handoff names only narrowing applyTidy’s uninterruptible region. That cannot make an OS signal reach the new process service while the tidy caller still installs engine.ts:62–67’s prepended hard-exit listener. Conversely, once Move the process layer, the file helpers, and the kit store to Effect #297 removes that listener and reaps the child before CLI exit as parent Move the engine-native layer to Effect #290 D2 requires, a stub that writes its marker only after its parent disappears cannot acknowledge that shutdown. The new caller and regression case both depend on the transitional exit order - Record that Move the process layer, the file helpers, and the kit store to Effect #297 removes tidy’s hard-exit wrapper and updates the existing signal case to verify child shutdown before CLI exit - class: incomplete handoff of transitional signal behavior

    Previous findings:

    • Round-3 finding on Research “Apply without interruption” and “Version”; Steps tidy: open - repeated above. The hung-tool scenario is fixed, but the new hard exit changes what can happen during log rotation.

    Manager response to round 3

    Repaired: none.

    Rejected: none.

    Redesigned:

    • Signal behavior change: redesigned so that no user-visible change remains, which also keeps the goldens free of a version bump (parent goldens row). tidyCommand runs inside exitOnSignal of cli/src/engine.ts (exported for this caller), so SIGINT and SIGTERM end the command at once with 130, as the base runMain interrupt did; the OS releases the lock. applyTidy stays uninterruptible only against a programmatic interrupt. The commands row gains a POSIX case: a du stub makes the CLI signal itself through the test preload and then waits, and the CLI exits 130 within a short bound. No version bump.
  8. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 5, delta

    Plan-review: repair

    • goal_fit - Goal (line 5); Research “Signals and interruption” and “Version” (lines 35, 40); Steps tidy (line 46) - The new deferral protects the log files but ends before planAndApply prints the apply result. In the base, cli/src/engine-native/tidy.ts:1118–1126,1269–1276 appends synchronously and returns the outcome; cli/src/commands/tidy.ts:57–58 prints its lines as the Promise resumes. Inference: if SIGTERM arrives during the new asynchronous append in tidy --apply --report, round 5 exits 130 at the end of the log region, before printing the completed removal or log-failure line that the base prints before handling the signal. That breaks the unchanged-output Goal and the no-bump premise in AGENTS.md:52 - Keep the deferred exit through printing the apply result, including when the runtime listener also requests interruption, while retaining prompt exit during a hung tool call - class: deferred exit ends before the user-visible result
    • goal_fit - Steps tidy (line 46); Acceptance commands (line 57) - The helper-only case can pass even if the real apply path never enters the deferral. The spawned signal case runs tidy --report without --apply, which bypasses applyTidy (cli/src/commands/tidy.ts:106–117), and the rotation case does not deliver a signal. Inference: every listed check can pass while a signal between rename and append leaves only tidy.log.1 - Replace the helper-only check with a selected tidy --apply case that delivers the signal at the rotation or append boundary and checks the rotated log, the appended lines, the printed apply result, and exit 130 - class: acceptance can pass without the protected apply behavior

    Previous findings:

    • Round-4 finding on Research “Files,” “Signals and interruption,” and “Version”; Steps tidy: resolved - The current decision defers the hard exit across both log operations. The output lost after that region is a separate defect reported above.
    • Round-4 finding on Acceptance commands: resolved - The waiting du stub has an independent hard lifetime, writes its exit marker on every exit path, and fixture removal waits for both the marker and the CLI exit.
    • Round-4 finding on Research “Signals and interruption”; Acceptance commands: resolved - The current decision and Move the process layer, the file helpers, and the kit store to Effect #297’s Goal require removing both tidy signal helpers, narrowing the apply region, and updating the case to verify child shutdown and reaping before CLI exit.

    Manager response to round 4

    Repaired:

    Rejected: none.

    Redesigned: none.

  9. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 6, delta

    Plan-review: repair

    • goal_fit - Goal (line 5); Research “Files,” “Signals and interruption,” and “Version” (lines 34–35, 40); Acceptance commands (line 57) - The deferral now lasts through printing, but it starts too late. The base rechecks and removes all scratch entries, then appends their results without yielding (cli/src/engine-native/tidy.ts:739–751,1247–1276); cli/src/commands/tidy.ts:57–58 prints those results when the Promise resumes. The pinned filesystem implementation makes the new rechecks asynchronous. Inference: with two idle scratch entries, SIGTERM during the second recheck can now exit 130 after deleting the first entry but before logging or printing its removal. The new rename-boundary case can pass despite that regression - Start deferral before the first asynchronous filesystem operation in the formerly synchronous scratch-and-log tail, keep it through printing, and cover the earlier signal boundary in the spawned case. Keep prompt exit while a tool is hung - class: signal deferral starts after a new interruption boundary
    • goal_fit - Acceptance commands (line 57) - The row limits the hung-du signal case to Linux and macOS but leaves the new scratch-rotation case unqualified. Windows runs the unit suite (.github/workflows/parity.yml:99–126) and has no tidy process list (cli/src/engine-native/tidy.ts:325–331). Tidy therefore keeps the seeded scratch folder (tidy.ts:795–798,1071–1077), so the fixture never reaches apply or the rename (cli/src/commands/tidy.ts:54–58) and cannot observe the required exit 130 - Limit the spawned scratch-rotation signal case to Linux and macOS. Keep the Windows dry-run and report expectations - class: acceptance fixture cannot reach the tested branch on a supported platform

    Previous findings:

    • Round-5 finding on Goal; Research “Signals and interruption” and “Version”; Steps tidy: resolved - The deferral now lasts through apply-result printing, and the uninterruptible region covers printing even when BunRuntime.runMain also requests interruption.
    • Round-5 finding on Steps tidy; Acceptance commands: resolved - The helper-only check is replaced by a spawned tidy --apply case that delivers SIGTERM between rename and append and checks stdout, both log files, and exit 130.

    Manager response to round 5

    Repaired:

    • Output after the region: applyTidy acquires deferSignalExit in the scope of the command, which closes after the apply result is printed; the apply and the printing run as one uninterruptible region, so the runMain interrupt also waits for the printing.
    • Coverage: the helper-only case is replaced by a spawned tidy --apply case that gets SIGTERM between the rename of tidy.log and the append, exits 130 after it prints the removed line, and keeps the old log in tidy.log.1 and the new line in tidy.log; it fails when the deferral is removed.

    Rejected: none.

    Redesigned: none.

  10. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 7, delta

    Plan-review: repair

    • goal_fit - Research “Signals and interruption” (line 35); Steps tidy; Acceptance commands - runTidy can run --report after a successful --apply (cli/src/commands/tidy.ts:108–120). A finalizer registered in the command scope runs when the whole command finishes, not when apply prints its result (Effect 4.1.7 scoped). Inference: if du hangs during the report phase of tidy --apply --report, SIGTERM is still deferred. The runtime interrupt waits for the uninterruptible subprocess bridge (cli/src/engine-native/tidyReport.ts:95–117; cli/src/engine-native/bridge.ts:49–54), so the CLI hangs instead of exiting promptly with 130. The report-only case does not enter the deferral and can pass - Keep exitOnSignal active for the whole command, but close a nested deferral scope immediately after apply-result printing and before entering the report - class: signal deferral outlives the protected work
    • goal_fit - Acceptance commands (line 57) - The shared fixture rule excludes docker from PATH, but the new hung-rm case needs a Docker stub there. With no executable, defaultTidyHost reports Docker missing, so planTidy does not list containers and applyTidy never reaches rm (cli/src/engine-native/tidy.ts:333–340,925–943,1234–1246) - Give the hung-rm case its own PATH containing the Docker stub. Keep Docker absent from the other fixtures and never resolve the real binary - class: acceptance fixture excludes the executable needed to reach the tested branch

    Previous findings:

    • Round-6 finding on Goal; Research “Files,” “Signals and interruption,” and “Version”; Acceptance commands: resolved - Deferral now starts at apply entry and covers the scratch rechecks, removals, log writes, and result printing. The tool-call exit points preserve prompt exit at a hung git or docker call.
    • Round-6 finding on Acceptance commands: resolved - Both spawned scratch-apply signal cases are limited to Linux and macOS. The Windows dry-run and report expectations remain.

    Manager response to round 6

    Repaired:

    • Windows: the spawned apply signal cases run on Linux and macOS only; the Windows dry-run and report expectations stay.

    Rejected: none.

    Redesigned:

    • Deferral start: the apply keeps exactly the base signal points. applyTidy acquires deferSignalExit at its start; each git and docker call of the apply runs inside the new signalExitPoint, where a recorded or new signal exits 130 at once. The spawned cases cover a signal during the second scratch recheck, one between the rename and the append, and a hung docker rm.
  11. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 8, delta

    Plan-review: repair

    • goal_fit - Acceptance commands, tidy --apply --report (line 57) - The fixture has “nothing to apply.” planAndApply prints Nothing to tidy. and skips applyTidy when there are no actions (cli/src/commands/tidy.ts:56–63), but runTidy still starts the report (cli/src/commands/tidy.ts:113–118). The check is meant to show that signal deferral ends before a hung report. As written, the CLI can exit promptly with 130 even if deferral still uses the whole-command scope, because the fixture never enters deferral - Seed one removable scratch entry and a report cache directory. Assert that the entry was removed, then send SIGTERM once the du stub is waiting on that cache and require exit 130 within the bound - class: acceptance fixture bypasses the state transition it checks

    Previous findings:

    • Round-7 finding on Research “Signals and interruption”; Steps tidy; Acceptance commands: resolved - The current design closes the nested deferral scope after printing the apply result and before starting the report. The command-wide signal handler stays active.
    • Round-7 finding on Acceptance commands: resolved - The hung-rm case now has its own PATH with the Docker stub and no real Docker executable.

    Manager response to round 7

    Repaired:

    • Deferral scope: applyTidy acquires deferSignalExit in a nested scope that runTidy opens around the apply and its printed result and closes before --report starts; exitOnSignal stays active for the whole command. A new spawned case: tidy --apply --report with a hung du stub exits 130 within the bound.
    • Docker stub PATH: the hung-rm case has its own PATH with the ps and lsof stubs and a docker stub, never the real docker.

    Rejected: none.

    Redesigned: none.

  12. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 9, delta

    Plan-review: pass

    None.

    Previous findings:

    • Round-8 finding on Acceptance commands, tidy --apply --report (line 57): resolved - The revised fixture removes a seeded idle scratch entry and checks its removed line before sending SIGTERM while the report’s du stub waits on .npm. Requiring exit 130 within the bound now checks that signal deferral ends before the report.

    Manager response to round 8

    Repaired:

    • Fixture: the tidy --apply --report case seeds one idle scratch entry and a .npm folder, asserts the removed line, and sends SIGTERM while the du stub waits on .npm; the CLI exits 130 within the bound.

    Rejected: none.

    Redesigned: none.

  13. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 1, lens correctness

    Code-review: pass

    Standards

    • [MEDIUM] Bug - cli/src/engine-native/tidy.ts:837-845, cli/src/engine-native/tidy.ts:1407-1419 - If another process creates a file after the apply-time recheck samples the scratch directory but while it awaits a child lstat, the new file is absent from the listing and the directory's fresh mtime is never read. Inference: tidy can delete the newly active directory; the serial async reads widen the window compared with the synchronous scan. removeTemporaryPath checks ownership and location, not activity. - Recheck the directory's identity and mtime after inspecting its children, and keep it if either changed during the scan. - class: stale directory snapshot before deletion
    • [MEDIUM] Performance - cli/src/engine-native/tidy.ts:307, cli/src/engine-native/tidy.ts:636-639, cli/src/engine-native/tidy.ts:825-845, cli/src/engine-native/tidy.ts:984, cli/src/engine-native/tidy.ts:1016-1021, cli/src/engine-native/tidyReport.ts:230-233 - On a busy Linux host or with a large scratch tree, the migration turns each metadata lookup into an async round trip but still waits for each result before issuing the next read. Inference: dispatch latency accumulates across every PID and directory entry, extending the time tidy --apply holds its lock and delaying tidy --report before disk measurement begins. The size of the slowdown is unmeasured. - Batch independent metadata reads with bounded concurrency, preserving result order and fail-closed checks. - class: serialized async metadata scans
    • [LOW] Bug - cli/src/engine-native/syncConcurrency.ts:43-47 - Unreached: if a task fails at the Effect scheduler's operation-budget boundary, Effect.exit can capture the failure and yield before the generator marks the pool as draining. Inference: a ready sibling can then admit a queued task after the failure. The bounded-runner fixtures do not exercise that boundary; report sizing has a short failure path, and worktree inspection recovers probe failures before they reach the pool. - Record the failure synchronously in the task's Effect.onExit callback, before returning control to the worker loop. - class: failure published after a scheduler yield
    • [LOW] Bug - cli/src/engine-native/tidy.ts:1259, cli/src/engine-native/tidy.ts:1424-1426 - Unreached: if an injected clock returns an invalid date after an apply has removed entries, timestamp formatting defects outside the typed log recovery, so the CLI never prints the completed action lines. The default host and both tidy test stubs use Date.now(), and no CLI input supplies a clock. The base caught this as a log failure and still returned the action lines. - Recover non-interruption defects at the log boundary as well as typed filesystem failures. - class: typed recovery drops legacy log defects
    • [LOW] Bug - cli/src/engine-native/tidy.ts:618-620, cli/src/engine-native/tidyReport.ts:362-365, cli/src/engine-native/tidyReport.ts:489-498 - An on-disk file beginning with a UTF-8 BOM is parsed differently. Effect's decoder strips the BOM, whereas the prior Node UTF-8 read retained it. A BOM-prefixed .git marker can enter worktree inspection instead of getting the original not a linked worktree reason; a BOM-prefixed Bun manifest or a .trashinfo file starting with a BOM-prefixed DeletionDate can add report lines the base omitted. Production reach assumes Bun's legacy UTF-8 read matches Node's. - Read bytes through FileSystem and decode without stripping the BOM at these parser boundaries. - class: implicit BOM normalization changes parsing

    Spec

    None.

    Code review round 1, lens spec-and-tests

    Code-review: pass

    Standards

    • [MEDIUM] Bug - cli/test/unit/tidy.test.ts:981-1000, cli/test/unit/tidy.test.ts:1078-1084, cli/test/unit/tidy.test.ts:1125-1158, cli/test/unit/tidy.test.ts:1313-1337 - If a regression makes docker rm defer SIGTERM, the test times out and teardown sends another SIGTERM to the same deferring handler. The CLI and stub can then remain alive until the stub's 90-second deadline, after teardown has stopped tracking the fixture. - Give teardown a separate way to release the waiting stub, confirm both exits and the marker, then remove the fixture. Keep the single self-signal on the passing path. - class: teardown repeats the failed stop mechanism
    • [MEDIUM] Bug - cli/test/unit/tidy.test.ts:1196-1216 - The spawned report test accepts any formatted size for .npm. If sizeKb still launches du but discards its result and returns zero, this case and the signal cases still pass. The commands row in plan-295-cr1.md:57 requires the measured entry. - Seed a cache whose size rounds to a nonzero value and compare the report line with an independent du -sk measurement of that fixture. - class: shape-only assertion for measured output
    • [MEDIUM] Maintainability - cli/test/unit/syncConcurrency.test.ts:11-20, cli/test/unit/syncConcurrency.test.ts:175-222, cli/src/engine-native/syncConcurrency.ts:43-52 - All six runner cases still pass if the worker captures only typed failures and lets defects escape. The outer Effect.all would then interrupt started siblings on a defect instead of draining them. No case interrupts the caller either. - Add gated cases that verify a defect drains the pool and retains its cause, and that interrupting the caller interrupts both started workers without starting queued work. - class: untested defect and interruption paths
    • [LOW] Bug - cli/test/unit/tidy.test.ts:913-921, cli/test/unit/tidy.test.ts:1226-1240, cli/src/engine-native/tidy.ts:751-764 - On Windows the isolated PATH has no Git, so the negative --repo case gets the expected error without Git ever checking the folder. It would reject a valid repository for the same reason. The linked-worktree test passes inputs.repo directly and does not cover this CLI resolution. - Put a working Git entry in the isolated Windows PATH and add a positive spawned --repo case to distinguish validation from an unavailable tool. - class: negative test satisfied by a missing dependency
    • [LOW] Bug - cli/test/unit/tidy.test.ts:894-900, cli/test/unit/tidy.test.ts:934-950 - On POSIX, a valid TMPDIR containing an apostrophe or dollar sign makes stub setup throw before any CLI assertion runs. - Quote the static paths with the existing shQuote helper and register a shell cleanup function as the trap, rather than embedding paths in the trap text. - class: fixture rejects valid host paths
    • [LOW] Maintainability - cli/test/unit/tidyReport.test.ts:65-91, cli/test/unit/tidyReport.test.ts:134-178, cli/src/engine-native/tidyReport.ts:528-539 - The report tests cover an unavailable process list and a typed Docker failure, but none makes a section die. Replacing catchCause with typed-only recovery leaves the assertions green even though a defect would abort the whole report. - Inject a defect into one section and assert its exact unavailable: line plus normal output from another section. - class: untested section defect isolation

    Spec

    • [LOW] Spec - cli/src/engine-native/tidy.ts:615-620, cli/src/engine-native/tidyReport.ts:359-365, cli/src/engine-native/tidyReport.ts:487-504 - A leading UTF-8 BOM now disappears before parsing. The Effect backend uses the default TextDecoder, whereas the removed UTF-8 reads preserved the BOM. Inference: a BOM-prefixed .git marker is now admitted as a candidate rather than kept as not a linked worktree; a BOM-prefixed Bun manifest now lists packages the base report skipped. The same change affects a .trashinfo file with DeletionDate on its first line. This conflicts with plan-295-cr1.md:34, “each call keeps its base outcome,” and the output constraint at line 72. - Read bytes through FileSystem and decode with ignoreBOM: true at the affected parsers. - class: changed UTF-8 decoding semantics
    • [LOW] Spec - .agents/skills/tidy-context/SKILL.md:12-13, .agents/skills/tidy-context/SKILL.md:73, cli/src/engine-native/kitLock.ts:153-162 - The updated lock guidance names releaseKitLock, but its source range still ends at line 121 and omits the release implementation. Step 2 in plan-295-cr1.md:47 calls for updating the source_files ranges; the metadata test only checks that the range ends inside the file. - Extend the lock range through the release implementation. - class: stale source range omits documented behavior

    Code review round 1, lens text-and-safety

    Code-review: pass

    Standards

    • [MEDIUM] Security - cli/src/engine-native/tidy.ts:824-845, cli/src/engine-native/tidy.ts:1400-1421 - If an agent creates a file in an old scratch directory after entryActivity samples the directory mtime, the new file is absent from the saved listing. The migration gives that race a separate asynchronous wait for every remaining child. Inference: the sweep can still classify the directory as idle and recursively delete the new file. removeTemporaryPath checks ownership and containment, not activity. This defeats the base rule that the safe sweep removes “idle scratch” (cli/AGENTS.md:19). - Recheck the directory identity and mtime after sampling the children, keep the entry if either changed or cannot be checked, and cover a write during the scan. - class: stale activity check before recursive deletion
    • [MEDIUM] Maintainability - cli/test/unit/tidy.test.ts:1196-1211, cli/src/engine-native/tidyReport.ts:221-251 - The spawned .npm test puts an unrestricted real du on PATH. The report also runs it on same-user directories under /tmp and /var/tmp and waits for those measurements before printing any section. Inference: a large or slow directory unrelated to the test can delay or time out the .npm assertion. - Delegate to real du only for the seeded .npm path and return a bounded stub response for other paths, as the waiting du fixture already does. - class: spawned test reads outside its fixture
    • [LOW] Maintainability - cli/test/unit/tidy.test.ts:975-999, cli/test/unit/tidy.test.ts:1075-1083, cli/test/unit/tidy.test.ts:1125-1144 - If teardown ends the CLI before its waiting stub reads process.ppid, the stub can mistake its new parent for the CLI and hold its ticket until the 90-second lifetime expires. Inference: the 10-second teardown then leaves the fixture behind. This is a gap in the second supervision implementation; the sync fixture already records the actual CLI PID and handles a late-starting stub. The direct child.kill() also contradicts the fixture's “no process of these cases signals another process” comment. - Reuse the existing supervisor's CLI PID record and request-file teardown for the signal cases. - class: duplicated child supervision loses parent identity
    • [LOW] Bug - .agents/skills/tidy-context/SKILL.md:147, cli/src/engine.ts:118-123 - A signal recorded between apply steps can still cause an immediate exit at the next Git or Docker call, before that call starts and before the results print. The guide says apply signals wait for the printed lines and describes immediate exit only while a tool call waits. - Document that entering an exit point also acts on a pending signal. - class: incomplete signal timing guidance
    • [LOW] Bug - .agents/skills/tidy-context/SKILL.md:3, .agents/skills/tidy-context/SKILL.md:169, cli/src/engine-native/DESIGN.md:143-146, cli/src/commands/tidy.ts:116-126 - A maintainer tracing the production tidy lock from the skill's description or the design overview is still directed to acquireKitLock, the Promise poll that now has only test callers. - Point production guidance to tryAcquireKitLock and describe the Promise poll separately as test-only. - class: stale production entry-point guidance
    • [LOW] Maintainability - cli/src/commands/tidy.ts:40, cli/src/engine-native/tidy.ts:47, cli/src/engine-native/tidy.ts:146, cli/src/engine-native/tidyReport.ts:54 - Unreached: no caller, fixture, or documented input imports these four new exports. The tidy command and report use the types locally, the tests use runTidy, TidyHost, and buildTidyReport, and the package declares a CLI rather than a library API. Exporting the definitions makes private implementation details look supported. - Keep the definitions local; retain exports that have callers, including TidyFailure. - class: unused internal exports

    Spec

    None.

  14. linked a pull request that will close this issueMove tidy to Effect #303on Dec 2, 2026
  15. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 2, delta

    Code-review: pass

    Previous findings

    The round-1 findings remain open in #302. This delta does not repair them.

    • Round-1 finding on cli/src/engine-native/tidy.ts:837-845: open - stale scratch snapshot before deletion.
    • Round-1 finding on cli/src/engine-native/tidy.ts:307: open - serialized metadata scans.
    • Round-1 finding on cli/src/engine-native/syncConcurrency.ts:43-47: open - failure publication can yield before the pool stops.
    • Round-1 finding on cli/src/engine-native/tidy.ts:1259: open - log recovery misses defects.
    • Round-1 finding on cli/src/engine-native/tidy.ts:618-620: open - BOM normalization changes parsing.
    • Round-1 finding on cli/test/unit/tidy.test.ts:981-1000: open - teardown repeats the failed stop mechanism.
    • Round-1 finding on cli/test/unit/tidy.test.ts:1196-1216: open - the assertion still checks size format, not the measured value.
    • Round-1 finding on cli/test/unit/syncConcurrency.test.ts:175-222: open - defect and interruption paths lack tests.
    • Round-1 finding on cli/test/unit/tidy.test.ts:1226-1240: open - missing Git can satisfy the Windows negative test.
    • Round-1 finding on cli/test/unit/tidy.test.ts:894-900: open - fixture setup rejects valid host paths.
    • Round-1 finding on cli/test/unit/tidyReport.test.ts:134-178: open - section defect isolation lacks a test.
    • Round-1 Spec finding on cli/src/engine-native/tidy.ts:615-620: open - UTF-8 decoding changes base behavior.
    • Round-1 Spec finding on .agents/skills/tidy-context/SKILL.md:12-13: open - the source range omits lock release.
    • Round-1 Security finding on cli/src/engine-native/tidy.ts:824-845: open - stale activity check before recursive deletion.
    • Round-1 finding on cli/test/unit/tidy.test.ts:1196-1211: open - real du can read outside the fixture.
    • Round-1 finding on cli/test/unit/tidy.test.ts:975-999: open - child supervision can lose the parent PID.
    • Round-1 finding on .agents/skills/tidy-context/SKILL.md:147: open - signal timing guidance omits pending signals.
    • Round-1 finding on .agents/skills/tidy-context/SKILL.md:169: open - production lock guidance points to the old entry point.
    • Round-1 finding on cli/src/commands/tidy.ts:40: open - unused internal exports.

    Standards

    None.

    Spec

    None.

    Manager response to round 1

    Repaired: none. Round 1 passed; its open findings are in #302.

    Rejected: none.

    Redesigned: none.

    Round 2 reviews the fix of a Full CI failure (RegExp.escape is not a function on the Ubuntu and Windows runners) in commit b7c4936.

  16. DocksDocks commented on Dec 2, 2026

    @DocksDocks
    OwnerAuthor

    Archived with landing pull request #303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions