principles 0.1.1 → 0.1.3

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/lib/principles/command_line.rb +6 -3
  4. data/lib/principles/controllers/command.rb +3 -2
  5. data/lib/principles/controllers/inventory.rb +9 -1
  6. data/lib/principles/controllers/member_acknowledgement.rb +21 -11
  7. data/lib/principles/controllers/running_tool.rb +6 -4
  8. data/lib/principles/data/command-steps.json +2 -2
  9. data/lib/principles/data/repository.rb +5 -0
  10. data/lib/principles/data/running_version.rb +1 -1
  11. data/lib/principles/data/schemas/assessment-answer.schema.json +3 -6
  12. data/lib/principles/data/schemas/audit-record.schema.json +2 -1
  13. data/lib/principles/data/schemas/correction-answer.schema.json +11 -6
  14. data/lib/principles/data/schemas/deciding-answer.schema.json +5 -1
  15. data/lib/principles/list_principles_options.rb +28 -0
  16. data/lib/principles/models/acknowledgement.rb +10 -0
  17. data/lib/principles/models/acknowledgement_placeholders.rb +43 -18
  18. data/lib/principles/models/answer_fields.rb +21 -2
  19. data/lib/principles/models/disposition.rb +6 -5
  20. data/lib/principles/models/disposition_placeholders.rb +15 -7
  21. data/lib/principles/models/finding_decision.rb +2 -1
  22. data/lib/principles/models/finding_write_ups.rb +9 -3
  23. data/lib/principles/models/named_placeholder.rb +17 -7
  24. data/lib/principles/models/open_findings_decision.rb +3 -2
  25. data/lib/principles/models/project_history.rb +9 -0
  26. data/lib/principles/models/record_format.rb +5 -3
  27. data/lib/principles/models/recorded_finding.rb +2 -2
  28. data/lib/principles/models/still_holds_restatement.rb +1 -1
  29. data/lib/principles/models/template_placeholders.rb +10 -9
  30. data/lib/principles/models/write_up_pointer.rb +12 -4
  31. data/lib/principles/version.rb +2 -2
  32. data/lib/principles/views/acknowledgement_result.rb +23 -16
  33. data/lib/principles/views/answer_in_a_file.rb +1 -1
  34. data/lib/principles/views/assessment_request.rb +7 -3
  35. data/lib/principles/views/correction_request.rb +2 -2
  36. data/lib/principles/views/invocation.rb +4 -3
  37. data/lib/principles/views/principle_read_result.rb +5 -0
  38. data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +1 -1
  39. data/lib/principles/views/prompts/assess-every-member/ask-whether-each-rule-is-enforced.md +2 -0
  40. data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +1 -1
  41. data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +1 -1
  42. data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +5 -4
  43. data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +1 -1
  44. data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +8 -8
  45. data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +2 -0
  46. data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +3 -3
  47. data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +1 -1
  48. data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +1 -1
  49. data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
  50. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dff6cef8ffe7bf8e4ae196d30990ef04dead3936c9589417f2d855e30537061b
4
- data.tar.gz: 15f837c78a1764c255d6f3d5d47569dd24715fdd12cd8ea7fb1e3e94be8a53a3
3
+ metadata.gz: f8b04054564dfc79ab583581eeaae27f66204b08442fafe36cca6e394cf7c03a
4
+ data.tar.gz: f50136eab25d56d28763cf45370cc82153b147cb09ff33a3115870bd1f8952c3
5
5
  SHA512:
6
- metadata.gz: 79b6c84811e0e3cab5be0e0ab17cb7197bb269bb40ba6f049779820776f8700d3c7fe09036f361adc4ea6aae46a1abc87403a95522d65cde128c17580d6c022d
7
- data.tar.gz: a057071b4e8e84c5d22d7582388018e106c044a831a7b604944dd1503e9f03ce3fc0957e467f2b0f8aa5b61ab47406b969cc4b02b7fb73c55c14b3162c9a5a33
6
+ metadata.gz: e8046d682bc212a7cc23b758e04475aa865e04bc52c39d8d0152ae84d9103e450e285c10f595dd716d7dd796127e4520e015b7a3c5c6d810a051913be86adb4c
7
+ data.tar.gz: 719dfe66f7590955ea3102a6f5895827b5a3ca4b47c1ba836492fc31dabc351c0bb901b54aaa1e620dcbff546088116d1668fae3c31db94c46985b8258c2f573
data/CHANGELOG.md CHANGED
@@ -13,6 +13,36 @@ 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.1.3] - 2026-11-24
17
+
18
+ ### Changed
19
+
20
+ - **Answer files land in the project's own ignored scratch folder when it has one, not a system temporary folder the agent may not be able to reach or find again.** When the project has a `tmp/` folder that git ignores, every answer file a printed next step names, from `principles start-audit`, `principles submit-answer` and `principles show-first-audit-brief`, is in it, where each named a system temporary folder; a project with no ignored `tmp/` keeps the temporary folder. The steps now say the file is kept out of git rather than outside the project, and the first-audit brief says to keep it at the one path named and nowhere else.
21
+ - **Choosing a finding's action in a correction means replacing a few words, not a long sentence.** Each disposition's `action` in the correction's answer, as `principles show-open-correction` and `principles show-answer-check --as template` print it, now reads "For F1: fixed, deferred, accepted or disagreed", and the answer guide `principles submit-answer` prints with the correction shows what each action adds. Each finding's action takes 57 bytes instead of 373, so a one-finding correction template takes 721 bytes instead of 1,037. An answer still holding an earlier release's long placeholder is refused as unchosen, as before.
22
+ - **Acknowledging several edited members fills each slot with a file-edit tool, with no script.** In `principles start-audit ID --member MEMBER --member MEMBER --as template`, each member's placeholders now name its entry by position, such as "M2: true only if it still says the same thing" and "M2: why, in one line of your own", where each repeated the member's full id, long and often holding quotes, that an edit had to quote exactly; the id stays the entry's key. A four-member template with long ids takes 1,104 bytes instead of 1,608. An answer still holding a placeholder, as this or an earlier release printed it, is refused as unanswered, as before.
23
+
24
+ ### Fixed
25
+
26
+ - **A member widened over lines its file already held is no longer described as an edit that inserted a line.** After `principles move-member --ending-at` stretches a member over existing text, `principles start-audit ID --member MEMBER` now says in the template that the member's span grew over lines its file already held, which may add a rule, where it said the change inserted a line though the file's text had not changed.
27
+
28
+ ## [0.1.2] - 2026-11-24
29
+
30
+ ### Added
31
+
32
+ - **A full audit now asks whether each rule its principle states is enforced, and whether each enforced rule is written down.** `principles start-audit ID` asks the agent to judge from the members' roles and text whether a check, hook or CI step enforces each rule, and to raise either gap as a finding, where a map holding only statements often went unremarked. It adds about 180 bytes to each full audit's request, and members judged at the last audit still carry their assessments forward.
33
+
34
+ - **Looping over the mapped principles takes no script.** `principles list-principles --lines` prints each principle's id alone, one per line, ready for a shell loop, where an agent pulled the ids out of the JSON listing with a script of its own.
35
+
36
+ ### Changed
37
+
38
+ - **A release needs its publisher only to type the RubyGems one-time code.** `bundle exec rake release:prepare` does everything slow: the gate, the tag, the public copy, and the gem built and checked. Then `bundle exec rake release:publish OTP=<code>` uploads the gem the moment the code arrives. After that it pushes, publishes the plugin through a merged pull request and commits the next patch, where nine closing commands were once run by hand. A stopped step resumes on a rerun, and a refused or expired code uploads nothing. **Breaking:** `RELEASE=1 bundle exec rake release` no longer publishes; `bundle exec rake release` is the dry run.
39
+
40
+ ### Fixed
41
+
42
+ - **A finding written up in an issue is pointed at by its link, with no stub file in the project.** A deferral's `recorded_at` in `principles submit-answer`, from a correction, a full audit's kept finding or `start-audit ID --open-findings`, now takes `{"url": "https://..."}`, where a link was refused. A link that is not a whole https one is refused with how to give one. `principles list-open-findings` reads nothing at the link, and never reports it lost. A record holding a link can be read only by this release or later: an older copy refuses it as newer, so leave it as it is.
43
+ - **A deferred, accepted or disagreed finding is no longer refused for a reassessment its template invited.** The correction's answer, as `principles show-open-correction` prints it, now leaves each `reassessment` null, which only a fix replaces, where it printed a sentence that any other action had to send back word for word.
44
+ - **A first audit run in the background knows where its answer file may not go, even in a worktree inside the repository's own folders.** The brief that `principles show-first-audit-brief ID` prints now names the project's root as the place no answer file may go, where it said only "never in the project".
45
+
16
46
  ## [0.1.1] - 2026-11-24
17
47
 
18
48
  ### Changed
@@ -6,6 +6,7 @@ require_relative "invocation_options"
6
6
  require_relative "after_commit_hook_options"
7
7
  require_relative "session_start_options"
8
8
  require_relative "list_open_findings_options"
9
+ require_relative "list_principles_options"
9
10
  require_relative "start_audit_options"
10
11
  require_relative "models/command_steps"
11
12
  require_relative "prose_list"
@@ -160,13 +161,15 @@ module Principles
160
161
  end
161
162
 
162
163
  # Options checked together, each set owning what is wrong with it as given: --session-start, the
