Skip to content

refactor: split the root main.go into topical files (pure declaration moves) - #745

Merged
dmmdea merged 4 commits into
mainfrom
refactor/split-root-main
Oct 30, 2026
Merged

dmmdea merged 4 commits into
mainfrom
refactor/split-root-main

Conversation

@dmmdea

@dmmdea dmmdea commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Intent

Desloppify backlog ("god files"): the root main.go was 5359 lines. It is split into topical files of package main by pure declaration moves; identical behaviour.

Scope

The root package: main.go plus 11 new files (cli_support.go, task_cmd.go, generate_image_cmd.go, generate_video_cmd.go, generate_audio_cmd.go, delegate_cmd.go, fleet_serve_cmd.go, doctor_cmd.go, report_cmd.go, learn_cmd.go, confhead_cmd.go), eleven root tests that read main.go by name re-keyed to the split set, six docs/systems pointer updates, the fragment. No declaration renamed or edited.

What changed

main.go 5359 -> 1196 (keeps func main, usage/usageTo, hoistGlobalConfig, the subcommand dispatch, const version). Second commit: main_door_test.go holds the shared 12-file list (mainSplitFiles) and two helpers; TestEveryCLIRequestCarriesADoor now sees all 22 core.Request literals (before the split it saw only the 1 in main.go after the move, so the lint had gone blind); the fleet-serve, mcp-startup, display-watch, lease-standing, research-quotes and delegate-intake wiring tests parse the 12 files as one declaration set.

 30 files changed, 5014 insertions(+), 4802 deletions(-)

The real run and its output

Declaration census (go/ast hash of every top-level declaration, comments stripped) before and after: 1002 declarations, diff empty, run by the builder and again by an independent verifier in a throwaway worktree of origin/main. go build ./... ok; go vet . ok; gofmt clean on every new file; the changelog/version/pins/deletion lints ok; every re-keyed test PASS by name; TestRecipeAuditIsRegisteredInMain, TestTraceCorpusIsRegisteredInMain, TestVersionSourcesAgree, TestIngressGuardNoteIsPrintedWhereTheOperatorLooks and TestNoNewBareHTTPClient checked and PASS unchanged. CI runs the whole package.

Blast radius

None at runtime; file layout of the root package.

Risk

Low. Tier: no_review (ordinary change (consequential 0.3, blast 1.82))

Follow-ups (not in this PR)

  • The usage-text and dispatch checks still key on main.go by name; re-key them if those ever move.
  • Comments in doctor_backends.go, gate_cmd.go and ledger_failures.go still say "main.go" for moved code.

🤖 Generated with Claude Code

dmmdea and others added 3 commits October 29, 2026 21:23
Pure declaration moves, no behaviour change. New files: cli_support.go,
task_cmd.go, generate_image_cmd.go, generate_video_cmd.go,
generate_audio_cmd.go, delegate_cmd.go, fleet_serve_cmd.go, doctor_cmd.go,
report_cmd.go, learn_cmd.go, confhead_cmd.go. main.go keeps the entry point
and the functions that source-scanning tests read by file name. The census
tool's before/after output is byte-identical (1002 declarations); the file
paths named in docs/systems follow, and a changes/unreleased fragment is added.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The main.go split moved about 21 of 22 core.Request literals out of main.go, so the door lint went blind. The source-scanning tests now read main.go plus the 11 split files (shared mainSplitFiles list, mainSplitSource and parseMainSplit helpers in main_door_test.go); what each asserts is unchanged.

- TestEveryCLIRequestCarriesADoor: scans every core.Request literal in all 12 files (22 literals), reports file:line.
- TestServeBuildsItsJobStoreThroughNewFleetJobs: text of the 12 files.
- TestFleetServeStartsItsSamplerThroughTheChooser: text of the 12 files (call counts across the set).
- TestFleetServePrintsTheAuthLineOnEveryStart: text of the 12 files.
- TestRunMCPCapturesTheStartupImageBeforeOpeningAnything and the runFleetServe capture pin: funcBody reads the 12 files.
- TestTheCLIVerbsPrepareEachSubtaskOnItsOwnAndSpliceTheRefusals, TestFleetServeStartsAndStopsTheDisplayWatch, TestRunFleetServeAppliesItsNodeIDBeforeOpeningThePipeline, TestRunFleetServePassesTheConfigItReadToTheStartupRefusal, TestFleetServeWiresTheLeaseStanding, TestTheResearchVerbChecksItsQuotesAgainstThePages: parse the 12 files as one declaration set.

Left on main.go by name because the dispatch and usage text stayed there: TestRecipeAuditIsRegisteredInMain, TestTraceCorpusIsRegisteredInMain, TestVersionSourcesAgree. bare_http_client_allowlist_test.go keys no main.go site, so no counts moved.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…kage

The lint built its builders map per file, so cliPinOptions, which moved to a split file of main.go, no longer vouched for the two engine calls that stayed in main.go. Builders are now collected in a first pass over every file and keyed by package directory, then every call is checked.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dmmdea
dmmdea force-pushed the refactor/split-root-main branch from 00a220f to 2050728 Compare October 30, 2026 02:24
The render test that checks the shipped template list reads the --template help sentence from the Go source; that flag moved from main.go to generate_video_cmd.go in the split. The test now reads that file; the other five places it checks are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dmmdea
dmmdea merged commit 9eac4bc into main Oct 30, 2026
6 checks passed
@dmmdea
dmmdea deleted the refactor/split-root-main branch October 30, 2026 02:49
@dmmdea dmmdea mentioned this pull request Oct 30, 2026
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