principles 0.0.11 → 0.1.0
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/CHANGELOG.md +31 -0
- data/lib/principles/controllers/answer.rb +2 -2
- data/lib/principles/controllers/assessment.rb +19 -3
- data/lib/principles/controllers/audit.rb +14 -4
- data/lib/principles/controllers/full_audit_request.rb +16 -10
- data/lib/principles/controllers/guidance_search_paths.rb +1 -1
- data/lib/principles/controllers/member_addition.rb +4 -1
- data/lib/principles/controllers/member_problems_report.rb +7 -6
- data/lib/principles/controllers/open_finding_decisions.rb +66 -0
- data/lib/principles/controllers/running_tool.rb +22 -5
- data/lib/principles/controllers/survey.rb +3 -2
- data/lib/principles/data/candidate_files_found.rb +6 -4
- data/lib/principles/data/command-steps.json +17 -17
- data/lib/principles/data/json_text.rb +5 -1
- data/lib/principles/data/parser_message.rb +61 -0
- data/lib/principles/data/project_files.rb +4 -2
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/audit-record.schema.json +15 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/{repointing-answer.schema.json → deciding-answer.schema.json} +12 -6
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/launch.rb +5 -3
- data/lib/principles/models/after_commit_input.rb +1 -0
- data/lib/principles/models/assessment_basis.rb +1 -1
- data/lib/principles/models/audit.rb +23 -3
- data/lib/principles/models/audit_entry_protecting_map.rb +1 -0
- data/lib/principles/models/audit_record.rb +5 -14
- data/lib/principles/models/audit_records.rb +1 -1
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +1 -1
- data/lib/principles/models/candidate_inventory.rb +19 -9
- data/lib/principles/models/candidate_outline.rb +1 -1
- data/lib/principles/models/changed_regions.rb +1 -1
- data/lib/principles/models/command_steps.rb +1 -2
- data/lib/principles/models/correction_basis.rb +1 -1
- data/lib/principles/models/declared_map_changes.rb +1 -2
- data/lib/principles/models/finding_decision.rb +84 -0
- data/lib/principles/models/finding_write_ups.rb +2 -1
- data/lib/principles/models/first_full_audit.rb +1 -0
- data/lib/principles/models/frontmatter_fields.rb +1 -1
- data/lib/principles/models/guidance_search_path.rb +1 -1
- data/lib/principles/models/guidance_search_paths.rb +5 -1
- data/lib/principles/models/head_moves.rb +1 -0
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +1 -1
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/json_path_selectors.rb +1 -1
- data/lib/principles/models/json_path_string.rb +1 -1
- data/lib/principles/models/last_completed_revision.rb +1 -1
- data/lib/principles/models/line_diff.rb +1 -1
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/loading_scope.rb +1 -0
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/map_change.rb +66 -0
- data/lib/principles/models/mapped_principles.rb +4 -0
- data/lib/principles/models/markdown_file.rb +22 -1
- data/lib/principles/models/member.rb +1 -1
- data/lib/principles/models/member_elsewhere.rb +1 -1
- data/lib/principles/models/member_file.rb +6 -1
- data/lib/principles/models/member_hashes_as_written.rb +2 -2
- data/lib/principles/models/member_history.rb +1 -1
- data/lib/principles/models/member_lines.rb +1 -1
- data/lib/principles/models/member_loading_scopes.rb +1 -0
- data/lib/principles/models/member_mapping_run.rb +4 -4
- data/lib/principles/models/member_moves.rb +1 -2
- data/lib/principles/models/member_problems.rb +5 -1
- data/lib/principles/models/member_region.rb +1 -1
- data/lib/principles/models/members_elsewhere.rb +1 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +1 -0
- data/lib/principles/models/members_sharing_lines.rb +1 -1
- data/lib/principles/models/misspelt_member_id.rb +1 -1
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/open_findings_decision.rb +124 -0
- data/lib/principles/models/open_findings_elsewhere.rb +1 -1
- data/lib/principles/models/other_templates_placeholders.rb +1 -0
- data/lib/principles/models/outline_budget.rb +1 -1
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +1 -1
- data/lib/principles/models/part_named.rb +1 -1
- data/lib/principles/models/plain_text_file.rb +1 -1
- data/lib/principles/models/principle_history.rb +3 -3
- data/lib/principles/models/principle_members.rb +1 -1
- data/lib/principles/models/problem_report.rb +13 -1
- data/lib/principles/models/project.rb +8 -3
- data/lib/principles/models/project_at_commit.rb +9 -19
- data/lib/principles/models/prose_line.rb +36 -0
- data/lib/principles/models/record_format.rb +17 -4
- data/lib/principles/models/recorded_finding.rb +47 -7
- data/lib/principles/models/recorded_findings.rb +7 -7
- data/lib/principles/models/recorded_hashes.rb +1 -1
- data/lib/principles/models/recorded_members.rb +6 -8
- data/lib/principles/models/report_hooks.rb +1 -0
- data/lib/principles/models/request_id.rb +2 -2
- data/lib/principles/models/sent_answer.rb +1 -0
- data/lib/principles/models/session_start_input.rb +1 -0
- data/lib/principles/models/stale_request.rb +22 -8
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/survey_search_paths.rb +13 -5
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/unchecked_members.rb +1 -0
- data/lib/principles/models/uncommitted_outside_the_map.rb +1 -1
- data/lib/principles/models/unknown_principle.rb +1 -0
- data/lib/principles/models/write_up_opening.rb +5 -31
- data/lib/principles/models/write_up_pointer.rb +2 -1
- data/lib/principles/start_audit_options.rb +25 -18
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +12 -9
- data/lib/principles/views/added_member.rb +10 -1
- data/lib/principles/views/answer_in_a_file.rb +16 -4
- data/lib/principles/views/assessment_answer_guide.rb +59 -0
- data/lib/principles/views/assessment_request.rb +2 -26
- data/lib/principles/views/audit_result.rb +15 -6
- data/lib/principles/views/candidate_files_result.rb +9 -4
- data/lib/principles/views/context_parts.rb +40 -9
- data/lib/principles/views/correction_request.rb +8 -5
- data/lib/principles/views/first_audit_brief.rb +2 -1
- data/lib/principles/views/guidance_search_paths_result.rb +13 -6
- data/lib/principles/views/invocation.rb +14 -4
- data/lib/principles/views/json_on_one_line.rb +18 -0
- data/lib/principles/views/open_findings_decision_result.rb +60 -0
- data/lib/principles/views/problem_facts.rb +46 -0
- data/lib/principles/views/problem_result.rb +42 -31
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +2 -1
- data/lib/principles/views/prompts/decide-open-findings/give-only-what-changed-of-each.md +6 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/where-a-survey-with-only-looks.md +4 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +1 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +8 -8
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- metadata +14 -7
- data/lib/principles/controllers/repoint.rb +0 -67
- data/lib/principles/models/repoint.rb +0 -125
- data/lib/principles/models/write_up_repoint.rb +0 -38
- data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +0 -10
- data/lib/principles/views/repoint_result.rb +0 -80
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "time"
|
|
5
|
-
require_relative "answer_phase"
|
|
6
|
-
require_relative "../models/finding_write_ups"
|
|
7
|
-
require_relative "../models/repoint"
|
|
8
|
-
require_relative "../views/repoint_result"
|
|
9
|
-
|
|
10
|
-
require_relative "../views/answered_request"
|
|
11
|
-
|
|
12
|
-
module Principles
|
|
13
|
-
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
14
|
-
# controllers/CLAUDE.md owns the boundary.
|
|
15
|
-
module Controllers
|
|
16
|
-
# A repoint of a principle's open findings' write-ups: start-audit ID --write-ups lists each open finding
|
|
17
|
-
# with where its write-up is now, and submit-answer points the recorded_at the agent gives in the audit record.
|
|
18
|
-
class Repoint < AnswerPhase
|
|
19
|
-
# The request for principle id's open findings.
|
|
20
|
-
#: (String) -> Hash[String, untyped]
|
|
21
|
-
def start(id)
|
|
22
|
-
naming_the_executable do
|
|
23
|
-
record = @audit_records.find(id)
|
|
24
|
-
repoint = repoint_of(id, record)
|
|
25
|
-
findings = Models::FindingWriteUps.of(@project, [record].compact).listed
|
|
26
|
-
view.request(request_id: repoint.request_id.to_s, principle_id: id, revision: repoint.revision,
|
|
27
|
-
findings: findings).merge("wrote" => [])
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# The result of answering, and the record it changes, not yet written, which the repoint refuses once the last
|
|
32
|
-
# completed record changed after the request was printed, unless it writes nothing.
|
|
33
|
-
# @override
|
|
34
|
-
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
35
|
-
def answered(submitted)
|
|
36
|
-
id = submitted.request_id.principle_id
|
|
37
|
-
response = submitted.response
|
|
38
|
-
repoint = repoint_of(id, @audit_records.find(id))
|
|
39
|
-
repointed, changes = repoint.writable(response, records: @audit_records, at: Time.now.utc.iso8601) do |locator|
|
|
40
|
-
snapshot(locator)
|
|
41
|
-
end
|
|
42
|
-
[Views::AnsweredRequest.new(view.repointed(principle_id: id, file: @audit_records.file(id),
|
|
43
|
-
outcome: outcome(repoint, repointed))), changes]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
# The repoint of principle id's open findings, as its record holds them.
|
|
49
|
-
#: (String, Models::AuditRecord?) -> Models::Repoint
|
|
50
|
-
def repoint_of(id, record) = Models::Repoint.new(principle_id: id, record: record, history: @history)
|
|
51
|
-
|
|
52
|
-
# What the repoint did, and each other principle's open finding whose write-up cannot be found (T16).
|
|
53
|
-
#: (Models::Repoint, Models::AuditRecord) -> Views::RepointResult::Outcome
|
|
54
|
-
def outcome(repoint, repointed)
|
|
55
|
-
others = @audit_records.of(@principles.ids - [repointed.principle_id])
|
|
56
|
-
Views::RepointResult::Outcome.new(repointed: repoint.moved_ids(repointed),
|
|
57
|
-
unchanged: repoint.unchanged_ids(repointed),
|
|
58
|
-
not_found_elsewhere: Models::FindingWriteUps.of(@project, others).not_found)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
#: () -> Views::RepointResult
|
|
62
|
-
def view
|
|
63
|
-
Views::RepointResult.new(invocation)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "../error"
|
|
5
|
-
require_relative "answer_fields"
|
|
6
|
-
require_relative "answer_place"
|
|
7
|
-
require_relative "audit_record"
|
|
8
|
-
require_relative "audit_records"
|
|
9
|
-
require_relative "last_completed_revision"
|
|
10
|
-
require_relative "project_history"
|
|
11
|
-
require_relative "request_id"
|
|
12
|
-
require_relative "write_up_repoint"
|
|
13
|
-
|
|
14
|
-
module Principles
|
|
15
|
-
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
16
|
-
module Models
|
|
17
|
-
# A repoint of a principle's open findings' write-ups without a full audit: the agent, having checked
|
|
18
|
-
# where a write-up moved to, gives each finding it names a new recorded_at, and the last completed record keeps
|
|
19
|
-
# it, with where it pointed before, when and why. Judging that the new place holds the write-up is the agent's.
|
|
20
|
-
class Repoint
|
|
21
|
-
PHASE = "repointing"
|
|
22
|
-
|
|
23
|
-
# record is the principle's audit record now; history says whether a new pointer's file is committed.
|
|
24
|
-
#: (principle_id: String, record: AuditRecord?, history: ProjectHistory) -> void
|
|
25
|
-
def initialize(principle_id:, record:, history:)
|
|
26
|
-
@principle_id = principle_id
|
|
27
|
-
@record = record
|
|
28
|
-
@history = history
|
|
29
|
-
freeze
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# The request's id, digesting the last completed record's revision it was printed after, so an answer is
|
|
33
|
-
# matched to the record it read.
|
|
34
|
-
#: () -> RequestId
|
|
35
|
-
def request_id = RequestId.for(principle_id: @principle_id, phase: PHASE, parts: [revision])
|
|
36
|
-
|
|
37
|
-
# The completed record's revision, which the request prints and the answer hands back.
|
|
38
|
-
#: () -> String
|
|
39
|
-
def revision = completed.revision
|
|
40
|
-
|
|
41
|
-
# The record with each repoint the answer gives in it, once each names a different open finding and each new
|
|
42
|
-
# pointer is located by the block, in a committed file; a repoint whose recorded_at is null leaves its
|
|
43
|
-
# finding as it is.
|
|
44
|
-
#: (untyped, at: String) { (Locator) -> void } -> AuditRecord
|
|
45
|
-
def accepted(response, at:, &locate)
|
|
46
|
-
fields = AnswerFields.new(locate)
|
|
47
|
-
repoints = response.fetch("repoints")
|
|
48
|
-
each_open_once(repoints.map { |repoint| repoint.fetch("finding_id") })
|
|
49
|
-
given = repoints.each_with_index.select { |repoint, _| repoint["recorded_at"] }
|
|
50
|
-
completed.repointed(given.map { |repoint, index| located(repoint, index, fields) }, at: at)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# The record accepted from the answer, as accepted gives it, and the records it changes among records, not yet
|
|
54
|
-
# written: refused once the record changed after the request, whose revision the answer quotes back in its basis,
|
|
55
|
-
# was printed, unless it changes none.
|
|
56
|
-
#: (untyped, records: AuditRecords, at: String) { (Locator) -> void } -> [AuditRecord, Array[AuditRecord]]
|
|
57
|
-
def writable(response, records:, at:, &locate)
|
|
58
|
-
repointed = accepted(response, at:, &locate)
|
|
59
|
-
changes = records.changes(repointed)
|
|
60
|
-
LastCompletedRevision.new(response.dig("basis", "revision")).confirm_writable(@principle_id, @record, changes)
|
|
61
|
-
[repointed, changes]
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# The ids of the completed record's open findings that repointed, the record accepted, points elsewhere (T16).
|
|
65
|
-
#: (AuditRecord) -> Array[String]
|
|
66
|
-
def moved_ids(repointed) = repointed.write_ups_moved_since(completed)
|
|
67
|
-
|
|
68
|
-
# The ids of the rest, which repointed leaves where they pointed, so a repeat or a skipped finding is seen as one.
|
|
69
|
-
#: (AuditRecord) -> Array[String]
|
|
70
|
-
def unchanged_ids(repointed) = completed.open_ids - moved_ids(repointed)
|
|
71
|
-
|
|
72
|
-
# Refuses unless the principle's record is a completed audit's: an open record outside git keeps the completed
|
|
73
|
-
# one, whose findings its correction will decide, and with none there is nothing to repoint.
|
|
74
|
-
#: () -> AuditRecord
|
|
75
|
-
def completed
|
|
76
|
-
record = @record
|
|
77
|
-
return record if record&.completed?
|
|
78
|
-
|
|
79
|
-
start = "#{Error::EXECUTABLE} start-audit #{@principle_id}"
|
|
80
|
-
if record
|
|
81
|
-
raise Error.new("cannot_repoint",
|
|
82
|
-
"#{@principle_id} has an audit left open, whose correction decides its findings",
|
|
83
|
-
"Answer that correction, or start the audit again: #{start}")
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
raise Error.new("cannot_repoint", "#{@principle_id} has no completed audit, so no finding is open",
|
|
87
|
-
"Run a full audit first: #{start}")
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
# Refuses ids, the findings an answer's repoints name, when one is not open in the completed record or two
|
|
93
|
-
# name one finding, since either would otherwise read as a success.
|
|
94
|
-
#: (Array[String]) -> void
|
|
95
|
-
def each_open_once(ids)
|
|
96
|
-
open = completed.open_ids
|
|
97
|
-
unknown = ids - open
|
|
98
|
-
unless unknown.empty?
|
|
99
|
-
raise Error.new("unknown_finding", "#{@principle_id}'s last completed audit leaves no finding " \
|
|
100
|
-
"#{unknown.join(", ")} open",
|
|
101
|
-
"Repoint only its open findings: #{open.join(", ")}")
|
|
102
|
-
end
|
|
103
|
-
each_once(ids)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
#: (Array[String]) -> void
|
|
107
|
-
def each_once(ids)
|
|
108
|
-
repeated = ids.tally.select { |_, count| count > 1 }.keys
|
|
109
|
-
return if repeated.empty?
|
|
110
|
-
|
|
111
|
-
raise Error.new("duplicate_finding", "Repoints name #{repeated.join(", ")} more than once",
|
|
112
|
-
"Give each finding one repoint.")
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# The repoint at index, its recorded_at located and committed, and its reason given.
|
|
116
|
-
#: (Hash[String, untyped], Integer, AnswerFields) -> WriteUpRepoint
|
|
117
|
-
def located(repoint, index, fields)
|
|
118
|
-
place = AnswerPlace.new("/repoints/#{index}", "Finding #{repoint["finding_id"]}")
|
|
119
|
-
pointer = fields.write_up_pointer(repoint["recorded_at"], place.child("recorded_at"))
|
|
120
|
-
@history.refuse_uncommitted_write_up(pointer.path)
|
|
121
|
-
WriteUpRepoint.answered(repoint, pointer, fields, place)
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "answer_fields"
|
|
5
|
-
require_relative "recorded_finding"
|
|
6
|
-
require_relative "write_up_pointer"
|
|
7
|
-
|
|
8
|
-
module Principles
|
|
9
|
-
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
10
|
-
module Models
|
|
11
|
-
# One finding's write-up pointer moved by a repoint: the finding it names, the recorded_at the agent
|
|
12
|
-
# found the write-up at, and why. It moves a finding there, keeping where it pointed before, when and why.
|
|
13
|
-
class WriteUpRepoint
|
|
14
|
-
# The repoint one entry of an answer's repoints gives, to recorded_at, its pointer already located, refused by
|
|
15
|
-
# fields without a reason, since the record keeps why each pointer moved, naming its place in the answer.
|
|
16
|
-
#: (Hash[String, untyped], WriteUpPointer, AnswerFields, AnswerPlace) -> WriteUpRepoint
|
|
17
|
-
def self.answered(repoint, recorded_at, fields, place)
|
|
18
|
-
new(finding_id: repoint.fetch("finding_id"), recorded_at: recorded_at,
|
|
19
|
-
reason: fields.text_at(repoint["reason"], "repoint.reason", place.child("reason")))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
#: String
|
|
23
|
-
attr_reader :finding_id
|
|
24
|
-
|
|
25
|
-
#: (finding_id: String, recorded_at: WriteUpPointer, reason: String) -> void
|
|
26
|
-
def initialize(finding_id:, recorded_at:, reason:)
|
|
27
|
-
@finding_id = finding_id
|
|
28
|
-
@recorded_at = recorded_at
|
|
29
|
-
@reason = reason
|
|
30
|
-
freeze
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# finding moved to this repoint's recorded_at, for its reason, at at.
|
|
34
|
-
#: (RecordedFinding, at: String) -> RecordedFinding
|
|
35
|
-
def applied_to(finding, at:) = finding.moved_to(@recorded_at, at: at, reason: @reason)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Each open finding in `findings` has its `recorded_at`, and what list-open-findings says of the write-up there: its
|
|
2
|
-
`write_up_opening`, or why there is none in `write_up_opening_reason`. When the file is missing, git's match for it is
|
|
3
|
-
in `write_up_opening_error.git_detected_rename`, with `starting_at_found_in_rename` when the pointer quotes a
|
|
4
|
-
`starting_at`. Git's match can pair a deleted file with an unrelated similar one, so read the file it names before you
|
|
5
|
-
use it. For each finding whose write-up you found, set its `recorded_at` in `repoints` to where the write-up is now,
|
|
6
|
-
as `{"path": ..., "heading": ...}` or with `starting_at`, and give a one-line `reason`. Leave `recorded_at` null for a
|
|
7
|
-
finding you do not repoint. Only `recorded_at` changes: the finding stays open, with its problem, action and dates,
|
|
8
|
-
for the next full audit to decide. During a full audit, give the new `recorded_at` in that finding's still_holds
|
|
9
|
-
decision instead, since a repoint changes the record that audit's request was printed after. Do not edit the audit
|
|
10
|
-
record by hand: nothing would check that the new pointer is found.
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "invocation"
|
|
5
|
-
require_relative "prompts"
|
|
6
|
-
|
|
7
|
-
module Principles
|
|
8
|
-
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
|
-
module Views
|
|
10
|
-
# A repoint of a principle's open findings' write-ups: its request and its result.
|
|
11
|
-
class RepointResult
|
|
12
|
-
# What an accepted repoint did: the ids of the findings it repointed and of those it left where they point,
|
|
13
|
-
# and each other principle's open finding whose write-up cannot be found, with those principles (T16).
|
|
14
|
-
class Outcome
|
|
15
|
-
#: Array[String]
|
|
16
|
-
attr_reader :repointed, :unchanged
|
|
17
|
-
# Each as its principle and finding_id.
|
|
18
|
-
#: Array[Hash[String, String]]
|
|
19
|
-
attr_reader :not_found_elsewhere
|
|
20
|
-
|
|
21
|
-
#: (repointed: Array[String], unchanged: Array[String], not_found_elsewhere: Array[Hash[String, String]])
|
|
22
|
-
#| -> void
|
|
23
|
-
def initialize(repointed:, unchanged:, not_found_elsewhere:)
|
|
24
|
-
@repointed = repointed
|
|
25
|
-
@unchanged = unchanged
|
|
26
|
-
@not_found_elsewhere = not_found_elsewhere
|
|
27
|
-
freeze
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# The other principles not_found_elsewhere names, each once.
|
|
31
|
-
#: () -> Array[String]
|
|
32
|
-
def principles_elsewhere = @not_found_elsewhere.map { |finding| finding.fetch("principle") }.uniq
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
#: (Invocation) -> void
|
|
36
|
-
def initialize(invocation)
|
|
37
|
-
@invocation = invocation
|
|
38
|
-
freeze
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# findings are the open findings, each with its recorded_at and what list-open-findings says of its write-up.
|
|
42
|
-
#: (request_id: String, principle_id: String, revision: String?, findings: Array[Hash[String, untyped]])
|
|
43
|
-
#| -> Hash[String, untyped]
|
|
44
|
-
def request(request_id:, principle_id:, revision:, findings:)
|
|
45
|
-
repoints = findings.map do |finding|
|
|
46
|
-
{ "finding_id" => finding["finding_id"], "recorded_at" => nil, "reason" => "" }
|
|
47
|
-
end
|
|
48
|
-
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "repointing",
|
|
49
|
-
"context" => { "principle_id" => principle_id, "findings" => findings,
|
|
50
|
-
"question" => Prompts.text("repoint-write-ups/point-each-moved-write-up-at-its-new-place") },
|
|
51
|
-
"response_template" => { "request_id" => request_id, "basis" => { "revision" => revision },
|
|
52
|
-
"repoints" => repoints },
|
|
53
|
-
"answer_with" => @invocation.submit_answer(request_id) }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# The repoints were accepted, as outcome says, and file holds them.
|
|
57
|
-
#: (principle_id: String, file: String, outcome: Outcome) -> Hash[String, untyped]
|
|
58
|
-
def repointed(principle_id:, file:, outcome:)
|
|
59
|
-
{ "status" => "write_ups_repointed", "principle_id" => principle_id, "repointed" => outcome.repointed,
|
|
60
|
-
"unchanged" => outcome.unchanged, "other_write_ups_not_found" => outcome.not_found_elsewhere,
|
|
61
|
-
"files_to_commit" => [file],
|
|
62
|
-
"next_action" => "Commit #{file}. After committing, this names no write-up of #{principle_id} it cannot " \
|
|
63
|
-
"find: #{@invocation.in_project("list-open-findings", principle_id, usage: "--short")}" \
|
|
64
|
-
"#{elsewhere(outcome.principles_elsewhere)}" }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
# The request that repoints each other principle's write-ups, one per line, or nothing when there is none.
|
|
70
|
-
#: (Array[String]) -> String
|
|
71
|
-
def elsewhere(principle_ids)
|
|
72
|
-
return "" if principle_ids.empty?
|
|
73
|
-
|
|
74
|
-
commands = principle_ids.map { |id| "#{@invocation.in_project("start-audit", id, usage: "--write-ups")}\n" }
|
|
75
|
-
"\nWrite-ups of other principles cannot be found either, listed under other_write_ups_not_found. " \
|
|
76
|
-
"Check each, and repoint it with its own request:\n#{commands.join}"
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|