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
@@ -0,0 +1,92 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "psych"
5
+ require_relative "outline_section"
6
+ require_relative "text_within"
7
+ require_relative "without_prose"
8
+
9
+ module Principles
10
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
+ module Models
12
+ # A CI workflow's text as its outline reads it: a section per job, headed by its id and name, its items the job's
13
+ # steps, each by its name or else what it runs or uses. A rule a project enforces in CI is named there, and a
14
+ # survey reading Markdown headings alone never found it. The YAML is read as nodes, which keep each job's lines
15
+ # and leave a key such as `on` a string.
16
+ class WorkflowJobs
17
+ include WithoutProse
18
+
19
+ # A GitHub Actions workflow file, the kind of text this reads.
20
+ PATH = %r{(?:\A|/)\.github/workflows/[^/]+\.ya?ml\z}
21
+ # What a step without a name is known by, in the order looked for.
22
+ STEP_KEYS = %w[run uses].freeze
23
+
24
+ #: (String) -> void
25
+ def initialize(text)
26
+ @text = text
27
+ freeze
28
+ end
29
+
30
+ # Each job as a section, spanning the lines from its id to its last; none when the YAML does not parse, so the
31
+ # file is listed by its path and size alone.
32
+ #: () -> Array[OutlineSection]
33
+ def sections
34
+ document = Psych.parse(@text) or return []
35
+
36
+ pairs(value(document.root, "jobs")).map do |id, job|
37
+ OutlineSection.new(heading: heading(id.value, value(job, "name")), items: steps(value(job, "steps")),
38
+ first_line: id.start_line + 1, last_line: job.end_line)
39
+ end
40
+ rescue Psych::SyntaxError
41
+ []
42
+ end
43
+
44
+ private
45
+
46
+ #: (String, Psych::Nodes::Node?) -> String
47
+ def heading(id, name) = name.is_a?(Psych::Nodes::Scalar) ? "job #{id}: #{name.value}" : "job #{id}"
48
+
49
+ # Each step as an item, by its name, or else by the first line of what it runs or the action it uses, on the line
50
+ # its step starts.
51
+ #: (Psych::Nodes::Node?) -> Array[OutlineItem]
52
+ def steps(sequence)
53
+ return [] unless sequence.is_a?(Psych::Nodes::Sequence)
54
+
55
+ sequence.children.filter_map do |step|
56
+ text = step_text(step) or next
57
+
58
+ OutlineItem.new("- #{TextWithin.new(text, at_most: OutlineSection::ITEM_CHARACTERS).by_words}",
59
+ line: step.start_line + 1)
60
+ end
61
+ end
62
+
63
+ # A step by its name, or else by the first line of what it runs or the action it uses; nil with none of them.
64
+ #: (Psych::Nodes::Node) -> String?
65
+ def step_text(step)
66
+ key = STEP_KEYS.find { |each| scalar(step, each) }
67
+ scalar(step, "name") || (key && "#{key}: #{scalar(step, key).to_s.lines.first.to_s.strip}")
68
+ end
69
+
70
+ # The text of a mapping's scalar value under key; nil when it has none.
71
+ #: (Psych::Nodes::Node?, String) -> String?
72
+ def scalar(mapping, key)
73
+ found = value(mapping, key)
74
+ found.value if found.is_a?(Psych::Nodes::Scalar)
75
+ end
76
+
77
+ # A mapping's value node under key; nil when the node is no mapping or lacks the key.
78
+ #: (Psych::Nodes::Node?, String) -> Psych::Nodes::Node?
79
+ def value(mapping, key) = pairs(mapping).find { |found, _| found.value == key }&.last
80
+
81
+ # A mapping's keys with their values, its keys scalars; none for any other node.
82
+ #: (Psych::Nodes::Node?) -> Array[[Psych::Nodes::Scalar, Psych::Nodes::Node]]
83
+ def pairs(mapping)
84
+ return [] unless mapping.is_a?(Psych::Nodes::Mapping)
85
+
86
+ mapping.children.each_slice(2).filter_map do |key, found|
87
+ [key, found] if key.is_a?(Psych::Nodes::Scalar) && found
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,27 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation_options"
5
+
6
+ module Principles
7
+ # The options choosing which form show-members-in-logged-requests prints, --short, --places or --member, and what
8
+ # is wrong with them as given, which CommandLine refuses as a usage error.
9
+ class ShowMembersInLoggedRequestsOptions
10
+ #: (InvocationOptions) -> void
11
+ def initialize(options)
12
+ @places = !options.value("places").nil? #: bool
13
+ @short = !options.value("short").nil? #: bool
14
+ @member = !options.value("member").nil? #: bool
15
+ freeze
16
+ end
17
+
18
+ # What is wrong with the options as given, or nil when they fit.
19
+ #: () -> String?
20
+ def fault
21
+ return "--member lists the named members' places, which --short does not print; give one" if @member && @short
22
+ return "--member lists the named members' places, and --places every member's; give one" if @member && @places
23
+
24
+ "--places lists every place a member was seen, which --short does not print; give one" if @places && @short
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation_options"
5
+
6
+ module Principles
7
+ # The options choosing what show-principle prints, every member or the one --member names, and what is wrong with
8
+ # them as given, which CommandLine refuses as a usage error.
9
+ class ShowPrincipleOptions
10
+ COMMAND = "show-principle"
11
+ # How a refusal of several --member options says to repair it.
12
+ ONE_OR_NONE = "give one, or none for every member"
13
+
14
+ #: (InvocationOptions) -> void
15
+ def initialize(options)
16
+ @members = (options.value("member") || []).size #: Integer
17
+ @loads = !options.value("loads").nil? #: bool
18
+ freeze
19
+ end
20
+
21
+ # What is wrong with the options as given, or nil when they fit: --member prints one member, so a second would be
22
+ # dropped without a word, and so would --loads, which adds to the whole map.
23
+ #: () -> String?
24
+ def fault
25
+ return "#{COMMAND} prints one member, but --member was given #{@members} times; #{ONE_OR_NONE}" if @members > 1
26
+ return unless @loads && @members == 1
27
+
28
+ "--loads adds when each member's file loads to the whole map, which --member does not print; drop --loads to " \
29
+ "see one member, or --member to see every member's loads"
30
+ end
31
+ end
32
+ end
@@ -3,9 +3,9 @@
3
3
 
