principles 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +132 -0
- data/README.md +10 -6
- data/lib/principles/command_line.rb +15 -6
- data/lib/principles/command_routes.rb +11 -1
- data/lib/principles/controllers/acknowledgement.rb +19 -4
- data/lib/principles/controllers/acknowledgements.rb +43 -12
- data/lib/principles/controllers/after_commit_report.rb +15 -2
- data/lib/principles/controllers/assessment.rb +7 -3
- data/lib/principles/controllers/audit.rb +17 -8
- data/lib/principles/controllers/audit_completion.rb +34 -9
- data/lib/principles/controllers/carrier_practices.rb +26 -0
- data/lib/principles/controllers/command.rb +31 -3
- data/lib/principles/controllers/correction.rb +15 -5
- data/lib/principles/controllers/full_audit_request.rb +38 -42
- data/lib/principles/controllers/inventory.rb +77 -71
- data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
- data/lib/principles/controllers/member_acknowledgement.rb +21 -11
- data/lib/principles/controllers/member_addition.rb +19 -4
- data/lib/principles/controllers/member_entries.rb +25 -6
- data/lib/principles/controllers/member_problems_report.rb +26 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
- data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
- data/lib/principles/controllers/members_to_assess.rb +24 -7
- data/lib/principles/controllers/meta_principle_setup.rb +2 -2
- data/lib/principles/controllers/open_correction.rb +3 -2
- data/lib/principles/controllers/parts_to_read.rb +46 -5
- data/lib/principles/controllers/plugin_member_addition.rb +48 -0
- data/lib/principles/controllers/principle_listing.rb +84 -0
- data/lib/principles/controllers/request_logging.rb +52 -0
- data/lib/principles/controllers/running_tool.rb +45 -17
- data/lib/principles/data/branches_bringing_in.rb +52 -0
- data/lib/principles/data/changes_since.rb +56 -0
- data/lib/principles/data/claude_code_home.rb +58 -0
- data/lib/principles/data/command-steps.json +91 -15
- data/lib/principles/data/decoded_leaf.rb +63 -0
- data/lib/principles/data/head_reflog.rb +13 -2
- data/lib/principles/data/kept_line.rb +32 -0
- data/lib/principles/data/known_marketplaces.rb +50 -0
- data/lib/principles/data/logged_request_matches.rb +138 -0
- data/lib/principles/data/logged_request_scan.rb +120 -0
- data/lib/principles/data/map_files.rb +18 -4
- data/lib/principles/data/plugin_folder.rb +85 -0
- data/lib/principles/data/plugin_registry.rb +73 -0
- data/lib/principles/data/principles_store.rb +49 -0
- data/lib/principles/data/ran.rb +25 -0
- data/lib/principles/data/raw_request_filter.rb +61 -0
- data/lib/principles/data/repository.rb +34 -27
- data/lib/principles/data/request_logging_folder.rb +167 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
- data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
- 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 +14 -0
- data/lib/principles/data/schemas/member-map.schema.json +10 -1
- data/lib/principles/data/string_counts.rb +39 -0
- data/lib/principles/data/tools_on_path.rb +25 -0
- data/lib/principles/invocation_options.rb +4 -2
- data/lib/principles/launch.rb +14 -4
- data/lib/principles/models/acknowledged_check.rb +11 -1
- data/lib/principles/models/acknowledgement.rb +15 -0
- data/lib/principles/models/acknowledgement_placeholders.rb +43 -18
- data/lib/principles/models/acknowledgement_refusal.rb +20 -11
- data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
- data/lib/principles/models/after_commit_input.rb +5 -0
- data/lib/principles/models/answer_fields.rb +3 -0
- data/lib/principles/models/assessment_basis.rb +10 -3
- data/lib/principles/models/audit.rb +10 -10
- data/lib/principles/models/audit_record.rb +10 -0
- data/lib/principles/models/audit_records.rb +4 -3
- data/lib/principles/models/audit_start.rb +9 -0
- data/lib/principles/models/authored_locator.rb +33 -0
- data/lib/principles/models/candidate_files.rb +23 -3
- data/lib/principles/models/candidate_outline.rb +18 -125
- data/lib/principles/models/captured_sessions.rb +128 -0
- data/lib/principles/models/carrier_kind.rb +79 -0
- data/lib/principles/models/cited_files.rb +12 -3
- data/lib/principles/models/decided_prior_findings.rb +5 -0
- data/lib/principles/models/disposition.rb +38 -7
- data/lib/principles/models/disposition_placeholders.rb +27 -7
- data/lib/principles/models/disposition_text_field.rb +4 -0
- data/lib/principles/models/feature.rb +53 -0
- data/lib/principles/models/finding_outcomes.rb +55 -0
- data/lib/principles/models/findings_left_open.rb +9 -11
- data/lib/principles/models/head_moves.rb +27 -10
- data/lib/principles/models/installed_component.rb +55 -0
- data/lib/principles/models/installed_plugins.rb +174 -0
- data/lib/principles/models/kept_sessions.rb +34 -0
- data/lib/principles/models/locator.rb +8 -0
- data/lib/principles/models/logged_request_reach.rb +44 -0
- data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
- data/lib/principles/models/mapped_baseline.rb +46 -0
- data/lib/principles/models/maps_holding_file_whole.rb +42 -0
- data/lib/principles/models/markdown_text.rb +143 -0
- data/lib/principles/models/member.rb +14 -1
- data/lib/principles/models/member_entry.rb +56 -0
- data/lib/principles/models/member_lines.rb +11 -0
- data/lib/principles/models/member_loads.rb +17 -2
- data/lib/principles/models/member_problems.rb +45 -42
- data/lib/principles/models/member_reach.rb +36 -0
- data/lib/principles/models/member_snapshots.rb +23 -4
- data/lib/principles/models/member_text_as_sent.rb +31 -0
- data/lib/principles/models/member_texts.rb +45 -0
- data/lib/principles/models/members_in_logged_requests.rb +240 -0
- data/lib/principles/models/missing_files.rb +41 -16
- data/lib/principles/models/named_placeholder.rb +17 -7
- data/lib/principles/models/nearly_matching_maps.rb +56 -0
- data/lib/principles/models/open_correction.rb +5 -0
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/outline_budget.rb +10 -1
- data/lib/principles/models/outline_item.rb +25 -0
- data/lib/principles/models/outline_section.rb +15 -4
- data/lib/principles/models/part_named.rb +16 -2
- data/lib/principles/models/plugin_component.rb +37 -0
- data/lib/principles/models/plugin_install.rb +33 -0
- data/lib/principles/models/plugin_name.rb +23 -0
- data/lib/principles/models/plugin_reference.rb +53 -0
- data/lib/principles/models/principle_members.rb +15 -0
- data/lib/principles/models/prior_finding_decision.rb +1 -1
- data/lib/principles/models/prior_finding_outcomes.rb +12 -1
- data/lib/principles/models/problem_report.rb +14 -25
- data/lib/principles/models/project.rb +35 -29
- data/lib/principles/models/project_history.rb +23 -0
- data/lib/principles/models/recorded_members.rb +7 -0
- data/lib/principles/models/request_logging.rb +196 -0
- data/lib/principles/models/runs_from.rb +0 -5
- data/lib/principles/models/script_comments.rb +58 -0
- data/lib/principles/models/stale_request.rb +9 -0
- data/lib/principles/models/template_placeholders.rb +10 -9
- data/lib/principles/models/unfixed_part.rb +82 -0
- data/lib/principles/models/unresolved_plugin_members.rb +35 -0
- data/lib/principles/models/whole_file_member_read.rb +48 -0
- data/lib/principles/models/without_prose.rb +20 -0
- data/lib/principles/models/workflow_jobs.rb +92 -0
- data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
- data/lib/principles/show_principle_options.rb +32 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +31 -12
- data/lib/principles/views/acknowledgement_result.rb +41 -29
- data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
- data/lib/principles/views/acknowledgements_offered.rb +54 -0
- data/lib/principles/views/added_member.rb +22 -6
- data/lib/principles/views/answer_in_a_file.rb +16 -16
- data/lib/principles/views/assessed_members.rb +18 -7
- data/lib/principles/views/assessment_request.rb +8 -3
- data/lib/principles/views/audit_changes.rb +14 -8
- data/lib/principles/views/audit_findings.rb +34 -0
- data/lib/principles/views/audit_result.rb +14 -19
- data/lib/principles/views/carrier_checks.rb +40 -0
- data/lib/principles/views/carrier_practices_page.rb +49 -0
- data/lib/principles/views/completed_audit_findings.rb +33 -0
- data/lib/principles/views/completed_audit_next_step.rb +12 -4
- data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
- data/lib/principles/views/context_parts.rb +129 -25
- data/lib/principles/views/correction_request.rb +22 -17
- data/lib/principles/views/disposition_template.rb +35 -0
- data/lib/principles/views/first_audit.rb +29 -15
- data/lib/principles/views/first_audit_brief.rb +0 -1
- data/lib/principles/views/first_audit_line.rb +4 -5
- data/lib/principles/views/invocation.rb +16 -6
- data/lib/principles/views/last_record_notice.rb +41 -0
- data/lib/principles/views/lines_shared_with_member.rb +16 -22
- data/lib/principles/views/logged_request_status_meanings.rb +29 -0
- data/lib/principles/views/logged_requests_evidence.rb +69 -0
- data/lib/principles/views/map_added_to.rb +14 -12
- data/lib/principles/views/map_result.rb +39 -17
- data/lib/principles/views/member_change_since_baseline.rb +4 -0
- data/lib/principles/views/member_row.rb +13 -4
- data/lib/principles/views/member_sets_overlap.rb +31 -0
- data/lib/principles/views/members_a_commit_changed.rb +42 -25
- data/lib/principles/views/members_changed_during_audit.rb +27 -0
- data/lib/principles/views/members_in_logged_requests_result.rb +68 -0
- data/lib/principles/views/members_too_short_to_scan.rb +45 -0
- data/lib/principles/views/members_with_no_baseline.rb +6 -6
- data/lib/principles/views/meta_principle_result.rb +14 -2
- data/lib/principles/views/open_findings_line.rb +31 -92
- data/lib/principles/views/parts_index_result.rb +9 -5
- data/lib/principles/views/principle_read_result.rb +52 -11
- data/lib/principles/views/prior_findings_result.rb +9 -1
- data/lib/principles/views/problem_facts.rb +5 -3
- data/lib/principles/views/problem_lines.rb +32 -6
- data/lib/principles/views/problem_result.rb +7 -15
- 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/claim-an-earlier-first-raised-at.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
- data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
- 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 +5 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +1 -1
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +50 -51
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +3 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +20 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +48 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +14 -14
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +11 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +10 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +32 -0
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
- data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
- data/lib/principles/views/request_logging_result.rb +62 -0
- data/lib/principles/views/request_part.rb +10 -4
- data/lib/principles/views/request_parts.rb +9 -0
- data/lib/principles/views/whole_file_elsewhere.rb +30 -0
- metadata +101 -4
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "logged_request_status_meanings"
|
|
5
|
+
require_relative "problem_lines"
|
|
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
|
+
# How many mapped members have each status, so the agent sizes what it reads before reading any member, what each
|
|
11
|
+
# status means, then which mapped members' text the captured requests held, by member, how many requests have no
|
|
12
|
+
# query_source, which requests quote a logged request's path, which the scan could not read through, how complete
|
|
13
|
+
# the scan was, and the files the scan wrote: none.
|
|
14
|
+
class MembersInLoggedRequestsResult
|
|
15
|
+
# The result from seen, the scan's report, as the request logging gives it.
|
|
16
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
17
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
18
|
+
#| completeness: Hash[String, untyped] }) -> Hash[String, untyped]
|
|
19
|
+
def result(seen)
|
|
20
|
+
{ "members_by_status" => seen[:members_by_status], "status_meanings" => LoggedRequestStatusMeanings.new.to_h,
|
|
21
|
+
"members" => seen[:members], "orphans" => seen[:orphans],
|
|
22
|
+
"quoting_requests" => seen[:quoting_requests], "unreadable" => seen[:unreadable],
|
|
23
|
+
"completeness" => seen[:completeness], "wrote" => [] }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# --short: the count of members with each status, with how many requests the scan read, whether it read every
|
|
27
|
+
# one through, since an absence holds only then, how many it could not read, and how many quote a logged
|
|
28
|
+
# request, where a presence may be a quote; then one tab-separated line a member: its status, principle, member
|
|
29
|
+
# key, with its id where it is now once moved, and the segments it was seen in, or - for none.
|
|
30
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
31
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
32
|
+
#| completeness: Hash[String, untyped] }) -> Lines
|
|
33
|
+
def short(seen)
|
|
34
|
+
lines = [counts(seen), *seen[:members].map { member_line(it) }]
|
|
35
|
+
Lines.new(stdout: lines.map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# The counts by status, then what the scan read, as short prints it.
|
|
41
|
+
#: ({ members_by_status: Hash[String, Integer], members: Array[Hash[String, untyped]], orphans: Integer,
|
|
42
|
+
#| quoting_requests: Array[String], unreadable: Array[Hash[String, String]],
|
|
43
|
+
#| completeness: Hash[String, untyped] }) -> String
|
|
44
|
+
def counts(seen)
|
|
45
|
+
completeness = seen[:completeness]
|
|
46
|
+
whole = completeness.fetch("complete") ? "complete" : "not complete"
|
|
47
|
+
read = "#{completeness.fetch("captured")} captured, #{whole}, #{seen[:unreadable].size} unreadable, " \
|
|
48
|
+
"#{seen[:quoting_requests].size} quoting a logged request"
|
|
49
|
+
"#{seen[:members_by_status].map { |status, count| "#{status} #{count}" }.join(", ")}; #{read}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# One member's line: status, principle, member key, with its id where it is now once moved, and the distinct
|
|
53
|
+
# segments it was seen in.
|
|
54
|
+
#: (Hash[String, untyped]) -> String
|
|
55
|
+
def member_line(member)
|
|
56
|
+
segments = member.fetch("segments")
|
|
57
|
+
[*member.values_at("status", "principle"), named(member), segments.empty? ? "-" : segments.join(",")].join("\t")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# member's key, followed by its id once a move has left the key naming where it was.
|
|
61
|
+
#: (Hash[String, untyped]) -> String
|
|
62
|
+
def named(member)
|
|
63
|
+
key = member.fetch("member")
|
|
64
|
+
member.key?("id") ? "#{key} (now #{member.fetch("id")})" : key
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
6
|
+
module Views
|
|
7
|
+
# What list-member-problems adds, while requests are logged, for each member too short to find in a logged
|
|
8
|
+
# request: it lists each under too_short_to_scan, and its next_action asks for the move that widens each, after
|
|
9
|
+
# every other action, since the member's own text is as fresh as before.
|
|
10
|
+
class MembersTooShortToScan
|
|
11
|
+
# members is each such member by its principle, id and the move-member options that widen it, placeholders
|
|
12
|
+
# left to fill; invocation names the commands.
|
|
13
|
+
#: (Invocation, Array[Hash[String, String]]) -> void
|
|
14
|
+
def initialize(invocation, members)
|
|
15
|
+
@invocation = invocation
|
|
16
|
+
@members = members
|
|
17
|
+
freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# report, list-member-problems' result whose next_action names a command as names_a_command says, with these
|
|
21
|
+
# members added, and whether its next_action names a command now.
|
|
22
|
+
#: (Hash[String, untyped], bool, nothing_changed: String) -> [Hash[String, untyped], bool]
|
|
23
|
+
def added_to(report, names_a_command, nothing_changed:)
|
|
24
|
+
return [report, names_a_command] if @members.empty?
|
|
25
|
+
|
|
26
|
+
action = report.fetch("next_action")
|
|
27
|
+
earlier = action == nothing_changed ? [] : [action]
|
|
28
|
+
[report.merge("too_short_to_scan" => @members.map { it.slice("principle", "id") },
|
|
29
|
+
"next_action" => [*earlier, *@members.map { widen(it) }].join("\n")), true]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# The line asking to widen member, with the move that does it.
|
|
35
|
+
#: (Hash[String, String]) -> String
|
|
36
|
+
def widen(member)
|
|
37
|
+
principle = member.fetch("principle")
|
|
38
|
+
id = member.fetch("id")
|
|
39
|
+
"#{id} of #{principle} has no line long enough to find in a logged request, so the scan cannot show " \
|
|
40
|
+
"whether it reached the agent; widen it to take in a longer line: " \
|
|
41
|
+
"#{@invocation.in_project("move-member", principle, id, usage: member.fetch("move"))}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -39,18 +39,18 @@ module Principles
|
|
|
39
39
|
#: () -> bool
|
|
40
40
|
def committing? = @because == "not_committed" && !@files.empty?
|
|
41
41
|
|
|
42
|
-
# What
|
|
43
|
-
# differ from HEAD, or
|
|
44
|
-
# audit command starts a line of its own, after its purpose.
|
|
42
|
+
# What the agent does to give the members a baseline, as one imperative: complete an audit outside git, or
|
|
43
|
+
# in git commit the files that differ from HEAD, or audit again when none does, since every file is
|
|
44
|
+
# committed already. The audit command starts a line of its own, after its purpose.
|
|
45
45
|
#: () -> String
|
|
46
46
|
def remedy
|
|
47
|
-
return "
|
|
47
|
+
return " Commit #{ProseList.new(@files)} #{to_give}." if committing?
|
|
48
48
|
|
|
49
|
-
"#{all_committed if @because == "not_committed"}\
|
|
49
|
+
"#{all_committed if @because == "not_committed"}\nRun this audit #{to_give}: #{@audit}"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
#: () -> String
|
|
53
|
-
def
|
|
53
|
+
def to_give = "to give #{one? ? "it" : "each"} one"
|
|
54
54
|
|
|
55
55
|
#: () -> String
|
|
56
56
|
def all_committed
|
|
@@ -104,11 +104,14 @@ module Principles
|
|
|
104
104
|
class MapInProject
|
|
105
105
|
#: bool
|
|
106
106
|
attr_reader :set_up
|
|
107
|
+
#: bool
|
|
108
|
+
attr_reader :already_mapped
|
|
107
109
|
|
|
108
110
|
#: (already_mapped: bool, members_in_entry_files: Array[Hash[String, String]], set_up: bool) -> void
|
|
109
111
|
def initialize(already_mapped:, members_in_entry_files:, set_up:)
|
|
110
112
|
@fields = { "already_mapped" => already_mapped,
|
|
111
113
|
"members_in_entry_files" => members_in_entry_files }.freeze #: Hash[String, untyped]
|
|
114
|
+
@already_mapped = already_mapped
|
|
112
115
|
@set_up = set_up
|
|
113
116
|
freeze
|
|
114
117
|
end
|
|
@@ -122,9 +125,9 @@ module Principles
|
|
|
122
125
|
#: (PrintedPrinciple, Placement, MapInProject, existing_principles: Array[Hash[String, untyped]])
|
|
123
126
|
#| -> Hash[String, untyped]
|
|
124
127
|
def proposal(principle, placement, map_in_project, existing_principles:)
|
|
125
|
-
hook_setup = placement.hooks_run? ? {} : { "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
|
|
126
128
|
{ "status" => "question", "principle_id" => principle.id, "map_file" => principle.file,
|
|
127
|
-
"map" => principle.map, **map_in_project.to_h, **placement.to_h,
|
|
129
|
+
"map" => principle.map, **map_in_project.to_h, **placement.to_h,
|
|
130
|
+
**hook_setup(placement, mapped: map_in_project.already_mapped || existing_principles.any?),
|
|
128
131
|
"existing_principles" => existing_principles,
|
|
129
132
|
"question" => map_in_project.set_up ? steps_lacking(principle, placement) : question(principle.id),
|
|
130
133
|
"answer_with" => add_member(principle.id), "next_action" => next_action(principle.id, existing_principles) }
|
|
@@ -132,6 +135,15 @@ module Principles
|
|
|
132
135
|
|
|
133
136
|
private
|
|
134
137
|
|
|
138
|
+
# The hook entries that report changed members, offered only while the plugin's hooks do not run and once a map
|
|
139
|
+
# exists, since before any map they report nothing.
|
|
140
|
+
#: (Placement, mapped: bool) -> Hash[String, String]
|
|
141
|
+
def hook_setup(placement, mapped:)
|
|
142
|
+
return {} if placement.hooks_run? || !mapped
|
|
143
|
+
|
|
144
|
+
{ "hook_setup" => ReportHooksOffer.new(@invocation).to_s }
|
|
145
|
+
end
|
|
146
|
+
|
|
135
147
|
# What to agree with the user and place, with the command that maps a passage the project has in a step's
|
|
136
148
|
# place, and the one that maps the passage once it is placed.
|
|
137
149
|
#: (String) -> String
|
|
@@ -10,14 +10,11 @@ module Principles
|
|
|
10
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
11
|
module Views
|
|
12
12
|
# list-open-findings --short: the one line a session-start hook puts into the agent's context while any
|
|
13
|
-
# finding is open that someone should raise, and nothing when none is. It
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
13
|
+
# finding is open that someone should raise, and nothing when none is. It says first to act on each that waits
|
|
14
|
+
# on the agent and to raise each that waits on a person, and why, then states the facts the agent judges from,
|
|
15
|
+
# how many wait on someone named or on no one and how long the oldest has, with the command that lists whom
|
|
16
|
+
# each waits on.
|
|
17
17
|
class OpenFindingsLine
|
|
18
|
-
# A waits_on longer than this is cut, so the line stays one short line.
|
|
19
|
-
WAITS_ON_LIMIT = 80
|
|
20
|
-
|
|
21
18
|
# The session's start the line is worded for, as Claude Code's SessionStart hook names it: startup, resume,
|
|
22
19
|
# clear or compact. It says what the context holds already, and so which reply raises the findings.
|
|
23
20
|
class SessionStart
|
|
@@ -59,20 +56,9 @@ module Principles
|
|
|
59
56
|
#: () -> Integer
|
|
60
57
|
def unnamed = @fields.fetch("waiting_on_no_one_named")
|
|
61
58
|
|
|
62
|
-
#: () -> Integer
|
|
63
|
-
def to_raise = @fields.fetch("to_raise")
|
|
64
|
-
|
|
65
|
-
# Whether the one finding to raise is one waiting on someone named, whose own line names its need.
|
|
66
|
-
#: () -> bool
|
|
67
|
-
def alone? = to_raise == 1 && named == 1
|
|
68
|
-
|
|
69
59
|
# The oldest open finding of all, by principle and finding_id.
|
|
70
60
|
#: () -> Hash[String, untyped]
|
|
71
61
|
def oldest = @fields.slice("principle", "finding_id")
|
|
72
|
-
|
|
73
|
-
# The oldest finding waiting on someone named, by principle, finding_id and waits_on, or nil.
|
|
74
|
-
#: () -> Hash[String, untyped]?
|
|
75
|
-
def oldest_named = @fields["oldest_waiting_on_someone"]
|
|
76
62
|
end
|
|
77
63
|
|
|
78
64
|
#: (Invocation) -> void
|
|
@@ -84,77 +70,61 @@ module Principles
|
|
|
84
70
|
# waiting is nil when no finding is open, or the count of open findings with the oldest one's principle,
|
|
85
71
|
# finding_id, days_open, how many wait on someone named and the oldest of those, or nil. not_found is each
|
|
86
72
|
# open finding, by principle and finding_id, whose write-up can no longer be found where its recorded_at
|
|
87
|
-
# points. source is the session's start: startup, resume, clear or compact.
|
|
88
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String
|
|
89
|
-
def short(waiting, not_found = [], source: "startup"
|
|
90
|
-
Lines.new(stdout: lines(waiting, not_found, source
|
|
73
|
+
# points. source is the session's start: startup, resume, clear or compact.
|
|
74
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Lines
|
|
75
|
+
def short(waiting, not_found = [], source: "startup")
|
|
76
|
+
Lines.new(stdout: lines(waiting, not_found, source:).map { "#{it}\n" }.join, stderr: "", status: 0)
|
|
91
77
|
end
|
|
92
78
|
|
|
93
79
|
# short's line, as a list of none or one, which report-at-session-start prints among its own.
|
|
94
|
-
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String
|
|
95
|
-
def lines(waiting, not_found = [], source: "startup"
|
|
80
|
+
#: (Hash[String, untyped]?, ?Array[Hash[String, untyped]], ?source: String) -> Array[String]
|
|
81
|
+
def lines(waiting, not_found = [], source: "startup")
|
|
96
82
|
start = SessionStart.new(source)
|
|
97
83
|
return [] unless waiting
|
|
98
84
|
|
|
99
85
|
waiting = Waiting.new(waiting)
|
|
100
86
|
return [resumed("#{how_long(waiting)} (#{oldest(waiting.oldest)})", not_found)] if start.resumed?
|
|
101
|
-
return [] if waiting.to_raise.zero?
|
|
102
87
|
|
|
103
|
-
[whole(waiting, not_found, start
|
|
88
|
+
[whole(waiting, not_found, start)]
|
|
104
89
|
end
|
|
105
90
|
|
|
106
91
|
private
|
|
107
92
|
|
|
108
|
-
# The line with what to do about the findings, for a context that does not hold it yet: the
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
# The line with what to do about the findings, for a context that does not hold it yet: the reply that raises
|
|
94
|
+
# them and why, then the facts, then the command listing them all with whom each waits on. With none naming
|
|
95
|
+
# anyone, none can wait on the agent, so it says only to raise them.
|
|
96
|
+
#: (Waiting, Array[Hash[String, untyped]], SessionStart) -> String
|
|
97
|
+
def whole(waiting, not_found, start)
|
|
98
|
+
values = { reply: start.reply, command: all,
|
|
99
|
+
facts: "#{counts(waiting)}, the oldest #{age(waiting.days_open)}.#{write_ups(not_found)}" }
|
|
100
|
+
return Prompts.text("start-a-session/raise-the-open-findings-waiting-on-no-one", **values) \
|
|
101
|
+
if waiting.named.zero?
|
|
102
|
+
|
|
103
|
+
Prompts.text("start-a-session/act-on-the-open-findings", whom: whom(waiting), **values)
|
|
116
104
|
end
|
|
117
105
|
|
|
118
106
|
# The command listing every open finding, a line each.
|
|
119
107
|
#: () -> String
|
|
120
108
|
def all = @invocation.in_project("list-open-findings", options: ["--lines"])
|
|
121
109
|
|
|
122
|
-
#
|
|
123
|
-
# no one,
|
|
110
|
+
# Whom the findings the agent raises wait on, while some name someone, once it acts on those that wait on
|
|
111
|
+
# itself: a person, and no one, if any names none, since nothing else will raise those either.
|
|
124
112
|
#: (Waiting) -> String
|
|
125
|
-
def
|
|
126
|
-
return "If it waits on your user, raise it" if waiting.alone?
|
|
127
|
-
return "Raise each" if waiting.named.zero?
|
|
113
|
+
def whom(waiting) = "a person#{" or on no one" if waiting.unnamed.positive?}"
|
|
128
114
|
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# The sentence naming the oldest finding that waits on someone named, and whom, counting them when several do.
|
|
115
|
+
# How many wait on someone named and on no one, the first counted as the sentence's subject.
|
|
133
116
|
#: (Waiting) -> String
|
|
134
|
-
def
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return "Open finding #{named} waits on: #{need}" if waiting.named == 1
|
|
140
|
-
|
|
141
|
-
"#{counted(waiting.named)} on someone; the oldest, #{named} waits on: #{need}"
|
|
117
|
+
def counts(waiting)
|
|
118
|
+
unnamed = waiting.unnamed
|
|
119
|
+
return "#{counted(unnamed)} on no one named" if waiting.named.zero?
|
|
120
|
+
|
|
121
|
+
"#{counted(waiting.named)} on someone named#{", #{unnamed} on no one" if unnamed.positive?}"
|
|
142
122
|
end
|
|
143
123
|
|
|
144
124
|
# How long a finding has gone unraised, in whole days.
|
|
145
125
|
#: (Integer) -> String
|
|
146
126
|
def age(days) = "open #{days} #{days == 1 ? "day" : "days"}"
|
|
147
127
|
|
|
148
|
-
# The sentence counting the findings deferred with no waits_on, after any naming someone.
|
|
149
|
-
#: (Waiting) -> String
|
|
150
|
-
def no_one_named(waiting)
|
|
151
|
-
unnamed = waiting.unnamed
|
|
152
|
-
return "" if unnamed.zero?
|
|
153
|
-
return " #{unnamed} #{unnamed == 1 ? "waits" : "wait"} on no one named." if waiting.named.positive?
|
|
154
|
-
|
|
155
|
-
"#{counted(unnamed)} on no one named."
|
|
156
|
-
end
|
|
157
|
-
|
|
158
128
|
# How many open findings wait, as the subject of the sentence saying on whom.
|
|
159
129
|
#: (Integer) -> String
|
|
160
130
|
def counted(count) = count == 1 ? "1 open finding waits" : "#{count} open findings wait"
|
|
@@ -168,14 +138,6 @@ module Principles
|
|
|
168
138
|
command: @invocation.in_project("list-open-findings", options: ["--short"]))
|
|
169
139
|
end
|
|
170
140
|
|
|
171
|
-
# git's user name as a fact, for the agent to judge whether the person a finding waits on is its user.
|
|
172
|
-
#: (String?) -> String
|
|
173
|
-
def git_user(name)
|
|
174
|
-
return " git has no user.name set." unless name
|
|
175
|
-
|
|
176
|
-
" git's user.name is #{VisibleText.new(name)}."
|
|
177
|
-
end
|
|
178
|
-
|
|
179
141
|
# The sentence naming the write-ups that can no longer be found, the first by its principle and id, or
|
|
180
142
|
# nothing when every pointer resolves, so the usual line is unchanged.
|
|
181
143
|
#: (Array[Hash[String, untyped]]) -> String
|
|
@@ -206,32 +168,9 @@ module Principles
|
|
|
206
168
|
"for #{days} #{days == 1 ? "day" : "days"}"
|
|
207
169
|
end
|
|
208
170
|
|
|
209
|
-
# A finding's waits_on, cut when long. It is free text, so it is cut by characters first and then escaped,
|
|
210
|
-
# which may run past the limit to show it.
|
|
211
|
-
#: (String) -> String
|
|
212
|
-
def need(waits_on)
|
|
213
|
-
waits_on = closed("#{whole_words(waits_on[0, WAITS_ON_LIMIT - 3].to_s)}...") if waits_on.length > WAITS_ON_LIMIT
|
|
214
|
-
VisibleText.new(waits_on).to_s
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# A cut waits_on up to its last whole word, so it never ends in part of one, or as cut when it is one
|
|
218
|
-
# word, which has no boundary to cut at.
|
|
219
|
-
#: (String) -> String
|
|
220
|
-
def whole_words(cut)
|
|
221
|
-
boundary = cut.rindex(" ") or return cut
|
|
222
|
-
cut[0, boundary].to_s
|
|
223
|
-
end
|
|
224
|
-
|
|
225
171
|
# The oldest finding's principle and id, which is free text and so escaped.
|
|
226
172
|
#: (Hash[String, untyped]) -> String
|
|
227
173
|
def oldest(waiting) = "#{waiting.fetch("principle")} #{VisibleText.new(waiting.fetch("finding_id"))}"
|
|
228
|
-
|
|
229
|
-
# A cut waits_on with a ")" for each "(" the cut left open, so the line's own parenthesis still reads as
|
|
230
|
-
# closing the finding's name.
|
|
231
|
-
#: (String) -> String
|
|
232
|
-
def closed(cut)
|
|
233
|
-
cut + (")" * [cut.count("(") - cut.count(")"), 0].max)
|
|
234
|
-
end
|
|
235
174
|
end
|
|
236
175
|
end
|
|
237
176
|
end
|
|
@@ -31,7 +31,7 @@ module Principles
|
|
|
31
31
|
"unless you judge it again. --as template prints the same answer long, with each slot's help. " \
|
|
32
32
|
"Then fill in the answer the response_template part prints"
|
|
33
33
|
fill = AnswerInAFile.new(@invocation).assessment(request.principle_id, request_id:)
|
|
34
|
-
listed(index, request.principle_id)
|
|
34
|
+
listed(index, request.principle_id, request.bytes_unknown)
|
|
35
35
|
.merge(TrimmedInstructionsNote.new(request.trimmed_instruction_fields).to_h)
|
|
36
36
|
.merge("answer_with" => @invocation.submit_answer(request_id),
|
|
37
37
|
"next_action" => "#{read}, #{carried(request)}. #{fill}")
|
|
@@ -49,10 +49,14 @@ module Principles
|
|
|
49
49
|
# The index under its request id, after the command that prints a part named after it, each entry's part as a
|
|
50
50
|
# shell reads it, quoted where a shell would split or expand it, so it runs as printed; the answer's template
|
|
51
51
|
# names each member by its id unquoted. One command rather than one an entry, since an entry's would repeat it
|
|
52
|
-
# and cost more than reading the whole request.
|
|
53
|
-
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
54
|
-
def listed(index, principle_id)
|
|
55
|
-
entries = index.fetch("index").map
|
|
52
|
+
# and cost more than reading the whole request. Each part bytes_unknown names gives why it has no bytes instead.
|
|
53
|
+
#: (Hash[String, untyped], String, Hash[String, String]) -> Hash[String, untyped]
|
|
54
|
+
def listed(index, principle_id, bytes_unknown)
|
|
55
|
+
entries = index.fetch("index").map do |entry|
|
|
56
|
+
part = entry.fetch("part")
|
|
57
|
+
sized = bytes_unknown.key?(part) ? entry.except("bytes").merge("bytes_unknown" => bytes_unknown[part]) : entry
|
|
58
|
+
sized.merge("part" => ShellWord.new(part).to_s)
|
|
59
|
+
end
|
|
56
60
|
{ "request_id" => index.fetch("request_id"),
|
|
57
61
|
"part_command" => @invocation.in_project("start-audit", principle_id, options: ["--part"]),
|
|
58
62
|
"index" => entries }
|
|
@@ -15,6 +15,10 @@ module Principles
|
|
|
15
15
|
# The JSON results of reading principles, show-principle and list-principles, with commands for the invocation
|
|
16
16
|
# running now. They change with what a read reports, such as freshness and repairs; MapResult prints the writes.
|
|
17
17
|
class PrincipleReadResult
|
|
18
|
+
# The fields of a kept assessment show-principle --member prints: the judgement and its sighting, not what it
|
|
19
|
+
# was judged on.
|
|
20
|
+
ASSESSMENT_SHOWN = %w[assessed_at assessment delivery observation observed_at].freeze
|
|
21
|
+
|
|
18
22
|
#: (Invocation) -> void
|
|
19
23
|
def initialize(invocation)
|
|
20
24
|
@invocation = invocation
|
|
@@ -25,14 +29,36 @@ module Principles
|
|
|
25
29
|
# an audit would refuse, with its repair_with commands, from the moves repairs gives it.
|
|
26
30
|
# hook_settings_not_read names each project settings file whose hooks this tool could not read.
|
|
27
31
|
# loaded_files lists each file the members load once, with the total of those loading at session start.
|
|
32
|
+
# unresolved names each plugin member no installed plugin gives, which no repair is offered for.
|
|
28
33
|
#: (PrintedPrinciple, repairs: Hash[String, Array[MemberRepairs::Move]],
|
|
29
|
-
#| ?hook_settings_not_read: Array[Hash[String, String]], ?loaded_files: Hash[String, untyped]
|
|
30
|
-
#| -> Hash[String, untyped]
|
|
31
|
-
def shown(principle, repairs:, hook_settings_not_read: [], loaded_files: {})
|
|
34
|
+
#| ?hook_settings_not_read: Array[Hash[String, String]], ?loaded_files: Hash[String, untyped],
|
|
35
|
+
#| ?unresolved: Array[String]) -> Hash[String, untyped]
|
|
36
|
+
def shown(principle, repairs:, hook_settings_not_read: [], loaded_files: {}, unresolved: [])
|
|
32
37
|
unread = hook_settings_not_read.empty? ? {} : { "hook_settings_not_read" => hook_settings_not_read }
|
|
33
38
|
{ "id" => principle.id, "map_file" => principle.file, **principle.declared,
|
|
34
39
|
"members" => principle.members.map { |member| repaired(principle.id, member, repairs) },
|
|
35
|
-
**loaded_files, **unread, "next_action" => shown_next_action(principle, repairs.keys) }
|
|
40
|
+
**loaded_files, **unread, "next_action" => shown_next_action(principle, repairs.keys, unresolved) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# show-principle --member: one member of principle_id, where it is now and how fresh, beside the assessment the
|
|
44
|
+
# last completed audit kept for it and the last acknowledgement since, without what either was judged on, and
|
|
45
|
+
# nothing of the other members.
|
|
46
|
+
#: (String, Hash[String, untyped], Hash[String, untyped]?, Hash[String, untyped]?) -> Hash[String, untyped]
|
|
47
|
+
def one_member(principle_id, member, assessment, acknowledgement)
|
|
48
|
+
judged = { "last_assessment" => assessment&.slice(*ASSESSMENT_SHOWN),
|
|
49
|
+
"last_acknowledgement" => acknowledgement&.slice("acknowledged_at", "reason", "commit") }
|
|
50
|
+
{ "id" => principle_id, "member" => member.merge(judged.compact),
|
|
51
|
+
"next_action" => "To see every member of #{principle_id}: " \
|
|
52
|
+
"#{@invocation.in_project("show-principle", principle_id)}" }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# shown, show-principle's result for principle_id printed without when each member's file loads, its next_action
|
|
56
|
+
# naming --loads, which prints that too.
|
|
57
|
+
#: (Hash[String, untyped], String) -> Hash[String, untyped]
|
|
58
|
+
def without_loads(shown, principle_id)
|
|
59
|
+
asked = @invocation.in_project("show-principle", principle_id, usage: "--loads")
|
|
60
|
+
shown.merge("next_action" => "#{shown.fetch("next_action")}\nTo see when each member's file loads, and its " \
|
|
61
|
+
"size: #{asked}")
|
|
36
62
|
end
|
|
37
63
|
|
|
38
64
|
# list-principles: each entry is { "id", "description", "members_by_freshness" }. waiting is each principle whose
|
|
@@ -97,17 +123,32 @@ module Principles
|
|
|
97
123
|
MemberRepairs.new(@invocation).beside(id, member, repairs[member.fetch("id")])
|
|
98
124
|
end
|
|
99
125
|
|
|
100
|
-
# Repair each member in broken, the ids of those an audit would refuse
|
|
101
|
-
# never assessed.
|
|
102
|
-
#: (PrintedPrinciple, Array[String]) -> String
|
|
103
|
-
def shown_next_action(principle, broken)
|
|
104
|
-
unless broken.empty?
|
|
105
|
-
return
|
|
106
|
-
"its repair_with: #{broken.join(", ")}."
|
|
126
|
+
# Repair each member in broken, the ids of those an audit would refuse, and say which plugin members in
|
|
127
|
+
# unresolved no installed plugin gives; otherwise audit when one changed or was never assessed.
|
|
128
|
+
#: (PrintedPrinciple, Array[String], Array[String]) -> String
|
|
129
|
+
def shown_next_action(principle, broken, unresolved)
|
|
130
|
+
unless broken.empty? && unresolved.empty?
|
|
131
|
+
return [repair_broken(broken), unresolved_plugin_members(unresolved)].compact.join(" ")
|
|
107
132
|
end
|
|
108
133
|
|
|
109
134
|
"Audit when a member is changed or unassessed: #{@invocation.in_project("start-audit", principle.id)}"
|
|
110
135
|
end
|
|
136
|
+
|
|
137
|
+
#: (Array[String]) -> String?
|
|
138
|
+
def repair_broken(broken)
|
|
139
|
+
return if broken.empty?
|
|
140
|
+
|
|
141
|
+
"Repair each member that cannot be found or read before auditing, with one of the commands in its " \
|
|
142
|
+
"repair_with: #{broken.join(", ")}."
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
#: (Array[String]) -> String?
|
|
146
|
+
def unresolved_plugin_members(unresolved)
|
|
147
|
+
return if unresolved.empty?
|
|
148
|
+
|
|
149
|
+
"No plugin installed for this project gives #{ProseList.new(unresolved)}; each one's error says why and " \
|
|
150
|
+
"how to resolve it."
|
|
151
|
+
end
|
|
111
152
|
end
|
|
112
153
|
end
|
|
113
154
|
end
|
|
@@ -33,7 +33,8 @@ module Principles
|
|
|
33
33
|
RequestPart.new(shown: { PART => @prior.map { |finding| shown(finding) } },
|
|
34
34
|
instructions: [Instruction.new("prior_findings_instruction", instruction)],
|
|
35
35
|
slots: { "prior_finding_decisions" => @prior.map { |finding| decision(finding) } },
|
|
36
|
-
help: { "prior_finding_decisions" => @placeholders }
|
|
36
|
+
help: { "prior_finding_decisions" => @placeholders },
|
|
37
|
+
alone: { "prior_finding_decisions" => @prior.map { |finding| decision_alone(finding) } })
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
private
|
|
@@ -55,6 +56,13 @@ module Principles
|
|
|
55
56
|
evidence_not_kept?(finding) ? decision.merge("problem_evidence" => []) : decision
|
|
56
57
|
end
|
|
57
58
|
|
|
59
|
+
# The decision to fill in on finding in the answer printed alone, which no list of prior findings stands beside,
|
|
60
|
+
# with the finding's problem after its id, so the agent deciding it can tell what it is.
|
|
61
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
62
|
+
def decision_alone(finding)
|
|
63
|
+
{ "finding_id" => nil, "finding_problem" => finding.fetch("problem"), **decision(finding) }
|
|
64
|
+
end
|
|
65
|
+
|
|
58
66
|
# How to decide the prior findings, naming each one's id, so a new finding is given another, each paragraph with
|
|
59
67
|
# whether its case holds: how to keep what a deferral waits on holds only when one carries waits_on, how to
|
|
60
68
|
# claim an earlier first_raised_at never, since no fact marks a finding dated late, so it is read whole, and how
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "acknowledgements_offered"
|
|
4
5
|
require_relative "record_waiting_on_an_upgrade"
|
|
5
6
|
|
|
6
7
|
module Principles
|
|
@@ -20,16 +21,17 @@ module Principles
|
|
|
20
21
|
#: Hash[String, Array[String]]
|
|
21
22
|
attr_reader :audit_files
|
|
22
23
|
|
|
23
|
-
#:
|
|
24
|
+
#: AcknowledgementsOffered
|
|
24
25
|
attr_reader :acknowledgeable
|
|
25
26
|
|
|
26
27
|
#: Array[RecordWaitingOnAnUpgrade]
|
|
27
28
|
attr_reader :waiting
|
|
28
29
|
|
|
29
30
|
#: (?not_read: Array[String], ?no_baseline_files: Hash[String, Array[String]],
|
|
30
|
-
#| ?audit_files: Hash[String, Array[String]], ?acknowledgeable:
|
|
31
|
+
#| ?audit_files: Hash[String, Array[String]], ?acknowledgeable: AcknowledgementsOffered,
|
|
31
32
|
#| ?waiting: Array[RecordWaitingOnAnUpgrade]) -> void
|
|
32
|
-
def initialize(not_read: [], no_baseline_files: {}, audit_files: {}, acknowledgeable:
|
|
33
|
+
def initialize(not_read: [], no_baseline_files: {}, audit_files: {}, acknowledgeable: AcknowledgementsOffered::NONE,
|
|
34
|
+
waiting: [])
|
|
33
35
|
@not_read = not_read
|
|
34
36
|
@no_baseline_files = no_baseline_files
|
|
35
37
|
@audit_files = audit_files
|
|
@@ -13,9 +13,9 @@ module Principles
|
|
|
13
13
|
Lines = Struct.new(:stdout, :stderr, :status, keyword_init: true)
|
|
14
14
|
|
|
15
15
|
# list-member-problems --short, for a commit hook or heartbeat that acts on an exit status and short lines
|
|
16
|
-
# alone: one tab-separated line per changed member on stdout, then one per
|
|
17
|
-
#
|
|
18
|
-
# anything an empty stdout would hide.
|
|
16
|
+
# alone: one tab-separated line per changed member on stdout, then one per plugin member no installed plugin
|
|
17
|
+
# gives, then one per principle counting its members no audit has assessed, exit 3 when a changed member's row
|
|
18
|
+
# or a count asks for action, and on stderr what to do next and anything an empty stdout would hide.
|
|
19
19
|
class ProblemLines
|
|
20
20
|
# The exit status that says a member's own text changed since an audit or acknowledgement assessed it, or that
|
|
21
21
|
# no audit has assessed a member; 1 and 2 already mean refused and usage error.
|
|
@@ -36,13 +36,22 @@ module Principles
|
|
|
36
36
|
#: (Hash[String, untyped], nothing_changed: String, assessed_change: bool,
|
|
37
37
|
#| never_assessed: Hash[String, Integer], names_a_command: bool) -> Lines
|
|
38
38
|
def short(report, nothing_changed:, assessed_change:, never_assessed:, names_a_command:)
|
|
39
|
-
rows
|
|
40
|
-
never_assessed.map { |id, count| counted(id, count) }
|
|
41
|
-
Lines.new(stdout: rows.map { "#{it}\n" }.join,
|
|
39
|
+
Lines.new(stdout: rows(report, never_assessed).map { "#{it}\n" }.join,
|
|
42
40
|
stderr: notes(report, nothing_changed, names_a_command).map { |note| "#{note}\n" }.join,
|
|
43
41
|
status: assessed_change || !never_assessed.empty? ? CHANGED : 0)
|
|
44
42
|
end
|
|
45
43
|
|
|
44
|
+
# short's lines, or when they are empty, one stderr line saying nothing changed among members, so an agent can
|
|
45
|
+
# tell a clean project from a run that printed nothing; stdout stays empty for a trigger acting on its rows. The
|
|
46
|
+
# session-start lines never carry it, since that output is spent in every session.
|
|
47
|
+
#: (Lines, members: Integer) -> Lines
|
|
48
|
+
def saying_nothing_changed(short, members:)
|
|
49
|
+
return short unless short.stdout.empty? && short.stderr.empty?
|
|
50
|
+
|
|
51
|
+
Lines.new(stdout: "", stderr: "Nothing changed (#{members} member#{"s" unless members == 1}).\n",
|
|
52
|
+
status: short.status)
|
|
53
|
+
end
|
|
54
|
+
|
|
46
55
|
# short's lines for a session-start hook: on stdout, one line for each principle with a changed member an
|
|
47
56
|
# audit or acknowledgement assessed, as session_start_lines says, from changed, in place of the rows and
|
|
48
57
|
# never-assessed counts, which an always-loaded carrier cannot afford; stderr and the status kept.
|
|
@@ -67,6 +76,23 @@ module Principles
|
|
|
67
76
|
|
|
68
77
|
private
|
|
69
78
|
|
|
79
|
+
# short's stdout rows: each changed member's, then each plugin member's no installed plugin gives, then each
|
|
80
|
+
# principle's count of members no audit has assessed.
|
|
81
|
+
#: (Hash[String, untyped], Hash[String, Integer]) -> Array[String]
|
|
82
|
+
def rows(report, never_assessed)
|
|
83
|
+
report.fetch("members").map { MemberRow.new(it).short } +
|
|
84
|
+
report.fetch("plugin_unresolved", []).map { unresolved(it) } +
|
|
85
|
+
never_assessed.map { |id, count| counted(id, count) }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The row of a plugin member no installed plugin gives, in a changed member's fields: its principle, id, that it
|
|
89
|
+
# is unresolved and why. It moves no count or exit status: a session without the plugin has nothing to act on.
|
|
90
|
+
#: (Hash[String, untyped]) -> String
|
|
91
|
+
def unresolved(member)
|
|
92
|
+
[member.fetch("principle"), member.fetch("id"), "plugin_unresolved", member.fetch("reason")]
|
|
93
|
+
.map { VisibleText.new(it).to_s }.join("\t")
|
|
94
|
+
end
|
|
95
|
+
|
|
70
96
|
# The session-start line on principle id's count of changed audited members.
|
|
71
97
|
#: (String, Integer) -> String
|
|
72
98
|
def changed_line(id, count)
|