principles 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +383 -0
  3. data/LICENSE +202 -0
  4. data/NOTICE +4 -0
  5. data/README.md +111 -0
  6. data/exe/principles +20 -0
  7. data/lib/principles/after_commit_hook_options.rb +2 -2
  8. data/lib/principles/cli.rb +58 -41
  9. data/lib/principles/command_line.rb +37 -14
  10. data/lib/principles/command_routes.rb +21 -7
  11. data/lib/principles/controllers/acknowledgement.rb +50 -118
  12. data/lib/principles/controllers/acknowledgements.rb +154 -0
  13. data/lib/principles/controllers/after_commit_report.rb +44 -0
  14. data/lib/principles/controllers/answer.rb +52 -21
  15. data/lib/principles/controllers/answer_phase.rb +20 -3
  16. data/lib/principles/controllers/assessment.rb +41 -28
  17. data/lib/principles/controllers/audit.rb +59 -15
  18. data/lib/principles/controllers/audit_completion.rb +25 -12
  19. data/lib/principles/controllers/command.rb +13 -12
  20. data/lib/principles/controllers/correction.rb +26 -11
  21. data/lib/principles/controllers/first_audit_brief.rb +40 -0
  22. data/lib/principles/controllers/full_audit_request.rb +47 -83
  23. data/lib/principles/controllers/hook_setup.rb +49 -0
  24. data/lib/principles/controllers/inventory.rb +10 -8
  25. data/lib/principles/controllers/mapping.rb +2 -2
  26. data/lib/principles/controllers/member_acknowledgement.rb +148 -0
  27. data/lib/principles/controllers/member_entries.rb +4 -4
  28. data/lib/principles/controllers/member_problems_report.rb +84 -30
  29. data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
  30. data/lib/principles/controllers/members_to_assess.rb +23 -20
  31. data/lib/principles/controllers/meta_principle_setup.rb +5 -6
  32. data/lib/principles/controllers/open_correction.rb +42 -0
  33. data/lib/principles/controllers/parts_to_read.rb +117 -0
  34. data/lib/principles/controllers/repoint.rb +1 -1
  35. data/lib/principles/controllers/running_tool.rb +56 -6
  36. data/lib/principles/controllers/session_start_report.rb +62 -0
  37. data/lib/principles/controllers/survey.rb +2 -2
  38. data/lib/principles/data/audit_files.rb +7 -7
  39. data/lib/principles/data/bounded_file.rb +1 -1
  40. data/lib/principles/data/candidate_files_found.rb +6 -3
  41. data/lib/principles/data/command-steps.json +67 -12
  42. data/lib/principles/data/expected_type.rb +3 -3
  43. data/lib/principles/data/first_parent_log.rb +1 -1
  44. data/lib/principles/data/head_reflog.rb +74 -0
  45. data/lib/principles/data/hook_input.rb +59 -0
  46. data/lib/principles/data/ignored_by_git.rb +2 -2
  47. data/lib/principles/data/known_fields.rb +1 -1
  48. data/lib/principles/data/linked_path.rb +1 -1
  49. data/lib/principles/data/map_files.rb +2 -2
  50. data/lib/principles/data/principles_on_path.rb +83 -0
  51. data/lib/principles/data/principles_subfolder.rb +1 -1
  52. data/lib/principles/data/project_files.rb +10 -3
  53. data/lib/principles/data/repository.rb +14 -7
  54. data/lib/principles/data/running_version.rb +10 -8
  55. data/lib/principles/data/schema_check.rb +5 -5
  56. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -20
  57. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +95 -0
  58. data/lib/principles/data/schemas/assessment-answer.schema.json +55 -20
  59. data/lib/principles/data/schemas/audit-record.schema.json +29 -20
  60. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  61. data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
  62. data/lib/principles/data/schemas/correction-answer.schema.json +14 -62
  63. data/lib/principles/data/schemas/member-map.schema.json +3 -3
  64. data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
  65. data/lib/principles/error.rb +4 -4
  66. data/lib/principles/failure_refusal.rb +57 -0
  67. data/lib/principles/invocation_options.rb +7 -6
  68. data/lib/principles/launch.rb +49 -0
  69. data/lib/principles/list_open_findings_options.rb +23 -0
  70. data/lib/principles/models/accepted_loading.rb +2 -2
  71. data/lib/principles/models/acknowledged_check.rb +106 -0
  72. data/lib/principles/models/acknowledgement.rb +51 -53
  73. data/lib/principles/models/acknowledgement_left_as_printed.rb +18 -5
  74. data/lib/principles/models/acknowledgement_refusal.rb +25 -10
  75. data/lib/principles/models/acknowledgements.rb +115 -0
  76. data/lib/principles/models/acknowledgements_across.rb +68 -0
  77. data/lib/principles/models/activation.rb +2 -2
  78. data/lib/principles/models/after_commit_input.rb +115 -0
  79. data/lib/principles/models/agent_loads.rb +1 -1
  80. data/lib/principles/models/answer_fields.rb +2 -2
  81. data/lib/principles/models/answer_place.rb +3 -3
  82. data/lib/principles/models/answer_text.rb +2 -2
  83. data/lib/principles/models/answered_time.rb +12 -3
  84. data/lib/principles/models/assessment_answer.rb +10 -10
  85. data/lib/principles/models/assessment_basis.rb +2 -2
  86. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  87. data/lib/principles/models/assessment_report.rb +14 -15
  88. data/lib/principles/models/audit.rb +46 -34
  89. data/lib/principles/models/audit_record.rb +58 -27
  90. data/lib/principles/models/audit_records.rb +13 -13
  91. data/lib/principles/models/audit_start.rb +3 -3
  92. data/lib/principles/models/audited_member_lines.rb +1 -1
  93. data/lib/principles/models/candidate_files.rb +18 -10
  94. data/lib/principles/models/candidate_inventory.rb +6 -6
  95. data/lib/principles/models/candidate_outline.rb +9 -9
  96. data/lib/principles/models/carried_assessments.rb +18 -3
  97. data/lib/principles/models/carried_member.rb +5 -5
  98. data/lib/principles/models/changed_regions.rb +92 -0
  99. data/lib/principles/models/check_result_guide.rb +50 -0
  100. data/lib/principles/models/check_since_last_audit.rb +5 -4
  101. data/lib/principles/models/cited_files.rb +4 -4
  102. data/lib/principles/models/command_steps.rb +3 -3
  103. data/lib/principles/models/commits_brought_in.rb +1 -1
  104. data/lib/principles/models/commits_since_base.rb +1 -1
  105. data/lib/principles/models/correction_answer.rb +2 -2
  106. data/lib/principles/models/correction_basis.rb +19 -10
  107. data/lib/principles/models/dated_line.rb +1 -2
  108. data/lib/principles/models/decided_prior_findings.rb +6 -6
  109. data/lib/principles/models/declared_map_changes.rb +5 -5
  110. data/lib/principles/models/disposition.rb +21 -21
  111. data/lib/principles/models/entry_file.rb +1 -1
  112. data/lib/principles/models/entry_files.rb +1 -1
  113. data/lib/principles/models/evidence_item.rb +1 -1
  114. data/lib/principles/models/evidence_lines_since.rb +2 -2
  115. data/lib/principles/models/evidence_replacements.rb +3 -3
  116. data/lib/principles/models/finding_write_ups.rb +12 -5
  117. data/lib/principles/models/findings_left_open.rb +4 -4
  118. data/lib/principles/models/first_full_audit.rb +32 -0
  119. data/lib/principles/models/first_raised_claim.rb +1 -1
  120. data/lib/principles/models/fix_only_fields.rb +1 -1
  121. data/lib/principles/models/head_moves.rb +66 -0
  122. data/lib/principles/models/hook_commands.rb +49 -4
  123. data/lib/principles/models/ignored_candidates.rb +1 -1
  124. data/lib/principles/models/instruction_named.rb +2 -3
  125. data/lib/principles/models/json_digest.rb +2 -2
  126. data/lib/principles/models/json_path_query.rb +1 -1
  127. data/lib/principles/models/kept_prior_finding.rb +9 -9
  128. data/lib/principles/models/last_completed_revision.rb +4 -5
  129. data/lib/principles/models/left_as_printed.rb +2 -2
  130. data/lib/principles/models/line_diff.rb +113 -0
  131. data/lib/principles/models/line_span.rb +1 -1
  132. data/lib/principles/models/list_member_problems_check.rb +80 -0
  133. data/lib/principles/models/listed_members.rb +47 -0
  134. data/lib/principles/models/loaded_files.rb +4 -5
  135. data/lib/principles/models/loading_decision.rb +19 -10
  136. data/lib/principles/models/loading_facts.rb +1 -1
  137. data/lib/principles/models/loads_to_check.rb +1 -2
  138. data/lib/principles/models/located_text.rb +1 -1
  139. data/lib/principles/models/mapped_principles.rb +2 -2
  140. data/lib/principles/models/member.rb +31 -4
  141. data/lib/principles/models/member_assessments.rb +17 -8
  142. data/lib/principles/models/member_elsewhere.rb +4 -4
  143. data/lib/principles/models/member_file.rb +4 -4
  144. data/lib/principles/models/member_grounds.rb +1 -1
  145. data/lib/principles/models/member_hashes_as_written.rb +1 -1
  146. data/lib/principles/models/member_lines.rb +29 -61
  147. data/lib/principles/models/member_loads.rb +2 -2
  148. data/lib/principles/models/member_moves.rb +1 -1
  149. data/lib/principles/models/member_problems.rb +21 -18
  150. data/lib/principles/models/member_repair_moves.rb +15 -9
  151. data/lib/principles/models/member_sighting.rb +12 -15
  152. data/lib/principles/models/member_snapshots.rb +1 -1
  153. data/lib/principles/models/member_state.rb +1 -1
  154. data/lib/principles/models/members_across_principles.rb +77 -0
  155. data/lib/principles/models/members_elsewhere.rb +2 -2
  156. data/lib/principles/models/members_sharing_lines.rb +7 -7
  157. data/lib/principles/models/meta_principle.rb +11 -4
  158. data/lib/principles/models/missing_files.rb +3 -3
  159. data/lib/principles/models/new_findings.rb +4 -4
  160. data/lib/principles/models/open_correction.rb +57 -0
  161. data/lib/principles/models/open_finding.rb +36 -31
  162. data/lib/principles/models/open_findings_elsewhere.rb +2 -2
  163. data/lib/principles/models/other_principles.rb +2 -2
  164. data/lib/principles/models/other_templates_placeholders.rb +17 -16
  165. data/lib/principles/models/outline_budget.rb +7 -7
  166. data/lib/principles/models/outline_group.rb +1 -1
  167. data/lib/principles/models/outline_section.rb +2 -2
  168. data/lib/principles/models/part_named.rb +41 -0
  169. data/lib/principles/models/placement.rb +2 -2
  170. data/lib/principles/models/principle.rb +13 -13
  171. data/lib/principles/models/principle_history.rb +8 -8
  172. data/lib/principles/models/principle_members.rb +14 -7
  173. data/lib/principles/models/principles_folder_move.rb +1 -1
  174. data/lib/principles/models/principles_on_path.rb +29 -0
  175. data/lib/principles/models/principles_package.rb +3 -3
  176. data/lib/principles/models/prior_decision_fields.rb +8 -8
  177. data/lib/principles/models/prior_finding_decision.rb +8 -8
  178. data/lib/principles/models/prior_finding_outcomes.rb +1 -1
  179. data/lib/principles/models/prior_findings.rb +5 -5
  180. data/lib/principles/models/problem_report.rb +42 -9
  181. data/lib/principles/models/project.rb +29 -20
  182. data/lib/principles/models/project_history.rb +18 -12
  183. data/lib/principles/models/quoted_change.rb +8 -8
  184. data/lib/principles/models/recent_decision.rb +3 -3
  185. data/lib/principles/models/record_format.rb +16 -10
  186. data/lib/principles/models/record_judged_against.rb +4 -4
  187. data/lib/principles/models/recorded_entry.rb +17 -8
  188. data/lib/principles/models/recorded_finding.rb +9 -9
  189. data/lib/principles/models/recorded_findings.rb +2 -2
  190. data/lib/principles/models/recorded_hashes.rb +2 -2
  191. data/lib/principles/models/recorded_members.rb +13 -13
  192. data/lib/principles/models/refusal_before_shape.rb +2 -2
  193. data/lib/principles/models/repoint.rb +3 -3
  194. data/lib/principles/models/report_hooks.rb +69 -0
  195. data/lib/principles/models/reported_check.rb +42 -36
  196. data/lib/principles/models/request_id.rb +19 -7
  197. data/lib/principles/models/runs_from.rb +7 -2
  198. data/lib/principles/models/sent_answer.rb +38 -16
  199. data/lib/principles/models/sent_prior_decisions.rb +1 -1
  200. data/lib/principles/models/session_start_input.rb +37 -0
  201. data/lib/principles/models/shape_problems_beside.rb +1 -1
  202. data/lib/principles/models/skill_loads.rb +1 -1
  203. data/lib/principles/models/stale_request.rb +59 -0
  204. data/lib/principles/models/still_holds_restatement.rb +6 -6
  205. data/lib/principles/models/submitted_answer.rb +1 -1
  206. data/lib/principles/models/template_placeholders.rb +6 -6
  207. data/lib/principles/models/text_within.rb +1 -1
  208. data/lib/principles/models/tracked_paths.rb +38 -0
  209. data/lib/principles/models/unchecked_members.rb +2 -2
  210. data/lib/principles/models/uncommitted_files.rb +1 -1
  211. data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
  212. data/lib/principles/models/waits_on.rb +1 -1
  213. data/lib/principles/models/write_up_opening.rb +5 -5
  214. data/lib/principles/models/write_up_pointer.rb +3 -3
  215. data/lib/principles/models/write_up_repoint.rb +2 -3
  216. data/lib/principles/positional_arguments.rb +15 -7
  217. data/lib/principles/prose_list.rb +1 -1
  218. data/lib/principles/session_start_options.rb +3 -3
  219. data/lib/principles/start_audit_options.rb +54 -12
  220. data/lib/principles/supported_ruby.rb +24 -7
  221. data/lib/principles/version.rb +2 -2
  222. data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
  223. data/lib/principles/views/acknowledgement_result.rb +137 -17
  224. data/lib/principles/views/activation_in_hand.rb +1 -1
  225. data/lib/principles/views/answered_request.rb +6 -2
  226. data/lib/principles/views/assessed_members.rb +68 -38
  227. data/lib/principles/views/assessment_request.rb +43 -21
  228. data/lib/principles/views/audit_changes.rb +4 -4
  229. data/lib/principles/views/audit_commit.rb +5 -4
  230. data/lib/principles/views/audit_result.rb +100 -53
  231. data/lib/principles/views/candidate_files_result.rb +7 -6
  232. data/lib/principles/views/check_notes.rb +29 -6
  233. data/lib/principles/views/check_result_template.rb +51 -39
  234. data/lib/principles/views/completed_audit_next_step.rb +44 -0
  235. data/lib/principles/views/context_parts.rb +112 -0
  236. data/lib/principles/views/correction_request.rb +49 -33
  237. data/lib/principles/views/diff_since_last_audit.rb +8 -6
  238. data/lib/principles/views/findings_result.rb +33 -1
  239. data/lib/principles/views/first_audit_brief.rb +51 -0
  240. data/lib/principles/views/first_audit_line.rb +45 -0
  241. data/lib/principles/views/help.rb +4 -4
  242. data/lib/principles/views/hook_setup_result.rb +91 -0
  243. data/lib/principles/views/instruction.rb +3 -3
  244. data/lib/principles/views/invocation.rb +32 -9
  245. data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
  246. data/lib/principles/views/landed_since_base.rb +1 -1
  247. data/lib/principles/views/line_history_since_last_audit.rb +35 -0
  248. data/lib/principles/views/lines_shared_with_member.rb +6 -6
  249. data/lib/principles/views/loads_to_check_result.rb +11 -7
  250. data/lib/principles/views/map_added_to.rb +3 -3
  251. data/lib/principles/views/map_result.rb +9 -9
  252. data/lib/principles/views/member_change_since_baseline.rb +44 -23
  253. data/lib/principles/views/member_lines_beside_text.rb +43 -0
  254. data/lib/principles/views/member_repairs.rb +3 -2
  255. data/lib/principles/views/member_row.rb +61 -0
  256. data/lib/principles/views/members_a_commit_changed.rb +15 -11
  257. data/lib/principles/views/members_with_no_baseline.rb +10 -3
  258. data/lib/principles/views/meta_principle_passage.rb +1 -1
  259. data/lib/principles/views/meta_principle_result.rb +12 -5
  260. data/lib/principles/views/one_member_check_result_template.rb +24 -12
  261. data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
  262. data/lib/principles/views/open_findings_line.rb +26 -36
  263. data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
  264. data/lib/principles/views/outside_the_map_result.rb +5 -2
  265. data/lib/principles/views/package_since_last_audit_result.rb +29 -6
  266. data/lib/principles/views/parts_index_result.rb +60 -0
  267. data/lib/principles/views/principle_read_result.rb +5 -6
  268. data/lib/principles/views/principle_with_changed_members.rb +1 -1
  269. data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
  270. data/lib/principles/views/printed_json.rb +51 -0
  271. data/lib/principles/views/printed_principle.rb +1 -1
  272. data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
  273. data/lib/principles/views/prior_findings_result.rb +17 -14
  274. data/lib/principles/views/problem_lines.rb +70 -45
  275. data/lib/principles/views/problem_result.rb +75 -43
  276. data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
  277. data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
  278. data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
  279. data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
  280. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
  281. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
  282. data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
  283. data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
  284. data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
  285. data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
  286. data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
  287. data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
  288. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
  289. data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
  290. data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
  291. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
  292. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
  293. data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
  294. data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
  295. data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
  296. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  297. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
  298. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
  299. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
  300. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
  301. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
  302. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +16 -16
  303. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
  304. data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
  305. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
  306. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +22 -20
  307. data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
  308. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
  309. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
  310. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
  311. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -28
  312. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +39 -38
  313. data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
  314. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
  315. data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
  316. data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
  317. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
  318. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
  319. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
  320. data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
  321. data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
  322. data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
  323. data/lib/principles/views/prompts.rb +1 -1
  324. data/lib/principles/views/read_the_change.rb +36 -0
  325. data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
  326. data/lib/principles/views/repoint_result.rb +1 -1
  327. data/lib/principles/views/report_hooks_offer.rb +25 -0
  328. data/lib/principles/views/request_part.rb +5 -5
  329. data/lib/principles/views/request_parts.rb +1 -1
  330. data/lib/principles/views/session_start_report.rb +46 -0
  331. data/lib/principles/views/shell_word.rb +1 -1
  332. data/lib/principles/views/trimmed_instructions_note.rb +30 -0
  333. data/lib/principles/views/visible_text.rb +1 -1
  334. data/lib/principles/views/workflow_diagram.rb +1 -1
  335. data/principles.gemspec +44 -0
  336. metadata +95 -14
  337. data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
  338. data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
@@ -0,0 +1,83 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "English"
5
+ require "timeout"
6
+
7
+ module Principles
8
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
9
+ module Data
10
+ # The principles a bare principles command runs, the first on PATH, when it is another file than this run's own:
11
+ # its path, what it prints for --version and which of the commands asked about it does not run, or nil when PATH
12
+ # finds none, finds this one, or that one prints no version.
13
+ class PrinciplesOnPath
14
+ # How long that copy may take to print its version before it is stopped and read as printing none.
15
+ TIMEOUT_S = 3
16
+
17
+ #: (String, own: String) -> void
18
+ def initialize(path, own:)
19
+ @folders = path.split(File::PATH_SEPARATOR) #: Array[String]
20
+ @own = own
21
+ freeze
22
+ end
23
+
24
+ # asking names the commands to ask that copy about, each started for its --help, so none for a caller that
25
+ # needs only its version.
26
+ #: (?Array[String]) -> [String, String, Array[String]]?
27
+ def other(asking = [])
28
+ found = first or return nil
29
+ return nil if same_file?(found, @own)
30
+
31
+ version = version_of(found).to_s.strip
32
+ version.empty? ? nil : [found, version, asking.reject { runs?(found, it) }]
33
+ rescue SystemCallError
34
+ nil
35
+ end
36
+
37
+ # Whether the first principles on PATH is this run's own file, so a bare principles runs this same copy.
38
+ #: () -> bool
39
+ def own_first?
40
+ found = first
41
+ found ? same_file?(found, @own) : false
42
+ end
43
+
44
+ private
45
+
46
+ # What found prints for --version when it exits 0 within TIMEOUT_S, or nil.
47
+ #: (String) -> String?
48
+ def version_of(found)
49
+ printed = within_timeout(found, "--version")
50
+ printed if $CHILD_STATUS&.success?
51
+ end
52
+
53
+ # Whether found runs command, as its --help exits 0 within TIMEOUT_S; a command it does not know exits 2.
54
+ #: (String, String) -> bool
55
+ def runs?(found, command)
56
+ !within_timeout(found, command, "--help").nil? && $CHILD_STATUS&.success? == true
57
+ end
58
+
59
+ # What found prints on stdout for arguments, read until it exits, or nil once TIMEOUT_S passes and it is stopped.
60
+ #: (String, *String) -> String?
61
+ def within_timeout(found, *arguments)
62
+ IO.popen([found, *arguments], err: File::NULL) do |io|
63
+ Timeout.timeout(TIMEOUT_S) { io.read }
64
+ rescue Timeout::Error
65
+ Process.kill("KILL", io.pid)
66
+ nil
67
+ end
68
+ end
69
+
70
+ #: () -> String?
71
+ def first
72
+ @folders.map { File.join(it, "principles") }.find { File.file?(it) && File.executable?(it) }
73
+ end
74
+
75
+ #: (String, String) -> bool
76
+ def same_file?(one, other)
77
+ File.realpath(one) == File.realpath(other)
78
+ rescue SystemCallError
79
+ false
80
+ end
81
+ end
82
+ end
83
+ end
@@ -18,7 +18,7 @@ module Principles
18
18
  class PrinciplesSubfolder
19
19
  # The folder a project keeps its maps and audit records in.
20
20
  FOLDER = PrinciplesDirectory::FOLDER
21
- # Its name before the rename to principles; a project an older version mapped still holds it (#536).
21
+ # Its name before the rename to principles; a project an older version mapped still holds it.
22
22
  EARLIER_FOLDER = ".memeplex"
23
23
 
24
24
  #: (String, String) -> void
@@ -32,11 +32,11 @@ module Principles
32
32
  end
33
33
 
34
34
  # The paths the text at path depends on, each symbolic link on the way and then the file they lead to, as
35
- # LinkedPath gives them; path alone when it passes through no link (#695).
35
+ # LinkedPath gives them; path alone when it passes through no link.
36
36
  #: (String) -> Array[String]
37
37
  def text_paths(path) = linked(path).text_paths
38
38
 
39
- # The file path's links lead to, read in place of path; path itself when it passes through no link (#695).
39
+ # The file path's links lead to, read in place of path; path itself when it passes through no link.
40
40
  #: (String) -> String
41
41
  def leads_to(path) = linked(path).leads_to
42
42
 
@@ -56,6 +56,13 @@ module Principles
56
56
  absolute.start_with?("#{@root}/") && File.file?(absolute)
57
57
  end
58
58
 
59
+ # Whether path names a folder inside the project.
60
+ #: (String) -> bool
61
+ def folder?(path)
62
+ absolute = File.expand_path(path, @root)
63
+ absolute.start_with?("#{@root}/") && File.directory?(absolute)
64
+ end
65
+
59
66
  #: (String) -> String
60
67
  def resolve(path)
61
68
  absolute = File.expand_path(path, @root)
@@ -90,7 +97,7 @@ module Principles
90
97
  #: (Array[String]) -> Array[String]?
91
98
  def ignored_paths(paths) = IgnoredByGit.new(@root, paths).facts&.fetch("ignored")
92
99
 
93
- # JSON from the file at path, which a refusal's message calls named (#1118).
100
+ # JSON from the file at path, which a refusal's message calls named.
94
101
  #: (String, ?named: String) -> untyped
95
102
  def read_json(path, named: path)
96
103
  parse_json(BoundedFile.new(path, named:).read, path, named:)
@@ -74,7 +74,7 @@ module Principles
74
74
  end
75
75
 
76
76
  # The full sha of the commit revision names, as git resolves it, or nil when it names none. The revision is the
77
- # agent's own, so git reads it after --end-of-options, never as an option (#1171).
77
+ # agent's own, so git reads it after --end-of-options, never as an option.
78
78
  #: (String) -> String?
