Skip to content

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

Closed

Description

@lex00

Prerequisite for #1266.

What a snapshot records today

Identity and status per resource, plus the stack's CloudFormation exports:

"webServer": {
  "type": "AWS::EC2::Instance",
  "physicalId": "i-e392157f576caf855",
  "status": "CREATE_COMPLETE",
  "attributes": { "expAmiName": "...", "expDefaultSubnet1": "...", "expHttpPort": "80", ... }
}

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

Why that blocks snapshot-backed search

chant's distinguishing answers are folds over topology. internetFacing resolves subnet → route table → internet gateway, including a default VPC's main-table association. effectiveIngress resolves rules across directly attached security groups and any reached through a launch template.

None of those inputs are in the snapshot. So search --at latest "kind:EC2::Instance attr:internetFacing=true" cannot be answered from a recorded observation, which is most of the value of #1266.

The machinery already exists

observeResourcesDeep and deepDiffForLexicon are implemented and wired into lifecycle diff --live — that is what "lexicons with a deep reader also report property-level drift" refers to. takeSnapshot only ever calls the thin describeResources path.

Proposal

Let a snapshot be taken at deep depth, and record which depth it was taken at.

chant lifecycle snapshot <env> --deep
  • The snapshot records the normalized per-resource property trees the deep reader returns, alongside the identity it already keeps.
  • depth becomes a field on the snapshot, surfaced in lifecycle show and in search's provenance line (Design: search reads observations from a source, and always says which one #1266), so a caller knows what the recorded observation can and cannot answer.
  • Thin stays the default. A deep read is more provider calls and a larger record; it should be asked for.

Deep observation already has the rules this needs — a reader that throws reports entities as NOT-OBSERVED with read-failed rather than vanishing (#1089), and secrets are masked before any property tree is rendered or committed (#1014). Both matter more for a snapshot than for a diff, because a snapshot is written to git and read back later.

Open question

Whether the fold results themselves (internetFacing, effectiveIngress) should be recorded, or only their inputs so folds re-run at query time. Recording inputs keeps the snapshot a record of observation rather than of computation, and means a fold improvement applies retroactively to old snapshots. That seems clearly right, but it makes a deep snapshot meaningfully larger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions