principles 0.0.10 → 0.0.11

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -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/assessment.rb +1 -1
  7. data/lib/principles/controllers/audit.rb +2 -1
  8. data/lib/principles/controllers/broken_member_repairs.rb +60 -0
  9. data/lib/principles/controllers/command.rb +8 -30
  10. data/lib/principles/controllers/correction.rb +7 -5
  11. data/lib/principles/controllers/full_audit_request.rb +32 -16
  12. data/lib/principles/controllers/inventory.rb +3 -3
  13. data/lib/principles/controllers/member_acknowledgement.rb +5 -5
  14. data/lib/principles/controllers/member_addition.rb +1 -1
  15. data/lib/principles/controllers/member_entries.rb +1 -1
  16. data/lib/principles/controllers/member_problems_report.rb +4 -1
  17. data/lib/principles/controllers/members_to_assess.rb +1 -1
  18. data/lib/principles/controllers/meta_principle_setup.rb +4 -3
  19. data/lib/principles/controllers/open_correction.rb +3 -3
  20. data/lib/principles/data/command-steps.json +4 -4
  21. data/lib/principles/data/repository.rb +4 -4
  22. data/lib/principles/data/running_version.rb +1 -1
  23. data/lib/principles/data/schemas/command-steps.schema.json +1 -1
  24. data/lib/principles/invocation_options.rb +4 -4
  25. data/lib/principles/models/acknowledgement.rb +1 -27
  26. data/lib/principles/models/acknowledgement_left_as_printed.rb +2 -1
  27. data/lib/principles/models/acknowledgement_placeholders.rb +48 -0
  28. data/lib/principles/models/assessment_answer.rb +2 -2
  29. data/lib/principles/models/assessment_left_as_printed.rb +1 -1
  30. data/lib/principles/models/audit.rb +1 -1
  31. data/lib/principles/models/audit_records.rb +1 -1
  32. data/lib/principles/models/candidate_inventory.rb +1 -1
  33. data/lib/principles/models/disposition.rb +12 -76
  34. data/lib/principles/models/disposition_placeholders.rb +48 -0
  35. data/lib/principles/models/disposition_text_field.rb +41 -0
  36. data/lib/principles/models/evidence_item.rb +1 -1
  37. data/lib/principles/models/fix_only_fields.rb +4 -3
  38. data/lib/principles/models/located_text.rb +19 -11
  39. data/lib/principles/models/member_assessments.rb +11 -4
  40. data/lib/principles/models/member_file.rb +9 -12
  41. data/lib/principles/models/member_mapping_run.rb +1 -1
  42. data/lib/principles/models/member_repair_moves.rb +20 -4
  43. data/lib/principles/models/member_snapshots.rb +10 -10
  44. data/lib/principles/models/members_sharing_lines.rb +1 -1
  45. data/lib/principles/models/misspelt_member_id.rb +9 -3
  46. data/lib/principles/models/named_placeholder.rb +32 -0
  47. data/lib/principles/models/other_templates_placeholders.rb +25 -6
  48. data/lib/principles/models/principle_history.rb +4 -3
  49. data/lib/principles/models/project.rb +7 -13
  50. data/lib/principles/models/project_at_commit.rb +70 -0
  51. data/lib/principles/models/project_history.rb +10 -52
  52. data/lib/principles/models/sent_answer.rb +4 -3
  53. data/lib/principles/models/template_placeholders.rb +22 -7
  54. data/lib/principles/models/text_size.rb +11 -3
  55. data/lib/principles/models/unfinished_field.rb +34 -0
  56. data/lib/principles/start_audit_options.rb +10 -2
  57. data/lib/principles/version.rb +2 -2
  58. data/lib/principles/views/acknowledged_result.rb +59 -0
  59. data/lib/principles/views/acknowledgement_result.rb +32 -42
  60. data/lib/principles/views/answer_in_a_file.rb +53 -0
  61. data/lib/principles/views/assessed_members.rb +4 -2
  62. data/lib/principles/views/audit_result.rb +3 -1
  63. data/lib/principles/views/context_parts.rb +1 -1
  64. data/lib/principles/views/correction_request.rb +19 -13
  65. data/lib/principles/views/member_repairs.rb +21 -5
  66. data/lib/principles/views/meta_principle_result.rb +26 -5
  67. data/lib/principles/views/parts_index_result.rb +8 -6
  68. data/lib/principles/views/principle_read_result.rb +2 -2
  69. data/lib/principles/views/problem_lines.rb +8 -3
  70. data/lib/principles/views/problem_result.rb +11 -0
  71. data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +6 -0
  72. data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
  73. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-check.md +4 -3
  74. data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +4 -3
  75. data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +7 -8
  76. data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +4 -3
  77. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member-check.md +4 -3
  78. data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +4 -3
  79. data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +13 -12
  80. data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +5 -5
  81. data/lib/principles/views/prompts/start-a-session/act-on-the-changed-principles.md +2 -0
  82. data/lib/principles/views/prompts.rb +7 -4
  83. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc95d7d905593eee8514b36fd6cbc6a80629a6f210542a232dada441890cf454
4
- data.tar.gz: 964984c9b9d5a44d53c65ce0b92924d960eca08db17a93897abbe17db71b7482
3
+ metadata.gz: ac03ff91b01f56693d63602bc0d007a3243f1a8ed1c9697127fca9b264b7234c
4
+ data.tar.gz: 86a1ba738d48e8bb8998e20f414301b20f4e2331f22c1ffcd12503a7d7503531
5
5
  SHA512:
6
- metadata.gz: 4534da22b02e7aa9a8e961268a1710f430c27bca7a8613b4d4fd1a8c337705f1a41967dbc3abb976535ae58891f66211ebea1b18e27fab015c88b6f5d35cb1df
7
- data.tar.gz: 7b17bd8475e8158b80a9c4af83ff94de2022bd2525901096ea7ae16163c2f811fb1441c1591ea33415fce5f7ef8a8e763900f61a63443158b3bc21ddfb69d4d2
6
+ metadata.gz: 776d152b59dee834bda7b649501848673629fb884d5801a98b3a4a9ae2f721532fb4ba74f7b43b8ff7764d3bf94a589d1ff08bbf36531faf9d95e955d27da1bb
7
+ data.tar.gz: cb0962c763b4094d145fb5a31e59577e827b2031e32479f95bc292e45586b2dcf63a7e03b0bd7a5b196378f2c894aab745584bca7cee7399b33fea8d2314c62a
data/CHANGELOG.md CHANGED
@@ -13,6 +13,17 @@ The agent's mechanics are the means, never the lead: do not open with "An agent
13
13
 
14
14
  ## Unreleased
15
15
 
16
+ ## [0.0.11] - 2026-11-22
17
+
18
+ ### Changed
19
+
20
+ - **An audit reads the parts of a request it needs in one call, with no script to stitch them together.** `principles start-audit ID --part A --part B` prints each part named, in the order given, under the request's one `request_id`, instead of one call per part, and beside `--as template` each member's slot named in one `member_assessments`. `--part response_template`, the bare answer to save as it stands, is refused beside another part.
21
+ - **Checking a principle's changed members reads only what decides the next step, with no script to pull the fields out.** `principles list-member-problems [ID]` now gives each changed member's id, state, baseline and the command that clears it without the list of commits that changed it, one entry per commit; `--history` adds that list back when your agent needs it.
22
+ - **A session start costs the same whether one principle's audited rules changed or several did.** When more than one principle has changed audited members, `principles report-at-session-start` prints one line counting them, with `principles list-member-problems --short` to list them, instead of a line per principle: 208 bytes for any number of principles, where four printed 747. A single principle's line is as before.
23
+ - **A member named by its heading or passage alone is one command away from the right id, not a trip through `show-principle`.** When `change-member-role`, `change-member-check`, `remove-member-check`, `move-member` or `remove-member` is given text that exactly one mapped member's id ends with, after its `#` or `@`, the refusal names that id and starts its repair with the same command run on it. Nothing runs on the guess itself.
24
+ - **Your agent fills a full audit's answer with its own file editor, with no script to unwrap or escape it.** `principles start-audit ID --part response_template` now prints the answer bare, ready to save and submit as it stands, and the request and its `--part index` say to save it to a file outside the project, fill it there with the agent's file-edit tool rather than a shell heredoc, and submit that file, naming the only three characters JSON escapes. The line adds about 420 bytes to each full-audit request. A correction's next step says the same of its dispositions, saved from `show-open-correction`, and an acknowledgement request, for one member, several or members across principles, now has a next step too, saving the answer `--as template` prints, and its refusals send the agent back to that saved answer rather than to the request.
25
+ - **Each member's slot in a full audit's answer is its own, so a file editor's one-match replace fills one slot at a time.** Every judged member's assessment placeholder now names its member, and an answer that leaves any member's placeholder in a slot, its own or one pasted from another, is refused as left as printed. A correction's dispositions do the same, each one's action, reason and reassessment placeholders naming its finding, and so does each member's entry in an acknowledgement's answer.
26
+
16
27
  ## [0.0.10] - 2026-11-21
17
28
 
18
29
  ### Changed
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
- ![Six pocket compasses on white paper, every needle pointing the same way but one small red needle that has swung off course](https://raw.githubusercontent.com/realfastAI/principles/main/images/banner.webp)
2
-
3
1
  # Harness Principles
4
2
 
5
3
  <p>Built with ❤️ at&nbsp;<a href="https://realfast.ai"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/realfastAI/principles/main/images/realfast-logo-white.svg"><img src="https://raw.githubusercontent.com/realfastAI/principles/main/images/realfast-logo-ink.svg" alt="realfast" height="15"></picture></a></p>
@@ -6,7 +6,9 @@ require_relative "answer_phase"
6
6
  require_relative "../prose_list"
7
7
  require_relative "member_acknowledgement"
8
8
  require_relative "../models/acknowledgement"
9
+ require_relative "../models/acknowledgement_placeholders"
9
10
  require_relative "../models/reported_check"
11
+ require_relative "../views/acknowledged_result"
10
12
  require_relative "../views/acknowledgement_result"
11
13
 
12
14
  module Principles
@@ -41,7 +43,7 @@ module Principles
41
43
  def answered(submitted)
42
44
  id = submitted.request_id.principle_id
43
45
  member = answering(submitted)
44
- [view.acknowledged(principle_id: id, member_id: member.member.id, file: @audit_records.file(id)),
46
+ [accepted_view.acknowledged(principle_id: id, member_id: member.member.id, file: @audit_records.file(id)),
45
47
  [accepted(member, submitted.response)]]
46
48
  end
47
49
 
@@ -63,7 +65,7 @@ module Principles
63
65
 
64
66
  # The fields an answer may leave as its template printed them, read before its shape.
65
67
  #: () -> Models::AcknowledgementLeftAsPrinted
66
- def left_as_printed = Models::Acknowledgement::LEFT_AS_PRINTED
68
+ def left_as_printed = Models::AcknowledgementPlaceholders::LEFT_AS_PRINTED
67
69
 
68
70
  # The placeholders a one-member audit's template prints, which its answer may leave as printed: its own, and
69
71
  # check_result's for a check the last audit ran, the only check it acknowledges. The member is in the
@@ -71,8 +73,9 @@ module Principles
71
73
  # @override
72
74
  #: (Models::RequestId) -> Hash[String, untyped]?
73
75
  def printed_placeholders(_request_id)
74
- MemberAcknowledgement.placeholders(Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h
75
- .merge("exit_status" => Models::Acknowledgement::EXIT_STATUS_PLACEHOLDER))
76
+ exit_status = Models::AcknowledgementPlaceholders::EXIT_STATUS_PLACEHOLDER
77
+ unchanged = Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h
78
+ MemberAcknowledgement.placeholders(unchanged.merge("exit_status" => exit_status))
76
79
  end
77
80
 
78
81
  # The one-member audit of principle id's member, as a refusal naming a near miss leads its repair with.
@@ -109,6 +112,10 @@ module Principles
109
112
  def view
110
113
  Views::AcknowledgementResult.new(invocation)
111
114
  end
115
+
116
+ # The view of an accepted answer.
117
+ #: () -> Views::AcknowledgedResult
118
+ def accepted_view = Views::AcknowledgedResult.new(invocation)
112
119
  end
113
120
  end
114
121
  end
@@ -51,8 +51,8 @@ module Principles
51
51
 
52
52
  id = submitted.request_id.principle_id
53
53
  several, members = answering_several(submitted)
54
- [view.several_acknowledged(principle_id: id, member_ids: members.map { it.member.id },
55
- file: @audit_records.file(id)),
54
+ [accepted_view.several_acknowledged(principle_id: id, member_ids: members.map { it.member.id },
55
+ file: @audit_records.file(id)),
56
56
  [all_accepted(several, members, submitted.response)]]
57
57
  end
58
58
 
@@ -72,8 +72,8 @@ module Principles
72
72
  records = across.accepted(submitted.response) do |id, several, answer|
73
73
  all_accepted(several, by_principle.fetch(id), answer, acknowledging: across.acknowledging)
74
74
  end
75
- [view.across_acknowledged(member_ids: across.member_ids,
76
- files: by_principle.keys.to_h { [it, @audit_records.file(it)] }), records]
75
+ files = by_principle.keys.to_h { [it, @audit_records.file(it)] }
76
+ [accepted_view.across_acknowledged(member_ids: across.member_ids, files:), records]
77
77
  end
78
78
 
79
79
  # The members each principle basis names maps, refused when a later copy wrote any of their records, or as stale
@@ -140,7 +140,7 @@ module Principles
140
140
  def request_to_correct(basis, audit, findings)
141
141
  head = Views::AnswerHead.new(request_id: basis.request_id(audit.id, audit.now).to_s, basis: basis.to_h)
142
142
  Views::CorrectionRequest.new(head: head, principle_id: audit.id, findings: findings,
143
- placeholders: Models::Disposition::TEMPLATE_PLACEHOLDERS)
143
+ placeholders: Models::DispositionPlaceholders::TEMPLATE_PLACEHOLDERS)
144
144
  end
145
145
 
146
146
  # The open record that keeps the assessment, and outside git what the audit began from, and the last completed
@@ -74,7 +74,8 @@ module Principles
74
74
  # The part of the request --part names, or beside --as template the member's slot of the answer it names.
75
75
  #: (FullAuditRequest, Hash[String, untyped]) -> Hash[String, untyped]
76
76
  def full_part(full, options)
77
- options["as"] ? full.slot_to_fill(options.fetch("part")) : full.part(options.fetch("part"))
77
+ parts = options.fetch("part")
78
+ options["as"] ? full.slot_to_fill(parts) : full.part(parts)
78
79
  end
79
80
 
80
81
  # id's committed record. With none, an id no map has is refused as show-principle refuses it, since
@@ -0,0 +1,60 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../error"
5
+ require_relative "../models/mapped_principles"
6
+ require_relative "../models/member_repair_moves"
7
+ require_relative "../views/invocation"
8
+ require_relative "../views/member_repairs"
9
+
10
+ module Principles
11
+ # Each runs one command: reads models, applies their rules and prints through a view.
12
+ # controllers/CLAUDE.md owns the boundary.
13
+ module Controllers
14
+ # The repairs this tool prints for members it cannot find, in the project's maps: the moves
15
+ # Models::MemberRepairMoves gives for each, printed by Views::MemberRepairs, beside a broken_members refusal or a
16
+ # member show-principle shows.
17
+ class BrokenMemberRepairs
18
+ #: (Models::MappedPrinciples, Views::Invocation) -> void
19
+ def initialize(principles, invocation)
20
+ @principles = principles
21
+ @repairs = Views::MemberRepairs.new(invocation) #: Views::MemberRepairs
22
+ freeze
23
+ end
24
+
25
+ # A broken_members refusal, with each member's own repair commands beside it as repair_with, since a
26
+ # model's repair can only name placeholders. Any other refusal is returned as it is.
27
+ #: (Error) -> Error
28
+ def beside(error)
29
+ return error unless error.payload["code"] == "broken_members"
30
+
31
+ members = error.payload.fetch("members").map do |entry|
32
+ repaired({ "principle" => error.payload["principle"] }.compact.merge(entry))
33
+ end
34
+ error.including("members" => members)
35
+ end
36
+
37
+ # The moves that may repair member, which a refusal with code says this tool cannot find; tracked_as is the
38
+ # spelling git tracks its path under, when the refusal names one.
39
+ #: (Hash[String, untyped], code: String?, tracked_as: String?) -> Array[Views::MemberRepairs::Move]
40
+ def moves(member, code:, tracked_as:)
41
+ Models::MemberRepairMoves.new(member, code:, tracked_as:).to_a
42
+ .map { Views::MemberRepairs::Move.new(keep: it.keep, fill: it.fill) }
43
+ end
44
+
45
+ private
46
+
47
+ # entry with repair_with, when it names a member its map still lists.
48
+ #: (Hash[String, untyped]) -> Hash[String, untyped]
49
+ def repaired(entry)
50
+ principle = entry["principle"] or return entry
51
+ id = entry["id"] or return entry
52
+ member = @principles.find(principle).member(id)
53
+ moves = moves(member, code: entry["code"], tracked_as: entry["tracked_as"])
54
+ entry.merge("repair_with" => @repairs.commands(principle, id, moves))
55
+ rescue Error
56
+ entry
57
+ end
58
+ end
59
+ end
60
+ end
@@ -8,7 +8,6 @@ require_relative "../models/audit"
8
8
  require_relative "../models/carried_assessments"
9
9
  require_relative "../models/member"
10
10
  require_relative "../models/member_grounds"
11
- require_relative "../models/member_repair_moves"
12
11
  require_relative "../models/principle_history"
13
12
  require_relative "../models/members_sharing_lines"
14
13
  require_relative "../models/project"
@@ -17,8 +16,8 @@ require_relative "../models/record_judged_against"
17
16
  require_relative "../views/audit_result"
18
17
  require_relative "../views/lines_shared_with_member"
19
18
  require_relative "../views/map_result"
20
- require_relative "../views/member_repairs"
21
19
  require_relative "../views/record_waiting_on_an_upgrade"
20
+ require_relative "broken_member_repairs"
22
21
  require_relative "running_tool"
23
22
 
24
23
  module Principles
@@ -76,33 +75,12 @@ module Principles
76
75
  refusal = (rerun ? e.rerun_with_near_miss(&rerun) : e).printing_commands do |command|
77
76
  invocation.listed_in_project(command.command, command.values, options: command.options, usage: command.usage)
78
77
  end
79
- raise with_member_repairs(refusal).naming(invocation.prefix)
78
+ raise broken_member_repairs.beside(refusal).naming(invocation.prefix)
80
79
  end
81
80
 
82
- # A broken_members refusal, with each member's own repair commands beside it as repair_with, since a
83
- # model's repair can only name placeholders. Any other refusal is returned as it is.
84
- #: (Error) -> Error
85
- def with_member_repairs(error)
86
- return error unless error.payload["code"] == "broken_members"
87
-
88
- repairs = Views::MemberRepairs.new(invocation)
89
- members = error.payload.fetch("members").map do |entry|
90
- repaired({ "principle" => error.payload["principle"] }.compact.merge(entry), repairs)
91
- end
92
- error.including("members" => members)
93
- end
94
-
95
- # entry with repair_with, when it names a member its map still lists.
96
- #: (Hash[String, untyped], Views::MemberRepairs) -> Hash[String, untyped]
97
- def repaired(entry, repairs)
98
- principle = entry["principle"] or return entry
99
- id = entry["id"] or return entry
100
- member = @principles.find(principle).member(id)
101
- moves = Models::MemberRepairMoves.new(member, code: entry["code"], tracked_as: entry["tracked_as"]).to_a
102
- entry.merge("repair_with" => repairs.commands(principle, id, moves))
103
- rescue Error
104
- entry
105
- end
81
+ # The repairs this tool prints for members it cannot find, in this project's maps.
82
+ #: () -> BrokenMemberRepairs
83
+ def broken_member_repairs = BrokenMemberRepairs.new(@principles, invocation)
106
84
 
107
85
  #: (String) -> bot
108
86
  def unknown(command)
@@ -166,7 +144,7 @@ module Principles
166
144
 
167
145
  # Each member's hash at base, or nil outside git.
168
146
  #: (String?, Models::Principle) -> Hash[String, String]?
169
- def committed(base, map) = base ? @history.hashes_at(base, map.members) : nil
147
+ def committed(base, map) = base ? @history.at(base).hashes(map.members) : nil
170
148
 
171
149
  # When each of the map's members loads, by id, which a full audit's request lists against the activation and
172
150
  # show-principle prints, from the project's hooks as hooks read them.
@@ -201,9 +179,9 @@ module Principles
201
179
  end
202
180
 
203
181
  # Where a member is in its file now, and the hash of what it says there.
204
- #: (Models::Locator) -> Hash[String, untyped]
182
+ #: (Models::Locator) -> Models::LocatedText
205
183
  def snapshot(locator)
206
- @project.locate(locator)
184
+ @project.located_text(locator)
207
185
  end
208
186
 
209
187
  # The members sharing a line with member where it is now, in map and in the other maps, as add-member and
@@ -7,7 +7,7 @@ require_relative "../models/correction_answer"
7
7
  require_relative "../models/declared_map_changes"
8
8
  require_relative "../models/finding_write_ups"
9
9
  require_relative "../models/request_id"
10
- require_relative "../views/prompts"
10
+ require_relative "../views/correction_request"
11
11
  require_relative "audit_completion"
12
12
 
13
13
  module Principles
@@ -57,7 +57,7 @@ module Principles
57
57
 
58
58
  # The placeholders a correction's template printed, its dispositions'.
59
59
  #: (Models::RequestId) -> Hash[String, untyped]?
60
- def printed_placeholders(_request_id) = Models::Disposition::TEMPLATE_PLACEHOLDERS
60
+ def printed_placeholders(_request_id) = Models::DispositionPlaceholders::TEMPLATE_PLACEHOLDERS
61
61
 
62
62
  # The result of judging a correction answer: its basis, moves and dispositions checked, and the audit completed.
63
63
  #: (Models::RequestId, untyped, Models::Audit) -> [untyped, Array[Models::AuditRecord]]
@@ -77,12 +77,14 @@ module Principles
77
77
  def resumed(audit, basis, before, moves) = audit.resumed(basis, before, moves, @audit_records.find(audit.id))
78
78
 
79
79
  # The packaged answer guide, which the correction request prints, is the one owner of its samples, the text
80
- # the agent saw, so its sample for each action is handed to the model, which refuses a field given back as
81
- # its sample. Should the tool be upgraded between request and answer, that answer is checked only
80
+ # the agent saw, but for the deferred sample's reason, which is the template's reason placeholder that
81
+ # Models::Disposition owns. Its sample for each action is handed to the model, which refuses a field given back
82
+ # as its sample. Should the tool be upgraded between request and answer, that answer is checked only
82
83
  # against the new guide's samples.
83
84
  #: (untyped, Array[untyped], Models::AuditStart, Models::Audit) -> Array[Models::Disposition]
84
85
  def dispositions(response, findings, start, audit)
85
- samples = Views::Prompts.data("dispose-of-each-finding/answer-guide").fetch("disposition")
86
+ samples = Views::CorrectionRequest.answer_guide(Models::DispositionPlaceholders::PLACEHOLDERS.fetch("reason"))
87
+ .fetch("disposition")
86
88
  Models::CorrectionAnswer.new(response, findings, samples:) { |locator| snapshot(locator) }
87
89
  .dispositions(changed: start.changed(now: audit.now))
88
90
  end
@@ -55,31 +55,47 @@ module Principles
55
55
  { "request_id" => request.request_id, named => request.whole_instruction(named), "wrote" => [] }
56
56
  end
57
57
 
58
- # The part of this request --part names, printed alone under the request's id, so the agent need not read the
59
- # whole request for it, the index with how to answer it, and one it leaves out for listing nothing as empty;
60
- # refused when the request has no part by that name.
61
- #: (String) -> Hash[String, untyped]
62
- def part(name)
58
+ # The parts of this request each --part names, in the order given, printed together under the request's one
59
+ # id, so the agent need not read the whole request for them, the index with how to answer it, and one it leaves
60
+ # out for listing nothing as empty; the answer to fill bare, given alone, to save as it stands; refused when the
61
+ # request has no part by one of the names.
62
+ #: (Array[String]) -> Hash[String, untyped]
63
+ def part(names)
63
64
  request = asked
64
65
  parts = request.context_parts(texts: member_texts, optional: PartsToRead::OPTIONAL)
65
- named = Models::PartNamed.new(name, principle_id: @id, printed: parts.printable, empty: parts.left_out).part
66
- shown = { "request_id" => request.request_id, **parts.shown(named) }
67
- shown = Views::PartsIndexResult.new(invocation).printed(shown, request) if named == Views::ContextParts::INDEX
68
- shown.merge("wrote" => [])
66
+ named = names.map { named_in(parts, it) }
67
+ return parts.shown(Views::ContextParts::TEMPLATE) if named == [Views::ContextParts::TEMPLATE]
68
+
69
+ shown = named.reduce({ "request_id" => request.request_id }) { |all, name| all.merge(parts.shown(name)) }
70
+ answering(request, shown, named).merge("wrote" => [])
69
71
  end
70
72
 
71
- # The slot of the answer to fill that --part names beside --as template, a member's as members/ID, printed alone
72
- # under the request's id; refused when the template has no slot by that name.
73
- #: (String) -> Hash[String, untyped]
74
- def slot_to_fill(name)
73
+ # The slots of the answer to fill that each --part names beside --as template, a member's as members/ID, in the
74
+ # order given, printed together under the request's id; refused when the template has no slot by one name.
75
+ #: (Array[String]) -> Hash[String, untyped]
76
+ def slot_to_fill(names)
75
77
  request = asked
76
78
  slots = request.slots_to_fill
77
- named = Models::PartNamed.new(name, principle_id: @id, printed: slots.keys, template: true).part
78
- { "request_id" => request.request_id, "member_assessments" => [slots.fetch(named)], "wrote" => [] }
79
+ named = names.map { Models::PartNamed.new(it, principle_id: @id, printed: slots.keys, template: true).part }
80
+ { "request_id" => request.request_id, "member_assessments" => named.map { slots.fetch(it) }, "wrote" => [] }
79
81
  end
80
82
 
81
83
  private
82
84
 
85
+ # The part name names in parts, refused when the request neither prints it nor leaves it out as empty.
86
+ #: (Views::ContextParts, String) -> String
87
+ def named_in(parts, name)
88
+ Models::PartNamed.new(name, principle_id: @id, printed: parts.printable, empty: parts.left_out).part
89
+ end
90
+
91
+ # shown, the parts named printed from request, with how to answer the request when the index is among them.
92
+ #: (Views::AssessmentRequest, Hash[String, untyped], Array[String]) -> Hash[String, untyped]
93
+ def answering(request, shown, named)
94
+ return shown unless named.include?(Views::ContextParts::INDEX)
95
+
96
+ Views::PartsIndexResult.new(invocation).printed(shown, request)
97
+ end
98
+
83
99
  # The request and what it asks, listing the findings the last completed audit left to decide, under an id that
84
100
  # digests them and the revision of that audit's record, but not the findings other principles leave
85
101
  # open on members sharing these lines.
@@ -116,7 +132,7 @@ module Principles
116
132
  Views::AssessedMembers.new(@listing.members,
117
133
  reviewed_check_placeholders: Models::ReportedCheck::PLACEHOLDERS.to_h,
118
134
  unchanged_check_placeholders: Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h,
119
- assessment_placeholder: Models::MemberAssessments::PLACEHOLDER)
135
+ assessment_placeholder: Models::MemberAssessments::NAMED_PLACEHOLDER)
120
136
  end
121
137
 
122
138
  # Each member's lines now, by id, without their line endings, so its part carries the text it is judged on.
@@ -65,14 +65,14 @@ module Principles
65
65
 
66
66
  # The moves that may repair each shown member whose reference is broken, so an audit would refuse it, by id in the
67
67
  # map's order.
68
- #: (Models::Principle, Array[Hash[String, untyped]]) -> Hash[String, Array[Hash[String, untyped]]]
68
+ #: (Models::Principle, Array[Hash[String, untyped]]) -> Hash[String, Array[Views::MemberRepairs::Move]]
69
69
  def repairs(principle, members)
70
+ broken = broken_member_repairs
70
71
  members.select { |member| Models::MemberState.new(member.fetch("id"), member.fetch("freshness")).broken? }
71
72
  .to_h do |member|
72
73
  id = member.fetch("id")
73
74
  error = member.fetch("error", {})
74
- [id, Models::MemberRepairMoves.new(principle.member(id), code: error["code"],
75
- tracked_as: error["tracked_as"]).to_a]
75
+ [id, broken.moves(principle.member(id), code: error["code"], tracked_as: error["tracked_as"])]
76
76
  end
77
77
  end
78
78
 
@@ -3,6 +3,7 @@
3
3
 
4
4
  require_relative "command"
5
5
  require_relative "../models/acknowledgement"
6
+ require_relative "../models/acknowledgement_placeholders"
6
7
  require_relative "../models/check_since_last_audit"
7
8
  require_relative "../models/list_member_problems_check"
8
9
  require_relative "../models/listed_members"
@@ -26,7 +27,7 @@ module Principles
26
27
  #: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?) -> Hash[String, untyped]
27
28
  def self.placeholders(check_result, change = nil)
28
29
  quotes = change&.first_changed_lines.to_h
29
- { **Models::Acknowledgement.placeholders_beside(quotes),
30
+ { **Models::AcknowledgementPlaceholders.beside(quotes),
30
31
  **(check_result ? { "check_result" => check_result } : {}) }
31
32
  end
32
33
 
@@ -45,7 +46,7 @@ module Principles
45
46
  @base = @history.base_commit(principle_id, [@principles.file(principle_id), @member.path]) #: String?
46
47
  @acknowledgement = Models::Acknowledgement.new(
47
48
  principle_id:, member: @member, record: @audit_records.find(principle_id), base: @base,
48
- now_sha256: @project.locate(@member.locator).fetch("sha256")
49
+ now_sha256: @project.located_text(@member.locator).sha256
49
50
  ) #: Models::Acknowledgement
50
51
  end
51
52
 
@@ -100,9 +101,8 @@ module Principles
100
101
  def check_template
101
102
  checks = Models::CheckSinceLastAudit.new(principle_history: principle_history(@id),
102
103
  record: @audit_records.find(@id))
103
- Views::OneMemberCheckResultTemplate.for(checks.entry(@member),
104
- exit_status: Models::Acknowledgement::EXIT_STATUS_PLACEHOLDER,
105
- own_listing: !own_listing.nil?)
104
+ exit_status = Models::AcknowledgementPlaceholders::EXIT_STATUS_PLACEHOLDER
105
+ Views::OneMemberCheckResultTemplate.for(checks.entry(@member), exit_status:, own_listing: !own_listing.nil?)
106
106
  end
107
107
 
108
108
  # The member's check read as this tool's own list-member-problems --short; nil for any other.
@@ -48,7 +48,7 @@ module Principles
48
48
  # The new member's id, current lines and stored check, located only after its map was saved.
49
49
  #: () -> Hash[String, untyped]
50
50
  def located_member
51
- { "id" => @member.id }.merge(snapshot(@member.locator).slice("first_line", "last_line"))
51
+ { "id" => @member.id }.merge(snapshot(@member.locator).lines)
52
52
  .merge(@member.to_h.slice("check"))
53
53
  end
54
54
 
@@ -68,7 +68,7 @@ module Principles
68
68
  #: (Hash[String, untyped]) -> Hash[String, untyped]
69
69
  def span(member)
70
70
  { "id" => Models::Member.new(member).id }
71
- .merge(snapshot(Models::Member.new(member).locator).slice("first_line", "last_line"))
71
+ .merge(snapshot(Models::Member.new(member).locator).lines)
72
72
  end
73
73
 
74
74
  # Points an existing member at a new place (a narrower passage, a renamed heading, an anchor that was
@@ -56,7 +56,10 @@ module Principles
56
56
  .printed(after: options.fetch("commits_after"), event: event)
57
57
  end
58
58
 
59
- return checked_report(id).merge("wrote" => []) unless options["short"]
59
+ unless options["short"]
60
+ return Views::ProblemResult.new(invocation).listed(checked_report(id), history: options.key?("history"))
61
+ .merge("wrote" => [])
62
+ end
60
63
 
61
64
  short(id, session_start: options["session_start"], named: options.key?("project"))
62
65
  end
@@ -124,7 +124,7 @@ module Principles
124
124
  # Whether the evidence at locator no longer hashes to sha, or can no longer be found.
125
125
  #: (Models::Locator, String) -> bool
126
126
  def evidence_changed?(locator, sha)
127
- snapshot(locator).fetch("sha256") != sha
127
+ snapshot(locator).sha256 != sha
128
128
  rescue Error
129
129
  true
130
130
  end
@@ -80,11 +80,12 @@ module Principles
80
80
 
81
81
  # The passage's text, as the agent pastes it, with its size, which loads in every session (F9), and what it
82
82
  # presumes of a teammate without principles.
83
- #: (Views::MetaPrincipleResult) -> Hash[String, untyped]
83
+ #: (Views::MetaPrincipleResult) -> Views::MetaPrincipleResult::Passage
84
84
  def passage(view)
85
85
  text = view.passage
86
- size = Models::TextSize.new(text).under(%w[bytes estimated_tokens])
87
- { "text" => text, **size, "presumes" => view.presumes(size.fetch("estimated_tokens")) }
86
+ size = Models::TextSize.new(text)
87
+ Views::MetaPrincipleResult::Passage.new(text: text, bytes: size.bytes, estimated_tokens: size.estimated_tokens,
88
+ presumes: view.presumes(size.estimated_tokens))
88
89
  end
89
90
  end
90
91
  end
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "command"
5
- require_relative "../models/disposition"
5
+ require_relative "../models/disposition_placeholders"
6
6
  require_relative "../models/open_correction"
7
7
  require_relative "../views/answer_head"
8
8
  require_relative "../views/correction_request"
@@ -34,8 +34,8 @@ module Principles
34
34
  kept = Models::OpenCorrection.kept(principle_id, @audit_records.find(principle_id),
35
35
  file: @audit_records.file(principle_id))
36
36
  head = Views::AnswerHead.new(request_id: kept.request_id, basis: kept.basis)
37
- Views::CorrectionRequest.new(head:, principle_id:, findings: kept.findings,
38
- placeholders: Models::Disposition::TEMPLATE_PLACEHOLDERS).correction_to_fill
37
+ placeholders = Models::DispositionPlaceholders::TEMPLATE_PLACEHOLDERS
38
+ Views::CorrectionRequest.new(head:, principle_id:, findings: kept.findings, placeholders:).correction_to_fill
39
39
  end
40
40
  end
41
41
  end
@@ -70,12 +70,12 @@
70
70
  ]
71
71
  },
72
72
  {
73
- "name": "list-member-problems", "usage": "list-member-problems [ID] [--short | --commits-after COMMIT --hook-event EVENT]", "group": "read", "options": ["short", "session-start", "commits-after", "hook-event"],
73
+ "name": "list-member-problems", "usage": "list-member-problems [ID] [--history | --short | --commits-after COMMIT --hook-event EVENT]", "group": "read", "options": ["history", "short", "session-start", "commits-after", "hook-event"],
74
74
  "summary": "Members whose reference is broken, or whose own text changed since their baseline.",
75
75
  "help": "learn-what-a-command-does/list-member-problems",
76
76
  "steps": [
77
77
  { "id": "compare-members-with-their-baselines", "actor": "cli",
78
- "does": "Finds each member of map ID, or of every map, and compares its own text with the last audit's hash for it, or else with its text at the commit that mapped it where it is. Refuses while any member cannot be found or read, or a map cannot be read, so a gate can stop on the exit status; otherwise lists each changed member with what it was compared with, and counts every state. With --short, prints one tab-separated line per changed member, then one per principle counting its members no audit has assessed, and exits 3 when it prints any line.",
78
+ "does": "Finds each member of map ID, or of every map, and compares its own text with the last audit's hash for it, or else with its text at the commit that mapped it where it is. Refuses while any member cannot be found or read, or a map cannot be read, so a gate can stop on the exit status; otherwise lists each changed member with what it was compared with, and with --history the commits that changed it, and counts every state. With --short, prints one tab-separated line per changed member, then one per principle counting its members no audit has assessed, and exits 3 when it prints any line.",
79
79
  "refuses": ["broken_members"], "refuses_like": ["read-map", "read-audit"] },
80
80
  { "id": "repair-or-audit", "actor": "agent",
81
81
  "does": "For a refusal, say whether each listed member moved or is gone, and repair it. For a changed member, audit its principle when the change was meant to alter the principle.",
@@ -132,7 +132,7 @@
132
132
  "help": "learn-what-a-command-does/report-at-session-start",
133
133
  "steps": [
134
134
  { "id": "report-at-session-start", "actor": "cli",
135
- "does": "Reads the SessionStart hook's JSON on stdin and always exits 0, since the host adds a SessionStart hook's output to the context only then. Prints nothing in a project with no maps. Otherwise prints, each line marked principles:, one line for each principle whose members an audit assessed changed since, with its count, that its audit no longer covers them, and the list-member-problems ID command to run before the user's task, which offers acknowledging them or auditing again, then, in git, what gives each principle's members with no baseline one, then each principle whose audit record a later release wrote, whose audits wait on an upgrade, then, while any principle awaits its first full audit, one line counting them that asks for one background subagent to follow show-first-audit-brief, or to offer the audit at the next pause if none can be started, and at resume and compact only the count, asking for no second subagent, then, while any audit finding is left open, the one line list-open-findings --short prints, worded for the session's start. When list-member-problems refuses, prints instead its code and the command that shows its repair; input it cannot read is read as a startup." }
135
+ "does": "Reads the SessionStart hook's JSON on stdin and always exits 0, since the host adds a SessionStart hook's output to the context only then. Prints nothing in a project with no maps. Otherwise prints, each line marked principles:, for one principle whose members an audit assessed changed since, a line with its count, that its audit no longer covers them, and the list-member-problems ID command to run before the user's task, which offers acknowledging them or auditing again, or for several, one line counting them with the list-member-problems --short command that lists them, then, in git, what gives each principle's members with no baseline one, then each principle whose audit record a later release wrote, whose audits wait on an upgrade, then, while any principle awaits its first full audit, one line counting them that asks for one background subagent to follow show-first-audit-brief, or to offer the audit at the next pause if none can be started, and at resume and compact only the count, asking for no second subagent, then, while any audit finding is left open, the one line list-open-findings --short prints, worded for the session's start. When list-member-problems refuses, prints instead its code and the command that shows its repair; input it cannot read is read as a startup." }
136
136
  ]
137
137
  },
138
138
  {
@@ -314,7 +314,7 @@
314
314
  ]
315
315
  },
316
316
  {
317
- "name": "start-audit", "usage": "start-audit ID [ID ...] [--member MEMBER ... | --write-ups] [--as template [--part members/ID] | --instruction FIELD | --part PART]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction", "part"],
317
+ "name": "start-audit", "usage": "start-audit ID [ID ...] [--member MEMBER ... | --write-ups] [--as template [--part members/ID ...] | --instruction FIELD | --part PART ...]", "group": "write-audit-record", "options": ["member", "write-ups", "as", "instruction", "part"],
318
318
  "summary": "Ask for an assessment of every member and the set.",
319
319
  "help": "learn-what-a-command-does/start-audit",
320
320
  "steps": [
@@ -112,17 +112,17 @@ module Principles
112
112
  # Which of paths, relative to the project, git does not track and does not ignore. Before the first
113
113
  # commit, every path not staged is one.
114
114
  #: (Array[String]) -> Array[String]
115
- def untracked(paths)
115
+ def untracked_excluding_ignored(paths)
116
116
  return [] if paths.empty?
117
117
 
118
118
  output, = git(["ls-files", "--others", "--exclude-standard", "-z", "--", *paths])
119
119
  output.split("\0").sort
120
120
  end
121
121
 
122
- # Which of paths, relative to the project, git does not track, ignored or not. Unlike untracked, it names an
123
- # ignored file too, since git holds it no more than an untracked one.
122
+ # Which of paths, relative to the project, git does not track, ignored or not. Unlike
123
+ # untracked_excluding_ignored, it names an ignored file too, since git holds it no more than an untracked one.
124
124
  #: (Array[String]) -> Array[String]
125
- def not_tracked(paths)
125
+ def untracked_including_ignored(paths)
126
126
  return [] if paths.empty?
127
127
 
128
128
  output, = git(["ls-files", "--others", "-z", "--", *paths])
@@ -12,7 +12,7 @@ module Principles
12
12
  class RunningVersion
13
13
  # git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
14
14
  # export-subst; a checkout keeps the placeholder as written.
15
- ARCHIVED_COMMIT = "a8698c23" #: String
15
+ ARCHIVED_COMMIT = "6eaca172" #: String
16
16
 
17
17
  #: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
18
18
  def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
@@ -72,7 +72,7 @@
72
72
  "usage": { "$ref": "#/$defs/prose" },
73
73
  "group": { "$ref": "#/$defs/slug" },
74
74
  "options": { "type": "array", "uniqueItems": true,
75
- "items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "confirm", "lines", "open-findings"] } },
75
+ "items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "confirm", "lines", "open-findings", "history"] } },
76
76
  "requires": { "type": "array", "uniqueItems": true, "items": { "enum": ["file"] } },
77
77
  "summary": { "$ref": "#/$defs/prose" },
78
78
  "help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },