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,61 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+ require "tempfile"
6
+ require_relative "ran"
7
+
8
+ module Principles
9
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
10
+ module Data
11
+ # The request files that may hold one of some patterns, found by one rg run over the files as the host wrote them,
12
+ # so only those are decoded. The JSON writers of the hosts it captures, Node's among them, and jq and Ruby's, agree
13
+ # on writing a quote, a backslash and a control character, and differ on a slash, a DEL and a non-ASCII character,
14
+ # each written raw or as an escape, so each pattern is looked for in every one of those forms. A writer escaping
15
+ # < > & as Go's HTML-safe form does is not covered.
16
+ class RawRequestFilter
17
+ # rg's options for listing each file holding a fixed string, one a line, ignore files left unread, since git
18
+ # ignores the folder the requests are in.
19
+ SEARCH = %w[--no-config --no-ignore -F -l].freeze #: Array[String]
20
+ # A character outside ASCII, which a writer may write as itself or as \u escapes, in either case of hex digit.
21
+ NON_ASCII = /[^\x00-\x7f]/
22
+
23
+ # Each of files, in the requests folder, that may hold one of patterns, none of them empty, and whether rg read
24
+ # every file, finding one or none, and wrote no error.
25
+ #: (String, Array[String], Array[String]) -> [Array[String], bool]
26
+ def self.listing(requests, files, patterns)
27
+ Tempfile.create("principles-raw-patterns") do |listed|
28
+ listed.write(patterns.flat_map { written_forms(it) }.uniq.join("\n"))
29
+ listed.flush
30
+ search = ["rg", *SEARCH, "-f", listed.path]
31
+ Tempfile.create("principles-raw-errors") { listed_by(requests, search, files, it) }
32
+ end
33
+ end
34
+
35
+ # Each of files the command lists, run with them in the requests folder, and whether it found one or none and
36
+ # wrote no error to errors.
37
+ #: (String, Array[String], Array[String], File) -> [Array[String], bool]
38
+ def self.listed_by(requests, command, files, errors)
39
+ printed, status = Ran.run([*command, "--", *files], requests, errors.path)
40
+ [files & printed.split("\n"), [0, 1].include?(status) && File.empty?(errors.path)]
41
+ end
42
+
43
+ # Each form a JSON writer may write pattern in inside a string.
44
+ #: (String) -> Array[String]
45
+ def self.written_forms(pattern)
46
+ [JSON.generate(pattern)[1..-2].to_s]
47
+ .flat_map { [it, it.gsub("/", "\\/")] }
48
+ .flat_map { [it, it.gsub("\u007f", "\\u007f")] }
49
+ .flat_map { |form| [form, *%w[%04x %04X].map { |hex| form.gsub(NON_ASCII) { escaped(it, hex) } }] }
50
+ .uniq
51
+ end
52
+
53
+ # character as \u escapes, a surrogate pair beyond the first plane, with hex digits as hex writes them.
54
+ #: (String, String) -> String
55
+ def self.escaped(character, hex)
56
+ character.encode("UTF-16BE").unpack("n*").map { "\\u#{format(hex, it)}" }.join
57
+ end
58
+ private_class_method :listed_by, :written_forms, :escaped
59
+ end
60
+ end
61
+ end
@@ -5,6 +5,8 @@ require_relative "git_command"
5
5
  require_relative "verified_head"
6
6
  require_relative "first_parent_log"
7
7
  require_relative "working_tree_changes"
8
+ require_relative "changes_since"
9
+ require_relative "branches_bringing_in"
8
10
  require_relative "committed_texts"
9
11
 
10
12
  module Principles
@@ -29,6 +31,8 @@ module Principles
29
31
  @texts = CommittedTexts.new(root, ->(name) { show(name) }) #: CommittedTexts
30
32
  @log = FirstParentLog.new(@git) #: FirstParentLog
31
33
  @changes = WorkingTreeChanges.new(@git) #: WorkingTreeChanges
34
+ @since = ChangesSince.new(@git) #: ChangesSince
35
+ @branches = BranchesBringingIn.new(@git) #: BranchesBringingIn
32
36
  end
33
37
 
34
38
  # A strict permission snapshot; legacy best-effort readers keep their existing behavior.
@@ -42,11 +46,16 @@ module Principles
42
46
  ok && output.strip == "true"
43
47
  end
44
48
 
45
- # The user name git commits as here, or nil when none is set.
46
- #: () -> String?
47
- def user_name
48
- name, ok = git(["config", "user.name"])
49
- ok && !name.strip.empty? ? name.strip : nil
49
+ # The project's root at its place in the repository's main checkout, which a worktree shares its history with;
50
+ # in the main checkout, or outside git, the project's own root.
51
+ #: () -> String
52
+ def main_checkout_root
53
+ top, = git(["rev-parse", "--path-format=absolute", "--show-toplevel"])
54
+ common, ok = git(["rev-parse", "--path-format=absolute", "--git-common-dir"])
55
+ return @root unless ok
56
+
57
+ inside = File.realpath(@root).delete_prefix(File.realpath(top.strip))
58
+ File.join(File.realpath(File.dirname(common.strip)), inside)
50
59
  end
51
60
 
52
61
  # The full sha of the last commit that changed path, or nil outside git or when no commit has.
@@ -56,6 +65,14 @@ module Principles
56
65
  ok && !sha.strip.empty? ? sha.strip : nil
57
66
  end
58
67
 
68
+ # The full sha of the newest commit on at's first-parent line that changed any of paths, nil when none did. git
69
+ # stops at the first it finds, so this reads no further back than that commit.
70
+ #: (Array[String], at: String) -> String?
71
+ def last_change(paths, at:)
72
+ sha, ok = git(["log", "-1", "--first-parent", "--format=%H", "--end-of-options", revision(at), "--", *paths])
73
+ ok && !sha.strip.empty? ? sha.strip : nil
74
+ end
75
+
59
76
  # Whether path, relative to the project, is absent from the working tree.
60
77
  #: (String) -> bool
61
78
  def absent?(path)
@@ -65,16 +82,12 @@ module Principles
65
82
  # Each rename git detects between commit and the working tree, as {"from", "to", "similarity"}, with paths
66
83
  # relative to the project; none outside git or when commit is not there, as in a shallow clone.
67
84
  #: (String) -> Array[Hash[String, untyped]]
68
- def renames_since(commit)
69
- output, ok = git(["diff", "-M", "-z", "--name-status", "--relative", "--diff-filter=R", revision(commit), "--"])
70
- return [] unless ok
85
+ def renames_since(commit) = @since.renames(revision(commit))
71
86
 
72
- output.force_encoding("UTF-8").split("\0").each_slice(3).filter_map do |status, from, to|
73
- next unless status.to_s.start_with?("R") && from && to
74
-
75
- { "from" => from, "to" => to, "similarity" => status.to_s.delete_prefix("R").to_i }
76
- end
77
- end
87
+ # Each of paths that a local branch's commits not on HEAD bring in, with the branches that do, as
88
+ # BranchesBringingIn reads them.
89
+ #: (Array[String]) -> Hash[String, Array[String]]
90
+ def branches_bringing_in(paths) = @branches.of(paths)
78
91
 
79
92
  # The full sha at HEAD, or nil outside git or before the first commit.
80
93
  #: () -> String?
@@ -95,10 +108,7 @@ module Principles
95
108
  # deleted, and a rename by both its names, since git is asked to detect none. commit is a full sha, as commit_of
96
109
  # gives it, so git cannot read it as an option.
97
110
  #: (String) -> Array[String]
98
- def changed_since(commit)
99
- output, ok = git(["diff", "--name-only", "-z", "--relative", "--no-renames", revision(commit), "HEAD", "--"])
100
- ok ? output.force_encoding("UTF-8").split("\0").sort : []
101
- end
111
+ def changed_since(commit) = @since.paths(revision(commit))
102
112
 
103
113
  # Which of paths, relative to the project, are untracked or ignored, or differ from HEAD in the index
104
114
  # or the working tree. Before the first commit, every path does.
@@ -143,15 +153,7 @@ module Principles
143
153
  # The commits after commit, up to HEAD, that changed any of paths, newest first, each as its short sha and
144
154
  # subject line.
145
155
  #: (String, Array[String]) -> Array[Hash[String, String]]
146
- def commits_since(commit, paths)
147
- output, ok = git(["log", "--format=%h%x00%s", "--end-of-options", "#{revision(commit)}..HEAD", "--", *paths])
148
- return [] unless ok
149
-
150
- output.force_encoding("UTF-8").lines.map do |line|
151
- sha, subject = line.chomp.split("\0", 2)
152
- { "commit" => sha.to_s, "subject" => subject.to_s }
153
- end
154
- end
156
+ def commits_since(commit, paths) = @since.commits(revision(commit), paths)
155
157
 
156
158
  # Every commit on up_to's first-parent line, HEAD's unless given, that changed any of paths, newest first, each
157
159
  # as its full and short sha, subject line, author date and whether it is a root commit ("true" or "false"); none
@@ -0,0 +1,135 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "principles_directory"
5
+ require_relative "captured_requests"
6
+ require "fileutils"
7
+ require "json"
8
+ require "tempfile"
9
+
10
+ module Principles
11
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
12
+ module Data
13
+ # The folder where the host writes each request it sends, with the files this tool writes beside them: the
14
+ # .gitignore that has git ignore the folder, and the launch file that switches the capture. Each name is
15
+ # relative to the folder.
16
+ class RequestLoggingFolder
17
+ NAME = "request-logging"
18
+ FOLDER = "#{PrinciplesDirectory::FOLDER}/#{NAME}".freeze #: String
19
+ IGNORE = ".gitignore"
20
+ SETTINGS = "settings.json"
21
+ # The sessions this project's session-start hook registered while request logging is on in the user's own
22
+ # settings, one JSON object a line.
23
+ REGISTRY = "sessions.jsonl"
24
+ REQUESTS = "requests"
25
+ # The host's one line per response it received, naming the request and response files and the session.
26
+ INDEX = "#{REQUESTS}/#{CapturedRequests::INDEX}".freeze #: String
27
+
28
+ #: (String) -> void
29
+ def initialize(root)
30
+ @root = root
31
+ @directory = PrinciplesDirectory.new(root, NAME) #: PrinciplesDirectory
32
+ freeze
33
+ end
34
+
35
+ # name as a path relative to the project.
36
+ #: (String) -> String
37
+ def relative(name) = "#{FOLDER}/#{name}"
38
+
39
+ # name as an absolute path, as a launch file must name the folder the host writes to.
40
+ #: (String) -> String
41
+ def absolute(name) = File.join(@root, FOLDER, name)
42
+
43
+ #: () -> bool
44
+ def exist? = File.directory?(@directory.path)
45
+
46
+ # Every file in the folder, as a name relative to it, sorted.
47
+ #: () -> Array[String]
48
+ def files
49
+ base = @directory.path
50
+ Dir.glob("**/*", File::FNM_DOTMATCH, base: base).select { |name| File.file?(File.join(base, name)) }.sort
51
+ end
52
+
53
+ # The host's requests/ folder here, with what it wrote there.
54
+ #: () -> CapturedRequests
55
+ def requests = CapturedRequests.new(File.join(@directory.path, REQUESTS), shown_as: relative(REQUESTS))
56
+
57
+ # Every file the host wrote under requests/, but its index, sorted by name.
58
+ #: () -> Array[CapturedRequests::CapturedFile]
59
+ def captured_files = requests.captured_files
60
+
61
+ # Each line of the host's index, leaving out a line that is not a JSON object naming a session and its files.
62
+ #: () -> Array[CapturedRequests::IndexLine]
63
+ def index_lines = requests.index_lines
64
+
65
+ # Writes name, creating the folder readable only by its owner, since what it holds is a whole session's context.
66
+ #: (String, String) -> void
67
+ def write(name, text)
68
+ target = File.join(@directory.path, name)
69
+ FileUtils.mkdir_p(File.dirname(target), mode: 0o700)
70
+ Tempfile.create(["request-logging", ".tmp"], File.dirname(target)) do |temporary|
71
+ temporary.write(text)
72
+ temporary.flush
73
+ File.rename(temporary.path, target)
74
+ end
75
+ end
76
+
77
+ # Each line of the registry, as written; none while it is absent.
78
+ #: () -> Array[String]
79
+ def registry_lines
80
+ path = File.join(@directory.path, REGISTRY)
81
+ File.file?(path) ? File.readlines(path, chomp: true) : []
82
+ end
83
+
84
+ # Each session the registry names, in the order it was registered, leaving out a line that names none.
85
+ #: () -> Array[String]
86
+ def registered_session_ids = RegistryLines.new(registry_lines).session_ids
87
+
88
+ # Adds line to the end of the registry, so two sessions starting at once each keep theirs.
89
+ #: (String) -> void
90
+ def append_to_registry(line)
91
+ File.open(File.join(@directory.path, REGISTRY), "a", 0o600) { it.write("#{line}\n") }
92
+ end
93
+
94
+ # Writes the launch file, its fields as JSON.
95
+ #: (Hash[String, untyped]) -> void
96
+ def write_settings(fields) = write(SETTINGS, "#{JSON.pretty_generate(fields)}\n")
97
+
98
+ #: (String) -> void
99
+ def remove(name) = File.delete(File.join(@directory.path, name))
100
+
101
+ # Removes one file the host wrote directly under requests/, refusing any other name.
102
+ #: (String) -> void
103
+ def remove_request(name) = requests.remove_request(name)
104
+
105
+ # The requests the host captured here, scanned by jq and rg.
106
+ #: () -> LoggedRequestScan
107
+ def scan = requests.scan
108
+
109
+ # Removes the folder when nothing is left in it.
110
+ #: () -> void
111
+ def remove_if_empty
112
+ Dir.rmdir(@directory.path) if exist? && Dir.empty?(@directory.path)
113
+ end
114
+ end
115
+
116
+ # The registry's lines read as the sessions they name, shared by the folder and its stand-in.
117
+ class RegistryLines
118
+ #: (Array[String]) -> void
119
+ def initialize(lines)
120
+ @lines = lines
121
+ freeze
122
+ end
123
+
124
+ #: () -> Array[String]
125
+ def session_ids
126
+ @lines.filter_map do |line|
127
+ fields = JSON.parse(line)
128
+ fields["session_id"] if fields.is_a?(Hash) && fields["session_id"].is_a?(String)
129
+ rescue JSON::ParserError
130
+ nil
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,33 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
6
+ module Data
7
+ # A captured request's shape, as the scan reads it: how many tools it lists, how many messages it holds, how its
8
+ # last message ends, text, tool_result or other, and its thread role, continues when it names the message before
9
+ # it in the host's server-side thread, starts when its thread names none, and none without one: each a fixed
10
+ # word, never the request's own text. A plain class, not ::Data.define, since Sorbet's strict level needs a
11
+ # signature for each reader.
12
+ class RequestShape
13
+ #: (tools: Integer, messages: Integer, ending: String, ?thread: String) -> void
14
+ def initialize(tools:, messages:, ending:, thread: "none")
15
+ @tools = tools
16
+ @messages = messages
17
+ @ending = ending
18
+ @thread = thread
19
+ freeze
20
+ end
21
+
22
+ #: Integer
23
+ attr_reader :tools, :messages
24
+
25
+ #: String
26
+ attr_reader :ending, :thread
27
+
28
+ # Whether the request continues a thread, sending only what it adds to the one before.
29
+ #: () -> bool
30
+ def continues_thread? = @thread == "continues"
31
+ end
32
+ end
33
+ end
@@ -12,7 +12,7 @@ module Principles
12
12
  class RunningVersion
13
13
  # git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
14
14
  # export-subst; a checkout keeps the placeholder as written.
15
- ARCHIVED_COMMIT = "9e955b6b" #: String
15
+ ARCHIVED_COMMIT = "bc6c8da7" #: String
16
16
 
17
17
  #: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
18
18
  def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "acknowledgement-answer.schema.json",
4
4
  "title": "Acknowledgement answer",
5
- "description": "What an agent answers a one-member audit with: the request id and basis, and under members one entry keyed by the member id, as an answer for several members holds it, saying whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it, or \"\" for a side with no line the other lacks; a quote left out, as is the basis's base_commit, which the request id already pins, is read as the request's first_changed_lines printed it. Fields this tool does not read are refused. Models::Acknowledgement checks the quotes and the reason.",
5
+ "description": "What an agent answers a one-member audit with: the request id and basis, and under members one entry keyed by the member id, as an answer for several members holds it, saying whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it, or \"\" for a side with no line the other lacks; a quote left out, as is the basis's base_commit, which the request id already pins, is read as the request's first_changed_lines printed it. Fields this tool does not read are refused, but for answer_with and each entry's role, which the template printed alone carries for the agent to read and which are read as nothing. Models::Acknowledgement checks the quotes and the reason.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "required": [
@@ -14,6 +14,10 @@
14
14
  "request_id": {
15
15
  "type": "string"
16
16
  },
17
+ "answer_with": {
18
+ "type": "string",
19
+ "description": "The command that submits this answer from the file it is saved in, as the template printed alone carries it. Sent back, it is read as nothing."
20
+ },
17
21
  "basis": {
18
22
  "type": "object",
19
23
  "additionalProperties": false,
@@ -49,6 +53,17 @@
49
53
  "reason"
50
54
  ],
51
55
  "properties": {
56
+ "roles": {
57
+ "type": "object",
58
+ "additionalProperties": {
59
+ "type": "string"
60
+ },
61
+ "description": "The member's role by each principle that maps it, which the template printed alone across principles carries beside meaning_kept for the agent judging it. Sent back, it is read as nothing."
62
+ },
63
+ "role": {
64
+ "type": "string",
65
+ "description": "The member's role as its map names it, which the template printed alone carries beside meaning_kept for the agent judging it. Sent back, it is read as nothing."
66
+ },
52
67
  "meaning_kept": {
53
68
  "type": "boolean"
54
69
  },
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "acknowledgements-answer.schema.json",
4
4
  "title": "Acknowledgements answer",
5
- "description": "What an agent answers a request to acknowledge several members of one principle, or the members several principles map, holding: the request's id, its basis naming each member, and under members one entry per member, keyed by its id, holding what a one-member answer holds beside its head. Fields this tool does not read are refused. Models::Acknowledgements refuses an answer whose members differ from its basis, and each entry is checked as Models::Acknowledgement checks a one-member answer.",
5
+ "description": "What an agent answers a request to acknowledge several members of one principle, or the members several principles map, holding: the request's id, its basis naming each member, and under members one entry per member, keyed by its id, holding what a one-member answer holds beside its head. Fields this tool does not read are refused, but for answer_with and each entry's role, or roles across principles, which the template printed alone carries for the agent to read and which are read as nothing. Models::Acknowledgements refuses an answer whose members differ from its basis, and each entry is checked as Models::Acknowledgement checks a one-member answer.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "required": [
@@ -14,6 +14,10 @@
14
14
  "request_id": {
15
15
  "type": "string"
16
16
  },
17
+ "answer_with": {
18
+ "type": "string",
19
+ "description": "The command that submits this answer from the file it is saved in, as the template printed alone carries it. Sent back, it is read as nothing."
20
+ },
17
21
  "basis": {
18
22
  "type": "object",
19
23
  "additionalProperties": false,
@@ -47,6 +51,17 @@
47
51
  "reason"
48
52
  ],
49
53
  "properties": {
54
+ "roles": {
55
+ "type": "object",
56
+ "additionalProperties": {
57
+ "type": "string"
58
+ },
59
+ "description": "The member's role by each principle that maps it, which the template printed alone across principles carries beside meaning_kept for the agent judging it. Sent back, it is read as nothing."
60
+ },
61
+ "role": {
62
+ "type": "string",
63
+ "description": "The member's role as its map names it, which the template printed alone carries beside meaning_kept for the agent judging it. Sent back, it is read as nothing."
64
+ },
50
65
  "meaning_kept": {
51
66
  "type": "boolean"
52
67
  },
@@ -57,6 +57,10 @@
57
57
  "carried_forward": {
58
58
  "const": true
59
59
  },
60
+ "judge_because": {
61
+ "type": "string",
62
+ "description": "Why the request judges this member afresh, as its template prints it; sent back or not, Models::MemberAssessments keeps nothing from it."
63
+ },
60
64
  "assessment": {
61
65
  "type": "string"
62
66
  },
@@ -232,6 +236,10 @@
232
236
  "required": ["finding_id", "decision"],
233
237
  "properties": {
234
238
  "finding_id": { "type": "string" },
239
+ "finding_problem": {
240
+ "type": "string",
241
+ "description": "The finding's problem as the template prints it beside its decision, for the agent deciding it to read. Sent back, it is read as nothing; problem restates the finding."
242
+ },
235
243
  "decision": { "type": ["string", "null"] },
236
244
  "reason": { "type": "string" },
237
245
  "as": { "type": "string" },
@@ -72,7 +72,7 @@
72
72
  "usage": { "$ref": "#/$defs/prose" },
73
73
  "group": { "$ref": "#/$defs/slug" },
74
74
  "options": { "type": "array", "uniqueItems": true,
75
- "items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "only", "confirm", "lines", "open-findings", "history"] } },
75
+ "items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "plugin", "role", "name", "reason", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "only", "confirm", "lines", "open-findings", "history", "loads", "keep-sessions", "findings", "places", "for-user", "session"] } },
76
76
  "requires": { "type": "array", "uniqueItems": true, "items": { "enum": ["file"] } },
77
77
  "summary": { "$ref": "#/$defs/prose" },
78
78
  "help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
@@ -14,12 +14,13 @@
14
14
  "properties": {
15
15
  "fixed": {
16
16
  "type": "object",
17
- "required": ["action", "reason", "changed_members", "removed_members", "evidence", "reassessment", "recorded_at"],
17
+ "required": ["action", "reason", "changed_members", "changed_map_entries", "removed_members", "evidence", "reassessment", "recorded_at"],
18
18
  "additionalProperties": false,
19
19
  "properties": {
20
20
  "action": { "const": "fixed" },
21
21
  "reason": { "type": "string", "minLength": 1 },
22
22
  "changed_members": { "type": "array", "items": { "type": "string" } },
23
+ "changed_map_entries": { "type": "array", "items": { "type": "string" } },
23
24
  "removed_members": { "type": "array", "items": { "type": "string" } },
24
25
  "evidence": { "type": "array", "items": { "type": "object" } },
25
26
  "reassessment": { "type": "string", "minLength": 1 },
@@ -241,6 +241,20 @@
241
241
  "waits_on": {
242
242
  "type": ["string", "null"],
243
243
  "description": "On a deferral, one line saying whom it waits on and to decide what; null on any disposition. Models::CorrectionAnswer refuses a value on another action, or one not one line."
244
+ },
245
+ "unfixed_part": {
246
+ "type": "object",
247
+ "additionalProperties": false,
248
+ "required": ["id", "problem", "action", "reason"],
249
+ "description": "On a fix that settles only part of its finding, the part left unfixed, raised as a new finding of the finding's members under its own id, deferred or accepted as a disposition is. Models::Disposition refuses it on any other action.",
250
+ "properties": {
251
+ "id": { "type": "string" },
252
+ "problem": { "type": "string" },
253
+ "action": { "type": ["string", "null"] },
254
+ "reason": { "type": "string" },
255
+ "recorded_at": {"x-type-refusal-advice":{"keys":["path","url","heading","starting_at","ending_at","query"],"says":"with path, plus starting_at (or heading) when the file holds more than this finding, or with url alone, a whole https link, for a write-up outside the project such as an issue"},"type":["object","null"],"additionalProperties":false,"properties":{"path":{"type":"string"},"url":{"type":"string"},"heading":{"type":"string"},"starting_at":{"type":"string"},"ending_at":{"type":"string"},"query":{"type":"string"}}},
256
+ "waits_on": {"type":["string","null"]}
257
+ }
244
258
  }
245
259
  }
246
260
  }
@@ -30,8 +30,19 @@
30
30
  "query": { "type": "string", "minLength": 1 },
31
31
  "ending_at": { "type": "string", "minLength": 1 },
32
32
  "role": { "type": "string", "minLength": 1 },
33
+ "name": { "type": "string", "minLength": 1, "description": "A short name stating the member's intent, shown first in output. Display only: commands take the member's id, never its name." },
34
+ "reason": { "type": "string", "minLength": 1, "description": "Why this member's carrier and place put the principle in context when its work is in hand and keep it out otherwise, ending in the observation that would show it false, named by host channel or seen_only_as_read. A full audit asks whether it still holds." },
33
35
  "key": { "type": "string", "minLength": 1, "description": "What the member is known by across moves, which its audit record files its hash under. Absent, it is the member's id. move-member stores the old id here on a member's first move, and add-member gives a member a key of its own when its id is the key of a member that moved away." },
34
- "check": { "type": "string", "minLength": 1, "description": "The command that enforces this member, which an audit asks the agent to run and report. This tool never runs it." }
36
+ "check": { "type": "string", "minLength": 1, "description": "The command that enforces this member, which an audit asks the agent to run and report. This tool never runs it." },
37
+ "pinned": {
38
+ "type": "object",
39
+ "description": "For a member read from an installed plugin: the version the host had installed when it was mapped, and the SHA-256 of the member's text then. Only the hash says whether the text changed; the version is shown for information.",
40
+ "required": ["version", "sha256"],
41
+ "properties": {
42
+ "version": { "type": "string", "minLength": 1 },
43
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
44
+ }
45
+ }
35
46
  }
36
47
  }
37
48
  }
@@ -0,0 +1,26 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+
6
+ module Principles
7
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
8
+ module Data
9
+ # The names of the env entries a Claude Code settings file sets, never their values, since the file can hold the
10
+ # user's tokens.
11
+ module SettingsEnvKeys
12
+ # Each name the text's env sets, none when it sets no env, or nil when the text is not a JSON object whose env
13
+ # is an object.
14
+ #: (String) -> Array[String]?
15
+ def self.of(text)
16
+ settings = JSON.parse(text)
17
+ return nil unless settings.is_a?(Hash)
18
+
19
+ env = settings.fetch("env", {})
20
+ env.is_a?(Hash) ? env.keys : nil
21
+ rescue JSON::ParserError
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,39 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "tempfile"
5
+ require_relative "ran"
6
+
7
+ module Principles
8
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
9
+ module Data
10
+ # How many strings each of some request files holds, counted by one jq run without decoding them, for the requests
11
+ # the raw filter leaves undecoded, so the scan still says how much it read.
12
+ module StringCounts
13
+ # Each request with its count, as request<TAB>count.
14
+ COUNT = '"\(input_filename | split("/") | last)\t\([.. | strings] | length)"'
15
+
16
+ # Each of files, in the requests folder, with its count of strings, and whether jq read every file through and
17
+ # wrote no error, whose words are never kept, since they can quote a value from a request.
18
+ #: (String, Array[String]) -> [Hash[String, Integer], bool]
19
+ def self.of(requests, files)
20
+ return [{}, true] if files.empty?
21
+
22
+ Tempfile.create("principles-count-errors") do |errors|
23
+ printed, status = Ran.run(["jq", "-r", COUNT, *files], requests, errors.path)
24
+ [counted(printed), [0].include?(status) && File.empty?(errors.path)]
25
+ end
26
+ end
27
+
28
+ # Each request jq printed, with its count.
29
+ #: (String) -> Hash[String, Integer]
30
+ def self.counted(printed)
31
+ printed.split("\n").to_h do |line|
32
+ request, count = line.split("\t", 2)
33
+ [request.to_s, Integer(count)]
34
+ end
35
+ end
36
+ private_class_method :counted
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ # Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
6
+ module Data
7
+ # The fast standard tools PATH holds, such as jq and rg, which a bulk scan runs in place of Ruby: a tool is on
8
+ # PATH when a folder on it holds an executable file of that name.
9
+ class ToolsOnPath
10
+ #: (String) -> void
11
+ def initialize(path)
12
+ @folders = path.split(File::PATH_SEPARATOR).reject(&:empty?) #: Array[String]
13
+ freeze
14
+ end
15
+
16
+ #: (String) -> bool
17
+ def include?(tool)
18
+ @folders.any? do |folder|
19
+ found = File.join(folder, tool)
20
+ File.file?(found) && File.executable?(found)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end