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
@@ -9,14 +9,15 @@ module Principles
9
9
  class InvocationOptions
10
10
  # The options that take a value; --help, -h and --version take none.
11
11
  VALUE_OPTIONS = %w[project file description path section starting-at ending-at query role
12
- check member session-start commits-after hook-event as instruction].freeze #: Array[String]
13
- # The options that take no value, as list-member-problems --short (#291).
14
- FLAG_OPTIONS = %w[short when-invoked always write-ups confirm].freeze #: Array[String]
15
- # The options that may be given more than once, each value kept in order, as change-activation --when-files.
16
- LIST_OPTIONS = %w[when-files also].freeze #: Array[String]
12
+ check session-start commits-after hook-event as instruction part].freeze #: Array[String]
13
+ # The options that take no value, as list-member-problems --short.
14
+ FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm].freeze #: Array[String]
15
+ # The options that may be given more than once, each value kept in order, as change-activation --when-files and
16
+ # start-audit --member.
17
+ LIST_OPTIONS = %w[when-files also member].freeze #: Array[String]
17
18
  # The words that name an option taking the next word as its value.
18
19
  VALUE_WORDS = (VALUE_OPTIONS + LIST_OPTIONS).map { |name| "--#{name}" }.freeze #: Array[String]
19
- # Every word the parser reads as an option, which an option taking a value refuses as its value (#750).
20
+ # Every word the parser reads as an option, which an option taking a value refuses as its value.
20
21
  WORDS = [*VALUE_WORDS, *FLAG_OPTIONS.map { |name| "--#{name}" }, "--help", "-h",
21
22
  "--version"].freeze #: Array[String]
22
23
 
@@ -0,0 +1,49 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "version"
5
+ require_relative "data/running_version"
6
+ require_relative "data/principles_on_path"
7
+ require_relative "controllers/running_tool"
8
+
9
+ module Principles
10
+ # This process as its entry point launched it: the executable that entry point names itself by, the file it was
11
+ # launched as, PATH and the folder it started in, read here so that no layer reads them. It gives every controller
12
+ # the same RunningTool.
13
+ class Launch
14
+ #: (String) -> void
15
+ def initialize(executable)
16
+ @executable = executable
17
+ freeze
18
+ end
19
+
20
+ # This run of the tool: the executable it was invoked as, its version, and what PATH and its folder say of it,
21
+ # each read only when a command needs it.
22
+ #: () -> Controllers::RunningTool
23
+ def running_tool
24
+ Controllers::RunningTool.new(executable: @executable, version: -> { running_version },
25
+ other_on_path: ->(asking) { on_path.other(asking) },
26
+ launched_on_path: -> { on_path.own_first? },
27
+ cwd: started_in)
28
+ end
29
+
30
+ private
31
+
32
+ # The folder this run was started in, by its real path, as a project's root is given, or nil when it is gone.
33
+ #: () -> String?
34
+ def started_in
35
+ File.realpath(Dir.pwd)
36
+ rescue SystemCallError
37
+ nil
38
+ end
39
+
40
+ # The principles on PATH, against this run's own file: the plugin's bin or a RubyGems binstub when either
41
+ # launched it, else this tool's executable.
42
+ #: () -> Data::PrinciplesOnPath
43
+ def on_path = Data::PrinciplesOnPath.new(ENV.fetch("PATH", ""), own: File.expand_path($PROGRAM_NAME))
44
+
45
+ # The version of this tool that is running, as a build stamped it or a checkout's commit gives it.
46
+ #: () -> String
47
+ def running_version = Data::RunningVersion.new(release: RELEASE, built: BUILT_VERSION).to_s
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation_options"
5
+
6
+ module Principles
7
+ # The options choosing which form list-open-findings prints, --lines or --short, and what is wrong with them
8
+ # as given, which CommandLine refuses as a usage error.
9
+ class ListOpenFindingsOptions
10
+ #: (InvocationOptions) -> void
11
+ def initialize(options)
12
+ @lines = !options.value("lines").nil? #: bool
13
+ @short = !options.value("short").nil? #: bool
14
+ freeze
15
+ end
16
+
17
+ # What is wrong with the options as given, or nil when they fit.
18
+ #: () -> String?
19
+ def fault
20
+ "--lines and --short each print a different form of the list; give one" if @lines && @short
21
+ end
22
+ end
23
+ end
@@ -7,9 +7,9 @@ module Principles
7
7
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
8
  module Models
