principles 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +383 -0
  3. data/LICENSE +202 -0
  4. data/NOTICE +4 -0
  5. data/README.md +111 -0
  6. data/exe/principles +20 -0
  7. data/lib/principles/after_commit_hook_options.rb +2 -2
  8. data/lib/principles/cli.rb +50 -42
  9. data/lib/principles/command_line.rb +22 -16
  10. data/lib/principles/command_routes.rb +20 -6
  11. data/lib/principles/controllers/acknowledgement.rb +29 -74
  12. data/lib/principles/controllers/acknowledgements.rb +154 -0
  13. data/lib/principles/controllers/after_commit_report.rb +44 -0
  14. data/lib/principles/controllers/answer.rb +48 -18
  15. data/lib/principles/controllers/answer_phase.rb +20 -3
  16. data/lib/principles/controllers/assessment.rb +32 -11
  17. data/lib/principles/controllers/audit.rb +43 -19
  18. data/lib/principles/controllers/audit_completion.rb +21 -12
  19. data/lib/principles/controllers/command.rb +13 -12
  20. data/lib/principles/controllers/correction.rb +15 -7
  21. data/lib/principles/controllers/first_audit_brief.rb +40 -0
  22. data/lib/principles/controllers/full_audit_request.rb +41 -82
  23. data/lib/principles/controllers/hook_setup.rb +49 -0
  24. data/lib/principles/controllers/inventory.rb +10 -8
  25. data/lib/principles/controllers/mapping.rb +2 -2
  26. data/lib/principles/controllers/member_acknowledgement.rb +32 -21
  27. data/lib/principles/controllers/member_entries.rb +4 -4
  28. data/lib/principles/controllers/member_problems_report.rb +62 -16
  29. data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
  30. data/lib/principles/controllers/members_to_assess.rb +23 -20
  31. data/lib/principles/controllers/meta_principle_setup.rb +5 -6
  32. data/lib/principles/controllers/open_correction.rb +42 -0
  33. data/lib/principles/controllers/parts_to_read.rb +117 -0
  34. data/lib/principles/controllers/repoint.rb +1 -1
  35. data/lib/principles/controllers/running_tool.rb +56 -6
  36. data/lib/principles/controllers/session_start_report.rb +62 -0
  37. data/lib/principles/controllers/survey.rb +2 -2
  38. data/lib/principles/data/audit_files.rb +7 -7
  39. data/lib/principles/data/bounded_file.rb +1 -1
  40. data/lib/principles/data/candidate_files_found.rb +6 -3
  41. data/lib/principles/data/command-steps.json +61 -6
  42. data/lib/principles/data/expected_type.rb +3 -3
  43. data/lib/principles/data/first_parent_log.rb +1 -1
  44. data/lib/principles/data/head_reflog.rb +74 -0
  45. data/lib/principles/data/hook_input.rb +59 -0
  46. data/lib/principles/data/ignored_by_git.rb +2 -2
  47. data/lib/principles/data/known_fields.rb +1 -1
  48. data/lib/principles/data/linked_path.rb +1 -1
  49. data/lib/principles/data/map_files.rb +2 -2
  50. data/lib/principles/data/principles_on_path.rb +83 -0
  51. data/lib/principles/data/principles_subfolder.rb +1 -1
  52. data/lib/principles/data/project_files.rb +10 -3
  53. data/lib/principles/data/repository.rb +14 -7
  54. data/lib/principles/data/running_version.rb +10 -8
  55. data/lib/principles/data/schema_check.rb +5 -5
  56. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -21
  57. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
  58. data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
  59. data/lib/principles/data/schemas/audit-record.schema.json +29 -20
  60. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  61. data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
  62. data/lib/principles/data/schemas/correction-answer.schema.json +9 -9
  63. data/lib/principles/data/schemas/member-map.schema.json +3 -3
  64. data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
  65. data/lib/principles/error.rb +4 -4
  66. data/lib/principles/failure_refusal.rb +57 -0
  67. data/lib/principles/invocation_options.rb +4 -4
  68. data/lib/principles/launch.rb +49 -0
  69. data/lib/principles/list_open_findings_options.rb +1 -1
  70. data/lib/principles/models/accepted_loading.rb +2 -2
  71. data/lib/principles/models/acknowledged_check.rb +23 -11
  72. data/lib/principles/models/acknowledgement.rb +34 -18
  73. data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
  74. data/lib/principles/models/acknowledgement_refusal.rb +25 -10
  75. data/lib/principles/models/acknowledgements.rb +45 -29
  76. data/lib/principles/models/acknowledgements_across.rb +68 -0
  77. data/lib/principles/models/activation.rb +2 -2
  78. data/lib/principles/models/after_commit_input.rb +115 -0
  79. data/lib/principles/models/agent_loads.rb +1 -1
  80. data/lib/principles/models/answer_fields.rb +2 -2
  81. data/lib/principles/models/answer_place.rb +3 -3
  82. data/lib/principles/models/answer_text.rb +2 -2
  83. data/lib/principles/models/answered_time.rb +4 -4
  84. data/lib/principles/models/assessment_answer.rb +10 -10
  85. data/lib/principles/models/assessment_basis.rb +2 -2
  86. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  87. data/lib/principles/models/assessment_report.rb +6 -7
  88. data/lib/principles/models/audit.rb +33 -34
  89. data/lib/principles/models/audit_record.rb +54 -28
  90. data/lib/principles/models/audit_records.rb +13 -13
  91. data/lib/principles/models/audit_start.rb +3 -3
  92. data/lib/principles/models/audited_member_lines.rb +1 -1
  93. data/lib/principles/models/candidate_files.rb +18 -10
  94. data/lib/principles/models/candidate_inventory.rb +6 -6
  95. data/lib/principles/models/candidate_outline.rb +9 -9
  96. data/lib/principles/models/carried_assessments.rb +18 -3
  97. data/lib/principles/models/carried_member.rb +5 -5
  98. data/lib/principles/models/changed_regions.rb +92 -0
  99. data/lib/principles/models/check_result_guide.rb +50 -0
  100. data/lib/principles/models/check_since_last_audit.rb +5 -4
  101. data/lib/principles/models/cited_files.rb +4 -4
  102. data/lib/principles/models/command_steps.rb +3 -3
  103. data/lib/principles/models/commits_brought_in.rb +1 -1
  104. data/lib/principles/models/commits_since_base.rb +1 -1
  105. data/lib/principles/models/correction_answer.rb +2 -2
  106. data/lib/principles/models/correction_basis.rb +7 -7
  107. data/lib/principles/models/dated_line.rb +1 -2
  108. data/lib/principles/models/decided_prior_findings.rb +6 -6
  109. data/lib/principles/models/declared_map_changes.rb +5 -5
  110. data/lib/principles/models/disposition.rb +21 -21
  111. data/lib/principles/models/entry_file.rb +1 -1
  112. data/lib/principles/models/entry_files.rb +1 -1
  113. data/lib/principles/models/evidence_item.rb +1 -1
  114. data/lib/principles/models/evidence_lines_since.rb +2 -2
  115. data/lib/principles/models/evidence_replacements.rb +3 -3
  116. data/lib/principles/models/finding_write_ups.rb +12 -5
  117. data/lib/principles/models/findings_left_open.rb +4 -4
  118. data/lib/principles/models/first_full_audit.rb +32 -0
  119. data/lib/principles/models/first_raised_claim.rb +1 -1
  120. data/lib/principles/models/fix_only_fields.rb +1 -1
  121. data/lib/principles/models/head_moves.rb +66 -0
  122. data/lib/principles/models/hook_commands.rb +49 -4
  123. data/lib/principles/models/ignored_candidates.rb +1 -1
  124. data/lib/principles/models/instruction_named.rb +2 -3
  125. data/lib/principles/models/json_digest.rb +2 -2
  126. data/lib/principles/models/json_path_query.rb +1 -1
  127. data/lib/principles/models/kept_prior_finding.rb +9 -9
  128. data/lib/principles/models/last_completed_revision.rb +4 -5
  129. data/lib/principles/models/left_as_printed.rb +2 -2
  130. data/lib/principles/models/line_diff.rb +113 -0
  131. data/lib/principles/models/line_span.rb +1 -1
  132. data/lib/principles/models/list_member_problems_check.rb +4 -4
  133. data/lib/principles/models/listed_members.rb +7 -9
  134. data/lib/principles/models/loaded_files.rb +4 -5
  135. data/lib/principles/models/loading_decision.rb +3 -3
  136. data/lib/principles/models/loading_facts.rb +1 -1
  137. data/lib/principles/models/loads_to_check.rb +1 -1
  138. data/lib/principles/models/located_text.rb +1 -1
  139. data/lib/principles/models/mapped_principles.rb +2 -2
  140. data/lib/principles/models/member.rb +31 -4
  141. data/lib/principles/models/member_assessments.rb +8 -8
  142. data/lib/principles/models/member_elsewhere.rb +4 -4
  143. data/lib/principles/models/member_file.rb +4 -4
  144. data/lib/principles/models/member_grounds.rb +1 -1
  145. data/lib/principles/models/member_hashes_as_written.rb +1 -1
  146. data/lib/principles/models/member_lines.rb +29 -61
  147. data/lib/principles/models/member_loads.rb +2 -2
  148. data/lib/principles/models/member_moves.rb +1 -1
  149. data/lib/principles/models/member_problems.rb +14 -15
  150. data/lib/principles/models/member_repair_moves.rb +15 -9
  151. data/lib/principles/models/member_sighting.rb +10 -10
  152. data/lib/principles/models/member_snapshots.rb +1 -1
  153. data/lib/principles/models/member_state.rb +1 -1
  154. data/lib/principles/models/members_across_principles.rb +77 -0
  155. data/lib/principles/models/members_elsewhere.rb +2 -2
  156. data/lib/principles/models/members_sharing_lines.rb +7 -7
  157. data/lib/principles/models/meta_principle.rb +11 -4
  158. data/lib/principles/models/missing_files.rb +3 -3
  159. data/lib/principles/models/new_findings.rb +4 -4
  160. data/lib/principles/models/open_correction.rb +57 -0
  161. data/lib/principles/models/open_finding.rb +36 -31
  162. data/lib/principles/models/open_findings_elsewhere.rb +2 -2
  163. data/lib/principles/models/other_principles.rb +2 -2
  164. data/lib/principles/models/other_templates_placeholders.rb +17 -16
  165. data/lib/principles/models/outline_budget.rb +7 -7
  166. data/lib/principles/models/outline_group.rb +1 -1
  167. data/lib/principles/models/outline_section.rb +2 -2
  168. data/lib/principles/models/part_named.rb +41 -0
  169. data/lib/principles/models/placement.rb +2 -2
  170. data/lib/principles/models/principle.rb +13 -13
  171. data/lib/principles/models/principle_history.rb +8 -8
  172. data/lib/principles/models/principle_members.rb +14 -7
  173. data/lib/principles/models/principles_folder_move.rb +1 -1
  174. data/lib/principles/models/principles_on_path.rb +29 -0
  175. data/lib/principles/models/principles_package.rb +3 -3
  176. data/lib/principles/models/prior_decision_fields.rb +8 -8
  177. data/lib/principles/models/prior_finding_decision.rb +8 -8
  178. data/lib/principles/models/prior_finding_outcomes.rb +1 -1
  179. data/lib/principles/models/prior_findings.rb +5 -5
  180. data/lib/principles/models/problem_report.rb +26 -8
  181. data/lib/principles/models/project.rb +27 -19
  182. data/lib/principles/models/project_history.rb +18 -12
  183. data/lib/principles/models/quoted_change.rb +8 -8
  184. data/lib/principles/models/recent_decision.rb +3 -3
  185. data/lib/principles/models/record_format.rb +16 -10
  186. data/lib/principles/models/record_judged_against.rb +4 -4
  187. data/lib/principles/models/recorded_entry.rb +17 -8
  188. data/lib/principles/models/recorded_finding.rb +9 -9
  189. data/lib/principles/models/recorded_findings.rb +2 -2
  190. data/lib/principles/models/recorded_hashes.rb +2 -2
  191. data/lib/principles/models/recorded_members.rb +13 -13
  192. data/lib/principles/models/refusal_before_shape.rb +2 -2
  193. data/lib/principles/models/repoint.rb +3 -3
  194. data/lib/principles/models/report_hooks.rb +69 -0
  195. data/lib/principles/models/reported_check.rb +34 -31
  196. data/lib/principles/models/request_id.rb +18 -6
  197. data/lib/principles/models/runs_from.rb +7 -2
  198. data/lib/principles/models/sent_answer.rb +14 -12
  199. data/lib/principles/models/sent_prior_decisions.rb +1 -1
  200. data/lib/principles/models/session_start_input.rb +37 -0
  201. data/lib/principles/models/shape_problems_beside.rb +1 -1
  202. data/lib/principles/models/skill_loads.rb +1 -1
  203. data/lib/principles/models/stale_request.rb +59 -0
  204. data/lib/principles/models/still_holds_restatement.rb +6 -6
  205. data/lib/principles/models/submitted_answer.rb +1 -1
  206. data/lib/principles/models/template_placeholders.rb +6 -6
  207. data/lib/principles/models/text_within.rb +1 -1
  208. data/lib/principles/models/tracked_paths.rb +38 -0
  209. data/lib/principles/models/unchecked_members.rb +2 -2
  210. data/lib/principles/models/uncommitted_files.rb +1 -1
  211. data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
  212. data/lib/principles/models/waits_on.rb +1 -1
  213. data/lib/principles/models/write_up_opening.rb +5 -5
  214. data/lib/principles/models/write_up_pointer.rb +3 -3
  215. data/lib/principles/models/write_up_repoint.rb +2 -3
  216. data/lib/principles/positional_arguments.rb +13 -6
  217. data/lib/principles/prose_list.rb +1 -1
  218. data/lib/principles/session_start_options.rb +1 -1
  219. data/lib/principles/start_audit_options.rb +46 -12
  220. data/lib/principles/supported_ruby.rb +24 -7
  221. data/lib/principles/version.rb +2 -2
  222. data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
  223. data/lib/principles/views/acknowledgement_result.rb +97 -11
  224. data/lib/principles/views/activation_in_hand.rb +1 -1
  225. data/lib/principles/views/answered_request.rb +6 -2
  226. data/lib/principles/views/assessed_members.rb +50 -41
  227. data/lib/principles/views/assessment_request.rb +39 -36
  228. data/lib/principles/views/audit_changes.rb +4 -4
  229. data/lib/principles/views/audit_commit.rb +5 -4
  230. data/lib/principles/views/audit_result.rb +92 -53
  231. data/lib/principles/views/candidate_files_result.rb +7 -6
  232. data/lib/principles/views/check_notes.rb +29 -6
  233. data/lib/principles/views/check_result_template.rb +45 -34
  234. data/lib/principles/views/completed_audit_next_step.rb +44 -0
  235. data/lib/principles/views/context_parts.rb +112 -0
  236. data/lib/principles/views/correction_request.rb +44 -25
  237. data/lib/principles/views/diff_since_last_audit.rb +8 -6
  238. data/lib/principles/views/findings_result.rb +17 -6
  239. data/lib/principles/views/first_audit_brief.rb +51 -0
  240. data/lib/principles/views/first_audit_line.rb +45 -0
  241. data/lib/principles/views/help.rb +4 -4
  242. data/lib/principles/views/hook_setup_result.rb +91 -0
  243. data/lib/principles/views/instruction.rb +3 -3
  244. data/lib/principles/views/invocation.rb +14 -6
  245. data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
  246. data/lib/principles/views/landed_since_base.rb +1 -1
  247. data/lib/principles/views/line_history_since_last_audit.rb +35 -0
  248. data/lib/principles/views/lines_shared_with_member.rb +6 -6
  249. data/lib/principles/views/loads_to_check_result.rb +8 -5
  250. data/lib/principles/views/map_added_to.rb +3 -3
  251. data/lib/principles/views/map_result.rb +9 -9
  252. data/lib/principles/views/member_change_since_baseline.rb +44 -23
  253. data/lib/principles/views/member_lines_beside_text.rb +43 -0
  254. data/lib/principles/views/member_repairs.rb +3 -2
  255. data/lib/principles/views/member_row.rb +2 -2
  256. data/lib/principles/views/members_a_commit_changed.rb +13 -10
  257. data/lib/principles/views/members_with_no_baseline.rb +3 -3
  258. data/lib/principles/views/meta_principle_passage.rb +1 -1
  259. data/lib/principles/views/meta_principle_result.rb +12 -5
  260. data/lib/principles/views/one_member_check_result_template.rb +7 -7
  261. data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
  262. data/lib/principles/views/open_findings_line.rb +25 -36
  263. data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
  264. data/lib/principles/views/outside_the_map_result.rb +5 -2
  265. data/lib/principles/views/package_since_last_audit_result.rb +29 -6
  266. data/lib/principles/views/parts_index_result.rb +60 -0
  267. data/lib/principles/views/principle_read_result.rb +5 -6
  268. data/lib/principles/views/principle_with_changed_members.rb +1 -1
  269. data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
  270. data/lib/principles/views/printed_json.rb +51 -0
  271. data/lib/principles/views/printed_principle.rb +1 -1
  272. data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
  273. data/lib/principles/views/prior_findings_result.rb +17 -14
  274. data/lib/principles/views/problem_lines.rb +39 -17
  275. data/lib/principles/views/problem_result.rb +40 -37
  276. data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
  277. data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
  278. data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
  279. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
  280. data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
  281. data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
  282. data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
  283. data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
  284. data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
  285. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
  286. data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
  287. data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
  288. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
  289. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
  290. data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
  291. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  292. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
  293. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
  294. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
  295. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
  296. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
  297. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
  298. data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
  299. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
  300. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +20 -18
  301. data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
  302. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
  303. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
  304. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
  305. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +21 -22
  306. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
  307. data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
  308. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
  309. data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
  310. data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
  311. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
  312. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -1
  313. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
  314. data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
  315. data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
  316. data/lib/principles/views/prompts.rb +1 -1
  317. data/lib/principles/views/read_the_change.rb +36 -0
  318. data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
  319. data/lib/principles/views/repoint_result.rb +1 -1
  320. data/lib/principles/views/report_hooks_offer.rb +25 -0
  321. data/lib/principles/views/request_part.rb +5 -5
  322. data/lib/principles/views/request_parts.rb +1 -1
  323. data/lib/principles/views/session_start_report.rb +46 -0
  324. data/lib/principles/views/shell_word.rb +1 -1
  325. data/lib/principles/views/trimmed_instructions_note.rb +30 -0
  326. data/lib/principles/views/visible_text.rb +1 -1
  327. data/lib/principles/views/workflow_diagram.rb +1 -1
  328. data/principles.gemspec +44 -0
  329. metadata +83 -14
  330. data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
  331. data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
@@ -0,0 +1,38 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../error"
5
+
6
+ module Principles
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
+ module Models
9
+ # Every path git tracks, as git spells it, which tells a path renamed in case alone from the old spelling a disk
10
+ # that folds case, such as macOS's default, still opens. Outside git it holds none, and refuses nothing.
11
+ class TrackedPaths
12
+ #: (Array[String]) -> void
13
+ def initialize(paths)
14
+ @paths = paths.to_set #: Set[String]
15
+ freeze
16
+ end
17
+
18
+ # The spelling git tracks path under when it tracks it only in another case; nil when git tracks path as spelt,
19
+ # or no spelling of it at all.
20
+ #: (String) -> String?
21
+ def other_case_of(path)
22
+ @paths.find { it.casecmp?(path) } unless @paths.include?(path)
23
+ end
24
+
25
+ # path, refused while git tracks it only in another case: this disk opens it, but a clone on a disk that does
26
+ # not fold case would not find it.
27
+ #: (String) -> String
28
+ def spelt_as_tracked(path)
29
+ tracked = other_case_of(path) or return path
30
+
31
+ raise Error.new("renamed_in_case", "git tracks #{path} only as #{tracked}, renamed in case alone: this disk " \
32
+ "still opens the old name, but a clone on a case-sensitive disk would not",
33
+ "Check that #{tracked} is the file this member was mapped in, then move the member to " \
34
+ "that path with move-member.", path).including("tracked_as" => tracked)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -11,7 +11,7 @@ module Principles
11
11
  module Models
12
12
  # The members of a principle that name no check, whose assessments take no check_result. An answer is read for
13
13
  # one before its shape is checked, since the shape would ask for the command such a check_result lacks, sending
14
- # the agent to fill in what it should remove (#1088).
14
+ # the agent to fill in what it should remove.
15
15
  class UncheckedMembers
16
16
  include RefusalBeforeShape
17
17
 
@@ -38,7 +38,7 @@ module Principles
38
38
  end
39
39
 
40
40
  # Refuses reported, the check_result given on the assessment at place of a member with no check, naming the
41
- # members that hold the principle's checks, since an agent may have taken this one for one of them (#1090); nil
41
+ # members that hold the principle's checks, since an agent may have taken this one for one of them; nil
42
42
  # when none is given, as such an assessment should.
43
43
  #: (AnswerPlace, untyped) -> nil
44
44
  def refuse_at(place, reported)
@@ -22,7 +22,7 @@ module Principles
22
22
  end
23
23
 
24
24
  # Refuses the write-up at path while it, or a file its links lead to, differs from HEAD: the record is committed
25
- # pointing at it, so a fresh clone would find nothing there (#760).
25
+ # pointing at it, so a fresh clone would find nothing there.
26
26
  #: (String) -> void
27
27
  def refuse_write_up(path)
28
28
  return if @paths.empty?
@@ -5,8 +5,8 @@ module Principles
5
5
  # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
6
6
  module Models
7
7
  # The project's files outside a principle's map that differ from the audit's base commit, as an assessment
8
- # request names them (#409). A project with many untracked files would put every one into each request, so
9
- # it names the first few and counts the rest (#426, D38).
8
+ # request names them. A project with many untracked files would put every one into each request, so
9
+ # it names the first few and counts the rest.
10
10
  class UncommittedOutsideTheMap
11
11
  # The most paths a request names: enough to show a pattern, such as a generated folder, in a short list of
12
12
  # its own; git status lists them all.
@@ -8,7 +8,7 @@ require_relative "dated_line"
8
8
  module Principles
9
9
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
10
  module Models
11
- # The one line an answer may give on a deferred finding, saying whom it waits on and to decide what (D52).
11
+ # The one line an answer may give on a deferred finding, saying whom it waits on and to decide what.
12
12
  # What the line says is the agent's judgement; this tool checks only that it is one line, on a finding left
13
13
  # deferred. A null stands on any finding, so a template's null kept on another action is not refused.
14
14
  class WaitsOn
@@ -5,7 +5,7 @@ module Principles
5
5
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
6
6
  module Models
7
7
  # The opening of a write-up's region in a file's text: what list-open-findings prints as a finding's
8
- # write_up_opening, and show-answer-check previews (#300, #411). This tool does not judge what it says.
8
+ # write_up_opening, and show-answer-check previews. This tool does not judge what it says.
9
9
  class WriteUpOpening
10
10
  # The longest opening printed whole; a longer one is cut and marked truncated.
11
11
  LIMIT = 200
@@ -61,7 +61,7 @@ module Principles
61
61
  private
62
62
 
63
63
  # text whole within the limit, or else up to the last whole word that fits, since a cut mid-word reads as a
64
- # different phrase (#1078); one word longer than the limit is cut where the limit falls.
64
+ # different phrase; one word longer than the limit is cut where the limit falls.
65
65
  #: (String) -> String
66
66
  def cut(text)
67
67
  return text if text.length <= LIMIT
@@ -71,10 +71,10 @@ module Principles
71
71
  fits[0, boundary].to_s
72
72
  end
73
73
 
74
- # A heading line whole, since a heading is not a sentence and "F4." may number it (#739). Otherwise the
74
+ # A heading line whole, since a heading is not a sentence and "F4." may number it. Otherwise the
75
75
  # first sentence: hard-wrapped lines joined with single spaces up to the sentence's end, or else to its
76
76
  # paragraph's end, a blank line, the next list item or heading, or the file's end. It runs past the region's
77
- # end, since a starting_at alone locates one line (#697).
77
+ # end, since a starting_at alone locates one line.
78
78
  #: (Integer) -> String
79
79
  def opening_text(index)
80
80
  return line(index).text if line(index).heading?
@@ -90,7 +90,7 @@ module Principles
90
90
  end
91
91
 
92
92
  # text up to the end of its first sentence, or all of it when none ends. A mark inside a parenthesis, as in
93
- # "(e.g. this)", ends no sentence, since cutting there leaves a fragment (#1078).
93
+ # "(e.g. this)", ends no sentence, since cutting there leaves a fragment.
94
94
  #: (String) -> String
95
95
  def sentence(text)
96
96
  ends = text.to_enum(:scan, SENTENCE_END).map { Regexp.last_match&.end(0) }
@@ -7,7 +7,7 @@ module Principles
7
7
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
8
  module Models
9
9
  # Where a finding is written up, as its record's recorded_at keeps it: a path, with a heading or a starting_at
10
- # inside it (#768). It holds that place as the Locator the hash it was read from gives, which keeps its keys, nulls
10
+ # inside it. It holds that place as the Locator the hash it was read from gives, which keeps its keys, nulls
11
11
  # and order, since the record's bytes and each digest over them depend on it; two pointers are the same when
12
12
  # those hashes hold the same keys and values, in any order.
13
13
  class WriteUpPointer
@@ -25,12 +25,12 @@ module Principles
25
25
  #: () -> bool
26
26
  def starting_at? = !@locator.starting_at.nil?
27
27
 
28
- # The same heading or starting_at in the file at path, as a repoint checks git's match for a missing file (#722).
28
+ # The same heading or starting_at in the file at path, as a repoint checks git's match for a missing file.
29
29
  #: (String) -> WriteUpPointer
30
30
  def in_file(path) = WriteUpPointer.new(to_h.merge("path" => path))
31
31
 
32
32
  # The opening of its write-up in project's file as it stands now, as WriteUpOpening finds it, or nil when there
33
- # is none; refused when the pointer no longer resolves (#300).
33
+ # is none; refused when the pointer no longer resolves.
34
34
  #: (Project) -> Hash[String, untyped]?
35
35
  def opening_in(project) = project.member_file(path).write_up_opening(@locator)
36
36
 
@@ -8,12 +8,11 @@ require_relative "write_up_pointer"
8
8
  module Principles
9
9
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
10
  module Models
11
- # One finding's write-up pointer moved by a repoint (D59): the finding it names, the recorded_at the agent
11
+ # One finding's write-up pointer moved by a repoint: the finding it names, the recorded_at the agent
12
12
  # found the write-up at, and why. It moves a finding there, keeping where it pointed before, when and why.
13
13
  class WriteUpRepoint
14
14
  # The repoint one entry of an answer's repoints gives, to recorded_at, its pointer already located, refused by
15
- # fields without a reason, since the record keeps why each pointer moved (#760), naming its place in the answer
16
- # (#787).
15
+ # fields without a reason, since the record keeps why each pointer moved, naming its place in the answer.
17
16
  #: (Hash[String, untyped], WriteUpPointer, AnswerFields, AnswerPlace) -> WriteUpRepoint
18
17
  def self.answered(repoint, recorded_at, fields, place)
