hecks 2.8.0 → 2.9.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 (404) hide show
  1. checksums.yaml +4 -4
  2. data/exe/hecks +4 -6
  3. data/lib/hecks/adapters/driven/claude_code.rb +4 -104
  4. data/lib/hecks/adapters/driven/d1.rb +44 -237
  5. data/lib/hecks/adapters/driven/folder.rb +17 -76
  6. data/lib/hecks/adapters/driven/google_authentication.rb +15 -49
  7. data/lib/hecks/adapters/driven/governance_authorization.rb +23 -70
  8. data/lib/hecks/adapters/driven/heki/journal.rb +8 -41
  9. data/lib/hecks/adapters/driven/heki/saga_store.rb +12 -54
  10. data/lib/hecks/adapters/driven/heki/snapshot.rb +4 -12
  11. data/lib/hecks/adapters/driven/heki.rb +13 -42
  12. data/lib/hecks/adapters/driven/identity_registry.rb +3 -14
  13. data/lib/hecks/adapters/driven/in_memory_ordering.rb +9 -26
  14. data/lib/hecks/adapters/driven/in_process_key_vault.rb +2 -14
  15. data/lib/hecks/adapters/driven/lambda/client.rb +10 -51
  16. data/lib/hecks/adapters/driven/lambda.rb +10 -84
  17. data/lib/hecks/adapters/driven/local_storage.rb +5 -40
  18. data/lib/hecks/adapters/driven/memory.rb +17 -98
  19. data/lib/hecks/adapters/driven/mock_stripe_adapter.rb +5 -21
  20. data/lib/hecks/adapters/driven/postgres/codec.rb +6 -28
  21. data/lib/hecks/adapters/driven/postgres/outbox.rb +3 -12
  22. data/lib/hecks/adapters/driven/postgres/reconnect.rb +4 -30
  23. data/lib/hecks/adapters/driven/postgres/schema_builder.rb +34 -108
  24. data/lib/hecks/adapters/driven/postgres.rb +145 -134
  25. data/lib/hecks/adapters/driven/postgres_era.adapter +4 -15
  26. data/lib/hecks/adapters/driven/prism.rb +7 -30
  27. data/lib/hecks/adapters/driven/sql_query_builder.rb +21 -121
  28. data/lib/hecks/adapters/driven/sqlite/codec.rb +8 -40
  29. data/lib/hecks/adapters/driven/sqlite/projection.rb +26 -82
  30. data/lib/hecks/adapters/driven/sqlite/schema_builder.rb +40 -84
  31. data/lib/hecks/adapters/driven/sqlite.rb +128 -65
  32. data/lib/hecks/adapters/driven/tenant_provisioner.rb +5 -48
  33. data/lib/hecks/adapters/driven.rb +5 -36
  34. data/lib/hecks/adapters/driving/github_webhook.rb +8 -76
  35. data/lib/hecks/behaviors/dsl.rb +7 -25
  36. data/lib/hecks/behaviors/expectations.rb +31 -141
  37. data/lib/hecks/behaviors/ir.rb +7 -20
  38. data/lib/hecks/behaviors/rspec.rb +6 -17
  39. data/lib/hecks/behaviors/runner.rb +10 -34
  40. data/lib/hecks/behaviors.rb +4 -8
  41. data/lib/hecks/bluebook/aggregate.rb +9 -75
  42. data/lib/hecks/bluebook/assembly/aggregate_assembly.rb +9 -38
  43. data/lib/hecks/bluebook/assembly/build.rb +4 -15
  44. data/lib/hecks/bluebook/assembly/contract.rb +15 -136
  45. data/lib/hecks/bluebook/assembly/contracts.rb +54 -174
  46. data/lib/hecks/bluebook/assembly/marks.rb +31 -223
  47. data/lib/hecks/bluebook/assembly/specializer.rb +6 -52
  48. data/lib/hecks/bluebook/assembly.rb +6 -45
  49. data/lib/hecks/bluebook/attribute.rb +12 -61
  50. data/lib/hecks/bluebook/behaviour/aggregate.rb +10 -39
  51. data/lib/hecks/bluebook/behaviour/attribute.rb +3 -14
  52. data/lib/hecks/bluebook/behaviour/chapter.rb +14 -42
  53. data/lib/hecks/bluebook/behaviour/command.rb +14 -66
  54. data/lib/hecks/bluebook/behaviour/domain_port.rb +4 -20
  55. data/lib/hecks/bluebook/behaviour/entity.rb +7 -27
  56. data/lib/hecks/bluebook/behaviour/hexagon.rb +23 -41
  57. data/lib/hecks/bluebook/behaviour/lifecycle.rb +15 -40
  58. data/lib/hecks/bluebook/behaviour/policy.rb +23 -52
  59. data/lib/hecks/bluebook/behaviour/process_manager.rb +30 -57
  60. data/lib/hecks/bluebook/behaviour/read_model.rb +25 -31
  61. data/lib/hecks/bluebook/behaviour/traits.rb +27 -64
  62. data/lib/hecks/bluebook/behaviour/value_object.rb +5 -24
  63. data/lib/hecks/bluebook/capabilities.rb +17 -49
  64. data/lib/hecks/bluebook/chapter.rb +10 -48
  65. data/lib/hecks/bluebook/command.rb +23 -81
  66. data/lib/hecks/bluebook/domain_port.rb +14 -63
  67. data/lib/hecks/bluebook/dsl/aggregate_builder/sealing.rb +50 -229
  68. data/lib/hecks/bluebook/dsl/aggregate_builder.rb +50 -377
  69. data/lib/hecks/bluebook/dsl/attribute_collector.rb +33 -204
  70. data/lib/hecks/bluebook/dsl/binding_proxy.rb +16 -69
  71. data/lib/hecks/bluebook/dsl/bluebook_builder/validation.rb +86 -708
  72. data/lib/hecks/bluebook/dsl/bluebook_builder.rb +56 -170
  73. data/lib/hecks/bluebook/dsl/bootstrap_table.rb +1 -0
  74. data/lib/hecks/bluebook/dsl/command_builder.rb +74 -546
  75. data/lib/hecks/bluebook/dsl/const_shim.rb +8 -41
  76. data/lib/hecks/bluebook/dsl/domain_port_builder.rb +12 -87
  77. data/lib/hecks/bluebook/dsl/entity_builder.rb +44 -330
  78. data/lib/hecks/bluebook/dsl/generic_dispatch.rb +20 -269
  79. data/lib/hecks/bluebook/dsl/hecksagon_builder.rb +26 -194
  80. data/lib/hecks/bluebook/dsl/identity_declaration.rb +13 -88
  81. data/lib/hecks/bluebook/dsl/lifecycle_builder.rb +6 -20
  82. data/lib/hecks/bluebook/dsl/policy_builder.rb +16 -88
  83. data/lib/hecks/bluebook/dsl/port_builder.rb +2 -6
  84. data/lib/hecks/bluebook/dsl/port_operation_builder.rb +22 -96
  85. data/lib/hecks/bluebook/dsl/process_manager_builder.rb +31 -184
  86. data/lib/hecks/bluebook/dsl/query_builder.rb +11 -42
  87. data/lib/hecks/bluebook/dsl/read_model_builder.rb +75 -201
  88. data/lib/hecks/bluebook/dsl/rule_reference.rb +22 -163
  89. data/lib/hecks/bluebook/dsl/translation_builder.rb +28 -114
  90. data/lib/hecks/bluebook/dsl/value_object_builder.rb +10 -124
  91. data/lib/hecks/bluebook/dsl/word_gate.rb +16 -162
  92. data/lib/hecks/bluebook/dsl/world_builder.rb +19 -111
  93. data/lib/hecks/bluebook/entity.rb +13 -71
  94. data/lib/hecks/bluebook/expression/ast_json.rb +24 -190
  95. data/lib/hecks/bluebook/expression/ast_reader.rb +12 -54
  96. data/lib/hecks/bluebook/expression/canonical_form.rb +11 -88
  97. data/lib/hecks/bluebook/expression/evaluator.rb +47 -295
  98. data/lib/hecks/bluebook/expression/resolver/block_predicates.rb +30 -147
  99. data/lib/hecks/bluebook/expression/resolver.rb +37 -660
  100. data/lib/hecks/bluebook/hexagon.rb +5 -28
  101. data/lib/hecks/bluebook/lifecycle.rb +5 -16
  102. data/lib/hecks/bluebook/meta_validator/adapter_judge.rb +1 -7
  103. data/lib/hecks/bluebook/meta_validator/judge.rb +111 -361
  104. data/lib/hecks/bluebook/meta_validator/plan.rb +33 -162
  105. data/lib/hecks/bluebook/meta_validator/port_judge.rb +2 -7
  106. data/lib/hecks/bluebook/meta_validator/readings.rb +56 -342
  107. data/lib/hecks/bluebook/meta_validator/reconstruction.rb +24 -176
  108. data/lib/hecks/bluebook/meta_validator/shapes.rb +53 -267
  109. data/lib/hecks/bluebook/meta_validator/syntax_boot.rb +43 -305
  110. data/lib/hecks/bluebook/meta_validator/translation_judge.rb +7 -43
  111. data/lib/hecks/bluebook/meta_validator/world_judge.rb +6 -18
  112. data/lib/hecks/bluebook/meta_validator.rb +79 -349
  113. data/lib/hecks/bluebook/model_check/client_profile.rb +6 -21
  114. data/lib/hecks/bluebook/model_check.rb +100 -597
  115. data/lib/hecks/bluebook/pattern_subset.rb +11 -69
  116. data/lib/hecks/bluebook/process_manager.rb +13 -83
  117. data/lib/hecks/bluebook/project_loader.rb +3 -39
  118. data/lib/hecks/bluebook/project_register.rb +12 -60
  119. data/lib/hecks/bluebook/query.rb +9 -48
  120. data/lib/hecks/bluebook/read_model.rb +57 -81
  121. data/lib/hecks/bluebook/reference.rb +7 -41
  122. data/lib/hecks/bluebook/smoke_test.rb +8 -98
  123. data/lib/hecks/bluebook/synthesizer.rb +13 -62
  124. data/lib/hecks/bluebook/translation.rb +26 -62
  125. data/lib/hecks/bluebook/value_object.rb +11 -36
  126. data/lib/hecks/bluebook.rb +5 -22
  127. data/lib/hecks/cache_dir.rb +4 -23
  128. data/lib/hecks/cli/document.rb +3 -21
  129. data/lib/hecks/cli/ir.rb +3 -5
  130. data/lib/hecks/cli/mcp.rb +2 -3
  131. data/lib/hecks/cli/mcp_door.rb +19 -114
  132. data/lib/hecks/cli/model_check.rb +18 -85
  133. data/lib/hecks/cli/project_cli.rb +7 -40
  134. data/lib/hecks/cli/project_diagrams.rb +0 -7
  135. data/lib/hecks/cli/run.rb +12 -58
  136. data/lib/hecks/cli/smoke_test.rb +2 -16
  137. data/lib/hecks/cli/stores.rb +1 -2
  138. data/lib/hecks/cli.rb +18 -24
  139. data/lib/hecks/construct.rb +8 -34
  140. data/lib/hecks/deploy/bluebook/deploy.bluebook +33 -142
  141. data/lib/hecks/deploy/bluebook/deploy.hecksagon +2 -9
  142. data/lib/hecks/embryonaut_bluebook/lock.rb +3 -35
  143. data/lib/hecks/embryonaut_bluebook/shape.rb +1 -17
  144. data/lib/hecks/embryonaut_bluebook/vendor.rb +8 -53
  145. data/lib/hecks/embryonaut_bluebook/vendor_cli.rb +4 -19
  146. data/lib/hecks/embryonaut_bluebook.rb +4 -71
  147. data/lib/hecks/facade/cli_door.rb +24 -106
  148. data/lib/hecks/facade/cli_runner.rb +28 -172
  149. data/lib/hecks/facade/command_request.rb +13 -33
  150. data/lib/hecks/facade/handle.rb +34 -121
  151. data/lib/hecks/facade/json_door.rb +31 -146
  152. data/lib/hecks/facade/surface/aggregate_door.rb +39 -104
  153. data/lib/hecks/facade/surface/chapter.rb +10 -54
  154. data/lib/hecks/facade/surface.rb +8 -23
  155. data/lib/hecks/facade.rb +10 -25
  156. data/lib/hecks/forms/app.rb +15 -70
  157. data/lib/hecks/forms/command_form_renderer.rb +10 -29
  158. data/lib/hecks/forms/field_renderer.rb +17 -156
  159. data/lib/hecks/forms/field_shape.rb +30 -222
  160. data/lib/hecks/forms/html.rb +12 -47
  161. data/lib/hecks/forms/index_renderer.rb +1 -4
  162. data/lib/hecks/forms/page.rb +3 -9
  163. data/lib/hecks/forms/params.rb +14 -60
  164. data/lib/hecks/forms/port_argument.rb +2 -19
  165. data/lib/hecks/forms/query_form_renderer.rb +4 -79
  166. data/lib/hecks/forms/record_renderer.rb +8 -75
  167. data/lib/hecks/forms/record_table.rb +7 -50
  168. data/lib/hecks/forms/reference_options.rb +3 -30
  169. data/lib/hecks/forms/value_object_shape.rb +8 -35
  170. data/lib/hecks/forms.rb +5 -33
  171. data/lib/hecks/fqn.rb +5 -12
  172. data/lib/hecks/framework/bluebook/compliance.bluebook +16 -65
  173. data/lib/hecks/framework/bluebook/console_settings.bluebook +47 -134
  174. data/lib/hecks/framework/bluebook/framework.hecksagon +5 -14
  175. data/lib/hecks/framework/bluebook/governance.bluebook +13 -34
  176. data/lib/hecks/framework/bluebook/identity.bluebook +11 -26
  177. data/lib/hecks/framework/bluebook/privacy.bluebook +8 -33
  178. data/lib/hecks/framework.rb +11 -80
  179. data/lib/hecks/freezer.rb +5 -39
  180. data/lib/hecks/grammar/expression.bluebook +15 -40
  181. data/lib/hecks/grammar/translation.bluebook +3 -6
  182. data/lib/hecks/grammar.rb +16 -41
  183. data/lib/hecks/ir.rb +14 -83
  184. data/lib/hecks/language/adapter.bluebook +2 -7
  185. data/lib/hecks/language/bluebook/aggregate.bluebook +56 -221
  186. data/lib/hecks/language/bluebook/attaches/paging.bluebook +6 -15
  187. data/lib/hecks/language/bluebook/bluebook.bluebook +15 -83
  188. data/lib/hecks/language/bluebook/bluebook.hecksagon +3 -15
  189. data/lib/hecks/language/bluebook/command.bluebook +27 -144
  190. data/lib/hecks/language/bluebook/entity.bluebook +24 -97
  191. data/lib/hecks/language/bluebook/policy.bluebook +16 -67
  192. data/lib/hecks/language/bluebook/process_manager.bluebook +28 -151
  193. data/lib/hecks/language/bluebook/projection.bluebook +126 -60
  194. data/lib/hecks/language/bluebook/query.bluebook +12 -43
  195. data/lib/hecks/language/bluebook/shape.bluebook +23 -73
  196. data/lib/hecks/language/bluebook/syntax.bluebook +51 -262
  197. data/lib/hecks/language/bluebook/vocabulary.bluebook +82 -197
  198. data/lib/hecks/language/hecksagon/adapter_binding.bluebook +3 -10
  199. data/lib/hecks/language/hecksagon/domain_port.bluebook +4 -19
  200. data/lib/hecks/language/hecksagon/hecksagon.bluebook +6 -25
  201. data/lib/hecks/language/hecksagon/port_operation.bluebook +3 -14
  202. data/lib/hecks/language/oidc.json +35 -0
  203. data/lib/hecks/language/port.bluebook +4 -17
  204. data/lib/hecks/language/translation/translation.bluebook +3 -9
  205. data/lib/hecks/language/translation/translation_aggregate.bluebook +5 -24
  206. data/lib/hecks/language/world/wiring.bluebook +1 -3
  207. data/lib/hecks/language/world/world.bluebook +5 -7
  208. data/lib/hecks/literal.rb +8 -50
  209. data/lib/hecks/mcp_door_scope.rb +9 -90
  210. data/lib/hecks/mcp_stdio_guard.rb +4 -41
  211. data/lib/hecks/naming.rb +29 -137
  212. data/lib/hecks/ports/access_control.rb +7 -23
  213. data/lib/hecks/ports/agent/answers.rb +5 -23
  214. data/lib/hecks/ports/agent.rb +47 -172
  215. data/lib/hecks/ports/authentication.rb +12 -39
  216. data/lib/hecks/ports/authorization.rb +16 -43
  217. data/lib/hecks/ports/clock.rb +5 -45
  218. data/lib/hecks/ports/extraction.rb +7 -12
  219. data/lib/hecks/ports/identity_assignment.rb +8 -29
  220. data/lib/hecks/ports/identity_generation.rb +6 -29
  221. data/lib/hecks/ports/identity_resolution.rb +2 -10
  222. data/lib/hecks/ports/key_vault.rb +9 -45
  223. data/lib/hecks/ports/persistence/append_only.rb +61 -64
  224. data/lib/hecks/ports/persistence/binding_policy.rb +4 -14
  225. data/lib/hecks/ports/persistence/codec_boundary.rb +20 -80
  226. data/lib/hecks/ports/persistence/null_saga_store.rb +4 -20
  227. data/lib/hecks/ports/persistence/plugin.rb +13 -42
  228. data/lib/hecks/ports/persistence/plugins/era/era_check.rb +38 -141
  229. data/lib/hecks/ports/persistence/plugins/era/era_guard/shape_diff.rb +15 -115
  230. data/lib/hecks/ports/persistence/plugins/era/era_guard.rb +16 -84
  231. data/lib/hecks/ports/persistence/plugins/era/era_tamper.rb +6 -25
  232. data/lib/hecks/ports/persistence/plugins/era/expected_era.rb +3 -22
  233. data/lib/hecks/ports/persistence/plugins/era/lineage.rb +55 -181
  234. data/lib/hecks/ports/persistence/plugins/era/postgres_era/events.rb +77 -0
  235. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/era_store.rb +12 -122
  236. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/field_cache.rb +28 -128
  237. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/head_compiler.rb +73 -474
  238. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/mint_transaction.rb +31 -124
  239. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/provisioning.rb +45 -219
  240. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/resumable_backfill.rb +13 -108
  241. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/tail_merge.rb +18 -75
  242. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/transform_installer.rb +9 -49
  243. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage.rb +6 -123
  244. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/coverage_check.rb +23 -55
  245. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/era_resolver.rb +14 -72
  246. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/merge_coordinator.rb +7 -16
  247. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb +14 -115
  248. data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager.rb +13 -45
  249. data/lib/hecks/ports/persistence/plugins/era/postgres_era.rb +127 -554
  250. data/lib/hecks/ports/persistence/plugins/era/storage_shape.rb +13 -63
  251. data/lib/hecks/ports/persistence/plugins/era/translation/audit/approval_digest.rb +2 -17
  252. data/lib/hecks/ports/persistence/plugins/era/translation/audit/layer_one.rb +3 -14
  253. data/lib/hecks/ports/persistence/plugins/era/translation/audit/layer_two.rb +13 -58
  254. data/lib/hecks/ports/persistence/plugins/era/translation/audit/unfed_report.rb +3 -17
  255. data/lib/hecks/ports/persistence/plugins/era/translation/audit.rb +9 -26
  256. data/lib/hecks/ports/persistence/plugins/era/translation/reattest.rb +9 -25
  257. data/lib/hecks/ports/persistence/plugins/era/translation/rule_compiler.rb +18 -124
  258. data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/differ.rb +34 -123
  259. data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/renderer.rb +5 -12
  260. data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/writer.rb +3 -9
  261. data/lib/hecks/ports/persistence/plugins/era/translation/scaffold.rb +2 -14
  262. data/lib/hecks/ports/persistence/plugins/era.rb +4 -23
  263. data/lib/hecks/ports/persistence/postgres_dump/connection.rb +7 -23
  264. data/lib/hecks/ports/persistence/postgres_dump.rb +4 -35
  265. data/lib/hecks/ports/persistence/remote_runtime.rb +2 -24
  266. data/lib/hecks/ports/persistence/repository_factory.rb +8 -27
  267. data/lib/hecks/ports/persistence/state_codec.rb +23 -103
  268. data/lib/hecks/ports/persistence.rb +7 -14
  269. data/lib/hecks/ports/projection.rb +42 -84
  270. data/lib/hecks/ports/query/in_memory.rb +10 -58
  271. data/lib/hecks/ports/query/ordering.rb +11 -32
  272. data/lib/hecks/ports/query.rb +14 -37
  273. data/lib/hecks/ports.rb +2 -8
  274. data/lib/hecks/projections/bootstrap_table.rb +11 -43
  275. data/lib/hecks/projections/deploy/fargate/assembly.rb +2 -15
  276. data/lib/hecks/projections/deploy/fargate/cdn.rb +1 -48
  277. data/lib/hecks/projections/deploy/fargate/cdn_default.rb +2 -11
  278. data/lib/hecks/projections/deploy/fargate/check.rb +5 -14
  279. data/lib/hecks/projections/deploy/fargate/containers.rb +3 -78
  280. data/lib/hecks/projections/deploy/fargate/extras.rb +3 -44
  281. data/lib/hecks/projections/deploy/fargate/monitoring.rb +0 -44
  282. data/lib/hecks/projections/deploy/fargate/settings.rb +2 -54
  283. data/lib/hecks/projections/deploy/fargate/yaml.rb +13 -58
  284. data/lib/hecks/projections/deploy/fargate.rb +35 -202
  285. data/lib/hecks/projections/deploy/lambda.rb +150 -678
  286. data/lib/hecks/projections/deploy/preview/access_yaml.rb +1 -33
  287. data/lib/hecks/projections/deploy/preview/containers.rb +6 -111
  288. data/lib/hecks/projections/deploy/preview/routing_yaml.rb +4 -56
  289. data/lib/hecks/projections/deploy/preview/script.rb +2 -14
  290. data/lib/hecks/projections/deploy/preview/settings.rb +3 -33
  291. data/lib/hecks/projections/deploy/preview/task_yaml.rb +2 -38
  292. data/lib/hecks/projections/deploy/preview/template.rb +2 -58
  293. data/lib/hecks/projections/deploy/preview.rb +2 -67
  294. data/lib/hecks/projections/deploy/scripts/settings.rb +3 -25
  295. data/lib/hecks/projections/deploy/scripts.rb +4 -57
  296. data/lib/hecks/projections/deploy/shared.rb +47 -146
  297. data/lib/hecks/projections/deploy/smoke.rb +4 -61
  298. data/lib/hecks/projections/deploy/template_diff/comparer.rb +3 -25
  299. data/lib/hecks/projections/deploy/template_diff/loader.rb +2 -11
  300. data/lib/hecks/projections/deploy/template_diff.rb +5 -57
  301. data/lib/hecks/projections/diagrams.rb +20 -582
  302. data/lib/hecks/projections/glossary/html.rb +14 -130
  303. data/lib/hecks/projections/glossary/markdown.rb +8 -69
  304. data/lib/hecks/projections/glossary/mermaid.rb +9 -66
  305. data/lib/hecks/projections/glossary/sensitivity.rb +5 -34
  306. data/lib/hecks/projections/glossary/sentences.rb +14 -159
  307. data/lib/hecks/projections/glossary.rb +30 -222
  308. data/lib/hecks/projections/ir.rb +3 -10
  309. data/lib/hecks/projections/model/deviations.rb +15 -42
  310. data/lib/hecks/projections/model.rb +12 -51
  311. data/lib/hecks/projections/oidc.rb +12 -56
  312. data/lib/hecks/projections/parser_table.rb +9 -28
  313. data/lib/hecks/projections/reference.rb +2 -15
  314. data/lib/hecks/projections/rust_vocabulary.rb +12 -250
  315. data/lib/hecks/projections/shape.rb +3 -29
  316. data/lib/hecks/projections/statements.rb +7 -86
  317. data/lib/hecks/projections/vocabulary.rb +6 -22
  318. data/lib/hecks/projections.rb +2 -16
  319. data/lib/hecks/projector/cli_projector.rb +60 -375
  320. data/lib/hecks/projector/docs_projector.rb +10 -201
  321. data/lib/hecks/projector/exporter.rb +42 -134
  322. data/lib/hecks/projector/ir_projector.rb +2 -9
  323. data/lib/hecks/projector/narrate_projector.rb +15 -189
  324. data/lib/hecks/projector/target.rb +13 -76
  325. data/lib/hecks/projector.rb +30 -121
  326. data/lib/hecks/query_specification/common/comparators.rb +5 -26
  327. data/lib/hecks/query_specification/common/comparison.rb +35 -143
  328. data/lib/hecks/query_specification/common/dsl.rb +8 -24
  329. data/lib/hecks/query_specification/common/null_policy.rb +20 -70
  330. data/lib/hecks/query_specification/common/options.rb +2 -6
  331. data/lib/hecks/query_specification/common/where_clause.rb +2 -10
  332. data/lib/hecks/query_specification/field_path.rb +37 -77
  333. data/lib/hecks/query_specification/hop_path.rb +12 -76
  334. data/lib/hecks/release/gem_pin.rb +2 -26
  335. data/lib/hecks/release/runner/ci_publisher.rb +3 -6
  336. data/lib/hecks/release/runner/commands.rb +2 -4
  337. data/lib/hecks/release/runner/gem_publisher.rb +2 -3
  338. data/lib/hecks/release/runner/npm_publisher.rb +6 -20
  339. data/lib/hecks/release/runner/preflight.rb +4 -19
  340. data/lib/hecks/release/runner/tagger.rb +2 -9
  341. data/lib/hecks/release/runner.rb +3 -32
  342. data/lib/hecks/rendering.rb +4 -26
  343. data/lib/hecks/router/namespace_installer.rb +12 -36
  344. data/lib/hecks/router.rb +4 -8
  345. data/lib/hecks/runtime/aggregate_lock.rb +8 -33
  346. data/lib/hecks/runtime/boot_gates.rb +3 -18
  347. data/lib/hecks/runtime/caller.rb +19 -59
  348. data/lib/hecks/runtime/capability_graph.rb +5 -21
  349. data/lib/hecks/runtime/command_interpreter/argument_gate.rb +16 -78
  350. data/lib/hecks/runtime/command_interpreter/mutation_applier.rb +23 -160
  351. data/lib/hecks/runtime/command_interpreter.rb +124 -306
  352. data/lib/hecks/runtime/command_rules/admissibility.rb +95 -366
  353. data/lib/hecks/runtime/command_rules/arithmetic.rb +66 -196
  354. data/lib/hecks/runtime/command_rules/authorization.rb +13 -45
  355. data/lib/hecks/runtime/command_rules/emission.rb +8 -21
  356. data/lib/hecks/runtime/command_rules/references.rb +23 -202
  357. data/lib/hecks/runtime/dependency_planning.rb +30 -102
  358. data/lib/hecks/runtime/dispatcher.rb +82 -241
  359. data/lib/hecks/runtime/entity_element.rb +40 -462
  360. data/lib/hecks/runtime/entity_interpreter.rb +64 -219
  361. data/lib/hecks/runtime/errors.rb +32 -115
  362. data/lib/hecks/runtime/event.rb +3 -25
  363. data/lib/hecks/runtime/identity.rb +18 -154
  364. data/lib/hecks/runtime/instance.rb +18 -150
  365. data/lib/hecks/runtime/interpreting.rb +11 -70
  366. data/lib/hecks/runtime/invocation.rb +28 -164
  367. data/lib/hecks/runtime/loader.rb +48 -186
  368. data/lib/hecks/runtime/outbox.rb +38 -261
  369. data/lib/hecks/runtime/policy_interpreter.rb +38 -200
  370. data/lib/hecks/runtime/port_operation_interpreter.rb +26 -87
  371. data/lib/hecks/runtime/query_interpreter.rb +45 -187
  372. data/lib/hecks/runtime/reaction_invocation.rb +36 -138
  373. data/lib/hecks/runtime/read_model_interpreter.rb +117 -208
  374. data/lib/hecks/runtime/rebuild_sweep.rb +8 -54
  375. data/lib/hecks/runtime/reference_hop.rb +8 -81
  376. data/lib/hecks/runtime/refusal_wording.rb +8 -89
  377. data/lib/hecks/runtime/registry/saga_persistence.rb +10 -102
  378. data/lib/hecks/runtime/registry/verification.rb +52 -225
  379. data/lib/hecks/runtime/registry/world_defaults.rb +4 -53
  380. data/lib/hecks/runtime/registry.rb +99 -244
  381. data/lib/hecks/runtime/remote_dispatcher.rb +37 -152
  382. data/lib/hecks/runtime/routing.rb +4 -15
  383. data/lib/hecks/runtime/saga_interpreter/correlation.rb +14 -61
  384. data/lib/hecks/runtime/saga_interpreter.rb +79 -263
  385. data/lib/hecks/runtime/saga_pending_dispatch.rb +2 -43
  386. data/lib/hecks/runtime/tenant_check.rb +6 -68
  387. data/lib/hecks/runtime/tenant_scope.rb +3 -28
  388. data/lib/hecks/runtime/value/admission.rb +16 -67
  389. data/lib/hecks/runtime/value/coercion.rb +155 -641
  390. data/lib/hecks/runtime/value/entity_list_coercion.rb +26 -219
  391. data/lib/hecks/runtime/value.rb +12 -84
  392. data/lib/hecks/runtime.rb +17 -65
  393. data/lib/hecks/storehouse.rb +141 -568
  394. data/lib/hecks/tenancy/bluebook/tenancy.bluebook +8 -32
  395. data/lib/hecks/tenancy/bluebook/tenancy.hecksagon +6 -23
  396. data/lib/hecks/vendoring/git_environment.rb +2 -8
  397. data/lib/hecks/vendoring/git_source.rb +4 -10
  398. data/lib/hecks/vendoring.rb +7 -46
  399. data/lib/hecks/version.rb +3 -14
  400. data/lib/hecks.rb +26 -81
  401. data/lib/rubocop/cop/hecks/fallback_hash_lookup.rb +8 -46
  402. data/lib/rubocop/cop/hecks/sequential_hash_rename_in_loop.rb +11 -80
  403. data/lib/rubocop/cop/hecks/thread_shared_ivar_mutation.rb +10 -99
  404. metadata +3 -2
