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
@@ -2,8 +2,10 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "../prose_list"
5
+ require_relative "invocation"
5
6
  require_relative "member_lines_beside_text"
6
7
  require_relative "printed_json"
8
+ require_relative "prompts"
7
9
 
8
10
  module Principles
9
11
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
@@ -15,18 +17,93 @@ module Principles
15
17
  # What starts a member's part name, keeping member ids apart from the context's keys.
16
18
  MEMBER = "members/" #: String
17
19
 
20
+ # What starts the name of a part holding one member's text alone, apart from its member part.
21
+ TEXT = "member_text/" #: String
22
+
18
23
  # The part that lists every other part, so the agent sizes its reads before it makes them.
19
24
  INDEX = "index" #: String
20
25
 
26
+ # The part listing the id of each member this audit judges, one a line, for the agent to read their parts by.
27
+ JUDGED = "judged_members" #: String
28
+
21
29
  # The part holding the answer to fill, as the request prints it beside its context.
22
30
  TEMPLATE = "response_template" #: String
23
31
 
32
+ # Each member's lines now, by id, one string each, as the request's parts print them and the whole request does
33
+ # not: in the member's part, or, for each member apart names, in a part of its own.
34
+ class MemberTexts
35
+ #: (Hash[String, Array[String]], ?apart: TextsApart?) -> void
36
+ def initialize(lines, apart: nil)
37
+ @lines = lines
38
+ @apart = apart
39
+ freeze
40
+ end
41
+
42
+ # The id of each member whose text prints in a part of its own.
43
+ #: () -> Array[String]
44
+ def apart = @apart&.ids || []
45
+
46
+ # The lines the part of the member id prints, or nil when none are given for it.
47
+ #: (String) -> Array[String]?
48
+ def beside(id) = @lines[id]
49
+
50
+ # The lines of the member id, as its own text part prints them.
51
+ #: (String) -> Array[String]
52
+ def of(id) = @lines.fetch(id)
53
+
54
+ # How the member part of id names its text part, which prints in bytes, or nil when its text prints in its
55
+ # member part.
56
+ #: (String) { () -> Integer } -> Hash[String, untyped]?
57
+ def text_part(id, &) = @apart&.text_part(id, &)
58
+ end
59
+
60
+ # The members whose text prints in a part of its own in the full audit of principle_id, each part printed by a
61
+ # command as invocation runs it, and when the request says to read each of them whole, by id, in read_whole:
62
+ # "judged", as a step of judging it, or "flagged", if a carried member a fact fires on is judged again.
63
+ class TextsApart
64
+ #: (Array[String], Invocation, principle_id: String, ?read_whole: Hash[String, String]) -> void
65
+ def initialize(ids, invocation, principle_id:, read_whole: {})
66
+ @ids = ids
67
+ @invocation = invocation
68
+ @principle_id = principle_id
69
+ @read_whole = read_whole
70
+ freeze
71
+ end
72
+
73
+ # The id of each member whose text prints in a part of its own.
74
+ #: Array[String]
75
+ attr_reader :ids
76
+
77
+ # How the member part of id names its text part, which prints in the bytes the block gives: the command that
78
+ # prints it, and, when the request says to, when to read it whole; nil when its text is not apart.
79
+ #: (String) { () -> Integer } -> Hash[String, untyped]?
80
+ def text_part(id, &bytes)
81
+ return unless @ids.include?(id)
82
+
83
+ named = { "read_with" => @invocation.in_project("start-audit", @principle_id,
84
+ options: ["--part", "#{TEXT}#{id}"]), "bytes" => bytes.call }
85
+ when_read = @read_whole[id] or return named
86
+
87
+ named.merge("read_whole" => read_whole(when_read))
88
+ end
89
+
90
+ private
91
+
92
+ # The prompt saying when to read a text part whole, by when_read, as read_whole gives it.
93
+ #: (String) -> String
94
+ def read_whole(when_read)
95
+ return Prompts.text("assess-every-member/read-a-flagged-member-s-text-whole") if when_read == "flagged"
96
+
97
+ Prompts.text("assess-every-member/read-a-judged-member-s-text-whole")
98
+ end
99
+ end
100
+
24
101
  # instruction_fields is each field the context prints an instruction under, in order. template is the answer to
25
- # fill, as the request prints it. texts is each member's lines now, by id, one string each, which its part
26
- # prints and the whole request does not. optional names each part the context lists only when it holds something.
102
+ # fill, as the request prints it. texts is each member's lines now, as its parts print them. optional names each
103
+ # part the context lists only when it holds something.
27
104
  #: (Hash[String, untyped], instruction_fields: Array[String], template: Hash[String, untyped],
28
- #| ?texts: Hash[String, Array[String]], ?optional: Array[String]) -> void
29
- def initialize(context, instruction_fields:, template:, texts: {}, optional: [])
105
+ #| ?texts: MemberTexts, ?optional: Array[String]) -> void
106
+ def initialize(context, instruction_fields:, template:, texts: MemberTexts.new({}), optional: [])
30
107
  @context = context
31
108
  @instruction_fields = instruction_fields
32
109
  @template = template
@@ -36,16 +113,17 @@ module Principles
36
113
  end
37
114
 
38
115
  # Each part's name, in the order the context prints it, then each member's as members/ID, in the request's order,
39
- # then each instruction field, in the order the context prints them, and last the answer to fill.
116
+ # then each text printed apart as member_text/ID, then each instruction field, in the order the context prints
117
+ # them, and last the answer to fill.
40
118
  #: () -> Array[String]
41
119
  def names
42
120
  [*(@context.keys - ["members", *@instruction_fields]), *members.map { "#{MEMBER}#{it.fetch("id")}" },
43
- *@instruction_fields, TEMPLATE]
121
+ *@texts.apart.map { "#{TEXT}#{it}" }, *@instruction_fields, TEMPLATE]
44
122
  end
45
123
 
46
- # Each name --part prints: the index, then each part it lists.
124
+ # Each name --part prints: the index and the judged members' ids, then each part the index lists.
47
125
  #: () -> Array[String]
48
- def printable = [INDEX, *names]
126
+ def printable = [INDEX, JUDGED, *names]
49
127
 
50
128
  # Each optional part the context leaves out, holding nothing for this request, which --part prints as empty.
51
129
  #: () -> Array[String]
@@ -55,18 +133,9 @@ module Principles
55
133
  #: () -> Hash[String, Integer]
56
134
  def part_bytes = names.to_h { [it, bytes(shown(it))] }
57
135
 
58
- # The part name, under its key, as the context prints it; a member's entry alone under members, with its text
59
- # when given, its id read after the one prefix, so an id with a slash, or starting members/, is read whole.
136
+ # The part name: a listing of the other parts, or one of them as from_context prints it.
60
137
  #: (String) -> Hash[String, untyped]
61
- def shown(name)
62
- return { INDEX => index } if name == INDEX
63
- return empty([name]) if left_out.include?(name)
64
- return @template if name == TEMPLATE
65
- return { name => @context.fetch(name) } unless name.start_with?(MEMBER)
66
-
67
- id = name.delete_prefix(MEMBER)
68
- { "members" => members.select { it.fetch("id") == id }.map { with_text(it) } }
69
- end
138
+ def shown(name) = listing(name) || from_context(name)
70
139
 
71
140
  # The parts names, each as shown prints it, printed together: each member's in one members list and each empty
72
141
  # one named in one part_empty, in the order given, where merging the parts one by one leaves the last alone.
@@ -78,14 +147,31 @@ module Principles
78
147
 
79
148
  private
80
149
 
81
- # together with each member names names in one members list; together as it is when names name no member.
150
+ # The part name, under its key, as the context prints it; a member's entry alone under members, with its text
151
+ # when given, its id read after the one prefix, so an id with a slash, or starting members/, is read whole.
152
+ #: (String) -> Hash[String, untyped]
153
+ def from_context(name)
154
+ return empty([name]) if left_out.include?(name)
155
+ return @template if name == TEMPLATE
156
+ return text_part(name.delete_prefix(TEXT)) if name.start_with?(TEXT)
157
+ return { name => @context.fetch(name) } unless name.start_with?(MEMBER)
158
+
159
+ member_part(name.delete_prefix(MEMBER))
160
+ end
161
+
162
+ # together with each member names names in one members list, and each text in one member_texts list; together
163
+ # as it is when names name neither.
82
164
  #: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
83
165
  def with_every_member(together, names)
84
- return together unless together.key?("members")
85
-
86
- together.merge("members" => names.flat_map { shown(it).fetch("members", []) })
166
+ %w[members member_texts].select { together.key?(it) }.reduce(together) do |all, list|
167
+ all.merge(list => names.flat_map { shown(it).fetch(list, []) })
168
+ end
87
169
  end
88
170
 
171
+ # The text of the member id alone, apart from its member part.
172
+ #: (String) -> Hash[String, untyped]
173
+ def text_part(id) = { "member_texts" => [{ "id" => id, "text" => @texts.of(id) }] }
174
+
89
175
  # together with one part_empty naming every empty part names; together as it is when names name none.
90
176
  #: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
91
177
  def with_every_empty(together, names)
@@ -111,15 +197,33 @@ module Principles
111
197
  end
112
198
  end
113
199
 
200
+ # The part name when it lists the other parts, as the index does, or the members this audit judges; nil for any
201
+ # other part.
202
+ #: (String) -> Hash[String, untyped]?
203
+ def listing(name)
204
+ if name == INDEX then { INDEX => index }
205
+ elsif name == JUDGED then { JUDGED => members.reject { it["carried_forward"] }.map { it.fetch("id") } }
206
+ end
207
+ end
208
+
114
209
  # How many bytes value prints as, as this tool prints a result.
115
210
  #: (Hash[String, untyped]) -> Integer
116
211
  def bytes(value) = PrintedJson.bytes(value)
117
212
 
213
+ # The part of the member id: its entry alone under members, as with_text prints it.
214
+ #: (String) -> Hash[String, untyped]
215
+ def member_part(id) = { "members" => members.select { it.fetch("id") == id }.map { with_text(it) } }
216
+
118
217
  # member as the request lists it, with its text when given, and then its acknowledged lines now pointing at
119
- # that text, so the part prints each line now once.
218
+ # that text, so the part prints each line now once; or, when its text prints apart, with how to read that part
219
+ # and its bytes in place of the text.
120
220
  #: (Hash[String, untyped]) -> Hash[String, untyped]
121
221
  def with_text(member)
122
- text = @texts[member.fetch("id")] or return member
222
+ id = member.fetch("id")
223
+ named = @texts.text_part(id) { bytes(text_part(id)) }
224
+ return member.merge("text_part" => named) if named
225
+
226
+ text = @texts.beside(id) or return member
123
227
  since = member["acknowledged_since_last_audit"]
124
228
  return member.merge("text" => text) unless since
125
229
 
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative "answer_head"
5
5
  require_relative "answer_in_a_file"
6
+ require_relative "disposition_template"
6
7
  require_relative "invocation"
7
8
  require_relative "prompts"
8
9
  require_relative "shell_word"
@@ -14,14 +15,16 @@ module Principles
14
15
  # every disposition's shape, and what submitting the assessment stored.
15
16
  class CorrectionRequest
16
17
  # head is what the answer hands back unchanged, the request's id and the basis the correction depends on;
17
- # placeholders is the text the template leaves in each field the agent writes, with %<id>s where each
18
- # disposition names its finding.
19
- #: (head: AnswerHead, principle_id: String, findings: Array[untyped], placeholders: Hash[String, String]) -> void
20
- def initialize(head:, principle_id:, findings:, placeholders:)
18
+ # disposition is what the template starts each finding's disposition with; carrier_checks is the check for each
19
+ # carrier kind the findings' members are in, as CarrierChecks prints them.
20
+ #: (head: AnswerHead, principle_id: String, findings: Array[untyped], disposition: DispositionTemplate,
21
+ #| ?carrier_checks: Hash[String, untyped]) -> void
22
+ def initialize(head:, principle_id:, findings:, disposition:, carrier_checks: {})
21
23
  @head = head
24
+ @carrier_checks = carrier_checks
22
25
  @principle_id = principle_id
23
26
  @findings = findings
24
- @placeholders = placeholders
27
+ @disposition = disposition
25
28
  freeze
26
29
  end
27
30
 
@@ -29,12 +32,24 @@ module Principles
29
32
  #: () -> String
30
33
  def request_id = @head.request_id
31
34
 
32
- # The findings to dispose of, the question and a guide to every disposition's shape.
35
+ # The findings to dispose of, the check for each carrier their members are in, the question and a guide to every
36
+ # disposition's shape.
33
37
  #: () -> Hash[String, untyped]
34
38
  def context
35
39
  { "principle_id" => @principle_id, "findings" => @findings,
36
- "question" => Prompts.text("dispose-of-each-finding/fix-or-record-each-finding"),
37
- "answer_guide" => self.class.answer_guide(@placeholders.fetch("reason")) }
40
+ **({ "carrier_checks" => @carrier_checks } unless @carrier_checks.empty?),
41
+ "question" => question,
42
+ "answer_guide" => self.class.answer_guide(@disposition.reason) }
43
+ end
44
+
45
+ # What the correction asks, and, when it carries carrier checks, to read a kind's page before fixing a member
46
+ # there, since a page command printed beside the members was skipped (019 F4).
47
+ #: () -> String
48
+ def question
49
+ fix = Prompts.text("dispose-of-each-finding/fix-or-record-each-finding")
50
+ return fix if @carrier_checks.empty?
51
+
52
+ "#{fix}\n#{Prompts.text("dispose-of-each-finding/read-the-carrier-page-before-fixing")}"
38
53
  end
39
54
 
40
55
  # The guide to every disposition's shape, whose deferred sample's reason is reason_placeholder, the template's,
@@ -50,13 +65,7 @@ module Principles
50
65
  # both print one template.
51
66
  #: () -> Hash[String, untyped]
52
67
  def template
53
- @head.leading("dispositions" => @findings.map do |finding|
54
- named = @placeholders.transform_values { format(it, id: finding["id"]) }
55
- { "finding_id" => finding["id"], "action" => named.fetch("action"),
56
- "reason" => named.fetch("reason"), "changed_members" => [], "removed_members" => [],
57
- "evidence" => [],
58
- "reassessment" => nil, "recorded_at" => nil, "waits_on" => nil }
59
- end)
68
+ @head.leading("dispositions" => @findings.map { @disposition.for(it) })
60
69
  end
61
70
 
62
71
  # The correction's answer alone, as show-answer-check --as template prints it.
@@ -74,7 +83,7 @@ module Principles
74
83
  #: (Hash[String, untyped], Invocation, String) -> Hash[String, untyped]
75
84
  def with_correction_to_fill(acceptable, invocation, answer_file)
76
85
  assessment_id = acceptable.fetch("request_id")
77
- file = invocation.answer_file(request_id)
86
+ file = correction_file(invocation)
78
87
  save = "Once this answer is submitted with the last line's command, save the correction's answer it leads " \
79
88
  "to in a file kept out of git, at this full path, the same from every shell, from this command's " \
80
89
  "output: #{alone(assessment_id, answer_file, invocation)} > #{ShellWord.new(file)}\nFill only its " \
@@ -86,7 +95,13 @@ module Principles
86
95
  # How to fill the correction by hand: save its answer alone, which show-open-correction prints bare from the
87
96
  # open record, to a file, fill only its dispositions there with a file-edit tool, and submit that file.
88
97
  #: (Invocation) -> String
89
- def to_fill_by_hand(invocation) = AnswerInAFile.new(invocation).correction(@principle_id, request_id:)
98
+ def to_fill_by_hand(invocation)
99
+ AnswerInAFile.new(invocation).correction(@principle_id, request_id:, file: correction_file(invocation))
100
+ end
101
+
102
+ # The file the correction's answer is saved in, named by its principle and phase.
103
+ #: (Invocation) -> String
104
+ def correction_file(invocation) = invocation.answer_file(@principle_id, "correction")
90
105
 
91
106
  # What to keep while the correction is open, and the read-only command that prints its answer again from the
92
107
  # open record, in git or outside it.
@@ -0,0 +1,35 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
6
+ module Views
7
+ # The disposition a correction's template starts each finding with: the text it leaves in each field the agent
8
+ # writes, with %<id>s where it names its finding, and the fields a finding starts from in place of null, as a
9
+ # deferral raised again carries its recorded_at and waits_on.
10
+ class DispositionTemplate
11
+ # placeholders is the text left in each field the agent writes; filled is, by finding id, the fields a
12
+ # disposition starts from in place of null.
13
+ #: (Hash[String, String], ?Hash[String, Hash[String, untyped]]) -> void
14
+ def initialize(placeholders, filled = {})
15
+ @placeholders = placeholders
16
+ @filled = filled
17
+ freeze
18
+ end
19
+
20
+ # The reason placeholder, with its %<id>s slot unfilled.
21
+ #: () -> String
22
+ def reason = @placeholders.fetch("reason")
23
+
24
+ # The disposition finding starts with.
25
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
26
+ def for(finding)
27
+ named = @placeholders.transform_values { format(it, id: finding["id"]) }
28
+ { "finding_id" => finding["id"], "action" => named.fetch("action"),
29
+ "reason" => named.fetch("reason"), "changed_members" => [], "changed_map_entries" => [],
30
+ "removed_members" => [], "evidence" => [],
31
+ "reassessment" => nil, "recorded_at" => nil, "waits_on" => nil }.merge(@filled.fetch(finding["id"], {}))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -18,9 +18,9 @@ module Principles
18
18
  end
19
19
 
20
20
  # The step after adding members, since the next add-member remains the command to answer with.
21
- #: (String, ?keeps_others_held: bool) -> String
22
- def after_mapping(id, keeps_others_held: false)
23
- return after_keeping_mapping(id) if keeps_others_held
21
+ #: (String, ?keeps_held: Array[String]?) -> String
22
+ def after_mapping(id, keeps_held: nil)
23
+ return after_keeping_mapping(id, keeps_held) if keeps_held
24
24
 
25
25
  if @in_git
26
26
  return "When the map lists every member, commit it: list-member-problems then reports any change to a " \
@@ -41,27 +41,41 @@ module Principles
41
41
  "To find the first of them: #{@invocation.in_project("list-candidate-files")}"
42
42
  end
43
43
 
44
- "This principle's first full audit judges whether the keeping works for the principles under " \
45
- "existing_principles.\n" \
46
- "To start it: #{@invocation.in_project("start-audit", id)}"
44
+ keeping_audit(id, principles: "the principles under existing_principles")
47
45
  end
48
46
 
49
47
  private
50
48
 
51
- # Adding the keeping passage retains setup's first-own-principle prerequisite.
52
- #: (String) -> String
53
- def after_keeping_mapping(id)
54
- baseline = if @in_git
55
- "When the map lists every member, commit it: that commit is the members' baseline until an audit."
56
- else
57
- "Outside git, the first full audit gives each member its baseline."
58
- end
49
+ # The keeping audit, for the principles it keeps held, as the command that printed them names them.
50
+ #: (String, principles: String) -> String
51
+ def keeping_audit(id, principles:)
52
+ "This principle's first full audit judges whether the keeping works for #{principles}.\n" \
53
+ "To start it: #{start_audit(id)}"
54
+ end
55
+
56
+ # Adding the keeping passage retains setup's first-own-principle prerequisite while it holds none.
57
+ #: (String, Array[String]) -> String
58
+ def after_keeping_mapping(id, keeps_held)
59
+ if keeps_held.any?
60
+ return "#{keeping_baseline}\n#{keeping_audit(id, principles: "the principles list-principles lists")}"
61
+ end
62
+
59
63
  Prompts.text("set-principles-up/first-keeping-audit-after-own-principle",
60
- baseline: baseline,
64
+ baseline: keeping_baseline,
61
65
  find: @invocation.in_project("list-candidate-files"),
62
66
  audit: start_audit(id))
63
67
  end
64
68
 
69
+ # What gives the keeping map's members their baseline until its first full audit.
70
+ #: () -> String
71
+ def keeping_baseline
72
+ if @in_git
73
+ "When the map lists every member, commit it: that commit is the members' baseline until an audit."
74
+ else
75
+ "Outside git, the first full audit gives each member its baseline."
76
+ end
77
+ end
78
+
65
79
  #: (String) -> String
66
80
  def start_audit(id)
67
81
  @invocation.in_project("start-audit", id)
@@ -24,7 +24,7 @@ module Principles
24
24
  return [] if count.zero?
25
25
 
26
26
  counted = count == 1 ? "1 principle has" : "#{count} principles have"
27
- [%w[resume compact].include?(source) ? started_already(counted, count) : asked(counted, count)]
27
+ [%w[resume compact].include?(source) ? started_already(counted, count) : asked(counted)]
28
28
  end
29
29
 
30
30
  private
@@ -34,11 +34,10 @@ module Principles
34
34
  Prompts.text("start-a-session/start-no-second-first-audit", counted:, them: count == 1 ? "it" : "one")
35
35
  end
36
36
 
37
- #: (String, Integer) -> String
38
- def asked(counted, count)
37
+ #: (String) -> String
38
+ def asked(counted)
39
39
  Prompts.text("start-a-session/hand-the-first-audit-to-a-subagent",
40
- counted:, them: count == 1 ? "it" : "them",
41
- command: @invocation.in_project("show-first-audit-brief"))
40
+ counted:, command: @invocation.in_project("show-first-audit-brief"))
42
41
  end
43
42
  end
44
43
  end
@@ -76,9 +76,11 @@ module Principles
76
76
 
77
77
  # command, followed by the echo that runs when it exits other than 0, which it never does once started: plain
78
78
  # text at session start, and after a call the hook's JSON, since the agent never reads such a hook's plain
79
- # stdout.
79
+ # stdout. Before an edit it says nothing and lets the edit through, since the other hooks already say so.
80
80
  #: (String, String) -> String
81
81
  def guarded(event, command)
82
+ return "#{EXECUTABLE} #{command} || true" if event == "PreToolUse"
83
+
82
84
  said = if event == "SessionStart"
83
85
  FAILED
84
86
  else
@@ -60,11 +60,20 @@ module Principles
60
60
  in_project("submit-answer", request_id, options: ["--file", file])
61
61
  end
62
62
 
63
- # The file to save the answer name names in, a request id or a principle id, by its full path in temp_directory,
64
- # so every shell that runs the printed commands names the same file: a sandboxed and an unsandboxed one
65
- # read $TMPDIR as different folders.
66
- #: (String) -> String
67
- def answer_file(name) = "#{@temp_directory.chomp("/")}/principles-#{name}-answer.json"
63
+ # The file to save an answer for principle_id in, by its full path in temp_directory, so every shell that runs
64
+ # the printed commands names the same file: a sandboxed and an unsandboxed one read $TMPDIR as different
65
+ # folders. An answer to a request in phase is named by the request's principle and phase alone, not its id, so a
66
+ # request printed again after HEAD moved, with a new id, names the file the first one saved to.
67
+ #: (String, ?String?) -> String
68
+ def answer_file(principle_id, phase = nil)
69
+ "#{@temp_directory.chomp("/")}/#{self.class.answer_name(principle_id, phase)}"
70
+ end
71
+
72
+ # The name of the file an answer for principle_id in phase is saved in, the one owner of its shape.
73
+ #: (String, ?String?) -> String
74
+ def self.answer_name(principle_id, phase = nil)
75
+ "principles-#{[principle_id, phase].compact.join(".")}-answer.json"
76
+ end
68
77
 
69
78
  # The same command, its values given as one list, as a refusal's repair command holds them.
70
79
  #: (String, Array[String], ?options: Array[String], ?usage: String?) -> String
@@ -0,0 +1,41 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation"
5
+
6
+ module Principles
7
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
8
+ module Views
9
+ # The notice start-audit adds about the principle's last audit record, beside a full audit's request: a record
10
+ # left uncommitted, or one holding an open audit.
11
+ class LastRecordNotice
12
+ #: (Invocation) -> void
13
+ def initialize(invocation)
14
+ @invocation = invocation
15
+ freeze
16
+ end
17
+
18
+ # The notice start-audit adds when the last audit's record is not committed.
19
+ #: (String) -> String
20
+ def uncommitted(file)
21
+ "The last audit's record, #{file}, is not committed. Commit it, so the project keeps it."
22
+ end
23
+
24
+ # The notice start-audit adds, in git, when the last audit's record is open: its correction completes it, so it
25
+ # is never committed.
26
+ #: (String) -> String
27
+ def open(file)
28
+ "The last audit's record, #{file}, holds an open audit, waiting on its correction. Do not commit it: submit " \
29
+ "that correction, or answer this request, which replaces it, or discard it with `git restore #{file}`."
30
+ end
31
+
32
+ # The notice start-audit adds while principle_id's last audit is open and keeps its correction: the command that
33
+ # prints that correction again, to resume it.
34
+ #: (String) -> String
35
+ def resume(principle_id)
36
+ "The last audit of #{principle_id} is open, waiting on its correction. To resume it, print that correction " \
37
+ "again: #{@invocation.in_project("show-open-correction", principle_id)}"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -19,6 +19,11 @@ module Principles
19
19
  TEXT_CHECK = "Lines are not text: where two share a first or last line, a passage can start or end partway " \
20
20
  "through it, so check the text there before deciding which edit reaches which member. " #: String
21
21
 
22
+ # What an edit to this member reaches when one of them spans all of its lines.
23
+ SPANNING = "Every edit to this member's text is an edit to each marked spans_these_lines too. " #: String
24
+ # What an edit to one of them reaches when it lies within this member's lines.
25
+ WITHIN = "Every edit to the text of each marked within_these_lines is an edit to this member's too. " #: String
26
+
22
27
  # text_check says whether a member holding another's lines is not a whole file, so the text needs checking.
23
28
  #: (?overlaps: Array[String], ?same_lines_as: Array[String], ?mapped_elsewhere: Array[Hash[String, untyped]],
24
29
  #| ?text_check: bool) -> void
@@ -60,33 +65,22 @@ module Principles
60
65
  "share changes each. #{spans_note}Check that this member's role fits beside the roles they give it there. "
61
66
  end
62
67
 
63
- # Which of them span all of this member's lines and which lie within them, so the agent can work out which
64
- # member an edit reaches. Lines are not text, so the agent checks where they share a first or last line.
68
+ # What an edit reaches where some of them are marked spans_these_lines or within_these_lines, said once by the
69
+ # mark, since mapped_elsewhere names each; one sentence per entry made a whole-file member's result 9.4 KB.
70
+ # Lines are not text, so the agent checks where they share a first or last line.
65
71
  #: () -> String
66
72
  def spans_note
67
- spans = @mapped_elsewhere.filter_map do |each|
68
- if each["spans_these_lines"] then spanning(each)
69
- elsif each["within_these_lines"] then within(each)
70
- end
71
- end
72
- "#{spans.join}#{TEXT_CHECK if @text_check && spans.any?}"
73
- end
73
+ spans = marked?("spans_these_lines")
74
+ within = marked?("within_these_lines")
75
+ return "" unless spans || within
74
76
 
75
- # One that spans all of this member's lines: an edit to this member reaches it, and one outside them only it.
76
- #: (Hash[String, untyped]) -> String
77
- def spanning(each)
78
- id = "`#{each.fetch("member_id")}`"
79
- "#{id} in #{each.fetch("principle_id")} spans all of this member's lines, so every edit to this member's " \
80
- "text is an edit to it too, and an edit outside the shared lines reaches only #{id}. "
77
+ "#{SPANNING if spans}#{WITHIN if within}An edit outside the shared lines reaches only the member it is in. " \
78
+ "#{TEXT_CHECK if @text_check}"
81
79
  end
82
80
 
83
- # One within this member's lines: an edit to it reaches this member, and one outside them only this member.
84
- #: (Hash[String, untyped]) -> String
85
- def within(each)
86
- "`#{each.fetch("member_id")}` in #{each.fetch("principle_id")} lies within this member's lines, so every " \
87
- "edit to its text is an edit to this member's too, and an edit outside the shared lines reaches only " \
88
- "this member. "
89
- end
81
+ # Whether any of them carries this mark.
82
+ #: (String) -> bool
83
+ def marked?(mark) = @mapped_elsewhere.any? { |each| each[mark] }
90
84
 
91
85
  # Equal lines are not equal text, as a passage can end within its last line, so the agent decides.
92
86
  #: () -> String
@@ -0,0 +1,29 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "prompts"
5
+
6
+ module Principles
7
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
8
+ module Views
9
+ # What each status a member can have in the logged requests means, in one line each, printed once beside the
10
+ # members that carry them, so the agent reads a status without guessing. not_a_carrier comes first, since a first
11
+ # reader most often mistakes it for a gap.
12
+ class LoggedRequestStatusMeanings
13
+ #: () -> void
14
+ def initialize
15
+ freeze
16
+ end
17
+
18
+ # Each status, with its one-line meaning.
19
+ #: () -> Hash[String, String]
20
+ def to_h
21
+ { "not_a_carrier" => Prompts.text("read-what-reached-the-context/what-not-a-carrier-means"),
22
+ "present" => Prompts.text("read-what-reached-the-context/what-present-means"),
23
+ "present_but_not_loaded" => Prompts.text("read-what-reached-the-context/what-present-but-not-loaded-means"),
24
+ "absent" => Prompts.text("read-what-reached-the-context/what-absent-means"),
25
+ "unmeasurable" => Prompts.text("read-what-reached-the-context/what-unmeasurable-means") }
26
+ end
27
+ end
28
+ end
29
+ end