Skip to content

feat: spawn footprint in the libs/footprint schema, and spawn teardown --plan (#1653) - #1663

Merged
scttfrdmn merged 2 commits into
mainfrom
feat/1653-footprint
Nov 17, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
feat/1653-footprint

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1653. Part of the leave-no-trace epic spore-host/spore-host#752.

What changes

spawn footprint -o json now emits the shared libs/footprint Report (schema 1). This breaks the JSON shape: regions/tagged[]/control_plane[]/global[]/notes are gone, replaced by {schema, tool, account, generated_at, resources[], warnings[]}. Each resource carries arn, type, region, scope, name, ownership, class, deletable, reason, depends_on, tags. I found no consumer of the old shape in spawn, lagotto, spore-host-mcp, spawn-ts or calque (grepped clones). The one consumer inside spawn was the substrate e2e test TestTier0_Footprint_JSONIsParseable, and it is updated here. The text tables stay, with a new "Teardown view" section added.

New inventory sources (pkg/aws/footprint_report.go):

  • managed policies under /spore-host/, via ListPolicies PathPrefix=/spore-host/ and ListPolicyTags
  • CloudFormation stacks named like spore.host's (DescribeStacks): a role=service or infra-account stack is permanent, *_IN_PROGRESS is active, a deployed one is residue, a failed or rolled-back one is litter
  • spawn-pipeline-* SNS topics
  • anything tagged spore-host:managed-by by any tool (a second RGT query)
  • calque: calque-* queues, calque-nfs-sg, calque-* AMIs, and calque roles and profiles through the name scan (calque was added to the name prefixes). All of them are foreign.
  • Scheduler schedules were already listed. An enabled schedule is now active.

Rules (pkg/footprintspawn, pure, one place):

  • Ownership:
    • foreign when the name is calque-/lagotto-/truffle-, even if it carries a spawn tag
    • tagged when managed-by=spawn
    • foreign when managed-by names another tool
    • otherwise legacy-name
  • Class, first match wins:
    • permanent: the boundary, spore-host:permanent, role=service, or the infra account
    • user-data: a results bucket not proven empty, any other bucket, AMIs and snapshots, a workstation key, an Elastic IP spawn did not allocate
    • active: something in use now
    • residue: spawn's own machinery
    • litter: everything else
  • Patterns cover exactly the types pkg/teardown can delete, and a test holds the two sets equal.

spawn teardown --plan <file|-> --mode report|reap (cmd/teardown.go, pkg/teardown):

  • It runs footprint.NewPlan and then footprint.Execute with spawn's ByType deleter.
  • Report mode is the default.
  • Reap mode needs --yes. It refuses in the infra account or an account it cannot identify.
  • With no lease yet, reap refuses unless the hidden --i-understand-no-lease is passed. That runs under an in-process stand-in lease (a lifecycletest table) that coordinates with no one.
  • Describe re-derives "in use" from the live account, and Delete refuses anything in use (ErrInUse). This matters because footprint.Deletable lets active through.

Gates

make check passes. I ran it from a space-free copy (/private/tmp), because the clone's path contains a space. scripts/check-build-tags.sh gives a false failure when run through the /tmp symlink and passes from the physical path. make api-snapshot shows additions only. make cli-iam-actions and make gen-docs were regenerated. semgrep is clean on the changed files. The e2e tier-0 footprint tests pass against substrate.

…n --plan (#1653)

`spawn footprint -o json` is now the shared libs/footprint Report (schema 1):
every resource with arn, type, region, scope, name, tags, ownership
(tagged|legacy-name|foreign), class (litter|residue|active|user-data|permanent),
deletable, reason and depends_on. Breaking change to the JSON shape; the text
tables stay and gain a "Teardown view".

New inventory sources: managed policies under /spore-host/ (ListPolicies +
ListPolicyTags), CloudFormation stacks named like spore.host's, spawn-pipeline-*
SNS topics, anything tagged spore-host:managed-by by any tool, and calque's
queues, calque-nfs-sg and AMIs (plus calque-* roles/profiles via the name scan),
all calque/lagotto resources as ownership foreign.

The rules live in pkg/footprintspawn (ownership, class, Patterns); pkg/teardown
is the footprint.Deleter over the existing per-type deleters (RemoveResource,
egress-proxy teardown, instancerole, bucketsweep, poolqueue's rule). Describe
re-derives in-use from the live account and Delete refuses anything in use.

`spawn teardown --plan <file|-> --mode report|reap`: report is the default;
reap needs --yes, never runs in the infra account, and refuses without the
shared-account lease unless the hidden --i-understand-no-lease is passed.

libs bumped to v0.53.0.

Fixes #1653
@scttfrdmn

Copy link
Copy Markdown
Contributor Author

LIVE check (read-only, 2026-11-17, branch build)

spawn footprint --all-regions -o json:

  • dev 435415984226: 33 resources, 0 warnings.
    • 8 deletable: the test role and profile spawn-instance-d83504c4, the shared spored role and profile (residue), 2 attached spored policies (active, so refused on re-check), and 2 terminated test instances. Listing terminated instances is noise; consider excluding them.
    • The boundary is classed permanent.
  • Owner account 942542972736: 89 resources, 0 warnings, 0 deletable. Everything there predates the tags (legacy-name or user-data), and calque, lagotto and aws-realign resources are foreign.

spawn teardown --plan <dev report> (report mode, the default):

  • would-delete: spawn-instance-d83504c4, then spored-baseline-policy-v3, which is unattached only after that role goes. The order is right.
  • kept: the cross-account and portal roles (legacy-name) and the results/staging buckets.
  • "Nothing was deleted." CloudTrail shows 0 mutating calls in the window, and the role still exists.

Follow-ups:

@scttfrdmn
scttfrdmn marked this pull request as ready for review November 17, 2026 00:03
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

@scttfrdmn
scttfrdmn merged commit 7be6fe8 into main Nov 17, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1653-footprint branch November 17, 2026 00:35
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.

spawn footprint: add policies, stacks, SNS and calque, and make it safe to drive deletion

1 participant