Skip to content

refactor(server): keep the settlement service in one module

MacroscopeApp / Macroscope - Effect Service Conventions failed Aug 29, 2026 in 2m 1s

Effect Service Conventions: 1 issue found

  • apps/server/src/orchestration/Layers/ThreadSettlementReactor.test.ts — the reactor implementation was hoisted to the canonical apps/server/src/orchestration/ThreadSettlementReactor.ts, but its test file remains in the legacy Layers/ directory; move it next to the canonical module and update the relative imports.

No other convention violations were found in the changed Effect service code.

Details

Note

Your check run agent prompt is: .macroscope/check-run-agents/effect-service-conventions.md
More information about how Check Run Agents work can be found in our Help Center.

Checked in this run:

  • apps/server/src/orchestration/ThreadSettlementReactor.ts: canonical single-module layout (imports, Context.Service tag with inline interface, make, layer), ThreadSettlementReactor["Service"] used for the inferred shape, all dependencies acquired from the environment (OrchestrationEngine, ProjectionSnapshotQuery, ServerSettingsService, GitManager, PullRequestService, Crypto), no ManagedRuntime/runPromise, subpath namespace imports for effect/* and local service modules, named import for the pure forkParked helper and @t3tools/contracts. No issues.
  • Old Services/ThreadSettlementReactor.ts and Layers/ThreadSettlementReactor.ts are deleted with no compatibility shims; consumers (server.ts, Layers/OrchestrationReactor.ts, integration harness, tests) point at the canonical path.
  • Layer.succeed(ThreadSettlementReactor, { ... }) occurrences in OrchestrationEngineHarness.integration.ts and Layers/OrchestrationReactor.test.ts are legitimate test seams.
  • apps/server/src/git/GitManager.ts branchPullRequest: GitManagerError carries bounded structural context (operation, cwd, static detail); no cause/message stringification introduced.
  • apps/server/src/orchestration/ThreadSettlementPolicy.ts is pure helper code with no service or error definitions.
  • Client-side changes (web/mobile/desktop) contain no Effect service definitions or new runtime boundaries.

🔍 Agent activity — 8 tool calls

💭 Good, it looks like the split layout issue was addressed since the diff now shows a single canonical file at ThreadSettlementReactor.ts. I want to open the actual file to check it follows conventions.

1. browse_code — apps/server/src/orchestration/ThreadSettlementReactor.ts

2. browse_code — apps/server/src/orchestration/**/ThreadSettlement*

💭 I notice the test file sits in the legacy Layers/ directory while the actual implementation lives directly under orchestration/, which is a file layout mismatch I should flag per the convention for reconciling domain/Services and domain/Layers files. Now I'm checking import styles throughout the file — package imports, service namespace imports, and helper imports all look correctly formatted against convention. Looking at the other diff files: GitManager's new branchPullRequest method constructs its error consistently with existing patterns, the ProviderCommandReactor dispatch logic looks fine, and the test harness setup with Layer.mock and Layer.succeed appears sound. I'm also checking whether the new tests are justified by actual new behavior rather than just padding a refactor, and reviewing whether the Effect.die call using a plain Error should instead follow the tagged error class convention used elsewhere. The dying-then-catching pattern here is essentially using a defect as control flow to skip processing when a linked PR project is missing, then logging a warning — which is a bit unusual but not clearly against the stated conventions, though the opaque error message lacking the projectId context is worth noting as a minor improvement opportunity. I also notice an inconsistency: when project itself is undefined, the code returns null, but when the linked project is undefined, it dies instead — that's more a correctness nit than a convention violation. I want to check if Effect.die with a plain Error shows up elsewhere in the codebase for context, and I should also verify the old ThreadSettlementReactor files are truly gone from both Services and Layers directories. I'm going to check whether the test file was already at Layers/ back in commit 142b4e3, or if the implementation moved without the corresponding test — let me diff that commit against head to see.

3. git_tools — 142b4e3..2bff0bf

4. git_tools — Effect.die(new Error

💭 Using Effect.die with a plain Error for invariant violations matches existing production code, so that's not something to flag. I'm now checking whether the test file's location follows the convention of hoisting merged service/layer files, since it should be colocated with the newly moved module. The reactor test sitting in the Layers directory looks like a leftover from the prior move, and since this module is new to the PR, its test file should really live at the canonical location — a small but legitimate finding, and it's within scope since it matches the include patterns. I'm scanning the other touched server files for any Layer.succeed, ManagedRuntime, or runPromise additions, confirming the server.ts change is fine, the test files use acceptable seams with Layer.succeed, and ThreadSettlementPolicy.ts stays pure with no services. Now I'm checking GitManager.ts's error handling additions to see if they follow the established error conventions. Verifying that GitManagerError's cause field is optional, and confirming the ws.ts changes don't touch service conventions. Now checking whether the new reactor's start function properly returns an effect scoped correctly and uses forkParked as expected, and I want to check whether the makeDrainableWorker import is a plain helper factory rather than a full service module with tag/make/layer structure.

5. git_tools — makeDrainableWorker

6. git_tools — apps/server/src/orchestration/Layers/ThreadSettlementReactor.test.ts

💭 It looks like the commit that moved the settlement service to its canonical path left the test file behind in Layers/. I want to check the name_status output for that commit to confirm this.

7. git_tools — 2bff0bf

💭 That test file left in Layers/ is a leftover from the service that's since been hoisted elsewhere. Since it's newly added in the diff, I can comment at line 1 suggesting it be moved to apps/server/src/orchestration/ and its relative imports updated accordingly. I'm scanning the test file's imports to give precise guidance—paths like ../../git/GitManager.ts, ../../pullRequest/PullRequestService.ts, ../../serverActivation.ts, ../../serverSettings.ts, ../Errors.ts, and the Services/ThreadSettlementReactor imports would all need their relative depth adjusted if the file moves. Nothing else stands out as a convention issue. The main target for flagging is really aliased layer imports, not named tag imports—those are common practice elsewhere in the codebase, so I'll leave that alone. That narrows things to just the misplaced test file, a minor but real layout leftover, and I'm inclined to note it without necessarily failing the whole check over it. I'm weighing whether this minor leftover test file warrants a failing state versus neutral, but since the check defaults to failure when findings exist, I'll set it to failure. It's a small, easily fixable layout leftover from a migration where the implementation was hoisted but the colocated test wasn't moved alongside it. I'll keep the comment body concise, and skip including a diff since the file was moved, so a unified diff isn't feasible here.

8. modify_pr — Reviewed the new ThreadSettlementReactor service and the touched call sites against the Effect service conventions. The hoist to apps/server/src/orchestration/ThreadSettlementReactor.ts (inline Context.Service interface, exported make, exported layer, ThreadSettlementReactor["Service"] references, namespaced effect/* and local service imports) looks correct, and the old Services//Layers/ modules are gone. One leftover from that migration: the reactor's test file still lives in orchestration/Layers/.


Agent Credits: 110 credits

Token usage: 12 uncached input · 473,941 cache-read input · 101,606 cache-write input · 6,987 output
Agent Credits may also include non-token charges from external tools such as web research.