79
79
  def commit_of(revision)
80
80
  sha, ok = git(["rev-parse", "--verify", "--quiet", "--end-of-options", "#{revision}^{commit}"])
@@ -83,7 +83,7 @@ module Principles
83
83
 
84
84
  # Each path the commits after commit changed, up to HEAD, sorted and relative to the project: added, edited or
85
85
  # deleted, and a rename by both its names, since git is asked to detect none. commit is a full sha, as commit_of
86
- # gives it, so git cannot read it as an option (#1171).
86
+ # gives it, so git cannot read it as an option.
87
87
  #: (String) -> Array[String]
88
88
  def changed_since(commit)
89
89
  output, ok = git(["diff", "--name-only", "-z", "--relative", "--no-renames", revision(commit), "HEAD", "--"])
@@ -113,7 +113,7 @@ module Principles
113
113
  end
114
114
 
115
115
  # Which of paths, relative to the project, git does not track, ignored or not. Unlike untracked, it names an
116
- # ignored file too, since git holds it no more than an untracked one (#896).
116
+ # ignored file too, since git holds it no more than an untracked one.
117
117
  #: (Array[String]) -> Array[String]
118
118
  def not_tracked(paths)
119
119
  return [] if paths.empty?
@@ -122,10 +122,18 @@ module Principles
122
122
  output.split("\0").sort
123
123
  end
124
124
 
125
+ # Every path in the project git tracks, as git spells it, sorted, so a path a disk that folds case opens under
126
+ # another spelling can be told apart; none outside git.
127
+ #: () -> Array[String]
128
+ def tracked_files
129
+ output, ok = git(["ls-files", "-z"])
130
+ ok ? output.force_encoding("UTF-8").split("\0").sort : []
131
+ end
132
+
125
133
  # Every file in the project that differs from HEAD, is gone since it, or is untracked, sorted. Unlike
126
134
  # uncommitted, it leaves ignored files out: it is asked about the whole project, where an ignored file is
127
135
  # one the owner chose to keep out of git, while uncommitted is asked about named members, which an audit
128
- # needs committed (#390, #409). Before the first commit, every file not ignored is one.
136
+ # needs committed. Before the first commit, every file not ignored is one.
129
137
  #: () -> Array[String]
130
138
  def changed_files
131
139
  changed, = head ? git(["diff", "--name-only", "--relative", "-z", "HEAD"]) : [""]
@@ -134,7 +142,7 @@ module Principles
134
142
  end
135
143
 
136
144
  # path's text at commit, frozen, or nil when the commit does not hold it. Text at a full sha never changes, so
137
- # git is asked for it once; HEAD moves with each commit, so it is asked every time (#1161).
145
+ # git is asked for it once; HEAD moves with each commit, so it is asked every time.
138
146
  #: (String, String) -> String?
139
147
  def text_at(commit, path)
140
148
  return read_text_at(commit, path) unless FULL_SHA.match?(commit)
@@ -159,8 +167,7 @@ module Principles
159
167
  # as its full and short sha, subject line, author date and whether it is a root commit ("true" or "false"); none
160
168
  # outside git. since leaves out since and every commit before it. The list and each commit are frozen. Between
161
169
  # full shas the list never changes, so git is asked for it once, and a refusal, as for a sha the clone lacks, is
162
- # kept too, since asking again would be refused again; HEAD moves with each commit, so it is asked every time
163
- # (#1161).
170
+ # kept too, since asking again would be refused again; HEAD moves with each commit, so it is asked every time.
164
171
  #: (Array[String], ?since: String?, ?up_to: String) -> Array[Hash[String, String]]
165
172
  def commits_touching(paths, since: nil, up_to: "HEAD")
166
173
  range = since ? "#{revision(since)}..#{revision(up_to)}" : revision(up_to)
@@ -1,29 +1,31 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../version"
5
4
  require_relative "git_command"
6
5
 
7
6
  module Principles
8
7
  # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
9
8
  module Data
10
- # The version that is running: what a build stamped, or, in a checkout, the release
11
- # with the commit it runs from, as RELEASE.g<short sha>. The g keeps a development version a RubyGems
12
- # prerelease even when every character of the sha is a digit.
9
+ # The version that is running: what a build stamped, or, in a checkout, the release with the commit it runs
10
+ # from, as RELEASE.g<short sha>. Its caller hands in both from version.rb. The g keeps a development version a
11
+ # RubyGems prerelease even when every character of the sha is a digit.
13
12
  class RunningVersion
14
13
  # git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
15
- # export-subst; a checkout keeps the placeholder as written (#898).
14
+ # export-subst; a checkout keeps the placeholder as written.
16
15
  ARCHIVED_COMMIT = "$Format:%h$" #: String
17
16
 
18
- #: (?String, ?archived_commit: String) -> void
19
- def initialize(checkout = File.expand_path("../../..", __dir__), archived_commit: ARCHIVED_COMMIT)
17
+ #: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
18
+ def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
19
+ archived_commit: ARCHIVED_COMMIT)
20
20
  @checkout = checkout
21
+ @release = release
22
+ @built = built
21
23
  @archived_commit = archived_commit
22
24
  end
23
25
 
24
26
  #: () -> String
25
27
  def to_s
26
- BUILT_VERSION || "#{RELEASE}.g#{commit}"
28
+ @built || "#{@release}.g#{commit}"
27
29
  end
28
30
 
29
31
  private
@@ -11,17 +11,17 @@ module Principles
11
11
  # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
12
12
  module Data
13
13
  # Checks parsed JSON against one of the schemas in schemas/, with the standard library alone, so a run
14
- # needs no gem (D29). It supports only KEYWORDS, which is what this tool's own schemas use; a spec fails on
14
+ # needs no gem. It supports only KEYWORDS, which is what this tool's own schemas use; a spec fails on
15
15
  # a schema that uses another, and a conformance spec compares its verdicts with json_schemer's.
16
16
  class SchemaCheck
17
17
  # The keywords a schema may use, besides annotations such as title and description.
18
18
  KEYWORDS = %w[type properties required additionalProperties items minLength pattern enum const].freeze
19
19
  # This tool's own schema keyword, on an object that refuses fields it does not name: for a field an agent
20
- # may put there by mistake, where it belongs instead, which its refusal adds (#769), as {field => text}.
20
+ # may put there by mistake, where it belongs instead, which its refusal adds, as {field => text}.
21
21
  UNREAD_FIELD_ADVICE = "x-unread-field-advice"
22
22
  # This tool's own schema keyword, on a string with a pattern: what to say when the value does not match, in place
23
23
  # of the pattern, for a field whose pattern holds a template's placeholder, which another template's wording
24
- # fails (#1082).
24
+ # fails.
25
25
  UNMATCHED_ADVICE = "x-unmatched-advice"
26
26
  # Keywords that only describe, and check nothing; the refusal advice is worded into a refusal.
