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
@@ -1,14 +1,17 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../prose_list"
5
4
  require_relative "assessment_request"
6
5
  require_relative "answered_request"
7
6
  require_relative "audit_changes"
7
+ require_relative "completed_audit_next_step"
8
8
  require_relative "correction_request"
9
9
  require_relative "invocation"
10
10
  require_relative "prior_finding_decisions_result"
11
11
  require_relative "prompts"
12
+ require_relative "report_hooks_offer"
13
+ require_relative "trimmed_instructions_note"
14
+ require_relative "../prose_list"
12
15
 
13
16
  module Principles
14
17
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
@@ -26,11 +29,8 @@ module Principles
26
29
  end
27
30
 
28
31
  # An answer's result as submit-answer prints it: a correction request in full, with how to answer it.
29
- #: (AnsweredRequest | CorrectionRequest, source_request_id: String, answer_file: String)
30
- #| -> Hash[String, untyped]
31
- def present(output, source_request_id:, answer_file:)
32
- output.presented_with(self, source_request_id, answer_file)
33
- end
32
+ #: (AnsweredRequest | CorrectionRequest) -> Hash[String, untyped]
33
+ def present(output) = output.presented_with(self)
34
34
 
35
35
  # A correction request adds its answer to fill; a terminal result leaves the acceptable preview alone.
36
36
  #: (Hash[String, untyped], AnsweredRequest | CorrectionRequest, answer_file: String) -> Hash[String, untyped]
@@ -39,14 +39,14 @@ module Principles
39
39
  end
40
40
 
41
41
  # show-answer-check: the answer passed every check, and what submitting it would write. open_findings_will_print
42
- # previews each written-up finding's write_up_opening, and is nil when the record would keep none (#411).
43
- # map_entry_changes gives each claimed map entry's changed role and check, left out when there is none (#462).
44
- # answer_file is the --file value the answer was checked from, which the submit command gives again (#859).
42
+ # previews each written-up finding's write_up_opening, and is nil when the record would keep none.
43
+ # map_entry_changes gives each claimed map entry's changed role and check, left out when there is none.
44
+ # answer_file is the --file value the answer was checked from, which the submit command gives again.
45
45
  #: (String, Array[String], answer_file: String, ?open_findings_will_print: Array[Hash[String, untyped]]?,
46
46
  #| ?map_entry_changes: Array[Hash[String, untyped]]) -> Hash[String, untyped]
47
47
  def acceptable(request_id, would_write, answer_file:, open_findings_will_print: nil, map_entry_changes: [])
48
48
  submit = @invocation.submit_answer(request_id, file: answer_file)
49
- waits = "Submitting this answer writes nothing yet: the audit record is written when the audit completes.\n"
49
+ waits = "Submitting this answer writes nothing: the audit record already holds what it would write.\n"
50
50
  waits = "" unless would_write.empty?
51
51
  result = { "status" => "answer_acceptable", "request_id" => request_id, "would_write" => would_write }
52
52
  result = result.merge("open_findings_will_print" => open_findings_will_print) if open_findings_will_print
@@ -54,34 +54,73 @@ module Principles
54
54
  result.merge("next_action" => "#{waits}Submit the same answer unchanged, as you gave it: #{submit}")
55
55
  end
56
56
 
