Repository navigation
fix(lifecycle): snapshot a stack in the region it declares (#1261) - #1262
Merged
Merged
Conversation
`chant lifecycle snapshot` observed every stack against the ambient region, so
a multi-region estate recorded only the stacks that happened to share it. The
rest failed with "aws: no valid resources or artifacts returned" — and because
the command still wrote the stacks it could reach, the result read as a
per-stack quirk rather than a systematic miss. A later diff would then read
those stacks back as absent rather than unobserved.
`config.stacks[].region` was already declared and already honored elsewhere:
`chant search --live` maps stacks to `{ name, region, src }`, and the AWS
lexicon's `describeResources` takes a `region` and builds `--region` args from
it. Only the snapshot path dropped it — `resolveStackTargets` discarded
`s.region`, and `takeSnapshot` had nowhere to put one.
Thread it through those two layers. No new concept: the region a stack deploys
to is the region it is read from.
`listArtifacts` deliberately does not take one. Artifacts are registry and
chart objects (docker, helm), not regional cloud resources.
Verified against a four-stack estate across us-east-1, us-west-1 and
us-west-2: 2 of 4 stacks captured before, 4 of 4 after.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J3xEUD47xeEX2AK9xSvBug
lex00
added a commit
that referenced
this pull request
Jul 31, 2026
…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
force-pushed
the
fix/lifecycle-snapshot-region
branch
from
July 31, 2026 03:49
c28f957 to
0e55bfe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1261.
The bug
chant lifecycle snapshot <env>observed every stack against the ambient region. On a multi-region estate only the stacks sharing that region were recorded; the rest failed with:Because the command still wrote the stacks it could reach and exited 0, the failure read as a per-stack quirk rather than a systematic region miss. A later
diffwould read the missing stacks back as absent rather than unobserved.The cause
config.stacks[].regionis declared, and is already honored everywhere else:cli/handlers/search.tsmaps stacks to{ name, region, src }, which is whysearch --livecovers a multi-region estate correctly.describeResourcesacceptsregion?: stringand builds--regionargs from it, with the comment "Multi-region estates: target this stack's region, not the ambient one."Only the snapshot path dropped it.
resolveStackTargetsmappedconfig.stacksto{ stack, root }and discardeds.region, andtakeSnapshothad no option to carry one, so the plugin never received a region and fell back to the ambient one.The change
Thread the declared region through the two layers that dropped it:
StackTargetgainsregion, andresolveStackTargetscarriess.region.takeSnapshot's options gainregion, forwarded todescribeResources.No new concept — the region a stack deploys to is the region it is read from.
listArtifactsdeliberately does not take a region. Artifacts are registry and chart objects (docker, helm), not regional cloud resources.Verification
Against a four-stack estate spanning
us-east-1×2,us-west-1andus-west-2, withAWS_DEFAULT_REGION=us-east-1.Before — 2 of 4 stacks, 21 resources:
After — 4 of 4 stacks, 37 resources:
Tests
Four added, covering both layers and both directions:
takeSnapshotforwards a declared region todescribeResources, and leaves itundefinedwhen none is declared (so the ambient-region default is preserved for single-region projects).undefinedfor a stack that declares none.just build,npx eslint packages/, and the fulllifecycle+cli/handlerssuites pass (458 tests).Follow-up, not in this PR
runLifecycleDiffLiveis reached from the sameresolveStackTargetsloop and is passed onlystack: target.stack, solifecycle difflooks like the same shape.observeResourcesalready acceptsstacks: Array<{ name, region, src }>, so the plumbing exists. I left it alone because I only reproduced the snapshot path; noted in #1261.🤖 Generated with Claude Code
https://claude.ai/code/session_01J3xEUD47xeEX2AK9xSvBug