principles 0.1.3 → 0.1.5

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 (312) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +151 -1
  3. data/README.md +10 -6
  4. data/exe/principles +1 -1
  5. data/lib/principles/cli.rb +9 -10
  6. data/lib/principles/command_line.rb +15 -6
  7. data/lib/principles/command_routes.rb +18 -2
  8. data/lib/principles/controllers/acknowledgement.rb +19 -4
  9. data/lib/principles/controllers/acknowledgements.rb +43 -12
  10. data/lib/principles/controllers/after_commit_report.rb +15 -2
  11. data/lib/principles/controllers/assessment.rb +7 -3
  12. data/lib/principles/controllers/audit.rb +17 -8
  13. data/lib/principles/controllers/audit_completion.rb +34 -9
  14. data/lib/principles/controllers/carrier_edit_report.rb +40 -0
  15. data/lib/principles/controllers/carrier_practices.rb +26 -0
  16. data/lib/principles/controllers/command.rb +36 -5
  17. data/lib/principles/controllers/context_budget.rb +61 -0
  18. data/lib/principles/controllers/correction.rb +15 -5
  19. data/lib/principles/controllers/full_audit_request.rb +38 -42
  20. data/lib/principles/controllers/inventory.rb +78 -71
  21. data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
  22. data/lib/principles/controllers/member_addition.rb +20 -5
  23. data/lib/principles/controllers/member_entries.rb +50 -39
  24. data/lib/principles/controllers/member_entry_changes.rb +71 -0
  25. data/lib/principles/controllers/member_problems_report.rb +26 -6
  26. data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
  27. data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
  28. data/lib/principles/controllers/members_to_assess.rb +35 -8
  29. data/lib/principles/controllers/meta_principle_setup.rb +12 -4
  30. data/lib/principles/controllers/open_correction.rb +3 -2
  31. data/lib/principles/controllers/parts_to_read.rb +48 -6
  32. data/lib/principles/controllers/plugin_member_addition.rb +48 -0
  33. data/lib/principles/controllers/principle_listing.rb +84 -0
  34. data/lib/principles/controllers/request_logging.rb +65 -0
  35. data/lib/principles/controllers/running_tool.rb +55 -15
  36. data/lib/principles/controllers/session_start_report.rb +26 -2
  37. data/lib/principles/data/branches_bringing_in.rb +52 -0
  38. data/lib/principles/data/captured_requests.rb +118 -0
  39. data/lib/principles/data/carrier_page_markers.rb +38 -0
  40. data/lib/principles/data/changes_since.rb +56 -0
  41. data/lib/principles/data/claude_code_home.rb +75 -0
  42. data/lib/principles/data/command-steps.json +139 -23
  43. data/lib/principles/data/decoded_leaf.rb +63 -0
  44. data/lib/principles/data/head_reflog.rb +13 -2
  45. data/lib/principles/data/kept_line.rb +39 -0
  46. data/lib/principles/data/known_marketplaces.rb +50 -0
  47. data/lib/principles/data/logged_request_matches.rb +144 -0
  48. data/lib/principles/data/logged_request_scan.rb +188 -0
  49. data/lib/principles/data/map_files.rb +18 -4
  50. data/lib/principles/data/plugin_folder.rb +85 -0
  51. data/lib/principles/data/plugin_registry.rb +73 -0
  52. data/lib/principles/data/principles_store.rb +49 -0
  53. data/lib/principles/data/project_files.rb +15 -0
  54. data/lib/principles/data/ran.rb +25 -0
  55. data/lib/principles/data/raw_request_filter.rb +61 -0
  56. data/lib/principles/data/repository.rb +29 -27
  57. data/lib/principles/data/request_logging_folder.rb +135 -0
  58. data/lib/principles/data/request_shape.rb +33 -0
  59. data/lib/principles/data/running_version.rb +1 -1
  60. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
  61. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
  62. data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
  63. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  64. data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
  65. data/lib/principles/data/schemas/correction-answer.schema.json +14 -0
  66. data/lib/principles/data/schemas/member-map.schema.json +12 -1
  67. data/lib/principles/data/settings_env_keys.rb +26 -0
  68. data/lib/principles/data/string_counts.rb +39 -0
  69. data/lib/principles/data/tools_on_path.rb +25 -0
  70. data/lib/principles/data/user_request_logging_folder.rb +73 -0
  71. data/lib/principles/invocation_options.rb +5 -3
  72. data/lib/principles/launch.rb +29 -10
  73. data/lib/principles/models/acknowledged_check.rb +11 -1
  74. data/lib/principles/models/acknowledgement.rb +5 -0
  75. data/lib/principles/models/acknowledgement_refusal.rb +20 -11
  76. data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
  77. data/lib/principles/models/after_commit_input.rb +5 -0
  78. data/lib/principles/models/answer_fields.rb +3 -0
  79. data/lib/principles/models/assessment_basis.rb +10 -3
  80. data/lib/principles/models/audit.rb +10 -10
  81. data/lib/principles/models/audit_record.rb +10 -0
  82. data/lib/principles/models/audit_records.rb +4 -3
  83. data/lib/principles/models/audit_start.rb +9 -0
  84. data/lib/principles/models/authored_locator.rb +33 -0
  85. data/lib/principles/models/candidate_files.rb +23 -3
  86. data/lib/principles/models/candidate_outline.rb +18 -125
  87. data/lib/principles/models/captured_sessions.rb +166 -0
  88. data/lib/principles/models/carrier_edit_input.rb +56 -0
  89. data/lib/principles/models/carrier_kind.rb +79 -0
  90. data/lib/principles/models/carrier_pages_shown.rb +28 -0
  91. data/lib/principles/models/carved_message_bytes.rb +115 -0
  92. data/lib/principles/models/cited_files.rb +12 -3
  93. data/lib/principles/models/context_parts.rb +59 -0
  94. data/lib/principles/models/decided_prior_findings.rb +5 -0
  95. data/lib/principles/models/declared_map_changes.rb +22 -13
  96. data/lib/principles/models/disposition.rb +37 -6
  97. data/lib/principles/models/disposition_placeholders.rb +12 -0
  98. data/lib/principles/models/disposition_text_field.rb +4 -0
  99. data/lib/principles/models/dropped_thinking.rb +73 -0
  100. data/lib/principles/models/feature.rb +54 -0
  101. data/lib/principles/models/finding_outcomes.rb +55 -0
  102. data/lib/principles/models/findings_left_open.rb +9 -11
  103. data/lib/principles/models/head_moves.rb +27 -10
  104. data/lib/principles/models/installed_component.rb +55 -0
  105. data/lib/principles/models/installed_plugins.rb +174 -0
  106. data/lib/principles/models/kept_sessions.rb +34 -0
  107. data/lib/principles/models/locator.rb +8 -0
  108. data/lib/principles/models/logged_request_reach.rb +52 -0
  109. data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
  110. data/lib/principles/models/map_format_raise.rb +28 -0
  111. data/lib/principles/models/mapped_baseline.rb +46 -0
  112. data/lib/principles/models/mapped_principles.rb +2 -1
  113. data/lib/principles/models/maps_holding_file_whole.rb +42 -0
  114. data/lib/principles/models/markdown_text.rb +143 -0
  115. data/lib/principles/models/member.rb +19 -1
  116. data/lib/principles/models/member_entry.rb +56 -0
  117. data/lib/principles/models/member_justification.rb +52 -0
  118. data/lib/principles/models/member_lines.rb +11 -0
  119. data/lib/principles/models/member_loads.rb +17 -2
  120. data/lib/principles/models/member_problems.rb +46 -42
  121. data/lib/principles/models/member_reach.rb +59 -0
  122. data/lib/principles/models/member_snapshots.rb +34 -4
  123. data/lib/principles/models/member_text_as_sent.rb +31 -0
  124. data/lib/principles/models/member_texts.rb +45 -0
  125. data/lib/principles/models/members_by_part.rb +67 -0
  126. data/lib/principles/models/members_in_logged_requests.rb +279 -0
  127. data/lib/principles/models/meta_principle.rb +4 -4
  128. data/lib/principles/models/missing_files.rb +41 -16
  129. data/lib/principles/models/nearly_matching_maps.rb +56 -0
  130. data/lib/principles/models/open_correction.rb +5 -0
  131. data/lib/principles/models/open_finding.rb +4 -3
  132. data/lib/principles/models/outline_budget.rb +10 -1
  133. data/lib/principles/models/outline_item.rb +25 -0
  134. data/lib/principles/models/outline_section.rb +15 -4
  135. data/lib/principles/models/part_named.rb +16 -2
  136. data/lib/principles/models/part_token_estimates.rb +60 -0
  137. data/lib/principles/models/plugin_component.rb +37 -0
  138. data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
  139. data/lib/principles/models/plugin_install.rb +33 -0
  140. data/lib/principles/models/plugin_name.rb +23 -0
  141. data/lib/principles/models/plugin_reference.rb +53 -0
  142. data/lib/principles/models/principle.rb +7 -4
  143. data/lib/principles/models/principle_members.rb +22 -0
  144. data/lib/principles/models/prior_finding_decision.rb +1 -1
  145. data/lib/principles/models/prior_finding_outcomes.rb +12 -1
  146. data/lib/principles/models/problem_report.rb +14 -25
  147. data/lib/principles/models/project.rb +51 -56
  148. data/lib/principles/models/project_harness.rb +48 -0
  149. data/lib/principles/models/project_history.rb +19 -5
  150. data/lib/principles/models/recorded_members.rb +7 -0
  151. data/lib/principles/models/report_hooks.rb +9 -4
  152. data/lib/principles/models/request_channel.rb +62 -0
  153. data/lib/principles/models/request_kind.rb +62 -0
  154. data/lib/principles/models/request_logging.rb +231 -0
  155. data/lib/principles/models/request_logging_guard.rb +84 -0
  156. data/lib/principles/models/request_time.rb +46 -0
  157. data/lib/principles/models/runs_from.rb +0 -5
  158. data/lib/principles/models/script_comments.rb +58 -0
  159. data/lib/principles/models/session_registry.rb +61 -0
  160. data/lib/principles/models/session_start_input.rb +11 -2
  161. data/lib/principles/models/session_trend.rb +36 -0
  162. data/lib/principles/models/stale_request.rb +9 -0
  163. data/lib/principles/models/turn_opening.rb +83 -0
  164. data/lib/principles/models/turn_position.rb +43 -0
  165. data/lib/principles/models/unfixed_part.rb +82 -0
  166. data/lib/principles/models/unresolved_plugin_members.rb +35 -0
  167. data/lib/principles/models/user_logged_requests.rb +90 -0
  168. data/lib/principles/models/user_settings_entries.rb +49 -0
  169. data/lib/principles/models/whole_file_member_read.rb +48 -0
  170. data/lib/principles/models/without_prose.rb +20 -0
  171. data/lib/principles/models/workflow_jobs.rb +92 -0
  172. data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
  173. data/lib/principles/show_principle_options.rb +32 -0
  174. data/lib/principles/version.rb +2 -2
  175. data/lib/principles/views/acknowledged_result.rb +31 -12
  176. data/lib/principles/views/acknowledgement_result.rb +18 -13
  177. data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
  178. data/lib/principles/views/acknowledgements_offered.rb +54 -0
  179. data/lib/principles/views/added_member.rb +22 -6
  180. data/lib/principles/views/answer_in_a_file.rb +15 -15
  181. data/lib/principles/views/assessed_members.rb +19 -8
  182. data/lib/principles/views/assessment_request.rb +14 -6
  183. data/lib/principles/views/audit_changes.rb +14 -8
  184. data/lib/principles/views/audit_findings.rb +34 -0
  185. data/lib/principles/views/audit_result.rb +26 -24
  186. data/lib/principles/views/candidate_files_result.rb +1 -1
  187. data/lib/principles/views/carrier_checks.rb +40 -0
  188. data/lib/principles/views/carrier_edit_denial.rb +36 -0
  189. data/lib/principles/views/carrier_practices_page.rb +49 -0
  190. data/lib/principles/views/completed_audit_findings.rb +33 -0
  191. data/lib/principles/views/completed_audit_next_step.rb +12 -4
  192. data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
  193. data/lib/principles/views/context_budget_result.rb +99 -0
  194. data/lib/principles/views/context_parts.rb +129 -25
  195. data/lib/principles/views/correction_request.rb +32 -17
  196. data/lib/principles/views/disposition_template.rb +35 -0
  197. data/lib/principles/views/first_audit.rb +29 -15
  198. data/lib/principles/views/first_audit_line.rb +4 -5
  199. data/lib/principles/views/hook_setup_result.rb +3 -1
  200. data/lib/principles/views/invocation.rb +14 -5
  201. data/lib/principles/views/last_record_notice.rb +41 -0
  202. data/lib/principles/views/lines_shared_with_member.rb +16 -22
  203. data/lib/principles/views/logged_request_status_meanings.rb +29 -0
  204. data/lib/principles/views/logged_requests_evidence.rb +84 -0
  205. data/lib/principles/views/map_added_to.rb +14 -12
  206. data/lib/principles/views/map_format_raised.rb +28 -0
  207. data/lib/principles/views/map_result.rb +41 -18
  208. data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
  209. data/lib/principles/views/member_change_since_baseline.rb +4 -0
  210. data/lib/principles/views/member_row.rb +13 -4
  211. data/lib/principles/views/member_sets_overlap.rb +31 -0
  212. data/lib/principles/views/members_a_commit_changed.rb +42 -25
  213. data/lib/principles/views/members_changed_during_audit.rb +27 -0
  214. data/lib/principles/views/members_in_logged_requests_result.rb +123 -0
  215. data/lib/principles/views/members_too_short_to_scan.rb +45 -0
  216. data/lib/principles/views/members_with_no_baseline.rb +6 -6
  217. data/lib/principles/views/meta_principle_result.rb +52 -15
  218. data/lib/principles/views/open_findings_line.rb +31 -92
  219. data/lib/principles/views/parts_index_result.rb +9 -5
  220. data/lib/principles/views/principle_read_result.rb +52 -11
  221. data/lib/principles/views/prior_findings_result.rb +9 -1
  222. data/lib/principles/views/problem_facts.rb +5 -3
  223. data/lib/principles/views/problem_lines.rb +54 -6
  224. data/lib/principles/views/problem_result.rb +7 -15
  225. data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
  226. data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
  227. data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +6 -6
  228. data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
  229. data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
  230. data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
  231. data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
  232. data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
  233. data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
  234. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
  235. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +6 -1
  236. data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
  237. data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
  238. data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
  239. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
  240. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
  241. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
  242. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
  243. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
  244. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
  245. data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
  246. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +49 -51
  247. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
  248. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
  249. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
  250. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
  251. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
  252. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
  253. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
  254. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
  255. data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +22 -0
  256. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
  257. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +8 -4
  258. data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
  259. data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
  260. data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
  261. data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
  262. data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
  263. data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
  264. data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +22 -0
  265. data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +62 -0
  266. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
  267. data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +16 -16
  268. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
  269. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +17 -17
  270. data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +18 -0
  271. data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +44 -0
  272. data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
  273. data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
  274. data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
  275. data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
  276. data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
  277. data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
  278. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
  279. data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
  280. data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
  281. data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
  282. data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
  283. data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
  284. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
  285. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
  286. data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
  287. data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
  288. data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
  289. data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
  290. data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
  291. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
  292. data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
  293. data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
  294. data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
  295. data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
  296. data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
  297. data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
  298. data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
  299. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
  300. data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
  301. data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
  302. data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
  303. data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
  304. data/lib/principles/views/request_logging_result.rb +108 -0
  305. data/lib/principles/views/request_part.rb +10 -4
  306. data/lib/principles/views/request_parts.rb +9 -0
  307. data/lib/principles/views/set_up_offer_line.rb +43 -0
  308. data/lib/principles/views/whole_file_elsewhere.rb +30 -0
  309. metadata +154 -5
  310. data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
  311. data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
  312. data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
@@ -10,41 +10,88 @@ module Principles
10
10
  # Each runs one command: reads models, applies their rules and prints through a view.
11
11
  # controllers/CLAUDE.md owns the boundary.
12
12
  module Controllers
13
- # The reads that show what a project has mapped: its principles, and each member and how fresh it is against the
14
- # last audit. None changes anything on disk. Survey runs the survey of candidate files.
13
+ # show-principle: each member of one principle and how fresh it is against the last audit. It changes nothing on
14
+ # disk. PrincipleListing lists every principle, and Survey runs the survey of candidate files.
15
15
  class Inventory < Command
16
16
  #: (String, String?, Hash[String, untyped]) -> untyped
17
17
  def call(command, id, options)
18
18
  naming_the_executable do
19
19
  case command
20
- when "list-principles" then listed(options)
21
- when "show-principle" then members(required_id(id)).merge("wrote" => [])
20
+ when "show-principle" then shown(required_id(id), options).merge("wrote" => [])
22
21
  else unknown(command)
23
22
  end
24
23
  end
25
24
  end
26
25
 
27
- # Each principle id names as list-principles lists it: its description and its members by freshness, or the
28
- # refusal that kept its map from being read.
29
- #: (Array[String]) -> Array[Hash[String, untyped]]
30
- def rows(ids) = ids.map { entry(it) }
31
-
32
26
  private
33
27
 
34
- #: (String) -> untyped
35
- def members(id)
28
+ # The principle id names as show-principle prints it, or only the member --member names, refused when its map
29
+ # lacks it.
30
+ #: (String, Hash[String, untyped]) -> untyped
31
+ def shown(id, options)
32
+ member_id = options["member"]&.first
33
+ return members(id, loads: options["loads"]) unless member_id
34
+
35
+ one_member(@principles.find(id), member_id)
36
+ end
37
+
38
+ # The member of principle with member_id, where it is now, how fresh against the last audit, and the last
39
+ # judgements the last completed audit's record keeps of it: its assessment and the last acknowledgement since.
40
+ #: (Models::Principle, String) -> Hash[String, untyped]
41
+ def one_member(principle, member_id)
42
+ member = principle.member(member_id)
43
+ audit = @audit_records.find(principle.id)
44
+ now = fresh(member, audit&.members&.hashes || Models::RecordedHashes::NONE)
45
+ span = now.fetch("snapshot", {}).slice("first_line", "last_line")
46
+ read_result.one_member(principle.id, { "id" => member_id, **member, **span, **now.except("snapshot") },
47
+ *judgements(audit, Models::Member.new(member).key))
48
+ end
49
+
50
+ # The assessment the last completed audit in audit kept for the member known by key, and the last
51
+ # acknowledgement made of it since, each none when the record keeps none.
52
+ #: (Models::AuditRecord?, String) -> [Hash[String, untyped]?, Hash[String, untyped]?]
53
+ def judgements(audit, key)
54
+ completed = audit&.last_completed or return [nil, nil]
55
+ [completed.members.recorded(key)&.assessment, completed.members.acknowledgements_for(key).last]
56
+ end
57
+
58
+ # The principle id names as show-principle prints it, with when each member's file loads only when loads asks.
59
+ #: (String, loads: bool?) -> untyped
60
+ def members(id, loads:)
36
61
  principle = @principles.find(id)
37
62
  audit = @audit_records.find(id)
38
- hooks = @project.hook_commands
39
- members = shown_members(principle, audit, hooks)
40
- shown = read_result.shown(printed_principle(principle, members: members),
41
- repairs: repairs(principle, members), hook_settings_not_read: hooks.not_read,
42
- loaded_files: @project.loaded_files(principle.members, hooks).to_h)
63
+ shown = principle_shown(principle, audit, loads: loads)
43
64
  return shown unless audit
44
65
 
45
66
  shown.merge("last_audit" => audit.last_audit(map_version: principle.version))
46
67
  end
47
68
 
69
+ # The principle with each member and its repairs, and with loads also when each member's file loads, the files
70
+ # they load and the hook settings not read; without, its next_action names --loads.
71
+ #: (Models::Principle, Models::AuditRecord?, loads: bool?) -> Hash[String, untyped]
72
+ def principle_shown(principle, audit, loads:)
73
+ harness = @project.harness
74
+ hooks = harness.hook_commands
75
+ members = shown_members(principle, audit, hooks)
76
+ if loads
77
+ return members_listed(principle, members, hook_settings_not_read: hooks.not_read,
78
+ loaded_files: harness.loaded_files(principle.members, hooks).to_h)
79
+ end
80
+
81
+ read_result.without_loads(members_listed(principle, members.map { it.except("loads") }), principle.id)
82
+ end
83
+
84
+ # The principle with members, their repairs and the plugin members no installed plugin gives, beside what
85
+ # show-principle --loads adds: the hook settings not read and the files the members load.
86
+ #: (Models::Principle, Array[Hash[String, untyped]], ?hook_settings_not_read: Array[Hash[String, String]],
87
+ #| ?loaded_files: Hash[String, untyped]) -> Hash[String, untyped]
88
+ def members_listed(principle, members, hook_settings_not_read: [], loaded_files: {})
89
+ unresolved = members.select { unresolved?(it) }.map { it.fetch("id") }
90
+ read_result.shown(printed_principle(principle, members: members), repairs: repairs(principle, members),
91
+ hook_settings_not_read:, loaded_files:,
92
+ unresolved:)
93
+ end
94
+
48
95
  # Each member as show-principle prints it, with its loads read once for the whole map, from hooks.
49
96
  #: (Models::Principle, Models::AuditRecord?, Models::HookCommands) -> Array[Hash[String, untyped]]
50
97
  def shown_members(principle, audit, hooks)
@@ -60,9 +107,23 @@ module Principles
60
107
  def shown_member(member, audit, loads)
61
108
  now = fresh(member, audit&.members&.hashes || Models::RecordedHashes::NONE)
62
109
  member.merge(now.fetch("snapshot", {}).slice("first_line", "last_line"), now,
63
- "loads" => loads.to_h)
110
+ "loads" => loads.to_h, **plugin_source(member, now))
64
111
  end
65
112
 
113
+ # Where a plugin member found now comes from, at the version installed now, read-only; nothing for a project
114
+ # file, or for a plugin member now says no installed plugin gives.
115
+ #: (Hash[String, untyped], Hash[String, untyped]) -> Hash[String, untyped]
116
+ def plugin_source(member, now)
117
+ return {} if unresolved?(now)
118
+
119
+ source = @project.installed_plugins.source_of(Models::Member.new(member))
120
+ source ? { "source" => source } : {}
121
+ end
122
+
123
+ # Whether a member shown is a plugin member no installed plugin gives.
124
+ #: (Hash[String, untyped]) -> bool
125
+ def unresolved?(shown) = shown.fetch("freshness") == "plugin_unresolved"
126
+
66
127
  # The moves that may repair each shown member whose reference is broken, so an audit would refuse it, by id in the
67
128
  # map's order.
68
129
  #: (Models::Principle, Array[Hash[String, untyped]]) -> Hash[String, Array[Views::MemberRepairs::Move]]
@@ -86,64 +147,10 @@ module Principles
86
147
  {}
87
148
  end
88
149
 
89
- # Where the member is now and whether it changed since the record holding hashes assessed it.
90
- #: (Hash[String, untyped], Models::RecordedHashes) -> Hash[String, untyped]
91
- def fresh(member, hashes)
92
- found = Models::Member.new(member)
93
- @project.freshness(found.locator) { |sha| hashes.freshness(found.key, sha) }
94
- end
95
-
96
150
  #: () -> Views::PrincipleReadResult
97
151
  def read_result
98
152
  Views::PrincipleReadResult.new(invocation)
99
153
  end
100
-
101
- # list-principles as options ask: each id on a line with --lines, else the rows as JSON.
102
- #: (Hash[String, untyped]) -> untyped
103
- def listed(options)
104
- return read_result.ids(@principles.ids) if options["lines"]
105
-
106
- listing(open_findings: options["open_findings"]).merge("wrote" => [])
107
- end
108
-
109
- # Its next_action offers an audit while one principle's audits do not wait on an upgrade; a map listed with its
110
- # refusal counts, since repairing it leaves it to audit. With open_findings, each row lists its open findings.
111
- #: (open_findings: bool?) -> untyped
112
- def listing(open_findings:)
113
- ids = @principles.ids
114
- waiting = ids.filter_map { waiting_on_an_upgrade(it) }
115
- listed = open_findings ? read_result.with_open_findings(rows(ids), open_by_principle(ids)) : rows(ids)
116
- read_result.listing(listed, waiting: waiting, one_to_audit: waiting.size < ids.size)
117
- end
118
-
119
- # Each principle's open findings, from every record this copy can read, as list-open-findings reads them,
120
- # aged until now, by principle id.
121
- #: (Array[String]) -> Hash[String, Array[Hash[String, untyped]]]
122
- def open_by_principle(ids)
123
- now = Time.now.utc
124
- @audit_records.readable_of(ids).flat_map(&:left_open).map { it.waited_at(now) }
125
- .group_by { it.fetch("principle") }
126
- end
127
-
128
- # One map's row; a map this tool cannot read is listed with its refusal, so the others still show, and one
129
- # whose record a later copy wrote says its audits wait on an upgrade, as show-audit does.
130
- #: (String) -> Hash[String, untyped]
131
- def entry(id)
132
- map = @principles.find(id)
133
- row = map.description_with_id.merge("members_by_freshness" => members_by_freshness(map))
134
- row = row.merge(read_result.no_members(@principles.file(id))) if map.unstarted?
135
- row.merge(waiting_on_an_upgrade(id)&.marker || {})
136
- rescue Error => e
137
- { "id" => id, "refusal" => e.payload }
138
- end
139
-
140
- # How many of map's members are in each freshness state, against its principle's last audit, or the hashes a
141
- # record a later copy wrote holds, read-only, when this copy cannot read the rest of it.
142
- #: (Models::Principle) -> Hash[String, Integer]
143
- def members_by_freshness(map)
144
- hashes = @audit_records.hashes_to_compare(map.id)
145
- map.members_shown.map { |member| fresh(member, hashes).fetch("freshness") }.tally.sort.to_h
146
- end
147
154
  end
148
155
  end
149
156
  end
@@ -0,0 +1,51 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+ require_relative "../views/last_record_notice"
6
+
7
+ module Principles
8
+ # Each runs one command: reads models, applies their rules and prints through a view.
9
+ # controllers/CLAUDE.md owns the boundary.
10
+ module Controllers
11
+ # The notice a full audit's request prints when the last audit's record of its principle was left uncommitted,
12
+ # which FullAuditRequest hands over: a completed one to commit, or an open one, which its correction completes,
13
+ # never to commit; and, when the open record keeps its correction, how to resume it.
14
+ class LastRecordNoticeBeside < Command
15
+ # principle_id names the principle audited; base is the commit its audit is based on, nil outside git.
16
+ #: (Models::Project, tool: RunningTool, principle_id: String, base: String?) -> void
17
+ def initialize(project, tool:, principle_id:, base:)
18
+ super(project, tool: tool)
19
+ @id = principle_id
20
+ @base = base
21
+ end
22
+
23
+ # output, with the notice when there is one, committed or not, in git or outside.
24
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
25
+ def beside(output)
26
+ record = @audit_records.find(@id)
27
+ notices = Views::LastRecordNotice.new(invocation)
28
+ resume = (notices.resume(@id) if record&.correction)
29
+ notice = [uncommitted_record_notice(record, notices), resume].compact.join(" ")
30
+ notice.empty? ? output : output.merge("notice" => notice)
31
+ end
32
+
33
+ private
34
+
35
+ # What notices says of record when, in git, its file differs from the last commit, or nil when it does not.
36
+ #: (Models::AuditRecord?, Views::LastRecordNotice) -> String?
37
+ def uncommitted_record_notice(record, notices)
38
+ return unless @base && uncommitted_record?
39
+
40
+ file = @audit_records.file(@id)
41
+ record&.open? ? notices.open(file) : notices.uncommitted(file)
42
+ end
43
+
44
+ # Whether the last audit's record exists but differs from the last commit, so it may be left behind.
45
+ #: () -> bool
46
+ def uncommitted_record?
47
+ @audit_records.exist?(@id) && @history.uncommitted([@audit_records.file(@id)]).any?
48
+ end
49
+ end
50
+ end
51
+ end
@@ -4,9 +4,13 @@
4
4
  require_relative "command"
5
5
  require_relative "../models/member"
6
6
  require_relative "../models/members_in_consecutive_sections"
7
+ require_relative "../models/maps_holding_file_whole"
8
+ require_relative "../models/nearly_matching_maps"
7
9
  require_relative "../models/member_loading_scopes"
8
10
  require_relative "../views/map_added_to"
9
11
  require_relative "../views/consecutive_sections_elsewhere"
12
+ require_relative "../views/whole_file_elsewhere"
13
+ require_relative "../views/member_sets_overlap"
10
14
  require_relative "../views/new_loading_scope"
11
15
 
12
16
  module Principles
@@ -27,13 +31,24 @@ module Principles
27
31
  added = located_member
28
32
  shared = lines_shared(@member, @map)
29
33
  joined = joined_for(added_to)
30
- sections = Models::MembersInConsecutiveSections.new(@project, @member).elsewhere(except: @map.id)
31
- consecutive = Views::ConsecutiveSectionsElsewhere.new(sections)
32
- map_result.member_added(principle, added: added, shared: shared, joined: joined, consecutive: consecutive)
34
+ map_result.member_added(principle, added: added, shared: shared, joined: joined,
35
+ other_maps: other_maps(added_to))
33
36
  end
34
37
 
35
38
  private
36
39
 
40
+ # What other maps hold of the new member that the agent judges: consecutive complete sections, its file held
41
+ # whole, and a member set nearly matching the one it joined, added_to.
42
+ #: (Models::Principle)
43
+ #| -> Array[Views::ConsecutiveSectionsElsewhere | Views::WholeFileElsewhere | Views::MemberSetsOverlap]
44
+ def other_maps(added_to)
45
+ sections = Models::MembersInConsecutiveSections.new(@project, @member).elsewhere(except: @map.id)
46
+ whole = Models::MapsHoldingFileWhole.new(@project, @member).elsewhere(except: @map.id)
47
+ near = Models::NearlyMatchingMaps.new(@project, added_to, @member).elsewhere
48
+ [Views::ConsecutiveSectionsElsewhere.new(sections), Views::WholeFileElsewhere.new(whole),
49
+ Views::MemberSetsOverlap.new(near)]
50
+ end
51
+
37
52
  # The updated map's after-save context, keeping the reminder facts captured before the write.
38
53
  #: (Models::Principle) -> Views::MapAddedTo
39
54
  def joined_for(added_to)
@@ -41,7 +56,7 @@ module Principles
41
56
  joined = @joined.with_completeness_question(
42
57
  asks: added_to.members.asks_about_completeness?(no_completed_audit: no_completed)
43
58
  )
44
- scopes = Models::MemberLoadingScopes.new(@project.member_loads(added_to.members))
59
+ scopes = Models::MemberLoadingScopes.new(@project.harness.member_loads(added_to.members))
45
60
  joined.with_loading_scope(Views::NewLoadingScope.new(scopes.introduced_by(@member.id)))
46
61
  end
47
62
 
@@ -59,7 +74,7 @@ module Principles
59
74
  #: () -> Views::MapAddedTo
60
75
  def joined
61
76
  history = principle_history(@map.id)
62
- Views::MapAddedTo.new(keeps_others_held: @map.keeps_others_held?,
77
+ Views::MapAddedTo.new(keeps_held: (@principles.ids - [@map.id] if @map.keeps_others_held?),
63
78
  correction_may_be_open: history.startable_at_head?,
64
79
  reminded: history.first_add_since_commit?(@map))
65
80
  end
@@ -3,6 +3,10 @@
3
3
 
4
4
  require_relative "command"
5
5
  require_relative "member_addition"
6
+ require_relative "member_entry_changes"
7
+ require_relative "plugin_member_addition"
8
+ require_relative "../models/authored_locator"
9
+ require_relative "../models/member_justification"
6
10
 
7
11
  module Principles
8
12
  # Each runs one command: reads models, applies their rules and prints through a view.
@@ -15,24 +19,36 @@ module Principles
15
19
  # Each command and the method that runs it.
16
20
  COMMANDS = {
17
21
  "add-member" => :add_member, "move-member" => :move_member,
18
- "change-member-role" => :change_member_role, "change-member-check" => :change_member_check,
19
- "remove-member-check" => :remove_member_check, "remove-member" => :remove_member
22
+ "remove-member" => :remove_member
20
23
  }.freeze #: Hash[String, Symbol]
21
24
 
22
25
  # Each location option and the name the agent typed it as.
23
26
  LOCATION_OPTIONS = { "section" => "--section", "starting_at" => "--starting-at",
24
27
  "ending_at" => "--ending-at", "query" => "--query" }.freeze #: Hash[String, String]
25
28
 
29
+ # The options beside --role that justify a new member, stored when given, in the order the map holds them.
30
+ JUSTIFYING_OPTIONS = %w[name reason].freeze #: Array[String]
31
+
26
32
  #: (String, String?, Hash[String, untyped]) -> untyped
27
33
  def call(command, id, options)
28
34
  naming_the_executable(rerun: ->(member) { rerun(command, id.to_s, member, options) }) do
29
- method = COMMANDS[command] or unknown(command)
30
- send(method, required_id(id), options)
35
+ run(command, id, options)
31
36
  end
32
37
  end
33
38
 
34
39
  private
35
40
 
41
+ # Runs command on principle id: a change to what a member's entry says of it in MemberEntryChanges, any other
42
+ # here.
43
+ #: (String, String?, Hash[String, untyped]) -> untyped
44
+ def run(command, id, options)
45
+ changes = MemberEntryChanges::COMMANDS.key?(command)
46
+ return handed(MemberEntryChanges).call(command, required_id(id), options) if changes
47
+
48
+ method = COMMANDS[command] or unknown(command)
49
+ send(method, required_id(id), options)
50
+ end
51
+
36
52
  # command as the agent ran it on principle id, with member in place of the member id it gave, and its options
37
53
  # as given, each quoted for a shell and named as the agent typed it: a location by LOCATION_OPTIONS, any other,
38
54
  # such as --path or --role, by its own one-word name.
@@ -46,9 +62,17 @@ module Principles
46
62
 
47
63
  #: (String, Hash[String, untyped]) -> untyped
48
64
  def add_member(id, options)
65
+ return handed(PluginMemberAddition).add(id, options, justified(options)) if options.key?("plugin")
66
+
67
+ add_project_member(id, options)
68
+ end
69
+
70
+ # Adds a member from a project file, the map's own or a new one for the keeping principle.
71
+ #: (String, Hash[String, untyped]) -> untyped
72
+ def add_project_member(id, options)
49
73
  started = !@principles.mapped?(id)
50
74
  map = @principles.addable(id)
51
- member = located(options, { "path" => text(options["path"], "PATH") }).merge(played(options))
75
+ member = new_member(options)
52
76
  addition = handed(MemberAddition, map: map, member: member)
53
77
  updated = map.adding(member)
54
78
  write_map(updated) do |printed|
@@ -57,10 +81,28 @@ module Principles
57
81
  end
58
82
  end
59
83
 
60
- # The part a new member plays, and the check that enforces it when one is named.
84
+ # The new member the options name: its place in its file, its opening stored as AuthoredLocator says, the part it
85
+ # plays and any check.
86
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
87
+ def new_member(options)
88
+ member = located(options, { "path" => text(options["path"], "PATH") })
89
+ opening = Models::AuthoredLocator.new(@project, Models::Member.new(member).locator).stored.starting_at
90
+ (opening ? member.merge("starting_at" => opening) : member).merge(played(options))
91
+ end
92
+
93
+ # The part a new member plays, with the name and reason that justify it, each when given, as a plugin member
94
+ # stores them too.
95
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
96
+ def justified(options)
97
+ Models::MemberJustification.new(options.slice("name", "reason")).check
98
+ given = JUSTIFYING_OPTIONS.select { |field| options[field] }
99
+ { "role" => text(options["role"], "--role"), **given.to_h { [it, text(options[it], "--#{it}")] } }
100
+ end
101
+
102
+ # The part a project member plays, as justified, and the check that enforces it when one is named.
61
103
  #: (Hash[String, untyped]) -> Hash[String, untyped]
62
104
  def played(options)
63
- role = { "role" => text(options["role"], "--role") }
105
+ role = justified(options)
64
106
  options["check"] ? role.merge("check" => text(options["check"], "--check")) : role
65
107
  end
66
108
 
@@ -79,7 +121,7 @@ module Principles
79
121
  map = @principles.find(id)
80
122
  old = map.member(text(options["member"], "MEMBER"))
81
123
  member = located(options, { "path" => new_path(options, old) })
82
- moved = span(member)
124
+ moved = span(member).merge(member)
83
125
  write_map(map.moving(Models::Member.new(old).id, member)) do |printed|
84
126
  map_result.member_moved(printed, from: Models::Member.new(old).id, moved: moved)
85
127
  end
@@ -91,37 +133,6 @@ module Principles
91
133
  options["path"] ? text(options["path"], "--path") : old.fetch("path")
92
134
  end
93
135
 
94
- #: (String, Hash[String, untyped]) -> untyped
95
- def change_member_role(id, options)
96
- map = @principles.find(id)
97
- target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
98
- write_map(map.changing_role(target, text(options["role"], "--role"))) do |printed|
99
- map_result.member_replaced(printed, member: target, done: "Changed the role of #{target}.")
100
- end
101
- end
102
-
103
- # Names the command that enforces a member, which the audit asks the agent to run.
104
- #: (String, Hash[String, untyped]) -> untyped
105
- def change_member_check(id, options)
106
- map = @principles.find(id)
107
- target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
108
- check = text(options["check"], "--check")
109
- changed = map.changing_check(target, check)
110
- hidden = Models::Member.new(changed.member(target)).check_hidden_characters
111
- write_map(changed) { |printed| map_result.check_changed(printed, member: target, hidden: hidden) }
112
- end
113
-
114
- #: (String, Hash[String, untyped]) -> untyped
115
- def remove_member_check(id, options)
116
- map = @principles.find(id)
117
- target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
118
- write_map(map.removing_check(target)) do |printed|
119
- map_result.member_replaced(printed, member: target,
120
- done: "Removed the check of #{target}; the audit no longer asks for " \
121
- "its result.")
122
- end
123
- end
124
-
125
136
  #: (String, Hash[String, untyped]) -> untyped
126
137
  def remove_member(id, options)
127
138
  map = @principles.find(id)
@@ -0,0 +1,71 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "command"
5
+
6
+ module Principles
7
+ # Each runs one command: reads models, applies their rules and prints through a view.
8
+ # controllers/CLAUDE.md owns the boundary.
9
+ module Controllers
10
+ # The writes that change what an existing member's entry in the committed member map says of it, apart from where
11
+ # it is: the part it plays and the check that enforces it. MemberEntries runs each command and hands it here, so a
12
+ # near-miss member id is repaired as for every member command.
13
+ class MemberEntryChanges < Command
14
+ # Each command and the method that runs it.
15
+ COMMANDS = {
16
+ "change-member-role" => :change_member_role, "change-member-name" => :change_member_name,
17
+ "change-member-reason" => :change_member_reason,
18
+ "change-member-check" => :change_member_check,
19
+ "remove-member-check" => :remove_member_check
20
+ }.freeze #: Hash[String, Symbol]
21
+
22
+ #: (String, String, Hash[String, untyped]) -> untyped
23
+ def call(command, id, options) = send(COMMANDS.fetch(command), id, options)
24
+
25
+ private
26
+
27
+ #: (String, Hash[String, untyped]) -> untyped
28
+ def change_member_role(id, options) = change_field(id, options, "role")
29
+
30
+ # Renames a member for display; its id and key stay, since commands never find a member by its name.
31
+ #: (String, Hash[String, untyped]) -> untyped
32
+ def change_member_name(id, options) = change_field(id, options, "name")
33
+
34
+ # Rewrites why a member's carrier puts its principle in context, as an audit that shows the reason false asks.
35
+ #: (String, Hash[String, untyped]) -> untyped
36
+ def change_member_reason(id, options) = change_field(id, options, "reason")
37
+
38
+ # Replaces what the member's entry says in field with the value its option of that name gives.
39
+ #: (String, Hash[String, untyped], String) -> untyped
40
+ def change_field(id, options, field)
41
+ map = @principles.find(id)
42
+ target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
43
+ value = text(options[field], "--#{field}")
44
+ write_map(map.saying(target, field, value)) do |printed|
45
+ map_result.entry_changed(printed, member: target, field: field, value: value)
46
+ end
47
+ end
48
+
49
+ # Names the command that enforces a member, which the audit asks the agent to run.
50
+ #: (String, Hash[String, untyped]) -> untyped
51
+ def change_member_check(id, options)
52
+ map = @principles.find(id)
53
+ target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
54
+ check = text(options["check"], "--check")
55
+ changed = map.changing_check(target, check)
56
+ hidden = Models::Member.new(changed.member(target)).check_hidden_characters
57
+ write_map(changed) { |printed| map_result.check_changed(printed, member: target, hidden: hidden) }
58
+ end
59
+
60
+ #: (String, Hash[String, untyped]) -> untyped
61
+ def remove_member_check(id, options)
62
+ map = @principles.find(id)
63
+ target = Models::Member.new(map.member(text(options["member"], "MEMBER"))).id
64
+ write_map(map.removing_check(target)) do |printed|
65
+ map_result.member_replaced(printed, done: "Removed the check of #{target}; the audit no longer asks for " \
66
+ "its result.")
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -4,9 +4,11 @@
4
4
  require_relative "command"
5
5
  require_relative "members_a_commit_changed"
6
6
  require_relative "../models/member_problems"
7
+ require_relative "../models/members_in_logged_requests"
7
8
  require_relative "../models/problem_report"
8
9
  require_relative "../views/record_waiting_on_an_upgrade"
9
10
  require_relative "../views/problem_result"
11
+ require_relative "../views/members_too_short_to_scan"
10
12
  require_relative "../views/problem_lines"
11
13
  require_relative "../views/first_audit_line"
12
14
 
@@ -77,9 +79,9 @@ module Principles
77
79
  lines = view.short(report, nothing_changed: Views::ProblemResult::NOTHING_CHANGED,
78
80
  assessed_change: problems.assessed_change?,
79
81
  never_assessed: problems.never_assessed, names_a_command:)
80
- return lines unless session_start
82
+ return view.at_session_start(lines, changed: problems.assessed_changes) if session_start
81
83
 
82
- view.at_session_start(lines, changed: problems.assessed_changes)
84
+ view.saying_nothing_changed(view.explaining_rows(lines, report), members: report.fetch("counts").values.sum)
83
85
  end
84
86
 
85
87
  # list-member-problems' JSON result for map id, or every map, without the files it wrote.
@@ -121,10 +123,28 @@ module Principles
121
123
  facts = Views::ProblemFacts.new(not_read: @project.unread_older_files,
122
124
  no_baseline_files: problems.files_to_commit(@principles),
123
125
  audit_files: problems.audit_files_to_commit(@principles),
124
- acknowledgeable: problems.acknowledgeable_together(
125
- except: waiting.map(&:principle)
126
- ), waiting:)
127
- Views::ProblemResult.new(printing).checked_naming_commands(report, facts)
126
+ acknowledgeable: offered(problems, waiting), waiting:)
127
+ result, names_a_command = Views::ProblemResult.new(printing).checked_naming_commands(report, facts)
128
+ nothing_changed = Views::ProblemResult::NOTHING_CHANGED
129
+ Views::MembersTooShortToScan.new(printing, too_short).added_to(result, names_a_command, nothing_changed:)
130
+ end
131
+
132
+ # While requests are logged here, each member of the project's own files too short to find in one, by its
133
+ # principle, id and the move-member options that widen it; none otherwise, since only the scan needs them.
134
+ #: () -> Array[Hash[String, String]]
135
+ def too_short
136
+ return [] unless @project.request_logging.in_use?
137
+
138
+ Models::MembersInLoggedRequests.too_short_in(@project).map do |member|
139
+ { "principle" => member.principle, "id" => member.id, "move" => member.move_placeholders }
140
+ end
141
+ end
142
+
143
+ # The one-member audits problems offers, but for the principles waiting on an upgrade, whose audits wait.
144
+ #: (Models::ProblemReport, Array[Views::RecordWaitingOnAnUpgrade]) -> Views::AcknowledgementsOffered
145
+ def offered(problems, waiting)
146
+ offer = problems.acknowledgements(except: waiting.map(&:principle))
147
+ Views::AcknowledgementsOffered.new(offer.together, last: offer.last)
128
148
  end
129
149
  end
130
150
  end
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "command"
5
+ require_relative "../models/plugin_reference"
5
6
  require_relative "../views/members_a_commit_changed"
6
7
 
7
8
  module Principles
@@ -28,7 +29,7 @@ module Principles
28
29
  changed = @history.commits_brought_in(after).changed_by(members)
29
30
  return Views::MembersACommitChanged::NOTHING if changed.empty?
30
31
 
31
- changed_lines(event, changed, others: members.size - changed.size)
32
+ changed_lines(event, changed, others: still_listed(members - changed))
32
33
  rescue Error => e
33
34
  return Views::MembersACommitChanged::NOTHING unless @history.touched_since?(after, @principles.readable_paths)
34
35
 
@@ -37,16 +38,24 @@ module Principles
37
38
 
38
39
  private
39
40
 
40
- # The hook's output naming changed, the members the commits changed, beside others still listed, with the wait
41
- # of each of their principles whose record a later copy wrote, which says why their audits wait.
42
- #: (String, Array[Hash[String, untyped]], others: Integer) -> Views::Lines
41
+ # The hook's output naming changed, the members the commits changed, beside others still listed, those in a
42
+ # plugin apart, since no commit changes them, with the wait of each of their principles whose record a later copy
43
+ # wrote, which says why their audits wait.
44
+ #: (String, Array[Hash[String, untyped]], others: Views::MembersACommitChanged::StillListed) -> Views::Lines
43
45
  def changed_lines(event, changed, others:)
44
46
  waits = changed.map { it.fetch("principle") }.uniq.filter_map { waiting_on_an_upgrade(it) }
45
47
  view.changed(event, changed, others:, waits:)
46
48
  end
47
49
 
50
+ # The other members still listed, counted apart when a plugin holds them, which no commit changes.
51
+ #: (Array[Hash[String, untyped]]) -> Views::MembersACommitChanged::StillListed
52
+ def still_listed(others)
53
+ in_plugins, from_commits = others.partition { Models::PluginReference.in(it.fetch("id")) }
54
+ Views::MembersACommitChanged::StillListed.new(from_commits.size, in_plugins.size)
55
+ end
56
+
48
57
  #: () -> Views::MembersACommitChanged
49
- def view = Views::MembersACommitChanged.new(invocation, skill: @tool.runs_from.principles_skill_in_this_session?)
58
+ def view = Views::MembersACommitChanged.new(invocation)
50
59
  end
51
60
  end
52
61
  end