principles 0.0.5 → 0.0.7
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/after_commit_hook_options.rb +4 -1
- data/lib/principles/cli.rb +9 -0
- data/lib/principles/command_line.rb +31 -30
- data/lib/principles/command_routes.rb +9 -3
- data/lib/principles/controllers/acknowledgement.rb +82 -95
- data/lib/principles/controllers/answer.rb +14 -11
- data/lib/principles/controllers/assessment.rb +27 -24
- data/lib/principles/controllers/audit.rb +24 -4
- data/lib/principles/controllers/audit_completion.rb +10 -4
- data/lib/principles/controllers/command.rb +2 -2
- data/lib/principles/controllers/correction.rb +16 -7
- data/lib/principles/controllers/full_audit_request.rb +8 -3
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +3 -22
- data/lib/principles/controllers/mapping.rb +9 -1
- data/lib/principles/controllers/member_acknowledgement.rb +137 -0
- data/lib/principles/controllers/member_addition.rb +65 -0
- data/lib/principles/controllers/member_entries.rb +6 -24
- data/lib/principles/controllers/member_problems_report.rb +33 -25
- data/lib/principles/controllers/members_to_assess.rb +1 -1
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +5 -2
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +86 -25
- data/lib/principles/data/committed_tree.rb +84 -0
- data/lib/principles/data/first_parent_log.rb +48 -0
- data/lib/principles/data/first_parent_range.rb +122 -0
- data/lib/principles/data/git_command.rb +37 -0
- data/lib/principles/data/guidance_search_paths_file.rb +107 -0
- data/lib/principles/data/map_files.rb +35 -10
- data/lib/principles/data/principles_directory.rb +40 -0
- data/lib/principles/data/principles_subfolder.rb +39 -16
- data/lib/principles/data/project_files.rb +11 -3
- data/lib/principles/data/repository.rb +55 -29
- data/lib/principles/data/requested_candidate_files.rb +43 -0
- data/lib/principles/data/running_version.rb +3 -5
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +6 -6
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +88 -0
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -63
- data/lib/principles/data/schemas/assessment-answer.schema.json +15 -1
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +12 -54
- data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
- data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
- data/lib/principles/data/verified_head.rb +162 -0
- data/lib/principles/invocation_options.rb +5 -4
- data/lib/principles/list_open_findings_options.rb +23 -0
- data/lib/principles/models/acknowledged_check.rb +94 -0
- data/lib/principles/models/acknowledgement.rb +40 -36
- data/lib/principles/models/acknowledgement_left_as_printed.rb +72 -0
- data/lib/principles/models/acknowledgements.rb +99 -0
- data/lib/principles/models/answered_time.rb +9 -0
- data/lib/principles/models/assessment_report.rb +13 -13
- data/lib/principles/models/audit.rb +17 -4
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +9 -0
- data/lib/principles/models/audit_records.rb +34 -8
- data/lib/principles/models/candidate_files.rb +17 -6
- data/lib/principles/models/candidate_inventory.rb +51 -7
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/check_since_last_audit.rb +4 -8
- data/lib/principles/models/correction_basis.rb +14 -5
- data/lib/principles/models/declared_map_changes.rb +25 -9
- data/lib/principles/models/declared_member_removals.rb +75 -0
- data/lib/principles/models/disposition.rb +4 -2
- data/lib/principles/models/fix_only_fields.rb +12 -0
- data/lib/principles/models/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/list_member_problems_check.rb +80 -0
- data/lib/principles/models/listed_members.rb +49 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_decision.rb +17 -8
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/loads_to_check.rb +0 -1
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +11 -2
- data/lib/principles/models/member_file.rb +20 -71
- data/lib/principles/models/member_history.rb +7 -5
- data/lib/principles/models/member_loading_scopes.rb +49 -0
- data/lib/principles/models/member_loads.rb +4 -0
- data/lib/principles/models/member_mapping_run.rb +30 -0
- data/lib/principles/models/member_moves.rb +4 -0
- data/lib/principles/models/member_problems.rb +57 -29
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +9 -11
- data/lib/principles/models/member_sighting.rb +5 -8
- data/lib/principles/models/member_snapshots.rb +14 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
- data/lib/principles/models/meta_principle.rb +14 -0
- data/lib/principles/models/missing_files.rb +2 -2
- data/lib/principles/models/other_templates_placeholders.rb +1 -1
- data/lib/principles/models/outline_budget.rb +29 -14
- data/lib/principles/models/principle.rb +14 -7
- data/lib/principles/models/principle_file_revision.rb +48 -0
- data/lib/principles/models/principle_history.rb +46 -19
- data/lib/principles/models/principle_lineage.rb +118 -0
- data/lib/principles/models/principle_map_revision.rb +39 -0
- data/lib/principles/models/principle_mapping_history.rb +132 -0
- data/lib/principles/models/principle_members.rb +14 -0
- data/lib/principles/models/principle_predecessor.rb +45 -0
- data/lib/principles/models/principle_publication.rb +177 -0
- data/lib/principles/models/principle_revision.rb +104 -0
- data/lib/principles/models/problem_report.rb +36 -9
- data/lib/principles/models/project.rb +47 -30
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/record_format.rb +6 -0
- data/lib/principles/models/reported_check.rb +16 -12
- data/lib/principles/models/request_id.rb +1 -1
- data/lib/principles/models/sent_answer.rb +35 -5
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/positional_arguments.rb +38 -0
- data/lib/principles/session_start_options.rb +3 -3
- data/lib/principles/start_audit_options.rb +10 -2
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +54 -16
- data/lib/principles/views/added_member.rb +41 -0
- data/lib/principles/views/answered_request.rb +21 -0
- data/lib/principles/views/assessed_members.rb +26 -5
- data/lib/principles/views/assessment_request.rb +24 -4
- data/lib/principles/views/audit_result.rb +30 -27
- data/lib/principles/views/candidate_files_result.rb +56 -12
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_result_template.rb +18 -17
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +38 -10
- data/lib/principles/views/findings_result.rb +21 -0
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/invocation.rb +19 -4
- data/lib/principles/views/json_with_entries_on_lines.rb +12 -4
- data/lib/principles/views/loads_to_check_result.rb +3 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +22 -42
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +2 -1
- data/lib/principles/views/member_repairs.rb +2 -1
- data/lib/principles/views/member_row.rb +61 -0
- data/lib/principles/views/members_a_commit_changed.rb +2 -1
- data/lib/principles/views/members_with_no_baseline.rb +8 -1
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +37 -21
- data/lib/principles/views/open_findings_line.rb +2 -1
- data/lib/principles/views/principle_read_result.rb +4 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/problem_lines.rb +50 -45
- data/lib/principles/views/problem_result.rb +59 -25
- data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -3
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -43
- data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -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 +5 -3
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +12 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +4 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +37 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +20 -19
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +33 -7
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +10 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +1 -1
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
- metadata +67 -4
- data/lib/principles/models/candidate_listing.rb +0 -41
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "audit_record"
|
|
6
|
+
require_relative "request_id"
|
|
7
|
+
require_relative "sent_answer"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
|
+
module Models
|
|
12
|
+
# Several members of one principle acknowledged in one request and one answer (#1169): each member's entry is
|
|
13
|
+
# judged as its own one-member answer would be, and the answer is accepted for every member, in one record, or
|
|
14
|
+
# refused for all, so no baseline moves unless each does.
|
|
15
|
+
class Acknowledgements
|
|
16
|
+
PHASE = "acknowledgements"
|
|
17
|
+
|
|
18
|
+
# The JSON pointer to member_id's entry in an answer's members.
|
|
19
|
+
#: (String) -> String
|
|
20
|
+
def self.entry_pointer(member_id) = "/members/#{member_id.gsub("~", "~0").gsub("/", "~1")}"
|
|
21
|
+
|
|
22
|
+
# The members as members names them, each id beside its one-member request's id, in the order named; refused
|
|
23
|
+
# when one is named twice, which the answer would then judge once.
|
|
24
|
+
#: (principle_id: String, members: Array[[String, RequestId]]) -> Acknowledgements
|
|
25
|
+
def self.of(principle_id:, members:)
|
|
26
|
+
ids = members.map(&:first)
|
|
27
|
+
twice = ids.find { |id| ids.count(id) > 1 }
|
|
28
|
+
if twice
|
|
29
|
+
raise Error.new("invalid_answer", "#{SentAnswer::NAMED}'s basis names #{twice} twice", SentAnswer::REPAIR,
|
|
30
|
+
fields: [{ "pointer" => "/basis/member_ids", "problem" => "names #{twice} twice" }])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
new(principle_id:, requests: members.to_h)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# requests holds each member's one-member request id under the member's id, in the order they were named.
|
|
37
|
+
#: (principle_id: String, requests: Hash[String, RequestId]) -> void
|
|
38
|
+
def initialize(principle_id:, requests:)
|
|
39
|
+
@principle_id = principle_id
|
|
40
|
+
@requests = requests
|
|
41
|
+
freeze
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The request's id: each member's one-member request id, sorted, so it depends on which members it asks
|
|
45
|
+
# about and on everything each of their requests depends on, not on the order they were named in.
|
|
46
|
+
#: () -> RequestId
|
|
47
|
+
def request_id
|
|
48
|
+
RequestId.for(principle_id: @principle_id, phase: PHASE, parts: @requests.values.map(&:to_s).sort)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The record with every member's baseline moved, once the answer holds an entry for each member and no other:
|
|
52
|
+
# accept is given each member's id, its entry and the record the members before it changed, nil for the first,
|
|
53
|
+
# and gives the record with that member's acknowledgement in it too, or refuses the whole answer.
|
|
54
|
+
#: (untyped) { (String, untyped, AuditRecord?) -> AuditRecord } -> AuditRecord
|
|
55
|
+
def accepted(answer, &accept)
|
|
56
|
+
entries = answer.fetch("members")
|
|
57
|
+
refuse_unmatched(entries.keys)
|
|
58
|
+
ids = @requests.keys
|
|
59
|
+
first = ids.fetch(0)
|
|
60
|
+
ids.drop(1).reduce(in_entry(first) { accept.call(first, entries.fetch(first), nil) }) do |record, id|
|
|
61
|
+
in_entry(id) { accept.call(id, entries.fetch(id), record) }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
# What the block gives for member_id's entry, a refusal of a field in it pointing at that field in the entry,
|
|
68
|
+
# since a member's acknowledgement points from the entry's root as an answer to one member does (#1276).
|
|
69
|
+
#: (String) { () -> AuditRecord } -> AuditRecord
|
|
70
|
+
def in_entry(member_id, &)
|
|
71
|
+
yield
|
|
72
|
+
rescue Error => e
|
|
73
|
+
fields = e.payload["fields"]
|
|
74
|
+
raise unless fields
|
|
75
|
+
|
|
76
|
+
entry = Acknowledgements.entry_pointer(member_id)
|
|
77
|
+
raise e.including("fields" => fields.map { it.merge("pointer" => entry + it.fetch("pointer")) })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Refuses the answer whole unless its members hold an entry for each member its basis names, and for no other.
|
|
81
|
+
#: (Array[String]) -> void
|
|
82
|
+
def refuse_unmatched(answered)
|
|
83
|
+
missing = (@requests.keys - answered).map { problem(it, "is required, since basis.member_ids names it") }
|
|
84
|
+
extra = (answered - @requests.keys).map { problem(it, "is not a member basis.member_ids names") }
|
|
85
|
+
fields = missing + extra
|
|
86
|
+
return if fields.empty?
|
|
87
|
+
|
|
88
|
+
raise Error.new("invalid_answer", "#{SentAnswer::NAMED} does not answer each member it names, so no member " \
|
|
89
|
+
"is acknowledged", SentAnswer::REPAIR, fields:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# The problem with the answer's entry for member_id, at its JSON pointer.
|
|
93
|
+
#: (String, String) -> Hash[String, String]
|
|
94
|
+
def problem(member_id, text)
|
|
95
|
+
{ "pointer" => Acknowledgements.entry_pointer(member_id), "problem" => text }
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -48,6 +48,15 @@ module Principles
|
|
|
48
48
|
nil
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
# It in audited_at's form when it names a time to the second exactly, with any UTC offset, so a clock's own
|
|
52
|
+
# offset is the same instant (#1187); otherwise as given, a date alone included, for its sighting to refuse.
|
|
53
|
+
#: () -> untyped
|
|
54
|
+
def in_audited_at_form
|
|
55
|
+
return @value if date_alone?
|
|
56
|
+
|
|
57
|
+
exact_utc || @value
|
|
58
|
+
end
|
|
59
|
+
|
|
51
60
|
# Whether it is later than time, both UTC times in audited_at's form: a sighting is made before the answer that
|
|
52
61
|
# reports it (#699), so a repair never prints one later (#801).
|
|
53
62
|
#: (String) -> bool
|
|
@@ -11,8 +11,8 @@ module Principles
|
|
|
11
11
|
# What an assessment reported beyond its findings, which its audit's record and commit carry: by member id, the
|
|
12
12
|
# fields of each member's record entry, such as its assessment (D49) and its check's result (D30), and the paths
|
|
13
13
|
# its recent decision cites, which the record does not keep but the completed audit asks to commit when they
|
|
14
|
-
# differ from HEAD (#860).
|
|
15
|
-
# the one owner of how it is carried.
|
|
14
|
+
# differ from HEAD (#860). The open record keeps it for the correction to read back, and the correction's basis
|
|
15
|
+
# carries only those paths and the record's digest (D87); this is the one owner of how it is carried.
|
|
16
16
|
class AssessmentReport
|
|
17
17
|
# The report of the answer assessed, each assessment it makes, rather than carries, with the grounds it was
|
|
18
18
|
# judged on (D49).
|
|
@@ -25,12 +25,14 @@ module Principles
|
|
|
25
25
|
new(fields, recent_decision_paths: assessed.recent_decision_paths)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
# The report
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
# The report an open record keeps for its correction to read back: each member's entry without the hash and key
|
|
29
|
+
# the record adds, under the ids of any members moves moved, with the recent decision's paths, which the basis
|
|
30
|
+
# carries (D87). A completed record read back so gives the report that completed it, for an identical retry
|
|
31
|
+
# (D24).
|
|
32
|
+
#: (AuditRecord, CorrectionBasis, MemberMoves) -> AssessmentReport
|
|
33
|
+
def self.recorded(record, basis, moves)
|
|
34
|
+
fields = record.to_h.fetch("members").transform_values { |entry| entry.except("sha256", "key") }
|
|
35
|
+
new(moves.hashes(fields), recent_decision_paths: basis.to_h.fetch("recent_decision_paths", []))
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
# The paths the recent decision cites as evidence.
|
|
@@ -49,12 +51,10 @@ module Principles
|
|
|
49
51
|
#: (String) -> Hash[String, untyped]
|
|
50
52
|
def entry_fields_of(id) = @entry_fields.fetch(id, {})
|
|
51
53
|
|
|
52
|
-
#
|
|
54
|
+
# What a correction basis carries of it: the recent decision's paths, which no record keeps, when there are any.
|
|
55
|
+
# The open record keeps the rest (D87).
|
|
53
56
|
#: () -> Hash[String, untyped]
|
|
54
|
-
def basis_fields
|
|
55
|
-
{ "entry_fields" => @entry_fields, "recent_decision_paths" => @recent_decision_paths }
|
|
56
|
-
.reject { |_key, value| value.empty? }
|
|
57
|
-
end
|
|
57
|
+
def basis_fields = @recent_decision_paths.empty? ? {} : { "recent_decision_paths" => @recent_decision_paths }
|
|
58
58
|
|
|
59
59
|
NONE = new #: AssessmentReport
|
|
60
60
|
end
|
|
@@ -101,10 +101,23 @@ module Principles
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
# What the audit a correction's basis names began from: its base commit, each member's hash then
|
|
104
|
-
# (before), and the assessment's report
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
# (before), and the assessment's report record keeps, under the ids of any moved members (D87). The record is
|
|
105
|
+
# the open one the basis was printed with, or a completed one, which only an identical retry may complete
|
|
106
|
+
# again (D24); none, or another open one, refuses the correction as stale.
|
|
107
|
+
#: (CorrectionBasis, Hash[String, String], MemberMoves, AuditRecord?) -> AuditStart
|
|
108
|
+
def resumed(basis, before, moves, record)
|
|
109
|
+
raise stale_request unless record && (record.completed? || basis.printed_with?(record))
|
|
110
|
+
|
|
111
|
+
started(basis.base_commit, before, AssessmentReport.recorded(record, basis, moves))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Refuses, as stale, a correction read back from a completed record, as resumed allows, unless completing it
|
|
115
|
+
# writes nothing: only an identical retry of the correction that completed it (D24) may read one, never an
|
|
116
|
+
# earlier audit's record that git restore put back in place of the open one (D87). An audit that read no record
|
|
117
|
+
# back, one completed from its assessment, gives none.
|
|
118
|
+
#: (AuditRecord?, Array[AuditRecord]) -> void
|
|
119
|
+
def confirm_read_back(record, changes)
|
|
120
|
+
raise stale_request if record&.completed? && !changes.empty?
|
|
108
121
|
end
|
|
109
122
|
|
|
110
123
|
# The map the audit began from: the current one when it is unchanged and the answer declares no change; or,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
module Models
|
|
8
|
+
# A current audit entry protects its map from unconfirmed removal, whether the entry is readable or not.
|
|
9
|
+
class AuditEntryProtectingMap
|
|
10
|
+
#: (String, String) -> void
|
|
11
|
+
def initialize(id, path)
|
|
12
|
+
@id = id.dup.freeze #: String
|
|
13
|
+
@path = path.dup.freeze #: String
|
|
14
|
+
freeze
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#: () -> Error
|
|
18
|
+
def refusal
|
|
19
|
+
Error.new("principle_has_audit_record", "#{@id} has a current audit entry",
|
|
20
|
+
"Removing this map deactivates it in routine reports; retained findings remain unresolved. " \
|
|
21
|
+
"Keep it unless that is intended.\n" \
|
|
22
|
+
"To inspect a readable record: #{Error::EXECUTABLE} show-audit #{@id}\n" \
|
|
23
|
+
"To deactivate only the map, retaining its audit entry: " \
|
|
24
|
+
"#{Error::EXECUTABLE} remove-principle #{@id} --confirm", @path)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -68,6 +68,11 @@ module Principles
|
|
|
68
68
|
@fields.fetch("principle_id")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# A digest of what the record says of each member, apart from when its assessment was made: an open record's
|
|
72
|
+
# assessment, which its correction's basis carries so the correction is refused once the record changed (D87).
|
|
73
|
+
#: () -> String
|
|
74
|
+
def assessment_digest = JsonDigest.new(members.undated).to_s
|
|
75
|
+
|
|
71
76
|
# The hashes the audit began from, kept outside git only.
|
|
72
77
|
#: () -> Hash[String, String]?
|
|
73
78
|
def base_members
|
|
@@ -98,6 +103,10 @@ module Principles
|
|
|
98
103
|
"map_changed" => @fields["map_version"] != map_version }
|
|
99
104
|
end
|
|
100
105
|
|
|
106
|
+
# Completion certainty for optional mapping feedback; the record owns its format and kept history.
|
|
107
|
+
#: () -> bool
|
|
108
|
+
def known_no_completed_audit? = !RecordFormat.new(@fields).newer? && last_completed.nil?
|
|
109
|
+
|
|
101
110
|
# Whether the audit this record describes completed, rather than being left open outside git.
|
|
102
111
|
#: () -> bool
|
|
103
112
|
def completed?
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
4
6
|
require_relative "../error"
|
|
5
7
|
require_relative "../data/audit_files"
|
|
6
8
|
require_relative "audit_record"
|
|
9
|
+
require_relative "audit_entry_protecting_map"
|
|
7
10
|
require_relative "member_hashes_as_written"
|
|
8
11
|
require_relative "recorded_hashes"
|
|
9
12
|
require_relative "project_history"
|
|
@@ -39,6 +42,27 @@ module Principles
|
|
|
39
42
|
fields && AuditRecord.new(fields)
|
|
40
43
|
end
|
|
41
44
|
|
|
45
|
+
# One exact historical selection, without a routed lookup or a format stamp.
|
|
46
|
+
#: (String, String) -> AuditRecord
|
|
47
|
+
def parsed_history(id, text)
|
|
48
|
+
fields = @files.parse(id, text) { refuse_unreadable(it, file(id)) }
|
|
49
|
+
refuse_unreadable(fields, file(id))
|
|
50
|
+
record = AuditRecord.new(JSON.parse(JSON.generate(fields), freeze: true))
|
|
51
|
+
return record if record.principle_id == id && record.completed?
|
|
52
|
+
|
|
53
|
+
raise Error.new("invalid_audit_record", "#{file(id)} is not a completed record of #{id}",
|
|
54
|
+
"Preserve this record and inspect its identity and status before changing an ID.", file(id))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Optional mapping feedback: a missing record is known absence; unreadable records leave this unknown.
|
|
58
|
+
#: (String) -> bool
|
|
59
|
+
def known_no_completed_audit?(id)
|
|
60
|
+
audit = find(id) or return true
|
|
61
|
+
audit.known_no_completed_audit?
|
|
62
|
+
rescue Error
|
|
63
|
+
false
|
|
64
|
+
end
|
|
65
|
+
|
|
42
66
|
# The findings id's record leaves open: none when it has no record, and none when its record cannot be read,
|
|
43
67
|
# which list-member-problems reports, so a command reading other principles' findings beside its own is not
|
|
44
68
|
# refused for theirs (#772).
|
|
@@ -61,8 +85,8 @@ module Principles
|
|
|
61
85
|
# when it has none, is not newer, or is refused for another reason, which reading it reports (D85).
|
|
62
86
|
#: (String) -> RecordFormat?
|
|
63
87
|
def newer_format(id)
|
|
64
|
-
fields = @files.read(id) { |raw| return newer_of(raw) }
|
|
65
|
-
fields && newer_of(fields)
|
|
88
|
+
fields = @files.read(id) { |raw| return RecordFormat.newer_of(raw) }
|
|
89
|
+
fields && RecordFormat.newer_of(fields)
|
|
66
90
|
rescue Error
|
|
67
91
|
nil
|
|
68
92
|
end
|
|
@@ -110,6 +134,14 @@ module Principles
|
|
|
110
134
|
@files.exist?(id)
|
|
111
135
|
end
|
|
112
136
|
|
|
137
|
+
#: (String, ?confirmed: bool) -> void
|
|
138
|
+
def refuse_map_removal(id, confirmed: false)
|
|
139
|
+
return unless @files.entry?(id)
|
|
140
|
+
return if confirmed
|
|
141
|
+
|
|
142
|
+
raise AuditEntryProtectingMap.new(id, file(id)).refusal
|
|
143
|
+
end
|
|
144
|
+
|
|
113
145
|
# The record as a change to write, unless it says what the record on disk says, apart from when.
|
|
114
146
|
#: (AuditRecord) -> Array[AuditRecord]
|
|
115
147
|
def changes(record)
|
|
@@ -159,12 +191,6 @@ module Principles
|
|
|
159
191
|
MemberHashesAsWritten.new(nil)
|
|
160
192
|
end
|
|
161
193
|
|
|
162
|
-
#: (untyped) -> RecordFormat?
|
|
163
|
-
def newer_of(fields)
|
|
164
|
-
format = RecordFormat.new(fields) if fields.is_a?(Hash)
|
|
165
|
-
format if format&.newer?
|
|
166
|
-
end
|
|
167
|
-
|
|
168
194
|
# Refuses fields, a record at file the schema refused, as one a later copy wrote when its format says so, so
|
|
169
195
|
# its repair is never to repair or restore a record that is not broken (D85, V3).
|
|
170
196
|
#: (untyped, String) -> void
|
|
@@ -10,7 +10,8 @@ module Principles
|
|
|
10
10
|
# skill's templates, references and examples once filled most of a 10KB inventory (alpha 011
|
|
11
11
|
# friction 2). So Markdown files and harness settings are listed one by one, except inside a skill,
|
|
12
12
|
# where only SKILL.md, the file the harness loads, is listed. Every other file is counted under its
|
|
13
|
-
# directory.
|
|
13
|
+
# directory. Explicit selections are always named, including skill references and non-Markdown text files.
|
|
14
|
+
# The agent still sees where every file is, and decides what to read.
|
|
14
15
|
class CandidateFiles
|
|
15
16
|
# A file a harness reads as settings, listed by name like guidance.
|
|
16
17
|
SETTINGS = %r{(?:\A|/)\.claude/settings[^/]*\.json\z}
|
|
@@ -19,23 +20,25 @@ module Principles
|
|
|
19
20
|
IN_SKILL = %r{(?:\A|/)\.claude/skills/[^/]+/}
|
|
20
21
|
SKILL_ENTRY = %r{(?:\A|/)\.claude/skills/[^/]+/SKILL\.md\z}
|
|
21
22
|
|
|
22
|
-
#: (Array[Hash[String, untyped]], text_of: ^(String) -> String) -> void
|
|
23
|
-
def initialize(files, text_of:)
|
|
23
|
+
#: (Array[Hash[String, untyped]], text_of: ^(String) -> String, ?selected: Array[String]) -> void
|
|
24
|
+
def initialize(files, text_of:, selected: [])
|
|
24
25
|
@files = files #: Array[Hash[String, untyped]]
|
|
25
26
|
@text_of = text_of
|
|
27
|
+
@selected = selected
|
|
26
28
|
freeze
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
# The inventory's files, each Markdown one the survey reads with its outline, the other files counted by
|
|
30
32
|
# directory, and those test-data hints that name a listed file, whose files the survey leaves out unread (#1153).
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
# The files changed names, which a range of commits changed, list first, each marked changed_in_range (#1171).
|
|
34
|
+
#: (Array[Hash[String, untyped]], ?changed: Array[String]) -> Hash[String, untyped]
|
|
35
|
+
def listing(test_data_hints, changed: [])
|
|
33
36
|
outlines = outlines(test_data_hints)
|
|
34
37
|
files = listed.map do |file|
|
|
35
38
|
outline = outlines[file.fetch("path")]
|
|
36
39
|
outline ? file.merge(outline.to_h) : file
|
|
37
40
|
end
|
|
38
|
-
{ "files" => files,
|
|
41
|
+
{ "files" => changed_first(files, changed),
|
|
39
42
|
"other_files_by_directory" => other_files_by_directory, "possibly_test_data" => hints(test_data_hints) }
|
|
40
43
|
end
|
|
41
44
|
|
|
@@ -65,6 +68,13 @@ module Principles
|
|
|
65
68
|
|
|
66
69
|
private
|
|
67
70
|
|
|
71
|
+
# files with those changed names first, each marked changed_in_range, and the rest after, each in its order.
|
|
72
|
+
#: (Array[Hash[String, untyped]], Array[String]) -> Array[Hash[String, untyped]]
|
|
73
|
+
def changed_first(files, changed)
|
|
74
|
+
in_range, rest = files.partition { |file| changed.include?(file.fetch("path")) }
|
|
75
|
+
in_range.map { |file| file.merge("changed_in_range" => true) } + rest
|
|
76
|
+
end
|
|
77
|
+
|
|
68
78
|
# The test-data hints that name a listed file.
|
|
69
79
|
#: (Array[Hash[String, untyped]]) -> Array[Hash[String, untyped]]
|
|
70
80
|
def hints(test_data_hints)
|
|
@@ -80,6 +90,7 @@ module Principles
|
|
|
80
90
|
|
|
81
91
|
#: (String) -> bool
|
|
82
92
|
def named?(path)
|
|
93
|
+
return true if @selected.include?(path)
|
|
83
94
|
return path.match?(SKILL_ENTRY) if path.match?(IN_SKILL)
|
|
84
95
|
|
|
85
96
|
path.match?(MARKDOWN) || path.match?(SETTINGS)
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
4
|
+
require_relative "../data/project_files"
|
|
5
|
+
require_relative "candidate_files"
|
|
6
|
+
require_relative "ignored_candidates"
|
|
5
7
|
require_relative "outline_budget"
|
|
6
8
|
require_relative "project_history"
|
|
9
|
+
require_relative "survey_search_paths"
|
|
7
10
|
|
|
8
11
|
module Principles
|
|
9
12
|
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
10
13
|
module Models
|
|
11
|
-
# What list-candidate-files found: the inventory of candidate files as
|
|
14
|
+
# What list-candidate-files found: the inventory of candidate files as it lists them, and in git
|
|
12
15
|
# which of them, or of the files their links lead to, git does not track. Each list that names a file is
|
|
13
16
|
# something the agent asks the project's owner about before mapping, and only those are asked, since asks for
|
|
14
17
|
# empty lists hid the one that applied (#405).
|
|
@@ -20,17 +23,58 @@ module Principles
|
|
|
20
23
|
# longer one would bury the ask, so the agent reads it from its list instead (#412).
|
|
21
24
|
NAMED_INLINE_AT_MOST = 3
|
|
22
25
|
|
|
26
|
+
# What list-candidate-files finds in the project's files, each listed file's text read from them. After a commit,
|
|
27
|
+
# a full sha, the files its range changed come first, the Markdown ones outside the places hosts load listed too
|
|
28
|
+
# (#1171). The Markdown files not yet committed are named apart then, under uncommitted, since no commit in the
|
|
29
|
+
# range holds them.
|
|
30
|
+
#: (Data::ProjectFiles, ProjectHistory, search_paths: SurveySearchPaths, ?after: String?,
|
|
31
|
+
#| ?mapped: Array[String]) -> CandidateInventory
|
|
32
|
+
def self.read(files, history, search_paths:, after: nil, mapped: [])
|
|
33
|
+
changed = after ? history.changed_after(after) : []
|
|
34
|
+
inventory = files.inventory(also: changed.grep(CandidateFiles::MARKDOWN) | (changed & mapped),
|
|
35
|
+
matching: search_paths.globs).merge(search_paths.recorded_listing)
|
|
36
|
+
inventory = inventory.merge("uncommitted" => uncommitted_markdown(history)) if after
|
|
37
|
+
found(inventory, history, changed:) { |path| files.read_text(path) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# An explicit file request uses the survey's entries and budget without its broad search.
|
|
41
|
+
#: (Data::ProjectFiles, ProjectHistory, paths: Array[String]) -> CandidateInventory
|
|
42
|
+
def self.requested(files, history, paths:)
|
|
43
|
+
found(files.requested_inventory(paths), history) { |path| files.read_text(path) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The Markdown files that differ from HEAD or are untracked, ignored ones aside.
|
|
47
|
+
#: (ProjectHistory) -> Array[String]
|
|
48
|
+
def self.uncommitted_markdown(history) = (history.uncommitted_outside([]) || []).grep(CandidateFiles::MARKDOWN)
|
|
49
|
+
private_class_method :uncommitted_markdown
|
|
50
|
+
|
|
23
51
|
# What the project's inventory lists, and which listed files, or files their links lead to, history says
|
|
24
52
|
# git does not track.
|
|
25
53
|
# Each listed file's text, which its outline is read from, is what the block gives for its path.
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
# changed names the files a range of commits changed, which list first, marked (#1171).
|
|
55
|
+
#: (Hash[String, untyped], ProjectHistory, ?changed: Array[String]) { (String) -> String } -> CandidateInventory
|
|
56
|
+
def self.found(inventory, history, changed: [], &text_of)
|
|
28
57
|
texts = {} #: Hash[String, String]
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
files = CandidateFiles.new(inventory.fetch("files"), selected: inventory.fetch("selected_files", []),
|
|
59
|
+
text_of: ->(path) { texts[path] ||= text_of.call(path) })
|
|
60
|
+
hints = inventory.fetch("possibly_test_data")
|
|
61
|
+
listed = listed(inventory, files.listing(hints, changed:))
|
|
31
62
|
new(listed, untracked: history.untracked(listed.fetch("files").map { it.fetch("path") }),
|
|
32
|
-
outlines:
|
|
63
|
+
outlines: files.outlines(hints))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# The inventory as list-candidate-files lists it: the instruction files agent hosts load by convention, the other
|
|
67
|
+
# files counted by directory, the listed files that look like test data, and in git the ignored ones, unread, each
|
|
68
|
+
# folder git ignores counted once.
|
|
69
|
+
#: (Hash[String, untyped], Hash[String, untyped]) -> Hash[String, untyped]
|
|
70
|
+
def self.listed(inventory, files_listing)
|
|
71
|
+
listed = inventory.except("ignored", "ignored_ancestor_folders", "selected_files").merge(files_listing)
|
|
72
|
+
return listed unless inventory.key?("ignored")
|
|
73
|
+
|
|
74
|
+
listed.merge(IgnoredCandidates.new(paths: inventory.fetch("ignored"),
|
|
75
|
+
folders: inventory.fetch("ignored_ancestor_folders")).listing)
|
|
33
76
|
end
|
|
77
|
+
private_class_method :listed
|
|
34
78
|
|
|
35
79
|
# The listing, as list-candidate-files prints it.
|
|
36
80
|
#: Hash[String, untyped]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../data/repository"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
|
+
module Models
|
|
9
|
+
# The commit first read by one command, including a captured absence. Later history reads share this baseline.
|
|
10
|
+
class CapturedHead
|
|
11
|
+
#: (Data::Repository) -> void
|
|
12
|
+
def initialize(repository)
|
|
13
|
+
@repository = repository
|
|
14
|
+
@commit = nil #: String?
|
|
15
|
+
@read = false #: bool
|
|
16
|
+
@verified = nil #: Data::VerifiedHead?
|
|
17
|
+
@ranges = {} #: Hash[[String?, String], Data::FirstParentRange]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#: () -> String?
|
|
21
|
+
def commit
|
|
22
|
+
return @commit if @read
|
|
23
|
+
|
|
24
|
+
@read = true
|
|
25
|
+
@commit = (@repository.head if @repository.inside?)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Permission checks share the command's baseline, refusing disagreement with a prior best-effort read.
|
|
29
|
+
#: (String) -> bool
|
|
30
|
+
def entry?(path) = verified.entry?(path)
|
|
31
|
+
|
|
32
|
+
#: (String, String) -> bool
|
|
33
|
+
def entry_at?(revision, path) = verified.entry_at?(revision, path)
|
|
34
|
+
|
|
35
|
+
#: (String, String) -> Hash[String, String]?
|
|
36
|
+
def raw_entry_at(revision, path) = verified.raw_entry_at(revision, path)
|
|
37
|
+
|
|
38
|
+
# Cache constructed values by owned coordinates; each value certifies its span lazily when queried.
|
|
39
|
+
#: (String?, through: String) -> Data::FirstParentRange
|
|
40
|
+
def first_parent_range(base, through:)
|
|
41
|
+
captured = verified
|
|
42
|
+
lower = base&.dup&.freeze
|
|
43
|
+
upper = through.dup.freeze
|
|
44
|
+
key = [lower, upper].freeze
|
|
45
|
+
@ranges[key] ||= captured.first_parent_range(lower, through: upper)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#: (String) -> String?
|
|
49
|
+
def first_parent_of(revision) = verified.first_parent_of(revision)
|
|
50
|
+
|
|
51
|
+
#: (String, Array[String]) -> Array[String]
|
|
52
|
+
def commits_touching_since(base, paths) = verified.commits_touching_since(base, paths)
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
#: () -> Data::VerifiedHead
|
|
57
|
+
def verified
|
|
58
|
+
return @verified if @verified
|
|
59
|
+
|
|
60
|
+
captured = @repository.verified_head
|
|
61
|
+
revision = captured.commit
|
|
62
|
+
if @read && @commit != revision
|
|
63
|
+
raise Error.new("git_history_unavailable", "HEAD changed after this command captured its history",
|
|
64
|
+
"Stop concurrent Git writers and retry this command. No map was created or removed.")
|
|
65
|
+
end
|
|
66
|
+
@commit = revision
|
|
67
|
+
@read = true
|
|
68
|
+
@verified = captured
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -5,8 +5,6 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "audit_record"
|
|
6
6
|
require_relative "member"
|
|
7
7
|
require_relative "principle_history"
|
|
8
|
-
require_relative "mapped_principles"
|
|
9
|
-
require_relative "project_history"
|
|
10
8
|
|
|
11
9
|
module Principles
|
|
12
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -16,11 +14,9 @@ module Principles
|
|
|
16
14
|
# committed map, and the audit asks the agent to run it, so a check no audit has seen needs a review
|
|
17
15
|
# first (#227). This tool states the fact; the review is the agent's step.
|
|
18
16
|
class CheckSinceLastAudit
|
|
19
|
-
#: (
|
|
20
|
-
def initialize(
|
|
21
|
-
@
|
|
22
|
-
@history = history
|
|
23
|
-
@principles = principles
|
|
17
|
+
#: (principle_history: PrincipleHistory, record: AuditRecord?) -> void
|
|
18
|
+
def initialize(principle_history:, record:)
|
|
19
|
+
@principle_history = principle_history
|
|
24
20
|
@record = record
|
|
25
21
|
freeze
|
|
26
22
|
end
|
|
@@ -66,7 +62,7 @@ module Principles
|
|
|
66
62
|
|
|
67
63
|
#: (String, String) -> String?
|
|
68
64
|
def commit_that_set(key, check)
|
|
69
|
-
run =
|
|
65
|
+
run = @principle_history.runs([key]).fetch(key)
|
|
70
66
|
run.take_while { |_sha, fields| Member.new(fields).check == check }.last&.first
|
|
71
67
|
end
|
|
72
68
|
end
|
|
@@ -16,13 +16,16 @@ module Principles
|
|
|
16
16
|
# (D35), which travel to completion as those do. It also carries the last completed record's revision, so a
|
|
17
17
|
# correction is refused once that record changed (#646).
|
|
18
18
|
class CorrectionBasis
|
|
19
|
-
# The basis printed for a correction of findings, assessed from start: its base, its map's version
|
|
20
|
-
# assessment
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
# The basis printed for a correction of findings, assessed from start: its base, its map's version, the digest of
|
|
20
|
+
# the assessment the open record keeps, and what else of the assessment's report AssessmentReport carries in a
|
|
21
|
+
# basis (D87); revision is the last completed record's.
|
|
22
|
+
#: (AuditStart, findings: Array[untyped], revision: String?, open_record: AuditRecord,
|
|
23
|
+
#| ?prior: DecidedPriorFindings) -> CorrectionBasis
|
|
24
|
+
def self.printed(start, findings:, revision:, open_record:, prior: DecidedPriorFindings::NONE)
|
|
23
25
|
basis = { "base_commit" => start.base, "map_version" => start.map_version,
|
|
24
26
|
"last_completed_revision" => revision,
|
|
25
|
-
"findings" => findings.map { |finding| finding.slice(*RecordedFinding::RAISED_FIELDS) }
|
|
27
|
+
"findings" => findings.map { |finding| finding.slice(*RecordedFinding::RAISED_FIELDS) },
|
|
28
|
+
"assessment_report_sha256" => open_record.assessment_digest }
|
|
26
29
|
basis = basis.merge(start.reported.basis_fields)
|
|
27
30
|
new(prior.none? ? basis : basis.merge("prior_findings" => prior.to_h))
|
|
28
31
|
end
|
|
@@ -61,6 +64,12 @@ module Principles
|
|
|
61
64
|
RequestId.handing_back(principle_id: principle_id, phase: "correction", handed: @fields, parts: [before])
|
|
62
65
|
end
|
|
63
66
|
|
|
67
|
+
# Whether record is the open record this basis was printed with, its assessment unchanged since (D87).
|
|
68
|
+
#: (AuditRecord?) -> bool
|
|
69
|
+
def printed_with?(record)
|
|
70
|
+
!record.nil? && !record.completed? && record.assessment_digest == @fields["assessment_report_sha256"]
|
|
71
|
+
end
|
|
72
|
+
|
|
64
73
|
# The last completed record's revision when the request was printed, which refuses a correction once that
|
|
65
74
|
# record changed (#646).
|
|
66
75
|
#: () -> LastCompletedRevision
|