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,11 +16,12 @@ require_relative "carried_assessments"
16
16
  require_relative "prior_findings"
17
17
  require_relative "decided_prior_findings"
18
18
  require_relative "disposition"
19
+ require_relative "stale_request"
19
20
 
20
21
  module Principles
21
22
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
22
23
  module Models
23
- # One principle's audit as its map and members are now. Nothing about a request is stored (D25): each
24
+ # One principle's audit as its map and members are now. Nothing about a request is stored: each
24
25
  # request id digests what the request depends on, so an answer is refused when what it was asked about
25
26
  # has changed since. A correction is based on the map's version and each finding's members, never on
26
27
  # the agent's prose.
@@ -45,9 +46,9 @@ module Principles
45
46
  def map_version = @map.version
46
47
 
47
48
  # The id of the assessment request printed with basis: its base commit, nil outside git, and the last
48
- # completed record's revision, so an answer cannot point the request at a later record (#653).
49
- # prior is what PriorFindings#digested gives, empty when the last audit left no finding to decide (D35);
50
- # loads is what LoadsToCheck#listed gives, nil when the activation lists nothing to check (#355).
49
+ # completed record's revision, so an answer cannot point the request at a later record.
50
+ # prior is what PriorFindings#digested gives, empty when the last audit left no finding to decide;
51
+ # loads is what LoadsToCheck#listed gives, nil when the activation lists nothing to check.
51
52
  #: (AssessmentBasis, ?Array[Hash[String, untyped]], ?Hash[String, untyped]?) -> RequestId
52
53
  def assessment_id(basis, prior = [], loads = nil)
53
54
  parts = [map_version, basis.digested, @now]
@@ -58,31 +59,30 @@ module Principles
58
59
 
59
60
  # Refuses an assessment unless request_id is the one printed with basis for the map and members as they are
60
61
  # now, and, in git, the members are as its base holds them (committed).
61
- # It returns the findings the last audit, whose record is given, left for this one to decide (D35); loads is
62
- # what the audit lists to check now, so a change to what lists a member to check makes the request stale (#355).
62
+ # It returns the findings the last audit, whose record is given, left for this one to decide; loads is
63
+ # what the audit lists to check now, so a change to what lists a member to check makes the request stale.
63
64
  #: (RequestId, basis: AssessmentBasis, committed: Hash[String, String]?, record: AuditRecord?,
64
65
  #| loads: LoadsToCheck) -> PriorFindings
65
66
  def check_assessment_request(request_id, basis:, committed:, record:, loads:)
66
67
  prior = prior_findings(record)
67
68
  now_id = assessment_id(basis, prior.digested, loads.listed)
68
- raise stale_request unless now_id == request_id && (basis.base.nil? || committed == @now)
69
+ return prior if now_id == request_id && (basis.base.nil? || committed == @now)
69
70
 
70
- prior
71
+ raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false).refusal
71
72
  end
72
73
 
73
- # The answer to this audit's assessment request, checked against each member, each member's check (D30)
74
- # and each member the listing names to check against the activation (#355); the block locates each piece of
74
+ # The answer to this audit's assessment request, checked against each member, each member's check
75
+ # and each member the listing names to check against the activation; the block locates each piece of
75
76
  # evidence, giving where it is and the hash of its text.
76
77
  # judged_against is the principle's record as it stands, which says which members' last assessments the
77
- # answer may carry forward (D49); answered_at is when the answer came, which no sighting it reports is after
78
- # (#699).
78
+ # answer may carry forward; answered_at is when the answer came, which no sighting it reports is after.
79
79
  #: (untyped, RecordJudgedAgainst, String) { (Locator) -> Hash[String, untyped] }
80
80
  #| -> AssessmentAnswer
81
81
  def assessment(response, judged_against, answered_at, &)
82
82
  AssessmentAnswer.new(response, members, answered_at: answered_at, judged_against: judged_against, &)
83
83
  end
84
84
 
85
- # A digest of what this audit's assessments answer: its description and question (D49).
85
+ # A digest of what this audit's assessments answer: its description and question.
86
86
  #: (String) -> String
87
87
  def judged_against(question) = started(nil, {}).judged_against(question)
88
88
 
@@ -94,16 +94,16 @@ module Principles
94
94
  end
95
95
 
96
96
  # What an audit answered by assessed began from: base, each member's hash now, and what the answer reported
97
- # beyond its findings, each assessment with the grounds it was judged on (D49).
97
+ # beyond its findings, each assessment with the grounds it was judged on.
98
98
  #: (String?, AssessmentAnswer, MemberGrounds) -> AuditStart
99
99
  def assessed_start(base, assessed, grounds)
100
100
  started(base, @now, AssessmentReport.answered(assessed, grounds))
101
101
  end
102
102
 
