principles 0.0.4 → 0.0.5
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 +3 -1
- data/lib/principles/command_line.rb +35 -7
- data/lib/principles/command_routes.rb +4 -3
- data/lib/principles/controllers/acknowledgement.rb +80 -14
- data/lib/principles/controllers/answer.rb +42 -75
- data/lib/principles/controllers/answer_phase.rb +54 -0
- data/lib/principles/controllers/assessment.rb +33 -9
- data/lib/principles/controllers/audit.rb +17 -6
- data/lib/principles/controllers/audit_completion.rb +6 -4
- data/lib/principles/controllers/command.rb +3 -2
- data/lib/principles/controllers/correction.rb +19 -9
- data/lib/principles/controllers/full_audit_request.rb +10 -0
- data/lib/principles/controllers/inventory.rb +25 -20
- data/lib/principles/controllers/member_problems_report.rb +11 -4
- data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
- data/lib/principles/controllers/members_to_assess.rb +20 -12
- data/lib/principles/controllers/repoint.rb +18 -22
- data/lib/principles/data/bounded_file.rb +9 -4
- data/lib/principles/data/command-steps.json +9 -9
- data/lib/principles/data/project_files.rb +11 -8
- data/lib/principles/data/schema_check.rb +16 -6
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +17 -3
- data/lib/principles/data/schemas/answer-guide.schema.json +5 -10
- 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/invocation_options.rb +1 -1
- data/lib/principles/models/acknowledgement.rb +73 -84
- 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_record.rb +9 -17
- data/lib/principles/models/audit_records.rb +19 -16
- data/lib/principles/models/candidate_files.rb +30 -7
- data/lib/principles/models/candidate_inventory.rb +23 -6
- data/lib/principles/models/candidate_listing.rb +12 -3
- data/lib/principles/models/candidate_outline.rb +195 -0
- data/lib/principles/models/carried_member.rb +42 -0
- data/lib/principles/models/check_since_last_audit.rb +16 -3
- data/lib/principles/models/command_steps.rb +17 -1
- data/lib/principles/models/declared_map_changes.rb +5 -4
- data/lib/principles/models/frontmatter_fields.rb +9 -8
- data/lib/principles/models/instruction_named.rb +35 -0
- data/lib/principles/models/left_as_printed.rb +39 -0
- data/lib/principles/models/member_assessments.rb +9 -31
- data/lib/principles/models/member_file.rb +35 -11
- data/lib/principles/models/member_hashes_as_written.rb +10 -6
- data/lib/principles/models/member_lines.rb +63 -15
- data/lib/principles/models/member_problems.rb +24 -18
- data/lib/principles/models/member_repair_moves.rb +54 -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 +127 -0
- data/lib/principles/models/outline_group.rb +31 -0
- data/lib/principles/models/outline_section.rb +56 -0
- data/lib/principles/models/principle_members.rb +11 -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/project.rb +10 -19
- data/lib/principles/models/quoted_change.rb +137 -0
- data/lib/principles/models/record_format.rb +6 -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 +3 -13
- data/lib/principles/models/sent_answer.rb +51 -0
- data/lib/principles/models/shape_problems_beside.rb +40 -0
- data/lib/principles/models/submitted_answer.rb +34 -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/write_up_opening.rb +21 -4
- 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 +15 -7
- data/lib/principles/views/assessed_members.rb +43 -10
- data/lib/principles/views/assessment_request.rb +89 -30
- data/lib/principles/views/audit_result.rb +19 -2
- data/lib/principles/views/candidate_files_result.rb +41 -19
- data/lib/principles/views/check_notes.rb +44 -0
- data/lib/principles/views/check_result_template.rb +14 -23
- data/lib/principles/views/instruction.rb +74 -0
- data/lib/principles/views/json_with_entries_on_lines.rb +51 -0
- data/lib/principles/views/loads_to_check_result.rb +2 -2
- data/lib/principles/views/map_result.rb +2 -2
- data/lib/principles/views/member_change_since_baseline.rb +22 -5
- data/lib/principles/views/member_repairs.rb +21 -52
- data/lib/principles/views/members_a_commit_changed.rb +16 -6
- data/lib/principles/views/one_member_check_result_template.rb +43 -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 +20 -28
- data/lib/principles/views/prior_findings_result.rb +23 -15
- 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 +5 -10
- 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/fix-or-record-each-finding.md +4 -3
- 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-one-principle.md +9 -5
- 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/learn-what-a-command-does/list-candidate-files.md +21 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +4 -4
- 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/show-answer-check.md +1 -1
- 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 +3 -3
- 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 +39 -5
- 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,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "acknowledgement-answer.schema.json",
|
|
4
4
|
"title": "Acknowledgement answer",
|
|
5
|
-
"description": "What an agent answers a one-member audit with (D33): the request's id and basis, whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it. Fields this tool does not read are refused (D29). Models::Acknowledgement checks the quotes and the reason.",
|
|
5
|
+
"description": "What an agent answers a one-member audit with (D33): the request's id and basis, whether the change keeps the member's meaning, a one-line reason, and a line quoted from the member's text before the change and one from after it, or \"\" for a side with no line the other lacks. Fields this tool does not read are refused (D29). Models::Acknowledgement checks the quotes and the reason.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": false,
|
|
8
8
|
"required": ["request_id", "basis", "meaning_kept", "reason", "old_line", "new_line"],
|
|
@@ -19,7 +19,21 @@
|
|
|
19
19
|
},
|
|
20
20
|
"meaning_kept": { "type": "boolean" },
|
|
21
21
|
"reason": { "type": "string", "minLength": 1 },
|
|
22
|
-
"old_line": { "type": "string"
|
|
23
|
-
"new_line": { "type": "string"
|
|
22
|
+
"old_line": { "type": "string" },
|
|
23
|
+
"new_line": { "type": "string" },
|
|
24
|
+
"check_result": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": false,
|
|
27
|
+
"x-unread-field-advice": {
|
|
28
|
+
"not_run_reason": "a check that cannot be run here needs a full audit: start one instead"
|
|
29
|
+
},
|
|
30
|
+
"required": ["command"],
|
|
31
|
+
"description": "The result of the member's check, which the answer reports when the member has one: the command as the map names it and its exit_status, which must be 0, since a check that fails or cannot be run is a full audit's to judge, with review_basis when a new line says what its review rested on (D30, D63, #1115). Models::ReportedCheck checks it.",
|
|
32
|
+
"properties": {
|
|
33
|
+
"command": { "type": "string" },
|
|
34
|
+
"exit_status": { "type": ["integer", "string"] },
|
|
35
|
+
"review_basis": { "type": "string" }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
}
|
|
25
39
|
}
|
|
@@ -80,18 +80,13 @@
|
|
|
80
80
|
"reassessment": { "type": "string" },
|
|
81
81
|
"check_result": {
|
|
82
82
|
"type": "object",
|
|
83
|
-
"required": ["
|
|
83
|
+
"required": ["command", "exit_status", "review_basis", "not_run_reason", "limits"],
|
|
84
84
|
"additionalProperties": false,
|
|
85
85
|
"properties": {
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
"not_run": {
|
|
92
|
-
"type": "object", "required": ["command", "not_run_reason"], "additionalProperties": false,
|
|
93
|
-
"properties": { "command": { "type": "string" }, "not_run_reason": { "type": "string" } }
|
|
94
|
-
},
|
|
86
|
+
"command": { "type": "string" },
|
|
87
|
+
"exit_status": { "type": "integer" },
|
|
88
|
+
"review_basis": { "type": "string" },
|
|
89
|
+
"not_run_reason": { "type": "string" },
|
|
95
90
|
"limits": { "type": "string" }
|
|
96
91
|
}
|
|
97
92
|
}
|
|
@@ -198,7 +198,16 @@
|
|
|
198
198
|
"reason": { "type": "string", "minLength": 1 },
|
|
199
199
|
"acknowledged_at": { "type": "string", "minLength": 1 },
|
|
200
200
|
"deferred_findings": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
201
|
-
"accepted_findings": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
201
|
+
"accepted_findings": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
202
|
+
"check_result": {
|
|
203
|
+
"description": "The run of the member's check the acknowledgement's answer reported, which passed (#1112).",
|
|
204
|
+
"type": "object",
|
|
205
|
+
"required": ["command", "exit_status"],
|
|
206
|
+
"properties": {
|
|
207
|
+
"command": { "type": "string", "minLength": 1 },
|
|
208
|
+
"exit_status": { "type": "integer" }
|
|
209
|
+
}
|
|
210
|
+
}
|
|
202
211
|
}
|
|
203
212
|
}
|
|
204
213
|
}
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
"usage": { "$ref": "#/$defs/prose" },
|
|
73
73
|
"group": { "$ref": "#/$defs/slug" },
|
|
74
74
|
"options": { "type": "array", "uniqueItems": true,
|
|
75
|
-
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as"] } },
|
|
75
|
+
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction"] } },
|
|
76
|
+
"requires": { "type": "array", "uniqueItems": true, "items": { "enum": ["file"] } },
|
|
76
77
|
"summary": { "$ref": "#/$defs/prose" },
|
|
77
78
|
"help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
|
78
79
|
"steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/step" } }
|
|
@@ -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 as].freeze #: Array[String]
|
|
12
|
+
check member session-start commits-after hook-event as instruction].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,16 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
+
require_relative "acknowledgement_refusal"
|
|
5
6
|
require_relative "request_id"
|
|
6
7
|
require_relative "audit_record"
|
|
7
8
|
require_relative "member"
|
|
9
|
+
require_relative "member_lines"
|
|
8
10
|
require_relative "placement"
|
|
11
|
+
require_relative "quoted_change"
|
|
12
|
+
require_relative "reported_check"
|
|
13
|
+
require_relative "answer_place"
|
|
14
|
+
require_relative "template_placeholders"
|
|
9
15
|
|
|
10
16
|
module Principles
|
|
11
17
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -14,28 +20,23 @@ module Principles
|
|
|
14
20
|
# from before and after it, so the record's baseline for that member moves on and --short stops repeating it.
|
|
15
21
|
# Refused outside git, for a member no completed audit assessed, and for an unchanged or checked member.
|
|
16
22
|
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
23
|
PHASE = "acknowledgement"
|
|
37
|
-
# The
|
|
38
|
-
|
|
24
|
+
# The text the answer's template prints in each field the agent judges, which an answer may not send back, so
|
|
25
|
+
# a template returned as printed acknowledges nothing (#773). Its quotes print first_changed_lines instead,
|
|
26
|
+
# which the answer may send back as printed (#1111). After a pure insertion, meaning_kept's says that an
|
|
27
|
+
# inserted line usually adds a rule, for an agent that reads the template alone (#1142).
|
|
28
|
+
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
29
|
+
{ "meaning_kept" => "true only if the member still says the same thing",
|
|
30
|
+
"reason" => "Why, in one line of your own" },
|
|
31
|
+
also_printed: { "meaning_kept" => "true only if the member still says the same thing; old_line \"\" means a " \
|
|
32
|
+
"line was inserted, which usually adds a rule" }
|
|
33
|
+
) #: TemplatePlaceholders
|
|
34
|
+
|
|
35
|
+
# The placeholders the template prints beside quotes, its first_changed_lines.
|
|
36
|
+
#: (Hash[String, String]) -> Hash[String, untyped]
|
|
37
|
+
def self.placeholders_beside(quotes)
|
|
38
|
+
quotes["old_line"] == "" ? PLACEHOLDERS.with_other_text_in("meaning_kept") : PLACEHOLDERS.to_h
|
|
39
|
+
end
|
|
39
40
|
|
|
40
41
|
# before holds the member's lines at its baseline commit, now its lines and hash at base, HEAD.
|
|
41
42
|
#: (principle_id: String, member: Member, record: AuditRecord?, base: String?, now_sha256: String) -> void
|
|
@@ -109,95 +110,83 @@ module Principles
|
|
|
109
110
|
end
|
|
110
111
|
|
|
111
112
|
# 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
|
-
|
|
113
|
+
# member's lines at the baseline commit and now. The change keeps the check run the answer reported, which the
|
|
114
|
+
# member's check_result cannot show was this run when the last audit's passed with the same command (#1112).
|
|
115
|
+
#: (untyped, MemberLines, at: String) -> AuditRecord
|
|
116
|
+
def accepted(answer, lines, at:)
|
|
117
|
+
checked(answer, lines)
|
|
118
|
+
result = check_result(answer)
|
|
119
|
+
run = result ? { "check_result" => result.slice("command", "exit_status") } : {}
|
|
116
120
|
acknowledgeable.acknowledged(@member.key, { "from_sha256" => acknowledgeable.members.hash_for(@member.key),
|
|
117
121
|
"to_sha256" => @now_sha256, "commit" => @base,
|
|
118
122
|
"reason" => answer.fetch("reason"), "acknowledged_at" => at,
|
|
119
|
-
**open_findings })
|
|
123
|
+
**open_findings, **run }, check_result: result)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# The result the answer reports for the member's check, checked against the check the record ran and carrying
|
|
127
|
+
# the line its last review rested on (D30, D63), once it passed: a check that failed or could not run is a full
|
|
128
|
+
# audit's to judge (#1071). nil for a member without a check, whose answer may report none.
|
|
129
|
+
#: (untyped) -> Hash[String, untyped]?
|
|
130
|
+
def check_result(answer)
|
|
131
|
+
check = @member.check
|
|
132
|
+
refuse("it has no check, so its answer reports no check_result") if !check && answer.key?("check_result")
|
|
133
|
+
return unless check
|
|
134
|
+
|
|
135
|
+
record = acknowledgeable
|
|
136
|
+
passed(ReportedCheck.new(AnswerPlace.new("", "The acknowledgement"), check,
|
|
137
|
+
ran: record.check_run_for(@member.key), kept: record.check_review_for(@member.key))
|
|
138
|
+
.result(answer["check_result"]))
|
|
120
139
|
end
|
|
121
140
|
|
|
141
|
+
# The first line on each side of the change that the other lacks, which the request hints the quotes from.
|
|
142
|
+
#: (MemberLines) -> Hash[String, String]
|
|
143
|
+
def first_changed_lines(lines) = quoted_change(lines).first_changed_lines
|
|
144
|
+
|
|
122
145
|
private
|
|
123
146
|
|
|
124
|
-
#
|
|
147
|
+
# result, once its check exited 0. It always gives an exit status, since the answer's schema refuses
|
|
148
|
+
# not_run_reason (#1115).
|
|
149
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
150
|
+
def passed(result)
|
|
151
|
+
status = result.fetch("exit_status")
|
|
152
|
+
return result if status.zero?
|
|
153
|
+
|
|
154
|
+
refuse("its check `#{result.fetch("command")}` exited #{status}, so a full audit judges it")
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# The change the answer quotes, between the member's lines at the baseline and now.
|
|
158
|
+
#: (MemberLines) -> QuotedChange
|
|
159
|
+
def quoted_change(lines) = QuotedChange.new(lines, member_id: @member.id)
|
|
160
|
+
|
|
161
|
+
# The ids of the findings the last audit left open on this member with action, found by key, so a member moved
|
|
162
|
+
# since keeps its findings (#547).
|
|
125
163
|
#: (String) -> Array[String]
|
|
126
164
|
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") }
|
|
165
|
+
acknowledgeable.left_open.select { |finding| finding.action == action && finding.on?(@member.key) }.map(&:id)
|
|
131
166
|
end
|
|
132
167
|
|
|
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
168
|
# The completed record, once the member can be acknowledged.
|
|
138
169
|
#: () -> AuditRecord
|
|
139
170
|
def acknowledgeable
|
|
140
171
|
refuse("an acknowledgement is judged against committed text, so it needs git") unless @base
|
|
141
172
|
record = @record or no_completed_audit
|
|
142
|
-
|
|
173
|
+
AcknowledgementRefusal.of(record, @member, now_sha256: @now_sha256)&.raise!
|
|
143
174
|
record
|
|
144
175
|
end
|
|
145
176
|
|
|
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)
|
|
177
|
+
#: (untyped, MemberLines) -> void
|
|
178
|
+
def checked(answer, lines)
|
|
161
179
|
refuse("the answer says the change does not keep #{@member.id}'s meaning") unless answer["meaning_kept"] == true
|
|
162
180
|
reason = answer.fetch("reason").to_s
|
|
163
181
|
refuse("the reason must be one line") if reason.include?("\n")
|
|
164
|
-
|
|
165
|
-
now_side = SideOfTheChange.new(now, "at HEAD")
|
|
166
|
-
quoted(answer.fetch("old_line"), then_side, now_side)
|
|
167
|
-
quoted(answer.fetch("new_line"), now_side, then_side)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
# A quote is a whole line of this side, or a fragment long enough to show the edit that only this side reads.
|
|
171
|
-
#: (String, SideOfTheChange, SideOfTheChange) -> void
|
|
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.")
|
|
182
|
+
quoted_change(lines).check(old_line: answer.fetch("old_line"), new_line: answer.fetch("new_line"))
|
|
179
183
|
end
|
|
180
184
|
|
|
181
|
-
#: () -> bot
|
|
182
|
-
def
|
|
185
|
+
#: (String) -> bot
|
|
186
|
+
def refuse(why) = AcknowledgementRefusal.new(@member, @principle_id).refuse(why)
|
|
183
187
|
|
|
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
188
|
#: () -> 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
|
|
189
|
+
def no_completed_audit = AcknowledgementRefusal.new(@member, @principle_id, :not_completed).raise!
|
|
201
190
|
end
|
|
202
191
|
end
|
|
203
192
|
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
|
|
@@ -98,20 +98,6 @@ module Principles
|
|
|
98
98
|
"map_changed" => @fields["map_version"] != map_version }
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
# Why a one-member audit cannot judge member's change against this record, or nil when it can (D33): the
|
|
102
|
-
# record must be completed and have assessed the member, the member's text must differ from the one it
|
|
103
|
-
# assessed, and the member must have no check. The one owner of these preconditions, which list-member-problems
|
|
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
|
|
114
|
-
|
|
115
101
|
# Whether the audit this record describes completed, rather than being left open outside git.
|
|
116
102
|
#: () -> bool
|
|
117
103
|
def completed?
|
|
@@ -162,9 +148,10 @@ module Principles
|
|
|
162
148
|
|
|
163
149
|
# This record with the member known by key moved to change's to_sha256, and change kept beside it (D33).
|
|
164
150
|
# Nothing else changes: the map version, base commit and findings stay the audit's own.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
151
|
+
# check_result is the result reported for the member's check, which replaces the one the record kept (#1071).
|
|
152
|
+
#: (String, Hash[String, untyped], ?check_result: Hash[String, untyped]?) -> AuditRecord
|
|
153
|
+
def acknowledged(key, change, check_result: nil)
|
|
154
|
+
AuditRecord.new(@fields.merge("members" => members.acknowledged(key, change, check_result:).to_h))
|
|
168
155
|
end
|
|
169
156
|
|
|
170
157
|
# This record with each finding a repoint names moved by it at at (D59); the last repoint naming a finding
|
|
@@ -197,6 +184,11 @@ module Principles
|
|
|
197
184
|
#: () -> Array[String]
|
|
198
185
|
def open_ids = left_open.map(&:id)
|
|
199
186
|
|
|
187
|
+
# The ids of the findings it leaves open on the member known by key, which the next full audit decides beside
|
|
188
|
+
# it (D93).
|
|
189
|
+
#: (String) -> Array[String]
|
|
190
|
+
def open_ids_on(key) = left_open.select { it.on?(key) }.map(&:id)
|
|
191
|
+
|
|
200
192
|
# The ids of the findings its audit resolved: those it fixed, and each prior finding decided resolved, never
|
|
201
193
|
# one withdrawn (#714).
|
|
202
194
|
#: (DecidedPriorFindings) -> Array[String]
|