@carbonenginejs/runtime-utils 0.1.1 → 0.1.3

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 (104) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +23 -23
  3. package/README.md +69 -69
  4. package/THIRD-PARTY-NOTICES.md +64 -64
  5. package/docs/README.md +74 -73
  6. package/docs/architecture.md +101 -101
  7. package/docs/concepts/foundation-consolidation.md +85 -85
  8. package/docs/concepts/model-lifecycle.md +111 -0
  9. package/docs/const-kb.md +85 -87
  10. package/docs/core-types/DECORATOR-TODOS.md +25 -25
  11. package/docs/core-types/README.md +229 -168
  12. package/docs/reference/api.md +105 -102
  13. package/docs/reference/classes/README.md +135 -135
  14. package/package.json +139 -139
  15. package/src/arrays.js +5 -5
  16. package/src/audio/audioFormats.js +34 -34
  17. package/src/audio/index.js +1 -1
  18. package/src/box3.js +331 -331
  19. package/src/bytes.js +56 -56
  20. package/src/compression.js +56 -56
  21. package/src/constants/index.js +7 -7
  22. package/src/constants/trinity.js +13 -13
  23. package/src/constants.js +15 -15
  24. package/src/curve.js +79 -79
  25. package/src/d3d/dxgiFormats.js +46 -46
  26. package/src/d3d/index.js +2 -2
  27. package/src/d3d/primitiveTopology.js +11 -11
  28. package/src/document/CjsCarbonDocument.js +212 -212
  29. package/src/document/CjsClassRegistry.js +373 -373
  30. package/src/document/CjsDocumentDehydrator.js +142 -142
  31. package/src/document/CjsDocumentHydrator.js +156 -156
  32. package/src/document/CjsStructRegistry.js +348 -348
  33. package/src/document/hydrationAdapter.js +129 -129
  34. package/src/document/index.js +6 -6
  35. package/src/errors/CjsError.js +286 -286
  36. package/src/errors/index.js +5 -5
  37. package/src/geometry/box.js +22 -22
  38. package/src/geometry/cylinder.js +22 -22
  39. package/src/geometry/helpers/earcut.js +1 -1
  40. package/src/geometry/helpers/misc.js +3 -3
  41. package/src/geometry/index.js +8 -8
  42. package/src/geometry/json.js +67 -67
  43. package/src/geometry/lathe.js +44 -44
  44. package/src/geometry/plane.js +14 -14
  45. package/src/geometry/shape.js +4 -4
  46. package/src/geometry/sphere.js +24 -24
  47. package/src/geometry/torus.js +14 -14
  48. package/src/graphics/colorSpaces.js +22 -22
  49. package/src/graphics/index.js +4 -4
  50. package/src/graphics/pixelFormats.js +158 -158
  51. package/src/graphics/textureDimensions.js +22 -22
  52. package/src/graphics/trinityEnums.js +87 -87
  53. package/src/index.js +62 -62
  54. package/src/is.js +108 -46
  55. package/src/json.js +23 -23
  56. package/src/lifecycle/CjsLifecycleState.js +77 -77
  57. package/src/lifecycle/index.js +1 -1
  58. package/src/lne3.js +70 -70
  59. package/src/lookup.js +48 -48
  60. package/src/mat3.js +51 -51
  61. package/src/mat4.js +699 -699
  62. package/src/math/index.js +25 -25
  63. package/src/math/scalar.js +63 -63
  64. package/src/media/index.js +1 -1
  65. package/src/media/mediaTypes.js +50 -50
  66. package/src/mesh.js +424 -424
  67. package/src/model/CjsEventEmitter.js +333 -333
  68. package/src/model/CjsModel.js +1589 -1544
  69. package/src/model/CjsModelState.js +72 -72
  70. package/src/model/index.js +4 -4
  71. package/src/model/sourceRecordUtils.js +54 -54
  72. package/src/noise.js +310 -310
  73. package/src/num.js +827 -827
  74. package/src/object.js +39 -39
  75. package/src/path.js +53 -53
  76. package/src/pln.js +125 -125
  77. package/src/pool.js +9 -9
  78. package/src/quat.js +144 -144
  79. package/src/ray3.js +188 -188
  80. package/src/renderContext/formats.js +145 -145
  81. package/src/renderContext/index.js +5 -5
  82. package/src/renderContext/presentation.js +125 -125
  83. package/src/renderContext/resources.js +27 -27
  84. package/src/renderContext/upscaling.js +22 -22
  85. package/src/renderContext/window.js +20 -20
  86. package/src/runtime/CjsRuntimeState.js +50 -50
  87. package/src/schema/CjsSchema.js +555 -318
  88. package/src/schema/index.js +4 -4
  89. package/src/shader/index.js +1 -1
  90. package/src/shader/shaderStages.js +37 -37
  91. package/src/sph3.js +181 -181
  92. package/src/tangent.js +288 -288
  93. package/src/text.js +40 -40
  94. package/src/tri3.js +98 -98
  95. package/src/types/carbonTypes.js +635 -635
  96. package/src/types/index.js +2 -2
  97. package/src/utils.js +58 -58
  98. package/src/validation.js +46 -46
  99. package/src/vec2.js +229 -229
  100. package/src/vec3.js +1188 -1172
  101. package/src/vec4.js +347 -347
  102. package/src/vertex.js +108 -108
  103. package/src/webgpu/index.js +1 -1
  104. package/src/webgpu/textureFormats.js +121 -121
@@ -1,102 +1,102 @@
1
- # Runtime utilities architecture
2
-
3
- Status: Evolving
4
- Scope: `@carbonenginejs/runtime-utils`
5
- Audience: Runtime authors and maintainers
6
- Summary: Defines the package dependency boundary, ownership rules, and stability expectations.
7
-
8
- ## Purpose
9
-
10
- `runtime-utils` supplies the lowest reusable layer for CarbonEngineJS runtime
11
- libraries. Consumers can use it without introducing a dependency on another
12
- organization package or pulling browser and Node tool behavior into the
13
- runtime graph.
14
-
15
- ## Dependency contract
16
-
17
- Organization-dependency-free means:
18
-
19
- - published source must not import another `@carbonenginejs/*` package;
20
- - public subpaths must remain safe to import independently;
21
- - published source must not import Node built-ins or reference Node-only
22
- globals;
23
- - module evaluation must not perform environment-specific work.
24
-
25
- It does not mean that all third-party dependencies are prohibited. A focused,
26
- browser-safe dependency such as `gl-matrix` is acceptable when it supplies a
27
- foundation primitive, preserves independent subpaths, and does not introduce
28
- organization dependency cycles.
29
-
30
- ## Dependency direction
31
-
32
- ```text
33
- runtime-* packages tools-browser (planned; unreleased)
34
- \ /
35
- \ /
36
- v v
37
- runtime-utils
38
- |
39
- v
40
- third-party or Web-standard primitives
41
- ```
42
-
43
- Dependencies point toward `runtime-utils`; `runtime-utils` never reaches back
44
- into a runtime, engine, format, browser tool, or Node tool package.
45
-
46
- ## Admission rules
47
-
48
- Code belongs in `runtime-utils` only when all of these are true:
49
-
50
- 1. More than one runtime-facing package needs the same primitive or contract.
51
- 2. The behavior is useful without application, rendering, resource, or domain
52
- policy.
53
- 3. The implementation can satisfy the dependency contract above.
54
- 4. Its public semantics are stable enough for broad reuse.
55
- 5. Owning it here reduces duplicated foundation behavior rather than merely
56
- shortening an import.
57
-
58
- With foundation consolidation complete, new responsibilities should be
59
- uncommon. Additions require a demonstrated cross-package need and a clear
60
- subpath owner.
61
-
62
- ## Current ownership
63
-
64
- The implemented package currently owns:
65
-
66
- - neutral array, byte, text, JSON, lookup, and path mechanics;
67
- - structured operational errors without logging or transport policy;
68
- - shared `isSomething` predicates and small validation assertions;
69
- - browser-standard gzip decompression helpers;
70
- - scalar, vector, quaternion, matrix, geometry, mesh, tangent, noise, and curve
71
- math;
72
- - shared media, graphics, render-context, audio, shader, D3D, and WebGPU
73
- constants; and
74
- - Carbon type descriptors, schema metadata, models, lifecycle state,
75
- documents, hydration, and dehydration.
76
-
77
- The [API reference](reference/api.md) is the exact current inventory.
78
-
79
- ## Ownership elsewhere
80
-
1
+ # Runtime utilities architecture
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils`
5
+ Audience: Runtime authors and maintainers
6
+ Summary: Defines the package dependency boundary, ownership rules, and stability expectations.
7
+
8
+ ## Purpose
9
+
10
+ `runtime-utils` supplies the lowest reusable layer for CarbonEngineJS runtime
11
+ libraries. Consumers can use it without introducing a dependency on another
12
+ organization package or pulling browser and Node tool behavior into the
13
+ runtime graph.
14
+
15
+ ## Dependency contract
16
+
17
+ Organization-dependency-free means:
18
+
19
+ - published source must not import another `@carbonenginejs/*` package;
20
+ - public subpaths must remain safe to import independently;
21
+ - published source must not import Node built-ins or reference Node-only
22
+ globals;
23
+ - module evaluation must not perform environment-specific work.
24
+
25
+ It does not mean that all third-party dependencies are prohibited. A focused,
26
+ browser-safe dependency such as `gl-matrix` is acceptable when it supplies a
27
+ foundation primitive, preserves independent subpaths, and does not introduce
28
+ organization dependency cycles.
29
+
30
+ ## Dependency direction
31
+
32
+ ```text
33
+ runtime-* packages tools-browser
34
+ \ /
35
+ \ /
36
+ v v
37
+ runtime-utils
38
+ |
39
+ v
40
+ third-party or Web-standard primitives
41
+ ```
42
+
43
+ Dependencies point toward `runtime-utils`; `runtime-utils` never reaches back
44
+ into a runtime, engine, format, browser tool, or Node tool package.
45
+
46
+ ## Admission rules
47
+
48
+ Code belongs in `runtime-utils` only when all of these are true:
49
+
50
+ 1. More than one runtime-facing package needs the same primitive or contract.
51
+ 2. The behavior is useful without application, rendering, resource, or domain
52
+ policy.
53
+ 3. The implementation can satisfy the dependency contract above.
54
+ 4. Its public semantics are stable enough for broad reuse.
55
+ 5. Owning it here reduces duplicated foundation behavior rather than merely
56
+ shortening an import.
57
+
58
+ With foundation consolidation complete, new responsibilities should be
59
+ uncommon. Additions require a demonstrated cross-package need and a clear
60
+ subpath owner.
61
+
62
+ ## Current ownership
63
+
64
+ The implemented package currently owns:
65
+
66
+ - neutral array, byte, text, JSON, lookup, and path mechanics;
67
+ - structured operational errors without logging or transport policy;
68
+ - shared `isSomething` predicates and small validation assertions;
69
+ - browser-standard gzip decompression helpers;
70
+ - scalar, vector, quaternion, matrix, geometry, mesh, tangent, noise, and curve
71
+ math;
72
+ - shared media, graphics, render-context, audio, shader, D3D, and WebGPU
73
+ constants; and
74
+ - Carbon type descriptors, schema metadata, models, lifecycle state,
75
+ documents, hydration, and dehydration.
76
+
77
+ The [API reference](reference/api.md) is the exact current inventory.
78
+
79
+ ## Ownership elsewhere
80
+
81
81
  - Browser-facing demos, clients, remote readers, inspectors, integration
82
- helpers, and usable reference implementations have the planned owner
83
- `@carbonenginejs/tools-browser`, which is not currently released.
84
- - Node filesystems, caches, credentials, servers, command-line interfaces, and
85
- build orchestration belong in `@carbonenginejs/tools-core`.
86
- - Runtime graph objects and domain readers belong in their owning
87
- `runtime-*` package.
88
- - Backend objects and realization policy belong in `engine-*` packages.
89
- - Generated schemas, enums, and domain libraries remain generated artifacts
90
- owned by their producer and consuming domain.
91
-
92
- ## Consolidated foundation boundary
93
-
94
- The former math, constant, and Carbon type-system foundations now live under
95
- coherent `runtime-utils` subpaths. Former math and constant family suffixes
96
- remain available at the top level for mechanical migration, while `/math/*`
97
- and `/const/*` aliases group the same implementations.
98
-
99
- The root intentionally excludes type/model/document barrels so importing a
100
- neutral utility does not initialize registry and model families. See
101
- [Foundation consolidation](concepts/foundation-consolidation.md) for the
102
- layout and migration status.
82
+ helpers, and usable reference implementations belong in
83
+ `@carbonenginejs/tools-browser`.
84
+ - Node filesystems, caches, credentials, servers, command-line interfaces, and
85
+ build orchestration belong in `@carbonenginejs/tools-core`.
86
+ - Runtime graph objects and domain readers belong in their owning
87
+ `runtime-*` package.
88
+ - Backend objects and realization policy belong in `engine-*` packages.
89
+ - Generated schemas, enums, and domain libraries remain generated artifacts
90
+ owned by their producer and consuming domain.
91
+
92
+ ## Consolidated foundation boundary
93
+
94
+ The former math, constant, and Carbon type-system foundations now live under
95
+ coherent `runtime-utils` subpaths. Former math and constant family suffixes
96
+ remain available at the top level for mechanical migration, while `/math/*`
97
+ and `/const/*` aliases group the same implementations.
98
+
99
+ The root intentionally excludes type/model/document barrels so importing a
100
+ neutral utility does not initialize registry and model families. See
101
+ [Foundation consolidation](concepts/foundation-consolidation.md) for the
102
+ layout and migration status.
@@ -1,85 +1,85 @@
1
- # Runtime foundation consolidation
2
-
3
- Status: Evolving
4
- Scope: `@carbonenginejs/runtime-utils` foundation boundary
5
- Audience: Runtime authors, integrators, and maintainers
6
- Summary: Records the consolidated math, constant, and type-system ownership and migration contract.
7
-
8
- ## Purpose
9
-
10
- `runtime-utils` is the single stable, browser-safe foundation commonly
11
- consumed by CarbonEngineJS runtime libraries.
12
-
13
- The surviving repository now contains the former utility, math, constant, and
14
- Carbon type-system implementations. Their inherited test suites run together,
15
- and every advertised package subpath is independently importable.
16
-
17
- ## Current ownership
18
-
19
- `@carbonenginejs/runtime-utils` is the sole current source owner for neutral
20
- mechanics, math, shared constants, Carbon types, schema metadata, registries,
21
- models, documents, lifecycle, hydration, and dehydration.
22
-
23
- ## Implemented layout
24
-
25
- The moved families map directly enough to preserve useful imports:
26
-
27
- | Moved family | `runtime-utils` family |
28
- | --- | --- |
29
- | Math | Existing top-level suffixes such as `./vec3`, plus `./math` and matching `./math/*` aliases |
30
- | Constants | Existing family suffixes such as `./graphics`, plus `./const` and matching `./const/*` aliases |
31
- | Carbon types/models | `./types`, `./schema`, `./model`, `./document`, `./hydration`, and `./lifecycle` |
32
-
33
- The root export may expose common mechanics and family namespaces. It must not
34
- introduce ambiguous duplicate names or require eager evaluation of every math,
35
- constant, schema, model, and document module.
36
-
37
- The package depends on `gl-matrix`. That is compatible with the boundary
38
- because `runtime-utils` prohibits organization dependencies, not focused
39
- browser-safe third-party foundations.
40
-
41
- ## Shared predicates
42
-
43
- There is one curated `runtime-utils/is` surface:
44
-
45
- - predicates return literal booleans;
46
- - generally useful structural checks belong here;
47
- - vector and matrix checks join only with explicit math semantics;
48
- - domain checks remain with their domain package;
49
- - browser-specific checks remain outside this package; their planned,
50
- unreleased owner is `tools-browser`;
51
- - established core predicate behavior wins wherever old names overlap.
52
-
53
- The goal is a useful shared predicate library, not a reduced compatibility
54
- snapshot.
55
-
56
- ## Migration map
57
-
58
- | Former import | Current import |
59
- | --- | --- |
60
- | `@carbonenginejs/core-math` | `@carbonenginejs/runtime-utils/math` |
61
- | `@carbonenginejs/core-math/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
62
- | `@carbonenginejs/runtime-const` | `@carbonenginejs/runtime-utils/const` |
63
- | `@carbonenginejs/runtime-const/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
64
- | `@carbonenginejs/core-types/<subpath>` | The matching `@carbonenginejs/runtime-utils/<subpath>` |
65
- | `@carbonenginejs/core-types` | The direct runtime-utils type/model/document subpaths used by the consumer |
66
-
67
- The former package names are predecessor identities, not compatibility
68
- packages; maintained source lives here. The one deliberate API correction is
69
- scalar Hermite interpolation:
70
- use `cubicHermite` or `cubicHermiteDerivative` with argument order
71
- `(startValue, startTangent, endValue, endTangent, amount)`.
72
-
73
- ## Stability target
74
-
75
- After consolidation, `runtime-utils` should change infrequently. New
76
- responsibilities need a demonstrated cross-runtime use case, browser-safe
77
- semantics, no CarbonEngineJS dependencies, and a coherent public subpath.
78
-
79
- The result is a runtime foundation, not a general utility dumping ground.
80
-
81
- ## Related documentation
82
-
83
- - [Package documentation](../README.md)
84
- - [Architecture and admission rules](../architecture.md)
85
- - [Current API reference](../reference/api.md)
1
+ # Runtime foundation consolidation
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils` foundation boundary
5
+ Audience: Runtime authors, integrators, and maintainers
6
+ Summary: Records the consolidated math, constant, and type-system ownership and migration contract.
7
+
8
+ ## Purpose
9
+
10
+ `runtime-utils` is the single stable, browser-safe foundation commonly
11
+ consumed by CarbonEngineJS runtime libraries.
12
+
13
+ The surviving repository now contains the former utility, math, constant, and
14
+ Carbon type-system implementations. Their inherited test suites run together,
15
+ and every advertised package subpath is independently importable.
16
+
17
+ ## Current ownership
18
+
19
+ `@carbonenginejs/runtime-utils` is the sole current source owner for neutral
20
+ mechanics, math, shared constants, Carbon types, schema metadata, registries,
21
+ models, documents, lifecycle, hydration, and dehydration.
22
+
23
+ ## Implemented layout
24
+
25
+ The moved families map directly enough to preserve useful imports:
26
+
27
+ | Moved family | `runtime-utils` family |
28
+ | --- | --- |
29
+ | Math | Existing top-level suffixes such as `./vec3`, plus `./math` and matching `./math/*` aliases |
30
+ | Constants | Existing family suffixes such as `./graphics`, plus `./const` and matching `./const/*` aliases |
31
+ | Carbon types/models | `./types`, `./schema`, `./model`, `./document`, `./hydration`, and `./lifecycle` |
32
+
33
+ The root export may expose common mechanics and family namespaces. It must not
34
+ introduce ambiguous duplicate names or require eager evaluation of every math,
35
+ constant, schema, model, and document module.
36
+
37
+ The package depends on `gl-matrix`. That is compatible with the boundary
38
+ because `runtime-utils` prohibits organization dependencies, not focused
39
+ browser-safe third-party foundations.
40
+
41
+ ## Shared predicates
42
+
43
+ There is one curated `runtime-utils/is` surface:
44
+
45
+ - predicates return literal booleans;
46
+ - generally useful structural checks belong here;
47
+ - vector and matrix checks join only with explicit math semantics;
48
+ - domain checks remain with their domain package;
49
+ - browser-specific checks remain outside this package and belong in
50
+ `tools-browser`;
51
+ - established core predicate behavior wins wherever old names overlap.
52
+
53
+ The goal is a useful shared predicate library, not a reduced compatibility
54
+ snapshot.
55
+
56
+ ## Migration map
57
+
58
+ | Former import | Current import |
59
+ | --- | --- |
60
+ | `@carbonenginejs/core-math` | `@carbonenginejs/runtime-utils/math` |
61
+ | `@carbonenginejs/core-math/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
62
+ | `@carbonenginejs/runtime-const` | `@carbonenginejs/runtime-utils/const` |
63
+ | `@carbonenginejs/runtime-const/<subpath>` | `@carbonenginejs/runtime-utils/<subpath>` |
64
+ | `@carbonenginejs/core-types/<subpath>` | The matching `@carbonenginejs/runtime-utils/<subpath>` |
65
+ | `@carbonenginejs/core-types` | The direct runtime-utils type/model/document subpaths used by the consumer |
66
+
67
+ The former package names are predecessor identities, not compatibility
68
+ packages; maintained source lives here. The one deliberate API correction is
69
+ scalar Hermite interpolation:
70
+ use `cubicHermite` or `cubicHermiteDerivative` with argument order
71
+ `(startValue, startTangent, endValue, endTangent, amount)`.
72
+
73
+ ## Stability target
74
+
75
+ After consolidation, `runtime-utils` should change infrequently. New
76
+ responsibilities need a demonstrated cross-runtime use case, browser-safe
77
+ semantics, no CarbonEngineJS dependencies, and a coherent public subpath.
78
+
79
+ The result is a runtime foundation, not a general utility dumping ground.
80
+
81
+ ## Related documentation
82
+
83
+ - [Package documentation](../README.md)
84
+ - [Architecture and admission rules](../architecture.md)
85
+ - [Current API reference](../reference/api.md)
@@ -0,0 +1,111 @@
1
+ # Model lifecycle
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-utils/model` and the optional lifecycle-state subpath
5
+ Audience: Runtime authors implementing mutable schema-backed models
6
+ Summary: Defines the current dirty-settlement, traversal, initialization, resource, and optional lifecycle-state contracts.
7
+
8
+ ## Runtime state
9
+
10
+ Every `CjsModel` owns one non-enumerable `__state` value. Its ordinary
11
+ `CjsModelState` contains:
12
+
13
+ - `dirty`, the one generic “a settle is owed” marker;
14
+ - `flags`, lazy invalidations cleared by the consumer that recomputes them;
15
+ - `rebuild`, work requirements cleared by the work method that succeeds;
16
+ - `updating`, the settle re-entrancy guard; and
17
+ - `suppressEvents`, the counted construction/teardown event gate.
18
+
19
+ The event emitter adds event storage only while listeners exist. Flags and
20
+ rebuild requirements are deliberately separate from `dirty`: neither makes
21
+ `IsDirty()` true, and a successful settle does not clear either set.
22
+
23
+ ## Cooperative dirty settlement
24
+
25
+ `SetValues` marks the model dirty only when at least one field changes and
26
+ `markDirty !== false`. Schema-declared flag and rebuild consequences add tokens
27
+ to their respective sets; they do not independently mark the model dirty. Code
28
+ that mutates fields directly must call `MarkDirty()` or explicitly call
29
+ `UpdateValues()` to say “apply these changes.”
30
+
31
+ `UpdateValues()` always runs at least one `OnModified()` pass. It clears
32
+ `dirty` before each pass and repeats when the hook dirties the model again.
33
+ The model must settle within 32 passes.
34
+
35
+ - Returning `false` from `OnModified()` rejects the settle and retains
36
+ `dirty`.
37
+ - Throwing or exceeding the pass limit also retains `dirty`.
38
+ - A successful settle emits one final `modified` event with `{ source }`
39
+ unless events are suppressed.
40
+
41
+ The pipeline cannot promise a changed-property list to `OnModified()` or to
42
+ the ordinary settled event. Callers that need changed names use the
43
+ `SetValues` return value. A direct `SetValues(..., { markDirty: false })` path
44
+ may emit an immediate payload containing `properties`; that is not the normal
45
+ settled-event shape.
46
+
47
+ ## Initialization
48
+
49
+ `CjsModel.from()` constructs or imports the graph, resolves references, then
50
+ initializes models created by the operation. Each initialization walk follows
51
+ owned children in post-order:
52
+
53
+ 1. suppress events for the model;
54
+ 2. add every declared flag/rebuild consequence and mark it dirty;
55
+ 3. call an optional `Initialize()` with no arguments;
56
+ 4. settle anything still dirty with events suppressed; and
57
+ 5. release the event gate.
58
+
59
+ Children therefore initialize before their owning parents. Shared or cyclic
60
+ graphs use the operation's visited set and initialize each model once.
61
+
62
+ The document hydration adapter has its own `construct`, `applyValues`, and
63
+ `finalize` contract. Its exact `Initialize` argument policy is not normalized
64
+ with `CjsModel.from()` and should not be assumed interchangeable.
65
+
66
+ ## Traversal and resources
67
+
68
+ `Traverse(visitor, options)` follows only schema-declared model relationships
69
+ and does not revisit cycles. It supports:
70
+
71
+ - pre-order or post-order visits;
72
+ - forward or reverse field/list order; and
73
+ - all relationships or owned relationships only.
74
+
75
+ Returning `false` from a pre-order visitor prunes that model's descendants.
76
+ Post-order return values are ignored.
77
+
78
+ `GetResources(out)` traverses the whole model graph, deduplicates resources,
79
+ and replaces the supplied output array. It collects schema-declared resource
80
+ fields and adds any iterable returned by `OnGetResources()`. A resource hook
81
+ does not prune descendants.
82
+
83
+ ## Optional lifecycle state
84
+
85
+ The `./lifecycle` subpath can install `CjsLifecycleState` into
86
+ `__state.lifecycle`. Its current statuses are `alive`, `destroyPending`,
87
+ `destroying`, and `destroyed`.
88
+
89
+ Installing this state is optional. An object without it is ordinarily alive
90
+ and unmanaged. Runtime-utils does not provide a generic lifecycle manager or
91
+ automatic transitions between these statuses.
92
+
93
+ ## Not provided by this foundation
94
+
95
+ The current model/lifecycle surface does not define:
96
+
97
+ - a generic `Destroy` operation;
98
+ - ownership-aware cloning or destruction;
99
+ - generic `SetValue` or `GetValue` methods;
100
+ - fetching;
101
+ - pre-modification events;
102
+ - property-level dirty state; or
103
+ - persistent initialization-transition management.
104
+
105
+ Domain packages may define those behaviors when they own the policy. They
106
+ must not infer them from historical lifecycle proposals.
107
+
108
+ ## Related documentation
109
+
110
+ - [Carbon type and model guide](../core-types/README.md)
111
+ - [Current API reference](../reference/api.md)