9
9
  # The decision a completed audit accepted on a member's loading, kept in the member's record entry with the
10
- # member's text hash, as the next full audit shows it beside the member's row (#502 step 5). It changed since when
10
+ # member's text hash, as the next full audit shows it beside the member's row. It changed since when
11
11
  # what it weighed changed: when the member loads, or the member's own text. A file's size alone moves with every
12
- # edit elsewhere in a shared file, so it does not count (second alpha user on 5bedec4, #515).
12
+ # edit elsewhere in a shared file, so it does not count.
13
13
  class AcceptedLoading
14
14
  # entry is the member's record entry, holding loading_accepted and sha256.
15
15
  #: (Hash[String, untyped]) -> void
@@ -0,0 +1,106 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../error"
5
+ require_relative "acknowledgement_refusal"
6
+ require_relative "answer_place"
7
+ require_relative "audit_record"
8
+ require_relative "check_result_guide"
9
+ require_relative "listed_members"
10
+ require_relative "../prose_list"
11
+ require_relative "member"
12
+ require_relative "reported_check"
13
+
14
+ module Principles
15
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
16
+ module Models
17
+ # The run of its member's check that a one-member audit's answer reports: checked against the check
18
+ # the record ran, carrying the line its last review rested on, and accepted only once it passed, since a
19
+ # check that failed or could not run is a full audit's to judge.
20
+ class AcknowledgedCheck
21
+ # Where a one-member audit's answer gives its check_result, which a refusal of a field in it points into.
22
+ CHECK_RESULT = AnswerPlace.new("/check_result", "The acknowledgement") #: AnswerPlace
23
+
24
+ # record is the completed record the member is judged against. listed is what the member's check lists now,
25
+ # when it is this tool's own list-member-problems, which exits 3 while it lists the member.
26
+ #: (member: Member, principle_id: String, record: AuditRecord, ?listed: ListedMembers?) -> void
27
+ def initialize(member:, principle_id:, record:, listed: nil)
28
+ @member = member
29
+ @principle_id = principle_id
30
+ @record = record
31
+ @listed = listed
32
+ freeze
33
+ end
34
+
35
+ # The result the answer reports for the member's check, once it passed; nil for a member without a check,
36
+ # whose answer may report none.
37
+ #: (untyped) -> Hash[String, untyped]?
38
+ def result(answer)
39
+ check = @member.check
40
+ refuse("it has no check, so its answer reports no check_result") if !check && answer.key?("check_result")
41
+ return unless check
42
+
43
+ sent = answer["check_result"] or missing
44
+ passed(ReportedCheck.new(AnswerPlace.new("", "The acknowledgement"), check,
45
+ ran: @record.check_run_for(@member.key), kept: @record.check_review_for(@member.key),
46
+ guide: CheckResultGuide::ACKNOWLEDGEMENT)
47
+ .result(reported(sent, check)), sent)
48
+ end
49
+
50
+ private
51
+
52
+ # result, once its check exited 0, or 3 for this tool's own list-member-problems while it lists only members
53
+ # this answer acknowledges, which it lists no more once the record is committed. It always gives an
54
+ # exit status, since the answer's schema refuses not_run_reason. sent is the check_result as given.
55
+ #: (Hash[String, untyped], Hash[String, untyped]) -> Hash[String, untyped]
56
+ def passed(result, sent)
57
+ status = result.fetch("exit_status")
58
+ command = result.fetch("command")
59
+ return result if status.zero? || (status == 3 && lists_only_the_acknowledged?(command, sent))
60
+
61
+ refuse("its check `#{command}` exited #{status}, so a full audit judges it")
62
+ end
63
+
64
+ # Whether the member's check is this tool's own list-member-problems and lists only members this answer
65
+ # acknowledges, refusing a listed_members that is not what it lists now, and a listing of another member,
66
+ # which it would still list once the record is committed.
67
+ #: (String, Hash[String, untyped]) -> bool
68
+ def lists_only_the_acknowledged?(command, sent)
69
+ listed = @listed or return false
70
+ misreported(command) unless listed.reported?(sent["listed_members"])
71
+ others = listed.unacknowledged
72
+ return true if others.empty?
73
+
74
+ refuse("its check `#{command}` exited 3 and lists #{ProseList.new(others)}, which this " \
75
+ "answer does not acknowledge, so a full audit judges it")
76
+ end
77
+
78
+ # Refuses a listed_members that is not what the member's own list-member-problems check lists now.
79
+ #: (String) -> bot
80
+ def misreported(command)
81
+ raise CHECK_RESULT.child("listed_members").refusal(
82
+ Error.new("invalid_answer", "check_result.listed_members is not what `#{command}` lists now",
83
+ "Run `#{command}` and give, under check_result.listed_members, the member id in the second " \
84
+ "column of each line it prints.")
85
+ )
86
+ end
87
+
88
+ # The check_result the answer reports, its command read as the request printed it when left out.
89
+ #: (untyped, String) -> untyped
90
+ def reported(sent, check) = sent.is_a?(Hash) ? { "command" => check, **sent.except("listed_members") } : sent
91
+
92
+ # Refuses an answer for a checked member that reports no check_result, naming the instruction and template slot
93
+ # its request prints, not the full audit's answer_guide, which it does not.
94
+ #: () -> bot
95
+ def missing
96
+ raise CHECK_RESULT.refusal(
97
+ Error.new("invalid_check_result", "the member has a check, so its acknowledgement needs a check_result",
98
+ CheckResultGuide::ACKNOWLEDGEMENT.missing)
99
+ )
100
+ end
101
+
102
+ #: (String) -> bot
103
+ def refuse(why) = AcknowledgementRefusal.new(@member, @principle_id).refuse(why)
104
+ end
105
+ end
106
+ end
@@ -2,8 +2,10 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "../error"
5
+ require_relative "acknowledged_check"
5
6
  require_relative "acknowledgement_left_as_printed"
6
7
  require_relative "acknowledgement_refusal"
8
+ require_relative "acknowledgements"
7
9
  require_relative "request_id"
8
10
  require_relative "audit_record"
9
11
  require_relative "member"
@@ -11,21 +13,20 @@ require_relative "member_lines"
11
13
  require_relative "placement"
12
14
  require_relative "quoted_change"
13
15
  require_relative "reported_check"
14
- require_relative "answer_place"
15
16
  require_relative "template_placeholders"
16
17
 
17
18
  module Principles
18
19
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
19
20
  module Models
20
- # A one-member audit (D33): the agent says a committed change to one member keeps its meaning, quoting a line
21
+ # A one-member audit: the agent says a committed change to one member keeps its meaning, quoting a line
21
22
  # from before and after it, so the record's baseline for that member moves on and --short stops repeating it.
22
23
  # Refused outside git, for a member no completed audit assessed, and for an unchanged or checked member.
23
24
  class Acknowledgement
24
25
  PHASE = "acknowledgement"
25
26
  # The text the answer's template prints in each field the agent judges, which an answer may not send back, so
26
- # a template returned as printed acknowledges nothing (#773). It prints no quotes, which an answer leaving them
27
- # out reads as first_changed_lines (#1111, #1166, #1170). After a pure insertion, meaning_kept's says that an
28
- # inserted line usually adds a rule, for an agent that reads the template alone (#1142).
27
+ # a template returned as printed acknowledges nothing. It prints no quotes, which an answer leaving them
28
+ # out reads as first_changed_lines. After a pure insertion, meaning_kept's says that an
29
+ # inserted line usually adds a rule, for an agent that reads the template alone.
29
30
  PLACEHOLDERS = TemplatePlaceholders.new(
30
31
  { "meaning_kept" => "true only if the member still says the same thing",
31
32
  "reason" => "Why, in one line of your own" },
@@ -33,9 +34,9 @@ module Principles
33
34
  "a line, which usually adds a rule" }
