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,60 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
6
+ module Models
7
+ # Each part of a turn opening's context with an estimate of its tokens: its share of the request's bytes, at
8
+ # that request's own bytes a token, of the input tokens the host counted. The host counts no part's tokens, so
9
+ # each is an estimate. Shares are rounded down and the tokens left go one each to the largest remainders, the
10
+ # earlier part first on a tie, so the estimates sum to the host's count exactly.
11
+ class PartTokenEstimates
12
+ # parts each give their bytes; input_tokens is the host's count, or nil where it gave none.
13
+ #: (Array[Hash[String, untyped]], Integer?) -> void
14
+ def initialize(parts, input_tokens)
15
+ @parts = parts
16
+ @input_tokens = input_tokens
17
+ freeze
18
+ end
19
+
20
+ # Each part with its estimated_tokens: null for every part where the host gave no count, or the request has no
21
+ # bytes to share it by.
22
+ #: () -> Array[Hash[String, untyped]]
23
+ def to_a
24
+ estimates = estimated
25
+ @parts.each_with_index.map { |part, index| part.merge("estimated_tokens" => estimates&.fetch(index)) }
26
+ end
27
+
28
+ # The request's bytes for each token the host counted, to two places, or nil where it gave none.
29
+ #: () -> Float?
30
+ def bytes_per_token
31
+ tokens = @input_tokens
32
+ tokens&.positive? ? total.fdiv(tokens).round(2).to_f : nil
33
+ end
34
+
35
+ private
36
+
37
+ #: () -> Integer
38
+ def total = @parts.sum { it.fetch("bytes") }
39
+
40
+ # Each part's estimate in order, by largest remainder; nil where there is nothing to share or share it by.
41
+ #: () -> Array[Integer]?
42
+ def estimated
43
+ tokens = @input_tokens
44
+ bytes = total
45
+ return unless tokens && bytes.positive?
46
+
47
+ shares = @parts.map { (it.fetch("bytes") * tokens).divmod(bytes) }
48
+ raised = largest_remainders(shares, tokens - shares.sum(&:first))
49
+ shares.each_with_index.map { |(floor, _), index| raised.include?(index) ? floor + 1 : floor }
50
+ end
51
+
52
+ # The indexes of the count shares, each [floor, remainder], with the largest remainders, the earlier first on
53
+ # a tie.
54
+ #: (Array[[Integer, Integer]], Integer) -> Array[Integer]
55
+ def largest_remainders(shares, count)
56
+ shares.each_index.sort_by { |index| [-shares.fetch(index).last, index] }.first(count)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,37 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../error"
5
+
6
+ module Principles
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
+ module Models
9
+ # The file a plugin member names, by its path inside the plugin. It takes plain characters only, segments of
10
+ # letters, digits, dots, dashes and underscores, none of them . or .., so it can only name a file under the
11
+ # plugin's own folder and reads the same wherever it is printed. No first case needs any other character.
12
+ class PluginComponent
13
+ # One segment of the path: plain characters, and not . or .. alone.
14
+ SEGMENT = /\A(?!\.{1,2}\z)[A-Za-z0-9._-]+\z/ #: Regexp
15
+
16
+ # Whether path is plain, as a component must be.
17
+ #: (String) -> bool
18
+ def self.plain?(path) = !path.empty? && path.split("/", -1).all? { |segment| segment.match?(SEGMENT) }
19
+
20
+ #: String
21
+ attr_reader :path
22
+
23
+ #: (String) -> void
24
+ def initialize(path)
25
+ unless self.class.plain?(path)
26
+ raise Error.new("plugin_component_not_plain",
27
+ "#{path.inspect} is not a plain relative path inside the plugin",
28
+ "Name the file by its path inside the plugin, in segments of letters, digits, dots, " \
29
+ "dashes and underscores, with no . or .. segment.")
30
+ end
31
+
32
+ @path = path
33
+ freeze
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,61 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+ require_relative "../error"
6
+ require_relative "../data/project_files"
7
+
8
+ module Principles
9
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
+ module Models
11
+ # The line of the project's settings that enables the principles plugin for every session in the project, its
12
+ # enabledPlugins entry, which can be the meta-principle's first member: mapping it writes only .principles/ and
13
+ # edits none of the project's guidance (019 F8). It is a fact about the file, read as Claude Code's project-scope
14
+ # settings shape it; whether the team can install the plugin is not something this tool can see.
15
+ class PluginEnabledInProjectSettings
16
+ # The project-scope settings file a team commits, unlike the local one each user keeps.
17
+ PATH = ".claude/settings.json"
18
+
19
+ # The plugin's name in an enabledPlugins key, before the marketplace it comes from.
20
+ PLUGIN = "principles"
21
+
22
+ # The enabling line in files' project settings, or nil when the file is absent, unreadable or does not enable
23
+ # the plugin.
24
+ #: (Data::ProjectFiles) -> PluginEnabledInProjectSettings?
25
+ def self.read(files)
26
+ return nil unless files.file?(PATH)
27
+
28
+ text = files.read_text(PATH)
29
+ key = enabling_key(files.parse_json(text, PATH)) or return nil
30
+ line = text[/#{Regexp.escape(JSON.generate(key))}\s*:\s*true/] or return nil
31
+ new(line)
32
+ rescue Error
33
+ nil
34
+ end
35
+
36
+ # The enabledPlugins key in settings that turns this plugin on, from any marketplace, or nil.
37
+ #: (untyped) -> String?
38
+ def self.enabling_key(settings)
39
+ plugins = settings.is_a?(Hash) ? settings["enabledPlugins"] : nil
40
+ return nil unless plugins.is_a?(Hash)
41
+
42
+ plugins.find { |name, on| on == true && name.to_s.split("@").first == PLUGIN }&.first
43
+ end
44
+ private_class_method :enabling_key
45
+
46
+ # starting_at is the enabling entry's text as the file holds it.
47
+ #: (String) -> void
48
+ def initialize(starting_at)
49
+ @starting_at = starting_at
50
+ freeze
51
+ end
52
+
53
+ # The literal opening that locates the line in the file, as add-member's --starting-at takes it.
54
+ #: String
55
+ attr_reader :starting_at
56
+
57
+ #: () -> String
58
+ def path = PATH
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
6
+ module Models
7
+ # The install of a plugin a session in the project loads, as one of its Claude Code registry rows: the first, in
8
+ # the host's order, that is a user install or one for the project's main checkout. A probe found the host chose so:
9
+ # by order, not by a ranking of scopes, and in a git worktree by its main checkout's row.
10
+ class PluginInstall
11
+ # The row that applies to the project whose main checkout is at main_checkout, or nil when none does.
12
+ #: (Array[Hash[String, String?]], main_checkout: String) -> PluginInstall?
13
+ def self.applying(rows, main_checkout:)
14
+ row = rows.find { |each| each["scope"] == "user" || each["project_path"] == main_checkout }
15
+ new(row) if row
16
+ end
17
+
18
+ #: (Hash[String, String?]) -> void
19
+ def initialize(row)
20
+ @row = row
21
+ freeze
22
+ end
23
+
24
+ # The version the host installed, which it gives for the agent's information only.
25
+ #: () -> String?
26
+ def version = @row["version"]
27
+
28
+ # The folder the host installed this copy in.
29
+ #: () -> String?
30
+ def install_path = @row["install_path"]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
6
+ module Models
7
+ # A plugin's install name as Claude Code records it, NAME@MARKETPLACE, which names the marketplace it came from.
8
+ class PluginName
9
+ #: (String) -> void
10
+ def initialize(name)
11
+ @name = name
12
+ freeze
13
+ end
14
+
15
+ # The marketplace the plugin came from: what follows the first @, or the whole name when it has none.
16
+ #: () -> String
17
+ def marketplace = @name.split("@", 2).last.to_s
18
+
19
+ #: () -> String
20
+ def to_s = @name
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,53 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "plugin_component"
5
+
6
+ module Principles
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
+ module Models
9
+ # A plugin member's path in its map, plugin://HOST/NAME@MARKETPLACE/COMPONENT: the host, the plugin's install name
10
+ # and the file's path inside the plugin, with no version, so its id stays the same across updates, and no machine
11
+ # path.
12
+ class PluginReference
13
+ # The host a plugin member's path names; Codex is not read yet.
14
+ HOST = "claude-code" #: String
15
+
16
+ # What every plugin member's path starts with.
17
+ PREFIX = "plugin://#{HOST}/".freeze #: String
18
+
19
+ # The plugin member path names, or nil when it names a project file.
20
+ #: (String) -> PluginReference?
21
+ def self.in(path)
22
+ return unless path.start_with?(PREFIX)
23
+
24
+ name, component = path.delete_prefix(PREFIX).split("/", 2)
25
+ new(name.to_s, PluginComponent.new(component.to_s))
26
+ end
27
+
28
+ # The plugin's install name, NAME@MARKETPLACE.
29
+ #: String
30
+ attr_reader :name
31
+
32
+ #: PluginComponent
33
+ attr_reader :component
34
+
35
+ #: (String, PluginComponent) -> void
36
+ def initialize(name, component)
37
+ @name = name
38
+ @component = component
39
+ freeze
40
+ end
41
+
42
+ #: () -> String
43
+ def to_s = "#{PREFIX}#{@name}/#{@component.path}"
44
+
45
+ # Where it comes from, at the version installed, as a result prints it: read-only, since the host replaces its
46
+ # files on update.
47
+ #: (String?) -> Hash[String, untyped]
48
+ def source(version)
49
+ { "host" => HOST, "plugin" => @name, "version" => version, "component" => @component.path, "read_only" => true }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -89,9 +89,7 @@ module Principles
89
89
 
90
90
  # Each member as this tool prints it: its id beside the fields shown gives it.
91
91
  #: () -> Array[Hash[String, untyped]]
92
- def members_shown
93
- @members.zip(shown.fetch("members")).map { |member, fields| { "id" => member.id }.merge(fields) }
94
- end
92
+ def members_shown = @members.shown(shown.fetch("members"))
95
93
 
96
94
  # The map as its file holds it.
97
95
  #: () -> Hash[String, untyped]
@@ -146,7 +144,12 @@ module Principles
146
144
  end
147
145
 
148
146
  #: (String, String) -> Principle
149
- def changing_role(member_id, role) = changing(member_id, "role" => role)
147
+ def changing_role(member_id, role) = saying(member_id, "role", role)
148
+
149
+ # This principle with member_id's entry giving value as field, one of the fields that say what the member is,
150
+ # never where: its role, its reason, or its name, which is for display only, so its id and key stay.
151
+ #: (String, String, String) -> Principle
152
+ def saying(member_id, field, value) = changing(member_id, field => value)
150
153
 
151
154
  # Names the command that enforces a member, which an audit asks the agent to run. This tool
152
155
  # stores it and never runs it.
@@ -46,6 +46,21 @@ module Principles
46
46
  #: () -> Array[String]
47
47
  def keys = @list.map(&:key)
48
48
 
49
+ # The members in the project's own files, which git holds, leaving out those a plugin gives.
50
+ #: () -> PrincipleMembers
51
+ def in_project = PrincipleMembers.new(@principle_id, @list.reject(&:plugin_reference))
52
+
53
+ # What the map pinned of each plugin member, by key: the version and the hash of its text when it was mapped.
54
+ #: () -> Hash[String, Hash[String, String]]
55
+ def pinned
56
+ pins = {} #: Hash[String, Hash[String, String]]
57
+ @list.each do |member|
58
+ pin = member.pinned
59
+ pins[member.key] = pin if pin
60
+ end
61
+ pins
62
+ end
63
+
49
64
  # Each member by its id.
50
65
  #: () -> Hash[String, Member]
51
66
  def by_id = @list.to_h { |member| [member.id, member] }
@@ -72,6 +87,13 @@ module Principles
72
87
  in_files(paths).map { |member| { "id" => member.id, "path" => member.path } }
73
88
  end
74
89
 
90
+ # Each member as this tool prints it: led by its name when it has one, since the name says what it is for and
91
+ # the id only where it is, then its id beside fields, its entry as shown, in the map's order.
92
+ #: (Array[Hash[String, untyped]]) -> Array[Hash[String, untyped]]
93
+ def shown(fields)
94
+ @list.each_with_index.map { |member, at| { **member.named, "id" => member.id }.merge(fields.fetch(at)) }
95
+ end
96
+
75
97
  # A small first map prompts an agent question, not a minimum member count or a verdict of incompleteness.
76
98
  # no_completed_audit is known absence from the record owner; false also covers unknown state.
77
99
  #: (no_completed_audit: bool) -> bool
@@ -124,7 +124,7 @@ module Principles
124
124
  #: () -> bot
125
125
  def unrecorded_deferral
126
126
  invalid("deferring it needs recorded_at, or null when it is written up nowhere",
127
- "Set recorded_at to where #{@id} is written up, as {\"path\": ..., \"heading\": ...}, or to null.")
127
+ "Set recorded_at to where #{@id} is written up, as #{AnswerFields::WRITE_UP_FORMS}; or to null.")
128
128
  end
129
129
 
130
130
  # The action the finding keeps once decided, or nil when the decision closes it or raises it again.
@@ -26,7 +26,8 @@ module Principles
26
26
  holding = of(["still_holds"]).map(&:kept)
27
27
  DecidedPriorFindings.new(
28
28
  { "kept" => holding.map(&:to_h), "closed" => of(PriorFindingDecision::CLOSING).map(&:closed),
29
- "inherited" => first_raised(of(["raised_again"])), **changed(holding) }
29
+ "inherited" => first_raised(of(["raised_again"])),
30
+ "deferrals_raised_again" => deferrals(of(["raised_again"])), **changed(holding) }
30
31
  )
31
32
  end
32
33
 
@@ -54,6 +55,16 @@ module Principles
54
55
  end
55
56
  end
56
57
 
58
+ # Where each deferral raised again was written up and whom it waited on, by the id of the new finding it became,
59
+ # so that finding's correction starts from them rather than from nothing.
60
+ #: (Array[PriorFindingDecision]) -> Hash[String, Hash[String, untyped]]
61
+ def deferrals(raised)
62
+ raised.select { |decision| decision.finding.action == "deferred" }.to_h do |decision|
63
+ [decision.raised_as, { "recorded_at" => decision.finding.recorded_at&.to_h,
64
+ "waits_on" => decision.finding.waits_on }]
65
+ end
66
+ end
67
+
57
68
  #: (String, Array[String]) -> void
58
69
  def raised_once(as, ids)
59
70
  return if ids.one?
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "../error"
5
+ require_relative "acknowledgements_to_offer"
5
6
  require_relative "member_problems"
6
7
  require_relative "missing_files"
7
8
 
@@ -52,7 +53,8 @@ module Principles
52
53
 
53
54
  { "members" => changed(&),
54
55
  "counts" => @maps.flat_map(&:entries).map { |each| each.fetch("state") }.tally.sort.to_h,
55
- "compared_with" => compared_with, **no_baseline_because, **awaiting_first_audit_field, **mapping_facts }
56
+ "compared_with" => compared_with, **no_baseline_because, **awaiting_first_audit_field, **mapping_facts,
57
+ **plugin_unresolved }
56
58
  end
57
59
 
58
60
  # The principles that await their first full audit, in map order, which list-member-problems names in one
@@ -74,22 +76,10 @@ module Principles
74
76
  #: () -> Hash[String, Integer]
75
77
  def never_assessed = @maps.to_h { [it.principle_id, it.never_assessed] }.reject { |_, count| count.zero? }
76
78
 
77
- # For each map with a changed member a one-member audit may judge, the ids of those members, which
78
- # list-member-problems offers that audit for, one command per principle.
79
- #: () -> Hash[String, Array[String]]
80
- def acknowledgeable
81
- @maps.to_h { |map| [map.principle_id, map.acknowledgeable_member_ids] }.reject { |_, ids| ids.empty? }
82
- end
83
-
84
- # The acknowledgeable members, those of principles that share one joined in one acknowledgement across them:
85
- # each set of principle ids, in id order, with the members they acknowledge together, leaving out the
86
- # principles in except, whose records wait on an upgrade.
87
- #: (?except: Array[String]) -> Hash[Array[String], Array[String]]
88
- def acknowledgeable_together(except: [])
89
- acknowledgeable.reduce({}) do |groups, (id, members)|
90
- except.include?(id) ? groups : joining(groups, id, members)
91
- end
92
- end
79
+ # The one-member audits list-member-problems offers, but for the principles in except, whose records wait on an
80
+ # upgrade.
81
+ #: (?except: Array[String]) -> AcknowledgementsToOffer
82
+ def acknowledgements(except: []) = AcknowledgementsToOffer.new(@maps, except:)
93
83
 
94
84
  # For each map with members no baseline holds, its map file and the files those members are in, and in git
95
85
  # only those of them that differ from HEAD or are untracked, since committing an unchanged file does nothing.
@@ -161,6 +151,13 @@ module Principles
161
151
  "empty_maps" => @maps.select(&:empty_map?).map(&:principle_id) }.reject { |_key, ids| ids.empty? }
162
152
  end
163
153
 
154
+ # Each plugin member no installed plugin gives, with why, which refuses nothing; none when every one resolves.
155
+ #: () -> Hash[String, Array[Hash[String, untyped]]]
156
+ def plugin_unresolved
157
+ unresolved = @maps.flat_map(&:entries).select { it.fetch("state") == "plugin_unresolved" }
158
+ unresolved.empty? ? {} : { "plugin_unresolved" => unresolved.map { it.slice("principle", "id", "reason") } }
159
+ end
160
+
164
161
  #: (Array[Hash[String, untyped]]) -> bot
165
162
  def refuse(broken)
166
163
  named = broken.map { |each| [each["principle"], each["id"]].compact.join(" ") }
@@ -169,14 +166,6 @@ module Principles
169
166
  rerun: "#{Error::EXECUTABLE} list-member-problems",
170
167
  note: "A map listed as unreadable_map needs its own refusal's repair. ")
171
168
  end
172
-
173
- # groups with principle id's members joined into each group that shares one of them, as one group.
174
- #: (Hash[Array[String], Array[String]], String, Array[String]) -> Hash[Array[String], Array[String]]
175
- def joining(groups, id, members)
176
- joined = groups.select { |_ids, others| others.intersect?(members) }
177
- rest = groups.reject { |ids, _others| joined.key?(ids) }
178
- rest.merge([*joined.keys.flatten, id].sort => [*joined.values.flatten, *members].uniq)
179
- end
180
169
  end
181
170
  end
182
171
  end
@@ -3,22 +3,18 @@
3
3
 
4
4
  require_relative "../data/project_files"
5
5
  require_relative "../data/project_root"
6
- require_relative "../data/map_files"
7
- require_relative "../data/audit_files"
8
- require_relative "../data/principles_subfolder"
6
+ require_relative "../data/principles_store"
9
7
  require_relative "../data/repository"
8
+ require_relative "../data/claude_code_home"
9
+ require_relative "../data/user_request_logging_folder"
10
10
  require_relative "candidate_inventory"
11
11
  require_relative "entry_files"
12
12
  require_relative "member"
13
13
  require_relative "member_file"
14
- require_relative "hook_commands"
15
- require_relative "loaded_files"
16
14
  require_relative "located_text"
17
- require_relative "member_loads"
18
15
  require_relative "member_lines"
19
16
  require_relative "mapped_principles"
20
17
  require_relative "member_snapshots"
21
- require_relative "missing_files"
22
18
  require_relative "locate_refusal"
23
19
  require_relative "audit_records"
24
20
  require_relative "project_history"
@@ -26,15 +22,21 @@ require_relative "principle_history"
26
22
  require_relative "principles_folder_move"
27
23
  require_relative "sent_answer"
28
24
  require_relative "guidance_search_paths"
25
+ require_relative "request_logging"
26
+ require_relative "session_registry"
27
+ require_relative "user_settings_entries"
29
28
  require_relative "survey_search_paths"
29
+ require_relative "installed_plugins"
30
+ require_relative "plugin_reference"
31
+ require_relative "project_harness"
30
32
 
31
33
  module Principles
32
34
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
33
35
  module Models
34
36
  # The user's project as this tool reads it: its instruction files, each member's text, the answers an
35
37
  # agent hands in, and the maps, audit records and git history kept beside them. Controllers reach the
36
- # project only through this model. It is handed its five data adapters, so a spec can hand it stand-ins
37
- # that meet the same contracts.
38
+ # project only through this model. It is handed its data adapters, this tool's own files under .principles as
39
+ # one store, so a spec can hand it stand-ins that meet the same contracts.
38
40
  class Project
39
41
  # An implicit invocation reuses its nearest established project; an explicit root uses .at directly.
40
42
  #: (String) -> Project
@@ -44,20 +46,22 @@ module Principles
44
46
  #: (String) -> Project
45
47
  def self.at(root)
46
48
  files = Data::ProjectFiles.new(root)
47
- new(files: files, maps: Data::MapFiles.new(Data::PrinciplesSubfolder.new(files.root, "maps")),
48
- audits: Data::AuditFiles.new(Data::PrinciplesSubfolder.new(files.root, "audits")),
49
- repository: Data::Repository.new(files.root),
50
- guidance_search_paths: Data::GuidanceSearchPathsFile.new(Data::PrinciplesDirectory.new(files.root)))
49
+ new(files: files, store: Data::PrinciplesStore.at(files.root), repository: Data::Repository.new(files.root),
50
+ claude_code: Data::ClaudeCodeHome.from_environment,
51
+ user_request_logging: Data::UserRequestLoggingFolder.from_environment)
51
52
  end
52
53
 
53
- #: (files: Data::ProjectFiles, maps: Data::MapFiles, audits: Data::AuditFiles,
54
- #| repository: Data::Repository, guidance_search_paths: Data::GuidanceSearchPathsFile) -> void
55
- def initialize(files:, maps:, audits:, repository:, guidance_search_paths:)
54
+ #: (files: Data::ProjectFiles, store: Data::PrinciplesStore, repository: Data::Repository,
55
+ #| claude_code: Data::ClaudeCodeHome, user_request_logging: Data::UserRequestLoggingFolder) -> void
56
+ def initialize(files:, store:, repository:, claude_code:, user_request_logging:)
56
57
  @files = files
57
- @maps = maps
58
- @audits = audits
58
+ @maps = store.maps #: Data::MapFiles
59
+ @audits = store.audits #: Data::AuditFiles
59
60
  @repository = repository
60
- @guidance_search_paths = guidance_search_paths
61
+ @guidance_search_paths = store.guidance_search_paths #: Data::GuidanceSearchPathsFile
62
+ @request_logging = store.request_logging #: Data::RequestLoggingFolder
63
+ @claude_code = claude_code
64
+ @user_request_logging = user_request_logging
61
65
  @history = nil #: ProjectHistory?
62
66
  @principle_histories = {} #: Hash[[String, PrincipleMappingHistory?], PrincipleHistory]
63
67
  end
@@ -86,9 +90,20 @@ module Principles
86
90
  GuidanceSearchPaths.read(@guidance_search_paths)
87
91
  end
88
92
 
89
- # The user name git commits as here, or nil when none is set, which the session-start line states as a fact.
90
- #: () -> String?
91
- def git_user_name = @repository.user_name
93
+ # The requests the host sent, captured into a folder git must ignore.
94
+ #: () -> RequestLogging
95
+ def request_logging
96
+ RequestLogging.new(@request_logging, @files, registry: SessionRegistry.new(@user_request_logging, @repository),
97
+ user_folder: @user_request_logging)
98
+ end
99
+
100
+ # The plugins Claude Code installed that a session in the project loads, as installed for its main checkout.
101
+ # The entries in the user's own settings that turn request logging on for every session they start.
102
+ #: () -> UserSettingsEntries
103
+ def user_settings_entries = UserSettingsEntries.new(@claude_code, @user_request_logging)
104
+
105
+ #: () -> InstalledPlugins
106
+ def installed_plugins = InstalledPlugins.new(@claude_code, main_checkout: @repository.main_checkout_root)
92
107
 
93
108
  # The project's history, one for the whole command, so every read names the HEAD it first read.
94
109
  #: () -> ProjectHistory
@@ -148,10 +163,13 @@ module Principles
148
163
  member_lines(locator, since: since) || MemberLinesNotFoundAtLastAudit.new
149
164
  end
150
165
 
151
- # The project file at path as the type that finds a member in it, refused when it cannot be read, or while git
152
- # tracks it only in another case.
166
+ # The file at path as the type that finds a member in it: an installed plugin's file, as InstalledPlugins
167
+ # refuses it, or the project's, refused when it cannot be read, or while git tracks it only in another case.
153
168
  #: (String) -> MemberFile
154
169
  def member_file(path)
170
+ plugin = PluginReference.in(path)
171
+ return installed_plugins.member_file(plugin) if plugin
172
+
155
173
  MemberFile.for(path: history.tracked_paths.spelt_as_tracked(path), text: @files.read_text(path))
156
174
  end
157
175
 
@@ -170,48 +188,25 @@ module Principles
170
188
  @files.file?(OLDER_STATE) ? [OLDER_STATE] : []
171
189
  end
172
190
 
173
- # Each member's hash now by key, or the refusal that says why its text cannot be found or read.
174
- #: (PrincipleMembers) -> Hash[String, untyped]
175
- def current_by_key(members)
176
- members.to_h do |member|
177
- [member.key, located_text(member.locator).sha256]
178
- rescue Error => e
179
- [member.key, e.payload]
180
- end
181
- end
182
-
183
- #: (String, Array[Hash[String, untyped]]) -> bot
184
- def refuse_broken(map_id, broken)
185
- ids = broken.map { |member| member.fetch("id") }.join(", ")
186
- missing = MissingFiles.new(broken, principle: map_id, history: history)
187
- raise missing.refusal("#{broken.length} of #{map_id}'s members cannot be found or read: #{ids}")
188
- end
189
-
190
191
  # A member's text now and how fresh it is, which the block says from its hash. A member whose place
191
192
  # in its file is gone is locator_lost; one whose file cannot be read is unavailable. Both keep the
192
- # refusal.
193
+ # refusal. A plugin member no installed plugin gives, for any reason, is plugin_unresolved with that reason, a
194
+ # quiet state and not a broken one, as list-member-problems lists it, so nothing offers to move or remove it.
193
195
  #: (Locator) { (String) -> String } -> Hash[String, untyped]
194
196
  def freshness(locator, &)
195
197
  now = located_text(locator)
196
198
  { "snapshot" => now.to_h, "freshness" => yield(now.sha256) }
197
199
  rescue Error => e
198
- { "freshness" => LocateRefusal.new(e.payload).member_state, "error" => e.payload }
199
- end
200
+ if PluginReference.in(locator.path)
201
+ return { "freshness" => "plugin_unresolved", "reason" => e.payload.fetch("code"), "error" => e.payload }
202
+ end
200
203
 
201
- # Each member's MemberLoads by id: when each host loads it into context, with the size of what loads, and
202
- # the project hooks whose commands name its file, read once for them all unless the caller already read them.
203
- #: (PrincipleMembers, ?HookCommands) -> Hash[String, MemberLoads]
204
- def member_loads(members, hooks = hook_commands)
205
- members.to_h { |member| [member.id, MemberLoads.read(@files, member.locator, hooks: hooks)] }
204
+ { "freshness" => LocateRefusal.new(e.payload).member_state, "error" => e.payload }
206
205
  end
207
206
 
208
- # The files members load, each read whole once, with the project's hooks as hooks read them.
209
- #: (PrincipleMembers, HookCommands) -> LoadedFiles
210
- def loaded_files(members, hooks) = LoadedFiles.read(@files, members, hooks: hooks)
211
-
212
- # The command hooks in each of paths present, the project settings files unless others are given.
213
- #: (?Array[String]) -> HookCommands
214
- def hook_commands(paths = HookCommands::SETTINGS) = HookCommands.read(@files, paths)
207
+ # What a host's harness reads from the project's files.
208
+ #: () -> ProjectHarness
209
+ def harness = ProjectHarness.new(@files)
215
210
 
216
211
  # The root entry files every session of a host loads, whether one links the other and which git does not
217
212
  # track.