fix(audit): resolve issue #157 — coordinator replay, store cycles, CI gates#177
Merged
Merged
Conversation
…fy types - .npmrc: remove pnpm-only `onlyBuiltDependencies` block that triggered `Unknown project config` warnings on every npm invocation. - scripts/test-semgrep-filesystem-safety.mjs: add preflight that exits 1 with an install hint when `semgrep` is missing, instead of spawnSync ENOENT with a wall of node internals. - knip: declare `semgrep`/`gitleaks` as ignored binaries and drop the unused `@types/dompurify` devDep (dompurify v3 ships its own types). Addresses findings 7 and 41 of issue johannesjo#157. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…rator `npm run lint:arch` failed with 7 circular store imports plus a renderer- imports-main violation. Untangled without behavior changes: - `src/store/focused-panel.ts` (new): the focus-registry getters/setters (`triggerFocus`, `getTaskFocusedPanel`, `setTaskFocusedPanel`, `isPanelFocused`, `defaultPanelFor`, `aiTerminalPanels`, etc.) live here. `focus.ts` keeps grid navigation and re-exports the moved symbols for backward compatibility with existing call sites. - `src/store/project-cleanup.ts` (new): `removeProjectWithTasks` is now the lone orchestrator that depends on both projects and tasks, so `projects.ts` no longer needs to import `closeTask`. - Updated `navigation`, `tasks`, `terminals`, `ui` (and `ui.test.ts` mock target) to import focused-panel helpers from the new module instead of round-tripping through `focus.ts`. After this change the projects↔tasks, persistence chain, navigation↔ focus, and focus↔tasks cycles are gone. - .dependency-cruiser.cjs: `electron/mcp/prompt-detect.ts` is a pure regex module already shared with the renderer task-status pipeline; whitelist it next to `electron/ipc/channels.ts` so the rule's intent (block Node/Electron-bound code) remains while the documented shared module is allowed. Addresses finding 2 of issue johannesjo#157. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…lete() path `waitForSignalDone` had two terminal paths: the registered `wrapped` resolver (which cleared the timer, wrote the replay cache, and resolved) and the timeout callback (which removed the resolver, finished the wait, but \*did not\* write the replay cache before resolving). A client retry that reused the same requestId after a timeout would therefore re-enter the wait path and register a fresh resolver, inflating `activeSignalWaitCounts` and re-blocking the coordinator's notification batching. - Collapse both paths into a single idempotent `complete(result)` that clears the timer, removes itself from `anySignalResolvers`, calls `finishSignalWait`, writes the replay cache when `requestId` is set, and resolves the promise. The `settled` guard makes repeated calls a no-op so external callers can keep shifting the resolver out before invoking it. - Drop the now-redundant `finishSignalWait` calls in the three external paths that consume a resolver (PTY exit, cleanupChildTask, signalDone) — `complete` handles bookkeeping itself, so leaving the manual call in place would double-decrement the wait count. - In `unregisterCoordinator`, snapshot the resolvers before fan-out because `complete` now splices itself from the live array. - Add a coordinator.test.ts case: same requestId after a timeout returns the cached timed-out result quickly instead of starting a new live wait. Addresses finding 1 of issue johannesjo#157. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
CI previously ran only typecheck/lint/format and skipped both the electron compile (`npm run compile` is the closest thing to a build gate for main-process code) and the test suite. After the cycle fix and knip cleanup, the static gates are green, so wire them in: - `npm run check` — covers compile + typecheck + lint + format:check. - `npm run lint:arch` — depcruise enforcement, now green. - `npm run lint:dead` — knip, now green. - `npm test` — vitest run across renderer and main suites. Addresses finding 3 of issue johannesjo#157. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Owner
|
Thank you very much! <3 |
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.
Closes the highest-priority correctness and quality-gate items from issue #157. Each commit maps to one finding; tests, typecheck, lint, lint:arch, lint:dead, and format:check all pass locally.
Summary
wait_for_signal_donetimeout bypassed the replay cache. Collapsed the two terminal paths (resolver and timeout) into a single idempotentcomplete(result)so timer cleanup, replay-cache write,anySignalResolversremoval,finishSignalWait, and promise resolution all happen once. Removed the now-redundantfinishSignalWaitcalls in the three external paths that consume a resolver (PTY exit handler,cleanupChildTask,signalDone) so the active-wait count is not double-decremented.unregisterCoordinatornow snapshots the resolver list before fan-out becausecompletesplices itself out of the live array.src/store/focused-panel.tsand movedremoveProjectWithTasksintosrc/store/project-cleanup.ts.projects.tsno longer importscloseTask, andnavigation/tasks/terminals/uiimport focus helpers directly fromfocused-panelinstead of round-tripping throughfocus.ts.focus.tsre-exports the moved symbols for existing component imports. The sharedelectron/mcp/prompt-detect.ts(pure regex helpers reused by the renderer task-status pipeline) is whitelisted alongsidechannels.tsin.dependency-cruiser.cjs.npm run check(which also runscompile),npm run lint:arch,npm run lint:dead, andnpm test.@types/dompurifydevDep (dompurify v3 ships its own types) and registeredsemgrep/gitleaksunderignoreBinaries.npm run lint:deadnow exits 0.1a65f3aalready retired the OpenSpec workflow, and the only remainder (openspec/changes/add-focus-mode-shortcut/.claude/) is gitignored..npmrcwarnings and semgrep preflight. Removed the pnpm-onlyonlyBuiltDependenciesblock that triggeredUnknown project configwarnings on every npm invocation, and added asemgrep --versionpreflight toscripts/test-semgrep-filesystem-safety.mjsso a missing binary yields an install hint instead of aspawnSync ENOENTnode stack trace.Test plan
npm run check(compile + typecheck + lint + format:check)npm run lint:arch—no dependency violations found (346 modules, 1096 dependencies cruised)npm run lint:dead— exits 0 (only knip "Configuration hints" remain, which are informational)npm test—1413 passed | 24 skipped (1437)waitForSignalDoneinelectron/mcp/coordinator.test.tsnode scripts/test-semgrep-filesystem-safety.mjswith semgrep absent now prints an install hint and exits 1 (instead of dumping internals)🤖 Generated with Claude Code