refactor: decompose the three largest TypeScript god files into single-responsibility modules#1183
Conversation
…ules Decompose the 1654-line RelaycastMessagingClient file into single- responsibility siblings behind an unchanged public surface: - relaycast-translate.ts: pure wire<->domain translation and record readers - relaycast-placement.ts: RelayPlacementError, placement payload helpers - relaycast-client.ts: structural relaycast adapter types, options, factory relaycast.ts (now 1126 lines) keeps the stateful client and re-exports RelayPlacementError and RelaycastMessagingOptions so consumers are unaffected. Pure move: no behavior change. Verified with build, full test suite (959 pass), and an SDK public-surface smoke test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPFXDfGA74hrgEBah6KTT2
…modules Drop the export keyword on readRecord/readNumber/readBoolean/readStringArray/ readMention in relaycast-translate.ts — they are only used within the module. asRecord, readStr, and definedOptions stay exported since relaycast.ts and relaycast-client.ts consume them. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPFXDfGA74hrgEBah6KTT2
…rocess Decompose the 1199-line HarnessDriverClient file into two single-responsibility siblings behind an unchanged public surface (client.ts now 931 lines): - spawn-request.ts: spawn input -> broker /api/spawn request-body builders and the beforeAgentSpawn patch applier - broker-process.ts: managed broker child-process lifecycle (API-URL wait, stdio drain, recent-output buffering, startup-error formatting, shutdown) BrokerExitInfo moved into broker-process.ts and is re-exported from client.ts so the package barrel surface is unchanged. Pure move: no behavior change. Verified with build, full test suite (959 pass), and a harness-driver smoke test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPFXDfGA74hrgEBah6KTT2
Move the pure, side-effect-free workflow-path parsers out of workflows.ts (1129 -> 893 lines) into a focused workflow-paths.ts module: the YAML path parser, the TypeScript literal scanner, the parseWorkflowPaths dispatcher, and inferWorkflowFileType / shouldSyncCodeByDefault. Validation (validateYamlWorkflow / validateTypeScriptWorkflow, which shells out), the runtime PATH_NAME_RE guard, GitHub-remote helpers, and the cloud execution/API/S3 code stay in workflows.ts, which re-exports the three parser entry points so the package barrel and tests still import them from './workflows.js'. Pure move: no behavior change. Verified with build, full test suite (959 pass), and a parser smoke test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPFXDfGA74hrgEBah6KTT2
Move the trajectory from active/ to completed/ after wrapping up the SDK/ harness-driver/cloud god-file decompositions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPFXDfGA74hrgEBah6KTT2
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThree large TypeScript modules ( ChangesGod-file decomposition across cloud, harness-driver, and sdk packages
Agent trajectory artifacts
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
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/cloud/src/workflow-paths.ts`:
- Around line 126-201: The functions extractPathArrayLiterals,
extractObjectLiterals, and readStringProperty scan raw source code without
skipping comments, which causes commented-out paths to be incorrectly extracted
as active workflow paths. Add comment-skipping logic to the scanner by creating
a helper function that identifies and skips single-line comments (starting with
//) and block comments (/* ... */), then integrate this helper into the
extraction functions propertyPattern and methodPattern execution loops in
extractPathArrayLiterals, and in the character-by-character scanning loops of
extractObjectLiterals and readStringProperty to ensure commented content is
never parsed as active declarations.
- Around line 52-67: The parser in the switch statement handling the key-value
pairs does not properly process YAML block scalars (indicated by | or >) for the
pushPrBody field. When a block scalar indicator like pushPrBody: | is
encountered, the code currently stores only the marker character instead of
collecting the subsequent indented lines. Modify the handling for the pushPrBody
case to detect when the value starts with | or > (block scalar indicators) and
if so, collect all following indented lines as the actual multi-line content
rather than storing just the marker. Apply the same fix to any other cases
mentioned at lines 117-119 that also handle multi-line content.
In `@packages/harness-driver/src/broker-process.ts`:
- Around line 176-189: The fast-path check in the waitForExit function only
checks if child.exitCode is not null to determine if the process has already
exited, but this misses processes that exited via signal where exitCode is null
and signalCode is not null. Update the condition to also check for
child.signalCode !== null so that processes that have already exited via signal
are detected immediately and the function can resolve without waiting for the
timeout, avoiding unnecessary SIGKILL attempts and shutdown latency.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 46dc6c62-0bb3-4a0e-9463-a9862e05be94
📒 Files selected for processing (12)
.agentworkforce/trajectories/completed/2026-06/traj_q768ixcuyzh7.trace.json.agentworkforce/trajectories/completed/2026-06/traj_q768ixcuyzh7/summary.md.agentworkforce/trajectories/completed/2026-06/traj_q768ixcuyzh7/trajectory.jsonpackages/cloud/src/workflow-paths.tspackages/cloud/src/workflows.tspackages/harness-driver/src/broker-process.tspackages/harness-driver/src/client.tspackages/harness-driver/src/spawn-request.tspackages/sdk/src/messaging/relaycast-client.tspackages/sdk/src/messaging/relaycast-placement.tspackages/sdk/src/messaging/relaycast-translate.tspackages/sdk/src/messaging/relaycast.ts
- workflow-paths: parse YAML block scalars (`pushPrBody: |`/`>`) instead of storing just the marker, so multi-line PR bodies survive parsing. - workflow-paths: strip TS comments before the literal scanner so commented-out `paths` declarations are no longer extracted and synced. - broker-process: in waitForExit, treat a signal-killed child (exitCode null, signalCode set) as already exited to avoid a redundant SIGKILL/timeout wait. Adds parser tests for block scalars, folded scalars, and commented-out paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FtB14k7pSUoKwd5SgUj2Pc
Summary
Continues the god-file decomposition pattern (prior
e7fd375did the CLI) on the three largest TypeScript files — the system's most central client/orchestration surfaces. Each change is a behavior-preserving pure move behind an unchanged public API.sdk/messaging/relaycast.tsrelaycast-translate.ts,relaycast-placement.ts,relaycast-client.tsharness-driver/client.tsspawn-request.ts,broker-process.tscloud/workflows.tsworkflow-paths.tsThe common thread: separate pure logic (wire↔domain translation, spawn-request shaping, workflow-path parsing) from the stateful/IO code (messaging client, broker-process client, cloud S3/API orchestrator). Public surfaces are preserved via re-exports, so consumers and tests are unaffected.
Per-file detail
relaycast.ts→relaycast-translate.ts(pure wire↔domain translation + record readers),relaycast-placement.ts(RelayPlacementError, placement payload helpers),relaycast-client.ts(structural relaycast adapter types, options,createRelaycastClient). Re-exportsRelayPlacementErrorandRelaycastMessagingOptions. A follow-up commit also unexports the translate readers that don't cross a module boundary (review feedback).harness-driver/client.ts→spawn-request.ts(/api/spawnbody builders + patch applier),broker-process.ts(managed broker child-process lifecycle: API-URL wait, stdio drain, recent-output buffering, startup-error formatting, shutdown).BrokerExitInfomoved and re-exported so the package barrel is unchanged.cloud/workflows.ts→workflow-paths.ts(YAML path parser + TS literal scanner +parseWorkflowPaths/inferWorkflowFileType/shouldSyncCodeByDefault). Validation (which shells out), the runtimePATH_NAME_REguard, GitHub-remote helpers, and all execution/API/S3 code stay behind; the three parser entry points are re-exported so the barrel and tests still import from./workflows.js.Verification (every step)
npm run build:coregreen, 0 TS errors.vitest run— 959 passed / 5 skipped, identical to baseline throughout.agents.list; harness-driverisProcessRunning/buffer-cap/spawn-body builders; cloud YAML+TS path parsing + re-export identity).Notes
translate.tsrecord readers withnormalize.ts's. They have genuine semantic divergence (normalize.readStringcoerces numbers→strings;readRecordclones) — consolidating would be a silent behavior change, not a refactor.CHANGELOG.mdentry: these are internal module reorganizations with no user-visible effect.🤖 Generated with Claude Code
Generated by Claude Code