Skip to content

refactor: package code organization wave 15 - #2394

Merged
gsxdsm merged 9 commits into
mainfrom
feature/code-organization-wave15
Jul 23, 2026
Merged

refactor: package code organization wave 15#2394
gsxdsm merged 9 commits into
mainfrom
feature/code-organization-wave15

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wave 15 of package code organization.

Peels

  • types/settings-scope.ts — global/project settings (~2.2k lines)
  • types/archive-planning.ts — archive, mesh/multi-project, planning sessions
  • task-store/project-store-ops.ts — rename of remaining-ops-1 (last numbered ops module)

LOC

  • types.ts ~5872 → ~3074

Test plan

  • @fusion/core typecheck
  • CI merge gate

Stack: this PR → #2397#2398

Summary by CodeRabbit

  • Refactor
    • Reorganized and expanded the core public type surface into dedicated modules for settings, archive/planning, board, tasks, todo lists, plugin activation, and multi-project setup.
    • Improved the browser-safe type exports to keep the public contracts consistent.
    • Updated internal project-level operation wiring to use the correct project implementations.
  • Bug Fixes
    • Fixed a workflow creation test hook to inject the correct pre-insert behavior for workflow-definition collision/allocator scenarios.
  • Chores
    • Refreshed internal headers and updated line-count baselines.

…ore-ops

Behavior-preserving package organization after wave 14:
- types/settings-scope.ts — global/project settings (~2.2k lines)
- types/archive-planning.ts — archive entries, mesh/planning, multi-project types
- rename remaining-ops-1 → task-store/project-store-ops.ts (last numbered ops gone)
- Ratchet types.ts line-count ceiling (~5872 → ~3074)
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@gsxdsm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e53308e8-9419-4743-ba73-00bc29814b97

📥 Commits

Reviewing files that changed from the base of the PR and between 097b684 and 59bc1fa.

📒 Files selected for processing (3)
  • packages/core/src/store.ts
  • packages/core/src/types.ts
  • packages/core/src/types/task-core.ts
📝 Walkthrough

Walkthrough

The PR extracts core, settings, archive-planning, and related contracts from types.ts into dedicated modules, preserves barrel exports, updates line-count baselines, and redirects selected TaskStore operations and workflow-definition test hooks to project-store-ops.js.

Changes

Core type extraction and wiring

Layer / File(s) Summary
Core domain contracts
packages/core/src/types/task-core.ts, packages/core/src/types/task-log.ts, packages/core/src/types/todo-list.ts, packages/core/src/types/board-config.ts, packages/core/src/types/plugin-activation.ts, packages/core/src/types/multiproject-setup.ts
Adds dedicated task, logging, todo, board, plugin activation, and multi-project setup contracts, including merge, checkout, task verification, distributed IDs, autostash, and migration shapes.
Settings scope contracts
packages/core/src/types/settings-scope.ts
Adds global, project, merged settings, MCP transport, remote-access, authentication, defaults, guards, and sanitization contracts.
Archive and mesh contracts
packages/core/src/types/archive-planning.ts
Adds archive, planning, node discovery, mesh synchronization, Docker-node, project registry, health, activity, and concurrency types.
Type barrel integration
packages/core/src/types.ts, scripts/line-count-baseline.json
Moves extracted declarations behind dedicated-module imports and re-exports, and updates baseline counts.
TaskStore project-operation wiring
packages/core/src/store.ts, packages/core/src/__tests__/postgres/workflow-create.pg.test.ts, packages/core/src/task-store/*
Redirects project-level operation implementations and the workflow-definition test hook to project-store-ops.js, with related header updates.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the refactor, but it is too generic to convey the specific code-organization changes. Use a more specific title, such as extracting settings and planning types into dedicated modules and renaming the remaining ops store.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/code-organization-wave15

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reorganizes the core package into smaller domain modules. The main changes are:

  • Moves task, settings, board, archive, planning, and related types into dedicated files.
  • Preserves the public type and runtime exports through types.ts.
  • Renames the numbered project-store operations module and updates its import paths.
  • Updates the PostgreSQL workflow creation test hook import.
  • Refreshes the line-count baseline.

Confidence Score: 5/5

This looks safe to merge.

  • The moved declarations remain available through the main type barrel.
  • The known runtime and test imports use the renamed project-store module.
  • No blocking issue tied to an earlier review finding remains in the changed code.

Important Files Changed

Filename Overview
packages/core/src/types.ts Replaces inline declarations with imports and re-exports from the new domain type modules.
packages/core/src/types/settings-scope.ts Contains the extracted settings contracts, defaults, key classifiers, and sanitizers.
packages/core/src/types/archive-planning.ts Contains the extracted archive, planning, mesh, node, and Docker contracts and helpers.
packages/core/src/task-store/project-store-ops.ts Renames the former numbered operations module without substantive implementation changes.
packages/core/src/store.ts Updates the project-store operations import to use the renamed module.
packages/core/src/tests/postgres/workflow-create.pg.test.ts Updates the workflow-definition test hook import to use the renamed module.

Reviews (8): Last reviewed commit: "merge: origin/main into feature/code-org..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/core/src/types/settings-scope.ts (1)

75-86: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

GlobalSettings duplicates DaemonTokenSettings instead of extending it.

daemonToken/daemonPort/daemonHost (with identical JSDoc) are declared both as the standalone DaemonTokenSettings interface and inline in GlobalSettings. Extending DaemonTokenSettings would remove the duplication and keep the two from drifting.

♻️ Proposed fix
-export interface GlobalSettings {
+export interface GlobalSettings extends DaemonTokenSettings {
   /** Maximum PostgreSQL server connections for Fusion's embedded database. Applied on the next Fusion restart. */
   embeddedPostgresMaxConnections?: number;
