principles 0.0.5 → 0.0.7

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 (192) hide show
  1. checksums.yaml +4 -4
  2. data/lib/principles/after_commit_hook_options.rb +4 -1
  3. data/lib/principles/cli.rb +9 -0
  4. data/lib/principles/command_line.rb +31 -30
  5. data/lib/principles/command_routes.rb +9 -3
  6. data/lib/principles/controllers/acknowledgement.rb +82 -95
  7. data/lib/principles/controllers/answer.rb +14 -11
  8. data/lib/principles/controllers/assessment.rb +27 -24
  9. data/lib/principles/controllers/audit.rb +24 -4
  10. data/lib/principles/controllers/audit_completion.rb +10 -4
  11. data/lib/principles/controllers/command.rb +2 -2
  12. data/lib/principles/controllers/correction.rb +16 -7
  13. data/lib/principles/controllers/full_audit_request.rb +8 -3
  14. data/lib/principles/controllers/guidance_search_paths.rb +31 -0
  15. data/lib/principles/controllers/inventory.rb +3 -22
  16. data/lib/principles/controllers/mapping.rb +9 -1
  17. data/lib/principles/controllers/member_acknowledgement.rb +137 -0
  18. data/lib/principles/controllers/member_addition.rb +65 -0
  19. data/lib/principles/controllers/member_entries.rb +6 -24
  20. data/lib/principles/controllers/member_problems_report.rb +33 -25
  21. data/lib/principles/controllers/members_to_assess.rb +1 -1
  22. data/lib/principles/controllers/meta_principle_setup.rb +1 -1
  23. data/lib/principles/controllers/repoint.rb +5 -2
  24. data/lib/principles/controllers/survey.rb +60 -0
  25. data/lib/principles/data/audit_files.rb +4 -0
  26. data/lib/principles/data/candidate_files_found.rb +48 -13
  27. data/lib/principles/data/command-steps.json +86 -25
  28. data/lib/principles/data/committed_tree.rb +84 -0
  29. data/lib/principles/data/first_parent_log.rb +48 -0
  30. data/lib/principles/data/first_parent_range.rb +122 -0
  31. data/lib/principles/data/git_command.rb +37 -0
  32. data/lib/principles/data/guidance_search_paths_file.rb +107 -0
  33. data/lib/principles/data/map_files.rb +35 -10
  34. data/lib/principles/data/principles_directory.rb +40 -0
  35. data/lib/principles/data/principles_subfolder.rb +39 -16
  36. data/lib/principles/data/project_files.rb +11 -3
  37. data/lib/principles/data/repository.rb +55 -29
  38. data/lib/principles/data/requested_candidate_files.rb +43 -0
  39. data/lib/principles/data/running_version.rb +3 -5
  40. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +6 -6
  41. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +88 -0
  42. data/lib/principles/data/schemas/answer-guide.schema.json +255 -63
  43. data/lib/principles/data/schemas/assessment-answer.schema.json +15 -1
  44. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  45. data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
  46. data/lib/principles/data/schemas/correction-answer.schema.json +12 -54
  47. data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
  48. data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
  49. data/lib/principles/data/verified_head.rb +162 -0
  50. data/lib/principles/invocation_options.rb +5 -4
  51. data/lib/principles/list_open_findings_options.rb +23 -0
  52. data/lib/principles/models/acknowledged_check.rb +94 -0
  53. data/lib/principles/models/acknowledgement.rb +40 -36
  54. data/lib/principles/models/acknowledgement_left_as_printed.rb +72 -0
  55. data/lib/principles/models/acknowledgements.rb +99 -0
  56. data/lib/principles/models/answered_time.rb +9 -0
  57. data/lib/principles/models/assessment_report.rb +13 -13
  58. data/lib/principles/models/audit.rb +17 -4
  59. data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
  60. data/lib/principles/models/audit_record.rb +9 -0
  61. data/lib/principles/models/audit_records.rb +34 -8
  62. data/lib/principles/models/candidate_files.rb +17 -6
  63. data/lib/principles/models/candidate_inventory.rb +51 -7
  64. data/lib/principles/models/captured_head.rb +72 -0
  65. data/lib/principles/models/check_since_last_audit.rb +4 -8
  66. data/lib/principles/models/correction_basis.rb +14 -5
  67. data/lib/principles/models/declared_map_changes.rb +25 -9
  68. data/lib/principles/models/declared_member_removals.rb +75 -0
  69. data/lib/principles/models/disposition.rb +4 -2
  70. data/lib/principles/models/fix_only_fields.rb +12 -0
  71. data/lib/principles/models/guidance_search_path.rb +26 -0
  72. data/lib/principles/models/guidance_search_paths.rb +57 -0
  73. data/lib/principles/models/line_span.rb +6 -0
  74. data/lib/principles/models/list_member_problems_check.rb +80 -0
  75. data/lib/principles/models/listed_members.rb +49 -0
  76. data/lib/principles/models/loaded_files.rb +1 -2
  77. data/lib/principles/models/loading_decision.rb +17 -8
  78. data/lib/principles/models/loading_scope.rb +61 -0
  79. data/lib/principles/models/loads_to_check.rb +0 -1
  80. data/lib/principles/models/locator.rb +6 -0
  81. data/lib/principles/models/mapped_principles.rb +39 -37
  82. data/lib/principles/models/member_assessments.rb +11 -2
  83. data/lib/principles/models/member_file.rb +20 -71
  84. data/lib/principles/models/member_history.rb +7 -5
  85. data/lib/principles/models/member_loading_scopes.rb +49 -0
  86. data/lib/principles/models/member_loads.rb +4 -0
  87. data/lib/principles/models/member_mapping_run.rb +30 -0
  88. data/lib/principles/models/member_moves.rb +4 -0
  89. data/lib/principles/models/member_problems.rb +57 -29
  90. data/lib/principles/models/member_region.rb +129 -0
  91. data/lib/principles/models/member_repair_moves.rb +9 -11
  92. data/lib/principles/models/member_sighting.rb +5 -8
  93. data/lib/principles/models/member_snapshots.rb +14 -1
  94. data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
  95. data/lib/principles/models/meta_principle.rb +14 -0
  96. data/lib/principles/models/missing_files.rb +2 -2
  97. data/lib/principles/models/other_templates_placeholders.rb +1 -1
  98. data/lib/principles/models/outline_budget.rb +29 -14
  99. data/lib/principles/models/principle.rb +14 -7
  100. data/lib/principles/models/principle_file_revision.rb +48 -0
  101. data/lib/principles/models/principle_history.rb +46 -19
  102. data/lib/principles/models/principle_lineage.rb +118 -0
  103. data/lib/principles/models/principle_map_revision.rb +39 -0
  104. data/lib/principles/models/principle_mapping_history.rb +132 -0
  105. data/lib/principles/models/principle_members.rb +14 -0
  106. data/lib/principles/models/principle_predecessor.rb +45 -0
  107. data/lib/principles/models/principle_publication.rb +177 -0
  108. data/lib/principles/models/principle_revision.rb +104 -0
  109. data/lib/principles/models/problem_report.rb +36 -9
  110. data/lib/principles/models/project.rb +47 -30
  111. data/lib/principles/models/project_history.rb +45 -25
  112. data/lib/principles/models/record_format.rb +6 -0
  113. data/lib/principles/models/reported_check.rb +16 -12
  114. data/lib/principles/models/request_id.rb +1 -1
  115. data/lib/principles/models/sent_answer.rb +35 -5
  116. data/lib/principles/models/survey_search_paths.rb +26 -0
  117. data/lib/principles/models/uncommitted_files.rb +50 -0
  118. data/lib/principles/models/unknown_principle.rb +29 -0
  119. data/lib/principles/positional_arguments.rb +38 -0
  120. data/lib/principles/session_start_options.rb +3 -3
  121. data/lib/principles/start_audit_options.rb +10 -2
  122. data/lib/principles/version.rb +2 -2
  123. data/lib/principles/views/acknowledgement_result.rb +54 -16
  124. data/lib/principles/views/added_member.rb +41 -0
  125. data/lib/principles/views/answered_request.rb +21 -0
  126. data/lib/principles/views/assessed_members.rb +26 -5
  127. data/lib/principles/views/assessment_request.rb +24 -4
  128. data/lib/principles/views/audit_result.rb +30 -27
  129. data/lib/principles/views/candidate_files_result.rb +56 -12
  130. data/lib/principles/views/candidate_outlines_result.rb +25 -0
  131. data/lib/principles/views/check_result_template.rb +18 -17
  132. data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
  133. data/lib/principles/views/correction_request.rb +38 -10
  134. data/lib/principles/views/findings_result.rb +21 -0
  135. data/lib/principles/views/guidance_search_paths_result.rb +26 -0
  136. data/lib/principles/views/invocation.rb +19 -4
  137. data/lib/principles/views/json_with_entries_on_lines.rb +12 -4
  138. data/lib/principles/views/loads_to_check_result.rb +3 -2
  139. data/lib/principles/views/map_added_to.rb +56 -2
  140. data/lib/principles/views/map_result.rb +22 -42
  141. data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
  142. data/lib/principles/views/member_change_since_baseline.rb +2 -1
  143. data/lib/principles/views/member_repairs.rb +2 -1
  144. data/lib/principles/views/member_row.rb +61 -0
  145. data/lib/principles/views/members_a_commit_changed.rb +2 -1
  146. data/lib/principles/views/members_with_no_baseline.rb +8 -1
  147. data/lib/principles/views/new_loading_scope.rb +31 -0
  148. data/lib/principles/views/one_member_check_result_template.rb +37 -21
  149. data/lib/principles/views/open_findings_line.rb +2 -1
  150. data/lib/principles/views/principle_read_result.rb +4 -1
  151. data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
  152. data/lib/principles/views/problem_lines.rb +50 -45
  153. data/lib/principles/views/problem_result.rb +59 -25
  154. data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
  155. data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -3
  156. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
  157. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -6
  158. data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -43
  159. data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
  160. data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
  161. data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
  162. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
  163. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +12 -0
  164. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
  165. data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
  166. data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
  167. data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +4 -2
  168. data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
  169. data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +2 -2
  170. data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
  171. data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
  172. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
  173. data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
  174. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
  175. data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
  176. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
  177. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +37 -4
  178. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +20 -19
  179. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
  180. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
  181. data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
  182. data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
  183. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +33 -7
  184. data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
  185. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +10 -10
  186. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
  187. data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
  188. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +1 -1
  189. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
  190. data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
  191. metadata +67 -4
  192. data/lib/principles/models/candidate_listing.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40e41136c5be852cc2019089d41ab1548144e52138ab51c80211befe32bfa411
4
- data.tar.gz: 3d7d56d9ba40d0678e39fcd4b7f6ecca2b231ac5b449f07af84617b8e0ad1a91
3
+ metadata.gz: d5d575d0453395ba5141ec7780917df605ff9fc26293bd31fa383ab4bf76db04
4
+ data.tar.gz: 75adf95a072fa1d188e18216ea73423255898c4f4d4914cb2229b3f6a5f8bf88
5
5
  SHA512:
6
- metadata.gz: ff6dd21e3e9a0e929ae135aaaa587b8781e6bea67ac6547fa8b23ce43d15a75d05a3c9490eaecf1049d76384df1e39eb7e5d6c0605a883dc67ff5051b308f12b
7
- data.tar.gz: cd61142617ebf7f28eba7b2ae5bc89e1dd18d745fb8d9c763bacf68c6e2dacc7a5cc5f66869c0bf4da24d584134612b4f9ae52a63d682931c342a96217476bb0
6
+ metadata.gz: a9faed0ef7cc9f65234fa8add36851d815780e558ef618663413239b2b27a8679682dfacb9faa1cd7cab8e9997fe4e812b76982c9bb24498bbf1e1880751b3c8
7
+ data.tar.gz: f6ef3034f68217f1702235584cc338e028785d1581d971fd79bb786cd546fc5b86450c842747974c57867b0901b82f721b5b5ce65ad2048cd90723251788d25f
@@ -5,12 +5,15 @@ require_relative "invocation_options"
5
5
 
6
6
  module Principles
7
7
  # The options the plugin's after-commit hook gives list-member-problems, --commits-after and --hook-event (D73),
8
- # and what is wrong with them as given, which CommandLine refuses as a usage error.
8
+ # and what is wrong with them as given, which CommandLine refuses as a usage error. list-candidate-files takes
9
+ # --commits-after for a range of its own, so CommandLine checks these on COMMAND alone (#1171).
9
10
  class AfterCommitHookOptions
10
11
  # The events Claude Code runs the after-commit hook on, which --hook-event echoes back to it.
11
12
  EVENTS = %w[PostToolUse PostToolUseFailure].freeze #: Array[String]
12
13
  # A commit's full sha, SHA-1 or SHA-256, which the hook resolves HEAD@{1} to before passing it.
13
14
  FULL_SHA = /\A\h{40}(?:\h{24})?\z/ #: Regexp
15
+ # The command the hook runs, the one these options are checked on.
16
+ COMMAND = "list-member-problems"
14
17
 
15
18
  #: (InvocationOptions) -> void
16
19
  def initialize(options)
@@ -51,6 +51,8 @@ module Principles
51
51
  def dispatch(line)
52
52
  return printed(running_version) if line.option("version")
53
53
 
54
+ return printed(help_topic(line)) if line.help_words?
55
+
54
56
  command = line.command or return printed(help.overview)
55
57
  return printed(help_for(command)) if line.option("help")
56
58
 
@@ -148,6 +150,13 @@ module Principles
148
150
  #: () -> String
149
151
  def running_version = Data::RunningVersion.new.to_s
150
152
 
153
+ # The page help COMMAND asks for, as COMMAND --help prints it, or the overview for help alone (#1167).
154
+ #: (CommandLine) -> String
155
+ def help_topic(line)
156
+ topic = line.help_topic
157
+ topic ? help_for(topic) : help.overview
158
+ end
159
+
151
160
  # A command's --help, from the steps command-steps.json lists for it.
152
161
  #: (String) -> String
153
162
  def help_for(command)
@@ -5,9 +5,11 @@ require "optparse"
5
5
  require_relative "invocation_options"
6
6
  require_relative "after_commit_hook_options"
7
7
  require_relative "session_start_options"
8
+ require_relative "list_open_findings_options"
8
9
  require_relative "start_audit_options"
9
10
  require_relative "models/command_steps"
10
11
  require_relative "prose_list"
12
+ require_relative "positional_arguments"
11
13
 
12
14
  module Principles
13
15
  # One invocation's words: the command, its positional arguments and its options, refused with an
@@ -57,6 +59,14 @@ module Principles
57
59
  #: () -> bool
58
60
  def project_given? = @options.given.include?("project")
59
61
 
62
+ # Whether the words ask for help by word, as help or help COMMAND, which an agent tries before --help (#1167).
63
+ #: () -> bool
64
+ def help_words? = @arguments.first == "help"
65
+
66
+ # The command help COMMAND names, or nil for help alone.
67
+ #: () -> String?
68
+ def help_topic = @arguments[1]
69
+
60
70
  # The command named first; nil when none is, and refused when this tool has no such command.
61
71
  #: () -> String?
62
72
  def command
@@ -81,43 +91,31 @@ module Principles
81
91
  # The principle id, for a command whose first argument is one.
82
92
  #: () -> String?
83
93
  def id
84
- %w[id id?].include?(names.first) ? values.first : nil
94
+ positionals.id
85
95
  end
86
96
 
87
97
  # The options, with every positional argument but the id under its name.
88
98
  #: () -> Hash[String, untyped]
89
99
  def command_options
90
- names.zip(values).each_with_object(@options.to_h) do |(name, value), all|
91
- all[name] = value unless %w[id id?].include?(name)
92
- end
100
+ @options.to_h.merge(positionals.bindings)
93
101
  end
94
102
 
95
103
  private
96
104
 
97
- #: () -> Array[String]
98
- def names
99
- @positional.fetch(command.to_s)
100
- end
101
-
102
- #: () -> Array[String]
103
- def values
104
- @arguments.drop(1)
105
- end
105
+ #: () -> PositionalArguments
106
+ def positionals = PositionalArguments.new(@positional.fetch(command.to_s), @arguments.drop(1))
106
107
 
107
108
  # Each argument the command needs and was not given, named in one refusal: an agent that met one refusal per
108
109
  # missing argument repaired them one at a time (#1083). Each option command-steps.json says it requires is one.
110
+ # The repair names the command's usage, which shows what to give (#1273).
109
111
  #: (String) -> void
110
112
  def check_missing(name)
111
- missing = missing_arguments + missing_options(name)
113
+ missing = positionals.missing + missing_options(name)
112
114
  return if missing.empty?
113
115
 
114
- raise OptionParser::MissingArgument, "#{name} needs #{ProseList.new(missing)}"
116
+ raise UsageRefusal.new("missing argument: #{name} needs #{ProseList.new(missing)}", help_repair(name))
115
117
  end
116
118
 
117
- # The positional arguments the command needs past those given, as usage names them.
118
- #: () -> Array[String]
119
- def missing_arguments = names.drop(values.length).reject { |each| each.end_with?("?") }.map(&:upcase)
120
-
121
119
  # The options command name requires and was not given, as a refusal names them.
122
120
  #: (String) -> Array[String]
123
121
  def missing_options(name)
@@ -128,18 +126,12 @@ module Principles
128
126
  # Too many arguments; check_missing has refused too few.
129
127
  #: (String) -> void
130
128
  def check_arguments(name)
131
- return if values.length <= names.length
129
+ return unless positionals.too_many?
132
130
 
133
- takes = "#{name} takes #{shown_arguments}".strip.sub(/ takes\z/, " takes no arguments")
131
+ takes = "#{name} takes #{positionals.shown}".strip.sub(/ takes\z/, " takes no arguments")
134
132
  raise OptionParser::InvalidArgument, takes
135
133
  end
136
134
 
137
- # The positional arguments as usage shows them; a name ending in ? is optional and shown in brackets.
138
- #: () -> String
139
- def shown_arguments
140
- names.map { |each| each.end_with?("?") ? "[#{each.chomp("?").upcase}]" : each.upcase }.join(" ")
141
- end
142
-
143
135
  # An option a command does not take is refused, so a mistyped command never runs as something else.
144
136
  #: (String) -> void
145
137
  def check_options(name)
@@ -166,10 +158,13 @@ module Principles
166
158
  end
167
159
 
168
160
  # Options checked together, each set owning what is wrong with it as given: --session-start (#717), the
169
- # after-commit hook's pair (D73) and the audit start-audit begins (#760); the first fault is refused.
161
+ # after-commit hook's pair on the command it runs (D73), the audit start-audit begins (#760) and the form
162
+ # list-open-findings prints (#1156); the first fault is refused.
170
163
  #: (String) -> void
171
164
  def check_combined_options(name)
172
- sets = [SessionStartOptions.new(@options), AfterCommitHookOptions.new(@options), StartAuditOptions.new(@options)]
165
+ hook = (AfterCommitHookOptions.new(@options) if name == AfterCommitHookOptions::COMMAND)
166
+ sets = [SessionStartOptions.new(@options), hook, StartAuditOptions.new(@options),
167
+ ListOpenFindingsOptions.new(@options)].compact
173
168
  fault = sets.filter_map(&:fault).first or return
174
169
  raise UsageRefusal.new(fault, help_repair(name))
175
170
  end
@@ -193,7 +188,13 @@ module Principles
193
188
  #: (String) -> Models::CommandSteps::Command?
194
189
  def steps(name) = Models::CommandSteps.load.command(name)
195
190
 
191
+ # The command's usage, which names every option it takes, so a near-miss such as --heading for --section shows
192
+ # beside the refusal (#1273), then where to see what each takes. The usage leaves out the executable, so it is not
193
+ # read as a command to run as printed.
196
194
  #: (String) -> String
197
- def help_repair(name) = "To see what it takes: #{@executable} #{name} --help"
195
+ def help_repair(name)
196
+ usage = steps(name)&.usage or return "To see what it takes: #{@executable} #{name} --help"
197
+ "Usage: #{usage}\nTo see what each takes: #{@executable} #{name} --help"
198
+ end
198
199
  end
199
200
  end
@@ -2,6 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "controllers/inventory"
5
+ require_relative "controllers/survey"
6
+ require_relative "controllers/guidance_search_paths"
5
7
  require_relative "controllers/member_problems_report"
6
8
  require_relative "controllers/mapping"
7
9
  require_relative "controllers/meta_principle_setup"
@@ -31,7 +33,10 @@ module Principles
31
33
  end
32
34
 
33
35
  ROUTES = {
34
- "list-candidate-files" => Route.new(Controllers::Inventory, []),
36
+ "list-candidate-files" => Route.new(Controllers::Survey, []),
37
+ "show-candidate-outlines" => Route.new(Controllers::Survey, ["path..."]),
38
+ "add-guidance-search-path" => Route.new(Controllers::GuidanceSearchPaths, %w[glob]),
39
+ "remove-guidance-search-path" => Route.new(Controllers::GuidanceSearchPaths, %w[glob]),
35
40
  "list-principles" => Route.new(Controllers::Inventory, []),
36
41
  "list-member-problems" => Route.new(Controllers::MemberProblemsReport, %w[id?]),
37
42
  "show-principle" => Route.new(Controllers::Inventory, %w[id]),
@@ -39,6 +44,7 @@ module Principles
39
44
  "list-open-findings" => Route.new(Controllers::Audit, %w[id?]),
40
45
  "show-meta-principle-passage" => Route.new(Controllers::MetaPrincipleSetup, []),
41
46
  "create-principle" => Route.new(Controllers::Mapping, %w[id]),
47
+ "remove-principle" => Route.new(Controllers::Mapping, %w[id]),
42
48
  "change-description" => Route.new(Controllers::Mapping, %w[id]),
43
49
  "change-activation" => Route.new(Controllers::Mapping, %w[id]),
44
50
  "add-member" => Route.new(Controllers::MemberEntries, %w[id path]),
@@ -48,8 +54,8 @@ module Principles
48
54
  "remove-member-check" => Route.new(Controllers::MemberEntries, %w[id member]),
49
55
  "remove-member" => Route.new(Controllers::MemberEntries, %w[id member]),
50
56
  "start-audit" => Route.new(Controllers::Audit, %w[id]),
51
- "submit-answer" => Route.new(Controllers::Answer, %w[request_id]),
52
- "show-answer-check" => Route.new(Controllers::Answer, %w[request_id])
57
+ "submit-answer" => Route.new(Controllers::Answer, %w[request_id?]),
58
+ "show-answer-check" => Route.new(Controllers::Answer, %w[request_id?])
53
59
  }.freeze #: Hash[String, Route]
54
60
 
55
61
  # Each command's positional arguments, in order, as CommandLine takes them.
@@ -1,13 +1,12 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "json"
5
4
  require "time"
6
5
  require_relative "answer_phase"
6
+ require_relative "member_acknowledgement"
7
7
  require_relative "../models/acknowledgement"
8
- require_relative "../models/check_since_last_audit"
8
+ require_relative "../models/acknowledgements"
9
9
  require_relative "../models/reported_check"
10
- require_relative "../views/one_member_check_result_template"
11
10
  require_relative "../views/acknowledgement_result"
12
11
 
13
12
  module Principles
@@ -21,9 +20,8 @@ module Principles
21
20
  #: (String, String) -> Hash[String, untyped]
22
21
  def start(id, member_id)
23
22
  naming_the_executable(rerun: one_member_audit(id)) do
24
- acknowledgement, change, check_result = asked(id, member_id)
25
- view.request(request_id: acknowledgement.request_id.to_s, principle_id: id, change: change,
26
- open_findings: acknowledgement.open_findings, placeholders: placeholders(check_result, change))
23
+ member = of(id, member_id)
24
+ view.request(request_id: member.acknowledgement.request_id.to_s, principle_id: id, asked: member.asked)
27
25
  .merge("wrote" => [])
28
26
  end
29
27
  end
@@ -33,29 +31,45 @@ module Principles
33
31
  #: (String, String) -> Hash[String, untyped]
34
32
  def to_fill(id, member_id)
35
33
  naming_the_executable(rerun: one_member_audit(id)) do
36
- acknowledgement, change, check_result = asked(id, member_id)
37
- view.answer_to_fill(request_id: acknowledgement.request_id.to_s, change: change,
38
- placeholders: placeholders(check_result, change))
34
+ member = of(id, member_id)
35
+ view.answer_to_fill(request_id: member.acknowledgement.request_id.to_s, asked: member.asked)
36
+ end
37
+ end
38
+
39
+ # The request for several of principle id's members in one answer (#1169), or with to_fill its answer alone:
40
+ # each member as its own request shows it.
41
+ #: (String, Array[String], to_fill: bool) -> Hash[String, untyped]
42
+ def several(id, member_ids, to_fill:)
43
+ naming_the_executable(rerun: one_member_audit(id)) do
44
+ members = member_ids.map { of(id, it) }
45
+ request_id = several_of(id, members).request_id.to_s
46
+ asked = members.map(&:asked)
47
+ next view.several_to_fill(request_id:, members: asked) if to_fill
48
+
49
+ view.several_request(request_id:, principle_id: id, members: asked).merge("wrote" => [])
39
50
  end
40
51
  end
41
52
 
42
53
  # The result of answering, and the record it changes, not yet written.
43
54
  # @override
44
- #: (Models::SubmittedAnswer) -> [Hash[String, untyped], Array[Models::AuditRecord]]
55
+ #: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
45
56
  def answered(submitted)
46
- request_id = submitted.request_id
47
- response = submitted.response
48
- id = request_id.principle_id
49
- acknowledgement, member, = prepared(id, response.fetch("basis").fetch("member_id"))
50
- stale(id, member.id) unless acknowledgement.request_id.to_s == request_id.to_s
51
- [view.acknowledged(principle_id: id, member_id: member.id, file: @audit_records.file(id)),
52
- [accepted(id, acknowledgement, member, response)]]
57
+ return several_answered(submitted) if submitted.request_id.phase == Models::Acknowledgements::PHASE
58
+
59
+ id = submitted.request_id.principle_id
60
+ member = answering(submitted)
61
+ [view.acknowledged(principle_id: id, member_id: member.member.id, file: @audit_records.file(id)),
62
+ [member.accepted(submitted.response, at: Time.now.utc.iso8601)]]
53
63
  end
54
64
 
55
65
  # The refusals an answer meets before its shape: any phase's, then a placeholder its template printed left in,
56
- # which the shape would refuse in meaning_kept without naming it (#773).
66
+ # which the shape would refuse in meaning_kept without naming it (#773), or in a checked member's exit_status
67
+ # with a repair this template does not take (#1170), read in each member's entry of an answer to several (#1169).
57
68
  #: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
58
- def before_shape(request_id) = [*super, Models::Acknowledgement::PLACEHOLDERS]
69
+ def before_shape(request_id)
70
+ left = Models::Acknowledgement::LEFT_AS_PRINTED
71
+ [*super, request_id.phase == Models::Acknowledgements::PHASE ? left.in_each_member : left]
72
+ end
59
73
 
60
74
  private
61
75
 
@@ -64,45 +78,9 @@ module Principles
64
78
  # answer, not the request id, so this names the check's whether the member has one.
65
79
  # @override
66
80
  #: (Models::RequestId) -> Hash[String, untyped]?
67
- def printed_placeholders(_request_id) = placeholders(Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h)
68
-
69
- # The acknowledgement of principle id's member, its change since its baseline, as the request shows it, and the
70
- # check_result its answer fills, if the member has a check.
71
- #: (String, String) -> [Models::Acknowledgement, Views::MemberChangeSinceBaseline, Hash[String, untyped]?]
72
- def asked(id, member_id)
73
- acknowledgement, member, base = prepared(id, member_id)
74
- baseline, lines = since_baseline(id, acknowledgement, member)
75
- check_result = check_template(id, member)
76
- [acknowledgement,
77
- Views::MemberChangeSinceBaseline.new(
78
- member: shown(acknowledgement, member, baseline), member_lines: lines.shown(taken: bytes_of(check_result)),
79
- first_changed_lines: acknowledgement.first_changed_lines(lines),
80
- commits: commits(acknowledgement, baseline, base), paths: acknowledgement.paths_since(baseline)
81
- ), check_result]
82
- end
83
-
84
- # The bytes check_result takes as the request prints it, which the member's lines give up (#1119).
85
- #: (Hash[String, untyped]?) -> Integer
86
- def bytes_of(check_result) = check_result ? JSON.pretty_generate(check_result).bytesize : 0
87
-
88
- # The text the template prints in each field the agent writes: its judgement's placeholders, the quotes as the
89
- # change's first_changed_lines hints them (#1111), and check_result's for a checked member.
90
- #: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?) -> Hash[String, untyped]
91
- def placeholders(check_result, change = nil)
92
- quotes = change&.first_changed_lines.to_h
93
- { **Models::Acknowledgement.placeholders_beside(quotes), **quotes,
94
- **(check_result ? { "check_result" => check_result } : {}) }
95
- end
96
-
97
- # The check_result a checked member's answer fills, for the check the last audit ran, which a one-member audit
98
- # requires (D30, D63, #1071), asking for a passing run alone (#1112); nil for a member without a check.
99
- #: (String, Models::Member) -> Hash[String, untyped]?
100
- def check_template(id, member)
101
- checks = Models::CheckSinceLastAudit.new(id:, history: @history, principles: @principles,
102
- record: @audit_records.find(id))
103
- Views::OneMemberCheckResultTemplate.for(checks.entry(member),
104
- review_basis:
105
- Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.fetch("review_basis"))
81
+ def printed_placeholders(_request_id)
82
+ MemberAcknowledgement.placeholders(Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h
83
+ .merge("exit_status" => Models::Acknowledgement::EXIT_STATUS_PLACEHOLDER))
106
84
  end
107
85
 
108
86
  # The one-member audit of principle id's member, as a refusal naming a near miss leads its repair with (D56).
@@ -111,56 +89,65 @@ module Principles
111
89
  ->(member) { invocation.in_project("start-audit", id, options: ["--member", member]) }
112
90
  end
113
91
 
114
- # The record with the acknowledgement in it, once its quotes are found at the baseline and now.
115
- #: (String, Models::Acknowledgement, Models::Member, untyped) -> Models::AuditRecord
116
- def accepted(id, acknowledgement, member, response)
117
- _baseline, lines = since_baseline(id, acknowledgement, member)
118
- acknowledgement.accepted(response, lines, at: Time.now.utc.iso8601)
92
+ # The member the answer acknowledges, refused as stale unless its request is still the one the answer answers.
93
+ #: (Models::SubmittedAnswer) -> MemberAcknowledgement
94
+ def answering(submitted)
95
+ id = submitted.request_id.principle_id
96
+ member = of(id, submitted.response.fetch("basis").fetch("member_id"))
97
+ stale(id, member.member.id) unless member.acknowledgement.request_id == submitted.request_id
98
+ member
119
99
  end
120
100
 
121
- # The member as the request shows it, with where it was at its baseline when it has moved since (#547).
122
- #: (Models::Acknowledgement, Models::Member, Models::Placement) -> Hash[String, untyped]
123
- def shown(acknowledgement, member, baseline)
124
- moved_from = acknowledgement.moved_from(baseline)
125
- { "id" => member.id, "role" => member.role, **(member.check ? { "check" => member.check } : {}),
126
- "evidence" => [member.reference],
127
- **(moved_from ? { "evidence_at_baseline" => [moved_from] } : {}) }
101
+ # The result of answering a request for several members, and the one record their acknowledgements change.
102
+ #: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
103
+ def several_answered(submitted)
104
+ id = submitted.request_id.principle_id
105
+ several, members = answering_several(submitted)
106
+ [view.several_acknowledged(principle_id: id, member_ids: members.map { it.member.id },
107
+ file: @audit_records.file(id)),
108
+ [all_accepted(several, members, submitted.response)]]
128
109
  end
129
110
 
130
- # The commits the request names: the baseline's, HEAD, and the audit's base when the baseline is later (#550).
131
- #: (Models::Acknowledgement, Models::Placement, String?) -> Hash[String, String]
132
- def commits(acknowledgement, baseline, base)
133
- audit_base = acknowledgement.audit_base(baseline)
134
- { "baseline" => baseline.commit, "base" => base.to_s, **(audit_base ? { "audit_base" => audit_base } : {}) }
111
+ # The members the answer acknowledges, refused as stale unless their request is still the one it answers.
112
+ #: (Models::SubmittedAnswer) -> [Models::Acknowledgements, Array[MemberAcknowledgement]]
113
+ def answering_several(submitted)
114
+ id = submitted.request_id.principle_id
115
+ members = submitted.response.fetch("basis").fetch("member_ids").map { of(id, it) }
116
+ several = several_of(id, members)
117
+ stale(id, members.map { it.member.id }) unless several.request_id == submitted.request_id
118
+ [several, members]
135
119
  end
136
120
 
137
- # The member's baseline, the oldest commit from the one it was last judged at that holds the text the audit
138
- # record vouches for, placed as that commit's map placed it or as it is placed now (#547, #550), and its own
139
- # lines there and now, which the answer's quotes are checked against (#379).
140
- #: (String, Models::Acknowledgement, Models::Member) -> [Models::Placement, Models::MemberLines]
141
- def since_baseline(id, acknowledgement, member)
142
- placements = principle_history(id).placements_since(acknowledgement.last_judged_commit, member.key,
143
- @principles.find(id).member(member.id))
144
- baseline = acknowledgement.baseline(placements)
145
- lines = @project.member_lines(member.locator, since: baseline.commit, then_locator: baseline.locator)
146
- [baseline, acknowledgement.compared(lines)]
121
+ # The record with each member's acknowledgement in it, once the answer holds for every one of them.
122
+ #: (Models::Acknowledgements, Array[MemberAcknowledgement], untyped) -> Models::AuditRecord
123
+ def all_accepted(several, members, response)
124
+ at = Time.now.utc.iso8601
125
+ by_id = members.to_h { [it.member.id, it] }
126
+ acknowledging = by_id.keys
127
+ several.accepted(response) do |member_id, entry, into|
128
+ by_id.fetch(member_id).accepted(entry, at:, acknowledging:, into:)
129
+ end
147
130
  end
148
131
 
149
- #: (String, String) -> [Models::Acknowledgement, Models::Member, String?]
150
- def prepared(id, member_id)
151
- member = Models::Member.new(@principles.find(id).member(member_id))
152
- base = @history.base_commit(id, [@principles.file(id), member.path])
153
- now = @project.locate(member.locator).fetch("sha256")
154
- [Models::Acknowledgement.new(principle_id: id, member: member, record: @audit_records.find(id), base: base,
155
- now_sha256: now), member, base]
132
+ # The acknowledgements of several of principle id's members, each under its member's id, in one request.
133
+ #: (String, Array[MemberAcknowledgement]) -> Models::Acknowledgements
134
+ def several_of(id, members)
135
+ named = members.map { [it.member.id, it.acknowledgement.request_id] }
136
+ Models::Acknowledgements.of(principle_id: id, members: named)
156
137
  end
157
138
 
158
- #: (String, String) -> bot
159
- def stale(id, member_id)
139
+ # principle_id's member member_id, as its one-member audit asks and answers it.
140
+ #: (String, String) -> MemberAcknowledgement
141
+ def of(id, member_id) = handed(MemberAcknowledgement, principle_id: id, member_id:)
142
+
143
+ # Refuses an answer to a request that no longer matches the project, naming the request for the same members.
144
+ #: (String, String | Array[String]) -> bot
145
+ def stale(id, member_ids)
146
+ options = Array(member_ids).flat_map { ["--member", it] }
160
147
  raise Error.new("stale_request", "This request no longer matches #{id}: the member, its baseline or the " \
161
148
  "commit it was based on has changed since it was printed",
162
149
  "Start it again and answer the new request: " \
163
- "#{invocation.in_project("start-audit", id, options: ["--member", member_id])}")
150
+ "#{invocation.in_project("start-audit", id, options:)}")
164
151
  end
165
152
 
166
153
  #: () -> Views::AcknowledgementResult
@@ -21,14 +21,14 @@ module Principles
21
21
  # The controller that answers for each phase a request id may name.
22
22
  PHASE_CONTROLLERS = {
23
23
  "assessment" => Assessment, "correction" => Correction, "acknowledgement" => Acknowledgement,
24
- "repointing" => Repoint
24
+ "acknowledgements" => Acknowledgement, "repointing" => Repoint
25
25
  }.freeze #: Hash[String, Class[AnswerPhase]]
26
26
 
27
27
  #: (String, String?, Hash[String, untyped]) -> untyped
28
28
  def call(command, _id, options)
29
29
  naming_the_executable do
30
30
  case command
31
- when "submit-answer" then submit_answer(submitted(options))
31
+ when "submit-answer" then submit_answer(submitted(options), options.fetch("file"))
32
32
  when "show-answer-check" then check_answer(submitted(options), options.fetch("file"))
33
33
  else unknown(command)
34
34
  end
@@ -37,13 +37,14 @@ module Principles
37
37
 
38
38
  private
39
39
 
40
- # The answer from --file, where - means it was read from stdin, to the request REQUEST_ID names, checked against
41
- # the schema for the phase that id names once its head says it answers a request that still matches the project,
42
- # with the prior findings a full audit's request listed, which checking its head found (#1052).
40
+ # The answer from --file, where - means it was read from stdin, to the request REQUEST_ID names, or the answer's
41
+ # own request_id when none is given (#995), checked against the schema for the phase that id names once its head
42
+ # says it answers a request that still matches the project, with the prior findings a full audit's request
43
+ # listed, which checking its head found (#1052).
43
44
  #: (Hash[String, untyped]) -> Models::SubmittedAnswer
44
45
  def submitted(options)
45
- request_id = Models::RequestId.parse(options.fetch("request_id"))
46
- sent = @project.answer(options.fetch("file"), stdin: options["stdin"], phase: request_id.phase)
46
+ sent = @project.answer(options.fetch("file"), stdin: options["stdin"], given: options["request_id"])
47
+ request_id = sent.request_id
47
48
  prior = checked_head(request_id, sent.head)
48
49
  Models::SubmittedAnswer.new(request_id, sent.checked(phase(request_id).before_shape(request_id)), prior)
49
50
  end
@@ -59,11 +60,12 @@ module Principles
59
60
  end
60
61
 
61
62
  # Accepts the answer and writes the record changes it makes.
62
- #: (Models::SubmittedAnswer) -> untyped
63
- def submit_answer(submitted)
63
+ #: (Models::SubmittedAnswer, String) -> untyped
64
+ def submit_answer(submitted, answer_file)
64
65
  output, changes = judged(submitted)
65
66
  wrote = changes.map { |record| @audit_records.save(record) }
66
- audit_result.present(output).merge("wrote" => wrote)
67
+ audit_result.present(output, source_request_id: submitted.request_id.to_s,
68
+ answer_file: answer_file).merge("wrote" => wrote)
67
69
  end
68
70
 
69
71
  # Runs every check submit-answer would, and says what it would write, writing nothing; its submit command
@@ -72,7 +74,8 @@ module Principles
72
74
  #: (Models::SubmittedAnswer, String) -> untyped
73
75
  def check_answer(submitted, answer_file)
74
76
  output, changes = judged(submitted)
75
- audit_result.with_correction_to_fill(acceptable(submitted, answer_file, changes), output).merge("wrote" => [])
77
+ audit_result.with_correction_to_fill(acceptable(submitted, answer_file, changes), output,
78
+ answer_file: answer_file).merge("wrote" => [])
76
79
  end
77
80
 
78
81
  # The answer passed every check: what submitting it would write, and its submit command.
@@ -7,6 +7,7 @@ require_relative "../models/assessment_left_as_printed"
7
7
  require_relative "../models/audit"
8
8
  require_relative "../models/request_id"
9
9
  require_relative "../models/unchecked_members"
10
+ require_relative "../models/uncommitted_files"
10
11
  require_relative "audit_completion"
11
12
  require_relative "full_audit_request"
12
13
 
@@ -40,8 +41,11 @@ module Principles
40
41
  def checked_request(request_id, head)
41
42
  audit = audit_now(request_id.principle_id)
42
43
  basis = Models::AssessmentBasis.new(head.fetch("basis"))
43
- audit.check_assessment_request(request_id, basis: basis, committed: committed(basis.base, audit.map),
44
- record: @audit_records.find(audit.id), loads: loads_to_check(audit))
44
+ prior = audit.check_assessment_request(request_id, basis: basis, committed: committed(basis.base, audit.map),
45
+ record: @audit_records.find(audit.id),
46
+ loads: loads_to_check(audit))
47
+ principle_history(audit.id).confirm_current_id_since(basis.base)
48
+ prior
45
49
  end
46
50
 
47
51
  # The refusals an answer meets before its shape: first a check_result on a member with no check, which the
@@ -59,7 +63,14 @@ module Principles
59
63
 
60
64
  # The placeholders a full audit's template printed, as start-audit --as template prints it now (#1084).
61
65
  #: (Models::RequestId) -> Hash[String, untyped]?
62
- def printed_placeholders(request_id) = handed(FullAuditRequest, principle_id: request_id.principle_id).to_fill
66
+ def printed_placeholders(request_id)
67
+ handed(FullAuditRequest, principle_id: request_id.principle_id).to_fill
68
+ rescue Error => e
69
+ # Template construction keeps the start guard, but this caller already has an answer to retry.
70
+ raise unless e.payload.fetch("code") == "uncommitted_files"
71
+
72
+ raise e.including("repair" => Models::UncommittedFiles::ASSESSMENT_REPAIR)
73
+ end
63
74
 
64
75
  # The assessment's fields and its decisions on the prior findings checked, then the audit completed or its
65
76
  # correction asked for.
@@ -89,15 +100,18 @@ module Principles
89
100
  correction_request(start, audit, findings, decided, assessed)
90
101
  end
91
102
 
92
- # The correction request for findings, and outside git the open record that keeps what the audit began from.
103
+ # The correction request for findings, and the open record that keeps the assessment, whose digest its basis
104
+ # carries in place of the assessment, so the correction reads it back from the record (D87).
93
105
  # It is refused before it is printed once the last completed record changed, so no fix is made for an audit
94
- # that cannot complete (D50). The check results travel in the basis, so the completed record keeps them (D30).
106
+ # that cannot complete (D50). The check results travel in the record, so the completed record keeps them (D30).
95
107
  #: (Models::AuditStart, Models::Audit, Array[untyped], Models::DecidedPriorFindings, Models::AssessmentBasis)
96
108
  #| -> [untyped, Array[Models::AuditRecord]]
97
109
  def correction_request(start, audit, findings, decided, assessed)
98
110
  assessed.printed_after.confirm_unchanged(audit.id, @audit_records.find(audit.id))
99
- basis = printed_basis(start, findings, decided, assessed)
100
- [request_to_correct(basis, audit, findings), open_record_changes(start, audit, basis.to_h)]
111
+ record = open_record(start, audit, findings)
112
+ basis = Models::CorrectionBasis.printed(start, findings: findings, prior: decided, revision: assessed.revision,
113
+ open_record: record)
114
+ [request_to_correct(basis, audit, findings), @audit_records.changes(record)]
101
115
  end
102
116
 
103
117
  # The correction request for findings, answered under an id that digests its basis and the members now.
@@ -108,24 +122,13 @@ module Principles
108
122
  placeholders: Models::Disposition::TEMPLATE_PLACEHOLDERS)
109
123
  end
110
124
 
111
- # The basis a correction request prints, for the agent to hand back with its answer.
112
- # Its revision is the one the assessment was printed after, carried forward, so the correction is refused once
113
- # that record changes (#646, D50).
114
- #: (Models::AuditStart, Array[untyped], Models::DecidedPriorFindings, Models::AssessmentBasis)
115
- #| -> Models::CorrectionBasis
116
- def printed_basis(start, findings, decided, assessed)
117
- Models::CorrectionBasis.printed(start, findings: findings, prior: decided, revision: assessed.revision)
118
- end
119
-
120
- # Outside git, the open record that keeps what the audit began from, and the last completed record, so a
121
- # restarted audit still lists its prior findings (D35); in git, nothing.
122
- #: (Models::AuditStart, Models::Audit, Hash[String, untyped]) -> Array[Models::AuditRecord]
123
- def open_record_changes(start, audit, basis)
124
- return [] if start.base
125
-
125
+ # The open record that keeps the assessment, and outside git what the audit began from, and the last completed
126
+ # record, so a restarted audit still lists its prior findings (D35), in git as outside it (D87).
127
+ #: (Models::AuditStart, Models::Audit, Array[untyped]) -> Models::AuditRecord
128
+ def open_record(start, audit, findings)
126
129
  last = @audit_records.find(audit.id)&.last_completed
127
- record = handed(AuditCompletion).record(start, basis.fetch("findings"), "open", audit.now, last)
128
- @audit_records.changes(record)
130
+ raised = findings.map { |finding| finding.slice(*Models::RecordedFinding::RAISED_FIELDS) }
131
+ handed(AuditCompletion).record(start, raised, "open", audit.now, last)
129
132
  end
130
133
  end
131
134
  end