principles 0.0.6 → 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 (338) 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 +58 -41
  9. data/lib/principles/command_line.rb +37 -14
  10. data/lib/principles/command_routes.rb +21 -7
  11. data/lib/principles/controllers/acknowledgement.rb +50 -118
  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 +52 -21
  15. data/lib/principles/controllers/answer_phase.rb +20 -3
  16. data/lib/principles/controllers/assessment.rb +41 -28
  17. data/lib/principles/controllers/audit.rb +59 -15
  18. data/lib/principles/controllers/audit_completion.rb +25 -12
  19. data/lib/principles/controllers/command.rb +13 -12
  20. data/lib/principles/controllers/correction.rb +26 -11
  21. data/lib/principles/controllers/first_audit_brief.rb +40 -0
  22. data/lib/principles/controllers/full_audit_request.rb +47 -83
  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 +148 -0
  27. data/lib/principles/controllers/member_entries.rb +4 -4
  28. data/lib/principles/controllers/member_problems_report.rb +84 -30
  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 +67 -12
  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 -20
  57. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +95 -0
  58. data/lib/principles/data/schemas/assessment-answer.schema.json +55 -20
  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 +14 -62
  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 +7 -6
  68. data/lib/principles/launch.rb +49 -0
  69. data/lib/principles/list_open_findings_options.rb +23 -0
  70. data/lib/principles/models/accepted_loading.rb +2 -2
  71. data/lib/principles/models/acknowledged_check.rb +106 -0
  72. data/lib/principles/models/acknowledgement.rb +51 -53
  73. data/lib/principles/models/acknowledgement_left_as_printed.rb +18 -5
  74. data/lib/principles/models/acknowledgement_refusal.rb +25 -10
  75. data/lib/principles/models/acknowledgements.rb +115 -0
  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 +12 -3
  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 +14 -15
  88. data/lib/principles/models/audit.rb +46 -34
  89. data/lib/principles/models/audit_record.rb +58 -27
  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 +19 -10
  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 +80 -0
  133. data/lib/principles/models/listed_members.rb +47 -0
  134. data/lib/principles/models/loaded_files.rb +4 -5
  135. data/lib/principles/models/loading_decision.rb +19 -10
  136. data/lib/principles/models/loading_facts.rb +1 -1
  137. data/lib/principles/models/loads_to_check.rb +1 -2
  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 +17 -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 +21 -18
  150. data/lib/principles/models/member_repair_moves.rb +15 -9
  151. data/lib/principles/models/member_sighting.rb +12 -15
  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 +42 -9
  181. data/lib/principles/models/project.rb +29 -20
  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 +42 -36
  196. data/lib/principles/models/request_id.rb +19 -7
  197. data/lib/principles/models/runs_from.rb +7 -2
  198. data/lib/principles/models/sent_answer.rb +38 -16
  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 +15 -7
  217. data/lib/principles/prose_list.rb +1 -1
  218. data/lib/principles/session_start_options.rb +3 -3
  219. data/lib/principles/start_audit_options.rb +54 -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 +137 -17
  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 +68 -38
  227. data/lib/principles/views/assessment_request.rb +43 -21
  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 +100 -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 +51 -39
  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 +49 -33
  237. data/lib/principles/views/diff_since_last_audit.rb +8 -6
  238. data/lib/principles/views/findings_result.rb +33 -1
  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 +32 -9
  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 +11 -7
  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 +61 -0
  256. data/lib/principles/views/members_a_commit_changed.rb +15 -11
  257. data/lib/principles/views/members_with_no_baseline.rb +10 -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 +24 -12
  261. data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
  262. data/lib/principles/views/open_findings_line.rb +26 -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 +70 -45
  275. data/lib/principles/views/problem_result.rb +75 -43
  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/report-the-exit-status-its-own-listing-gives.md +3 -0
  279. data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
  280. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
  281. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
  282. data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
  283. data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
  284. data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
  285. data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
  286. data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
  287. data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
  288. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
  289. data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
  290. data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
  291. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
  292. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
  293. data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
  294. data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
  295. data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
  296. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  297. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
  298. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
  299. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
  300. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
  301. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
  302. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +16 -16
  303. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
  304. data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
  305. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
  306. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +22 -20
  307. data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
  308. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
  309. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
  310. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
  311. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -28
  312. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +39 -38
  313. data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
  314. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
  315. data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
  316. data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
  317. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
  318. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
  319. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
  320. data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
  321. data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
  322. data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
  323. data/lib/principles/views/prompts.rb +1 -1
  324. data/lib/principles/views/read_the_change.rb +36 -0
  325. data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
  326. data/lib/principles/views/repoint_result.rb +1 -1
  327. data/lib/principles/views/report_hooks_offer.rb +25 -0
  328. data/lib/principles/views/request_part.rb +5 -5
  329. data/lib/principles/views/request_parts.rb +1 -1
  330. data/lib/principles/views/session_start_report.rb +46 -0
  331. data/lib/principles/views/shell_word.rb +1 -1
  332. data/lib/principles/views/trimmed_instructions_note.rb +30 -0
  333. data/lib/principles/views/visible_text.rb +1 -1
  334. data/lib/principles/views/workflow_diagram.rb +1 -1
  335. data/principles.gemspec +44 -0
  336. metadata +95 -14
  337. data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
  338. data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
