Skip to content

feat(lifecycle): snapshot at deep depth, and say which depth it was (#1267) - #1270

Merged
lex00 merged 2 commits into
mainfrom
feat/deep-snapshots
Jul 31, 2026
Merged

lex00 merged 2 commits into
mainfrom
feat/deep-snapshots

Conversation

@lex00

@lex00 lex00 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Closes #1267. Stacked on #1262 — targets fix/lifecycle-snapshot-region, since the deep path reuses the per-stack region that fix threads through. Retarget to main once #1262 merges.

Why

A snapshot recorded identity — logical name, type, physical id, status — plus the stack's CloudFormation exports. It carried no per-resource properties, so nothing that folds over topology could be answered from one.

That attributes blob is the stack's exports and is identical for every resource in the stack. Verified: webServer, publicSubnet and webSecurityGroup in the same snapshot all carry the same one. No subnet for an instance, no attached security groups, no route-table associations, no ingress rules.

observeResourcesDeep already existed, and was already wired into lifecycle diff --live. Only the snapshot path never called it.

What changed

chant lifecycle snapshot <env> --deep records each resource's normalized property tree beside the identity it already kept. Thin stays the default — a deep read is more provider calls and a larger record, so it should be asked for.

Depth is recorded, not inferred. depth is absent on a thin snapshot rather than set to "identity", because every snapshot written before this was thin and treating a missing field as unknown would invalidate all of them. lifecycle show states it:

floci/…-us-east-1__aws — 17 resources — deep (3 property trees) — 2026-07-31T03:46Z
floci/…-us-west-1__aws — 8 resources — identity only — 2026-07-31T03:46Z

properties sits beside resources, not merged into it, so a reader that only wants identity does not have to learn a new shape and old and new snapshots parse the same way.

Degradation is explicit at every step, following #1089's rule that an unread resource is a hole with a reason and never a clean empty answer:

  • a lexicon with no deep reader warns and records identity
  • a deep read returning nothing warns and keeps the identity snapshot, rather than discarding one that was already good
  • a type outside the Cloud Control allowlist is recorded unobserved, per entity, with the kind named

Region, again

The deep path was region-blind in a way the thin path no longer is. observeResourcesDeep took no region at any layer — not the core interface, not DeepObserveOptions, not the AWS reader — so a multi-region estate read every stack against the ambient region and the out-of-region ones came back empty. Threaded the same way #1262 did for thin, down to describe-stack-resources and cloudcontrol get-resource.

Verification

Against a four-stack estate spanning us-east-1 ×2, us-west-1 and us-west-2:

ec2-multiregion-EC2-ks84v1fh12-us-east-1: Snapshot saved (aws(17))   → deep, 3 property trees
ec2-multiregion-EC2-ls9fuhb522-us-west-1: Snapshot saved (aws(8))    → identity, every entity explained
ec2-multiregion-EC2-ls9fuhb522-us-west-2: Snapshot saved (aws(8))    → identity, every entity explained
ec2-multiregion-QARoles-us-east-1:        Snapshot saved (aws(4))    → deep, 3 property trees

The west stacks degrade honestly rather than silently:

warning: aws: not observed deeply — publicSubnet (AWS::EC2::Subnet) — no reader for this resource kind
warning: aws: not observed deeply — routeTable (AWS::EC2::RouteTable) — no reader for this resource kind

Tests

Six added: thin by default with no depth written; deep records trees alongside identity; no deep reader warns and stays thin; an empty deep read downgrades rather than discarding; unreadable entities are reported; and the stack's region reaches the deep reader.

just build and npx eslint packages/ lexicons/aws/src clean; 1535 tests pass across lifecycle, cli/handlers and the AWS lexicon.

What this does not do yet

Coverage is now the constraint rather than the mechanism. DEEP_READABLE_TYPES holds four types and none of the EC2 topology types are among them, so internetFacing and effectiveIngress still cannot be answered from a snapshot. Filed as #1269, and it is the remaining blocker for snapshot-backed search (#1266).

🤖 Generated with Claude Code

https://claude.ai/code/session_01J3xEUD47xeEX2AK9xSvBug

…1267)

A snapshot recorded identity — logical name, type, physical id, status — plus
the stack's CloudFormation exports. It carried no per-resource properties, so
nothing that folds over topology could be answered from one. `webServer`,
`publicSubnet` and `webSecurityGroup` in the same snapshot all held an
identical `attributes` blob of stack exports.

`observeResourcesDeep` already existed and was already wired into
`lifecycle diff --live`. Only the snapshot path never called it.

`chant lifecycle snapshot <env> --deep` now records each resource's normalized
property tree beside the identity it already kept. Thin stays the default: a
deep read is more provider calls and a larger record, so it is asked for.

Depth is recorded, not inferred. `depth` is absent on a thin snapshot, because
every snapshot written before this was thin and treating a missing field as
unknown would invalidate them all. `lifecycle show` states it, so a reader
knows what a snapshot can answer before asking.

Degradation is explicit at every step, following #1089's rule that an unread
resource is a hole with a reason and never a clean empty answer:

  - a lexicon with no deep reader warns and records identity
  - a deep read returning nothing warns and keeps the identity snapshot rather
    than discarding one that was already good
  - a type outside the Cloud Control allowlist is recorded unobserved, per
    entity, with the kind named

The deep path was region-blind — `observeResourcesDeep` took no region at any
layer, so a multi-region estate read every stack against the ambient one and
the out-of-region stacks came back empty. Thread it the same way #1262 did for
thin, through DeepObserveOptions, the lexicon interface, and the AWS reader's
describe-stack-resources and cloudcontrol get-resource calls.

Verified against a four-stack estate across three regions. Coverage is now the
constraint rather than the mechanism: the allowlist holds four types and the
EC2 topology types are not among them, so the folds still cannot be answered
from a snapshot. Filed as #1269.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J3xEUD47xeEX2AK9xSvBug
@lex00
lex00 changed the base branch from fix/lifecycle-snapshot-region to main July 31, 2026 22:10
Both sides add to the same lifecycle surfaces and neither replaces the other:
main brought --at/--ambient and observed edges, this branch brings --deep and
the recorded depth. Conflicts resolved by keeping both — the snapshot options
object carries cwd/stack/region/deep/ambient/ambientKinds, LifecycleSnapshot
carries depth, properties and edges, and the CLI accepts all the flags.
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.

Deep snapshots: record the property trees the folds need, not just identity

1 participant