principles 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/lib/principles/cli.rb +3 -1
  3. data/lib/principles/command_line.rb +35 -7
  4. data/lib/principles/command_routes.rb +4 -3
  5. data/lib/principles/controllers/acknowledgement.rb +80 -14
  6. data/lib/principles/controllers/answer.rb +42 -75
  7. data/lib/principles/controllers/answer_phase.rb +54 -0
  8. data/lib/principles/controllers/assessment.rb +33 -9
  9. data/lib/principles/controllers/audit.rb +17 -6
  10. data/lib/principles/controllers/audit_completion.rb +6 -4
  11. data/lib/principles/controllers/command.rb +3 -2
  12. data/lib/principles/controllers/correction.rb +19 -9
  13. data/lib/principles/controllers/full_audit_request.rb +10 -0
  14. data/lib/principles/controllers/inventory.rb +25 -20
  15. data/lib/principles/controllers/member_problems_report.rb +11 -4
  16. data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
  17. data/lib/principles/controllers/members_to_assess.rb +20 -12
  18. data/lib/principles/controllers/repoint.rb +18 -22
  19. data/lib/principles/data/bounded_file.rb +9 -4
  20. data/lib/principles/data/command-steps.json +9 -9
  21. data/lib/principles/data/project_files.rb +11 -8
  22. data/lib/principles/data/schema_check.rb +16 -6
  23. data/lib/principles/data/schemas/acknowledgement-answer.schema.json +17 -3
  24. data/lib/principles/data/schemas/answer-guide.schema.json +5 -10
  25. data/lib/principles/data/schemas/audit-record.schema.json +10 -1
  26. data/lib/principles/data/schemas/command-steps.schema.json +2 -1
  27. data/lib/principles/invocation_options.rb +1 -1
  28. data/lib/principles/models/acknowledgement.rb +73 -84
  29. data/lib/principles/models/acknowledgement_refusal.rb +90 -0
  30. data/lib/principles/models/answer_place.rb +4 -0
  31. data/lib/principles/models/assessment_answer.rb +0 -45
  32. data/lib/principles/models/assessment_left_as_printed.rb +81 -0
  33. data/lib/principles/models/audit_record.rb +9 -17
  34. data/lib/principles/models/audit_records.rb +19 -16
  35. data/lib/principles/models/candidate_files.rb +30 -7
  36. data/lib/principles/models/candidate_inventory.rb +23 -6
  37. data/lib/principles/models/candidate_listing.rb +12 -3
  38. data/lib/principles/models/candidate_outline.rb +195 -0
  39. data/lib/principles/models/carried_member.rb +42 -0
  40. data/lib/principles/models/check_since_last_audit.rb +16 -3
  41. data/lib/principles/models/command_steps.rb +17 -1
  42. data/lib/principles/models/declared_map_changes.rb +5 -4
  43. data/lib/principles/models/frontmatter_fields.rb +9 -8
  44. data/lib/principles/models/instruction_named.rb +35 -0
  45. data/lib/principles/models/left_as_printed.rb +39 -0
  46. data/lib/principles/models/member_assessments.rb +9 -31
  47. data/lib/principles/models/member_file.rb +35 -11
  48. data/lib/principles/models/member_hashes_as_written.rb +10 -6
  49. data/lib/principles/models/member_lines.rb +63 -15
  50. data/lib/principles/models/member_problems.rb +24 -18
  51. data/lib/principles/models/member_repair_moves.rb +54 -0
  52. data/lib/principles/models/missing_files.rb +2 -2
  53. data/lib/principles/models/open_findings_elsewhere.rb +4 -0
  54. data/lib/principles/models/other_templates_placeholders.rb +81 -42
  55. data/lib/principles/models/outline_budget.rb +127 -0
  56. data/lib/principles/models/outline_group.rb +31 -0
  57. data/lib/principles/models/outline_section.rb +56 -0
  58. data/lib/principles/models/principle_members.rb +11 -0
  59. data/lib/principles/models/prior_decision_fields.rb +3 -2
  60. data/lib/principles/models/prior_finding_decision.rb +14 -4
  61. data/lib/principles/models/project.rb +10 -19
  62. data/lib/principles/models/quoted_change.rb +137 -0
  63. data/lib/principles/models/record_format.rb +6 -2
  64. data/lib/principles/models/recorded_entry.rb +6 -0
  65. data/lib/principles/models/recorded_hashes.rb +7 -3
  66. data/lib/principles/models/recorded_members.rb +27 -15
  67. data/lib/principles/models/refusal_before_shape.rb +21 -0
  68. data/lib/principles/models/repoint.rb +13 -0
  69. data/lib/principles/models/reported_check.rb +3 -13
  70. data/lib/principles/models/sent_answer.rb +51 -0
  71. data/lib/principles/models/shape_problems_beside.rb +40 -0
  72. data/lib/principles/models/submitted_answer.rb +34 -0
  73. data/lib/principles/models/template_placeholders.rb +34 -4
  74. data/lib/principles/models/text_within.rb +55 -0
  75. data/lib/principles/models/unchecked_members.rb +76 -0
  76. data/lib/principles/models/write_up_opening.rb +21 -4
  77. data/lib/principles/session_start_options.rb +2 -2
  78. data/lib/principles/start_audit_options.rb +19 -4
  79. data/lib/principles/version.rb +2 -2
  80. data/lib/principles/views/acknowledgement_result.rb +15 -7
  81. data/lib/principles/views/assessed_members.rb +43 -10
  82. data/lib/principles/views/assessment_request.rb +89 -30
  83. data/lib/principles/views/audit_result.rb +19 -2
  84. data/lib/principles/views/candidate_files_result.rb +41 -19
  85. data/lib/principles/views/check_notes.rb +44 -0
  86. data/lib/principles/views/check_result_template.rb +14 -23
  87. data/lib/principles/views/instruction.rb +74 -0
  88. data/lib/principles/views/json_with_entries_on_lines.rb +51 -0
  89. data/lib/principles/views/loads_to_check_result.rb +2 -2
  90. data/lib/principles/views/map_result.rb +2 -2
  91. data/lib/principles/views/member_change_since_baseline.rb +22 -5
  92. data/lib/principles/views/member_repairs.rb +21 -52
  93. data/lib/principles/views/members_a_commit_changed.rb +16 -6
  94. data/lib/principles/views/one_member_check_result_template.rb +43 -0
  95. data/lib/principles/views/open_findings_elsewhere_result.rb +3 -3
  96. data/lib/principles/views/open_findings_line.rb +77 -23
  97. data/lib/principles/views/principle_read_result.rb +20 -28
  98. data/lib/principles/views/prior_findings_result.rb +23 -15
  99. data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -0
  100. data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -12
  101. data/lib/principles/views/prompts/assess-every-member/answer-guide.json +5 -10
  102. data/lib/principles/views/prompts/assess-every-member/assess-each-member-and-the-set.md +0 -4
  103. data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +7 -0
  104. data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +4 -16
  105. data/lib/principles/views/prompts/assess-every-member/judge-the-set-with-carried-assessments.md +5 -10
  106. data/lib/principles/views/prompts/assess-every-member/keep-or-change-what-a-deferral-waits-on.md +4 -0
  107. data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +8 -0
  108. data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -0
  109. data/lib/principles/views/prompts/assess-every-member/review-a-new-or-changed-check-before-running-it.md +9 -0
  110. data/lib/principles/views/prompts/assess-every-member/say-what-observed-means.md +4 -0
  111. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +4 -3
  112. data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-after-the-table.md +1 -0
  113. data/lib/principles/views/prompts/find-a-principle-to-map/ask-which-principle-to-map.md +2 -0
  114. data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +9 -5
  115. data/lib/principles/views/prompts/find-a-principle-to-map/leave-test-data-out-of-the-survey.md +1 -0
  116. data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +3 -0
  117. data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +3 -0
  118. data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +21 -6
  119. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +4 -4
  120. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
  121. data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +1 -2
  122. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +1 -1
  123. data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +5 -5
  124. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +24 -24
  125. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +3 -3
  126. data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +1 -0
  127. data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +2 -0
  128. data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -0
  129. data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +9 -6
  130. data/lib/principles/views/prompts/start-a-session/see-the-earlier-line.md +2 -0
  131. data/lib/principles/views/record_waiting_on_an_upgrade.rb +3 -3
  132. data/lib/principles/views/request_part.rb +16 -8
  133. data/lib/principles/views/request_parts.rb +4 -0
  134. metadata +39 -5
  135. data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-before-mapping.md +0 -1
  136. data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +0 -1
  137. data/lib/principles/views/prompts/set-principles-up/set-up-first.md +0 -2
@@ -12,6 +12,7 @@ module Principles
12
12
  @member = !options.value("member").nil? #: bool
13
13
  @write_ups = !options.value("write_ups").nil? #: bool
14
14
  @form = options.value("as") #: String?
15
+ @instruction = !options.value("instruction").nil? #: bool
15
16
  freeze
16
17
  end
17
18
 
@@ -20,18 +21,32 @@ module Principles
20
21
  def fault
21
22
  return "--member and --write-ups each start a different audit; give one" if @member && @write_ups
22
23
 
23
- form_fault
24
+ instruction_fault || form_fault
24
25
  end
25
26
 
26
27
  private
27
28
 
28
- # --as template prints a full audit's answer alone, the one form built so far (D81 step 1); nil when it fits.
29
+ # --instruction prints one field of a full audit's request whole (D81 step 2); nil when nothing beside it prints
30
+ # another output.
31
+ #: () -> String?
32
+ def instruction_fault
33
+ return unless @instruction
34
+
35
+ other = if @form then "the answer --as template prints"
36
+ elsif @member then "the one-member audit --member starts"
37
+ elsif @write_ups then "the repoint --write-ups starts"
38
+ end
39
+ "--instruction prints one field of a full audit's request, not of #{other}" if other
40
+ end
41
+
42
+ # --as template prints a full audit's answer alone (D81 step 1), or a one-member audit's (#773), the one form
43
+ # built so far; nil when it fits.
29
44
  #: () -> String?
30
45
  def form_fault
31
46
  form = @form or return
32
- return "--as takes template, the full audit's answer alone, not #{form}" unless form == "template"
47
+ return "--as takes template, the answer alone, not #{form}" unless form == "template"
33
48
 