@@ -6,6 +6,7 @@ require_relative "../models/finding_write_ups"
6
6
  require_relative "../models/request_id"
7
7
  require_relative "../models/submitted_answer"
8
8
  require_relative "acknowledgement"
9
+ require_relative "acknowledgements"
9
10
  require_relative "correction"
10
11
  require_relative "repoint"
11
12
  require_relative "assessment"
@@ -16,20 +17,23 @@ module Principles
16
17
  module Controllers
17
18
  # Answering an audit's requests: this tool checks the answer against the project's files and, when the
18
19
  # audit completes, writes the committed audit record. Nothing else is stored: each request id is a
19
- # digest of what the request depends on, so an answer is checked against the project as it is now (D25).
20
+ # digest of what the request depends on, so an answer is checked against the project as it is now.
20
21
  class Answer < Command
21
22
  # The controller that answers for each phase a request id may name.
22
23
  PHASE_CONTROLLERS = {
23
24
  "assessment" => Assessment, "correction" => Correction, "acknowledgement" => Acknowledgement,
24
- "repointing" => Repoint
25
+ "acknowledgements" => Acknowledgements, "repointing" => Repoint
25
26
  }.freeze #: Hash[String, Class[AnswerPhase]]
26
27
 
27
28
  #: (String, String?, Hash[String, untyped]) -> untyped
28
29
  def call(command, _id, options)
29
30
  naming_the_executable do
30
31
  case command
31
- when "submit-answer" then submit_answer(submitted(options), options.fetch("file"))
32
- when "show-answer-check" then check_answer(submitted(options), options.fetch("file"))
32
+ when "submit-answer" then submit_answer(submitted(options))
33
+ when "show-answer-check"
34
+ next correction_to_fill(submitted(options)) if options["as"]
35
+
36
+ check_answer(submitted(options), options.fetch("file"))
33
37
  else unknown(command)
34
38
  end
35
39
  end
@@ -37,20 +41,21 @@ module Principles
37
41
 
38
42
  private
39
43
 
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).
44
+ # The answer from --file, where - means it was read from stdin, to the request REQUEST_ID names, or the answer's
45
+ # own request_id when none is given, checked against the schema for the phase that id names once its head
46
+ # says it answers a request that still matches the project, with the prior findings a full audit's request
47
+ # listed, which checking its head found.
43
48
  #: (Hash[String, untyped]) -> Models::SubmittedAnswer
44
49
  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)
50
+ sent = @project.answer(options.fetch("file"), stdin: options["stdin"], given: options["request_id"])
51
+ request_id = sent.request_id
47
52
  prior = checked_head(request_id, sent.head)
48
53
  Models::SubmittedAnswer.new(request_id, sent.checked(phase(request_id).before_shape(request_id)), prior)
49
54
  end
50
55
 
51
56
  # Refuses an answer from its head alone: a record a later copy wrote is refused first, read afresh as
52
- # start-audit reads it, so nothing is written over one that landed mid-audit (D85), then an answer to another
53
- # request, then whatever the phase checks of its request from the head alone (#1052).
57
+ # start-audit reads it, so nothing is written over one that landed mid-audit, then an answer to another
58
+ # request, then whatever the phase checks of its request from the head alone.
54
59
  #: (Models::RequestId, Hash[String, untyped]) -> Models::PriorFindings?
55
60
  def checked_head(request_id, head)
56
61
  @audit_records.refuse_newer(request_id.principle_id, version: @tool.version)
@@ -59,22 +64,48 @@ module Principles
59
64
  end
60
65
 
61
66
  # Accepts the answer and writes the record changes it makes.
62
- #: (Models::SubmittedAnswer, String) -> untyped
63
- def submit_answer(submitted, answer_file)
67
+ #: (Models::SubmittedAnswer) -> untyped
68
+ def submit_answer(submitted)
64
69
  output, changes = judged(submitted)
70
+ carried = phase(submitted.request_id).carried_naming_decided(submitted)
65
71
  wrote = changes.map { |record| @audit_records.save(record) }
66
- audit_result.present(output, source_request_id: submitted.request_id.to_s,
67
- answer_file: answer_file).merge("wrote" => wrote)
72
+ presented = audit_result.present(output)
73
+ audit_result.submitted_citing_decided_findings(presented, carried, submitted.request_id.principle_id)
74
+ .merge("wrote" => wrote)
68
75
  end
69
76
 
70
- # Runs every check submit-answer would, and says what it would write, writing nothing; its submit command
71
- # gives answer_file, the --file value it was checked from, again. An assessment with findings also gives the
72
- # correction's answer it leads to, to fill (D81 step 3).
77
+ # Runs every check submit-answer would, says what it would write and each fact to confirm first, such as a
78
+ # write-up pointer it drops, writing nothing; its submit command gives answer_file, the --file value it was
79
+ # checked from, again. An assessment with findings also gives the
80
+ # correction's answer it leads to, to fill.
73
81
  #: (Models::SubmittedAnswer, String) -> untyped