163
- # after-commit hook's pair on the command it runs, the audit start-audit begins and the form
164
- # list-open-findings prints; the first fault is refused.
164
+ # after-commit hook's pair on the command it runs, the audit start-audit begins and the forms
165
+ # list-open-findings and list-principles print; the first fault is refused.
165
166
  #: (String) -> void
166
167
  def check_combined_options(name)
167
168
  hook = (AfterCommitHookOptions.new(@options) if name == AfterCommitHookOptions::COMMAND)
169
+ principles = (ListPrinciplesOptions.new(@options) if name == ListPrinciplesOptions::COMMAND)
168
170
  start_audit = StartAuditOptions.new(@options, several_ids: several_ids?(name))
169
- sets = [SessionStartOptions.new(@options), hook, start_audit, ListOpenFindingsOptions.new(@options)].compact
171
+ sets = [SessionStartOptions.new(@options), hook, start_audit, ListOpenFindingsOptions.new(@options),
172
+ principles].compact
170
173
  fault = sets.filter_map(&:fault).first or return
171
174
  raise UsageRefusal.new(fault, help_repair(name))
172
175
  end
@@ -94,10 +94,11 @@ module Principles
94
94
  controller.new(@project, tool: @tool, **)
95
95
  end
96
96
 
97
- # The executable and project that printed commands name, built for each run and never stored.
97
+ # The executable and project that printed commands name, and the folder a printed answer is saved in, built for
98
+ # each run and never stored.
98
99
  #: () -> Views::Invocation
99
100
  def invocation
100
- @tool.invocation(@project.root)
101
+ @tool.invocation(@project.root, answer_folder: @history.ignored_tmp_folder)
101
102
  end
102
103
 
103
104
  # Principle id as waiting on an upgrade, when a later copy wrote its record.
@@ -17,7 +17,7 @@ module Principles
17
17
  def call(command, id, options)
18
18
  naming_the_executable do
19
19
  case command
20
- when "list-principles" then listing(open_findings: options["open_findings"]).merge("wrote" => [])
20
+ when "list-principles" then listed(options)
21
21
  when "show-principle" then members(required_id(id)).merge("wrote" => [])
22
22
  else unknown(command)
23
23
  end
@@ -98,6 +98,14 @@ module Principles
98
98
  Views::PrincipleReadResult.new(invocation)
99
99
  end
100
100
 
101
+ # list-principles as options ask: each id on a line with --lines, else the rows as JSON.
102
+ #: (Hash[String, untyped]) -> untyped
103
+ def listed(options)
104
+ return read_result.ids(@principles.ids) if options["lines"]
105
+
106
+ listing(open_findings: options["open_findings"]).merge("wrote" => [])
107
+ end
108
+
101
109
  # Its next_action offers an audit while one principle's audits do not wait on an upgrade; a map listed with its
102
110
  # refusal counts, since repairing it leaves it to audit. With open_findings, each row lists its open findings.
103
111
  #: (open_findings: bool?) -> untyped
@@ -22,12 +22,13 @@ module Principles
22
22
  # template prints, and the record with the acknowledgement in it once the answer holds.
23
23
  class MemberAcknowledgement < Command
24
24
  # The text the template prints in each field the agent writes: its judgement's placeholders, meaning_kept's
25
- # chosen by whether the change's first_changed_lines is a pure insertion, and check_result's for a
26
- # checked member. The quotes the answer reads as first_changed_lines when left out are not printed.
27
- #: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?) -> Hash[String, untyped]
28
- def self.placeholders(check_result, change = nil)
25
+ # chosen by whether the change's first_changed_lines is a pure insertion and file_unchanged, whether the
26
+ # member's file text is as at its baseline, and check_result's for a checked member. The quotes the answer
27
+ # reads as first_changed_lines when left out are not printed.
28
+ #: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?, ?file_unchanged: bool) -> Hash[String, untyped]
29
+ def self.placeholders(check_result, change = nil, file_unchanged: false)
29
30
  quotes = change&.first_changed_lines.to_h
30
- { **Models::AcknowledgementPlaceholders.beside(quotes),
31
+ { **Models::AcknowledgementPlaceholders.beside(quotes, file_unchanged:),
31
32
  **(check_result ? { "check_result" => check_result } : {}) }
32
33
  end
33
34
 
@@ -57,13 +58,11 @@ module Principles
57
58
  def asked
58
59
  baseline, lines = since_baseline
59
60
  check = check_template
60
- change = Views::MemberChangeSinceBaseline.new(
61
- member: shown(baseline), member_lines: lines.shown(taken: bytes_of(check)),
62
- first_changed_lines: @acknowledgement.first_changed_lines(lines), commits: commits(baseline),
63
- read_the_change: read_the_change(baseline)
64
- )
61
+ change = change_since(baseline, lines, check)
65
62
  { change:, context: { **@acknowledgement.open_findings, **instruction_for(check) },
66
- placeholders: MemberAcknowledgement.placeholders(check&.to_h, change) }
63
+ placeholders: MemberAcknowledgement.placeholders(
64
+ check&.to_h, change, file_unchanged: @acknowledgement.file_unchanged_since?(baseline, @project)
65
+ ) }
67
66
  end
68
67
 
69
68
  # The record with the acknowledgement in it, once its quotes are found at the baseline and now, made to into
@@ -79,6 +78,17 @@ module Principles
79
78
 
80
79
  private
81
80
 
81
+ # The member's change since baseline as the request shows it, its lines giving up the bytes check takes.
82
+ #: (Models::Placement, Models::MemberLines, Views::OneMemberCheckResultTemplate?)
83
+ #| -> Views::MemberChangeSinceBaseline
84
+ def change_since(baseline, lines, check)
85
+ Views::MemberChangeSinceBaseline.new(
86
+ member: shown(baseline), member_lines: lines.shown(taken: bytes_of(check)),
87
+ first_changed_lines: @acknowledgement.first_changed_lines(lines), commits: commits(baseline),
88
+ read_the_change: read_the_change(baseline)
89
+ )
90
+ end
91
+
82
92
  # What the member's check lists now beside the members the answer acknowledges, when the check is this
83
93
  # tool's own list-member-problems --short; nil for any other check.
84
94
  #: (Array[[String, String]]) -> Models::ListedMembers?
@@ -72,10 +72,12 @@ module Principles
72
72
  # The executable and project that this run's printed commands name, for the project at root. A command line run
73
73
  # printed as the bare principles, from root itself, leaves out --project, since a command copied from its
74
74
  # output runs there too; any other run names the project, as the plugin's hooks and a checkout's commands may
75
- # be run from elsewhere.
76
- #: (String) -> Views::Invocation
77
- def invocation(root)
78
- Views::Invocation.new(executable: executable, project: root, temp_directory: @folders.temp_directory,
75
+ # be run from elsewhere. answer_folder is the project's own folder for a printed answer, when it has one, which
76
+ # every answer file is saved in rather than the temporary folder.
77
+ #: (String, ?answer_folder: String?) -> Views::Invocation
78
+ def invocation(root, answer_folder: nil)
79
+ Views::Invocation.new(executable: executable, project: root,
80
+ temp_directory: answer_folder || @folders.temp_directory,
79
81
  named: !bare_from_path? || root != @folders.cwd)
80
82
  end
81
83
 
@@ -60,12 +60,12 @@
60
60
  ]
61
61
  },
62
62
  {
63
- "name": "list-principles", "usage": "list-principles [--open-findings]", "group": "read", "options": ["open-findings"],
63
+ "name": "list-principles", "usage": "list-principles [--open-findings | --lines]", "group": "read", "options": ["open-findings", "lines"],
64
64
  "summary": "Every mapped principle and whether its members are current.",
65
65
  "help": "learn-what-a-command-does/list-principles",
66
66
  "steps": [
67
67
  { "id": "count-members-by-freshness", "actor": "cli",
68
- "does": "Reads every map and the audit record of each, and counts its members as current, changed, unassessed, locator_lost or unavailable. With --open-findings, adds each principle's open findings, one line each, saying whom it waits on, or that it is accepted, and how many days it has been open.",
68
+ "does": "Reads every map and the audit record of each, and counts its members as current, changed, unassessed, locator_lost or unavailable. With --open-findings, adds each principle's open findings, one line each, saying whom it waits on, or that it is accepted, and how many days it has been open. With --lines, prints each principle's id alone, one per line, and reads no map.",
69
69
  "refuses_like": ["read-map", "read-audit"] }
70
70
  ]
71
71
  },
@@ -109,6 +109,11 @@ module Principles
109
109
  #: (Array[String]) -> Array[String]
110
110
  def untracked_excluding_ignored(paths) = @changes.untracked_excluding_ignored(paths)
111
111
 
112
+ # Whether git ignores path, relative to the project, a folder ending in "/"; false outside git. check-ignore
113
+ # refuses literal pathspecs, and reads each path as a name, never a glob, without them.
114
+ #: (String) -> bool
115
+ def ignores?(path) = git(["--no-literal-pathspecs", "check-ignore", "-q", "--", path]).last
116
+
112
117
  # Which of paths, relative to the project, git does not track, ignored or not.
113
118
  #: (Array[String]) -> Array[String]
114
119
  def untracked_including_ignored(paths) = @changes.untracked_including_ignored(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 = "e72082ee" #: String
15
+ ARCHIVED_COMMIT = "9e955b6b" #: 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,
@@ -253,18 +253,15 @@
253
253
  },
254
254
  "recorded_at": {
255
255
  "x-type-refusal-advice": {
256
- "keys": [
257
- "heading",
258
- "starting_at"
259
- ],
260
- "says": "plus starting_at (or heading) when the file holds more than this finding"
256
+ "keys": ["path", "url", "heading", "starting_at", "ending_at", "query"],
257
+ "says": "with path, plus starting_at (or heading) when the file holds more than this finding, or with url alone, a whole https link, for a write-up outside the project such as an issue"
261
258
  },
262
259
  "type": ["object", "null", "string"],
263
260
  "description": "On a still_holds decision, a new pointer to the write-up, or null for none. A string is the template's placeholder, left as printed.",
264
- "required": ["path"],
265
261
  "additionalProperties": false,
266
262
  "properties": {
267
263
  "path": { "type": "string" },
264
+ "url": { "type": "string" },
268
265
  "heading": { "type": "string" },
269
266
  "starting_at": { "type": "string" },
270
267
  "ending_at": { "type": "string" },
@@ -268,9 +268,10 @@
268
268
  "waits_on_since": { "type": "string", "minLength": 1, "description": "When an earlier audit asked waits_on, carried since. Absent means this record's audited_at; only principles writes it." },
269
269
  "recorded_at": {
270
270
  "type": "object",
271
- "required": ["path"],
271
+ "description": "A file in the project, by path and optionally a place inside it, or a write-up outside the project by url alone.",
272
272
  "properties": {
273
273
  "path": { "type": "string", "minLength": 1 },
274
+ "url": { "type": "string", "minLength": 1 },
274
275
  "heading": { "type": "string" },
275
276
  "starting_at": { "type": "string" },
276
277
  "ending_at": { "type": "string" },
@@ -181,23 +181,27 @@
181
181
  "recorded_at": {
182
182
  "x-type-refusal-advice": {
183
183
  "keys": [
184
+ "path",
185
+ "url",
184
186
  "heading",
185
- "starting_at"
187
+ "starting_at",
188
+ "ending_at",
189
+ "query"
186
190
  ],
187
- "says": "plus starting_at (or heading) when the file holds more than this finding"
191
+ "says": "with path, plus starting_at (or heading) when the file holds more than this finding, or with url alone, a whole https link, for a write-up outside the project such as an issue"
188
192
  },
189
193
  "type": [
190
194
  "object",
191
195
  "null"
192
196
  ],
193
- "required": [
194
- "path"
195
- ],
196
197
  "additionalProperties": false,
197
198
  "properties": {
198
199
  "path": {
199
200
  "type": "string"
200
201
  },
202
+ "url": {
203
+ "type": "string"
204
+ },
201
205
  "heading": {
202
206
  "type": "string"
203
207
  },
@@ -231,7 +235,8 @@
231
235
  }
232
236
  },
233
237
  "reassessment": {
234
- "type": "string"
238
+ "type": ["string", "null"],
239
+ "description": "How a fix's changed members now carry the principle: the template prints null, which any other action keeps or omits, and Models::Disposition refuses on a fix."
235
240
  },
236
241
  "waits_on": {
237
242
  "type": ["string", "null"],
@@ -31,11 +31,15 @@
31
31
  "action": { "type": "string" },
32
32
  "waits_on": { "type": ["string", "null"] },
33
33
  "recorded_at": {
34
+ "x-type-refusal-advice": {
35
+ "keys": ["path", "url", "heading", "starting_at", "ending_at", "query"],
36
+ "says": "with path, plus starting_at (or heading) when the file holds more than this finding, or with url alone, a whole https link, for a write-up outside the project such as an issue"
37
+ },
34
38
  "type": ["object", "null"],
35
- "required": ["path"],
36
39
  "additionalProperties": false,
37
40
  "properties": {
38
41
  "path": { "type": "string" },
42
+ "url": { "type": "string" },
39
43
  "heading": { "type": "string" },
40
44
  "starting_at": { "type": "string" },
41
45
  "ending_at": { "type": "string" },
@@ -0,0 +1,28 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "invocation_options"
5
+
6
+ module Principles
7
+ # The options choosing what list-principles prints, --lines or --open-findings, and what is wrong with them as
8
+ # given, which CommandLine refuses as a usage error.
9
+ class ListPrinciplesOptions
10
+ COMMAND = "list-principles"
11
+
12
+ #: (InvocationOptions) -> void
13
+ def initialize(options)
14
+ @lines = !options.value("lines").nil? #: bool
15
+ @open_findings = !options.value("open_findings").nil? #: bool
16
+ freeze
17
+ end
18
+
19
+ # What is wrong with the options as given, or nil when they fit: --lines prints ids alone, so it would drop the
20
+ # open findings asked for without a word.
21
+ #: () -> String?
22
+ def fault
23
+ return unless @lines && @open_findings
24
+
25
+ "--lines prints only each principle's id, so it shows no open findings; give one of --lines and --open-findings"
26
+ end
27
+ end
28
+ end
@@ -61,6 +61,16 @@ module Principles
61
61
  #: (Placement) -> Array[String]
62
62
  def paths_since(baseline) = baseline.paths_to(@member.path)
63
63
 
64
+ # Whether the member's file at the base commit holds the text its file held at baseline, so a change to the
65
+ # member is a change to its span alone, as after move-member --ending-at.
66
+ #: (Placement, Project) -> bool
67
+ def file_unchanged_since?(baseline, project)
68
+ base = @base or return false
69
+
70
+ then_text = project.history.at(baseline.commit).text(baseline.reference.fetch("path"))
71
+ !then_text.nil? && then_text == project.history.at(base).text(@member.path)
72
+ end
73
+
64
74
  # The commit the member was last judged at, when baseline is later than it, as when the member's own full
65
75
  # audit fixed it after its base.
66
76
  #: (Placement) -> String?
@@ -12,23 +12,45 @@ module Principles
12
12
  # The text a one-member audit's template prints in each field the agent writes, and the refusal of an answer
13
13
  # that sends any back as printed.
14
14
  class AcknowledgementPlaceholders
15
+ # meaning_kept's placeholder after a pure insertion, for an agent that reads the template alone: an inserted
16
+ # line usually adds a rule.
17
+ INSERTED = NamedPlaceholder.new(
18
+ "M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; this change inserted a line, " \
19
+ "which usually adds a rule",
20
+ before: NamedPlaceholder.new(
21
+ "true only if #{NamedPlaceholder::SLOT} still says the same thing; this change inserted a line, which " \
22
+ "usually adds a rule",
23
+ before: "true only if the member still says the same thing; this change inserted a line, which " \
24
+ "usually adds a rule"
25
+ )
26
+ ) #: NamedPlaceholder
27
+ # meaning_kept's placeholder when the member's lines grew and its file's text did not change, as after
28
+ # move-member --ending-at, where no line was inserted; it printed INSERTED before.
29
+ SPAN_GREW = NamedPlaceholder.new(
30
+ "M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; its span grew over lines its file " \
31
+ "already held, which may add a rule",
32
+ before: INSERTED
33
+ ) #: NamedPlaceholder
15
34
  # The text the answer's template prints in each field the agent judges, which an answer may not send back, so
16
35
  # 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.
36
+ # out reads as first_changed_lines. After a pure insertion, meaning_kept's is INSERTED, or SPAN_GREW when the
37
+ # file's text did not change.
38
+ # Each names the entry it is printed in by its position, M1 the first, so no two members' slots are alike and
39
+ # one edit fills one, short since an edit tool's old_string quotes it whole; the member's id, which may be long
40
+ # and hold quotes, is the entry's key alone. Any entry's, or the text printed before, naming the member's id or
41
+ # neither, is left as printed.
21
42
  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
- ) }
43
+ { "meaning_kept" => NamedPlaceholder.new(
44
+ "M#{NamedPlaceholder::SLOT}: true only if it still says the same thing",
45
+ before: NamedPlaceholder.new("true only if #{NamedPlaceholder::SLOT} still says the same thing",
46
+ before: "true only if the member still says the same thing")
47
+ ),
48
+ "reason" => NamedPlaceholder.new(
49
+ "M#{NamedPlaceholder::SLOT}: why, in one line of your own",
50
+ before: NamedPlaceholder.new("Why, for #{NamedPlaceholder::SLOT}, in one line of your own",
51
+ before: "Why, in one line of your own")
52
+ ) },
53
+ also_printed: { "meaning_kept" => { inserted: INSERTED, span_grew: SPAN_GREW } }
32
54
  ) #: TemplatePlaceholders
33
55
  # The text a checked member's template prints where its check's exit status goes, short since the request's
34
56
  # context says how to run the check.
@@ -38,10 +60,13 @@ module Principles
38
60
  PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
39
61
  ) #: AcknowledgementLeftAsPrinted
40
62
 
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
63
+ # The placeholders the template prints beside quotes, its first_changed_lines, file_unchanged saying whether
64
+ # the member's file holds the same text as at its baseline, so only its span changed.
65
+ #: (Hash[String, String], ?file_unchanged: bool) -> Hash[String, untyped]
66
+ def self.beside(quotes, file_unchanged: false)
67
+ return PLACEHOLDERS.to_h unless quotes["old_line"] == ""
68
+
69
+ PLACEHOLDERS.with_other_text_in("meaning_kept", file_unchanged ? :span_grew : :inserted)
45
70
  end
46
71
  end
47
72
  end
@@ -13,6 +13,12 @@ module Principles
13
13
  # The checks every answer's fields share: a field is a nonempty string or an array, and each piece of
14
14
  # evidence names a path that the caller's block locates in the project.
15
15
  class AnswerFields
16
+ # A whole https link: a host, then anything but whitespace.
17
+ LINK = %r{\Ahttps://[^\s/?#]+\S*\z}
18
+ LINK_REPAIR = "Give recorded_at as {\"url\": \"https://...\"}, the whole link to where it is written up, " \
19
+ "such as an issue, with no other field; or as {\"path\": ..., \"heading\": ...} for a file in " \
20
+ "the project."
21
+
16
22
  #: (^(Locator) -> void) -> void
17
23
  def initialize(locate)
18
24
  @locate = locate
@@ -56,12 +62,25 @@ module Principles
56
62
  end
57
63
  end
58
64
 
59
- # Where a finding is written up, located at its place in the answer, as the value its record keeps.
65
+ # Where a finding is written up, located at its place in the answer, as the value its record keeps: a place in a
66
+ # project file, or a link outside the project, which is checked as a link and read nowhere.
60
67
  #: (untyped, AnswerPlace) -> WriteUpPointer
61
68
  def write_up_pointer(reference, place)
62
- pointer(reference, place)
69
+ reference.key?("url") ? link(reference, place.child("url")) : pointer(reference, place)
63
70
  WriteUpPointer.new(reference)
64
71
  end
72
+
73
+ private
74
+
75
+ # A write-up's url: a whole https link with a host and no space, given alone.
76
+ #: (Hash[String, untyped], AnswerPlace) -> void
77
+ def link(reference, place)
78
+ url = reference["url"]
79
+ return if reference.size == 1 && url.is_a?(String) && url.match?(LINK)
80
+
81
+ raise place.refusal(Error.new("invalid_answer", "recorded_at's url must be a whole https link, given alone",
82
+ LINK_REPAIR))
83
+ end
65
84
  end
66
85
  end
67
86
  end
@@ -51,9 +51,9 @@ module Principles
51
51
  #: () -> Array[String]
52
52
  def changed_members = @disposition.fetch("changed_members", [])
53
53
 
54
- # The file where the finding is written up, if anywhere.
54
+ # The project file where the finding is written up, if anywhere; none for a write-up at a url.
55
55
  #: () -> String?
56
- def recorded_path = recorded_at&.path
56
+ def recorded_path = recorded_at&.file
57
57
 
58
58
  # What the audit record keeps of this disposition beside its finding: the action, and why a finding left
59
59
  # unfixed was left so, which a fix's reassessment answers instead; where the finding is written up and
@@ -98,7 +98,7 @@ module Principles
98
98
  action = @disposition["action"]
99
99
  return if ACTIONS.include?(action)
100
100
 
101
- unchosen = action.nil? || DispositionPlaceholders::ACTION.left?(action)
101
+ unchosen = action.nil? || DispositionPlaceholders.action_left?(action)
102
102
  problem = unchosen ? "is not chosen" : "is #{action.inspect}, not one of the four"
103
103
  UnfinishedField.new(@place.child("action"), "action",
104
104
  problem:, repair: "Set its action to one of fixed, deferred, accepted or disagreed.")
@@ -154,12 +154,13 @@ module Principles
154
154
  left_reassessment: DispositionPlaceholders::TEXT_FIELDS.fetch("reassessment").placeholder)
155
155
  end
156
156
 
157
- # Each piece of evidence, and where the finding is written up, located in the project.
157
+ # Each piece of evidence located in the project, and where the finding is written up, there or at a link.
158
158
  #: () -> void
159
159
  def locate_pointers
160
160
  fix_fields.check_removal_evidence if fixed?
161
161
  @fields.evidence(fix_fields.list("evidence"), @place.child("evidence"))
162
- @fields.pointer(@disposition["recorded_at"], @place.child("recorded_at")) if @disposition["recorded_at"]
162
+ recorded_at = @disposition["recorded_at"]
163
+ @fields.write_up_pointer(recorded_at, @place.child("recorded_at")) if recorded_at
163
164
  end
164
165
 
165
166
  # A deferral must say where it is written up, or null, so an answer reused from before recorded_at existed
@@ -28,21 +28,29 @@ module Principles
28
28
  }.freeze #: Hash[String, DispositionTextField]
29
29
  # The placeholder in each field, which the template prints with the disposition's finding in its slot.
30
30
  PLACEHOLDERS = TEXT_FIELDS.transform_values { it.placeholder.slotted }.freeze #: Hash[String, String]
31
- # What action takes, said where it is written when the correction's answer is printed with no answer guide
32
- # beside it, as show-answer-check prints it, before it named the finding. It is help, never an action, so it
33
- # is left unchosen.
31
+ # What action takes, as the correction's template printed it in action before it named the finding: one long
32
+ # sentence of every action's fields, which the agent replaced whole. It is help, never an action, so an answer
33
+ # still sending it is left unchosen.
34
34
  ACTION_PLACEHOLDER = "One of fixed, deferred, accepted or disagreed, each with a reason: fixed lists " \
35
35
  "changed_members for current text changes, optional removed_members for map removals, " \
36
36
  "and evidence and gives a reassessment; deferred gives recorded_at, " \
37
37
  "where the write-up is, and may give waits_on; any other action leaves changed_members, " \
38
38
  "evidence and reassessment as printed" #: String
39
- # The action's placeholder, naming the finding.
40
- ACTION = NamedPlaceholder.new("For #{NamedPlaceholder::SLOT}, #{ACTION_PLACEHOLDER.sub(/\AO/, "o")}",
39
+ # The action's placeholder as it was printed naming the finding, before it named the four choices alone.
40
+ EARLIER_ACTION = NamedPlaceholder.new("For #{NamedPlaceholder::SLOT}, #{ACTION_PLACEHOLDER.sub(/\AO/, "o")}",
41
+ before: ACTION_PLACEHOLDER) #: NamedPlaceholder
42
+ # The action's placeholder, naming the finding and the four choices alone, short enough to replace with one;
43
+ # the answer guide shows each action's fields.
44
+ ACTION = NamedPlaceholder.new("For #{NamedPlaceholder::SLOT}: fixed, deferred, accepted or disagreed",
41
45
  before: ACTION_PLACEHOLDER) #: NamedPlaceholder
42
- # Every placeholder a slot of a correction's template prints, for any finding.
43
- NAMED = [*TEXT_FIELDS.values.map(&:placeholder), ACTION].freeze #: Array[NamedPlaceholder]
46
+ # Every placeholder a slot of a correction's template prints, for any finding, or printed before.
47
+ NAMED = [*TEXT_FIELDS.values.map(&:placeholder), ACTION, EARLIER_ACTION].freeze #: Array[NamedPlaceholder]
44
48
  # Every placeholder a correction's template prints, each text field's and the action's, each with its slot.
45
49
  TEMPLATE_PLACEHOLDERS = PLACEHOLDERS.merge("action" => ACTION.slotted).freeze #: Hash[String, String]
50
+
51
+ # Whether action is the action's placeholder, as this release prints it or an earlier one did, for any finding.
52
+ #: (untyped) -> bool
53
+ def self.action_left?(action) = [ACTION, EARLIER_ACTION].any? { it.left?(action) }
46
54
  end
47
55
  end
48
56
  end
@@ -25,7 +25,8 @@ module Principles
25
25
  "waits_on" => "One line, on a deferred finding only: whom it now waits on and to decide what. Or null, " \
26
26
  "even on a deferred finding, to drop it.",
27
27
  "action" => "deferred or accepted, as when the owner rules; its reason becomes the finding's own.",
28
- "recorded_at" => "Where its write-up is now, in a committed file: {\"path\": ..., \"heading\": ...}, or null.",
28
+ "recorded_at" => "Where its write-up is now, in a committed file: {\"path\": ..., \"heading\": ...}; outside " \
29
+ "the project, such as an issue: {\"url\": \"https://...\"}; or null.",
29
30
  "reason" => "One line saying why, required with any change. A field left out keeps its value; " \
30
31
  "decision_fields may be kept or deleted."
31
32
  }.freeze #: Hash[String, String]
@@ -62,8 +62,14 @@ module Principles
62
62
 
63
63
  # pointer's write_up_opening, or null with the reason: not_recorded, empty_region, or unavailable with the
64
64
  # refusal, so one pointer that no longer resolves never refuses the whole list.
65
+ # A url's is null as outside_project, since this tool reads nothing outside the project.
65
66
  #: (WriteUpPointer?) -> Hash[String, untyped]
66
- def opening_fields(pointer) = pointer ? opening_found(pointer) : none("not_recorded")
67
+ def opening_fields(pointer)
68
+ return none("not_recorded") unless pointer
69
+ return none("outside_project") if pointer.url
70
+
71
+ opening_found(pointer)
72
+ end
67
73
 
68
74
  # The write_up_opening pointer leads to, or null with why: empty_region, or unavailable with the refusal.
69
75
  #: (WriteUpPointer) -> Hash[String, untyped]
@@ -74,10 +80,10 @@ module Principles
74
80
  none("unavailable").merge("write_up_opening_error" => unavailable(e.payload, pointer))
75
81
  end
76
82
 
77
- # Whether a recorded pointer no longer resolves in the project's file now.
83
+ # Whether a recorded pointer no longer resolves in the project's file now; a url names no file here to lose.
78
84
  #: (WriteUpPointer?) -> bool
79
85
  def unresolved?(pointer)
80
- return false unless pointer
86
+ return false if pointer.nil? || pointer.url
81
87
 
82
88
  pointer.opening_in(@project)
83
89
  false