34
35
  ) #: TemplatePlaceholders
35
36
  # The text a checked member's template prints where its check's exit status goes, short since the request's
36
- # context says how to run the check (#1170).
37
- EXIT_STATUS_PLACEHOLDER = "the check's exit status, an integer" #: String
38
- # The fields an answer may not send back as the template printed them, refused before its shape (#773, #1170).
37
+ # context says how to run the check.
38
+ EXIT_STATUS_PLACEHOLDER = ReportedCheck::EXIT_STATUS_PLACEHOLDER #: String
39
+ # The fields an answer may not send back as the template printed them, refused before its shape.
39
40
  LEFT_AS_PRINTED = AcknowledgementLeftAsPrinted.new(
40
41
  PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
41
42
  ) #: AcknowledgementLeftAsPrinted
@@ -58,16 +59,16 @@ module Principles
58
59
  end
59
60
 
60
61
  # The member's lines at its baseline and now, which the answer quotes; refused when the member cannot be found
61
- # where its baseline was read, since there is no line there to quote (#459); #baseline reads a moved member
62
- # where the map then placed it (#547).
62
+ # where its baseline was read, since there is no line there to quote; #baseline reads a moved member
63
+ # where the map then placed it.
63
64
  #: (MemberLines?) -> MemberLines
64
65
  def compared(lines)
65
66
  lines or refuse("it cannot be found in its file at its baseline commit #{last_judged_commit}")
66
67
  end
67
68
 
68
69
  # The member's baseline: the oldest of placements, from the commit it was last judged at on, that holds the
69
- # text the record vouches for, which is later than that commit when its full audit fixed it (#550), and as the
70
- # map then placed it when it has moved since (#547). Refused when none does, since that text is not the
70
+ # text the record vouches for, which is later than that commit when its full audit fixed it, and as the
71
+ # map then placed it when it has moved since. Refused when none does, since that text is not the
71
72
  # audited one.
72
73
  #: (Enumerable[Placement]) -> Placement
73
74
  def baseline(placements)
@@ -76,18 +77,18 @@ module Principles
76
77
  refuse("its text does not match the audit record at #{last_judged_commit} or any later commit")
77
78
  end
78
79
 
79
- # Where the member was at baseline, when that is not where it is now, as after a move (#547).
80
+ # Where the member was at baseline, when that is not where it is now, as after a move.
80
81
  #: (Placement) -> Hash[String, untyped]?
81
82
  def moved_from(baseline)
82
83
  baseline.reference unless baseline.reference == @member.reference
83
84
  end
84
85
 
85
- # The paths the change since baseline spans, which the baseline's placement owns (#551).
86
+ # The paths the change since baseline spans, which the baseline's placement owns.
86
87
  #: (Placement) -> Array[String]
87
88
  def paths_since(baseline) = baseline.paths_to(@member.path)
88
89
 
89
90
  # The commit the member was last judged at, when baseline is later than it, as when the member's own full
90
- # audit fixed it after its base (#550).
91
+ # audit fixed it after its base.
91
92
  #: (Placement) -> String?
92
93
  def audit_base(baseline)
93
94
  judged = last_judged_commit
@@ -118,40 +119,51 @@ module Principles
118
119
  end
119
120
 
120
121
  # The ids of the deferred and the accepted findings the last audit left on this member, which the request
121
- # and the acknowledgement name (D33), the accepted ones since an edit may bear on whether they still hold
122
- # (D35 brief, finding 11).
122
+ # and the acknowledgement name, the accepted ones since an edit may bear on whether they still hold
123
123
  #: () -> Hash[String, Array[String]]
124
124
  def open_findings
125
125
  { "deferred_findings" => findings_on_member("deferred"), "accepted_findings" => findings_on_member("accepted") }
126
126
  end
127
127
 
