principles 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/principles/cli.rb +7 -1
- data/lib/principles/command_line.rb +12 -29
- data/lib/principles/controllers/acknowledgement.rb +4 -4
- data/lib/principles/controllers/answer.rb +64 -100
- data/lib/principles/controllers/assessment.rb +108 -0
- data/lib/principles/controllers/audit.rb +29 -135
- data/lib/principles/controllers/audit_completion.rb +2 -4
- data/lib/principles/controllers/command.rb +27 -13
- data/lib/principles/controllers/correction.rb +4 -4
- data/lib/principles/controllers/full_audit_request.rb +180 -0
- data/lib/principles/controllers/inventory.rb +32 -70
- data/lib/principles/controllers/mapping.rb +3 -3
- data/lib/principles/controllers/member_entries.rb +24 -12
- data/lib/principles/controllers/member_problems_report.rb +72 -0
- data/lib/principles/controllers/members_a_commit_changed.rb +10 -2
- data/lib/principles/controllers/members_to_assess.rb +16 -9
- data/lib/principles/controllers/meta_principle_setup.rb +5 -5
- data/lib/principles/controllers/repoint.rb +1 -1
- data/lib/principles/controllers/running_tool.rb +1 -1
- data/lib/principles/data/audit_files.rb +11 -7
- data/lib/principles/data/bounded_file.rb +11 -0
- data/lib/principles/data/command-steps.json +7 -6
- data/lib/principles/data/map_files.rb +2 -2
- data/lib/principles/data/principles_subfolder.rb +8 -1
- data/lib/principles/data/project_files.rb +1 -7
- data/lib/principles/data/project_root.rb +48 -0
- data/lib/principles/data/schema_check.rb +23 -5
- data/lib/principles/data/schemas/assessment-answer.schema.json +18 -9
- data/lib/principles/data/schemas/audit-record.schema.json +3 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +2 -3
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/models/assessment_answer.rb +64 -17
- data/lib/principles/models/audit.rb +24 -15
- data/lib/principles/models/audit_record.rb +10 -3
- data/lib/principles/models/audit_records.rb +74 -4
- data/lib/principles/models/audit_start.rb +3 -3
- data/lib/principles/models/carried_assessments.rb +1 -1
- data/lib/principles/models/check_since_last_audit.rb +6 -6
- data/lib/principles/models/correction_basis.rb +1 -1
- data/lib/principles/models/decided_prior_findings.rb +9 -19
- data/lib/principles/models/declared_map_changes.rb +8 -8
- data/lib/principles/models/disposition.rb +28 -24
- data/lib/principles/models/evidence_replacements.rb +8 -1
- data/lib/principles/models/fix_only_fields.rb +67 -0
- data/lib/principles/models/kept_prior_finding.rb +12 -7
- data/lib/principles/models/loaded_files.rb +5 -3
- data/lib/principles/models/loading_decision.rb +9 -2
- data/lib/principles/models/{member_maps.rb → mapped_principles.rb} +15 -15
- data/lib/principles/models/member.rb +1 -1
- data/lib/principles/models/member_assessments.rb +48 -3
- data/lib/principles/models/member_grounds.rb +2 -2
- data/lib/principles/models/member_hashes_as_written.rb +40 -0
- data/lib/principles/models/member_moves.rb +3 -3
- data/lib/principles/models/member_problems.rb +38 -18
- data/lib/principles/models/members_sharing_lines.rb +3 -3
- data/lib/principles/models/new_findings.rb +55 -0
- data/lib/principles/models/open_finding.rb +23 -13
- data/lib/principles/models/other_principles.rb +1 -1
- data/lib/principles/models/other_templates_placeholders.rb +74 -0
- data/lib/principles/models/{member_map.rb → principle.rb} +45 -40
- data/lib/principles/models/{member_map_history.rb → principle_history.rb} +38 -15
- data/lib/principles/models/{map_members.rb → principle_members.rb} +4 -4
- data/lib/principles/models/prior_decision_fields.rb +46 -0
- data/lib/principles/models/prior_finding_decision.rb +24 -3
- data/lib/principles/models/prior_finding_outcomes.rb +10 -3
- data/lib/principles/models/prior_findings.rb +1 -1
- data/lib/principles/models/problem_report.rb +7 -3
- data/lib/principles/models/project.rb +27 -13
- data/lib/principles/models/project_history.rb +2 -2
- data/lib/principles/models/recent_decision.rb +90 -0
- data/lib/principles/models/record_format.rb +105 -0
- data/lib/principles/models/recorded_finding.rb +4 -0
- data/lib/principles/models/recorded_hashes.rb +39 -0
- data/lib/principles/models/recorded_members.rb +17 -12
- data/lib/principles/models/reported_check.rb +63 -11
- data/lib/principles/models/request_id.rb +24 -4
- data/lib/principles/models/sent_prior_decisions.rb +31 -0
- data/lib/principles/models/still_holds_restatement.rb +7 -10
- data/lib/principles/models/template_placeholders.rb +41 -0
- data/lib/principles/session_start_options.rb +29 -0
- data/lib/principles/start_audit_options.rb +37 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/answer_head.rb +29 -0
- data/lib/principles/views/assessed_members.rb +96 -0
- data/lib/principles/views/assessment_request.rb +51 -49
- data/lib/principles/views/audit_result.rb +38 -42
- data/lib/principles/views/check_result_template.rb +31 -10
- data/lib/principles/views/correction_request.rb +64 -0
- data/lib/principles/views/first_audit.rb +71 -0
- data/lib/principles/views/help.rb +3 -2
- data/lib/principles/views/loads_to_check_result.rb +11 -4
- data/lib/principles/views/map_added_to.rb +31 -0
- data/lib/principles/views/map_result.rb +37 -22
- data/lib/principles/views/members_a_commit_changed.rb +30 -10
- data/lib/principles/views/meta_principle_result.rb +3 -14
- data/lib/principles/views/principle_read_result.rb +27 -10
- data/lib/principles/views/prior_finding_decisions_result.rb +13 -14
- data/lib/principles/views/prior_findings_result.rb +7 -3
- data/lib/principles/views/problem_lines.rb +14 -11
- data/lib/principles/views/problem_result.rb +30 -16
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +3 -2
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +3 -6
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +4 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +7 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +22 -20
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +8 -5
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +3 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/select-the-project-root.md +1 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +6 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +3 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +8 -8
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +37 -37
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +1 -0
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +4 -0
- data/lib/principles/views/prompts/set-principles-up/first-keeping-audit-after-own-principle.md +10 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +2 -1
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +54 -0
- data/lib/principles/views/request_part.rb +14 -2
- data/lib/principles/views/request_parts.rb +4 -0
- metadata +33 -7
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
require_relative "../error"
|
|
5
5
|
require_relative "../data/audit_files"
|
|
6
6
|
require_relative "audit_record"
|
|
7
|
+
require_relative "member_hashes_as_written"
|
|
8
|
+
require_relative "recorded_hashes"
|
|
7
9
|
require_relative "project_history"
|
|
8
10
|
|
|
9
11
|
module Principles
|
|
@@ -24,15 +26,16 @@ module Principles
|
|
|
24
26
|
def at(id, commit)
|
|
25
27
|
[file(id), earlier_file(id)].each do |path|
|
|
26
28
|
text = @history.text_at(commit, path) or next
|
|
27
|
-
return [path, AuditRecord.new(@files.parse(id, text))]
|
|
29
|
+
return [path, AuditRecord.new(@files.parse(id, text) { refuse_unreadable(it, path) })]
|
|
28
30
|
end
|
|
29
31
|
nil
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
# id's record, or nil when it has none; Data::AuditFiles refuses one that is unparseable
|
|
34
|
+
# id's record, or nil when it has none; Data::AuditFiles refuses one that is unparseable, and one its schema
|
|
35
|
+
# refuses, unless a later copy wrote it (D85).
|
|
33
36
|
#: (String) -> AuditRecord?
|
|
34
37
|
def find(id)
|
|
35
|
-
fields = @files.read(id)
|
|
38
|
+
fields = @files.read(id) { refuse_unreadable(it, file(id)) }
|
|
36
39
|
fields && AuditRecord.new(fields)
|
|
37
40
|
end
|
|
38
41
|
|
|
@@ -46,10 +49,52 @@ module Principles
|
|
|
46
49
|
[]
|
|
47
50
|
end
|
|
48
51
|
|
|
52
|
+
# Refuses to let this copy, at version, rewrite id's record when a later copy wrote it at a newer format,
|
|
53
|
+
# read afresh so a record that lands mid-audit is caught too (D85).
|
|
54
|
+
#: (String, version: String) -> void
|
|
55
|
+
def refuse_newer(id, version:)
|
|
56
|
+
record = find(id) or return
|
|
57
|
+
RecordFormat.new(record.to_h).refuse_rewrite(file(id), version: version)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The format of id's record when a later copy wrote it, read whether or not this copy's schema accepts it; nil
|
|
61
|
+
# when it has none, is not newer, or is refused for another reason, which reading it reports (D85).
|
|
62
|
+
#: (String) -> RecordFormat?
|
|
63
|
+
def newer_format(id)
|
|
64
|
+
fields = @files.read(id) { |raw| return newer_of(raw) }
|
|
65
|
+
fields && newer_of(fields)
|
|
66
|
+
rescue Error
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Id's record, if this copy can read it, and the member hashes it holds, which its members are compared with:
|
|
71
|
+
# the record's own when this copy can read it, and as written when its schema refuses one a later copy wrote,
|
|
72
|
+
# marked waiting when a later copy wrote it, so the comparison is read-only (D85 V8, #1066, #1067).
|
|
73
|
+
#: (String) -> [AuditRecord?, RecordedHashes]
|
|
74
|
+
def for_comparison(id)
|
|
75
|
+
audit = find(id) or return [nil, RecordedHashes::NONE]
|
|
76
|
+
[audit, RecordedHashes.new(audit.members.hashes_by_key, waiting: RecordFormat.new(audit.to_h).newer?)]
|
|
77
|
+
rescue Error => e
|
|
78
|
+
raise unless e.payload.fetch("code") == "newer_audit_record"
|
|
79
|
+
|
|
80
|
+
[nil, RecordedHashes.new(member_hashes_as_written(id).by_key, waiting: true)]
|
|
81
|
+
end
|
|
82
|
+
|
|
49
83
|
# The record of each of ids that has one.
|
|
50
84
|
#: (Array[String]) -> Array[AuditRecord]
|
|
51
85
|
def of(ids) = ids.filter_map { |id| find(id) }
|
|
52
86
|
|
|
87
|
+
# The record of each of ids that this copy can read, leaving out one a later copy wrote that it cannot, so a
|
|
88
|
+
# read across principles is not refused for that one, whose audits wait on an upgrade (D85, V8).
|
|
89
|
+
#: (Array[String]) -> Array[AuditRecord]
|
|
90
|
+
def readable_of(ids)
|
|
91
|
+
ids.filter_map do |id|
|
|
92
|
+
find(id)
|
|
93
|
+
rescue Error => e
|
|
94
|
+
raise unless e.payload.fetch("code") == "newer_audit_record"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
53
98
|
# id's record, refused when it has none.
|
|
54
99
|
#: (String) -> AuditRecord
|
|
55
100
|
def fetch(id)
|
|
@@ -83,7 +128,7 @@ module Principles
|
|
|
83
128
|
#: (AuditRecord) -> String
|
|
84
129
|
def save(record)
|
|
85
130
|
id = record.principle_id
|
|
86
|
-
@files.write(id, record.
|
|
131
|
+
@files.write(id, record.stamped)
|
|
87
132
|
file(id)
|
|
88
133
|
end
|
|
89
134
|
|
|
@@ -98,6 +143,31 @@ module Principles
|
|
|
98
143
|
def earlier_file(id)
|
|
99
144
|
@files.earlier_relative(id)
|
|
100
145
|
end
|
|
146
|
+
|
|
147
|
+
private
|
|
148
|
+
|
|
149
|
+
# The member hashes of id's record as a later copy wrote it, read without this copy's schema, which refuses it;
|
|
150
|
+
# none when it cannot be parsed at all (#1066).
|
|
151
|
+
#: (String) -> MemberHashesAsWritten
|
|
152
|
+
def member_hashes_as_written(id)
|
|
153
|
+
fields = @files.read(id) { |raw| return MemberHashesAsWritten.new(raw) }
|
|
154
|
+
MemberHashesAsWritten.new(fields)
|
|
155
|
+
rescue Error
|
|
156
|
+
MemberHashesAsWritten.new(nil)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#: (untyped) -> RecordFormat?
|
|
160
|
+
def newer_of(fields)
|
|
161
|
+
format = RecordFormat.new(fields) if fields.is_a?(Hash)
|
|
162
|
+
format if format&.newer?
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Refuses fields, a record at file the schema refused, as one a later copy wrote when its format says so, so
|
|
166
|
+
# its repair is never to repair or restore a record that is not broken (D85, V3).
|
|
167
|
+
#: (untyped, String) -> void
|
|
168
|
+
def refuse_unreadable(fields, file)
|
|
169
|
+
RecordFormat.new(fields).refuse_unreadable(file) if fields.is_a?(Hash)
|
|
170
|
+
end
|
|
101
171
|
end
|
|
102
172
|
end
|
|
103
173
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative "assessment_report"
|
|
5
5
|
require_relative "json_digest"
|
|
6
|
-
require_relative "
|
|
6
|
+
require_relative "principle"
|
|
7
7
|
|
|
8
8
|
module Principles
|
|
9
9
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -21,10 +21,10 @@ module Principles
|
|
|
21
21
|
attr_reader :reported
|
|
22
22
|
|
|
23
23
|
# The map of the principle the audit is of.
|
|
24
|
-
#:
|
|
24
|
+
#: Principle
|
|
25
25
|
attr_reader :map
|
|
26
26
|
|
|
27
|
-
#: (map:
|
|
27
|
+
#: (map: Principle, base: String?, before: Hash[String, String], ?reported: AssessmentReport) -> void
|
|
28
28
|
def initialize(map:, base:, before:, reported: AssessmentReport::NONE)
|
|
29
29
|
@map = map
|
|
30
30
|
@base = base
|
|
@@ -16,7 +16,7 @@ module Principles
|
|
|
16
16
|
class CarriedAssessments
|
|
17
17
|
# record is the principle's audit record now, if any; members are the map's members now, with their hashes in
|
|
18
18
|
# now and their grounds; judged_against digests the description and question this audit asks.
|
|
19
|
-
#: (AuditRecord?, members:
|
|
19
|
+
#: (AuditRecord?, members: PrincipleMembers, judged_against: String, now: Hash[String, String],
|
|
20
20
|
#| grounds: MemberGrounds) -> void
|
|
21
21
|
def initialize(record, members:, judged_against:, now:, grounds:)
|
|
22
22
|
@last = record&.last_completed #: AuditRecord?
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
require_relative "../error"
|
|
5
5
|
require_relative "audit_record"
|
|
6
6
|
require_relative "member"
|
|
7
|
-
require_relative "
|
|
8
|
-
require_relative "
|
|
7
|
+
require_relative "principle_history"
|
|
8
|
+
require_relative "mapped_principles"
|
|
9
9
|
require_relative "project_history"
|
|
10
10
|
|
|
11
11
|
module Principles
|
|
@@ -16,11 +16,11 @@ module Principles
|
|
|
16
16
|
# committed map, and the audit asks the agent to run it, so a check no audit has seen needs a review
|
|
17
17
|
# first (#227). This tool states the fact; the review is the agent's step.
|
|
18
18
|
class CheckSinceLastAudit
|
|
19
|
-
#: (id: String, history: ProjectHistory,
|
|
20
|
-
def initialize(id:, history:,
|
|
19
|
+
#: (id: String, history: ProjectHistory, principles: MappedPrinciples, record: AuditRecord?) -> void
|
|
20
|
+
def initialize(id:, history:, principles:, record:)
|
|
21
21
|
@id = id
|
|
22
22
|
@history = history
|
|
23
|
-
@
|
|
23
|
+
@principles = principles
|
|
24
24
|
@record = record
|
|
25
25
|
freeze
|
|
26
26
|
end
|
|
@@ -53,7 +53,7 @@ module Principles
|
|
|
53
53
|
|
|
54
54
|
#: (String, String) -> String?
|
|
55
55
|
def commit_that_set(key, check)
|
|
56
|
-
run =
|
|
56
|
+
run = PrincipleHistory.new(id: @id, history: @history, principles: @principles).runs([key]).fetch(key)
|
|
57
57
|
run.take_while { |_sha, fields| Member.new(fields).check == check }.last&.first
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -58,7 +58,7 @@ module Principles
|
|
|
58
58
|
# The id of the correction request of principle_id for this basis, with each member's hash when the audit began.
|
|
59
59
|
#: (String, Hash[String, String]) -> RequestId
|
|
60
60
|
def request_id(principle_id, before)
|
|
61
|
-
RequestId.
|
|
61
|
+
RequestId.handing_back(principle_id: principle_id, phase: "correction", handed: @fields, parts: [before])
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# The last completed record's revision when the request was printed, which refuses a correction once that
|
|
@@ -54,25 +54,15 @@ module Principles
|
|
|
54
54
|
#: () -> Array[String]
|
|
55
55
|
def resolved_ids = closed.select { |each| each["decision"] == "resolved" }.map { |each| each.fetch("finding_id") }
|
|
56
56
|
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#: () -> Array[Hash[String, untyped]]
|
|
67
|
-
def waits_on_dropped
|
|
68
|
-
@fields.fetch("waits_on_dropped", [])
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Each kept evidence item a still_holds decision gave a new place, as it was and is now (D70). A correction
|
|
72
|
-
# basis printed before this was built carries none.
|
|
73
|
-
#: () -> Array[Hash[String, untyped]]
|
|
74
|
-
def evidence_replaced
|
|
75
|
-
@fields.fetch("evidence_replaced", [])
|
|
57
|
+
# What the decisions changed of the findings kept, each list by the name the completed result gives it after
|
|
58
|
+
# prior_findings_: each pointer a decision dropped with null, with the pointer it had (#374); each waits_on it
|
|
59
|
+
# dropped, with null or by accepting it, with the line and since it had (D52); each kept evidence item it gave a
|
|
60
|
+
# new place (D70); and each problem it restated (D82), each as it was and is now. A correction basis printed
|
|
61
|
+
# before a list was built carries none of it.
|
|
62
|
+
#: () -> Hash[String, Array[Hash[String, untyped]]]
|
|
63
|
+
def changed
|
|
64
|
+
{ "pointers_dropped" => @fields.fetch("dropped", []),
|
|
65
|
+
**%w[waits_on_dropped evidence_replaced problems_restated].to_h { |name| [name, @fields.fetch(name, [])] } }
|
|
76
66
|
end
|
|
77
67
|
|
|
78
68
|
# When the prior finding that the new finding id raises again was first raised, or nothing.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
-
require_relative "
|
|
5
|
+
require_relative "principle"
|
|
6
6
|
require_relative "member_moves"
|
|
7
7
|
|
|
8
8
|
module Principles
|
|
@@ -36,7 +36,7 @@ module Principles
|
|
|
36
36
|
# The base commit, to read there the map the audit began from, or nil when nothing is declared and current is
|
|
37
37
|
# still at map_version, the version the audit began from. Outside git, a map that changed is refused, as are
|
|
38
38
|
# declared changes, since there is no base map to check them against.
|
|
39
|
-
#: (String?,
|
|
39
|
+
#: (String?, Principle, map_version: String, map_file: String) -> String?
|
|
40
40
|
def base_to_read(base, current, map_version:, map_file:)
|
|
41
41
|
return check_in_git(base, principle_id: current.id) unless empty?
|
|
42
42
|
return if current.version == map_version
|
|
@@ -59,7 +59,7 @@ module Principles
|
|
|
59
59
|
|
|
60
60
|
# Refuses unless base is the map the audit began from and current is base with exactly the declared
|
|
61
61
|
# members moved, the claimed members' role and check changed, and any members added (T69).
|
|
62
|
-
#: (
|
|
62
|
+
#: (Principle, Principle, map_version: String, map_file: String) -> void
|
|
63
63
|
def check(base, current, map_version:, map_file:)
|
|
64
64
|
raise unexplained(current.id, map_file) unless base.version == map_version
|
|
65
65
|
|
|
@@ -70,7 +70,7 @@ module Principles
|
|
|
70
70
|
# Each claimed member's role and check, as was and now, where they differ between the base map with the
|
|
71
71
|
# declared moves applied, which check compares, and current. The block gives [base, current], and is
|
|
72
72
|
# called only when a fix claims an entry, so nothing else reads the base map (#462).
|
|
73
|
-
#: () { () -> [
|
|
73
|
+
#: () { () -> [Principle, Principle] } -> Array[Hash[String, untyped]]
|
|
74
74
|
def entry_changes(&)
|
|
75
75
|
return [] if @entries.empty?
|
|
76
76
|
|
|
@@ -89,7 +89,7 @@ module Principles
|
|
|
89
89
|
private
|
|
90
90
|
|
|
91
91
|
# expected with each member of current whose id it lacks added, as add-member adds it.
|
|
92
|
-
#: (
|
|
92
|
+
#: (Principle, Principle) -> Principle
|
|
93
93
|
def with_added(expected, current)
|
|
94
94
|
added = current.members.ids - expected.members.ids
|
|
95
95
|
added.reduce(expected) { |map, id| map.adding(current.member(id)) }
|
|
@@ -102,7 +102,7 @@ module Principles
|
|
|
102
102
|
|
|
103
103
|
# The map with the claimed member's role and check as current holds them, refused when they are as
|
|
104
104
|
# they were at the base commit.
|
|
105
|
-
#: (
|
|
105
|
+
#: (Principle, Principle, String) -> Principle
|
|
106
106
|
def claimed_entry(map, current, id)
|
|
107
107
|
unless current.members.taken?(id)
|
|
108
108
|
raise Error.new("unknown_member", "#{id} is not a member of #{current.id}",
|
|
@@ -118,7 +118,7 @@ module Principles
|
|
|
118
118
|
|
|
119
119
|
# The map with the member's role and check changed to now's, as change-member-role, change-member-check
|
|
120
120
|
# and remove-member-check changed them.
|
|
121
|
-
#: (
|
|
121
|
+
#: (Principle, String, Hash[String, untyped]) -> Principle
|
|
122
122
|
def replayed(map, id, now)
|
|
123
123
|
roled = map.changing_role(id, now.fetch("role"))
|
|
124
124
|
return roled.changing_check(id, now.fetch("check")) if now.key?("check")
|
|
@@ -132,7 +132,7 @@ module Principles
|
|
|
132
132
|
{ "member_id" => id, **changed.to_h { |field| [field, { "was" => was[field], "now" => now[field] }] } }
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
#: (
|
|
135
|
+
#: (Principle, Principle, String) -> bool
|
|
136
136
|
def as_at_base?(map, current, id)
|
|
137
137
|
map.member(id).slice("role", "check") == current.member(id).slice("role", "check")
|
|
138
138
|
end
|
|
@@ -5,6 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "answer_fields"
|
|
6
6
|
require_relative "answer_place"
|
|
7
7
|
require_relative "answer_text"
|
|
8
|
+
require_relative "fix_only_fields"
|
|
8
9
|
require_relative "waits_on"
|
|
9
10
|
require_relative "write_up_pointer"
|
|
10
11
|
|
|
@@ -75,11 +76,20 @@ module Principles
|
|
|
75
76
|
TEXT_FIELDS = {
|
|
76
77
|
"reason" => TextField.new(placeholder: "Why, and what remains",
|
|
77
78
|
repair: "Write why you chose this action and what remains."),
|
|
78
|
-
"reassessment" => TextField.new(placeholder: "
|
|
79
|
+
"reassessment" => TextField.new(placeholder: "fixed only: how the changed members now carry the " \
|
|
80
|
+
"principle. Leave as printed otherwise",
|
|
79
81
|
repair: "Write how the changed members now carry the principle.")
|
|
80
82
|
}.freeze #: Hash[String, TextField]
|
|
81
83
|
# The placeholder in each field, which the template prints.
|
|
82
84
|
PLACEHOLDERS = TEXT_FIELDS.transform_values(&:placeholder).freeze #: Hash[String, String]
|
|
85
|
+
# What action takes, said where it is written when the correction's answer is printed with no answer guide
|
|
86
|
+
# beside it, as show-answer-check prints it (D81 step 3). It is help, never an action, so it is left unchosen.
|
|
87
|
+
ACTION_PLACEHOLDER = "One of fixed, deferred, accepted or disagreed, each with a reason: fixed lists " \
|
|
88
|
+
"changed_members and evidence and gives a reassessment; deferred gives recorded_at, " \
|
|
89
|
+
"where the write-up is, and may give waits_on; any other action leaves changed_members, " \
|
|
90
|
+
"evidence and reassessment as printed" #: String
|
|
91
|
+
# Every placeholder a correction's template prints: each text field's, and the action's.
|
|
92
|
+
TEMPLATE_PLACEHOLDERS = PLACEHOLDERS.merge("action" => ACTION_PLACEHOLDER).freeze #: Hash[String, String]
|
|
83
93
|
|
|
84
94
|
# at is the disposition's place in the answer, such as /dispositions/0, which a refusal about its pointers names.
|
|
85
95
|
# samples is the answer guide's disposition for each action, whose text illustrates each field (#789).
|
|
@@ -105,19 +115,21 @@ module Principles
|
|
|
105
115
|
#: () -> bool
|
|
106
116
|
def fixed? = action == "fixed"
|
|
107
117
|
|
|
108
|
-
# The members a fix says it changed.
|
|
118
|
+
# The members a fix says it changed; none from a disposition that omits them, as one not fixed may (#997).
|
|
109
119
|
#: () -> Array[String]
|
|
110
|
-
def changed_members = @disposition.fetch("changed_members")
|
|
120
|
+
def changed_members = @disposition.fetch("changed_members", [])
|
|
111
121
|
|
|
112
122
|
# The file where the finding is written up, if anywhere.
|
|
113
123
|
#: () -> String?
|
|
114
124
|
def recorded_path = recorded_at&.path
|
|
115
125
|
|
|
116
|
-
# What the audit record keeps of this disposition beside its finding: the action,
|
|
117
|
-
#
|
|
126
|
+
# What the audit record keeps of this disposition beside its finding: the action, and why a finding left
|
|
127
|
+
# unfixed was left so, which a fix's reassessment answers instead (#996); where the finding is written up and
|
|
128
|
+
# what a deferral waits on, when given (D52).
|
|
118
129
|
#: () -> Hash[String, untyped]
|
|
119
130
|
def recorded_outcome
|
|
120
|
-
{ "action" => action, "
|
|
131
|
+
{ "action" => action, "reason" => (@disposition["reason"] unless fixed?), "recorded_at" => recorded_at&.to_h,
|
|
132
|
+
"waits_on" => @disposition["waits_on"] }.compact
|
|
121
133
|
end
|
|
122
134
|
|
|
123
135
|
# Where the finding is written up, if anywhere, as checked_fields located it.
|
|
@@ -140,21 +152,22 @@ module Principles
|
|
|
140
152
|
def claimed_members(changed)
|
|
141
153
|
action = @disposition["action"]
|
|
142
154
|
checked_fields
|
|
143
|
-
members = @fields.array(
|
|
155
|
+
members = @fields.array(fix_fields.list("changed_members"), "changed_members")
|
|
144
156
|
entries = @disposition.fetch("changed_map_entries", [])
|
|
145
|
-
action == "fixed" ? fixed_members(members, entries, changed) : unclaimed(members, entries)
|
|
157
|
+
action == "fixed" ? fixed_members(members, entries, changed) : fix_fields.unclaimed(members, entries)
|
|
146
158
|
end
|
|
147
159
|
|
|
148
160
|
private
|
|
149
161
|
|
|
150
|
-
# The template leaves each action null, since choosing it is the agent's call; a null
|
|
151
|
-
# left for the agent, with the four to choose from (#708).
|
|
162
|
+
# The template leaves each action null, or as its placeholder, since choosing it is the agent's call; a null,
|
|
163
|
+
# placeholder or unknown one is left for the agent, with the four to choose from (#708).
|
|
152
164
|
#: () -> UnfinishedField?
|
|
153
165
|
def unchosen_action
|
|
154
166
|
action = @disposition["action"]
|
|
155
167
|
return if ACTIONS.include?(action)
|
|
156
168
|
|
|
157
|
-
|
|
169
|
+
unchosen = action.nil? || action == ACTION_PLACEHOLDER
|
|
170
|
+
problem = unchosen ? "is not chosen" : "is #{action.inspect}, not one of the four"
|
|
158
171
|
UnfinishedField.new(@place.child("action"), "action",
|
|
159
172
|
problem:, repair: "Set its action to one of fixed, deferred, accepted or disagreed.")
|
|
160
173
|
end
|
|
@@ -201,10 +214,13 @@ module Principles
|
|
|
201
214
|
.check(code: "invalid_disposition", subject: "Finding #{finding_id}")
|
|
202
215
|
end
|
|
203
216
|
|
|
217
|
+
#: () -> FixOnlyFields
|
|
218
|
+
def fix_fields = FixOnlyFields.new(@disposition, left_reassessment: PLACEHOLDERS.fetch("reassessment"))
|
|
219
|
+
|
|
204
220
|
# Each piece of evidence, and where the finding is written up, located in the project.
|
|
205
221
|
#: () -> void
|
|
206
222
|
def locate_pointers
|
|
207
|
-
@fields.evidence(
|
|
223
|
+
@fields.evidence(fix_fields.list("evidence"), @place.child("evidence"))
|
|
208
224
|
@fields.pointer(@disposition["recorded_at"], @place.child("recorded_at")) if @disposition["recorded_at"]
|
|
209
225
|
end
|
|
210
226
|
|
|
@@ -216,18 +232,6 @@ module Principles
|
|
|
216
232
|
"Set recorded_at to where the finding is written up, as {\"path\": ..., \"heading\": ...}, " \
|
|
217
233
|
"or to null when it is written up nowhere.")
|
|
218
234
|
end
|
|
219
|
-
|
|
220
|
-
#: (Array[untyped], Array[untyped]) -> Array[untyped]
|
|
221
|
-
def unclaimed(members, entries)
|
|
222
|
-
unless entries.empty?
|
|
223
|
-
raise Error.new("invalid_disposition", "Only a fixed disposition may list changed_map_entries",
|
|
224
|
-
"Mark it fixed with a reassessment, or omit changed_map_entries.")
|
|
225
|
-
end
|
|
226
|
-
return [] if members.empty?
|
|
227
|
-
|
|
228
|
-
raise Error.new("invalid_disposition", "Only a fixed disposition may claim changed members",
|
|
229
|
-
"Mark it fixed with a reassessment, or omit changed_members.")
|
|
230
|
-
end
|
|
231
235
|
end
|
|
232
236
|
end
|
|
233
237
|
end
|
|
@@ -68,7 +68,7 @@ module Principles
|
|
|
68
68
|
unnamed(id, refuse) if named.any?(nil)
|
|
69
69
|
stray = named.grep_v(0...@kept.size).first
|
|
70
70
|
if stray
|
|
71
|
-
refuse.call(
|
|
71
|
+
refuse.call(stray_problem(stray),
|
|
72
72
|
"Name by replaces a position in #{id}'s evidence, from 0 to #{@kept.size - 1}.")
|
|
73
73
|
end
|
|
74
74
|
twice = named.find { |index| named.count(index) > 1 } or return
|
|
@@ -76,6 +76,13 @@ module Principles
|
|
|
76
76
|
"Give each item of #{id}'s evidence at most one entry in its problem_evidence.")
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# What is wrong with a replaces naming no kept item: text is only ever the template's placeholder, which the
|
|
80
|
+
# answer's schema lets through for it (#1043).
|
|
81
|
+
#: (untyped) -> String
|
|
82
|
+
def stray_problem(stray)
|
|
83
|
+
stray.is_a?(String) ? "replaces is left as printed" : "replaces #{stray} names no item of its evidence"
|
|
84
|
+
end
|
|
85
|
+
|
|
79
86
|
# Refuses entries that do not say which kept item each replaces, since the record keeps the evidence it was
|
|
80
87
|
# raised with.
|
|
81
88
|
#: (String, ^(String, String?) -> void) -> void
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "answer_text"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# The fields of a disposition that only a fix uses, changed_members, changed_map_entries, evidence and
|
|
11
|
+
# reassessment, and what its action allows of them: a fix gives them, and any other action may omit them, or leave
|
|
12
|
+
# them as printed, and claims no change (#997).
|
|
13
|
+
class FixOnlyFields
|
|
14
|
+
# disposition is the disposition as the agent gave it; left_reassessment is the reassessment its template
|
|
15
|
+
# prints, which a disposition not fixed leaves as printed.
|
|
16
|
+
#: (Hash[String, untyped], left_reassessment: String) -> void
|
|
17
|
+
def initialize(disposition, left_reassessment:)
|
|
18
|
+
@disposition = disposition
|
|
19
|
+
@left_reassessment = left_reassessment
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The list field name gives, as given, or an empty list when a disposition not fixed omits it; a fix omitting
|
|
24
|
+
# it is refused, naming the field.
|
|
25
|
+
#: (String) -> untyped
|
|
26
|
+
def list(name) = @disposition.fetch(name) { fixed? ? missing_from_fix(name) : [] }
|
|
27
|
+
|
|
28
|
+
# The members a disposition not fixed claims, none, refusing one that lists changed members or map entries,
|
|
29
|
+
# writes a reassessment or lists evidence, each of which it would drop unread though the agent may have meant
|
|
30
|
+
# a fix.
|
|
31
|
+
#: (Array[untyped], Array[untyped]) -> Array[untyped]
|
|
32
|
+
def unclaimed(members, entries)
|
|
33
|
+
unless entries.empty?
|
|
34
|
+
raise Error.new("invalid_disposition", "Only a fixed disposition may list changed_map_entries",
|
|
35
|
+
"Mark it fixed with a reassessment, or omit changed_map_entries.")
|
|
36
|
+
end
|
|
37
|
+
fix_text_unclaimed
|
|
38
|
+
return [] if members.empty?
|
|
39
|
+
|
|
40
|
+
raise Error.new("invalid_disposition", "Only a fixed disposition may claim changed members",
|
|
41
|
+
"Mark it fixed with a reassessment, or omit changed_members.")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
#: () -> bool
|
|
47
|
+
def fixed? = @disposition["action"] == "fixed"
|
|
48
|
+
|
|
49
|
+
#: (String) -> bot
|
|
50
|
+
def missing_from_fix(name)
|
|
51
|
+
raise Error.new("invalid_disposition", "Finding #{@disposition["finding_id"]} is fixed, so it needs #{name}",
|
|
52
|
+
"List in #{name} what the fix changed, or choose another action.")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Refuses a reassessment written, or evidence listed, on a disposition not fixed; each left as printed is not
|
|
56
|
+
# given.
|
|
57
|
+
#: () -> void
|
|
58
|
+
def fix_text_unclaimed
|
|
59
|
+
reassessment = @disposition["reassessment"]
|
|
60
|
+
written = reassessment != @left_reassessment && AnswerText.new(reassessment).written?
|
|
61
|
+
field = ("reassessment" if written) || ("evidence" unless list("evidence").empty?) or return
|
|
62
|
+
raise Error.new("invalid_disposition", "Only a fixed disposition may give #{field}",
|
|
63
|
+
"Mark it fixed, or leave #{field} as printed.")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "first_raised_claim"
|
|
5
|
-
require_relative "
|
|
5
|
+
require_relative "principle_members"
|
|
6
6
|
require_relative "open_finding"
|
|
7
7
|
require_relative "waits_on"
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ module Principles
|
|
|
14
14
|
class KeptPriorFinding
|
|
15
15
|
# decision is the checked still_holds decision on finding, the prior finding as its record left it open; members
|
|
16
16
|
# are the map's members now, under whose ids it is recorded.
|
|
17
|
-
#: (Hash[String, untyped], OpenFinding,
|
|
17
|
+
#: (Hash[String, untyped], OpenFinding, PrincipleMembers) -> void
|
|
18
18
|
def initialize(decision, finding, members)
|
|
19
19
|
@decision = decision
|
|
20
20
|
@finding = finding
|
|
@@ -22,9 +22,10 @@ module Principles
|
|
|
22
22
|
freeze
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# The finding as the record keeps it, with any problem,
|
|
26
|
-
# first_raised_at it claimed with the commit it cited (D53); a null pointer drops the one
|
|
27
|
-
# as OpenFinding#evidence_after says, from its own state rather than as the request
|
|
25
|
+
# The finding as the record keeps it, with any problem, pointer, or action and its reason, its decision gave
|
|
26
|
+
# (#996), and any earlier first_raised_at it claimed with the commit it cited (D53); a null pointer drops the one
|
|
27
|
+
# it had. Its evidence is as OpenFinding#evidence_after says, from its own state rather than as the request
|
|
28
|
+
# printed it (D64, D70).
|
|
28
29
|
#: () -> Hash[String, untyped]
|
|
29
30
|
def to_h = @record
|
|
30
31
|
|
|
@@ -45,16 +46,20 @@ module Principles
|
|
|
45
46
|
{ "finding_id" => @finding.id, **@finding.waiting }
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
# The problem its decision restated, as it was and is now, or nil when it restated none (D82).
|
|
50
|
+
#: () -> Hash[String, String]?
|
|
51
|
+
def problem_restated = @finding.restated(@decision["problem"])
|
|
52
|
+
|
|
48
53
|
# Each kept evidence item its decision gave a new place, as it was and is now (D70).
|
|
49
54
|
#: () -> Array[Hash[String, untyped]]
|
|
50
55
|
def swaps = @finding.replacements(@decision["problem_evidence"]).swaps(@finding.id)
|
|
51
56
|
|
|
52
57
|
private
|
|
53
58
|
|
|
54
|
-
#: (
|
|
59
|
+
#: (PrincipleMembers) -> Hash[String, untyped]
|
|
55
60
|
def record(members)
|
|
56
61
|
kept = @finding.kept_against(members)
|
|
57
|
-
.merge(@decision.slice("problem", "action", "recorded_at", *FirstRaisedClaim::FIELDS),
|
|
62
|
+
.merge(@decision.slice("problem", "action", "reason", "recorded_at", *FirstRaisedClaim::FIELDS),
|
|
58
63
|
{ "evidence" => @finding.evidence_after(@decision["problem_evidence"]) }).compact
|
|
59
64
|
kept.merge(waiting_after(kept))
|
|
60
65
|
end
|
|
@@ -13,7 +13,7 @@ module Principles
|
|
|
13
13
|
# size and is not totalled.
|
|
14
14
|
class LoadedFiles
|
|
15
15
|
# The files members load, each read whole once, as files hold it.
|
|
16
|
-
#: (Data::ProjectFiles,
|
|
16
|
+
#: (Data::ProjectFiles, PrincipleMembers, hooks: HookCommands) -> LoadedFiles
|
|
17
17
|
def self.read(files, members, hooks:)
|
|
18
18
|
new(members.paths.to_h { |path| [path, MemberLoads.of_file(files, path, hooks: hooks)] })
|
|
19
19
|
end
|
|
@@ -25,13 +25,15 @@ module Principles
|
|
|
25
25
|
freeze
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
# files_loaded and session_start_total,
|
|
28
|
+
# The aggregate's derivation basis, files_loaded and session_start_total, empty lists/totals omitted.
|
|
29
29
|
#: () -> Hash[String, untyped]
|
|
30
30
|
def to_h
|
|
31
31
|
return {} if @loads.empty?
|
|
32
32
|
|
|
33
33
|
total = session_start_total
|
|
34
|
-
{ "
|
|
34
|
+
{ "loading_basis" => { "host" => "claude_code", "kind" => "documented_prediction",
|
|
35
|
+
"session_start_assumption" => "project_root" },
|
|
36
|
+
"files_loaded" => @loads.map { |path, file| { "path" => path }.merge(file.claude_code) },
|
|
35
37
|
**(total ? { "session_start_total" => total } : {}) }
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
5
|
require_relative "answer_text"
|
|
6
|
+
require_relative "template_placeholders"
|
|
6
7
|
|
|
7
8
|
module Principles
|
|
8
9
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -11,10 +12,16 @@ module Principles
|
|
|
11
12
|
# activation (#355). Whether the member should load as it does is the agent's judgement; this tool checks the
|
|
12
13
|
# decision's shape.
|
|
13
14
|
class LoadingDecision
|
|
14
|
-
#
|
|
15
|
+
# The reason start-audit --as template prints in each decision, which left as printed is not given (#994).
|
|
16
|
+
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
17
|
+
{ "reason" => "One line saying why the member loads as it does" }
|
|
18
|
+
) #: TemplatePlaceholders
|
|
19
|
+
|
|
20
|
+
# decision is as the answer gave it, a reason left as its placeholder not given; index is its place in
|
|
21
|
+
# loading_decisions.
|
|
15
22
|
#: (untyped, Integer) -> void
|
|
16
23
|
def initialize(decision, index)
|
|
17
|
-
@decision = decision.is_a?(Hash) ? decision : {} #: Hash[String, untyped]
|
|
24
|
+
@decision = decision.is_a?(Hash) ? PLACEHOLDERS.given(decision) : {} #: Hash[String, untyped]
|
|
18
25
|
@index = index
|
|
19
26
|
freeze
|
|
20
27
|
end
|