Skip to content

refactor: package code organization wave 9#2274

Merged
gsxdsm merged 3 commits into
mainfrom
feature/code-organization-wave9
Jul 18, 2026
Merged

refactor: package code organization wave 9#2274
gsxdsm merged 3 commits into
mainfrom
feature/code-organization-wave9

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wave 9 of package code organization (plan: docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md), after #2252.

Peels

New module Parent
app/api/global-and-pi-settings.ts legacy.ts
app/api/task-content.ts legacy.ts (attachments/logs/comments/docs/artifacts)
types/messages.ts types.ts
merger-diff-volume-gate helpers merger.ts

Public paths stay stable via re-exports.

LOC

  • legacy.ts ~10561 → ~10269
  • types.ts ~6998 → ~6937
  • merger.ts ~11223 → ~11208

Test plan

  • core/engine/dashboard typecheck (app)
  • eslint on peeled modules
  • api-tasks + memory/agent-log focused tests
  • CI merge gate

Summary by CodeRabbit

  • New Features
    • Added dashboard API endpoints for global and project-scoped settings, PI configuration, notification testing, and PI package install/reinstall.
    • Added task content APIs covering attachments, agent logs, session files, task comments, task documents, artifacts, and project markdown files.
    • Added structured messaging contracts and participant/message normalization.
    • Added diff-volume gate settings resolution and formatted findings output.
  • Refactor
    • Organized messaging and dashboard API surface into dedicated modules via re-exports.
    • Removed a deprecated verification-output alias.

Behavior-preserving package organization after #2252:
- app/api/global-and-pi-settings.ts and task-content.ts from legacy.ts
- types/messages.ts (ParticipantType + Message contracts)
- merger-diff-volume-gate: resolveDiffVolumeGateSettings + formatFindings
Ratchet legacy/types/merger line-count ceilings downward.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 43338d10-d83e-41b5-811c-478062d86007

📥 Commits

Reviewing files that changed from the base of the PR and between 776e90b and 49a3fd9.

📒 Files selected for processing (3)
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/legacy.ts
  • packages/dashboard/app/api/task-content.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/task-content.ts

📝 Walkthrough

Walkthrough

The PR modularizes core message contracts, adds dashboard clients for settings and task content, preserves legacy API exports, and extracts diff-volume gate utilities from the merger module.

Changes

Core message contracts

Layer / File(s) Summary
Message contract module
packages/core/src/types/messages.ts
Defines participant normalization, message metadata, persistence, creation, and filtering contracts.
Message contract re-exports
packages/core/src/types.ts
Keeps existing message exports available through the core types barrel.

Dashboard API modules

Layer / File(s) Summary
Settings and PI API clients
packages/dashboard/app/api/global-and-pi-settings.ts
Adds typed helpers for settings, PI extensions, notifications, PI configuration, and package operations.
Task-content API clients
packages/dashboard/app/api/task-content.ts
Adds typed attachment, log, comment, document, artifact, and markdown-file API helpers.
Legacy API compatibility
packages/dashboard/app/api/legacy.ts
Re-exports the extracted APIs and preserves legacy artifact type access and function names.

Engine diff-volume utilities

Layer / File(s) Summary
Diff-volume gate utilities
packages/engine/src/merger-diff-volume-gate.ts
Defines normalized gate settings and formatted diff-volume findings.
Merger utility wiring
packages/engine/src/merger.ts
Re-exports the extracted utilities, removes local implementations and the deprecated alias.
Line-count baselines
scripts/line-count-baseline.json
Updates stored baselines for the reorganized files.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • Runfusion/Fusion#2139: Both changes modularize message exports from packages/core/src/types.ts into dedicated type modules.

Suggested reviewers: automata-intelligentsia, plarson

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the refactor, but it is too generic to convey the main code changes in this PR. Use a more specific title such as "refactor package APIs: move settings, task content, messages, and merger helpers".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/code-organization-wave9

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 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reorganizes several large package modules while preserving their public paths. The main changes are:

  • Messaging contracts moved into a dedicated core module.
  • Global settings and task-content APIs moved out of the dashboard legacy module.
  • Diff-volume gate helpers moved into their focused engine module.
  • Legacy exports retained for existing callers.

Confidence Score: 5/5

This looks safe to merge.

  • The missing legacy markdown options type is now re-exported.
  • No blocking issue remains in the updated compatibility surface.

Important Files Changed

Filename Overview
packages/core/src/types.ts Re-exports messaging values and types from the new focused module.
packages/core/src/types/messages.ts Contains the extracted messaging contracts and normalization helpers.
packages/dashboard/app/api/legacy.ts Re-exports the extracted settings and task-content APIs, including the restored markdown options type.
packages/dashboard/app/api/global-and-pi-settings.ts Contains the extracted global settings, notification, extension, and Pi package APIs.
packages/dashboard/app/api/task-content.ts Contains the extracted attachment, log, comment, document, and artifact APIs.
packages/engine/src/merger-diff-volume-gate.ts Now owns diff-volume settings resolution and finding formatting.
packages/engine/src/merger.ts Imports and re-exports the extracted diff-volume helpers.

Reviews (3): Last reviewed commit: "Merge origin/main into feature/code-orga..." | Re-trigger Greptile

Comment thread packages/dashboard/app/api/legacy.ts

@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: 3

🤖 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/dashboard/app/api/global-and-pi-settings.ts`:
- Around line 53-62: Update testNotification so the explicitly selected
providerId is applied after spreading config in the request body. This prevents
config.providerId from overriding the function argument while preserving all
other configuration fields.

In `@packages/dashboard/app/api/task-content.ts`:
- Around line 34-36: Update deleteAttachment and the affected key-based API
methods in packages/dashboard/app/api/task-content.ts at lines 34-36, 129-131,
133-135, 254-269, and 271-275 to wrap each user-defined filename or key path
segment with encodeURIComponent before constructing the URL; apply the same
encoding consistently at all five sites.
- Around line 29-31: Update the upload response handling around the JSON parsing
in the task-content request to safely handle non-JSON error responses: catch
parse failures, preserve the HTTP failure status, and throw an error using the
parsed API message when available or an HTTP-status-based fallback otherwise.
Follow the existing pattern used by fetchAgentLogsWithMeta.
🪄 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: 406e5db1-b6a4-401c-b53b-271c75ce79c4

📥 Commits

Reviewing files that changed from the base of the PR and between 065890c and 776e90b.

📒 Files selected for processing (8)
  • packages/core/src/types.ts
  • packages/core/src/types/messages.ts
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/legacy.ts
  • packages/dashboard/app/api/task-content.ts
  • packages/engine/src/merger-diff-volume-gate.ts
  • packages/engine/src/merger.ts
  • scripts/line-count-baseline.json

Comment thread packages/dashboard/app/api/global-and-pi-settings.ts
Comment thread packages/dashboard/app/api/task-content.ts Outdated
Comment thread packages/dashboard/app/api/task-content.ts
gsxdsm added 2 commits July 17, 2026 17:31
- Re-export FetchProjectMarkdownFilesOptions from legacy API barrel
- Pin providerId last in testNotification so config cannot override it
- Safely parse non-JSON upload error bodies with HTTP status fallback
- encodeURIComponent for attachment filename and document key path segments
Resolve types.ts messaging conflict by keeping the wave9 peel re-exports
and folding main's task-proposal metadata + ephemeral policy into
types/messages.ts. Refresh line-count baseline after main landings.
@gsxdsm
gsxdsm merged commit ca7bc3e into main Jul 18, 2026
7 checks passed
@gsxdsm
gsxdsm deleted the feature/code-organization-wave9 branch July 18, 2026 21:43
gsxdsm added a commit that referenced this pull request Jul 19, 2026
## Summary

Wave 10 of package code organization (plan:
`docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md`),
after #2274.

### Peels

| New module | Parent |
|---|---|
| `types/agents.ts` | `types.ts` (permissions, Agent entity, ratings,
reflections, heartbeat run types) |
| `app/api/missions.ts` | `legacy.ts` (hierarchy, assertions,
validation, autopilot) |
| `app/api/messaging.ts` | `legacy.ts` (mailbox, approvals,
reflections/ratings, budget) |
| `app/api/plugins-and-skills.ts` | `legacy.ts` |
| `app/api/todo.ts` | `legacy.ts` |
| `app/api/insights.ts` | `legacy.ts` |
| `app/api/system-panel.ts` | `legacy.ts` |
| `task-store/workflow-definitions.ts` | rename of `remaining-ops-8` |

Mission interview SSE streams stay in `legacy.ts` until
`createResilientEventSource` is shared.

Public paths stay stable via re-exports.

### LOC

- `types.ts` ~7101 → ~6165
- `legacy.ts` ~10273 → ~8913

### Shims

- `types.ts` → `types/agents.ts` (delete-when: consumers import agents
domain directly)
- `legacy.ts` → peels above (delete-when: dashboard imports domain
modules)
- `remaining-ops-8` → `workflow-definitions` (rename complete)

## Test plan

- [x] `@fusion/core` typecheck
- [x] eslint on peeled dashboard API modules
- [x] `pnpm check:line-count`
- [x] `agent-permissions` + `agent-permission-policy` tests
- [x] `plugin-setup-api` tests
- [ ] CI merge gate

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

* **New Features**
* Added typed dashboard API support for missions, milestones/features,
validation loops, and autopilot.
  * Added insights browsing and management, including run triggering.
* Added messaging/mailboxes and approvals, plus agent reflections,
ratings, and budget controls.
  * Added plugins & skills management and discovery.
  * Added todo lists and items with reordering.
* Added system monitoring controls: rebuilds/restarts, logs, and
research finding promotion.
* **Improvements**
* Centralized agent-related type contracts for safer browser
consumption.
* Enhanced legacy API compatibility and improved AI session deletion
error handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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