principles 0.0.10 → 0.1.0

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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/README.md +0 -2
  4. data/lib/principles/controllers/acknowledgement.rb +11 -4
  5. data/lib/principles/controllers/acknowledgements.rb +4 -4
  6. data/lib/principles/controllers/answer.rb +2 -2
  7. data/lib/principles/controllers/assessment.rb +20 -4
  8. data/lib/principles/controllers/audit.rb +16 -5
  9. data/lib/principles/controllers/broken_member_repairs.rb +60 -0
  10. data/lib/principles/controllers/command.rb +8 -30
  11. data/lib/principles/controllers/correction.rb +7 -5
  12. data/lib/principles/controllers/full_audit_request.rb +44 -22
  13. data/lib/principles/controllers/guidance_search_paths.rb +1 -1
  14. data/lib/principles/controllers/inventory.rb +3 -3
  15. data/lib/principles/controllers/member_acknowledgement.rb +5 -5
  16. data/lib/principles/controllers/member_addition.rb +5 -2
  17. data/lib/principles/controllers/member_entries.rb +1 -1
  18. data/lib/principles/controllers/member_problems_report.rb +11 -7
  19. data/lib/principles/controllers/members_to_assess.rb +1 -1
  20. data/lib/principles/controllers/meta_principle_setup.rb +4 -3
  21. data/lib/principles/controllers/open_correction.rb +3 -3
  22. data/lib/principles/controllers/open_finding_decisions.rb +66 -0
  23. data/lib/principles/controllers/running_tool.rb +22 -5
  24. data/lib/principles/controllers/survey.rb +3 -2
  25. data/lib/principles/data/candidate_files_found.rb +6 -4
  26. data/lib/principles/data/command-steps.json +20 -20
  27. data/lib/principles/data/json_text.rb +5 -1
  28. data/lib/principles/data/parser_message.rb +61 -0
  29. data/lib/principles/data/project_files.rb +4 -2
  30. data/lib/principles/data/repository.rb +4 -4
  31. data/lib/principles/data/running_version.rb +1 -1
  32. data/lib/principles/data/schemas/audit-record.schema.json +15 -0
  33. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  34. data/lib/principles/data/schemas/{repointing-answer.schema.json → deciding-answer.schema.json} +12 -6
  35. data/lib/principles/invocation_options.rb +4 -4
  36. data/lib/principles/launch.rb +5 -3
  37. data/lib/principles/models/acknowledgement.rb +1 -27
  38. data/lib/principles/models/acknowledgement_left_as_printed.rb +2 -1
  39. data/lib/principles/models/acknowledgement_placeholders.rb +48 -0
  40. data/lib/principles/models/after_commit_input.rb +1 -0
  41. data/lib/principles/models/assessment_answer.rb +2 -2
  42. data/lib/principles/models/assessment_basis.rb +1 -1
  43. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  44. data/lib/principles/models/audit.rb +24 -4
  45. data/lib/principles/models/audit_entry_protecting_map.rb +1 -0
  46. data/lib/principles/models/audit_record.rb +5 -14
  47. data/lib/principles/models/audit_records.rb +2 -2
  48. data/lib/principles/models/audited_member_lines.rb +1 -1
  49. data/lib/principles/models/candidate_files.rb +1 -1
  50. data/lib/principles/models/candidate_inventory.rb +20 -10
  51. data/lib/principles/models/candidate_outline.rb +1 -1
  52. data/lib/principles/models/changed_regions.rb +1 -1
  53. data/lib/principles/models/command_steps.rb +1 -2
  54. data/lib/principles/models/correction_basis.rb +1 -1
  55. data/lib/principles/models/declared_map_changes.rb +1 -2
  56. data/lib/principles/models/disposition.rb +12 -76
  57. data/lib/principles/models/disposition_placeholders.rb +48 -0
  58. data/lib/principles/models/disposition_text_field.rb +41 -0
  59. data/lib/principles/models/evidence_item.rb +1 -1
  60. data/lib/principles/models/finding_decision.rb +84 -0
  61. data/lib/principles/models/finding_write_ups.rb +2 -1
  62. data/lib/principles/models/first_full_audit.rb +1 -0
  63. data/lib/principles/models/fix_only_fields.rb +4 -3
  64. data/lib/principles/models/frontmatter_fields.rb +1 -1
  65. data/lib/principles/models/guidance_search_path.rb +1 -1
  66. data/lib/principles/models/guidance_search_paths.rb +5 -1
  67. data/lib/principles/models/head_moves.rb +1 -0
  68. data/lib/principles/models/ignored_candidates.rb +1 -1
  69. data/lib/principles/models/instruction_named.rb +1 -1
  70. data/lib/principles/models/json_path_query.rb +1 -1
  71. data/lib/principles/models/json_path_selectors.rb +1 -1
  72. data/lib/principles/models/json_path_string.rb +1 -1
  73. data/lib/principles/models/last_completed_revision.rb +1 -1
  74. data/lib/principles/models/line_diff.rb +1 -1
  75. data/lib/principles/models/line_span.rb +1 -1
  76. data/lib/principles/models/loading_scope.rb +1 -0
  77. data/lib/principles/models/located_text.rb +20 -12
  78. data/lib/principles/models/map_change.rb +66 -0
  79. data/lib/principles/models/mapped_principles.rb +4 -0
  80. data/lib/principles/models/markdown_file.rb +22 -1
  81. data/lib/principles/models/member.rb +1 -1
  82. data/lib/principles/models/member_assessments.rb +11 -4
  83. data/lib/principles/models/member_elsewhere.rb +1 -1
  84. data/lib/principles/models/member_file.rb +15 -13
  85. data/lib/principles/models/member_hashes_as_written.rb +2 -2
  86. data/lib/principles/models/member_history.rb +1 -1
  87. data/lib/principles/models/member_lines.rb +1 -1
  88. data/lib/principles/models/member_loading_scopes.rb +1 -0
  89. data/lib/principles/models/member_mapping_run.rb +4 -4
  90. data/lib/principles/models/member_moves.rb +1 -2
  91. data/lib/principles/models/member_problems.rb +5 -1
  92. data/lib/principles/models/member_region.rb +1 -1
  93. data/lib/principles/models/member_repair_moves.rb +20 -4
  94. data/lib/principles/models/member_snapshots.rb +10 -10
  95. data/lib/principles/models/members_elsewhere.rb +1 -1
  96. data/lib/principles/models/members_in_consecutive_sections.rb +1 -0
  97. data/lib/principles/models/members_sharing_lines.rb +2 -2
  98. data/lib/principles/models/misspelt_member_id.rb +10 -4
  99. data/lib/principles/models/named_placeholder.rb +32 -0
  100. data/lib/principles/models/open_finding.rb +4 -3
  101. data/lib/principles/models/open_findings_decision.rb +124 -0
  102. data/lib/principles/models/open_findings_elsewhere.rb +1 -1
  103. data/lib/principles/models/other_templates_placeholders.rb +26 -6
  104. data/lib/principles/models/outline_budget.rb +1 -1
  105. data/lib/principles/models/outline_group.rb +1 -1
  106. data/lib/principles/models/outline_section.rb +1 -1
  107. data/lib/principles/models/part_named.rb +1 -1
  108. data/lib/principles/models/plain_text_file.rb +1 -1
  109. data/lib/principles/models/principle_history.rb +5 -4
  110. data/lib/principles/models/principle_members.rb +1 -1
  111. data/lib/principles/models/problem_report.rb +13 -1
  112. data/lib/principles/models/project.rb +15 -16
  113. data/lib/principles/models/project_at_commit.rb +60 -0
  114. data/lib/principles/models/project_history.rb +10 -52
  115. data/lib/principles/models/prose_line.rb +36 -0
  116. data/lib/principles/models/record_format.rb +17 -4
  117. data/lib/principles/models/recorded_finding.rb +47 -7
  118. data/lib/principles/models/recorded_findings.rb +7 -7
  119. data/lib/principles/models/recorded_hashes.rb +1 -1
  120. data/lib/principles/models/recorded_members.rb +6 -8
  121. data/lib/principles/models/report_hooks.rb +1 -0
  122. data/lib/principles/models/request_id.rb +2 -2
  123. data/lib/principles/models/sent_answer.rb +5 -3
  124. data/lib/principles/models/session_start_input.rb +1 -0
  125. data/lib/principles/models/stale_request.rb +22 -8
  126. data/lib/principles/models/submitted_answer.rb +1 -1
  127. data/lib/principles/models/survey_search_paths.rb +13 -5
  128. data/lib/principles/models/template_placeholders.rb +22 -7
  129. data/lib/principles/models/text_size.rb +11 -3
  130. data/lib/principles/models/text_within.rb +1 -1
  131. data/lib/principles/models/unchecked_members.rb +1 -0
  132. data/lib/principles/models/uncommitted_outside_the_map.rb +1 -1
  133. data/lib/principles/models/unfinished_field.rb +34 -0
  134. data/lib/principles/models/unknown_principle.rb +1 -0
  135. data/lib/principles/models/write_up_opening.rb +5 -31
  136. data/lib/principles/models/write_up_pointer.rb +2 -1
  137. data/lib/principles/start_audit_options.rb +35 -20
  138. data/lib/principles/version.rb +2 -2
  139. data/lib/principles/views/acknowledged_result.rb +59 -0
  140. data/lib/principles/views/acknowledgement_result.rb +44 -51
  141. data/lib/principles/views/added_member.rb +10 -1
  142. data/lib/principles/views/answer_in_a_file.rb +65 -0
  143. data/lib/principles/views/assessed_members.rb +4 -2
  144. data/lib/principles/views/assessment_answer_guide.rb +59 -0
  145. data/lib/principles/views/assessment_request.rb +2 -26
  146. data/lib/principles/views/audit_result.rb +18 -7
  147. data/lib/principles/views/candidate_files_result.rb +9 -4
  148. data/lib/principles/views/context_parts.rb +41 -10
  149. data/lib/principles/views/correction_request.rb +27 -18
  150. data/lib/principles/views/first_audit_brief.rb +2 -1
  151. data/lib/principles/views/guidance_search_paths_result.rb +13 -6
  152. data/lib/principles/views/invocation.rb +14 -4
  153. data/lib/principles/views/json_on_one_line.rb +18 -0
  154. data/lib/principles/views/member_repairs.rb +21 -5
  155. data/lib/principles/views/meta_principle_result.rb +26 -5
  156. data/lib/principles/views/open_findings_decision_result.rb +60 -0
  157. data/lib/principles/views/parts_index_result.rb +8 -6
  158. data/lib/principles/views/principle_read_result.rb +2 -2
  159. data/lib/principles/views/problem_facts.rb +46 -0
  160. data/lib/principles/views/problem_lines.rb +8 -3
  161. data/lib/principles/views/problem_result.rb +53 -31
  162. data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +6 -0
  163. data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +2 -1
  164. data/lib/principles/views/prompts/decide-open-findings/give-only-what-changed-of-each.md +6 -0
  165. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  166. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -1
  167. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +2 -2
  168. data/lib/principles/views/prompts/find-a-principle-to-map/where-a-survey-with-only-looks.md +4 -0
  169. data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +2 -1
  170. data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +1 -0
  171. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-check.md +4 -3
  172. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +4 -3
  173. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +12 -12
  174. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +7 -8
  175. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -12
  176. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +4 -3
  177. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member-check.md +4 -3
  178. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +4 -3
  179. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +13 -12
  180. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +2 -2
  181. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +2 -2
  182. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +12 -12
  183. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
  184. data/lib/principles/views/prompts/start-a-session/act-on-the-changed-principles.md +2 -0
  185. data/lib/principles/views/prompts.rb +7 -4
  186. metadata +26 -8
  187. data/lib/principles/controllers/repoint.rb +0 -67
  188. data/lib/principles/models/repoint.rb +0 -125
  189. data/lib/principles/models/write_up_repoint.rb +0 -38
  190. data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +0 -10
  191. data/lib/principles/views/repoint_result.rb +0 -80
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "tmpdir"
4
5
  require_relative "version"
5
6
  require_relative "data/running_version"
6
7
  require_relative "data/principles_on_path"
@@ -8,8 +9,8 @@ require_relative "controllers/running_tool"
8
9
 
9
10
  module Principles
10
11
  # This process as its entry point launched it: the executable that entry point names itself by, the file it was
11
- # launched as, PATH and the folder it started in, read here so that no layer reads them. It gives every controller
12
- # the same RunningTool.
12
+ # launched as, PATH, the folder it started in and its temporary folder, read here so that no layer reads them. It
13
+ # gives every controller the same RunningTool.
13
14
  class Launch
14
15
  #: (String) -> void
15
16
  def initialize(executable)
@@ -24,7 +25,8 @@ module Principles
24
25
  Controllers::RunningTool.new(executable: @executable, version: -> { running_version },
25
26
  other_on_path: ->(asking) { on_path.other(asking) },
26
27
  launched_on_path: -> { on_path.own_first? },
27
- cwd: started_in)
28
+ folders: Controllers::RunningTool::Folders.new(cwd: started_in,
29
+ temp_directory: Dir.tmpdir))
28
30
  end
29
31
 
30
32
  private
@@ -3,7 +3,7 @@
3
3
 
4
4
  require_relative "../error"
5
5
  require_relative "acknowledged_check"
6
- require_relative "acknowledgement_left_as_printed"
6
+ require_relative "acknowledgement_placeholders"
7
7
  require_relative "acknowledgement_refusal"
8
8
  require_relative "acknowledgements"
9
9
  require_relative "request_id"
@@ -12,8 +12,6 @@ require_relative "member"
12
12
  require_relative "member_lines"
13
13
  require_relative "placement"
14
14
  require_relative "quoted_change"
15
- require_relative "reported_check"
16
- require_relative "template_placeholders"
17
15
 
18
16
  module Principles
19
17
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
@@ -23,30 +21,6 @@ module Principles
23
21
  # Refused outside git, for a member no completed audit assessed, and for an unchanged or checked member.
24
22
  class Acknowledgement
25
23
  PHASE = "acknowledgement"
26
- # The text the answer's template prints in each field the agent judges, which an answer may not send back, so
27
- # a template returned as printed acknowledges nothing. It prints no quotes, which an answer leaving them
28
- # out reads as first_changed_lines. After a pure insertion, meaning_kept's says that an
29
- # inserted line usually adds a rule, for an agent that reads the template alone.
30
- PLACEHOLDERS = TemplatePlaceholders.new(
31
- { "meaning_kept" => "true only if the member still says the same thing",
32
- "reason" => "Why, in one line of your own" },
33
- also_printed: { "meaning_kept" => "true only if the member still says the same thing; this change inserted " \
34
- "a line, which usually adds a rule" }
35
- ) #: TemplatePlaceholders
36
- # The text a checked member's template prints where its check's exit status goes, short since the request's
37
- # context says how to run the check.
38
- EXIT_STATUS_PLACEHOLDER = ReportedCheck::EXIT_STATUS_PLACEHOLDER #: String
39
- # The fields an answer may not send back as the template printed them, refused before its shape.
40
- LEFT_AS_PRINTED = AcknowledgementLeftAsPrinted.new(
41
- PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
42
- ) #: AcknowledgementLeftAsPrinted
43
-
44
- # The placeholders the template prints beside quotes, its first_changed_lines.
45
- #: (Hash[String, String]) -> Hash[String, untyped]
46
- def self.placeholders_beside(quotes)
47
- quotes["old_line"] == "" ? PLACEHOLDERS.with_other_text_in("meaning_kept") : PLACEHOLDERS.to_h
48
- end
49
-
50
24
  # before holds the member's lines at its baseline commit, now its lines and hash at base, HEAD.
51
25
  #: (principle_id: String, member: Member, record: AuditRecord?, base: String?, now_sha256: String) -> void
52
26
  def initialize(principle_id:, member:, record:, base:, now_sha256:)
@@ -12,7 +12,8 @@ module Principles
12
12
  # The fields a one-member audit's answer leaves as its template printed them, refused in one refusal before the
13
13
  # answer's shape: its judgement's, meaning_kept and reason, and a checked member's exit_status, which was
14
14
  # otherwise refused as text with a repair offering the not_run_reason this template refuses. It holds the
15
- # placeholders the template prints in each; Acknowledgement::LEFT_AS_PRINTED is the one every acknowledgement uses.
15
+ # placeholders the template prints in each; AcknowledgementPlaceholders::LEFT_AS_PRINTED is the one every
16
+ # acknowledgement uses.
16
17
  class AcknowledgementLeftAsPrinted
17
18
  include RefusalBeforeShape
18
19
 
@@ -0,0 +1,48 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "acknowledgement_left_as_printed"
5
+ require_relative "named_placeholder"
6
+ require_relative "reported_check"
7
+ require_relative "template_placeholders"
8
+
9
+ module Principles
10
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
+ module Models
12
+ # The text a one-member audit's template prints in each field the agent writes, and the refusal of an answer
13
+ # that sends any back as printed.
14
+ class AcknowledgementPlaceholders
15
+ # The text the answer's template prints in each field the agent judges, which an answer may not send back, so
16
+ # a template returned as printed acknowledges nothing. It prints no quotes, which an answer leaving them
17
+ # out reads as first_changed_lines. After a pure insertion, meaning_kept's says that an
18
+ # inserted line usually adds a rule, for an agent that reads the template alone.
19
+ # Each names the member of the entry it is printed in, so no two members' slots are alike and one edit fills
20
+ # one; any member's, or the text printed before each named one, is left as printed.
21
+ PLACEHOLDERS = TemplatePlaceholders.new(
22
+ { "meaning_kept" => NamedPlaceholder.new("true only if #{NamedPlaceholder::SLOT} still says the same thing",
23
+ before: "true only if the member still says the same thing"),
24
+ "reason" => NamedPlaceholder.new("Why, for #{NamedPlaceholder::SLOT}, in one line of your own",
25
+ before: "Why, in one line of your own") },
26
+ also_printed: { "meaning_kept" => NamedPlaceholder.new(
27
+ "true only if #{NamedPlaceholder::SLOT} still says the same thing; this change inserted a line, which " \
28
+ "usually adds a rule",
29
+ before: "true only if the member still says the same thing; this change inserted a line, which usually " \
30
+ "adds a rule"
31
+ ) }
32
+ ) #: TemplatePlaceholders
33
+ # The text a checked member's template prints where its check's exit status goes, short since the request's
34
+ # context says how to run the check.
35
+ EXIT_STATUS_PLACEHOLDER = ReportedCheck::EXIT_STATUS_PLACEHOLDER #: String
36
+ # The fields an answer may not send back as the template printed them, refused before its shape.
37
+ LEFT_AS_PRINTED = AcknowledgementLeftAsPrinted.new(
38
+ PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
39
+ ) #: AcknowledgementLeftAsPrinted
40
+
41
+ # The placeholders the template prints beside quotes, its first_changed_lines.
42
+ #: (Hash[String, String]) -> Hash[String, untyped]
43
+ def self.beside(quotes)
44
+ quotes["old_line"] == "" ? PLACEHOLDERS.with_other_text_in("meaning_kept") : PLACEHOLDERS.to_h
45
+ end
46
+ end
47
+ end
48
+ end
@@ -4,6 +4,7 @@
4
4
  require "json"
5
5
 
6
6
  module Principles
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
7
8
  module Models
8
9
  # The JSON a host hands its hook after each shell call, as report-after-commit reads it: the event it ran on,
9
10
  # when the call started, and the directories whose repositories the call may have committed in. Input it cannot
@@ -32,14 +32,14 @@ module Principles
32
32
  "\"observed\" and adds observation, and observed_at for one before this audit." #: String
33
33
 
34
34
  #: (untyped, PrincipleMembers, answered_at: String, ?judged_against: RecordJudgedAgainst?)
35
- #| { (Locator) -> Hash[String, untyped] } -> void
35
+ #| { (Locator) -> LocatedText } -> void
36
36
  def initialize(response, members, answered_at:, judged_against: nil, &locate)
37
37
  @response = response
38
38
  @members = members
39
39
  @answered_at = answered_at
40
40
  @judged_against = judged_against
41
41
  @loads = judged_against&.loads #: LoadsToCheck?
42
- @locate = locate #: ^(Locator) -> Hash[String, untyped]
42
+ @locate = locate #: ^(Locator) -> LocatedText
43
43
  @fields = AnswerFields.new(locate) #: AnswerFields
44
44
  end
45
45
 
@@ -5,7 +5,7 @@ require_relative "audit_record"
5
5
  require_relative "last_completed_revision"
6
6
 
7
7
  module Principles
8
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
8
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
9
9
  module Models
10
10
  # What an assessment request prints as its basis, which the agent hands back with the answer: the commit the
11
11
  # audit is based on, nil outside git, and the revision of the last completed audit record when the request was
@@ -55,7 +55,7 @@ module Principles
55
55
  # The fields of assessment, as sent, that are still the text the template printed there and must be written.
56
56
  #: (Hash[String, untyped]) -> Array[String]
57
57
  def unwritten_fields(assessment)
58
- [("assessment" if assessment["assessment"] == MemberAssessments::PLACEHOLDER),
58
+ [("assessment" if MemberAssessments::ASSESSMENT.left?(assessment["assessment"])),
59
59
  ("observation" if assessment["delivery"] == "observed" &&
60
60
  MemberAssessments::SIGHTING.left?("observation", assessment["observation"]))].compact
61
61
  end
@@ -17,6 +17,7 @@ require_relative "prior_findings"
17
17
  require_relative "decided_prior_findings"
18
18
  require_relative "disposition"
19
19
  require_relative "stale_request"
20
+ require_relative "map_change"
20
21
 
21
22
  module Principles
22
23
  # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
@@ -61,14 +62,18 @@ module Principles
61
62
  # now, and, in git, the members are as its base holds them (committed).
62
63
  # It returns the findings the last audit, whose record is given, left for this one to decide; loads is
63
64
  # what the audit lists to check now, so a change to what lists a member to check makes the request stale.
65
+ # The block gives the map at the base commit, nil when it cannot be read, asked only for a request that no
66
+ # longer matches, so the refusal names a change to the map when that map explains it.
64
67
  #: (RequestId, basis: AssessmentBasis, committed: Hash[String, String]?, record: AuditRecord?,
65
- #| loads: LoadsToCheck) -> PriorFindings
66
- def check_assessment_request(request_id, basis:, committed:, record:, loads:)
68
+ #| loads: LoadsToCheck) ?{ () -> Principle? } -> PriorFindings
69
+ def check_assessment_request(request_id, basis:, committed:, record:, loads:, &started_from)
67
70
  prior = prior_findings(record)
68
71
  now_id = assessment_id(basis, prior.digested, loads.listed)
69
72
  return prior if now_id == request_id && (basis.base.nil? || committed == @now)
70
73
 
71
- raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false).refusal
74
+ raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false,
75
+ map_change: map_change(request_id, basis, record, loads,
76
+ started_from)).refusal
72
77
  end
73
78
 
74
79
  # The answer to this audit's assessment request, checked against each member, each member's check
@@ -76,7 +81,7 @@ module Principles
76
81
  # evidence, giving where it is and the hash of its text.
77
82
  # judged_against is the principle's record as it stands, which says which members' last assessments the
78
83
  # answer may carry forward; answered_at is when the answer came, which no sighting it reports is after.
79
- #: (untyped, RecordJudgedAgainst, String) { (Locator) -> Hash[String, untyped] }
84
+ #: (untyped, RecordJudgedAgainst, String) { (Locator) -> LocatedText }
80
85
  #| -> AssessmentAnswer
81
86
  def assessment(response, judged_against, answered_at, &)
82
87
  AssessmentAnswer.new(response, members, answered_at: answered_at, judged_against: judged_against, &)
@@ -216,6 +221,21 @@ module Principles
216
221
 
217
222
  #: () -> Error
218
223
  def stale_request = StaleRequest.new(id).refusal
224
+
225
+ # How the map differs from the one started_from gives, when the request was printed from that map with the
226
+ # members as they are now; nil when there is no such map, it is this one, it does not give request_id, or the
227
+ # change names nothing.
228
+ #: (RequestId, AssessmentBasis, AuditRecord?, LoadsToCheck, (^() -> Principle?)?) -> MapChange?
229
+ def map_change(request_id, basis, record, loads, started_from)
230
+ base = started_from&.call
231
+ return unless base && base.version != map_version
232
+
233
+ printed = Audit.new(map: base, now: @now)
234
+ return unless printed.assessment_id(basis, printed.prior_findings(record).digested, loads.listed) == request_id
235
+
236
+ change = MapChange.new(base, @map)
237
+ change unless change.empty?
238
+ end
219
239
  end
220
240
  end
221
241
  end
@@ -4,6 +4,7 @@
4
4
  require_relative "../error"
5
5
 
6
6
  module Principles
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
7
8
  module Models
8
9
  # A current audit entry protects its map from unconfirmed removal, whether the entry is readable or not.
9
10
  class AuditEntryProtectingMap
@@ -10,7 +10,7 @@ require_relative "recorded_findings"
10
10
  require_relative "record_format"
11
11
  require_relative "recorded_members"
12
12
  require_relative "json_digest"
13
- require_relative "write_up_repoint"
13
+ require_relative "finding_decision"
14
14
  require_relative "../data/schema_check"
15
15
 
16
16
  module Principles
@@ -183,19 +183,10 @@ module Principles
183
183
  AuditRecord.new(@fields.merge("members" => members.acknowledged(key, change, check_result:).to_h))
184
184
  end
185
185
 
186
- # This record with each finding a repoint names moved by it at at; the last repoint naming a finding
187
- # wins.
188
- #: (Array[WriteUpRepoint], at: String) -> AuditRecord
189
- def repointed(repoints, at:)
190
- AuditRecord.new(@fields.merge("findings" => findings.repointed(repoints, at: at).to_a))
191
- end
192
-
193
- # The ids of the findings it leaves open whose recorded_at points elsewhere than earlier's did, as a repoint
194
- # moved them.
195
- #: (AuditRecord) -> Array[String]
196
- def write_ups_moved_since(earlier)
197
- before = earlier.left_open.to_h { |finding| [finding.id, finding.recorded_at] }
198
- left_open.select { |finding| before.key?(finding.id) && before[finding.id] != finding.recorded_at }.map(&:id)
186
+ # This record with each decision applied at at to the finding it names.
187
+ #: (Array[FindingDecision], at: String) -> AuditRecord
188
+ def decided(decisions, at:)
189
+ AuditRecord.new(@fields.merge("findings" => findings.decided(decisions, at: at).to_a))
199
190
  end
200
191
 
201
192
  # Each finding the last completed audit deferred or accepted, which the next full audit must decide:
@@ -28,7 +28,7 @@ module Principles
28
28
  #: (String, String) -> [String, AuditRecord]?
29
29
  def at(id, commit)
30
30
  [file(id), earlier_file(id)].each do |path|
31
- text = @history.text_at(commit, path) or next
31
+ text = @history.at(commit).text(path) or next
32
32
  return [path, AuditRecord.new(@files.parse(id, text) { refuse_unreadable(it, path) })]
33
33
  end
34
34
  nil
@@ -97,7 +97,7 @@ module Principles
97
97
  #: (String) -> RecordedHashes
98
98
  def hashes_to_compare(id)
99
99
  audit = find(id) or return RecordedHashes::NONE
100
- RecordedHashes.new(audit.members.hashes_by_key, waiting: RecordFormat.new(audit.to_h).newer?)
100
+ audit.members.hashes(waiting: RecordFormat.new(audit.to_h).newer?)
101
101
  rescue RecordFormat::NewerFormatError
102
102
  RecordedHashes.new(member_hashes_as_written(id).by_key, waiting: true)
103
103
  end
@@ -7,7 +7,7 @@ require_relative "located_text"
7
7
  require_relative "line_span"
8
8
 
9
9
  module Principles
10
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
10
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
11
11
  module Models
12
12
  # The lines a full audit's members span now, each with its file, against which each evidence item of another
13
13
  # principle's open finding is said to share lines or not. These are lines, not a verdict on whether
@@ -4,7 +4,7 @@
4
4
  require_relative "candidate_outline"
5
5
 
6
6
  module Principles
7
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
8
  module Models
9
9
  # The instruction files list-candidate-files offers, shortened without judging what is guidance. A
10
10
  # skill's templates, references and examples once filled most of a 10KB inventory (alpha 011
@@ -9,7 +9,7 @@ require_relative "project_history"
9
9
  require_relative "survey_search_paths"
10
10
 
11
11
  module Principles
12
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
12
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
13
13
  module Models
14
14
  # What list-candidate-files found: the inventory of candidate files as it lists them, and in git
15
15
  # which of them, or of the files their links lead to, git does not track. Each list that names a file is
@@ -32,9 +32,10 @@ module Principles
32
32
  def self.read(files, history, search_paths:, after: nil, mapped: [])
33
33
  changed = after ? history.changed_after(after) : []
34
34
  inventory = files.inventory(also: changed.grep(CandidateFiles::MARKDOWN) | (changed & mapped),
35
- matching: search_paths.globs).merge(search_paths.recorded_listing)
35
+ matching: search_paths.globs, conventional: search_paths.conventional?)
36
+ inventory = inventory.merge(search_paths.recorded_listing)
36
37
  inventory = inventory.merge("uncommitted" => uncommitted_markdown(history)) if after
37
- found(inventory, history, changed:) { |path| files.read_text(path) }
38
+ found(inventory, history, changed:, conventional: search_paths.conventional?) { |path| files.read_text(path) }
38
39
  end
39
40
 
40
41
  # An explicit file request uses the survey's entries and budget without its broad search.
@@ -52,15 +53,16 @@ module Principles
52
53
  # git does not track.
53
54
  # Each listed file's text, which its outline is read from, is what the block gives for its path.
54
55
  # changed names the files a range of commits changed, which list first, marked.
55
- #: (Hash[String, untyped], ProjectHistory, ?changed: Array[String]) { (String) -> String } -> CandidateInventory
56
- def self.found(inventory, history, changed: [], &text_of)
56
+ #: (Hash[String, untyped], ProjectHistory, ?changed: Array[String], ?conventional: bool) { (String) -> String }
57
+ #| -> CandidateInventory
58
+ def self.found(inventory, history, changed: [], conventional: true, &text_of)
57
59
  texts = {} #: Hash[String, String]
58
60
  files = CandidateFiles.new(inventory.fetch("files"), selected: inventory.fetch("selected_files", []),
59
61
  text_of: ->(path) { texts[path] ||= text_of.call(path) })
60
62
  hints = inventory.fetch("possibly_test_data")
61
63
  listed = listed(inventory, files.listing(hints, changed:))
62
- new(listed, untracked: history.untracked(listed.fetch("files").map { it.fetch("path") }),
63
- outlines: files.outlines(hints))
64
+ new(listed, untracked: history.untracked_excluding_ignored(listed.fetch("files").map { it.fetch("path") }),
65
+ outlines: files.outlines(hints), conventional:)
64
66
  end
65
67
 
66
68
  # The inventory as list-candidate-files lists it: the instruction files agent hosts load by convention, the other
@@ -86,11 +88,13 @@ module Principles
86
88
  attr_reader :untracked
87
89
 
88
90
  # outlines holds each outlined file's outline, by path, which within_budget cuts by.
89
- #: (Hash[String, untyped], untracked: Array[String]?, ?outlines: Hash[String, CandidateOutline]) -> void
90
- def initialize(listing, untracked:, outlines: {})
91
+ #: (Hash[String, untyped], untracked: Array[String]?, ?outlines: Hash[String, CandidateOutline],
92
+ #| ?conventional: bool) -> void
93
+ def initialize(listing, untracked:, outlines: {}, conventional: true)
91
94
  @listing = listing
92
95
  @untracked = untracked
93
96
  @outlines = outlines
97
+ @conventional = conventional
94
98
  @lists = listing.merge("untracked" => untracked) #: Hash[String, untyped]
95
99
  freeze
96
100
  end
@@ -98,6 +102,10 @@ module Principles
98
102
  #: () -> Hash[String, untyped]
99
103
  def to_h = @listing
100
104
 
105
+ # Whether the survey looked in the places hosts load by convention, as it does unless --only narrowed it.
106
+ #: () -> bool
107
+ def conventional? = @conventional
108
+
101
109
  # This inventory with its files' list items cut to OutlineBudget, the block giving the bytes each inventory tried
102
110
  # prints as.
103
111
  #: () { (CandidateInventory) -> Integer } -> CandidateInventory
@@ -118,7 +126,9 @@ module Principles
118
126
  private
119
127
 
120
128
  #: (Hash[String, untyped]) -> CandidateInventory
121
- def with(listing) = CandidateInventory.new(listing, untracked: @untracked, outlines: @outlines)
129
+ def with(listing)
130
+ CandidateInventory.new(listing, untracked: @untracked, outlines: @outlines, conventional: @conventional)
131
+ end
122
132
 
123
133
  # The path one list entry names: a file's path, a folder, or the path itself.
124
134
  #: (untyped) -> String
@@ -8,7 +8,7 @@ require_relative "outline_section"
8
8
  require_relative "text_within"
9
9
 
10
10
  module Principles
11
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
11
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
12
12
  module Models
13
13
  # One candidate file's outline, as the survey reads it in place of the file: its Markdown headings in order, and
14
14
  # under each its top-level list items. One user scripted a heading grep over 45 files to survey them,
@@ -4,7 +4,7 @@
4
4
  require_relative "line_diff"
5
5
 
6
6
  module Principles
7
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
7
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
8
8
  module Models
9
9
  # A long member's changed lines as a request shows them: each run of changed lines with up to context unchanged
10
10
  # lines around it, as git shows a hunk, runs whose context would meet joined into one region, and each later
@@ -5,8 +5,7 @@ require_relative "../error"
5
5
  require_relative "../data/command_steps_file"
6
6
 
7
7
  module Principles
8
- # Values built from validated data, and the rules a schema cannot express. models/CLAUDE.md owns the
9
- # boundary.
8
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
10
9
  module Models
11
10
  # The steps each command runs: which are this tool's and which are the agent's, the refusals each of
12
11
  # this tool's steps can raise, and where each step leads. Each command's --help and the workflow diagram
@@ -8,7 +8,7 @@ require_relative "last_completed_revision"
8
8
  require_relative "recorded_finding"
9
9
 
10
10
  module Principles
11
- # The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
11
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
12
12
  module Models
13
13
  # What a correction request depends on, which it prints as its basis and the agent hands back with the answer:
14
14
  # the base commit, the map's version, each finding's members and problem, what the assessment reported beyond its
@@ -7,8 +7,7 @@ require_relative "member_moves"
7
7
  require_relative "declared_member_removals"
8
8
 
9
9
  module Principles
10
- # The domain: maps, audits and command steps, with every rule a schema cannot express.
11
- # models/CLAUDE.md owns the boundary.
10
+ # The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
12
11
  module Models
13
12
  # The changes a correction declares it made to the map after the audit began: the members it moved,
14
13
  # and the members whose role or check a fix changed, which each fixed disposition lists in
@@ -5,7 +5,10 @@ require_relative "../error"
5
5
  require_relative "answer_fields"
6
6
  require_relative "answer_place"
7
7
  require_relative "answer_text"
8
+ require_relative "disposition_placeholders"
9
+ require_relative "disposition_text_field"
8
10
  require_relative "fix_only_fields"
11
+ require_relative "unfinished_field"
9
12
  require_relative "waits_on"
10
13
  require_relative "write_up_pointer"
11
14
 
@@ -20,78 +23,6 @@ module Principles
20
23
  class Disposition
21
24
  ACTIONS = %w[fixed deferred accepted disagreed].freeze #: Array[String]
22
25
 
23
- # A field the agent left unfinished: empty, the template's placeholder, the answer guide's sample, or
24
- # an action not one of the four. It says where it sits in the answer and what to write there, which one
25
- # refusal lists beside every other.
26
- class UnfinishedField
27
- #: String
28
- attr_reader :repair
29
-
30
- #: (AnswerPlace, String, problem: String, repair: String) -> void
31
- def initialize(place, name, problem:, repair:)
32
- @place = place
33
- @name = name
34
- @problem = problem
35
- @repair = repair
36
- freeze
37
- end
38
-
39
- # Whose field it is, such as "Finding F1 reason".
40
- #: () -> String
41
- def to_s = "#{@place.subject} #{@name}"
42
-
43
- # Its entry in the refusal's fields, as a malformed answer's are.
44
- #: () -> Hash[String, String]
45
- def field = { "pointer" => @place.pointer, "problem" => @problem }
46
- end
47
-
48
- # A text field the agent must write: the placeholder the correction template leaves in it, which an answer may
49
- # not send back unchanged, and what to write instead; reassessment applies only to a fix.
50
- class TextField
51
- #: String
52
- attr_reader :placeholder
53
-
54
- #: (placeholder: String, repair: String) -> void
55
- def initialize(placeholder:, repair:)
56
- @placeholder = placeholder
57
- @repair = repair
58
- freeze
59
- end
60
-
61
- # The field named name, at place, when value leaves it empty, as the placeholder or as sample,
62
- # the answer guide's illustration of this field for the disposition's action, if it gives one.
63
- #: (untyped, AnswerPlace, String, sample: String?) -> UnfinishedField?
64
- def left_in(value, place, name, sample:)
65
- problem = if !AnswerText.new(value).written? then "must be a nonempty string"
66
- elsif value == @placeholder then "is the template's placeholder, unchanged"
67
- elsif value == sample then SAMPLE_UNCHANGED
68
- end
69
- UnfinishedField.new(place, name, problem:, repair: @repair) if problem
70
- end
71
- end
72
-
73
- # The problem with a field the agent gave back as the answer guide's sample.
74
- SAMPLE_UNCHANGED = "is the answer guide's sample, unchanged" #: String
75
-
76
- TEXT_FIELDS = {
77
- "reason" => TextField.new(placeholder: "Why, and what remains",
78
- repair: "Write why you chose this action and what remains."),
79
- "reassessment" => TextField.new(placeholder: "fixed only: how the changed members now carry the " \
80
- "principle. Leave as printed otherwise",
81
- repair: "Write how the changed members now carry the principle.")
82
- }.freeze #: Hash[String, TextField]
83
- # The placeholder in each field, which the template prints.
84
- PLACEHOLDERS = TEXT_FIELDS.transform_values(&:placeholder).freeze #: Hash[String, String]
85
- # What action takes, said where it is written when the correction's answer is printed with no answer guide
86
- # beside it, as show-answer-check prints it. It is help, never an action, so it is left unchosen.
87
- ACTION_PLACEHOLDER = "One of fixed, deferred, accepted or disagreed, each with a reason: fixed lists " \
88
- "changed_members for current text changes, optional removed_members for map removals, " \
89
- "and evidence and gives a reassessment; deferred gives recorded_at, " \
90
- "where the write-up is, and may give waits_on; any other action leaves changed_members, " \
91
- "evidence and reassessment as printed" #: String
92
- # Every placeholder a correction's template prints: each text field's, and the action's.
93
- TEMPLATE_PLACEHOLDERS = PLACEHOLDERS.merge("action" => ACTION_PLACEHOLDER).freeze #: Hash[String, String]
94
-
95
26
  # at is the disposition's place in the answer, such as /dispositions/0, which a refusal about its pointers names.
96
27
  # samples is the answer guide's disposition for each action, whose text illustrates each field.
97
28
  #: (untyped, AnswerFields, at: String, samples: Hash[String, untyped]) -> void
@@ -167,7 +98,7 @@ module Principles
167
98
  action = @disposition["action"]
168
99
  return if ACTIONS.include?(action)
169
100
 
170
- unchosen = action.nil? || action == ACTION_PLACEHOLDER
101
+ unchosen = action.nil? || DispositionPlaceholders::ACTION.left?(action)
171
102
  problem = unchosen ? "is not chosen" : "is #{action.inspect}, not one of the four"
172
103
  UnfinishedField.new(@place.child("action"), "action",
173
104
  problem:, repair: "Set its action to one of fixed, deferred, accepted or disagreed.")
@@ -178,7 +109,8 @@ module Principles
178
109
  #: () -> Array[UnfinishedField]
179
110
  def unwritten_text
180
111
  action = @disposition["action"]
181
- required = action == "fixed" ? TEXT_FIELDS : TEXT_FIELDS.slice("reason")
112
+ fields = DispositionPlaceholders::TEXT_FIELDS
113
+ required = action == "fixed" ? fields : fields.slice("reason")
182
114
  required.filter_map do |name, field|
183
115
  field.left_in(@disposition[name], @place.child(name), name, sample: @samples.dig(action, name))
184
116
  end
@@ -191,7 +123,8 @@ module Principles
191
123
  sample = @samples.dig(@disposition["action"], "waits_on")
192
124
  return unless sample && @disposition["waits_on"] == sample
193
125
 
194
- UnfinishedField.new(@place.child("waits_on"), "waits_on", problem: SAMPLE_UNCHANGED, repair: WaitsOn::REPAIR)
126
+ UnfinishedField.new(@place.child("waits_on"), "waits_on", problem: DispositionTextField::SAMPLE_UNCHANGED,
127
+ repair: WaitsOn::REPAIR)
195
128
  end
196
129
 
197
130
  # A fix's claimed members, each of which must have changed. A fix may claim no member's text when it
@@ -216,7 +149,10 @@ module Principles
216
149
  end
217
150
 
218
151
  #: () -> FixOnlyFields
219
- def fix_fields = FixOnlyFields.new(@disposition, left_reassessment: PLACEHOLDERS.fetch("reassessment"))
152
+ def fix_fields
153
+ FixOnlyFields.new(@disposition,
154
+ left_reassessment: DispositionPlaceholders::TEXT_FIELDS.fetch("reassessment").placeholder)
155
+ end
220
156
 
221
157
  # Each piece of evidence, and where the finding is written up, located in the project.
222
158
  #: () -> void