Skip to content

refactor: move package into emulator/ subdirectory (clean root) - #310

Merged
scttfrdmn merged 1 commit into
mainfrom
refactor/move-pkg-to-emulator
Jun 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
refactor/move-pkg-to-emulator

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Part A of 3 (reorg → README → docs site). Layout-only change; no runtime behaviour change.

What

Moves all 286 package substrate files (173 source + 113 test) + the embedded ui.html from the repo root into emulator/, leaving a clean professional root:

cmd/  emulator/  docs/  examples/  deploy/  configs/  python/  test/  .github/
+ go.mod go.sum Makefile Dockerfile docker-compose.yml *.md LICENSE substrate.yaml.example
  • Package renamed substrate → emulator (matches directory; idiomatic).
  • Public Go import is now github.com/scttfrdmn/substrate/emulator (symbols emulator.X).
  • go install …/cmd/substrate install path and the HTTP wire contract are unchanged.

Why it's safe

The single-package-at-root layout was a constraint of being a Go library, not a choice — but no external project Go-imports the package (lagotto, queuezero, spawn, etc. all use the running emulator over HTTP). So the import-path change has zero external blast radius; only in-repo importers needed updating:

  • cmd/substrate, examples/*, test/e2e (import path; kept the substrate alias to minimize churn)
  • the generated-fixture template string in replay_export.go
  • Makefile ldflags → …/emulator.Version

All 286 moves are tracked by git as renames (history preserved).

Not doing

No multi-package split — emulator stays one package in one directory (per project convention + solo-consumer reality). No wire/behaviour changes.

Verification

make build / make test (race) / make lint / go vet ./... / make e2e all green. go:embed ui.html confirmed still serving GET /ui (200). Grep confirms zero bare-root imports and zero package substrate clauses remain.

Relocate all 286 package files (173 source + 113 test) plus the embedded
ui.html from the repo root into emulator/, leaving a clean professional root
(cmd/ emulator/ docs/ examples/ deploy/ configs/ python/ test/ + project files).

- Rename package substrate → emulator (and substrate_test → emulator_test).
- Public Go import path is now github.com/scttfrdmn/substrate/emulator with
  symbols emulator.X. cmd/substrate install path and the HTTP wire contract are
  unchanged; no runtime behaviour change.
- Update the only in-repo Go importers: cmd/substrate, examples/*, test/e2e
  (import path; keep substrate alias), and the generated-fixture template in
  replay_export.go. Makefile ldflags now set …/emulator.Version.
- Clean stray root artifacts (coverage*, binaries, *.db); gitignore coverage_main.out.

No external consumers Go-import the package (all use the HTTP server), so the
import-path change has zero external blast radius.

make build/test(race)/lint/vet/e2e all green; go:embed ui.html still serves /ui.
@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 6e95eb7 into main Jun 3, 2026
10 checks passed
@scttfrdmn
scttfrdmn deleted the refactor/move-pkg-to-emulator branch June 3, 2026 23:13
scttfrdmn added a commit that referenced this pull request Jun 10, 2026
…327)

The emulator/ reorg (#310) renamed the package clause substrate -> emulator but
left five files' leading doc comments saying 'Package substrate' / 'Package
substrate_test', which Go convention flags as a name mismatch. Update the comment
lines (doc.go, doc_plugins.go, sns_types.go, coverage_test.go,
v030_coverage_test.go); 'Substrate' as the product name in prose is unchanged.

Doc-comment only; no code or behaviour change.
scttfrdmn added a commit that referenced this pull request Jul 31, 2026
…FN types (#387, #388, #389)

EC2 Fleet (#387)
----------------
Add CreateFleet, DescribeFleets, and DeleteFleets. Instances launch through
the same runInstances path as a direct launch, so they are visible to
DescribeInstances with subnet/security-group validation, placement groups, and
launch-time tag propagation intact.

LaunchTemplateConfigs[] x Overrides[] flatten into ordered capacity pools
(sorted by Priority under a prioritized allocation strategy) and are fulfilled
round-robin, so fleetInstanceSet carries one item per pool each with a *list*
of instance IDs — the shape callers most often flatten incorrectly. An instant
fleet returns instances and errors synchronously; request/maintain fleets
return only the fleet ID, matching AWS.

Partial fulfillment is seedable via POST/DELETE /v1/ec2/fleet-shortfall, keyed
by launch-template ID/name or "*". A fleet that asks for 12 and receives 8
still returns a fleet ID and echoes the *request* in TotalTargetCapacity, so
this is where callers most often go wrong — and it is rare and hard to trigger
against real AWS. Seeding makes it instant and reproducible; the shortfall is
reported per pool in errorSet with a configurable code and lifecycle.

CFN wiring (#388)
-----------------
Four resource types had working API handlers but fell through to
deployGenericStub, so a stack deployed "successfully" while the resource was
never created:

- AWS::EC2::LaunchTemplate — Ref is the real lt-… ID, usable by CreateFleet
- AWS::IAM::InstanceProfile — creates the profile and attaches each Roles entry
- AWS::EC2::SecurityGroupIngress / ::SecurityGroupEgress — standalone rules,
  resolving Source/DestinationSecurityGroupId through Ref/GetAtt

AWS::EC2::SecurityGroup now also authorizes its inline SecurityGroupIngress/
Egress rules, which were parsed but never applied — so previously *neither*
spelling produced rules, and DescribeSecurityGroups reported an empty group
regardless of how the template was written.

This needed a type change: EC2IPPermission had no way to express a rule whose
source is another security group (a self-referencing rule has no CIDR at all).
Added UserIDGroupPairs, parsing of IpPermissions.N.Groups.M.GroupId, and
groups>item rendering in DescribeSecurityGroups. While there, the rule parser
now reads every IpPermissions.N entry and all of each entry's IpRanges.M rather
than only the first of each, and revoke matches on source as well as ports.

AWS::EC2::Instance passes through IamInstanceProfile, KeyName, and
SecurityGroupIds — the profile reference is only resolvable now that
AWS::IAM::InstanceProfile creates a real profile.

The generic-stub warning reports whether the type's service plugin is loaded;
it previously read as "substrate doesn't model this", misleading when the
actions exist and only the wiring is missing.

AWS::EC2::NetworkInterface is left stubbed — it needs a CreateNetworkInterface
handler first, which #388 notes belongs in its own issue.

Docs (#389)
-----------
emulator/doc.go claimed 39 plugins and 23 S3 operations; the registry has 63
and s3_plugin.go 53. The counts that #364 made generated had drifted here, so
doc.go now points at the generated docs/services.md rather than repeating a
number that can drift. CLAUDE.md's key-files table pointed at four paths that
moved to emulator/ in the #310 reorg and pinned a now-stale next version.

All wire shapes were verified against the AWS API reference: the XML elements
are fleetId/fleetInstanceSet/errorSet (not the boto3-facing names), and source
security groups use IpPermissions.N.Groups.M.GroupId.

Closes #387
Closes #388
Closes #389
scttfrdmn added a commit that referenced this pull request Aug 1, 2026
…FN types (#387, #388, #389)

EC2 Fleet (#387)
----------------
Add CreateFleet, DescribeFleets, and DeleteFleets. Instances launch through
the same runInstances path as a direct launch, so they are visible to
DescribeInstances with subnet/security-group validation, placement groups, and
launch-time tag propagation intact.

LaunchTemplateConfigs[] x Overrides[] flatten into ordered capacity pools
(sorted by Priority under a prioritized allocation strategy) and are fulfilled
round-robin, so fleetInstanceSet carries one item per pool each with a *list*
of instance IDs — the shape callers most often flatten incorrectly. An instant
fleet returns instances and errors synchronously; request/maintain fleets
return only the fleet ID, matching AWS.

Partial fulfillment is seedable via POST/DELETE /v1/ec2/fleet-shortfall, keyed
by launch-template ID/name or "*". A fleet that asks for 12 and receives 8
still returns a fleet ID and echoes the *request* in TotalTargetCapacity, so
this is where callers most often go wrong — and it is rare and hard to trigger
against real AWS. Seeding makes it instant and reproducible; the shortfall is
reported per pool in errorSet with a configurable code and lifecycle.

CFN wiring (#388)
-----------------
Four resource types had working API handlers but fell through to
deployGenericStub, so a stack deployed "successfully" while the resource was
never created:

- AWS::EC2::LaunchTemplate — Ref is the real lt-… ID, usable by CreateFleet
- AWS::IAM::InstanceProfile — creates the profile and attaches each Roles entry
- AWS::EC2::SecurityGroupIngress / ::SecurityGroupEgress — standalone rules,
  resolving Source/DestinationSecurityGroupId through Ref/GetAtt

AWS::EC2::SecurityGroup now also authorizes its inline SecurityGroupIngress/
Egress rules, which were parsed but never applied — so previously *neither*
spelling produced rules, and DescribeSecurityGroups reported an empty group
regardless of how the template was written.

This needed a type change: EC2IPPermission had no way to express a rule whose
source is another security group (a self-referencing rule has no CIDR at all).
Added UserIDGroupPairs, parsing of IpPermissions.N.Groups.M.GroupId, and
groups>item rendering in DescribeSecurityGroups. While there, the rule parser
now reads every IpPermissions.N entry and all of each entry's IpRanges.M rather
than only the first of each, and revoke matches on source as well as ports.

AWS::EC2::Instance passes through IamInstanceProfile, KeyName, and
SecurityGroupIds — the profile reference is only resolvable now that
AWS::IAM::InstanceProfile creates a real profile.

The generic-stub warning reports whether the type's service plugin is loaded;
it previously read as "substrate doesn't model this", misleading when the
actions exist and only the wiring is missing.

AWS::EC2::NetworkInterface is left stubbed — it needs a CreateNetworkInterface
handler first, which #388 notes belongs in its own issue.

Docs (#389)
-----------
emulator/doc.go claimed 39 plugins and 23 S3 operations; the registry has 63
and s3_plugin.go 53. The counts that #364 made generated had drifted here, so
doc.go now points at the generated docs/services.md rather than repeating a
number that can drift. CLAUDE.md's key-files table pointed at four paths that
moved to emulator/ in the #310 reorg and pinned a now-stale next version.

All wire shapes were verified against the AWS API reference: the XML elements
are fleetId/fleetInstanceSet/errorSet (not the boto3-facing names), and source
security groups use IpPermissions.N.Groups.M.GroupId.

Closes #387
Closes #388
Closes #389
scttfrdmn added a commit that referenced this pull request Aug 1, 2026
…FN types (#387, #388, #389) (#390)

EC2 Fleet (#387)
----------------
Add CreateFleet, DescribeFleets, and DeleteFleets. Instances launch through
the same runInstances path as a direct launch, so they are visible to
DescribeInstances with subnet/security-group validation, placement groups, and
launch-time tag propagation intact.

LaunchTemplateConfigs[] x Overrides[] flatten into ordered capacity pools
(sorted by Priority under a prioritized allocation strategy) and are fulfilled
round-robin, so fleetInstanceSet carries one item per pool each with a *list*
of instance IDs — the shape callers most often flatten incorrectly. An instant
fleet returns instances and errors synchronously; request/maintain fleets
return only the fleet ID, matching AWS.

Partial fulfillment is seedable via POST/DELETE /v1/ec2/fleet-shortfall, keyed
by launch-template ID/name or "*". A fleet that asks for 12 and receives 8
still returns a fleet ID and echoes the *request* in TotalTargetCapacity, so
this is where callers most often go wrong — and it is rare and hard to trigger
against real AWS. Seeding makes it instant and reproducible; the shortfall is
reported per pool in errorSet with a configurable code and lifecycle.

CFN wiring (#388)
-----------------
Four resource types had working API handlers but fell through to
deployGenericStub, so a stack deployed "successfully" while the resource was
never created:

- AWS::EC2::LaunchTemplate — Ref is the real lt-… ID, usable by CreateFleet
- AWS::IAM::InstanceProfile — creates the profile and attaches each Roles entry
- AWS::EC2::SecurityGroupIngress / ::SecurityGroupEgress — standalone rules,
  resolving Source/DestinationSecurityGroupId through Ref/GetAtt

AWS::EC2::SecurityGroup now also authorizes its inline SecurityGroupIngress/
Egress rules, which were parsed but never applied — so previously *neither*
spelling produced rules, and DescribeSecurityGroups reported an empty group
regardless of how the template was written.

This needed a type change: EC2IPPermission had no way to express a rule whose
source is another security group (a self-referencing rule has no CIDR at all).
Added UserIDGroupPairs, parsing of IpPermissions.N.Groups.M.GroupId, and
groups>item rendering in DescribeSecurityGroups. While there, the rule parser
now reads every IpPermissions.N entry and all of each entry's IpRanges.M rather
than only the first of each, and revoke matches on source as well as ports.

AWS::EC2::Instance passes through IamInstanceProfile, KeyName, and
SecurityGroupIds — the profile reference is only resolvable now that
AWS::IAM::InstanceProfile creates a real profile.

The generic-stub warning reports whether the type's service plugin is loaded;
it previously read as "substrate doesn't model this", misleading when the
actions exist and only the wiring is missing.

AWS::EC2::NetworkInterface is left stubbed — it needs a CreateNetworkInterface
handler first, which #388 notes belongs in its own issue.

Docs (#389)
-----------
emulator/doc.go claimed 39 plugins and 23 S3 operations; the registry has 63
and s3_plugin.go 53. The counts that #364 made generated had drifted here, so
doc.go now points at the generated docs/services.md rather than repeating a
number that can drift. CLAUDE.md's key-files table pointed at four paths that
moved to emulator/ in the #310 reorg and pinned a now-stale next version.

All wire shapes were verified against the AWS API reference: the XML elements
are fleetId/fleetInstanceSet/errorSet (not the boto3-facing names), and source
security groups use IpPermissions.N.Groups.M.GroupId.

Closes #387
Closes #388
Closes #389
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