@plasius/gpu-model-core 0.1.0 → 0.3.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/README.md +131 -0
- package/dist/index.cjs +679 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +239 -1
- package/dist/index.d.ts +239 -1
- package/dist/index.js +669 -214
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,137 @@ Canonical model document, resource graph, diagnostics, and adapter contracts.
|
|
|
4
4
|
|
|
5
5
|
This repository is the dedicated package boundary defined by ADR 0094.
|
|
6
6
|
|
|
7
|
+
## Diagnostics, repairs and conversion loss
|
|
8
|
+
|
|
9
|
+
`evaluateGpuModelDiagnostics` validates a format adapter's completed report.
|
|
10
|
+
It defaults to strict mode, rejecting every standard violation. Tolerant and
|
|
11
|
+
forensic modes accept only supported rules with `repairApplied: true`, which
|
|
12
|
+
attests that the adapter performed and verified the exact `action` exposed by
|
|
13
|
+
`GPU_MODEL_REPAIR_RULES`. It does **not** parse a model or perform repairs.
|
|
14
|
+
Continue to validate the repaired document with `validateGpuModelDocument`.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { evaluateGpuModelDiagnostics } from "@plasius/gpu-model-core";
|
|
18
|
+
|
|
19
|
+
const report = evaluateGpuModelDiagnostics({
|
|
20
|
+
standard: "gltf-glb",
|
|
21
|
+
mode: "tolerant",
|
|
22
|
+
issues: [{
|
|
23
|
+
kind: "violation",
|
|
24
|
+
ruleId: "missing-normals",
|
|
25
|
+
code: "NORMAL_REQUIRED",
|
|
26
|
+
path: "/meshes/0/primitives/0/attributes/NORMAL",
|
|
27
|
+
message: "Required normals were missing",
|
|
28
|
+
originalValue: null,
|
|
29
|
+
repairApplied: true, // Adapter already generated and validated normals.
|
|
30
|
+
}],
|
|
31
|
+
});
|
|
32
|
+
// report.accepted === true; report.repairs contains the complete repair record.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Blocking errors, repairs, unsupported data, warnings and loss are separate
|
|
36
|
+
`kind` variants. Unknown rules and unsupported data block every mode. Repairs
|
|
37
|
+
preserve `originalValue`, `action`, `severity`, `affectedPath`, `confidence`, and
|
|
38
|
+
`ruleId`. The supported profiles are `gltf-glb`, `obj-mtl`, `fbx`, and `cad-bim`;
|
|
39
|
+
OBJ cannot use the skin-weight repair rule. The exported policy text records
|
|
40
|
+
the upstream rule; executable contract actions deliberately narrow ambiguous
|
|
41
|
+
fallbacks: invalid primitives are dropped (never clamped), unavailable textures
|
|
42
|
+
remain unresolved, and malformed material references use the canonical default.
|
|
43
|
+
These three fallbacks require a `kind: "loss"` issue at the same path. Each loss
|
|
44
|
+
states `effect: "dropped" | "approximated"`; any loss blocks acceptance unless
|
|
45
|
+
`allowLoss: true` is explicitly supplied, including in strict mode.
|
|
46
|
+
|
|
47
|
+
Forensic mode requires `rawSource`, a relevant, scrubbed JSON snapshot. Other
|
|
48
|
+
modes reject that field to prevent unintended retention. Source evidence is
|
|
49
|
+
separate from ordinary diagnostics and remains available even when conversion
|
|
50
|
+
is rejected. Represent source NaN/Infinity as descriptive strings, not numbers.
|
|
51
|
+
Never include credentials, signed URLs or unrelated personal data, and never
|
|
52
|
+
log raw evidence or repair snapshots. The package performs no logging, I/O,
|
|
53
|
+
persistence or credential detection. Use serialized JSON as the boundary for
|
|
54
|
+
untrusted executable producers; JavaScript Proxies are not inert data.
|
|
55
|
+
|
|
56
|
+
`GPU_MODEL_DIAGNOSTIC_LIMITS` bounds the entire input to 1 MiB of JSON UTF-8,
|
|
57
|
+
4096 issues, 16384 JSON values, depth 12, 1024 members per evidence container
|
|
58
|
+
and 65536 UTF-16 units per string. All ceilings apply together. Optional
|
|
59
|
+
`maxEvidenceBytes` lowers the aggregate byte ceiling, including report fields
|
|
60
|
+
and the limit itself. Overflow, unknown keys, getters, cycles, sparse arrays,
|
|
61
|
+
exotic objects and malformed reports throw a static `GpuModelDiagnosticsError`
|
|
62
|
+
without echoing caller data. Successful output is deeply frozen and owned by
|
|
63
|
+
the package; caller objects remain mutable and unchanged.
|
|
64
|
+
|
|
65
|
+
The parent `gpu.model.conversion.enabled` flag governs adapter adoption. Keep
|
|
66
|
+
it disabled until adapter-specific conformance tests pass; rollback disables
|
|
67
|
+
the flag and restores strict mode. This API changes no stored flag and adds no
|
|
68
|
+
UI capability. Synthetic contract fixtures cover glTF, OBJ, FBX and CAD reports;
|
|
69
|
+
actual parsing and geometry verification belong to their format adapters.
|
|
70
|
+
See [ADR-0008](docs/adrs/adr-0008-bounded-adapter-diagnostics-and-repair-ledgers.md).
|
|
71
|
+
|
|
72
|
+
## Canonical conversion resource graph
|
|
73
|
+
|
|
74
|
+
`createGpuModelResourceGraph` projects a privately verified `GpuModelDocument`
|
|
75
|
+
into a frozen dependency graph for resources, accessors, textures, materials,
|
|
76
|
+
skeletons (including joints), skins, animations, provenance and conversion
|
|
77
|
+
packages. It reuses the canonical values and immutable `Blob` payloads. Material
|
|
78
|
+
bindings retain samplers and intended usage; texture values retain their hashes,
|
|
79
|
+
MIME types, paths, colour spaces and export embedding policy.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { createGpuModelResourceGraph, gpuModelResourceKey,
|
|
83
|
+
type GpuModelDocument } from "@plasius/gpu-model-core";
|
|
84
|
+
|
|
85
|
+
declare const document: GpuModelDocument; // From the verification factory.
|
|
86
|
+
const graph = createGpuModelResourceGraph(document, {
|
|
87
|
+
resources: document.resources.map(resource => ({
|
|
88
|
+
resourceId: resource.id,
|
|
89
|
+
location: { kind: "embedded" },
|
|
90
|
+
exportEmbeddingPolicy: "inherit-source",
|
|
91
|
+
})),
|
|
92
|
+
packages: [{ id: "conversion", members: document.resources.map(resource => ({
|
|
93
|
+
kind: "resource", id: resource.id,
|
|
94
|
+
})) }],
|
|
95
|
+
});
|
|
96
|
+
const conversion = graph.nodes.find(node =>
|
|
97
|
+
node.key === gpuModelResourceKey("package", "conversion"));
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Supply exactly one binding per document resource. For external origins use
|
|
101
|
+
`location: { kind: "external", relativePath: "textures/albedo.png" }`; the bytes
|
|
102
|
+
must already have been resolved and verified. Paths use portable ASCII letters,
|
|
103
|
+
digits, dots, underscores, hyphens and slash separators, with no absolute paths,
|
|
104
|
+
traversal, URL syntax, device names or trailing dots. Components are at most 255
|
|
105
|
+
characters and paths at most 1024. Case-insensitive duplicate paths and file versus
|
|
106
|
+
directory collisions fail. Descriptors do not authorize network/file access.
|
|
107
|
+
|
|
108
|
+
Resource export policies are `inherit-source`, `prefer-embedded`,
|
|
109
|
+
`prefer-external` and `forbid-embedding`. The last requires an external origin.
|
|
110
|
+
Exporters must satisfy resource and texture restrictions together, resolve
|
|
111
|
+
preferences for the target, enforce destination-root confinement and validate
|
|
112
|
+
their actual output. The graph neither writes packages nor proves export success.
|
|
113
|
+
Asset catalogue admission and promotion remain owned by `@plasius/asset-contracts`.
|
|
114
|
+
|
|
115
|
+
`gpuModelResourceKey(kind, id)` encodes a JSON tuple, independent of declaration
|
|
116
|
+
order and locale. Logical IDs are distinct from byte-content hashes. Nodes and
|
|
117
|
+
dependency keys are sorted; joint/animation sample order stays intact. Package
|
|
118
|
+
members are typed references, may include packages, and must form a DAG. Missing,
|
|
119
|
+
repeated or cyclic references fail with fixed `GpuModelResourceGraphError.code`
|
|
120
|
+
values. Canonical document validation still owns scene and semantic references.
|
|
121
|
+
Animation target associations remain in canonical values, outside dependency
|
|
122
|
+
edges. This is a resource dependency graph, not a replacement scene graph.
|
|
123
|
+
|
|
124
|
+
`GPU_MODEL_RESOURCE_GRAPH_LIMITS` caps 65536 nodes, 262144 dependency declarations
|
|
125
|
+
(including repeated semantic dependencies before deduplication), and 256 packages.
|
|
126
|
+
These ceilings may reject a large otherwise-valid canonical document. Construction
|
|
127
|
+
performs no I/O, retries, logging or hashing; input accessors and malformed
|
|
128
|
+
containers fail closed. Do not treat executable JavaScript Proxies as inert input.
|
|
129
|
+
`isGpuModelResourceGraph` recognizes only locally constructed graphs. Structured
|
|
130
|
+
clones must be rebuilt from a reverified document. The graph retains authored
|
|
131
|
+
metadata and provenance: it is not a redaction boundary or a public logging format.
|
|
132
|
+
|
|
133
|
+
Adoption inherits the remotely evaluated `gpu.model.conversion.enabled` flag;
|
|
134
|
+
rollback disables conversion adoption and pins the prior package release. No
|
|
135
|
+
stored flag or UI capability changes here. See
|
|
136
|
+
[ADR-0009](docs/adrs/adr-0009-canonical-conversion-resource-graph.md).
|
|
137
|
+
|
|
7
138
|
## Implementation tracker
|
|
8
139
|
|
|
9
140
|
The canonical conversion architecture is defined by [ADR 0094 in `plasius-ltd-site`](https://github.com/Plasius-LTD/plasius-ltd-site/blob/main/docs/adrs/adr-0094-gpu-model-family-and-canonical-proxy-conversion.md). The package implementation work is split into Project-tracked Tasks:
|