128
+ # Whether the last audit deferred a finding on this member, which acknowledging it leaves open for a full audit.
129
+ #: () -> bool
130
+ def keeps_deferred_findings? = findings_on_member("deferred").any?
131
+
132
+ # The answer's entry for its member, under members by the member's id as several members' entries are;
133
+ # refused when members leaves it out or holds another member.
134
+ #: (untyped) -> untyped
135
+ def entry_in(answer)
136
+ entries = answer.fetch("members")
137
+ refusal = Acknowledgements.unmatched(missing: [@member.id] - entries.keys, extra: entries.keys - [@member.id],
138
+ named_by: "basis.member_ids")
139
+ raise refusal if refusal
140
+
141
+ entries.fetch(@member.id)
142
+ end
143
+
128
144
  # The record with this member's baseline moved to its text now, once the answer is checked against the
129
145
  # member's lines at the baseline commit and now. The change keeps the check run the answer reported, which the
130
- # member's check_result cannot show was this run when the last audit's passed with the same command (#1112).
131
- #: (untyped, MemberLines, at: String) -> AuditRecord
132
- def accepted(answer, lines, at:)
146
+ # member's check_result cannot show was this run when the last audit's passed with the same command.
147
+ # into is the record the change is made to: the one this member is judged against, unless another member's
148
+ # acknowledgement in the same answer has already changed it. listed is what the member's check lists now, when
149
+ # it is this tool's own list-member-problems.
150
+ #: (untyped, MemberLines, at: String, ?into: AuditRecord?, ?listed: ListedMembers?) -> AuditRecord
151
+ def accepted(answer, lines, at:, into: nil, listed: nil)
133
152
  checked(answer, lines)
134
- result = check_result(answer)
153
+ result = check_result(answer, listed)
135
154
  run = result ? { "check_result" => result.slice("command", "exit_status") } : {}
136
- acknowledgeable.acknowledged(@member.key, { "from_sha256" => acknowledgeable.members.hash_for(@member.key),
137
- "to_sha256" => @now_sha256, "commit" => @base,
138
- "reason" => answer.fetch("reason"), "acknowledged_at" => at,
139
- **open_findings, **run }, check_result: result)
155
+ from = acknowledgeable.members.hash_for(@member.key)
156
+ (into || acknowledgeable).acknowledged(@member.key, { "from_sha256" => from, "to_sha256" => @now_sha256,
157
+ "commit" => @base, "reason" => answer.fetch("reason"),
158
+ "acknowledged_at" => at, **open_findings, **run },
159
+ check_result: result)
140
160
  end
141
161
 
142
- # The result the answer reports for the member's check, checked against the check the record ran and carrying
143
- # the line its last review rested on (D30, D63), once it passed: a check that failed or could not run is a full
144
- # audit's to judge (#1071). nil for a member without a check, whose answer may report none.
145
- #: (untyped) -> Hash[String, untyped]?
146
- def check_result(answer)
147
- check = @member.check
148
- refuse("it has no check, so its answer reports no check_result") if !check && answer.key?("check_result")
149
- return unless check
150
-
151
- record = acknowledgeable
152
- passed(ReportedCheck.new(AnswerPlace.new("", "The acknowledgement"), check,
153
- ran: record.check_run_for(@member.key), kept: record.check_review_for(@member.key))
154
- .result(reported_check(answer["check_result"], check)))
162
+ # The result the answer reports for the member's check, once it passed; nil for a member without a check.
163
+ #: (untyped, ?ListedMembers?) -> Hash[String, untyped]?
164
+ def check_result(answer, listed = nil)
165
+ AcknowledgedCheck.new(member: @member, principle_id: @principle_id, record: acknowledgeable, listed:)
166
+ .result(answer)
155
167
  end
156
168
 
157
169
  # The first line on each side of the change that the other lacks, which the request hints the quotes from.
@@ -160,26 +172,12 @@ module Principles
160
172
 
161
173
  private
162
174
 
163
- # result, once its check exited 0. It always gives an exit status, since the answer's schema refuses
164
- # not_run_reason (#1115).
165
- #: (Hash[String, untyped]) -> Hash[String, untyped]
166
- def passed(result)
167
- status = result.fetch("exit_status")
168
- return result if status.zero?
169
-
170
- refuse("its check `#{result.fetch("command")}` exited #{status}, so a full audit judges it")
171
- end
172
-
173
- # The check_result the answer reports, its command read as the request printed it when left out (#1166).
174
- #: (untyped, String) -> untyped
175
- def reported_check(reported, check) = reported.is_a?(Hash) ? { "command" => check, **reported } : reported
176
-
177
175
  # The change the answer quotes, between the member's lines at the baseline and now.
178
176
  #: (MemberLines) -> QuotedChange
179
177
  def quoted_change(lines) = QuotedChange.new(lines, member_id: @member.id)
180
178
 
181
179
  # The ids of the findings the last audit left open on this member with action, found by key, so a member moved
182
- # since keeps its findings (#547).
180
+ # since keeps its findings.
183
181
  #: (String) -> Array[String]
184
182
  def findings_on_member(action)
185
183
  acknowledgeable.left_open.select { |finding| finding.action == action && finding.on?(@member.key) }.map(&:id)
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "acknowledgements"
4
5
  require_relative "left_as_printed"
5
6
  require_relative "refusal_before_shape"
6
7
  require_relative "template_placeholders"
@@ -9,16 +10,17 @@ module Principles
9
10
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
11
  module Models
11
12
  # The fields a one-member audit's answer leaves as its template printed them, refused in one refusal before the
12
- # answer's shape: its judgement's, meaning_kept and reason (#773), and a checked member's exit_status, which was
13
- # otherwise refused as text with a repair offering the not_run_reason this template refuses (#1170). It holds the
14
- # placeholders the template prints in each; Acknowledgement::LEFT_AS_PRINTED is the one a one-member audit uses.
13
+ # answer's shape: its judgement's, meaning_kept and reason, and a checked member's exit_status, which was
14
+ # otherwise refused as text with a repair offering the not_run_reason this template refuses. It holds the
15
+ # placeholders the template prints in each; Acknowledgement::LEFT_AS_PRINTED is the one every acknowledgement uses.
15
16
  class AcknowledgementLeftAsPrinted
16
17
  include RefusalBeforeShape
17
18
 
18
19
  # The field, named as a refusal names it, where a checked member's answer reports its exit status.
19
20
  EXIT_STATUS = "check_result.exit_status" #: String
20
21
 
21
- # judged holds the placeholders of the judgement's fields, exit_status the one printed where the status goes.
22
+ # judged holds the placeholders of the judgement's fields, exit_status the one printed where the status goes;
23
+ # they are read in each entry of the answer's members, keyed by member id, for one member as for several.
22
24
  #: (TemplatePlaceholders, exit_status: String) -> void
23
25
  def initialize(judged, exit_status:)
24
26
  @judged = judged
@@ -31,11 +33,22 @@ module Principles
31
33
  def refuse_in(answer, _source, shape_problems)
32
34
  return unless answer.is_a?(Hash)
33
35
 
34
- LeftAsPrinted.new(left_in(answer).to_h { [it, "/#{it.tr(".", "/")}"] }).refuse(besides: shape_problems)
36
+ LeftAsPrinted.new(pointers_in(answer)).refuse(besides: shape_problems)
35
37
  end
36
38
 
37
39
  private
38
40
 
41
+ # Each field left as printed in each entry of the answer's members, by name, beside its pointer.
42
+ #: (Hash[String, untyped]) -> Hash[String, String]
43
+ def pointers_in(answer)
44
+ members = answer["members"]
45
+ return {} unless members.is_a?(Hash)
46
+
47
+ members.select { |_id, entry| entry.is_a?(Hash) }.flat_map do |id, entry|
48
+ left_in(entry).map { ["#{id} #{it}", "#{Acknowledgements.entry_pointer(id)}/#{it.tr(".", "/")}"] }
49
+ end.to_h
50
+ end
51
+
39
52
  # Each field answer leaves as printed, by name.
40
53
  #: (Hash[String, untyped]) -> Array[String]
41
54
  def left_in(answer)
@@ -7,21 +7,22 @@ require_relative "member"
7
7
  module Principles
8
8
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
9
9
  module Models
10
- # Why a one-member audit cannot judge a member's change (D33), as the audit record finds it: each sends the agent
11
- # to the full audit, but a member whose text is the one last judged needs nothing at all (#553).
10
+ # Why a one-member audit cannot judge a member's change, as the audit record finds it: each sends the agent
11
+ # to the full audit, but a member whose text is the one last judged needs nothing at all.
12
12
  class AcknowledgementRefusal
