hecks 3.0.4 → 3.1.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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/exe/hecks +25 -7
  3. data/lib/hecks/adapters/driven/lambda/client.rb +1 -1
  4. data/lib/hecks/adapters/driven/lambda.rb +1 -1
  5. data/lib/hecks/adapters/driven/tenant_provisioner.rb +2 -2
  6. data/lib/hecks/bluebook/dsl/hecksagon_builder.rb +59 -32
  7. data/lib/hecks/bluebook/hexagon.rb +45 -25
  8. data/lib/hecks/bluebook/model_check.rb +7 -7
  9. data/lib/hecks/chapters.rb +31 -3
  10. data/lib/hecks/cli/check_era.rb +1 -1
  11. data/lib/hecks/cli/console.rb +24 -8
  12. data/lib/hecks/cli/deploy_template_diff.rb +1 -1
  13. data/lib/hecks/cli/doc_coverage.rb +1 -1
  14. data/lib/hecks/cli/domain_stub.rb +128 -0
  15. data/lib/hecks/cli/interview_draft.rb +246 -0
  16. data/lib/hecks/cli/model_check.rb +1 -1
  17. data/lib/hecks/cli/project_cli.rb +69 -18
  18. data/lib/hecks/cli/reference.rb +2 -1
  19. data/lib/hecks/cli/refresh_rspec_runtime_baseline.rb +1 -1
  20. data/lib/hecks/cli/seed_semantics_corpus.rb +38 -9
  21. data/lib/hecks/cli/spec_example.rb +1 -1
  22. data/lib/hecks/cli/stress_concurrency_specs.rb +14 -5
  23. data/lib/hecks/corpus.rb +11 -8
  24. data/lib/hecks/deploy/bluebook/deploy.bluebook +85 -12
  25. data/lib/hecks/deploy/oidc.json +5 -0
  26. data/lib/hecks/doc/reference.rb +4 -3
  27. data/lib/hecks/doors/cli_door.rb +13 -13
  28. data/lib/hecks/doors/cli_runner.rb +52 -32
  29. data/lib/hecks/doors/launcher_options.rb +23 -5
  30. data/lib/hecks/doors/mcp_door.rb +40 -18
  31. data/lib/hecks/doors/mcp_door_scope.rb +244 -24
  32. data/lib/hecks/doors.rb +1 -1
  33. data/lib/hecks/embryonaut_bluebook.rb +2 -2
  34. data/lib/hecks/forms/banking_presentation.rb +1 -1
  35. data/lib/hecks/framework/bluebook/compliance.bluebook +1 -1
  36. data/lib/hecks/framework/bluebook/console_settings.bluebook +1 -1
  37. data/lib/hecks/framework/bluebook/framework.hecksagon +4 -4
  38. data/lib/hecks/framework.rb +1 -1
  39. data/lib/hecks/fuzzing/combination_miner.rb +1 -1
  40. data/lib/hecks/fuzzing/concurrent_dispatch.rb +1 -1
  41. data/lib/hecks/fuzzing/differential.rb +4 -2
  42. data/lib/hecks/fuzzing/era_boundary.rb +1 -1
  43. data/lib/hecks/fuzzing/form_census.rb +2 -2
  44. data/lib/hecks/fuzzing/generated_domain_check.rb +1 -1
  45. data/lib/hecks/fuzzing/isolated_boot.rb +10 -3
  46. data/lib/hecks/fuzzing/persistence_parity.rb +2 -2
  47. data/lib/hecks/fuzzing/target_capabilities.rb +3 -3
  48. data/lib/hecks/gate/stages.yml +8 -4
  49. data/lib/hecks/grammar/grammar.hecksagon +2 -2
  50. data/lib/hecks/hecks/adapters/deploy_toolchain.rb +4 -4
  51. data/lib/hecks/hecks/adapters/host_http.rb +4 -3
  52. data/lib/hecks/hecks/adapters/local_files.rb +59 -0
  53. data/lib/hecks/hecks/adapters/site_toolchain.adapter +7 -0
  54. data/lib/hecks/hecks/adapters/site_toolchain.rb +54 -0
  55. data/lib/hecks/hecks/codebase.bluebook +4 -3
  56. data/lib/hecks/hecks/context_map.hecksagon +2 -2
  57. data/lib/hecks/hecks/custodian.bluebook +45 -3
  58. data/lib/hecks/hecks/hecks.hecksagon +10 -4
  59. data/lib/hecks/hecks/hecks.world +7 -4
  60. data/lib/hecks/hecks/site.behaviors +17 -0
  61. data/lib/hecks/hecks/site.world +10 -0
  62. data/lib/hecks/language/bluebook/bluebook.hecksagon +1 -1
  63. data/lib/hecks/language/hecksagon/hecksagon.bluebook +24 -47
  64. data/lib/hecks/ports/persistence/plugins/era/era_check.rb +4 -4
  65. data/lib/hecks/ports/persistence/plugins/era/postgres_era.rb +2 -1
  66. data/lib/hecks/projections/deploy/box/settings.rb +248 -0
  67. data/lib/hecks/projections/deploy/box/templates/box.yaml.tmpl +267 -0
  68. data/lib/hecks/projections/deploy/box/templates/deploy-box.sh.tmpl +70 -0
  69. data/lib/hecks/projections/deploy/box/templates/fetch-secrets.sh +21 -0
  70. data/lib/hecks/projections/deploy/box/templates/rds.yaml.tmpl +165 -0
  71. data/lib/hecks/projections/deploy/box/templates/render-compose.sh.tmpl +43 -0
  72. data/lib/hecks/projections/deploy/box.rb +387 -0
  73. data/lib/hecks/projections/deploy/fargate/cdn.rb +13 -1
  74. data/lib/hecks/projections/deploy/fargate.rb +1 -1
  75. data/lib/hecks/projections/deploy/lambda.rb +11 -10
  76. data/lib/hecks/projections/deploy/scripts/hosting.mk.tmpl +1 -1
  77. data/lib/hecks/projections/diagrams.rb +2 -2
  78. data/lib/hecks/projections/site/edge/behaviours.rb +107 -0
  79. data/lib/hecks/projections/site/edge/checks.rb +137 -0
  80. data/lib/hecks/projections/site/edge/pattern.rb +50 -0
  81. data/lib/hecks/projections/site/edge/rules.rb +128 -0
  82. data/lib/hecks/projections/site/edge.rb +136 -0
  83. data/lib/hecks/projections/site/regions.rb +44 -0
  84. data/lib/hecks/projections/site/routes_ts.rb +284 -0
  85. data/lib/hecks/projections/site/site_cdn.rb +78 -0
  86. data/lib/hecks/projections/site/table/checks.rb +124 -0
  87. data/lib/hecks/projections/site/table/row_builder.rb +155 -0
  88. data/lib/hecks/projections/site/table.rb +98 -0
  89. data/lib/hecks/projections.rb +2 -0
  90. data/lib/hecks/projector/cli_projector.rb +172 -95
  91. data/lib/hecks/quality_control/adapters/agent.adapter +1 -1
  92. data/lib/hecks/quality_control/adapters/agent.rb +2 -2
  93. data/lib/hecks/quality_control/cli/qa_concurrency_racer.rb +3 -3
  94. data/lib/hecks/quality_control/cli/qa_discover_external_domains.rb +8 -8
  95. data/lib/hecks/quality_control/cli/qa_domain_novelty.rb +3 -3
  96. data/lib/hecks/quality_control/cli/qa_generated_domains.rb +4 -4
  97. data/lib/hecks/quality_control/cli/qa_log_bug.rb +2 -2
  98. data/lib/hecks/quality_control/cli/qa_mine_combinations.rb +6 -5
  99. data/lib/hecks/quality_control/cli/qa_postgres_migrate.rb +2 -2
  100. data/lib/hecks/quality_control/cli/qa_postgres_role.rb +5 -5
  101. data/lib/hecks/quality_control/cli/qa_pr_check.rb +3 -3
  102. data/lib/hecks/quality_control/cli/qa_sweep/all_mode.rb +3 -3
  103. data/lib/hecks/quality_control/cli/qa_sweep/checks.rb +2 -2
  104. data/lib/hecks/quality_control/cli/qa_sweep.rb +10 -9
  105. data/lib/hecks/quality_control/cli/qa_tick.rb +3 -3
  106. data/lib/hecks/quality_control/quality_control.bluebook +18 -18
  107. data/lib/hecks/quality_control/quality_control.hecksagon +1 -1
  108. data/lib/hecks/runtime/command_interpreter.rb +2 -0
  109. data/lib/hecks/runtime/interpreting.rb +21 -0
  110. data/lib/hecks/runtime/invocation.rb +5 -3
  111. data/lib/hecks/runtime/registry/verification.rb +15 -29
  112. data/lib/hecks/runtime/registry.rb +14 -20
  113. data/lib/hecks/rust_build/append_optionals.rb +79 -0
  114. data/lib/hecks/rust_build/conformance_fuzz.rb +2 -1
  115. data/lib/hecks/rust_build/domain_name.rb +26 -0
  116. data/lib/hecks/rust_build/kernel_input.rb +58 -0
  117. data/lib/hecks/rust_build/project_rust/codegen_run.rb +143 -0
  118. data/lib/hecks/rust_build/project_rust/root_mod.rb +1 -1
  119. data/lib/hecks/rust_build/project_rust.rb +57 -24
  120. data/lib/hecks/rust_build/rust_literal.rb +33 -0
  121. data/lib/hecks/rust_build/write_if_changed.rb +86 -0
  122. data/lib/hecks/site/bluebook/site.bluebook +205 -0
  123. data/lib/hecks/site/bluebook/site.hecksagon +5 -0
  124. data/lib/hecks/site/bluebook/site.ports.hecksagon +15 -0
  125. data/lib/hecks/sme/bluebook/sme.bluebook +336 -0
  126. data/lib/hecks/sme/bluebook/sme.hecksagon +5 -0
  127. data/lib/hecks/storehouse.rb +37 -7
  128. data/lib/hecks/tenancy/bluebook/tenancy.bluebook +1 -1
  129. data/lib/hecks/three_zero/forms.yml +88 -88
  130. data/lib/hecks/tools/ci_gates.rb +1 -1
  131. data/lib/hecks/tools/deploy_recipe.rb +14 -6
  132. data/lib/hecks/tools/oidc_manifests.rb +2 -1
  133. data/lib/hecks/tools/sequence_script.rb +2 -2
  134. data/lib/hecks/tools/site_routes.rb +152 -0
  135. data/lib/hecks/tools/tenant_provisioning.rb +1 -1
  136. data/lib/hecks/tools.rb +1 -0
  137. data/lib/hecks/version.rb +1 -1
  138. data/rust/build/src/cargo_sync.rs +1 -1
  139. data/rust/build/src/pipeline.rs +23 -16
  140. data/rust/build/src/resolve.rs +39 -6
  141. data/rust/host/HECKS_RELEASE +1 -1
  142. data/rust/host/src/api.rs +1 -1
  143. data/rust/host/src/dispatch.rs +87 -7
  144. data/rust/host/src/needs.rs +111 -0
  145. data/rust/host/src/web/newsletter/template.rs +69 -0
  146. data/rust/host/src/web/newsletter/tests.rs +43 -0
  147. data/rust/host/src/web/newsletter.rs +6 -1
  148. data/rust/host/src/web/newsletter_send.rs +1 -1
  149. data/rust/parser/src/keywords.rs +7 -6
  150. data/rust/parser/src/main.rs +4 -3
  151. data/rust/parser/src/parse/chapter.rs +1 -1
  152. data/rust/parser/src/parse/hecksagon.rs +25 -10
  153. data/rust/project/mutations.rb +4 -30
  154. data/rust/project/naming.rb +8 -28
  155. data/rust/project/write_if_changed.rb +4 -80
  156. data/rust/project_rust_pipeline.rb +16 -12
  157. data/rust/src/kernel/cli.rs +2 -0
  158. data/rust/src/kernel/needs.rs +74 -1
  159. metadata +39 -2
@@ -2,7 +2,7 @@ require_relative "../naming"
2
2
 
3
3
  module Hecks
4
4
  module Projector
5
- # Projects a bluebook as its own command-line surface: the verb tree, argument spec
5
+ # Projects a bluebook as its own command-line surface: the command tree, argument spec
6
6
  # and usage text. Nothing executes here; the generic runner (`hecks run`) parses against it.
7
7
  #
8
8
  # Argument types come from the declared field types, never from guessing at the
@@ -10,22 +10,22 @@ module Hecks
10
10
  module CliProjector
11
11
  module_function
12
12
 
13
- # Projects the verb and question tables and the usage text. Commands and queries are
13
+ # Projects the command and question tables and the usage text. Commands and queries are
14
14
  # separate namespaces (a chapter may declare both under one name); ask a query with `ask`.
15
15
  #
16
16
  # @param bluebook [Bluebook::Chapter] the booted domain to project
17
17
  # @param options [Hash{Symbol => Object}] `:program` (default `"hecks run"`) for the usage
18
- # text; `:verb` and `:ask` select one verb's `--help` text; `:names` maps a launcher
18
+ # text; `:command` and `:ask` select one command's `--help` text; `:names` maps a launcher
19
19
  # name to the command it stands for (`{ "mcp" => "serve_mcp" }`); `:mint_run_keys` makes a
20
- # creating verb's `run` key optional, since the launcher mints it
21
- # @return [Hash{Symbol => Object}] `:verbs`, `:questions`, `:names` (alias tables) and
20
+ # creating command's `run` key optional, since the launcher mints it
21
+ # @return [Hash{Symbol => Object}] `:commands`, `:questions`, `:names` (alias tables) and
22
22
  # `:usage` (pre-rendered help text)
23
- # @raise [Bluebook::DSL::Malformed] if two verbs project to the same command-line name
23
+ # @raise [Bluebook::DSL::Malformed] if two commands project to the same command-line name
24
24
  def call(bluebook:, options: {})
25
- verbs = {}
25
+ commands = {}
26
26
  questions = {}
27
27
 
28
- bluebook.aggregates.each { |aggregate| claim_aggregate(verbs, questions, bluebook, aggregate) }
28
+ bluebook.aggregates.each { |aggregate| claim_aggregate(commands, questions, bluebook, aggregate) }
29
29
 
30
30
  # A report belongs to the chapter, not an aggregate, so it is addressed
31
31
  # `Chapter.Report` (one dot) where a query is `Chapter::Aggregate.Query`.
@@ -33,59 +33,55 @@ module Hecks
33
33
  claim(questions, Naming.snake(model.hecks_name), report_spec(bluebook, model))
34
34
  end
35
35
 
36
- mint_run_keys(verbs) if options[:mint_run_keys]
36
+ mint_run_keys(commands) if options[:mint_run_keys]
37
37
 
38
38
  # The display name is the shortest unambiguous one; both spellings are accepted.
39
- display_names([verbs, questions], options[:names])
39
+ display_names([commands, questions], options[:names])
40
40
 
41
- { verbs: verbs, questions: questions,
42
- names: { command: aliases(verbs), question: aliases(questions) },
43
- usage: usage(bluebook, verbs, questions, options) }
41
+ { commands: commands, questions: questions,
42
+ names: { command: aliases(commands), question: aliases(questions) },
43
+ usage: usage(bluebook, commands, questions, options) }
44
44
  end
45
45
 
46
- # Claims the verbs and questions of one aggregate and its entities and ports.
46
+ # Claims the commands and questions of one aggregate and its entities and ports.
47
47
  #
48
- # @param verbs [Hash{String => Hash}] the verb map, mutated in place
48
+ # @param commands [Hash{String => Hash}] the command map, mutated in place
49
49
  # @param questions [Hash{String => Hash}] the question map, mutated in place
50
50
  # @param bluebook [Bluebook::Chapter] the booted domain
51
51
  # @param aggregate [Bluebook::Aggregate] the aggregate to claim
52
52
  # @return [void]
53
- def claim_aggregate(verbs, questions, bluebook, aggregate)
54
- aggregate.commands.each { |c| claim(verbs, name_for(aggregate, c), command_spec(bluebook, aggregate, nil, c)) }
53
+ def claim_aggregate(commands, questions, bluebook, aggregate)
54
+ aggregate.commands.each { |c| claim(commands, name_for(aggregate, c), command_spec(bluebook, aggregate, nil, c)) }
55
55
  aggregate.queries.each { |q| claim(questions, name_for(aggregate, q), query_spec(bluebook, aggregate, nil, q)) }
56
56
 
57
57
  aggregate.entities.each do |entity|
58
58
  entity.commands.each do |c|
59
- claim(verbs, name_for(aggregate, c, entity), command_spec(bluebook, aggregate, entity, c))
59
+ claim(commands, name_for(aggregate, c, entity), command_spec(bluebook, aggregate, entity, c))
60
60
  end
61
61
  entity.queries.each do |q|
62
62
  claim(questions, name_for(aggregate, q, entity), query_spec(bluebook, aggregate, entity, q))
63
63
  end
64
64
  end
65
65
 
66
- # Port operations dispatch by the same name as a command, so they are verbs too.
66
+ # Port operations dispatch by the same name as a command, so they are commands too.
67
67
  aggregate.ports.each do |port|
68
- port.operations.each { |o| claim(verbs, name_for(aggregate, o), port_spec(bluebook, aggregate, port, o)) }
68
+ port.operations.each { |o| claim(commands, name_for(aggregate, o), port_spec(bluebook, aggregate, port, o)) }
69
69
  end
70
70
  end
71
71
 
72
- # Sets `:short` on each spec: the last segment when exactly one verb ends in it,
73
- # else the full name (two aggregates both declaring `Close` keep both spellings).
72
+ # Sets `:short` on each spec to its full `aggregate.command` name: a command is always
73
+ # called with its aggregate, so adding a command elsewhere never changes what a call means.
74
74
  #
75
- # @param specs [Hash{String => Hash}] the verb or question map, mutated in place
75
+ # @param specs [Hash{String => Hash}] the command or query map, mutated in place
76
76
  # @return [void]
77
- def shorten(specs)
78
- tails = specs.keys.group_by { |name| name.split(".").last }
79
- specs.each do |name, spec|
80
- tail = name.split(".").last
81
- spec[:short] = tails[tail].length == 1 ? tail : name
82
- end
77
+ def qualify(specs)
78
+ specs.each { |name, spec| spec[:short] = name }
83
79
  end
84
80
 
85
- # Marks the `run` key of each creating verb `minted`: optional, and never filled by a bare
81
+ # Marks the `run` key of each creating command `minted`: optional, and never filled by a bare
86
82
  # word, since the launcher makes one when it is left out.
87
- def mint_run_keys(verbs)
88
- verbs.each_value do |spec|
83
+ def mint_run_keys(commands)
84
+ commands.each_value do |spec|
89
85
  next unless spec[:creates]
90
86
 
91
87
  spec[:arguments] = spec[:arguments].map do |argument|
@@ -96,14 +92,14 @@ module Hecks
96
92
  end
97
93
  end
98
94
 
99
- # Sets the display name of every spec in each map: shortened, then renamed by `names`.
95
+ # Sets the display name of every spec in each map: its full name, then renamed by `names`.
100
96
  #
101
- # @param maps [Array<Hash{String => Hash}>] the verb and question maps, mutated in place
97
+ # @param maps [Array<Hash{String => Hash}>] the command and question maps, mutated in place
102
98
  # @param names [Hash, nil] the chapter's launcher names
103
99
  # @return [void]
104
100
  def display_names(maps, names)
105
101
  maps.each do |specs|
106
- shorten(specs)
102
+ qualify(specs)
107
103
  rename(specs, names)
108
104
  end
109
105
  end
@@ -114,7 +110,7 @@ module Hecks
114
110
  # replaced keeps working (`:short_was`, read by `aliases`). A table entry naming no
115
111
  # command in `specs` belongs to the other namespace and is skipped.
116
112
  #
117
- # @param specs [Hash{String => Hash}] the verb or question map, mutated in place
113
+ # @param specs [Hash{String => Hash}] the command or question map, mutated in place
118
114
  # @param names [Hash{String, Symbol => String, Symbol}, nil] launcher name to command name
119
115
  # @return [void]
120
116
  # @raise [Bluebook::DSL::Malformed] if a launcher name is already another command's name
@@ -131,8 +127,8 @@ module Hecks
131
127
  end
132
128
  end
133
129
 
134
- # Maps every accepted spelling (full name, `:short` and a renamed command's old short
135
- # name) to the full name.
130
+ # Maps every accepted spelling (full name, `:short` and a renamed command's old name)
131
+ # to the full name.
136
132
  def aliases(specs)
137
133
  specs.each_with_object({}) do |(name, spec), map|
138
134
  map[name] = name
@@ -142,34 +138,34 @@ module Hecks
142
138
  end
143
139
 
144
140
  # Stores `spec` under `name`, refusing a second claim rather than silently
145
- # keeping whichever verb was walked first.
141
+ # keeping whichever command was walked first.
146
142
  #
147
- # @raise [Bluebook::DSL::Malformed] if `name` is already claimed by another verb
148
- def claim(verbs, name, spec)
149
- if verbs.key?(name)
143
+ # @raise [Bluebook::DSL::Malformed] if `name` is already claimed by another command
144
+ def claim(commands, name, spec)
145
+ if commands.key?(name)
150
146
  raise Bluebook::DSL::Malformed,
151
- "two verbs project to the command-line name #{name.inspect}: " \
152
- "#{verbs[name][:verb]} and #{spec[:verb]} — rename one"
147
+ "two commands project to the command-line name #{name.inspect}: " \
148
+ "#{commands[name][:command]} and #{spec[:command]} — rename one"
153
149
  end
154
150
 
155
- verbs[name] = spec
151
+ commands[name] = spec
156
152
  end
157
153
 
158
- # The dotted command-line name, `aggregate[.entity].verb`, snake-cased.
159
- def name_for(aggregate, verb, entity = nil)
154
+ # The dotted command-line name, `aggregate[.entity].command`, snake-cased.
155
+ def name_for(aggregate, command, entity = nil)
160
156
  parts = [Naming.snake(aggregate.hecks_name)]
161
157
  parts << Naming.snake(entity.hecks_name) if entity
162
- parts << Naming.snake(verb.hecks_name)
158
+ parts << Naming.snake(command.hecks_name)
163
159
  parts.join(".")
164
160
  end
165
161
 
166
- # The verb's language name, `Chapter::Aggregate[.Entity].Verb`, for help text.
167
- def fqn(bluebook, aggregate, verb, entity = nil)
162
+ # The command's language name, `Chapter::Aggregate[.Entity].Verb`, for help text.
163
+ def fqn(bluebook, aggregate, command, entity = nil)
168
164
  [bluebook.name, "::", aggregate.hecks_name, ".",
169
- entity ? "#{entity.hecks_name}." : "", verb.hecks_name].join
165
+ entity ? "#{entity.hecks_name}." : "", command.hecks_name].join
170
166
  end
171
167
 
172
- # The options that name the record a verb acts on, before its own arguments.
168
+ # The options that name the record a command acts on, before its own arguments.
173
169
  # `nil` (a creating command) takes none: there is no record yet.
174
170
  # Ports always pass `:aggregate`, since a port is declared on an aggregate.
175
171
  def receiver_options(receiver, aggregate, entity)
@@ -204,8 +200,9 @@ module Hecks
204
200
  arguments = receiver_options(receiver, aggregate, entity) + arguments
205
201
  legacy_arguments = receiver == :aggregate ? [{ path: "id", type: "String", required: true }] : []