@@
-  /** The daemon authentication token (format: fn_<32 hex chars>).
-   *  Used for authenticating CLI clients to the daemon server. */
-  daemonToken?: string;
-  /** Port for daemon mode server binding. Default: 4040. */
-  daemonPort?: number;
-  /** Host for daemon mode server binding. Default: "127.0.0.1" (localhost only).
-   *  Set to "0.0.0.0" explicitly to expose the API on all interfaces — only do
-   *  this if you understand the implications (terminal/exec endpoints become
-   *  reachable from the LAN even with a bearer token). */
-  daemonHost?: string;
   /** When true, enables automatic settings synchronization between nodes.

Also applies to: 705-714

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/types/settings-scope.ts` around lines 75 - 86, Update
GlobalSettings to extend DaemonTokenSettings and remove its duplicated
daemonToken, daemonPort, and daemonHost declarations, preserving the shared
JSDoc and existing settings contract through the inherited interface.
packages/core/src/types/archive-planning.ts (1)

525-586: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Move the Docker-node import/export block to the top of the file.

This second import/export pair (Docker types + validateDockerNodeConfig/sanitizeDockerNodeConfigForResponse) sits ~500 lines into the file instead of alongside the imports at lines 6-23. ES module imports hoist regardless of position, so this is not a functional bug, but it hurts discoverability in a newly-created module.

-/** A runtime node that can host project execution (local machine or remote host) */
+import type {
+  DockerNodeConfig,
+  DockerNodeVolumeMount,
+  // ...remaining docker-nodes.js types...
+} from "./docker-nodes.js";
+export type { DockerNodeConfig, DockerNodeVolumeMount /* ... */ };
+import { validateDockerNodeConfig, sanitizeDockerNodeConfigForResponse } from "./docker-nodes.js";
+export { validateDockerNodeConfig, sanitizeDockerNodeConfigForResponse };
+
+/** A runtime node that can host project execution (local machine or remote host) */
 export interface NodeConfig {

(and remove the duplicate block from its current mid-file location)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/types/archive-planning.ts` around lines 525 - 586, Move the
Docker-node type import/export block and the
validateDockerNodeConfig/sanitizeDockerNodeConfigForResponse import/export block
to the top-level import/export section of the module, alongside the existing
imports. Remove the duplicate blocks from their current mid-file location,
preserving the same symbols and exports.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/task-store/task-store-helpers.ts`:
- Line 10: Correct the historical filename in the file header comment, replacing
the inaccurate `project-store-ops0.ts` reference with the verified predecessor
filename from the rename history, consistent with the `remaining-ops-*` series
and current `project-store-ops.ts` name.

In `@scripts/line-count-baseline.json`:
- Around line 19-22: Add a line-count baseline entry for
packages/core/src/types/archive-planning.ts in scripts/line-count-baseline.json,
using its current line count (approximately 899). Keep the existing
types/settings-scope.ts entry and ensure the new file is included in
check:line-count monitoring.

---

Nitpick comments:
In `@packages/core/src/types/archive-planning.ts`:
- Around line 525-586: Move the Docker-node type import/export block and the
validateDockerNodeConfig/sanitizeDockerNodeConfigForResponse import/export block
to the top-level import/export section of the module, alongside the existing
imports. Remove the duplicate blocks from their current mid-file location,
preserving the same symbols and exports.

In `@packages/core/src/types/settings-scope.ts`:
- Around line 75-86: Update GlobalSettings to extend DaemonTokenSettings and
remove its duplicated daemonToken, daemonPort, and daemonHost declarations,
preserving the shared JSDoc and existing settings contract through the inherited
interface.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bc5f89a-2599-4af2-b149-98383d02fd12

📥 Commits

Reviewing files that changed from the base of the PR and between a9de6b2 and 56fa2a5.

📒 Files selected for processing (8)
  • packages/core/src/__tests__/postgres/workflow-create.pg.test.ts
  • packages/core/src/store.ts
  • packages/core/src/task-store/project-store-ops.ts
  • packages/core/src/task-store/task-store-helpers.ts
  • packages/core/src/types.ts
  • packages/core/src/types/archive-planning.ts
  • packages/core/src/types/settings-scope.ts
  • scripts/line-count-baseline.json

*
* FNXC:CodeOrganization 2026-07-16-20:00:
* Renamed from remaining-ops-10.ts (domain: task-store helper ops).
* Renamed from project-store-ops0.ts (domain: task-store helper ops).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the historical filename attribution.

This comment now references project-store-ops0.ts, while the supplied rename context identifies the numbered remaining-ops-* series and the current file as project-store-ops.ts. Update it to the actual predecessor filename, or verify the historical name before merging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/task-store/task-store-helpers.ts` at line 10, Correct the
historical filename in the file header comment, replacing the inaccurate
`project-store-ops0.ts` reference with the verified predecessor filename from
the rename history, consistent with the `remaining-ops-*` series and current
`project-store-ops.ts` name.

Comment on lines 19 to 22
"packages/core/src/store.ts": 2820,
"packages/core/src/types.ts": 5872,
"packages/core/src/types.ts": 3074,
"packages/core/src/types/settings-scope.ts": 2287,
"packages/dashboard/app/App.tsx": 2136,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Missing baseline entry for the new packages/core/src/types/archive-planning.ts.

types/settings-scope.ts gets a new baseline entry (2287) but the equally new types/archive-planning.ts (~899 lines) has none, leaving it unmonitored by check:line-count. This also doesn't match the PR's claim of updating "line-count baselines" (plural) for the extraction.

   "packages/core/src/store.ts": 2820,
   "packages/core/src/types.ts": 3074,
+  "packages/core/src/types/archive-planning.ts": 899,
   "packages/core/src/types/settings-scope.ts": 2287,
   "packages/dashboard/app/App.tsx": 2136,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"packages/core/src/store.ts": 2820,
"packages/core/src/types.ts": 5872,
"packages/core/src/types.ts": 3074,
"packages/core/src/types/settings-scope.ts": 2287,
"packages/dashboard/app/App.tsx": 2136,
"packages/core/src/store.ts": 2820,
"packages/core/src/types.ts": 3074,
"packages/core/src/types/archive-planning.ts": 899,
"packages/core/src/types/settings-scope.ts": 2287,
"packages/dashboard/app/App.tsx": 2136,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/line-count-baseline.json` around lines 19 - 22, Add a line-count
baseline entry for packages/core/src/types/archive-planning.ts in
scripts/line-count-baseline.json, using its current line count (approximately
899). Keep the existing types/settings-scope.ts entry and ensure the new file is
included in check:line-count monitoring.

gsxdsm added 5 commits July 22, 2026 01:32
Resolve packages/core/src/types.ts conflict by keeping the wave15
settings-scope peel re-exports and porting selectedWorkflowModelLanes
(#2400) into types/settings-scope.ts ProjectSettings.
## Summary

Wave 16 of package code organization (stacks on #2394).

### Peels
- `types/task-log.ts`, `types/task-core.ts` — task model + logs
- `types/todo-list.ts`, `types/board-config.ts`,
`types/plugin-activation.ts`, `types/multiproject-setup.ts`

### LOC
- `types.ts` ~3074 → ~1473 (under 2000-line hard cap)

## Test plan
- [x] `@fusion/core` typecheck
- [ ] CI merge gate

**Stack:** #2394 → **this PR** → #2398

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Reorganized core task, workflow, settings, board, project, and
activity type definitions into dedicated modules.
* Consolidated project-store operation wiring without changing
functionality.
* Improved maintainability of task logs, todo lists, plugin activation,
and multi-project setup contracts.

* **Documentation**
* Updated internal metadata and naming references to reflect the
reorganized modules.

* **Tests**
* Updated PostgreSQL workflow-definition tests to use the corresponding
testing hook; existing coverage and behavior remain unchanged.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
After task-core peels, types.ts no longer references signal types
inline. Convert leftover import-type lines to type-only re-exports so
eslint is clean and the dashboard vite @fusion/core alias still
resolves stall/staleness/overseer types.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/core/src/types/todo-list.ts (1)

10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move SHARED_STATE_SNAPSHOT_VERSION out of todo-list types.

This constant is used by shared-mesh-state.ts, mesh sync validation/tests, and dashboard mesh routes to version shared mesh snapshots, not todo-list state. Relocate it to the mesh/archive/planning domain types and update types.tstodo-list re-export section accordingly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/types/todo-list.ts` around lines 10 - 11, Move
SHARED_STATE_SNAPSHOT_VERSION from the todo-list types module into the
mesh/archive/planning domain types module, then update types.ts so the todo-list
re-export no longer owns or exposes it and consumers import it from its new
domain location. Preserve the constant’s value and update all references in
shared-mesh-state.ts, mesh sync validation/tests, and dashboard mesh routes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/core/src/types/todo-list.ts`:
- Around line 10-11: Move SHARED_STATE_SNAPSHOT_VERSION from the todo-list types
module into the mesh/archive/planning domain types module, then update types.ts
so the todo-list re-export no longer owns or exposes it and consumers import it
from its new domain location. Preserve the constant’s value and update all
references in shared-mesh-state.ts, mesh sync validation/tests, and dashboard
mesh routes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 06af6a3d-e610-41d8-9e9f-1033edc91596

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1eac4 and 097b684.

📒 Files selected for processing (9)
  • packages/core/src/store.ts
  • packages/core/src/types.ts
  • packages/core/src/types/board-config.ts
  • packages/core/src/types/multiproject-setup.ts
  • packages/core/src/types/plugin-activation.ts
  • packages/core/src/types/task-core.ts
  • packages/core/src/types/task-log.ts
  • packages/core/src/types/todo-list.ts
  • scripts/line-count-baseline.json
💤 Files with no reviewable changes (1)
  • scripts/line-count-baseline.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/store.ts

Keep task-core peels for types.ts and port main's TaskWedgeNotificationState
/ wedgeNotification fields into types/task-core.ts with barrel re-exports.
@gsxdsm
gsxdsm merged commit 6166535 into main Jul 23, 2026
7 checks passed
@gsxdsm
gsxdsm deleted the feature/code-organization-wave15 branch July 23, 2026 07:01
gsxdsm added a commit that referenced this pull request Jul 26, 2026
Wave 16 of package code organization (stacks on #2394).

- `types/task-log.ts`, `types/task-core.ts` — task model + logs
- `types/todo-list.ts`, `types/board-config.ts`,
`types/plugin-activation.ts`, `types/multiproject-setup.ts`

- `types.ts` ~3074 → ~1473 (under 2000-line hard cap)

- [x] `@fusion/core` typecheck
- [ ] CI merge gate

**Stack:** #2394 → **this PR** → #2398

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **Refactor**
* Reorganized core task, workflow, settings, board, project, and
activity type definitions into dedicated modules.
* Consolidated project-store operation wiring without changing
functionality.
* Improved maintainability of task logs, todo lists, plugin activation,
and multi-project setup contracts.

* **Documentation**
* Updated internal metadata and naming references to reflect the
reorganized modules.

* **Tests**
* Updated PostgreSQL workflow-definition tests to use the corresponding
testing hook; existing coverage and behavior remain unchanged.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
gsxdsm added a commit that referenced this pull request Aug 3, 2026
## Summary

Wave 17 organizes Fusion into **domain folders** (stacks on #2397).

### Layout
- **core/types/** — board, task, agents, settings, merge, workflow,
mesh, …
- **core/src/** — agents, ai, async-stores, workflows, tasks, config,
db, …
- **dashboard/app/api/** — client, tasks, agents, git, missions,
planning, …
- **engine/src/** — agents, auth, execution, merge, missions, overseer,
worktree, …

Root keepers retained for large entrypoints (`store.ts`, `executor.ts`,
`merger.ts`, …).

Public barrels (`@fusion/core`, `@fusion/engine`, `app/api.ts` → legacy)
stay stable.

## Test plan
- [x] `@fusion/core` typecheck
- [x] `@fusion/engine` typecheck (pre-existing playwright-core noise
only)
- [ ] CI merge gate

**Stack:** #2394#2397 → **this PR**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant