principles 0.0.7 → 0.0.8

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 (331) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +383 -0
  3. data/LICENSE +202 -0
  4. data/NOTICE +4 -0
  5. data/README.md +111 -0
  6. data/exe/principles +20 -0
  7. data/lib/principles/after_commit_hook_options.rb +2 -2
  8. data/lib/principles/cli.rb +50 -42
  9. data/lib/principles/command_line.rb +22 -16
  10. data/lib/principles/command_routes.rb +20 -6
  11. data/lib/principles/controllers/acknowledgement.rb +29 -74
  12. data/lib/principles/controllers/acknowledgements.rb +154 -0
  13. data/lib/principles/controllers/after_commit_report.rb +44 -0
  14. data/lib/principles/controllers/answer.rb +48 -18
  15. data/lib/principles/controllers/answer_phase.rb +20 -3
  16. data/lib/principles/controllers/assessment.rb +32 -11
  17. data/lib/principles/controllers/audit.rb +43 -19
  18. data/lib/principles/controllers/audit_completion.rb +21 -12
  19. data/lib/principles/controllers/command.rb +13 -12
  20. data/lib/principles/controllers/correction.rb +15 -7
  21. data/lib/principles/controllers/first_audit_brief.rb +40 -0
  22. data/lib/principles/controllers/full_audit_request.rb +41 -82
  23. data/lib/principles/controllers/hook_setup.rb +49 -0
  24. data/lib/principles/controllers/inventory.rb +10 -8
  25. data/lib/principles/controllers/mapping.rb +2 -2
  26. data/lib/principles/controllers/member_acknowledgement.rb +32 -21
  27. data/lib/principles/controllers/member_entries.rb +4 -4
  28. data/lib/principles/controllers/member_problems_report.rb +62 -16
  29. data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
  30. data/lib/principles/controllers/members_to_assess.rb +23 -20
  31. data/lib/principles/controllers/meta_principle_setup.rb +5 -6
  32. data/lib/principles/controllers/open_correction.rb +42 -0
  33. data/lib/principles/controllers/parts_to_read.rb +117 -0
  34. data/lib/principles/controllers/repoint.rb +1 -1
  35. data/lib/principles/controllers/running_tool.rb +56 -6
  36. data/lib/principles/controllers/session_start_report.rb +62 -0
  37. data/lib/principles/controllers/survey.rb +2 -2
  38. data/lib/principles/data/audit_files.rb +7 -7
  39. data/lib/principles/data/bounded_file.rb +1 -1
  40. data/lib/principles/data/candidate_files_found.rb +6 -3
  41. data/lib/principles/data/command-steps.json +61 -6
  42. data/lib/principles/data/expected_type.rb +3 -3
  43. data/lib/principles/data/first_parent_log.rb +1 -1
  44. data/lib/principles/data/head_reflog.rb +74 -0
  45. data/lib/principles/data/hook_input.rb +59 -0
  46. data/lib/principles/data/ignored_by_git.rb +2 -2
  47. data/lib/principles/data/known_fields.rb +1 -1
  48. data/lib/principles/data/linked_path.rb +1 -1
  49. data/lib/principles/data/map_files.rb +2 -2
  50. data/lib/principles/data/principles_on_path.rb +83 -0
  51. data/lib/principles/data/principles_subfolder.rb +1 -1
  52. data/lib/principles/data/project_files.rb +10 -3
  53. data/lib/principles/data/repository.rb +14 -7
  54. data/lib/principles/data/running_version.rb +10 -8
  55. data/lib/principles/data/schema_check.rb +5 -5
  56. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -21
  57. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
  58. data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
  59. data/lib/principles/data/schemas/audit-record.schema.json +29 -20
  60. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  61. data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
  62. data/lib/principles/data/schemas/correction-answer.schema.json +9 -9
  63. data/lib/principles/data/schemas/member-map.schema.json +3 -3
  64. data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
  65. data/lib/principles/error.rb +4 -4
  66. data/lib/principles/failure_refusal.rb +57 -0
  67. data/lib/principles/invocation_options.rb +4 -4
  68. data/lib/principles/launch.rb +49 -0
  69. data/lib/principles/list_open_findings_options.rb +1 -1
  70. data/lib/principles/models/accepted_loading.rb +2 -2
  71. data/lib/principles/models/acknowledged_check.rb +23 -11
  72. data/lib/principles/models/acknowledgement.rb +34 -18
  73. data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
  74. data/lib/principles/models/acknowledgement_refusal.rb +25 -10
  75. data/lib/principles/models/acknowledgements.rb +45 -29
  76. data/lib/principles/models/acknowledgements_across.rb +68 -0
  77. data/lib/principles/models/activation.rb +2 -2
  78. data/lib/principles/models/after_commit_input.rb +115 -0
  79. data/lib/principles/models/agent_loads.rb +1 -1
  80. data/lib/principles/models/answer_fields.rb +2 -2
  81. data/lib/principles/models/answer_place.rb +3 -3
  82. data/lib/principles/models/answer_text.rb +2 -2
  83. data/lib/principles/models/answered_time.rb +4 -4
  84. data/lib/principles/models/assessment_answer.rb +10 -10
  85. data/lib/principles/models/assessment_basis.rb +2 -2
  86. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  87. data/lib/principles/models/assessment_report.rb +6 -7
  88. data/lib/principles/models/audit.rb +33 -34
  89. data/lib/principles/models/audit_record.rb +54 -28
  90. data/lib/principles/models/audit_records.rb +13 -13
  91. data/lib/principles/models/audit_start.rb +3 -3
  92. data/lib/principles/models/audited_member_lines.rb +1 -1
  93. data/lib/principles/models/candidate_files.rb +18 -10
  94. data/lib/principles/models/candidate_inventory.rb +6 -6
  95. data/lib/principles/models/candidate_outline.rb +9 -9
  96. data/lib/principles/models/carried_assessments.rb +18 -3
  97. data/lib/principles/models/carried_member.rb +5 -5
  98. data/lib/principles/models/changed_regions.rb +92 -0
  99. data/lib/principles/models/check_result_guide.rb +50 -0
  100. data/lib/principles/models/check_since_last_audit.rb +5 -4
  101. data/lib/principles/models/cited_files.rb +4 -4
  102. data/lib/principles/models/command_steps.rb +3 -3
  103. data/lib/principles/models/commits_brought_in.rb +1 -1
  104. data/lib/principles/models/commits_since_base.rb +1 -1
  105. data/lib/principles/models/correction_answer.rb +2 -2
  106. data/lib/principles/models/correction_basis.rb +7 -7
  107. data/lib/principles/models/dated_line.rb +1 -2
  108. data/lib/principles/models/decided_prior_findings.rb +6 -6
  109. data/lib/principles/models/declared_map_changes.rb +5 -5
  110. data/lib/principles/models/disposition.rb +21 -21
  111. data/lib/principles/models/entry_file.rb +1 -1
  112. data/lib/principles/models/entry_files.rb +1 -1
  113. data/lib/principles/models/evidence_item.rb +1 -1
  114. data/lib/principles/models/evidence_lines_since.rb +2 -2
  115. data/lib/principles/models/evidence_replacements.rb +3 -3
  116. data/lib/principles/models/finding_write_ups.rb +12 -5
  117. data/lib/principles/models/findings_left_open.rb +4 -4
  118. data/lib/principles/models/first_full_audit.rb +32 -0
  119. data/lib/principles/models/first_raised_claim.rb +1 -1
  120. data/lib/principles/models/fix_only_fields.rb +1 -1
  121. data/lib/principles/models/head_moves.rb +66 -0
  122. data/lib/principles/models/hook_commands.rb +49 -4
  123. data/lib/principles/models/ignored_candidates.rb +1 -1
  124. data/lib/principles/models/instruction_named.rb +2 -3
  125. data/lib/principles/models/json_digest.rb +2 -2
  126. data/lib/principles/models/json_path_query.rb +1 -1
  127. data/lib/principles/models/kept_prior_finding.rb +9 -9
  128. data/lib/principles/models/last_completed_revision.rb +4 -5
  129. data/lib/principles/models/left_as_printed.rb +2 -2
  130. data/lib/principles/models/line_diff.rb +113 -0
  131. data/lib/principles/models/line_span.rb +1 -1
  132. data/lib/principles/models/list_member_problems_check.rb +4 -4
  133. data/lib/principles/models/listed_members.rb +7 -9
  134. data/lib/principles/models/loaded_files.rb +4 -5
  135. data/lib/principles/models/loading_decision.rb +3 -3
  136. data/lib/principles/models/loading_facts.rb +1 -1
  137. data/lib/principles/models/loads_to_check.rb +1 -1
  138. data/lib/principles/models/located_text.rb +1 -1
  139. data/lib/principles/models/mapped_principles.rb +2 -2
  140. data/lib/principles/models/member.rb +31 -4
  141. data/lib/principles/models/member_assessments.rb +8 -8
  142. data/lib/principles/models/member_elsewhere.rb +4 -4
  143. data/lib/principles/models/member_file.rb +4 -4
  144. data/lib/principles/models/member_grounds.rb +1 -1
  145. data/lib/principles/models/member_hashes_as_written.rb +1 -1
  146. data/lib/principles/models/member_lines.rb +29 -61
  147. data/lib/principles/models/member_loads.rb +2 -2
  148. data/lib/principles/models/member_moves.rb +1 -1
  149. data/lib/principles/models/member_problems.rb +14 -15
  150. data/lib/principles/models/member_repair_moves.rb +15 -9
  151. data/lib/principles/models/member_sighting.rb +10 -10
  152. data/lib/principles/models/member_snapshots.rb +1 -1
  153. data/lib/principles/models/member_state.rb +1 -1
  154. data/lib/principles/models/members_across_principles.rb +77 -0
  155. data/lib/principles/models/members_elsewhere.rb +2 -2
  156. data/lib/principles/models/members_sharing_lines.rb +7 -7
  157. data/lib/principles/models/meta_principle.rb +11 -4
  158. data/lib/principles/models/missing_files.rb +3 -3
  159. data/lib/principles/models/new_findings.rb +4 -4
  160. data/lib/principles/models/open_correction.rb +57 -0
  161. data/lib/principles/models/open_finding.rb +36 -31
  162. data/lib/principles/models/open_findings_elsewhere.rb +2 -2
  163. data/lib/principles/models/other_principles.rb +2 -2
  164. data/lib/principles/models/other_templates_placeholders.rb +17 -16
  165. data/lib/principles/models/outline_budget.rb +7 -7
  166. data/lib/principles/models/outline_group.rb +1 -1
  167. data/lib/principles/models/outline_section.rb +2 -2
  168. data/lib/principles/models/part_named.rb +41 -0
  169. data/lib/principles/models/placement.rb +2 -2
  170. data/lib/principles/models/principle.rb +13 -13
  171. data/lib/principles/models/principle_history.rb +8 -8
  172. data/lib/principles/models/principle_members.rb +14 -7
  173. data/lib/principles/models/principles_folder_move.rb +1 -1
  174. data/lib/principles/models/principles_on_path.rb +29 -0
  175. data/lib/principles/models/principles_package.rb +3 -3
  176. data/lib/principles/models/prior_decision_fields.rb +8 -8
  177. data/lib/principles/models/prior_finding_decision.rb +8 -8
  178. data/lib/principles/models/prior_finding_outcomes.rb +1 -1
  179. data/lib/principles/models/prior_findings.rb +5 -5
  180. data/lib/principles/models/problem_report.rb +26 -8
  181. data/lib/principles/models/project.rb +27 -19
  182. data/lib/principles/models/project_history.rb +18 -12
  183. data/lib/principles/models/quoted_change.rb +8 -8
  184. data/lib/principles/models/recent_decision.rb +3 -3
  185. data/lib/principles/models/record_format.rb +16 -10
  186. data/lib/principles/models/record_judged_against.rb +4 -4
  187. data/lib/principles/models/recorded_entry.rb +17 -8
  188. data/lib/principles/models/recorded_finding.rb +9 -9
  189. data/lib/principles/models/recorded_findings.rb +2 -2
  190. data/lib/principles/models/recorded_hashes.rb +2 -2
  191. data/lib/principles/models/recorded_members.rb +13 -13
  192. data/lib/principles/models/refusal_before_shape.rb +2 -2
  193. data/lib/principles/models/repoint.rb +3 -3
  194. data/lib/principles/models/report_hooks.rb +69 -0
  195. data/lib/principles/models/reported_check.rb +34 -31
  196. data/lib/principles/models/request_id.rb +18 -6
  197. data/lib/principles/models/runs_from.rb +7 -2
  198. data/lib/principles/models/sent_answer.rb +14 -12
  199. data/lib/principles/models/sent_prior_decisions.rb +1 -1
  200. data/lib/principles/models/session_start_input.rb +37 -0
  201. data/lib/principles/models/shape_problems_beside.rb +1 -1
  202. data/lib/principles/models/skill_loads.rb +1 -1
  203. data/lib/principles/models/stale_request.rb +59 -0
  204. data/lib/principles/models/still_holds_restatement.rb +6 -6
  205. data/lib/principles/models/submitted_answer.rb +1 -1
  206. data/lib/principles/models/template_placeholders.rb +6 -6
  207. data/lib/principles/models/text_within.rb +1 -1
  208. data/lib/principles/models/tracked_paths.rb +38 -0
  209. data/lib/principles/models/unchecked_members.rb +2 -2
  210. data/lib/principles/models/uncommitted_files.rb +1 -1
  211. data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
  212. data/lib/principles/models/waits_on.rb +1 -1
  213. data/lib/principles/models/write_up_opening.rb +5 -5
  214. data/lib/principles/models/write_up_pointer.rb +3 -3
  215. data/lib/principles/models/write_up_repoint.rb +2 -3
  216. data/lib/principles/positional_arguments.rb +13 -6
  217. data/lib/principles/prose_list.rb +1 -1
  218. data/lib/principles/session_start_options.rb +1 -1
  219. data/lib/principles/start_audit_options.rb +46 -12
  220. data/lib/principles/supported_ruby.rb +24 -7
  221. data/lib/principles/version.rb +2 -2
  222. data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
  223. data/lib/principles/views/acknowledgement_result.rb +97 -11
  224. data/lib/principles/views/activation_in_hand.rb +1 -1
  225. data/lib/principles/views/answered_request.rb +6 -2
  226. data/lib/principles/views/assessed_members.rb +50 -41
  227. data/lib/principles/views/assessment_request.rb +39 -36
  228. data/lib/principles/views/audit_changes.rb +4 -4
  229. data/lib/principles/views/audit_commit.rb +5 -4
  230. data/lib/principles/views/audit_result.rb +92 -53
  231. data/lib/principles/views/candidate_files_result.rb +7 -6
  232. data/lib/principles/views/check_notes.rb +29 -6
  233. data/lib/principles/views/check_result_template.rb +45 -34
  234. data/lib/principles/views/completed_audit_next_step.rb +44 -0
  235. data/lib/principles/views/context_parts.rb +112 -0
  236. data/lib/principles/views/correction_request.rb +44 -25
  237. data/lib/principles/views/diff_since_last_audit.rb +8 -6
  238. data/lib/principles/views/findings_result.rb +17 -6
  239. data/lib/principles/views/first_audit_brief.rb +51 -0
  240. data/lib/principles/views/first_audit_line.rb +45 -0
  241. data/lib/principles/views/help.rb +4 -4
  242. data/lib/principles/views/hook_setup_result.rb +91 -0
  243. data/lib/principles/views/instruction.rb +3 -3
  244. data/lib/principles/views/invocation.rb +14 -6
  245. data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
  246. data/lib/principles/views/landed_since_base.rb +1 -1
  247. data/lib/principles/views/line_history_since_last_audit.rb +35 -0
  248. data/lib/principles/views/lines_shared_with_member.rb +6 -6
  249. data/lib/principles/views/loads_to_check_result.rb +8 -5
  250. data/lib/principles/views/map_added_to.rb +3 -3
  251. data/lib/principles/views/map_result.rb +9 -9
  252. data/lib/principles/views/member_change_since_baseline.rb +44 -23
  253. data/lib/principles/views/member_lines_beside_text.rb +43 -0
  254. data/lib/principles/views/member_repairs.rb +3 -2
  255. data/lib/principles/views/member_row.rb +2 -2
  256. data/lib/principles/views/members_a_commit_changed.rb +13 -10
  257. data/lib/principles/views/members_with_no_baseline.rb +3 -3
  258. data/lib/principles/views/meta_principle_passage.rb +1 -1
  259. data/lib/principles/views/meta_principle_result.rb +12 -5
  260. data/lib/principles/views/one_member_check_result_template.rb +7 -7
  261. data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
  262. data/lib/principles/views/open_findings_line.rb +25 -36
  263. data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
  264. data/lib/principles/views/outside_the_map_result.rb +5 -2
  265. data/lib/principles/views/package_since_last_audit_result.rb +29 -6
  266. data/lib/principles/views/parts_index_result.rb +60 -0
  267. data/lib/principles/views/principle_read_result.rb +5 -6
  268. data/lib/principles/views/principle_with_changed_members.rb +1 -1
  269. data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
  270. data/lib/principles/views/printed_json.rb +51 -0
  271. data/lib/principles/views/printed_principle.rb +1 -1
  272. data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
  273. data/lib/principles/views/prior_findings_result.rb +17 -14
  274. data/lib/principles/views/problem_lines.rb +39 -17
  275. data/lib/principles/views/problem_result.rb +40 -37
  276. data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
  277. data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
  278. data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
  279. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
  280. data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
  281. data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
  282. data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
  283. data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
  284. data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
  285. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
  286. data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
  287. data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
  288. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
  289. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
  290. data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
  291. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  292. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
  293. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
  294. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
  295. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
  296. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
  297. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
  298. data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
  299. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
  300. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +20 -18
  301. data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
  302. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
  303. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
  304. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
  305. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +21 -22
  306. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
  307. data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
  308. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
  309. data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
  310. data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
  311. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
  312. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -1
  313. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
  314. data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
  315. data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
  316. data/lib/principles/views/prompts.rb +1 -1
  317. data/lib/principles/views/read_the_change.rb +36 -0
  318. data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
  319. data/lib/principles/views/repoint_result.rb +1 -1
  320. data/lib/principles/views/report_hooks_offer.rb +25 -0
  321. data/lib/principles/views/request_part.rb +5 -5
  322. data/lib/principles/views/request_parts.rb +1 -1
  323. data/lib/principles/views/session_start_report.rb +46 -0
  324. data/lib/principles/views/shell_word.rb +1 -1
  325. data/lib/principles/views/trimmed_instructions_note.rb +30 -0
  326. data/lib/principles/views/visible_text.rb +1 -1
  327. data/lib/principles/views/workflow_diagram.rb +1 -1
  328. data/principles.gemspec +44 -0
  329. metadata +83 -14
  330. data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
  331. data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
@@ -7,7 +7,7 @@ module Principles
7
7
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
8
8
  module Views
9
9
  # The members an assessment request lists, each a plain entry of id, role, first_line, last_line, the evidence
10
- # that locates it and, for a member with a check, the check whose result the template asks for (D30): what the
10
+ # that locates it and, for a member with a check, the check whose result the template asks for: what the
11
11
  # request shows of each, the template entry each starts with, and what they carry that the request explains.
12
12
  class AssessedMembers
13
13
  # What the request shows of each member.
@@ -16,25 +16,20 @@ module Principles
16
16
  mapped_elsewhere].freeze #: Array[String]
17
17
 
18
18
  # reviewed_check_placeholders is the text a checked member's template prints in each field it may leave as
19
- # printed to give none, for a check reviewed before it runs (#993); unchanged_check_placeholders, for one the
20
- # last audit ran (#1010).
21
- # assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back
22
- # (#991). sighting_placeholders is the text the template printed alone gives observation and observed_at beside
23
- # delivery, which a delivery not observed leaves as printed (#1010).
19
+ # printed to give none, for a check reviewed before it runs; unchanged_check_placeholders, for one the
20
+ # last audit ran.
21
+ # assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back.
24
22
  #: (Array[Hash[String, untyped]], reviewed_check_placeholders: Hash[String, String],
25
- #| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String,
26
- #| sighting_placeholders: Hash[String, String]) -> void
27
- def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:,
28
- sighting_placeholders:)
23
+ #| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String) -> void
24
+ def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:)
29
25
  @assessment_placeholder = assessment_placeholder
30
- @sighting_placeholders = sighting_placeholders
31
26
  @members = members
32
27
  @reviewed_check_placeholders = reviewed_check_placeholders
33
28
  @unchanged_check_placeholders = unchanged_check_placeholders
34
29
  freeze
35
30
  end
36
31
 
37
- # What the request shows of a carried member no flag fires on (D93): what names it and its check, whose result
32
+ # What the request shows of a carried member no flag fires on: what names it and its check, whose result
38
33
  # the template still asks for, and of its carried assessment only its dates and flags.
39
34
  COMPACT = %w[id role check check_since_last_audit check_hidden_characters carried_forward].freeze #: Array[String]
40
35
  # What a compact member shows of its carried assessment.
@@ -42,7 +37,7 @@ module Principles
42
37
  file_changed_outside_member].freeze #: Array[String]
43
38
 
44
39
  # Each member as the request's context shows it, its fields in SHOWN's order; a carried member no flag fires on
45
- # compactly, as COMPACT and CARRIED_COMPACTLY say, its stored assessment one show-audit away (D93).
40
+ # compactly, as COMPACT and CARRIED_COMPACTLY say, its stored assessment one show-audit away.
46
41
  #: () -> Array[Hash[String, untyped]]
47
42
  def shown
48
43
  @members.map do |member|
@@ -53,62 +48,75 @@ module Principles
53
48
  end
54
49
  end
55
50
 
56
- # How to run and report each checked member's check, by id, as the template printed alone gives it beside the
57
- # members, since it has no context to show it in (#1024, #1191).
58
- #: () -> Hash[String, String]
59
- def check_instructions
60
- @members.to_h { [it.fetch("id"), check_template(it)&.instruction] }.compact
51
+ # What the template printed alone says of the checks before its members, since it has no context to show it in:
52
+ # the carried members whose template entry in templates still asks for a check_result, under
53
+ # carried_checks_to_run, named before the members so a reader skipping carried markers still runs each, and how
54
+ # to run and report the checks of each standing under shared_check_instructions, and each checked member's own
55
+ # lines by id under check_instructions; each only when it lists any.
56
+ #: (Array[Hash[String, untyped]]) -> Hash[String, untyped]
57
+ def checks_to_fill(templates)
58
+ carried = carried_checked(templates)
59
+ instructions = @members.to_h { [it.fetch("id"), check_template(it)&.own_instruction] }.compact
60
+ { "carried_checks_to_run" => carried, **shared_check_instructions, "check_instructions" => instructions }
61
+ .reject { _2.empty? }
61
62
  end
62
63
 
63
- # Each member's template entry: a fresh assessment to fill in, or, for a member whose last assessment is
64
- # carried forward, the marker that keeps it (D49); either with its check's result when it has a check.
65
- #: () -> Array[Hash[String, untyped]]
66
- def templates = @members.map { |member| template(member) }
64
+ # The id of each carried member whose entry in templates still asks for a check_result.
65
+ #: (Array[Hash[String, untyped]]) -> Array[String]
66
+ def carried_checked(templates)
67
+ templates.select { it["carried_forward"] && it.key?("check_result") }.map { it.fetch("member_id") }
68
+ end
67
69
 
68
- # Each member's template entry as the template printed alone gives it: a fresh assessment also prints
69
- # observation and observed_at after delivery, so reporting a sighting fills them (#1010).
70
- #: () -> Array[Hash[String, untyped]]
71
- def templates_to_fill
72
- templates.map do |entry|
73
- next entry unless entry.key?("delivery")
70
+ # How to run and report the checks of each standing, once, with the ids of the members it is for, under
71
+ # shared_check_instructions, whose own lines check_instructions adds; nothing when none has a check.
72
+ #: () -> Hash[String, Array[Hash[String, untyped]]]
73
+ def shared_check_instructions
74
+ checks = @members.filter_map { |member| check_template(member)&.then { [member.fetch("id"), it] } }
75
+ return {} if checks.empty?
74
76
 
75
- entry.flat_map { |field, value| [[field, value], *(@sighting_placeholders if field == "delivery")] }.to_h
76
- end
77
+ { "shared_check_instructions" => checks.group_by { |_, template| template.status }.map do |_, grouped|
78
+ { "member_ids" => grouped.map(&:first), "instruction" => grouped.fetch(0).last.shared_instruction }
79
+ end }
77
80
  end
78
81
 
79
- # Whether any member has a check, whose result's shapes the answer guide then shows (D30).
82
+ # Each member's template entry: a fresh assessment to fill in, or, for a member whose last assessment is
83
+ # carried forward, the marker that keeps it; either with its check's result when it has a check.
84
+ #: () -> Array[Hash[String, untyped]]
85
+ def templates = @members.map { |member| template(member) }
86
+
87
+ # Whether any member has a check, whose result's shapes the answer guide then shows.
80
88
  #: () -> bool
81
89
  def checked? = @members.any? { |member| member["check"] }
82
90
 
83
- # Whether any member's check is new or changed, so no audit ran it as it is now, to review before it runs (D63).
91
+ # Whether any member's check is new or changed, so no audit ran it as it is now, to review before it runs.
84
92
  #: () -> bool
85
93
  def check_to_review?
86
94
  @members.any? { |member| member["check"] && member.dig("check_since_last_audit", "status") != "unchanged" }
87
95
  end
88
96
 
89
- # Whether the request carries any member's last assessment forward (D49).
97
+ # Whether the request carries any member's last assessment forward.
90
98
  #: () -> bool
91
99
  def carried_forward? = @members.any? { |member| member["carried_forward"] }
92
100
 
93
- # Whether any member is judged afresh, whose template then gives a delivery (#983).
101
+ # Whether any member is judged afresh, whose template then gives a delivery.
94
102
  #: () -> bool
95
103
  def judged_afresh? = @members.any? { |member| !member["carried_forward"] }
96
104
 
97
- # Whether a carried member no flag fires on prints compactly, with no assessment (D93).
105
+ # Whether a carried member no flag fires on prints compactly, with no assessment.
98
106
  #: () -> bool
99
107
  def carried_compactly? = @members.any? { |member| compact?(member) }
100
108
 
101
- # Each reason a member is judged afresh, once (D61).
109
+ # Each reason a member is judged afresh, once.
102
110
  #: () -> Array[String]
103
111
  def judge_because = @members.filter_map { |member| member["judge_because"] }.uniq
104
112
 
105
- # Each entry naming another principle's role for a member's lines (#719).
113
+ # Each entry naming another principle's role for a member's lines.
106
114
  #: () -> Array[Hash[String, untyped]]
107
115
  def mapped_elsewhere = shown.flat_map { |member| member["mapped_elsewhere"] || [] }
108
116
 
109
117
  private
110
118
 
111
- # Whether member is carried with no flag firing on it, so it prints compactly (D93).
119
+ # Whether member is carried with no flag firing on it, so it prints compactly.
112
120
  #: (Hash[String, untyped]) -> bool
113
121
  def compact?(member) = member["carried_forward"] && !member["flagged"]
114
122
 
@@ -130,11 +138,12 @@ module Principles
130
138
  unchanged_placeholders: @unchanged_check_placeholders)
131
139
  end
132
140
 
133
- # The member's check_instruction, as the request's context shows it beside the member; none without a check.
141
+ # The member's own check_instruction, as the request's context shows it beside the member; none without a check
142
+ # or without lines of its own beside shared_check_instructions.
134
143
  #: (Hash[String, untyped]) -> Hash[String, String]
135
144
  def instruction(member)
136
- template = check_template(member) or return {}
137
- { "check_instruction" => template.instruction }
145
+ own = check_template(member)&.own_instruction or return {}
146
+ { "check_instruction" => own }
138
147
  end
139
148
 
140
149
  #: (Hash[String, untyped]) -> Hash[String, untyped]
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative "answer_head"
5
5
  require_relative "assessed_members"
6
+ require_relative "context_parts"
6
7
  require_relative "instruction"
7
8
  require_relative "prompts"
8
9
  require_relative "request_parts"
@@ -19,11 +20,11 @@ module Principles
19
20
  "as copy_from says."
20
21
  }.freeze #: Hash[String, String]
21
22
  # How mapped_elsewhere_instruction's paragraph on open findings elsewhere begins, which prints only when an
22
- # entry names one (#808).
23
+ # entry names one.
23
24
  OPEN_FINDINGS_ELSEWHERE = "Where an entry names `open_finding_ids`" #: String
24
25
 
25
- # The question every member's assessment answers, which a completed record digests with the description (D49):
26
- # the whole question, what observed means too, however much of it a request prints (#983).
26
+ # The question every member's assessment answers, which a completed record digests with the description:
27
+ # the whole question, what observed means too, however much of it a request prints.
27
28
  #: () -> String
28
29
  def self.question = question_paragraphs.join(" ")
29
30
 
@@ -37,10 +38,10 @@ module Principles
37
38
  # principle is the principle_id and description it names. head is what the answer hands back unchanged: the
38
39
  # request's id and its basis, the base commit and the last completed record's revision. parts are what the
39
40
  # agent reads beside the members before the question, such as the files outside the map that differ from the
40
- # base commit (#409), each with any slots it adds to the template (D60). placeholders is what the answer's own
41
- # fields print, by field, which their models own: collective_assessment's, which an answer may not send back
42
- # (#991), and recent_decision's, each field of both its forms, in the template alone, which the agent fills one
43
- # of (#994).
41
+ # base commit, each with any slots it adds to the template. placeholders is what the answer's own
42
+ # fields print, by field, which their models own: collective_assessment's, which an answer may not send back,
43
+ # and recent_decision's, each field of both its forms, in the template alone, which the agent fills one
44
+ # of.
44
45
  #: (principle: Hash[String, untyped], members: AssessedMembers, head: AnswerHead,
45
46
  #| placeholders: Hash[String, untyped], ?parts: Array[RequestPart]) -> void
46
47
  def initialize(principle:, members:, head:, placeholders:, parts: [])
@@ -59,15 +60,23 @@ module Principles
59
60
  # What the agent assesses, its other parts, the question and a guide to the answer's shapes.
60
61
  #: () -> Hash[String, untyped]
61
62
  def context
62
- listed = @principle.merge("members" => @members.shown)
63
+ listed = @principle.merge("members" => @members.shown, **@members.shared_check_instructions)
63
64
  @parts.shown_after(listed).merge(asked)
64
65
  end
65
66
 
66
67
  # The fields the request prints an instruction under, in the order it prints them: the question, the answer
67
- # guide and each field named for an instruction (D81 step 2).
68
+ # guide and each field named for an instruction.
68
69
  #: () -> Array[String]
69
70
  def instruction_fields = printed_instructions.map(&:field)
70
71
 
72
+ # The parts of the context start-audit --part prints alone, each member's with its lines now, by id, from texts,
73
+ # and each instruction field and the answer to fill as the request prints them; optional names each part the
74
+ # context lists only when it holds something.
75
+ #: (?texts: Hash[String, Array[String]], ?optional: Array[String]) -> ContextParts
76
+ def context_parts(texts: {}, optional: [])
77
+ ContextParts.new(context, instruction_fields:, template:, texts:, optional:)
78
+ end
79
+
71
80
  # The principle the request audits.
72
81
  #: () -> String
73
82
  def principle_id = @principle.fetch("principle_id")
@@ -87,35 +96,29 @@ module Principles
87
96
  end
88
97
 
89
98
  # The answer to fill in as printed alone, with no request beside it: each placeholder says what its field
90
- # takes, and points at nothing left unprinted (D81 step 1), after one note saying how a field left as printed is
91
- # read (#1043, D88), and the carried members whose check it still asks to run, named before the members so a
92
- # reader skipping carried markers still runs each (D12, D19).
99
+ # takes, and points at nothing left unprinted, after one note saying how a field left as printed is
100
+ # read, and the carried members whose check it still asks to run, named before the members so a
101
+ # reader skipping carried markers still runs each.
93
102
  #: () -> Hash[String, untyped]
94
103
  def template_to_fill
95
- members = @members.templates_to_fill
104
+ members = @members.templates
96
105
  filled = assessed(@placeholders.fetch("recent_decision"), members)
97
106
  @head.leading(@parts.filled_after({ "left_as_printed_rule" => @placeholders.fetch("left_as_printed_rule"),
98
- **carried_checks_to_run(members), **check_instructions, **filled,
107
+ **@members.checks_to_fill(members), **filled,
99
108
  "findings" => [@placeholders.fetch("new_finding")] }))
100
109
  end
101
110
 
102
- private
111
+ # Whether a carried member's entry in the answer to fill prints a check_result slot to fill.
112
+ #: () -> bool
113
+ def carried_check_to_fill? = @members.carried_checked(@members.templates).any?
103
114
 
104
- # How to run and report each checked member's check, by its id, under check_instructions; nothing when no member
105
- # has a check (#1191).
106
- #: () -> Hash[String, untyped]
107
- def check_instructions
108
- instructions = @members.check_instructions
109
- instructions.empty? ? {} : { "check_instructions" => instructions }
115
+ # Each member's slot of the answer printed alone, as template_to_fill prints it, by its part name, members/ID.
116
+ #: () -> Hash[String, Hash[String, untyped]]
117
+ def slots_to_fill
118
+ @members.templates.to_h { ["#{ContextParts::MEMBER}#{it.fetch("member_id")}", it] }
110
119
  end
111
120
 
112
- # The ids of the carried members whose template entry asks for a check_result, under carried_checks_to_run,
113
- # or nothing when there are none.
114
- #: (Array[Hash[String, untyped]]) -> Hash[String, Array[String]]
115
- def carried_checks_to_run(members)
116
- ids = members.select { it["carried_forward"] && it.key?("check_result") }.map { it.fetch("member_id") }
117
- ids.empty? ? {} : { "carried_checks_to_run" => ids }
118
- end
121
+ private
119
122
 
120
123
  # The answer's fields after its head and before its parts' slots, recent_decision and the members' templates as
121
124
  # given.
@@ -142,7 +145,7 @@ module Principles
142
145
  carried_forward_instruction, mapped_elsewhere_instruction, answer_guide]
143
146
  end
144
147
 
145
- # The question, defining observed only when a member is judged afresh, whose delivery it guides (#983).
148
+ # The question, defining observed only when a member is judged afresh, whose delivery it guides.
146
149
  #: () -> Instruction
147
150
  def question
148
151
  assess, observed = AssessmentRequest.question_paragraphs
@@ -150,7 +153,7 @@ module Principles
150
153
  end
151
154
 
152
155
  # Why each member with judge_because is judged afresh, explaining only the values the members carry, so the
153
- # agent meets each value's meaning where it meets the value (D61); nothing when no member gives one.
156
+ # agent meets each value's meaning where it meets the value; nothing when no member gives one.
154
157
  #: () -> Instruction
155
158
  def judge_because_instruction
156
159
  reasons = @members.judge_because
@@ -161,8 +164,8 @@ module Principles
161
164
  end
162
165
 
163
166
  # How to judge the roles other principles give a member's lines, printed only when a member shares lines with
164
- # another principle's (#719, D61), and, when an entry names findings open on its member, where to read how to
165
- # treat them, which prints apart, before the question (#808).
167
+ # another principle's, and, when an entry names findings open on its member, where to read how to
168
+ # treat them, which prints apart, before the question.
166
169
  #: () -> Instruction
167
170
  def mapped_elsewhere_instruction
168
171
  entries = @members.mapped_elsewhere
@@ -174,9 +177,9 @@ module Principles
174
177
  end
175
178
 
176
179
  # The answer guide, showing check_result's fields only when a member has a check, so an audit
177
- # with no checks costs no more context than before (D30), and delivery's shapes only when a member is judged
178
- # afresh, since a carried member's marker gives none (#983). check_result's limits say how to review a check
179
- # before running it only when a check is new or changed, as that check's own template says too (#983).
180
+ # with no checks costs no more context than before, and delivery's shapes only when a member is judged
181
+ # afresh, since a carried member's marker gives none. check_result's limits say how to review a check
182
+ # before running it only when a check is new or changed, as that check's own template says too.
180
183
  #: () -> GuideInstruction
181
184
  def answer_guide
182
185
  guide = Prompts.data("assess-every-member/answer-guide")
@@ -199,7 +202,7 @@ module Principles
199
202
  end
200
203
 
201
204
  # How to answer when the request carries some members' last assessments forward; nothing when it carries none.
202
- # What a compact carried member shows, and what prints one whole, only when one prints compactly (#983).
205
+ # What a compact carried member shows, and what prints one whole, only when one prints compactly.
203
206
  #: () -> Instruction
204
207
  def carried_forward_instruction
205
208
  carry = Prompts.text("assess-every-member/judge-the-set-with-carried-assessments")
@@ -10,8 +10,8 @@ module Principles
10
10
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
11
11
  module Views
12
12
  # What a completed audit changed in the project, as its result prints it: the files to commit, in git what
13
- # landed since the base commit, as LandedSinceBase prints it, each other principle whose members its fixes changed
14
- # (#410), each file the record cites that no longer exists (#861), and each member added to the map during the
13
+ # landed since the base commit, as LandedSinceBase prints it, each other principle whose members its fixes changed,
14
+ # each file the record cites that no longer exists, and each member added to the map during the
15
15
  # audit, which no assessment read, so the next full audit assesses it (T69).
16
16
  class AuditChanges
17
17
  #: (files_to_commit: Array[String], ?landed: LandedSinceBase?,
@@ -46,7 +46,7 @@ module Principles
46
46
  end
47
47
 
48
48
  # Refuses, staging nothing, while a merge is unfinished, whose commit would otherwise take in these files
49
- # (758f12b, #811), saying why on stderr, the one place the stop is explained (#828). It fails with false, not
49
+ # (758f12b), saying why on stderr, the one place the stop is explained. It fails with false, not
50
50
  # exit, so a shell running it outside the printed subshell survives; the braces keep a failed cd from reading
51
51
  # as a merge. The message is in single quotes, so it holds no apostrophe.
52
52
  NO_MERGE_UNFINISHED = '{ test ! -e "$(git rev-parse --git-path MERGE_HEAD)" || ' \
@@ -55,7 +55,7 @@ module Principles
55
55
 
56
56
  # In git, the command that commits the files to commit and nothing else staged, with subject, run from
57
57
  # project, where those paths are relative. Each path is quoted for the shell and read by git as written, since
58
- # project files anyone may have written name them (#227, #811). nil outside git, where it could not run.
58
+ # project files anyone may have written name them. nil outside git, where it could not run.
59
59
  #: (String, String) -> String?
60
60
  def commit_with(subject, project)
61
61
  return unless @landed
@@ -19,7 +19,7 @@ module Principles
19
19
  end
20
20
 
21
21
  # The command, and beside it what replacing its default subject asks, since an agent reading commit_with
22
- # alone would otherwise run the default (#853).
22
+ # alone would otherwise run the default.
23
23
  #: () -> Hash[String, String]
24
24
  def fields
25
25
  { "commit_with" => @command,
@@ -27,12 +27,13 @@ module Principles
27
27
  subject: @subject) }
28
28
  end
29
29
 
30
- # The step that commits the files, the command ending its line (#811), up to the report that follows; its
31
- # wording is its prompt's. Why the command stops during a merge is its own to say, on stderr (#828).
30
+ # The step that commits the files with commit_with's command, which it names rather than prints a second time,
31
+ # up to the report that follows; its wording is its prompt's. Why the command stops during a
32
+ # merge is its own to say, on stderr.
32
33
  #: () -> String
33
34
  def next_step
34
35
  commit = Prompts.text("report-the-completed-audit/commit-only-what-the-audit-changed",
35
- files: ProseList.new(@files_to_commit).to_s, command: @command)
36
+ files: ProseList.new(@files_to_commit).to_s)
36
37
  "#{commit}\nThen"
37
38
  end
38
39
 
@@ -1,14 +1,17 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../prose_list"
5
4
  require_relative "assessment_request"
6
5
  require_relative "answered_request"
7
6
  require_relative "audit_changes"
7
+ require_relative "completed_audit_next_step"
8
8
  require_relative "correction_request"
9
9
  require_relative "invocation"
10
10
  require_relative "prior_finding_decisions_result"
11
11
  require_relative "prompts"
12
+ require_relative "report_hooks_offer"
13
+ require_relative "trimmed_instructions_note"
14
+ require_relative "../prose_list"
12
15
 
13
16
  module Principles
14
17
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
@@ -26,11 +29,8 @@ module Principles
26
29
  end
27
30
 
28
31
  # An answer's result as submit-answer prints it: a correction request in full, with how to answer it.
29
- #: (AnsweredRequest | CorrectionRequest, source_request_id: String, answer_file: String)
30
- #| -> Hash[String, untyped]
31
- def present(output, source_request_id:, answer_file:)
32
- output.presented_with(self, source_request_id, answer_file)
33
- end
32
+ #: (AnsweredRequest | CorrectionRequest) -> Hash[String, untyped]
33
+ def present(output) = output.presented_with(self)
34
34
 
35
35
  # A correction request adds its answer to fill; a terminal result leaves the acceptable preview alone.
36
36
  #: (Hash[String, untyped], AnsweredRequest | CorrectionRequest, answer_file: String) -> Hash[String, untyped]
@@ -39,9 +39,9 @@ module Principles
39
39
  end
40
40
 
41
41
  # show-answer-check: the answer passed every check, and what submitting it would write. open_findings_will_print
42
- # previews each written-up finding's write_up_opening, and is nil when the record would keep none (#411).
43
- # map_entry_changes gives each claimed map entry's changed role and check, left out when there is none (#462).
44
- # answer_file is the --file value the answer was checked from, which the submit command gives again (#859).
42
+ # previews each written-up finding's write_up_opening, and is nil when the record would keep none.
43
+ # map_entry_changes gives each claimed map entry's changed role and check, left out when there is none.
44
+ # answer_file is the --file value the answer was checked from, which the submit command gives again.
45
45
  #: (String, Array[String], answer_file: String, ?open_findings_will_print: Array[Hash[String, untyped]]?,
46
46
  #| ?map_entry_changes: Array[Hash[String, untyped]]) -> Hash[String, untyped]
47
47
  def acceptable(request_id, would_write, answer_file:, open_findings_will_print: nil, map_entry_changes: [])
@@ -54,34 +54,73 @@ module Principles
54
54
  result.merge("next_action" => "#{waits}Submit the same answer unchanged, as you gave it: #{submit}")
55
55
  end
56
56
 
57
+ # show-answer-check's acceptable result, with each carried member whose kept assessment names a finding the
58
+ # answer decides other than still_holds under carried_assessments_citing_decided_findings, and a first line
59
+ # asking the agent to judge each; unchanged when there is none.
60
+ #: (Hash[String, untyped], Array[Hash[String, untyped]]) -> Hash[String, untyped]
61
+ def citing_decided_findings(acceptable, carried)
62
+ judged_first(acceptable, "carried_assessments_citing_decided_findings", carried,
63
+ Prompts.text("assess-every-member/judge-a-carried-assessment-citing-a-decided-finding"))
64
+ end
65
+
66
+ # show-answer-check's acceptable result, with each prior finding whose write-up pointer the answer drops with
67
+ # null, and the pointer it had, under prior_findings_pointers_dropped, and a first line asking the agent to
68
+ # confirm each; unchanged when there is none.
69
+ #: (Hash[String, untyped], Array[Hash[String, untyped]]) -> Hash[String, untyped]
70
+ def dropping_pointers(acceptable, dropped)
71
+ judged_first(acceptable, "prior_findings_pointers_dropped", dropped,
72
+ Prompts.text("assess-every-member/confirm-each-write-up-pointer-the-answer-drops"))
73
+ end
74
+
75
+ # show-answer-check's acceptable result, its first line naming each deferred finding the answer writes up nowhere
76
+ # and saying that null is allowed; unchanged when there is none.
77
+ #: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
78
+ def deferred_written_up_nowhere(acceptable, finding_ids)
79
+ return acceptable if finding_ids.empty?
80
+
81
+ line = Prompts.text("dispose-of-each-finding/confirm-each-deferral-written-up-nowhere",
82
+ finding_ids: ProseList.new(finding_ids).to_s)
83
+ acceptable.merge("next_action" => "#{line}\n#{acceptable.fetch("next_action")}")
84
+ end
85
+
86
+ # submit-answer's result for principle_id's assessment, as citing_decided_findings gives show-answer-check's,
87
+ # its first line saying, since the answer is now written, that the next full audit judges each afresh.
88
+ #: (Hash[String, untyped], Array[Hash[String, untyped]], String) -> Hash[String, untyped]
89
+ def submitted_citing_decided_findings(result, carried, principle_id)
90
+ judged_first(result, "carried_assessments_citing_decided_findings", carried,
91
+ Prompts.text("assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding",
92
+ start_audit: @invocation.in_project("start-audit", principle_id)))
93
+ end
94
+
57
95
  # start-audit: the assessment request, as a judgement to answer under its request id, its context naming the
58
96
  # instructions it prints only in part and the flag that prints one whole, so a trimmed field is not taken for
59
- # the whole (#983), without the command the agent just ran (#1125).
97
+ # the whole, without the command the agent just ran. Its head names the command listing its parts, so a long
98
+ # request is read in parts rather than paged by script.
60
99
  #: (AssessmentRequest) -> Hash[String, untyped]
61
100
  def assessment_request(request)
62
- output = judgement("assessment", request)
63
- trimmed = request.trimmed_instruction_fields
64
- return output if trimmed.empty?
65
-
66
- note = Prompts.text("assess-every-member/read-a-trimmed-instruction-whole", fields: ProseList.new(trimmed).to_s)
67
- output.merge("context" => output.fetch("context").merge("trimmed_instructions" => note))
101
+ output = judgement("assessment", request, { "read_in_parts" => read_in_parts(request.principle_id) },
102
+ to_fill: { "response_template" => request.template })
103
+ note = TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h
104
+ output.merge("context" => output.fetch("context").merge(note))
68
105
  end
69
106
 
70
- # start-audit --as template: the assessment's answer alone, to fill and submit (D81 step 1).
107
+ # start-audit --as template: the assessment's answer alone, to fill and submit.
71
108
  #: (AssessmentRequest) -> Hash[String, untyped]
72
109
  def answer_to_fill(request) = request.template_to_fill
73
110
 
74
111
  # submit-answer: the correction request that follows an assessment with findings, as a judgement to answer
75
- # under its request id, saying what submitting the assessment stored.
76
- #: (CorrectionRequest, source_request_id: String, answer_file: String) -> Hash[String, untyped]
77
- def correction_request(request, source_request_id:, answer_file:)
112
+ # under its request id, saying what submitting the assessment stored and how to fill its answer by hand. Its
113
+ # answer to fill is left to show-open-correction, which next_action says to save it from, rather than printed
114
+ # here too.
115
+ #: (CorrectionRequest) -> Hash[String, untyped]
116
+ def correction_request(request)
78
117
  judgement("correction", request).merge("stored" => request.stored,
79
- "correction_recovery" => request.recovery(source_request_id, answer_file,
80
- @invocation))
118
+ "correction_recovery" => request.recovery(@invocation),
119
+ "next_action" => request.to_fill_by_hand(@invocation))
81
120
  end
82
121
 
83
122
  # A completed audit: its resolved and open findings, the files to commit and, in git, each changed
84
- # member's commits since the base commit and the command that commits those files alone (#811), each prior
123
+ # member's commits since the base commit and the command that commits those files alone, each prior
85
124
  # finding's decision, and the next step. The command's subject states only what the audit did, which the
86
125
  # agent rewords to its project's convention.
87
126
  #: (principle_id: String, resolved: Array[untyped], open: Array[untyped], changes: AuditChanges,
@@ -94,18 +133,19 @@ module Principles
94
133
  "open_findings" => open, "files_to_commit" => changes.files_to_commit,
95
134
  "limits" => Prompts.text("report-the-completed-audit/what-completion-means"),
96
135
  **changed.except("files_to_commit"), **commit.fields }
97
- next_action = completed_next_action(principle_id, changes, commit)
136
+ next_action = CompletedAuditNextStep.new(@invocation).to_s(principle_id, changes, commit)
98
137
  decisions.added_to(output).merge("next_action" => next_action,
99
138
  "full_record" => @invocation.in_project("show-audit", principle_id))
100
139
  end
101
140
 
102
141
  # completed, a completed audit's result, offering to set principles up after its next_action, as it does
103
- # while nothing keeps them held between audits (D95).
104
- #: (Hash[String, untyped]) -> Hash[String, untyped]
105
- def offering_set_up(completed)
106
- offer = Prompts.text("set-principles-up/keep-them-held-between-audits",
107
- command: @invocation.in_project("show-meta-principle-passage"))
108
- completed.merge("next_action" => "#{completed.fetch("next_action")}\n#{offer}")
142
+ # while nothing keeps them held between audits, and with hooks, the hook entries that report between them.
143
+ #: (Hash[String, untyped], hooks: bool) -> Hash[String, untyped]
144
+ def offering_set_up(completed, hooks:)
145
+ offers = [Prompts.text("set-principles-up/keep-them-held-between-audits",
146
+ command: @invocation.in_project("show-meta-principle-passage"))]
147
+ offers << ReportHooksOffer.new(@invocation).to_s if hooks
148
+ completed.merge("next_action" => [completed.fetch("next_action"), *offers].join("\n"))
109
149
  end
110
150
 
111
151
  # The notice start-audit adds when the last audit's record is not committed.
@@ -115,7 +155,7 @@ module Principles
115
155
  end
116
156
 
117
157
  # The notice start-audit adds, in git, when the last audit's record is open: its correction completes it, so it
118
- # is never committed (D87).
158
+ # is never committed.
119
159
  #: (String) -> String
120
160
  def open_record_notice(file)
121
161
  "The last audit's record, #{file}, holds an open audit, waiting on its correction. Do not commit it: submit " \
@@ -131,32 +171,31 @@ module Principles
131
171
 
132
172
  private
133
173
 
134
- # request as a judgement to answer in phase, under its id, which its template's head also gives.
135
- #: (String, AssessmentRequest | CorrectionRequest) -> Hash[String, untyped]
136
- def judgement(phase, request)
137
- { "status" => "agent_judgement_required", "request_id" => request.request_id, "phase" => phase,
138
- "context" => request.context, "response_template" => request.template,
139
- "limits" => Prompts.text("answer-any-judgement-request/what-a-self-audit-cannot-show") }
140
- end
174
+ # result with facts under field and judge as next_action's first line, or all of it for a request to answer,
175
+ # which has none; unchanged when facts is empty.
176
+ #: (Hash[String, untyped], String, Array[Hash[String, untyped]], String) -> Hash[String, untyped]
177
+ def judged_first(result, field, facts, judge)
178
+ return result if facts.empty?
141
179
 
142
- # A completed audit's next step, from what it changed and how to commit it.
143
- #: (String, AuditChanges, AuditCommit | AuditCommit::ByHand) -> String
144
- def completed_next_action(id, changes, commit)
145
- "#{commit.next_step} report the outcome to the project's owner.\n" \
146
- "#{others_changed(changes.other_changed)}" \
147
- "After members change, audit this principle again: #{@invocation.in_project("start-audit", id)}"
180
+ result.merge(field => facts, "next_action" => [judge, result["next_action"]].compact.join("\n"))
148
181
  end
149
182
 
150
- # The other principles whose members this audit's fixes changed, each to re-audit, or one member's edit
151
- # to acknowledge; the agent judges which (#410). Nothing when there are none.
152
- #: (Array[PrincipleWithChangedMembers]) -> String
153
- def others_changed(others)
154
- return "" if others.empty?
183
+ # How to read principle_id's full-audit request in parts: the command listing them, and the flag printing one.
184
+ #: (String) -> String
185
+ def read_in_parts(principle_id)
186
+ index = @invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::INDEX])
187
+ Prompts.text("assess-every-member/read-the-request-in-parts", index:)
188
+ end
155
189
 
156
- commands = others.map { |each| "#{@invocation.in_project("start-audit", each.principle_id)}\n" }
157
- "This audit's fixes also changed or broke members of other principles, listed under " \
158
- "other_principles_with_changed_members. Repair a broken one from show-principle's repair_with. To " \
159
- "acknowledge one member's edit instead, add --member MEMBER to its audit. Re-audit each:\n#{commands.join}"
190
+ # request as a judgement to answer in phase, under its id, which its template's head also gives, with any
191
+ # opening fields after the phase and before the context, and to_fill, the answer to fill when this request
192
+ # prints it, after the context.
193
+ #: (String, AssessmentRequest | CorrectionRequest, ?Hash[String, String], ?to_fill: Hash[String, untyped])
194
+ #| -> Hash[String, untyped]
195
+ def judgement(phase, request, opening = {}, to_fill: {})
196
+ { "status" => "agent_judgement_required", "request_id" => request.request_id, "phase" => phase, **opening,
197
+ "context" => request.context, **to_fill,
198
+ "limits" => Prompts.text("answer-any-judgement-request/what-a-self-audit-cannot-show") }
160
199
  end
161
200
  end
162
201
  end