103
103
  # What the audit a correction's basis names began from: its base commit, each member's hash then
104
- # (before), and the assessment's report record keeps, under the ids of any moved members (D87). The record is
104
+ # (before), and the assessment's report record keeps, under the ids of any moved members. The record is
105
105
  # the open one the basis was printed with, or a completed one, which only an identical retry may complete
106
- # again (D24); none, or another open one, refuses the correction as stale.
106
+ # again; none, or another open one, refuses the correction as stale.
107
107
  #: (CorrectionBasis, Hash[String, String], MemberMoves, AuditRecord?) -> AuditStart
108
108
  def resumed(basis, before, moves, record)
109
109
  raise stale_request unless record && (record.completed? || basis.printed_with?(record))
@@ -112,8 +112,8 @@ module Principles
112
112
  end
113
113
 
114
114
  # Refuses, as stale, a correction read back from a completed record, as resumed allows, unless completing it
115
- # writes nothing: only an identical retry of the correction that completed it (D24) may read one, never an
116
- # earlier audit's record that git restore put back in place of the open one (D87). An audit that read no record
115
+ # writes nothing: only an identical retry of the correction that completed it may read one, never an
116
+ # earlier audit's record that git restore put back in place of the open one. An audit that read no record
117
117
  # back, one completed from its assessment, gives none.
118
118
  #: (AuditRecord?, Array[AuditRecord]) -> void
119
119
  def confirm_read_back(record, changes)
@@ -134,7 +134,7 @@ module Principles
134
134
  end
135
135
 
136
136
  # The hashes the audit began from (before), refused unless they were found and request_id is the one
137
- # printed for them and basis; a basis the answer edited is refused as that, not as a stale request (#1045).
137
+ # printed for them and basis; a basis the answer edited is refused as that, not as a stale request.
138
138
  #: (RequestId, CorrectionBasis, Hash[String, String]?) -> Hash[String, String]
139
139
  def confirmed_start(request_id, basis, before)
140
140
  differs = basis.request_id(id, before || {}).differs_from(request_id)
@@ -145,8 +145,8 @@ module Principles
145
145
  end
146
146
 
147
147
  # Each finding's outcome: its members and its disposition's action, where it is recorded, if anywhere, and
148
- # what a deferral says it waits on, if anything (D52).
149
- # Then each prior finding kept (D35); a new finding that raises one again keeps when it was first raised.
148
+ # what a deferral says it waits on, if anything.
149
+ # Then each prior finding kept; a new finding that raises one again keeps when it was first raised.
150
150
  #: (Array[untyped], Array[Disposition], ?DecidedPriorFindings) -> Array[untyped]
151
151
  def outcomes(findings, dispositions, prior = DecidedPriorFindings::NONE)
152
152
  findings.map do |finding|
@@ -157,20 +157,20 @@ module Principles
157
157
  end
158
158
 
159
159
  # What each member's assessment is judged on beside its text, from each member's loads: its map entry and when
160
- # it loads (D49).
160
+ # it loads.
161
161
  #: (Hash[String, MemberLoads]) -> MemberGrounds
162
162
  def grounds(loads) = MemberGrounds.new(members, loads)
163
163
 
164
164
  # Which members' last assessments this audit carries forward, from the principle's record now, grounds, and the
165
- # question the request asks (D49).
165
+ # question the request asks.
166
166
  #: (AuditRecord?, grounds: MemberGrounds, question: String) -> CarriedAssessments
167
167
  def carried_assessments(record, grounds:, question:)
168
168
  CarriedAssessments.new(record, members: members, judged_against: judged_against(question), now: @now,
169
169
  grounds: grounds)
170
170
  end
171
171
 
172
- # The members this audit lists to check against the map's activation, from each member's loads (#355), each
173
- # with the decision the last completed audit, whose record is given, accepted on its loading (#502).
172
+ # The members this audit lists to check against the map's activation, from each member's loads, each
173
+ # with the decision the last completed audit, whose record is given, accepted on its loading.
174
174
  #: (Hash[String, MemberLoads], ?AuditRecord?) -> LoadsToCheck
175
175
  def loads_to_check(loads, record = nil)
176
176
  completed = record&.last_completed
@@ -178,7 +178,7 @@ module Principles
178
178
  accepted: completed ? completed.members.loading_accepted(members) : {})
179
179
  end
180
180
 
181
- # The findings the last audit left for this one to decide (D35), from its record.
181
+ # The findings the last audit left for this one to decide, from its record.
182
182
  #: (AuditRecord?) -> PriorFindings
183
183
  def prior_findings(record)
184
184
  PriorFindings.new(record: record, now: @now, members: members)
@@ -192,7 +192,7 @@ module Principles
192
192
  (fixed + dispositions.filter_map(&:recorded_path)).uniq
193
193
  end
194
194
 
