Skip to content

feat(state): pass entity props through describeResources() (#39)#44

Merged
lex00 merged 1 commit into
mainfrom
feat/describe-resources-entity-props-issue-39
May 9, 2026
Merged

feat(state): pass entity props through describeResources() (#39)#44
lex00 merged 1 commit into
mainfrom
feat/describe-resources-entity-props-issue-39

Conversation

@lex00
Copy link
Copy Markdown
Contributor

@lex00 lex00 commented May 9, 2026

Summary

Closes #39. Extends LexiconPlugin.describeResources() with entities: Map<string, { entityType, props }> so plugins can map cloud-side identifiers back to chant entity names. Solves the round-trip problem identified during #27 where the Temporal lexicon was forced to use server-side keys (namespace/prod) instead of chant entity names.

describeResources?(options: {
  environment: string;
  buildOutput: string;
  entityNames: string[];
  entities: Map<string, { entityType: string; props: Record<string, unknown> }>;  // ← new
}): Promise<Record<string, ResourceMetadata>>

entityNames preserved for the simple case. AWS lexicon (CloudFormation logical IDs == chant entity names) continues unchanged.

Temporal mapping

Server-side identifier Chant entity match
Namespace prod Entity with entityType: "Temporal::Namespace" and props.name === "prod"
SearchAttribute prod/Project Entity with entityType: "Temporal::SearchAttribute" and props.name === "Project" + props.namespace === "prod" (or default-fallback to first declared namespace)
Schedule prod/daily-report Entity with entityType: "Temporal::Schedule" and props.scheduleId === "daily-report"

Server-side resources without a matching declaration still surface as orphan keys (namespace/<name>, etc.) so chant state diff --live correctly reports them as orphan (in cloud, not declared) rather than forcing a synthetic mapping.

Tests

4 new cases in describe-resources.test.ts:

  • Namespace mapping by props.name
  • SearchAttribute mapping by props.name + props.namespace
  • Schedule mapping by props.scheduleId
  • SearchAttribute namespace fallback to first declared

Plus the 5 existing cases updated to pass entities: new Map() (no behavior change since they don't declare entities).

Verification

  • just build clean
  • npx vitest run → 1639/1639 pass

Test plan

Extends LexiconPlugin.describeResources options with:

  entities: Map<string, { entityType, props }>

so plugins can map cloud-side identifiers back to chant entity names.
Existing entityNames is preserved as a convenience for the simple case;
the AWS lexicon (CloudFormation logical IDs already match chant entity
names) continues unchanged.

Temporal lexicon now uses entity props for round-trip mapping:
  - Namespace:       props.name              -> entity name
  - SearchAttribute: <ns>/<props.name>       -> entity name
  - Schedule:        <ns>/<props.scheduleId> -> entity name

Server-side resources without a matching declaration still surface as
orphan keys (namespace/<name>, etc.) so chant state diff --live can
report them as 'orphan' (in cloud, not declared) instead of forcing a
synthetic mapping.

Callers updated:
  - state/snapshot.ts: takeSnapshot() builds the entities map per lexicon
  - cli/handlers/state.ts: runStateDiffLive does the same

Tests:
  - 4 new round-trip cases in describe-resources.test.ts:
      namespace mapping by props.name
      search-attribute mapping by props.name + props.namespace
      schedule mapping by props.scheduleId
      search-attribute namespace fallback to first declared
  - existing 5 cases updated to pass entities: new Map() (no behavior
    change since they don't declare any entities)
@lex00 lex00 merged commit b7f3ebe into main May 9, 2026
9 checks passed
@lex00 lex00 deleted the feat/describe-resources-entity-props-issue-39 branch May 9, 2026 23:48
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.

describeResources() contract doesn't pass entity props — limits live-diff name mapping

1 participant