4
4
  module Principles
5
5
  # The next production release, as major.minor.patch. A production build is versioned with this alone.
6
- RELEASE = "0.1.3"
6
+ RELEASE = "0.1.5"
7
7
  # The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
8
8
  # packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
9
9
  # Data::RunningVersion reads the commit this tool runs from instead.
10
- BUILT_VERSION = "0.1.3" #: String?
10
+ BUILT_VERSION = "0.1.5" #: String?
11
11
  end
@@ -17,43 +17,62 @@ module Principles
17
17
  freeze
18
18
  end
19
19
 
20
- # The acknowledgement of each of member_ids was accepted, and file holds them all.
21
- #: (principle_id: String, member_ids: Array[String], file: String) -> AnsweredRequest
22
- def several_acknowledged(principle_id:, member_ids:, file:)
20
+ # The acknowledgement of each of member_ids was accepted, and file holds them all; open_findings are the ids of
21
+ # the findings the last audit left open on them, which it leaves open.
22
+ #: (principle_id: String, member_ids: Array[String], file: String, ?open_findings: Array[String])
23
+ #| -> AnsweredRequest
24
+ def several_acknowledged(principle_id:, member_ids:, file:, open_findings: [])
23
25
  AnsweredRequest.new(
24
26
  "status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
25
27
  "files_to_commit" => [file],
26
28
  "next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
27
- "This no longer lists them: " \
29
+ "#{still_open(principle_id, open_findings)}This no longer lists them: " \
28
30
  "#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
29
31
  )
30
32
  end
31
33
 
32
34
  # The acknowledgement of each of member_ids was accepted for every principle that maps it, each principle's in its
33
- # file, under its id in files.
34
- #: (member_ids: Array[String], files: Hash[String, String]) -> AnsweredRequest
35
- def across_acknowledged(member_ids:, files:)
35
+ # file, under its id in files; open_findings are, under a principle's id, the ids of the findings its last audit
36
+ # left open on them, which it leaves open.
37
+ #: (member_ids: Array[String], files: Hash[String, String], ?open_findings: Hash[String, Array[String]])
38
+ #| -> AnsweredRequest
39
+ def across_acknowledged(member_ids:, files:, open_findings: {})
36
40
  AnsweredRequest.new(
37
41
  "status" => "acknowledged", "principle_ids" => files.keys, "member_ids" => member_ids,
38
42
  "files_to_commit" => files.values,
39
43
  "next_action" => "Commit #{ProseList.new(files.values)}. #{ProseList.new(member_ids)} read as judged until " \
40
- "each is edited again.\nThis no longer lists them: " \
44
+ "each is edited again.\n#{open_findings.map { |id, ids| still_open(id, ids) }.join}" \
45
+ "This no longer lists them: " \
41
46
  "#{@invocation.in_project("list-member-problems", usage: "--short")}"
42
47
  )
43
48
  end
44
49
 
45
- # The acknowledgement was accepted and file holds it.
46
- #: (principle_id: String, member_id: String, file: String) -> AnsweredRequest
47
- def acknowledged(principle_id:, member_id:, file:)
50
+ # The acknowledgement was accepted and file holds it; open_findings are the ids of the findings the last audit
51
+ # left open on the member, which it leaves open.
52
+ #: (principle_id: String, member_id: String, file: String, ?open_findings: Array[String]) -> AnsweredRequest
53
+ def acknowledged(principle_id:, member_id:, file:, open_findings: [])
48
54
  fields = {
49
55
  "status" => "acknowledged", "principle_id" => principle_id, "member_ids" => [member_id],
50
56
  "files_to_commit" => [file],
51
57
  "next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
52
- "This no longer lists it: " \
58
+ "#{still_open(principle_id, open_findings)}This no longer lists it: " \
53
59
  "#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
54
60
  }
55
61
  AnsweredRequest.new(fields)
56
62
  end
63
+
64
+ private
65
+
66
+ # The line saying that open_findings stay open, since only a full audit of principle_id decides one, with the
67
+ # command that starts it; nothing when there are none.
68
+ #: (String, Array[String]) -> String
69
+ def still_open(principle_id, open_findings)
70
+ return "" if open_findings.empty?
71
+
72
+ stays, each = open_findings.one? ? %w[stays it] : %w[stay each]
73
+ "#{ProseList.new(open_findings)} #{stays} open: an acknowledgement decides no finding, and the next full " \
74
+ "audit decides #{each}: #{@invocation.in_project("start-audit", principle_id)}\n"
75
+ end
57
76
  end
58
77
  end
59
78
  end
@@ -24,15 +24,17 @@ module Principles
24
24
  # what the request's context shows beside it, such as the record's findings on the member; and under
25
25
  # :placeholders the text the template prints in each field the agent writes. What the agent judges is under
26
26
  # context, the question first, so an agent reading the request's head finds what it is asked before the text.
27
- #: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
28
- def request(request_id:, principle_id:, asked:)
27
+ # answer_file is the file its next_action saves the answer in, as in each request below.
28
+ #: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped], answer_file: String)
29
+ #| -> Hash[String, untyped]
30
+ def request(request_id:, principle_id:, asked:, answer_file:)
29
31
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
30
32
  "context" => { "principle_id" => principle_id,
31
33
  "question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning"),
32
34
  **asked.fetch(:change).to_h, **asked.fetch(:context) },
33
35
  "response_template" => answer_to_fill(request_id:, asked:),
34
36
  "answer_with" => @invocation.submit_answer(request_id),
35
- "next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:) }
37
+ "next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:, file: answer_file) }
36
38
  end
37
39
 
38
40
  # The answer to the request request_id names, to fill: the request prints it as response_template, and
@@ -50,15 +52,17 @@ module Principles
50
52
  # change, the context its own request shows beside it and the placeholders its template prints, as one member's
51
53
  # request holds them, under context.members and the template's members in the order the agent named them. The
52
54
  # question leads the context, so an agent reading the request's head finds what it is asked before the members.
53
- #: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
54
- def several_request(request_id:, principle_id:, members:)
55
+ #: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]], answer_file: String)
56
+ #| -> Hash[String, untyped]
57
+ def several_request(request_id:, principle_id:, members:, answer_file:)
55
58
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
56
59
  "context" => { "principle_id" => principle_id,
57
60
  "question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning"),
58
61
  "members" => shown(members) },
59
62
  "response_template" => several_to_fill(request_id:, members:),
60
63
  "answer_with" => @invocation.submit_answer(request_id),
61
- "next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id }, request_id:) }
64
+ "next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id },
65
+ request_id:, file: answer_file) }
62
66
  end
63
67
 
64
68
  # The answer to the request for several members request_id names, to fill: its basis names each member, and
@@ -74,15 +78,16 @@ module Principles
74
78
  # judged once for every principle that maps it. keeping_deferred names each principle whose members keep a
75
79
  # deferred finding, which the request says only a full audit resolves. The question leads the context, as in
76
80
  # one principle's requests.
77
- #: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]],
81
+ #: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]], answer_file: String,
78
82
  #| ?keeping_deferred: Array[String]) -> Hash[String, untyped]
79
- def across_request(request_id:, principles:, keeping_deferred: [])
83
+ def across_request(request_id:, principles:, answer_file:, keeping_deferred: [])
80
84
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
81
85
  "context" => { "question" => across_question, "principles" => shown_once(principles),
82
86
  **deferred_findings_kept(keeping_deferred) },
83
87
  "response_template" => across_to_fill(request_id:, principles:),
84
88
  "answer_with" => @invocation.submit_answer(request_id),
85
- "next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles), request_id:) }
89
+ "next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles),
90
+ request_id:, file: answer_file) }
86
91
  end
87
92
 
88
93
  # The answer to the request for the members several principles map, to fill: its basis names each principle and
@@ -121,10 +126,10 @@ module Principles
121
126
  def named_entry(asked, position) = [asked.fetch(:change).member_id, named(asked.fetch(:placeholders), position)]
122
127
 
123
128
  # How to fill the answer to request_id, acknowledging member_ids of principle_ids: saved bare from
124
- # start-audit --as template to a file the agent edits.
125
- #: (Array[String], Array[String], request_id: String) -> String
126
- def to_fill(principle_ids, member_ids, request_id:)
127
- AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:)
129
+ # start-audit --as template to file, which the agent edits.
130
+ #: (Array[String], Array[String], request_id: String, file: String) -> String
131
+ def to_fill(principle_ids, member_ids, request_id:, file:)
132
+ AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:, file:)
128
133
  end
129
134
 
130
135
  # Each member the principles' requests ask about, once, in the order they ask.
@@ -0,0 +1,55 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation"
5
+ require_relative "member_change_since_baseline"
6
+
7
+ module Principles
8
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
9
+ module Views
10
+ # An acknowledgement's answer to fill as start-audit --member --as template prints it alone, where no request
11
+ # stands beside it: the answer its request prints as response_template, with what that request shows beside it
12
+ # for the agent to read, each member's role before its own fields and answer_with, the command that submits the
13
+ # file the request's next_action saves it in. The answer reads neither.
14
+ class AcknowledgementTemplateAlone
15
+ #: (Invocation) -> void
16
+ def initialize(invocation)
17
+ @invocation = invocation
18
+ freeze
19
+ end
20
+
21
+ # answer, whose members asked asks about, each as its member's part of the request holds it, with each role,
22
+ # submitted from answer_file, the file the request's next_action saves it in.
23
+ #: (Hash[String, untyped], Array[Hash[Symbol, untyped]], answer_file: String) -> Hash[String, untyped]
24
+ def of(answer, asked, answer_file:)
25
+ changes = asked.map { it.fetch(:change) } #: Array[MemberChangeSinceBaseline]
26
+ printed(answer, changes.to_h { [it.member_id, { "role" => it.role }] }, answer_file)
27
+ end
28
+
29
+ # answer for the members several principles map, each principles' members as their part of the request holds
30
+ # them: as of gives it, but with each member's roles, by the principle mapping it with each.
31
+ #: (Hash[String, untyped], Hash[String, Array[Hash[Symbol, untyped]]], answer_file: String)
32
+ #| -> Hash[String, untyped]
33
+ def across(answer, principles, answer_file:)
34
+ roles = {} #: Hash[String, Hash[String, String]]
35
+ principles.each do |principle_id, asked|
36
+ asked.each do |member|
37
+ change = member.fetch(:change) #: MemberChangeSinceBaseline
38
+ (roles[change.member_id] ||= {})[principle_id] = change.role
39
+ end
40
+ end
41
+ printed(answer, roles.transform_values { { "roles" => it } }, answer_file)
42
+ end
43
+
44
+ private
45
+
46
+ # answer with each member's read_only fields before its own, and answer_with, submitting answer_file, after them.
47
+ #: (Hash[String, untyped], Hash[String, Hash[String, untyped]], String) -> Hash[String, untyped]
48
+ def printed(answer, read_only, answer_file)
49
+ members = answer.fetch("members").to_h { |id, entry| [id, { **read_only.fetch(id), **entry }] }
50
+ submit = @invocation.submit_answer(answer.fetch("request_id"), file: answer_file)
51
+ { **answer, "members" => members, "answer_with" => submit }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,54 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation"
5
+ require_relative "problem_lines"
6
+ require_relative "shell_word"
7
+ require_relative "../prose_list"
8
+
9
+ module Principles
10
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
11
+ module Views
12
+ # The one-member audits list-member-problems offers: by the principles that acknowledge them together, in the
13
+ # order the model gives, the changed members each acknowledgement takes in, one command for each set, and those
14
+ # whose check is this tool's own list-member-problems --short, which the model puts last.
15
+ class AcknowledgementsOffered
16
+ # groups gives, for each set of principle ids, the members they acknowledge together; last, the members whose
17
+ # check is this tool's own --short.
18
+ #: (Hash[Array[String], Array[String]], ?last: Array[String]) -> void
19
+ def initialize(groups, last: [])
20
+ @groups = groups
21
+ @last = last
22
+ freeze
23
+ end
24
+
25
+ NONE = new({}) #: AcknowledgementsOffered
26
+
27
+ # The members an acknowledgement takes in for principle id.
28
+ #: (String) -> Array[String]
29
+ def members_of(id) = @groups.select { |ids, _| ids.include?(id) }.values.flatten
30
+
31
+ # Each acknowledgement's command, filled and shell-quoted so the agent types no id, through invocation; a set
32
+ # holding a member in last after a line asking to acknowledge it last, since its check exits as --short does
33
+ # while it lists a member the answer leaves out.
34
+ #: (Invocation) -> Array[String]
35
+ def lines(invocation)
36
+ @groups.flat_map do |ids, members|
37
+ line = invocation.listed_in_project("start-audit", ids, options: members.flat_map { ["--member", it] })
38
+ own = members & @last
39
+ own.empty? ? [line] : [last_line(own), line]
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ # The line asking to acknowledge own, members whose check is this tool's own --short, after the others.
46
+ #: (Array[String]) -> String
47
+ def last_line(own)
48
+ "Acknowledge #{ProseList.new(own.map { ShellWord.new(it).to_s })} last: its check, list-member-problems " \
49
+ "--short, exits #{ProblemLines::CHANGED} while it lists a member this acknowledgement leaves out, so first " \
50
+ "acknowledge or audit, and commit, each member listed that it leaves out."
51
+ end
52
+ end
53
+ end
54
+ end
@@ -3,16 +3,28 @@
3
3
 
4
4
  require_relative "lines_shared_with_member"
5
5
  require_relative "consecutive_sections_elsewhere"
6
+ require_relative "whole_file_elsewhere"
7
+ require_relative "member_sets_overlap"
6
8
 
7
9
  module Principles
8
10
  module Views
9
- # The member just added: its id, current lines and check, beside its shared/consecutive location facts.
11
+ # The member just added: its id, current lines and check, beside its shared-line facts and the facts of other
12
+ # maps it asks the agent to judge, each printed only when it has some.
10
13
  class AddedMember
11
- #: (Hash[String, untyped], shared: LinesSharedWithMember, consecutive: ConsecutiveSectionsElsewhere) -> void
12
- def initialize(added, shared:, consecutive:)
13
- @added = added.merge(shared.to_h).merge(consecutive.to_h) #: Hash[String, untyped]
14
+ # What the agent decides when other principles hold the new member's file whole or a nearly matching member set,
15
+ # asked once however many of those cues fire.
16
+ SCOPE_OR_JOIN = "Should each hold only the passages that carry it (move-member with " \
17
+ "--section or --starting-at), or are they one principle (join the maps: add one map's " \
18
+ "members to the other, then remove-principle)? " #: String
19
+
20
+ #: (Hash[String, untyped], shared: LinesSharedWithMember,
21
+ #| other_maps: Array[ConsecutiveSectionsElsewhere | WholeFileElsewhere | MemberSetsOverlap])
22
+ #| -> void
23
+ def initialize(added, shared:, other_maps:)
24
+ facts = other_maps.reduce(added.merge(shared.to_h)) { |merged, each| merged.merge(each.to_h) }
25
+ @added = facts #: Hash[String, untyped]
14
26
  @shared = shared
15
- @consecutive = consecutive
27
+ @other_maps = other_maps
16
28
  freeze
17
29
  end
18
30
 
@@ -25,11 +37,15 @@ module Principles
25
37
  # The same location/remapping opening precedes the map's own after-add guidance.
26
38
  #: () -> String
27
39
  def opening
28
- "#{span}#{@shared.note}#{@consecutive.note}Add the next member the same way. "
40
+ "#{span}#{@shared.note}#{@other_maps.map(&:note).join}#{SCOPE_OR_JOIN if scope_or_join?}" \
41
+ "Add the next member the same way. "
29
42
  end
30
43
 
31
44
  private
32
45
 
46
+ #: () -> bool
47
+ def scope_or_join? = @other_maps.any?(&:asks_scope_or_join?)
48
+
33
49
  # The lines a member spans, said so that a passage cut short shows; it ends with a space.
34
50
  #: () -> String
35
51
  def span
@@ -24,16 +24,16 @@ module Principles
24
24
  #: (String, request_id: String) -> String
25
25
  def assessment(principle_id, request_id:)
26
26
  line(@invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::TEMPLATE]),
27
- request_id:)
27
+ request_id:, file: @invocation.answer_file(principle_id, "assessment"))
28
28
  end
29
29
 
30
30
  # The line for acknowledging member_ids of principle_ids, whose answer start-audit --member --as template prints
31
- # bare.
32
- #: (Array[String], Array[String], request_id: String) -> String
33
- def acknowledgement(principle_ids, member_ids, request_id:)
31
+ # bare, to save in file.
32
+ #: (Array[String], Array[String], request_id: String, file: String) -> String
33
+ def acknowledgement(principle_ids, member_ids, request_id:, file:)
34
34
  named = member_ids.flat_map { ["--member", it] }
35
35
  line(@invocation.listed_in_project("start-audit", principle_ids, options: [*named, "--as", "template"]),
36
- request_id:)
36
+ request_id:, file:)
37
37
  end
38
38
 
39
39
  # The line for a decision on principle_id's open findings, whose answer start-audit --open-findings --as template
@@ -41,21 +41,21 @@ module Principles
41
41
  #: (String, request_id: String) -> String
42
42
  def open_findings(principle_id, request_id:)
43
43
  line(@invocation.in_project("start-audit", principle_id, options: %w[--open-findings --as template]),
44
- request_id:)
44
+ request_id:, file: @invocation.answer_file(principle_id, "deciding"))
45
45
  end
46
46
 
47
47
  # The line for an open correction, whose answer show-open-correction prints bare, of which only the
48
- # dispositions are the agent's to fill.
49
- #: (String, request_id: String) -> String
50
- def correction(principle_id, request_id:)
51
- line(@invocation.in_project("show-open-correction", principle_id), request_id:, what: "only its dispositions")
48
+ # dispositions are the agent's to fill, to save in file.
49
+ #: (String, request_id: String, file: String) -> String
50
+ def correction(principle_id, request_id:, file:)
51
+ line(@invocation.in_project("show-open-correction", principle_id), request_id:, file:,
52
+ what: "only its dispositions")
52
53
  end
53
54
 
54
- # The line for the answer request_id names, which the printed command save prints bare; what is the part of it
55
- # the agent fills.
56
- #: (String, request_id: String, ?what: String) -> String
57
- def line(save, request_id:, what: "it")
58
- file = @invocation.answer_file(request_id)
55
+ # The line for the answer request_id names, saved in file, which the printed command save prints bare; what is
56
+ # the part of it the agent fills.
57
+ #: (String, request_id: String, file: String, ?what: String) -> String
58
+ def line(save, request_id:, file:, what: "it")
59
59
  Prompts.text("answer-any-judgement-request/fill-the-answer-in-a-file",
60
60
  save: "#{save} > #{ShellWord.new(file)}", what:,
61
61
  answer_with: @invocation.submit_answer(request_id, file:))
@@ -11,19 +11,23 @@ module Principles
11
11
  # request shows of each, the template entry each starts with, and what they carry that the request explains.
12
12
  class AssessedMembers
13
13
  # What the request shows of each member.
14
- SHOWN = %w[id role first_line last_line check check_since_last_audit check_hidden_characters
15
- acknowledged_since_last_audit carried_forward open_finding_ids judge_because moved_from read_the_change
16
- mapped_elsewhere].freeze #: Array[String]
14
+ SHOWN = %w[name id role reason carrier first_line last_line source check check_since_last_audit
15
+ check_hidden_characters acknowledged_since_last_audit carried_forward open_finding_ids judge_because
16
+ moved_from read_the_change changed_lines mapped_elsewhere].freeze #: Array[String]
17
17
 
18
18
  # reviewed_check_placeholders is the text a checked member's template prints in each field it may leave as
19
19
  # printed to give none, for a check reviewed before it runs; unchanged_check_placeholders, for one the
20
20
  # last audit ran.
21
21
  # assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back, its
22
22
  # %<id>s filled with the member's id, so each slot's is its own and one edit fills one slot.
23
+ # carrier_checks is the check for each carrier kind the members are in, as CarrierChecks prints them.
23
24
  #: (Array[Hash[String, untyped]], reviewed_check_placeholders: Hash[String, String],
24
- #| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String) -> void
25
- def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:)
25
+ #| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String,
26
+ #| ?carrier_checks: Hash[String, untyped]) -> void
27
+ def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:,
28
+ carrier_checks: {})
26
29
  @assessment_placeholder = assessment_placeholder
30
+ @carrier_checks = carrier_checks
27
31
  @members = members
28
32
  @reviewed_check_placeholders = reviewed_check_placeholders
29
33
  @unchanged_check_placeholders = unchanged_check_placeholders
@@ -32,7 +36,8 @@ module Principles
32
36
 
33
37
  # What the request shows of a carried member no flag fires on: what names it and its check, whose result
34
38
  # the template still asks for, and of its carried assessment only its dates and flags.
35
- COMPACT = %w[id role check check_since_last_audit check_hidden_characters carried_forward].freeze #: Array[String]
39
+ COMPACT = %w[name id role reason carrier source check check_since_last_audit check_hidden_characters
40
+ carried_forward].freeze #: Array[String]
36
41
  # What a compact member shows of its carried assessment.
37
42
  CARRIED_COMPACTLY = %w[assessed_at observed_at observed_at_from_assessed_at evidence_changed
38
43
  file_changed_outside_member].freeze #: Array[String]
@@ -49,6 +54,11 @@ module Principles
49
54
  end
50
55
  end
51
56
 
57
+ # The check for each carrier kind the members are in, under carrier_checks, which the request prints beside
58
+ # them, outside the question a record digests; nothing when there are none.
59
+ #: () -> Hash[String, Hash[String, untyped]]
60
+ def carrier_checks = @carrier_checks.empty? ? {} : { "carrier_checks" => @carrier_checks }
61
+
52
62
  # What the template printed alone says of the checks before its members, since it has no context to show it in:
53
63
  # the carried members whose template entry in templates still asks for a check_result, under
54
64
  # carried_checks_to_run, named before the members so a reader skipping carried markers still runs each, and how
@@ -70,7 +80,7 @@ module Principles
70
80
 
71
81
  # How to run and report the checks of each standing, once, with the ids of the members it is for, under
72
82
  # shared_check_instructions, whose own lines check_instructions adds; nothing when none has a check.
73
- #: () -> Hash[String, Array[Hash[String, untyped]]]
83
+ #: () -> Hash[String, Hash[String, untyped]]
74
84
  def shared_check_instructions
75
85
  checks = @members.filter_map { |member| check_template(member)&.then { [member.fetch("id"), it] } }
76
86
  return {} if checks.empty?
@@ -150,10 +160,11 @@ module Principles
150
160
  #: (Hash[String, untyped]) -> Hash[String, untyped]
151
161
  def carried(member) = { "member_id" => member.fetch("id"), "carried_forward" => true }
152
162
 
163
+ # A fresh member's slot, naming why it is judged afresh, so the template printed alone says so too.
153
164
  #: (Hash[String, untyped]) -> Hash[String, untyped]
154
165
  def fresh(member)
155
166
  id = member.fetch("id")
156
- { "member_id" => id, "assessment" => format(@assessment_placeholder, id:),
167
+ { "member_id" => id, **member.slice("judge_because"), "assessment" => format(@assessment_placeholder, id:),
157
168
  "delivery" => "not_observed", "evidence" => member.fetch("evidence") }
158
169
  end
159
170
  end