principles 0.0.4 → 0.0.6
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 +3 -1
- data/lib/principles/command_line.rb +38 -26
- data/lib/principles/command_routes.rb +11 -4
- data/lib/principles/controllers/acknowledgement.rb +93 -17
- data/lib/principles/controllers/answer.rb +45 -76
- data/lib/principles/controllers/answer_phase.rb +54 -0
- data/lib/principles/controllers/assessment.rb +46 -11
- data/lib/principles/controllers/audit.rb +17 -6
- data/lib/principles/controllers/audit_completion.rb +9 -5
- data/lib/principles/controllers/command.rb +5 -4
- data/lib/principles/controllers/correction.rb +22 -10
- data/lib/principles/controllers/full_audit_request.rb +11 -1
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +15 -29
- data/lib/principles/controllers/mapping.rb +9 -1
- 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 +13 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
- data/lib/principles/controllers/members_to_assess.rb +21 -13
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +22 -23
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/bounded_file.rb +9 -4
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +85 -24
- 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 +22 -11
- 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/schema_check.rb +16 -6
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +18 -5
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -68
- data/lib/principles/data/schemas/audit-record.schema.json +10 -1
- data/lib/principles/data/schemas/command-steps.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +6 -0
- 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 +3 -3
- data/lib/principles/models/acknowledgement.rb +95 -84
- data/lib/principles/models/acknowledgement_left_as_printed.rb +51 -0
- data/lib/principles/models/acknowledgement_refusal.rb +90 -0
- data/lib/principles/models/answer_place.rb +4 -0
- data/lib/principles/models/assessment_answer.rb +0 -45
- data/lib/principles/models/assessment_left_as_printed.rb +81 -0
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +12 -16
- data/lib/principles/models/audit_records.rb +52 -23
- data/lib/principles/models/candidate_files.rb +44 -10
- data/lib/principles/models/candidate_inventory.rb +69 -8
- data/lib/principles/models/candidate_outline.rb +195 -0
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/carried_member.rb +42 -0
- data/lib/principles/models/check_since_last_audit.rb +20 -11
- data/lib/principles/models/command_steps.rb +17 -1
- data/lib/principles/models/declared_map_changes.rb +29 -12
- 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/frontmatter_fields.rb +9 -8
- data/lib/principles/models/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/instruction_named.rb +35 -0
- data/lib/principles/models/left_as_printed.rb +39 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +9 -31
- data/lib/principles/models/member_file.rb +20 -47
- data/lib/principles/models/member_hashes_as_written.rb +10 -6
- data/lib/principles/models/member_history.rb +7 -5
- data/lib/principles/models/member_lines.rb +63 -15
- 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 +63 -33
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +52 -0
- 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/open_findings_elsewhere.rb +4 -0
- data/lib/principles/models/other_templates_placeholders.rb +81 -42
- data/lib/principles/models/outline_budget.rb +142 -0
- data/lib/principles/models/outline_group.rb +31 -0
- data/lib/principles/models/outline_section.rb +56 -0
- 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 +25 -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/prior_decision_fields.rb +3 -2
- data/lib/principles/models/prior_finding_decision.rb +14 -4
- data/lib/principles/models/problem_report.rb +17 -5
- data/lib/principles/models/project.rb +46 -39
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/quoted_change.rb +137 -0
- data/lib/principles/models/record_format.rb +12 -2
- data/lib/principles/models/recorded_entry.rb +6 -0
- data/lib/principles/models/recorded_hashes.rb +7 -3
- data/lib/principles/models/recorded_members.rb +27 -15
- data/lib/principles/models/refusal_before_shape.rb +21 -0
- data/lib/principles/models/repoint.rb +13 -0
- data/lib/principles/models/reported_check.rb +5 -14
- data/lib/principles/models/sent_answer.rb +61 -0
- data/lib/principles/models/shape_problems_beside.rb +40 -0
- data/lib/principles/models/submitted_answer.rb +34 -0
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/template_placeholders.rb +34 -4
- data/lib/principles/models/text_within.rb +55 -0
- data/lib/principles/models/unchecked_members.rb +76 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/models/write_up_opening.rb +21 -4
- data/lib/principles/positional_arguments.rb +37 -0
- data/lib/principles/session_start_options.rb +2 -2
- data/lib/principles/start_audit_options.rb +19 -4
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +23 -11
- 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 +43 -10
- data/lib/principles/views/assessment_request.rb +91 -31
- data/lib/principles/views/audit_result.rb +40 -28
- data/lib/principles/views/candidate_files_result.rb +85 -19
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_notes.rb +44 -0
- data/lib/principles/views/check_result_template.rb +14 -23
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +32 -1
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/instruction.rb +74 -0
- data/lib/principles/views/json_with_entries_on_lines.rb +59 -0
- data/lib/principles/views/loads_to_check_result.rb +2 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +23 -43
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +23 -5
- data/lib/principles/views/member_repairs.rb +22 -52
- data/lib/principles/views/members_a_commit_changed.rb +16 -6
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +47 -0
- data/lib/principles/views/open_findings_elsewhere_result.rb +3 -3
- data/lib/principles/views/open_findings_line.rb +77 -23
- data/lib/principles/views/principle_read_result.rb +24 -29
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/prior_findings_result.rb +23 -15
- data/lib/principles/views/problem_lines.rb +3 -1
- data/lib/principles/views/problem_result.rb +8 -3
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -12
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -48
- data/lib/principles/views/prompts/assess-every-member/assess-each-member-and-the-set.md +0 -4
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +4 -16
- data/lib/principles/views/prompts/assess-every-member/judge-the-set-with-carried-assessments.md +5 -10
- data/lib/principles/views/prompts/assess-every-member/keep-or-change-what-a-deferral-waits-on.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +8 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/review-a-new-or-changed-check-before-running-it.md +9 -0
- data/lib/principles/views/prompts/assess-every-member/say-what-observed-means.md +4 -0
- 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 +16 -3
- 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/ask-the-owner-after-the-table.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-which-principle-to-map.md +2 -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 +11 -5
- 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/leave-test-data-out-of-the-survey.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +3 -0
- 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/list-candidate-files.md +55 -7
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +9 -8
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +1 -2
- 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 +27 -1
- 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/show-meta-principle-passage.md +5 -5
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +24 -24
- 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/report-after-a-commit/the-principles-skill-is-where-to-start.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +9 -6
- data/lib/principles/views/prompts/start-a-session/see-the-earlier-line.md +2 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +3 -3
- data/lib/principles/views/request_part.rb +16 -8
- data/lib/principles/views/request_parts.rb +4 -0
- metadata +92 -7
- data/lib/principles/models/candidate_listing.rb +0 -32
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-before-mapping.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/set-up-first.md +0 -2
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
+
require_relative "acknowledgement_left_as_printed"
|
|
6
|
+
require_relative "acknowledgement_refusal"
|
|
5
7
|
require_relative "request_id"
|
|
6
8
|
require_relative "audit_record"
|
|
7
9
|
require_relative "member"
|
|
10
|
+
require_relative "member_lines"
|
|
8
11
|
require_relative "placement"
|
|
12
|
+
require_relative "quoted_change"
|
|
13
|
+
require_relative "reported_check"
|
|
14
|
+
require_relative "answer_place"
|
|
15
|
+
require_relative "template_placeholders"
|
|
9
16
|
|
|
10
17
|
module Principles
|
|
11
18
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -14,28 +21,30 @@ module Principles
|
|
|
14
21
|
# from before and after it, so the record's baseline for that member moves on and --short stops repeating it.
|
|
15
22
|
# Refused outside git, for a member no completed audit assessed, and for an unchanged or checked member.
|
|
16
23
|
class Acknowledgement
|
|
17
|
-
# One side of the change a quote is checked against: the member's lines then, and when they read.
|
|
18
|
-
class SideOfTheChange
|
|
19
|
-
#: String
|
|
20
|
-
attr_reader :reads_at
|
|
21
|
-
|
|
22
|
-
#: (Array[String], String) -> void
|
|
23
|
-
def initialize(lines, reads_at)
|
|
24
|
-
@lines = lines.map(&:chomp) #: Array[String]
|
|
25
|
-
@reads_at = reads_at
|
|
26
|
-
freeze
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
#: (String) -> bool
|
|
30
|
-
def whole_line?(quote) = @lines.include?(quote)
|
|
31
|
-
|
|
32
|
-
#: (String) -> bool
|
|
33
|
-
def holds?(text) = @lines.any? { |line| line.include?(text) }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
24
|
PHASE = "acknowledgement"
|
|
37
|
-
# The
|
|
38
|
-
|
|
25
|
+
# The text the answer's template prints in each field the agent judges, which an answer may not send back, so
|
|
26
|
+
# a template returned as printed acknowledges nothing (#773). It prints no quotes, which an answer leaving them
|
|
27
|
+
# out reads as first_changed_lines (#1111, #1166, #1170). After a pure insertion, meaning_kept's says that an
|
|
28
|
+
# inserted line usually adds a rule, for an agent that reads the template alone (#1142).
|
|
29
|
+
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
30
|
+
{ "meaning_kept" => "true only if the member still says the same thing",
|
|
31
|
+
"reason" => "Why, in one line of your own" },
|
|
32
|
+
also_printed: { "meaning_kept" => "true only if the member still says the same thing; this change inserted " \
|
|
33
|
+
"a line, which usually adds a rule" }
|
|
34
|
+
) #: TemplatePlaceholders
|
|
35
|
+
# The text a checked member's template prints where its check's exit status goes, short since the request's
|
|
36
|
+
# context says how to run the check (#1170).
|
|
37
|
+
EXIT_STATUS_PLACEHOLDER = "the check's exit status, an integer" #: String
|
|
38
|
+
# The fields an answer may not send back as the template printed them, refused before its shape (#773, #1170).
|
|
39
|
+
LEFT_AS_PRINTED = AcknowledgementLeftAsPrinted.new(
|
|
40
|
+
PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
|
|
41
|
+
) #: AcknowledgementLeftAsPrinted
|
|
42
|
+
|
|
43
|
+
# The placeholders the template prints beside quotes, its first_changed_lines.
|
|
44
|
+
#: (Hash[String, String]) -> Hash[String, untyped]
|
|
45
|
+
def self.placeholders_beside(quotes)
|
|
46
|
+
quotes["old_line"] == "" ? PLACEHOLDERS.with_other_text_in("meaning_kept") : PLACEHOLDERS.to_h
|
|
47
|
+
end
|
|
39
48
|
|
|
40
49
|
# before holds the member's lines at its baseline commit, now its lines and hash at base, HEAD.
|
|
41
50
|
#: (principle_id: String, member: Member, record: AuditRecord?, base: String?, now_sha256: String) -> void
|
|
@@ -93,6 +102,14 @@ module Principles
|
|
|
93
102
|
record.members.acknowledgements_for(@member.key).last&.fetch("commit") || record.base_commit.to_s
|
|
94
103
|
end
|
|
95
104
|
|
|
105
|
+
# Keep the record's named reference and stable member key together during placement lookup.
|
|
106
|
+
#: (Project) -> Enumerator::Lazy[Placement]
|
|
107
|
+
def placements_in(project)
|
|
108
|
+
commit = last_judged_commit
|
|
109
|
+
fields = project.principles.find(@principle_id).member(@member.id)
|
|
110
|
+
project.principle_history(@principle_id).placements_since(commit, @member.key, fields)
|
|
111
|
+
end
|
|
112
|
+
|
|
96
113
|
# The request's id: the member, its hash at the baseline and now, and the commit it is judged at.
|
|
97
114
|
#: () -> RequestId
|
|
98
115
|
def request_id
|
|
@@ -109,95 +126,89 @@ module Principles
|
|
|
109
126
|
end
|
|
110
127
|
|
|
111
128
|
# The record with this member's baseline moved to its text now, once the answer is checked against the
|
|
112
|
-
# member's lines at the baseline commit and now.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
# member's lines at the baseline commit and now. The change keeps the check run the answer reported, which the
|
|
130
|
+
# member's check_result cannot show was this run when the last audit's passed with the same command (#1112).
|
|
131
|
+
#: (untyped, MemberLines, at: String) -> AuditRecord
|
|
132
|
+
def accepted(answer, lines, at:)
|
|
133
|
+
checked(answer, lines)
|
|
134
|
+
result = check_result(answer)
|
|
135
|
+
run = result ? { "check_result" => result.slice("command", "exit_status") } : {}
|
|
116
136
|
acknowledgeable.acknowledged(@member.key, { "from_sha256" => acknowledgeable.members.hash_for(@member.key),
|
|
117
137
|
"to_sha256" => @now_sha256, "commit" => @base,
|
|
118
138
|
"reason" => answer.fetch("reason"), "acknowledged_at" => at,
|
|
119
|
-
**open_findings })
|
|
139
|
+
**open_findings, **run }, check_result: result)
|
|
120
140
|
end
|
|
121
141
|
|
|
142
|
+
# The result the answer reports for the member's check, checked against the check the record ran and carrying
|
|
143
|
+
# the line its last review rested on (D30, D63), once it passed: a check that failed or could not run is a full
|
|
144
|
+
# audit's to judge (#1071). nil for a member without a check, whose answer may report none.
|
|
145
|
+
#: (untyped) -> Hash[String, untyped]?
|
|
146
|
+
def check_result(answer)
|
|
147
|
+
check = @member.check
|
|
148
|
+
refuse("it has no check, so its answer reports no check_result") if !check && answer.key?("check_result")
|
|
149
|
+
return unless check
|
|
150
|
+
|
|
151
|
+
record = acknowledgeable
|
|
152
|
+
passed(ReportedCheck.new(AnswerPlace.new("", "The acknowledgement"), check,
|
|
153
|
+
ran: record.check_run_for(@member.key), kept: record.check_review_for(@member.key))
|
|
154
|
+
.result(reported_check(answer["check_result"], check)))
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# The first line on each side of the change that the other lacks, which the request hints the quotes from.
|
|
158
|
+
#: (MemberLines) -> Hash[String, String]
|
|
159
|
+
def first_changed_lines(lines) = quoted_change(lines).first_changed_lines
|
|
160
|
+
|
|
122
161
|
private
|
|
123
162
|
|
|
124
|
-
#
|
|
163
|
+
# result, once its check exited 0. It always gives an exit status, since the answer's schema refuses
|
|
164
|
+
# not_run_reason (#1115).
|
|
165
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
166
|
+
def passed(result)
|
|
167
|
+
status = result.fetch("exit_status")
|
|
168
|
+
return result if status.zero?
|
|
169
|
+
|
|
170
|
+
refuse("its check `#{result.fetch("command")}` exited #{status}, so a full audit judges it")
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# The check_result the answer reports, its command read as the request printed it when left out (#1166).
|
|
174
|
+
#: (untyped, String) -> untyped
|
|
175
|
+
def reported_check(reported, check) = reported.is_a?(Hash) ? { "command" => check, **reported } : reported
|
|
176
|
+
|
|
177
|
+
# The change the answer quotes, between the member's lines at the baseline and now.
|
|
178
|
+
#: (MemberLines) -> QuotedChange
|
|
179
|
+
def quoted_change(lines) = QuotedChange.new(lines, member_id: @member.id)
|
|
180
|
+
|
|
181
|
+
# The ids of the findings the last audit left open on this member with action, found by key, so a member moved
|
|
182
|
+
# since keeps its findings (#547).
|
|
125
183
|
#: (String) -> Array[String]
|
|
126
184
|
def findings_on_member(action)
|
|
127
|
-
acknowledgeable.
|
|
128
|
-
.select { |finding| finding.fetch("action") == action }
|
|
129
|
-
.select { |finding| finding.fetch("member_ids").any? { |id| on_member?(id) } }
|
|
130
|
-
.map { |finding| finding.fetch("finding_id") }
|
|
185
|
+
acknowledgeable.left_open.select { |finding| finding.action == action && finding.on?(@member.key) }.map(&:id)
|
|
131
186
|
end
|
|
132
187
|
|
|
133
|
-
# Whether the record's id names this member, by key, so a member moved since keeps its findings (#547).
|
|
134
|
-
#: (String) -> bool
|
|
135
|
-
def on_member?(id) = acknowledgeable.members.key_of(id) == @member.key
|
|
136
|
-
|
|
137
188
|
# The completed record, once the member can be acknowledged.
|
|
138
189
|
#: () -> AuditRecord
|
|
139
190
|
def acknowledgeable
|
|
140
191
|
refuse("an acknowledgement is judged against committed text, so it needs git") unless @base
|
|
141
192
|
record = @record or no_completed_audit
|
|
142
|
-
|
|
193
|
+
AcknowledgementRefusal.of(record, @member, now_sha256: @now_sha256)&.raise!
|
|
143
194
|
record
|
|
144
195
|
end
|
|
145
196
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def refused_for(reason)
|
|
149
|
-
case reason
|
|
150
|
-
when :not_completed then no_completed_audit
|
|
151
|
-
when :not_assessed then refuse("no completed audit assessed #{@member.id}")
|
|
152
|
-
when :unchanged then nothing_to_acknowledge
|
|
153
|
-
when :checked then refuse("#{@member.id} has a check, and acknowledging a checked member is not built yet")
|
|
154
|
-
when nil then nil
|
|
155
|
-
else raise ArgumentError, "unknown acknowledgement refusal #{reason}"
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
#: (untyped, Array[String], Array[String]) -> void
|
|
160
|
-
def checked(answer, before, now)
|
|
197
|
+
#: (untyped, MemberLines) -> void
|
|
198
|
+
def checked(answer, lines)
|
|
161
199
|
refuse("the answer says the change does not keep #{@member.id}'s meaning") unless answer["meaning_kept"] == true
|
|
162
200
|
reason = answer.fetch("reason").to_s
|
|
163
201
|
refuse("the reason must be one line") if reason.include?("\n")
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
quoted(answer.fetch("new_line"), now_side, then_side)
|
|
202
|
+
change = quoted_change(lines)
|
|
203
|
+
quotes = change.first_changed_lines.merge(answer.slice("old_line", "new_line"))
|
|
204
|
+
change.check(old_line: quotes.fetch("old_line"), new_line: quotes.fetch("new_line"))
|
|
168
205
|
end
|
|
169
206
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def quoted(line, side, other)
|
|
173
|
-
return if side.whole_line?(line) || (line.length >= FRAGMENT_LENGTH && side.holds?(line) && !other.holds?(line))
|
|
174
|
-
|
|
175
|
-
raise Error.new("quote_not_found", "#{line.inspect} is not a line of #{@member.id} #{side.reads_at}",
|
|
176
|
-
"Quote a whole line of the member as it reads #{side.reads_at}, or at least " \
|
|
177
|
-
"#{FRAGMENT_LENGTH} characters of one that the member #{other.reads_at} does not hold, " \
|
|
178
|
-
"from the change the request names.")
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
#: () -> bot
|
|
182
|
-
def no_completed_audit = refuse("#{@principle_id} has no completed audit, so no baseline has been judged")
|
|
207
|
+
#: (String) -> bot
|
|
208
|
+
def refuse(why) = AcknowledgementRefusal.new(@member, @principle_id).refuse(why)
|
|
183
209
|
|
|
184
|
-
# A member whose text is the one last judged, as after a pure move, needs nothing: not an acknowledgement, and
|
|
185
|
-
# not the full audit the other refusals send the agent to (#553).
|
|
186
210
|
#: () -> bot
|
|
187
|
-
def
|
|
188
|
-
raise Error.new("cannot_acknowledge",
|
|
189
|
-
"#{@member.id}'s text is the one last judged, so there is nothing to acknowledge",
|
|
190
|
-
"Nothing needs doing.")
|
|
191
|
-
.ending_with([Error::RepairCommand.new(purpose: "After a committed edit changes it, acknowledge it",
|
|
192
|
-
command: "start-audit", values: [@principle_id],
|
|
193
|
-
options: ["--member", @member.id])])
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
#: (String) -> bot
|
|
197
|
-
def refuse(why)
|
|
198
|
-
raise Error.new("cannot_acknowledge", "#{@member.id} cannot be acknowledged: #{why}",
|
|
199
|
-
"For a full audit instead: #{Error::EXECUTABLE} start-audit #{@principle_id}")
|
|
200
|
-
end
|
|
211
|
+
def no_completed_audit = AcknowledgementRefusal.new(@member, @principle_id, :not_completed).raise!
|
|
201
212
|
end
|
|
202
213
|
end
|
|
203
214
|
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "left_as_printed"
|
|
5
|
+
require_relative "refusal_before_shape"
|
|
6
|
+
require_relative "template_placeholders"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
10
|
+
module Models
|
|
11
|
+
# The fields a one-member audit's answer leaves as its template printed them, refused in one refusal before the
|
|
12
|
+
# answer's shape: its judgement's, meaning_kept and reason (#773), and a checked member's exit_status, which was
|
|
13
|
+
# otherwise refused as text with a repair offering the not_run_reason this template refuses (#1170). It holds the
|
|
14
|
+
# placeholders the template prints in each; Acknowledgement::LEFT_AS_PRINTED is the one a one-member audit uses.
|
|
15
|
+
class AcknowledgementLeftAsPrinted
|
|
16
|
+
include RefusalBeforeShape
|
|
17
|
+
|
|
18
|
+
# The field, named as a refusal names it, where a checked member's answer reports its exit status.
|
|
19
|
+
EXIT_STATUS = "check_result.exit_status" #: String
|
|
20
|
+
|
|
21
|
+
# judged holds the placeholders of the judgement's fields, exit_status the one printed where the status goes.
|
|
22
|
+
#: (TemplatePlaceholders, exit_status: String) -> void
|
|
23
|
+
def initialize(judged, exit_status:)
|
|
24
|
+
@judged = judged
|
|
25
|
+
@exit_status = exit_status
|
|
26
|
+
freeze
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @override
|
|
30
|
+
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
31
|
+
def refuse_in(answer, _source, shape_problems)
|
|
32
|
+
return unless answer.is_a?(Hash)
|
|
33
|
+
|
|
34
|
+
LeftAsPrinted.new(left_in(answer).to_h { [it, "/#{it.tr(".", "/")}"] }).refuse(besides: shape_problems)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# Each field answer leaves as printed, by name.
|
|
40
|
+
#: (Hash[String, untyped]) -> Array[String]
|
|
41
|
+
def left_in(answer)
|
|
42
|
+
judged = @judged.to_h.keys.select { @judged.left?(it, answer[it]) }
|
|
43
|
+
status_left?(answer["check_result"]) ? [*judged, EXIT_STATUS] : judged
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Whether check_result's exit_status is the placeholder the template prints there.
|
|
47
|
+
#: (untyped) -> bool
|
|
48
|
+
def status_left?(check_result) = check_result.is_a?(Hash) && check_result["exit_status"] == @exit_status
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "member"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# Why a one-member audit cannot judge a member's change (D33), as the audit record finds it: each sends the agent
|
|
11
|
+
# to the full audit, but a member whose text is the one last judged needs nothing at all (#553).
|
|
12
|
+
class AcknowledgementRefusal
|
|
13
|
+
# Why a one-member audit cannot judge member's change against record, or nil when it can (D33): the record must
|
|
14
|
+
# be completed and have assessed the member, the member's text must differ from the one it assessed, its check
|
|
15
|
+
# must be the one the record ran, so none new, changed, removed or last not run escapes a full audit's review
|
|
16
|
+
# (D33, #1071). The one owner of these preconditions, which
|
|
17
|
+
# list-member-problems asks before offering the audit that Acknowledgement refuses by them (#626, #632); git is
|
|
18
|
+
# the callers' to know.
|
|
19
|
+
#: (AuditRecord, Member, now_sha256: String?) -> AcknowledgementRefusal?
|
|
20
|
+
def self.of(record, member, now_sha256:)
|
|
21
|
+
members = record.members
|
|
22
|
+
recorded = members.hash_for(member.key)
|
|
23
|
+
check = members.check_since(member.key, member.check)
|
|
24
|
+
reason = if !record.completed? then :not_completed
|
|
25
|
+
elsif !recorded then :not_assessed
|
|
26
|
+
elsif recorded == now_sha256 then :unchanged
|
|
27
|
+
elsif check != :unchanged then check
|
|
28
|
+
end
|
|
29
|
+
new(member, record.principle_id, reason, ran: members.check_run_for(member.key)) if reason
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# principle_id is the member's principle, whose full audit each refusal names. reason, which raise! raises, is
|
|
33
|
+
# :not_completed, :not_assessed, :unchanged, or how the member's check stands to the one the record
|
|
34
|
+
# ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason it
|
|
35
|
+
# only refuses for a reason its caller states.
|
|
36
|
+
#: (Member, String, ?Symbol?, ?ran: String?) -> void
|
|
37
|
+
def initialize(member, principle_id, reason = nil, ran: nil)
|
|
38
|
+
@reason = reason
|
|
39
|
+
@member = member
|
|
40
|
+
@principle_id = principle_id
|
|
41
|
+
@ran = ran
|
|
42
|
+
freeze
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Refuses the member's acknowledgement for why, sending the agent to its principle's full audit instead.
|
|
46
|
+
#: (String) -> bot
|
|
47
|
+
def refuse(why)
|
|
48
|
+
raise Error.new("cannot_acknowledge", "#{@member.id} cannot be acknowledged: #{why}",
|
|
49
|
+
"For a full audit instead: #{Error::EXECUTABLE} start-audit #{@principle_id}")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Raises it.
|
|
53
|
+
#: () -> bot
|
|
54
|
+
def raise!
|
|
55
|
+
case @reason
|
|
56
|
+
when :unchanged then nothing_to_acknowledge
|
|
57
|
+
when :not_completed then refuse("#{@principle_id} has no completed audit, so no baseline has been judged")
|
|
58
|
+
when :not_assessed then refuse("no completed audit assessed #{@member.id}")
|
|
59
|
+
else refuse("#{check_since_record}, so a full audit reviews it")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
# How the member's check stands to the one the record ran, which a full audit reviews before it runs (#1071).
|
|
66
|
+
#: () -> String
|
|
67
|
+
def check_since_record
|
|
68
|
+
case @reason
|
|
69
|
+
when :removed then "its check was removed since the last completed audit ran `#{@ran}`"
|
|
70
|
+
when :changed then "its check `#{@member.check}` changed since the last completed audit ran `#{@ran}`"
|
|
71
|
+
when :not_run then "the last completed audit reported its check `#{@member.check}` not run"
|
|
72
|
+
when :new then "its check `#{@member.check}` is new since the last completed audit"
|
|
73
|
+
else raise ArgumentError, "unknown acknowledgement refusal #{@reason}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# A member whose text is the one last judged, as after a pure move, needs nothing: not an acknowledgement, and
|
|
78
|
+
# not the full audit the other refusals send the agent to (#553).
|
|
79
|
+
#: () -> bot
|
|
80
|
+
def nothing_to_acknowledge
|
|
81
|
+
raise Error.new("cannot_acknowledge",
|
|
82
|
+
"#{@member.id}'s text is the one last judged, so there is nothing to acknowledge",
|
|
83
|
+
"Nothing needs doing.")
|
|
84
|
+
.ending_with([Error::RepairCommand.new(purpose: "After a committed edit changes it, acknowledge it",
|
|
85
|
+
command: "start-audit", values: [@principle_id],
|
|
86
|
+
options: ["--member", @member.id])])
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -20,6 +20,10 @@ module Principles
|
|
|
20
20
|
#: String
|
|
21
21
|
attr_reader :subject
|
|
22
22
|
|
|
23
|
+
# The place of the member assessment at index in an answer, which names the member it assesses.
|
|
24
|
+
#: (Integer, untyped) -> AnswerPlace
|
|
25
|
+
def self.member_assessment(index, member_id) = new("/member_assessments/#{index}", "Member #{member_id}")
|
|
26
|
+
|
|
23
27
|
#: (String, String) -> void
|
|
24
28
|
def initialize(pointer, subject)
|
|
25
29
|
@pointer = pointer
|
|
@@ -9,7 +9,6 @@ require_relative "loads_to_check"
|
|
|
9
9
|
require_relative "member_assessments"
|
|
10
10
|
require_relative "misspelt_member_id"
|
|
11
11
|
require_relative "new_findings"
|
|
12
|
-
require_relative "sent_prior_decisions"
|
|
13
12
|
require_relative "recent_decision"
|
|
14
13
|
require_relative "record_judged_against"
|
|
15
14
|
|
|
@@ -32,9 +31,6 @@ module Principles
|
|
|
32
31
|
LEFT_AS_PRINTED_RULE = "A field left as printed is read as omitted, as is this one: one saying \"else kept\" " \
|
|
33
32
|
"keeps what it had, and null drops it where offered." #: String
|
|
34
33
|
|
|
35
|
-
# The problem with a judgement sent back as its placeholder.
|
|
36
|
-
UNCHANGED = "is the template's placeholder, unchanged" #: String
|
|
37
|
-
|
|
38
34
|
#: (untyped, PrincipleMembers, answered_at: String, ?judged_against: RecordJudgedAgainst?)
|
|
39
35
|
#| { (Locator) -> Hash[String, untyped] } -> void
|
|
40
36
|
def initialize(response, members, answered_at:, judged_against: nil, &locate)
|
|
@@ -51,7 +47,6 @@ module Principles
|
|
|
51
47
|
# decision and each finding have been checked.
|
|
52
48
|
#: () -> Array[untyped]
|
|
53
49
|
def findings
|
|
54
|
-
refuse_left_as_printed
|
|
55
50
|
member_assessments.check
|
|
56
51
|
@fields.text(@response["collective_assessment"], "collective_assessment")
|
|
57
52
|
recent_decision.check(@fields)
|
|
@@ -86,46 +81,6 @@ module Principles
|
|
|
86
81
|
|
|
87
82
|
private
|
|
88
83
|
|
|
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
|
-
|
|
129
84
|
#: () -> MemberAssessments
|
|
130
85
|
def member_assessments
|
|
131
86
|
MemberAssessments.new(@response["member_assessments"], @members, fields: @fields,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "answer_place"
|
|
5
|
+
require_relative "left_as_printed"
|
|
6
|
+
require_relative "member_assessments"
|
|
7
|
+
require_relative "new_findings"
|
|
8
|
+
require_relative "recent_decision"
|
|
9
|
+
require_relative "refusal_before_shape"
|
|
10
|
+
require_relative "sent_prior_decisions"
|
|
11
|
+
|
|
12
|
+
module Principles
|
|
13
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
14
|
+
module Models
|
|
15
|
+
# The judgements a full audit's answer, as sent, leaves as its template printed them: the members', the set's,
|
|
16
|
+
# the recent decision's, a raised finding's text fields and a prior finding's decision (#991, #1010, #1040). It
|
|
17
|
+
# reads only what it finds in the shape it expects, so it may read an answer whose shape is still to be checked.
|
|
18
|
+
class AssessmentLeftAsPrinted
|
|
19
|
+
include RefusalBeforeShape
|
|
20
|
+
|
|
21
|
+
# Refuses answer naming each judgement it leaves as printed, then each of shape_problems elsewhere; nothing
|
|
22
|
+
# when it leaves none. source is unused, as other refusals before the shape name it.
|
|
23
|
+
# @override
|
|
24
|
+
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
25
|
+
def refuse_in(answer, _source, shape_problems)
|
|
26
|
+
of(answer).refuse(besides: shape_problems) if answer.is_a?(Hash)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# Each judgement answer leaves as printed, named, with its pointer.
|
|
32
|
+
#: (Hash[String, untyped]) -> LeftAsPrinted
|
|
33
|
+
def of(answer)
|
|
34
|
+
left = members_left(answer["member_assessments"])
|
|
35
|
+
left["collective_assessment"] = "/collective_assessment" if
|
|
36
|
+
answer["collective_assessment"] == AssessmentAnswer::COLLECTIVE_PLACEHOLDER
|
|
37
|
+
left["recent_decision"] = "/recent_decision" if recent_decision_left?(answer["recent_decision"])
|
|
38
|
+
LeftAsPrinted.new(left.merge(listed_left(answer)))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Each judgement a member's assessment leaves as printed, named by whose it is and what: its assessment, and an
|
|
42
|
+
# observed delivery's observation.
|
|
43
|
+
#: (untyped) -> Hash[String, String]
|
|
44
|
+
def members_left(assessments)
|
|
45
|
+
return {} unless assessments.is_a?(Array)
|
|
46
|
+
|
|
47
|
+
assessments.each_with_index.flat_map do |assessment, index|
|
|
48
|
+
next [] unless assessment.is_a?(Hash)
|
|
49
|
+
|
|
50
|
+
place = AnswerPlace.member_assessment(index, assessment["member_id"])
|
|
51
|
+
unwritten_fields(assessment).map { |field| ["#{place.subject} #{field}", place.child(field).pointer] }
|
|
52
|
+
end.to_h
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# The fields of assessment, as sent, that are still the text the template printed there and must be written.
|
|
56
|
+
#: (Hash[String, untyped]) -> Array[String]
|
|
57
|
+
def unwritten_fields(assessment)
|
|
58
|
+
[("assessment" if assessment["assessment"] == MemberAssessments::PLACEHOLDER),
|
|
59
|
+
("observation" if assessment["delivery"] == "observed" &&
|
|
60
|
+
MemberAssessments::SIGHTING.left?("observation", assessment["observation"]))].compact
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Each judgement the answer's lists leave as printed: a raised finding's text fields, and a prior finding's
|
|
64
|
+
# decision.
|
|
65
|
+
#: (Hash[String, untyped]) -> Hash[String, String]
|
|
66
|
+
def listed_left(answer)
|
|
67
|
+
findings, decisions = answer.values_at("findings", "prior_finding_decisions")
|
|
68
|
+
{ **(NewFindings.new(findings).left_as_printed if findings.is_a?(Array)),
|
|
69
|
+
**(SentPriorDecisions.new(decisions).left_as_printed if decisions.is_a?(Array)) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Whether decision gives fields and leaves each as the template printed it.
|
|
73
|
+
#: (untyped) -> bool
|
|
74
|
+
def recent_decision_left?(decision)
|
|
75
|
+
return false unless decision.is_a?(Hash)
|
|
76
|
+
|
|
77
|
+
RecentDecision.new(decision).left_as_printed?
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -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
|
|
@@ -98,19 +98,9 @@ module Principles
|
|
|
98
98
|
"map_changed" => @fields["map_version"] != map_version }
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# asks before offering the audit that Acknowledgement refuses by them (#626, #632); git is the callers' to know.
|
|
105
|
-
#: (Member, now_sha256: String?) -> Symbol?
|
|
106
|
-
def acknowledgement_refusal(member, now_sha256:)
|
|
107
|
-
recorded = members.hash_for(member.key)
|
|
108
|
-
return :not_completed unless completed?
|
|
109
|
-
return :not_assessed unless recorded
|
|
110
|
-
return :unchanged if recorded == now_sha256
|
|
111
|
-
|
|
112
|
-
:checked if member.check
|
|
113
|
-
end
|
|
101
|
+
# Completion certainty for optional mapping feedback; the record owns its format and kept history.
|
|
102
|
+
#: () -> bool
|
|
103
|
+
def known_no_completed_audit? = !RecordFormat.new(@fields).newer? && last_completed.nil?
|
|
114
104
|
|
|
115
105
|
# Whether the audit this record describes completed, rather than being left open outside git.
|
|
116
106
|
#: () -> bool
|
|
@@ -162,9 +152,10 @@ module Principles
|
|
|
162
152
|
|
|
163
153
|
# This record with the member known by key moved to change's to_sha256, and change kept beside it (D33).
|
|
164
154
|
# Nothing else changes: the map version, base commit and findings stay the audit's own.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
# check_result is the result reported for the member's check, which replaces the one the record kept (#1071).
|
|
156
|
+
#: (String, Hash[String, untyped], ?check_result: Hash[String, untyped]?) -> AuditRecord
|
|
157
|
+
def acknowledged(key, change, check_result: nil)
|
|
158
|
+
AuditRecord.new(@fields.merge("members" => members.acknowledged(key, change, check_result:).to_h))
|
|
168
159
|
end
|
|
169
160
|
|
|
170
161
|
# This record with each finding a repoint names moved by it at at (D59); the last repoint naming a finding
|
|
@@ -197,6 +188,11 @@ module Principles
|
|
|
197
188
|
#: () -> Array[String]
|
|
198
189
|
def open_ids = left_open.map(&:id)
|
|
199
190
|
|
|
191
|
+
# The ids of the findings it leaves open on the member known by key, which the next full audit decides beside
|
|
192
|
+
# it (D93).
|
|
193
|
+
#: (String) -> Array[String]
|
|
194
|
+
def open_ids_on(key) = left_open.select { it.on?(key) }.map(&:id)
|
|
195
|
+
|
|
200
196
|
# The ids of the findings its audit resolved: those it fixed, and each prior finding decided resolved, never
|
|
201
197
|
# one withdrawn (#714).
|
|
202
198
|
#: (DecidedPriorFindings) -> Array[String]
|