195
- # The path of the member with member_id in the map, refused as unknown_member when no member has it (#778).
195
+ # The path of the member with member_id in the map, refused as unknown_member when no member has it.
196
196
  #: (String) -> String
197
197
  def path_of(member_id) = members.found(member_id).path
198
198
 
@@ -209,14 +209,13 @@ module Principles
209
209
  fields: [{ "pointer" => "/basis", "problem" => "edited since it was printed" }])
210
210
  end
211
211
 
212
+ # The ids of the members whose hash now differs from the one committed, the base commit's, gives; none
213
+ # outside git.
214
+ #: (Hash[String, String]?) -> Array[String]
215
+ def changed_since(committed) = committed ? @now.reject { |member_id, sha| committed[member_id] == sha }.keys : []
216
+
212
217
  #: () -> Error
213
- def stale_request
214
- Error.new("stale_request", "This request no longer matches #{id}: its map, a member, the commit it " \
215
- "was based on, or what says when a listed member loads and how big it is " \
216
- "(project settings, frontmatter or a listed file), has changed since it was " \
217
- "printed, or another release or checkout of principles printed it",
218
- "Start the audit again and answer the new request: #{Error::EXECUTABLE} start-audit #{id}")
219
- end
218
+ def stale_request = StaleRequest.new(id).refusal
220
219
  end
221
220
  end
222
221
  end
@@ -17,12 +17,12 @@ module Principles
17
17
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
18
18
  module Models
19
19
  # The committed record of a principle's last audit: what it began from, each member's hash when it was
20
- # made and each finding's outcome with its problem (D34). Outside git it also keeps the hashes the audit
20
+ # made and each finding's outcome with its problem. Outside git it also keeps the hashes the audit
21
21
  # began from, which git keeps otherwise, and an open record keeps the last completed one, whose deferred
22
- # and accepted findings the next audit must still decide (D35).
22
+ # and accepted findings the next audit must still decide.
23
23
  class AuditRecord
24
24
  # The record an audit that began at start writes, with each member's hash, the result reported for its
25
- # check, if any (D30), and each finding's outcome. The hashes the audit began from are kept only outside
25
+ # check, if any, and each finding's outcome. The hashes the audit began from are kept only outside
26
26
  # git, where start has no base commit.
27
27
  #: (AuditStart, status: String, audited_at: String, members: Hash[String, String], findings: Array[untyped])
28
28
  #| -> AuditRecord
@@ -53,13 +53,13 @@ module Principles
53
53
  end
54
54
 
55
55
  # The record as this copy writes it, as RecordFormat stamps it. Only a write stamps it, so a record read without
56
- # a format keeps its revision (D85).
56
+ # a format keeps its revision.
57
57
  #: () -> Hash[String, untyped]
58
58
  def stamped = RecordFormat.new(@fields).stamped
59
59
 
60
60
  # A digest of the whole record. A correction carries the last completed record's from when its request was
61
- # printed, so it is refused once that record changed (#646). A formatter that only reorders its keys changes
62
- # neither what the record says nor its revision, as same_as? already compares it (#656).
61
+ # printed, so it is refused once that record changed. A formatter that only reorders its keys changes
62
+ # neither what the record says nor its revision, as same_as? already compares it.
63
63
  #: () -> String
64
64
  def revision = JsonDigest.new(@fields).to_s
65
65
 
@@ -69,7 +69,7 @@ module Principles
69
69
  end
70
70
 
71
71
  # A digest of what the record says of each member, apart from when its assessment was made: an open record's
72
- # assessment, which its correction's basis carries so the correction is refused once the record changed (D87).
72
+ # assessment, which its correction's basis carries so the correction is refused once the record changed.
73
73
  #: () -> String
74
74
  def assessment_digest = JsonDigest.new(members.undated).to_s
75
75
 
@@ -113,18 +113,38 @@ module Principles
113
113
  @fields["status"] == "completed"
114
114
  end
115
115
 
116
+ # Whether the audit this record describes is open: its assessment kept and its correction not yet answered.
117
+ #: () -> bool
118
+ def open? = !completed?
119
+
120
+ # Whether this record is open on a completed audit it keeps: a later full audit waiting on its correction.
121
+ #: () -> bool
122
+ def open_after_a_completed_audit? = open? && !last_completed.nil?
123
+
116
124
  # This open record, keeping the last completed record it replaces outside git, so the next audit still
117
- # decides that record's findings (D35); itself when there is none.
125
+ # decides that record's findings; itself when there is none.
118
126
  #: (AuditRecord?) -> AuditRecord
119
127
  def keeping(last_completed)
120
128
  last_completed ? AuditRecord.new(@fields.merge("last_completed" => last_completed.to_h)) : self
121
129
  end
122
130
 
