Skip to content

refactor(discussion): manage flat emulator package growth (file grouping, E2E split, maybe sub-packages) #371

Open

Description

@scttfrdmn

Non-urgent maintainability observation from the review. The emulator/ package is large and flat (core, plugins, CFN/Betty, pricing, faults, eventstore, tests in one namespace). Not a current defect, but navigation/ownership cost grows with plugin count.

Options (least invasive first):

  • Reorganize files into documented functional groups within the package; generate the service registry rather than accumulating registration by hand.
  • Split the single large E2E test file by behavior (protocol compat, CFN, replay, faults, state isolation, cost).
  • Only if warranted later: sub-packages (core/, controlplane/, services/<svc>/, cloudformation/, …) — requires the "sub-package needs an issue discussion first" rule per CLAUDE.md.

Discussion issue — no code until a direction is agreed. Part of v0.76.0 (stretch).

Activity

  1. added this to the v0.76.0 milestone on Jul 26, 2026
  2. scttfrdmn commented on Jul 26, 2026

    @scttfrdmn
    OwnerAuthor

    Grounding (current state)

    Assessment

    The flat package is a navigability/ownership cost, not a correctness problem. Two forces argue against an aggressive split right now:

    1. CLAUDE.md rule: sub-packages need an issue discussion first (this issue), and the single-package layout is a deliberate choice — the recent refactor: move package into emulator/ subdirectory (clean root) #310 rename kept everything in one package emulator.
    2. Blast radius: moving 174 files into sub-packages would touch nearly every symbol reference and every emulator_test file, produce a huge diff, and risk churn for months of git blame — for a maintainability gain, not a functional one.

    Recommendation (least-invasive first)

    • Now / cheap: adopt a file-naming convention as the de-facto grouping (already largely true: {service}_plugin.go + {service}_plugin_test.go, betty_*.go for CFN, *_control.go for seed endpoints). Document it in the contributor guide (added in docs: contributor guide (how to add a service plugin) + compatibility/fidelity policy #368) so the flat layout stays legible. The gen-service-reference generator (docs: generate service reference (and counts) from the plugin registry + CI drift guard #364) already removes the biggest ownership hazard — undocumented drift.
    • When a real pain point appears: split tests before source — e.g. group the largest plugin test files, or split any future large E2E file by behaviour. Tests move with zero API impact.
    • Defer sub-packages (core/, services/<svc>/, cloudformation/, …) until there's a concrete trigger (a genuine circular-dependency problem, a second consumer needing a subset, or a plugin count that makes the flat dir unworkable). Revisit then with a dedicated migration issue and a codemod, not by hand.

    Proposed disposition

    Close this as "documented, no structural change now": the naming convention + generated reference + contributor guide address the legibility concern at ~1% of the cost of a package split, and the split can be reopened with a concrete trigger. Leaving it open as a standing "revisit if X" marker is also fine — happy to go either way.

  3. scttfrdmn commented on Jul 26, 2026

    @scttfrdmn
    OwnerAuthor

    Disposition: keeping this open as a standing "revisit if" marker. No structural change now — the file-naming convention + registry-generated service reference (#364) + contributor guide (#368) address the legibility concern at a fraction of a package-split's cost. Reconsider sub-packages (core/, services/<svc>/, cloudformation/, …) when a concrete trigger appears: a genuine circular-dependency problem, a second consumer needing a subset of the package, or a plugin count that makes the flat directory unworkable. At that point, reopen with a dedicated migration issue and a codemod rather than a hand edit.

  4. modified the milestones: v0.76.0, v0.77.0 on Jul 26, 2026
  5. scttfrdmn commented on Aug 1, 2026

    @scttfrdmn
    OwnerAuthor

    Standing-marker check-in, since this issue's whole purpose is to be revisited against a trigger rather than acted on.

    The metrics moved but the shape didn't. Since the July assessment (174 non-test / 115 test files, ~136k LOC):

    Jul 26 now
    non-test .go 174 190
    test .go 115 127
    total LOC ~136k ~150k
    largest ec2_plugin.go 4.3k ec2_plugin.go 4.6k

    Growth is ~10% over five releases and it is all in the pattern the disposition predicted — new {service}_*.go and *_control.go files, not new cross-cutting ones. The convention absorbed it: v0.81.0's SQS work landed as sqs_control.go + sqs_consistency_test.go, v0.82.0's Fleet work as ec2_fleet.go. Nothing needed to know where to go.

    None of the three triggers has fired. No circular-dependency problem (the package is flat, so the class doesn't exist yet). No second consumer needing a subset — the downstream projects filing issues (objectfs, spore-host/spawn, parsl-ephemeral-aws) all consume the server over HTTP, not the Go package, so a package split would buy them nothing. And 190 files is larger but not unworkable, since the naming convention makes the directory listing itself the index.

    One weak counter-signal worth recording: ec2_plugin.go is at 4.6k lines and ec2_plugin_test.go at 4.0k, and EC2 keeps attracting work (#387 Fleet, #391 explicit-ID lookups, #412 ImageId validation, #431 open). Fleet went into its own ec2_fleet.go rather than growing the plugin further, which is the test-and-file-level relief the disposition recommends — split files before packages. If EC2 keeps growing, the next step is more ec2_*.go extractions, still with no API impact and no sub-package.

    Still leaving this open as the marker. Nothing here changes the recommendation; recording the numbers so the next check-in has a trend rather than a single data point.

  6. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    Milestone removed (was v0.77.0), and that milestone is now closed. No status change — this remains the standing "revisit if" marker its disposition made it.

    Why the milestone went: v0.77.0 is a phantom version. No such tag was ever cut (tags went v0.76.0 → v0.80.0), its closed issues actually shipped in v0.80.0 and v0.82.0, and per the release rules in CLAUDE.md a version must be strictly greater than the latest tag — so a v0.77.0 release can never exist to carry this. Holding the issue against it implied a target that cannot arrive. Unattached is the honest state for a trigger-driven issue, and nothing about the analysis below changes.

    Standing-marker check-in

    Measured on main at v0.95.0:

    Jul 26 Aug 1 now (Aug 9)
    non-test .go 174 190 216
    test .go 115 127 178
    total LOC ~136k ~150k ~200k
    largest ec2_plugin.go 4.3k ec2_plugin.go 4.6k cfn_deployer.go 5.6k

    Growth accelerated — ~33% LOC in eight days, faster than the ~10%-over-five-releases the last check-in recorded. The shape still holds, but one number changed character.

    ec2_plugin.go is no longer the largest file; cfn_deployer.go is, at 5.6k. That matters more than the raw count, because the two are different kinds of large. ec2_plugin.go is a service plugin, which is exactly the unit the naming convention is built around — it grows by adding operations that belong together, and a reader looking for EC2 behaviour knows where to go. cfn_deployer.go is cross-cutting: it dispatches to every service's resources, and the CFN work of the last few releases (#560 physical names, #581 instance-profile deletion, #501 events) all landed against it or beside it. The disposition's stated trigger is "a genuine circular-dependency problem, a second consumer needing a subset, or a plugin count that makes the flat directory unworkable." A single cross-cutting file becoming the largest unit is not on that list, but it is closer to the spirit of it than another plugin growing would be.

    Not proposing action. Two observations for whoever revisits:

    1. CFN is already de-facto grouped — cfn_deployer.go, cfn_rollback.go, cfn_events.go, cfn_resources_v*.go, cloudformation_plugin.go. The convention absorbed CloudFormation: DescribeStackEvents has no backing event model #501's new file (cfn_events.go) with no ambiguity about where it went, which is the convention working as designed. If a first split is ever taken, this cluster is the obvious candidate precisely because its boundary is already visible in the filenames.
    2. The betty_*.go files named in the July grounding are gone, renamed to cfn_* in refactor: remove the Betty naming, which refers to an unrelated project #549/v0.90.0. So one item in the original assessment has resolved itself, and the CFN cluster reads as a cluster now rather than as an unrelated prefix.
  7. removed this from the v0.77.0 milestone on Aug 9, 2026
  8. scttfrdmn commented on Sep 20, 2026

    @scttfrdmn
    OwnerAuthor

    Left unmilestoned deliberately in the roadmap pass that assigned the other 84 open issues to v0.121.0–v0.127.0.

    This issue is the design discussion itself, not a deliverable: CLAUDE.md requires that the sub-package question be settled in an issue before any package is added, and this is that issue. Giving it a release slot would commit a version to an outcome that has not been chosen yet — flat-with-file-grouping, an E2E split, and real sub-packages are three different amounts of work.

    It gets a milestone once a direction is agreed here. Nothing in v0.121.0–v0.127.0 depends on it; those releases are all behavioural fidelity within the existing layout.

  9. added
    type: chore
    priority: low
    status: needs-design
    on Nov 14, 2026
  10. scttfrdmn commented on Nov 15, 2026

    @scttfrdmn
    OwnerAuthor

    Re-triaged 2026-11-14 and left without a milestone, by decision. This is still the sub-package design discussion that CLAUDE.md requires before any package is added. Nothing scheduled depends on it.

    For when it's picked up, the size today: 68 plugins, 1,098 routed operations, all in emulator/. docs/contributing.md now lists each per-plugin bookkeeping table a new plugin touches, so the cost of the flat layout is easy to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: lowstatus: needs-designtype: chore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions