@githolon/dsl 0.108.7 → 0.110.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.
Files changed (307) hide show
  1. package/assets/operation-contract.wasm +0 -0
  2. package/check_package.mjs +12 -15
  3. package/compile_package.mjs +17 -18
  4. package/compile_proof.mjs +16 -1
  5. package/dart/CHANGELOG.md +76 -1
  6. package/dart/README.md +25 -2
  7. package/dart/lib/src/admission_decision.dart +41 -0
  8. package/dart/lib/src/application_framework_calls.dart +52 -2
  9. package/dart/lib/src/application_model_adoption.dart +187 -0
  10. package/dart/lib/src/application_status.dart +73 -0
  11. package/dart/lib/src/console_enrolment.dart +271 -0
  12. package/dart/lib/src/console_http_io.dart +26 -0
  13. package/dart/lib/src/console_http_stub.dart +7 -0
  14. package/dart/lib/src/dev_cloud.dart +69 -22
  15. package/dart/lib/src/generated_call.dart +83 -23
  16. package/dart/lib/src/kernel_primitives.dart +119 -0
  17. package/dart/lib/src/nms_conformance_runtime.dart +1 -1
  18. package/dart/lib/src/nms_generated_runtime.dart +32 -10
  19. package/dart/lib/src/nms_test_environment.dart +1 -1
  20. package/dart/lib/src/node_runner_transport.dart +41 -46
  21. package/dart/lib/src/observed_session_directory.dart +70 -0
  22. package/dart/lib/src/operation_receipts.dart +112 -0
  23. package/dart/lib/src/peer_application_streams.dart +103 -0
  24. package/dart/lib/src/reception/dart_reception.dart +4280 -0
  25. package/dart/lib/src/reception/event_desk.dart +211 -0
  26. package/dart/lib/src/reception/extremum_read.dart +46 -0
  27. package/dart/lib/src/reception/local_copies.dart +371 -0
  28. package/dart/lib/src/reception/peer_office_connection.dart +11 -0
  29. package/dart/lib/src/reception/progress_desk.dart +267 -0
  30. package/dart/lib/src/reception/reception_contract.dart +11 -0
  31. package/dart/lib/src/reception/reception_session.dart +284 -0
  32. package/dart/lib/src/reception/sync_diagnostics.dart +26 -0
  33. package/dart/lib/src/reception/workspace_preparation_report.dart +126 -0
  34. package/dart/lib/src/replica_readiness.dart +123 -0
  35. package/dart/lib/src/runner/node-entry.mjs +23905 -15774
  36. package/dart/lib/src/runtime_v2_gateway.dart +56 -3
  37. package/dart/lib/src/runtime_v2_transport.dart +544 -3
  38. package/dart/lib/src/session_bound.dart +200 -311
  39. package/dart/lib/src/signing_identity_kernel.dart +84 -0
  40. package/dart/lib/src/sync_status_projection.dart +548 -0
  41. package/dart/lib/src/sync_status_reducer.dart +170 -0
  42. package/dart/lib/src/test_harness.dart +809 -1153
  43. package/dart/lib/src/testing/test_custody.dart +66 -0
  44. package/dart/lib/src/testing/test_peer.dart +328 -0
  45. package/dart/lib/src/typed_watch_registry.dart +169 -0
  46. package/dart/lib/src/workspace_open_progress.dart +27 -0
  47. package/dart/pubspec.lock +24 -1
  48. package/dart/pubspec.yaml +7 -2
  49. package/dart/pubspec_overrides.yaml +2 -0
  50. package/dart/test/admission_decision_test.dart +48 -0
  51. package/dart/test/background_model_adoption_test.dart +228 -0
  52. package/dart/test/bundle_version_pairing_test.dart +4 -4
  53. package/dart/test/child_authentication_repair_test.dart +359 -0
  54. package/dart/test/cloud_bound_local_shell_test.dart +119 -0
  55. package/dart/test/console_enrolment_refusal_test.dart +52 -0
  56. package/dart/test/console_enrolment_test.dart +227 -0
  57. package/dart/test/errors_test.dart +5 -5
  58. package/dart/test/event_plane_seam_test.dart +50 -164
  59. package/dart/test/extremum_read_test.dart +58 -0
  60. package/dart/test/fixtures/wedge/wedge-entry.mjs +3 -21
  61. package/dart/test/generated_query_test.dart +32 -0
  62. package/dart/test/harness_phase_timeout_test.dart +18 -23
  63. package/dart/test/kernel_author_after_read_test.dart +242 -0
  64. package/dart/test/kernel_fence_test.dart +137 -0
  65. package/dart/test/local_copies_test.dart +222 -0
  66. package/dart/test/model_adoption_test.dart +198 -0
  67. package/dart/test/node_peer_local_custody_test.dart +153 -0
  68. package/dart/test/offer_authentication_proof_test.dart +352 -52
  69. package/dart/test/operation_compatibility_test.dart +151 -0
  70. package/dart/test/platform_credential_effect_test.dart +386 -0
  71. package/dart/test/receiving_group_open_test.dart +213 -0
  72. package/dart/test/reception/workspace_preparation_report_test.dart +103 -0
  73. package/dart/test/reception_span_trace_test.dart +23 -0
  74. package/dart/test/replica_readiness_test.dart +156 -0
  75. package/dart/test/runtime_projections_test.dart +92 -0
  76. package/dart/test/runtime_v2_gateway_test.dart +131 -0
  77. package/dart/test/signing_identity_kernel_test.dart +75 -0
  78. package/dart/test/sync_status_preparation_report_test.dart +29 -0
  79. package/dart/test/sync_status_reducer_test.dart +419 -0
  80. package/dart/test/test_harness_test.dart +71 -95
  81. package/dart/test/typed_query_watch_test.dart +170 -0
  82. package/dart/test/typed_watch_registry_test.dart +249 -0
  83. package/dart_lints/README.md +18 -0
  84. package/dart_lints/lib/nomos_lints.dart +70 -0
  85. package/dart_lints/pubspec.lock +580 -0
  86. package/dart_lints/pubspec.yaml +12 -0
  87. package/dart_lints/test/reference_identity_test.dart +75 -0
  88. package/dart_types/CHANGELOG.md +18 -0
  89. package/dart_types/lib/nomos_kernel_protocol.dart +21 -1
  90. package/dart_types/lib/nomos_types.dart +9 -1
  91. package/dart_types/lib/src/admission_decision.dart +37 -0
  92. package/dart_types/lib/src/aggregate_meta.dart +1 -1
  93. package/dart_types/lib/src/approved_model.dart +65 -0
  94. package/dart_types/lib/src/custody.dart +10 -18
  95. package/dart_types/lib/src/error_info.dart +4 -4
  96. package/dart_types/lib/src/errors.dart +29 -29
  97. package/dart_types/lib/src/foreign_ref.dart +62 -33
  98. package/dart_types/lib/src/local_work_rejected.dart +3 -3
  99. package/dart_types/lib/src/nomos_ref.dart +3 -1
  100. package/dart_types/lib/src/principal.dart +2 -2
  101. package/dart_types/lib/src/proto/google/protobuf/any.pb.dart +163 -0
  102. package/dart_types/lib/src/proto/google/protobuf/any.pbenum.dart +11 -0
  103. package/dart_types/lib/src/proto/nomos/discovery/v1/workspace_placement.pb.dart +137 -0
  104. package/dart_types/lib/src/proto/nomos/discovery/v1/workspace_placement.pbenum.dart +11 -0
  105. package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pb.dart +20721 -10433
  106. package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pbenum.dart +555 -27
  107. package/dart_types/lib/src/proto/nomos/runtime/v2/application_desk.pb.dart +387 -0
  108. package/dart_types/lib/src/proto/nomos/runtime/v2/application_desk.pbenum.dart +46 -0
  109. package/dart_types/lib/src/proto/nomos/runtime/v2/application_readiness_desk.pb.dart +295 -0
  110. package/dart_types/lib/src/proto/nomos/runtime/v2/application_readiness_desk.pbenum.dart +139 -0
  111. package/dart_types/lib/src/proto/nomos/runtime/v2/authentication_desk.pb.dart +269 -0
  112. package/dart_types/lib/src/proto/nomos/runtime/v2/authentication_desk.pbenum.dart +103 -0
  113. package/dart_types/lib/src/proto/nomos/runtime/v2/compatibility_desk.pb.dart +417 -0
  114. package/dart_types/lib/src/proto/nomos/runtime/v2/compatibility_desk.pbenum.dart +62 -0
  115. package/dart_types/lib/src/proto/nomos/runtime/v2/correspondence_desk.pb.dart +9968 -0
  116. package/dart_types/lib/src/proto/nomos/runtime/v2/correspondence_desk.pbenum.dart +133 -0
  117. package/dart_types/lib/src/proto/nomos/runtime/v2/credentials_desk.pb.dart +204 -0
  118. package/dart_types/lib/src/proto/nomos/runtime/v2/credentials_desk.pbenum.dart +54 -0
  119. package/dart_types/lib/src/proto/nomos/runtime/v2/custody_desk.pb.dart +1550 -0
  120. package/dart_types/lib/src/proto/nomos/runtime/v2/custody_desk.pbenum.dart +11 -0
  121. package/dart_types/lib/src/proto/nomos/runtime/v2/framework.pb.dart +710 -0
  122. package/dart_types/lib/src/proto/nomos/runtime/v2/framework.pbenum.dart +11 -0
  123. package/dart_types/lib/src/proto/nomos/runtime/v2/identity_desk.pb.dart +845 -0
  124. package/dart_types/lib/src/proto/nomos/runtime/v2/identity_desk.pbenum.dart +11 -0
  125. package/dart_types/lib/src/proto/nomos/runtime/v2/interaction_desk.pb.dart +198 -0
  126. package/dart_types/lib/src/proto/nomos/runtime/v2/interaction_desk.pbenum.dart +11 -0
  127. package/dart_types/lib/src/proto/nomos/runtime/v2/law_desk.pb.dart +369 -0
  128. package/dart_types/lib/src/proto/nomos/runtime/v2/law_desk.pbenum.dart +11 -0
  129. package/dart_types/lib/src/proto/nomos/runtime/v2/maintenance_desk.pb.dart +609 -0
  130. package/dart_types/lib/src/proto/nomos/runtime/v2/maintenance_desk.pbenum.dart +65 -0
  131. package/dart_types/lib/src/proto/nomos/runtime/v2/model_adoption_desk.pb.dart +358 -0
  132. package/dart_types/lib/src/proto/nomos/runtime/v2/model_adoption_desk.pbenum.dart +100 -0
  133. package/dart_types/lib/src/proto/nomos/runtime/v2/observability_desk.pb.dart +2231 -0
  134. package/dart_types/lib/src/proto/nomos/runtime/v2/observability_desk.pbenum.dart +271 -0
  135. package/dart_types/lib/src/proto/nomos/runtime/v2/placement_desk.pb.dart +1286 -0
  136. package/dart_types/lib/src/proto/nomos/runtime/v2/placement_desk.pbenum.dart +11 -0
  137. package/dart_types/lib/src/proto/nomos/runtime/v2/receiving_group_desk.pb.dart +636 -0
  138. package/dart_types/lib/src/proto/nomos/runtime/v2/receiving_group_desk.pbenum.dart +116 -0
  139. package/dart_types/lib/src/proto/nomos/runtime/v2/records_desk.pb.dart +1637 -0
  140. package/dart_types/lib/src/proto/nomos/runtime/v2/records_desk.pbenum.dart +175 -0
  141. package/dart_types/lib/src/proto/nomos/runtime/v2/recovery_desk.pb.dart +1269 -0
  142. package/dart_types/lib/src/proto/nomos/runtime/v2/recovery_desk.pbenum.dart +129 -0
  143. package/dart_types/lib/src/proto/nomos/runtime/v2/residency_desk.pb.dart +2782 -0
  144. package/dart_types/lib/src/proto/nomos/runtime/v2/residency_desk.pbenum.dart +97 -0
  145. package/dart_types/lib/src/proto/nomos/runtime/v2/runtime.pb.dart +2232 -8627
  146. package/dart_types/lib/src/proto/nomos/runtime/v2/runtime.pbenum.dart +0 -358
  147. package/dart_types/lib/src/proto/nomos/runtime/v2/sealing_desk.pb.dart +1639 -0
  148. package/dart_types/lib/src/proto/nomos/runtime/v2/sealing_desk.pbenum.dart +46 -0
  149. package/dart_types/lib/src/runtime_outcome.dart +133 -0
  150. package/dart_types/lib/src/subscriptions.dart +116 -23
  151. package/dart_types/pubspec.yaml +1 -1
  152. package/dart_types/test/extremum_subscriptions_test.dart +40 -0
  153. package/dart_types/test/foreign_ref_resolution_test.dart +75 -0
  154. package/dart_types/test/nomos_ref_address_test.dart +25 -0
  155. package/dart_types/test/ordered_subscriptions_test.dart +34 -0
  156. package/operation_contract_check.mjs +24 -0
  157. package/package.json +11 -6
  158. package/src/aggregate.ts +70 -10
  159. package/src/application_topology.ts +18 -11
  160. package/src/attested.ts +3 -0
  161. package/src/attested_core.ts +46 -3
  162. package/src/birth_meter_ensure.ts +19 -7
  163. package/src/births.ts +29 -4
  164. package/src/build_package.ts +140 -13
  165. package/src/business_birth.ts +181 -4
  166. package/src/codegen_call_proto.ts +1274 -0
  167. package/src/codegen_call_usda.ts +49 -6
  168. package/src/codegen_dart.ts +79 -44
  169. package/src/codegen_dart_client.ts +458 -800
  170. package/src/{codegen_dart_application.ts → codegen_dart_facade.ts} +331 -582
  171. package/src/codegen_dart_framework_calls.ts +320 -37
  172. package/src/codegen_dart_indexed_variant.ts +159 -0
  173. package/src/codegen_dart_scenario.ts +42 -13
  174. package/src/codegen_proof.ts +3 -3
  175. package/src/codegen_provider_dart.ts +5 -0
  176. package/src/codegen_query_proto.ts +158 -0
  177. package/src/codegen_refusal.ts +189 -0
  178. package/src/codegen_result_proto.ts +931 -0
  179. package/src/codegen_result_usda.ts +4 -0
  180. package/src/codegen_ts.ts +464 -616
  181. package/src/codegen_workspace_access.ts +105 -0
  182. package/src/compatibility_graph.ts +759 -0
  183. package/src/compatibility_usda.ts +264 -0
  184. package/src/compile_package_main.ts +1994 -1189
  185. package/src/custody_placement.ts +156 -0
  186. package/src/custody_placement_usda.ts +91 -0
  187. package/src/decl_shapes.ts +21 -2
  188. package/src/describe_model.ts +1 -0
  189. package/src/directive.ts +59 -2
  190. package/src/drivers.ts +51 -0
  191. package/src/engine_entry.ts +52 -8
  192. package/src/evolve_preview.ts +11 -4
  193. package/src/exists.ts +2 -0
  194. package/src/fields.ts +75 -11
  195. package/src/flow_gate.ts +2 -1
  196. package/src/framework/application_home.ts +170 -18
  197. package/src/framework/attested_receipts.ts +8 -3
  198. package/src/framework/auth_provider_law.ts +169 -9
  199. package/src/framework/birth_certificate_law.ts +4 -0
  200. package/src/framework/capability.ts +34 -3
  201. package/src/framework/child_authentication.ts +346 -0
  202. package/src/framework/console_governance.ts +295 -0
  203. package/src/framework/delegated_roles.ts +301 -0
  204. package/src/framework/domain_lifecycle.ts +26 -13
  205. package/src/framework/founding_genesis.ts +193 -0
  206. package/src/framework/framework_aggregates.ts +1 -1
  207. package/src/framework/genesis.ts +6 -1
  208. package/src/framework/governance_relations.ts +19 -0
  209. package/src/framework/home.ts +5 -734
  210. package/src/framework/legacy/child_auth_provider_epoch.ts +73 -0
  211. package/src/framework/model_authority_repair.ts +116 -0
  212. package/src/framework/model_authority_seed.ts +185 -0
  213. package/src/framework/model_transition.ts +211 -0
  214. package/src/framework/owned_custody.ts +1 -1
  215. package/src/framework/principal_enrollment.ts +302 -0
  216. package/src/framework/receiving_group.ts +857 -0
  217. package/src/framework/receiving_group_recovery.ts +314 -0
  218. package/src/framework/relations.ts +4 -8
  219. package/src/framework/signing_identity.ts +242 -95
  220. package/src/framework/source_roster.ts +11 -5
  221. package/src/framework/workspace_access.ts +149 -0
  222. package/src/framework/workspace_invariant.ts +73 -52
  223. package/src/framework/workspaces.ts +407 -40
  224. package/src/framework_call_definitions.ts +32 -3
  225. package/src/generated_client_bundle_boundary.ts +97 -0
  226. package/src/generated_client_names.ts +1 -0
  227. package/src/identity_usda.ts +27 -0
  228. package/src/index.ts +183 -12
  229. package/src/indexed_variant.ts +83 -0
  230. package/src/intent.ts +173 -45
  231. package/src/law_check.ts +8 -5
  232. package/src/law_dependency_index.ts +231 -0
  233. package/src/law_graph.ts +508 -71
  234. package/src/law_graph_usda.ts +170 -24
  235. package/src/law_identity.ts +119 -81
  236. package/src/law_source_map.ts +4 -1
  237. package/src/law_units.ts +498 -0
  238. package/src/law_value_type.ts +7 -3
  239. package/src/member_authentication.ts +302 -0
  240. package/src/null_meta.ts +1 -1
  241. package/src/openusd_compiled_layer.ts +132 -0
  242. package/src/operation_contract_check.ts +31 -0
  243. package/src/ordered_read.ts +2 -1
  244. package/src/package_config.ts +33 -12
  245. package/src/package_dependencies.ts +1 -0
  246. package/src/plan_source_slice.ts +30 -1
  247. package/src/protobuf_field_number.ts +36 -0
  248. package/src/provenance_wire.ts +6 -0
  249. package/src/query.ts +2 -1
  250. package/src/read.ts +50 -0
  251. package/src/relation.ts +4 -1
  252. package/src/relation_schema.ts +15 -2
  253. package/src/report.ts +2 -2
  254. package/src/sqlite_computation_bundle.ts +78 -0
  255. package/src/sqlite_computed.ts +102 -0
  256. package/src/sqlite_counts.ts +154 -0
  257. package/src/sqlite_layout.ts +823 -0
  258. package/src/sqlite_reads.ts +275 -0
  259. package/src/sqlite_samples.ts +185 -0
  260. package/src/stable_id_identity_bridge.ts +1 -1
  261. package/src/stable_ids_for_module.ts +16 -4
  262. package/src/test_call_usda.ts +6 -6
  263. package/src/usda_relationship_integrity.ts +20 -3
  264. package/src/usda_text.ts +21 -1
  265. package/src/value_object.ts +81 -11
  266. package/src/wire.ts +22 -0
  267. package/src/wire_encode.ts +227 -20
  268. package/src/workspace_sharding.ts +15 -6
  269. package/src/workspace_sharing.ts +51 -49
  270. package/src/zod_introspection.ts +2 -0
  271. package/compat_package.mjs +0 -46
  272. package/dart/lib/src/home.dart +0 -15
  273. package/dart/lib/src/runner/offline-install.mjs +0 -15367
  274. package/dart/lib/src/source_trust.dart +0 -51
  275. package/dart/lib/src/webview_bridge.dart +0 -6540
  276. package/dart/lib/src/workspace_name.dart +0 -30
  277. package/dart/test/acquire_session_credentials_test.dart +0 -150
  278. package/dart/test/acquire_session_test.dart +0 -534
  279. package/dart/test/adv_realm_interference_test.dart +0 -600
  280. package/dart/test/cloud_bound_topology_test.dart +0 -168
  281. package/dart/test/cluster_births_test.dart +0 -202
  282. package/dart/test/cluster_device_keyed_acceptance_test.dart +0 -105
  283. package/dart/test/cluster_local_autosync_test.dart +0 -123
  284. package/dart/test/cluster_scale_test.dart +0 -122
  285. package/dart/test/compat_test.dart +0 -61
  286. package/dart/test/dlq_session_surface_test.dart +0 -222
  287. package/dart/test/first_app_gauntlet_test.dart +0 -386
  288. package/dart/test/fixtures/wedge/fake-install.mjs +0 -11
  289. package/dart/test/four_layer_nested_topology_test.dart +0 -290
  290. package/dart/test/home_parity_test.dart +0 -13
  291. package/dart/test/local_sync_inert_test.dart +0 -107
  292. package/dart/test/node_runner_transport_test.dart +0 -78
  293. package/dart/test/parent_signer_recovery_test.dart +0 -155
  294. package/dart/test/residency_refusal_test.dart +0 -49
  295. package/dart/test/sealing_client_test.dart +0 -181
  296. package/dart/test/session_bound_test.dart +0 -285
  297. package/dart/test/stale_bundle_test.dart +0 -80
  298. package/dart/test/vo_read_typing_test.dart +0 -131
  299. package/dart/test/watch_after_offer_stall_test.dart +0 -100
  300. package/dart/test/webview_bridge_test.dart +0 -1930
  301. package/dart/test/workspace_name_test.dart +0 -24
  302. package/runtime/generated-application-host.js +0 -22860
  303. package/src/codegen_query_usda.ts +0 -214
  304. package/src/compat_manifest.ts +0 -26
  305. package/src/compat_package_main.ts +0 -224
  306. package/src/shape_compat.ts +0 -352
  307. package/src/usd_state.ts +0 -505