206
202
 
207
- { verb: fqn(bluebook, aggregate, command, entity), kind: :command,
203
+ { command: fqn(bluebook, aggregate, command, entity), kind: :command,
208
204
  summary: command.goal, role: command.role, role_gated: !command.role.to_s.empty?,
205
+ group: aggregate.hecks_name, internal: command.role.to_s == "System",
209
206
  creates: command.creates?,
210
207
  receiver: receiver, legacy_receiver: (receiver == :aggregate ? :id : nil),
211
208
  legacy_arguments: legacy_arguments,
@@ -213,15 +210,15 @@ module Hecks
213
210
  arguments: arguments }
214
211
  end
215
212
 
216
- # A port operation reads as a verb but reports as a boundary: it creates no
213
+ # A port operation reads as a command but reports as a boundary: it creates no
217
214
  # record, and an outbound failure is the other side's sentence, so `refusals` is empty.
218
215
  def port_spec(bluebook, aggregate, port, operation)
219
216
  arguments = receiver_options(:aggregate, aggregate, nil) +
220
217
  operation.attributes.flat_map { |a| options_for(a, aggregate, aggregate) }
221
218
 
222
219
  # `Dispatcher#dispatch` looks the head up as a port, so the wire name is
223
- # `Aggregate.Port.Operation`; the short name (see `shorten`) hides the port.
224
- { verb: [fqn(bluebook, aggregate, operation).sub(/\.[^.]+\z/, ""), port.name, operation.hecks_name].join("."),
220
+ # `Aggregate.Port.Operation`; the launcher name hides the port.
221
+ { command: [fqn(bluebook, aggregate, operation).sub(/\.[^.]+\z/, ""), port.name, operation.hecks_name].join("."),
225
222
  kind: :command, creates: false, receiver: :aggregate, refusals: [],
226
223
  # `role:` is help text only; port dispatch never reaches the role check,
227
224
  # so `role_gated` is always false here.
@@ -230,7 +227,7 @@ module Hecks
230
227
  else
231
228
  "#{port.name} telling #{aggregate.hecks_name}"
232
229
  end,
233
- role_gated: false,
230
+ role_gated: false, group: aggregate.hecks_name, internal: true,
234
231
  summary: port_summary(port, operation), arguments: arguments }
235
232
  end
236
233
 
@@ -253,17 +250,34 @@ module Hecks
253
250
  []
254
251
  end
255
252
 
256
- { verb: "#{bluebook.name}.#{model.hecks_name}", kind: :query,
253
+ { command: "#{bluebook.name}.#{model.hecks_name}", kind: :query,
257
254
  summary: model.description, arguments: arguments }
258
255
  end
259
256
 
257
+ # A question that only reads the aggregate's own records back: it returns no document and
258
+ # filters on nothing but the record's identity ("how one request ended") or its lifecycle
259
+ # status ("every request that was refused"). Each journaled run has such a pair, which a
260
+ # person reads through `hecks <command> --wait` rather than asking for by name, so the help
261
+ # sets them apart with the bookkeeping commands. A query that returns a document, or filters
262
+ # on anything else, is a real question. Only an aggregate that journals its own runs (it has
263
+ # system-role commands, the ones `internal` commands are made of) has such a pair: a release's
264
+ # "every version that was shipped" is a question worth asking by name.
265
+ def bookkeeping_query?(aggregate, query)
266
+ return false if query.returns || query.wheres.empty?
267
+ return false unless aggregate.commands.any? { |command| command.role.to_s == "System" }
268
+
269
+ own = Array(aggregate.identified_by).map(&:to_s) + [aggregate.lifecycle&.field.to_s]
270
+ query.wheres.all? { |clause| own.include?(clause.field.to_s) }
271
+ end
272
+
260
273
  def query_spec(bluebook, aggregate, entity, query)
261
274
  arguments = Array(query.to_h[:attributes]).flat_map do |declared|
262
275
  attribute = query.attributes.find { |a| a.name.to_s == declared[:name].to_s }
263
276
  attribute ? options_for(attribute, entity || aggregate, aggregate) : []
264
277
  end
265
278
 
266
- { verb: fqn(bluebook, aggregate, query, entity), kind: :query,
279
+ { command: fqn(bluebook, aggregate, query, entity), kind: :query, group: aggregate.hecks_name,
280
+ internal: entity.nil? && bookkeeping_query?(aggregate, query),
267
281
  summary: query.description, arguments: arguments, returns: query.returns }
268
282
  end
269
283
 
@@ -283,7 +297,7 @@ module Hecks
283
297
  return [reference_option(attribute)] if attribute.reference?
284
298
 
285
299
  value_object = value_object_for(attribute, holder, aggregate)
286
- return [scalar_option(path, attribute, optional)] unless value_object
300
+ return with_declared_default([scalar_option(path, attribute, optional)], attribute) unless value_object
287
301
 
288
302
  # The list flag rides on each leaf: without it a repeated flag overwrote the
289
303
  # leaf silently, and CliDoor only ever sees a path and a spec.
@@ -294,12 +308,31 @@ module Hecks
294
308
  scalar_option("#{path}.#{field.name}", field, optional || field.optional?,
295
309
  enum: closed_members(value_object, field))
296
310
  end
311
+ fields = with_declared_default(fields, attribute)
297
312
 
298
313
  return fields unless attribute.list?
299
314
 
300
315
  fields.map { |option| option.merge(list: true, note: [option[:note], "repeatable"].compact.join("; ")) }
301
316
  end
302
317
 
318
+ # Shows the default the attribute itself declares (`attribute :runs, Count, default: 30`) on
319
+ # the leaf it fills: the matching field for a hash default, the lone field for a bare one.
320
+ # An argument with a default is never required, since the runtime fills it when omitted.
321
+ #
322
+ # @param options [Array<Hash{Symbol => Object}>] the attribute's leaf option specs
323
+ # @param attribute [Object] the attribute, which may declare a default
324
+ # @return [Array<Hash{Symbol => Object}>] `options`, with the default shown where it lands
325
+ def with_declared_default(options, attribute)
326
+ declared = attribute.default if attribute.respond_to?(:default)
327
+ return options if declared.nil?
328
+
329
+ options.map do |option|
330
+ leaf = option[:path].split(".").last
331
+ value = declared.is_a?(Hash) ? declared.fetch(leaf.to_sym) { declared[leaf] } : (declared if options.one?)
332
+ value.nil? ? option : option.merge(default: value, required: false)
333
+ end
334
+ end
335
+
303
336
  def reference_option(attribute)
304
337
  { path: attribute.name.to_s, type: "String", required: !attribute.optional?,
305
338
  note: "id of a #{attribute.type.target_name}" }
@@ -335,7 +368,7 @@ module Hecks
335
368
  nil
336
369
  end
337
370
 
338
- # The conditions that refuse the verb when they hold, in the chapter's own words: a
371
+ # The conditions that refuse the command when they hold, in the chapter's own words: a
339
372
  # lifecycle state mismatch and a missing referenced record per `reference_to`.
340
373
  def refusals(command, holder)
341
374
  out = []
@@ -348,76 +381,120 @@ module Hecks
348
381
  out
349
382
  end
350
383
 
351
- # The conditions the verb needs: each `given` states what must hold, so the verb is
384
+ # The conditions the command needs: each `given` states what must hold, so the command is
352
385
  # refused unless it does.
353
386
  def requirements(command) = command.givens.map(&:description)
354
387
 
355
- # Renders the full verb/question table, or one verb's `--help` text when
356
- # `options[:verb]` names one.
357
- def usage(bluebook, verbs, questions, options)
388
+ # Renders the full command/question table, or one command's `--help` text when
389
+ # `options[:command]` names one.
390
+ def usage(bluebook, commands, questions, options)
358
391
  program = options[:program] || "hecks run"
359
- only = options[:verb]
392
+ only = options[:command]
360
393
 
361
394
  # `options[:ask]` picks the namespace when both hold the name; without it a
362
395
  # question's `--help` would print the command sharing its name.
363
396
  if only
364
- pool = options[:ask] ? questions : verbs
397
+ pool = options[:ask] ? questions : commands
365
398
  key = aliases(pool)[only] || (options[:ask] ? nil : aliases(questions)[only])
366
399
  spec = pool[key] || questions[key]
367
- return verb_help(program, spec[:short], spec, ask: options[:ask]) if spec
400
+ return command_help(program, spec[:short], spec, ask: options[:ask]) if spec
368
401
  end
369
402
 
370
- width = (verbs.values + questions.values).map { |spec| spec[:short].length }.max.to_i
403
+ width = (commands.values + questions.values).map { |spec| label(spec).length }.max.to_i
371
404
  out = ["#{bluebook.name} — #{bluebook.vision}", "",
372
- " #{program} <verb> [name=value …] do something",
373
- " #{program} ask <question> [name=value …] read something", ""]
405
+ " #{program} <command>! [name=value …] do something",
406
+ " #{program} query <query> [name=value …] read something", ""]
374
407
 
375
- out << "verbs:"
376
- verbs.each_value { |spec| out << " #{spec[:short].ljust(width)} #{spec[:summary]}" }
408
+ out << "commands:"
409
+ out.concat(listing(commands, width) { |spec| spec[:summary] })
377
410
  out << ""
378
- out << "questions (nothing here changes anything):"
379
- questions.each_value { |spec| out << " #{spec[:short].ljust(width)} #{first_sentence(spec[:summary])}" }
411
+ out << "queries (nothing here changes anything):"
412
+ out.concat(listing(questions, width) { |spec| first_sentence(spec[:summary]) })
380
413
  out << ""
381
- out << " #{program} <verb> --help what one verb wants, and every way it refuses"
382
- out << " a verb can always be spelled in full — #{example_qualified(verbs)}"
414
+ out << " #{program} <command> --help what one command wants, and every way it refuses"
415
+ out << " a command is called with its aggregate — #{example_qualified(commands)}"
383
416
  out.join("\n")
384
417
  end
385
418
 
386
- # One verb whose full spelling differs from its short one, or `""` when none does.
387
- def example_qualified(verbs)
388
- name, spec = verbs.find { |key, value| key != value[:short] } || verbs.first
389
- name ? "#{spec[:short]} is also #{name}" : ""
419
+ # The command or question lines of the help. A domain with more than one aggregate is listed
420
+ # under a heading per aggregate, so related commands sit together; the bookkeeping a run
421
+ # records about itself (`internal`: system-role commands and port operations) is set apart as
422
+ # names only, since a person never types them. A single-aggregate domain keeps the plain list.
423
+ def listing(specs, width)
424
+ shown, internal = specs.values.partition { |spec| !spec[:internal] }
425
+ groups = shown.group_by { |spec| spec[:group] }
426
+ lines = []
427
+ if groups.length > 1
428
+ groups.each do |group, members|
429
+ lines << " #{heading(group)}" if group
430
+ members.each { |spec| lines << " #{label(spec).ljust(width)} #{yield(spec)}" }
431
+ end
432
+ else
433
+ shown.each { |spec| lines << " #{label(spec).ljust(width)} #{yield(spec)}" }
434
+ end
435
+ lines.concat(internal_lines(internal)) unless internal.empty?
436
+ lines
437
+ end
438
+
439
+ # "LanguageRun" reads "Language": the Run suffix names the journaled-command shape all of
440
+ # these aggregates share, so it adds nothing under a heading ("Test suite", "Model check").
441
+ def heading(group)
442
+ words = Naming.snake(group.sub(/Run\z/, "")).tr("_", " ")
443
+ "#{words.capitalize}:"
444
+ end
445
+
446
+ # A command is written with the `!` that marks it; a query without one.
447
+ def label(spec) = spec[:kind] == :command ? "#{spec[:short]}!" : spec[:short]
448
+
449
+ # The internal commands as bare names, wrapped, under one line saying what they are.
450
+ def internal_lines(specs)
451
+ lines = [" internal — what a run records about itself, named here only (`--help` still works):"]
452
+ line = " "
453
+ specs.map { |spec| label(spec) }.each do |name|
454
+ if line.length + name.length + 1 > 98
455
+ lines << line
456
+ line = " "
457
+ end
458
+ line += " #{name}"
459
+ end
460
+ lines << line
461
+ end
462
+
463
+ # An example call, `aggregate.command!`, from the first command, or `""` when there is none.
464
+ def example_qualified(commands)
465
+ name = commands.keys.first
466
+ name ? "#{name}!" : ""
390
467
  end
391
468
 
392
- # The verb table wants a query description's first sentence; `--help` prints all.
469
+ # The command table wants a query description's first sentence; `--help` prints all.
393
470
  def first_sentence(text)
394
471
  text.to_s.split(/(?<=\.)\s/).first.to_s
395
472
  end
396
473
 
397
474
  # Four independent blocks, concatenated in fixed order: meta, invocation,
398
475
  # arguments, refusals.
399
- def verb_help(program, name, spec, ask: false)
400
- out = verb_help_meta_lines(name, spec)
401
- out.concat(verb_help_invocation_lines(program, name, spec, ask))
402
- out.concat(verb_help_argument_lines(spec))
403
- out.concat(verb_help_refusal_lines(spec))
476
+ def command_help(program, name, spec, ask: false)
477
+ out = command_help_meta_lines(name, spec)
478
+ out.concat(command_help_invocation_lines(program, name, spec, ask))
479
+ out.concat(command_help_argument_lines(spec))
480
+ out.concat(command_help_refusal_lines(spec))
404
481
  out.join("\n")
405
482
  end
406
483
 
407
- def verb_help_meta_lines(name, spec)
484
+ def command_help_meta_lines(name, spec)
408
485
  out = ["#{name} — #{spec[:summary]}", ""]
409
- out << "dispatches #{spec[:verb]}" if spec[:kind] == :command
410
- out << "reads #{spec[:verb]}" if spec[:kind] == :query
411
- out << "issued by #{spec[:role]}" if spec[:role]
486
+ out << "dispatches #{spec[:command]}" if spec[:kind] == :command
487
+ out << "reads #{spec[:command]}" if spec[:kind] == :query
488
+ out << "issued by #{spec[:role]}" if spec[:role]
412
489
  out
413
490
  end
414
491
 
415
- def verb_help_invocation_lines(program, name, spec, ask)
416
- invocation = ask ? "#{program} ask #{name}" : "#{program} #{name}"
492
+ def command_help_invocation_lines(program, name, spec, ask)
493
+ invocation = ask ? "#{program} query #{name}" : "#{program} #{name}!"
417
494
  ["", " #{invocation}#{spec[:arguments].map { |a| " #{a[:path]}=…" }.join}", ""]
418
495
  end
419
496
 
420
- def verb_help_argument_lines(spec)
497
+ def command_help_argument_lines(spec)
421
498
  return [] if spec[:arguments].empty?
422
499
 
423
500
  width = spec[:arguments].map { |a| a[:path].length }.max
@@ -434,7 +511,7 @@ module Hecks
434
511
  lines << ""
435
512
  end
436
513
 
437
- def verb_help_refusal_lines(spec)
514
+ def command_help_refusal_lines(spec)
438
515
  [["refused when:", spec[:refusals]], ["refused unless:", spec[:requirements]]].flat_map do |heading, items|
439
516
  Array(items).empty? ? [] : [heading, *items.map { |item| " #{item}" }, ""]
440
517
  end
@@ -1,4 +1,4 @@
1
- # Binds the `Agent` port to `Agent`; `hecks quality_control mine_combinations` asks it to write candidate domains.
1
+ # Binds the `Agent` port to `Agent`; `hecks quality_control target.mine_combinations` asks it to write candidate domains.
2
2
  # Required by name, not relative, so a copy of this directory shares the one implementation loaded.
3
3
  require "hecks/quality_control/adapters/agent"
4
4
 
@@ -6,8 +6,8 @@ require "shellwords"
6
6
  module Hecks
7
7
  module Adapters
8
8
  # The `Agent` port's adapter: hands a prompt to an agent on the command line and lets it work
9
- # in the checkout, the way `hecks quality_control mine_combinations` asks one for candidate
10
- # domains.
9
+ # in the checkout, the way `hecks quality_control target.mine_combinations` asks one for
10
+ # candidate domains.
11
11
  #
12
12
  # Not the interviewer behind the framework's `agent` port (`ClaudeCode`), which reads one
13
13
  # JSON answer back: this agent edits files, so the only answer is whether it finished.
@@ -7,14 +7,14 @@ require_relative "../../fuzzing/concurrent_dispatch"
7
7
 
8
8
  module Hecks
9
9
  module QualityControlCli
10
- # The command behind `hecks quality_control race`: one racer of
10
+ # The command behind `hecks quality_control sweep.race`: one racer of
11
11
  # `Hecks::Fuzzing::ConcurrentDispatch`, run as its own OS process.
12
12
  #
13
- # It is spawned, not forked: the caller (`hecks quality_control ask run`) holds live
13
+ # It is spawned, not forked: the caller (`hecks quality_control query sweep.run`) holds live
14
14
  # `PostgresEra` connections, and fork duplicates their file descriptors and SSL state,
15
15
  # corrupting them when a child exits.
16
16
  #
17
- # hecks quality_control race <domain-path> <database> <schema> <verb> <args-json>
17
+ # hecks quality_control sweep.race <domain-path> <database> <schema> <verb> <args-json>
18
18
  #
19
19
  # It prints one line, `succeeded`, `refused` or `crashed:<class>: <message>`, and always exits
20
20
  # 0.
@@ -5,15 +5,15 @@ require "open3"
5
5
 
6
6
  module Hecks
7
7
  module QualityControlCli
8
- # The command behind `hecks quality_control discover_external_domains`: reports sibling-repo
9
- # bluebook domains under `--projects-dir` that already depend on the hecks gem but are not
10
- # enrolled yet. It never enrolls anything itself.
8
+ # The command behind `hecks quality_control target.discover_external_domains`: reports
9
+ # sibling-repo bluebook domains under `--projects-dir` that already depend on the hecks gem but
10
+ # are not enrolled yet. It never enrolls anything itself.
11
11
  #
12
- # hecks quality_control discover_external_domains
13
- # hecks quality_control discover_external_domains --projects-dir ~/Projects
14
- # hecks quality_control discover_external_domains --max-depth 4
15
- # hecks quality_control discover_external_domains --known-path <path> ... # bypass the
16
- # ledger read
12
+ # hecks quality_control target.discover_external_domains
13
+ # hecks quality_control target.discover_external_domains --projects-dir ~/Projects
14
+ # hecks quality_control target.discover_external_domains --max-depth 4
15
+ # hecks quality_control target.discover_external_domains --known-path <path> ... # bypass
16
+ # the ledger read
17
17
  class QaDiscoverExternalDomains
18
18
  USAGE = "usage: hecks quality_control discover_external_domains [--projects-dir <path>] " \
19
19
  "[--max-depth N] [--known-path <path> ...]"
@@ -7,10 +7,10 @@ require_relative "../../fuzzing/form_census"
7
7
 
8
8
  module Hecks
9
9
  module QualityControlCli
10
- # The command behind `hecks quality_control judge_novelty`: does a new stress domain earn its
11
- # place? It is the gate before a domain becomes a `Target`.
10
+ # The command behind `hecks quality_control target.judge_novelty`: does a new stress domain earn
11
+ # its place? It is the gate before a domain becomes a `Target`.
12
12
  #
13
- # hecks quality_control judge_novelty <domain-path> [--against <path> ...]
13
+ # hecks quality_control target.judge_novelty <domain-path> [--against <path> ...]
14
14
  #
15
15
  # A domain is new when it puts two forms together on one aggregate that no existing target does
16
16
  # (`Hecks::Fuzzing::FormCensus`). It is compared against the ledger's `Target.path` rows unless
@@ -12,8 +12,8 @@ require_relative "child"
12
12
 
13
13
  module Hecks
14
14
  module QualityControlCli
15
- # The command behind `hecks quality_control check_generated_domains`: generates domains nobody
16
- # wrote and checks them the way the rotation does (`USAGE` lists the forms: generate,
15
+ # The command behind `hecks quality_control target.check_generated_domains`: generates domains
16
+ # nobody wrote and checks them the way the rotation does (`USAGE` lists the forms: generate,
17
17
  # `--blueprint`, `--source` and `--promote`).
18
18
  #
19
19
  # Exit codes: 0 every valid domain clean; 2 at least one finding; 1 operational error.
@@ -202,8 +202,8 @@ module Hecks
202
202
  ::QualityControlDials.const_get(name)
203
203
  end
204
204
 
205
- # `--from-dials` is how `hecks quality_control tick` runs this. The dials come from the text
206
- # of the bluebook before `Hecks.bluebook`, so the ledger's Postgres is not needed.
205
+ # `--from-dials` is how `hecks quality_control sweep.tick` runs this. The dials come from the
206
+ # text of the bluebook before `Hecks.bluebook`, so the ledger's Postgres is not needed.
207
207
  # `QA_GENERATED_DOMAINS_PER_TICK` overrides the count for one run.
208
208
  #
209
209
  # @return [Boolean] false when the dials turn the step off, true once they are applied
@@ -7,11 +7,11 @@ require_relative "../../ports/persistence/plugins/era"
7
7
 
8
8
  module Hecks
9
9
  module QualityControlCli
10
- # The command behind `hecks quality_control log`: logs a bug to the QualityControl ledger,
10
+ # The command behind `hecks quality_control bug.log`: logs a bug to the QualityControl ledger,
11
11
  # proven, numbered and triaged. It runs `--demonstration` first and refuses unless it exits
12
12
  # non-zero.
13
13
  #
14
- # hecks quality_control log --sweep <sweep-id> --title "…" \
14
+ # hecks quality_control bug.log --sweep <sweep-id> --title "…" \
15
15
  # --demonstration "bundle exec rspec spec/x_spec.rb -e 'the case'" \
16
16
  # --symptom "…" --expectation "…" --submitter "<who>" \
17
17
  # --triage self_contained|bigger [--tag word]… [--reproduced yes|no]
@@ -13,16 +13,17 @@ require_relative "../../hecks/adapters/codebase/tree"
13
13
 
14
14
  module Hecks
15
15
  module QualityControlCli
16
- # The command behind `hecks quality_control mine_combinations`: asks an agent to mine the
16
+ # The command behind `hecks quality_control target.mine_combinations`: asks an agent to mine the
17
17
  # adversarial corpus for new domain combinations, then checks them. It is opt-in and never run
18
- # by `hecks quality_control tick` (an agent call costs money and answers differently each run).
18
+ # by `hecks quality_control sweep.tick` (an agent call costs money and answers differently each
19
+ # run).
19
20
  # `--brief` prints the agent's prompt and stops; `--from <dir>` re-checks an earlier run;
20
21
  # `--against <domain>` narrows the census; `--agent "cmd"` reads the prompt on stdin.
21
22
  #
22
23
  # The agent defaults to `claude -p` (`QA_MINER_AGENT` overrides); candidates that boot are
23
- # checked by `hecks quality_control check_generated_domains --source`, whose report is this
24
- # command's report. Exit 0: all clean. 2: a finding (see `.claude/skills/hecks_qa/SKILL.md`). 1:
25
- # an operational
24
+ # checked by `hecks quality_control target.check_generated_domains --source`, whose report is
25
+ # this command's report. Exit 0: all clean. 2: a finding (see
26
+ # `.claude/skills/hecks_qa/SKILL.md`). 1: an operational
26
27
  # error.
27
28
  class QaMineCombinations
28
29
  EXIT_OK = 0