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.
- checksums.yaml +4 -4
- data/exe/hecks +4 -6
- data/lib/hecks/adapters/driven/claude_code.rb +4 -104
- data/lib/hecks/adapters/driven/d1.rb +44 -237
- data/lib/hecks/adapters/driven/folder.rb +17 -76
- data/lib/hecks/adapters/driven/google_authentication.rb +15 -49
- data/lib/hecks/adapters/driven/governance_authorization.rb +23 -70
- data/lib/hecks/adapters/driven/heki/journal.rb +8 -41
- data/lib/hecks/adapters/driven/heki/saga_store.rb +12 -54
- data/lib/hecks/adapters/driven/heki/snapshot.rb +4 -12
- data/lib/hecks/adapters/driven/heki.rb +13 -42
- data/lib/hecks/adapters/driven/identity_registry.rb +3 -14
- data/lib/hecks/adapters/driven/in_memory_ordering.rb +9 -26
- data/lib/hecks/adapters/driven/in_process_key_vault.rb +2 -14
- data/lib/hecks/adapters/driven/lambda/client.rb +10 -51
- data/lib/hecks/adapters/driven/lambda.rb +10 -84
- data/lib/hecks/adapters/driven/local_storage.rb +5 -40
- data/lib/hecks/adapters/driven/memory.rb +17 -98
- data/lib/hecks/adapters/driven/mock_stripe_adapter.rb +5 -21
- data/lib/hecks/adapters/driven/postgres/codec.rb +6 -28
- data/lib/hecks/adapters/driven/postgres/outbox.rb +3 -12
- data/lib/hecks/adapters/driven/postgres/reconnect.rb +4 -30
- data/lib/hecks/adapters/driven/postgres/schema_builder.rb +34 -108
- data/lib/hecks/adapters/driven/postgres.rb +145 -134
- data/lib/hecks/adapters/driven/postgres_era.adapter +4 -15
- data/lib/hecks/adapters/driven/prism.rb +7 -30
- data/lib/hecks/adapters/driven/sql_query_builder.rb +21 -121
- data/lib/hecks/adapters/driven/sqlite/codec.rb +8 -40
- data/lib/hecks/adapters/driven/sqlite/projection.rb +26 -82
- data/lib/hecks/adapters/driven/sqlite/schema_builder.rb +40 -84
- data/lib/hecks/adapters/driven/sqlite.rb +128 -65
- data/lib/hecks/adapters/driven/tenant_provisioner.rb +5 -48
- data/lib/hecks/adapters/driven.rb +5 -36
- data/lib/hecks/adapters/driving/github_webhook.rb +8 -76
- data/lib/hecks/behaviors/dsl.rb +7 -25
- data/lib/hecks/behaviors/expectations.rb +31 -141
- data/lib/hecks/behaviors/ir.rb +7 -20
- data/lib/hecks/behaviors/rspec.rb +6 -17
- data/lib/hecks/behaviors/runner.rb +10 -34
- data/lib/hecks/behaviors.rb +4 -8
- data/lib/hecks/bluebook/aggregate.rb +9 -75
- data/lib/hecks/bluebook/assembly/aggregate_assembly.rb +9 -38
- data/lib/hecks/bluebook/assembly/build.rb +4 -15
- data/lib/hecks/bluebook/assembly/contract.rb +15 -136
- data/lib/hecks/bluebook/assembly/contracts.rb +54 -174
- data/lib/hecks/bluebook/assembly/marks.rb +31 -223
- data/lib/hecks/bluebook/assembly/specializer.rb +6 -52
- data/lib/hecks/bluebook/assembly.rb +6 -45
- data/lib/hecks/bluebook/attribute.rb +12 -61
- data/lib/hecks/bluebook/behaviour/aggregate.rb +10 -39
- data/lib/hecks/bluebook/behaviour/attribute.rb +3 -14
- data/lib/hecks/bluebook/behaviour/chapter.rb +14 -42
- data/lib/hecks/bluebook/behaviour/command.rb +14 -66
- data/lib/hecks/bluebook/behaviour/domain_port.rb +4 -20
- data/lib/hecks/bluebook/behaviour/entity.rb +7 -27
- data/lib/hecks/bluebook/behaviour/hexagon.rb +23 -41
- data/lib/hecks/bluebook/behaviour/lifecycle.rb +15 -40
- data/lib/hecks/bluebook/behaviour/policy.rb +23 -52
- data/lib/hecks/bluebook/behaviour/process_manager.rb +30 -57
- data/lib/hecks/bluebook/behaviour/read_model.rb +25 -31
- data/lib/hecks/bluebook/behaviour/traits.rb +27 -64
- data/lib/hecks/bluebook/behaviour/value_object.rb +5 -24
- data/lib/hecks/bluebook/capabilities.rb +17 -49
- data/lib/hecks/bluebook/chapter.rb +10 -48
- data/lib/hecks/bluebook/command.rb +23 -81
- data/lib/hecks/bluebook/domain_port.rb +14 -63
- data/lib/hecks/bluebook/dsl/aggregate_builder/sealing.rb +50 -229
- data/lib/hecks/bluebook/dsl/aggregate_builder.rb +50 -377
- data/lib/hecks/bluebook/dsl/attribute_collector.rb +33 -204
- data/lib/hecks/bluebook/dsl/binding_proxy.rb +16 -69
- data/lib/hecks/bluebook/dsl/bluebook_builder/validation.rb +86 -708
- data/lib/hecks/bluebook/dsl/bluebook_builder.rb +56 -170
- data/lib/hecks/bluebook/dsl/bootstrap_table.rb +1 -0
- data/lib/hecks/bluebook/dsl/command_builder.rb +74 -546
- data/lib/hecks/bluebook/dsl/const_shim.rb +8 -41
- data/lib/hecks/bluebook/dsl/domain_port_builder.rb +12 -87
- data/lib/hecks/bluebook/dsl/entity_builder.rb +44 -330
- data/lib/hecks/bluebook/dsl/generic_dispatch.rb +20 -269
- data/lib/hecks/bluebook/dsl/hecksagon_builder.rb +26 -194
- data/lib/hecks/bluebook/dsl/identity_declaration.rb +13 -88
- data/lib/hecks/bluebook/dsl/lifecycle_builder.rb +6 -20
- data/lib/hecks/bluebook/dsl/policy_builder.rb +16 -88
- data/lib/hecks/bluebook/dsl/port_builder.rb +2 -6
- data/lib/hecks/bluebook/dsl/port_operation_builder.rb +22 -96
- data/lib/hecks/bluebook/dsl/process_manager_builder.rb +31 -184
- data/lib/hecks/bluebook/dsl/query_builder.rb +11 -42
- data/lib/hecks/bluebook/dsl/read_model_builder.rb +75 -201
- data/lib/hecks/bluebook/dsl/rule_reference.rb +22 -163
- data/lib/hecks/bluebook/dsl/translation_builder.rb +28 -114
- data/lib/hecks/bluebook/dsl/value_object_builder.rb +10 -124
- data/lib/hecks/bluebook/dsl/word_gate.rb +16 -162
- data/lib/hecks/bluebook/dsl/world_builder.rb +19 -111
- data/lib/hecks/bluebook/entity.rb +13 -71
- data/lib/hecks/bluebook/expression/ast_json.rb +24 -190
- data/lib/hecks/bluebook/expression/ast_reader.rb +12 -54
- data/lib/hecks/bluebook/expression/canonical_form.rb +11 -88
- data/lib/hecks/bluebook/expression/evaluator.rb +47 -295
- data/lib/hecks/bluebook/expression/resolver/block_predicates.rb +30 -147
- data/lib/hecks/bluebook/expression/resolver.rb +37 -660
- data/lib/hecks/bluebook/hexagon.rb +5 -28
- data/lib/hecks/bluebook/lifecycle.rb +5 -16
- data/lib/hecks/bluebook/meta_validator/adapter_judge.rb +1 -7
- data/lib/hecks/bluebook/meta_validator/judge.rb +111 -361
- data/lib/hecks/bluebook/meta_validator/plan.rb +33 -162
- data/lib/hecks/bluebook/meta_validator/port_judge.rb +2 -7
- data/lib/hecks/bluebook/meta_validator/readings.rb +56 -342
- data/lib/hecks/bluebook/meta_validator/reconstruction.rb +24 -176
- data/lib/hecks/bluebook/meta_validator/shapes.rb +53 -267
- data/lib/hecks/bluebook/meta_validator/syntax_boot.rb +43 -305
- data/lib/hecks/bluebook/meta_validator/translation_judge.rb +7 -43
- data/lib/hecks/bluebook/meta_validator/world_judge.rb +6 -18
- data/lib/hecks/bluebook/meta_validator.rb +79 -349
- data/lib/hecks/bluebook/model_check/client_profile.rb +6 -21
- data/lib/hecks/bluebook/model_check.rb +100 -597
- data/lib/hecks/bluebook/pattern_subset.rb +11 -69
- data/lib/hecks/bluebook/process_manager.rb +13 -83
- data/lib/hecks/bluebook/project_loader.rb +3 -39
- data/lib/hecks/bluebook/project_register.rb +12 -60
- data/lib/hecks/bluebook/query.rb +9 -48
- data/lib/hecks/bluebook/read_model.rb +57 -81
- data/lib/hecks/bluebook/reference.rb +7 -41
- data/lib/hecks/bluebook/smoke_test.rb +8 -98
- data/lib/hecks/bluebook/synthesizer.rb +13 -62
- data/lib/hecks/bluebook/translation.rb +26 -62
- data/lib/hecks/bluebook/value_object.rb +11 -36
- data/lib/hecks/bluebook.rb +5 -22
- data/lib/hecks/cache_dir.rb +4 -23
- data/lib/hecks/cli/document.rb +3 -21
- data/lib/hecks/cli/ir.rb +3 -5
- data/lib/hecks/cli/mcp.rb +2 -3
- data/lib/hecks/cli/mcp_door.rb +19 -114
- data/lib/hecks/cli/model_check.rb +18 -85
- data/lib/hecks/cli/project_cli.rb +7 -40
- data/lib/hecks/cli/project_diagrams.rb +0 -7
- data/lib/hecks/cli/run.rb +12 -58
- data/lib/hecks/cli/smoke_test.rb +2 -16
- data/lib/hecks/cli/stores.rb +1 -2
- data/lib/hecks/cli.rb +18 -24
- data/lib/hecks/construct.rb +8 -34
- data/lib/hecks/deploy/bluebook/deploy.bluebook +33 -142
- data/lib/hecks/deploy/bluebook/deploy.hecksagon +2 -9
- data/lib/hecks/embryonaut_bluebook/lock.rb +3 -35
- data/lib/hecks/embryonaut_bluebook/shape.rb +1 -17
- data/lib/hecks/embryonaut_bluebook/vendor.rb +8 -53
- data/lib/hecks/embryonaut_bluebook/vendor_cli.rb +4 -19
- data/lib/hecks/embryonaut_bluebook.rb +4 -71
- data/lib/hecks/facade/cli_door.rb +24 -106
- data/lib/hecks/facade/cli_runner.rb +28 -172
- data/lib/hecks/facade/command_request.rb +13 -33
- data/lib/hecks/facade/handle.rb +34 -121
- data/lib/hecks/facade/json_door.rb +31 -146
- data/lib/hecks/facade/surface/aggregate_door.rb +39 -104
- data/lib/hecks/facade/surface/chapter.rb +10 -54
- data/lib/hecks/facade/surface.rb +8 -23
- data/lib/hecks/facade.rb +10 -25
- data/lib/hecks/forms/app.rb +15 -70
- data/lib/hecks/forms/command_form_renderer.rb +10 -29
- data/lib/hecks/forms/field_renderer.rb +17 -156
- data/lib/hecks/forms/field_shape.rb +30 -222
- data/lib/hecks/forms/html.rb +12 -47
- data/lib/hecks/forms/index_renderer.rb +1 -4
- data/lib/hecks/forms/page.rb +3 -9
- data/lib/hecks/forms/params.rb +14 -60
- data/lib/hecks/forms/port_argument.rb +2 -19
- data/lib/hecks/forms/query_form_renderer.rb +4 -79
- data/lib/hecks/forms/record_renderer.rb +8 -75
- data/lib/hecks/forms/record_table.rb +7 -50
- data/lib/hecks/forms/reference_options.rb +3 -30
- data/lib/hecks/forms/value_object_shape.rb +8 -35
- data/lib/hecks/forms.rb +5 -33
- data/lib/hecks/fqn.rb +5 -12
- data/lib/hecks/framework/bluebook/compliance.bluebook +16 -65
- data/lib/hecks/framework/bluebook/console_settings.bluebook +47 -134
- data/lib/hecks/framework/bluebook/framework.hecksagon +5 -14
- data/lib/hecks/framework/bluebook/governance.bluebook +13 -34
- data/lib/hecks/framework/bluebook/identity.bluebook +11 -26
- data/lib/hecks/framework/bluebook/privacy.bluebook +8 -33
- data/lib/hecks/framework.rb +11 -80
- data/lib/hecks/freezer.rb +5 -39
- data/lib/hecks/grammar/expression.bluebook +15 -40
- data/lib/hecks/grammar/translation.bluebook +3 -6
- data/lib/hecks/grammar.rb +16 -41
- data/lib/hecks/ir.rb +14 -83
- data/lib/hecks/language/adapter.bluebook +2 -7
- data/lib/hecks/language/bluebook/aggregate.bluebook +56 -221
- data/lib/hecks/language/bluebook/attaches/paging.bluebook +6 -15
- data/lib/hecks/language/bluebook/bluebook.bluebook +15 -83
- data/lib/hecks/language/bluebook/bluebook.hecksagon +3 -15
- data/lib/hecks/language/bluebook/command.bluebook +27 -144
- data/lib/hecks/language/bluebook/entity.bluebook +24 -97
- data/lib/hecks/language/bluebook/policy.bluebook +16 -67
- data/lib/hecks/language/bluebook/process_manager.bluebook +28 -151
- data/lib/hecks/language/bluebook/projection.bluebook +126 -60
- data/lib/hecks/language/bluebook/query.bluebook +12 -43
- data/lib/hecks/language/bluebook/shape.bluebook +23 -73
- data/lib/hecks/language/bluebook/syntax.bluebook +51 -262
- data/lib/hecks/language/bluebook/vocabulary.bluebook +82 -197
- data/lib/hecks/language/hecksagon/adapter_binding.bluebook +3 -10
- data/lib/hecks/language/hecksagon/domain_port.bluebook +4 -19
- data/lib/hecks/language/hecksagon/hecksagon.bluebook +6 -25
- data/lib/hecks/language/hecksagon/port_operation.bluebook +3 -14
- data/lib/hecks/language/oidc.json +35 -0
- data/lib/hecks/language/port.bluebook +4 -17
- data/lib/hecks/language/translation/translation.bluebook +3 -9
- data/lib/hecks/language/translation/translation_aggregate.bluebook +5 -24
- data/lib/hecks/language/world/wiring.bluebook +1 -3
- data/lib/hecks/language/world/world.bluebook +5 -7
- data/lib/hecks/literal.rb +8 -50
- data/lib/hecks/mcp_door_scope.rb +9 -90
- data/lib/hecks/mcp_stdio_guard.rb +4 -41
- data/lib/hecks/naming.rb +29 -137
- data/lib/hecks/ports/access_control.rb +7 -23
- data/lib/hecks/ports/agent/answers.rb +5 -23
- data/lib/hecks/ports/agent.rb +47 -172
- data/lib/hecks/ports/authentication.rb +12 -39
- data/lib/hecks/ports/authorization.rb +16 -43
- data/lib/hecks/ports/clock.rb +5 -45
- data/lib/hecks/ports/extraction.rb +7 -12
- data/lib/hecks/ports/identity_assignment.rb +8 -29
- data/lib/hecks/ports/identity_generation.rb +6 -29
- data/lib/hecks/ports/identity_resolution.rb +2 -10
- data/lib/hecks/ports/key_vault.rb +9 -45
- data/lib/hecks/ports/persistence/append_only.rb +61 -64
- data/lib/hecks/ports/persistence/binding_policy.rb +4 -14
- data/lib/hecks/ports/persistence/codec_boundary.rb +20 -80
- data/lib/hecks/ports/persistence/null_saga_store.rb +4 -20
- data/lib/hecks/ports/persistence/plugin.rb +13 -42
- data/lib/hecks/ports/persistence/plugins/era/era_check.rb +38 -141
- data/lib/hecks/ports/persistence/plugins/era/era_guard/shape_diff.rb +15 -115
- data/lib/hecks/ports/persistence/plugins/era/era_guard.rb +16 -84
- data/lib/hecks/ports/persistence/plugins/era/era_tamper.rb +6 -25
- data/lib/hecks/ports/persistence/plugins/era/expected_era.rb +3 -22
- data/lib/hecks/ports/persistence/plugins/era/lineage.rb +55 -181
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/events.rb +77 -0
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/era_store.rb +12 -122
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/field_cache.rb +28 -128
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/head_compiler.rb +73 -474
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/mint_transaction.rb +31 -124
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/provisioning.rb +45 -219
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/resumable_backfill.rb +13 -108
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/tail_merge.rb +18 -75
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage/transform_installer.rb +9 -49
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage.rb +6 -123
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/coverage_check.rb +23 -55
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/era_resolver.rb +14 -72
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/merge_coordinator.rb +7 -16
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager/minter.rb +14 -115
- data/lib/hecks/ports/persistence/plugins/era/postgres_era/lineage_manager.rb +13 -45
- data/lib/hecks/ports/persistence/plugins/era/postgres_era.rb +127 -554
- data/lib/hecks/ports/persistence/plugins/era/storage_shape.rb +13 -63
- data/lib/hecks/ports/persistence/plugins/era/translation/audit/approval_digest.rb +2 -17
- data/lib/hecks/ports/persistence/plugins/era/translation/audit/layer_one.rb +3 -14
- data/lib/hecks/ports/persistence/plugins/era/translation/audit/layer_two.rb +13 -58
- data/lib/hecks/ports/persistence/plugins/era/translation/audit/unfed_report.rb +3 -17
- data/lib/hecks/ports/persistence/plugins/era/translation/audit.rb +9 -26
- data/lib/hecks/ports/persistence/plugins/era/translation/reattest.rb +9 -25
- data/lib/hecks/ports/persistence/plugins/era/translation/rule_compiler.rb +18 -124
- data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/differ.rb +34 -123
- data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/renderer.rb +5 -12
- data/lib/hecks/ports/persistence/plugins/era/translation/scaffold/writer.rb +3 -9
- data/lib/hecks/ports/persistence/plugins/era/translation/scaffold.rb +2 -14
- data/lib/hecks/ports/persistence/plugins/era.rb +4 -23
- data/lib/hecks/ports/persistence/postgres_dump/connection.rb +7 -23
- data/lib/hecks/ports/persistence/postgres_dump.rb +4 -35
- data/lib/hecks/ports/persistence/remote_runtime.rb +2 -24
- data/lib/hecks/ports/persistence/repository_factory.rb +8 -27
- data/lib/hecks/ports/persistence/state_codec.rb +23 -103
- data/lib/hecks/ports/persistence.rb +7 -14
- data/lib/hecks/ports/projection.rb +42 -84
- data/lib/hecks/ports/query/in_memory.rb +10 -58
- data/lib/hecks/ports/query/ordering.rb +11 -32
- data/lib/hecks/ports/query.rb +14 -37
- data/lib/hecks/ports.rb +2 -8
- data/lib/hecks/projections/bootstrap_table.rb +11 -43
- data/lib/hecks/projections/deploy/fargate/assembly.rb +2 -15
- data/lib/hecks/projections/deploy/fargate/cdn.rb +1 -48
- data/lib/hecks/projections/deploy/fargate/cdn_default.rb +2 -11
- data/lib/hecks/projections/deploy/fargate/check.rb +5 -14
- data/lib/hecks/projections/deploy/fargate/containers.rb +3 -78
- data/lib/hecks/projections/deploy/fargate/extras.rb +3 -44
- data/lib/hecks/projections/deploy/fargate/monitoring.rb +0 -44
- data/lib/hecks/projections/deploy/fargate/settings.rb +2 -54
- data/lib/hecks/projections/deploy/fargate/yaml.rb +13 -58
- data/lib/hecks/projections/deploy/fargate.rb +35 -202
- data/lib/hecks/projections/deploy/lambda.rb +150 -678
- data/lib/hecks/projections/deploy/preview/access_yaml.rb +1 -33
- data/lib/hecks/projections/deploy/preview/containers.rb +6 -111
- data/lib/hecks/projections/deploy/preview/routing_yaml.rb +4 -56
- data/lib/hecks/projections/deploy/preview/script.rb +2 -14
- data/lib/hecks/projections/deploy/preview/settings.rb +3 -33
- data/lib/hecks/projections/deploy/preview/task_yaml.rb +2 -38
- data/lib/hecks/projections/deploy/preview/template.rb +2 -58
- data/lib/hecks/projections/deploy/preview.rb +2 -67
- data/lib/hecks/projections/deploy/scripts/settings.rb +3 -25
- data/lib/hecks/projections/deploy/scripts.rb +4 -57
- data/lib/hecks/projections/deploy/shared.rb +47 -146
- data/lib/hecks/projections/deploy/smoke.rb +4 -61
- data/lib/hecks/projections/deploy/template_diff/comparer.rb +3 -25
- data/lib/hecks/projections/deploy/template_diff/loader.rb +2 -11
- data/lib/hecks/projections/deploy/template_diff.rb +5 -57
- data/lib/hecks/projections/diagrams.rb +20 -582
- data/lib/hecks/projections/glossary/html.rb +14 -130
- data/lib/hecks/projections/glossary/markdown.rb +8 -69
- data/lib/hecks/projections/glossary/mermaid.rb +9 -66
- data/lib/hecks/projections/glossary/sensitivity.rb +5 -34
- data/lib/hecks/projections/glossary/sentences.rb +14 -159
- data/lib/hecks/projections/glossary.rb +30 -222
- data/lib/hecks/projections/ir.rb +3 -10
- data/lib/hecks/projections/model/deviations.rb +15 -42
- data/lib/hecks/projections/model.rb +12 -51
- data/lib/hecks/projections/oidc.rb +12 -56
- data/lib/hecks/projections/parser_table.rb +9 -28
- data/lib/hecks/projections/reference.rb +2 -15
- data/lib/hecks/projections/rust_vocabulary.rb +12 -250
- data/lib/hecks/projections/shape.rb +3 -29
- data/lib/hecks/projections/statements.rb +7 -86
- data/lib/hecks/projections/vocabulary.rb +6 -22
- data/lib/hecks/projections.rb +2 -16
- data/lib/hecks/projector/cli_projector.rb +60 -375
- data/lib/hecks/projector/docs_projector.rb +10 -201
- data/lib/hecks/projector/exporter.rb +42 -134
- data/lib/hecks/projector/ir_projector.rb +2 -9
- data/lib/hecks/projector/narrate_projector.rb +15 -189
- data/lib/hecks/projector/target.rb +13 -76
- data/lib/hecks/projector.rb +30 -121
- data/lib/hecks/query_specification/common/comparators.rb +5 -26
- data/lib/hecks/query_specification/common/comparison.rb +35 -143
- data/lib/hecks/query_specification/common/dsl.rb +8 -24
- data/lib/hecks/query_specification/common/null_policy.rb +20 -70
- data/lib/hecks/query_specification/common/options.rb +2 -6
- data/lib/hecks/query_specification/common/where_clause.rb +2 -10
- data/lib/hecks/query_specification/field_path.rb +37 -77
- data/lib/hecks/query_specification/hop_path.rb +12 -76
- data/lib/hecks/release/gem_pin.rb +2 -26
- data/lib/hecks/release/runner/ci_publisher.rb +3 -6
- data/lib/hecks/release/runner/commands.rb +2 -4
- data/lib/hecks/release/runner/gem_publisher.rb +2 -3
- data/lib/hecks/release/runner/npm_publisher.rb +6 -20
- data/lib/hecks/release/runner/preflight.rb +4 -19
- data/lib/hecks/release/runner/tagger.rb +2 -9
- data/lib/hecks/release/runner.rb +3 -32
- data/lib/hecks/rendering.rb +4 -26
- data/lib/hecks/router/namespace_installer.rb +12 -36
- data/lib/hecks/router.rb +4 -8
- data/lib/hecks/runtime/aggregate_lock.rb +8 -33
- data/lib/hecks/runtime/boot_gates.rb +3 -18
- data/lib/hecks/runtime/caller.rb +19 -59
- data/lib/hecks/runtime/capability_graph.rb +5 -21
- data/lib/hecks/runtime/command_interpreter/argument_gate.rb +16 -78
- data/lib/hecks/runtime/command_interpreter/mutation_applier.rb +23 -160
- data/lib/hecks/runtime/command_interpreter.rb +124 -306
- data/lib/hecks/runtime/command_rules/admissibility.rb +95 -366
- data/lib/hecks/runtime/command_rules/arithmetic.rb +66 -196
- data/lib/hecks/runtime/command_rules/authorization.rb +13 -45
- data/lib/hecks/runtime/command_rules/emission.rb +8 -21
- data/lib/hecks/runtime/command_rules/references.rb +23 -202
- data/lib/hecks/runtime/dependency_planning.rb +30 -102
- data/lib/hecks/runtime/dispatcher.rb +82 -241
- data/lib/hecks/runtime/entity_element.rb +40 -462
- data/lib/hecks/runtime/entity_interpreter.rb +64 -219
- data/lib/hecks/runtime/errors.rb +32 -115
- data/lib/hecks/runtime/event.rb +3 -25
- data/lib/hecks/runtime/identity.rb +18 -154
- data/lib/hecks/runtime/instance.rb +18 -150
- data/lib/hecks/runtime/interpreting.rb +11 -70
- data/lib/hecks/runtime/invocation.rb +28 -164
- data/lib/hecks/runtime/loader.rb +48 -186
- data/lib/hecks/runtime/outbox.rb +38 -261
- data/lib/hecks/runtime/policy_interpreter.rb +38 -200
- data/lib/hecks/runtime/port_operation_interpreter.rb +26 -87
- data/lib/hecks/runtime/query_interpreter.rb +45 -187
- data/lib/hecks/runtime/reaction_invocation.rb +36 -138
- data/lib/hecks/runtime/read_model_interpreter.rb +117 -208
- data/lib/hecks/runtime/rebuild_sweep.rb +8 -54
- data/lib/hecks/runtime/reference_hop.rb +8 -81
- data/lib/hecks/runtime/refusal_wording.rb +8 -89
- data/lib/hecks/runtime/registry/saga_persistence.rb +10 -102
- data/lib/hecks/runtime/registry/verification.rb +52 -225
- data/lib/hecks/runtime/registry/world_defaults.rb +4 -53
- data/lib/hecks/runtime/registry.rb +99 -244
- data/lib/hecks/runtime/remote_dispatcher.rb +37 -152
- data/lib/hecks/runtime/routing.rb +4 -15
- data/lib/hecks/runtime/saga_interpreter/correlation.rb +14 -61
- data/lib/hecks/runtime/saga_interpreter.rb +79 -263
- data/lib/hecks/runtime/saga_pending_dispatch.rb +2 -43
- data/lib/hecks/runtime/tenant_check.rb +6 -68
- data/lib/hecks/runtime/tenant_scope.rb +3 -28
- data/lib/hecks/runtime/value/admission.rb +16 -67
- data/lib/hecks/runtime/value/coercion.rb +155 -641
- data/lib/hecks/runtime/value/entity_list_coercion.rb +26 -219
- data/lib/hecks/runtime/value.rb +12 -84
- data/lib/hecks/runtime.rb +17 -65
- data/lib/hecks/storehouse.rb +141 -568
- data/lib/hecks/tenancy/bluebook/tenancy.bluebook +8 -32
- data/lib/hecks/tenancy/bluebook/tenancy.hecksagon +6 -23
- data/lib/hecks/vendoring/git_environment.rb +2 -8
- data/lib/hecks/vendoring/git_source.rb +4 -10
- data/lib/hecks/vendoring.rb +7 -46
- data/lib/hecks/version.rb +3 -14
- data/lib/hecks.rb +26 -81
- data/lib/rubocop/cop/hecks/fallback_hash_lookup.rb +8 -46
- data/lib/rubocop/cop/hecks/sequential_hash_rename_in_loop.rb +11 -80
- data/lib/rubocop/cop/hecks/thread_shared_ivar_mutation.rb +10 -99
- metadata +3 -2
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
module Hecks
|
|
2
2
|
module QuerySpecification
|
|
3
3
|
module Common
|
|
4
|
-
# Null
|
|
5
|
-
#
|
|
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
|
|
17
|
-
#
|
|
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`
|
|
26
|
-
#
|
|
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
|
|
32
|
-
#
|
|
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
|
-
#
|
|
54
|
-
#
|
|
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
|
|
67
|
-
#
|
|
68
|
-
# @param
|
|
69
|
-
#
|
|
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
|
-
#
|
|
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
|
|
92
|
-
# is
|
|
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
|
|
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
|
|
123
|
-
#
|
|
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
|
|
7
|
-
#
|
|
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`
|
|
5
|
-
#
|
|
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
|
|
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
|
-
#
|
|
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
|
-
#
|
|
33
|
-
#
|
|
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
|
|
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
|
-
#
|
|
72
|
-
#
|
|
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
|
-
#
|
|
87
|
-
#
|
|
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
|
|
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
|
|
97
|
-
# @yieldreturn [Class<Bluebook::ValueObject>, nil] the declared shape, or `nil`
|
|
98
|
-
#
|
|
99
|
-
#
|
|
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
|
-
#
|
|
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
|
-
#
|
|
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
|
-
# @
|
|
126
|
-
|
|
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
|
|
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|
|
|
91
|
+
!shape.nil? && shape.attributes.any? { |member| primitives.include?(member.type.to_s) }
|
|
138
92
|
end
|
|
139
93
|
|
|
140
|
-
#
|
|
141
|
-
|
|
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
|
|
144
|
-
#
|
|
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
|
|
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
|
-
#
|
|
19
|
-
#
|
|
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
|
|
35
|
-
#
|
|
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
|
-
#
|
|
40
|
-
#
|
|
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
|
|
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
|
-
#
|
|
69
|
-
#
|
|
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
|
|
153
|
-
#
|
|
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
|
-
#
|
|
6
|
-
#
|
|
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
|
-
#
|
|
7
|
-
# `.github/workflows/publish-client.yml
|
|
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
|
-
#
|
|
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
|
|
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
|
|
8
|
-
#
|
|
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!(
|