@@ -127,15 +127,48 @@ export const TS_CALL_USDA_PRELUDE = [
127
127
  `const _nmsGeneratedCall = <Domain extends string, Directive extends string>(domain: Domain, directive: Directive, canonicalUsda: Uint8Array, routingCandidates: readonly string[]): NmsGeneratedCall<Domain, Directive> =>`,
128
128
  ` ({ domain, directive, canonicalUsda, routingCandidates: [...new Set(routingCandidates)] }) as unknown as NmsGeneratedCall<Domain, Directive>;`,
129
129
  ``,
130
+ `type _NmsCallReferenceData = { readonly workspace: string; readonly type: string; readonly id: string };`,
131
+ `const _nmsReferenceTypeMatches = (actual: string, expected: string): boolean =>`,
132
+ ` expected === "" || actual === expected || actual.endsWith("." + expected);`,
133
+ `const _nmsReferenceData = (value: unknown, field = "reference"): _NmsCallReferenceData => {`,
134
+ ` if (typeof value !== "object" || value === null) {`,
135
+ ` throw new TypeError(field + " must carry a complete NomosRef { workspace, type, id }");`,
136
+ ` }`,
137
+ ` const ref = value as { workspace?: unknown; type?: unknown; id?: unknown };`,
138
+ ` if (typeof ref.workspace !== "string" || ref.workspace.length === 0 || typeof ref.type !== "string" || ref.type.length === 0 || typeof ref.id !== "string" || ref.id.length === 0) {`,
139
+ ` throw new TypeError(field + " must carry a complete NomosRef { workspace, type, id }");`,
140
+ ` }`,
141
+ ` return { workspace: ref.workspace, type: ref.type, id: ref.id };`,
142
+ `};`,
143
+ `const _nmsReferenceId = (value: unknown, expectedType: string, workspace: string, field: string): string => {`,
144
+ ` const ref = _nmsReferenceData(value, field);`,
145
+ ` if (!_nmsReferenceTypeMatches(ref.type, expectedType)) {`,
146
+ ` throw new TypeError(field + " refers to " + ref.type + "; expected " + expectedType);`,
147
+ ` }`,
148
+ ` if (workspace !== "" && ref.workspace !== workspace) {`,
149
+ ` throw new TypeError(field + " belongs to workspace " + ref.workspace + "; this application is bound to " + workspace);`,
150
+ ` }`,
151
+ ` return ref.id;`,
152
+ `};`,
153
+ `const _nmsCheckedReferenceData = (value: unknown, expectedType: string, workspace: string, field: string): _NmsCallReferenceData => {`,
154
+ ` _nmsReferenceId(value, expectedType, workspace, field);`,
155
+ ` return _nmsReferenceData(value, field);`,
156
+ `};`,
157
+ ``,
130
158
  `declare const _nmsGeneratedQueryBrand: unique symbol;`,
131
159
  `interface NmsGeneratedQuery<Domain extends string = string, Query extends string = string> {`,
132
160
  ` readonly domain: Domain;`,
133
161
  ` readonly query: Query;`,
134
- ` readonly canonicalArgumentsUsda: Uint8Array;`,
162
+ ` readonly protobufType: string;`,
163
+ ` readonly protobufPayload: Uint8Array;`,
135
164
  ` readonly [_nmsGeneratedQueryBrand]: readonly [Domain, Query];`,
136
165
  `}`,
137
- `const _nmsGeneratedQuery = <Domain extends string, Query extends string>(domain: Domain, query: Query, canonicalArgumentsUsda: Uint8Array): NmsGeneratedQuery<Domain, Query> =>`,
138
- ` ({ domain, query, canonicalArgumentsUsda }) as NmsGeneratedQuery<Domain, Query>;`,
166
+ `const _nmsGeneratedQuery = <Domain extends string, Query extends string>(domain: Domain, query: Query, protobufType: string, protobufPayload: Uint8Array): NmsGeneratedQuery<Domain, Query> =>`,
167
+ ` ({ domain, query, protobufType, protobufPayload }) as NmsGeneratedQuery<Domain, Query>;`,
168
+ `interface NmsGeneratedResult {`,
169
+ ` readonly protobufType: string;`,
170
+ ` readonly protobufPayload: Uint8Array;`,
171
+ `}`,
139
172
  ``,
140
173
  // The same generated call encoder runs in browsers, Dart's JS runner and the
141
174
  // sealed QuickJS engine. TextEncoder is a browser/Node convenience, not an
@@ -197,6 +230,14 @@ export const TS_CALL_USDA_PRELUDE = [
197
230
  ``,
198
231
  ] as const;
199
232
 
233
+ /** Query arguments still use their existing nominal USDA contract. Keep that
234
+ * surface isolated from directive authoring while it is migrated separately. */
235
+ export const TS_QUERY_USDA_PRELUDE = TS_CALL_USDA_PRELUDE.slice(
236
+ TS_CALL_USDA_PRELUDE.findIndex((line) =>
237
+ line.startsWith("declare const _nmsGeneratedQueryBrand")
238
+ ),
239
+ );
240
+
200
241
  /** OpenUSD syntax primitives for generated Dart clients. These helpers never
201
242
  * inspect domain values: every value access is expanded into a directive-
202
243
  * specific encoder by {@link emitDartCallUsdaEncoder}. */
@@ -270,6 +311,7 @@ export function emitTsCallUsdaEncoder(
270
311
  if (intent === undefined) {
271
312
  throw new Error(`call USDA codegen: domain '${domain}' has no law intent for '${directive}'`);
272
313
  }
314
+ const publicDirective = intent.publicRoute ?? intent.entity.label;
273
315
  const contract = nodes.get(intent.accepts.id);
274
316
  if (contract?.kind !== "payload-contract") {
275
317
  throw new Error(`call USDA codegen: '${domain}/${directive}' accepts no payload contract`);
@@ -315,7 +357,7 @@ export function emitTsCallUsdaEncoder(
315
357
  const canonicalValue = valueIsCanonical || semantic === undefined
316
358
  ? value
317
359
  : semantic.kind === "id-reference"
318
- ? `_nmsReferenceId(${value}, ${JSON.stringify(semantic.target)}, nmsInternalWorkspace, ${JSON.stringify(fieldLabel)})`
360
+ ? `_nmsReferenceId(${value}, ${JSON.stringify(semantic.target)}, ${semantic.targetKind === "contract" ? '\"\"' : "nmsInternalWorkspace"}, ${JSON.stringify(fieldLabel)})`
319
361
  : semantic.kind === "address-reference"
320
362
  ? `_nmsCheckedReferenceData(${value}, ${JSON.stringify(semantic.target)}, "", ${JSON.stringify(fieldLabel)})`
321
363
  : semantic.kind === "versioned-reference"
@@ -641,7 +683,7 @@ export function emitTsCallUsdaEncoder(
641
683
  ` _nmsUsdaClose(out, 2);`,
642
684
  ` _nmsUsdaClose(out, 1);`,
643
685
  ` _nmsUsdaClose(out, 0);`,
644
- ` return _nmsGeneratedCall(${JSON.stringify(domain)}, ${JSON.stringify(directive)}, _nmsUsdaUtf8(out.join("\\n") + "\\n"), _nmsRoutingCandidates);`,
686
+ ` return _nmsGeneratedCall(${JSON.stringify(domain)}, ${JSON.stringify(publicDirective)}, _nmsUsdaUtf8(out.join("\\n") + "\\n"), _nmsRoutingCandidates);`,
645
687
  `}`,
646
688
  ``,
647
689
  );
@@ -676,6 +718,7 @@ export function emitDartCallUsdaEncoder(
676
718
  if (intent === undefined) {
677
719
  throw new Error(`Dart call USDA codegen: domain '${domain}' has no law intent for '${directive}'`);
678
720
  }
721
+ const publicDirective = intent.publicRoute ?? intent.entity.label;
679
722
  const contract = nodes.get(intent.accepts.id);
680
723
  if (contract?.kind !== "payload-contract") {
681
724
  throw new Error(`Dart call USDA codegen: '${domain}/${directive}' accepts no payload contract`);
@@ -1106,7 +1149,7 @@ export function emitDartCallUsdaEncoder(
1106
1149
  ` _nmsUsdaClose(out, 0);`,
1107
1150
  ` return NmsInternalGeneratedCalls.create(`,
1108
1151
  ` domain: ${dartString(domain)},`,
1109
- ` directive: ${dartString(directive)},`,
1152
+ ` directive: ${dartString(publicDirective)},`,
1110
1153
  ` canonicalUsda: Uint8List.fromList(utf8.encode('\${out.join('\\n')}\\n')),`,
1111
1154
  ` );`,
1112
1155
  `}`,
@@ -1,7 +1,8 @@
1
+ import { dartRefusalUnions } from "./codegen_refusal.js";
1
2
  // NOMOS — Nomos Sovereign: participants act · verify · remember LOCALLY; hosted
2
3
  // remotes are replaceable custody/transport, not truth. ⇒ ONE Nomos GitHolon
3
4
  // wasm32-wasip1 artifact {kernel · projection · embedded QuickJS engine},
4
- // byte-identical everywhere. Host JS is only the bridge; domain JS runs inside
5
+ // byte-identical everywhere. Host JS is only the session; domain JS runs inside
5
6
  // GitHolon, never as a second execution path.
6
7
  // If a file isn't this / hosting this / authoring for this / proving this — it's gone.
7
8
 
@@ -28,10 +29,12 @@
28
29
  */
29
30
  import { z } from "zod";
30
31
  import { enumTypeNameOf } from "./enum_type.js";
31
- import { voMetaOf, collectPayloadValueObjectDescriptors, collectValueObjectDescriptors, idOfMetaOf, idOfTargetKindOf, refOfMetaOf, versionedRefOfMetaOf, brandedIdMetaOf, NOMOS_UNIT_BRAND } from "./value_object.js";
32
+ import { voMetaOf, collectPayloadValueObjectDescriptors, collectSchemaValueObjectDescriptors, collectValueObjectDescriptors, idOfMetaOf, idOfTargetKindOf, refOfMetaOf, versionedRefOfMetaOf, brandedIdMetaOf, NOMOS_UNIT_BRAND } from "./value_object.js";
32
33
  import { recursiveTypeBaseName, zodUnwrapLazy } from "./zod_lazy.js";
33
34
  import type { AggregateHandle } from "./aggregate.js";
34
35
  import type { WorkspaceInvariantDecl } from "./framework/workspace_invariant.js";
36
+ import type { IndexedVariant } from "./indexed_variant.js";
37
+ import { emitDartIndexedVariant } from "./codegen_dart_indexed_variant.js";
35
38
  import type { RelationTypeDecl } from "./relation_schema.js";
36
39
  import { isGitObjectIdSchema, isSha256DigestSchema, type Field, type FieldKind, type ValueObjectDescriptor, type ValueObjectFieldDescriptor } from "./fields.js";
37
40
  import { admitsNull, nullMetaOf, nullDocLine } from "./null_meta.js";
@@ -953,6 +956,8 @@ function unwrapProjectionReturn(zt: z.ZodTypeAny): z.ZodTypeAny {
953
956
  }
954
957
 
955
958
  function projectionReturnDartBaseType(schema: z.ZodTypeAny): string {
959
+ const valueObject = voMetaOf(schema);
960
+ if (valueObject !== undefined) return valueObject.name;
956
961
  const inner = unwrapProjectionReturn(schema);
957
962
  switch (zodTypeName(inner)) {
958
963
  case "ZodString":
@@ -978,6 +983,10 @@ function projectionReturnDartType(schema: z.ZodTypeAny): string {
978
983
  }
979
984
 
980
985
  function parseProjectionReturnField(field: string, schema: z.ZodTypeAny): string {
986
+ const valueObject = voMetaOf(schema);
987
+ if (valueObject !== undefined) {
988
+ return `(() { final v = data['${field}']; return v == null ? null : ${valueObject.name}.fromProjected((v as Map).cast<String, Object?>()); })()`;
989
+ }
981
990
  const inner = unwrapProjectionReturn(schema);
982
991
  switch (zodTypeName(inner)) {
983
992
  case "ZodString":
@@ -1828,25 +1837,7 @@ function emitAggregate(
1828
1837
  ` );`,
1829
1838
  ` }`,
1830
1839
  ``,
1831
- ...(attributedFields.length > 0
1832
- ? [
1833
- [
1834
- ...attributedFields.flatMap((f) => [
1835
- ` /// Author provenance of [${f}] (who wrote the current value + whether a`,
1836
- ` /// concurrent competing write was auto-merged away). Null when the field`,
1837
- ` /// has no folded provenance yet (pre-attribution rows).`,
1838
- ` FieldProvenance? get ${f}Provenance => \$provenance['${f}'];`,
1839
- ]),
1840
- ` /// The last verified author per attributed field (fields with an unknown`,
1841
- ` /// author are omitted) — the "who last touched this row" convenience.`,
1842
- ` Map<String, String> get lastAuthors => {`,
1843
- ` for (final e in \$provenance.entries)`,
1844
- ` if (e.value.author != null) e.key: e.value.author!,`,
1845
- ` };`,
1846
- ].join("\n"),
1847
- ``,
1848
- ]
1849
- : []),
1840
+ ...emitProvenanceAccessors(attributedFields),
1850
1841
  ` @override`,
1851
1842
  ` bool operator ==(Object other) =>`,
1852
1843
  ` other is ${className} &&`,
@@ -2034,8 +2025,9 @@ export function unionArmClassName(unionName: string, armKey: string): string {
2034
2025
 
2035
2026
  /** The Dart type of one VO descriptor field. `voName`/`fieldName` name the field's
2036
2027
  * generated enum type (`<VoName><FieldName>Enum`) — threaded through arrays. */
2037
- function dartTypeOfVoField(f: ValueObjectFieldDescriptor, voName: string, fieldName: string): string {
2038
- switch (f.type) {
2028
+ export function dartTypeOfVoField(f: ValueObjectFieldDescriptor, voName: string, fieldName: string): string {
2029
+ const value = (() => {
2030
+ switch (f.type) {
2039
2031
  case "string":
2040
2032
  return f.idOf !== undefined
2041
2033
  ? `NomosRef<${f.idOfContract === true ? contractTypeName(f.idOf) : concreteClassName(f.idOf)}>`
@@ -2058,7 +2050,9 @@ function dartTypeOfVoField(f: ValueObjectFieldDescriptor, voName: string, fieldN
2058
2050
  case "object":
2059
2051
  case "geometry":
2060
2052
  return f.ref; // the named VO class (emitted alongside / imported)
2061
- }
2053
+ }
2054
+ })();
2055
+ return f.nullable === true ? `${value}?` : value;
2062
2056
  }
2063
2057
 
2064
2058
  /** A Dart expression converting the RAW decoded json value `expr` to the field's typed
@@ -2201,7 +2195,7 @@ function emitCopyWith(
2201
2195
  );
2202
2196
  const args = fields.map((x) =>
2203
2197
  x.optional
2204
- ? ` ${x.member}: identical(${x.member}, _voUnset) ? this.${x.member} : ${x.member} as ${x.dartType}?,`
2198
+ ? ` ${x.member}: identical(${x.member}, _voUnset) ? this.${x.member} : ${x.member} as ${x.dartType}${x.dartType.endsWith("?") ? "" : "?"},`
2205
2199
  : ` ${x.member}: ${x.member} ?? this.${x.member},`,
2206
2200
  );
2207
2201
  return [
@@ -2275,20 +2269,22 @@ function emitUnionClasses(d: ValueObjectDescriptor): string {
2275
2269
  const literalGetters = armLiterals.map((x) => ` String get ${x.member} => '${(x.f as { value: string }).value}';`);
2276
2270
  const literalToLines = armLiterals.map((x) => ` '${x.wireName}': '${(x.f as { value: string }).value}',`);
2277
2271
  const decls = [
2278
- ...armFields.filter((x) => x.f.type !== "literal").map((x) => ` final ${dartTypeOfVoField(x.f, cls, x.wireName)}${x.optional ? "?" : ""} ${x.member};`),
2272
+ ...armFields.filter((x) => x.f.type !== "literal").map((x) => ` final ${dartTypeOfVoField(x.f, cls, x.wireName)}${x.optional && x.f.nullable !== true ? "?" : ""} ${x.member};`),
2279
2273
  ...literalGetters,
2280
2274
  ];
2281
2275
  const ctor = fields.length === 0
2282
2276
  ? [` const ${cls}();`]
2283
2277
  : [` const ${cls}({`, ...fields.map((x) => (x.optional ? ` this.${x.member},` : ` required this.${x.member},`)), ` });`];
2284
2278
  const fromLines = fields.map((x) =>
2285
- x.optional
2279
+ x.optional || x.f.nullable === true
2286
2280
  ? ` ${x.member}: m['${x.wireName}'] == null ? null : ${voFromExpr(x.f, `m['${x.wireName}']!`, cls, x.wireName)},`
2287
2281
  : ` ${x.member}: ${voFromExpr(x.f, `m['${x.wireName}']!`, cls, x.wireName)},`,
2288
2282
  );
2289
2283
  const toLines = fields.map((x) =>
2290
2284
  x.optional
2291
2285
  ? ` if (${x.member} != null) '${x.wireName}': ${voToJsonExpr(x.f, `${x.member}!`)},`
2286
+ : x.f.nullable === true
2287
+ ? ` '${x.wireName}': ${x.member} == null ? null : ${voToJsonExpr(x.f, `${x.member}!`)},`
2292
2288
  : ` '${x.wireName}': ${voToJsonExpr(x.f, x.member)},`,
2293
2289
  );
2294
2290
  return [
@@ -2306,7 +2302,7 @@ function emitUnionClasses(d: ValueObjectDescriptor): string {
2306
2302
  ...toLines,
2307
2303
  ` };`,
2308
2304
  ``,
2309
- ...emitCopyWith(cls, fields.map((x) => ({ member: x.member, dartType: dartTypeOfVoField(x.f, cls, x.wireName), optional: x.optional }))),
2305
+ ...emitCopyWith(cls, fields.map((x) => ({ member: x.member, dartType: dartTypeOfVoField(x.f, cls, x.wireName), optional: x.optional || x.f.nullable === true }))),
2310
2306
  ` @override`,
2311
2307
  ` bool operator ==(Object other) => other is ${cls} && _voJsonEq(other.toJson(), toJson());`,
2312
2308
  ` @override`,
@@ -2450,17 +2446,19 @@ function emitValueObjectClass(d: ValueObjectDescriptor): string {
2450
2446
  (x) => ` '${x.wireName}': '${(x.f as { value: string }).value}',`,
2451
2447
  );
2452
2448
  const decls = fields.map(
2453
- (x) => ` final ${dartTypeOfVoField(x.f, d.name, x.wireName)}${x.optional ? "?" : ""} ${x.member};`,
2449
+ (x) => ` final ${dartTypeOfVoField(x.f, d.name, x.wireName)}${x.optional && x.f.nullable !== true ? "?" : ""} ${x.member};`,
2454
2450
  );
2455
2451
  const ctor = fields.map((x) => (x.optional ? ` this.${x.member},` : ` required this.${x.member},`));
2456
2452
  const fromLines = fields.map((x) =>
2457
- x.optional
2453
+ x.optional || x.f.nullable === true
2458
2454
  ? ` ${x.member}: m['${x.wireName}'] == null ? null : ${voFromExpr(x.f, `m['${x.wireName}']!`, d.name, x.wireName)},`
2459
2455
  : ` ${x.member}: ${voFromExpr(x.f, `m['${x.wireName}']!`, d.name, x.wireName)},`,
2460
2456
  );
2461
2457
  const toLines = fields.map((x) =>
2462
2458
  x.optional
2463
2459
  ? ` if (${x.member} != null) '${x.wireName}': ${voToJsonExpr(x.f, `${x.member}!`)},`
2460
+ : x.f.nullable === true
2461
+ ? ` '${x.wireName}': ${x.member} == null ? null : ${voToJsonExpr(x.f, `${x.member}!`)},`
2464
2462
  : ` '${x.wireName}': ${voToJsonExpr(x.f, x.member)},`,
2465
2463
  );
2466
2464
  return [
@@ -2487,7 +2485,7 @@ function emitValueObjectClass(d: ValueObjectDescriptor): string {
2487
2485
  ...toLines,
2488
2486
  ` };`,
2489
2487
  ``,
2490
- ...emitCopyWith(d.name, fields.map((x) => ({ member: x.member, dartType: dartTypeOfVoField(x.f, d.name, x.wireName), optional: x.optional }))),
2488
+ ...emitCopyWith(d.name, fields.map((x) => ({ member: x.member, dartType: dartTypeOfVoField(x.f, d.name, x.wireName), optional: x.optional || x.f.nullable === true }))),
2491
2489
  ``,
2492
2490
  ` @override`,
2493
2491
  ` bool operator ==(Object other) =>`,
@@ -2757,7 +2755,7 @@ function emitDartActivityArm(e: PackageActivityEntry): string[] {
2757
2755
  * The full source of the shared `activity_registry.dart` file — the PURE per-directive activity registry
2758
2756
  * + `renderActivity(rawRow) => ActivityEvent?`, emitted ONCE per package into the TYPES package (both the
2759
2757
  * flat + layered emit). References only nomos_types (`ActivityEvent`/`ActivityRef`/`ActivitySeverity`/
2760
- * `renderActivityTemplate`), so the file is PURE (frontend-safe, no bridge). A raw row is
2758
+ * `renderActivityTemplate`), so the file is PURE (frontend-safe, no session). A raw row is
2761
2759
  * `{ intentId, domain, directiveId, actorSubject, occurredAt, payload }` (the runtime's per-committed-intent
2762
2760
  * shape); `renderActivity` returns null only for work outside the generated public business package.
2763
2761
  */
@@ -2779,23 +2777,20 @@ export function generateDartActivityRegistry(entries: readonly PackageActivityEn
2779
2777
  ``,
2780
2778
  `import 'package:nomos_client/src/nms_generated_runtime.dart';`,
2781
2779
  ``,
2782
- `/// One business-readable difference found while proving a candidate model against history.`,
2783
- `enum NomosModelDifferenceKind { rules, outcome, evidence }`,
2780
+ `/// One business-readable difference found at the current model frontier.`,
2781
+ `enum NomosModelDifferenceKind { compatibility, frontier }`,
2784
2782
  ``,
2785
2783
  `class NomosModelDifference {`,
2786
2784
  ` final NomosModelDifferenceKind kind;`,
2787
2785
  ` final String? area;`,
2788
- ` final String? action;`,
2789
2786
  ` final String summary;`,
2790
- ` const NomosModelDifference({required this.kind, this.area, this.action, required this.summary});`,
2787
+ ` const NomosModelDifference({required this.kind, this.area, required this.summary});`,
2791
2788
  `}`,
2792
2789
  ``,
2793
2790
  `class NomosModelReview {`,
2794
- ` final int checkedActions;`,
2795
- ` final int candidateActions;`,
2796
- ` final bool? sameOutcome;`,
2791
+ ` final bool? ready;`,
2797
2792
  ` final List<NomosModelDifference> differences;`,
2798
- ` const NomosModelReview({required this.checkedActions, required this.candidateActions, required this.sameOutcome, required this.differences});`,
2793
+ ` const NomosModelReview({required this.ready, required this.differences});`,
2799
2794
  `}`,
2800
2795
  ``,
2801
2796
  `enum NomosModelAdoptionStatus { adopted, needsStaging, needsDecision, blocked }`,
@@ -2827,7 +2822,7 @@ export function generateDartActivityRegistry(entries: readonly PackageActivityEn
2827
2822
  ` if (status != NomosModelAdoptionStatus.needsDecision || acceptDecision == null) {`,
2828
2823
  ` throw StateError('This model change is not waiting for a business decision.');`,
2829
2824
  ` }`,
2830
- ` if (reason.isEmpty) throw ArgumentError('accept(reason) needs the business reason for changing prior outcomes');`,
2825
+ ` if (reason.isEmpty) throw ArgumentError('accept(reason) needs the business reason for changing stable identities');`,
2831
2826
  ` return acceptDecision(reason);`,
2832
2827
  ` }`,
2833
2828
  `}`,
@@ -3100,7 +3095,7 @@ function foreignRefExpr(s: AggFieldSpec, aggregate: string): string {
3100
3095
  // workspace resolves to not-found, never throws).
3101
3096
  const wsExpr = `(readStrOrNull(data, '${wsField}') ?? '')`;
3102
3097
  const build = (idVar: string): string =>
3103
- `NmsInternalForeignRefs.create<${target}>(id: ${idVar}, workspace: ${wsExpr}, type: '${s.foreignRefAggregateType ?? target}', fromJson: ${target}.fromJson)`;
3098
+ `NmsInternalForeignRefs.create<${target}>(id: ${idVar}, workspace: ${wsExpr}, type: '${s.foreignRefAggregateType ?? target}')`;
3104
3099
  return s.optional
3105
3100
  ? `() { final v = ${idReader}; return v == null ? null : ${build("v")}; }()`
3106
3101
  : build(idReader);
@@ -3251,7 +3246,7 @@ function slotDecodeCallback(s: AggFieldSpec, mode: "aggregate" | "readModel"): s
3251
3246
  // read through the normal field path). A plain ref keeps its typed-id decode.
3252
3247
  if (s.foreignRefTarget !== undefined) {
3253
3248
  const t = s.foreignRefTarget;
3254
- return `(v) => NmsInternalForeignRefs.create<${t}>(id: v as String, workspace: '', type: '${t}', fromJson: ${t}.fromJson)`;
3249
+ return `(v) => NmsInternalForeignRefs.create<${t}>(id: v as String, workspace: '', type: '${t}')`;
3255
3250
  }
3256
3251
  return s.refIdClass !== undefined
3257
3252
  ? `(v) => NmsInternalNomosRefs.create<${s.refIdClass}>(workspace: _location, type: '${s.refAggregateType}', id: v as String)`
@@ -3614,6 +3609,24 @@ function emitFulfilmentSealed(
3614
3609
  return { code, consumed, accessorType: base, accessorName: decl.name };
3615
3610
  }
3616
3611
 
3612
+ /** Pure metadata accessors shared by aggregate values and their generated read models. */
3613
+ function emitProvenanceAccessors(fields: readonly string[]): string[] {
3614
+ if (fields.length === 0) return [];
3615
+ return [
3616
+ ...fields.flatMap((field) => [
3617
+ ` /// Author of the current value and whether concurrent writes competed.`,
3618
+ ` /// Null when this field has no folded provenance yet (pre-attribution rows).`,
3619
+ ` FieldProvenance? get ${field}Provenance => \$provenance['${field}'];`,
3620
+ ]),
3621
+ ` /// Last verified author per attributed field; unknown authors are omitted.`,
3622
+ ` Map<String, String> get lastAuthors => {`,
3623
+ ` for (final e in \$provenance.entries)`,
3624
+ ` if (e.value.author != null) e.key: e.value.author!,`,
3625
+ ` };`,
3626
+ ``,
3627
+ ];
3628
+ }
3629
+
3617
3630
  function emitReadModel(
3618
3631
  agg: AggregateHandle,
3619
3632
  enumDartTypes: Map<string, string>,
@@ -3625,6 +3638,9 @@ function emitReadModel(
3625
3638
  ): string {
3626
3639
  const className = readModelClassName(agg.id);
3627
3640
  const wireType = agg.id;
3641
+ // The generated client decodes attribution into read models as well as aggregate
3642
+ // values. These are two views of the same declared member metadata.
3643
+ const attributedFields = agg.attributedFields ?? [];
3628
3644
  const allSpecs = aggregateFieldSpecs(
3629
3645
  agg,
3630
3646
  enumDartTypes,
@@ -3653,6 +3669,10 @@ function emitReadModel(
3653
3669
  ` /// The canonical workspace-qualified identity of this ${concreteClassName(agg.id)}.`,
3654
3670
  ` /// Pass this exact value to generated actions, find and watch methods.`,
3655
3671
  ` final NomosRef<${concreteClassName(agg.id)}> ref;`,
3672
+ ...(attributedFields.length > 0
3673
+ ? [` /// Author metadata for the declared attributed fields; absent before attribution.`,
3674
+ ` final Map<String, FieldProvenance> \$provenance;`]
3675
+ : []),
3656
3676
  ...(sealedFulfilment !== null
3657
3677
  ? [
3658
3678
  ` /// How complete this record is. Switch exhaustively — each variant's fields are`,
@@ -3695,6 +3715,7 @@ function emitReadModel(
3695
3715
  ].join("\n");
3696
3716
  const ctorParams = [
3697
3717
  ` required this.ref,`,
3718
+ ...(attributedFields.length > 0 ? [` this.\$provenance = const {},`] : []),
3698
3719
  ...(sealedFulfilment !== null
3699
3720
  ? [
3700
3721
  // Defaults to Unfulfilled: the projection serves PARTIAL folds, and "nothing claimed
@@ -3724,7 +3745,7 @@ function emitReadModel(
3724
3745
  // SURFACED MERGE CONFLICTS: per-Surfaced-field convenience accessors (the pending seam an app
3725
3746
  // branches on without hand-parsing) — an EXTENSION on the read model, mirroring the ref-traversal
3726
3747
  // accessor pattern (codegen_dart_client.ts P2). They live HERE (the pure types file), not on the
3727
- // client: they are pure field reads needing no bridge, and in layered-packages mode the types
3748
+ // client: they are pure field reads needing no session, and in layered-packages mode the types
3728
3749
  // package must not depend on the client. A Surfaced-free aggregate emits none (byte-identical).
3729
3750
  const surfacedSpecs = specs.filter((s) => s.surfaced === true);
3730
3751
  const surfacedExtension =
@@ -3747,6 +3768,9 @@ function emitReadModel(
3747
3768
 
3748
3769
  const parseLines = [
3749
3770
  ` ref: NmsInternalNomosRefs.create<${concreteClassName(agg.id)}>(workspace: _location, type: _kind.isEmpty ? '${aggregateWireTypeForAggregate(agg.id)}' : _kind, id: id),`,
3771
+ ...(attributedFields.length > 0
3772
+ ? [` \$provenance: FieldProvenance.mapFromJson(data['__prov']),`]
3773
+ : []),
3750
3774
  ...(sealedFulfilment !== null
3751
3775
  ? [` ${dartMemberName(sealedFulfilment.accessorName)}: _decode${sealedFulfilment.accessorType}(data),`]
3752
3776
  : []),
@@ -3798,6 +3822,7 @@ function emitReadModel(
3798
3822
  parseLines,
3799
3823
  ` );`,
3800
3824
  ` }`,
3825
+ ...emitProvenanceAccessors(attributedFields),
3801
3826
  `}`,
3802
3827
  ...surfacedExtension,
3803
3828
  ].join("\n");
@@ -4829,6 +4854,8 @@ export interface DomainModule {
4829
4854
  * additive `nomosValueObjects` USD key (`usd.ts`).
4830
4855
  */
4831
4856
  valueObjects?: readonly ValueObjectDescriptor[];
4857
+ /** Explicit discriminator/value relationships; generated bindings own typed edit construction. */
4858
+ indexedVariants?: readonly IndexedVariant[];
4832
4859
  /**
4833
4860
  * DOMAIN CONTRACTS (`architecture/domain_contracts.md`) — the public DTO shapes this domain declares
4834
4861
  * (`recordContract(id, fields)`), discovered by shape and composed across the domain's modules. ADDITIVE +
@@ -4982,7 +5009,13 @@ export function generateDartDomain(mod: DomainModule, opts: GenerateDartDomainOp
4982
5009
  const publicAggregateValueObjectsByName = new Map<string, ValueObjectDescriptor>();
4983
5010
  for (const descriptor of [
4984
5011
  ...collectValueObjectDescriptors(publicAggregates),
5012
+ ...collectSchemaValueObjectDescriptors([
5013
+ ...(mod.deriveds ?? []).map((read) => read.returns),
5014
+ ...(mod.combineds ?? []).map((read) => read.returns),
5015
+ ]),
4985
5016
  ...(opts.additionalValueObjects ?? []),
5017
+ ...(mod.workspaceInvariants ?? []).flatMap(rule => rule.refusal ? [rule.refusal.descriptor, ...rule.refusal.dependencies] : []),
5018
+ ...(mod.indexedVariants ?? []).flatMap((binding) => [binding.value.descriptor, ...binding.value.dependencies]),
4986
5019
  ]) {
4987
5020
  const prior = publicAggregateValueObjectsByName.get(descriptor.name);
4988
5021
  if (prior !== undefined && JSON.stringify(prior) !== JSON.stringify(descriptor)) {
@@ -5126,6 +5159,8 @@ export function generateDartDomain(mod: DomainModule, opts: GenerateDartDomainOp
5126
5159
  ]),
5127
5160
  ]
5128
5161
  : []),
5162
+ ...(mod.indexedVariants ?? []).map(emitDartIndexedVariant),
5163
+ ...dartRefusalUnions(mod),
5129
5164
  ].join("\n\n");
5130
5165
  // The symbols whose Dart surface this file EMITS (framework-shared ones live in the shared file).
5131
5166
  const localAggregates = mod.aggregates.filter((a) => !skipAggregateIds.has(a.id));