@intentius/chant 0.52.1 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/agents/checks.d.ts +35 -0
  2. package/dist/agents/checks.d.ts.map +1 -0
  3. package/dist/agents/discover.d.ts +86 -0
  4. package/dist/agents/discover.d.ts.map +1 -0
  5. package/dist/agents/importer.d.ts +46 -0
  6. package/dist/agents/importer.d.ts.map +1 -0
  7. package/dist/agents/index.d.ts +14 -0
  8. package/dist/agents/index.d.ts.map +1 -0
  9. package/dist/agents/types.d.ts +196 -0
  10. package/dist/agents/types.d.ts.map +1 -0
  11. package/dist/audit/catalog.d.ts +4 -1
  12. package/dist/audit/catalog.d.ts.map +1 -1
  13. package/dist/audit/report.d.ts +8 -0
  14. package/dist/audit/report.d.ts.map +1 -1
  15. package/dist/audit/rules-doc.d.ts.map +1 -1
  16. package/dist/cdk/advise.d.ts +29 -0
  17. package/dist/cdk/advise.d.ts.map +1 -0
  18. package/dist/cdk/assembly.d.ts +38 -0
  19. package/dist/cdk/assembly.d.ts.map +1 -0
  20. package/dist/cdk/graph.d.ts +68 -0
  21. package/dist/cdk/graph.d.ts.map +1 -0
  22. package/dist/cdk/tier-map.d.ts +44 -0
  23. package/dist/cdk/tier-map.d.ts.map +1 -0
  24. package/dist/cdk/types.d.ts +114 -0
  25. package/dist/cdk/types.d.ts.map +1 -0
  26. package/dist/cli/commands/audit-agents.d.ts +83 -0
  27. package/dist/cli/commands/audit-agents.d.ts.map +1 -0
  28. package/dist/cli/commands/carve-apply.d.ts.map +1 -1
  29. package/dist/cli/commands/carve-bridge.d.ts.map +1 -1
  30. package/dist/cli/commands/carve-emit.d.ts.map +1 -1
  31. package/dist/cli/commands/carve.d.ts +48 -6
  32. package/dist/cli/commands/carve.d.ts.map +1 -1
  33. package/dist/cli/commands/import-agents.d.ts +64 -0
  34. package/dist/cli/commands/import-agents.d.ts.map +1 -0
  35. package/dist/cli/handlers/carve-emit.d.ts.map +1 -1
  36. package/dist/cli/handlers/carve.d.ts +5 -4
  37. package/dist/cli/handlers/carve.d.ts.map +1 -1
  38. package/dist/cli/handlers/lifecycle.d.ts +10 -0
  39. package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
  40. package/dist/cli/handlers/misc.d.ts.map +1 -1
  41. package/dist/cli/main.d.ts.map +1 -1
  42. package/dist/cli/registry.d.ts +15 -0
  43. package/dist/cli/registry.d.ts.map +1 -1
  44. package/dist/identity.d.ts +196 -0
  45. package/dist/identity.d.ts.map +1 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/lexicon.d.ts +52 -0
  49. package/dist/lexicon.d.ts.map +1 -1
  50. package/dist/terraform/adopt-state.d.ts +17 -63
  51. package/dist/terraform/adopt-state.d.ts.map +1 -1
  52. package/dist/terraform/aws-resources.d.ts +1 -1
  53. package/dist/terraform/bridge.d.ts.map +1 -1
  54. package/dist/terraform/carve-provider.d.ts +142 -0
  55. package/dist/terraform/carve-provider.d.ts.map +1 -0
  56. package/dist/terraform/carve.d.ts +36 -3
  57. package/dist/terraform/carve.d.ts.map +1 -1
  58. package/dist/terraform/emit-source.d.ts +25 -0
  59. package/dist/terraform/emit-source.d.ts.map +1 -0
  60. package/dist/terraform/graduate.d.ts +11 -1
  61. package/dist/terraform/graduate.d.ts.map +1 -1
  62. package/dist/terraform/providers/aws.d.ts +19 -0
  63. package/dist/terraform/providers/aws.d.ts.map +1 -0
  64. package/dist/terraform/providers/gcp.d.ts +41 -0
  65. package/dist/terraform/providers/gcp.d.ts.map +1 -0
  66. package/dist/terraform/providers/index.d.ts +15 -0
  67. package/dist/terraform/providers/index.d.ts.map +1 -0
  68. package/dist/terraform/providers/kubernetes.d.ts +29 -0
  69. package/dist/terraform/providers/kubernetes.d.ts.map +1 -0
  70. package/dist/terraform/score.d.ts +70 -4
  71. package/dist/terraform/score.d.ts.map +1 -1
  72. package/dist/terraform/tier-map.d.ts +38 -26
  73. package/dist/terraform/tier-map.d.ts.map +1 -1
  74. package/dist/terraform/types.d.ts +6 -0
  75. package/dist/terraform/types.d.ts.map +1 -1
  76. package/dist/yaml.d.ts.map +1 -1
  77. package/package.json +6 -1
  78. package/src/agents/checks.test.ts +228 -0
  79. package/src/agents/checks.ts +429 -0
  80. package/src/agents/discover.test.ts +310 -0
  81. package/src/agents/discover.ts +939 -0
  82. package/src/agents/importer.ts +49 -0
  83. package/src/agents/index.ts +29 -0
  84. package/src/agents/types.ts +207 -0
  85. package/src/audit/catalog.ts +90 -1
  86. package/src/audit/report.ts +9 -1
  87. package/src/audit/rules-doc.ts +6 -0
  88. package/src/cdk/__fixtures__/cdk.out/AppStack.template.json +171 -0
  89. package/src/cdk/__fixtures__/cdk.out/DataStack.template.json +90 -0
  90. package/src/cdk/__fixtures__/cdk.out/cdk.out +1 -0
  91. package/src/cdk/__fixtures__/cdk.out/manifest.json +30 -0
  92. package/src/cdk/__fixtures__/cdk.out/tree.json +201 -0
  93. package/src/cdk/__fixtures__/cdk.out-dummy/LookupStack.template.json +29 -0
  94. package/src/cdk/__fixtures__/cdk.out-dummy/manifest.json +26 -0
  95. package/src/cdk/advise.test.ts +208 -0
  96. package/src/cdk/advise.ts +44 -0
  97. package/src/cdk/assembly.ts +133 -0
  98. package/src/cdk/graph.test.ts +206 -0
  99. package/src/cdk/graph.ts +525 -0
  100. package/src/cdk/tier-map.ts +71 -0
  101. package/src/cdk/types.ts +115 -0
  102. package/src/cli/commands/audit-agents.test.ts +260 -0
  103. package/src/cli/commands/audit-agents.ts +387 -0
  104. package/src/cli/commands/carve-apply.ts +20 -4
  105. package/src/cli/commands/carve-bridge.test.ts +30 -0
  106. package/src/cli/commands/carve-bridge.ts +24 -2
  107. package/src/cli/commands/carve-emit-k8s.test.ts +262 -0
  108. package/src/cli/commands/carve-emit-provider.test.ts +207 -0
  109. package/src/cli/commands/carve-emit.test.ts +72 -1
  110. package/src/cli/commands/carve-emit.ts +55 -28
  111. package/src/cli/commands/carve.ts +139 -36
  112. package/src/cli/commands/import-agents.test.ts +208 -0
  113. package/src/cli/commands/import-agents.ts +196 -0
  114. package/src/cli/handlers/carve-emit.ts +8 -1
  115. package/src/cli/handlers/carve.ts +8 -7
  116. package/src/cli/handlers/lifecycle.test.ts +187 -1
  117. package/src/cli/handlers/lifecycle.ts +125 -1
  118. package/src/cli/handlers/misc.ts +111 -0
  119. package/src/cli/main.ts +29 -5
  120. package/src/cli/registry.ts +15 -0
  121. package/src/identity.test.ts +199 -0
  122. package/src/identity.ts +346 -0
  123. package/src/index.ts +1 -0
  124. package/src/lexicon.ts +65 -0
  125. package/src/terraform/__fixtures__/gcp-estate/main.tf +60 -0
  126. package/src/terraform/adopt-state.test.ts +131 -0
  127. package/src/terraform/adopt-state.ts +22 -167
  128. package/src/terraform/aws-resources.test.ts +55 -16
  129. package/src/terraform/aws-resources.ts +1 -1
  130. package/src/terraform/bridge.test.ts +12 -0
  131. package/src/terraform/bridge.ts +4 -1
  132. package/src/terraform/carve-provider.test.ts +155 -0
  133. package/src/terraform/carve-provider.ts +237 -0
  134. package/src/terraform/carve.test.ts +55 -1
  135. package/src/terraform/carve.ts +0 -0
  136. package/src/terraform/emit-source.ts +39 -0
  137. package/src/terraform/graduate.test.ts +37 -0
  138. package/src/terraform/graduate.ts +55 -7
  139. package/src/terraform/graph.ts +3 -3
  140. package/src/terraform/providers/aws.ts +169 -0
  141. package/src/terraform/providers/gcp.test.ts +228 -0
  142. package/src/terraform/providers/gcp.ts +329 -0
  143. package/src/terraform/providers/index.ts +21 -0
  144. package/src/terraform/providers/kubernetes.ts +224 -0
  145. package/src/terraform/score.ts +111 -25
  146. package/src/terraform/tier-map.ts +55 -90
  147. package/src/terraform/types.ts +6 -0
  148. package/src/yaml.test.ts +54 -0
  149. package/src/yaml.ts +24 -3
