principles 0.0.1 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/principles/cli.rb +7 -1
- data/lib/principles/command_line.rb +12 -29
- data/lib/principles/controllers/acknowledgement.rb +4 -4
- data/lib/principles/controllers/answer.rb +64 -100
- data/lib/principles/controllers/assessment.rb +108 -0
- data/lib/principles/controllers/audit.rb +29 -135
- data/lib/principles/controllers/audit_completion.rb +2 -4
- data/lib/principles/controllers/command.rb +27 -13
- data/lib/principles/controllers/correction.rb +4 -4
- data/lib/principles/controllers/full_audit_request.rb +180 -0
- data/lib/principles/controllers/inventory.rb +32 -70
- data/lib/principles/controllers/mapping.rb +3 -3
- data/lib/principles/controllers/member_entries.rb +24 -12
- data/lib/principles/controllers/member_problems_report.rb +72 -0
- data/lib/principles/controllers/members_a_commit_changed.rb +10 -2
- data/lib/principles/controllers/members_to_assess.rb +16 -9
- data/lib/principles/controllers/meta_principle_setup.rb +5 -5
- data/lib/principles/controllers/repoint.rb +1 -1
- data/lib/principles/controllers/running_tool.rb +1 -1
- data/lib/principles/data/audit_files.rb +11 -7
- data/lib/principles/data/bounded_file.rb +11 -0
- data/lib/principles/data/command-steps.json +7 -6
- data/lib/principles/data/map_files.rb +2 -2
- data/lib/principles/data/principles_subfolder.rb +8 -1
- data/lib/principles/data/project_files.rb +1 -7
- data/lib/principles/data/project_root.rb +48 -0
- data/lib/principles/data/schema_check.rb +23 -5
- data/lib/principles/data/schemas/assessment-answer.schema.json +18 -9
- data/lib/principles/data/schemas/audit-record.schema.json +3 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +2 -3
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/models/assessment_answer.rb +64 -17
- data/lib/principles/models/audit.rb +24 -15
- data/lib/principles/models/audit_record.rb +10 -3
- data/lib/principles/models/audit_records.rb +74 -4
- data/lib/principles/models/audit_start.rb +3 -3
- data/lib/principles/models/carried_assessments.rb +1 -1
- data/lib/principles/models/check_since_last_audit.rb +6 -6
- data/lib/principles/models/correction_basis.rb +1 -1
- data/lib/principles/models/decided_prior_findings.rb +9 -19
- data/lib/principles/models/declared_map_changes.rb +8 -8
- data/lib/principles/models/disposition.rb +28 -24
- data/lib/principles/models/evidence_replacements.rb +8 -1
- data/lib/principles/models/fix_only_fields.rb +67 -0
- data/lib/principles/models/kept_prior_finding.rb +12 -7
- data/lib/principles/models/loaded_files.rb +5 -3
- data/lib/principles/models/loading_decision.rb +9 -2
- data/lib/principles/models/{member_maps.rb → mapped_principles.rb} +15 -15
- data/lib/principles/models/member.rb +1 -1
- data/lib/principles/models/member_assessments.rb +48 -3
- data/lib/principles/models/member_grounds.rb +2 -2
- data/lib/principles/models/member_hashes_as_written.rb +40 -0
- data/lib/principles/models/member_moves.rb +3 -3
- data/lib/principles/models/member_problems.rb +38 -18
- data/lib/principles/models/members_sharing_lines.rb +3 -3
- data/lib/principles/models/new_findings.rb +55 -0
- data/lib/principles/models/open_finding.rb +23 -13
- data/lib/principles/models/other_principles.rb +1 -1
- data/lib/principles/models/other_templates_placeholders.rb +74 -0
- data/lib/principles/models/{member_map.rb → principle.rb} +45 -40
- data/lib/principles/models/{member_map_history.rb → principle_history.rb} +38 -15
- data/lib/principles/models/{map_members.rb → principle_members.rb} +4 -4
- data/lib/principles/models/prior_decision_fields.rb +46 -0
- data/lib/principles/models/prior_finding_decision.rb +24 -3
- data/lib/principles/models/prior_finding_outcomes.rb +10 -3
- data/lib/principles/models/prior_findings.rb +1 -1
- data/lib/principles/models/problem_report.rb +7 -3
- data/lib/principles/models/project.rb +27 -13
- data/lib/principles/models/project_history.rb +2 -2
- data/lib/principles/models/recent_decision.rb +90 -0
- data/lib/principles/models/record_format.rb +105 -0
- data/lib/principles/models/recorded_finding.rb +4 -0
- data/lib/principles/models/recorded_hashes.rb +39 -0
- data/lib/principles/models/recorded_members.rb +17 -12
- data/lib/principles/models/reported_check.rb +63 -11
- data/lib/principles/models/request_id.rb +24 -4
- data/lib/principles/models/sent_prior_decisions.rb +31 -0
- data/lib/principles/models/still_holds_restatement.rb +7 -10
- data/lib/principles/models/template_placeholders.rb +41 -0
- data/lib/principles/session_start_options.rb +29 -0
- data/lib/principles/start_audit_options.rb +37 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/answer_head.rb +29 -0
- data/lib/principles/views/assessed_members.rb +96 -0
- data/lib/principles/views/assessment_request.rb +51 -49
- data/lib/principles/views/audit_result.rb +38 -42
- data/lib/principles/views/check_result_template.rb +31 -10
- data/lib/principles/views/correction_request.rb +64 -0
- data/lib/principles/views/first_audit.rb +71 -0
- data/lib/principles/views/help.rb +3 -2
- data/lib/principles/views/loads_to_check_result.rb +11 -4
- data/lib/principles/views/map_added_to.rb +31 -0
- data/lib/principles/views/map_result.rb +37 -22
- data/lib/principles/views/members_a_commit_changed.rb +30 -10
- data/lib/principles/views/meta_principle_result.rb +3 -14
- data/lib/principles/views/principle_read_result.rb +27 -10
- data/lib/principles/views/prior_finding_decisions_result.rb +13 -14
- data/lib/principles/views/prior_findings_result.rb +7 -3
- data/lib/principles/views/problem_lines.rb +14 -11
- data/lib/principles/views/problem_result.rb +30 -16
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +3 -2
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +3 -6
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +4 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +7 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +22 -20
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +8 -5
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +3 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/select-the-project-root.md +1 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +6 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +3 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +8 -8
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +37 -37
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +1 -0
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +4 -0
- data/lib/principles/views/prompts/set-principles-up/first-keeping-audit-after-own-principle.md +10 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +2 -1
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +54 -0
- data/lib/principles/views/request_part.rb +14 -2
- data/lib/principles/views/request_parts.rb +4 -0
- metadata +33 -7
|
@@ -38,7 +38,7 @@ module Principles
|
|
|
38
38
|
# whose maps or records have not moved. A file an older version left beside no subfolder holds none.
|
|
39
39
|
#: () -> Array[String]
|
|
40
40
|
def held_in
|
|
41
|
-
[FOLDER, EARLIER_FOLDER].select { |folder|
|
|
41
|
+
[FOLDER, EARLIER_FOLDER].select { |folder| directory?(File.join(@root, folder, @name)) }
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# The file id names in this directory.
|
|
@@ -78,6 +78,13 @@ module Principles
|
|
|
78
78
|
|
|
79
79
|
private
|
|
80
80
|
|
|
81
|
+
#: (String) -> bool
|
|
82
|
+
def directory?(path)
|
|
83
|
+
File.stat(path).directory?
|
|
84
|
+
rescue Errno::ENOENT, Errno::ENOTDIR
|
|
85
|
+
false
|
|
86
|
+
end
|
|
87
|
+
|
|
81
88
|
#: (String) -> void
|
|
82
89
|
def refuse_link(relative)
|
|
83
90
|
return unless File.symlink?(File.join(@root, relative))
|
|
@@ -25,13 +25,7 @@ module Principles
|
|
|
25
25
|
# Models::MemberFile finds a member's place in it.
|
|
26
26
|
#: (String) -> String
|
|
27
27
|
def read_text(path)
|
|
28
|
-
|
|
29
|
-
unless text.valid_encoding?
|
|
30
|
-
raise Error.new("invalid_encoding", "Cannot read UTF-8 text", "Choose a text member.",
|
|
31
|
-
path)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
text
|
|
28
|
+
BoundedFile.new(resolve(path), shown_as: path).read_text
|
|
35
29
|
rescue SystemCallError => e
|
|
36
30
|
raise Error.new("unreadable_file", e.message, "Restore a readable project-local file, then retry.", path)
|
|
37
31
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "principles_subfolder"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
8
|
+
module Data
|
|
9
|
+
# The physical project boundary selected from an implicit working directory.
|
|
10
|
+
class ProjectRoot
|
|
11
|
+
#: (String) -> void
|
|
12
|
+
def initialize(directory)
|
|
13
|
+
@selected = File.realpath(directory) #: String
|
|
14
|
+
freeze
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#: () -> String
|
|
18
|
+
def path
|
|
19
|
+
directory = @selected
|
|
20
|
+
loop do
|
|
21
|
+
return directory if store?(directory)
|
|
22
|
+
return @selected if entry?(directory, ".git") || File.dirname(directory) == directory
|
|
23
|
+
|
|
24
|
+
directory = File.dirname(directory)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
#: (String) -> bool
|
|
31
|
+
def store?(directory)
|
|
32
|
+
return true if entry?(directory, PrinciplesSubfolder::FOLDER)
|
|
33
|
+
|
|
34
|
+
%w[maps audits].any? do |name|
|
|
35
|
+
PrinciplesSubfolder.new(directory, name).held_in.include?(PrinciplesSubfolder::EARLIER_FOLDER)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#: (String, String) -> bool
|
|
40
|
+
def entry?(directory, name)
|
|
41
|
+
File.lstat(File.join(directory, name))
|
|
42
|
+
true
|
|
43
|
+
rescue Errno::ENOENT
|
|
44
|
+
false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -18,12 +18,28 @@ module Principles
|
|
|
18
18
|
# This tool's own schema keyword, on an object that refuses fields it does not name: for a field an agent
|
|
19
19
|
# may put there by mistake, where it belongs instead, which its refusal adds (#769), as {field => text}.
|
|
20
20
|
UNREAD_FIELD_ADVICE = "x-unread-field-advice"
|
|
21
|
+
# This tool's own schema keyword, on a string with a pattern: what to say when the value does not match, in place
|
|
22
|
+
# of the pattern, for a field whose pattern holds a template's placeholder, which another template's wording
|
|
23
|
+
# fails (#1082).
|
|
24
|
+
UNMATCHED_ADVICE = "x-unmatched-advice"
|
|
21
25
|
# Keywords that only describe, and check nothing; the refusal advice is worded into a refusal.
|
|
22
|
-
ANNOTATIONS = %W[$schema $id title description #{ExpectedType::ADVICE} #{UNREAD_FIELD_ADVICE}
|
|
26
|
+
ANNOTATIONS = %W[$schema $id title description #{ExpectedType::ADVICE} #{UNREAD_FIELD_ADVICE}
|
|
27
|
+
#{UNMATCHED_ADVICE}].freeze
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
# schema is the one named, unless a narrower one is given.
|
|
30
|
+
#: (String, ?Hash[String, untyped]) -> void
|
|
31
|
+
def initialize(name, schema = JSON.parse(File.read(File.join(__dir__, "schemas", "#{name}.schema.json"))))
|
|
32
|
+
@name = name
|
|
33
|
+
@schema = schema #: Hash[String, untyped]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The check of only the top-level fields named, any other field let through, so the part a later step depends
|
|
37
|
+
# on is checked before the rest, as an answer's head is (#1052).
|
|
38
|
+
#: (Array[String]) -> SchemaCheck
|
|
39
|
+
def only(fields)
|
|
40
|
+
SchemaCheck.new(@name, @schema.merge("properties" => @schema.fetch("properties", {}).slice(*fields),
|
|
41
|
+
"required" => @schema.fetch("required", []) & fields,
|
|
42
|
+
"additionalProperties" => true))
|
|
27
43
|
end
|
|
28
44
|
|
|
29
45
|
# Each place data breaks the schema, as a JSON pointer and what is wrong there, sorted by pointer.
|
|
@@ -71,7 +87,9 @@ module Principles
|
|
|
71
87
|
#: (Hash[String, untyped], String, String, Array[Hash[String, String]]) -> void
|
|
72
88
|
def check_string(schema, value, pointer, found)
|
|
73
89
|
found << problem(pointer, "must not be empty") if too_short?(schema, value)
|
|
74
|
-
|
|
90
|
+
return unless unmatched?(schema, value)
|
|
91
|
+
|
|
92
|
+
found << problem(pointer, schema[UNMATCHED_ADVICE] || "must match #{schema["pattern"]}")
|
|
75
93
|
end
|
|
76
94
|
|
|
77
95
|
#: (Hash[String, untyped], String) -> bool
|
|
@@ -112,7 +112,8 @@
|
|
|
112
112
|
"type": "string"
|
|
113
113
|
},
|
|
114
114
|
"exit_status": {
|
|
115
|
-
"type": "integer"
|
|
115
|
+
"type": ["integer", "string"],
|
|
116
|
+
"description": "The run's exit status. A string is the template's placeholder, left unfilled, which Models::ReportedCheck reads as not given (#993)."
|
|
116
117
|
},
|
|
117
118
|
"not_run_reason": {
|
|
118
119
|
"type": "string"
|
|
@@ -125,6 +126,10 @@
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
},
|
|
129
|
+
"left_as_printed_rule": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"description": "The note start-audit --as template prints at its head saying how a field left as printed is read, which an answer may send back and Models::AssessmentAnswer ignores, whatever it holds (#1043, D88)."
|
|
132
|
+
},
|
|
128
133
|
"collective_assessment": {
|
|
129
134
|
"type": "string"
|
|
130
135
|
},
|
|
@@ -139,7 +144,8 @@
|
|
|
139
144
|
"type": "string"
|
|
140
145
|
},
|
|
141
146
|
"evidence": {
|
|
142
|
-
"type": "array",
|
|
147
|
+
"type": ["array", "string"],
|
|
148
|
+
"description": "Pointers to where the decision is recorded. A string is the template's placeholder, left as printed, which Models::RecentDecision reads as not given (#994).",
|
|
143
149
|
"items": {
|
|
144
150
|
"type": "object",
|
|
145
151
|
"required": [
|
|
@@ -202,8 +208,9 @@
|
|
|
202
208
|
},
|
|
203
209
|
"raised_in": {
|
|
204
210
|
"type": "string",
|
|
205
|
-
"pattern": "^[0-9a-f]{40}([0-9a-f]{24})
|
|
206
|
-
"
|
|
211
|
+
"pattern": "^([0-9a-f]{40}([0-9a-f]{24})?|With first_raised_at: its record's commit, full sha; else leave)$",
|
|
212
|
+
"x-unmatched-advice": "is not this template's placeholder nor a full commit sha, as an answer filled from another template leaves it: start from this request's response_template",
|
|
213
|
+
"description": "The full sha of the commit whose audit record, at .principles/audits/ID.json or the earlier .memeplex/audits/ID.json, left this finding open at first_raised_at (D53). The one other value is the template's placeholder, word for word, which Models::PriorFindingDecision reads as not given, so only a sha reaches git (#994)."
|
|
207
214
|
},
|
|
208
215
|
"waits_on": {
|
|
209
216
|
"type": ["string", "null"],
|
|
@@ -217,7 +224,8 @@
|
|
|
217
224
|
],
|
|
218
225
|
"says": "plus starting_at (or heading) when the file holds more than this finding"
|
|
219
226
|
},
|
|
220
|
-
"type": ["object", "null"],
|
|
227
|
+
"type": ["object", "null", "string"],
|
|
228
|
+
"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 (#994).",
|
|
221
229
|
"required": ["path"],
|
|
222
230
|
"additionalProperties": false,
|
|
223
231
|
"properties": {
|
|
@@ -229,7 +237,8 @@
|
|
|
229
237
|
}
|
|
230
238
|
},
|
|
231
239
|
"evidence": {
|
|
232
|
-
"type": "array",
|
|
240
|
+
"type": ["array", "string"],
|
|
241
|
+
"description": "On a resolved decision, pointers to where the fix shows. A string is the template's placeholder, left as printed, which Models::PriorFindingDecision reads as not given (#994).",
|
|
233
242
|
"items": {
|
|
234
243
|
"type": "object",
|
|
235
244
|
"required": ["path"],
|
|
@@ -244,8 +253,8 @@
|
|
|
244
253
|
}
|
|
245
254
|
},
|
|
246
255
|
"problem_evidence": {
|
|
247
|
-
"description": "On a still_holds decision, pointers to where the problem is: for a finding marked evidence_not_kept, its evidence, which the record keeps (D64); for one whose record keeps evidence, each the new place of the kept item named by replaces, its position in the finding's evidence, which must no longer be found (D70). Models::StillHoldsRestatement refuses any other.",
|
|
248
|
-
"type": "array",
|
|
256
|
+
"description": "On a still_holds decision, pointers to where the problem is: for a finding marked evidence_not_kept, its evidence, which the record keeps (D64); for one whose record keeps evidence, each the new place of the kept item named by replaces, its position in the finding's evidence, which must no longer be found (D70). Models::StillHoldsRestatement refuses any other. A string is the template's placeholder, left as printed (#994).",
|
|
257
|
+
"type": ["array", "string"],
|
|
249
258
|
"items": {
|
|
250
259
|
"type": "object",
|
|
251
260
|
"required": ["path"],
|
|
@@ -256,7 +265,7 @@
|
|
|
256
265
|
"starting_at": { "type": "string" },
|
|
257
266
|
"ending_at": { "type": "string" },
|
|
258
267
|
"query": { "type": "string" },
|
|
259
|
-
"replaces": { "type": "integer" }
|
|
268
|
+
"replaces": { "type": ["integer", "string"], "description": "The position of the kept item it replaces. A string is the template's placeholder, which Models::EvidenceReplacements refuses as naming no item (#1042)." }
|
|
260
269
|
}
|
|
261
270
|
}
|
|
262
271
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
"type": "object",
|
|
7
7
|
"required": ["principle_id", "status", "map_version", "base_commit", "audited_at", "members", "findings"],
|
|
8
8
|
"properties": {
|
|
9
|
+
"format": { "type": "integer", "description": "The record format, raised when a field is added that an older copy would drop on a rewrite. A record without it is older than format 1, and any copy may rewrite it (D85)." },
|
|
10
|
+
"format_first_release": { "type": "string", "minLength": 1, "description": "The first release that wrote this format, which a copy that does not know it names as the update to make (D85)." },
|
|
9
11
|
"principle_id": { "type": "string", "minLength": 1 },
|
|
10
12
|
"status": { "enum": ["open", "completed"] },
|
|
11
13
|
"map_version": { "type": "string", "minLength": 1 },
|
|
@@ -243,6 +245,7 @@
|
|
|
243
245
|
"first_raised_at": { "type": "string", "minLength": 1, "description": "When an earlier audit first raised this finding, kept or raised again since (D35). Absent means this record's audited_at." },
|
|
244
246
|
"raised_in": { "type": "string", "minLength": 1, "description": "The commit whose record a full audit cited for an earlier first_raised_at, checked to leave this finding open then (D53)." },
|
|
245
247
|
"action": { "type": "string", "minLength": 1 },
|
|
248
|
+
"reason": { "type": "string", "minLength": 1, "description": "On a finding not fixed, why its answer chose its action, as the correction's disposition or a still_holds decision changing the action gave it, kept by each later audit that keeps the finding (#996). Absent from a fixed finding and from one recorded before it was kept." },
|
|
246
249
|
"waits_on": { "type": "string", "minLength": 1, "description": "On a deferred finding, the one line its answer gave saying whom it waits on and to decide what (D52)." },
|
|
247
250
|
"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 (D52)." },
|
|
248
251
|
"recorded_at": {
|
|
@@ -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"] } },
|
|
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"] } },
|
|
76
76
|
"summary": { "$ref": "#/$defs/prose" },
|
|
77
77
|
"help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
|
78
78
|
"steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/step" } }
|
|
@@ -185,10 +185,9 @@
|
|
|
185
185
|
"required": [
|
|
186
186
|
"finding_id",
|
|
187
187
|
"action",
|
|
188
|
-
"reason"
|
|
189
|
-
"evidence",
|
|
190
|
-
"changed_members"
|
|
188
|
+
"reason"
|
|
191
189
|
],
|
|
190
|
+
"description": "changed_members, evidence and reassessment are a fix's; Models::Disposition refuses a fixed disposition missing one, and any other may omit them (#997).",
|
|
192
191
|
"properties": {
|
|
193
192
|
"finding_id": {
|
|
194
193
|
"type": "string"
|
|
@@ -9,7 +9,7 @@ module Principles
|
|
|
9
9
|
class InvocationOptions
|
|
10
10
|
# The options that take a value; --help, -h and --version take none.
|
|
11
11
|
VALUE_OPTIONS = %w[project file description path section starting-at ending-at query role
|
|
12
|
-
check member session-start commits-after hook-event].freeze #: Array[String]
|
|
12
|
+
check member session-start commits-after hook-event as].freeze #: Array[String]
|
|
13
13
|
# The options that take no value, as list-member-problems --short (#291).
|
|
14
14
|
FLAG_OPTIONS = %w[short when-invoked always write-ups].freeze #: Array[String]
|
|
15
15
|
# The options that may be given more than once, each value kept in order, as change-activation --when-files.
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
+
require_relative "../prose_list"
|
|
5
6
|
require_relative "answer_fields"
|
|
7
|
+
require_relative "answer_place"
|
|
6
8
|
require_relative "loads_to_check"
|
|
7
9
|
require_relative "member_assessments"
|
|
8
10
|
require_relative "misspelt_member_id"
|
|
11
|
+
require_relative "new_findings"
|
|
12
|
+
require_relative "sent_prior_decisions"
|
|
13
|
+
require_relative "recent_decision"
|
|
9
14
|
require_relative "record_judged_against"
|
|
10
15
|
|
|
11
16
|
module Principles
|
|
@@ -18,7 +23,19 @@ module Principles
|
|
|
18
23
|
# whose loading it must decide (#355) and the assessments it may carry (D49); answered_at is when it came, which
|
|
19
24
|
# no sighting it reports is after (#699).
|
|
20
25
|
class AssessmentAnswer
|
|
21
|
-
|
|
26
|
+
# The text the template prints in collective_assessment, which an answer may not send back unchanged (#991).
|
|
27
|
+
COLLECTIVE_PLACEHOLDER = "How the members reinforce the principle, and any contradiction or missing " \
|
|
28
|
+
"connection." #: String
|
|
29
|
+
# How a field --as template's answer leaves as printed is read, printed once at the template's head in
|
|
30
|
+
# left_as_printed_rule, where an agent filling it reads, which the answer may send back and this tool ignores
|
|
31
|
+
# (#1043, D88).
|
|
32
|
+
LEFT_AS_PRINTED_RULE = "A field left as printed is read as omitted, as is this one: one saying \"else kept\" " \
|
|
33
|
+
"keeps what it had, and null drops it where offered." #: String
|
|
34
|
+
|
|
35
|
+
# The problem with a judgement sent back as its placeholder.
|
|
36
|
+
UNCHANGED = "is the template's placeholder, unchanged" #: String
|
|
37
|
+
|
|
38
|
+
#: (untyped, PrincipleMembers, answered_at: String, ?judged_against: RecordJudgedAgainst?)
|
|
22
39
|
#| { (Locator) -> Hash[String, untyped] } -> void
|
|
23
40
|
def initialize(response, members, answered_at:, judged_against: nil, &locate)
|
|
24
41
|
@response = response
|
|
@@ -34,9 +51,10 @@ module Principles
|
|
|
34
51
|
# decision and each finding have been checked.
|
|
35
52
|
#: () -> Array[untyped]
|
|
36
53
|
def findings
|
|
54
|
+
refuse_left_as_printed
|
|
37
55
|
member_assessments.check
|
|
38
56
|
@fields.text(@response["collective_assessment"], "collective_assessment")
|
|
39
|
-
recent_decision
|
|
57
|
+
recent_decision.check(@fields)
|
|
40
58
|
checked_findings
|
|
41
59
|
end
|
|
42
60
|
|
|
@@ -63,14 +81,51 @@ module Principles
|
|
|
63
81
|
# commit when they differ from HEAD (#860); none when the decision was unavailable.
|
|
64
82
|
#: () -> Array[String]
|
|
65
83
|
def recent_decision_paths
|
|
66
|
-
|
|
67
|
-
return [] if decision["unavailable_reason"]
|
|
68
|
-
|
|
69
|
-
decision.fetch("evidence").map { |item| item.fetch("path") }.uniq
|
|
84
|
+
recent_decision.paths
|
|
70
85
|
end
|
|
71
86
|
|
|
72
87
|
private
|
|
73
88
|
|
|
89
|
+
# Refuses each judgement the answer leaves as its template printed it, as left_as_printed names them, in one
|
|
90
|
+
# refusal, so a copied template takes one repair (#991, #1010, #1040).
|
|
91
|
+
#: () -> void
|
|
92
|
+
def refuse_left_as_printed
|
|
93
|
+
left = left_as_printed
|
|
94
|
+
return if left.empty?
|
|
95
|
+
|
|
96
|
+
raise Error.new("invalid_answer", "Still to write: #{ProseList.new(left.keys)}",
|
|
97
|
+
"Replace each placeholder named in fields with your own judgement.",
|
|
98
|
+
fields: left.values.map { { "pointer" => it, "problem" => UNCHANGED } })
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Each judgement the answer leaves as its template printed it, named, with its pointer: the members', the set's,
|
|
102
|
+
# the recent decision's, a raised finding's text fields and a prior finding's decision.
|
|
103
|
+
#: () -> Hash[String, String]
|
|
104
|
+
def left_as_printed
|
|
105
|
+
left = member_assessments.left_as_printed
|
|
106
|
+
left["collective_assessment"] = "/collective_assessment" if
|
|
107
|
+
@response["collective_assessment"] == COLLECTIVE_PLACEHOLDER
|
|
108
|
+
left["recent_decision"] = "/recent_decision" if recent_decision_left_as_printed?
|
|
109
|
+
left.merge(listed_left_as_printed)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Each judgement the answer's lists leave as printed: a raised finding's text fields (#1010), and a prior
|
|
113
|
+
# finding's decision (#1040).
|
|
114
|
+
#: () -> Hash[String, String]
|
|
115
|
+
def listed_left_as_printed
|
|
116
|
+
findings, decisions = @response.values_at("findings", "prior_finding_decisions")
|
|
117
|
+
{ **(NewFindings.new(findings).left_as_printed if findings.is_a?(Array)),
|
|
118
|
+
**(SentPriorDecisions.new(decisions).left_as_printed if decisions.is_a?(Array)) }
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Whether the answer gives a recent_decision and leaves each of its fields as the template printed it.
|
|
122
|
+
#: () -> bool
|
|
123
|
+
def recent_decision_left_as_printed?
|
|
124
|
+
return false unless @response["recent_decision"].is_a?(Hash)
|
|
125
|
+
|
|
126
|
+
recent_decision.left_as_printed?
|
|
127
|
+
end
|
|
128
|
+
|
|
74
129
|
#: () -> MemberAssessments
|
|
75
130
|
def member_assessments
|
|
76
131
|
MemberAssessments.new(@response["member_assessments"], @members, fields: @fields,
|
|
@@ -78,20 +133,12 @@ module Principles
|
|
|
78
133
|
answered_at: @answered_at)
|
|
79
134
|
end
|
|
80
135
|
|
|
81
|
-
#: () ->
|
|
82
|
-
def recent_decision
|
|
83
|
-
decision = @response.fetch("recent_decision")
|
|
84
|
-
if decision["unavailable_reason"]
|
|
85
|
-
@fields.text(decision["unavailable_reason"], "recent_decision.unavailable_reason")
|
|
86
|
-
else
|
|
87
|
-
@fields.text(decision["assessment"], "recent_decision.assessment")
|
|
88
|
-
@fields.evidence(decision["evidence"], AnswerPlace.new("/recent_decision/evidence", "Recent decision"))
|
|
89
|
-
end
|
|
90
|
-
end
|
|
136
|
+
#: () -> RecentDecision
|
|
137
|
+
def recent_decision = RecentDecision.new(@response.fetch("recent_decision"))
|
|
91
138
|
|
|
92
139
|
#: () -> Array[untyped]
|
|
93
140
|
def checked_findings
|
|
94
|
-
findings = @fields.array(@response["findings"], "findings")
|
|
141
|
+
findings = NewFindings.new(@fields.array(@response["findings"], "findings")).raised
|
|
95
142
|
finding_ids = findings.each_with_index.map { |finding, index| finding_id(finding, index) }
|
|
96
143
|
unless finding_ids.uniq == finding_ids
|
|
97
144
|
raise Error.new("duplicate_finding", "Finding ids repeat",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
-
require_relative "
|
|
5
|
+
require_relative "principle"
|
|
6
6
|
require_relative "declared_map_changes"
|
|
7
7
|
require_relative "request_id"
|
|
8
8
|
require_relative "correction_basis"
|
|
@@ -25,13 +25,13 @@ module Principles
|
|
|
25
25
|
# has changed since. A correction is based on the map's version and each finding's members, never on
|
|
26
26
|
# the agent's prose.
|
|
27
27
|
class Audit
|
|
28
|
-
#:
|
|
28
|
+
#: Principle
|
|
29
29
|
attr_reader :map
|
|
30
30
|
# Each member's hash now.
|
|
31
31
|
#: Hash[String, String]
|
|
32
32
|
attr_reader :now
|
|
33
33
|
|
|
34
|
-
#: (map:
|
|
34
|
+
#: (map: Principle, now: Hash[String, String]) -> void
|
|
35
35
|
def initialize(map:, now:)
|
|
36
36
|
@map = map
|
|
37
37
|
@now = now
|
|
@@ -79,7 +79,7 @@ module Principles
|
|
|
79
79
|
#: (untyped, RecordJudgedAgainst, String) { (Locator) -> Hash[String, untyped] }
|
|
80
80
|
#| -> AssessmentAnswer
|
|
81
81
|
def assessment(response, judged_against, answered_at, &)
|
|
82
|
-
AssessmentAnswer.new(response,
|
|
82
|
+
AssessmentAnswer.new(response, members, answered_at: answered_at, judged_against: judged_against, &)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
# A digest of what this audit's assessments answer: its description and question (D49).
|
|
@@ -110,7 +110,7 @@ module Principles
|
|
|
110
110
|
# The map the audit began from: the current one when it is unchanged and the answer declares no change; or,
|
|
111
111
|
# in git, the map at the base commit, which the block reads, refused unless the declared changes and any
|
|
112
112
|
# members added explain every change. Outside git, a map that changed is refused.
|
|
113
|
-
#: (CorrectionBasis, DeclaredMapChanges, map_file: String) { (String) ->
|
|
113
|
+
#: (CorrectionBasis, DeclaredMapChanges, map_file: String) { (String) -> Principle } -> Principle
|
|
114
114
|
def map_started_from(basis, changes, map_file:, &)
|
|
115
115
|
base = changes.base_to_read(basis.base_commit, @map, map_version: basis.map_version, map_file: map_file)
|
|
116
116
|
return @map unless base
|
|
@@ -121,10 +121,12 @@ module Principles
|
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
# The hashes the audit began from (before), refused unless they were found and request_id is the one
|
|
124
|
-
# printed for them and basis.
|
|
124
|
+
# printed for them and basis; a basis the answer edited is refused as that, not as a stale request (#1045).
|
|
125
125
|
#: (RequestId, CorrectionBasis, Hash[String, String]?) -> Hash[String, String]
|
|
126
126
|
def confirmed_start(request_id, basis, before)
|
|
127
|
-
|
|
127
|
+
differs = basis.request_id(id, before || {}).differs_from(request_id)
|
|
128
|
+
raise basis_edited(request_id) if differs == :handed
|
|
129
|
+
raise stale_request unless before && differs.nil?
|
|
128
130
|
|
|
129
131
|
before
|
|
130
132
|
end
|
|
@@ -144,13 +146,13 @@ module Principles
|
|
|
144
146
|
# What each member's assessment is judged on beside its text, from each member's loads: its map entry and when
|
|
145
147
|
# it loads (D49).
|
|
146
148
|
#: (Hash[String, MemberLoads]) -> MemberGrounds
|
|
147
|
-
def grounds(loads) = MemberGrounds.new(
|
|
149
|
+
def grounds(loads) = MemberGrounds.new(members, loads)
|
|
148
150
|
|
|
149
151
|
# Which members' last assessments this audit carries forward, from the principle's record now, grounds, and the
|
|
150
152
|
# question the request asks (D49).
|
|
151
153
|
#: (AuditRecord?, grounds: MemberGrounds, question: String) -> CarriedAssessments
|
|
152
154
|
def carried_assessments(record, grounds:, question:)
|
|
153
|
-
CarriedAssessments.new(record, members:
|
|
155
|
+
CarriedAssessments.new(record, members: members, judged_against: judged_against(question), now: @now,
|
|
154
156
|
grounds: grounds)
|
|
155
157
|
end
|
|
156
158
|
|
|
@@ -160,13 +162,13 @@ module Principles
|
|
|
160
162
|
def loads_to_check(loads, record = nil)
|
|
161
163
|
completed = record&.last_completed
|
|
162
164
|
LoadsToCheck.new(activation: @map.activation, loads: loads, hashes: @now,
|
|
163
|
-
accepted: completed ? completed.members.loading_accepted(
|
|
165
|
+
accepted: completed ? completed.members.loading_accepted(members) : {})
|
|
164
166
|
end
|
|
165
167
|
|
|
166
168
|
# The findings the last audit left for this one to decide (D35), from its record.
|
|
167
169
|
#: (AuditRecord?) -> PriorFindings
|
|
168
170
|
def prior_findings(record)
|
|
169
|
-
PriorFindings.new(record: record, now: @now, members:
|
|
171
|
+
PriorFindings.new(record: record, now: @now, members: members)
|
|
170
172
|
end
|
|
171
173
|
|
|
172
174
|
# The project files the dispositions say changed: each fixed member's file, then each file where a
|
|
@@ -179,20 +181,27 @@ module Principles
|
|
|
179
181
|
|
|
180
182
|
# The path of the member with member_id in the map, refused as unknown_member when no member has it (#778).
|
|
181
183
|
#: (String) -> String
|
|
182
|
-
def path_of(member_id) =
|
|
184
|
+
def path_of(member_id) = members.found(member_id).path
|
|
183
185
|
|
|
184
186
|
private
|
|
185
187
|
|
|
186
188
|
# The members as the map lists them, which say each one's id and check.
|
|
187
|
-
#: () ->
|
|
188
|
-
def
|
|
189
|
+
#: () -> PrincipleMembers
|
|
190
|
+
def members = @map.members
|
|
191
|
+
|
|
192
|
+
#: (RequestId) -> Error
|
|
193
|
+
def basis_edited(request_id)
|
|
194
|
+
Error.new("invalid_answer", "basis is not as request #{request_id} printed it",
|
|
195
|
+
"Give basis back as that request printed it; its keys may be in any order.",
|
|
196
|
+
fields: [{ "pointer" => "/basis", "problem" => "edited since it was printed" }])
|
|
197
|
+
end
|
|
189
198
|
|
|
190
199
|
#: () -> Error
|
|
191
200
|
def stale_request
|
|
192
201
|
Error.new("stale_request", "This request no longer matches #{id}: its map, a member, the commit it " \
|
|
193
202
|
"was based on, or what says when a listed member loads and how big it is " \
|
|
194
203
|
"(project settings, frontmatter or a listed file), has changed since it was " \
|
|
195
|
-
"printed",
|
|
204
|
+
"printed, or another release or checkout of principles printed it",
|
|
196
205
|
"Start the audit again and answer the new request: #{Error::EXECUTABLE} start-audit #{id}")
|
|
197
206
|
end
|
|
198
207
|
end
|
|
@@ -7,6 +7,7 @@ require_relative "decided_prior_findings"
|
|
|
7
7
|
require_relative "open_finding"
|
|
8
8
|
require_relative "principles_package"
|
|
9
9
|
require_relative "recorded_findings"
|
|
10
|
+
require_relative "record_format"
|
|
10
11
|
require_relative "recorded_members"
|
|
11
12
|
require_relative "json_digest"
|
|
12
13
|
require_relative "write_up_repoint"
|
|
@@ -51,6 +52,11 @@ module Principles
|
|
|
51
52
|
@fields
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
# The record as this copy writes it, as RecordFormat stamps it. Only a write stamps it, so a record read without
|
|
56
|
+
# a format keeps its revision (D85).
|
|
57
|
+
#: () -> Hash[String, untyped]
|
|
58
|
+
def stamped = RecordFormat.new(@fields).stamped
|
|
59
|
+
|
|
54
60
|
# A digest of the whole record. A correction carries the last completed record's from when its request was
|
|
55
61
|
# printed, so it is refused once that record changed (#646). A formatter that only reorders its keys changes
|
|
56
62
|
# neither what the record says nor its revision, as same_as? already compares it (#656).
|
|
@@ -68,15 +74,16 @@ module Principles
|
|
|
68
74
|
@fields["base_members"]
|
|
69
75
|
end
|
|
70
76
|
|
|
71
|
-
# Whether other says what this record says, apart from when it and its assessments were made
|
|
77
|
+
# Whether other says what this record says, apart from when it and its assessments were made and the format
|
|
78
|
+
# stamped when it is written.
|
|
72
79
|
#: (AuditRecord?) -> bool
|
|
73
80
|
def same_as?(other)
|
|
74
81
|
!other.nil? && other.undated == undated
|
|
75
82
|
end
|
|
76
83
|
|
|
77
|
-
# What this record says, without when it and each of its assessments were made.
|
|
84
|
+
# What this record says as it is written, without when it and each of its assessments were made.
|
|
78
85
|
#: () -> Hash[String, untyped]
|
|
79
|
-
def undated =
|
|
86
|
+
def undated = stamped.except("audited_at").merge("members" => members.undated)
|
|
80
87
|
|
|
81
88
|
# The commit the audit began from, or nil outside git.
|
|
82
89
|
#: () -> String?
|