19
18
  new(finding_id: repoint.fetch("finding_id"), recorded_at: recorded_at,
@@ -15,24 +15,31 @@ module Principles
15
15
  def id = %w[id id?].include?(@names.first) ? @values.first : nil
16
16
 
17
17
  # Every named argument other than the principle id, as the controller receives it, an optional one by its name
18
- # without the ?.
18
+ # without the ?, and a last one named NAME... under NAME, holding every value from its place on, which NAME?...
19
+ # lets be none.
19
20
  #: () -> Hash[String, untyped]
20
21
  def bindings
21
22
  bound = @names.map { it.chomp("?") }.zip(@values).to_h.except("id")
22
- repeated = @names.last
23
- return bound unless repeated == "path..."
23
+ return bound unless repeats?
24
24
 
25
- bound.except(repeated).merge("path" => @values.drop(@names.length - 1))
25
+ repeated = @names.last.to_s
26
+ bound.except(repeated).merge(repeated.delete_suffix("...").chomp("?") => @values.drop(@names.length - 1))
26
27
  end
27
28
 
28
29
  #: () -> Array[String]
29
- def missing = @names.drop(@values.length).reject { |name| name.end_with?("?") }.map(&:upcase)
30
+ def missing = @names.drop(@values.length).reject { |name| name.delete_suffix("...").end_with?("?") }.map(&:upcase)
30
31
 
31
32
  #: () -> bool
32
- def too_many? = @names.last != "path..." && @values.length > @names.length
33
+ def too_many? = !repeats? && @values.length > @names.length
33
34
 
34
35
  # The command's positional arguments as usage shows them, optional ones in brackets.
35
36
  #: () -> String
36
37
  def shown = @names.map { |name| name.end_with?("?") ? "[#{name.chomp("?").upcase}]" : name.upcase }.join(" ")
38
+
39
+ private
40
+
41
+ # Whether the last positional word, named NAME..., takes every value from its place on.
42
+ #: () -> bool
43
+ def repeats? = @names.last.to_s.end_with?("...")
37
44
  end
38
45
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Principles
5
5
  # Items as one would say them in a sentence: "a", "a and b", or "a, b and c", or with "or" for alternatives. It
6
- # is the one owner of that list, which several results and refusals print (#445, #731, #737), so every layer may
6
+ # is the one owner of that list, which several results and refusals print, so every layer may
7
7
  # load it, as it may error.rb.
8
8
  class ProseList
9
9
  #: (Array[String], ?conjunction: String) -> void
@@ -5,7 +5,7 @@ require_relative "invocation_options"
5
5
 
6
6
  module Principles
7
7
  # The option list-open-findings --short and list-member-problems --short take from Claude Code's SessionStart hook,
8
- # --session-start (#717, #1261), and what is wrong with it as given, which CommandLine refuses as a usage error.
8
+ # --session-start, and what is wrong with it as given, which CommandLine refuses as a usage error.
9
9
  class SessionStartOptions
10
10
  # The sources Claude Code's SessionStart hook names.
11
11
  SOURCES = %w[startup resume clear compact].freeze #: Array[String]
@@ -4,16 +4,19 @@
4
4
  require_relative "invocation_options"
5
5
 
6
6
  module Principles
7
- # The options that choose which audit start-audit begins, --member and --write-ups (#760), and the form --as prints
8
- # it in (D81), and what is wrong with them as given, which CommandLine refuses as a usage error.
7
+ # The options that choose which audit start-audit begins, --member and --write-ups, and the form --as prints
8
+ # it in, and what is wrong with them as given, which CommandLine refuses as a usage error.
9
9
  class StartAuditOptions
10
- #: (InvocationOptions) -> void
11
- def initialize(options)
10
+ # several_ids is whether start-audit was given more than one principle id.
11
+ #: (InvocationOptions, ?several_ids: bool) -> void
12
+ def initialize(options, several_ids: false)
13
+ @several_ids = several_ids
12
14
  @members = options.value("member") || [] #: Array[String]
13
15
  @member = !@members.empty? #: bool
14
16
  @write_ups = !options.value("write_ups").nil? #: bool
15
17
  @form = options.value("as") #: String?
16
18
  @instruction = !options.value("instruction").nil? #: bool
19
+ @part = !options.value("part").nil? #: bool
17
20
  freeze
18
21
  end
19
22
 
@@ -22,32 +25,63 @@ module Principles
22
25
  def fault
23
26
  return "--member and --write-ups each start a different audit; give one" if @member && @write_ups
24
27
 
25
- member_fault || instruction_fault || form_fault
28
+ several_ids_fault || member_fault || part_fault || instruction_fault || form_fault
26
29
  end
27
30
 
28
31
  private
29
32
 
30
- # A member given twice, which the agent would judge once (#1169); nil when each is given once.
33
+ # Several principle ids, which only an acknowledgement of members they each map spans; nil otherwise.
34
+ #: () -> String?
35
+ def several_ids_fault
36
+ return unless @several_ids && !@member
37
+
38
+ "several principle ids start one acknowledgement of the members they map, with --member; give one id for " \
39
+ "any other audit"
40
+ end
41
+
42
+ # A member given twice, which the agent would judge once; nil when each is given once.
31
43
  #: () -> String?
32
44
  def member_fault
33
45
  twice = @members.find { |member| @members.count(member) > 1 } or return
34
46
  "--member #{twice} is given twice; give each member once"
35
47
  end
36
48
 
37
- # --instruction prints one field of a full audit's request whole (D81 step 2); nil when nothing beside it prints
49
+ # --part prints one part of a full audit's request, or beside --as template one member's slot of its answer; nil
50
+ # when nothing beside it prints another output.
51
+ #: () -> String?
52
+ def part_fault
53
+ return unless @part
54
+
55
+ other = other_audit || ("the whole field --instruction prints" if @instruction)
56
+ "--part prints one part of a full audit's request, not of #{other}" if other
57
+ end
58
+
59
+ # --instruction prints one field of a full audit's request whole; nil when nothing beside it prints
38
60
  # another output.
39
61
  #: () -> String?
40
62
  def instruction_fault
41
63
  return unless @instruction
42
64
 
43
- other = if @form then "the answer --as template prints"
44
- elsif @member then "the one-member audit --member starts"
45
- elsif @write_ups then "the repoint --write-ups starts"
46
- end
65
+ other = other_output
47
66
  "--instruction prints one field of a full audit's request, not of #{other}" if other
48
67
  end
49
68
 
50
- # --as template prints a full audit's answer alone (D81 step 1), or a one-member audit's (#773), the one form
69
+ # What --as, --member or --write-ups prints instead of a full audit's request, which --part and --instruction each
70
+ # read from; nil when none is given.
71
+ #: () -> String?
72
+ def other_output
73
+ @form ? "the answer --as template prints" : other_audit
74
+ end
75
+
76
+ # What --member or --write-ups starts instead of a full audit; nil when neither is given.
77
+ #: () -> String?
78
+ def other_audit
79
+ if @member then "the one-member audit --member starts"
80
+ elsif @write_ups then "the repoint --write-ups starts"
81
+ end
82
+ end
83
+
84
+ # --as template prints a full audit's answer alone, or a one-member audit's, the one form
51
85
  # built so far; nil when it fits.
52
86
  #: () -> String?
53
87
  def form_fault
@@ -6,7 +6,7 @@ module Principles
6
6
  # parse lib/ still gets this tool's JSON refusal, not a SyntaxError. So this file stays in syntax any Ruby 2
7
7
  # parses, and requires only rbconfig: a GEM_HOME left by another Ruby can hand an old Ruby a json it cannot
8
8
  # parse. When the Ruby running is unsupported, it looks for a supported one that rbenv installed, since
9
- # rbenv otherwise picks Ruby by the directory this tool runs in, and runs this tool on that instead (D31).
9
+ # rbenv otherwise picks Ruby by the directory this tool runs in, and runs this tool on that instead.
10
10
  # Its bounds equal the gemspec's required_ruby_version; a spec checks it.
11
11
  class SupportedRuby
12
12
  MINIMUM = [3, 4, 2].freeze #: Array[Integer]
@@ -47,7 +47,7 @@ module Principles
47
47
  return { "hand_to" => [{ HANDED_OFF => other }, other, executable, *arguments] }
48
48
  end
49
49
 
50
- { "refuse" => refusal }
50
+ { "refuse" => refusal(setup_skill(executable)) }
51
51
  end
52
52
 
53
53
  private
@@ -75,19 +75,36 @@ module Principles
75
75
  File.basename(File.dirname(File.dirname(ruby))) # rubocop:disable Style/NestedFileDirname
76
76
  end
77
77
 
78
+ # The setup-ruby skill's file beside the plugin's bin/ that executable is in, if there is one: a skill that
79
+ # never loads itself, so the refusal names its file for the agent to read.
80
+ #: (String) -> String?
81
+ def setup_skill(executable)
82
+ plugin = File.dirname(File.dirname(executable)) # rubocop:disable Style/NestedFileDirname
83
+ skill = File.join(plugin, "skills", "setup-ruby", "SKILL.md")
84
+ skill if File.file?(skill)
85
+ end
86
+
78
87
  # This tool's refusal as JSON, written by hand because json may not load here.
79
- #: () -> String
80
- def refusal
88
+ #: (String?) -> String
89
+ def refusal(skill_file)
81
90
  require "rbconfig"
82
91
  needed = ">= #{MINIMUM.join(".")} and < #{BELOW.join(".")}"
83
92
  fields = [%w[status refused], %w[code unsupported_ruby],
84
93
  ["message", "This tool needs Ruby #{needed}; this is Ruby #{@running} at #{RbConfig.ruby}, and rbenv " \
85
94
  "has no Ruby it supports"],
86
- ["repair", "In Claude Code with the principles plugin, ask the user to run /principles:setup-ruby, " \
87
- "which installs one with rbenv and ruby-build. Otherwise install a Ruby #{needed} with " \
88
- "rbenv; it finds any rbenv Ruby it supports, whatever directory it runs in."]]
95
+ ["repair", repair(skill_file, needed)]]
89
96
  quoted = fields.map { |pair| pair.map { |text| "\"#{text.gsub(/[\\"]/) { |c| "\\#{c}" }}\"" }.join(":") }
90
97
  "{#{quoted.join(",")}}"
91
98
  end
99
+
100
+ # How to get a supported Ruby: by the plugin's setup-ruby skill when its file is here, otherwise with rbenv.
101
+ #: (String?, String) -> String
102
+ def repair(skill_file, needed)
103
+ return "Read #{skill_file} and follow it, asking the user before installing anything." if skill_file
104
+
105
+ "In Claude Code with the principles plugin, ask the user to run /principles:setup-ruby, which installs one " \
106
+ "with rbenv and ruby-build. Otherwise install a Ruby #{needed} with rbenv; it finds any rbenv Ruby it " \
107
+ "supports, whatever directory it runs in."
108
+ end
92
109
  end
93
110
  end
@@ -3,9 +3,9 @@
3
3
 
4
4
  module Principles
5
5
  # The next production release, as major.minor.patch. A production build is versioned with this alone.
6
- RELEASE = "0.0.7"
6
+ RELEASE = "0.0.8"
7
7
  # The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
8
8
  # packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
9
9
  # Data::RunningVersion reads the commit this tool runs from instead.
10
- BUILT_VERSION = "0.0.7" #: String?
10
+ BUILT_VERSION = "0.0.8" #: String?
11
11
  end
@@ -7,11 +7,11 @@ module Principles
7
7
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
8
8
  module Views
9
9
  # The edits to one member acknowledged since the last full audit, as the next full audit's request shows them
10
- # beside the member, so edits judged one at a time are judged together against the last audited text (D33).
10
+ # beside the member, so edits judged one at a time are judged together against the last audited text.
11
11
  class AcknowledgedSinceLastAudit
12
12
  # last_audited_commit is the last full audit's base commit; acknowledgements are the record's own, oldest
13
13
  # first; member_lines its own lines then and now, as a one-member audit shows them. The command that reads every
14
- # edit since is the member's read_the_change, which every member judged again carries (#771).
14
+ # edit since is the member's read_the_change, which every member judged again carries.
15
15
  #: (last_audited_commit: String, member_lines: Hash[String, untyped],
16
16
  #| acknowledgements: Array[Hash[String, untyped]]) -> void
17
17
  def initialize(last_audited_commit:, member_lines:, acknowledgements:)
@@ -10,7 +10,7 @@ require_relative "../prose_list"
10
10
  module Principles
11
11
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
12
12
  module Views
13
- # A one-member audit's request and its result (D33).
13
+ # A one-member audit's request and its result.
14
14
  class AcknowledgementResult
15
15
  #: (Invocation) -> void
16
16
  def initialize(invocation)
@@ -21,7 +21,7 @@ module Principles
21
21
  # asked is what the request asks of its member: under :change its change since its baseline; under :context
22
22
  # what the request's context shows beside it, such as the record's findings on the member; and under
23
23
  # :placeholders the text the template prints in each field the agent writes. What the agent judges is under
24
- # context, the question last, as in a full audit's request (D60).
24
+ # context, the question last, as in a full audit's request.
25
25
  #: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
26
26
  def request(request_id:, principle_id:, asked:)
27
27
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
@@ -32,22 +32,24 @@ module Principles
32
32
  end
33
33
 
34
34
  # The answer to the request request_id names, to fill: the request prints it as response_template, and
35
- # start-audit --member --as template prints it alone, each field the agent writes holding its placeholder (#773),
36
- # and only those: the fields the answer may add, the question names (#1170).
35
+ # start-audit --member --as template prints it alone, each field the agent writes holding its placeholder,
36
+ # and only those: the fields the answer may add, the question names, under members by the member's id,
37
+ # as several members' are, and its basis names it under member_ids, as theirs do.
37
38
  #: (request_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
38
39
  def answer_to_fill(request_id:, asked:)
39
- { "request_id" => request_id, "basis" => { "member_id" => asked.fetch(:change).member_id },
40
- **asked.fetch(:placeholders) }
40
+ member_id = asked.fetch(:change).member_id
41
+ { "request_id" => request_id, "basis" => { "member_ids" => [member_id] },
42
+ "members" => { member_id => asked.fetch(:placeholders) } }
41
43
  end
42
44
 
43
- # The request for several members' acknowledgements in one answer (#1169): each of members holds a member's
45
+ # The request for several members' acknowledgements in one answer: each of members holds a member's
44
46
  # change, the context its own request shows beside it and the placeholders its template prints, as one member's
45
47
  # request holds them, under context.members and the template's members in the order the agent named them.
46
48
  #: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
47
49
  def several_request(request_id:, principle_id:, members:)
48
50
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
49
51
  "context" => { "principle_id" => principle_id,
50
- "members" => members.map { { **it.fetch(:change).to_h, **it.fetch(:context) } },
52
+ "members" => shown(members),
51
53
  "question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning") },
52
54
  "response_template" => several_to_fill(request_id:, members:),
53
55
  "answer_with" => @invocation.submit_answer(request_id) }
@@ -61,6 +63,34 @@ module Principles
61
63
  "members" => members.to_h { [it.fetch(:change).member_id, it.fetch(:placeholders)] } }
62
64
  end
63
65
 
66
+ # The request for the members several principles map in one answer: under context.principles, each
67
+ # principle's members as its own request for several shows them, and in the template one entry per member,
68
+ # judged once for every principle that maps it. keeping_deferred names each principle whose members keep a
69
+ # deferred finding, which the request says only a full audit resolves.
70
+ #: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]],
71
+ #| ?keeping_deferred: Array[String]) -> Hash[String, untyped]
72
+ def across_request(request_id:, principles:, keeping_deferred: [])
73
+ { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
74
+ "context" => { "principles" => shown_once(principles),
75
+ **deferred_findings_kept(keeping_deferred), "question" => across_question },
76
+ "response_template" => across_to_fill(request_id:, principles:),
77
+ "answer_with" => @invocation.submit_answer(request_id) }
78
+ end
79
+
80
+ # The answer to the request for the members several principles map, to fill: its basis names each principle and
81
+ # each member, and its members hold one entry per member, with every field any principle's template prints for
82
+ # it, so check_result is there when any principle checks it, and the first principle's text where two
83
+ # print the same field.
84
+ #: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]]) -> Hash[String, untyped]
85
+ def across_to_fill(request_id:, principles:)
86
+ entries = principles.values.flatten.each_with_object({}) do |asked, by_member|
87
+ id = asked.fetch(:change).member_id
88
+ by_member[id] = asked.fetch(:placeholders).merge(by_member.fetch(id, {}))
89
+ end
90
+ { "request_id" => request_id, "basis" => { "principle_ids" => principles.keys, "member_ids" => entries.keys },
91
+ "members" => entries }
92
+ end
93
+
64
94
  # The acknowledgement of each of member_ids was accepted, and file holds them all.
65
95
  #: (principle_id: String, member_ids: Array[String], file: String) -> AnsweredRequest
66
96
  def several_acknowledged(principle_id:, member_ids:, file:)
@@ -68,23 +98,79 @@ module Principles
68
98
  "status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
69
99
  "files_to_commit" => [file],
70
100
  "next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
71
- "After committing, this no longer lists them: " \
101
+ "This no longer lists them: " \
72
102
  "#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
73
103
  )
74
104
  end
75
105
 
106
+ # The acknowledgement of each of member_ids was accepted for every principle that maps it, each principle's in its
107
+ # file, under its id in files.
108
+ #: (member_ids: Array[String], files: Hash[String, String]) -> AnsweredRequest
109
+ def across_acknowledged(member_ids:, files:)
110
+ AnsweredRequest.new(
111
+ "status" => "acknowledged", "principle_ids" => files.keys, "member_ids" => member_ids,
112
+ "files_to_commit" => files.values,
113
+ "next_action" => "Commit #{ProseList.new(files.values)}. #{ProseList.new(member_ids)} read as judged until " \
114
+ "each is edited again.\nThis no longer lists them: " \
115
+ "#{@invocation.in_project("list-member-problems", usage: "--short")}"
116
+ )
117
+ end
118
+
76
119
  # The acknowledgement was accepted and file holds it.
77
120
  #: (principle_id: String, member_id: String, file: String) -> AnsweredRequest
78
121
  def acknowledged(principle_id:, member_id:, file:)
79
122
  fields = {
80
- "status" => "acknowledged", "principle_id" => principle_id, "member_id" => member_id,
123
+ "status" => "acknowledged", "principle_id" => principle_id, "member_ids" => [member_id],
81
124
  "files_to_commit" => [file],
82
125
  "next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
83
- "After committing, this no longer lists it: " \
126
+ "This no longer lists it: " \
84
127
  "#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
85
128
  }
86
129
  AnsweredRequest.new(fields)
87
130
  end
131
+
132
+ private
133
+
134
+ # Where to read the deferred findings an acknowledgement across principles keeps, and the full audit of each
135
+ # principle in ids that resolves them, one command to a line; nothing when ids is empty.
136
+ #: (Array[String]) -> Hash[String, String]
137
+ def deferred_findings_kept(ids)
138
+ return {} if ids.empty?
139
+
140
+ read = Prompts.text("acknowledge-a-change/read-the-deferred-findings-it-keeps",
141
+ list_open_findings: @invocation.in_project("list-open-findings", options: ["--lines"]))
142
+ audits = ids.map do |id|
143
+ Prompts.text("acknowledge-a-change/resolve-them-in-a-full-audit",
144
+ principle_id: id, start_audit: @invocation.in_project("start-audit", id))
145
+ end
146
+ { "deferred_findings_kept" => [read, *audits].join("\n") }
147
+ end
148
+
149
+ # The question a request across principles asks: judge each member once, then as several members are judged.
150
+ #: () -> String
151
+ def across_question
152
+ once = Prompts.text("acknowledge-a-change/judge-each-member-once-for-every-principle")
153
+ "#{once} #{Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning")}"
154
+ end
155
+
156
+ # Each principle's members as shown, a member an earlier principle already shows with the same change naming that
157
+ # principle under change_shown_under in place of the change, so its lines print once.
158
+ #: (Hash[String, Array[Hash[Symbol, untyped]]]) -> Hash[String, Hash[String, untyped]]
159
+ def shown_once(principles)
160
+ first = {} #: Hash[String, [String, MemberChangeSinceBaseline]]
161
+ principles.to_h do |principle_id, members|
162
+ [principle_id, { "members" => members.map do |asked|
163
+ change = asked.fetch(:change)
164
+ earlier, shown = first[change.member_id] ||= [principle_id, change]
165
+ repeated = earlier != principle_id && shown.same_change_as?(change)
166
+ { **(repeated ? change.shown_under(earlier) : change.to_h), **asked.fetch(:context) }
167
+ end }]
168
+ end
169
+ end
170
+
171
+ # Each member's change and the context beside it, as its own request shows them.
172
+ #: (Array[Hash[Symbol, untyped]]) -> Array[Hash[String, untyped]]
173
+ def shown(members) = members.map { { **it.fetch(:change).to_h, **it.fetch(:context) } }
88
174
  end
89
175
  end
90
176
  end
@@ -4,7 +4,7 @@
4
4
  module Principles
5
5
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
6
6
  module Views
7
- # How this tool says when a principle's work is in hand, from the activation its map stores (D38): the phrase
7
+ # How this tool says when a principle's work is in hand, from the activation its map stores: the phrase
8
8
  # change-activation's question carries, and that later results will share.
9
9
  class ActivationInHand
10
10
  # How the question words each value of Models::Activation#full_audit_lists.
@@ -11,11 +11,15 @@ module Principles
11
11
  freeze
12
12
  end
13
13
 
14
- #: (AuditResult, String, String) -> Hash[String, untyped]
15
- def presented_with(_view, _source_request_id, _answer_file) = @fields
14
+ #: (AuditResult) -> Hash[String, untyped]
15
+ def presented_with(_view) = @fields
16
16
 
17
17
  #: (Hash[String, untyped], Invocation, String) -> Hash[String, untyped]
18
18
  def with_correction_to_fill(acceptable, _invocation, _answer_file) = acceptable
19
+
20
+ # No correction follows a terminal answer, so there is none to fill.
21
+ #: () -> nil
22
+ def correction_to_fill = nil
19
23
  end
20
24
  end
21
25
  end