@@ -0,0 +1,142 @@
1
+ /**
2
+ * The carve provider seam (#2016).
3
+ *
4
+ * `carve advise|emit|bridge` used to reach into the AWS carve table directly:
5
+ * the tier map derived from it, the emit gate was `awsCarveType(t) !== undefined`,
6
+ * the adopter called `applyAwsMapper`, and the emitted project's lexicon was a
7
+ * constant. A second provider — Kubernetes emit (#999), GCP (#2017) — had
8
+ * nowhere to land except a parallel path beside the AWS one.
9
+ *
10
+ * A provider owns one or more Terraform type prefixes and answers everything
11
+ * the carve commands ask about the types under them: how each ranks against a
12
+ * native spec, which HCL attribute carries the physical name, which
13
+ * sub-resources fold into a parent, which types emit can produce source for,
14
+ * and how to adopt one from `.tfstate`.
15
+ *
16
+ * ── Why the registry lives in core, not behind a `LexiconPlugin` capability ──
17
+ *
18
+ * `carve advise` runs against a Terraform directory that is not a chant project:
19
+ * there is no `chant.config.ts` naming lexicons, so there is nothing to load
20
+ * plugins from, and `carve emit --state` is deliberately offline (see the
21
+ * handler). Behind a plugin capability both would have to load plugins to learn
22
+ * that a type ranks tier 1. Providers are also Terraform-provider knowledge
23
+ * (`terraform-provider-aws` attribute names), which belongs beside the HCL
24
+ * parser rather than inside a lexicon.
25
+ *
26
+ * `registerCarveProvider` is exported, so a plugin that wants to contribute a
27
+ * provider at runtime still can — the seam does not foreclose it, it just does
28
+ * not require plugin loading for the paths that run without one.
29
+ */
30
+ import type { StateResource } from "./state.js";
31
+ export interface TierInfo {
32
+ tier: 1 | 2 | 3;
33
+ /** The native spec type a carve would target, for the report. */
34
+ mapsTo: string;
35
+ }
36
+ /**
37
+ * One deferred outbound input turned into a build parameter (#998). Derived
38
+ * from the boundary report's outbound edges + the state's resolved attributes
39
+ * in `carve-emit.ts`; consumed by a provider's `adopt` (source substitution)
40
+ * and by the scaffold (`chant.config.ts` `buildParams` declaration).
41
+ */
42
+ export interface DeferredParam {
43
+ /** Build-parameter name, source-referenceable (`params.<name>`). */
44
+ name: string;
45
+ /** The carved resource's own Terraform attribute the value enters through. */
46
+ tfAttr: string;
47
+ /** The survivor the Terraform source read, e.g. `aws_vpc.main`. */
48
+ survivor: string;
49
+ /** Survivor attribute(s) read, e.g. `["id"]`. */
50
+ attrs: string[];
51
+ /** The state-resolved value — the parameter's declared default. */
52
+ default?: string | number | boolean;
53
+ }
54
+ /** What one folded sub-resource contributed to the parent's emitted props (#1637). */
55
+ export interface FoldedContribution {
56
+ /** The sub-resource's Terraform address, e.g. `aws_s3_bucket_versioning.assets`. */
57
+ address: string;
58
+ /** Native properties it added to the parent, e.g. `["VersioningConfiguration"]`. */
59
+ props: string[];
60
+ }
61
+ export interface AdoptedSource {
62
+ fileName: string;
63
+ content: string;
64
+ /** True when at least one attribute was mapped to a native prop. */
65
+ mapped: boolean;
66
+ nativeType: string;
67
+ /** Deferred params actually substituted into the emitted props (#998). */
68
+ parameterized: string[];
69
+ /** Folded sub-resources and the props each one joined into the parent (#1637). */
70
+ folded: FoldedContribution[];
71
+ }
72
+ export interface CarveProvider {
73
+ /** Registry id, unique. Registering a second provider under it replaces the first. */
74
+ readonly name: string;
75
+ /**
76
+ * Terraform type prefixes this provider owns, e.g. `["aws_"]`. Resolution
77
+ * takes the longest match, so a narrower provider can claim a subset of a
78
+ * wider one's prefix.
79
+ */
80
+ readonly tfTypePrefixes: readonly string[];
81
+ /**
82
+ * The chant lexicon emitted source targets — the scaffolded project's
83
+ * dependency and `--lexicon` flag, and the lexicon the live import runs
84
+ * against.
85
+ */
86
+ readonly lexicon: string;
87
+ /** Terraform type → native tier, contributed to the advisor's tier map. */
88
+ readonly tiers: Readonly<Record<string, TierInfo>>;
89
+ /**
90
+ * Terraform type → the HCL attribute carrying the physical name. A dotted
91
+ * entry is a path into nested blocks (`manifest.metadata.name`); the bridge
92
+ * refuses those, since a data-source body is flat `attr = value`.
93
+ */
94
+ readonly identityAttrs?: Readonly<Record<string, string>>;
95
+ /**
96
+ * Sub-resource Terraform type → parent type, for types Terraform splits out
97
+ * of the resource the native spec keeps them in.
98
+ */
99
+ readonly foldsInto?: Readonly<Record<string, string>>;
100
+ /**
101
+ * Terraform types `carve emit` can produce chant source for — narrower than
102
+ * `tiers`, which advise also ranks types no emit path can adopt. Absent or
103
+ * empty means advise-only. Declaring types here obliges the provider to
104
+ * implement {@link adopt}: both emit paths gate on the same list (#2015), so
105
+ * a type the live path accepts must be adoptable from state too.
106
+ */
107
+ readonly emitTypes?: readonly string[];
108
+ /** Adopt a resource from Terraform state into chant source. */
109
+ adopt?(resource: StateResource, params: DeferredParam[], folded: StateResource[]): AdoptedSource | null;
110
+ /**
111
+ * The native selector type the live (cloud→code) import filters on, e.g.
112
+ * `AWS::S3::Bucket`. Undefined when this type has no live adoption path —
113
+ * `carve emit --env` refuses it rather than importing the wrong thing.
114
+ */
115
+ liveSelectorType?(tfType: string): string | undefined;
116
+ }
117
+ /**
118
+ * Register a carve provider. Returns a function that removes it again, so a
119
+ * test (or a plugin unloading) leaves the registry as it found it.
120
+ */
121
+ export declare function registerCarveProvider(provider: CarveProvider): () => void;
122
+ /** Every registered provider, in registration order. */
123
+ export declare function carveProviders(): readonly CarveProvider[];
124
+ /** The provider owning this Terraform type, by longest prefix match. */
125
+ export declare function resolveCarveProvider(tfType: string): CarveProvider | undefined;
126
+ /**
127
+ * The provider that can emit chant source for this Terraform type. Narrower
128
+ * than {@link resolveCarveProvider}: a provider owns every type under its
129
+ * prefix for advise, and only the ones on its `emitTypes` list for emit.
130
+ */
131
+ export declare function resolveEmitProvider(tfType: string): CarveProvider | undefined;
132
+ /** Every Terraform type any registered provider can emit, sorted, for user-facing hints. */
133
+ export declare function carveEmitTypes(): string[];
134
+ /** The lexicons emit can adopt into, sorted — what the CLI loads plugins for. */
135
+ export declare function carveEmitLexicons(): string[];
136
+ /** Terraform resource type → native tier, merged over every provider. Read-only: it is the cached index. */
137
+ export declare function carveTierMap(): Readonly<Record<string, TierInfo>>;
138
+ /** The HCL attribute carrying this type's physical name, if its provider declares one. */
139
+ export declare function carveIdentityAttr(tfType: string): string | undefined;
140
+ /** The parent Terraform type this sub-resource folds into, if any. */
141
+ export declare function carveFoldParent(tfType: string): string | undefined;
142
+ //# sourceMappingURL=carve-provider.d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,CAAC,CAAC,CAEjE;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE;AAED,sEAAsE;AACtE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE"}
@@ -10,6 +10,7 @@
10
10
  * (via live import) and generating the TF patches live in the command/bridge
