principles 0.0.10 → 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 +42 -0
- data/README.md +0 -2
- data/lib/principles/controllers/acknowledgement.rb +11 -4
- data/lib/principles/controllers/acknowledgements.rb +4 -4
- data/lib/principles/controllers/answer.rb +2 -2
- data/lib/principles/controllers/assessment.rb +20 -4
- data/lib/principles/controllers/audit.rb +16 -5
- data/lib/principles/controllers/broken_member_repairs.rb +60 -0
- data/lib/principles/controllers/command.rb +8 -30
- data/lib/principles/controllers/correction.rb +7 -5
- data/lib/principles/controllers/full_audit_request.rb +44 -22
- data/lib/principles/controllers/guidance_search_paths.rb +1 -1
- data/lib/principles/controllers/inventory.rb +3 -3
- data/lib/principles/controllers/member_acknowledgement.rb +5 -5
- data/lib/principles/controllers/member_addition.rb +5 -2
- data/lib/principles/controllers/member_entries.rb +1 -1
- data/lib/principles/controllers/member_problems_report.rb +11 -7
- data/lib/principles/controllers/members_to_assess.rb +1 -1
- data/lib/principles/controllers/meta_principle_setup.rb +4 -3
- data/lib/principles/controllers/open_correction.rb +3 -3
- 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 +20 -20
- 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/repository.rb +4 -4
- 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 +4 -4
- data/lib/principles/launch.rb +5 -3
- data/lib/principles/models/acknowledgement.rb +1 -27
- data/lib/principles/models/acknowledgement_left_as_printed.rb +2 -1
- data/lib/principles/models/acknowledgement_placeholders.rb +48 -0
- data/lib/principles/models/after_commit_input.rb +1 -0
- data/lib/principles/models/assessment_answer.rb +2 -2
- data/lib/principles/models/assessment_basis.rb +1 -1
- data/lib/principles/models/assessment_left_as_printed.rb +1 -1
- data/lib/principles/models/audit.rb +24 -4
- 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 +2 -2
- 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 +20 -10
- 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/disposition.rb +12 -76
- data/lib/principles/models/disposition_placeholders.rb +48 -0
- data/lib/principles/models/disposition_text_field.rb +41 -0
- data/lib/principles/models/evidence_item.rb +1 -1
- 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/fix_only_fields.rb +4 -3
- 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 +20 -12
- 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_assessments.rb +11 -4
- data/lib/principles/models/member_elsewhere.rb +1 -1
- data/lib/principles/models/member_file.rb +15 -13
- 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/member_repair_moves.rb +20 -4
- data/lib/principles/models/member_snapshots.rb +10 -10
- 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 +2 -2
- data/lib/principles/models/misspelt_member_id.rb +10 -4
- data/lib/principles/models/named_placeholder.rb +32 -0
- 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 +26 -6
- 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 +5 -4
- data/lib/principles/models/principle_members.rb +1 -1
- data/lib/principles/models/problem_report.rb +13 -1
- data/lib/principles/models/project.rb +15 -16
- data/lib/principles/models/project_at_commit.rb +60 -0
- data/lib/principles/models/project_history.rb +10 -52
- 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 +5 -3
- 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/template_placeholders.rb +22 -7
- data/lib/principles/models/text_size.rb +11 -3
- 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/unfinished_field.rb +34 -0
- 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 +35 -20
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +59 -0
- data/lib/principles/views/acknowledgement_result.rb +44 -51
- data/lib/principles/views/added_member.rb +10 -1
- data/lib/principles/views/answer_in_a_file.rb +65 -0
- data/lib/principles/views/assessed_members.rb +4 -2
- 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 +18 -7
- data/lib/principles/views/candidate_files_result.rb +9 -4
- data/lib/principles/views/context_parts.rb +41 -10
- data/lib/principles/views/correction_request.rb +27 -18
- 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/member_repairs.rb +21 -5
- data/lib/principles/views/meta_principle_result.rb +26 -5
- data/lib/principles/views/open_findings_decision_result.rb +60 -0
- data/lib/principles/views/parts_index_result.rb +8 -6
- data/lib/principles/views/principle_read_result.rb +2 -2
- data/lib/principles/views/problem_facts.rb +46 -0
- data/lib/principles/views/problem_lines.rb +8 -3
- data/lib/principles/views/problem_result.rb +53 -31
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +6 -0
- 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/answer-guide.json +1 -1
- 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/change-member-check.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +4 -3
- 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-member-problems.md +7 -8
- 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/move-member.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member-check.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +13 -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 +12 -12
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- data/lib/principles/views/prompts/start-a-session/act-on-the-changed-principles.md +2 -0
- data/lib/principles/views/prompts.rb +7 -4
- metadata +26 -8
- 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,17 +1,19 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "answer_in_a_file"
|
|
4
5
|
require_relative "invocation"
|
|
5
|
-
require_relative "answered_request"
|
|
6
6
|
require_relative "member_change_since_baseline"
|
|
7
7
|
require_relative "prompts"
|
|
8
|
-
require_relative "../prose_list"
|
|
9
8
|
|
|
10
9
|
module Principles
|
|
11
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
12
11
|
module Views
|
|
13
12
|
# A one-member audit's request and its result.
|
|
14
13
|
class AcknowledgementResult
|
|
14
|
+
# Where a placeholder names the member of the entry it prints in.
|
|
15
|
+
SLOT = "%<id>s" #: String
|
|
16
|
+
|
|
15
17
|
#: (Invocation) -> void
|
|
16
18
|
def initialize(invocation)
|
|
17
19
|
@invocation = invocation
|
|
@@ -21,14 +23,16 @@ module Principles
|
|
|
21
23
|
# asked is what the request asks of its member: under :change its change since its baseline; under :context
|
|
22
24
|
# what the request's context shows beside it, such as the record's findings on the member; and under
|
|
23
25
|
# :placeholders the text the template prints in each field the agent writes. What the agent judges is under
|
|
24
|
-
# context, the question
|
|
26
|
+
# context, the question first, so an agent reading the request's head finds what it is asked before the text.
|
|
25
27
|
#: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
|
|
26
28
|
def request(request_id:, principle_id:, asked:)
|
|
27
29
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
|
|
28
|
-
"context" => { "principle_id" => principle_id,
|
|
29
|
-
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning")
|
|
30
|
+
"context" => { "principle_id" => principle_id,
|
|
31
|
+
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning"),
|
|
32
|
+
**asked.fetch(:change).to_h, **asked.fetch(:context) },
|
|
30
33
|
"response_template" => answer_to_fill(request_id:, asked:),
|
|
31
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
34
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
35
|
+
"next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:) }
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
# The answer to the request request_id names, to fill: the request prints it as response_template, and
|
|
@@ -39,20 +43,22 @@ module Principles
|
|
|
39
43
|
def answer_to_fill(request_id:, asked:)
|
|
40
44
|
member_id = asked.fetch(:change).member_id
|
|
41
45
|
{ "request_id" => request_id, "basis" => { "member_ids" => [member_id] },
|
|
42
|
-
"members" => { member_id => asked.fetch(:placeholders) } }
|
|
46
|
+
"members" => { member_id => named(asked.fetch(:placeholders), member_id) } }
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
# The request for several members' acknowledgements in one answer: each of members holds a member's
|
|
46
50
|
# change, the context its own request shows beside it and the placeholders its template prints, as one member's
|
|
47
|
-
# request holds them, under context.members and the template's members in the order the agent named them.
|
|
51
|
+
# request holds them, under context.members and the template's members in the order the agent named them. The
|
|
52
|
+
# question leads the context, so an agent reading the request's head finds what it is asked before the members.
|
|
48
53
|
#: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
49
54
|
def several_request(request_id:, principle_id:, members:)
|
|
50
55
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
51
56
|
"context" => { "principle_id" => principle_id,
|
|
52
|
-
"
|
|
53
|
-
"
|
|
57
|
+
"question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning"),
|
|
58
|
+
"members" => shown(members) },
|
|
54
59
|
"response_template" => several_to_fill(request_id:, members:),
|
|
55
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
60
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
61
|
+
"next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id }, request_id:) }
|
|
56
62
|
end
|
|
57
63
|
|
|
58
64
|
# The answer to the request for several members request_id names, to fill: its basis names each member, and
|
|
@@ -60,21 +66,23 @@ module Principles
|
|
|
60
66
|
#: (request_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
61
67
|
def several_to_fill(request_id:, members:)
|
|
62
68
|
{ "request_id" => request_id, "basis" => { "member_ids" => members.map { it.fetch(:change).member_id } },
|
|
63
|
-
"members" => members.to_h {
|
|
69
|
+
"members" => members.to_h { named_entry(it) } }
|
|
64
70
|
end
|
|
65
71
|
|
|
66
72
|
# The request for the members several principles map in one answer: under context.principles, each
|
|
67
73
|
# principle's members as its own request for several shows them, and in the template one entry per member,
|
|
68
74
|
# judged once for every principle that maps it. keeping_deferred names each principle whose members keep a
|
|
69
|
-
# deferred finding, which the request says only a full audit resolves.
|
|
75
|
+
# deferred finding, which the request says only a full audit resolves. The question leads the context, as in
|
|
76
|
+
# one principle's requests.
|
|
70
77
|
#: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]],
|
|
71
78
|
#| ?keeping_deferred: Array[String]) -> Hash[String, untyped]
|
|
72
79
|
def across_request(request_id:, principles:, keeping_deferred: [])
|
|
73
80
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
74
|
-
"context" => { "principles" => shown_once(principles),
|
|
75
|
-
**deferred_findings_kept(keeping_deferred)
|
|
81
|
+
"context" => { "question" => across_question, "principles" => shown_once(principles),
|
|
82
|
+
**deferred_findings_kept(keeping_deferred) },
|
|
76
83
|
"response_template" => across_to_fill(request_id:, principles:),
|
|
77
|
-
"answer_with" => @invocation.submit_answer(request_id)
|
|
84
|
+
"answer_with" => @invocation.submit_answer(request_id),
|
|
85
|
+
"next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles), request_id:) }
|
|
78
86
|
end
|
|
79
87
|
|
|
80
88
|
# The answer to the request for the members several principles map, to fill: its basis names each principle and
|
|
@@ -85,51 +93,36 @@ module Principles
|
|
|
85
93
|
def across_to_fill(request_id:, principles:)
|
|
86
94
|
entries = principles.values.flatten.each_with_object({}) do |asked, by_member|
|
|
87
95
|
id = asked.fetch(:change).member_id
|
|
88
|
-
by_member[id] = asked.fetch(:placeholders).merge(by_member.fetch(id, {}))
|
|
96
|
+
by_member[id] = named(asked.fetch(:placeholders), id).merge(by_member.fetch(id, {}))
|
|
89
97
|
end
|
|
90
98
|
{ "request_id" => request_id, "basis" => { "principle_ids" => principles.keys, "member_ids" => entries.keys },
|
|
91
99
|
"members" => entries }
|
|
92
100
|
end
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
|
|
101
|
-
"This no longer lists them: " \
|
|
102
|
-
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
103
|
-
)
|
|
104
|
-
end
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
# placeholders with each one's SLOT naming the member id, as its entry in the template prints them; any other
|
|
105
|
+
# text, a percent sign included, as it is.
|
|
106
|
+
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
107
|
+
def named(placeholders, id) = placeholders.transform_values { it.is_a?(String) ? it.gsub(SLOT, id) : it }
|
|
105
108
|
|
|
106
|
-
# The
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"status" => "acknowledged", "principle_ids" => files.keys, "member_ids" => member_ids,
|
|
112
|
-
"files_to_commit" => files.values,
|
|
113
|
-
"next_action" => "Commit #{ProseList.new(files.values)}. #{ProseList.new(member_ids)} read as judged until " \
|
|
114
|
-
"each is edited again.\nThis no longer lists them: " \
|
|
115
|
-
"#{@invocation.in_project("list-member-problems", usage: "--short")}"
|
|
116
|
-
)
|
|
109
|
+
# The template's entry for the member asked asks about, by its id.
|
|
110
|
+
#: (Hash[Symbol, untyped]) -> [String, Hash[String, untyped]]
|
|
111
|
+
def named_entry(asked)
|
|
112
|
+
id = asked.fetch(:change).member_id
|
|
113
|
+
[id, named(asked.fetch(:placeholders), id)]
|
|
117
114
|
end
|
|
118
115
|
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"files_to_commit" => [file],
|
|
125
|
-
"next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
|
|
126
|
-
"This no longer lists it: " \
|
|
127
|
-
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
128
|
-
}
|
|
129
|
-
AnsweredRequest.new(fields)
|
|
116
|
+
# How to fill the answer to request_id, acknowledging member_ids of principle_ids: saved bare from
|
|
117
|
+
# start-audit --as template to a file the agent edits.
|
|
118
|
+
#: (Array[String], Array[String], request_id: String) -> String
|
|
119
|
+
def to_fill(principle_ids, member_ids, request_id:)
|
|
120
|
+
AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:)
|
|
130
121
|
end
|
|
131
122
|
|
|
132
|
-
|
|
123
|
+
# Each member the principles' requests ask about, once, in the order they ask.
|
|
124
|
+
#: (Hash[String, Array[Hash[Symbol, untyped]]]) -> Array[String]
|
|
125
|
+
def across_member_ids(principles) = principles.values.flatten.map { it.fetch(:change).member_id }.uniq
|
|
133
126
|
|
|
134
127
|
# Where to read the deferred findings an acknowledgement across principles keeps, and the full audit of each
|
|
135
128
|
# principle in ids that resolves them, one command to a line; nothing when ids is empty.
|
|
@@ -34,7 +34,16 @@ module Principles
|
|
|
34
34
|
#: () -> String
|
|
35
35
|
def span
|
|
36
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. "
|
|
37
|
+
"if that is not the passage you meant, move it with move-member. #{runs_on}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# What the agent judges when the paragraph or list item a one-line passage starts runs on past it; it ends with
|
|
41
|
+
# a space, or is empty.
|
|
42
|
+
#: () -> String
|
|
43
|
+
def runs_on
|
|
44
|
+
line = @added["continues_to_line"] or return ""
|
|
45
|
+
"Its paragraph or list item continues to line #{line}; if the member is all of it, move it with " \
|
|
46
|
+
"--ending-at quoting the words that end it. "
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "context_parts"
|
|
5
|
+
require_relative "invocation"
|
|
6
|
+
require_relative "prompts"
|
|
7
|
+
require_relative "shell_word"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
|
+
module Views
|
|
12
|
+
# How to fill an answer this tool prints bare: save it to a file outside the project, named in full, fill it
|
|
13
|
+
# there with the agent's own file-edit tool, and submit that file, with the three characters JSON escapes.
|
|
14
|
+
# Filling a template in a shell heredoc took a script, since prose full of quotes needed escaping for the shell
|
|
15
|
+
# and for JSON.
|
|
16
|
+
class AnswerInAFile
|
|
17
|
+
#: (Invocation) -> void
|
|
18
|
+
def initialize(invocation)
|
|
19
|
+
@invocation = invocation
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The line for a full audit's assessment, whose answer start-audit --part response_template prints bare.
|
|
24
|
+
#: (String, request_id: String) -> String
|
|
25
|
+
def assessment(principle_id, request_id:)
|
|
26
|
+
line(@invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::TEMPLATE]),
|
|
27
|
+
request_id:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# The line for acknowledging member_ids of principle_ids, whose answer start-audit --member --as template prints
|
|
31
|
+
# bare.
|
|
32
|
+
#: (Array[String], Array[String], request_id: String) -> String
|
|
33
|
+
def acknowledgement(principle_ids, member_ids, request_id:)
|
|
34
|
+
named = member_ids.flat_map { ["--member", it] }
|
|
35
|
+
line(@invocation.listed_in_project("start-audit", principle_ids, options: [*named, "--as", "template"]),
|
|
36
|
+
request_id:)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The line for a decision on principle_id's open findings, whose answer start-audit --open-findings --as template
|
|
40
|
+
# prints bare.
|
|
41
|
+
#: (String, request_id: String) -> String
|
|
42
|
+
def open_findings(principle_id, request_id:)
|
|
43
|
+
line(@invocation.in_project("start-audit", principle_id, options: %w[--open-findings --as template]),
|
|
44
|
+
request_id:)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# The line for an open correction, whose answer show-open-correction prints bare, of which only the
|
|
48
|
+
# dispositions are the agent's to fill.
|
|
49
|
+
#: (String, request_id: String) -> String
|
|
50
|
+
def correction(principle_id, request_id:)
|
|
51
|
+
line(@invocation.in_project("show-open-correction", principle_id), request_id:, what: "only its dispositions")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The line for the answer request_id names, which the printed command save prints bare; what is the part of it
|
|
55
|
+
# the agent fills.
|
|
56
|
+
#: (String, request_id: String, ?what: String) -> String
|
|
57
|
+
def line(save, request_id:, what: "it")
|
|
58
|
+
file = @invocation.answer_file(request_id)
|
|
59
|
+
Prompts.text("answer-any-judgement-request/fill-the-answer-in-a-file",
|
|
60
|
+
save: "#{save} > #{ShellWord.new(file)}", what:,
|
|
61
|
+
answer_with: @invocation.submit_answer(request_id, file:))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -18,7 +18,8 @@ module Principles
|
|
|
18
18
|
# reviewed_check_placeholders is the text a checked member's template prints in each field it may leave as
|
|
19
19
|
# printed to give none, for a check reviewed before it runs; unchanged_check_placeholders, for one the
|
|
20
20
|
# last audit ran.
|
|
21
|
-
# assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back
|
|
21
|
+
# assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back, its
|
|
22
|
+
# %<id>s filled with the member's id, so each slot's is its own and one edit fills one slot.
|
|
22
23
|
#: (Array[Hash[String, untyped]], reviewed_check_placeholders: Hash[String, String],
|
|
23
24
|
#| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String) -> void
|
|
24
25
|
def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:)
|
|
@@ -151,7 +152,8 @@ module Principles
|
|
|
151
152
|
|
|
152
153
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
153
154
|
def fresh(member)
|
|
154
|
-
|
|
155
|
+
id = member.fetch("id")
|
|
156
|
+
{ "member_id" => id, "assessment" => format(@assessment_placeholder, id:),
|
|
155
157
|
"delivery" => "not_observed", "evidence" => member.fetch("evidence") }
|
|
156
158
|
end
|
|
157
159
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "assessed_members"
|
|
5
|
+
require_relative "instruction"
|
|
6
|
+
require_relative "json_on_one_line"
|
|
7
|
+
require_relative "prompts"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
|
+
module Views
|
|
12
|
+
# The guide to a full audit's answer shapes, printed under answer_guide with the entries whose case the request's
|
|
13
|
+
# members hold.
|
|
14
|
+
class AssessmentAnswerGuide
|
|
15
|
+
#: (AssessedMembers) -> void
|
|
16
|
+
def initialize(members)
|
|
17
|
+
@members = members
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The answer guide, showing check_result's fields only when a member has a check, so an audit
|
|
22
|
+
# with no checks costs no more context than before, and delivery's shapes only when a member is judged
|
|
23
|
+
# afresh, since a carried member's marker gives none. check_result's limits say how to review a check
|
|
24
|
+
# before running it only when a check is new or changed, as that check's own template says too.
|
|
25
|
+
#: () -> GuideInstruction
|
|
26
|
+
def instruction
|
|
27
|
+
guide = with_examples_on_lines(Prompts.data("assess-every-member/answer-guide"))
|
|
28
|
+
narrowed = @members.check_to_review? ? {} : guide.slice("check_result")
|
|
29
|
+
GuideInstruction.new("answer_guide", guide.merge("check_result" => reviewed(guide.fetch("check_result"))),
|
|
30
|
+
narrowed:) do |entry|
|
|
31
|
+
case entry
|
|
32
|
+
when "check_result" then @members.checked?
|
|
33
|
+
when "member_delivery" then @members.judged_afresh?
|
|
34
|
+
else true
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
# guide with each entry's examples printing compact, a line each, since the agent copies each one whole.
|
|
42
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
43
|
+
def with_examples_on_lines(guide)
|
|
44
|
+
guide.transform_values do |entry|
|
|
45
|
+
next entry unless entry.is_a?(Hash) && entry.key?("examples")
|
|
46
|
+
|
|
47
|
+
entry.merge("examples" => entry.fetch("examples").transform_values { JsonOnOneLine[it] })
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# check_result's guide entry whole, its limits ending with how to review a new or changed check before running it.
|
|
52
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
53
|
+
def reviewed(check_result)
|
|
54
|
+
review = Prompts.text("assess-every-member/review-a-new-or-changed-check-before-running-it")
|
|
55
|
+
check_result.merge("limits" => "#{check_result.fetch("limits")} #{review}")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "answer_head"
|
|
5
|
+
require_relative "assessment_answer_guide"
|
|
5
6
|
require_relative "assessed_members"
|
|
6
7
|
require_relative "context_parts"
|
|
7
8
|
require_relative "instruction"
|
|
@@ -142,7 +143,7 @@ module Principles
|
|
|
142
143
|
#: () -> Array[Instruction | GuideInstruction]
|
|
143
144
|
def instructions
|
|
144
145
|
[question, judge_because_instruction,
|
|
145
|
-
carried_forward_instruction, mapped_elsewhere_instruction,
|
|
146
|
+
carried_forward_instruction, mapped_elsewhere_instruction, AssessmentAnswerGuide.new(@members).instruction]
|
|
146
147
|
end
|
|
147
148
|
|
|
148
149
|
# The question, defining observed only when a member is judged afresh, whose delivery it guides.
|
|
@@ -176,31 +177,6 @@ module Principles
|
|
|
176
177
|
end
|
|
177
178
|
end
|
|
178
179
|
|
|
179
|
-
# The answer guide, showing check_result's fields only when a member has a check, so an audit
|
|
180
|
-
# with no checks costs no more context than before, and delivery's shapes only when a member is judged
|
|
181
|
-
# afresh, since a carried member's marker gives none. check_result's limits say how to review a check
|
|
182
|
-
# before running it only when a check is new or changed, as that check's own template says too.
|
|
183
|
-
#: () -> GuideInstruction
|
|
184
|
-
def answer_guide
|
|
185
|
-
guide = Prompts.data("assess-every-member/answer-guide")
|
|
186
|
-
narrowed = @members.check_to_review? ? {} : guide.slice("check_result")
|
|
187
|
-
GuideInstruction.new("answer_guide", guide.merge("check_result" => reviewed(guide.fetch("check_result"))),
|
|
188
|
-
narrowed:) do |entry|
|
|
189
|
-
case entry
|
|
190
|
-
when "check_result" then @members.checked?
|
|
191
|
-
when "member_delivery" then @members.judged_afresh?
|
|
192
|
-
else true
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# check_result's guide entry whole, its limits ending with how to review a new or changed check before running it.
|
|
198
|
-
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
199
|
-
def reviewed(check_result)
|
|
200
|
-
review = Prompts.text("assess-every-member/review-a-new-or-changed-check-before-running-it")
|
|
201
|
-
check_result.merge("limits" => "#{check_result.fetch("limits")} #{review}")
|
|
202
|
-
end
|
|
203
|
-
|
|
204
180
|
# How to answer when the request carries some members' last assessments forward; nothing when it carries none.
|
|
205
181
|
# What a compact carried member shows, and what prints one whole, only when one prints compactly.
|
|
206
182
|
#: () -> Instruction
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "assessment_request"
|
|
5
|
+
require_relative "answer_in_a_file"
|
|
5
6
|
require_relative "answered_request"
|
|
6
7
|
require_relative "audit_changes"
|
|
7
8
|
require_relative "completed_audit_next_step"
|
|
@@ -10,6 +11,7 @@ require_relative "invocation"
|
|
|
10
11
|
require_relative "prior_finding_decisions_result"
|
|
11
12
|
require_relative "prompts"
|
|
12
13
|
require_relative "report_hooks_offer"
|
|
14
|
+
require_relative "shell_word"
|
|
13
15
|
require_relative "trimmed_instructions_note"
|
|
14
16
|
require_relative "../prose_list"
|
|
15
17
|
|
|
@@ -94,14 +96,14 @@ module Principles
|
|
|
94
96
|
|
|
95
97
|
# start-audit: the assessment request, as a judgement to answer under its request id, its context naming the
|
|
96
98
|
# instructions it prints only in part and the flag that prints one whole, so a trimmed field is not taken for
|
|
97
|
-
# the whole, without the command the agent just ran
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
output = judgement("assessment", request, { "read_in_parts" => read_in_parts(request.principle_id) },
|
|
99
|
+
# the whole, without the command the agent just ran, after its head, which sizes each part as part_bytes.
|
|
100
|
+
#: (AssessmentRequest, part_bytes: Hash[String, Integer]) -> Hash[String, untyped]
|
|
101
|
+
def assessment_request(request, part_bytes:)
|
|
102
|
+
output = judgement("assessment", request, assessment_head(request.principle_id, part_bytes),
|
|
102
103
|
to_fill: { "response_template" => request.template })
|
|
103
104
|
note = TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h
|
|
104
|
-
|
|
105
|
+
fill = AnswerInAFile.new(@invocation).assessment(request.principle_id, request_id: request.request_id)
|
|
106
|
+
output.merge("context" => output.fetch("context").merge(note), "next_action" => fill)
|
|
105
107
|
end
|
|
106
108
|
|
|
107
109
|
# start-audit --as template: the assessment's answer alone, to fill and submit.
|
|
@@ -180,6 +182,15 @@ module Principles
|
|
|
180
182
|
result.merge(field => facts, "next_action" => [judge, result["next_action"]].compact.join("\n"))
|
|
181
183
|
end
|
|
182
184
|
|
|
185
|
+
# What a full audit's request of principle_id prints before its context: the command listing its parts, so a
|
|
186
|
+
# long request is read in parts rather than paged by script, and part_bytes, each part's bytes by its name as a
|
|
187
|
+
# shell reads it, as the index prints them, so the agent sizes its reads without running a script for them.
|
|
188
|
+
#: (String, Hash[String, Integer]) -> Hash[String, untyped]
|
|
189
|
+
def assessment_head(principle_id, part_bytes)
|
|
190
|
+
{ "read_in_parts" => read_in_parts(principle_id),
|
|
191
|
+
"part_bytes" => part_bytes.transform_keys { ShellWord.new(it).to_s } }
|
|
192
|
+
end
|
|
193
|
+
|
|
183
194
|
# How to read principle_id's full-audit request in parts: the command listing them, and the flag printing one.
|
|
184
195
|
#: (String) -> String
|
|
185
196
|
def read_in_parts(principle_id)
|
|
@@ -190,7 +201,7 @@ module Principles
|
|
|
190
201
|
# request as a judgement to answer in phase, under its id, which its template's head also gives, with any
|
|
191
202
|
# opening fields after the phase and before the context, and to_fill, the answer to fill when this request
|
|
192
203
|
# prints it, after the context.
|
|
193
|
-
#: (String, AssessmentRequest | CorrectionRequest, ?Hash[String,
|
|
204
|
+
#: (String, AssessmentRequest | CorrectionRequest, ?Hash[String, untyped], ?to_fill: Hash[String, untyped])
|
|
194
205
|
#| -> Hash[String, untyped]
|
|
195
206
|
def judgement(phase, request, opening = {}, to_fill: {})
|
|
196
207
|
{ "status" => "agent_judgement_required", "request_id" => request.request_id, "phase" => phase, **opening,
|
|
@@ -33,12 +33,15 @@ module Principles
|
|
|
33
33
|
#: () -> Integer?
|
|
34
34
|
def range_outlines_bytes = @inventory["range_outlines_bytes"]
|
|
35
35
|
|
|
36
|
+
# conventional says whether the survey looked in the places hosts load by convention, as it does
|
|
37
|
+
# unless --only narrowed it to its globs' matches.
|
|
36
38
|
#: (inventory: Hash[String, untyped], untracked: Array[String]?,
|
|
37
|
-
#| owner_asks: Hash[String, Array[String]]) -> void
|
|
38
|
-
def initialize(inventory:, untracked:, owner_asks:)
|
|
39
|
+
#| owner_asks: Hash[String, Array[String]], ?conventional: bool) -> void
|
|
40
|
+
def initialize(inventory:, untracked:, owner_asks:, conventional: true)
|
|
39
41
|
@inventory = inventory
|
|
40
42
|
@untracked = untracked
|
|
41
43
|
@owner_asks = owner_asks
|
|
44
|
+
@conventional = conventional
|
|
42
45
|
freeze
|
|
43
46
|
end
|
|
44
47
|
|
|
@@ -47,8 +50,10 @@ module Principles
|
|
|
47
50
|
#: () -> Hash[String, untyped]
|
|
48
51
|
def listed
|
|
49
52
|
files = @inventory.fetch("files").map { |file| file.slice(*PRINTED_FILE_FIELDS) }
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
scope = if @conventional then Prompts.text("find-a-principle-to-map/where-the-inventory-looks")
|
|
54
|
+
else Prompts.text("find-a-principle-to-map/where-a-survey-with-only-looks")
|
|
55
|
+
end
|
|
56
|
+
listed = @inventory.merge("files" => files, "scope" => scope)
|
|
52
57
|
@untracked ? listed.merge("untracked" => @untracked) : listed
|
|
53
58
|
end
|
|
54
59
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "../prose_list"
|
|
4
5
|
require_relative "member_lines_beside_text"
|
|
5
6
|
require_relative "printed_json"
|
|
6
7
|
|
|
@@ -20,10 +21,6 @@ module Principles
|
|
|
20
21
|
# The part holding the answer to fill, as the request prints it beside its context.
|
|
21
22
|
TEMPLATE = "response_template" #: String
|
|
22
23
|
|
|
23
|
-
# What --part prints for an optional part the request leaves out, holding nothing for it.
|
|
24
|
-
EMPTY = { "part_empty" => "Nothing to list for this request; " \
|
|
25
|
-
"the answer needs nothing for it." }.freeze #: Hash[String, String]
|
|
26
|
-
|
|
27
24
|
# instruction_fields is each field the context prints an instruction under, in order. template is the answer to
|
|
28
25
|
# fill, as the request prints it. texts is each member's lines now, by id, one string each, which its part
|
|
29
26
|
# prints and the whole request does not. optional names each part the context lists only when it holds something.
|
|
@@ -54,29 +51,63 @@ module Principles
|
|
|
54
51
|
#: () -> Array[String]
|
|
55
52
|
def left_out = @optional - @context.keys
|
|
56
53
|
|
|
54
|
+
# Each part's name, as names lists it, with the bytes --part prints of its value.
|
|
55
|
+
#: () -> Hash[String, Integer]
|
|
56
|
+
def part_bytes = names.to_h { [it, bytes(shown(it))] }
|
|
57
|
+
|
|
57
58
|
# The part name, under its key, as the context prints it; a member's entry alone under members, with its text
|
|
58
59
|
# when given, its id read after the one prefix, so an id with a slash, or starting members/, is read whole.
|
|
59
60
|
#: (String) -> Hash[String, untyped]
|
|
60
61
|
def shown(name)
|
|
61
62
|
return { INDEX => index } if name == INDEX
|
|
62
|
-
return
|
|
63
|
-
return
|
|
63
|
+
return empty([name]) if left_out.include?(name)
|
|
64
|
+
return @template if name == TEMPLATE
|
|
64
65
|
return { name => @context.fetch(name) } unless name.start_with?(MEMBER)
|
|
65
66
|
|
|
66
67
|
id = name.delete_prefix(MEMBER)
|
|
67
68
|
{ "members" => members.select { it.fetch("id") == id }.map { with_text(it) } }
|
|
68
69
|
end
|
|
69
70
|
|
|
71
|
+
# The parts names, each as shown prints it, printed together: each member's in one members list and each empty
|
|
72
|
+
# one named in one part_empty, in the order given, where merging the parts one by one leaves the last alone.
|
|
73
|
+
#: (Array[String]) -> Hash[String, untyped]
|
|
74
|
+
def shown_together(names)
|
|
75
|
+
together = names.reduce({}) { |all, name| all.merge(shown(name)) } #: Hash[String, untyped]
|
|
76
|
+
with_every_empty(with_every_member(together, names), names)
|
|
77
|
+
end
|
|
78
|
+
|
|
70
79
|
private
|
|
71
80
|
|
|
81
|
+
# together with each member names names in one members list; together as it is when names name no member.
|
|
82
|
+
#: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
|
|
83
|
+
def with_every_member(together, names)
|
|
84
|
+
return together unless together.key?("members")
|
|
85
|
+
|
|
86
|
+
together.merge("members" => names.flat_map { shown(it).fetch("members", []) })
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# together with one part_empty naming every empty part names; together as it is when names name none.
|
|
90
|
+
#: (Hash[String, untyped], Array[String]) -> Hash[String, untyped]
|
|
91
|
+
def with_every_empty(together, names)
|
|
92
|
+
empty_named = names & left_out
|
|
93
|
+
empty_named.empty? ? together : together.merge(empty(empty_named))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# What --part prints for the optional parts names, which the request leaves out for holding nothing, naming each
|
|
97
|
+
# in the order given, so the agent knows which of the parts it asked for were empty.
|
|
98
|
+
#: (Array[String]) -> Hash[String, String]
|
|
99
|
+
def empty(names)
|
|
100
|
+
{ "part_empty" => "Nothing to list for #{ProseList.new(names)} in this request; " \
|
|
101
|
+
"the answer needs nothing for #{names.one? ? "it" : "them"}." }
|
|
102
|
+
end
|
|
103
|
+
|
|
72
104
|
# Each part with the bytes --part prints of its value, and each member with whether this audit judges it, and
|
|
73
105
|
# why when the request says, or carries its last assessment forward.
|
|
74
106
|
#: () -> Array[Hash[String, untyped]]
|
|
75
107
|
def index
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
name.start_with?(MEMBER) ? entry.merge(judged(part.fetch("members").fetch(0))) : entry
|
|
108
|
+
part_bytes.map do |name, size|
|
|
109
|
+
entry = { "part" => name, "bytes" => size }
|
|
110
|
+
name.start_with?(MEMBER) ? entry.merge(judged(shown(name).fetch("members").fetch(0))) : entry
|
|
80
111
|
end
|
|
81
112
|
end
|
|
82
113
|
|