principles 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/principles/after_commit_hook_options.rb +4 -1
- data/lib/principles/cli.rb +9 -0
- data/lib/principles/command_line.rb +31 -30
- data/lib/principles/command_routes.rb +9 -3
- data/lib/principles/controllers/acknowledgement.rb +82 -95
- data/lib/principles/controllers/answer.rb +14 -11
- data/lib/principles/controllers/assessment.rb +27 -24
- data/lib/principles/controllers/audit.rb +24 -4
- data/lib/principles/controllers/audit_completion.rb +10 -4
- data/lib/principles/controllers/command.rb +2 -2
- data/lib/principles/controllers/correction.rb +16 -7
- data/lib/principles/controllers/full_audit_request.rb +8 -3
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +3 -22
- data/lib/principles/controllers/mapping.rb +9 -1
- data/lib/principles/controllers/member_acknowledgement.rb +137 -0
- data/lib/principles/controllers/member_addition.rb +65 -0
- data/lib/principles/controllers/member_entries.rb +6 -24
- data/lib/principles/controllers/member_problems_report.rb +33 -25
- data/lib/principles/controllers/members_to_assess.rb +1 -1
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +5 -2
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +86 -25
- data/lib/principles/data/committed_tree.rb +84 -0
- data/lib/principles/data/first_parent_log.rb +48 -0
- data/lib/principles/data/first_parent_range.rb +122 -0
- data/lib/principles/data/git_command.rb +37 -0
- data/lib/principles/data/guidance_search_paths_file.rb +107 -0
- data/lib/principles/data/map_files.rb +35 -10
- data/lib/principles/data/principles_directory.rb +40 -0
- data/lib/principles/data/principles_subfolder.rb +39 -16
- data/lib/principles/data/project_files.rb +11 -3
- data/lib/principles/data/repository.rb +55 -29
- data/lib/principles/data/requested_candidate_files.rb +43 -0
- data/lib/principles/data/running_version.rb +3 -5
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +6 -6
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +88 -0
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -63
- data/lib/principles/data/schemas/assessment-answer.schema.json +15 -1
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +12 -54
- data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
- data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
- data/lib/principles/data/verified_head.rb +162 -0
- data/lib/principles/invocation_options.rb +5 -4
- data/lib/principles/list_open_findings_options.rb +23 -0
- data/lib/principles/models/acknowledged_check.rb +94 -0
- data/lib/principles/models/acknowledgement.rb +40 -36
- data/lib/principles/models/acknowledgement_left_as_printed.rb +72 -0
- data/lib/principles/models/acknowledgements.rb +99 -0
- data/lib/principles/models/answered_time.rb +9 -0
- data/lib/principles/models/assessment_report.rb +13 -13
- data/lib/principles/models/audit.rb +17 -4
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +9 -0
- data/lib/principles/models/audit_records.rb +34 -8
- data/lib/principles/models/candidate_files.rb +17 -6
- data/lib/principles/models/candidate_inventory.rb +51 -7
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/check_since_last_audit.rb +4 -8
- data/lib/principles/models/correction_basis.rb +14 -5
- data/lib/principles/models/declared_map_changes.rb +25 -9
- data/lib/principles/models/declared_member_removals.rb +75 -0
- data/lib/principles/models/disposition.rb +4 -2
- data/lib/principles/models/fix_only_fields.rb +12 -0
- data/lib/principles/models/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/list_member_problems_check.rb +80 -0
- data/lib/principles/models/listed_members.rb +49 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_decision.rb +17 -8
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/loads_to_check.rb +0 -1
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +11 -2
- data/lib/principles/models/member_file.rb +20 -71
- data/lib/principles/models/member_history.rb +7 -5
- data/lib/principles/models/member_loading_scopes.rb +49 -0
- data/lib/principles/models/member_loads.rb +4 -0
- data/lib/principles/models/member_mapping_run.rb +30 -0
- data/lib/principles/models/member_moves.rb +4 -0
- data/lib/principles/models/member_problems.rb +57 -29
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +9 -11
- data/lib/principles/models/member_sighting.rb +5 -8
- data/lib/principles/models/member_snapshots.rb +14 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
- data/lib/principles/models/meta_principle.rb +14 -0
- data/lib/principles/models/missing_files.rb +2 -2
- data/lib/principles/models/other_templates_placeholders.rb +1 -1
- data/lib/principles/models/outline_budget.rb +29 -14
- data/lib/principles/models/principle.rb +14 -7
- data/lib/principles/models/principle_file_revision.rb +48 -0
- data/lib/principles/models/principle_history.rb +46 -19
- data/lib/principles/models/principle_lineage.rb +118 -0
- data/lib/principles/models/principle_map_revision.rb +39 -0
- data/lib/principles/models/principle_mapping_history.rb +132 -0
- data/lib/principles/models/principle_members.rb +14 -0
- data/lib/principles/models/principle_predecessor.rb +45 -0
- data/lib/principles/models/principle_publication.rb +177 -0
- data/lib/principles/models/principle_revision.rb +104 -0
- data/lib/principles/models/problem_report.rb +36 -9
- data/lib/principles/models/project.rb +47 -30
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/record_format.rb +6 -0
- data/lib/principles/models/reported_check.rb +16 -12
- data/lib/principles/models/request_id.rb +1 -1
- data/lib/principles/models/sent_answer.rb +35 -5
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/positional_arguments.rb +38 -0
- data/lib/principles/session_start_options.rb +3 -3
- data/lib/principles/start_audit_options.rb +10 -2
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +54 -16
- data/lib/principles/views/added_member.rb +41 -0
- data/lib/principles/views/answered_request.rb +21 -0
- data/lib/principles/views/assessed_members.rb +26 -5
- data/lib/principles/views/assessment_request.rb +24 -4
- data/lib/principles/views/audit_result.rb +30 -27
- data/lib/principles/views/candidate_files_result.rb +56 -12
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_result_template.rb +18 -17
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +38 -10
- data/lib/principles/views/findings_result.rb +21 -0
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/invocation.rb +19 -4
- data/lib/principles/views/json_with_entries_on_lines.rb +12 -4
- data/lib/principles/views/loads_to_check_result.rb +3 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +22 -42
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +2 -1
- data/lib/principles/views/member_repairs.rb +2 -1
- data/lib/principles/views/member_row.rb +61 -0
- data/lib/principles/views/members_a_commit_changed.rb +2 -1
- data/lib/principles/views/members_with_no_baseline.rb +8 -1
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +37 -21
- data/lib/principles/views/open_findings_line.rb +2 -1
- data/lib/principles/views/principle_read_result.rb +4 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/problem_lines.rb +50 -45
- data/lib/principles/views/problem_result.rb +59 -25
- data/lib/principles/views/prompts/acknowledge-a-change/report-the-exit-status-its-own-listing-gives.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -3
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-each-change-keeps-its-meaning.md +8 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -43
- data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +2 -1
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +12 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +4 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +37 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +20 -19
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +33 -7
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +10 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +1 -1
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-with-the-principles-skill.md +1 -0
- metadata +67 -4
- data/lib/principles/models/candidate_listing.rb +0 -41
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
require_relative "invocation_options"
|
|
5
5
|
|
|
6
6
|
module Principles
|
|
7
|
-
# The option list-open-findings --short
|
|
8
|
-
# is wrong with it as given, which CommandLine refuses as a usage error.
|
|
7
|
+
# The option list-open-findings --short and list-member-problems --short take from Claude Code's SessionStart hook,
|
|
8
|
+
# --session-start (#717, #1261), and what is wrong with it as given, which CommandLine refuses as a usage error.
|
|
9
9
|
class SessionStartOptions
|
|
10
10
|
# The sources Claude Code's SessionStart hook names.
|
|
11
11
|
SOURCES = %w[startup resume clear compact].freeze #: Array[String]
|
|
@@ -17,7 +17,7 @@ module Principles
|
|
|
17
17
|
freeze
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# What is wrong with the option as given, or nil when it fits or is not given; it
|
|
20
|
+
# What is wrong with the option as given, or nil when it fits or is not given; it shapes only --short's lines.
|
|
21
21
|
#: () -> String?
|
|
22
22
|
def fault
|
|
23
23
|
start = @start or return
|
|
@@ -9,7 +9,8 @@ module Principles
|
|
|
9
9
|
class StartAuditOptions
|
|
10
10
|
#: (InvocationOptions) -> void
|
|
11
11
|
def initialize(options)
|
|
12
|
-
@
|
|
12
|
+
@members = options.value("member") || [] #: Array[String]
|
|
13
|
+
@member = !@members.empty? #: bool
|
|
13
14
|
@write_ups = !options.value("write_ups").nil? #: bool
|
|
14
15
|
@form = options.value("as") #: String?
|
|
15
16
|
@instruction = !options.value("instruction").nil? #: bool
|
|
@@ -21,11 +22,18 @@ module Principles
|
|
|
21
22
|
def fault
|
|
22
23
|
return "--member and --write-ups each start a different audit; give one" if @member && @write_ups
|
|
23
24
|
|
|
24
|
-
instruction_fault || form_fault
|
|
25
|
+
member_fault || instruction_fault || form_fault
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
private
|
|
28
29
|
|
|
30
|
+
# A member given twice, which the agent would judge once (#1169); nil when each is given once.
|
|
31
|
+
#: () -> String?
|
|
32
|
+
def member_fault
|
|
33
|
+
twice = @members.find { |member| @members.count(member) > 1 } or return
|
|
34
|
+
"--member #{twice} is given twice; give each member once"
|
|
35
|
+
end
|
|
36
|
+
|
|
29
37
|
# --instruction prints one field of a full audit's request whole (D81 step 2); nil when nothing beside it prints
|
|
30
38
|
# another output.
|
|
31
39
|
#: () -> String?
|
data/lib/principles/version.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The next production release, as major.minor.patch. A production build is versioned with this alone.
|
|
6
|
-
RELEASE = "0.0.
|
|
6
|
+
RELEASE = "0.0.7"
|
|
7
7
|
# The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
|
|
8
8
|
# packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
|
|
9
9
|
# Data::RunningVersion reads the commit this tool runs from instead.
|
|
10
|
-
BUILT_VERSION = "0.0.
|
|
10
|
+
BUILT_VERSION = "0.0.7" #: String?
|
|
11
11
|
end
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "invocation"
|
|
5
|
+
require_relative "answered_request"
|
|
5
6
|
require_relative "member_change_since_baseline"
|
|
6
7
|
require_relative "prompts"
|
|
8
|
+
require_relative "../prose_list"
|
|
7
9
|
|
|
8
10
|
module Principles
|
|
9
11
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
@@ -16,36 +18,72 @@ module Principles
|
|
|
16
18
|
freeze
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
+
# asked is what the request asks of its member: under :change its change since its baseline; under :context
|
|
22
|
+
# what the request's context shows beside it, such as the record's findings on the member; and under
|
|
23
|
+
# :placeholders the text the template prints in each field the agent writes. What the agent judges is under
|
|
21
24
|
# context, the question last, as in a full audit's request (D60).
|
|
22
|
-
#: (request_id: String, principle_id: String,
|
|
23
|
-
|
|
24
|
-
def request(request_id:, principle_id:, change:, open_findings:, placeholders:)
|
|
25
|
+
#: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
|
|
26
|
+
def request(request_id:, principle_id:, asked:)
|
|
25
27
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
|
|
26
|
-
"context" => { "principle_id" => principle_id, **change.to_h, **
|
|
28
|
+
"context" => { "principle_id" => principle_id, **asked.fetch(:change).to_h, **asked.fetch(:context),
|
|
27
29
|
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning") },
|
|
28
|
-
"response_template" => answer_to_fill(request_id:,
|
|
30
|
+
"response_template" => answer_to_fill(request_id:, asked:),
|
|
29
31
|
"answer_with" => @invocation.submit_answer(request_id) }
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
# The answer to the request request_id names, to fill: the request prints it as response_template, and
|
|
33
|
-
# start-audit --member --as template prints it alone, each field the agent writes holding its placeholder (#773)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def answer_to_fill(request_id:,
|
|
37
|
-
{ "request_id" => request_id,
|
|
38
|
-
|
|
35
|
+
# start-audit --member --as template prints it alone, each field the agent writes holding its placeholder (#773),
|
|
36
|
+
# and only those: the fields the answer may add, the question names (#1170).
|
|
37
|
+
#: (request_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
|
|
38
|
+
def answer_to_fill(request_id:, asked:)
|
|
39
|
+
{ "request_id" => request_id, "basis" => { "member_id" => asked.fetch(:change).member_id },
|
|
40
|
+
**asked.fetch(:placeholders) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# The request for several members' acknowledgements in one answer (#1169): each of members holds a member's
|
|
44
|
+
# change, the context its own request shows beside it and the placeholders its template prints, as one member's
|
|
45
|
+
# request holds them, under context.members and the template's members in the order the agent named them.
|
|
46
|
+
#: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
47
|
+
def several_request(request_id:, principle_id:, members:)
|
|
48
|
+
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
49
|
+
"context" => { "principle_id" => principle_id,
|
|
50
|
+
"members" => members.map { { **it.fetch(:change).to_h, **it.fetch(:context) } },
|
|
51
|
+
"question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning") },
|
|
52
|
+
"response_template" => several_to_fill(request_id:, members:),
|
|
53
|
+
"answer_with" => @invocation.submit_answer(request_id) }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# The answer to the request for several members request_id names, to fill: its basis names each member, and
|
|
57
|
+
# its members hold each one's placeholders under its id, as start-audit --as template prints it alone.
|
|
58
|
+
#: (request_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
59
|
+
def several_to_fill(request_id:, members:)
|
|
60
|
+
{ "request_id" => request_id, "basis" => { "member_ids" => members.map { it.fetch(:change).member_id } },
|
|
61
|
+
"members" => members.to_h { [it.fetch(:change).member_id, it.fetch(:placeholders)] } }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# The acknowledgement of each of member_ids was accepted, and file holds them all.
|
|
65
|
+
#: (principle_id: String, member_ids: Array[String], file: String) -> AnsweredRequest
|
|
66
|
+
def several_acknowledged(principle_id:, member_ids:, file:)
|
|
67
|
+
AnsweredRequest.new(
|
|
68
|
+
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
|
|
69
|
+
"files_to_commit" => [file],
|
|
70
|
+
"next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
|
|
71
|
+
"After committing, this no longer lists them: " \
|
|
72
|
+
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
73
|
+
)
|
|
39
74
|
end
|
|
40
75
|
|
|
41
76
|
# The acknowledgement was accepted and file holds it.
|
|
42
|
-
#: (principle_id: String, member_id: String, file: String) ->
|
|
77
|
+
#: (principle_id: String, member_id: String, file: String) -> AnsweredRequest
|
|
43
78
|
def acknowledged(principle_id:, member_id:, file:)
|
|
44
|
-
|
|
79
|
+
fields = {
|
|
80
|
+
"status" => "acknowledged", "principle_id" => principle_id, "member_id" => member_id,
|
|
45
81
|
"files_to_commit" => [file],
|
|
46
82
|
"next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
|
|
47
83
|
"After committing, this no longer lists it: " \
|
|
48
|
-
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
84
|
+
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
85
|
+
}
|
|
86
|
+
AnsweredRequest.new(fields)
|
|
49
87
|
end
|
|
50
88
|
end
|
|
51
89
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "lines_shared_with_member"
|
|
5
|
+
require_relative "consecutive_sections_elsewhere"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
module Views
|
|
9
|
+
# The member just added: its id, current lines and check, beside its shared/consecutive location facts.
|
|
10
|
+
class AddedMember
|
|
11
|
+
#: (Hash[String, untyped], shared: LinesSharedWithMember, consecutive: ConsecutiveSectionsElsewhere) -> void
|
|
12
|
+
def initialize(added, shared:, consecutive:)
|
|
13
|
+
@added = added.merge(shared.to_h).merge(consecutive.to_h) #: Hash[String, untyped]
|
|
14
|
+
@shared = shared
|
|
15
|
+
@consecutive = consecutive
|
|
16
|
+
freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#: () -> String
|
|
20
|
+
def id = @added.fetch("id")
|
|
21
|
+
|
|
22
|
+
#: () -> Hash[String, untyped]
|
|
23
|
+
def to_h = @added
|
|
24
|
+
|
|
25
|
+
# The same location/remapping opening precedes the map's own after-add guidance.
|
|
26
|
+
#: () -> String
|
|
27
|
+
def opening
|
|
28
|
+
"#{span}#{@shared.note}#{@consecutive.note}Add the next member the same way. "
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
# The lines a member spans, said so that a passage cut short shows; it ends with a space.
|
|
34
|
+
#: () -> String
|
|
35
|
+
def span
|
|
36
|
+
"#{id} spans lines #{@added.fetch("first_line")} to #{@added.fetch("last_line")}; " \
|
|
37
|
+
"if that is not the passage you meant, move it with move-member. "
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
module Views
|
|
6
|
+
# An answered request's terminal result fields, with no further correction template to fill.
|
|
7
|
+
class AnsweredRequest
|
|
8
|
+
#: (Hash[String, untyped]) -> void
|
|
9
|
+
def initialize(fields)
|
|
10
|
+
@fields = fields
|
|
11
|
+
freeze
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#: (AuditResult, String, String) -> Hash[String, untyped]
|
|
15
|
+
def presented_with(_view, _source_request_id, _answer_file) = @fields
|
|
16
|
+
|
|
17
|
+
#: (Hash[String, untyped], Invocation, String) -> Hash[String, untyped]
|
|
18
|
+
def with_correction_to_fill(acceptable, _invocation, _answer_file) = acceptable
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -46,12 +46,20 @@ module Principles
|
|
|
46
46
|
#: () -> Array[Hash[String, untyped]]
|
|
47
47
|
def shown
|
|
48
48
|
@members.map do |member|
|
|
49
|
-
next fields(member, SHOWN) unless compact?(member)
|
|
49
|
+
next fields(member, SHOWN).merge(instruction(member)) unless compact?(member)
|
|
50
50
|
|
|
51
|
-
fields(member, COMPACT).merge(
|
|
51
|
+
fields(member, COMPACT).merge(instruction(member),
|
|
52
|
+
"carried_forward" => member.fetch("carried_forward").slice(*CARRIED_COMPACTLY))
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
|
|
56
|
+
# How to run and report each checked member's check, by id, as the template printed alone gives it beside the
|
|
57
|
+
# members, since it has no context to show it in (#1024, #1191).
|
|
58
|
+
#: () -> Hash[String, String]
|
|
59
|
+
def check_instructions
|
|
60
|
+
@members.to_h { [it.fetch("id"), check_template(it)&.instruction] }.compact
|
|
61
|
+
end
|
|
62
|
+
|
|
55
63
|
# Each member's template entry: a fresh assessment to fill in, or, for a member whose last assessment is
|
|
56
64
|
# carried forward, the marker that keeps it (D49); either with its check's result when it has a check.
|
|
57
65
|
#: () -> Array[Hash[String, untyped]]
|
|
@@ -111,9 +119,22 @@ module Principles
|
|
|
111
119
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
112
120
|
def template(member)
|
|
113
121
|
assessed = member["carried_forward"] ? carried(member) : fresh(member)
|
|
114
|
-
template =
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
template = check_template(member)
|
|
123
|
+
template ? assessed.merge("check_result" => template.to_h) : assessed
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# The check_result template of a checked member, with its instruction; nil for one without a check.
|
|
127
|
+
#: (Hash[String, untyped]) -> CheckResultTemplate?
|
|
128
|
+
def check_template(member)
|
|
129
|
+
CheckResultTemplate.for(member, reviewed_placeholders: @reviewed_check_placeholders,
|
|
130
|
+
unchanged_placeholders: @unchanged_check_placeholders)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# The member's check_instruction, as the request's context shows it beside the member; none without a check.
|
|
134
|
+
#: (Hash[String, untyped]) -> Hash[String, String]
|
|
135
|
+
def instruction(member)
|
|
136
|
+
template = check_template(member) or return {}
|
|
137
|
+
{ "check_instruction" => template.instruction }
|
|
117
138
|
end
|
|
118
139
|
|
|
119
140
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
@@ -15,7 +15,8 @@ module Principles
|
|
|
15
15
|
class AssessmentRequest
|
|
16
16
|
# The recent_decision the request's template prints, which names the other form in the guide beside it.
|
|
17
17
|
IN_GUIDE = {
|
|
18
|
-
"unavailable_reason" => "Or
|
|
18
|
+
"unavailable_reason" => "Or replace this object with answer_guide.recent_decision.examples.assessed " \
|
|
19
|
+
"as copy_from says."
|
|
19
20
|
}.freeze #: Hash[String, String]
|
|
20
21
|
# How mapped_elsewhere_instruction's paragraph on open findings elsewhere begins, which prints only when an
|
|
21
22
|
# entry names one (#808).
|
|
@@ -87,16 +88,35 @@ module Principles
|
|
|
87
88
|
|
|
88
89
|
# The answer to fill in as printed alone, with no request beside it: each placeholder says what its field
|
|
89
90
|
# takes, and points at nothing left unprinted (D81 step 1), after one note saying how a field left as printed is
|
|
90
|
-
# read (#1043, D88)
|
|
91
|
+
# read (#1043, D88), and the carried members whose check it still asks to run, named before the members so a
|
|
92
|
+
# reader skipping carried markers still runs each (D12, D19).
|
|
91
93
|
#: () -> Hash[String, untyped]
|
|
92
94
|
def template_to_fill
|
|
93
|
-
|
|
95
|
+
members = @members.templates_to_fill
|
|
96
|
+
filled = assessed(@placeholders.fetch("recent_decision"), members)
|
|
94
97
|
@head.leading(@parts.filled_after({ "left_as_printed_rule" => @placeholders.fetch("left_as_printed_rule"),
|
|
95
|
-
**
|
|
98
|
+
**carried_checks_to_run(members), **check_instructions, **filled,
|
|
99
|
+
"findings" => [@placeholders.fetch("new_finding")] }))
|
|
96
100
|
end
|
|
97
101
|
|
|
98
102
|
private
|
|
99
103
|
|
|
104
|
+
# How to run and report each checked member's check, by its id, under check_instructions; nothing when no member
|
|
105
|
+
# has a check (#1191).
|
|
106
|
+
#: () -> Hash[String, untyped]
|
|
107
|
+
def check_instructions
|
|
108
|
+
instructions = @members.check_instructions
|
|
109
|
+
instructions.empty? ? {} : { "check_instructions" => instructions }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# The ids of the carried members whose template entry asks for a check_result, under carried_checks_to_run,
|
|
113
|
+
# or nothing when there are none.
|
|
114
|
+
#: (Array[Hash[String, untyped]]) -> Hash[String, Array[String]]
|
|
115
|
+
def carried_checks_to_run(members)
|
|
116
|
+
ids = members.select { it["carried_forward"] && it.key?("check_result") }.map { it.fetch("member_id") }
|
|
117
|
+
ids.empty? ? {} : { "carried_checks_to_run" => ids }
|
|
118
|
+
end
|
|
119
|
+
|
|
100
120
|
# The answer's fields after its head and before its parts' slots, recent_decision and the members' templates as
|
|
101
121
|
# given.
|
|
102
122
|
#: (Hash[String, String], Array[Hash[String, untyped]]) -> Hash[String, untyped]
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative "../prose_list"
|
|
5
5
|
require_relative "assessment_request"
|
|
6
|
+
require_relative "answered_request"
|
|
6
7
|
require_relative "audit_changes"
|
|
7
8
|
require_relative "correction_request"
|
|
8
9
|
require_relative "invocation"
|
|
@@ -25,25 +26,16 @@ module Principles
|
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
# An answer's result as submit-answer prints it: a correction request in full, with how to answer it.
|
|
28
|
-
#: (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
output
|
|
29
|
+
#: (AnsweredRequest | CorrectionRequest, source_request_id: String, answer_file: String)
|
|
30
|
+
#| -> Hash[String, untyped]
|
|
31
|
+
def present(output, source_request_id:, answer_file:)
|
|
32
|
+
output.presented_with(self, source_request_id, answer_file)
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
#
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
#: (Hash[String, untyped], Hash[String, untyped] | CorrectionRequest) -> Hash[String, untyped]
|
|
39
|
-
def with_correction_to_fill(acceptable, output)
|
|
40
|
-
return acceptable unless output.is_a?(CorrectionRequest)
|
|
41
|
-
|
|
42
|
-
save = "Once this answer is submitted with the last line's command, save correction_template, the " \
|
|
43
|
-
"correction's answer it leads to, to a file outside the project, such as under $TMPDIR, fill only " \
|
|
44
|
-
"its dispositions, and submit it: #{@invocation.submit_answer(output.request_id)}"
|
|
45
|
-
acceptable.merge("correction_template" => output.template,
|
|
46
|
-
"next_action" => "#{save}\n#{acceptable.fetch("next_action")}")
|
|
35
|
+
# A correction request adds its answer to fill; a terminal result leaves the acceptable preview alone.
|
|
36
|
+
#: (Hash[String, untyped], AnsweredRequest | CorrectionRequest, answer_file: String) -> Hash[String, untyped]
|
|
37
|
+
def with_correction_to_fill(acceptable, output, answer_file:)
|
|
38
|
+
output.with_correction_to_fill(acceptable, @invocation, answer_file)
|
|
47
39
|
end
|
|
48
40
|
|
|
49
41
|
# show-answer-check: the answer passed every check, and what submitting it would write. open_findings_will_print
|
|
@@ -54,7 +46,7 @@ module Principles
|
|
|
54
46
|
#| ?map_entry_changes: Array[Hash[String, untyped]]) -> Hash[String, untyped]
|
|
55
47
|
def acceptable(request_id, would_write, answer_file:, open_findings_will_print: nil, map_entry_changes: [])
|
|
56
48
|
submit = @invocation.submit_answer(request_id, file: answer_file)
|
|
57
|
-
waits = "Submitting this answer writes nothing
|
|
49
|
+
waits = "Submitting this answer writes nothing: the audit record already holds what it would write.\n"
|
|
58
50
|
waits = "" unless would_write.empty?
|
|
59
51
|
result = { "status" => "answer_acceptable", "request_id" => request_id, "would_write" => would_write }
|
|
60
52
|
result = result.merge("open_findings_will_print" => open_findings_will_print) if open_findings_will_print
|
|
@@ -81,9 +73,11 @@ module Principles
|
|
|
81
73
|
|
|
82
74
|
# submit-answer: the correction request that follows an assessment with findings, as a judgement to answer
|
|
83
75
|
# under its request id, saying what submitting the assessment stored.
|
|
84
|
-
#: (CorrectionRequest) -> Hash[String, untyped]
|
|
85
|
-
def correction_request(request)
|
|
86
|
-
judgement("correction", request).merge("stored" => request.stored
|
|
76
|
+
#: (CorrectionRequest, source_request_id: String, answer_file: String) -> Hash[String, untyped]
|
|
77
|
+
def correction_request(request, source_request_id:, answer_file:)
|
|
78
|
+
judgement("correction", request).merge("stored" => request.stored,
|
|
79
|
+
"correction_recovery" => request.recovery(source_request_id, answer_file,
|
|
80
|
+
@invocation))
|
|
87
81
|
end
|
|
88
82
|
|
|
89
83
|
# A completed audit: its resolved and open findings, the files to commit and, in git, each changed
|
|
@@ -120,6 +114,21 @@ module Principles
|
|
|
120
114
|
"The last audit's record, #{file}, is not committed. Commit it, so the project keeps it."
|
|
121
115
|
end
|
|
122
116
|
|
|
117
|
+
# The notice start-audit adds, in git, when the last audit's record is open: its correction completes it, so it
|
|
118
|
+
# is never committed (D87).
|
|
119
|
+
#: (String) -> String
|
|
120
|
+
def open_record_notice(file)
|
|
121
|
+
"The last audit's record, #{file}, holds an open audit, waiting on its correction. Do not commit it: submit " \
|
|
122
|
+
"that correction, or answer this request, which replaces it, or discard it with `git restore #{file}`."
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Wraps a known judgement request with this run's project and answer command.
|
|
126
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
127
|
+
def request(output)
|
|
128
|
+
submit = @invocation.submit_answer(output.fetch("request_id"))
|
|
129
|
+
output.merge("project" => @invocation.project, "answer_with" => submit)
|
|
130
|
+
end
|
|
131
|
+
|
|
123
132
|
private
|
|
124
133
|
|
|
125
134
|
# request as a judgement to answer in phase, under its id, which its template's head also gives.
|
|
@@ -130,12 +139,6 @@ module Principles
|
|
|
130
139
|
"limits" => Prompts.text("answer-any-judgement-request/what-a-self-audit-cannot-show") }
|
|
131
140
|
end
|
|
132
141
|
|
|
133
|
-
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
134
|
-
def request(output)
|
|
135
|
-
submit = @invocation.submit_answer(output.fetch("request_id"))
|
|
136
|
-
output.merge("project" => @invocation.project, "answer_with" => submit)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
142
|
# A completed audit's next step, from what it changed and how to commit it.
|
|
140
143
|
#: (String, AuditChanges, AuditCommit | AuditCommit::ByHand) -> String
|
|
141
144
|
def completed_next_action(id, changes, commit)
|
|
@@ -15,7 +15,7 @@ module Principles
|
|
|
15
15
|
# name in it (#405, #412).
|
|
16
16
|
class Found
|
|
17
17
|
# What each listed file prints: where it is, how big, where a link leads, and what the survey reads of it.
|
|
18
|
-
PRINTED_FILE_FIELDS = %w[path characters symlink_to description opening_line outline].freeze
|
|
18
|
+
PRINTED_FILE_FIELDS = %w[path characters symlink_to changed_in_range description opening_line outline].freeze
|
|
19
19
|
|
|
20
20
|
#: Hash[String, Array[String]]
|
|
21
21
|
attr_reader :owner_asks
|
|
@@ -28,6 +28,10 @@ module Principles
|
|
|
28
28
|
#: () -> bool
|
|
29
29
|
def left_out? = @inventory.key?("outlines_left_out")
|
|
30
30
|
|
|
31
|
+
# What the outlines of the files a range changed print, when every cut left them past the budget (#1171).
|
|
32
|
+
#: () -> Integer?
|
|
33
|
+
def range_outlines_bytes = @inventory["range_outlines_bytes"]
|
|
34
|
+
|
|
31
35
|
#: (inventory: Hash[String, untyped], untracked: Array[String]?,
|
|
32
36
|
#| owner_asks: Hash[String, Array[String]]) -> void
|
|
33
37
|
def initialize(inventory:, untracked:, owner_asks:)
|
|
@@ -59,25 +63,58 @@ module Principles
|
|
|
59
63
|
|
|
60
64
|
# The inventory, and the question of which principle to map, with one item for each list under found's owner_asks
|
|
61
65
|
# to ask the owner about.
|
|
62
|
-
#: (Found, existing_maps: Array[String], map_file: String
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
#: (Found, existing_maps: Array[String], map_file: String,
|
|
67
|
+
#| mapped_principles: Array[Hash[String, untyped]]) -> Hash[String, untyped]
|
|
68
|
+
def question(found, existing_maps:, map_file:, mapped_principles:)
|
|
69
|
+
survey, choice = survey_questions(existing_maps)
|
|
70
|
+
result = { "status" => "question", "inventory" => found.listed, "existing_maps" => existing_maps,
|
|
71
|
+
"writes" => Prompts.text("find-a-principle-to-map/what-each-command-writes", map_file: map_file),
|
|
72
|
+
"question" => principle_question(found, survey: survey, choice: choice),
|
|
73
|
+
"answer_with" => mapping_answer(existing_maps),
|
|
74
|
+
**(mapped_principles.empty? ? {} : { "mapped_principles" => mapped_principles }) }
|
|
75
|
+
existing_maps.empty? ? result : instructions_first(result)
|
|
68
76
|
end
|
|
69
77
|
|
|
70
78
|
private
|
|
71
79
|
|
|
80
|
+
# Keep the survey's next action and existing-map comparison ahead of a potentially large inventory.
|
|
81
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
82
|
+
def instructions_first(result)
|
|
83
|
+
result.slice("status", "question", "answer_with", "mapped_principles", "existing_maps").merge(result)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# The table instructions and its later choice, with or without mapped rules to compare against.
|
|
87
|
+
#: (Array[String]) -> [String, String]
|
|
88
|
+
def survey_questions(existing_maps)
|
|
89
|
+
if existing_maps.empty?
|
|
90
|
+
[Prompts.text("find-a-principle-to-map/choose-one-principle"),
|
|
91
|
+
Prompts.text("find-a-principle-to-map/ask-which-principle-to-map")]
|
|
92
|
+
else
|
|
93
|
+
[Prompts.text("find-a-principle-to-map/compare-with-mapped-principles"),
|
|
94
|
+
Prompts.text("find-a-principle-to-map/choose-an-existing-or-new-principle")]
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# The map writes available after the table: extending an existing principle or starting a distinct one.
|
|
99
|
+
#: (Array[String]) -> String
|
|
100
|
+
def mapping_answer(existing_maps)
|
|
101
|
+
create = @invocation.in_project("create-principle", usage: CREATE_PRINCIPLE_USAGE)
|
|
102
|
+
return create if existing_maps.empty?
|
|
103
|
+
|
|
104
|
+
add = @invocation.in_project("add-member", usage: "ID PATH --role ROLE")
|
|
105
|
+
"To add a member to an existing principle: #{add}\nTo map a distinct principle: #{create}"
|
|
106
|
+
end
|
|
107
|
+
|
|
72
108
|
# The survey, leaving out files possibly test data, and when outlines were cut or left out how to read them, then
|
|
73
109
|
# one item per list to ask the owner about after the table.
|
|
74
|
-
#: (Found) -> String
|
|
75
|
-
def principle_question(found)
|
|
110
|
+
#: (Found, survey: String, choice: String) -> String
|
|
111
|
+
def principle_question(found, survey:, choice:)
|
|
76
112
|
owner_asks = found.owner_asks
|
|
77
113
|
asks = owner_asks.map { |key, paths| "- #{owner_ask(key, named: inline(paths))}" }
|
|
78
|
-
[
|
|
114
|
+
[survey, *left_out_of_the_survey(owner_asks),
|
|
79
115
|
*budget_notes(found),
|
|
80
|
-
|
|
116
|
+
choice,
|
|
117
|
+
Prompts.text("find-a-principle-to-map/ask-about-other-guidance-search-paths"),
|
|
81
118
|
*([Prompts.text("find-a-principle-to-map/ask-the-owner-after-the-table"), *asks].join("\n") if asks.any?)]
|
|
82
119
|
.join("\n\n")
|
|
83
120
|
end
|
|
@@ -86,7 +123,14 @@ module Principles
|
|
|
86
123
|
#: (Found) -> Array[String]
|
|
87
124
|
def budget_notes(found)
|
|
88
125
|
[*(Prompts.text("find-a-principle-to-map/read-a-cut-section-back") if found.cut?),
|
|
89
|
-
*(Prompts.text("find-a-principle-to-map/read-left-out-files") if found.left_out?)
|
|
126
|
+
*(Prompts.text("find-a-principle-to-map/read-left-out-files") if found.left_out?),
|
|
127
|
+
*range_past_budget(found.range_outlines_bytes)]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# How to survey a range whose own outlines pass the budget, given what they print; nothing when they do not.
|
|
131
|
+
#: (Integer?) -> Array[String]
|
|
132
|
+
def range_past_budget(bytes)
|
|
133
|
+
bytes ? [Prompts.text("find-a-principle-to-map/survey-a-later-range", bytes: bytes.to_s)] : []
|
|
90
134
|
end
|
|
91
135
|
|
|
92
136
|
# The line leaving files possibly test data out of the survey, when any is listed.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "prompts"
|
|
5
|
+
require_relative "json_with_entries_on_lines"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
module Views
|
|
9
|
+
# The requested outlines, with the same omissions as a survey and the way to request less at once.
|
|
10
|
+
class CandidateOutlinesResult
|
|
11
|
+
#: (Hash[String, untyped]) -> void
|
|
12
|
+
def initialize(inventory)
|
|
13
|
+
@inventory = inventory
|
|
14
|
+
freeze
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#: () -> JsonWithEntriesOnLines
|
|
18
|
+
def result
|
|
19
|
+
values = { "status" => "ok", "question" => Prompts.text("read-requested-outlines/continue-the-survey"),
|
|
20
|
+
"inventory" => @inventory, "wrote" => [] }
|
|
21
|
+
JsonWithEntriesOnLines.new(values, under: "inventory", key: "files")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -7,25 +7,25 @@ require_relative "prompts"
|
|
|
7
7
|
module Principles
|
|
8
8
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
9
9
|
module Views
|
|
10
|
-
# The check_result a checked member's assessment template starts with: its command,
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# since, is reviewed before it runs (#227), so it also gives review_basis to fill
|
|
14
|
-
# it holds is named where that decision is made (#260).
|
|
10
|
+
# The check_result a checked member's assessment template starts with: its command, a short exit_status
|
|
11
|
+
# placeholder where the run's status goes, and not_run_reason, the alternative, as a placeholder an answer leaves
|
|
12
|
+
# as printed when it reports a run (#993), with its instruction, what to do before replacing it (#1191). A check
|
|
13
|
+
# no audit has run, or one changed since, is reviewed before it runs (#227), so it also gives review_basis to fill
|
|
14
|
+
# (D63), and any hidden character it holds is named where that decision is made (#260).
|
|
15
15
|
class CheckResultTemplate
|
|
16
16
|
# The template for the checked member a request lists as entry, with its check, how that stands to the last
|
|
17
17
|
# audit's and any hidden characters in it; nil for a member without a check.
|
|
18
18
|
#: (Hash[String, untyped], reviewed_placeholders: Hash[String, String],
|
|
19
|
-
#| unchanged_placeholders: Hash[String, String]) ->
|
|
19
|
+
#| unchanged_placeholders: Hash[String, String]) -> CheckResultTemplate?
|
|
20
20
|
def self.for(entry, reviewed_placeholders:, unchanged_placeholders:)
|
|
21
21
|
check = entry["check"] or return
|
|
22
22
|
new(check, entry["check_since_last_audit"], entry.fetch("check_hidden_characters", []),
|
|
23
|
-
reviewed_placeholders:, unchanged_placeholders:)
|
|
23
|
+
reviewed_placeholders:, unchanged_placeholders:)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
# reviewed_placeholders gives the text of not_run_reason and review_basis, which an answer
|
|
27
|
-
# give neither, for a check reviewed before it runs; unchanged_placeholders gives it for one
|
|
28
|
-
# whose review_basis left as printed keeps the line that audit kept (#1010).
|
|
26
|
+
# reviewed_placeholders gives the text of exit_status, and of not_run_reason and review_basis, which an answer
|
|
27
|
+
# leaves as printed to give neither, for a check reviewed before it runs; unchanged_placeholders gives it for one
|
|
28
|
+
# the last audit ran, whose review_basis left as printed keeps the line that audit kept (#1010).
|
|
29
29
|
#: (String, Hash[String, untyped]?, ?Array[String], reviewed_placeholders: Hash[String, String],
|
|
30
30
|
#| unchanged_placeholders: Hash[String, String]) -> void
|
|
31
31
|
def initialize(check, since_last_audit, hidden_characters = [], reviewed_placeholders:, unchanged_placeholders:)
|
|
@@ -39,20 +39,21 @@ module Principles
|
|
|
39
39
|
|
|
40
40
|
#: () -> Hash[String, untyped]
|
|
41
41
|
def to_h
|
|
42
|
-
{ "command" => @check, "exit_status" =>
|
|
42
|
+
{ "command" => @check, "exit_status" => @placeholders.fetch("exit_status"),
|
|
43
43
|
"not_run_reason" => @placeholders.fetch("not_run_reason"),
|
|
44
44
|
"review_basis" => @placeholders.fetch("review_basis") }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# What to do before replacing exit_status, then that a named check runs at every full audit, which holds for
|
|
50
|
-
# each status.
|
|
47
|
+
# What to do before replacing exit_status, with what the check hides, then that a named check runs at every
|
|
48
|
+
# full audit, which holds for each status.
|
|
51
49
|
#: () -> String
|
|
52
|
-
def
|
|
53
|
-
[*steps, Prompts.text("assess-every-member/run-a-named-check-at-every-full-audit")]
|
|
50
|
+
def instruction
|
|
51
|
+
[@notes.hidden_characters, *steps, Prompts.text("assess-every-member/run-a-named-check-at-every-full-audit")]
|
|
52
|
+
.compact.join(" ")
|
|
54
53
|
end
|
|
55
54
|
|
|
55
|
+
private
|
|
56
|
+
|
|
56
57
|
# An unchanged check is run and reported, keeping any line its last review rested on; a new or changed one is
|
|
57
58
|
# reviewed first, its review introduced by what it is, then run and reported with what that review rested on,
|
|
58
59
|
# as both ask the same way.
|