13
- # Why a one-member audit cannot judge member's change against record, or nil when it can (D33): the record must
13
+ # Why a one-member audit cannot judge member's change against record, or nil when it can: the record must
14
14
  # be completed and have assessed the member, the member's text must differ from the one it assessed, its check
15
- # must be the one the record ran, so none new, changed, removed or last not run escapes a full audit's review
16
- # (D33, #1071). The one owner of these preconditions, which
17
- # list-member-problems asks before offering the audit that Acknowledgement refuses by them (#626, #632); git is
15
+ # must be the one the record ran, so none new, changed, removed or last not run escapes a full audit's review.
16
+ # The one owner of these preconditions, which
17
+ # list-member-problems asks before offering the audit that Acknowledgement refuses by them; git is
18
18
  # the callers' to know.
19
19
  #: (AuditRecord, Member, now_sha256: String?) -> AcknowledgementRefusal?
20
20
  def self.of(record, member, now_sha256:)
21
21
  members = record.members
22
22
  recorded = members.hash_for(member.key)
23
23
  check = members.check_since(member.key, member.check)
24
- reason = if !record.completed? then :not_completed
24
+ reason = if record.open_after_a_completed_audit? then :open
25
+ elsif !record.completed? then :not_completed
25
26
  elsif !recorded then :not_assessed
26
27
  elsif recorded == now_sha256 then :unchanged
27
28
  elsif check != :unchanged then check
@@ -30,7 +31,7 @@ module Principles
30
31
  end
31
32
 
32
33
  # principle_id is the member's principle, whose full audit each refusal names. reason, which raise! raises, is
33
- # :not_completed, :not_assessed, :unchanged, or how the member's check stands to the one the record
34
+ # :open, :not_completed, :not_assessed, :unchanged, or how the member's check stands to the one the record
34
35
  # ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason it
35
36
  # only refuses for a reason its caller states.
36
37
  #: (Member, String, ?Symbol?, ?ran: String?) -> void
@@ -54,6 +55,7 @@ module Principles
54
55
  def raise!
55
56
  case @reason
56
57
  when :unchanged then nothing_to_acknowledge
58
+ when :open then open_audit
57
59
  when :not_completed then refuse("#{@principle_id} has no completed audit, so no baseline has been judged")
58
60
  when :not_assessed then refuse("no completed audit assessed #{@member.id}")
59
61
  else refuse("#{check_since_record}, so a full audit reviews it")
@@ -62,7 +64,7 @@ module Principles
62
64
 
63
65
  private
64
66
 
65
- # How the member's check stands to the one the record ran, which a full audit reviews before it runs (#1071).
67
+ # How the member's check stands to the one the record ran, which a full audit reviews before it runs.
66
68
  #: () -> String
67
69
  def check_since_record
68
70
  case @reason
@@ -74,8 +76,21 @@ module Principles
74
76
  end
75
77
  end
76
78
 
79
+ # A full audit open on a completed one, waiting on its correction: the step to finish, not a missing audit to
80
+ # run, after which the member is acknowledged if it still differs from what that audit judged.
81
+ #: () -> bot
82
+ def open_audit
83
+ raise Error.new("cannot_acknowledge",
84
+ "#{@member.id} cannot be acknowledged: #{@principle_id} has a full audit open, waiting on " \
85
+ "its correction",
86
+ "Submit that correction to complete the audit; then acknowledge this member if it is still " \
87
+ "listed as changed.")
88
+ .ending_with([Error::RepairCommand.new(purpose: "To start the full audit again instead",
89
+ command: "start-audit", values: [@principle_id])])
90
+ end
91
+
77
92
  # A member whose text is the one last judged, as after a pure move, needs nothing: not an acknowledgement, and
78
- # not the full audit the other refusals send the agent to (#553).
93
+ # not the full audit the other refusals send the agent to.
79
94
  #: () -> bot
80
95
  def nothing_to_acknowledge
81
96
  raise Error.new("cannot_acknowledge",