document-model 6.2.3-dev.94 → 6.2.3-dev.96

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.
@@ -1,4 +1,4 @@
1
- import { DefinitionCheckReport, DefinitionCheckSkipReason, DefinitionDiagnostic, DefinitionPath, DefinitionSource, DocumentModelDefinition, DocumentModelModule, DocumentModelPHState, Sha256Digest, UpgradeManifest } from "@powerhousedao/shared/document-model";
1
+ import { DefinitionCheckProfile, DefinitionCheckReport, DefinitionCheckSkipReason, DefinitionDiagnostic, DefinitionPath, DefinitionSource, DocumentModelDefinition, DocumentModelModule, DocumentModelPHState, Sha256Digest, UpgradeManifest } from "@powerhousedao/shared/document-model";
2
2
  //#region src/definition/kernel/diagnostics.d.ts
3
3
  /** @experimental One line: code, severity and phase, location, message, expected, received, related and repair. */
4
4
  export declare function formatDefinitionDiagnostic(diagnostic: DefinitionDiagnostic): string;
@@ -169,8 +169,9 @@ type UnregisteredDefinition = {
169
169
  readonly specifier: `./${string}`;
170
170
  };
171
171
  /**
172
- * What every registered check reads. A wider input lets a later layer
173
- * register checks that need more, without changing the runner.
172
+ * @experimental What every registered check reads. A wider input, such as
173
+ * ph-cli's release evidence, lets a later layer register checks that need
174
+ * more, without changing the runner.
174
175
  */
175
176
  type DefinitionCheckInput = {
176
177
  readonly sourceSet: DefinitionSourceSet;
@@ -188,24 +189,86 @@ type LoadedDefinitionProject = DefinitionCheckInput & {
188
189
  };
189
190
  //#endregion
190
191
  //#region src/definition/tooling/check/types.d.ts
191
- /** One named check over normalized artifacts. It reports normalized paths. */
192
+ /**
193
+ * @experimental One named check over normalized artifacts, which ph-cli passes
194
+ * to `checkProjectDefinitions`. It reports normalized paths.
195
+ */
192
196
  type DefinitionCheck<TInput extends DefinitionCheckInput = DefinitionCheckInput> = {
193
197
  readonly name: string;
194
198
  readonly run: (input: TInput) => readonly DefinitionDiagnostic[] | Promise<readonly DefinitionDiagnostic[]>;
195
199
  };
196
200
  //#endregion
197
201
  //#region src/definition/tooling/check/check-project-definitions.d.ts
202
+ /**
203
+ * @experimental The checks `ph model check` runs on document models. A later
204
+ * layer, such as ph-cli's release profile, adds its own with
205
+ * `[...documentModelChecks, ...theirs]`.
206
+ */
207
+ export declare const documentModelChecks: readonly DefinitionCheck[];
198
208
  /**
199
209
  * @experimental Runs every check over a loaded project and builds the stored
200
210
  * check report with the project's load diagnostics. `definitions` adds
201
- * inventory entries a caller checked itself. Experimental while code-first
202
- * projects are introduced.
211
+ * inventory entries a caller checked itself; `profile` (default `edit`) names
212
+ * the check list the caller ran. Experimental while code-first projects are
213
+ * introduced.
203
214
  */
204
215
  export declare function checkProjectDefinitions<TInput extends DefinitionCheckInput = DefinitionCheckInput>(project: LoadedDefinitionProject & TInput, options?: {
205
216
  readonly checks?: readonly DefinitionCheck<TInput>[];
206
217
  readonly definitions?: DefinitionCheckReport["definitions"];
218
+ readonly profile?: DefinitionCheckProfile;
207
219
  }): Promise<DefinitionCheckReport>;
208
220
  //#endregion
221
+ //#region src/definition/tooling/release/types.d.ts
222
+ /**
223
+ * One reason a host would not serve a model as declared. Plain data, so a
224
+ * host's validator result is passed in as is and tooling never imports a host.
225
+ */
226
+ type HostValidationFindingData = {
227
+ readonly kind: "scalar-unbound";
228
+ readonly documentType: string;
229
+ readonly scalar: string;
230
+ } | {
231
+ readonly kind: "scalar-mismatch";
232
+ readonly documentType: string;
233
+ readonly scalar: string;
234
+ readonly packageName: string;
235
+ /** Canonical JSON of the stored scalar metadata. */
236
+ readonly declared: string;
237
+ readonly registered: string;
238
+ } | {
239
+ readonly kind: "definition-invalid" | "definition-mismatch";
240
+ readonly documentType: string;
241
+ /** The host's wire diagnostics, with paths into the module. */
242
+ readonly diagnostics: readonly DefinitionDiagnostic[];
243
+ };
244
+ /** @experimental A host validator's result, as ph-cli passes it to `releaseChecks`. */
245
+ type HostValidationEvidence = {
246
+ readonly completed: true;
247
+ readonly findings: readonly HostValidationFindingData[];
248
+ } | {
249
+ /** The host validator could not run over the package. */
250
+ readonly completed: false;
251
+ /** What stopped it, package relative. */
252
+ readonly reason: string;
253
+ readonly findings: readonly HostValidationFindingData[];
254
+ };
255
+ /** @experimental The evidence ph-cli gathers for the release profile. */
256
+ type ReleaseEvidence = {
257
+ readonly host: HostValidationEvidence;
258
+ };
259
+ /** @experimental The input `releaseChecks` read. */
260
+ type ReleaseCheckInput = DefinitionCheckInput & {
261
+ readonly release: ReleaseEvidence;
262
+ };
263
+ //#endregion
264
+ //#region src/definition/tooling/release/release-checks.d.ts
265
+ /**
266
+ * @experimental The checks the release profile of `ph build --release` and
267
+ * `ph model check --release` adds to `documentModelChecks`. They read the
268
+ * release evidence a caller gathered.
269
+ */
270
+ export declare const releaseChecks: readonly DefinitionCheck<ReleaseCheckInput>[];
271
+ //#endregion
209
272
  //#region src/definition/tooling/report/status.d.ts
210
273
  type DefinitionStatus = DefinitionCheckReport["status"];
211
274
  //#endregion
@@ -316,6 +379,6 @@ export declare function loadProjectDefinitions(request: {
316
379
  readonly importedFiles: (specifier: string) => readonly string[];
317
380
  }): Promise<ProjectDefinitions>;
318
381
  //#endregion
319
- export type { DefinitionInspectionReport, DefinitionSourceLoadRequest, DefinitionSourceOrigin, DefinitionSourceResolution, DefinitionSourceSelectionRequest, DefinitionSourceSet, DocumentModelFamilyInspection, DocumentModelInspection, LoadedDefinition, LoadedDefinitionSet, NormalizedDocumentModelArtifact, NormalizedDocumentModelResult, ProjectDefinitions, TypeScriptSourceImportInterface };
382
+ export type { DefinitionCheck, DefinitionCheckInput, DefinitionInspectionReport, DefinitionSourceLoadRequest, DefinitionSourceOrigin, DefinitionSourceResolution, DefinitionSourceSelectionRequest, DefinitionSourceSet, DocumentModelFamilyInspection, DocumentModelInspection, HostValidationEvidence, LoadedDefinition, LoadedDefinitionSet, NormalizedDocumentModelArtifact, NormalizedDocumentModelResult, ProjectDefinitions, ReleaseCheckInput, ReleaseEvidence, TypeScriptSourceImportInterface };
320
383
  export {};
321
384
  //# sourceMappingURL=tooling.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooling.d.mts","names":[],"sources":["../src/definition/kernel/diagnostics.ts","../src/definition/tooling/adapters/types.ts","../src/definition/tooling/adapters/code-first-document-model-source-adapter.ts","../src/definition/tooling/definition-source-types.ts","../src/definition/tooling/definition-source-loader.ts","../src/definition/tooling/definition-source-resolution.ts","../src/definition/tooling/adapters/producer.ts","../src/definition/tooling/report/types.ts","../src/definition/tooling/check/types.ts","../src/definition/tooling/check/check-project-definitions.ts","../src/definition/tooling/report/status.ts","../src/definition/tooling/inspect/types.ts","../src/definition/tooling/inspect/inspect-project-definitions.ts","../src/definition/tooling/project/project-definitions.ts"],"mappings":";;;wBAuQgB,2BACd,YAAY;;;;;;;KC3PF;WACD;WACA,QAAQ;WACR;WAEA;WAEA,YAAY;WAEZ,QAAQ;WAER,eAAe;;;KAId;WACD,oBAAoB;WAEpB,iBAAiB;WACjB,sBAAsB;;;;;;;;;wBC+MjB,kCACd,gBACA,QAAQ,mBACP;;;;;;;KCnOS,sBAAsB;;KAGtB,yBAAyB;;;;;;UAOpB;EACf,aAAa;aACF;aACA;aACA,iBAAiB;aACjB,SAAS;MAChB,QAAQ,SAAS;EAErB,iBAAiB,kBAAkB,eAAe;;;KAIxC;WACD;WAEA;;;KAIC,8BAA8B;;;;;WAK/B,iBAAiB;WACjB,SAAS;;;KAIR;WACD;WACA,WAAW;WACX,sBAAsB;;WAElB;WAAqC;;WAErC;WACA,YAAY;;;KAKf,iBAAiB;WAClB,QAAQ;WAER,MAAM;WACN,OAAO;;;KAIN,sBAAsB;WACvB,yBAAyB,iBAAiB;WAC1C,2BAA2B,iBAClC;;;;;;;;;;;;qBCqfS;;EAQX,YAAY,UAAU;EAItB,QACE,SAAS,mCACR;EAIG,2BACJ,SAAS,8BACR,QAAQ;;;;;;;;EA6EL,oBACJ,SAAS;aACE;MAEV;aAEY;aACA,WAAW,SAAS;;aAGpB;aACA,sBAAsB;;EAuB/B,WAAW;;;;;;;;wBC7IH,2BACd,SAAS,mCACR;;;;;;;;KC7iBS,wBAAwB,MAAM,mBAAmB;KAEjD;WACD,oBAAoB;WACpB,sBAAsB;;WAEtB,aAAa,oBAAoB;;KAGhC;WACD,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;;WAET;;WAEA,QAAQ;;WAER;;KAGC,sBACV,OAAO,4BACJ,sBAAsB,QAAQ;;;;KC7BvB;WACD;;WAEA;;WAEA;;;;;;KAOC;WACD,WAAW;;WAEX,oBAAoB;WACpB,uBAAuB;;;KAItB,0BAA0B;WAC3B,aAAa;;WAEb,sBAAsB;;WAEtB,cAAc,oBAAoB;;;;;KC9BjC,gBACV,eAAe,uBAAuB;WAE7B;WACA,MACP,OAAO,oBAEI,yBACT,iBAAiB;;;;;;;;;;wBCkDD,wBACpB,eAAe,uBAAuB,sBAEtC,SAAS,0BAA0B,QACnC;WACW,kBAAkB,gBAAgB;WAClC,cAAc;IAExB,QAAQ;;;KC5DC,mBAAmB;;;;;;;KCGnB;WACD;WACA,QAAQ;WACR;aACE;aACA;;WAEF;aACE;aACA;aACA;eACE;eACA;eACA;eACA;eACA;eACA;iBACE;iBACA;;;;WAIN;aACE;aACA;;WAEF;;;;;;;;KASC;WACD;WACA;WACA;WACA,QAAQ;WACR,eAAe;WACf,mBAAmB;;;;;;;KAQlB;WACD;WACA;WACA,QAAQ;WACR,WAAW;WACX,mBAAmB;WACnB,sBAAsB;;WAEtB,aAAa;;;KAIZ;WACD;WACA;;;;;;;;;;wBC+CK,0BACd,SAAS,yBACT;WAAoB,YAAY;IAC/B;;;;;;;;KCjGS,qBAAqB;;WAEtB;;;;;;;;;;;wBAyJW,uBAAuB;WAClC,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;WACT,qBAAqB;WACrB,gBAAgB;IACvB,QAAQ"}
1
+ {"version":3,"file":"tooling.d.mts","names":[],"sources":["../src/definition/kernel/diagnostics.ts","../src/definition/tooling/adapters/types.ts","../src/definition/tooling/adapters/code-first-document-model-source-adapter.ts","../src/definition/tooling/definition-source-types.ts","../src/definition/tooling/definition-source-loader.ts","../src/definition/tooling/definition-source-resolution.ts","../src/definition/tooling/adapters/producer.ts","../src/definition/tooling/report/types.ts","../src/definition/tooling/check/types.ts","../src/definition/tooling/check/check-project-definitions.ts","../src/definition/tooling/release/types.ts","../src/definition/tooling/release/release-checks.ts","../src/definition/tooling/report/status.ts","../src/definition/tooling/inspect/types.ts","../src/definition/tooling/inspect/inspect-project-definitions.ts","../src/definition/tooling/project/project-definitions.ts"],"mappings":";;;wBAuQgB,2BACd,YAAY;;;;;;;KC3PF;WACD;WACA,QAAQ;WACR;WAEA;WAEA,YAAY;WAEZ,QAAQ;WAER,eAAe;;;KAId;WACD,oBAAoB;WAEpB,iBAAiB;WACjB,sBAAsB;;;;;;;;;wBC+MjB,kCACd,gBACA,QAAQ,mBACP;;;;;;;KCnOS,sBAAsB;;KAGtB,yBAAyB;;;;;;UAOpB;EACf,aAAa;aACF;aACA;aACA,iBAAiB;aACjB,SAAS;MAChB,QAAQ,SAAS;EAErB,iBAAiB,kBAAkB,eAAe;;;KAIxC;WACD;WAEA;;;KAIC,8BAA8B;;;;;WAK/B,iBAAiB;WACjB,SAAS;;;KAIR;WACD;WACA,WAAW;WACX,sBAAsB;;WAElB;WAAqC;;WAErC;WACA,YAAY;;;KAKf,iBAAiB;WAClB,QAAQ;WAER,MAAM;WACN,OAAO;;;KAIN,sBAAsB;WACvB,yBAAyB,iBAAiB;WAC1C,2BAA2B,iBAClC;;;;;;;;;;;;qBCqfS;;EAQX,YAAY,UAAU;EAItB,QACE,SAAS,mCACR;EAIG,2BACJ,SAAS,8BACR,QAAQ;;;;;;;;EA6EL,oBACJ,SAAS;aACE;MAEV;aAEY;aACA,WAAW,SAAS;;aAGpB;aACA,sBAAsB;;EAuB/B,WAAW;;;;;;;;wBC7IH,2BACd,SAAS,mCACR;;;;;;;;KC7iBS,wBAAwB,MAAM,mBAAmB;KAEjD;WACD,oBAAoB;WACpB,sBAAsB;;WAEtB,aAAa,oBAAoB;;KAGhC;WACD,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;;WAET;;WAEA,QAAQ;;WAER;;KAGC,sBACV,OAAO,4BACJ,sBAAsB,QAAQ;;;;KC7BvB;WACD;;WAEA;;WAEA;;;;;;;KAQC;WACD,WAAW;;WAEX,oBAAoB;WACpB,uBAAuB;;;KAItB,0BAA0B;WAC3B,aAAa;;WAEb,sBAAsB;;WAEtB,cAAc,oBAAoB;;;;;;;;KC5BjC,gBACV,eAAe,uBAAuB;WAE7B;WACA,MACP,OAAO,oBAEI,yBACT,iBAAiB;;;;;;;;;qBCYV,8BAA8B;;;;;;;;wBAsCrB,wBACpB,eAAe,uBAAuB,sBAEtC,SAAS,0BAA0B,QACnC;WACW,kBAAkB,gBAAgB;WAClC,cAAc;WACd,UAAU;IAEpB,QAAQ;;;;;;;KCnEC;WAEG;WACA;WACA;;WAGA;WACA;WACA;WACA;;WAEA;WACA;;WAGA;WACA;;WAEA,sBAAsB;;;KAIzB;WAEG;WACA,mBAAmB;;;WAInB;;WAEA;WACA,mBAAmB;;;KAItB;WAA6B,MAAM;;;KAGnC,oBAAoB;WACrB,SAAS;;;;;;;;;qBCvCP,wBAAwB,gBAAgB;;;KCEzC,mBAAmB;;;;;;;KCEnB;WACD;WACA,QAAQ;WACR;aACE;aACA;;WAEF;aACE;aACA;aACA;eACE;eACA;eACA;eACA;eACA;eACA;iBACE;iBACA;;;;WAIN;aACE;aACA;;WAEF;;;;;;;;KASC;WACD;WACA;WACA;WACA,QAAQ;WACR,eAAe;WACf,mBAAmB;;;;;;;KAQlB;WACD;WACA;WACA,QAAQ;WACR,WAAW;WACX,mBAAmB;WACnB,sBAAsB;;WAEtB,aAAa;;;KAIZ;WACD;WACA;;;;;;;;;;wBC+CK,0BACd,SAAS,yBACT;WAAoB,YAAY;IAC/B;;;;;;;;KCjGS,qBAAqB;;WAEtB;;;;;;;;;;;wBAyJW,uBAAuB;WAClC,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;WACT,qBAAqB;WACrB,gBAAgB;IACvB,QAAQ"}
package/dist/tooling.mjs CHANGED
@@ -4167,7 +4167,7 @@ function compareArtifacts(left, right) {
4167
4167
  function compareInventoryEntries(left, right) {
4168
4168
  return compareCodeUnits(left.key, right.key) || (left.version ?? 0) - (right.version ?? 0) || compareCodeUnits(left.source.specifier, right.source.specifier) || compareCodeUnits(canonicalJson(left.source.exportPath ?? []), canonicalJson(right.source.exportPath ?? [])) || compareCodeUnits(left.kind, right.kind);
4169
4169
  }
4170
- /** Builds the stored check report. Profile is `edit`: release checks come later. */
4170
+ /** Builds the stored check report. */
4171
4171
  function definitionCheckReport(input) {
4172
4172
  const diagnostics = sortedUniqueDiagnostics(input.diagnostics);
4173
4173
  const definitions = [...input.artifacts.map((artifact) => ({
@@ -4186,7 +4186,7 @@ function definitionCheckReport(input) {
4186
4186
  const common = {
4187
4187
  kind: "powerhouse.definition-check",
4188
4188
  formatVersion: 1,
4189
- profile: "edit",
4189
+ profile: input.profile,
4190
4190
  sourceSet: input.sourceSet,
4191
4191
  definitions,
4192
4192
  diagnostics,
@@ -4208,8 +4208,9 @@ function definitionCheckReport(input) {
4208
4208
  //#endregion
4209
4209
  //#region src/definition/tooling/check/check-project-definitions.ts
4210
4210
  /**
4211
- * The checks `ph model check` runs on document models. A later layer adds its
4212
- * own with `[...documentModelChecks, ...theirs]`.
4211
+ * @experimental The checks `ph model check` runs on document models. A later
4212
+ * layer, such as ph-cli's release profile, adds its own with
4213
+ * `[...documentModelChecks, ...theirs]`.
4213
4214
  */
4214
4215
  const documentModelChecks = Object.freeze([
4215
4216
  storedMaterializationCheck,
@@ -4235,14 +4236,16 @@ function relocated(diagnostic, relocations) {
4235
4236
  /**
4236
4237
  * @experimental Runs every check over a loaded project and builds the stored
4237
4238
  * check report with the project's load diagnostics. `definitions` adds
4238
- * inventory entries a caller checked itself. Experimental while code-first
4239
- * projects are introduced.
4239
+ * inventory entries a caller checked itself; `profile` (default `edit`) names
4240
+ * the check list the caller ran. Experimental while code-first projects are
4241
+ * introduced.
4240
4242
  */
4241
4243
  async function checkProjectDefinitions(project, options = {}) {
4242
4244
  const relocations = project.relocations ?? /* @__PURE__ */ new Map();
4243
4245
  const diagnostics = [...project.diagnostics];
4244
4246
  for (const check of options.checks ?? documentModelChecks) for (const diagnostic of await check.run(project)) diagnostics.push(relocated(diagnostic, relocations));
4245
4247
  return definitionCheckReport({
4248
+ profile: options.profile ?? "edit",
4246
4249
  sourceSet: project.sourceSet,
4247
4250
  ...project.skipReason !== void 0 && { skipReason: project.skipReason },
4248
4251
  artifacts: project.artifacts,
@@ -4251,6 +4254,160 @@ async function checkProjectDefinitions(project, options = {}) {
4251
4254
  });
4252
4255
  }
4253
4256
  //#endregion
4257
+ //#region src/definition/tooling/release/diagnostic-codes.ts
4258
+ const releaseDiagnostics = defineDiagnosticCatalog({
4259
+ "PH-REL-HOST-SCALAR-UNBOUND": {
4260
+ severity: "error",
4261
+ phase: "package",
4262
+ meaning: "A model declares a package scalar the package registers no binding for, so a host serves it without validation"
4263
+ },
4264
+ "PH-REL-HOST-SCALAR-MISMATCH": {
4265
+ severity: "error",
4266
+ phase: "package",
4267
+ meaning: "A model declares a package scalar whose stored metadata differs from the binding the package registers"
4268
+ },
4269
+ "PH-REL-HOST-DEFINITION-INVALID": {
4270
+ severity: "error",
4271
+ phase: "definition",
4272
+ meaning: "A module's definition fails the wire shape, so a host serves the model from its stored SDL"
4273
+ },
4274
+ "PH-REL-HOST-DEFINITION-MISMATCH": {
4275
+ severity: "error",
4276
+ phase: "definition",
4277
+ meaning: "A module's definition does not serve that module's document type or version, so a host serves the model from its stored SDL"
4278
+ },
4279
+ "PH-REL-HOST-VALIDATION-INCOMPLETE": {
4280
+ severity: "error",
4281
+ phase: "import",
4282
+ meaning: "Host validation did not run, so the release check cannot tell whether a host serves the package as declared"
4283
+ }
4284
+ }, toolingDiagnostics);
4285
+ //#endregion
4286
+ //#region src/definition/tooling/release/checks/host-validation.ts
4287
+ /**
4288
+ * Where an author edits what a finding names. A host finding names a document
4289
+ * type, not a version, so it points at every artifact of that type; a scalar
4290
+ * finding narrows that to the served specifications that declare the scalar.
4291
+ */
4292
+ function findingSites(artifacts, finding) {
4293
+ const ofType = artifacts.filter(({ documentType }) => documentType === finding.documentType);
4294
+ if ("scalar" in finding) {
4295
+ const declaring = ofType.flatMap((artifact) => {
4296
+ const served = servedSpecification(artifact);
4297
+ const index = served?.specification.scalars.findIndex(({ name }) => name === finding.scalar) ?? -1;
4298
+ return served === void 0 || index === -1 ? [] : [{
4299
+ artifact,
4300
+ path: [
4301
+ "specifications",
4302
+ served.index,
4303
+ "scalars",
4304
+ index
4305
+ ]
4306
+ }];
4307
+ });
4308
+ if (declaring.length > 0) return declaring;
4309
+ }
4310
+ return ofType.map((artifact) => ({
4311
+ artifact,
4312
+ path: []
4313
+ }));
4314
+ }
4315
+ /** The first site carries the diagnostic; the others are related locations. */
4316
+ function attribution(sites, finding, alsoHere) {
4317
+ if (sites.length === 0) return {
4318
+ path: [],
4319
+ related: []
4320
+ };
4321
+ const [first, ...others] = sites;
4322
+ return {
4323
+ source: first.artifact.source,
4324
+ path: first.path,
4325
+ related: others.map(({ artifact, path }) => ({
4326
+ source: artifact.source,
4327
+ path,
4328
+ message: alsoHere
4329
+ }))
4330
+ };
4331
+ }
4332
+ function hostFindingDiagnostic(artifacts, finding) {
4333
+ const { documentType } = finding;
4334
+ const sites = findingSites(artifacts, finding);
4335
+ switch (finding.kind) {
4336
+ case "scalar-unbound": {
4337
+ const { source, path, related } = attribution(sites, finding, `This version also declares ${finding.scalar}.`);
4338
+ return releaseDiagnostics.create({
4339
+ code: "PH-REL-HOST-SCALAR-UNBOUND",
4340
+ ...source !== void 0 && { source },
4341
+ definition: {
4342
+ kind: "scalar",
4343
+ key: finding.scalar
4344
+ },
4345
+ path,
4346
+ message: `${documentType} declares package scalar ${finding.scalar}, but the package registers no binding for it, so a host serves ${finding.scalar} values without validating them.`,
4347
+ expected: `an export named ${finding.scalar} in the package's scalars entry`,
4348
+ received: "no binding",
4349
+ repair: `Export the defineScalar binding the model uses from scalars/index.ts under the name ${finding.scalar}.`,
4350
+ ...related.length > 0 && { related }
4351
+ });
4352
+ }
4353
+ case "scalar-mismatch": {
4354
+ const { source, path, related } = attribution(sites, finding, `This version also declares ${finding.scalar}.`);
4355
+ return releaseDiagnostics.create({
4356
+ code: "PH-REL-HOST-SCALAR-MISMATCH",
4357
+ ...source !== void 0 && { source },
4358
+ definition: {
4359
+ kind: "scalar",
4360
+ key: finding.scalar
4361
+ },
4362
+ path,
4363
+ message: `${documentType} declares package scalar ${finding.scalar} differently from the binding package ${finding.packageName} registers, and a host serves the registered binding.`,
4364
+ expected: finding.declared,
4365
+ received: finding.registered,
4366
+ repair: `Use the ${finding.scalar} binding that scalars/index.ts exports in the model, so the model and the package declare one ${finding.scalar}.`,
4367
+ ...related.length > 0 && { related }
4368
+ });
4369
+ }
4370
+ case "definition-invalid":
4371
+ case "definition-mismatch": {
4372
+ const { source, path, related } = attribution(sites, finding, `This version of ${documentType} carries the same definition.`);
4373
+ const invalid = finding.kind === "definition-invalid";
4374
+ const repairs = [...new Set(finding.diagnostics.map((d) => d.repair))];
4375
+ return releaseDiagnostics.create({
4376
+ code: invalid ? "PH-REL-HOST-DEFINITION-INVALID" : "PH-REL-HOST-DEFINITION-MISMATCH",
4377
+ ...source !== void 0 && { source },
4378
+ definition: sites.length === 0 ? {
4379
+ kind: "document-model",
4380
+ key: documentType
4381
+ } : documentModelRef(sites[0].artifact),
4382
+ path,
4383
+ message: invalid ? `A host serves ${documentType} from its stored SDL, because the module's definition fails the wire shape.` : `A host serves ${documentType} from its stored SDL, because the module's definition declares another document type or version.`,
4384
+ repair: repairs.length > 0 ? repairs.join(" ") : "Materialize the module and its definition from the same declaration, and export the module materialize returned.",
4385
+ related: [...related, ...finding.diagnostics.map(({ code, path, message }) => ({
4386
+ path,
4387
+ message: `${code}: ${message}`
4388
+ }))]
4389
+ });
4390
+ }
4391
+ }
4392
+ }
4393
+ //#endregion
4394
+ //#region src/definition/tooling/release/release-checks.ts
4395
+ /**
4396
+ * @experimental The checks the release profile of `ph build --release` and
4397
+ * `ph model check --release` adds to `documentModelChecks`. They read the
4398
+ * release evidence a caller gathered.
4399
+ */
4400
+ const releaseChecks = Object.freeze([{
4401
+ name: "host-validation",
4402
+ run: ({ artifacts, release: { host } }) => [...host.completed ? [] : [releaseDiagnostics.create({
4403
+ code: "PH-REL-HOST-VALIDATION-INCOMPLETE",
4404
+ path: [],
4405
+ message: "Host validation did not run, so this check cannot tell whether a host serves the package's models as declared.",
4406
+ received: host.reason,
4407
+ repair: "Fix what stopped host validation, then run the release check again."
4408
+ })], ...host.findings.map((finding) => hostFindingDiagnostic(artifacts, finding))]
4409
+ }]);
4410
+ //#endregion
4254
4411
  //#region src/definition/tooling/inspect/diagnostic-codes.ts
4255
4412
  const inspectDiagnostics = defineDiagnosticCatalog({ "PH-INSPECT-SELECTION-UNKNOWN": {
4256
4413
  severity: "error",
@@ -5430,6 +5587,6 @@ async function loadProjectDefinitions(request) {
5430
5587
  };
5431
5588
  }
5432
5589
  //#endregion
5433
- export { DefinitionSourceLoader, adaptCodeFirstDocumentModelSource, checkProjectDefinitions, formatDefinitionDiagnostic, inspectProjectDefinitions, loadProjectDefinitions, resolveDefinitionSelection };
5590
+ export { DefinitionSourceLoader, adaptCodeFirstDocumentModelSource, checkProjectDefinitions, documentModelChecks, formatDefinitionDiagnostic, inspectProjectDefinitions, loadProjectDefinitions, releaseChecks, resolveDefinitionSelection };
5434
5591
 
5435
5592
  //# sourceMappingURL=tooling.mjs.map