@plasius/asset-contracts 0.5.0 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,24 @@
14
14
  - **Security**
15
15
  - (placeholder)
16
16
 
17
+ ## [0.6.0] - 2026-10-24
18
+
19
+ - **Added**
20
+ - Opt-in public-safe canonical conversion diagnostics with fixed codes/text,
21
+ resource/source identity, explicit loss/fallback evidence and legacy converter
22
+ projections. Reuses lazy model-core evaluation; independent approval and
23
+ promotion gates remain required.
24
+ - (placeholder)
25
+
26
+ - **Changed**
27
+ - (placeholder)
28
+
29
+ - **Fixed**
30
+ - (placeholder)
31
+
32
+ - **Security**
33
+ - (placeholder)
34
+
17
35
  ## [0.5.0] - 2026-10-24
18
36
 
19
37
  - **Added**
@@ -330,3 +348,4 @@
330
348
  [0.4.5]: https://github.com/Plasius-LTD/asset-contracts/releases/tag/v0.4.5
331
349
  [0.4.6]: https://github.com/Plasius-LTD/asset-contracts/releases/tag/v0.4.6
332
350
  [0.5.0]: https://github.com/Plasius-LTD/asset-contracts/releases/tag/v0.5.0
351
+ [0.6.0]: https://github.com/Plasius-LTD/asset-contracts/releases/tag/v0.6.0
package/README.md CHANGED
@@ -28,6 +28,7 @@ The exported surface covers:
28
28
  - asset job metadata contracts
29
29
  - manifest and file descriptor contracts
30
30
  - opt-in canonical model package inventory and exact-byte qualification
31
+ - opt-in public-safe canonical conversion diagnostics and resource/source binding
31
32
  - screenshot plan definitions
32
33
  - review findings and review report contracts
33
34
  - immutable promotion record contracts
@@ -104,6 +105,68 @@ runtime parser or renderer loading. Downstream adoption must use a released
104
105
  package. See [ADR 0009](./docs/adrs/adr-0009-model-resource-manifest-qualification.md)
105
106
  and [TDR 0004](./docs/tdrs/tdr-0004-model-resource-manifest-qualification.md).
106
107
 
108
+ ## Public Conversion Diagnostics
109
+
110
+ `qualifyModelConversionDiagnostics` adds an opt-in, version-1 JSON boundary over
111
+ published model-core diagnostics. It reuses the canonical evaluator, loading it
112
+ only when this async helper is called. Existing factories remain compatible.
113
+
114
+ ```ts
115
+ import { qualifyModelConversionDiagnostics } from "@plasius/asset-contracts";
116
+
117
+ const result = await qualifyModelConversionDiagnostics({
118
+ outcome: "completed", // or "unsupported" / "failed" from your trusted adapter
119
+ source: publicSourceProvenance, // existing ModelProvenance; original source hash
120
+ report: canonicalDiagnosticInput, // model-core GpuModelDiagnosticInput
121
+ resources: [{ path: "/meshes/0", resource: publicModelResourceRef }],
122
+ }, { signal: abortController.signal, timeoutMs: 10_000 });
123
+ // Only these existing diagnostic/loss fields belong in ModelConverterEvidence:
124
+ const converterEvidence = { ...trustedConverterIdentity, ...result.converter };
125
+ ```
126
+
127
+ Every non-root diagnostic path must match exactly one supplied resource binding.
128
+ The root path `/` refers to `result.source`; no resource is fabricated. Resource
129
+ references use existing credential-free `mcp://models/...` contracts and include
130
+ hash, length and MIME identity. Conflicting references for one URI reject. These
131
+ bindings and provenance are caller assertions, not proof that bytes were read.
132
+ Use manifest qualification and independent promotion checks at their boundaries.
133
+
134
+ Statuses are derived deterministically: explicit failure wins, then unsupported
135
+ data/outcome, then canonical rejection, then warning or clean success. Loss
136
+ requires canonical explicit consent; denied loss produces blocking legacy loss
137
+ evidence. Only canonical accepted repairs receive a fallback rule id. Unknown
138
+ repair rules remain blocking. Arbitrary adapter codes, messages, private paths,
139
+ provider exceptions, original repair values and forensic rawSource are never
140
+ serialized; unknown adapter codes map to fixed category codes. Public codes are
141
+ `conversion.warning`, `conversion.repair`, `conversion.loss.dropped`,
142
+ `conversion.loss.approximated`, `conversion.unsupported`, `conversion.blocked`
143
+ and `conversion.failed`, with fixed bounded messages. Malformed input rejects
144
+ with value-free `ModelConversionDiagnosticsError.code`.
145
+
146
+ This projection is technical evidence only. `technicalAccepted` never replaces
147
+ human approval, malware/security, rights, fidelity, confirmation or promotion
148
+ receipts. `result.converter` contains the exact existing diagnostics/losses
149
+ shape; the detailed `result.diagnostics` additionally binds resources and
150
+ loss/fallback metadata. Preserve all independent evidence when composing it.
151
+
152
+ Inputs must be inert JSON records; getters, exotic prototypes, sparse arrays,
153
+ cycles, symbols and extra contract keys reject. Metadata is snapshotted before
154
+ awaiting. Fixed ceilings are 100 issues/resources, depth 12, 16,384 values,
155
+ 2,048 characters per string and 262,144 total string characters. Non-completed
156
+ outcomes reserve one issue slot for a terminal diagnostic, so accept at most
157
+ 99 issues. Arrays never exceed legacy 100-entry limits. Default deadline is
158
+ 10 seconds, configurable from 1–60,000 ms; cancellation/deadlines bound the
159
+ lazy import wait and are checked around bounded synchronous evaluation. They
160
+ cannot preempt JavaScript evaluation or cancel the platform module loader.
161
+ No network, filesystem, logs, retries or persistent state are introduced.
162
+
163
+ Use the backend-evaluated `gpu.model.conversion.enabled` adoption decision;
164
+ disabled/rollback paths retain existing factories and diagnostics. No live flag
165
+ lookup/mutation or UI capability is added. The already-published exact
166
+ model-core0.7.0 dependency supplies evaluation without adding a parser or
167
+ renderer. No dependency version changes are needed. See [ADR 0010](./docs/adrs/adr-0010-public-conversion-diagnostics.md)
168
+ and [TDR 0005](./docs/tdrs/tdr-0005-public-conversion-diagnostics.md).
169
+
107
170
  ## Private Artifact Prevention
108
171
 
109
172
  Signed contributor agreements and contributor acceptance records are retained
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -39,6 +49,7 @@ __export(index_exports, {
39
49
  MODEL_CANDIDATE_HARD_GATE_KINDS: () => MODEL_CANDIDATE_HARD_GATE_KINDS,
40
50
  MODEL_CONFIRMATION_VIEW_KINDS: () => MODEL_CONFIRMATION_VIEW_KINDS,
41
51
  MODEL_CONFIRMATION_VIEW_SIZE_PX: () => MODEL_CONFIRMATION_VIEW_SIZE_PX,
52
+ MODEL_CONVERSION_DIAGNOSTIC_LIMITS: () => MODEL_CONVERSION_DIAGNOSTIC_LIMITS,
42
53
  MODEL_GENERATOR_DISABLED_REASON_CODE: () => MODEL_GENERATOR_DISABLED_REASON_CODE,
43
54
  MODEL_MATCH_ASSURANCE_BANDS: () => MODEL_MATCH_ASSURANCE_BANDS,
44
55
  MODEL_MATCH_ASSURANCE_THRESHOLDS: () => MODEL_MATCH_ASSURANCE_THRESHOLDS,
@@ -55,6 +66,7 @@ __export(index_exports, {
55
66
  MODEL_RESOURCE_MANIFEST_LIMITS: () => MODEL_RESOURCE_MANIFEST_LIMITS,
56
67
  MODEL_RIGHTS_STATUSES: () => MODEL_RIGHTS_STATUSES,
57
68
  MODEL_TEXT_ONLY_ASSURANCE_CEILING_REASON_CODE: () => MODEL_TEXT_ONLY_ASSURANCE_CEILING_REASON_CODE,
69
+ ModelConversionDiagnosticsError: () => ModelConversionDiagnosticsError,
58
70
  ModelResourceManifestError: () => ModelResourceManifestError,
59
71
  PVOX_ASSEMBLY_CLOSURE_HASH_DOMAIN: () => PVOX_ASSEMBLY_CLOSURE_HASH_DOMAIN,
60
72
  PVOX_ASSET_MANIFEST_VERSION: () => PVOX_ASSET_MANIFEST_VERSION,
@@ -246,6 +258,7 @@ __export(index_exports, {
246
258
  normalizeAssetId: () => normalizeAssetId,
247
259
  normalizePvoxRootHeaderForHashV1: () => normalizePvoxRootHeaderForHashV1,
248
260
  projectPvoxNamedJsonClosureV1: () => projectPvoxNamedJsonClosureV1,
261
+ qualifyModelConversionDiagnostics: () => qualifyModelConversionDiagnostics,
249
262
  qualifyModelResourceManifest: () => qualifyModelResourceManifest,
250
263
  toLegacyModelResolutionState: () => toLegacyModelResolutionState,
251
264
  validateGpuAssetFiles: () => validateGpuAssetFiles
@@ -6940,9 +6953,9 @@ function snapshot(value, budget, depth = 0) {
6940
6953
  return value;
6941
6954
  }
6942
6955
  if (Array.isArray(value)) return Object.freeze(list(value).map((item) => snapshot(item, budget, depth + 1)));
6943
- const fields = record(value);
6944
- for (const key of Object.keys(fields)) fields[key] = snapshot(fields[key], budget, depth + 1);
6945
- return Object.freeze(fields);
6956
+ const fields2 = record(value);
6957
+ for (const key of Object.keys(fields2)) fields2[key] = snapshot(fields2[key], budget, depth + 1);
6958
+ return Object.freeze(fields2);
6946
6959
  }
6947
6960
  function path(value) {
6948
6961
  if (typeof value !== "string" || value.length > 1024 || !value.length) fail();
@@ -7051,6 +7064,153 @@ async function qualify(input) {
7051
7064
  return Object.freeze({ ...manifest, files: Object.freeze([...manifest.files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0)) });
7052
7065
  }
7053
7066
 
7067
+ // src/model-conversion-diagnostics.ts
7068
+ var MODEL_CONVERSION_DIAGNOSTIC_LIMITS = Object.freeze({ issues: 100, resources: 100, values: 16384, depth: 12, string: 2048, characters: 262144, timeoutMs: 6e4 });
7069
+ var ModelConversionDiagnosticsError = class extends TypeError {
7070
+ constructor(code) {
7071
+ super(`Invalid model conversion diagnostics: ${code}`);
7072
+ this.code = code;
7073
+ this.name = "ModelConversionDiagnosticsError";
7074
+ }
7075
+ code;
7076
+ };
7077
+ function fail2(code = "invalid-input") {
7078
+ throw new ModelConversionDiagnosticsError(code);
7079
+ }
7080
+ function fields(value) {
7081
+ if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) fail2();
7082
+ const result = /* @__PURE__ */ Object.create(null);
7083
+ const keys = Reflect.ownKeys(value);
7084
+ if (keys.length > 1024) fail2("limit-exceeded");
7085
+ for (const key of keys) {
7086
+ if (typeof key !== "string" || key.length > 128 || ["__proto__", "prototype", "constructor"].includes(key)) fail2();
7087
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
7088
+ if (!("value" in descriptor) || !descriptor.enumerable) fail2();
7089
+ result[key] = descriptor.value;
7090
+ }
7091
+ return result;
7092
+ }
7093
+ function only(record2, keys) {
7094
+ if (Object.keys(record2).some((key) => !keys.includes(key))) fail2();
7095
+ }
7096
+ function snapshot2(value, budget, depth = 0) {
7097
+ if (--budget.values < 0 || depth > MODEL_CONVERSION_DIAGNOSTIC_LIMITS.depth) fail2("limit-exceeded");
7098
+ if (value === null || typeof value === "boolean") return value;
7099
+ if (typeof value === "string") {
7100
+ budget.characters -= value.length;
7101
+ if (value.length > MODEL_CONVERSION_DIAGNOSTIC_LIMITS.string || budget.characters < 0) fail2("limit-exceeded");
7102
+ return value;
7103
+ }
7104
+ if (typeof value === "number" && Number.isFinite(value)) return value;
7105
+ if (Array.isArray(value)) {
7106
+ if (Object.getPrototypeOf(value) !== Array.prototype || value.length > 1024) fail2("limit-exceeded");
7107
+ if (Reflect.ownKeys(value).length !== value.length + 1) fail2();
7108
+ const result = [];
7109
+ for (let i = 0; i < value.length; i++) {
7110
+ const descriptor = Object.getOwnPropertyDescriptor(value, String(i));
7111
+ if (!descriptor || !("value" in descriptor) || !descriptor.enumerable) fail2();
7112
+ result.push(snapshot2(descriptor.value, budget, depth + 1));
7113
+ }
7114
+ return Object.freeze(result);
7115
+ }
7116
+ const record2 = fields(value);
7117
+ for (const key of Object.keys(record2)) {
7118
+ budget.characters -= key.length;
7119
+ if (budget.characters < 0) fail2("limit-exceeded");
7120
+ record2[key] = snapshot2(record2[key], budget, depth + 1);
7121
+ }
7122
+ return Object.freeze(record2);
7123
+ }
7124
+ function legacy(value) {
7125
+ return Object.freeze({ severity: value.severity, code: value.code, message: value.message });
7126
+ }
7127
+ async function qualifyModelConversionDiagnostics(input, options = {}) {
7128
+ let timer;
7129
+ let signal;
7130
+ let onAbort;
7131
+ try {
7132
+ const start = performance.now();
7133
+ const controls = fields(options);
7134
+ only(controls, ["signal", "timeoutMs"]);
7135
+ const timeoutMs = controls.timeoutMs === void 0 ? 1e4 : controls.timeoutMs;
7136
+ if (typeof timeoutMs !== "number" || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > MODEL_CONVERSION_DIAGNOSTIC_LIMITS.timeoutMs) fail2();
7137
+ signal = controls.signal;
7138
+ const aborted = Object.getOwnPropertyDescriptor(AbortSignal.prototype, "aborted").get;
7139
+ const check = () => {
7140
+ if (signal !== void 0 && aborted.call(signal)) fail2("aborted");
7141
+ if (performance.now() - start >= timeoutMs) fail2("deadline-exceeded");
7142
+ };
7143
+ check();
7144
+ const args = fields(snapshot2(input, { values: MODEL_CONVERSION_DIAGNOSTIC_LIMITS.values, characters: MODEL_CONVERSION_DIAGNOSTIC_LIMITS.characters }));
7145
+ only(args, ["outcome", "source", "report", "resources"]);
7146
+ if (!["completed", "unsupported", "failed"].includes(args.outcome)) fail2();
7147
+ const source = createModelProvenance(args.source);
7148
+ const reportInput = fields(args.report);
7149
+ const maximumIssues = MODEL_CONVERSION_DIAGNOSTIC_LIMITS.issues - (args.outcome === "completed" ? 0 : 1);
7150
+ if (!Array.isArray(reportInput.issues) || reportInput.issues.length > maximumIssues) fail2("limit-exceeded");
7151
+ if (!Array.isArray(args.resources) || args.resources.length > MODEL_CONVERSION_DIAGNOSTIC_LIMITS.resources) fail2("limit-exceeded");
7152
+ const resources = /* @__PURE__ */ new Map();
7153
+ const identities = /* @__PURE__ */ new Map();
7154
+ for (const value of args.resources) {
7155
+ const binding = fields(value);
7156
+ only(binding, ["path", "resource"]);
7157
+ if (typeof binding.path !== "string" || !binding.path.startsWith("/") || binding.path === "/" || resources.has(binding.path)) fail2();
7158
+ const resource = createModelResourceRef(binding.resource);
7159
+ const identity = JSON.stringify(resource);
7160
+ if (identities.has(resource.uri) && identities.get(resource.uri) !== identity) fail2();
7161
+ identities.set(resource.uri, identity);
7162
+ resources.set(binding.path, resource);
7163
+ }
7164
+ check();
7165
+ const interrupted = new Promise((_resolve, reject) => {
7166
+ timer = setTimeout(() => reject(new ModelConversionDiagnosticsError("deadline-exceeded")), Math.max(1, timeoutMs - (performance.now() - start)));
7167
+ onAbort = () => reject(new ModelConversionDiagnosticsError("aborted"));
7168
+ if (signal) AbortSignal.prototype.addEventListener.call(signal, "abort", onAbort, { once: true });
7169
+ });
7170
+ const core = await Promise.race([import("@plasius/gpu-model-core"), interrupted]);
7171
+ check();
7172
+ const report = core.evaluateGpuModelDiagnostics(reportInput);
7173
+ const diagnostics = report.diagnostics.map((diagnostic) => {
7174
+ const resource = resources.get(diagnostic.path);
7175
+ if (diagnostic.path !== "/" && !resource) fail2("unbound-resource");
7176
+ const base = resource ? { resource } : {};
7177
+ switch (diagnostic.kind) {
7178
+ case "warning":
7179
+ return Object.freeze({ ...base, severity: "warning", code: "conversion.warning", message: "Conversion completed with an advisory." });
7180
+ case "repair":
7181
+ return Object.freeze({ ...base, severity: "warning", code: "conversion.repair", message: "Conversion applied a canonical repair fallback.", fallback: diagnostic.ruleId });
7182
+ case "loss":
7183
+ return Object.freeze({ ...base, severity: reportInput.allowLoss === true ? "warning" : "blocking", code: `conversion.loss.${diagnostic.effect}`, message: diagnostic.effect === "dropped" ? "Conversion dropped source data." : "Conversion approximated source data.", effect: diagnostic.effect });
7184
+ case "unsupported":
7185
+ return Object.freeze({ ...base, severity: "blocking", code: "conversion.unsupported", message: "Conversion encountered unsupported data." });
7186
+ case "blocking-error":
7187
+ return Object.freeze({ ...base, severity: "blocking", code: "conversion.blocked", message: "Conversion did not satisfy canonical validation policy." });
7188
+ }
7189
+ });
7190
+ if (args.outcome !== "completed") diagnostics.push(Object.freeze({ severity: "blocking", code: args.outcome === "failed" ? "conversion.failed" : "conversion.unsupported", message: args.outcome === "failed" ? "Conversion failed." : "Conversion encountered unsupported data." }));
7191
+ const technicalAccepted = args.outcome === "completed" && report.accepted;
7192
+ const status = args.outcome === "failed" ? "failed" : args.outcome === "unsupported" || report.diagnostics.some((item) => item.kind === "unsupported") ? "unsupported" : !technicalAccepted ? "failed" : diagnostics.length ? "warning" : "succeeded";
7193
+ const losses = diagnostics.filter((item) => item.effect !== void 0).map(legacy);
7194
+ check();
7195
+ return Object.freeze({
7196
+ contractVersion: 1,
7197
+ status,
7198
+ technicalAccepted,
7199
+ standard: report.standard,
7200
+ mode: report.mode,
7201
+ source,
7202
+ diagnostics: Object.freeze(diagnostics),
7203
+ converter: Object.freeze({ diagnostics: Object.freeze(diagnostics.filter((item) => item.effect === void 0).map(legacy)), losses: Object.freeze(losses) })
7204
+ });
7205
+ } catch (error) {
7206
+ if (error instanceof ModelConversionDiagnosticsError) throw error;
7207
+ return fail2();
7208
+ } finally {
7209
+ if (timer !== void 0) clearTimeout(timer);
7210
+ if (signal && onAbort) AbortSignal.prototype.removeEventListener.call(signal, "abort", onAbort);
7211
+ }
7212
+ }
7213
+
7054
7214
  // src/index.ts
7055
7215
  var ASSET_CONTRACTS_PACKAGE = "@plasius/asset-contracts";
7056
7216
  var UNIFIED_ASSET_PIPELINE_FEATURE_FLAG_ID = "asset.pipeline.unified-ai-assets.enabled";
@@ -7839,6 +7999,7 @@ function assertRequiredString(value, fieldName) {
7839
7999
  MODEL_CANDIDATE_HARD_GATE_KINDS,
7840
8000
  MODEL_CONFIRMATION_VIEW_KINDS,
7841
8001
  MODEL_CONFIRMATION_VIEW_SIZE_PX,
8002
+ MODEL_CONVERSION_DIAGNOSTIC_LIMITS,
7842
8003
  MODEL_GENERATOR_DISABLED_REASON_CODE,
7843
8004
  MODEL_MATCH_ASSURANCE_BANDS,
7844
8005
  MODEL_MATCH_ASSURANCE_THRESHOLDS,
@@ -7855,6 +8016,7 @@ function assertRequiredString(value, fieldName) {
7855
8016
  MODEL_RESOURCE_MANIFEST_LIMITS,
7856
8017
  MODEL_RIGHTS_STATUSES,
7857
8018
  MODEL_TEXT_ONLY_ASSURANCE_CEILING_REASON_CODE,
8019
+ ModelConversionDiagnosticsError,
7858
8020
  ModelResourceManifestError,
7859
8021
  PVOX_ASSEMBLY_CLOSURE_HASH_DOMAIN,
7860
8022
  PVOX_ASSET_MANIFEST_VERSION,
@@ -8046,6 +8208,7 @@ function assertRequiredString(value, fieldName) {
8046
8208
  normalizeAssetId,
8047
8209
  normalizePvoxRootHeaderForHashV1,
8048
8210
  projectPvoxNamedJsonClosureV1,
8211
+ qualifyModelConversionDiagnostics,
8049
8212
  qualifyModelResourceManifest,
8050
8213
  toLegacyModelResolutionState,
8051
8214
  validateGpuAssetFiles