@wairon/cli 5.1.1-dev.63 → 5.1.1-dev.64

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.
package/dist/cli/index.js CHANGED
@@ -65,7 +65,7 @@ var init_defaults = __esm({
65
65
  copilot: ".github/prompts",
66
66
  codex: ".codex/agents"
67
67
  };
68
- WAIRON_VERSION = "5.1.1-dev.63";
68
+ WAIRON_VERSION = "5.1.1-dev.64";
69
69
  GITHUB_REPO = "SYW-Apps/Waffle-AIron";
70
70
  SUPPORTED_ALIASES = ["wai"];
71
71
  SCAN_EXCLUDE_DIRS = /* @__PURE__ */ new Set([
@@ -2376,6 +2376,23 @@ var init_specs = __esm({
2376
2376
  * name — e.g. a store's `put` realized by `saveSnapshot`.
2377
2377
  */
2378
2378
  symbol: import_zod8.z.string().optional(),
2379
+ /**
2380
+ * The exported binding a consumer imports to REACH this method, when the
2381
+ * realization is published as a value that COMPOSES it rather than exported
2382
+ * in its own right — a rule module publishes `callConformanceRule`, and the
2383
+ * method is the `check` inside it.
2384
+ *
2385
+ * `symbol` cannot say this: it names the code-level name REALIZING the
2386
+ * contract method — the function itself — so a file whose whole published
2387
+ * surface is the composing value publishes a name no contract mentions, and
2388
+ * the surface check reads an unpromised export where the design has a
2389
+ * promised one. Naming the handle here is what closes that gap.
2390
+ *
2391
+ * A declaration, never a waiver: a handle the method's own source file
2392
+ * does not actually export is reported (UNREALIZED_EXPORT_HANDLE) and
2393
+ * allows nothing, so the field can never become a free-text suppression.
2394
+ */
2395
+ exportedVia: import_zod8.z.string().optional(),
2379
2396
  /** Opaque pack/tool extension data (see ExtDataSchema) — preserved verbatim. */
2380
2397
  ext: ExtDataSchema.optional()
2381
2398
  });
@@ -8861,7 +8878,7 @@ function buildCodeIndex(model) {
8861
8878
  const f = facts.get(path71);
8862
8879
  return f?.status === "analyzed" && f.analysisGrade === "exact" ? { path: path71, facts: f } : void 0;
8863
8880
  };
8864
- const originOf = (site, from) => {
8881
+ const originOf2 = (site, from) => {
8865
8882
  const resolved = scopeOf2(site, from);
8866
8883
  if (!resolved) return NO_ORIGIN;
8867
8884
  const { path: scope, facts: f } = resolved;
@@ -8882,7 +8899,7 @@ function buildCodeIndex(model) {
8882
8899
  return NO_ORIGIN;
8883
8900
  };
8884
8901
  const possibleOriginsOf = (site, from) => {
8885
- const proven = originOf(site, from);
8902
+ const proven = originOf2(site, from);
8886
8903
  if (!site.field && !site.constructed && !site.via) return proven;
8887
8904
  const resolved = scopeOf2(site, from);
8888
8905
  if (!resolved) return proven;
@@ -8906,7 +8923,7 @@ function buildCodeIndex(model) {
8906
8923
  declarationsAt,
8907
8924
  anchorsAt: (path71) => namesAt(anchors, pathKey(path71), (f) => /* @__PURE__ */ new Set([...f.declaredNames, ...f.exportedNames, ...f.anchoredNames])),
8908
8925
  findingAnchorsAt: (path71) => namesAt(findingAnchors, pathKey(path71), (f) => new Set(f.anchoredNames)),
8909
- originOf,
8926
+ originOf: originOf2,
8910
8927
  possibleOriginsOf
8911
8928
  };
8912
8929
  }
@@ -13962,6 +13979,107 @@ var init_type_realization = __esm({
13962
13979
  }
13963
13980
  });
13964
13981
 
13982
+ // src/core/rules/conformance/type-shape.ts
13983
+ function originOf(shape) {
13984
+ if (shape.origin === "derived") return "derived shape";
13985
+ return shape.inherited ? "declared shape (which extends another)" : "declared shape";
13986
+ }
13987
+ function absence(optional) {
13988
+ return optional ? "may be absent" : "is always there";
13989
+ }
13990
+ var typeShapeRule;
13991
+ var init_type_shape = __esm({
13992
+ "src/core/rules/conformance/type-shape.ts"() {
13993
+ "use strict";
13994
+ init_models();
13995
+ typeShapeRule = {
13996
+ name: "type-shape",
13997
+ description: "Code-to-contract for the DATA: a type spec's `fields` are compared, name by name, against the shape its `sourcePath` actually declares. `typeRealization` asks whether a type EXISTS in code; nothing asked whether it is the shape the spec claims, so a type spec could describe two fields of a six-field record \u2014 and call the two that are optional required \u2014 straight through a lock and a CI gate, while the ERD, the agent briefs and every implementer read it as truth. That is the worst of the code-to-spec gaps, because a wrong signature eventually breaks at a call site and a type spec that lies is only ever read by humans and agents. Two origins answer at exact grade: a DECLARED shape, whose members the file lists, and a DERIVED one, an alias followed one hop to the object literal its schema is built from, where the keys are the members. A shape that extends another is judged on what it shows and never on what it omits, since its inherited members are not in this file to count.",
13998
+ codes: [
13999
+ {
14000
+ code: "UNREALIZED_TYPE_FIELD",
14001
+ defaultSeverity: "warning",
14002
+ summary: "A type spec declares a field the shape at its sourcePath does not carry \u2014 the spec describes data the code does not have, and every reader of the ERD and the briefs has been told it exists",
14003
+ // Measured code↔spec drift, field by field, at a site the finding names
14004
+ // — which is why every one of them hands over `parts`.
14005
+ carryable: true
14006
+ },
14007
+ {
14008
+ code: "UNDECLARED_TYPE_FIELD",
14009
+ defaultSeverity: "warning",
14010
+ summary: "The shape at a type's sourcePath carries a field the type spec does not declare \u2014 data the design never described, so no diagram draws it and no brief hands it to an implementer",
14011
+ carryable: true
14012
+ },
14013
+ {
14014
+ code: "TYPE_FIELD_OPTIONALITY",
14015
+ defaultSeverity: "warning",
14016
+ summary: "A type spec and the shape at its sourcePath disagree about whether a field may be absent \u2014 one of them is telling a reader the data is guaranteed when it is not, or the reverse",
14017
+ carryable: true
14018
+ }
14019
+ ],
14020
+ check(ctx) {
14021
+ const code = ctx.codeIndex();
14022
+ for (const type of ctx.types) {
14023
+ if (!type.sourcePath) continue;
14024
+ if (type.subsystem && ctx.isInChainedSubproject(type.subsystem)) continue;
14025
+ const file = pathKey(type.sourcePath);
14026
+ const facts = code.factsAt(file);
14027
+ if (!facts || facts.status !== "analyzed" || facts.analysisGrade !== "exact") continue;
14028
+ const symbol = type.symbol ?? type.name;
14029
+ const shapes = facts.typeShapes;
14030
+ if (!shapes || !Object.prototype.hasOwnProperty.call(shapes, symbol)) continue;
14031
+ const shape = shapes[symbol];
14032
+ const specFields = type.fields ?? [];
14033
+ const specFieldNames = new Set(specFields.map((field) => field.name));
14034
+ const specMethodNames = new Set((type.methods ?? []).map((method2) => method2.name));
14035
+ const codeFields = new Map(shape.fields.map((field) => [field.name, field.optional]));
14036
+ const codeMethodNames = new Set(shape.methods);
14037
+ const unrealized = shape.inherited ? [] : specFields.filter((field) => !codeFields.has(field.name) && !codeMethodNames.has(field.name)).map((field) => field.name);
14038
+ if (unrealized.length > 0) {
14039
+ ctx.addIssue(
14040
+ "warning",
14041
+ "UNREALIZED_TYPE_FIELD",
14042
+ `Type "${type.id}" declares ${unrealized.length} field(s) the ${originOf(shape)} "${symbol}" in "${file}" does not carry \u2014 ${unrealized.map((name) => `"${name}"`).join(", ")}. The spec is describing data the code does not have, and nothing breaks at a call site to correct it: the ERD draws those fields and every brief hands them to an implementer as if they were there. Add them to the code, or drop them from the type.`,
14043
+ type.id,
14044
+ void 0,
14045
+ void 0,
14046
+ { at: symbol, covers: unrealized }
14047
+ );
14048
+ }
14049
+ const undeclared = shape.inherited ? [] : shape.fields.filter((field) => !specFieldNames.has(field.name) && !specMethodNames.has(field.name)).map((field) => field.name);
14050
+ if (undeclared.length > 0) {
14051
+ ctx.addIssue(
14052
+ "warning",
14053
+ "UNDECLARED_TYPE_FIELD",
14054
+ `The ${originOf(shape)} "${symbol}" in "${file}" carries ${undeclared.length} field(s) type "${type.id}" does not declare \u2014 ${undeclared.map((name) => `"${name}"`).join(", ")}. Data the design never described is data no diagram draws and no brief hands to an implementer, which is how a record grows past the model of it without anyone deciding to. Model the field, or take it out of the shape.`,
14055
+ type.id,
14056
+ void 0,
14057
+ void 0,
14058
+ { at: symbol, covers: undeclared }
14059
+ );
14060
+ }
14061
+ const disagreed = specFields.filter((field) => {
14062
+ const absentable = codeFields.get(field.name);
14063
+ return absentable !== void 0 && absentable !== !!field.optional;
14064
+ });
14065
+ if (disagreed.length > 0) {
14066
+ const told = disagreed.map((field) => `"${field.name}" (the spec says it ${absence(!!field.optional)}, the code says it ${absence(!!codeFields.get(field.name))})`).join("; ");
14067
+ ctx.addIssue(
14068
+ "warning",
14069
+ "TYPE_FIELD_OPTIONALITY",
14070
+ `Type "${type.id}" and the ${originOf(shape)} "${symbol}" in "${file}" disagree about whether ${disagreed.length} field(s) may be absent \u2014 ${told}. One of them is telling a reader the data is guaranteed when it is not, or the reverse. Absent-able is the code's word for it \u2014 a wrapper that lets the key be missing \u2014 and a wrapper that FILLS a missing key leaves the field required in the value the type finally holds, which is the shape the spec describes.`,
14071
+ type.id,
14072
+ void 0,
14073
+ void 0,
14074
+ { at: symbol, covers: disagreed.map((field) => field.name) }
14075
+ );
14076
+ }
14077
+ }
14078
+ }
14079
+ };
14080
+ }
14081
+ });
14082
+
13965
14083
  // src/core/rules/conformance/unclaimed-source.ts
13966
14084
  var unclaimedSourceRule;
13967
14085
  var init_unclaimed_source = __esm({
@@ -14015,6 +14133,133 @@ var init_unclaimed_source = __esm({
14015
14133
  }
14016
14134
  });
14017
14135
 
14136
+ // src/core/rules/conformance/export-conformance.ts
14137
+ var NOTHING_PROMISED, exportConformanceRule;
14138
+ var init_export_conformance = __esm({
14139
+ "src/core/rules/conformance/export-conformance.ts"() {
14140
+ "use strict";
14141
+ init_models();
14142
+ NOTHING_PROMISED = /* @__PURE__ */ new Set();
14143
+ exportConformanceRule = {
14144
+ name: "export-conformance",
14145
+ description: "Code-to-contract for the SURFACE: does this file publish anything the components it realizes never promised, that another component then takes? The rest of the conformance set reads contract-to-code \u2014 it asks whether the code holds what a spec claims \u2014 so a file could export whatever it liked under a component's name and nothing looked. That is one half of the same hole as a contract promising a parameter it never passes. A method's `exportedVia` names the export a consumer imports to REACH it \u2014 the value that composes it, which `symbol` cannot name because `symbol` names the function inside \u2014 and a declared handle the file does not actually export is itself a finding, so naming one can never become a free-text suppression. Both questions are asked only of a file read at exact grade, and a taker counts only when its own import specifier resolves to the file it is accused of taking from: below that nothing separates an export from a mention, or a shared word from a shared module.",
14146
+ codes: [
14147
+ {
14148
+ code: "UNDECLARED_EXPORT",
14149
+ defaultSeverity: "warning",
14150
+ summary: "A file realizing a component exports a name no contract of that component declares, and a file realizing a DIFFERENT component imports it \u2014 a surface reached across a boundary that the design never promised",
14151
+ // Measured code-to-spec drift at a site the finding names, so the
14152
+ // debt register may carry it — which is why it hands over `parts`.
14153
+ carryable: true
14154
+ },
14155
+ {
14156
+ code: "UNREALIZED_EXPORT_HANDLE",
14157
+ defaultSeverity: "warning",
14158
+ summary: "An implementation method declares an `exportedVia` handle its own source file does not export \u2014 the spec names a published route to the method that nobody can import"
14159
+ // Deliberately NOT carryable, and so it hands over no `parts`: a wrong
14160
+ // handle is one string to correct, and a parking space for it could
14161
+ // only ever be a parking space for a lie.
14162
+ }
14163
+ ],
14164
+ check(ctx) {
14165
+ const code = ctx.codeIndex();
14166
+ const realization = ctx.realizationIndex();
14167
+ const promised = /* @__PURE__ */ new Map();
14168
+ const promise = (file, name) => {
14169
+ if (!name) return;
14170
+ const key = pathKey(file);
14171
+ let names = promised.get(key);
14172
+ if (!names) promised.set(key, names = /* @__PURE__ */ new Set());
14173
+ names.add(name);
14174
+ };
14175
+ for (const file of realization.paths) {
14176
+ for (const component of realization.componentsAt(file)) {
14177
+ for (const method2 of ctx.interfaceMethodsOf(component.id)) promise(file, method2.name);
14178
+ for (const impl of realization.implementationsOf(component.id)) {
14179
+ for (const method2 of impl.methods ?? []) {
14180
+ promise(file, method2.name);
14181
+ promise(file, method2.symbol);
14182
+ }
14183
+ }
14184
+ }
14185
+ }
14186
+ for (const { implementation, method: method2, sourceFile, draftContext } of ctx.implementationMethods()) {
14187
+ const handle = method2.exportedVia;
14188
+ if (!handle || !sourceFile) continue;
14189
+ const file = pathKey(sourceFile);
14190
+ const facts = code.factsAt(file);
14191
+ if (!facts || facts.status !== "analyzed" || facts.analysisGrade !== "exact") continue;
14192
+ if (facts.exportedNames.includes(handle)) {
14193
+ promise(file, handle);
14194
+ continue;
14195
+ }
14196
+ ctx.addIssue(
14197
+ "warning",
14198
+ "UNREALIZED_EXPORT_HANDLE",
14199
+ `Method "${method2.name}" in implementation "${implementation.id}" declares exportedVia "${handle}", but "${file}" exports no such name. A handle names the export a consumer imports to REACH the method \u2014 the value that composes it, which \`symbol\` cannot name because \`symbol\` names the function inside \u2014 so one the file does not publish promises a route nobody can import. It allows nothing either: every export of this file is still read against the contracts. Name the binding the file actually exports, export it, or drop the handle.`,
14200
+ implementation.id,
14201
+ draftContext
14202
+ );
14203
+ }
14204
+ for (const type of ctx.types) {
14205
+ if (!type.sourcePath) continue;
14206
+ promise(type.sourcePath, type.symbol ?? type.name);
14207
+ for (const method2 of type.methods ?? []) {
14208
+ promise(method2.sourcePath ?? type.sourcePath, method2.symbol ?? method2.name);
14209
+ }
14210
+ }
14211
+ const takenFrom = /* @__PURE__ */ new Map();
14212
+ for (const consumer of realization.paths) {
14213
+ if (!code.exactPaths.has(consumer)) continue;
14214
+ for (const [local, binding] of Object.entries(code.factsAt(consumer)?.importBindings ?? {})) {
14215
+ if (binding.namespace) continue;
14216
+ const target = resolveImport(consumer, binding.from, code.paths);
14217
+ if (!target) continue;
14218
+ let names = takenFrom.get(target);
14219
+ if (!names) takenFrom.set(target, names = /* @__PURE__ */ new Map());
14220
+ for (const name of [local, binding.imported]) {
14221
+ if (!name) continue;
14222
+ let takers = names.get(name);
14223
+ if (!takers) names.set(name, takers = /* @__PURE__ */ new Set());
14224
+ takers.add(consumer);
14225
+ }
14226
+ }
14227
+ }
14228
+ for (const file of realization.paths) {
14229
+ const facts = code.factsAt(file);
14230
+ if (!facts || facts.status !== "analyzed" || facts.analysisGrade !== "exact") continue;
14231
+ const declared = promised.get(file) ?? NOTHING_PROMISED;
14232
+ const taken = takenFrom.get(file);
14233
+ const owners = new Set(realization.componentsAt(file).map((c) => c.id));
14234
+ const crossed = [];
14235
+ for (const name of [...new Set(facts.exportedNames)].sort()) {
14236
+ if (declared.has(name)) continue;
14237
+ const takers = taken?.get(name);
14238
+ if (!takers) continue;
14239
+ const crossing = [...takers].some(
14240
+ (taker) => taker !== file && !realization.componentsAt(taker).some((c) => owners.has(c.id))
14241
+ );
14242
+ if (crossing) crossed.push(name);
14243
+ }
14244
+ if (crossed.length === 0) continue;
14245
+ const [owner] = realization.implementationsAt(file).map((impl) => impl.id).sort();
14246
+ ctx.addIssue(
14247
+ "warning",
14248
+ "UNDECLARED_EXPORT",
14249
+ `Source file "${file}" publishes ${crossed.length} name(s) that no contract of the component(s) it realizes (${[...owners].sort().map((id) => `"${id}"`).join(", ")}) declares, and a file realizing NONE of those components imports each one FROM HERE \u2014 ${crossed.map((n) => `"${n}"`).join(", ")}. An export only this file's own components use is the module's private factoring and no concern of the design; one another component reaches for is a surface the design never promised. Declare it as a contract method, stop exporting it, or move it to the component that owns the name.`,
14250
+ owner,
14251
+ void 0,
14252
+ void 0,
14253
+ // The crossings themselves, named the way the message names them, so
14254
+ // a register entry written for today's set cannot carry tomorrow's.
14255
+ { at: file, covers: crossed }
14256
+ );
14257
+ }
14258
+ }
14259
+ };
14260
+ }
14261
+ });
14262
+
14018
14263
  // src/core/rules/conformance/carried-debt.ts
14019
14264
  var carriedDebtRule;
14020
14265
  var init_carried_debt = __esm({
@@ -15338,7 +15583,9 @@ var init_repository = __esm({
15338
15583
  init_integration_sim_wiring();
15339
15584
  init_integration_sim_coverage();
15340
15585
  init_type_realization();
15586
+ init_type_shape();
15341
15587
  init_unclaimed_source();
15588
+ init_export_conformance();
15342
15589
  init_carried_debt();
15343
15590
  init_coupling_health();
15344
15591
  init_signature_language_builtins();
@@ -15504,11 +15751,14 @@ var init_repository = __esm({
15504
15751
  integrationSimFileRule,
15505
15752
  integrationSimWiringRule,
15506
15753
  integrationSimCoverageRule,
15507
- // The data model's own claim on code, and the question no spec can ask
15508
- // from the spec side: which files are named by nothing at all. Last in
15509
- // the family because the second one reads what all the others named.
15754
+ // The data model's own claim on code — does the file hold the type, and is
15755
+ // it the SHAPE the spec claims — and then the question no spec can ask from
15756
+ // the spec side: which files are named by nothing at all. Last in the
15757
+ // family because that one reads what all the others named.
15510
15758
  typeRealizationRule,
15759
+ typeShapeRule,
15511
15760
  unclaimedSourceRule,
15761
+ exportConformanceRule,
15512
15762
  couplingRule,
15513
15763
  // Target-language fit in two questions: what a CONTRACT may name, and what
15514
15764
  // a NARRATIVE may describe.
@@ -15674,7 +15924,10 @@ function walkExact(ts, sourceText, fileName) {
15674
15924
  const typeOnlyBindings = /* @__PURE__ */ new Map();
15675
15925
  const fieldTypes = /* @__PURE__ */ new Map();
15676
15926
  const localTypes = /* @__PURE__ */ new Map();
15927
+ const typeShapes = /* @__PURE__ */ new Map();
15677
15928
  const mutableBindings = /* @__PURE__ */ new Set();
15929
+ const schemaConstants = /* @__PURE__ */ new Map();
15930
+ const derivedAliases = [];
15678
15931
  const receiverKey = (site) => site.via ?? (site.field ? `this.${site.field}` : site.constructed ? `new ${site.constructed}` : "");
15679
15932
  const siteKey = (site) => `${site.member ? "m" : "b"}:${receiverKey(site)}:${site.name}`;
15680
15933
  const addBindingNames = (name) => {
@@ -15708,6 +15961,79 @@ function walkExact(ts, sourceText, fileName) {
15708
15961
  named.add(typeName);
15709
15962
  localTypes.set(name.text, named);
15710
15963
  };
15964
+ const recordDeclaredShape = (name, members, inherited) => {
15965
+ const fields = [];
15966
+ const methods = [];
15967
+ for (const member of members) {
15968
+ const memberName = member.name ? propertyNameText(member.name) : void 0;
15969
+ if (!memberName) continue;
15970
+ if (ts.isMethodSignature(member) || ts.isMethodDeclaration(member) || ts.isGetAccessorDeclaration(member)) {
15971
+ methods.push(memberName);
15972
+ } else if (ts.isPropertySignature(member) || ts.isPropertyDeclaration(member)) {
15973
+ fields.push({ name: memberName, optional: !!member.questionToken });
15974
+ }
15975
+ }
15976
+ const shape = { origin: "declared", fields, methods };
15977
+ if (inherited) shape.inherited = true;
15978
+ typeShapes.set(name, shape);
15979
+ };
15980
+ const inferredSchemaConstant = (type) => {
15981
+ if (!ts.isTypeReferenceNode(type)) return void 0;
15982
+ const reference = ts.isIdentifier(type.typeName) ? type.typeName.text : ts.isQualifiedName(type.typeName) ? type.typeName.right.text : void 0;
15983
+ if (reference !== "infer") return void 0;
15984
+ const [argument] = type.typeArguments ?? [];
15985
+ if (!argument || !ts.isTypeQueryNode(argument) || !ts.isIdentifier(argument.exprName)) return void 0;
15986
+ return argument.exprName.text;
15987
+ };
15988
+ const baseObjectLiteral = (expression) => {
15989
+ let node = expression;
15990
+ const walked = /* @__PURE__ */ new Set();
15991
+ while (node && !walked.has(node)) {
15992
+ walked.add(node);
15993
+ if (ts.isCallExpression(node)) {
15994
+ const callee = node.expression;
15995
+ if (ts.isPropertyAccessExpression(callee) && callee.name.text === "object") {
15996
+ const literal = node.arguments.find((argument) => ts.isObjectLiteralExpression(argument));
15997
+ if (literal) return literal;
15998
+ }
15999
+ node = callee;
16000
+ } else if (ts.isPropertyAccessExpression(node)) {
16001
+ node = node.expression;
16002
+ } else break;
16003
+ }
16004
+ return void 0;
16005
+ };
16006
+ const chainedCombinators = (expression) => {
16007
+ const applied = /* @__PURE__ */ new Set();
16008
+ let node = expression;
16009
+ const walked = /* @__PURE__ */ new Set();
16010
+ while (node && !walked.has(node)) {
16011
+ walked.add(node);
16012
+ if (ts.isCallExpression(node)) {
16013
+ const callee = node.expression;
16014
+ if (ts.isPropertyAccessExpression(callee)) applied.add(callee.name.text);
16015
+ node = callee;
16016
+ } else if (ts.isPropertyAccessExpression(node)) {
16017
+ node = node.expression;
16018
+ } else break;
16019
+ }
16020
+ return applied;
16021
+ };
16022
+ const schemaMembers = (literal) => {
16023
+ const fields = [];
16024
+ for (const property of literal.properties) {
16025
+ const memberName = property.name ? propertyNameText(property.name) : void 0;
16026
+ if (!memberName) continue;
16027
+ if (ts.isShorthandPropertyAssignment(property)) {
16028
+ fields.push({ name: memberName, optional: false });
16029
+ } else if (ts.isPropertyAssignment(property)) {
16030
+ const applied = chainedCombinators(property.initializer);
16031
+ const optional = (applied.has("optional") || applied.has("nullish")) && !applied.has("default");
16032
+ fields.push({ name: memberName, optional });
16033
+ }
16034
+ }
16035
+ return fields;
16036
+ };
15711
16037
  const hasExportModifier = (node) => {
15712
16038
  const mods = node.modifiers;
15713
16039
  return !!mods?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
@@ -15776,6 +16102,23 @@ function walkExact(ts, sourceText, fileName) {
15776
16102
  recordFieldType(node.name, node.type);
15777
16103
  }
15778
16104
  if (ts.isParameter(node) || ts.isVariableDeclaration(node)) recordLocalType(node.name, node.type);
16105
+ if (ts.isInterfaceDeclaration(node)) {
16106
+ recordDeclaredShape(node.name.text, node.members, (node.heritageClauses?.length ?? 0) > 0);
16107
+ } else if (ts.isClassDeclaration(node) && node.name) {
16108
+ const extendsOther = (node.heritageClauses ?? []).some(
16109
+ (clause) => clause.token === ts.SyntaxKind.ExtendsKeyword
16110
+ );
16111
+ recordDeclaredShape(node.name.text, node.members, extendsOther);
16112
+ } else if (ts.isTypeAliasDeclaration(node)) {
16113
+ if (ts.isTypeLiteralNode(node.type)) recordDeclaredShape(node.name.text, node.type.members, false);
16114
+ else {
16115
+ const constant = inferredSchemaConstant(node.type);
16116
+ if (constant) derivedAliases.push({ name: node.name.text, constant });
16117
+ }
16118
+ }
16119
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer && !schemaConstants.has(node.name.text)) {
16120
+ schemaConstants.set(node.name.text, node.initializer);
16121
+ }
15779
16122
  if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node) || ts.isEnumDeclaration(node) || ts.isModuleDeclaration(node)) {
15780
16123
  const name = node.name && ts.isIdentifier(node.name) ? node.name.text : void 0;
15781
16124
  if (name) {
@@ -15851,8 +16194,16 @@ function walkExact(ts, sourceText, fileName) {
15851
16194
  ts.forEachChild(node, visit);
15852
16195
  };
15853
16196
  visit(sf);
16197
+ for (const alias of derivedAliases) {
16198
+ if (typeShapes.has(alias.name)) continue;
16199
+ const initializer = schemaConstants.get(alias.constant);
16200
+ if (!initializer) continue;
16201
+ const literal = baseObjectLiteral(initializer);
16202
+ if (!literal) continue;
16203
+ typeShapes.set(alias.name, { origin: "derived", fields: schemaMembers(literal), methods: [] });
16204
+ }
15854
16205
  const reexportOnly = sf.statements.length > 0 && sf.statements.every((st) => ts.isExportDeclaration(st) && !!st.moduleSpecifier);
15855
- return { declared, anchors, exported, imports, reexports, starExports, namedReexports, complexity, calls, importBindings, typeOnlyBindings, fieldTypes, localTypes, mutableBindings, reexportOnly };
16206
+ return { declared, anchors, exported, imports, reexports, starExports, namedReexports, complexity, calls, importBindings, typeOnlyBindings, fieldTypes, localTypes, typeShapes, mutableBindings, reexportOnly };
15856
16207
  }
15857
16208
  function resolveRelativeModule(fromFile, specifier) {
15858
16209
  if (!specifier.startsWith(".")) return null;
@@ -16034,6 +16385,7 @@ function buildCodeModel(implementations, types, projectRoot2, sourceRoots = [],
16034
16385
  typeOnlyBindings: Object.fromEntries(facts.typeOnlyBindings),
16035
16386
  fieldTypes: Object.fromEntries([...facts.fieldTypes].map(([k, v]) => [k, [...v]])),
16036
16387
  localTypes: Object.fromEntries([...facts.localTypes].map(([k, v]) => [k, [...v]])),
16388
+ typeShapes: Object.fromEntries(facts.typeShapes),
16037
16389
  topLevelMutableBindings: [...facts.mutableBindings],
16038
16390
  reexportOnly: facts.reexportOnly
16039
16391
  };
@@ -29639,6 +29991,7 @@ function createMcpServer(options = {}) {
29639
29991
  intent: import_zod11.z.string().optional().describe("detail: intent \u2014 behavioral prose (what it does and how it fails); substitute for a narrative"),
29640
29992
  conformance: conformanceEnum.optional().describe("Conformance tier for this method (overrides the spec default)"),
29641
29993
  symbol: import_zod11.z.string().optional().describe("Code-level name realizing this contract method in the sourcePath file, when it legitimately differs from the intent-language contract name (e.g. put realized by saveSnapshot)"),
29994
+ exportedVia: import_zod11.z.string().optional().describe("The exported binding a consumer imports to REACH this method, when the realization is published as a value that composes it rather than exported in its own right (a rule module publishes callConformanceRule, and the method is the check inside it). Not symbol, which names the function itself: this names the route to it, so the surface check reads that export as promised. A handle the method's own source file does not actually export is reported (UNREALIZED_EXPORT_HANDLE) and allows nothing"),
29642
29995
  ext: import_zod11.z.record(import_zod11.z.unknown()).optional().describe("Opaque pack/tool extension data for this method (namespaced keys) \u2014 preserved verbatim"),
29643
29996
  narrative: import_zod11.z.array(narrativeStepInput).optional(),
29644
29997
  calls: import_zod11.z.array(import_zod11.z.string().min(1)).optional().describe('The calls this method makes, when its narrative does not show them (detail: intent, or calls-only with no steps authored) \u2014 each as "<component>.<method>", the spelling the debt register and lint allows name a unit with. The narrative walk takes exactly these edges and no others, so an undeclared collaborator is NOT reached: this is what keeps unused-detection honest at a lower detail dial. Each entry is validated like a call step (the component resolves, this component declares it, the method is on its contract). Refused beside a non-empty narrative \u2014 add the call step there instead')