123
- # This record, saying what its assessments were judged against, as AuditStart#judged_against digests it (D49).
131
+ # This open record, keeping the correction its assessment's findings opened, its request_id and basis as
132
+ # printed, so show-open-correction prints it again.
133
+ #: (String, Hash[String, untyped]) -> AuditRecord
134
+ def correcting(request_id, basis)
135
+ AuditRecord.new(@fields.merge("correction" => { "request_id" => request_id, "basis" => basis }))
136
+ end
137
+
138
+ # The correction an open record keeps, its request_id and basis, or nil when it keeps none, as one an earlier
139
+ # release wrote.
140
+ #: () -> Hash[String, untyped]?
141
+ def correction = (@fields["correction"] if open?)
142
+
143
+ # This record, saying what its assessments were judged against, as AuditStart#judged_against digests it.
124
144
  #: (String) -> AuditRecord
125
145
  def judged(against) = AuditRecord.new(@fields.merge("judged_against" => against))
126
146
 
127
- # This record, keeping the release of principles its audit ran under, when the principle keeps one (D68).
147
+ # This record, keeping the release of principles its audit ran under, when the principle keeps one.
128
148
  #: (PrinciplesPackage?) -> AuditRecord
129
149
  def packaged(package) = package ? AuditRecord.new(@fields.merge("principles_package" => package.to_h)) : self
130
150
 
@@ -132,21 +152,21 @@ module Principles
132
152
  #: () -> PrinciplesPackage?
133
153
  def package = PrinciplesPackage.kept(@fields["principles_package"])
134
154
 
135
- # Whether this record kept its members' assessments, which a record written before D49 did not.
155
+ # Whether this record kept its members' assessments, which an older record did not.
136
156
  #: () -> bool
137
157
  def kept_assessments? = !@fields["judged_against"].nil?
138
158
 
139
- # Whether this record's assessments answered what against digests, as AuditStart#judged_against does (D49).
159
+ # Whether this record's assessments answered what against digests, as AuditStart#judged_against does.
140
160
  #: (String) -> bool
141
161
  def judged_against?(against) = @fields["judged_against"] == against
142
162
 
143
- # This record with each assessment its answer carried forward taken from last, the record it replaces (D49).
163
+ # This record with each assessment its answer carried forward taken from last, the record it replaces.
144
164
  #: (AuditRecord?) -> AuditRecord
145
165
  def carrying(last)
146
166
  AuditRecord.new(@fields.merge("members" => members.carrying(last&.last_completed&.members).to_h))
147
167
  end
148
168
 
149
- # The last completed audit's record: this one, or the one an open record keeps, or nil (D35).
169
+ # The last completed audit's record: this one, or the one an open record keeps, or nil.
150
170
  #: () -> AuditRecord?
151
171
  def last_completed
152
172
  return self if completed?
@@ -155,15 +175,15 @@ module Principles
155
175
  kept ? AuditRecord.new(kept) : nil
156
176
  end
157
177
 
158
- # This record with the member known by key moved to change's to_sha256, and change kept beside it (D33).
178
+ # This record with the member known by key moved to change's to_sha256, and change kept beside it.
159
179
  # Nothing else changes: the map version, base commit and findings stay the audit's own.
160
- # check_result is the result reported for the member's check, which replaces the one the record kept (#1071).
180
+ # check_result is the result reported for the member's check, which replaces the one the record kept.
161
181
  #: (String, Hash[String, untyped], ?check_result: Hash[String, untyped]?) -> AuditRecord
162
182
  def acknowledged(key, change, check_result: nil)
163
183
  AuditRecord.new(@fields.merge("members" => members.acknowledged(key, change, check_result:).to_h))
164
184
  end
165
185
 
166
- # This record with each finding a repoint names moved by it at at (D59); the last repoint naming a finding
186
+ # This record with each finding a repoint names moved by it at at; the last repoint naming a finding
167
187
  # wins.
168
188
  #: (Array[WriteUpRepoint], at: String) -> AuditRecord
169
189
  def repointed(repoints, at:)
@@ -171,16 +191,16 @@ module Principles
171
191
  end
172
192
 
173
193
  # The ids of the findings it leaves open whose recorded_at points elsewhere than earlier's did, as a repoint
174
- # moved them (D59, T16).
194
+ # moved them.
175
195
  #: (AuditRecord) -> Array[String]
176
196
  def write_ups_moved_since(earlier)
177
197
  before = earlier.left_open.to_h { |finding| [finding.id, finding.recorded_at] }
178
198
  left_open.select { |finding| before.key?(finding.id) && before[finding.id] != finding.recorded_at }.map(&:id)
179
199
  end
180
200
 
181
- # Each finding the last completed audit deferred or accepted, which the next full audit must decide (D35):
201
+ # Each finding the last completed audit deferred or accepted, which the next full audit must decide:
182
202
  # this record's own, or, while it is open outside git, those of the completed record it keeps, since its own
183
- # wait on its correction (#655). The one owner of which record's findings are open.
203
+ # wait on its correction. The one owner of which record's findings are open.
184
204
  #: () -> Array[OpenFinding]
185
205
  def left_open
186
206
  return findings.left_open if completed?
@@ -189,37 +209,37 @@ module Principles
189
209
  end
190
210
 
191
211
  # The ids of the findings it leaves open, as list-open-findings lists them: deferred or accepted, its own and any
192
- # prior finding kept (#714).
212
+ # prior finding kept.
193
213
  #: () -> Array[String]
194
214
  def open_ids = left_open.map(&:id)
195
215
 
196
216
  # The ids of the findings it leaves open on the member known by key, which the next full audit decides beside
197
- # it (D93).
217
+ # it.
198
218
  #: (String) -> Array[String]
199
219
  def open_ids_on(key) = left_open.select { it.on?(key) }.map(&:id)
200
220
 
201
221
  # The ids of the findings its audit resolved: those it fixed, and each prior finding decided resolved, never
202
- # one withdrawn (#714).
222
+ # one withdrawn.
203
223
  #: (DecidedPriorFindings) -> Array[String]
204
224
  def resolved_ids(decided)
205
225
  findings.fixed_ids + decided.resolved_ids
206
226
  end
207
227
 
208
- # Each finding left open, as list-open-findings prints it (D35, brief finding 13).
228
+ # Each finding left open, as list-open-findings prints it.
209
229
  #: () -> Array[Hash[String, untyped]]
210
230
  def open_findings = left_open.map(&:listed)
211
231
 
212
- # Each finding left open, as the next full audit's request lists it (D35).
232
+ # Each finding left open, as the next full audit's request lists it.
213
233
  #: () -> Array[Hash[String, untyped]]
214
234
  def prior_findings = left_open.map(&:for_next_audit)
215
235
 
216
236
  # The path of each file this record points at, through its assessments' evidence and its findings' evidence
217
- # and write-ups, which a clone must hold for the record to be checked there (#724).
237
+ # and write-ups, which a clone must hold for the record to be checked there.
218
238
  #: () -> Array[String]
219
239
  def cited_paths = (members.cited_paths + findings.cited_paths).uniq
220
240
 
221
241
  # The files this record cites, as history holds them now: which go with it when its completed audit is
222
- # committed, compared with HEAD only in git, and which no longer exist (#724, #861).
242
+ # committed, compared with HEAD only in git, and which no longer exist.
223
243
  #: (ProjectHistory) -> CitedFiles
224
244
  def cited_files(history) = CitedFiles.new(cited_paths, history, in_git: !base_commit.nil?)
225
245
 
@@ -234,7 +254,7 @@ module Principles
234
254
 
235
255
  # The line saying what the review of the check this record ran for the member known by key rested on, with the
236
256
  # date it was first kept: its own review_basis_since, or else this record's audited_at, which dates a line kept
237
- # here first (D63, D52). Nothing when the record ran no check for it or kept no line.
257
+ # here first. Nothing when the record ran no check for it or kept no line.
238
258
  #: (String) -> Hash[String, untyped]
239
259
  def check_review_for(key)
240
260
  kept = members.check_review_as_kept(key)
@@ -243,6 +263,12 @@ module Principles
243
263
  { "review_basis_since" => @fields["audited_at"] }.merge(kept)
244
264
  end
245
265
 
266
+ # That line as an answer keeping it carries it into the record it writes: as check_review_for dates it, from a
267
+ # completed record; from an open one as kept, since the audit completing it dates a line first kept there, so
268
+ # answering the same assessment again records the line as the first answer did.
269
+ #: (String) -> Hash[String, untyped]
270
+ def check_review_carried_for(key) = completed? ? check_review_for(key) : members.check_review_as_kept(key)
271
+
246
272
  private
247
273
 
248
274
  # The findings its own audit recorded, whatever it did about each, with the principle, audit time and members
@@ -24,7 +24,7 @@ module Principles
24
24
  end
25
25
 
26
26
  # The file id's record was in at commit, and that record, or nil when commit holds it in neither the folder
27
- # nor its earlier name, as outside git (D53). It is read only at a commit an agent names; nothing walks history.
27
+ # nor its earlier name, as outside git. It is read only at a commit an agent names; nothing walks history.
28
28
  #: (String, String) -> [String, AuditRecord]?
29
29
  def at(id, commit)
30
30
  [file(id), earlier_file(id)].each do |path|
@@ -35,7 +35,7 @@ module Principles
35
35
  end
36
36
 
37
37
  # id's record, or nil when it has none; Data::AuditFiles refuses one that is unparseable, and one its schema
38
- # refuses, unless a later copy wrote it (D85).
38
+ # refuses, unless a later copy wrote it.
39
39
  #: (String) -> AuditRecord?
40
40
  def find(id)
41
41
  fields = @files.read(id) { refuse_unreadable(it, file(id)) }
@@ -65,7 +65,7 @@ module Principles
65
65
 
66
66
  # The findings id's record leaves open: none when it has no record, and none when its record cannot be read,
67
67
  # which list-member-problems reports, so a command reading other principles' findings beside its own is not
68
- # refused for theirs (#772).
68
+ # refused for theirs.
69
69
  #: (String) -> Array[OpenFinding]
70
70
  def left_open_or_none(id)
71
71
  find(id)&.left_open || []
@@ -74,7 +74,7 @@ module Principles
74
74
  end
75
75
 
76
76
  # Refuses to let this copy, at version, rewrite id's record when a later copy wrote it at a newer format,
77
- # read afresh so a record that lands mid-audit is caught too (D85).
77
+ # read afresh so a record that lands mid-audit is caught too.
78
78
  #: (String, version: String) -> void
79
79
  def refuse_newer(id, version:)
80
80
  record = find(id) or return
@@ -82,7 +82,7 @@ module Principles
82
82
  end
83
83
 
84
84
  # The format of id's record when a later copy wrote it, read whether or not this copy's schema accepts it; nil
85
- # when it has none, is not newer, or is refused for another reason, which reading it reports (D85).
85
+ # when it has none, is not newer, or is refused for another reason, which reading it reports.
86
86
  #: (String) -> RecordFormat?
87
87
  def newer_format(id)
88
88
  fields = @files.read(id) { |raw| return RecordFormat.newer_of(raw) }
@@ -93,7 +93,7 @@ module Principles
93
93
 
94
94
  # The member hashes id's record holds, which its members are compared with: the record's own when this copy can
95
95
  # read it, and as written when its schema refuses one a later copy wrote, marked waiting when a later copy wrote
96
- # it, so the comparison is read-only (D85 V8, #1066, #1067); none when it has no record.
96
+ # it, so the comparison is read-only; none when it has no record.
97
97
  #: (String) -> RecordedHashes
98
98
  def hashes_to_compare(id)
99
99
  audit = find(id) or return RecordedHashes::NONE
@@ -103,7 +103,7 @@ module Principles
103
103
  end
104
104
 
105
105
  # id's record if this copy can read it; nil when it has none, or a later copy wrote it in a form this copy
106
- # cannot read, whose audits wait on an upgrade (D85, V8).
106
+ # cannot read, whose audits wait on an upgrade.
107
107
  #: (String) -> AuditRecord?
108
108
  def readable(id)
109
109
  find(id)
@@ -116,7 +116,7 @@ module Principles
116
116
  def of(ids) = ids.filter_map { |id| find(id) }
117
117
 
118
118
  # The record of each of ids that this copy can read, leaving out one a later copy wrote that it cannot, so a
119
- # read across principles is not refused for that one, whose audits wait on an upgrade (D85, V8).
119
+ # read across principles is not refused for that one, whose audits wait on an upgrade.
120
120
  #: (Array[String]) -> Array[AuditRecord]
121
121
  def readable_of(ids)
122
122
  ids.filter_map { readable(it) }
@@ -149,13 +149,13 @@ module Principles
149
149
  end
150
150
 
151
151
  # What record's completed audit asks to commit: its own file, then the files the record says go with it, of
152
- # changed and those it cites, with what reported cites that the record does not keep (#855, #860).
152
+ # changed and those it cites, with what reported cites that the record does not keep.
153
153
  #: (AuditRecord, Array[String], ?AssessmentReport) -> Array[String]
154
154
  def files_to_commit(record, changed, reported = AssessmentReport::NONE)
155
155
  [file(record.principle_id), *record.cited_files(@history).committed_with(changed, reported)]
156
156
  end
157
157
 
158
- # Each file record cites that no longer exists, which files_to_commit leaves out (#861).
158
+ # Each file record cites that no longer exists, which files_to_commit leaves out.
159
159
  #: (AuditRecord) -> Array[String]
160
160
  def cited_files_missing(record) = record.cited_files(@history).missing
161
161
 
@@ -173,7 +173,7 @@ module Principles
173
173
  @files.relative(id)
174
174
  end
175
175
 
176
- # The file id's record was kept in under the folder's earlier name, relative to the project (#536).
176
+ # The file id's record was kept in under the folder's earlier name, relative to the project.
177
177
  #: (String) -> String
178
178
  def earlier_file(id)
179
179
  @files.earlier_relative(id)
@@ -182,7 +182,7 @@ module Principles
182
182
  private
183
183
 
184
184
  # The member hashes of id's record as a later copy wrote it, read without this copy's schema, which refuses it;
185
- # none when it cannot be parsed at all (#1066).
185
+ # none when it cannot be parsed at all.
186
186
  #: (String) -> MemberHashesAsWritten
187
187
  def member_hashes_as_written(id)
188
188
  fields = @files.read(id) { |raw| return MemberHashesAsWritten.new(raw) }
@@ -192,7 +192,7 @@ module Principles
192
192
  end
193
193
 
194
194
  # Refuses fields, a record at file the schema refused, as one a later copy wrote when its format says so, so
195
- # its repair is never to repair or restore a record that is not broken (D85, V3).
195
+ # its repair is never to repair or restore a record that is not broken.
196
196
  #: (untyped, String) -> void
197
197
  def refuse_unreadable(fields, file)
198
198
  RecordFormat.new(fields).refuse_unreadable(file) if fields.is_a?(Hash)
@@ -57,9 +57,9 @@ module Principles
57
57
  def began_with?(id) = @before.key?(id)
58
58
 
59
59
  # The entry with its assessment dated assessed_at, and an observed sighting the answer gave no observed_at for
60
- # dated then too (#680), or a carried one left for completion to fill; when the member changed during the
60
+ # dated then too, or a carried one left for completion to fill; when the member changed during the
61
61
  # audit, as a fix in its correction changes it, no assessment read the text it is recorded at, so it keeps none
62
- # and says why (D49).
62
+ # and says why.
63
63
  #: (Hash[String, untyped], String, changed: bool) -> Hash[String, untyped]
64
64
  def with_assessment(entry, assessed_at, changed:)
65
65
  kept = entry["assessment"] or return entry
@@ -73,7 +73,7 @@ module Principles
73
73
  public
74
74
 
75
75
  # A digest of what this audit's assessments answered: the principle's description and question, the question
76
- # this tool asked. When either changes, the next full audit carries no assessment forward (D49).
76
+ # this tool asked. When either changes, the next full audit carries no assessment forward.
77
77
  #: (String) -> String
78
78
  def judged_against(question) = JsonDigest.new("description" => @map.description, "question" => question).to_s
79
79
 
@@ -10,7 +10,7 @@ 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
12
  # The lines a full audit's members span now, each with its file, against which each evidence item of another
13
- # principle's open finding is said to share lines or not (#792, D64). These are lines, not a verdict on whether
13
+ # principle's open finding is said to share lines or not. These are lines, not a verdict on whether
14
14
  # the finding is about the same problem, which the agent judges.
15
15
  class AuditedMemberLines
16
16
  # located gives, under each audited member's id, the text found for it now: its path and its lines.
@@ -13,12 +13,16 @@ module Principles
13
13
  # directory. Explicit selections are always named, including skill references and non-Markdown text files.
14
14
  # The agent still sees where every file is, and decides what to read.
15
15
  class CandidateFiles
16
- # A file a harness reads as settings, listed by name like guidance.
17
- SETTINGS = %r{(?:\A|/)\.claude/settings[^/]*\.json\z}
16
+ # A file a harness reads as settings, listed by name like guidance: Claude Code's settings, and Codex's hooks
17
+ # file and custom agents.
18
+ SETTINGS = %r{(?:\A|/)(?:\.claude/settings[^/]*\.json|\.codex/hooks\.json|\.codex/agents/[^/]+\.toml)\z}
18
19
  MARKDOWN = /\.md\z/i
19
- # A file inside a skill's folder, and whether it is the skill's entry point.
20
- IN_SKILL = %r{(?:\A|/)\.claude/skills/[^/]+/}
21
- SKILL_ENTRY = %r{(?:\A|/)\.claude/skills/[^/]+/SKILL\.md\z}
20
+ # A file inside a skill's folder, Claude Code's or Codex's, and whether it is the skill's entry point, spelt
21
+ # SKILL.md or in any other case, which a case-insensitive disk opens all the same.
22
+ IN_SKILL = %r{(?:\A|/)\.(?:claude|agents)/skills/[^/]+/}
23
+ SKILL_ENTRY = %r{(?:\A|/)\.(?:claude|agents)/skills/[^/]+/(?<name>SKILL\.md)\z}i
24
+ # The entry file's name as the skill format spells it.
25
+ SKILL_NAME = "SKILL.md"
22
26
 
23
27
  #: (Array[Hash[String, untyped]], text_of: ^(String) -> String, ?selected: Array[String]) -> void
24
28
  def initialize(files, text_of:, selected: [])
@@ -29,8 +33,8 @@ module Principles
29
33
  end
30
34
 
31
35
  # The inventory's files, each Markdown one the survey reads with its outline, the other files counted by
32
- # directory, and those test-data hints that name a listed file, whose files the survey leaves out unread (#1153).
33
- # The files changed names, which a range of commits changed, list first, each marked changed_in_range (#1171).
36
+ # directory, and those test-data hints that name a listed file, whose files the survey leaves out unread.
37
+ # The files changed names, which a range of commits changed, list first, each marked changed_in_range.
34
38
  #: (Array[Hash[String, untyped]], ?changed: Array[String]) -> Hash[String, untyped]
35
39
  def listing(test_data_hints, changed: [])
36
40
  outlines = outlines(test_data_hints)
@@ -43,7 +47,7 @@ module Principles
43
47
  end
44
48
 
45
49
  # The outline of each listed Markdown file the survey reads, by path: every one but those the test-data hints
46
- # name (#1153), which the budget cuts by (#1155).
50
+ # name, which the budget cuts by.
47
51
  #: (Array[Hash[String, untyped]]) -> Hash[String, CandidateOutline]
48
52
  def outlines(test_data_hints)
49
53
  test_data = hints(test_data_hints).map { |hint| hint.fetch("path") }
@@ -51,10 +55,14 @@ module Principles
51
55
  (paths - test_data).to_h { |path| [path, CandidateOutline.new(@text_of.call(path))] }
52
56
  end
53
57
 
54
- # Each Markdown or settings file, with its size.
58
+ # Each Markdown or settings file, with its size, and a skill's entry file spelt otherwise than SKILL.md with its
59
+ # name as spelt, a fact; whether a host loads it so is the agent's to check.
55
60
  #: () -> Array[Hash[String, untyped]]
56
61
  def listed
57
- @files.select { |file| named?(file.fetch("path")) }
62
+ @files.select { |file| named?(file.fetch("path")) }.map do |file|
63
+ name = SKILL_ENTRY.match(file.fetch("path"))&.[](:name)
64
+ name.nil? || name == SKILL_NAME ? file : file.merge("skill_file_spelt" => name)
65
+ end
58
66
  end
59
67
 
60
68
  # Each directory holding other files, and how many.
@@ -14,18 +14,18 @@ module Principles
14
14
  # What list-candidate-files found: the inventory of candidate files as it lists them, and in git
15
15
  # which of them, or of the files their links lead to, git does not track. Each list that names a file is
16
16
  # something the agent asks the project's owner about before mapping, and only those are asked, since asks for
17
- # empty lists hid the one that applied (#405).
17
+ # empty lists hid the one that applied.
18
18
  class CandidateInventory
19
19
  # The lists the agent asks the owner about, in the order the asks are put.
20
20
  OWNER_ASK_KEYS = %w[possibly_test_data untracked ignored ignored_folders].freeze
21
21
 
22
22
  # The most paths an ask names inline: a short list can be pasted to the owner as it stands, while a
23
- # longer one would bury the ask, so the agent reads it from its list instead (#412).
23
+ # longer one would bury the ask, so the agent reads it from its list instead.
24
24
  NAMED_INLINE_AT_MOST = 3
25
25
 
26
26
  # What list-candidate-files finds in the project's files, each listed file's text read from them. After a commit,
27
- # a full sha, the files its range changed come first, the Markdown ones outside the places hosts load listed too
28
- # (#1171). The Markdown files not yet committed are named apart then, under uncommitted, since no commit in the
27
+ # a full sha, the files its range changed come first, the Markdown ones outside the places hosts load listed too.
28
+ # The Markdown files not yet committed are named apart then, under uncommitted, since no commit in the
29
29
  # range holds them.
30
30
  #: (Data::ProjectFiles, ProjectHistory, search_paths: SurveySearchPaths, ?after: String?,
31
31
  #| ?mapped: Array[String]) -> CandidateInventory
@@ -51,7 +51,7 @@ module Principles
51
51
  # What the project's inventory lists, and which listed files, or files their links lead to, history says
52
52
  # git does not track.
53
53
  # Each listed file's text, which its outline is read from, is what the block gives for its path.
54
- # changed names the files a range of commits changed, which list first, marked (#1171).
54
+ # changed names the files a range of commits changed, which list first, marked.
55
55
  #: (Hash[String, untyped], ProjectHistory, ?changed: Array[String]) { (String) -> String } -> CandidateInventory
56
56
  def self.found(inventory, history, changed: [], &text_of)
57
57
  texts = {} #: Hash[String, String]
@@ -99,7 +99,7 @@ module Principles
99
99
  def to_h = @listing
100
100
 
101
101
  # This inventory with its files' list items cut to OutlineBudget, the block giving the bytes each inventory tried
102
- # prints as (#1155).
102
+ # prints as.
103
103
  #: () { (CandidateInventory) -> Integer } -> CandidateInventory
104
104
  def within_budget(&printed_bytes)
105
105
  with(OutlineBudget.new(@outlines).cut(@listing) { |listing| printed_bytes.call(with(listing)) })