@@ -1,37 +1,23 @@
1
1
  module Hecks
2
2
  module QuerySpecification
3
3
  module Common
4
- # Null-handling shared between the in-memory and SQL query
5
- # engines: stable null-aware ordering (#order, #sql_order) and
6
- # which comparators a null value can never satisfy (#unmatchable?,
7
- # #sql_predicate) — kept in one place because Memory, Postgres and
8
- # SQLite each default nulls differently and must be made to agree
9
- # explicitly rather than leaking their own native behavior.
4
+ # Null handling shared by the in-memory and SQL query engines: null-aware ordering
5
+ # and the comparators a null can never satisfy, so every adapter agrees.
10
6
  module NullPolicy
11
7
  module_function
12
8
 
13
9
  # Sorts records in memory by one key, placing the null-keyed ones where
14
10
  # the policy says and keeping ties in their incoming order.
15
11
  #
16
- # Stable on purpose : rows arrive already in identity order from
17
- # `Ports::Query::Ordering`, and that base is what makes a tie deterministic
18
- # rather than store-dependent. A plain sort_by is not stable in Ruby, so
19
- # equal keys would shuffle and the identity tier would be lost exactly
20
- # where it is needed. Descending reverses both partitions, so a tie reads
21
- # identity-descending too — the same total order sql_order renders as
22
- # `field DESC, id DESC`.
12
+ # Stable on purpose: rows arrive in identity order, which makes ties deterministic.
13
+ # Descending reverses both partitions, matching `sql_order`'s `field DESC, id DESC`.
23
14
  #
24
15
  # @param records [Array<Object>] the rows to order, already in identity order
25
- # @param direction [Symbol, String] `desc` in any letter case sorts descending;
26
- # anything else ascending
27
- # @param policy [NullSemantics, nil] where nulls go: mode `first` or `last`; `nil` or
28
- # any other mode (`native`) puts nulls first ascending and last descending
29
- # @yield reads the sort key out of one record
16
+ # @param direction [Symbol, String] `desc` sorts descending; anything else ascending
17
+ # @param policy [NullSemantics, nil] mode `first` or `last`; otherwise `native`
30
18
  # @yieldparam record [Object] one element of `records`
31
- # @yieldreturn [Comparable, nil] the key, mutually comparable across records; `nil`
32
- # marks the record as null-keyed
33
- # @return [Array<Object>] a new Array holding every record in the requested order
34
- # @raise [ArgumentError] if two non-nil keys cannot be compared with each other
19
+ # @yieldreturn [Comparable, nil] the sort key; `nil` marks the record null-keyed
20
+ # @return [Array<Object>] a new Array in the requested order
35
21
  def order(records, direction:, policy: nil, &key)
36
22
  descending = direction.to_s.downcase == "desc"
37
23
  null_rows, valued_rows = records.partition { |record| key.call(record).nil? }
@@ -50,27 +36,13 @@ module Hecks
50
36
  # Renders the `ORDER BY` terms for one expression, with an explicit
51
37
  # `NULLS FIRST`/`NULLS LAST` and an `id` tiebreak in the same direction.
52
38
  #
53
- # M3 — an undeclared (`native`) null policy still renders a
54
- # `NULLS ...` clause. Rendering none leaves each dialect's own
55
- # default to decide: Postgres puts nulls last on ASC (and first
56
- # on DESC), while `#order` above — this same "native" default,
57
- # for Memory — puts nulls first on ASC (and last on DESC), the
58
- # SQLite convention. Same query, same data, different row order
59
- # depending only on which adapter ran it. Rendered explicitly
60
- # here instead, so an undeclared policy means the same total
61
- # order everywhere rather than "whatever this store already does"
62
- # — matching `#order`'s own default rather than the other way
63
- # round, since that default is unconditional (Memory/Heki have no
64
- # dialect to defer to) and SQLite already agrees with it natively.
39
+ # An undeclared (`native`) policy still renders `NULLS ...`, because dialects
40
+ # differ (Postgres puts nulls last on ASC); this matches `#order`'s default.
65
41
  #
66
- # @param expression [String] the SQL expression to order by, already quoted or
67
- # built by the adapter; interpolated as is
68
- # @param direction [Symbol, String] `desc` in any letter case renders `DESC`;
69
- # anything else `ASC`
70
- # @param policy [NullSemantics, nil] mode `first` or `last` pins the nulls; `nil` or
71
- # any other mode renders `NULLS FIRST` ascending and `NULLS LAST` descending
72
- # @return [String] the terms without the `ORDER BY` keyword, such as
73
- # `"price ASC NULLS FIRST, id ASC"`
42
+ # @param expression [String] the SQL expression, interpolated as is
43
+ # @param direction [Symbol, String] `desc` renders `DESC`; anything else `ASC`
44
+ # @param policy [NullSemantics, nil] mode `first` or `last` pins the nulls
45
+ # @return [String] the terms without `ORDER BY`, such as `"price ASC NULLS FIRST, id ASC"`
74
46
  def sql_order(expression, direction, policy)
75
47
  direction = direction.to_s.downcase == "desc" ? "DESC" : "ASC"
76
48
  nulls = case policy&.mode.to_s
@@ -81,34 +53,13 @@ module Hecks
81
53
  "#{expression} #{direction}#{nulls}, id #{direction}"
82
54
  end
83
55
 
84
- # **The comparators a NULL cannot satisfy** — the other half of
85
- # `sql_predicate` below. That one answers "the value compared to is
86
- # null" (`eq: nil` -> IS NULL, `ne: nil` -> IS NOT NULL, a real
87
- # convention both adapters already shared). This one answers the
88
- # case nothing covered: the row's own value is null and the value
89
- # compared to is not.
56
+ # Comparators a NULL row value can never satisfy.
90
57
  #
91
- # SQL says unknown. `NULL <> 'red'` is NULL, not true, so the row
92
- # is not returned. Ruby says `nil != "red"` is true, so it is. The
93
- # two adapters therefore answered the same query on the same data
94
- # differently — Memory returning a row SQLite omitted — which is
95
- # not a difference of opinion a caller can plan around.
96
- #
97
- # Resolved toward SQL, and not because SQL is the store: an absent
98
- # or null field is unknown, not a value, and a comparison against
99
- # unknown is unknown rather than true. Making SQL match Ruby
100
- # instead would mean compiling every `ne:` to
101
- # `(col <> $1 OR col IS NULL)` — more to get right in two
102
- # dialects, and a reliable way to lose an index — to make a real
103
- # query engine agree with an in-memory one.
104
- #
105
- # `none_in_state` is deliberately not here: it is a 9th, vendored
106
- # comparator whose `held` is a reference id, and a row holding no
107
- # reference is genuinely "not in that state" rather than unknown.
58
+ # SQL treats `NULL <> 'red'` as unknown, so the row is dropped; Memory follows SQL.
59
+ # `none_in_state` is excluded: a row with no reference is not in that state.
108
60
  NULL_UNMATCHABLE = %w[eq ne lt lte gt gte in contains].freeze
109
61
 
110
- # Decides whether a comparison is lost before it starts because the row's
111
- # own value is null — the rule `NULL_UNMATCHABLE`'s comment argues for.
62
+ # Decides whether a comparison is lost because the row's own value is null.
112
63
  #
113
64
  # @param operation [Symbol, String] the comparator name, such as `:ne`
114
65
  # @param held [Object, nil] the row's own value for the field
@@ -119,9 +70,8 @@ module Hecks
119
70
  held.nil? && !want.nil? && NULL_UNMATCHABLE.include?(operation.to_s)
120
71
  end
121
72
 
122
- # Renders the SQL for a comparison against a null value — `eq: nil` as
123
- # `IS NULL`, `ne: nil` as `IS NOT NULL` — so an adapter never binds a
124
- # `NULL` parameter to `=` or `<>`.
73
+ # Renders the SQL for a comparison against a null value (`IS NULL`/`IS NOT NULL`),
74
+ # so an adapter never binds a `NULL` parameter to `=` or `<>`.
125
75
  #
126
76
  # @param expression [String] the SQL expression for the field, interpolated as is
127
77
  # @param operation [Symbol, String] the comparator name
@@ -3,12 +3,8 @@ require_relative "null_semantics"
3
3
  module Hecks
4
4
  module QuerySpecification
5
5
  module Common
6
- # The attribute set every query-shaped construct shares — wheres,
7
- # ordering, paging, cursor, authorization, null semantics,
8
- # inspection mode — plus `options_to_h`/`extra_options_to_h` for
9
- # serializing it. Both Bluebook::Query and
10
- # QuerySpecification::ReadModel::Specification subclass this
11
- # rather than each declaring the same fields twice.
6
+ # The attribute set every query-shaped construct shares, plus `options_to_h` and
7
+ # `extra_options_to_h` for serializing it.
12
8
  class Options
13
9
  attr_reader :wheres, :order_by, :limit, :offset, :cursor,
14
10
  :authorization, :null_semantics, :inspection
@@ -1,16 +1,8 @@
1
1
  module Hecks
2
2
  module QuerySpecification
3
3
  module Common
4
- # `target` — which many-side `include`d aggregate this clause applies
5
- # to on a `read_model` with more than one (ADR 0055's own `on:`,
6
- # `ReadModelBuilder#where_impl`). Always `nil` for a plain `Query`'s
7
- # own `where` (that builder never overrides `where_impl` to accept
8
- # `on:`), and `nil` for a `read_model` with a single many-side head,
9
- # where naming one is unnecessary. `to_h` omits the key entirely
10
- # rather than emitting `target: nil` — the same "absent, not null"
11
- # convention `count`/`median_field` already established
12
- # (`lib/hecks/bluebook/read_model.rb`), so every read model that
13
- # never uses `on:` keeps its existing wire shape byte-identical.
4
+ # One filter clause. `target` names the many-side `include`d aggregate on a
5
+ # `read_model` with several (ADR 0055); `to_h` omits it when `nil`.
14
6
  WhereClause = Struct.new(:field, :op, :value, :target, keyword_init: true) do
15
7
  def to_h
16
8
  base = { field: field.to_s, op: op.to_s, value: QuerySpecification.render_value(value) }
@@ -1,44 +1,20 @@
1
1
  module Hecks
2
2
  module QuerySpecification
3
- # One reading of a dotted query-field path, shared by every place that
4
- # would otherwise invent its own. Left to themselves they disagree: a
5
- # reference interpreter doing a bare `record[field]` lookup silently
6
- # matches nothing for a dotted path, an SQL side that splits dots but
7
- # judges numericness from the first nested segment only quietly
8
- # compares a two-level path as text, and a build seal walks the
9
- # declaration graph a third way. Three implementations of "what does
10
- # pizza.price_cents.cents mean" is two more than a language gets to
11
- # have.
3
+ # One reading of a dotted query-field path, shared by every caller that walks one.
12
4
  #
13
- # Two sides, deliberately in one file so they cannot drift:
14
- #
15
- # dig(holder, field) — value side: walk a record's held state,
16
- # segment by segment, through Value
17
- # objects and plain hashes alike.
18
- # leaf_attribute / numeric? — declaration side: walk the declared
19
- # shape to the attribute a path lands on.
20
- # Callers supply value-object lookup as a
21
- # block, because an Aggregate and a
22
- # mid-build AggregateBuilder hold their
23
- # shapes differently but walk the same.
5
+ # `dig` walks a record's held state; `leaf_attribute`/`numeric?` walk the declared shape.
24
6
  module FieldPath
25
7
  module_function
26
8
 
27
9
  NUMERIC_PRIMITIVES = %w[Integer Float].freeze
10
+ INTEGER_PRIMITIVES = %w[Integer].freeze
11
+ BOOLEAN_PRIMITIVES = %w[TrueClass FalseClass].freeze
28
12
  SCALAR_PRIMITIVES = %w[String Integer Float TrueClass FalseClass].freeze
29
13
 
30
14
  # Reads the value a dotted field path names out of a record's held state.
31
15
  #
32
- # The held value a dotted field names, or nil — never a raise. The
33
- # first segment reads off the record (an Instance, a Value, or a
34
- # plain row hash); the rest read through whatever each step holds. A
35
- # stored nested value object is a plain hash by the time it is read
36
- # back, keyed by symbol in memory and by string off a wire decode,
37
- # so both spellings are tried — `key?` first, never `||`, because
38
- # `||` falls through a genuinely-stored `false` to the other
39
- # spelling (usually absent) and returns `nil` instead. The seal
40
- # admits boolean leaves (`SCALAR_PRIMITIVES` below), so a `false`
41
- # here is a real, held answer, not a missing one.
16
+ # Nested value objects come back as hashes keyed by symbol (memory) or string (wire),
17
+ # so both are tried, `key?` first: `||` would turn a stored `false` into `nil`.
42
18
  #
43
19
  # @param holder [Runtime::Instance, Runtime::Value, Hash, nil] the record, value
44
20
  # object or row Hash the first segment is read from
@@ -52,8 +28,7 @@ module Hecks
52
28
  field.to_s.split(".").reduce(holder) { |current, segment| read(current, segment) }
53
29
  end
54
30
 
55
- # Reads one path segment off whatever the previous step held — a single
56
- # step of `dig`.
31
+ # Reads one path segment off whatever the previous step held.
57
32
  #
58
33
  # @param current [Runtime::Instance, Runtime::Value, Hash, Array, nil] the value the
59
34
  # walk has reached; a Hash is tried by Symbol key, then by String key
@@ -68,14 +43,8 @@ module Hecks
68
43
  return current.key?(sym) ? current[sym] : current[segment]
69
44
  end
70
45
 
71
- # M5 — "or nil, never raise" is this method's whole contract, and
72
- # an Array broke it: `Array#[]` demands an Integer index, so
73
- # `current[segment]` (a String) raised `TypeError` straight
74
- # through `dig` instead of answering nil. A dotted path stepping
75
- # into a list_of attribute (`where "tags.name" == "x"` against a
76
- # bare list, rather than each element) has no single member a
77
- # bare index would name anyway — nil is the honest answer, the
78
- # same one a dangling reference or a missing key already gets.
46
+ # A list has no single member a String index could name; `Array#[]` would raise
47
+ # TypeError, breaking dig's "nil, never raise" contract.
79
48
  return nil if current.is_a?(Array)
80
49
 
81
50
  current[segment]
@@ -83,21 +52,16 @@ module Hecks
83
52
 
84
53
  # Walks the declared shape to the attribute a dotted path lands on.
85
54
  #
86
- # The declared attribute a path lands on, or nil. `segments` is the
87
- # dotted tail — for a bare field it is empty and the root attribute
88
- # is its own leaf. The walk stops dead at a reference (an id is a
89
- # scalar; nothing nests under it) and at any member the declared
90
- # value object does not carry.
55
+ # `segments` is the dotted tail, empty for a bare field. The walk stops at a reference
56
+ # and at any member the declared value object does not carry.
91
57
  #
92
- # @param attribute [Bluebook::Attribute, nil] the root attribute the path's first
93
- # segment names; `nil` (no such attribute) answers `nil`
58
+ # @param attribute [Bluebook::Attribute, nil] the root attribute; `nil` answers `nil`
94
59
  # @param segments [Array<String>] the path's remaining segments, `[]` for a bare field
95
60
  # @yield looks a value object up by name in the caller's own declarations
96
- # @yieldparam type [String] the type name of the attribute being stepped into
97
- # @yieldreturn [Class<Bluebook::ValueObject>, nil] the declared shape, or `nil` when
98
- # the type is not a value object the caller knows
99
- # @return [Bluebook::Attribute, nil] the attribute at the end of the path; `nil` when
100
- # a step crosses a reference, an undeclared type or a member that does not exist
61
+ # @yieldparam type [String] the type name being stepped into
62
+ # @yieldreturn [Class<Bluebook::ValueObject>, nil] the declared shape, or `nil`
63
+ # @return [Bluebook::Attribute, nil] the leaf; `nil` when a step crosses a reference or
64
+ # lands on an undeclared type or missing member
101
65
  def leaf_attribute(attribute, segments)
102
66
  current = attribute
103
67
  segments.each do |segment|
@@ -109,43 +73,39 @@ module Hecks
109
73
  current
110
74
  end
111
75
 
112
- # Decides from the declared shape whether a field path holds a number.
76
+ # Whether a field path lands on one of `primitives`: itself, or (bare field only) a
77
+ # value object with a member typed as one.
113
78
  #
114
- # May an ordered comparator (lt/lte/gt/gte) land here, and may an
115
- # `ORDER BY` cast here numerically? A bare field keeps the one-level
116
- # convention every adapter already implements: a numeric primitive,
117
- # or a value object carrying at least one numeric member. A dotted
118
- # path must land on a numeric primitive itself — the convention does
119
- # not reach through a named path, it is the absence of one.
120
- #
121
- # @param attribute [Bluebook::Attribute, nil] the root attribute the path starts at;
122
- # `nil` answers `false`
79
+ # @param attribute [Bluebook::Attribute, nil] the root attribute; `nil` answers `false`
123
80
  # @param segments [Array<String>] the path's remaining segments, `[]` for a bare field
81
+ # @param primitives [Array<String>] the primitive type names that count as a match
124
82
  # @yield looks a value object up by name, as for `leaf_attribute`
125
- # @yieldparam type [String] the type name to look up
126
- # @yieldreturn [Class<Bluebook::ValueObject>, nil] the declared shape, or `nil`
127
- # @return [Boolean] `true` when the leaf is an `Integer` or `Float`, or a bare field
128
- # naming a value object with at least one such member; `false` for a list, a
129
- # reference, or a path that lands nowhere
130
- def numeric?(attribute, segments, &)
83
+ # @return [Boolean] `false` for a list, a reference, or a path that lands nowhere
84
+ def matches_primitive?(attribute, segments, primitives, &)
131
85
  leaf = leaf_attribute(attribute, segments, &)
132
86
  return false if leaf.nil? || leaf.list? || leaf.reference?
133
- return true if NUMERIC_PRIMITIVES.include?(leaf.type.to_s)
87
+ return true if primitives.include?(leaf.type.to_s)
134
88
  return false unless segments.empty?
135
89
 
136
90
  shape = yield(leaf.type.to_s)
137
- !shape.nil? && shape.attributes.any? { |member| NUMERIC_PRIMITIVES.include?(member.type.to_s) }
91
+ !shape.nil? && shape.attributes.any? { |member| primitives.include?(member.type.to_s) }
138
92
  end
139
93
 
140
- # Decides whether a path ends on a scalar primitive that every engine
141
- # compares the same way.
94
+ # @return [Boolean] whether a field path holds a number (`Integer` or `Float`)
95
+ def numeric?(attribute, segments, &) = matches_primitive?(attribute, segments, NUMERIC_PRIMITIVES, &)
96
+
97
+ # @return [Boolean] whether a field path holds specifically an `Integer` (not `Float`)
98
+ def integer?(attribute, segments, &) = matches_primitive?(attribute, segments, INTEGER_PRIMITIVES, &)
99
+
100
+ # @return [Boolean] whether a field path holds a `TrueClass`/`FalseClass`
101
+ def boolean?(attribute, segments, &) = matches_primitive?(attribute, segments, BOOLEAN_PRIMITIVES, &)
102
+
103
+ # Decides whether a path ends on a scalar primitive every engine compares alike.
142
104
  #
143
- # A dotted path must end on a scalar member — landing on a value
144
- # object would hand SQL a JSON object where the reference
145
- # interpreter unwraps a hash, and the two would answer differently.
105
+ # A dotted path landing on a value object would give SQL a JSON object where the
106
+ # reference interpreter unwraps a hash, so the two would disagree.
146
107
  #
147
- # @param attribute [Bluebook::Attribute, nil] the root attribute the path starts at;
148
- # `nil` answers `false`
108
+ # @param attribute [Bluebook::Attribute, nil] the root attribute; `nil` answers `false`
149
109
  # @param segments [Array<String>] the path's remaining segments, `[]` for a bare field
150
110
  # @yield looks a value object up by name, as for `leaf_attribute`
151
111
  # @yieldparam type [String] the type name to look up
@@ -2,61 +2,26 @@ require_relative "../naming"
2
2
 
3
3
  module Hecks
4
4
  module QuerySpecification
5
- # One reading of a dotted query-field path that hops through a
6
- # reference into another aggregate's own shape — FieldPath's
7
- # sibling, not its member. FieldPath walks a shape, which cannot
8
- # loop, and answers nil, never raising, because there is nothing
9
- # left to say beyond "not found." HopPath walks the reference
10
- # graph instead — `BluebookBuilder#validate_no_bidirectional_references!`
11
- # refuses any reference cycle at declaration time (ADR 0025,
12
- # "References" — widened from a direct pair to any ring, DFS over
13
- # the chapter's own reference graph), so what's left to guard here
14
- # is depth, not cycles: MAX_HOPS below, and this module's own
15
- # `refusal` states for a target the chapter doesn't resolve. A walk
16
- # here still needs to say why it stopped, not just that it did.
5
+ # One reading of a dotted query-field path that hops through a reference with `/`.
17
6
  #
18
- # Every method below takes an attribute array, never a "shape"
19
- # object — deliberately, because the two real callers hold their
20
- # attributes differently. `AggregateBuilder` (tier-1 seal, mid-
21
- # build) exposes `attributes` as a plain reader, but its own
22
- # `attribute(name, type = String, ...)` is the DSL's attribute-
23
- # declaring method — calling it as a finder would silently mint a
24
- # new String attribute instead of looking one up. A sealed
25
- # `Aggregate` (tier-2 seal, and every runtime target) has a
26
- # real `attribute(name)` finder, but taking the array either way
27
- # sidesteps the mismatch instead of asking every caller to know
28
- # which kind of object it holds.
7
+ # Takes attribute arrays, not shapes: AggregateBuilder's `attribute(name)` declares rather
8
+ # than finds, so the two real callers cannot share a finder.
29
9
  module HopPath
30
10
  module_function
31
11
 
32
12
  Hop = Struct.new(:attribute, :target_name, :target, keyword_init: true)
33
13
 
34
- # refusal: nil (clean), :unresolvable (a hop's target cannot be
35
- # found — cross-domain, or simply not declared in this chapter),
36
- # :too_deep (see MAX_HOPS below).
14
+ # `refusal` is nil when clean, `:unresolvable` when a hop's target is not found,
15
+ # `:too_deep` when the chain exceeds MAX_HOPS.
37
16
  Plan = Struct.new(:hops, :tail, :refusal, keyword_init: true)
38
17
 
39
- # A hop chain long enough to matter is long enough to be a
40
- # mistake — not a guard against a walk that cannot terminate.
41
- # Nothing here loops forever regardless of how the reference
42
- # graph is shaped: a hop chain is a literal dotted string, fixed
43
- # at declaration time, and every step consumes exactly one of
44
- # its own segments — the walk is bounded by what was typed, not
45
- # by the graph. A self-referential aggregate hopping through
46
- # itself more than once (`"parent.parent.name"`, a grandparent
47
- # query) is real, common, and perfectly safe; this exists only
48
- # to refuse a chain nobody meant to write this long.
18
+ # Bounds hop chains: a longer one is a mistake, not a runaway walk, since each
19
+ # step consumes one segment of the typed path.
49
20
  MAX_HOPS = 8
50
21
 
51
22
  # Names the path segment a reference attribute answers to.
52
23
  #
53
- # The segment name a Reference answers to in a hop path — its own
54
- # declared attribute name, unchanged (ADR 0025, "References":
55
- # `reference_to` mints that bare name, no `_id`, so there is
56
- # no derivation left to apply). `proposal/client` (a query hop)
57
- # and `proposal.client` (the Ruby accessor,
58
- # `Facade::Handle#define_reference_accessors`) name the same
59
- # concept the same way.
24
+ # The attribute's own declared name, unchanged (ADR 0025).
60
25
  #
61
26
  # @param attribute [Bluebook::Attribute] a reference-typed attribute
62
27
  # @return [String] the attribute's declared name
@@ -65,17 +30,8 @@ module Hecks
65
30
  # Decides whether a field path starts by hopping through one of the given
66
31
  # references, without resolving the reference's target.
67
32
  #
68
- # Does this path's head cross into another record via `/`? The
69
- # operator is the answer now, not a name collision to arbitrate —
70
- # `.` walks fields inside this record, `/` crosses into another
71
- # one, so a path with no `/` is never a hop, full stop, and the
72
- # old "a real local attribute wins first" rule (needed only
73
- # because `.` was overloaded for both meanings, and `client_id`
74
- # vs `client` was how the two were told apart) has nothing left
75
- # to arbitrate. Answerable from `attributes` alone — a Reference
76
- # knows its own `target_name` at declaration, before it can
77
- # `resolve` it — which is what lets the aggregate seal recognise
78
- # a hop it cannot yet check.
33
+ # A path with no `/` is never a hop: `.` walks fields inside a record, `/` crosses
34
+ # into another one.
79
35
  #
80
36
  # @param field [String, Symbol] the query field path, such as `:"client/status"`
81
37
  # @param attributes [Array<Bluebook::Attribute>] the attributes of the shape the path
@@ -91,17 +47,6 @@ module Hecks
91
47
 
92
48
  # Resolves the first hop of a field path and hands back what is left to walk.
93
49
  #
94
- # **One step**: does `field`'s head hop through one of `attributes`'
95
- # own references? Answers the resolved `Hop` plus the string
96
- # still left to walk (itself possibly another `/`-hop, against
97
- # the target's own attributes, or a plain `.`-dotted field walk
98
- # once the hops run out) — or nil, when the head names nothing or
99
- # the path has no `/` at all. This is the one primitive
100
- # Runtime::ReferenceHop needs: it recurses hop by hop through its
101
- # own `apply`, one ordinary same-aggregate query at a time, and
102
- # never needs the whole chain resolved up front the way a seal
103
- # does.
104
- #
105
50
  # @param field [String, Symbol] the query field path, such as `"client/region/name"`
106
51
  # @param attributes [Array<Bluebook::Attribute>] the attributes of the shape the path
107
52
  # starts from
@@ -124,11 +69,6 @@ module Hecks
124
69
  # Resolves every hop of a field path in order, stopping with a reason at
125
70
  # the first one it cannot follow.
126
71
  #
127
- # The whole chain, resolved — every hop's target found, in
128
- # order — for the one caller that needs it all at once:
129
- # `BluebookBuilder#validate_query_hops!`, checking a hop chain
130
- # before anything ever dispatches it.
131
- #
132
72
  # @param field [String, Symbol] the query field path, such as `"client/region/name"`
133
73
  # @param attributes [Array<Bluebook::Attribute>] the attributes of the shape the path
134
74
  # starts from
@@ -149,12 +89,8 @@ module Hecks
149
89
  hop, rest = step
150
90
  return Plan.new(hops: hops, tail: nil, refusal: :too_deep) if hops.size >= MAX_HOPS
151
91
 
152
- # Pushed even unresolved — a caller reporting :unresolvable
153
- # needs this hop's own target_name (real, known at
154
- # declaration, regardless of whether resolve succeeded), not
155
- # whatever hop came before it. `.target` is nil on this one
156
- # entry; every caller checking `hops.last.target` already has
157
- # to handle that, the same way `next_hop`'s own caller does.
92
+ # Pushed even unresolved: a caller reporting :unresolvable needs this hop's
93
+ # target_name, and `.target` is nil on this one entry.
158
94
  hops << hop
159
95
  return Plan.new(hops: hops, tail: nil, refusal: :unresolvable) unless hop.target
160
96
 
@@ -2,32 +2,8 @@ require_relative "gem_pin/published_versions"
2
2
 
3
3
  module Hecks
4
4
  module Release
5
- # Finds the hecks version a project runs on, and refuses one that a
6
- # stranger could not install.
7
- #
8
- # ## Why it exists
9
- #
10
- # A project that is copied out of its own workspace (handed to someone who
11
- # will `bundle install` it, or built in an image with no sibling checkout)
12
- # has to name a hecks release RubyGems actually publishes. A `path:` or
13
- # `git:` source only works where the path or remote is reachable, and a
14
- # version that was never published resolves nowhere. This reads the
15
- # project's Gemfiles and lockfiles, without running Bundler, and says which
16
- # version each pins or refuses.
17
- #
18
- # ## Resolution
19
- #
20
- # For each `Gemfile` under the root (a project can hold several, such as a
21
- # domain and a helper app) the pin is, in order: the version its
22
- # `Gemfile.lock` resolved, or the newest stable release its version
23
- # constraint allows. Each pin must be published; the Gemfiles need not
24
- # agree.
25
- #
26
- # ## Injectable network
27
- #
28
- # The published list comes from `published:`, any object answering
29
- # `include?(version)` and `newest_satisfying(requirement)`. The default asks
30
- # RubyGems; a caller without network hands in its own.
5
+ # Reads a project's Gemfiles and lockfiles (no Bundler run) and says which
6
+ # hecks version each pins, refusing any version RubyGems does not publish.
31
7
  class GemPin
32
8
  GEM_LINE = /^\s*gem\s+["']hecks["'](?<rest>.*)$/
33
9
  SOURCE_OPTION = /\b(?:path|git|github|gitlab|bitbucket|branch|ref|tag):/
@@ -3,13 +3,10 @@ require_relative "commands"
3
3
  module Hecks
4
4
  module Release
5
5
  class Runner
6
- # The npm step when CI publishes: the release tag triggers
7
- # `.github/workflows/publish-client.yml`, which publishes `@hecks/client`
8
- # with npm trusted publishing, so nothing is published from this machine.
9
- # This watches npm until the version appears.
6
+ # Watches npm for `@hecks/client` after CI publishes it via
7
+ # `.github/workflows/publish-client.yml` (npm trusted publishing).
10
8
  #
11
- # The clock and the pause are injected, so a spec runs the whole wait
12
- # without sleeping.
9
+ # Its clock and pause are injected, so a spec runs the wait without sleeping.
13
10
  class CiPublisher
14
11
  WORKFLOW = ".github/workflows/publish-client.yml".freeze
15
12
  INTERVAL = 15
@@ -9,10 +9,8 @@ module Hecks
9
9
  # Raised when a check refuses the release; the message names the fix.
10
10
  class Refusal < StandardError; end
11
11
 
12
- # Runs the release's external commands: git, gem, npm, curl, op.
13
- #
14
- # The runner takes any object answering `capture` and `run!` the way this
15
- # one does, so a spec hands in a recorder and never starts a real process.
12
+ # Runs the release's external commands (git, gem, npm, curl, op) through
13
+ # any object answering `capture`/`run!`, so a spec injects a recorder.
16
14
  class Commands
17
15
  # What a captured command printed and whether it succeeded.
18
16
  #
@@ -4,9 +4,8 @@ require_relative "commands"
4
4
  module Hecks
5
5
  module Release
6
6
  class Runner
7
- # The gem step: hands the push to `bin/release_gem`, which owns building the
8
- # gem and pushing it with the key 1Password holds. A dry run builds the gem
9
- # to prove it builds and deletes it.
7
+ # The gem step: hands the push to `bin/release_gem`, which builds and pushes
8
+ # it with the key 1Password holds; a dry run only builds it, then deletes it.
10
9
  class GemPublisher
11
10
  # @param root [String] the repository root
12
11
  # @param commands [#run!] runs the build and the push
@@ -6,17 +6,6 @@ module Hecks
6
6
  class Runner
7
7
  # The npm step: publishes `@hecks/client` from `packages/hecks-client`
8
8
  # with the token 1Password holds.
9
- #
10
- # `op run` resolves `release/npm_publish.env` into the environment of the
11
- # one `npm publish` process. npm reads its token from a config file, so a
12
- # throwaway user config holds a placeholder that npm expands from that
13
- # environment; the file never contains the token and is deleted afterwards.
14
- # The package's `prepack` builds `dist/`.
15
- #
16
- # The token is a granular one that bypasses two-factor authentication, because
17
- # the account's second factor is a passkey. As a fallback the publish runs with
18
- # `--auth-type=web` and its output is not captured, so if npm does ask for an
19
- # approval it prints the link straight to the terminal and waits for it.
20
9
  class NpmPublisher
21
10
  PACKAGE_DIR = "packages/hecks-client".freeze
22
11
  ENV_FILE = "release/npm_publish.env".freeze
@@ -24,21 +13,14 @@ module Hecks
24
13
  "This step waits for you.".freeze
25
14
  USERCONFIG_LINE = "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}".freeze
26
15
 
27
- # @param root [String] the repository root
28
- # @param commands [#run!] runs npm and op
29
- # @param console [Console] progress output
30
16
  def initialize(root:, commands:, console:)
31
17
  @root = root
32
18
  @commands = commands
33
19
  @console = console
34
20
  end
35
21
 
36
- # Publishes the package, or with `dry_run` only packs it.
37
- #
38
- # @param version [String] the version being released
39
- # @param dry_run [Boolean] run `npm publish --dry-run`, which needs no credentials
40
- # @return [void]
41
- # @raise [CommandFailed] if installing, building or publishing fails
22
+ # Publishes the package, or with `dry_run` only packs it, which needs no
23
+ # credentials.
42
24
  def publish!(version, dry_run:)
43
25
  install_dependencies
44
26
  if dry_run
@@ -57,6 +39,7 @@ module Hecks
57
39
  File.join(@root, PACKAGE_DIR)
58
40
  end
59
41
 
42
+ # npm's `prepack` hook builds `dist/`; there is no separate build step here.
60
43
  def install_dependencies
61
44
  return if Dir.exist?(File.join(package_dir, "node_modules"))
62
45
 
@@ -64,6 +47,9 @@ module Hecks
64
47
  @commands.run!("npm", "ci", chdir: package_dir)
65
48
  end
66
49
 
50
+ # The token bypasses 2FA (the account's second factor is a passkey); this
51
+ # fallback publish runs with `--auth-type=web` and doesn't capture output,
52
+ # so an approval prompt reaches the terminal.
67
53
  def publish_with_token
68
54
  with_userconfig do |userconfig|
69
55
  @commands.run!(