57
+ # show-answer-check's acceptable result, with each carried member whose kept assessment names a finding the
58
+ # answer decides other than still_holds under carried_assessments_citing_decided_findings, and a first line
59
+ # asking the agent to judge each; unchanged when there is none.
60
+ #: (Hash[String, untyped], Array[Hash[String, untyped]]) -> Hash[String, untyped]
61
+ def citing_decided_findings(acceptable, carried)
62
+ judged_first(acceptable, "carried_assessments_citing_decided_findings", carried,
63
+ Prompts.text("assess-every-member/judge-a-carried-assessment-citing-a-decided-finding"))
64
+ end
65
+
66
+ # show-answer-check's acceptable result, with each prior finding whose write-up pointer the answer drops with
67
+ # null, and the pointer it had, under prior_findings_pointers_dropped, and a first line asking the agent to
68
+ # confirm each; unchanged when there is none.
69
+ #: (Hash[String, untyped], Array[Hash[String, untyped]]) -> Hash[String, untyped]
70
+ def dropping_pointers(acceptable, dropped)
71
+ judged_first(acceptable, "prior_findings_pointers_dropped", dropped,
72
+ Prompts.text("assess-every-member/confirm-each-write-up-pointer-the-answer-drops"))
73
+ end
74
+
75
+ # show-answer-check's acceptable result, its first line naming each deferred finding the answer writes up nowhere
76
+ # and saying that null is allowed; unchanged when there is none.
77
+ #: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
78
+ def deferred_written_up_nowhere(acceptable, finding_ids)
79
+ return acceptable if finding_ids.empty?
80
+
81
+ line = Prompts.text("dispose-of-each-finding/confirm-each-deferral-written-up-nowhere",
82
+ finding_ids: ProseList.new(finding_ids).to_s)
83
+ acceptable.merge("next_action" => "#{line}\n#{acceptable.fetch("next_action")}")
84
+ end
85
+
86
+ # submit-answer's result for principle_id's assessment, as citing_decided_findings gives show-answer-check's,
87
+ # its first line saying, since the answer is now written, that the next full audit judges each afresh.
88
+ #: (Hash[String, untyped], Array[Hash[String, untyped]], String) -> Hash[String, untyped]
89
+ def submitted_citing_decided_findings(result, carried, principle_id)
90
+ judged_first(result, "carried_assessments_citing_decided_findings", carried,
91
+ Prompts.text("assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding",
92
+ start_audit: @invocation.in_project("start-audit", principle_id)))
93
+ end
94
+
57
95
  # start-audit: the assessment request, as a judgement to answer under its request id, its context naming the
58
96
  # instructions it prints only in part and the flag that prints one whole, so a trimmed field is not taken for
59
- # the whole (#983), without the command the agent just ran (#1125).
97
+ # the whole, without the command the agent just ran. Its head names the command listing its parts, so a long
98
+ # request is read in parts rather than paged by script.
60
99
  #: (AssessmentRequest) -> Hash[String, untyped]
61
100
  def assessment_request(request)
62
- output = judgement("assessment", request)
63
- trimmed = request.trimmed_instruction_fields
64
- return output if trimmed.empty?
65
-
66
- note = Prompts.text("assess-every-member/read-a-trimmed-instruction-whole", fields: ProseList.new(trimmed).to_s)
67
- output.merge("context" => output.fetch("context").merge("trimmed_instructions" => note))
101
+ output = judgement("assessment", request, { "read_in_parts" => read_in_parts(request.principle_id) },
102
+ to_fill: { "response_template" => request.template })
103
+ note = TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h
104
+ output.merge("context" => output.fetch("context").merge(note))
68
105
  end
69
106
 
70
- # start-audit --as template: the assessment's answer alone, to fill and submit (D81 step 1).
107
+ # start-audit --as template: the assessment's answer alone, to fill and submit.
71
108
  #: (AssessmentRequest) -> Hash[String, untyped]
72
109
  def answer_to_fill(request) = request.template_to_fill
73
110
 
74
111
  # submit-answer: the correction request that follows an assessment with findings, as a judgement to answer
75
- # under its request id, saying what submitting the assessment stored.
76
- #: (CorrectionRequest, source_request_id: String, answer_file: String) -> Hash[String, untyped]
77
- def correction_request(request, source_request_id:, answer_file:)
112
+ # under its request id, saying what submitting the assessment stored and how to fill its answer by hand. Its
113
+ # answer to fill is left to show-open-correction, which next_action says to save it from, rather than printed
114
+ # here too.
115
+ #: (CorrectionRequest) -> Hash[String, untyped]
116
+ def correction_request(request)
78
117
  judgement("correction", request).merge("stored" => request.stored,
79
- "correction_recovery" => request.recovery(source_request_id, answer_file,
80
- @invocation))
118
+ "correction_recovery" => request.recovery(@invocation),
119
+ "next_action" => request.to_fill_by_hand(@invocation))
81
120
  end
82
121
 
83
122
  # A completed audit: its resolved and open findings, the files to commit and, in git, each changed
84
- # member's commits since the base commit and the command that commits those files alone (#811), each prior
123
+ # member's commits since the base commit and the command that commits those files alone, each prior
85
124
  # finding's decision, and the next step. The command's subject states only what the audit did, which the