34
- "--as template prints a full audit's answer, not one --member or --write-ups starts" if @member || @write_ups
49
+ "--as template prints a full or one-member audit's answer, not one --write-ups starts" if @write_ups
35
50
  end
36
51
  end
37
52
  end
@@ -3,9 +3,9 @@
3
3
 
4
4
  module Principles
5
5
  # The next production release, as major.minor.patch. A production build is versioned with this alone.
6
- RELEASE = "0.0.4"
6
+ RELEASE = "0.0.5"
7
7
  # The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
8
8
  # packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
9
9
  # Data::RunningVersion reads the commit this tool runs from instead.
10
- BUILT_VERSION = "0.0.4" #: String?
10
+ BUILT_VERSION = "0.0.5" #: String?
11
11
  end
@@ -16,20 +16,28 @@ module Principles
16
16
  freeze
17
17
  end
18
18
 
19
- # change is the member's change since its baseline; open_findings, the record's findings on the member. What
20
- # the agent judges is under context, the question last, as in a full audit's request (D60).
19
+ # change is the member's change since its baseline; open_findings, the record's findings on the member;
20
+ # placeholders, the text the template prints in each field the agent writes. What the agent judges is under
21
+ # context, the question last, as in a full audit's request (D60).
21
22
  #: (request_id: String, principle_id: String, change: MemberChangeSinceBaseline,
22
- #| open_findings: Hash[String, Array[String]]) -> Hash[String, untyped]
23
- def request(request_id:, principle_id:, change:, open_findings:)
23
+ #| open_findings: Hash[String, Array[String]], placeholders: Hash[String, untyped]) -> Hash[String, untyped]
24
+ def request(request_id:, principle_id:, change:, open_findings:, placeholders:)
24
25
  { "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
25
26
  "context" => { "principle_id" => principle_id, **change.to_h, **open_findings,
26
27
  "question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning") },
27
- "response_template" => { "request_id" => request_id,
28
- "basis" => { "base_commit" => change.base_commit, "member_id" => change.member_id },
29
- "meaning_kept" => true, "reason" => "", "old_line" => "", "new_line" => "" },
28
+ "response_template" => answer_to_fill(request_id:, change:, placeholders:),
30
29
  "answer_with" => @invocation.submit_answer(request_id) }
31
30
  end
32
31
 
32
+ # The answer to the request request_id names, to fill: the request prints it as response_template, and
33
+ # start-audit --member --as template prints it alone, each field the agent writes holding its placeholder (#773).
34
+ #: (request_id: String, change: MemberChangeSinceBaseline, placeholders: Hash[String, untyped])
35
+ #| -> Hash[String, untyped]
36
+ def answer_to_fill(request_id:, change:, placeholders:)
37
+ { "request_id" => request_id,
38
+ "basis" => { "base_commit" => change.base_commit, "member_id" => change.member_id }, **placeholders }
39
+ end
40
+
33
41
  # The acknowledgement was accepted and file holds it.
34
42
  #: (principle_id: String, member_id: String, file: String) -> Hash[String, untyped]
35
43
  def acknowledged(principle_id:, member_id:, file:)
@@ -12,7 +12,7 @@ module Principles
12
12
  class AssessedMembers
13
13
  # What the request shows of each member.
14
14
  SHOWN = %w[id role first_line last_line check check_since_last_audit check_hidden_characters
15
- acknowledged_since_last_audit carried_forward judge_because moved_from read_the_change
15
+ acknowledged_since_last_audit carried_forward open_finding_ids judge_because moved_from read_the_change
16
16
  mapped_elsewhere].freeze #: Array[String]
17
17
 
18
18
  # reviewed_check_placeholders is the text a checked member's template prints in each field it may leave as
@@ -34,9 +34,23 @@ module Principles
34
34
  freeze
35
35
  end
36
36
 
37
- # Each member as the request's context shows it, its fields in SHOWN's order.
37
+ # What the request shows of a carried member no flag fires on (D93): what names it and its check, whose result
38
+ # the template still asks for, and of its carried assessment only its dates and flags.
39
+ COMPACT = %w[id role check check_since_last_audit check_hidden_characters carried_forward].freeze #: Array[String]
40
+ # What a compact member shows of its carried assessment.
41
+ CARRIED_COMPACTLY = %w[assessed_at observed_at observed_at_from_assessed_at evidence_changed
42
+ file_changed_outside_member].freeze #: Array[String]
43
+
44
+ # Each member as the request's context shows it, its fields in SHOWN's order; a carried member no flag fires on
45
+ # compactly, as COMPACT and CARRIED_COMPACTLY say, its stored assessment one show-audit away (D93).
38
46
  #: () -> Array[Hash[String, untyped]]
39
- def shown = @members.map { |member| SHOWN.select { member.key?(it) }.to_h { [it, member[it]] } }
47
+ def shown
48
+ @members.map do |member|
49
+ next fields(member, SHOWN) unless compact?(member)
50
+
51
+ fields(member, COMPACT).merge("carried_forward" => member.fetch("carried_forward").slice(*CARRIED_COMPACTLY))
52
+ end
53
+ end
40
54
 
41
55
  # Each member's template entry: a fresh assessment to fill in, or, for a member whose last assessment is
42
56
  # carried forward, the marker that keeps it (D49); either with its check's result when it has a check.
@@ -58,29 +72,48 @@ module Principles
58
72
  #: () -> bool
59
73
  def checked? = @members.any? { |member| member["check"] }
60
74
 
75
+ # Whether any member's check is new or changed, so no audit ran it as it is now, to review before it runs (D63).
76
+ #: () -> bool
77
+ def check_to_review?
78
+ @members.any? { |member| member["check"] && member.dig("check_since_last_audit", "status") != "unchanged" }
79
+ end
80
+
61
81
  # Whether the request carries any member's last assessment forward (D49).
62
82
  #: () -> bool
63
83
  def carried_forward? = @members.any? { |member| member["carried_forward"] }
64
84
 
85
+ # Whether any member is judged afresh, whose template then gives a delivery (#983).
86
+ #: () -> bool
87
+ def judged_afresh? = @members.any? { |member| !member["carried_forward"] }
88
+
89
+ # Whether a carried member no flag fires on prints compactly, with no assessment (D93).
90
+ #: () -> bool
91
+ def carried_compactly? = @members.any? { |member| compact?(member) }
92
+
65
93
  # Each reason a member is judged afresh, once (D61).
66
94
  #: () -> Array[String]
67
95
  def judge_because = @members.filter_map { |member| member["judge_because"] }.uniq
68
96
 
69
97
  # Each entry naming another principle's role for a member's lines (#719).
70
98
  #: () -> Array[Hash[String, untyped]]
71
- def mapped_elsewhere = @members.flat_map { |member| member["mapped_elsewhere"] || [] }
99
+ def mapped_elsewhere = shown.flat_map { |member| member["mapped_elsewhere"] || [] }
72
100
 
73
101
  private
74
102
 
103
+ # Whether member is carried with no flag firing on it, so it prints compactly (D93).
104
+ #: (Hash[String, untyped]) -> bool
105
+ def compact?(member) = member["carried_forward"] && !member["flagged"]
106
+
107
+ # member's fields named in names, in that order.
108
+ #: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
109
+ def fields(member, names) = names.select { member.key?(it) }.to_h { [it, member[it]] }
110
+
75
111
  #: (Hash[String, untyped]) -> Hash[String, untyped]
76
112
  def template(member)
77
113
  assessed = member["carried_forward"] ? carried(member) : fresh(member)
78
- check = member["check"] or return assessed
79
- template = CheckResultTemplate.new(check, member["check_since_last_audit"],
80
- member.fetch("check_hidden_characters", []),
81
- reviewed_placeholders: @reviewed_check_placeholders,
82
- unchanged_placeholders: @unchanged_check_placeholders)
83
- assessed.merge("check_result" => template.to_h)
114
+ template = CheckResultTemplate.for(member, reviewed_placeholders: @reviewed_check_placeholders,
115
+ unchanged_placeholders: @unchanged_check_placeholders)
116
+ template ? assessed.merge("check_result" => template) : assessed
84
117
  end
85
118
 
86
119
  #: (Hash[String, untyped]) -> Hash[String, untyped]
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative "answer_head"
5
5
  require_relative "assessed_members"
6
+ require_relative "instruction"
6
7
  require_relative "prompts"
7
8
  require_relative "request_parts"
8
9
 
@@ -16,10 +17,21 @@ module Principles
16
17
  IN_GUIDE = {
17
18
  "unavailable_reason" => "Or use the assessed shape in answer_guide.recent_decision."
18
19
  }.freeze #: Hash[String, String]
20
+ # How mapped_elsewhere_instruction's paragraph on open findings elsewhere begins, which prints only when an
21
+ # entry names one (#808).
22
+ OPEN_FINDINGS_ELSEWHERE = "Where an entry names `open_finding_ids`" #: String
19
23
 
20
- # The question every member's assessment answers, which a completed record digests with the description (D49).
24
+ # The question every member's assessment answers, which a completed record digests with the description (D49):
25
+ # the whole question, what observed means too, however much of it a request prints (#983).
21
26
  #: () -> String
22
- def self.question = Prompts.text("assess-every-member/assess-each-member-and-the-set")
27
+ def self.question = question_paragraphs.join(" ")
28
+
29
+ # The question's two parts: what to assess, and what observed means, which only a member judged afresh needs.
30
+ #: () -> [String, String]
31
+ def self.question_paragraphs
32
+ [Prompts.text("assess-every-member/assess-each-member-and-the-set"),
33
+ Prompts.text("assess-every-member/say-what-observed-means")]
34
+ end
23
35
 
24
36
  # principle is the principle_id and description it names. head is what the answer hands back unchanged: the
25
37
  # request's id and its basis, the base commit and the last completed record's revision. parts are what the
@@ -50,6 +62,23 @@ module Principles
50
62
  @parts.shown_after(listed).merge(asked)
51
63
  end
52
64
 
65
+ # The fields the request prints an instruction under, in the order it prints them: the question, the answer
66
+ # guide and each field named for an instruction (D81 step 2).
67
+ #: () -> Array[String]
68
+ def instruction_fields = printed_instructions.map(&:field)
69
+
70
+ # The principle the request audits.
71
+ #: () -> String
72
+ def principle_id = @principle.fetch("principle_id")
73
+
74
+ # The instruction fields the request prints only in part, leaving out paragraphs for cases it does not hold.
75
+ #: () -> Array[String]
76
+ def trimmed_instruction_fields = printed_instructions.select(&:trimmed?).map(&:field)
77
+
78
+ # The instruction field whole: every paragraph, the ones for cases the request does not hold too.
79
+ #: (String) -> untyped
80
+ def whole_instruction(field) = printed_instructions.find { it.field == field }&.whole
81
+
53
82
  # The answer to fill in: one assessment per member, and the set's.
54
83
  #: () -> Hash[String, untyped]
55
84
  def template
@@ -77,56 +106,86 @@ module Principles
77
106
  "recent_decision" => recent_decision, "findings" => [] }
78
107
  end
79
108
 
80
- # What the request asks of what the agent read: the question, why members are judged afresh, how to treat the
81
- # members it carries forward and the roles other principles give their lines, and the guide to the answer's
82
- # shapes.
109
+ # The instructions the request prints, in order: each part's, after its list, then its own.
110
+ #: () -> Array[Instruction | GuideInstruction]
111
+ def printed_instructions = [*@parts.instructions, *instructions].reject { it.printed.empty? }
112
+
113
+ # What the request asks of what the agent read, each of its own instructions as the request prints it.
83
114
  #: () -> Hash[String, untyped]
84
- def asked
85
- { "question" => AssessmentRequest.question }.merge(judge_because_instruction, carried_forward_instruction,
86
- mapped_elsewhere_instruction)
87
- .merge("answer_guide" => answer_guide)
115
+ def asked = instructions.reduce({}) { |all, instruction| all.merge(instruction.printed) }
116
+
117
+ # The request's own instructions: the question, why members are judged afresh, how to treat the members it
118
+ # carries forward and the roles other principles give their lines, and the guide to the answer's shapes.
119
+ #: () -> Array[Instruction | GuideInstruction]
120
+ def instructions
121
+ [question, judge_because_instruction,
122
+ carried_forward_instruction, mapped_elsewhere_instruction, answer_guide]
123
+ end
124
+
125
+ # The question, defining observed only when a member is judged afresh, whose delivery it guides (#983).
126
+ #: () -> Instruction
127
+ def question
128
+ assess, observed = AssessmentRequest.question_paragraphs
129
+ Instruction.new("question", [[assess, true], [observed, @members.judged_afresh?]])
88
130
  end
89
131
 
90
132
  # Why each member with judge_because is judged afresh, explaining only the values the members carry, so the
91
133
  # agent meets each value's meaning where it meets the value (D61); nothing when no member gives one.
92
- #: () -> Hash[String, untyped]
134
+ #: () -> Instruction
93
135
  def judge_because_instruction
94
136
  reasons = @members.judge_because
95
- return {} if reasons.empty?
96
-
97
- intro, *meanings = Prompts.text("assess-every-member/why-each-member-is-judged-again").split("\n\n")
98
- shown = meanings.select { |meaning| reasons.any? { |reason| meaning.start_with?("`#{reason}`:") } }
99
- { "judge_because_instruction" => [intro, *shown].join("\n\n") }
137
+ text = Prompts.text("assess-every-member/why-each-member-is-judged-again")
138
+ Instruction.of_paragraphs("judge_because_instruction", text) do |paragraph|
139
+ reasons.any? && (!paragraph.start_with?("`") || reasons.any? { paragraph.start_with?("`#{it}`:") })
140
+ end
100
141
  end
101
142
 
102
143
  # How to judge the roles other principles give a member's lines, printed only when a member shares lines with
103
144
  # another principle's (#719, D61), and, when an entry names findings open on its member, where to read how to
104
145
  # treat them, which prints apart, before the question (#808).
105
- #: () -> Hash[String, untyped]
146
+ #: () -> Instruction
106
147
  def mapped_elsewhere_instruction
107
148
  entries = @members.mapped_elsewhere
108
- return {} if entries.empty?
109
-
110
- roles, open_findings = Prompts.text("assess-every-member/check-roles-other-principles-give-these-lines")
111
- .split("\n\n")
112
- shown = entries.any? { |entry| entry["open_finding_ids"] } ? [roles, open_findings] : [roles]
113
- { "mapped_elsewhere_instruction" => shown.join("\n\n") }
149
+ open = entries.any? { |entry| entry["open_finding_ids"] }
150
+ text = Prompts.text("assess-every-member/check-roles-other-principles-give-these-lines")
151
+ Instruction.of_paragraphs("mapped_elsewhere_instruction", text) do |paragraph|
152
+ entries.any? && (open || !paragraph.start_with?(OPEN_FINDINGS_ELSEWHERE))
153
+ end
114
154
  end
115
155
 
116
- # The answer guide, showing the check result's shapes only when a member has a check, so an audit
117
- # with no checks costs no more context than before (D30).
118
- #: () -> Hash[String, untyped]
156
+ # The answer guide, showing check_result's fields only when a member has a check, so an audit
157
+ # with no checks costs no more context than before (D30), and delivery's shapes only when a member is judged
158
+ # afresh, since a carried member's marker gives none (#983). check_result's limits say how to review a check
159
+ # before running it only when a check is new or changed, as that check's own template says too (#983).
160
+ #: () -> GuideInstruction
119
161
  def answer_guide
120
162
  guide = Prompts.data("assess-every-member/answer-guide")
121
- @members.checked? ? guide : guide.except("check_result")
163
+ narrowed = @members.check_to_review? ? {} : guide.slice("check_result")
164
+ GuideInstruction.new("answer_guide", guide.merge("check_result" => reviewed(guide.fetch("check_result"))),
165
+ narrowed:) do |entry|
166
+ case entry
167
+ when "check_result" then @members.checked?
168
+ when "member_delivery" then @members.judged_afresh?
169
+ else true
170
+ end
171
+ end
172
+ end
173
+
174
+ # check_result's guide entry whole, its limits ending with how to review a new or changed check before running it.
175
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
176
+ def reviewed(check_result)
177
+ review = Prompts.text("assess-every-member/review-a-new-or-changed-check-before-running-it")
178
+ check_result.merge("limits" => "#{check_result.fetch("limits")} #{review}")
122
179
  end
123
180
 
124
181
  # How to answer when the request carries some members' last assessments forward; nothing when it carries none.
125
- #: () -> Hash[String, untyped]
182
+ # What a compact carried member shows, and what prints one whole, only when one prints compactly (#983).
183
+ #: () -> Instruction
126
184
  def carried_forward_instruction
127
- return {} unless @members.carried_forward?
128
-
129
- { "carried_forward_instruction" => Prompts.text("assess-every-member/judge-the-set-with-carried-assessments") }
185
+ carry = Prompts.text("assess-every-member/judge-the-set-with-carried-assessments")
186
+ compact = Prompts.text("assess-every-member/read-a-compact-carried-member")
187
+ Instruction.new("carried_forward_instruction",
188
+ [[carry, @members.carried_forward?], [compact, @members.carried_compactly?]])
130
189
  end
131
190
  end
132
191
  end
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "../prose_list"
4
5
  require_relative "assessment_request"
5
6
  require_relative "audit_changes"
6
7
  require_relative "correction_request"
@@ -61,10 +62,17 @@ module Principles
61
62
  result.merge("next_action" => "#{waits}Submit the same answer unchanged, as you gave it: #{submit}")
62
63
  end
63
64
 
64
- # start-audit: the assessment request, as a judgement to answer under its request id.
65
+ # start-audit: the assessment request, as a judgement to answer under its request id, its context naming the
66
+ # instructions it prints only in part and the flag that prints one whole, so a trimmed field is not taken for
67
+ # the whole (#983), without the command the agent just ran (#1125).
65
68
  #: (AssessmentRequest) -> Hash[String, untyped]
66
69
  def assessment_request(request)
67
- judgement("assessment", request)
70
+ output = judgement("assessment", request)
71
+ trimmed = request.trimmed_instruction_fields
72
+ return output if trimmed.empty?
73
+
74
+ note = Prompts.text("assess-every-member/read-a-trimmed-instruction-whole", fields: ProseList.new(trimmed).to_s)
75
+ output.merge("context" => output.fetch("context").merge("trimmed_instructions" => note))
68
76
  end
69
77
 
70
78
  # start-audit --as template: the assessment's answer alone, to fill and submit (D81 step 1).
@@ -97,6 +105,15 @@ module Principles
97
105
  "full_record" => @invocation.in_project("show-audit", principle_id))
98
106
  end
99
107
 
108
+ # completed, a completed audit's result, offering to set principles up after its next_action, as it does
109
+ # while nothing keeps them held between audits (D95).
110
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
111
+ def offering_set_up(completed)
112
+ offer = Prompts.text("set-principles-up/keep-them-held-between-audits",
113
+ command: @invocation.in_project("show-meta-principle-passage"))
114
+ completed.merge("next_action" => "#{completed.fetch("next_action")}\n#{offer}")
115
+ end
116
+
100
117
  # The notice start-audit adds when the last audit's record is not committed.
101
118
  #: (String) -> String
102
119
  def uncommitted_record_notice(file)
@@ -14,9 +14,20 @@ module Principles
14
14
  # outside git, where nothing checked them (#386), and the lists to ask the owner about, each with the paths to
15
15
  # name in it (#405, #412).
16
16
  class Found
17
+ # What each listed file prints: where it is, how big, where a link leads, and what the survey reads of it.
18
+ PRINTED_FILE_FIELDS = %w[path characters symlink_to description opening_line outline].freeze
19
+
17
20
  #: Hash[String, Array[String]]
18
21
  attr_reader :owner_asks
19
22
 
23
+ # Whether the inventory names files whose list items were cut to keep the result short (#1155).
24
+ #: () -> bool
25
+ def cut? = @inventory.key?("outlines_cut")
26
+
27
+ # Whether the inventory names files that print their path and size alone, their outlines left out (#1155).
28
+ #: () -> bool
29
+ def left_out? = @inventory.key?("outlines_left_out")
30
+
20
31
  #: (inventory: Hash[String, untyped], untracked: Array[String]?,
21
32
  #| owner_asks: Hash[String, Array[String]]) -> void
22
33
  def initialize(inventory:, untracked:, owner_asks:)
@@ -30,7 +41,7 @@ module Principles
30
41
  # in git.
31
42
  #: () -> Hash[String, untyped]
32
43
  def listed
33
- files = @inventory.fetch("files").map { |file| file.slice("path", "characters", "symlink_to") }
44
+ files = @inventory.fetch("files").map { |file| file.slice(*PRINTED_FILE_FIELDS) }
34
45
  listed = @inventory.merge("files" => files,
35
46
  "scope" => Prompts.text("find-a-principle-to-map/where-the-inventory-looks"))
36
47
  @untracked ? listed.merge("untracked" => @untracked) : listed
@@ -47,34 +58,45 @@ module Principles
47
58
  end
48
59
 
49
60
  # The inventory, and the question of which principle to map, with one item for each list under found's owner_asks
50
- # to ask the owner about. Until principles is set_up, next_action puts setting it up first.
51
- #: (Found, existing_maps: Array[String], map_file: String, set_up: bool) -> Hash[String, untyped]
52
- def question(found, existing_maps:, map_file:, set_up:)
61
+ # to ask the owner about.
62
+ #: (Found, existing_maps: Array[String], map_file: String) -> Hash[String, untyped]
63
+ def question(found, existing_maps:, map_file:)
53
64
  { "status" => "question", "inventory" => found.listed, "existing_maps" => existing_maps,
54
65
  "writes" => Prompts.text("find-a-principle-to-map/what-each-command-writes", map_file: map_file),
55
- "question" => principle_question(found.owner_asks),
56
- "answer_with" => @invocation.in_project("create-principle", usage: CREATE_PRINCIPLE_USAGE),
57
- **(set_up ? {} : { "next_action" => set_up_first }) }
66
+ "question" => principle_question(found),
67
+ "answer_with" => @invocation.in_project("create-principle", usage: CREATE_PRINCIPLE_USAGE) }
58
68
  end
59
69
 
60
70
  private
61
71
 
62
- # The line that puts setting principles up first, ending in its command.
63
- #: () -> String
64
- def set_up_first
65
- Prompts.text("set-principles-up/set-up-first",
66
- command: @invocation.in_project("show-meta-principle-passage"))
67
- end
68
-
69
- # Which principle to map, then one item per list to ask the owner about.
70
- #: (Hash[String, Array[String]]) -> String
71
- def principle_question(owner_asks)
72
+ # The survey, leaving out files possibly test data, and when outlines were cut or left out how to read them, then
73
+ # one item per list to ask the owner about after the table.
74
+ #: (Found) -> String
75
+ def principle_question(found)
76
+ owner_asks = found.owner_asks
72
77
  asks = owner_asks.map { |key, paths| "- #{owner_ask(key, named: inline(paths))}" }
73
- [Prompts.text("find-a-principle-to-map/choose-one-principle"),
74
- *([Prompts.text("find-a-principle-to-map/ask-the-owner-before-mapping"), *asks].join("\n") if asks.any?)]
78
+ [Prompts.text("find-a-principle-to-map/choose-one-principle"), *left_out_of_the_survey(owner_asks),
79
+ *budget_notes(found),
80
+ Prompts.text("find-a-principle-to-map/ask-which-principle-to-map"),
81
+ *([Prompts.text("find-a-principle-to-map/ask-the-owner-after-the-table"), *asks].join("\n") if asks.any?)]
75
82
  .join("\n\n")
76
83
  end
77
84
 
85
+ # How to read what the budget cut: a cut section back by its lines, and a file whose outline was left out.
86
+ #: (Found) -> Array[String]
87
+ def budget_notes(found)
88
+ [*(Prompts.text("find-a-principle-to-map/read-a-cut-section-back") if found.cut?),
89
+ *(Prompts.text("find-a-principle-to-map/read-left-out-files") if found.left_out?)]
90
+ end
91
+
92
+ # The line leaving files possibly test data out of the survey, when any is listed.
93
+ #: (Hash[String, Array[String]]) -> Array[String]
94
+ def left_out_of_the_survey(owner_asks)
95
+ return [] unless owner_asks.key?("possibly_test_data")
96
+
97
+ [Prompts.text("find-a-principle-to-map/leave-test-data-out-of-the-survey")]
98
+ end
99
+
78
100
  # The paths an ask names after its list's name, each quoted, since a path may hold a comma; none, nothing.
79
101
  #: (Array[String]) -> String
80
102
  def inline(paths) = paths.empty? ? "" : " (#{paths.map { |path| "`#{path}`" }.join(", ")})"
@@ -0,0 +1,44 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "prompts"
5
+
6
+ module Principles
7
+ # What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
8
+ module Views
9
+ # What a checked member's exit_status placeholder says of its check beside what to do, in a full audit's template
10
+ # and a one-member audit's alike: any hidden character the command holds (#260), and the line the last audit's
11
+ # review rested on, which a run keeps unless a new one is given (#849).
12
+ class CheckNotes
13
+ # since_last_audit is how the check stands to the last audit's, with the review line that audit kept, if any;
14
+ # hidden_characters names each hidden character in the command.
15
+ #: (Hash[String, untyped]?, Array[String]) -> void
16
+ def initialize(since_last_audit, hidden_characters)
17
+ @since_last_audit = since_last_audit
18
+ @hidden_characters = hidden_characters
19
+ freeze
20
+ end
21
+
22
+ # The note naming the command's hidden characters, where the decision to run it is made; nil when it has none.
23
+ #: () -> String?
24
+ def hidden_characters
25
+ return if @hidden_characters.empty?
26
+
27
+ Prompts.text("assess-every-member/have-hidden-characters-in-a-check-explained",
28
+ characters: @hidden_characters.join("; "))
29
+ end
30
+
31
+ # That a run keeps the line the last audit's review rested on, quoted with since when, unless a new one is
32
+ # given, so whether it still holds can be judged from the template (#849); a record from before D63 kept none,
33
+ # so there is nothing to say (#826).
34
+ #: () -> Array[String]
35
+ def kept_review
36
+ return [] unless @since_last_audit&.key?("review_basis")
37
+
38
+ [Prompts.text("assess-every-member/keep-the-last-review-basis-unless-you-give-a-new-one",
39
+ since: @since_last_audit.fetch("review_basis_since"),
40
+ basis: @since_last_audit.fetch("review_basis"))]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require_relative "check_notes"
4
5
  require_relative "prompts"
5
6
 
6
7
  module Principles
@@ -12,6 +13,16 @@ module Principles
12
13
  # since, is reviewed before it runs (#227), so it also gives review_basis to fill (D63), and any hidden character
13
14
  # it holds is named where that decision is made (#260).
14
15
  class CheckResultTemplate
16
+ # The template for the checked member a request lists as entry, with its check, how that stands to the last
17
+ # audit's and any hidden characters in it; nil for a member without a check.
18
+ #: (Hash[String, untyped], reviewed_placeholders: Hash[String, String],
19
+ #| unchanged_placeholders: Hash[String, String]) -> Hash[String, untyped]?
20
+ def self.for(entry, reviewed_placeholders:, unchanged_placeholders:)
21
+ check = entry["check"] or return
22
+ new(check, entry["check_since_last_audit"], entry.fetch("check_hidden_characters", []),
23
+ reviewed_placeholders:, unchanged_placeholders:).to_h
24
+ end
25
+
15
26
  # reviewed_placeholders gives the text of not_run_reason and review_basis, which an answer leaves as printed to
16
27
  # give neither, for a check reviewed before it runs; unchanged_placeholders gives it for one the last audit ran,
17
28
  # whose review_basis left as printed keeps the line that audit kept (#1010).
@@ -20,7 +31,7 @@ module Principles
20
31
  def initialize(check, since_last_audit, hidden_characters = [], reviewed_placeholders:, unchanged_placeholders:)
21
32
  @check = check
22
33
  @since_last_audit = since_last_audit
23
- @hidden_characters = hidden_characters
34
+ @notes = CheckNotes.new(since_last_audit, hidden_characters) #: CheckNotes
24
35
  unchanged = since_last_audit&.fetch("status") == "unchanged"
25
36
  @placeholders = unchanged ? unchanged_placeholders : reviewed_placeholders #: Hash[String, String]
26
37
  freeze
@@ -28,21 +39,13 @@ module Principles
28
39
 
29
40
  #: () -> Hash[String, untyped]
30
41
  def to_h
31
- { "command" => @check, "exit_status" => [hidden_characters, run_and_report].compact.join(" "),
42
+ { "command" => @check, "exit_status" => [@notes.hidden_characters, run_and_report].compact.join(" "),
32
43
  "not_run_reason" => @placeholders.fetch("not_run_reason"),
33
44
  "review_basis" => @placeholders.fetch("review_basis") }
34
45
  end
35
46
 
36
47
  private
37
48
 
38
- #: () -> String?
39
- def hidden_characters
40
- return if @hidden_characters.empty?
41
-
42
- Prompts.text("assess-every-member/have-hidden-characters-in-a-check-explained",
43
- characters: @hidden_characters.join("; "))
44
- end
45
-
46
49
  # What to do before replacing exit_status, then that a named check runs at every full audit, which holds for
47
50
  # each status.
48
51
  #: () -> String
@@ -56,7 +59,7 @@ module Principles
56
59
  #: () -> Array[String]
57
60
  def steps
58
61
  case @since_last_audit&.fetch("status")
59
- when "unchanged" then [Prompts.text("assess-every-member/run-the-check-then-report-it"), *kept_review]
62
+ when "unchanged" then [Prompts.text("assess-every-member/run-the-check-then-report-it"), *@notes.kept_review]
60
63
  when "changed"
61
64
  [Prompts.text("assess-every-member/have-a-changed-check-reviewed-before-running-it",
62
65
  changed_in: commit_clause(": commit %s changed it")), run_reviewed]
@@ -74,18 +77,6 @@ module Principles
74
77
  commit ? format(format, commit) : ""
75
78
  end
76
79
 
77
- # That a run keeps the line the last audit's review rested on, quoted with since when, unless a new one is
78
- # given, so whether it still holds can be judged from the template (#849); a record from before D63 kept none,
79
- # so there is nothing to say (#826).
80
- #: () -> Array[String]
81
- def kept_review
82
- return [] unless @since_last_audit&.key?("review_basis")
83
-
84
- [Prompts.text("assess-every-member/keep-the-last-review-basis-unless-you-give-a-new-one",
85
- since: @since_last_audit.fetch("review_basis_since"),
86
- basis: @since_last_audit.fetch("review_basis"))]
87
- end
88
-
89
80
  # Run a reviewed check, then report it with what its review rested on.
90
81
  #: () -> String
91
82
  def run_reviewed