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
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Sidu Ponnappa and Ontic Pte. Ltd. (realfast.ai)
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Principles
2
+ Copyright 2026 Sidu Ponnappa and Ontic Pte. Ltd. (realfast.ai)
3
+
4
+ This product is licensed under the Apache License, Version 2.0, in LICENSE.
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # Principles
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/principles.svg?icon=si%3Arubygems&icon_color=%23fafafa)](https://badge.fury.io/rb/principles)
4
+
5
+ **Tighter harness, longer leash: agents you can leave running.**
6
+
7
+ ## Install
8
+
9
+ Install the gem yourself. In Claude Code, the `!` prefix runs a shell command in your session:
10
+
11
+ ```
12
+ ! gem install principles
13
+ ```
14
+
15
+ Then ask your agent to map your project's principles. It runs `principles list-principles` and follows what each result tells it, so you never need to learn the commands. `principles` needs Ruby 3.4, and finds one installed by rbenv when the Ruby on your `PATH` is another version.
16
+
17
+ ## The problem: harness drift
18
+
19
+ Your agent works the way its harness tells it to: `CLAUDE.md` files, rules, skills, subagents, hooks and the scripts they call. A team's operating principles, such as test first or never commit on a red build, each end up written in several of those files.
20
+
21
+ Then someone sharpens a rule in `CLAUDE.md` but not in the reviewer subagent. Every file still loads and nothing errors, but your agent now reads instructions that disagree. That is **drift**. Left to pile up, it becomes **debt**: the same rule at different strengths, stale exceptions, checks nobody remembers adding. No review catches it, because each edit looks fine on its own. The problem lives between the files.
22
+
23
+ ## What `principles` does
24
+
25
+ - **Finds the principles you already have.** It surveys your guidance and shows which principles it carries, and where.
26
+ - **Maps each one.** A map names every place that carries a principle, and the part each place plays.
27
+ - **Catches drift.** `principles list-member-problems --short` names each mapped place that changed since its last audit, in a few lines made for a session-start hook.
28
+ - **Audits the places together.** Your agent judges whether they still agree. `principles` checks that every passage it cites exists, and records the result.
29
+ - **Makes debt deliberate.** Each finding is fixed, or recorded with whom it waits on.
30
+ - **Shows what to trim.** It points out rules stated twice, or loaded into every session when only some tasks need them.
31
+
32
+ `principles` never edits your harness and calls no model. Your agent reads and judges; `principles` keeps the books: what is mapped, what changed and which step comes next. Every result is JSON that names the next command. Maps and audits live in `.principles/`, committed beside your code, so your team shares them and their history.
33
+
34
+ ## Why it matters
35
+
36
+ An agent working unsupervised is only as good as the guidance in its context, and nobody is watching when that guidance is wrong.
37
+
38
+ - **Context efficiency.** Every line the harness loads costs the agent attention, in every session it loads in. Mapping each principle shows where it is stated twice, stated stale, or loaded where it is never needed, so that text can be cut.
39
+ - **Context relevant to the task.** A principle can record when its work is in hand, such as only while specs are written. An audit then flags each place that loads into every session anyway.
40
+ - **No silent drift, no growing debt.** Each change to a mapped place is caught and checked against the others.
41
+
42
+ Together these lengthen the time, and widen the kinds of work, for which you can leave an agent running and still get great work.
43
+
44
+ ## Example: one rename, three files
45
+
46
+ A project states its naming rule in three places:
47
+
48
+ ```markdown
49
+ <!-- CLAUDE.md -->
50
+ Name every file and function for what it is. When a term changes, rename it everywhere in the same commit.
51
+ Settled terms live in `docs/glossary.md`.
52
+
53
+ <!-- docs/glossary.md -->
54
+ - **order**: a customer's request to buy, before payment.
55
+
56
+ <!-- .claude/agents/reviewer.md -->
57
+ Reject a term that is not in `docs/glossary.md`.
58
+ ```
59
+
60
+ A teammate renames "order" to "basket" in the glossary alone. The one-line diff looks fine, but the reviewer will now reject every `order` left in the code. At the start of the next session, the agent runs:
61
+
62
+ ```sh
63
+ principles list-member-problems --short
64
+ ```
65
+
66
+ ```text
67
+ express-intent docs/glossary.md e6aabd6 Rename order to basket audit
68
+ ```
69
+
70
+ `principles start-audit express-intent` hands the agent all three places together. It reports the contradiction, citing each passage, and either finishes the rename or records an open finding. The audit is a file you commit: `.principles/audits/express-intent.json`. A typo fix costs less: the agent acknowledges that one place, saying in a line why its meaning is unchanged.
71
+
72
+ ## One principle, many places
73
+
74
+ Take express intent: every name says what the thing is and why it exists, and changes when understanding does. This means the agent renames things continuously, as the team's understanding changes, so that names stay current. In code it renames with a tool that changes every reference at once, such as `ast-grep` or an IDE's rename over MCP. A project's root and nested `CLAUDE.md` files, its glossary, design docs, a reviewer subagent and its README can all carry that one principle. Its map names them, so a change to one is checked against the rest.
75
+
76
+ ## Commands
77
+
78
+ Your agent drives these; each result names the next.
79
+
80
+ ```sh
81
+ principles list-principles # where to start
82
+ principles list-candidate-files # survey the guidance you already have
83
+ principles create-principle express-intent --description "Every name says what the thing is and why it exists"
84
+ principles add-member express-intent CLAUDE.md --section "Name things by intent" --role "States the rule"
85
+ principles start-audit express-intent
86
+ principles submit-answer REQUEST_ID --file answer.json
87
+ principles list-member-problems --short # what changed since the last audit
88
+ principles list-open-findings # findings still waiting
89
+ principles show-meta-principle-passage # a passage for CLAUDE.md that keeps the agent checking
90
+ principles show-hook-setup # hook entries that report changes as a session starts and after a commit
91
+ ```
92
+
93
+ The hook entries run `principles report-at-session-start` and `principles report-after-commit`, which a hook runs, not the agent.
94
+
95
+ `principles --help` lists every command, and `principles COMMAND --help` shows its steps. Each project keeps one `.principles/` at its root; `--project PATH` picks one, so projects in a monorepo stay independent.
96
+
97
+ ## Harnesses
98
+
99
+ **Claude Code** is the first target. **Codex** agents can use the same CLI from a shell, and share the same maps and audits. `show-hook-setup` prints Codex hook entries too, not yet tried in a real Codex session; native Codex skills are not built yet, and loading estimates describe Claude Code only.
100
+
101
+ ## Where it comes from
102
+
103
+ The project grows out of two practices developed through use: **express intent**, keeping names and definitions current as understanding changes; and **collaboration through agents**, helping people align on shared work through the agents they each work with.
104
+
105
+ ## Issues
106
+
107
+ Report a bug or ask for a feature at [github.com/realfastAI/principles/issues](https://github.com/realfastAI/principles/issues).
108
+
109
+ ## Licence
110
+
111
+ Principles is licensed under the [Apache License 2.0](LICENSE). Its [NOTICE](NOTICE) credits Sidu Ponnappa and Ontic Pte. Ltd. (realfast.ai) as copyright holders, and Apache 2.0 asks that every copy keep it.
data/exe/principles CHANGED
@@ -6,5 +6,25 @@
6
6
  require_relative "../lib/principles/supported_ruby"
7
7
  Principles::SupportedRuby.new(RUBY_VERSION, ENV.to_h).run_here_or_on_another(__FILE__, ARGV)
8
8
 
9
+ # A hook runs report-after-commit after every shell call, and most calls commit nothing, so that case is told from
10
+ # git's files alone, loading nothing else of this tool but the read of stdin. Its input is read as the command reads
11
+ # it, by Data::HookInput, which stops waiting on a stdin left open and sending nothing, and Models::AfterCommitInput.read;
12
+ # any failure here leaves the run to the command, which reports it in one line and exits 0. Like the rest of this
13
+ # file, it is written so an older Ruby can still parse it and reach the refusal above.
14
+ if ARGV == ["report-after-commit"]
15
+ require "stringio"
16
+ require_relative "../lib/principles/data/hook_input"
17
+ hook_input = Principles::Data::HookInput.new($stdin).text
18
+ begin
19
+ require_relative "../lib/principles/models/head_moves"
20
+ call = Principles::Models::AfterCommitInput.read(hook_input, ENV.to_h, clock: Time.now.to_i, home: Dir.home,
21
+ pwd: Dir.pwd)
22
+ exit 0 if call.event.nil? || Principles::Models::HeadMoves.new(call).to_a.empty?
23
+ rescue StandardError
24
+ nil
25
+ end
26
+ $stdin = StringIO.new(hook_input)
27
+ end
28
+
9
29
  require_relative "../lib/principles"
10
30
  exit Principles::CLI.run(ARGV)
@@ -4,9 +4,9 @@
4
4
  require_relative "invocation_options"
5
5
 
6
6
  module Principles
7
- # The options the plugin's after-commit hook gives list-member-problems, --commits-after and --hook-event (D73),
7
+ # The options the plugin's after-commit hook gives list-member-problems, --commits-after and --hook-event,
8
8
  # and what is wrong with them as given, which CommandLine refuses as a usage error. list-candidate-files takes
9
- # --commits-after for a range of its own, so CommandLine checks these on COMMAND alone (#1171).
9
+ # --commits-after for a range of its own, so CommandLine checks these on COMMAND alone.
10
10
  class AfterCommitHookOptions
11
11
  # The events Claude Code runs the after-commit hook on, which --hook-event echoes back to it.
12
12
  EVENTS = %w[PostToolUse PostToolUseFailure].freeze #: Array[String]
@@ -2,25 +2,25 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "json"
5
- require_relative "data/running_version"
6
5
  require_relative "models/project"
7
6
  require_relative "command_routes"
8
7
  require_relative "controllers/help"
9
8
  require_relative "command_line"
9
+ require_relative "failure_refusal"
10
+ require_relative "launch"
11
+ require_relative "data/hook_input"
12
+ require_relative "views/printed_json"
10
13
 
11
14
  module Principles
12
15
  # Parses one invocation, runs its step and prints the JSON result. Every refusal is one JSON object
13
16
  # naming its code and repair, because an agent's shell may merge stdout and stderr.
14
17
  class CLI
15
- # The repair for a shape error raised from this tool's own code. Such an error cannot say which file was at
16
- # fault, so the repair names every file a command reads, and blames none (D29).
17
- SHAPE_REPAIR = "A file this command read is not in the shape this tool writes: the map in " \
18
- ".principles/maps/ID.json, its audit record in .principles/audits/ID.json, or the answer given " \
19
- "with --file. Compare it with git, or with the request's response_template."
18
+ # The repair for a shape error raised from this tool's own code, which FailureRefusal owns.
19
+ SHAPE_REPAIR = FailureRefusal::SHAPE_REPAIR
20
20
 
21
21
  # Runs one invocation and returns its exit status: 0 for a result, 1 for a refusal, 2 for a usage error, and 3
22
22
  # when list-member-problems --short finds a member an audit assessed changed, or 4 when it finds only edits to
23
- # members no audit has assessed (D44). executable is the command every printed command
23
+ # members no audit has assessed. executable is the command every printed command
24
24
  # names: the entry point says how it is run.
25
25
  #: (Array[String], ?IO, ?IO, ?IO, ?executable: String) -> Integer
26
26
  def self.run(argv, stdout = $stdout, stderr = $stderr, stdin = $stdin,
@@ -38,14 +38,42 @@ module Principles
38
38
 
39
39
  #: (Array[String]) -> Integer
40
40
  def run(argv)
41
- dispatch(CommandLine.new(argv, positional: CommandRoutes::POSITIONAL, executable: @executable))
41
+ hook = hook_command(argv)
42
+ hook ? run_for_a_hook(hook, argv) : run_refusing(argv)
43
+ end
44
+
45
+ private
46
+
47
+ # Runs argv, refusing what does not fit with one JSON object on stderr and its status.
48
+ #: (Array[String]) -> Integer
49
+ def run_refusing(argv)
50
+ dispatch(command_line(argv))
42
51
  rescue Error => e
43
52
  refused(e.payload, 1)
44
53
  rescue OptionParser::ParseError, KeyError, TypeError, NoMethodError, ArgumentError, SystemCallError => e
45
- refused(refusal(e), e.is_a?(OptionParser::ParseError) ? 2 : 1)
54
+ failed = FailureRefusal.new(e, executable: running_tool.executable)
55
+ refused(failed.payload, failed.status)
46
56
  end
47
57
 
48
- private
58
+ # Runs argv for the hook that runs command, which exits 0 whatever fails, since a host shows the user an error for
59
+ # any other status and gives the agent nothing: a failure is one line the agent reads instead.
60
+ #: (String, Array[String]) -> Integer
61
+ def run_for_a_hook(command, argv)
62
+ dispatch(command_line(argv))
63
+ rescue StandardError => e
64
+ @stdout.puts(visible("principles: #{command} failed: #{e.class}: #{e.message.lines.first.to_s.chomp}"))
65
+ 0
66
+ end
67
+
68
+ # The command argv names first when a hook runs it, as a host names it, passing its JSON on stdin, or nil for any
69
+ # other: a hook command's name later in argv is another command's argument.
70
+ #: (Array[String]) -> String?
71
+ def hook_command(argv) = argv.first.then { it if CommandRoutes::ROUTES[it]&.reads_hook_input }
72
+
73
+ #: (Array[String]) -> CommandLine
74
+ def command_line(argv)
75
+ CommandLine.new(argv, positional: CommandRoutes::POSITIONAL, executable: running_tool.executable)
76
+ end
49
77
 
50
78
  #: (CommandLine) -> Integer
51
79
  def dispatch(line)
@@ -66,37 +94,22 @@ module Principles
66
94
  options = line.command_options
67
95
  # One byte past the limit is enough for the answer's own check to refuse it as too large.
68
96
  options["stdin"] = @stdin.read(Data::BoundedFile::LIMIT + 1).to_s if options["file"] == "-"
97
+ options["stdin"] = hook_input if CommandRoutes::ROUTES.fetch(command).reads_hook_input
69
98
  project = selected_project(line)
70
99
  CommandRoutes::CONTROLLERS.fetch(command).new(project, tool: running_tool)
71
100
  .call(command, line.id, options)
72
101
  end
73
102
 
103
+ # The JSON a host passes the hook that runs this command.
104
+ #: () -> String
105
+ def hook_input = Data::HookInput.new(@stdin).text
106
+
74
107
  #: (CommandLine) -> Models::Project
75
108
  def selected_project(line)
76
109
  root = line.option("project")
77
110
  line.project_given? ? Models::Project.at(root) : Models::Project.containing(root)
78
111
  end
79
112
 
80
- # The JSON object an agent reads for a failure that is not one of this tool's refusals.
81
- #: (StandardError) -> Hash[untyped, untyped]
82
- def refusal(error)
83
- case error
84
- when OptionParser::ParseError
85
- failure(error, status: "usage_error", code: "invalid_invocation", repair: usage_repair(error))
86
- when SystemCallError
87
- failure(error, status: "refused", code: "filesystem_error",
88
- repair: "Check the project path and file permissions, then retry.")
89
- else
90
- failure(error, status: "refused", code: "invalid_shape", repair: SHAPE_REPAIR)
91
- end
92
- end
93
-
94
- # The repair a refused command line carries for the command it names, or the advice to see every command.
95
- #: (OptionParser::ParseError) -> String
96
- def usage_repair(error)
97
- error.is_a?(CommandLine::UsageRefusal) ? error.repair : "To see every command: #{@executable} --help"
98
- end
99
-
100
113
  # Prints the refusal for the agent and returns the exit status.
101
114
  #: (Hash[untyped, untyped], Integer) -> Integer
102
115
  def refused(payload, status)
@@ -104,14 +117,9 @@ module Principles
104
117
  status
105
118
  end
106
119
 
107
- #: (StandardError, status: String, code: String, repair: String) -> Hash[Symbol, String]
108
- def failure(error, status:, code:, repair:)
109
- { status: status, code: code, message: error.message, repair: repair }
110
- end
111
-
112
120
  # json with every invisible formatting character and line or paragraph separator escaped, as JSON allows.
113
121
  # Text from project files can hold a right-to-left override or a zero-width space, which makes a printed
114
- # check or id look like something it is not (#227).
122
+ # check or id look like something it is not.
115
123
  #: (String) -> String
116
124
  def visible(json)
117
125
  json.gsub(/[\p{Cf}\p{Zl}\p{Zp}]/) do |character|
@@ -124,7 +132,7 @@ module Principles
124
132
  #: (untyped) -> Integer
125
133
  def printed_result(result)
126
134
  return printed(visible(result.text)) if result.is_a?(Views::JsonWithEntriesOnLines)
127
- return printed(visible(JSON.pretty_generate(result))) unless result.is_a?(Views::Lines)
135
+ return printed(visible(Views::PrintedJson.text(result))) unless result.is_a?(Views::Lines)
128
136
 
129
137
  @stdout.print(result.stdout)
130
138
  @stderr.print(result.stderr)
@@ -142,15 +150,15 @@ module Principles
142
150
  Controllers::Help.new(tool: running_tool)
143
151
  end
144
152
 
145
- # This run of the tool: the executable it was invoked as, and its version, read only when a command needs it.
153
+ # This run of the tool, as its entry point launched it.
146
154
  #: () -> Controllers::RunningTool
147
- def running_tool = Controllers::RunningTool.new(executable: @executable, version: -> { running_version })
155
+ def running_tool = Launch.new(@executable).running_tool
148
156
 
149
- # The version of this tool that is running, as a build stamped it or a checkout's commit gives it.
157
+ # The version of this tool that is running, as --version prints it.
150
158
  #: () -> String
151
- def running_version = Data::RunningVersion.new.to_s
159
+ def running_version = running_tool.version
152
160
 
153
- # The page help COMMAND asks for, as COMMAND --help prints it, or the overview for help alone (#1167).
161
+ # The page help COMMAND asks for, as COMMAND --help prints it, or the overview for help alone.
154
162
  #: (CommandLine) -> String
155
163
  def help_topic(line)
156
164
  topic = line.help_topic
@@ -19,7 +19,7 @@ module Principles
19
19
  REQUIRED_OPTION_WORDS = { "file" => "--file FILE, or --file - for stdin" }.freeze #: Hash[String, String]
20
20
 
21
21
  # argv is parsed at once; positional names each command's positional arguments, in order; executable is the
22
- # invocation a refusal tells the agent to run --help with (#562).
22
+ # invocation a refusal tells the agent to run --help with.
23
23
  #: (Array[String], positional: Hash[String, Array[String]], executable: String) -> void
24
24
  def initialize(argv, positional:, executable:)
25
25
  @positional = positional
@@ -27,13 +27,13 @@ module Principles
27
27
  @options = InvocationOptions.new #: InvocationOptions
28
28
  @arguments = argv.dup #: Array[String]
29
29
  # The words as typed: parsing takes the options out of @arguments, and a value option is checked against
30
- # the word that followed it (#750).
30
+ # the word that followed it.
31
31
  @words = argv.dup.freeze #: Array[String]
32
32
  parse(argv)
33
33
  end
34
34
 
35
35
  # A usage refusal that carries the repair for the command it names, which CLI prints in place of its
36
- # general advice (#576). It stays an OptionParser::ParseError, so it exits 2 like every usage refusal.
36
+ # general advice. It stays an OptionParser::ParseError, so it exits 2 like every usage refusal.
37
37
  class UsageRefusal < OptionParser::ParseError
38
38
  #: String
39
39
  attr_reader :repair
@@ -59,7 +59,7 @@ module Principles
59
59
  #: () -> bool
60
60
  def project_given? = @options.given.include?("project")
61
61
 
62
- # Whether the words ask for help by word, as help or help COMMAND, which an agent tries before --help (#1167).
62
+ # Whether the words ask for help by word, as help or help COMMAND, which an agent tries before --help.
63
63
  #: () -> bool
64
64
  def help_words? = @arguments.first == "help"
65
65
 
@@ -94,10 +94,12 @@ module Principles
94
94
  positionals.id
95
95
  end
96
96
 
97
- # The options, with every positional argument but the id under its name.
97
+ # The options, with every positional argument but the id under its name; project only when --project was given,
98
+ # so a command's printed commands name it only then.
98
99
  #: () -> Hash[String, untyped]
99
100
  def command_options
100
- @options.to_h.merge(positionals.bindings)
101
+ options = @options.to_h.merge(positionals.bindings)
102
+ project_given? ? options : options.except("project")
101
103
  end
102
104
 
103
105
  private
@@ -106,8 +108,8 @@ module Principles
106
108
  def positionals = PositionalArguments.new(@positional.fetch(command.to_s), @arguments.drop(1))
107
109
 
108
110
  # Each argument the command needs and was not given, named in one refusal: an agent that met one refusal per
109
- # missing argument repaired them one at a time (#1083). Each option command-steps.json says it requires is one.
110
- # The repair names the command's usage, which shows what to give (#1273).
111
+ # missing argument repaired them one at a time. Each option command-steps.json says it requires is one.
112
+ # The repair names the command's usage, which shows what to give.
111
113
  #: (String) -> void
112
114
  def check_missing(name)
113
115
  missing = positionals.missing + missing_options(name)
@@ -142,8 +144,8 @@ module Principles
142
144
  raise UsageRefusal.new("#{name} does not take #{unknown.join(", ")}", help_repair(name))
143
145
  end
144
146
 
145
- # An option that takes a value takes the next word, whatever it is, so --member --help took --help as the member
146
- # (#750). Only this tool's own option words are refused there, since a quote may start with dashes; such a word is
147
+ # An option that takes a value takes the next word, whatever it is, so --member --help took --help as the member.
148
+ # Only this tool's own option words are refused there, since a quote may start with dashes; such a word is
147
149
  # given as a value after =, as --starting-at=--role is.
148
150
  #: (String) -> void
149
151
  def check_values_are_not_options(name)
@@ -157,18 +159,22 @@ module Principles
157
159
  end
158
160
  end
159
161
 
160
- # Options checked together, each set owning what is wrong with it as given: --session-start (#717), the
161
- # after-commit hook's pair on the command it runs (D73), the audit start-audit begins (#760) and the form
162
- # list-open-findings prints (#1156); the first fault is refused.
162
+ # Options checked together, each set owning what is wrong with it as given: --session-start, the
163
+ # after-commit hook's pair on the command it runs, the audit start-audit begins and the form
164
+ # list-open-findings prints; the first fault is refused.
163
165
  #: (String) -> void
164
166
  def check_combined_options(name)
165
167
  hook = (AfterCommitHookOptions.new(@options) if name == AfterCommitHookOptions::COMMAND)
166
- sets = [SessionStartOptions.new(@options), hook, StartAuditOptions.new(@options),
167
- ListOpenFindingsOptions.new(@options)].compact
168
+ start_audit = StartAuditOptions.new(@options, several_ids: several_ids?(name))
169
+ sets = [SessionStartOptions.new(@options), hook, start_audit, ListOpenFindingsOptions.new(@options)].compact
168
170
  fault = sets.filter_map(&:fault).first or return
169
171
  raise UsageRefusal.new(fault, help_repair(name))
170
172
  end
171
173
 
174
+ # Whether command name is start-audit given more than one principle id.
175
+ #: (String) -> bool
176
+ def several_ids?(name) = name == "start-audit" && !positionals.bindings.fetch("other_ids", []).empty?
177
+
172
178
  # Parses argv's options; an option no command defines fails here, before the command is checked, and is
173
179
  # repaired with the help of the command argv names, or left to CLI's general advice when it names none.
174
180
  #: (Array[String]) -> void
@@ -189,7 +195,7 @@ module Principles
189
195
  def steps(name) = Models::CommandSteps.load.command(name)
190
196
 
191
197
  # The command's usage, which names every option it takes, so a near-miss such as --heading for --section shows
192
- # beside the refusal (#1273), then where to see what each takes. The usage leaves out the executable, so it is not
198
+ # beside the refusal, then where to see what each takes. The usage leaves out the executable, so it is not
193
199
  # read as a command to run as printed.
194
200
  #: (String) -> String
195
201
  def help_repair(name)