86
125
  # agent rewords to its project's convention.
87
126
  #: (principle_id: String, resolved: Array[untyped], open: Array[untyped], changes: AuditChanges,
@@ -94,18 +133,19 @@ module Principles
94
133
  "open_findings" => open, "files_to_commit" => changes.files_to_commit,
95
134
  "limits" => Prompts.text("report-the-completed-audit/what-completion-means"),
96
135
  **changed.except("files_to_commit"), **commit.fields }
97
- next_action = completed_next_action(principle_id, changes, commit)
136
+ next_action = CompletedAuditNextStep.new(@invocation).to_s(principle_id, changes, commit)
98
137
  decisions.added_to(output).merge("next_action" => next_action,
99
138
  "full_record" => @invocation.in_project("show-audit", principle_id))
100
139
  end
101
140
 
102
141
  # completed, a completed audit's result, offering to set principles up after its next_action, as it does
103
- # while nothing keeps them held between audits (D95).
104
- #: (Hash[String, untyped]) -> Hash[String, untyped]
105
- def offering_set_up(completed)
106
- offer = Prompts.text("set-principles-up/keep-them-held-between-audits",
107
- command: @invocation.in_project("show-meta-principle-passage"))
108
- completed.merge("next_action" => "#{completed.fetch("next_action")}\n#{offer}")
142
+ # while nothing keeps them held between audits, and with hooks, the hook entries that report between them.
143
+ #: (Hash[String, untyped], hooks: bool) -> Hash[String, untyped]
144
+ def offering_set_up(completed, hooks:)
145
+ offers = [Prompts.text("set-principles-up/keep-them-held-between-audits",
146
+ command: @invocation.in_project("show-meta-principle-passage"))]
147
+ offers << ReportHooksOffer.new(@invocation).to_s if hooks
148
+ completed.merge("next_action" => [completed.fetch("next_action"), *offers].join("\n"))
109
149
  end
110
150
 
111
151
  # The notice start-audit adds when the last audit's record is not committed.
@@ -114,6 +154,14 @@ module Principles
114
154
  "The last audit's record, #{file}, is not committed. Commit it, so the project keeps it."
115
155
  end
116
156
 
157
+ # The notice start-audit adds, in git, when the last audit's record is open: its correction completes it, so it
158
+ # is never committed.
159
+ #: (String) -> String
160
+ def open_record_notice(file)
161
+ "The last audit's record, #{file}, holds an open audit, waiting on its correction. Do not commit it: submit " \
162
+ "that correction, or answer this request, which replaces it, or discard it with `git restore #{file}`."
163
+ end
164
+
117
165
  # Wraps a known judgement request with this run's project and answer command.
118
166
  #: (Hash[String, untyped]) -> Hash[String, untyped]
119
167
  def request(output)
@@ -123,32 +171,31 @@ module Principles
123
171
 
124
172
  private
125
173
 
126
- # request as a judgement to answer in phase, under its id, which its template's head also gives.
127
- #: (String, AssessmentRequest | CorrectionRequest) -> Hash[String, untyped]
128
- def judgement(phase, request)
129
- { "status" => "agent_judgement_required", "request_id" => request.request_id, "phase" => phase,
130
- "context" => request.context, "response_template" => request.template,
131
- "limits" => Prompts.text("answer-any-judgement-request/what-a-self-audit-cannot-show") }
132
- end
174
+ # result with facts under field and judge as next_action's first line, or all of it for a request to answer,
175
+ # which has none; unchanged when facts is empty.
176
+ #: (Hash[String, untyped], String, Array[Hash[String, untyped]], String) -> Hash[String, untyped]
177
+ def judged_first(result, field, facts, judge)
178
+ return result if facts.empty?
133
179
 
134
- # A completed audit's next step, from what it changed and how to commit it.
135
- #: (String, AuditChanges, AuditCommit | AuditCommit::ByHand) -> String
136
- def completed_next_action(id, changes, commit)
137
- "#{commit.next_step} report the outcome to the project's owner.\n" \
138
- "#{others_changed(changes.other_changed)}" \
139
- "After members change, audit this principle again: #{@invocation.in_project("start-audit", id)}"
180
+ result.merge(field => facts, "next_action" => [judge, result["next_action"]].compact.join("\n"))
140
181
  end
141
182
 
142
- # The other principles whose members this audit's fixes changed, each to re-audit, or one member's edit
143
- # to acknowledge; the agent judges which (#410). Nothing when there are none.
144
- #: (Array[PrincipleWithChangedMembers]) -> String
145
- def others_changed(others)
146
- return "" if others.empty?
183
+ # How to read principle_id's full-audit request in parts: the command listing them, and the flag printing one.
184
+ #: (String) -> String
185
+ def read_in_parts(principle_id)
186
+ index = @invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::INDEX])
187
+ Prompts.text("assess-every-member/read-the-request-in-parts", index:)
188
+ end
147
189
 
148
- commands = others.map { |each| "#{@invocation.in_project("start-audit", each.principle_id)}\n" }
149
- "This audit's fixes also changed or broke members of other principles, listed under " \
150
- "other_principles_with_changed_members. Repair a broken one from show-principle's repair_with. To " \
151
- "acknowledge one member's edit instead, add --member MEMBER to its audit. Re-audit each:\n#{commands.join}"
190
+ # request as a judgement to answer in phase, under its id, which its template's head also gives, with any
191
+ # opening fields after the phase and before the context, and to_fill, the answer to fill when this request
192
+ # prints it, after the context.
193
+ #: (String, AssessmentRequest | CorrectionRequest, ?Hash[String, String], ?to_fill: Hash[String, untyped])
194
+ #| -> Hash[String, untyped]
195
+ def judgement(phase, request, opening = {}, to_fill: {})
196
+ { "status" => "agent_judgement_required", "request_id" => request.request_id, "phase" => phase, **opening,
197
+ "context" => request.context, **to_fill,
198
+ "limits" => Prompts.text("answer-any-judgement-request/what-a-self-audit-cannot-show") }
152
199
  end
153
200
  end
154
201
  end
@@ -11,24 +11,25 @@ module Principles
11
11
  # principle several of them reinforce, asked before anything is mapped.
12
12
  class CandidateFilesResult
13
13
  # What the search for candidates found, as plain values: the inventory, the files git does not track, nil
14
- # outside git, where nothing checked them (#386), and the lists to ask the owner about, each with the paths to
15
- # name in it (#405, #412).
14
+ # outside git, where nothing checked them, and the lists to ask the owner about, each with the paths to
15
+ # name in it.
16
16
  class Found
17
17
  # What each listed file prints: where it is, how big, where a link leads, and what the survey reads of it.
18
- PRINTED_FILE_FIELDS = %w[path characters symlink_to changed_in_range description opening_line outline].freeze
18
+ PRINTED_FILE_FIELDS = %w[path characters symlink_to changed_in_range skill_file_spelt description opening_line
19
+ outline].freeze
19
20
 
20
21
  #: Hash[String, Array[String]]
21
22
  attr_reader :owner_asks
22
23
 
23
- # Whether the inventory names files whose list items were cut to keep the result short (#1155).
24
+ # Whether the inventory names files whose list items were cut to keep the result short.
24
25
  #: () -> bool
25
26
  def cut? = @inventory.key?("outlines_cut")
26
27
 
27
- # Whether the inventory names files that print their path and size alone, their outlines left out (#1155).
28
+ # Whether the inventory names files that print their path and size alone, their outlines left out.
28
29
  #: () -> bool
29
30
  def left_out? = @inventory.key?("outlines_left_out")
30
31
 
31
- # What the outlines of the files a range changed print, when every cut left them past the budget (#1171).
32
+ # What the outlines of the files a range changed print, when every cut left them past the budget.
32
33
  #: () -> Integer?
33
34
  def range_outlines_bytes = @inventory["range_outlines_bytes"]
34
35
 
@@ -7,9 +7,12 @@ 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
  # What a checked member's exit_status placeholder says of its check beside what to do, in a full audit's template
10
- # and a one-member audit's alike: any hidden character the command holds (#260), and the line the last audit's
11
- # review rested on, which a run keeps unless a new one is given (#849).
10
+ # and a one-member audit's alike: any hidden character the command holds, and the line the last audit's
11
+ # review rested on, which a run keeps unless a new one is given.
12
12
  class CheckNotes
13
+ # Since when a line an audit still open kept was given, which that audit dates as it completes.
14
+ OPEN_SINCE = "this audit's open assessment" #: String
15
+
13
16
  # since_last_audit is how the check stands to the last audit's, with the review line that audit kept, if any;
14
17
  # hidden_characters names each hidden character in the command.
15
18
  #: (Hash[String, untyped]?, Array[String]) -> void
@@ -28,17 +31,37 @@ module Principles
28
31
  characters: @hidden_characters.join("; "))
29
32
  end
30
33
 
34
+ # The line the last audit's review rested on, which a full audit's template prints as review_basis's value to
35
+ # keep or replace; nil when that audit kept none.
36
+ #: () -> String?
37
+ def kept_basis = @since_last_audit&.fetch("review_basis", nil)
38
+
39
+ # That review_basis holds the line the last audit's review rested on, with since when, kept as printed unless
40
+ # replaced, for a template that prints it; nothing when that audit kept none.
41
+ #: () -> Array[String]
42
+ def printed_review
43
+ return [] unless kept_basis
44
+
45
+ [Prompts.text("assess-every-member/keep-the-printed-review-basis-or-replace-it", since: since)]
46
+ end
47
+
31
48
  # That a run keeps the line the last audit's review rested on, quoted with since when, unless a new one is
32
- # given, so whether it still holds can be judged from the template (#849); a record from before D63 kept none,
33
- # so there is nothing to say (#826).
49
+ # given, so whether it still holds can be judged from the template; an older record kept none,
50
+ # so there is nothing to say.
34
51
  #: () -> Array[String]
35
52
  def kept_review
36
53
  return [] unless @since_last_audit&.key?("review_basis")
37
54
 
38
55
  [Prompts.text("assess-every-member/keep-the-last-review-basis-unless-you-give-a-new-one",
39
- since: @since_last_audit.fetch("review_basis_since"),
40
- basis: @since_last_audit.fetch("review_basis"))]
56
+ since: since, basis: @since_last_audit.fetch("review_basis"))]
41
57
  end
58
+
59
+ private
60
+
61
+ # Since when the kept line was first kept: its date, or, while the audit that kept it is still open and so has
62
+ # not dated it, that audit's assessment.
63
+ #: () -> String
64
+ def since = @since_last_audit&.fetch("review_basis_since", nil) || OPEN_SINCE
42
65
  end
43
66
  end
44
67
  end
@@ -7,74 +7,86 @@ require_relative "prompts"
7
7
  module Principles
8
8
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
9
9
  module Views
10
- # The check_result a checked member's assessment template starts with: its command, an exit_status placeholder
11
- # that says what to do before replacing it with the run's status, and not_run_reason, the alternative, as a
12
- # placeholder an answer leaves as printed when it reports a run (#993). A check no audit has run, or one changed
13
- # since, is reviewed before it runs (#227), so it also gives review_basis to fill (D63), and any hidden character
14
- # it holds is named where that decision is made (#260).
10
+ # The check_result a checked member's assessment template starts with: its command, a short exit_status
11
+ # placeholder where the run's status goes, and not_run_reason, the alternative, as a placeholder an answer leaves
12
+ # as printed when it reports a run, with its instruction, what to do before replacing it. A check
13
+ # no audit has run, or one changed since, is reviewed before it runs, so it also gives review_basis to fill,
14
+ # and any hidden character it holds is named where that decision is made.
15
15
  class CheckResultTemplate
16
16
  # The template for the checked member a request lists as entry, with its check, how that stands to the last
17
17
  # audit's and any hidden characters in it; nil for a member without a check.
18
18
  #: (Hash[String, untyped], reviewed_placeholders: Hash[String, String],
19
- #| unchanged_placeholders: Hash[String, String]) -> Hash[String, untyped]?
19
+ #| unchanged_placeholders: Hash[String, String]) -> CheckResultTemplate?
20
20
  def self.for(entry, reviewed_placeholders:, unchanged_placeholders:)
21
21
  check = entry["check"] or return
22
22
  new(check, entry["check_since_last_audit"], entry.fetch("check_hidden_characters", []),
23
- reviewed_placeholders:, unchanged_placeholders:).to_h
23
+ reviewed_placeholders:, unchanged_placeholders:)
24
24
  end
25
25
 
26
- # reviewed_placeholders gives the text of not_run_reason and review_basis, which an answer leaves as printed to
27
- # give neither, for a check reviewed before it runs; unchanged_placeholders gives it for one the last audit ran,
28
- # whose review_basis left as printed keeps the line that audit kept (#1010).
26
+ # reviewed_placeholders gives the text of exit_status, and of not_run_reason and review_basis, which an answer
27
+ # leaves as printed to give neither, for a check reviewed before it runs; unchanged_placeholders gives it for one
28
+ # the last audit ran, whose review_basis left as printed keeps the line that audit kept.
29
29
  #: (String, Hash[String, untyped]?, ?Array[String], reviewed_placeholders: Hash[String, String],
30
30
  #| unchanged_placeholders: Hash[String, String]) -> void
31
31
  def initialize(check, since_last_audit, hidden_characters = [], reviewed_placeholders:, unchanged_placeholders:)
32
32
  @check = check
33
33
  @since_last_audit = since_last_audit
34
34
  @notes = CheckNotes.new(since_last_audit, hidden_characters) #: CheckNotes
35
- unchanged = since_last_audit&.fetch("status") == "unchanged"
36
- @placeholders = unchanged ? unchanged_placeholders : reviewed_placeholders #: Hash[String, String]
35
+ @unchanged = since_last_audit&.fetch("status") == "unchanged" #: bool
36
+ @placeholders = @unchanged ? unchanged_placeholders : reviewed_placeholders #: Hash[String, String]
37
37
  freeze
38
38
  end
39
39
 
40
+ # The check_result to fill. An unchanged check's gives its optional fields as values to edit, not instructions:
41
+ # no not_run_reason, and the line its last review rested on.
40
42
  #: () -> Hash[String, untyped]
41
43
  def to_h
42
- { "command" => @check, "exit_status" => [@notes.hidden_characters, run_and_report].compact.join(" "),
43
- "not_run_reason" => @placeholders.fetch("not_run_reason"),
44
- "review_basis" => @placeholders.fetch("review_basis") }
44
+ { "command" => @check, "exit_status" => @placeholders.fetch("exit_status"),
45
+ **(@unchanged ? { "not_run_reason" => nil, "review_basis" => @notes.kept_basis } : placeholders) }
45
46
  end
46
47
 
47
- private
48
+ # How the check stands to the last audit's: unchanged, changed or new, which sets the text it shares with every
49
+ # other check standing so.
50
+ #: () -> String
51
+ def status = @since_last_audit&.fetch("status", nil) || "new"
48
52
 
49
- # What to do before replacing exit_status, then that a named check runs at every full audit, which holds for
50
- # each status.
53
+ # What to do before replacing exit_status that every check of its status shares, ending with that a named check
54
+ # runs at every full audit, which a request prints once for the members it is for.
51
55
  #: () -> String
52
- def run_and_report
56
+ def shared_instruction
57
+ steps = case status
58
+ when "unchanged" then [Prompts.text("assess-every-member/run-the-check-then-report-it")]
59
+ when "changed"
60
+ [Prompts.text("assess-every-member/have-a-changed-check-reviewed-before-running-it"), run_reviewed]
61
+ else [Prompts.text("assess-every-member/have-a-new-check-reviewed-before-running-it"), run_reviewed]
62
+ end
53
63
  [*steps, Prompts.text("assess-every-member/run-a-named-check-at-every-full-audit")].join(" ")
54
64
  end
55
65
 
56
- # An unchanged check is run and reported, keeping any line its last review rested on; a new or changed one is
57
- # reviewed first, its review introduced by what it is, then run and reported with what that review rested on,
58
- # as both ask the same way.
59
- #: () -> Array[String]
60
- def steps
61
- case @since_last_audit&.fetch("status")
62
- when "unchanged" then [Prompts.text("assess-every-member/run-the-check-then-report-it"), *@notes.kept_review]
63
- when "changed"
64
- [Prompts.text("assess-every-member/have-a-changed-check-reviewed-before-running-it",
65
- changed_in: commit_clause(": commit %s changed it")), run_reviewed]
66
- else
67
- [Prompts.text("assess-every-member/have-a-new-check-reviewed-before-running-it",
68
- set_in: commit_clause("; commit %s set it")), run_reviewed]
69
- end
66
+ # This member's own lines beside the shared instruction: what the check hides, the commit that set or changed
67
+ # it, and the line its last review rested on; nil when it has none.
68
+ #: () -> String?
69
+ def own_instruction
70
+ lines = [@notes.hidden_characters, commit_line, *(@notes.printed_review if status == "unchanged")].compact
71
+ lines.join(" ") unless lines.empty?
70
72
  end
71
73
 
72
- # The commit that made the check what it is now, stated in the placeholder itself, since the template printed
73
- # alone has no context beside it (#1024); nothing outside git, or when no commit holds it.
74
- #: (String) -> String
75
- def commit_clause(format)
76
- commit = @since_last_audit&.fetch("changed_in", nil)
77
- commit ? format(format, commit) : ""
74
+ private
75
+
76
+ # The optional fields' placeholders, for a check reviewed before it runs.
77
+ #: () -> Hash[String, String]
78
+ def placeholders = @placeholders.slice("not_run_reason", "review_basis")
79
+
80
+ # The commit that made a new or changed check what it is now, stated where the run is asked, since the template
81
+ # printed alone has no context beside it; nil outside git, when no commit holds it, or for an unchanged
82
+ # check.
83
+ #: () -> String?
84
+ def commit_line
85
+ commit = @since_last_audit&.fetch("changed_in", nil) or return
86
+ return if status == "unchanged"
87
+
88
+ Prompts.text("assess-every-member/name-the-commit-that-made-the-check",
89
+ commit:, verb: status == "changed" ? "changed" : "set")
78
90
  end
79
91
 
80
92
  # Run a reviewed check, then report it with what its review rested on.
@@ -0,0 +1,44 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "audit_changes"
5
+ require_relative "audit_commit"
6
+ require_relative "invocation"
7
+ require_relative "principle_with_changed_members"
8
+
9
+ module Principles
10
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
11
+ module Views
12
+ # A completed audit's next step, from what it changed and how to commit it: commit and report, re-audit each other
13
+ # principle its fixes changed, and audit this principle again after its members change.
14
+ class CompletedAuditNextStep
15
+ #: (Invocation) -> void
16
+ def initialize(invocation)
17
+ @invocation = invocation
18
+ freeze
19
+ end
20
+
21
+ # The next step after principle id's audit completed with changes, committed as commit says.
22
+ #: (String, AuditChanges, AuditCommit | AuditCommit::ByHand) -> String
23
+ def to_s(id, changes, commit)
24
+ "#{commit.next_step} report the outcome to the project's owner.\n" \
25
+ "#{others_changed(changes.other_changed)}" \
26
+ "After members change, audit this principle again: #{@invocation.in_project("start-audit", id)}"
27
+ end
28
+
29
+ private
30
+
31
+ # The other principles whose members this audit's fixes changed, each to re-audit, or one member's edit
32
+ # to acknowledge; the agent judges which. Nothing when there are none.
33
+ #: (Array[PrincipleWithChangedMembers]) -> String
34
+ def others_changed(others)
35
+ return "" if others.empty?
36
+
37
+ commands = others.map { |each| "#{@invocation.in_project("start-audit", each.principle_id)}\n" }
38
+ "This audit's fixes also changed or broke members of other principles, listed under " \
39
+ "other_principles_with_changed_members. Repair a broken one from show-principle's repair_with. To " \
40
+ "acknowledge one member's edit instead, add --member MEMBER to its audit. Re-audit each:\n#{commands.join}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,112 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "member_lines_beside_text"
5
+ require_relative "printed_json"
6
+
7
+ module Principles
8
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
9
+ module Views
10
+ # The parts of a full audit's request that start-audit --part prints alone, by name, from the request's context:
11
+ # each key but the members and the instruction fields, each member alone, and each instruction field as the
12
+ # request prints it, in part where it trims one, which --instruction prints whole; and the index of them all.
13
+ class ContextParts
14
+ # What starts a member's part name, keeping member ids apart from the context's keys.
15
+ MEMBER = "members/" #: String
16
+
17
+ # The part that lists every other part, so the agent sizes its reads before it makes them.
18
+ INDEX = "index" #: String
19
+
20
+ # The part holding the answer to fill, as the request prints it beside its context.
21
+ TEMPLATE = "response_template" #: String
22
+
23
+ # What --part prints for an optional part the request leaves out, holding nothing for it.
24
+ EMPTY = { "part_empty" => "Nothing to list for this request; " \
25
+ "the answer needs nothing for it." }.freeze #: Hash[String, String]
26
+
27
+ # instruction_fields is each field the context prints an instruction under, in order. template is the answer to
28
+ # fill, as the request prints it. texts is each member's lines now, by id, one string each, which its part
29
+ # prints and the whole request does not. optional names each part the context lists only when it holds something.
30
+ #: (Hash[String, untyped], instruction_fields: Array[String], template: Hash[String, untyped],
31
+ #| ?texts: Hash[String, Array[String]], ?optional: Array[String]) -> void
32
+ def initialize(context, instruction_fields:, template:, texts: {}, optional: [])
33
+ @context = context
34
+ @instruction_fields = instruction_fields
35
+ @template = template
36
+ @texts = texts
37
+ @optional = optional
38
+ freeze
39
+ end
40
+
41
+ # Each part's name, in the order the context prints it, then each member's as members/ID, in the request's order,
42
+ # then each instruction field, in the order the context prints them, and last the answer to fill.
43
+ #: () -> Array[String]
44
+ def names
45
+ [*(@context.keys - ["members", *@instruction_fields]), *members.map { "#{MEMBER}#{it.fetch("id")}" },
46
+ *@instruction_fields, TEMPLATE]
47
+ end
48
+
49
+ # Each name --part prints: the index, then each part it lists.
50
+ #: () -> Array[String]
51
+ def printable = [INDEX, *names]
52
+
53
+ # Each optional part the context leaves out, holding nothing for this request, which --part prints as empty.
54
+ #: () -> Array[String]
55
+ def left_out = @optional - @context.keys
56
+
57
+ # The part name, under its key, as the context prints it; a member's entry alone under members, with its text
58
+ # when given, its id read after the one prefix, so an id with a slash, or starting members/, is read whole.
59
+ #: (String) -> Hash[String, untyped]
60
+ def shown(name)
61
+ return { INDEX => index } if name == INDEX
62
+ return EMPTY if left_out.include?(name)
63
+ return { TEMPLATE => @template } if name == TEMPLATE
64
+ return { name => @context.fetch(name) } unless name.start_with?(MEMBER)
65
+
66
+ id = name.delete_prefix(MEMBER)
67
+ { "members" => members.select { it.fetch("id") == id }.map { with_text(it) } }
68
+ end
69
+
70
+ private
71
+
72
+ # Each part with the bytes --part prints of its value, and each member with whether this audit judges it, and
73
+ # why when the request says, or carries its last assessment forward.
74
+ #: () -> Array[Hash[String, untyped]]
75
+ def index
76
+ names.map do |name|
77
+ part = shown(name)
78
+ entry = { "part" => name, "bytes" => bytes(part) }
79
+ name.start_with?(MEMBER) ? entry.merge(judged(part.fetch("members").fetch(0))) : entry
80
+ end
81
+ end
82
+
83
+ # How many bytes value prints as, as this tool prints a result.
84
+ #: (Hash[String, untyped]) -> Integer
85
+ def bytes(value) = PrintedJson.bytes(value)
86
+
87
+ # member as the request lists it, with its text when given, and then its acknowledged lines now pointing at
88
+ # that text, so the part prints each line now once.
89
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
90
+ def with_text(member)
91
+ text = @texts[member.fetch("id")] or return member
92
+ since = member["acknowledged_since_last_audit"]
93
+ return member.merge("text" => text) unless since
94
+
95
+ lines = MemberLinesBesideText.new(since.fetch("member_lines")).shown
96
+ member.merge("acknowledged_since_last_audit" => since.merge("member_lines" => lines), "text" => text)
97
+ end
98
+
99
+ # What this audit does with member: carries its last assessment forward, or judges it, with why when given.
100
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
101
+ def judged(member)
102
+ return { "this_audit" => "carries_forward" } if member["carried_forward"]
103
+
104
+ { "this_audit" => "judges", **member.slice("judge_because") }
105
+ end
106
+
107
+ # The members the request lists, each as it prints it.
108
+ #: () -> Array[Hash[String, untyped]]
109
+ def members = @context.fetch("members")
110
+ end
111
+ end
112
+ end