27
27
  ANNOTATIONS = %W[$schema $id title description #{ExpectedType::ADVICE} #{UNREAD_FIELD_ADVICE}
@@ -35,7 +35,7 @@ module Principles
35
35
  end
36
36
 
37
37
  # The check of only the top-level fields named, any other field let through, so the part a later step depends
38
- # on is checked before the rest, as an answer's head is (#1052).
38
+ # on is checked before the rest, as an answer's head is.
39
39
  #: (Array[String]) -> SchemaCheck
40
40
  def only(fields)
41
41
  SchemaCheck.new(@name, @schema.merge("properties" => @schema.fetch("properties", {}).slice(*fields),
@@ -138,7 +138,7 @@ module Principles
138
138
  end
139
139
 
140
140
  # Why key is refused in an object schema checks: not a field read there, the fields that are, so the agent need
141
- # not guess them (#1115), and what the schema says of key, if anything (#769).
141
+ # not guess them, and what the schema says of key, if anything.
142
142
  #: (Hash[String, untyped], String) -> String
143
143
  def unread(schema, key)
144
144
  read = schema.fetch("properties", {}).keys
@@ -2,37 +2,103 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "acknowledgement-answer.schema.json",
4
4
  "title": "Acknowledgement answer",
5
- "description": "What an agent answers a one-member audit with (D33): the request's id and basis, whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it, or \"\" for a side with no line the other lacks; a quote left out, as is the basis's base_commit, which the request id already pins, is read as the request's first_changed_lines printed it (#1166). Fields this tool does not read are refused (D29). Models::Acknowledgement checks the quotes and the reason.",
5
+ "description": "What an agent answers a one-member audit with: the request id and basis, and under members one entry keyed by the member id, as an answer for several members holds it, saying whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it, or \"\" for a side with no line the other lacks; a quote left out, as is the basis's base_commit, which the request id already pins, is read as the request's first_changed_lines printed it. Fields this tool does not read are refused. Models::Acknowledgement checks the quotes and the reason.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
- "required": ["request_id", "basis", "meaning_kept", "reason"],
8
+ "required": [
9
+ "request_id",
10
+ "basis",
11
+ "members"
12
+ ],
9
13
  "properties": {
10
- "request_id": { "type": "string" },
14
+ "request_id": {
15
+ "type": "string"
16
+ },
11
17
  "basis": {
12
18
  "type": "object",
13
19
  "additionalProperties": false,
14
- "required": ["member_id"],
20
+ "required": [
21
+ "member_ids"
22
+ ],
15
23
  "properties": {
16
- "base_commit": { "type": "string" },
17
- "member_id": { "type": "string" }
24
+ "base_commit": {
25
+ "type": "string"
26
+ },
27
+ "member_ids": {
28
+ "description": "The one member the answer acknowledges, as a list, as an answer for several members names them.",
29
+ "type": "array",
30
+ "minItems": 1,
31
+ "maxItems": 1,
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ }
36
+ },
37
+ "x-unread-field-advice": {
38
+ "member_id": "it is now basis.member_ids, a list of its one member id, as start-audit --as template prints it"
18
39
  }
19
40
  },
20
- "meaning_kept": { "type": "boolean" },
21
- "reason": { "type": "string", "minLength": 1 },
22
- "old_line": { "type": "string" },
23
- "new_line": { "type": "string" },
24
- "check_result": {
41
+ "members": {
25
42
  "type": "object",
26
- "additionalProperties": false,
27
- "x-unread-field-advice": {
28
- "not_run_reason": "a check that cannot be run here needs a full audit: start one instead"
29
- },
30
- "description": "The result of the member's check, which the answer reports when the member has one: the command as the map names it, or left out to read as the request printed it (#1166), and its exit_status, which must be 0, since a check that fails or cannot be run is a full audit's to judge, with review_basis when a new line says what its review rested on (D30, D63, #1115). Models::ReportedCheck checks it.",
31
- "properties": {
32
- "command": { "type": "string" },
33
- "exit_status": { "type": ["integer", "string"] },
34
- "review_basis": { "type": "string" }
43
+ "additionalProperties": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "description": "One member's judgement, read as a one-member answer's fields beside its request_id and basis are read (acknowledgement-answer.schema.json).",
47
+ "required": [
48
+ "meaning_kept",
49
+ "reason"
50
+ ],
51
+ "properties": {
52
+ "meaning_kept": {
53
+ "type": "boolean"
54
+ },
55
+ "reason": {
56
+ "type": "string",
57
+ "minLength": 1
58
+ },
59
+ "old_line": {
60
+ "type": "string"
61
+ },
62
+ "new_line": {
63
+ "type": "string"
64
+ },
65
+ "check_result": {
66
+ "type": "object",
67
+ "additionalProperties": false,
68
+ "x-unread-field-advice": {
69
+ "not_run_reason": "a check that cannot be run here needs a full audit: start one instead"
70
+ },
71
+ "description": "The result of the member's check, which the answer reports when the member has one: the command as the map names it, or left out to read as the request printed it, and its exit_status, which must be 0, since a check that fails or cannot be run is a full audit's to judge, with review_basis when a new line says what its review rested on; for this tool's own list-member-problems --short, which exits 3 while it lists the member, 3 with the member ids it lists under listed_members, each one this answer acknowledges. Models::ReportedCheck checks it.",
72
+ "properties": {
73
+ "command": {
74
+ "type": "string"
75
+ },
76
+ "exit_status": {
77
+ "type": [
78
+ "integer",
79
+ "string"
80
+ ]
81
+ },
82
+ "review_basis": {
83
+ "type": "string"
84
+ },
85
+ "listed_members": {
86
+ "type": "array",
87
+ "items": {
88
+ "type": "string"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
35
94
  }
36
95
  }
96
+ },
97
+ "x-unread-field-advice": {
98
+ "meaning_kept": "belongs under members, keyed by the member id basis.member_ids names, as start-audit --as template prints it",
99
+ "reason": "belongs under members, keyed by the member id basis.member_ids names, as start-audit --as template prints it",
100
+ "old_line": "belongs under members, keyed by the member id basis.member_ids names, as start-audit --as template prints it",
101
+ "new_line": "belongs under members, keyed by the member id basis.member_ids names, as start-audit --as template prints it",
102
+ "check_result": "belongs under members, keyed by the member id basis.member_ids names, as start-audit --as template prints it"
37
103
  }
38
104
  }
@@ -0,0 +1,95 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "acknowledgements-answer.schema.json",
4
+ "title": "Acknowledgements answer",
5
+ "description": "What an agent answers a request to acknowledge several members of one principle, or the members several principles map, holding: the request's id, its basis naming each member, and under members one entry per member, keyed by its id, holding what a one-member answer holds beside its head. Fields this tool does not read are refused. Models::Acknowledgements refuses an answer whose members differ from its basis, and each entry is checked as Models::Acknowledgement checks a one-member answer.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "request_id",
10
+ "basis",
11
+ "members"
12
+ ],
13
+ "properties": {
14
+ "request_id": {
15
+ "type": "string"
16
+ },
17
+ "basis": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": [
21
+ "member_ids"
22
+ ],
23
+ "properties": {
24
+ "principle_ids": {
25
+ "type": "array",
26
+ "description": "The principles that each acknowledge the members they map, when the request names several.",
27
+ "items": {
28
+ "type": "string"
29
+ }
30
+ },
31
+ "member_ids": {
32
+ "type": "array",
33
+ "items": {
34
+ "type": "string"
35
+ }
36
+ }
37
+ }
38
+ },
39
+ "members": {
40
+ "type": "object",
41
+ "additionalProperties": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "description": "One member's judgement, read as a one-member answer's fields beside its request_id and basis are read (acknowledgement-answer.schema.json).",
45
+ "required": [
46
+ "meaning_kept",
47
+ "reason"
48
+ ],
49
+ "properties": {
50
+ "meaning_kept": {
51
+ "type": "boolean"
52
+ },
53
+ "reason": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "old_line": {
58
+ "type": "string"
59
+ },
60
+ "new_line": {
61
+ "type": "string"
62
+ },
63
+ "check_result": {
64
+ "type": "object",
65
+ "additionalProperties": false,
66
+ "x-unread-field-advice": {
67
+ "not_run_reason": "a check that cannot be run here needs a full audit: start one instead"
68
+ },
69
+ "description": "The result of the member's check, which the answer reports when the member has one: the command as the map names it, or left out to read as the request printed it, and its exit_status, which must be 0, since a check that fails or cannot be run is a full audit's to judge, with review_basis when a new line says what its review rested on; for this tool's own list-member-problems --short, which exits 3 while it lists the member, 3 with the member ids it lists under listed_members, each one this answer acknowledges. Models::ReportedCheck checks it.",
70
+ "properties": {
71
+ "command": {
72
+ "type": "string"
73
+ },
74
+ "exit_status": {
75
+ "type": [
76
+ "integer",
77
+ "string"
78
+ ]
79
+ },
80
+ "review_basis": {
81
+ "type": "string"
82
+ },
83
+ "listed_members": {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "string"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }