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
@@ -16,13 +16,13 @@ module Principles
16
16
  # where it is written up, and the members a fix claims it changed. The agent's AnswerFields check each field
17
17
  # and locate each piece of evidence in the project. Its readers read what the agent gave, so callers ask them
18
18
  # only once CorrectionAnswer has checked every disposition, and found none of its fields unfinished, its action
19
- # among them (#753, #791, #794).
19
+ # among them.
20
20
  class Disposition
21
21
  ACTIONS = %w[fixed deferred accepted disagreed].freeze #: Array[String]
22
22
 
23
- # A field the agent left unfinished: empty, the template's placeholder, the answer guide's sample (#789), or
23
+ # A field the agent left unfinished: empty, the template's placeholder, the answer guide's sample, or
24
24
  # an action not one of the four. It says where it sits in the answer and what to write there, which one
25
- # refusal lists beside every other (#791).
25
+ # refusal lists beside every other.
26
26
  class UnfinishedField
27
27
  #: String
28
28
  attr_reader :repair
@@ -40,13 +40,13 @@ module Principles
40
40
  #: () -> String
41
41
  def to_s = "#{@place.subject} #{@name}"
42
42
 
43
- # Its entry in the refusal's fields, as a malformed answer's are (D29).
43
+ # Its entry in the refusal's fields, as a malformed answer's are.
44
44
  #: () -> Hash[String, String]
45
45
  def field = { "pointer" => @place.pointer, "problem" => @problem }
46
46
  end
47
47
 
48
48
  # A text field the agent must write: the placeholder the correction template leaves in it, which an answer may
49
- # not send back unchanged, and what to write instead; reassessment applies only to a fix (#725).
49
+ # not send back unchanged, and what to write instead; reassessment applies only to a fix.
50
50
  class TextField
51
51
  #: String
52
52
  attr_reader :placeholder
@@ -58,8 +58,8 @@ module Principles
58
58
  freeze
59
59
  end
60
60
 
61
- # The field named name, at place, when value leaves it empty, as the placeholder (#788, #725) or as sample,
62
- # the answer guide's illustration of this field for the disposition's action, if it gives one (#789).
61
+ # The field named name, at place, when value leaves it empty, as the placeholder or as sample,
62
+ # the answer guide's illustration of this field for the disposition's action, if it gives one.
63
63
  #: (untyped, AnswerPlace, String, sample: String?) -> UnfinishedField?
64
64
  def left_in(value, place, name, sample:)
65
65
  problem = if !AnswerText.new(value).written? then "must be a nonempty string"
@@ -70,7 +70,7 @@ module Principles
70
70
  end
71
71
  end
72
72
 
73
- # The problem with a field the agent gave back as the answer guide's sample (#789).
73
+ # The problem with a field the agent gave back as the answer guide's sample.
74
74
  SAMPLE_UNCHANGED = "is the answer guide's sample, unchanged" #: String
75
75
 
76
76
  TEXT_FIELDS = {
@@ -83,7 +83,7 @@ module Principles
83
83
  # The placeholder in each field, which the template prints.
84
84
  PLACEHOLDERS = TEXT_FIELDS.transform_values(&:placeholder).freeze #: Hash[String, String]
85
85
  # What action takes, said where it is written when the correction's answer is printed with no answer guide
86
- # beside it, as show-answer-check prints it (D81 step 3). It is help, never an action, so it is left unchosen.
86
+ # beside it, as show-answer-check prints it. It is help, never an action, so it is left unchosen.
87
87
  ACTION_PLACEHOLDER = "One of fixed, deferred, accepted or disagreed, each with a reason: fixed lists " \
88
88
  "changed_members for current text changes, optional removed_members for map removals, " \
89
89
  "and evidence and gives a reassessment; deferred gives recorded_at, " \
@@ -93,7 +93,7 @@ module Principles
93
93
  TEMPLATE_PLACEHOLDERS = PLACEHOLDERS.merge("action" => ACTION_PLACEHOLDER).freeze #: Hash[String, String]
94
94
 
95
95
  # at is the disposition's place in the answer, such as /dispositions/0, which a refusal about its pointers names.
96
- # samples is the answer guide's disposition for each action, whose text illustrates each field (#789).
96
+ # samples is the answer guide's disposition for each action, whose text illustrates each field.
97
97
  #: (untyped, AnswerFields, at: String, samples: Hash[String, untyped]) -> void
98
98
  def initialize(disposition, fields, at:, samples:)
99
99
  @disposition = disposition
@@ -116,7 +116,7 @@ module Principles
116
116
  #: () -> bool
117
117
  def fixed? = action == "fixed"
118
118
 
119
- # The members a fix says it changed; none from a disposition that omits them, as one not fixed may (#997).
119
+ # The members a fix says it changed; none from a disposition that omits them, as one not fixed may.
120
120
  #: () -> Array[String]
121
121
  def changed_members = @disposition.fetch("changed_members", [])
122
122
 
@@ -125,8 +125,8 @@ module Principles
125
125
  def recorded_path = recorded_at&.path
126
126
 
127
127
  # What the audit record keeps of this disposition beside its finding: the action, and why a finding left
128
- # unfixed was left so, which a fix's reassessment answers instead (#996); where the finding is written up and
129
- # what a deferral waits on, when given (D52).
128
+ # unfixed was left so, which a fix's reassessment answers instead; where the finding is written up and
129
+ # what a deferral waits on, when given.
130
130
  #: () -> Hash[String, untyped]
131
131
  def recorded_outcome
132
132
  { "action" => action, "reason" => (@disposition["reason"] unless fixed?), "recorded_at" => recorded_at&.to_h,
@@ -142,7 +142,7 @@ module Principles
142
142
 
143
143
  # Each field this disposition leaves for the agent still: an action that is not one of the four, the reason
144
144
  # left empty, as the template's placeholder or as the answer guide's sample, and so a fix's reassessment,
145
- # which applies to no other action, and a waits_on left as the guide's sample (#788, #789, #791, #794).
145
+ # which applies to no other action, and a waits_on left as the guide's sample.
146
146
  #: () -> Array[UnfinishedField]
147
147
  def unfinished = [*unchosen_action, *unwritten_text, *waits_on_left_as_sample]
148
148
 
@@ -161,7 +161,7 @@ module Principles
161
161
  private
162
162
 
163
163
  # The template leaves each action null, or as its placeholder, since choosing it is the agent's call; a null,
164
- # placeholder or unknown one is left for the agent, with the four to choose from (#708).
164
+ # placeholder or unknown one is left for the agent, with the four to choose from.
165
165
  #: () -> UnfinishedField?
166
166
  def unchosen_action
167
167
  action = @disposition["action"]
@@ -173,8 +173,8 @@ module Principles
173
173
  problem:, repair: "Set its action to one of fixed, deferred, accepted or disagreed.")
174
174
  end
175
175
 
176
- # The reason, and a fix's reassessment, when left empty, as the template's placeholder (#788, #725) or as the
177
- # answer guide's sample for this action (#789).
176
+ # The reason, and a fix's reassessment, when left empty, as the template's placeholder or as the
177
+ # answer guide's sample for this action.
178
178
  #: () -> Array[UnfinishedField]
179
179
  def unwritten_text
180
180
  action = @disposition["action"]
@@ -185,7 +185,7 @@ module Principles
185
185
  end
186
186
 
187
187
  # A deferral's waits_on left as the answer guide's sample, which illustrates the line without saying whom the
188
- # finding waits on. It is one line, so WaitsOn would keep it (#789).
188
+ # finding waits on. It is one line, so WaitsOn would keep it.
189
189
  #: () -> UnfinishedField?
190
190
  def waits_on_left_as_sample
191
191
  sample = @samples.dig(@disposition["action"], "waits_on")
@@ -195,7 +195,7 @@ module Principles
195
195
  end
196
196
 
197
197
  # A fix's claimed members, each of which must have changed. A fix may claim no member's text when it
198
- # claims a map entry instead, which DeclaredMapChanges has checked changed (D40).
198
+ # claims a map entry instead, which DeclaredMapChanges has checked changed.
199
199
  #: (Array[untyped], Array[untyped], Array[String]) -> Array[untyped]
200
200
  def fixed_members(members, entries, changed)
201
201
  return members unless (members.empty? && entries.empty?) || (members - changed).any?
@@ -206,7 +206,7 @@ module Principles
206
206
  end
207
207
 
208
208
  # The disposition's evidence and recorded_at, which a deferral must give, if only as null, and the
209
- # one line a deferral may give saying what it waits on (D52).
209
+ # one line a deferral may give saying what it waits on.
210
210
  #: () -> void
211
211
  def checked_fields
212
212
  locate_pointers
@@ -227,7 +227,7 @@ module Principles
227
227
  end
228
228
 
229
229
  # A deferral must say where it is written up, or null, so an answer reused from before recorded_at existed
230
- # cannot drop the pointer silently (#299).
230
+ # cannot drop the pointer silently.
231
231
  #: () -> bot
232
232
  def unrecorded_deferral
233
233
  raise Error.new("invalid_disposition", "Deferred finding #{finding_id} has no recorded_at",
@@ -11,7 +11,7 @@ module Principles
11
11
  # this tool refused it with when it cannot be read. It says whether it links the other entry file: as a symbolic
12
12
  # link to it, or by an import word, @AGENTS.md or @CLAUDE.md, which Claude Code documents as loading the file it
13
13
  # names. That is a fact about the string; a plain mention of the other's name is not a link, and an unread text
14
- # shows no import. It says, too, when git does not track it, since such a file may be the owner's alone (#896).
14
+ # shows no import. It says, too, when git does not track it, since such a file may be the owner's alone.
15
15
  class EntryFile
16
16
  # The entry file at path as the project holds it, or nil when there is none; tracked says whether git tracks
17
17
  # it, and is true outside git, where nothing is checked.
@@ -16,7 +16,7 @@ module Principles
16
16
 
17
17
  # Each entry file as the project holds it, or nil for one that does not exist. history says which git does not
18
18
  # track: a path whose own file, or a file its links lead to, git does not hold, so a fresh clone would not find
19
- # its text there (#695, #896).
19
+ # its text there.
20
20
  #: (Data::ProjectFiles, ProjectHistory) -> EntryFiles
21
21
  def self.read(files, history)
22
22
  new(PATHS.to_h { |path| [path, EntryFile.read(files, path, tracked: history.tracks?(path))] })
@@ -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
  # One item of the evidence a finding was raised with, as its record keeps it: a path, with a heading, passage or
10
- # query inside it, or none to name the whole file (D64). It holds that place as the Locator its record's hash
10
+ # query inside it, or none to name the whole file. It holds that place as the Locator its record's hash
11
11
  # gives, which keeps the hash's keys and order, since the record's bytes depend on it.
12
12
  class EvidenceItem
13
13
  # Where in the project the item points, as MemberFile reads it.
@@ -9,9 +9,9 @@ module Principles
9
9
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
10
  module Models
11
11
  # The lines one evidence item of a prior finding names at the commit the audit that kept the finding was based on,
12
- # and now, either nil where they cannot be found: what the next full audit's request says of the item (#858). A
12
+ # and now, either nil where they cannot be found: what the next full audit's request says of the item. A
13
13
  # removed pointer needs finding again and a reworded one judging again, so whether it is found now is said apart
14
- # from whether it changed (#877).
14
+ # from whether it changed.
15
15
  class EvidenceLinesSince
16
16
  # The lines item names in project at since and now, either nil where it cannot be found or read, so one moved or
17
17
  # removed pointer never refuses the request.
@@ -10,8 +10,8 @@ module Principles
10
10
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
11
  module Models
12
12
  # The new places a still_holds decision gives a kept finding's evidence items that are no longer found, each
13
- # problem_evidence entry naming by replaces the position of the item it replaces (D70). An item still found stays
14
- # as the audit raised it, so a decision never rewrites what an audit found (D64); git keeps the old pointer.
13
+ # problem_evidence entry naming by replaces the position of the item it replaces. An item still found stays
14
+ # as the audit raised it, so a decision never rewrites what an audit found; git keeps the old pointer.
15
15
  class EvidenceReplacements
16
16
  # The field an entry names the kept item it replaces by, which the record does not keep.
17
17
  REPLACES = "replaces"
@@ -77,7 +77,7 @@ module Principles
77
77
  end
78
78
 
79
79
  # What is wrong with a replaces naming no kept item: text is only ever the template's placeholder, which the
80
- # answer's schema lets through for it (#1043).
80
+ # answer's schema lets through for it.
81
81
  #: (untyped) -> String
82
82
  def stray_problem(stray)
83
83
  stray.is_a?(String) ? "replaces is left as printed" : "replaces #{stray} names no item of its evidence"
@@ -9,7 +9,7 @@ module Principles
9
9
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
10
  module Models
11
11
  # Some open findings, each with its write-up opening where its recorded_at points, as the project's file stands
12
- # now (#300).
12
+ # now.
13
13
  class FindingWriteUps
14
14
  # What to do about a recorded_at that no longer resolves, worded for a write-up rather than a member.
15
15
  REPAIR = "Fix the write-up, or point recorded_at at it again with start-audit --write-ups, without a full audit."
@@ -34,15 +34,22 @@ module Principles
34
34
  end
35
35
 
36
36
  # The findings that are written up somewhere, each with the write-up opening list-open-findings will print for
37
- # it, so a pointer that lands on a generic line is seen before the answer is submitted (#411).
37
+ # it, so a pointer that lands on a generic line is seen before the answer is submitted.
38
38
  #: () -> Array[Hash[String, untyped]]
39
39
  def written_up
40
40
  fields = %w[finding_id write_up_opening write_up_opening_reason write_up_opening_error]
41
41
  listed.select { |finding| finding["recorded_at"] }.map { |finding| finding.slice(*fields) }
42
42
  end
43
43
 
44
+ # The id of each deferred finding written up nowhere, its recorded_at null, which the question allows when there
45
+ # is nowhere to point but an agent may take for a pointer left out.
46
+ #: () -> Array[String]
47
+ def deferred_written_up_nowhere
48
+ @findings.select { |finding| finding.action == "deferred" && !finding.recorded_at }.map(&:id)
49
+ end
50
+
44
51
  # The findings whose write-up can no longer be found where recorded_at points, each by its principle and
45
- # finding_id, which list-open-findings --short names so a session-start hook shows the broken pointer (#694).
52
+ # finding_id, which list-open-findings --short names so a session-start hook shows the broken pointer.
46
53
  # It asks git for no rename, which only the full list prints.
47
54
  #: () -> Array[Hash[String, untyped]]
48
55
  def not_found
@@ -79,7 +86,7 @@ module Principles
79
86
 
80
87
  # The refusal that left a write-up unavailable, with any rename git detects for its file when that file is
81
88
  # missing. The agent checks the match before pointing recorded_at there: this tool does not decide the match
82
- # is the write-up, as for a member's missing file (#276, #694).
89
+ # is the write-up, as for a member's missing file.
83
90
  #: (Hash[String, untyped], WriteUpPointer) -> Hash[String, untyped]
84
91
  def unavailable(payload, pointer)
85
92
  refused = payload.slice("code", "message")
@@ -93,7 +100,7 @@ module Principles
93
100
  # Whether moved, the pointer with its starting_at in the file git matched, still resolves there: its
94
101
  # starting_at occurs exactly once there, within its heading's section when it names one, as a member's passage
95
102
  # must. A deterministic check of git's match, which the agent then reads as one fact; nothing for a pointer
96
- # with no starting_at (#722).
103
+ # with no starting_at.
97
104
  #: (WriteUpPointer) -> Hash[String, bool]
98
105
  def starting_at_found(moved)
99
106
  moved.starting_at? ? { "starting_at_found_in_rename" => !unresolved?(moved) } : {}
@@ -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
  # Every finding the records leave open, deferred or accepted, as one fact the session-start line states: how
10
- # many wait, and which has waited longest (D47).
10
+ # many wait, and which has waited longest.
11
11
  class FindingsLeftOpen
12
12
  # The findings each record leaves open for the next full audit.
13
13
  #: (Array[AuditRecord]) -> FindingsLeftOpen
@@ -19,14 +19,14 @@ module Principles
19
19
  freeze
20
20
  end
21
21
 
22
- # How many are open, how many of them record no waits_on (#736), and the one first raised earliest as it
22
+ # How many are open, how many of them are deferred with no waits_on, and the one first raised earliest as it
23
23
  # has waited until now, or nil when none is open. How long it waited runs from first_raised_at, never from when
24
- # its waits_on was asked, which a later audit may have given it (D52).
24
+ # its waits_on was asked, which a later audit may have given it.
25
25
  #: (Time) -> Hash[String, untyped]?
26
26
  def waiting_at(now)
27
27
  oldest = @findings.min_by(&:first_raised_time) or return nil
28
28
 
29
- { "count" => @findings.length, "without_waits_on" => @findings.count(&:without_waits_on?),
29
+ { "count" => @findings.length, "waiting_on_no_one_named" => @findings.count(&:waiting_on_no_one_named?),
30
30
  **oldest.waited_at(now) }
31
31
  end
32
32
  end
@@ -0,0 +1,32 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../error"
5
+ require_relative "audit_record"
6
+
7
+ module Principles
8
+ module Models
9
+ # A principle's first full audit, which one background subagent runs from show-first-audit-brief so the session
10
+ # that starts it spends little of its context on it: its id, and its record, or nil with none.
11
+ class FirstFullAudit
12
+ #: (String, AuditRecord?) -> void
13
+ def initialize(id, record)
14
+ @id = id
15
+ @record = record
16
+ freeze
17
+ end
18
+
19
+ # Refuses once a full audit of the principle has completed, its record completed or open on a later audit,
20
+ # since the brief is for a principle no audit has judged yet, and a second subagent would spend an audit's
21
+ # reading for nothing.
22
+ #: () -> void
23
+ def refuse_once_completed
24
+ @record&.last_completed or return
25
+
26
+ raise Error.new("first_audit_completed", "A full audit of #{@id} has completed, so its first is done",
27
+ "To list the principles still awaiting a first full audit, run:\n" \
28
+ "#{Error::EXECUTABLE} show-first-audit-brief")
29
+ end
30
+ end
31
+ end
32
+ end
@@ -10,7 +10,7 @@ module Principles
10
10
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
11
  module Models
12
12
  # A still_holds decision's claim that its finding was first raised earlier than the record says, citing in
13
- # raised_in the commit whose audit record left it open then (D53). Whether that record's finding is the same
13
+ # raised_in the commit whose audit record left it open then. Whether that record's finding is the same
14
14
  # finding is the agent's judgement. This tool checks only the facts the claim cites, at that one commit: the
15
15
  # record there leaves a finding with the same id deferred or accepted, its audit was made at the claimed time,
16
16
  # and that time is earlier than the one stored. It walks no history.
@@ -9,7 +9,7 @@ module Principles
9
9
  module Models
10
10
  # The fields of a disposition that only a fix uses, changed_members, changed_map_entries, evidence and
11
11
  # reassessment, and what its action allows of them: a fix gives them, and any other action may omit them, or leave
12
- # them as printed, and claims no change (#997).
12
+ # them as printed, and claims no change.
13
13
  class FixOnlyFields
14
14
  # disposition is the disposition as the agent gave it; left_reassessment is the reassessment its template
15
15
  # prints, which a disposition not fixed leaves as printed.
@@ -0,0 +1,66 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "after_commit_input"
5
+ require_relative "../data/head_reflog"
6
+
7
+ module Principles
8
+ module Models
9
+ # Which repositories' HEAD a shell call moved by committing, each named once, in the order the call's
10
+ # directories name them, with the commit HEAD named before the move: what report-after-commit reports on. A
11
+ # checkout or a reset moves HEAD to commits that exist already, so neither is named; the next session start
12
+ # shows any change there. A project never mapped, under the folder's name now or its earlier one, is not named.
13
+ class HeadMoves
14
+ # One repository's move: its root, and the full sha HEAD named before it.
15
+ class Move
16
+ #: String
17
+ attr_reader :root, :before
18
+
19
+ #: (root: String, before: String) -> void
20
+ def initialize(root:, before:)
21
+ @root = root
22
+ @before = before
23
+ freeze
24
+ end
25
+ end
26
+
27
+ # The reflog subjects of moves that bring in no new commit.
28
+ NOT_A_COMMIT = /\A(?:checkout|reset):/ #: Regexp
29
+
30
+ # git_at gives what git says of a directory, as Data::HeadReflog does.
31
+ #: (AfterCommitInput, ?^(String) -> untyped) -> void
32
+ def initialize(input, git_at = ->(directory) { Data::HeadReflog.new(directory) })
33
+ @input = input
34
+ @git_at = git_at
35
+ freeze
36
+ end
37
+
38
+ #: () -> Array[Move]
39
+ def to_a
40
+ seen = [] #: Array[String]
41
+ @input.directories.filter_map do |directory|
42
+ git = @git_at.call(directory)
43
+ root = git.toplevel
44
+ next if root.nil? || seen.include?(root)
45
+
46
+ seen << root
47
+ before = git.mapped? && before_the_move(git)
48
+ Move.new(root:, before:) if before
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ # The commit HEAD named before it moved during the call, or nil when it did not move then, or moved to no
55
+ # new commit. Without a reflog, HEAD's committer time stands in, and the commit before HEAD starts the range.
56
+ #: (untyped) -> String?
57
+ def before_the_move(git)
58
+ moved, subject = git.last_move
59
+ return (git.commit("HEAD^") if git.committed_at.to_i >= @input.started) unless moved
60
+ return if moved < @input.started || subject.to_s.match?(NOT_A_COMMIT)
61
+
62
+ git.commit("HEAD@{1}")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -1,8 +1,10 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "json"
4
5
  require_relative "../error"
5
6
  require_relative "../data/project_files"
7
+ require_relative "report_hooks"
6
8
 
7
9
  module Principles
8
10
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
@@ -19,10 +21,18 @@ module Principles
19
21
  # The project settings files whose hooks Claude Code runs in this checkout: the committed one and the local.
20
22
  SETTINGS = %w[.claude/settings.json .claude/settings.local.json].freeze #: Array[String]
21
23
 
22
- # The command hooks in each project settings file present, or the code each unreadable one was refused with.
23
- #: (Data::ProjectFiles) -> HookCommands
24
- def self.read(files)
25
- new(SETTINGS.select { |path| files.file?(path) }.to_h do |path|
24
+ # Those and each file a host without the plugin reads the project's own hooks from, as show-hook-setup names
25
+ # them, where a project without the plugin wires this tool's hooks.
26
+ ON_EVERY_HOST = (SETTINGS | ReportHooks::HOSTS.map(&:file)).freeze #: Array[String]
27
+
28
+ # A command handler's command as JSON text quotes it, its value's escapes kept.
29
+ COMMAND_VALUE = /"command"\s*:\s*"((?:[^"\\]|\\.)*)"/ #: Regexp
30
+
31
+ # The command hooks in each of paths present, the project settings files unless others are given, or the code
32
+ # each unreadable one was refused with.
33
+ #: (Data::ProjectFiles, ?Array[String]) -> HookCommands
34
+ def self.read(files, paths = SETTINGS)
35
+ new(paths.select { |path| files.file?(path) }.to_h do |path|
26
36
  [path, files.parse_json(files.read_text(path), path)]
27
37
  rescue Error => e
28
38
  [path, e.payload.fetch("code")]
@@ -46,6 +56,24 @@ module Principles
46
56
  end
47
57
  end
48
58
 
59
+ # Whether the settings file at path holds a command handler that runs this tool's command, as a whole word
60
+ # after a word ending in principles, as the entries show-hook-setup prints run it.
61
+ #: (String, String) -> bool
62
+ def runs?(path, command)
63
+ handlers.any? { |entry| entry["settings"] == path && running?(entry["command"].to_s, command) }
64
+ end
65
+
66
+ # Whether a passage of the settings file at path, which the block gives only once the file runs this tool's
67
+ # command, runs it too: a command value the passage quotes whole runs it. A passage is a JSON fragment, not a
68
+ # file to parse, so each value is decoded alone, and one it cuts off or cannot decode runs nothing; nor does
69
+ # a passage the block refuses to give, as when it can no longer be found.
70
+ #: (String, String) { () -> String } -> bool
71
+ def passage_runs?(path, command, &passage)
72
+ runs?(path, command) && command_values(passage.call).any? { |value| running?(value, command) }
73
+ rescue Error
74
+ false
75
+ end
76
+
49
77
  # Each settings file this tool could not read, or whose hooks are not the documented shape, with why.
50
78
  #: () -> Array[Hash[String, String]]
51
79
  def not_read
@@ -57,6 +85,23 @@ module Principles
57
85
 
58
86
  private
59
87
 
88
+ # Whether a handler's command text runs this tool's command, as a whole word after a word ending in
89
+ # principles.
90
+ #: (String, String) -> bool
91
+ def running?(text, command)
92
+ text.match?(%r{(?:\A|[\s/])principles["']?\s+#{Regexp.escape(command)}(?=\z|[\s"';|&)])})
93
+ end
94
+
95
+ # Each command value passage quotes whole, decoded, leaving out one it cannot decode.
96
+ #: (String) -> Array[String]
97
+ def command_values(passage)
98
+ passage.scan(COMMAND_VALUE).flatten.filter_map do |quoted|
99
+ JSON.parse(%("#{quoted}"))
100
+ rescue JSON::ParserError
101
+ nil
102
+ end
103
+ end
104
+
60
105
  # Every command handler in every readable settings file, in file and declaration order.
61
106
  #: () -> Array[Hash[String, untyped]]
62
107
  def handlers
@@ -6,7 +6,7 @@ module Principles
6
6
  module Models
7
7
  # The candidate files git ignores, which this tool names but never reads. A folder git ignores can hold many
8
8
  # copies of instruction files written there by specs or builds, and listing each buries a file ignored on
9
- # its own, such as personal settings (#406). So a file under a folder git ignores is counted under the
9
+ # its own, such as personal settings. So a file under a folder git ignores is counted under the
10
10
  # shallowest such folder, and only the rest are listed.
11
11
  class IgnoredCandidates
12
12
  # paths are the ignored candidates; folders are every folder above one that git ignores, each ending in "/".
@@ -7,9 +7,8 @@ require_relative "../prose_list"
7
7
  module Principles
8
8
  # The domain of principles and their maps: each model owns its rules and loads and saves itself through data/.
9
9
  module Models
10
- # The instruction field start-audit --instruction names, read whole from the request a full audit asks (D81 step
11
- # 2, #983). Only a field the request prints an instruction under can be read: the others explain fields it does
12
- # not hold.
10
+ # The instruction field start-audit --instruction names, read whole from the request a full audit asks. Only a
11
+ # field the request prints an instruction under can be read: the others explain fields it does not hold.
13
12
  class InstructionNamed
14
13
  #: (String, principle_id: String, printed: Array[String]) -> void
15
14
  def initialize(field, principle_id:, printed:)
@@ -8,8 +8,8 @@ module Principles
8
8
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
9
9
  module Models
10
10
  # The digest of what a JSON value says: its objects' keys in sorted order at every depth and its lists in their
11
- # own, so a formatter or a hand edit that only reorders a file's keys leaves it unchanged (#656). A map's
12
- # version and an audit record's revision are each one (D51).
11
+ # own, so a formatter or a hand edit that only reorders a file's keys leaves it unchanged. A map's
12
+ # version and an audit record's revision are each one.
13
13
  class JsonDigest
14
14
  #: (untyped) -> void
15
15
  def initialize(value)
@@ -9,7 +9,7 @@ require_relative "json_path_selectors"
9
9
  module Principles
10
10
  # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
11
11
  module Models
12
- # A query in this tool's own profile of RFC 9535 JSONPath (D32): from $, name selectors in dot or bracket
12
+ # A query in this tool's own profile of RFC 9535 JSONPath: from $, name selectors in dot or bracket
13
13
  # form, wildcards, and filters that keep the children whose relative paths equal strings, joined by &&.
14
14
  # A query outside the profile is refused whole, never half-read, so an id always holds standard JSONPath
15
15
  # and a later full implementation changes no map. It only evaluates over values already parsed as JSON.
@@ -9,7 +9,7 @@ require_relative "waits_on"
9
9
  module Principles
10
10
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
11
  module Models
12
- # A prior finding a still_holds decision kept (D35): the finding as the next record keeps it, and what the decision
12
+ # A prior finding a still_holds decision kept: the finding as the next record keeps it, and what the decision
13
13
  # dropped or replaced of it, which the completed result names so a change not meant can be seen and put back.
14
14
  class KeptPriorFinding
15
15
  # decision is the checked still_holds decision on finding, the prior finding as its record left it open; members
@@ -22,14 +22,14 @@ module Principles
22
22
  freeze
23
23
  end
24
24
 
25
- # The finding as the record keeps it, with any problem, pointer, or action and its reason, its decision gave
26
- # (#996), and any earlier first_raised_at it claimed with the commit it cited (D53); a null pointer drops the one
25
+ # The finding as the record keeps it, with any problem, pointer, or action and its reason, its decision gave,
26
+ # and any earlier first_raised_at it claimed with the commit it cited; a null pointer drops the one
27
27
  # it had. Its evidence is as OpenFinding#evidence_after says, from its own state rather than as the request
28
- # printed it (D64, D70).
28
+ # printed it.
29
29
  #: () -> Hash[String, untyped]
30
30
  def to_h = @record
31
31
 
32
- # The pointer it had that its decision dropped with a null recorded_at, or nil when it dropped none (#374).
32
+ # The pointer it had that its decision dropped with a null recorded_at, or nil when it dropped none.
33
33
  #: () -> Hash[String, untyped]?
34
34
  def dropped_write_up
35
35
  had = @finding.recorded_at
@@ -38,7 +38,7 @@ module Principles
38
38
  { "finding_id" => @finding.id, "recorded_at" => had.to_h }
39
39
  end
40
40
 
41
- # What it waited on that its decision dropped, with null or by accepting it, or nil when it dropped nothing (D52).
41
+ # What it waited on that its decision dropped, with null or by accepting it, or nil when it dropped nothing.
42
42
  #: () -> Hash[String, untyped]?
43
43
  def waits_on_dropped
44
44
  return if @finding.without_waits_on? || @record.key?("waits_on")
@@ -46,11 +46,11 @@ module Principles
46
46
  { "finding_id" => @finding.id, **@finding.waiting }
47
47
  end
48
48
 
49
- # The problem its decision restated, as it was and is now, or nil when it restated none (D82).
49
+ # The problem its decision restated, as it was and is now, or nil when it restated none.
50
50
  #: () -> Hash[String, String]?
51
51
  def problem_restated = @finding.restated(@decision["problem"])
52
52
 
53
- # Each kept evidence item its decision gave a new place, as it was and is now (D70).
53
+ # Each kept evidence item its decision gave a new place, as it was and is now.
54
54
  #: () -> Array[Hash[String, untyped]]
55
55
  def swaps = @finding.replacements(@decision["problem_evidence"]).swaps(@finding.id)
56
56
 
@@ -64,7 +64,7 @@ module Principles
64
64
  kept.merge(waiting_after(kept))
65
65
  end
66
66
 
67
- # What it waits on, and since when, after its decision (D52).
67
+ # What it waits on, and since when, after its decision.
68
68
  #: (Hash[String, untyped]) -> Hash[String, untyped]
69
69
  def waiting_after(kept)
70
70
  WaitsOn.new(@decision.fetch("waits_on", @finding.waits_on), action: kept.fetch("action"))
@@ -9,8 +9,7 @@ module Principles
9
9
  module Models
10
10
  # The revision of a principle's last completed audit record when a request was printed, or nil when there was
11
11
  # none. An assessment's basis and a correction's carry it, so either answer is refused once that record changed,
12
- # by another audit completing or a member's acknowledgement, rather than replacing it and what it left open
13
- # (#646, #653).
12
+ # by another audit completing or a member's acknowledgement, rather than replacing it and what it left open.
14
13
  class LastCompletedRevision
15
14
  #: (String?) -> void
16
15
  def initialize(revision)
@@ -19,7 +18,7 @@ module Principles
19
18
  end
20
19
 
21
20
  # Refuses an answer of principle_id that would write changes, when record, the record now, changed since the
22
- # request was printed. An answer that writes nothing, as an identical retry does, is accepted (D24).
21
+ # request was printed. An answer that writes nothing, as an identical retry does, is accepted.
23
22
  #: (String, AuditRecord?, Array[untyped]) -> void
24
23
  def confirm_writable(principle_id, record, changes)
25
24
  confirm_unchanged(principle_id, record) unless changes.empty?
@@ -27,7 +26,7 @@ module Principles
27
26
 
28
27
  # What the block gives, judging an answer of principle_id; but when the block refuses the answer while record,
29
28
  # the record now, changed since the request was printed, the refusal is that the request is stale, so the agent
30
- # does not repair an answer it must start again (#669). An answer the block refuses is not D24's identical
29
+ # does not repair an answer it must start again. An answer the block refuses is not the identical
31
30
  # retry, which passed every check, so the stale refusal always wins over it.
32
31
  #: [T] (String, AuditRecord?) { () -> T } -> T
33
32
  def refusing_stale_first(principle_id, record, &)
@@ -55,7 +54,7 @@ module Principles
55
54
  private
56
55
 
57
56
  # What changed the record last: its removal, the newest acknowledgement since its audit, or else the audit.
58
- # Acknowledgements are dropped when a full audit completes, so any kept is newer than the audit (D33).
57
+ # Acknowledgements are dropped when a full audit completes, so any kept is newer than the audit.
59
58
  #: (AuditRecord?) -> String
60
59
  def what_changed(last)
61
60
  return "the record was removed" unless last