principles 0.0.5 → 0.0.7

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 (192) hide show
  1. checksums.yaml +4 -4
  2. data/lib/principles/after_commit_hook_options.rb +4 -1
  3. data/lib/principles/cli.rb +9 -0
  4. data/lib/principles/command_line.rb +31 -30
  5. data/lib/principles/command_routes.rb +9 -3
  6. data/lib/principles/controllers/acknowledgement.rb +82 -95
  7. data/lib/principles/controllers/answer.rb +14 -11
  8. data/lib/principles/controllers/assessment.rb +27 -24
  9. data/lib/principles/controllers/audit.rb +24 -4
  10. data/lib/principles/controllers/audit_completion.rb +10 -4
  11. data/lib/principles/controllers/command.rb +2 -2
  12. data/lib/principles/controllers/correction.rb +16 -7
  13. data/lib/principles/controllers/full_audit_request.rb +8 -3
  14. data/lib/principles/controllers/guidance_search_paths.rb +31 -0
  15. data/lib/principles/controllers/inventory.rb +3 -22
  16. data/lib/principles/controllers/mapping.rb +9 -1
  17. data/lib/principles/controllers/member_acknowledgement.rb +137 -0
  18. data/lib/principles/controllers/member_addition.rb +65 -0
  19. data/lib/principles/controllers/member_entries.rb +6 -24
  20. data/lib/principles/controllers/member_problems_report.rb +33 -25
  21. data/lib/principles/controllers/members_to_assess.rb +1 -1
  22. data/lib/principles/controllers/meta_principle_setup.rb +1 -1
  23. data/lib/principles/controllers/repoint.rb +5 -2
  24. data/lib/principles/controllers/survey.rb +60 -0
  25. data/lib/principles/data/audit_files.rb +4 -0
  26. data/lib/principles/data/candidate_files_found.rb +48 -13
  27. data/lib/principles/data/command-steps.json +86 -25
  28. data/lib/principles/data/committed_tree.rb +84 -0
  29. data/lib/principles/data/first_parent_log.rb +48 -0
  30. data/lib/principles/data/first_parent_range.rb +122 -0
  31. data/lib/principles/data/git_command.rb +37 -0
  32. data/lib/principles/data/guidance_search_paths_file.rb +107 -0
  33. data/lib/principles/data/map_files.rb +35 -10
  34. data/lib/principles/data/principles_directory.rb +40 -0
  35. data/lib/principles/data/principles_subfolder.rb +39 -16
  36. data/lib/principles/data/project_files.rb +11 -3
  37. data/lib/principles/data/repository.rb +55 -29
  38. data/lib/principles/data/requested_candidate_files.rb +43 -0
  39. data/lib/principles/data/running_version.rb +3 -5
  40. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +6 -6
  41. data/lib/principles/data/schemas/acknowledgements-answer.schema.json +88 -0
  42. data/lib/principles/data/schemas/answer-guide.schema.json +255 -63
  43. data/lib/principles/data/schemas/assessment-answer.schema.json +15 -1
  44. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  45. data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
  46. data/lib/principles/data/schemas/correction-answer.schema.json +12 -54
  47. data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
  48. data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
  49. data/lib/principles/data/verified_head.rb +162 -0
  50. data/lib/principles/invocation_options.rb +5 -4
  51. data/lib/principles/list_open_findings_options.rb +23 -0
  52. data/lib/principles/models/acknowledged_check.rb +94 -0
  53. data/lib/principles/models/acknowledgement.rb +40 -36
  54. data/lib/principles/models/acknowledgement_left_as_printed.rb +72 -0
  55. data/lib/principles/models/acknowledgements.rb +99 -0
  56. data/lib/principles/models/answered_time.rb +9 -0
  57. data/lib/principles/models/assessment_report.rb +13 -13
  58. data/lib/principles/models/audit.rb +17 -4
  59. data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
  60. data/lib/principles/models/audit_record.rb +9 -0
  61. data/lib/principles/models/audit_records.rb +34 -8
  62. data/lib/principles/models/candidate_files.rb +17 -6
  63. data/lib/principles/models/candidate_inventory.rb +51 -7
  64. data/lib/principles/models/captured_head.rb +72 -0
  65. data/lib/principles/models/check_since_last_audit.rb +4 -8
  66. data/lib/principles/models/correction_basis.rb +14 -5
  67. data/lib/principles/models/declared_map_changes.rb +25 -9
  68. data/lib/principles/models/declared_member_removals.rb +75 -0
  69. data/lib/principles/models/disposition.rb +4 -2
  70. data/lib/principles/models/fix_only_fields.rb +12 -0
  71. data/lib/principles/models/guidance_search_path.rb +26 -0
  72. data/lib/principles/models/guidance_search_paths.rb +57 -0
  73. data/lib/principles/models/line_span.rb +6 -0
  74. data/lib/principles/models/list_member_problems_check.rb +80 -0
  75. data/lib/principles/models/listed_members.rb +49 -0
  76. data/lib/principles/models/loaded_files.rb +1 -2
  77. data/lib/principles/models/loading_decision.rb +17 -8
  78. data/lib/principles/models/loading_scope.rb +61 -0
  79. data/lib/principles/models/loads_to_check.rb +0 -1
  80. data/lib/principles/models/locator.rb +6 -0
  81. data/lib/principles/models/mapped_principles.rb +39 -37
  82. data/lib/principles/models/member_assessments.rb +11 -2
  83. data/lib/principles/models/member_file.rb +20 -71
  84. data/lib/principles/models/member_history.rb +7 -5
  85. data/lib/principles/models/member_loading_scopes.rb +49 -0
  86. data/lib/principles/models/member_loads.rb +4 -0
  87. data/lib/principles/models/member_mapping_run.rb +30 -0
  88. data/lib/principles/models/member_moves.rb +4 -0
  89. data/lib/principles/models/member_problems.rb +57 -29
  90. data/lib/principles/models/member_region.rb +129 -0
  91. data/lib/principles/models/member_repair_moves.rb +9 -11
  92. data/lib/principles/models/member_sighting.rb +5 -8
  93. data/lib/principles/models/member_snapshots.rb +14 -1
  94. data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
  95. data/lib/principles/models/meta_principle.rb +14 -0
  96. data/lib/principles/models/missing_files.rb +2 -2
  97. data/lib/principles/models/other_templates_placeholders.rb +1 -1
  98. data/lib/principles/models/outline_budget.rb +29 -14
  99. data/lib/principles/models/principle.rb +14 -7
  100. data/lib/principles/models/principle_file_revision.rb +48 -0
  101. data/lib/principles/models/principle_history.rb +46 -19
  102. data/lib/principles/models/principle_lineage.rb +118 -0
  103. data/lib/principles/models/principle_map_revision.rb +39 -0
  104. data/lib/principles/models/principle_mapping_history.rb +132 -0
  105. data/lib/principles/models/principle_members.rb +14 -0
  106. data/lib/principles/models/principle_predecessor.rb +45 -0
  107. data/lib/principles/models/principle_publication.rb +177 -0
  108. data/lib/principles/models/principle_revision.rb +104 -0
  109. data/lib/principles/models/problem_report.rb +36 -9
  110. data/lib/principles/models/project.rb +47 -30
  111. data/lib/principles/models/project_history.rb +45 -25
  112. data/lib/principles/models/record_format.rb +6 -0
  113. data/lib/principles/models/reported_check.rb +16 -12
  114. data/lib/principles/models/request_id.rb +1 -1
  115. data/lib/principles/models/sent_answer.rb +35 -5
  116. data/lib/principles/models/survey_search_paths.rb +26 -0
  117. data/lib/principles/models/uncommitted_files.rb +50 -0
  118. data/lib/principles/models/unknown_principle.rb +29 -0
  119. data/lib/principles/positional_arguments.rb +38 -0
  120. data/lib/principles/session_start_options.rb +3 -3
  121. data/lib/principles/start_audit_options.rb +10 -2
  122. data/lib/principles/version.rb +2 -2
  123. data/lib/principles/views/acknowledgement_result.rb +54 -16
  124. data/lib/principles/views/added_member.rb +41 -0
  125. data/lib/principles/views/answered_request.rb +21 -0
  126. data/lib/principles/views/assessed_members.rb +26 -5
  127. data/lib/principles/views/assessment_request.rb +24 -4
  128. data/lib/principles/views/audit_result.rb +30 -27
  129. data/lib/principles/views/candidate_files_result.rb +56 -12
  130. data/lib/principles/views/candidate_outlines_result.rb +25 -0
  131. data/lib/principles/views/check_result_template.rb +18 -17
  132. data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
  133. data/lib/principles/views/correction_request.rb +38 -10
  134. data/lib/principles/views/findings_result.rb +21 -0
  135. data/lib/principles/views/guidance_search_paths_result.rb +26 -0
  136. data/lib/principles/views/invocation.rb +19 -4
  137. data/lib/principles/views/json_with_entries_on_lines.rb +12 -4
  138. data/lib/principles/views/loads_to_check_result.rb +3 -2
  139. data/lib/principles/views/map_added_to.rb +56 -2
  140. data/lib/principles/views/map_result.rb +22 -42
  141. data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
  142. data/lib/principles/views/member_change_since_baseline.rb +2 -1
  143. data/lib/principles/views/member_repairs.rb +2 -1
  144. data/lib/principles/views/member_row.rb +61 -0
  145. data/lib/principles/views/members_a_commit_changed.rb +2 -1
  146. data/lib/principles/views/members_with_no_baseline.rb +8 -1
  147. data/lib/principles/views/new_loading_scope.rb +31 -0
  148. data/lib/principles/views/one_member_check_result_template.rb +37 -21
  149. data/lib/principles/views/open_findings_line.rb +2 -1
  150. data/lib/principles/views/principle_read_result.rb +4 -1
  151. data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
  152. data/lib/principles/views/problem_lines.rb +50 -45
  153. data/lib/principles/views/problem_result.rb +59 -25
  154. data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
  155. data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -3
  156. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
  157. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -6
  158. data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -43
  159. data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
  160. data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
  161. data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
  162. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
  163. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +12 -0
  164. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
  165. data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
  166. data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
  167. data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +4 -2
  168. data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
  169. data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +2 -2
  170. data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
  171. data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
  172. data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
  173. data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
  174. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
  175. data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
  176. data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
  177. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +37 -4
  178. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +20 -19
  179. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
  180. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
  181. data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
  182. data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
  183. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +33 -7
  184. data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
  185. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +10 -10
  186. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
  187. data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
  188. data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +1 -1
  189. data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
  190. data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
  191. metadata +67 -4
  192. data/lib/principles/models/candidate_listing.rb +0 -41
@@ -0,0 +1,31 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Principles
5
+ module Views
6
+ # A new known scope's literal facts and the availability question, from plain values only.
7
+ class NewLoadingScope
8
+ UNKNOWN_LIMIT = "Unknown scopes in not_compared remain limitations. "
9
+
10
+ #: (?Hash[String, untyped]) -> void
11
+ def initialize(facts = {})
12
+ @facts = facts
13
+ freeze
14
+ end
15
+
16
+ #: () -> Hash[String, untyped]
17
+ def to_h = @facts.empty? ? {} : { "new_loading_scope" => @facts }
18
+
19
+ #: () -> String
20
+ def note
21
+ return "" if @facts.empty?
22
+
23
+ "Claude Code loading derivation, assuming a session at the project root, gives this member a known " \
24
+ "scope not already represented (new_loading_scope). Will each carrier be available where this principle " \
25
+ "applies, or should one link to another carrier? These are predictions, not observed delivery; " \
26
+ "literal paths do not establish glob coverage. " \
27
+ "#{UNKNOWN_LIMIT if @facts.fetch("not_compared", []).any?}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -8,35 +8,51 @@ module Principles
8
8
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
9
9
  module Views
10
10
  # The check_result a one-member audit's template starts with for a checked member, whose check is the one the last
11
- # audit ran, since any other is refused at its start (#1071). It asks for a passing run alone, since one that fails
12
- # or cannot run is refused as a full audit's to judge, so it prints no not_run_reason and says nothing of how often
13
- # full audits run it (#1112).
11
+ # audit ran, since any other is refused at its start (#1071), and the instruction its request gives beside it. It
12
+ # asks for a passing run alone, since one that fails or cannot run is refused as a full audit's to judge, so it
13
+ # prints no not_run_reason and says nothing of how often full audits run it (#1112). Its exit_status holds a short
14
+ # placeholder where the integer goes, and what to do, with what the check hides and the line its last review rested
15
+ # on, is the instruction's (#1170).
14
16
  class OneMemberCheckResultTemplate
15
- # The template for the checked member a request lists as entry, with its check, how that stands to the last
16
- # audit's and any hidden characters in it; nil for a member without a check. review_basis is the text it prints
17
- # there, which an answer leaves as printed to keep the line the last audit kept (#1010).
18
- #: (Hash[String, untyped], review_basis: String) -> Hash[String, untyped]?
19
- def self.for(entry, review_basis:)
20
- check = entry["check"] or return
21
- new(check, CheckNotes.new(entry["check_since_last_audit"], entry.fetch("check_hidden_characters", [])),
22
- review_basis:).to_h
17
+ # The template for the checked member a request lists as entry, with how its check stands to the last audit's
18
+ # and any hidden characters in it; nil for a member without a check. exit_status is the placeholder it prints
19
+ # there, its one field: the answer reads the command as the request printed it and keeps the line the last
20
+ # review rested on, so neither is printed to fill (#1166, #1170). own_listing says the check is this tool's own
21
+ # list-member-problems, which exits 3 while it lists the member (#1276).
22
+ #: (Hash[String, untyped], exit_status: String, ?own_listing: bool) -> OneMemberCheckResultTemplate?
23
+ def self.for(entry, exit_status:, own_listing: false)
24
+ return unless entry["check"]
25
+
26
+ new(CheckNotes.new(entry["check_since_last_audit"], entry.fetch("check_hidden_characters", [])), exit_status:,
27
+ own_listing:)
23
28
  end
24
29
 
25
- #: (String, CheckNotes, review_basis: String) -> void
26
- def initialize(check, notes, review_basis:)
27
- @check = check
30
+ #: (CheckNotes, exit_status: String, ?own_listing: bool) -> void
31
+ def initialize(notes, exit_status:, own_listing: false)
28
32
  @notes = notes
29
- @review_basis = review_basis
33
+ @exit_status = exit_status
34
+ @own_listing = own_listing
30
35
  freeze
31
36
  end
32
37
 
38
+ # The check_result to fill, with an empty listed_members slot for this tool's own list-member-problems, whose
39
+ # instruction says what goes there (#1278).
33
40
  #: () -> Hash[String, untyped]
34
- def to_h
35
- { "command" => @check,
36
- "exit_status" => [@notes.hidden_characters,
37
- Prompts.text("acknowledge-a-change/run-the-check-and-report-it-passing"),
38
- *@notes.kept_review].compact.join(" "),
39
- "review_basis" => @review_basis }
41
+ def to_h = { "exit_status" => @exit_status, **(@own_listing ? { "listed_members" => [] } : {}) }
42
+
43
+ # What to do before filling exit_status, which the request gives as context.check_instruction.
44
+ #: () -> String
45
+ def instruction
46
+ [@notes.hidden_characters, Prompts.text("acknowledge-a-change/run-the-check-and-report-it-passing"),
47
+ *@notes.kept_review, own_listing].compact.join(" ")
48
+ end
49
+
50
+ private
51
+
52
+ # What to report for this tool's own list-member-problems, which exits 3 while it lists the member (#1276).
53
+ #: () -> String?
54
+ def own_listing
55
+ Prompts.text("acknowledge-a-change/report-the-exit-status-its-own-listing-gives") if @own_listing
40
56
  end
41
57
  end
42
58
  end
@@ -88,7 +88,8 @@ module Principles
88
88
  findings: "#{how_long(waiting)} (#{named(waiting)})",
89
89
  without_waits_on: without_waits_on(count, waiting.fetch("without_waits_on", 0)),
90
90
  write_ups: write_ups(not_found),
91
- them: them, each: each, command: @invocation.in_project("list-open-findings"))
91
+ them: them, each: each,
92
+ command: @invocation.in_project("list-open-findings", options: ["--lines"]))
92
93
  end
93
94
 
94
95
  # A resumed session's line: its conversation already holds the line printed when that context began, so this
@@ -63,7 +63,10 @@ module Principles
63
63
 
64
64
  audit = "To audit it: #{@invocation.in_project("start-audit", usage: "ID")}" if one_to_audit
65
65
  waits = waited_on(waiting) unless waiting.empty?
66
- ["To see a principle's members: #{@invocation.in_project("show-principle", usage: "ID")}", audit, waits].compact
66
+ ["To see a principle's members: #{@invocation.in_project("show-principle", usage: "ID")}", audit,
67
+ "To survey this project: #{@invocation.in_project("list-candidate-files")}",
68
+ "To survey the principles a change carries: " \
69
+ "#{@invocation.in_project("list-candidate-files", usage: "--commits-after REV")}", waits].compact
67
70
  end
68
71
 
69
72
  # The principles whose audits wait on an upgrade, and how to update, once for each way the records name.
@@ -18,12 +18,18 @@ module Principles
18
18
  freeze
19
19
  end
20
20
 
21
+ # The lack of a completed audit, independent of whether the map is committed or has members yet.
21
22
  #: () -> String
22
- def to_s
23
+ def notice
23
24
  one = @ids.length == 1
24
25
  carry = one ? "its members carry it" : "their members carry them"
25
- "No full audit has completed for #{ProseList.new(@ids)}, so whether #{carry} is unknown. " \
26
- "To start #{one ? "one" : "each"}:\n#{@audits.join("\n")}"
26
+ "No full audit has completed for #{ProseList.new(@ids)} (#{@ids.length} principle#{"s" unless one}), " \
27
+ "so whether #{carry} is unknown."
28
+ end
29
+
30
+ #: () -> String
31
+ def to_s
32
+ "#{notice} To start #{@ids.length == 1 ? "one" : "each"}:\n#{@audits.join("\n")}"
27
33
  end
28
34
  end
29
35
  end
@@ -1,8 +1,10 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "member_row"
4
5
  require_relative "visible_text"
5
6
  require_relative "invocation"
7
+ require_relative "prompts"
6
8
 
7
9
  module Principles
8
10
  # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
@@ -11,15 +13,13 @@ module Principles
11
13
  Lines = Struct.new(:stdout, :stderr, :status, keyword_init: true)
12
14
 
13
15
  # list-member-problems --short, for a commit hook or heartbeat that acts on an exit status and short lines
14
- # alone (#291): one tab-separated line per changed member on stdout, exit 3 when a member an audit assessed
15
- # changed and 4 when only members no audit assessed were edited (D44), and on stderr what to do next and
16
+ # alone (#291): one tab-separated line per changed member on stdout, then one per principle counting its members
17
+ # no audit has assessed (#1254), exit 3 when there is any line to act on, and on stderr what to do next and
16
18
  # anything an empty stdout would hide.
17
19
  class ProblemLines
18
- # The exit status that says a member's own text changed since an audit or acknowledgement assessed it; 1 and
19
- # 2 already mean refused and usage error.
20
+ # The exit status that says a member's own text changed since an audit or acknowledgement assessed it, or that
21
+ # no audit has assessed a member; 1 and 2 already mean refused and usage error.
20
22
  CHANGED = 3
21
- # The exit status that says only members no audit has assessed were edited since they were mapped.
22
- UNASSESSED_ONLY = 4
23
23
 
24
24
  NO_MAPS = "No principle is mapped in this project, so there is nothing to check."
25
25
 
@@ -30,58 +30,63 @@ module Principles
30
30
  end
31
31
 
32
32
  # report is list-member-problems' JSON result: its "members", "counts" and "next_action".
33
- # assessed_change says whether a member an audit assessed changed, and unassessed_change whether a member no
34
- # audit assessed was edited since mapping; the model decides both, so the status follows from them alone.
35
- #: (Hash[String, untyped], nothing_changed: String, assessed_change: bool, unassessed_change: bool) -> Lines
36
- def short(report, nothing_changed:, assessed_change:, unassessed_change:)
37
- members = report.fetch("members")
38
- Lines.new(stdout: members.map { |member| "#{row(member)}\n" }.join,
39
- stderr: notes(report, nothing_changed).map { |note| "#{note}\n" }.join,
40
- status: status(assessed_change, unassessed_change))
33
+ # assessed_change says whether a member an audit assessed changed, and never_assessed counts, by principle,
34
+ # the members no audit has assessed; the model decides both, so the status follows from them alone.
35
+ # names_a_command says whether next_action names one, as ProblemResult says (#1279).
36
+ #: (Hash[String, untyped], nothing_changed: String, assessed_change: bool,
37
+ #| never_assessed: Hash[String, Integer], names_a_command: bool) -> Lines
38
+ def short(report, nothing_changed:, assessed_change:, never_assessed:, names_a_command:)
39
+ rows = report.fetch("members").map { MemberRow.new(it).short } +
40
+ never_assessed.map { |id, count| counted(id, count) }
41
+ Lines.new(stdout: rows.map { "#{it}\n" }.join,
42
+ stderr: notes(report, nothing_changed, names_a_command).map { |note| "#{note}\n" }.join,
43
+ status: assessed_change || !never_assessed.empty? ? CHANGED : 0)
41
44
  end
42
45
 
43
- # One changed member's row, its fields tab-separated: its principle, id, newest commit that changed it (or
44
- # "uncommitted"), that commit's subject, and what it was compared with: "audit" or "mapping_commit". The
45
- # after-commit hook prints the same row for each member a commit changed (D73).
46
- #: (Hash[String, untyped]) -> String
47
- def row(member)
48
- history = member.fetch("history", {})
49
- newest = history.fetch("commits", []).first
50
- fields = [member.fetch("principle"), member.fetch("id"), newest ? newest.fetch("commit") : "uncommitted",
51
- newest ? described(newest, history) : "not committed yet", member.dig("since", "baseline"),
52
- *("waiting_on_an_upgrade" if member["waiting_on_an_upgrade"])]
53
- fields.map { |field| VisibleText.new(field.to_s).to_s }.join("\t")
46
+ # short's lines for a session-start hook (#1261): on stdout, first the context universal, unless source is
47
+ # resume, whose conversation holds it already (#1260), then one line for each principle with a changed member an
48
+ # audit or acknowledgement assessed, counting them, with the command that lists them, from changed, in place of
49
+ # the rows and never-assessed counts, which an always-loaded carrier cannot afford, then the principles skill as
50
+ # where to start, which the hook printed before (#986, #1260); stderr and the status kept. Its command leaves
51
+ # out --project, as the hook's own commands do, since a session runs in its project.
52
+ #: (Lines, changed: Hash[String, Integer], source: String) -> Lines
53
+ def at_session_start(short, changed:, source:)
54
+ counts = changed.map { |id, count| changed_line(id, count) }
55
+ stdout = [*(Prompts.text("start-a-session/every-loaded-line-costs-every-session") unless source == "resume"),
56
+ *counts, *(Prompts.text("start-a-session/start-with-the-principles-skill") unless counts.empty?)]
57
+ Lines.new(stdout: stdout.map { "#{it}\n" }.join, stderr: short.stderr, status: short.status)
54
58
  end
55
59
 
56
60
  private
57
61
 
58
- #: (bool, bool) -> Integer
59
- def status(assessed_change, unassessed_change)
60
- return CHANGED if assessed_change
61
-
62
- unassessed_change ? UNASSESSED_ONLY : 0
62
+ # The session-start line counting principle id's changed audited members, with the command that lists them.
63
+ #: (String, Integer) -> String
64
+ def changed_line(id, count)
65
+ "#{count} audited member#{"s" unless count == 1} of #{VisibleText.new(id)} changed: " \
66
+ "#{@invocation.without_project.in_project("list-member-problems", id, options: ["--short"])}"
63
67
  end
64
68
 
65
- # The newest commit's subject, with how many earlier commits changed the member, and whether it changed
66
- # again on disk.
67
- #: (Hash[String, untyped], Hash[String, untyped]) -> String
68
- def described(newest, history)
69
- earlier = history.fetch("commits").length - 1
70
- more = history.dig("stopped_at", "reason") == "limit" ? " or more" : ""
71
- notes = [("+#{earlier}#{more} earlier" if earlier.positive?),
72
- ("also uncommitted" if history["uncommitted"])].compact
73
- notes.empty? ? newest.fetch("subject") : "#{newest.fetch("subject")} (#{notes.join("; ")})"
74
- end
69
+ # The line counting principle id's members no audit has assessed, which a reader tells from a member's row by
70
+ # its two fields (#1254).
71
+ #: (String, Integer) -> String
72
+ def counted(id, count) = "#{VisibleText.new(id)}\t#{count} never assessed"
75
73
 
76
74
  # What the agent does next, and what an empty stdout would otherwise hide: no maps, or, in next_action,
77
75
  # each principle's members with no baseline to compare with and what gives them one (#564), and each
78
76
  # principle waiting on an upgrade, whose members are not counted, so they leave counts empty (D85, V8).
79
- #: (Hash[String, untyped], String) -> Array[String]
80
- def notes(report, nothing_changed)
81
- [(NO_MAPS if report.fetch("counts").empty? && !report.key?("records_waiting_on_an_upgrade")),
82
- (report.fetch("next_action") unless report.fetch("next_action") == nothing_changed),
83
- ("Details: #{@invocation.in_project("list-member-problems")}" unless report.fetch("members").empty?)].compact
77
+ #: (Hash[String, untyped], String, bool) -> Array[String]
78
+ def notes(report, nothing_changed, names_a_command)
79
+ no_maps = report.fetch("counts").empty? && !report.key?("empty_maps") &&
80
+ !report.key?("records_waiting_on_an_upgrade")
81
+ action = report.fetch("next_action")
82
+ [(NO_MAPS if no_maps), (project_line if names_a_command),
83
+ (action unless action == nothing_changed)].compact
84
84
  end
85
+
86
+ # The project once, before the first command stderr prints, where they run since they leave out --project,
87
+ # and how to see the details rows leave out, such as each commit's subject (#1263).
88
+ #: () -> String
89
+ def project_line = "In #{@invocation.project_word} (details: drop --short):"
85
90
  end
86
91
  end
87
92
  end
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative "invocation"
5
5
  require_relative "members_with_no_baseline"
6
+ require_relative "maps_needing_members_or_audit"
6
7
  require_relative "principles_with_no_completed_audit"
7
8
  require_relative "record_waiting_on_an_upgrade"
8
9
 
@@ -17,6 +18,10 @@ module Principles
17
18
  OLDER_STATE = "An older version of this tool kept audit runs in this file. This version does not read " \
18
19
  "it, so an audit recorded only there is not a baseline. Start a new audit to make one."
19
20
 
21
+ # The lead before the acknowledgements, which leaves the agent to judge each change (#1263).
22
+ ACKNOWLEDGE_LEAD = "Acknowledge members that still say the same thing; if one's meaning changed, or its check " \
23
+ "is new, changed or fails, run start-audit ID:"
24
+
20
25
  #: (Invocation) -> void
21
26
  def initialize(invocation)
22
27
  @invocation = invocation
@@ -31,49 +36,78 @@ module Principles
31
36
  #| ?acknowledgeable: Hash[String, Array[String]], ?waiting: Array[RecordWaitingOnAnUpgrade])
32
37
  #| -> Hash[String, untyped]
33
38
  def checked(report, not_read: [], no_baseline_files: {}, acknowledgeable: {}, waiting: [])
39
+ checked_naming_commands(report, not_read:, no_baseline_files:, acknowledgeable:, waiting:).first
40
+ end
41
+
42
+ # The same result, and whether its next_action names a command, before which --short names the project once
43
+ # (#1263), so no view reads the action's text to find one (#1279).
44
+ #: (Hash[String, untyped], ?not_read: Array[String], ?no_baseline_files: Hash[String, Array[String]],
45
+ #| ?acknowledgeable: Hash[String, Array[String]], ?waiting: Array[RecordWaitingOnAnUpgrade])
46
+ #| -> [Hash[String, untyped], bool]
47
+ def checked_naming_commands(report, not_read: [], no_baseline_files: {}, acknowledgeable: {}, waiting: [])
34
48
  unless not_read.empty?
35
49
  report = report.merge("not_read" => not_read.map { |file| { "file" => file, "because" => OLDER_STATE } })
36
50
  end
37
51
  report = report.merge("records_waiting_on_an_upgrade" => waiting.map(&:to_h)) unless waiting.empty?
38
- report.merge("next_action" => next_action(report, no_baseline_files:, acknowledgeable:, waiting:))
52
+ action, commands = next_action(report, no_baseline_files:, acknowledgeable:, waiting:)
53
+ [report.merge("next_action" => action), commands]
39
54
  end
40
55
 
41
56
  private
42
57
 
43
- # What to do next for report, each kind of action on lines of its own, or NOTHING_CHANGED when none applies.
58
+ # What to do next for report, each kind of action on lines of its own, or NOTHING_CHANGED when none applies,
59
+ # and whether it names a command: every changed, unaudited and mapping action does, a no-baseline one as it
60
+ # says, and neither the mapping notice nor a waiting principle's update sentence does.
44
61
  #: (Hash[String, untyped], no_baseline_files: Hash[String, Array[String]],
45
- #| acknowledgeable: Hash[String, Array[String]], waiting: Array[RecordWaitingOnAnUpgrade]) -> String
62
+ #| acknowledgeable: Hash[String, Array[String]], waiting: Array[RecordWaitingOnAnUpgrade]) -> [String, bool]
46
63
  def next_action(report, no_baseline_files:, acknowledgeable:, waiting:)
47
64
  waits = waiting.map(&:principle)
48
- action = [changed_action(report, acknowledgeable, waits), unaudited_action(report, waits),
49
- *no_baseline_actions(report, no_baseline_files).map(&:to_s), *waiting.map(&:to_s)].compact.join("\n")
50
- action.empty? ? NOTHING_CHANGED : action
65
+ mapping = MapsNeedingMembersOrAudit.new(@invocation, report: report, files_to_commit: no_baseline_files,
66
+ waiting: waits)
67
+ commanding = [changed_action(report, acknowledgeable, waits), unaudited_action(report, waits)].compact
68
+ no_baseline = no_baseline_actions(report, no_baseline_files)
69
+ action = [*commanding, mapping.notice, *no_baseline.map(&:to_s), *mapping.actions,
70
+ *waiting.map(&:to_s)].compact.join("\n")
71
+ [action.empty? ? NOTHING_CHANGED : action, names_a_command?(commanding, no_baseline, mapping)]
72
+ end
73
+
74
+ # Whether any of the actions that may name a command does.
75
+ #: (Array[String], Array[MembersWithNoBaseline], MapsNeedingMembersOrAudit) -> bool
76
+ def names_a_command?(commanding, no_baseline, mapping)
77
+ !commanding.empty? || no_baseline.any?(&:names_a_command?) || !mapping.actions.empty?
51
78
  end
52
79
 
53
80
  # For each principle with a changed member, its audits, each command ending its own line (#568): where
54
- # acknowledgeable names a member a one-member audit may judge, that audit for each such member, filled and
55
- # shell-quoted so the agent types no id (#626, D56), then the full audit, each with when to use it; elsewhere
56
- # the full audit alone, with no condition, as nothing else applies (#633). None for a principle in waits, whose
57
- # audits wait on an upgrade (#1066).
81
+ # acknowledgeable names members a one-member audit may judge, one acknowledgement for all of them (#1169,
82
+ # #1263), filled and shell-quoted so the agent types no id (#626, D56), after one lead saying when to audit in
83
+ # full instead; the full audit for a principle with a changed member no acknowledgement may judge, with no
84
+ # condition, as nothing else applies to it (#633). None for a principle in waits, whose audits wait on an
85
+ # upgrade (#1066).
58
86
  #: (Hash[String, untyped], Hash[String, Array[String]], Array[String]) -> String?
59
87
  def changed_action(report, acknowledgeable, waits)
60
- principles = report.fetch("members").map { |member| member.fetch("principle") }.uniq - waits
61
- audits = principles.flat_map do |id|
62
- full = @invocation.in_project("start-audit", id)
63
- members = acknowledgeable.fetch(id, [])
64
- next "Audit #{id} in full to judge its changed members: #{full}" if members.empty?
65
-
66
- [*members.flat_map { |member| acknowledge_lines(id, member) },
67
- "When a change alters what a member of #{id} says, or the member has a check, audit it in full: #{full}"]
68
- end
69
- audits.empty? ? nil : audits.join("\n")
88
+ changed = report.fetch("members").group_by { it.fetch("principle") }.except(*waits)
89
+ acknowledging = changed.keys.filter_map { |id| acknowledge_line(id, acknowledgeable.fetch(id, [])) }
90
+ full = changed.filter_map { |id, members| full_audit_line(id, members, acknowledgeable.fetch(id, [])) }
91
+ lines = [*(ACKNOWLEDGE_LEAD unless acknowledging.empty?), *acknowledging, *full]
92
+ lines.empty? ? nil : lines.join("\n")
93
+ end
94
+
95
+ # The one-member audit acknowledging every member of principle id in members, or nil when there is none.
96
+ #: (String, Array[String]) -> String?
97
+ def acknowledge_line(id, members)
98
+ return if members.empty?
99
+
100
+ @invocation.in_project("start-audit", id, options: members.flat_map { ["--member", it] })
70
101
  end
71
102
 
72
- # The lead naming member, and on a line of its own the one-member audit that acknowledges its change.
73
- #: (String, String) -> Array[String]
74
- def acknowledge_lines(id, member)
75
- ["When #{member} still says the same thing, acknowledge it:",
76
- @invocation.in_project("start-audit", id, options: ["--member", member])]
103
+ # The full audit of principle id, for its changed members no acknowledgement may judge, or nil when the
104
+ # acknowledgement takes in every one.
105
+ #: (String, Array[Hash[String, untyped]], Array[String]) -> String?
106
+ def full_audit_line(id, members, acknowledgeable)
107
+ return if members.all? { acknowledgeable.include?(it.fetch("id")) }
108
+
109
+ other = acknowledgeable.empty? ? "" : " other"
110
+ "Audit #{id} in full to judge its#{other} changed members: #{@invocation.in_project("start-audit", id)}"
77
111
  end
78
112
 
79
113
  # Members compared only with the commit that mapped them have never been assessed, so neither "changed" nor
@@ -0,0 +1,3 @@
1
+ One exception: this check is this tool's own list-member-problems, which lists this member, and any other the answer
2
+ acknowledges, until the record is committed, so it exits 3 now: report that 3, and under check_result.listed_members
3
+ the member id in the second column of each line it prints.
@@ -1,3 +1,3 @@
1
- Run the command in the project, then replace this text with its exit status, an integer. An acknowledgement
2
- keeps only a passing run: a check that fails or cannot be run here is a full audit's to judge, so start that
3
- audit instead of answering this one.
1
+ Run the member's check, the command member.check names, in the project, then give its exit status, an integer, as
2
+ check_result.exit_status. An acknowledgement keeps only a passing run: a check that fails or cannot be run here is a
3
+ full audit's to judge, so start that audit instead of answering this one.
@@ -0,0 +1,8 @@
1
+ Judge each member in `members` on its own: read its change in its member_lines, or by running its read_the_change.
2
+ Answer `meaning_kept: true` only when the member still says the same thing. A member still says the same thing after a
3
+ fixed typo, a reworded sentence or a renumbered citation; an added, dropped, reversed, narrowed or widened rule changes
4
+ what it says. The answer is accepted for every member or refused for all, so when one changed, or you are unsure,
5
+ start this request again without it and audit it in full. Give each a one-line `reason` in your own words, under its
6
+ id in the template's `members`; quotes left out read as its `first_changed_lines`. Optional in each: `old_line` and
7
+ `new_line`, another changed line per side or 30 characters including the edit; a check's `check_result.command` and
8
+ `check_result.review_basis`.
@@ -1,6 +1,6 @@
1
- Read the change in member_lines, or by running read_the_change. Answer `meaning_kept: true` only when the member still
2
- says the same thing. A member still says the same thing after a fixed typo, a reworded sentence or a renumbered
3
- citation; an added, dropped, reversed, narrowed or widened rule changes what it says. When it changed, or you are
4
- unsure, run a full audit instead. Give a one-line `reason` in your own words. The template quotes
5
- `first_changed_lines` as `old_line` and `new_line`: keep them, or quote another changed line of each side, or 30
6
- characters of one that include the edit.
1
+ Read the change in member_lines, or by running read_the_change. Answer `meaning_kept: true` only when the member
2
+ still says the same thing. A member still says the same thing after a fixed typo, a reworded sentence or a
3
+ renumbered citation; an added, dropped, reversed, narrowed or widened rule changes what it says. When it changed, or
4
+ you are unsure, run a full audit instead. Give a one-line `reason` in your own words, and fill the template; quotes
5
+ left out read as `first_changed_lines`. Optional: `old_line` and `new_line`, another changed line per side or 30
6
+ characters including the edit; `basis.base_commit`; a check's `check_result.command` and `check_result.review_basis`.
@@ -1,58 +1,82 @@
1
1
  {
2
2
  "finding": {
3
- "id": "F1",
4
- "member_ids": [
5
- "a member id from the map"
6
- ],
7
- "problem": "What is wrong",
8
- "consequence": "What goes wrong for an agent because of it",
9
- "proposed_action": "The concrete change",
10
- "evidence": [
11
- {
12
- "path": "a project file",
13
- "heading": "optional exact heading"
14
- },
15
- {
16
- "path": "a project file",
17
- "starting_at": "text that occurs once",
18
- "ending_at": "optional closing text"
19
- },
20
- {
21
- "path": "a project file with frontmatter",
22
- "query": "$.description"
3
+ "copy_to": "response_template.findings",
4
+ "copy_from": "Append one filled examples.finding object to this array. Do not submit this wrapper or notes.",
5
+ "examples": {
6
+ "finding": {
7
+ "id": "F1",
8
+ "member_ids": [
9
+ "a member id from the map"
10
+ ],
11
+ "problem": "What is wrong",
12
+ "consequence": "What goes wrong for an agent because of it",
13
+ "proposed_action": "The concrete change",
14
+ "evidence": [
15
+ {
16
+ "path": "a project file",
17
+ "heading": "optional exact heading"
18
+ },
19
+ {
20
+ "path": "a project file",
21
+ "starting_at": "text that occurs once",
22
+ "ending_at": "optional closing text"
23
+ },
24
+ {
25
+ "path": "a project file with frontmatter",
26
+ "query": "$.description"
27
+ }
28
+ ]
23
29
  }
24
- ]
30
+ },
31
+ "notes": "Evidence entries illustrate locator choices, not mandatory sample files: replace the example array with the actual located references needed for this finding. Fill every judgement and use mapped member IDs. Submitting findings starts a separate correction stage; it does not complete the audit."
25
32
  },
26
33
  "member_delivery": {
27
- "not_observed": {
28
- "delivery": "not_observed"
34
+ "copy_to": "response_template.member_assessments entry matching member_id",
35
+ "copy_from": "Merge only examples.observed or examples.not_observed into that existing entry, then fill its fields. Do not submit this wrapper or notes.",
36
+ "examples": {
37
+ "not_observed": {
38
+ "delivery": "not_observed"
39
+ },
40
+ "observed": {
41
+ "delivery": "observed",
42
+ "observation": "What you saw the member do, where you saw it, and what you did not see",
43
+ "observed_at": null
44
+ }
29
45
  },
30
- "observed": {
31
- "delivery": "observed",
32
- "observation": "What you saw the member do, where you saw it, and what you did not see",
33
- "observed_at": "Only when you saw it before this audit: when, in UTC as audited_at gives it; omit it, or give null, for a sighting made now. When the sighting is a dated record you read during this audit, such as a note or log of the mechanism acting, give the record's date, not the time you read it"
34
- }
46
+ "notes": "Reading source alone is not observed delivery. With not_observed, omit observation and observed_at; remove any substantive sighting fields from a previous choice. For a sighting now, leave observed_at null or omit it. For an earlier sighting, replace null with its UTC time in audited_at's form. When the sighting is a dated record you read during this audit, such as a note or log of the mechanism acting, give the record's date, not the time you read it"
35
47
  },
36
48
  "recent_decision": {
37
- "assessed": {
38
- "assessment": "How the decision held up against the members' own words; when only a commit message records it, name the commit by its sha and subject here",
39
- "evidence": [
40
- {
41
- "path": "a project file that records the decision; when only a commit message records it, the file that commit changed to carry it out",
42
- "heading": "optional exact heading"
43
- }
44
- ]
45
- },
46
- "unavailable": {
47
- "unavailable_reason": "Why no recent decision under this principle can be checked"
49
+ "copy_to": "response_template.recent_decision",
50
+ "copy_from": "Replace the whole object with only examples.assessed or examples.unavailable, then fill its fields. Do not merge alternatives or submit this wrapper.",
51
+ "examples": {
52
+ "assessed": {
53
+ "assessment": "How the decision held up against the members' own words; when only a commit message records it, name the commit by its sha and subject here",
54
+ "evidence": [
55
+ {
56
+ "path": "a project file that records the decision; when only a commit message records it, the file that commit changed to carry it out",
57
+ "heading": "optional exact heading"
58
+ }
59
+ ]
60
+ },
61
+ "unavailable": {
62
+ "unavailable_reason": "Why no recent decision under this principle can be checked"
63
+ }
48
64
  }
49
65
  },
50
66
  "reassessment": "Give a reassessment only for a fixed finding; omit it for deferred, accepted or disagreed.",
51
67
  "check_result": {
52
- "command": "the member's check, exactly as context.members lists it",
53
- "exit_status": 0,
54
- "review_basis": "One line saying what the review before the run rested on; needed beside exit_status when check_since_last_audit is new or changed",
55
- "not_run_reason": "Instead of exit_status, when you could not run it here: why, such as a missing tool or a sandbox",
68
+ "copy_to": "response_template.member_assessments entry matching member_id, inside check_result",
69
+ "copy_from": "Merge only examples.ran or examples.not_run into that existing object, then fill command and outcome. Leave unused fields exactly as that member's template printed them. For a new or changed run, write its review_basis; for an unchanged run, keep its own review_basis placeholder to retain the earlier line, or write a new basis. Do not submit this wrapper or limits.",
70
+ "examples": {
71
+ "ran": {
72
+ "command": "the member's check, exactly as context.members lists it",
73
+ "exit_status": 0
74
+ },
75
+ "not_run": {
76
+ "command": "the member's check, exactly as context.members lists it",
77
+ "not_run_reason": "Instead of exit_status, when you could not run it here: why, such as a missing tool or a sandbox"
78
+ }
79
+ },
56
80
  "limits": "Give a checked member's check_result in its own entry in member_assessments, where the template starts it, and none for a member without a check. A member that names a check asks for it to run at each full audit, however long it takes; if it is too slow to run at every audit, say so as a finding rather than skip it. Do not count on a permission prompt to show the command to anyone first. unchanged means an earlier audit ran this same command, not that it is safe: the audit record is committed too, and can be changed beside the check. Run the command in the project before you report its exit status: nothing runs it automatically, and nothing confirms that a reported run happened, that it ran on the files as they are now, or that the status is the one it returned. A failing check is a fact for your assessment; whether the member delivers stays your judgement."
57
81
  }
58
82
  }
@@ -11,7 +11,8 @@ A member whose loading the last full audit accepted carries `last_accepted`: its
11
11
  `unchanged` or `changed`, comparing when the member loads and the member's own text, not its file's size, so a file
12
12
  growing outside the member stays `unchanged`. An edit acknowledged with `--member`, or a fix made in that audit's
13
13
  correction, counts as the text the decision was kept with. When `since_accepted` is `changed`, `last_accepted.changed`
14
- names which moved, `loading` or `member_text`, beside the `loads` it accepted: weigh the decision again.
14
+ names which moved, `loading` or `member_text`, beside the `loads` it accepted: weigh the decision again. When it is
15
+ `unchanged` and its reason still holds, decide `kept` with no `reason`; the record keeps the last accepted reason.
15
16
 
16
17
  When this principle's work is in hand in every session, change the activation to always, under which no member is
17
18
  listed here: %{always}
@@ -1,2 +1,2 @@
1
- Run the command in the project, then replace this text with its exit status, an integer. If it could not be
2
- run, write why in not_run_reason instead, and leave this text as printed.
1
+ Run the command in the project, then replace exit_status with its exit status, an integer. If it could not be
2
+ run, write why in not_run_reason instead, and leave exit_status as printed.