74
82
  def check_answer(submitted, answer_file)
75
83
  output, changes = judged(submitted)
76
- audit_result.with_correction_to_fill(acceptable(submitted, answer_file, changes), output,
77
- answer_file: answer_file).merge("wrote" => [])
84
+ checked = to_confirm(acceptable(submitted, answer_file, changes), submitted, changes)
85
+ audit_result.with_correction_to_fill(checked, output, answer_file: answer_file).merge("wrote" => [])
86
+ end
87
+
88
+ # The acceptable result with each fact to confirm before submitting named first in its next_action: a carried
89
+ # assessment citing a decided finding, a write-up pointer the answer drops, and a deferral the record changes
90
+ # write up nowhere.
91
+ #: (Hash[String, untyped], Models::SubmittedAnswer, Array[Models::AuditRecord]) -> Hash[String, untyped]
92
+ def to_confirm(acceptable, submitted, changes)
93
+ answering = phase(submitted.request_id)
94
+ checked = audit_result.citing_decided_findings(acceptable, answering.carried_naming_decided(submitted))
95
+ checked = audit_result.dropping_pointers(checked, answering.pointers_dropped(submitted))
96
+ audit_result.deferred_written_up_nowhere(checked, answering.deferred_written_up_nowhere(changes))
97
+ end
98
+
99
+ # The correction's answer an assessment with findings leads to, alone, as show-answer-check --as template prints
100
+ # it to fill; refused for any other answer, which leads to none. Writes nothing.
101
+ #: (Models::SubmittedAnswer) -> Hash[String, untyped]
102
+ def correction_to_fill(submitted)
103
+ output, = judged(submitted)
104
+ output.correction_to_fill or
105
+ raise Error.new("no_correction_to_fill",
106
+ "This answer to #{submitted.request_id} leads to no correction: --as template prints the " \
107
+ "correction's answer that an assessment with findings leads to.",
108
+ "Check it without --as template, which says what submitting it would write.")
78
109
  end
79
110
 
80
111
  # The answer passed every check: what submitting it would write, and its submit command.
@@ -93,7 +124,7 @@ module Principles
93
124
  #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
94
125
  def claimed_map_entry_changes(submitted) = phase(submitted.request_id).map_entry_changes(submitted)
95
126
 
96
- # The result of answering, and each record change the answer makes, not yet written (D85).
127
+ # The result of answering, and each record change the answer makes, not yet written.
97
128
  #: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
98
129
  def judged(submitted) = phase(submitted.request_id).answered(submitted)
99
130
 
@@ -16,7 +16,7 @@ module Principles
16
16
  # @abstract
17
17
  class AnswerPhase < Command
18
18
  # The result of answering, and each record change the answer makes, not yet written; every phase changes only
19
- # the request's own principle's record (D85). Sorbet refuses a phase that does not define it, and takes an
19
+ # the request's own principle's record. Sorbet refuses a phase that does not define it, and takes an
20
20
  # abstract method only with a forwarding super for its body, which RuboCop would otherwise call useless.
21
21
  # @abstract
22
22
  #: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
@@ -31,10 +31,27 @@ module Principles
31
31
  #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
32
32
  def map_entry_changes(_submitted) = []
33
33
 
34
+ # Each member the answer carries forward whose kept assessment names a prior finding it decides other than
35
+ # still_holds, which only a full audit's assessment decides.
36
+ #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
37
+ def carried_naming_decided(_submitted) = []
38
+
39
+ # Each prior finding whose write-up pointer the answer drops with null, with the pointer it had, which only a
40
+ # full audit's assessment decides.
41
+ #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
42
+ def pointers_dropped(_submitted) = []
43
+
44
+ # Each finding the record changes leave deferred with recorded_at null, which only a correction disposes of.
45
+ #: (Array[Models::AuditRecord]) -> Array[String]
46
+ def deferred_written_up_nowhere(_changes) = []
47
+
34
48
  # The refusals an answer to the request request_id names meets before its shape, in order; any phase's is a
35
- # placeholder its template did not print (#1084).
49
+ # placeholder its template did not print.
36
50
  #: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
37
- def before_shape(request_id) = [Models::OtherTemplatesPlaceholders.besides(printed_placeholders(request_id))]
51
+ def before_shape(request_id)
52
+ [Models::OtherTemplatesPlaceholders.besides(printed_placeholders(request_id),
53
+ start_from: request_id.answer_to_fill)]
54
+ end
38
55
 
39
56
  private
40
57
 
@@ -17,7 +17,7 @@ module Principles
17
17
  module Controllers
18
18
  # A full audit's assessment, which submit-answer and show-answer-check hand over: this tool checks the request
19
19
  # it answers and each member's assessment, then completes an audit with no findings or asks for the correction
20
- # of its findings (D35, D50).
20
+ # of its findings.
21
21
  class Assessment < AnswerPhase
22
22
  # The result of answering an assessment request, which checked_request found unchanged, with the prior findings
23
23
  # it listed, and the record change it makes, not yet written.
@@ -36,7 +36,7 @@ module Principles
36
36
 
37
37
  # The prior findings the request an answer's head names listed, refused when that request, given the head's
38
38
  # basis, no longer matches the project, before the rest of the answer's shape is read: checked here alone, since
39
- # its template prints placeholders this release's schema could otherwise refuse first (#1052).
39
+ # its template prints placeholders this release's schema could otherwise refuse first.
40
40
  #: (Models::RequestId, Hash[String, untyped]) -> Models::PriorFindings
41
41
  def checked_request(request_id, head)
42
42
  audit = audit_now(request_id.principle_id)
@@ -49,9 +49,8 @@ module Principles
49
49
  end
50
50
 
51
51
  # The refusals an answer meets before its shape: first a check_result on a member with no check, which the
52
- # shape would refuse as lacking its command (#1088), then any phase's, whose template is read first, as before,
53
- # then a judgement left as its template printed it, named with the shape's problems, so one refusal names both
54
- # (#1109).
52
+ # shape would refuse as lacking its command, then any phase's, whose template is read first, as before,
53
+ # then a judgement left as its template printed it, named with the shape's problems, so one refusal names both.
55
54
  #: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
56
55
  def before_shape(request_id)
57
56
  any_phase = super
@@ -59,9 +58,29 @@ module Principles
59
58
  Models::AssessmentLeftAsPrinted.new]
60
59
  end
61
60
 
61
+ # Each member the answer carries forward whose kept assessment names a prior finding it decides other than
62
+ # still_holds, from the record the answer is judged against.
63
+ # @override
64
+ #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
65
+ def carried_naming_decided(submitted)
66
+ audit = audit_now(submitted.request_id.principle_id)
67
+ record_judged_against(audit).carried.naming_decided(submitted.response)
68
+ end
69
+
70
+ # Each prior finding whose write-up pointer the answer drops with null, with the pointer it had, as the
71
+ # decisions on the prior findings, once checked, say.
72
+ # @override
73
+ #: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
74
+ def pointers_dropped(submitted)
75
+ response = submitted.response
76
+ decided = submitted.prior_findings.decided(response["prior_finding_decisions"], response.fetch("findings", []),
77
+ records: @audit_records) { |locator| snapshot(locator) }
78
+ decided.changed.fetch("pointers_dropped")
79
+ end
80
+
62
81
  private
63
82
 
64
- # The placeholders a full audit's template printed, as start-audit --as template prints it now (#1084).
83
+ # The placeholders a full audit's template printed, as start-audit --as template prints it now.
65
84
  #: (Models::RequestId) -> Hash[String, untyped]?
66
85
  def printed_placeholders(request_id)
67
86
  handed(FullAuditRequest, principle_id: request_id.principle_id).to_fill
@@ -89,7 +108,7 @@ module Principles
89
108
 
90
109
  # Completes an audit with no findings. Otherwise asks the agent to correct them. Each is refused once the last
91
110
  # completed record changed after the assessment's request was printed, the completion unless it writes
92
- # nothing (D50).
111
+ # nothing.
93
112
  #: (Models::AuditStart, Models::Audit, Array[untyped], Models::DecidedPriorFindings, Models::AssessmentBasis)
94
113
  #| -> [untyped, Array[Models::AuditRecord]]
95
114
  def correction(start, audit, findings, decided, assessed)
@@ -100,15 +119,20 @@ module Principles
100
119
  correction_request(start, audit, findings, decided, assessed)
101
120
  end
102
121
 
103
- # The correction request for findings, and outside git the open record that keeps what the audit began from.
122
+ # The correction request for findings, and the open record that keeps the assessment, whose digest its basis
123
+ # carries in place of the assessment, so the correction reads it back from the record, and keeps the
124
+ # correction's request_id and basis, so show-open-correction prints it again.
104
125
  # It is refused before it is printed once the last completed record changed, so no fix is made for an audit
105
- # that cannot complete (D50). The check results travel in the basis, so the completed record keeps them (D30).
126
+ # that cannot complete. The check results travel in the record, so the completed record keeps them.
106
127
  #: (Models::AuditStart, Models::Audit, Array[untyped], Models::DecidedPriorFindings, Models::AssessmentBasis)
107
128
  #| -> [untyped, Array[Models::AuditRecord]]
108
129
  def correction_request(start, audit, findings, decided, assessed)
109
130
  assessed.printed_after.confirm_unchanged(audit.id, @audit_records.find(audit.id))
110
- basis = printed_basis(start, findings, decided, assessed)
111
- [request_to_correct(basis, audit, findings), open_record_changes(start, audit, basis.to_h)]
131
+ record = open_record(start, audit, findings)
132
+ basis = Models::CorrectionBasis.printed(start, findings: findings, prior: decided, revision: assessed.revision,
133
+ open_record: record)
134
+ request = request_to_correct(basis, audit, findings)
135
+ [request, @audit_records.changes(record.correcting(request.request_id, basis.to_h))]
112
136
  end
113
137
 
114
138
  # The correction request for findings, answered under an id that digests its basis and the members now.
@@ -119,24 +143,13 @@ module Principles
119
143
  placeholders: Models::Disposition::TEMPLATE_PLACEHOLDERS)
120
144
  end
121
145
 
122
- # The basis a correction request prints, for the agent to hand back with its answer.
123
- # Its revision is the one the assessment was printed after, carried forward, so the correction is refused once
124
- # that record changes (#646, D50).
125
- #: (Models::AuditStart, Array[untyped], Models::DecidedPriorFindings, Models::AssessmentBasis)
126
- #| -> Models::CorrectionBasis
127
- def printed_basis(start, findings, decided, assessed)
128
- Models::CorrectionBasis.printed(start, findings: findings, prior: decided, revision: assessed.revision)
129
- end
130
-
131
- # Outside git, the open record that keeps what the audit began from, and the last completed record, so a
132
- # restarted audit still lists its prior findings (D35); in git, nothing.
133
- #: (Models::AuditStart, Models::Audit, Hash[String, untyped]) -> Array[Models::AuditRecord]
134
- def open_record_changes(start, audit, basis)
135
- return [] if start.base
136
-
146
+ # The open record that keeps the assessment, and outside git what the audit began from, and the last completed
147
+ # record, so a restarted audit still lists its prior findings, in git as outside it.
148
+ #: (Models::AuditStart, Models::Audit, Array[untyped]) -> Models::AuditRecord
149
+ def open_record(start, audit, findings)
137
150
  last = @audit_records.find(audit.id)&.last_completed
138
- record = handed(AuditCompletion).record(start, basis.fetch("findings"), "open", audit.now, last)
139
- @audit_records.changes(record)
151
+ raised = findings.map { |finding| finding.slice(*Models::RecordedFinding::RAISED_FIELDS) }
152
+ handed(AuditCompletion).record(start, raised, "open", audit.now, last)
140
153
  end
141
154
  end
142
155
  end
@@ -7,6 +7,7 @@ require_relative "../models/finding_write_ups"
7
7
  require_relative "../views/findings_result"
8
8
  require_relative "../views/open_findings_line"
9
9
  require_relative "acknowledgement"
10
+ require_relative "acknowledgements"
10
11
  require_relative "full_audit_request"
11
12
  require_relative "repoint"
12
13
 
@@ -24,57 +25,100 @@ module Principles
24
25
  naming_the_executable do
25
26
  case command
26
27
  when "show-audit" then shown_audit(required_id(id))
27
- when "list-open-findings" then options["short"] ? open_findings_line(id, options) : open_findings(id)
28
+ when "list-open-findings" then listed_open_findings(id, options)
28
29
  else unknown(command)
29
30
  end
30
31
  end
31
32
  end
32
33
 
34
+ # The line report-at-session-start ends with while any finding is open, worded for the session's start, source,
35
+ # with list-open-findings --short's words, its command leaving out --project, since a session runs in its
36
+ # project; none while none is open.
37
+ #: (String) -> Array[String]
38
+ def session_start_open_findings(source)
39
+ records = open_records(nil)
40
+ waiting = Models::FindingsLeftOpen.of(records).waiting_at(Time.now.utc)
41
+ Views::OpenFindingsLine.new(invocation.without_project)
42
+ .lines(waiting, Models::FindingWriteUps.of(@project, records).not_found, source:)
43
+ end
44
+
33
45
  private
34
46
 
35
47
  # The audit start-audit's options ask for: a one-member audit with --member, a repoint of the open
36
- # findings' write-ups with --write-ups (D59), else a full audit; a full or one-member audit's answer alone with
37
- # --as template (D81, #773).
48
+ # findings' write-ups with --write-ups, else a full audit; a full or one-member audit's answer alone with
49
+ # --as template.
38
50
  #: (String, Hash[String, untyped]) -> Hash[String, untyped]
39
51
  def started_audit(id, options)
40
52
  naming_the_executable { @audit_records.refuse_newer(id, version: @tool.version) }
41
- return acknowledge(id, options["member"], to_fill: options["as"] == "template") if options["member"]
53
+ ids = [id, *options.fetch("other_ids", [])]
54
+ return acknowledge(ids, options.fetch("member"), to_fill: options["as"] == "template") if options["member"]
42
55
  return handed(Repoint).start(id) if options["write_ups"]
43
56
 
44
57
  full_audit(id, options)
45
58
  end
46
59
 
47
60
  # A full audit's request, or with --as template its answer alone, or with --instruction one instruction field
48
- # of it (D81).
61
+ # of it, or with --part one other part of it, or one member's slot of the answer beside --as template.
49
62
  #: (String, Hash[String, untyped]) -> Hash[String, untyped]
50
63
  def full_audit(id, options)
51
64
  naming_the_executable do
52
65
  full = handed(FullAuditRequest, principle_id: id)
53
66
  next full.instruction(options["instruction"]) if options["instruction"]
67
+ next full_part(full, options) if options["part"]
54
68
 
55
69
  options["as"] ? full.to_fill : full.printed
56
70
  end
57
71
  end
58
72
 
73
+ # The part of the request --part names, or beside --as template the member's slot of the answer it names.
74
+ #: (FullAuditRequest, Hash[String, untyped]) -> Hash[String, untyped]
75
+ def full_part(full, options)
76
+ options["as"] ? full.slot_to_fill(options.fetch("part")) : full.part(options.fetch("part"))
77
+ end
78
+
59
79
  # id's committed record. With none, an id no map has is refused as show-principle refuses it, since
60
- # starting its audit would be refused too; a record kept after its map was removed still shows (#577). One a
61
- # later copy wrote says its audits wait on an upgrade (D85, V8).
80
+ # starting its audit would be refused too; a record kept after its map was removed still shows. One a
81
+ # later copy wrote says its audits wait on an upgrade.
62
82
  #: (String) -> Hash[String, untyped]
63
83
  def shown_audit(id)
64
84
  @principles.find(id) unless @audit_records.exist?(id)
65
85
  @audit_records.fetch(id).shown.merge(waiting_beside(id), "wrote" => [])
66
86
  end
67
87
 
68
- # A one-member audit of member_id (D33), or its answer alone to fill (#773).
69
- #: (String, String, to_fill: bool) -> Hash[String, untyped]
70
- def acknowledge(id, member_id, to_fill:)
88
+ # A one-member audit of the member --member names, or of several members in one request, or of the
89
+ # members several principles map, or its answer alone to fill.
90
+ #: (Array[String], Array[String], to_fill: bool) -> Hash[String, untyped]
91
+ def acknowledge(ids, member_ids, to_fill:)
92
+ id = ids.fetch(0)
93
+ return handed(Acknowledgements).across(ids, member_ids, to_fill:) if ids.size > 1
94
+ return handed(Acknowledgements).several(id, member_ids, to_fill:) if member_ids.size > 1
95
+
71
96
  acknowledgement = handed(Acknowledgement)
97
+ member_id = member_ids.first.to_s
98
+
72
99
  to_fill ? acknowledgement.to_fill(id, member_id) : acknowledgement.start(id, member_id)
73
100
  end
74
101
 
75
- # The findings the last completed audit of map id, or of every map, deferred or accepted (#292, D35). Across
102
+ # The open findings in the form the options ask for: the session-start hook's one line with --short, a line each
103
+ # with --lines, or the full list.
104
+ #: (String?, Hash[String, untyped]) -> untyped
105
+ def listed_open_findings(id, options)
106
+ return open_findings_line(id, options) if options["short"]
107
+ return open_findings_lines(id) if options["lines"]
108
+
109
+ open_findings(id)
110
+ end
111
+
112
+ # Each open finding on a line, with whom it waits on and how long it has been open until now.
113
+ #: (String?) -> Views::Lines
114
+ def open_findings_lines(id)
115
+ now = Time.now.utc
116
+ Views::FindingsResult.new(invocation).lines(open_records(id).flat_map(&:left_open).map { it.waited_at(now) })
117
+ end
118
+
119
+ # The findings the last completed audit of map id, or of every map, deferred or accepted. Across
76
120
  # every map, it names each principle whose record a later copy wrote, so a list left without one that cannot be
77
- # read does not look whole (D85, V8).
121
+ # read does not look whole.
78
122
  #: (String?) -> Hash[String, untyped]
79
123
  def open_findings(id)
80
124
  listed = Models::FindingWriteUps.of(@project, open_records(id)).listed
@@ -85,8 +129,8 @@ module Principles
85
129
  end
86
130
 
87
131
  # The one line saying how many findings are open and how long the oldest has waited until now, and which
88
- # write-ups can no longer be found (#694), or nothing when none is open, for a session-start hook (D47),
89
- # worded for the session's start, startup unless --session-start names another (#717).
132
+ # write-ups can no longer be found, or nothing when none is open, for a session-start hook,
133
+ # worded for the session's start, startup unless --session-start names another.
90
134
  #: (String?, Hash[String, untyped]) -> Views::Lines
91
135
  def open_findings_line(id, options)
92
136
  records = open_records(id)
@@ -97,7 +141,7 @@ module Principles
97
141
 
98
142
  # The records whose open findings list-open-findings reads: id's, refused when a later copy wrote it in a
99
143
  # form this copy cannot read, since an empty list would say it has none; or every principle's this copy can
100
- # read, so one such record does not refuse the rest (D85, V8).
144
+ # read, so one such record does not refuse the rest.
101
145
  #: (String?) -> Array[Models::AuditRecord]
102
146
  def open_records(id)
103
147
  ids = @principles.ids_of(id)
@@ -18,31 +18,34 @@ module Principles
18
18
  # submit-answer reaches from an assessment with no findings or from a correction, with the record it writes,
19
19
  # the files to commit and what landed since the base commit.
20
20
  class AuditCompletion < Command
21
- # map_changes are the changes a correction declared to the map, which name the map file to commit (D40).
21
+ # map_changes are the changes a correction declared to the map, which name the map file to commit.
22
22
  # replacing is the revision of the last completed record when the request that completes the audit was
23
- # printed, which refuses to replace a record changed since (#646).
23
+ # printed, which refuses to replace a record changed since. read_back_from is the record a correction
24
+ # read the audit's assessment back from, which, when completed, only an identical retry completes again.
24
25
  #: (Models::Project, tool: RunningTool, ?map_changes: Models::DeclaredMapChanges?,
25
- #| ?replacing: Models::LastCompletedRevision?) -> void
26
- def initialize(project, tool:, map_changes: nil, replacing: nil)
26
+ #| ?replacing: Models::LastCompletedRevision?, ?read_back_from: Models::AuditRecord?) -> void
27
+ def initialize(project, tool:, map_changes: nil, replacing: nil, read_back_from: nil)
27
28
  super(project, tool: tool)
28
29
  @map_changes = map_changes #: Models::DeclaredMapChanges?
29
30
  @replacing = replacing #: Models::LastCompletedRevision?
31
+ @read_back_from = read_back_from #: Models::AuditRecord?
30
32
  end
31
33
 
32
34
  # The completed result, and the record change it makes, not yet written.
33
- # Each prior finding's decision is applied: a kept one stays in the record, and a closed one is reported (D35).
35
+ # Each prior finding's decision is applied: a kept one stays in the record, and a closed one is reported.
34
36
  #: (Models::AuditStart, Models::Audit, Array[Models::Disposition], Array[untyped], Models::DecidedPriorFindings)
35
37
  #| -> [untyped, Array[Models::AuditRecord]]
36
38
  def completed(start, audit, dispositions, findings, decided)
37
39
  written = record(start, audit.outcomes(findings, dispositions, decided), "completed", audit.now)
38
40
  changes = @audit_records.changes(written)
39
41
  @replacing&.confirm_writable(audit.id, @audit_records.find(audit.id), changes)
42
+ audit.confirm_read_back(@read_back_from, changes)
40
43
  [Views::AnsweredRequest.new(completion_result(start, audit, dispositions, decided, written)), changes]
41
44
  end
42
45
 
43
46
  # The record an audit writes, made now, saying what its assessments answered, with each assessment carried
44
- # forward taken from the record it replaces (D49), and the release of principles it ran under when its
45
- # principle keeps one (D68).
47
+ # forward taken from the record it replaces, and the release of principles it ran under when its
48
+ # principle keeps one.
46
49
  #: (Models::AuditStart, Array[untyped], String, Hash[String, String], ?Models::AuditRecord?)
47
50
  #| -> Models::AuditRecord
48
51
  def record(start, findings, status, members, last_completed = nil)
@@ -56,8 +59,8 @@ module Principles
56
59
  private
57
60
 
58
61
  # What the completed audit prints: its resolved and open findings, as the record it writes holds them, so they
59
- # agree with list-open-findings (#714); what it changed; each prior finding's decision (D35); and, while
60
- # principles is not set up, the offer to set it up (D95).
62
+ # agree with list-open-findings; what it changed; each prior finding's decision; and, while
63
+ # principles is not set up, the offer to set it up.
61
64
  #: (Models::AuditStart, Models::Audit, Array[Models::Disposition], Models::DecidedPriorFindings,
62
65
  #| Models::AuditRecord) -> untyped
63
66
  def completion_result(start, audit, dispositions, decided, written)
@@ -66,7 +69,17 @@ module Principles
66
69
  completed = audit_result.completion(principle_id: audit.id, resolved: written.resolved_ids(decided),
67
70
  open: written.open_ids,
68
71
  changes: changes(start, audit, dispositions, written), decisions: decisions)
69
- @principles.set_up? ? completed : audit_result.offering_set_up(completed)
72
+ offering_set_up(completed)
73
+ end
74
+
75
+ # completed, with the offer to set principles up while it is not, and outside the plugin, whose hooks report
76
+ # changed members already, the offer of the hook entries that do.
77
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
78
+ def offering_set_up(completed)
79
+ return completed if @principles.set_up?
80
+
81
+ hooks = !@tool.runs_from.session_start_hook_in_this_session?
82
+ audit_result.offering_set_up(completed, hooks: hooks)
70
83
  end
71
84
 
72
85
  # What the audit changed in the project: the files to commit, in git the commits since the base, the
@@ -83,8 +96,8 @@ module Principles
83
96
  end
84
97
 
85
98
  # Each other principle with a member in paths, the files this audit's fixes changed, whose own text now
86
- # differs from what this tool last knew of it or whose reference broke, as list-member-problems reports it
87
- # (#410). A map this tool
99
+ # differs from what this tool last knew of it or whose reference broke, as list-member-problems reports it.
100
+ # A map this tool
88
101
  # cannot read names none here; list-member-problems reports it.
89
102
  #: (Models::Audit, Array[String]) -> Array[Views::PrincipleWithChangedMembers]
90
103
  def other_changed(audit, paths)
@@ -67,8 +67,8 @@ module Principles
67
67
  end
68
68
 
69
69
  # Runs the block, putting the running executable into any refusal a model raised, followed by this project,
70
- # so a repair runs on the same project from anywhere, as answer_with does (#572). rerun, when given, prints the
71
- # command running now with another member id, which a refusal naming a near miss leads its repair with (D56).
70
+ # so a repair runs on the same project from anywhere, as answer_with does. rerun, when given, prints the
71
+ # command running now with another member id, which a refusal naming a near miss leads its repair with.
72
72
  #: [T] (?rerun: (^(String) -> String)?) { () -> T } -> T
73
73
  def naming_the_executable(rerun: nil, &)
74
74
  yield
@@ -76,11 +76,11 @@ module Principles
76
76
  refusal = (rerun ? e.rerun_with_near_miss(&rerun) : e).printing_commands do |command|
77
77
  invocation.listed_in_project(command.command, command.values, options: command.options, usage: command.usage)
78
78
  end
79
- raise with_member_repairs(refusal).naming("#{@tool.executable} #{invocation.project_option}")
79
+ raise with_member_repairs(refusal).naming(invocation.prefix)
80
80
  end
81
81
 
82
82
  # A broken_members refusal, with each member's own repair commands beside it as repair_with, since a
83
- # model's repair can only name placeholders (#252). Any other refusal is returned as it is.
83
+ # model's repair can only name placeholders. Any other refusal is returned as it is.
84
84
  #: (Error) -> Error
85
85
  def with_member_repairs(error)
86
86
  return error unless error.payload["code"] == "broken_members"
@@ -97,7 +97,8 @@ module Principles
97
97
  def repaired(entry, repairs)
98
98
  principle = entry["principle"] or return entry
99
99
  id = entry["id"] or return entry
100
- moves = Models::MemberRepairMoves.new(@principles.find(principle).member(id), code: entry["code"]).to_a
100
+ member = @principles.find(principle).member(id)
101
+ moves = Models::MemberRepairMoves.new(member, code: entry["code"], tracked_as: entry["tracked_as"]).to_a
101
102
  entry.merge("repair_with" => repairs.commands(principle, id, moves))
102
103
  rescue Error
103
104
  entry
@@ -118,10 +119,10 @@ module Principles
118
119
  # The executable and project that printed commands name, built for each run and never stored.
119
120
  #: () -> Views::Invocation
120
121
  def invocation
121
- Views::Invocation.new(executable: @tool.executable, project: @project.root)
122
+ @tool.invocation(@project.root)
122
123
  end
123
124
 
124
- # Principle id as waiting on an upgrade, when a later copy wrote its record (D85, V8).
125
+ # Principle id as waiting on an upgrade, when a later copy wrote its record.
125
126
  #: (String) -> Views::RecordWaitingOnAnUpgrade?
126
127
  def waiting_on_an_upgrade(id)
127
128
  format = @audit_records.newer_format(id) or return
@@ -129,7 +130,7 @@ module Principles
129
130
  newest: Models::RecordFormat::NEWEST, update: format.update_either_way)
130
131
  end
131
132
 
132
- # The line saying principle id's audits wait on an upgrade, as a field to print beside it, or none (#1067).
133
+ # The line saying principle id's audits wait on an upgrade, as a field to print beside it, or none.
133
134
  #: (String) -> Hash[String, String]
134
135
  def waiting_beside(id) = waiting_on_an_upgrade(id)&.beside || {}
135
136
 
@@ -173,7 +174,7 @@ module Principles
173
174
  def member_loads(map, hooks = @project.hook_commands) = @project.member_loads(map.members, hooks)
174
175
 
175
176
  # The members a full audit lists to check against its activation, each with the decision its last completed
176
- # audit, whose record is given or read now, accepted on the member's loading (#355, #502).
177
+ # audit, whose record is given or read now, accepted on the member's loading.
177
178
  #: (Models::Audit, ?Models::AuditRecord?) -> Models::LoadsToCheck
178
179
  def loads_to_check(audit, record = @audit_records.find(audit.id))
179
180
  audit.loads_to_check(member_loads(audit.map), record)
@@ -188,12 +189,12 @@ module Principles
188
189
  carried: carried_assessments(audit, record), record: record)
189
190
  end
190
191
 
191
- # What each member's assessment was judged on beside its text: its map entry and when it loads (D49).
192
+ # What each member's assessment was judged on beside its text: its map entry and when it loads.
192
193
  #: (Models::Audit) -> Models::MemberGrounds
193
194
  def grounds(audit) = audit.grounds(member_loads(audit.map))
194
195
 
195
196
  # Which members' last assessments a full audit carries forward, from its record, given or read now, and the
196
- # question it asks (D49).
197
+ # question it asks.
197
198
  #: (Models::Audit, ?Models::AuditRecord?) -> Models::CarriedAssessments
198
199
  def carried_assessments(audit, record = @audit_records.find(audit.id))
199
200
  audit.carried_assessments(record, grounds: grounds(audit), question: Views::AssessmentRequest.question)
@@ -206,7 +207,7 @@ module Principles
206
207
  end
207
208
 
208
209
  # The members sharing a line with member where it is now, in map and in the other maps, as add-member and
209
- # show-principle print them (#383, #541).
210
+ # show-principle print them.
210
211
  #: (Models::Member, Models::Principle) -> Views::LinesSharedWithMember
211
212
  def lines_shared(member, map)
212
213
  Views::LinesSharedWithMember.new(**Models::MembersSharingLines.of(@project, member).facts_beside(map))