11
11
  * layers; this module just classifies the boundary.
12
12
  */
13
+ import { type ScoreOptions } from "./score.js";
13
14
  import type { TfGraph } from "./types.js";
14
15
  /** One resource in the carve set (the selected node plus its folded sub-resources). */
15
16
  export interface CarveMember {
@@ -47,8 +48,17 @@ export interface BoundaryEdge {
47
48
  * named after on emit. For an output edge it is `["value"]`.
48
49
  */
49
50
  via: string[];
50
- bridge: "tf-data-source" | "tf-output-rewrite" | "deferred-input";
51
+ /**
52
+ * The patch that bridges the cut, in the surviving source's own vocabulary.
53
+ * Terraform: a `data` source, an `output` expression rewrite, or a deferred
54
+ * deploy-time input. CDK (#1056): `cdk-import` — the surviving app reimports
55
+ * the carved resource by ARN/name — or a `Outputs` rewrite. Open-ended: a
56
+ * reader must tolerate a value it does not know.
57
+ */
58
+ bridge: "tf-data-source" | "tf-output-rewrite" | "cdk-import" | "cfn-output-rewrite" | "deferred-input";
51
59
  required: "immediately" | "at-apply";
60
+ /** The two ends live in different CloudFormation templates (#1056). */
61
+ crossStack?: boolean;
52
62
  }
53
63
  export interface CarveReport {
54
64
  /** The selected resource address. */
@@ -64,20 +74,43 @@ export interface CarveReport {
64
74
  }
65
75
  /**
66
76
  * The carve set for a selected address: the node itself plus any sub-resources
67
- * that fold into it (same name, a `FOLDS_INTO` child type whose parent is the
77
+ * that fold into it (same name, a `foldParentOf` child type whose parent is the
68
78
  * selection). Those are carried along and inlined, not left behind.
69
79
  */
70
80
  export declare function resolveCarveSet(graph: TfGraph, target: string): CarveMember[];
81
+ /**
82
+ * Which source the graph came from, and so which vocabulary its bridge patches
83
+ * are named in. Terraform is the default; `cdk` is the read-only cloud-assembly
84
+ * advisor (#1056), where the surviving app reimports rather than adding a
85
+ * `data` source.
86
+ */
87
+ export type CarveDialect = "terraform" | "cdk";
88
+ export interface BoundaryOptions {
89
+ dialect?: CarveDialect;
90
+ /** Scoring hooks, so `peelability` is the same number the ranking reported. */
91
+ score?: ScoreOptions;
92
+ }
71
93
  /**
72
94
  * Classify the boundary of carving `target`: the inbound edges that need an
73
95
  * immediate data-source patch, and the outbound edges that become deferred
74
96
  * deploy-time inputs. Edges internal to the carve set (e.g. a folded
75
97
  * sub-resource pointing at its parent) are not boundary work.
76
98
  */
77
- export declare function boundaryReport(graph: TfGraph, target: string): CarveReport | null;
99
+ export declare function boundaryReport(graph: TfGraph, target: string, opts?: BoundaryOptions): CarveReport | null;
78
100
  /**
79
101
  * The build-parameter name a deferred input's carrying attribute becomes on
80
102
  * emit (#998) — shared so bridge notes and emitted `buildParams` agree.
81
103
  */
82
104
  export declare function deferredParamName(tfAttr: string): string;
105
+ /**
106
+ * Collapse duplicate edges (same survivor/carved pair), merging attrs.
107
+ *
108
+ * The map key below joins the two addresses with U+001F (unit separator).
109
+ * A Terraform address is built from HCL identifiers plus `.`, `[`, `]`, `"`
110
+ * and `-`; it cannot contain a C0 control character, so U+001F can never
111
+ * collide with an address component. Keep it that way — this key is never
112
+ * serialized, so a plain, non-printing separator is fine, but it must stay
113
+ * a character no address can produce.
114
+ */
115
+ export declare function dedupeEdges(edges: BoundaryEdge[]): BoundaryEdge[];
83
116
  //# sourceMappingURL=carve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"carve.d.ts","sourceRoot":"","sources":["../../src/terraform/carve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,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AAG,KAAK,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAQD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,eAAoB,GAAG,WAAW,GAAG,IAAI,CA0D7G;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAajE"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Source rendering shared by constructor-shaped carve providers (#2016).
3
+ *
4
+ * A provider that adopts into a typed chant constructor call — aws today, gcp
5
+ * next (#2017) — renders the same literal: an import, an exported `new Ctor({
6
+ * ...props })`, and a reference comment carrying whatever the mapping could not
7
+ * place. Only the lexicon import path and the property mapping differ, so the
8
+ * rendering lives here rather than being copied per provider.
9
+ *
10
+ * A provider whose native shape is not a constructor call (a Kubernetes
11
+ * manifest, #999) renders its own source and does not use this.
12
+ */
13
+ /** The core subpath the emitted source reads build parameters from. */
14
+ export declare const PARAMS_IMPORT = "@intentius/chant/params";
15
+ /** Marker for a prop whose value is a `params.<name>` reference, not a literal. */
16
+ export declare class ParamRef {
17
+ readonly name: string;
18
+ readonly type: "string" | "number" | "boolean";
19
+ constructor(name: string, type: "string" | "number" | "boolean");
20
+ }
21
+ /** Render a JS object literal with stable key order and given indent. */
22
+ export declare function renderObject(obj: Record<string, unknown>, indent: number): string;
23
+ /** A prop value: a `params.<name>` reference (cast keeps the project tsc-clean) or a literal. */
24
+ export declare function renderValue(value: unknown): string;
25
+ //# sourceMappingURL=emit-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-source.d.ts","sourceRoot":"","sources":["../../src/terraform/emit-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,uEAAuE;AACvE,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD,mFAAmF;AACnF,qBAAa,QAAQ;IAEjB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS;gBADrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS;CAEjD;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjF;AAED,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD"}
@@ -25,8 +25,10 @@ export declare const DEFAULT_TAG_OWNERSHIP_KEYS: ChannelKeys;
25
25
  export interface GraduationPlan {
26
26
  target: string;
27
27
  marker: OwnershipMarker;
28
- /** The ownership tags the emitted resource must carry to be chant-owned. */
28
+ /** The ownership entries the emitted resource must carry to be chant-owned. */
29
29
  ownershipTags: Record<string, string>;
30
+ /** What that channel is called on this target: `tags`, or `labels` for k8s. */
31
+ markerKind: string;
30
32
  /** The finalized, ordered apply runbook. */
31
33
  steps: string[];
32
34
  warnings: string[];
@@ -38,6 +40,14 @@ export interface GraduationOptions {
38
40
  env?: string;
39
41
  /** Override the tag channel (e.g. for a non-AWS lexicon). */
40
42
  channel?: ChannelKeys;
43
+ /**
44
+ * The lexicon the emitted source targets, from the carve provider that
45
+ * adopted the type. It decides how the build and the apply are spelled: a
46
+ * CloudFormation template and `aws cloudformation deploy` for aws, a manifest
47
+ * and `kubectl apply` for k8s (#999). Unknown falls back to the aws wording,
48
+ * which is what every carve was before there was a second provider.
49
+ */
50
+ lexicon?: string;
41
51
  }
42
52
  export declare function graduationPlan(report: CarveReport, opts?: GraduationOptions): GraduationPlan;
43
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"graduate.d.ts","sourceRoot":"","sources":["../../src/terraform/graduate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAIxC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,iBAAsB,GAAG,cAAc,CA2BhG;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAoC9C"}
1
+ {"version":3,"file":"graduate.d.ts","sourceRoot":"","sources":["../../src/terraform/graduate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAA0C,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAIxC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA6BD,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE,iBAAsB,GAAG,cAAc,CA4BhG;AAWD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAqC9C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The AWS carve provider (#2016) — the seam's implementation over the AWS
3
+ * carve-out table (`../aws-resources.ts`), which stays the single source of
4
+ * truth for which AWS Terraform types chant can carve and how.
5
+ *
6
+ * chant AWS constructors take CloudFormation PascalCase properties (e.g.
7
+ * `new Bucket({ BucketName })`), while Terraform state uses the provider's
8
+ * snake_case attributes (`bucket`, `tags`). Attributes without a mapping are
9
+ * preserved in a reference comment, never dropped.
10
+ *
11
+ * Deferred outbound inputs (#998): an attribute whose value the Terraform
12
+ * source read from a survivor (`vpc_id = aws_vpc.main.id`) is not a fact of
13
+ * the carved resource — it is a deploy-time input. Those props are emitted as
14
+ * `params.<name>` references instead of frozen literals, with the state's
15
+ * resolved value as the declared default (see `carve-emit.ts`'s scaffold).
16
+ */
17
+ import type { CarveProvider } from "../carve-provider.js";
18
+ export declare const awsCarveProvider: CarveProvider;
19
+ //# sourceMappingURL=aws.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../../src/terraform/providers/aws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAWH,OAAO,KAAK,EAAiB,aAAa,EAA+C,MAAM,mBAAmB,CAAC;AAgInH,eAAO,MAAM,gBAAgB,EAAE,aAc9B,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The GCP carve provider (#2017) — advise-only.
3
+ *
4
+ * `mapsTo` names a Config Connector type as the gcp lexicon spells it
5
+ * (`GCP::Storage::Bucket`), not a Terraform type and not a raw CNRM kind. Every
6
+ * value here is checked against `lexicons/gcp/dist/meta.json` by
7
+ * `gcp.test.ts`, so an entry pointing at a type the lexicon does not define
8
+ * fails the suite rather than shipping a report that promises a resource chant
9
+ * cannot build.
10
+ *
11
+ * The google Terraform provider and Config Connector wrap the same GCP API, so
12
+ * resource granularity matches almost everywhere. That is why `foldsInto` is
13
+ * empty: unlike S3, where Terraform splits versioning, ACLs and encryption out
14
+ * of the bucket CloudFormation keeps together, GCP has no family where several
15
+ * `google_*` resources collapse into one CNRM resource.
16
+ *
17
+ * Tiers follow the reshaping the constructor demands, not the API's size:
18
+ *
19
+ * 1 — flat rename, `google_pubsub_topic` to `GCP::Pubsub::Topic`.
20
+ * 2 — a cross-resource reference becomes a `*Ref` object, or a Terraform
21
+ * block list becomes a CNRM object. Most of the table.
22
+ * 3 — the native shape is a re-modelling. `google_container_cluster` inlines
23
+ * node pools Terraform also declares separately, `google_sql_database_
24
+ * instance` carries everything under `settings`, and the IAM membership
25
+ * resources map onto one generic `GCP::Iam::PolicyMember` per binding.
26
+ *
27
+ * No `emitTypes` and no `adopt`, so `carve emit` refuses these types on both
28
+ * paths with the same message (#2015). Emit is a larger piece of work than the
29
+ * per-attribute rename the tier map implies: CNRM addresses a sibling through
30
+ * a `*Ref` object rather than the id or self-link Terraform state holds, and
31
+ * the resource's own name lives in `metadata.name` with `resourceID` as the
32
+ * override, so a faithful adopter has to resolve both per type. Declaring emit
33
+ * before that exists would put back the advise/emit cliff #2015 closed.
34
+ */
35
+ import type { CarveProvider, TierInfo } from "../carve-provider.js";
36
+ /** Terraform type → tier, the shape the registry merges into the tier map. */
37
+ export declare const GCP_TIERS: Readonly<Record<string, TierInfo>>;
38
+ /** Terraform type → the HCL attribute carrying its physical name. */
39
+ export declare const GCP_IDENTITY_ATTRS: Readonly<Record<string, string>>;
40
+ export declare const gcpCarveProvider: CarveProvider;
41
+ //# sourceMappingURL=gcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../../src/terraform/providers/gcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiRjE,8EAA8E;AAC9E,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAExD,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI/D,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,aAQ9B,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The carve providers core ships with (#2016). Adding a provider is a file
3
+ * here plus a line in this list — no edit to `adopt-state.ts` or
4
+ * `carve-emit.ts`, which resolve everything through the registry.
5
+ *
6
+ * This module holds no runtime dependency on `../carve-provider`, so the
7
+ * registry can import the list without an import cycle.
8
+ */
9
+ import { awsCarveProvider } from "./aws.js";
10
+ import { gcpCarveProvider } from "./gcp.js";
11
+ import { kubernetesCarveProvider } from "./kubernetes.js";
12
+ import type { CarveProvider } from "../carve-provider.js";
13
+ export declare const BUILTIN_CARVE_PROVIDERS: readonly CarveProvider[];
14
+ export { awsCarveProvider, gcpCarveProvider, kubernetesCarveProvider };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/terraform/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAO,MAAM,uBAAuB,EAAE,SAAS,aAAa,EAI3D,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The Kubernetes carve provider (#2016 seam, #999 emit).
3
+ *
4
+ * `kubernetes_manifest` IS the manifest (tier 1) and is the type emit adopts.
5
+ * The typed provider resources (`kubernetes_deployment`, ...) reshape their HCL
6
+ * schema back into a manifest, so they rank tier 2; the common `_v1` aliases
7
+ * share their base type's entry. They are advise-only: recovering a manifest
8
+ * from the provider's own schema is a per-type reshaping (`container` blocks to
9
+ * `containers`, `metadata` blocks unwrapped from their single-element state
10
+ * arrays), not something the generic path below can do honestly, so emit
11
+ * refuses them on both paths with the same message (#2015).
12
+ *
13
+ * ── Two things `kubernetes_manifest` does not share with an AWS type ──
14
+ *
15
+ * It has no fixed entity type. The target kind lives INSIDE the resource: the
16
+ * `manifest` attribute is the body, and its `apiVersion`/`kind` are what say
17
+ * whether this block is a ConfigMap or a cert-manager Certificate. So `mapsTo`
18
+ * can only name the family, and `adopt` reads the body to learn the rest —
19
+ * which is also why one rule here covers every CRD.
20
+ *
21
+ * It has no live adoption path. `carve emit --env` filters a live export by a
22
+ * native type, and there is no type to filter by until the body is read; state
23
+ * is where the body is. `liveSelectorType` therefore returns undefined and
24
+ * `--env` refuses with "adopts it from state only", rather than importing
25
+ * something else.
26
+ */
27
+ import type { CarveProvider } from "../carve-provider.js";
28
+ export declare const kubernetesCarveProvider: CarveProvider;
29
+ //# sourceMappingURL=kubernetes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kubernetes.d.ts","sourceRoot":"","sources":["../../../src/terraform/providers/kubernetes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAiB,aAAa,EAA2B,MAAM,mBAAmB,CAAC;AAuL/F,eAAO,MAAM,uBAAuB,EAAE,aAarC,CAAC"}
@@ -18,11 +18,19 @@
18
18
  * expression in a block that manages no infrastructure, the same order of work
19
19
  * as recording an outbound deferred input. Hence 4, not 12.
20
20
  *
21
- * Sub-resources that inline into a parent (see `FOLDS_INTO`) are folded into the
21
+ * Sub-resources that inline into a parent (see `foldParentOf`) are folded into the
22
22
  * parent's carve set: they are removed from the ranking and their edge to the
23
23
  * parent is not counted as inbound — inlining them is free, not boundary work.
24
+ *
25
+ * The model itself is not Terraform-specific — the CDK cloud-assembly advisor
26
+ * (#1056) scores construct units with the same arithmetic. What differs per
27
+ * source is the type→tier lookup and the extra signals that source can see, so
28
+ * both are injectable via `ScoreOptions` rather than forked into a second
29
+ * scorer. Everything else — the six penalty terms, the clamp, the bands — is
30
+ * shared verbatim.
24
31
  */
25
- import type { TfGraph } from "./types.js";
32
+ import { type TierInfo } from "./tier-map.js";
33
+ import type { TfGraph, TfNode } from "./types.js";
26
34
  export type PeelabilityBand = "clean leaf" | "carvable w/ edits" | "leave in Terraform";
27
35
  export interface PeelabilityBreakdown {
28
36
  /** Inbound edges from resource/module blocks — a data-source patch each. */
@@ -33,7 +41,12 @@ export interface PeelabilityBreakdown {
33
41
  tier: 1 | 2 | 3 | null;
34
42
  hasDynamic: boolean;
35
43
  instances: number;
36
- /** Signed penalty contributions, for report transparency. */
44
+ /**
45
+ * Signed penalty contributions, for report transparency. The six shared terms
46
+ * are always present; a source-specific scorer may add its own keys (the CDK
47
+ * advisor's `asset`, say). A reader that sums the values reproduces the score;
48
+ * a reader that only knows the six named terms still reads those correctly.
49
+ */
37
50
  penalties: {
38
51
  inbound: number;
39
52
  outbound: number;
@@ -41,8 +54,26 @@ export interface PeelabilityBreakdown {
41
54
  tier: number;
42
55
  dynamic: number;
43
56
  instances: number;
57
+ [term: string]: number;
44
58
  };
45
59
  }
60
+ /**
61
+ * One unit of source a scored node stands for, when the node is a fold of
62
+ * several (#1056). A CDK construct emits 1..n CloudFormation resources and
63
+ * ranks once; this names the resources that carve with it. Absent on the
64
+ * Terraform path, where a fold is expressed by the child's absence from the
65
+ * ranking instead.
66
+ */
67
+ export interface CarveUnitMember {
68
+ /** Identifier within its template/estate — a CFN logical ID. */
69
+ id: string;
70
+ /** Resource type, e.g. `AWS::IAM::Role`. */
71
+ type: string;
72
+ /** The template/stack the member lives in. */
73
+ stack?: string;
74
+ /** The member's own source path, e.g. a CDK construct path. */
75
+ path?: string;
76
+ }
46
77
  export interface Peelability {
47
78
  address: string;
48
79
  kind: "resource" | "module";
@@ -51,11 +82,46 @@ export interface Peelability {
51
82
  /** Native spec type a carve would target; undefined for modules/unsupported. */
52
83
  mapsTo?: string;
53
84
  breakdown: PeelabilityBreakdown;
85
+ /**
86
+ * Source-specific facts about this node that the six penalty terms do not
87
+ * carry — why it was disqualified, what folded into it, what it is. Plain
88
+ * prose, for the report's benefit; nothing keys on it.
89
+ */
90
+ notes?: string[];
91
+ /** The source units folded into this node (#1056). */
92
+ members?: CarveUnitMember[];
93
+ }
94
+ /**
95
+ * Source-specific scoring input for one node, layered on the shared model.
96
+ * Everything here is optional: with no signals a node scores exactly as the
97
+ * Terraform path scores it.
98
+ */
99
+ export interface ScoreSignals {
100
+ /** Extra penalty terms, merged into `breakdown.penalties` and the total. */
101
+ penalties?: Record<string, number>;
102
+ notes?: string[];
103
+ members?: CarveUnitMember[];
104
+ /**
105
+ * When set, the node scores 0 and this is the stated reason. For claims the
106
+ * arithmetic cannot express — a CDK assembly synthesized from dummy lookup
107
+ * values is not a faithful picture of anything, so no score it produces is
108
+ * worth reading.
109
+ */
110
+ disqualified?: string;
111
+ }
112
+ export interface ScoreOptions {
113
+ /**
114
+ * Resource type → native tier. Defaults to the Terraform tier map; the CDK
115
+ * advisor passes a CloudFormation-keyed one. Modules keep the built-in
116
+ * {@link MODULE_TIER} treatment either way.
117
+ */
118
+ tierOf?: (type: string) => TierInfo | null;
119
+ signalsFor?: (node: TfNode) => ScoreSignals;
54
120
  }
55
121
  export declare function bandFor(score: number): PeelabilityBand;
56
122
  /**
57
123
  * Score every carvable node in the estate, ranked most-peelable first. Folded
58
124
  * sub-resources are omitted (they carve with their parent, not on their own).
59
125
  */
60
- export declare function scoreEstate(graph: TfGraph): Peelability[];
126
+ export declare function scoreEstate(graph: TfGraph, opts?: ScoreOptions): Peelability[];
61
127
  //# sourceMappingURL=score.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../src/terraform/score.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAExF,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,OAAO,EAAE,MAA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ACjB,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,CAAC;CAC7C;AAUD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAItD;AAyGD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,YAAiB,GAAG,WAAW,EAAE,CAMlF"}
@@ -1,39 +1,51 @@
1
1
  /**
2
- * Terraform-type → native-spec tier map for the carve-out advisor (#214 T3).
2
+ * Terraform-type → native-spec ranking for the carve-out advisor (#214 T3),
3
+ * resolved through the carve provider registry (`carve-provider.ts`, #2016).
3
4
  *
4
- * The AWS entries are derived from the single AWS carve-out table
5
- * (`aws-resources.ts`), so the advisor ranks exactly the AWS types `carve emit`
6
- * can produce — no advise↔emit cliff. Non-AWS entries (e.g. `kubernetes_manifest`)
7
- * are listed here directly; emit for those is a separate target.
5
+ * Every entry comes from a registered provider: the AWS ones from the single
6
+ * AWS carve-out table (`providers/aws.ts` over `aws-resources.ts`), so the
7
+ * advisor ranks exactly the AWS types `carve emit` can produce — no advise↔emit
8
+ * cliff — and the Kubernetes ones from `providers/kubernetes.ts`, which emits
9
+ * `kubernetes_manifest` and ranks the typed provider resources it does not.
8
10
  *
9
11
  * tier 1 — a clean 1:1 native resource
10
12
  * tier 2 — maps, but with reshaping
11
13
  * tier 3 — a hard/partial map
12
14
  * null — no known native mapping (unsupported provider/type) → score 0
13
- */
14
- export interface TierInfo {
15
- tier: 1 | 2 | 3;
16
- /** The native spec type a carve would target, for the report. */
17
- mapsTo: string;
18
- }
19
- /** TF resource type → native tier. Absent = unsupported (score 0). */
20
- export declare const TIER_MAP: Record<string, TierInfo>;
21
- /**
22
- * TF "sub-resource" types that inline into a parent resource rather than
23
- * standing alone (TF splits config the native spec keeps in one resource).
24
- * A sub-resource that shares its parent's name is folded into the parent's
25
- * carve set: it is not ranked on its own, and its edge to the parent does not
26
- * count as inbound boundary work — inlining it is free.
27
15
  *
28
- * Maps sub-resource TF type → parent TF type.
16
+ * These are functions, not frozen constants: the registry is open, so a
17
+ * provider registered after module load has to be visible here.
29
18
  */
30
- export declare const FOLDS_INTO: Record<string, string>;
19
+ import { type TierInfo } from "./carve-provider.js";
20
+ export { carveEmitTypes, type TierInfo } from "./carve-provider.js";
21
+ /** TF resource type → native tier, over every registered provider. Absent = unsupported (score 0). */
22
+ export declare function tierMap(): Readonly<Record<string, TierInfo>>;
23
+ export declare function resolveTier(tfType: string): TierInfo | null;
31
24
  /**
32
- * The HCL attribute carrying a resource's physical name, per type — AWS entries
33
- * derived from the carve-out table, non-AWS listed directly. A dotted entry is
34
- * a path into nested blocks (`manifest.metadata.name`). Used for the graph's
25
+ * The HCL attribute carrying a resource's physical name. A dotted entry is a
26
+ * path into nested blocks (`manifest.metadata.name`). Used for the graph's
35
27
  * identity and the live-import hint. Absent → fall back to the TF logical name.
36
28
  */
37
- export declare const IDENTITY_ATTR: Record<string, string>;
38
- export declare function resolveTier(tfType: string): TierInfo | null;
29
+ export declare function identityAttrOf(tfType: string): string | undefined;
30
+ /**
31
+ * The parent Terraform type a sub-resource folds into, if any. Terraform splits
32
+ * configuration the native spec keeps in one resource; a sub-resource sharing
33
+ * its parent's name carves with the parent rather than being ranked on its own.
34
+ */
35
+ export declare function foldParentOf(tfType: string): string | undefined;
36
+ /**
37
+ * Can `chant carve emit` produce chant source for this type? Narrower than
38
+ * `resolveTier`: providers also rank types no emit path can adopt (the typed
39
+ * `kubernetes_*` resources, whose manifest only the provider schema knows how
40
+ * to reassemble). Both emit paths — `--state` and `--env` — gate on this, so a
41
+ * type either command refuses is refused by the other with the same message.
42
+ */
43
+ export declare function canCarveEmit(tfType: string): boolean;
44
+ /**
45
+ * Can `chant carve bridge` render a Terraform `data` source for this type? A
46
+ * dotted identity attribute is a path into nested blocks, and a data source
47
+ * body is flat `attr = value` — `manifest.metadata.name = "x"` is not valid
48
+ * HCL. An absent entry is fine: the bridge writes a TODO comment instead.
49
+ */
50
+ export declare function canBridge(tfType: string): boolean;
39
51
  //# sourceMappingURL=tier-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tier-map.d.ts","sourceRoot":"","sources":["../../src/terraform/tier-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB;AA0CD,sEAAsE;AACtE,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAK7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiB7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGhD,CAAC;AAEF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAE3D"}
1
+ {"version":3,"file":"tier-map.d.ts","sourceRoot":"","sources":["../../src/terraform/tier-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjE,sGAAsG;AACtG,wBAAgB,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAE5D;AAED,w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