principles 0.1.3 → 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 +120 -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 +29 -2
- 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_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 +39 -13
- 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 +29 -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 +5 -0
- 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 +37 -6
- data/lib/principles/models/disposition_placeholders.rb +12 -0
- 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/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 +19 -5
- 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/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 +18 -13
- 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 +15 -15
- 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 +21 -16
- data/lib/principles/views/disposition_template.rb +35 -0
- data/lib/principles/views/first_audit.rb +29 -15
- data/lib/principles/views/first_audit_line.rb +4 -5
- data/lib/principles/views/invocation.rb +14 -5
- 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/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/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-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-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 +10 -10
- 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/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,20 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
|
+
module Models
|
|
7
|
+
# The parts of a candidate outline that text other than Markdown lacks: a description and an opening line, which
|
|
8
|
+
# a script or a CI workflow, outlined by its comments or its jobs, never has.
|
|
9
|
+
module WithoutProse
|
|
10
|
+
#: () -> nil
|
|
11
|
+
def description = nil
|
|
12
|
+
|
|
13
|
+
#: () -> nil
|
|
14
|
+
def cut_description = nil
|
|
15
|
+
|
|
16
|
+
#: () -> nil
|
|
17
|
+
def opening_line = nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "psych"
|
|
5
|
+
require_relative "outline_section"
|
|
6
|
+
require_relative "text_within"
|
|
7
|
+
require_relative "without_prose"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
|
+
module Models
|
|
12
|
+
# A CI workflow's text as its outline reads it: a section per job, headed by its id and name, its items the job's
|
|
13
|
+
# steps, each by its name or else what it runs or uses. A rule a project enforces in CI is named there, and a
|
|
14
|
+
# survey reading Markdown headings alone never found it. The YAML is read as nodes, which keep each job's lines
|
|
15
|
+
# and leave a key such as `on` a string.
|
|
16
|
+
class WorkflowJobs
|
|
17
|
+
include WithoutProse
|
|
18
|
+
|
|
19
|
+
# A GitHub Actions workflow file, the kind of text this reads.
|
|
20
|
+
PATH = %r{(?:\A|/)\.github/workflows/[^/]+\.ya?ml\z}
|
|
21
|
+
# What a step without a name is known by, in the order looked for.
|
|
22
|
+
STEP_KEYS = %w[run uses].freeze
|
|
23
|
+
|
|
24
|
+
#: (String) -> void
|
|
25
|
+
def initialize(text)
|
|
26
|
+
@text = text
|
|
27
|
+
freeze
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Each job as a section, spanning the lines from its id to its last; none when the YAML does not parse, so the
|
|
31
|
+
# file is listed by its path and size alone.
|
|
32
|
+
#: () -> Array[OutlineSection]
|
|
33
|
+
def sections
|
|
34
|
+
document = Psych.parse(@text) or return []
|
|
35
|
+
|
|
36
|
+
pairs(value(document.root, "jobs")).map do |id, job|
|
|
37
|
+
OutlineSection.new(heading: heading(id.value, value(job, "name")), items: steps(value(job, "steps")),
|
|
38
|
+
first_line: id.start_line + 1, last_line: job.end_line)
|
|
39
|
+
end
|
|
40
|
+
rescue Psych::SyntaxError
|
|
41
|
+
[]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
#: (String, Psych::Nodes::Node?) -> String
|
|
47
|
+
def heading(id, name) = name.is_a?(Psych::Nodes::Scalar) ? "job #{id}: #{name.value}" : "job #{id}"
|
|
48
|
+
|
|
49
|
+
# Each step as an item, by its name, or else by the first line of what it runs or the action it uses, on the line
|
|
50
|
+
# its step starts.
|
|
51
|
+
#: (Psych::Nodes::Node?) -> Array[OutlineItem]
|
|
52
|
+
def steps(sequence)
|
|
53
|
+
return [] unless sequence.is_a?(Psych::Nodes::Sequence)
|
|
54
|
+
|
|
55
|
+
sequence.children.filter_map do |step|
|
|
56
|
+
text = step_text(step) or next
|
|
57
|
+
|
|
58
|
+
OutlineItem.new("- #{TextWithin.new(text, at_most: OutlineSection::ITEM_CHARACTERS).by_words}",
|
|
59
|
+
line: step.start_line + 1)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A step by its name, or else by the first line of what it runs or the action it uses; nil with none of them.
|
|
64
|
+
#: (Psych::Nodes::Node) -> String?
|
|
65
|
+
def step_text(step)
|
|
66
|
+
key = STEP_KEYS.find { |each| scalar(step, each) }
|
|
67
|
+
scalar(step, "name") || (key && "#{key}: #{scalar(step, key).to_s.lines.first.to_s.strip}")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The text of a mapping's scalar value under key; nil when it has none.
|
|
71
|
+
#: (Psych::Nodes::Node?, String) -> String?
|
|
72
|
+
def scalar(mapping, key)
|
|
73
|
+
found = value(mapping, key)
|
|
74
|
+
found.value if found.is_a?(Psych::Nodes::Scalar)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# A mapping's value node under key; nil when the node is no mapping or lacks the key.
|
|
78
|
+
#: (Psych::Nodes::Node?, String) -> Psych::Nodes::Node?
|
|
79
|
+
def value(mapping, key) = pairs(mapping).find { |found, _| found.value == key }&.last
|
|
80
|
+
|
|
81
|
+
# A mapping's keys with their values, its keys scalars; none for any other node.
|
|
82
|
+
#: (Psych::Nodes::Node?) -> Array[[Psych::Nodes::Scalar, Psych::Nodes::Node]]
|
|
83
|
+
def pairs(mapping)
|
|
84
|
+
return [] unless mapping.is_a?(Psych::Nodes::Mapping)
|
|
85
|
+
|
|
86
|
+
mapping.children.each_slice(2).filter_map do |key, found|
|
|
87
|
+
[key, found] if key.is_a?(Psych::Nodes::Scalar) && found
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation_options"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The options choosing which form show-members-in-logged-requests prints, --short, --places or --member, and what
|
|
8
|
+
# is wrong with them as given, which CommandLine refuses as a usage error.
|
|
9
|
+
class ShowMembersInLoggedRequestsOptions
|
|
10
|
+
#: (InvocationOptions) -> void
|
|
11
|
+
def initialize(options)
|
|
12
|
+
@places = !options.value("places").nil? #: bool
|
|
13
|
+
@short = !options.value("short").nil? #: bool
|
|
14
|
+
@member = !options.value("member").nil? #: bool
|
|
15
|
+
freeze
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# What is wrong with the options as given, or nil when they fit.
|
|
19
|
+
#: () -> String?
|
|
20
|
+
def fault
|
|
21
|
+
return "--member lists the named members' places, which --short does not print; give one" if @member && @short
|
|
22
|
+
return "--member lists the named members' places, and --places every member's; give one" if @member && @places
|
|
23
|
+
|
|
24
|
+
"--places lists every place a member was seen, which --short does not print; give one" if @places && @short
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation_options"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The options choosing what show-principle prints, every member or the one --member names, and what is wrong with
|
|
8
|
+
# them as given, which CommandLine refuses as a usage error.
|
|
9
|
+
class ShowPrincipleOptions
|
|
10
|
+
COMMAND = "show-principle"
|
|
11
|
+
# How a refusal of several --member options says to repair it.
|
|
12
|
+
ONE_OR_NONE = "give one, or none for every member"
|
|
13
|
+
|
|
14
|
+
#: (InvocationOptions) -> void
|
|
15
|
+
def initialize(options)
|
|
16
|
+
@members = (options.value("member") || []).size #: Integer
|
|
17
|
+
@loads = !options.value("loads").nil? #: bool
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# What is wrong with the options as given, or nil when they fit: --member prints one member, so a second would be
|
|
22
|
+
# dropped without a word, and so would --loads, which adds to the whole map.
|
|
23
|
+
#: () -> String?
|
|
24
|
+
def fault
|
|
25
|
+
return "#{COMMAND} prints one member, but --member was given #{@members} times; #{ONE_OR_NONE}" if @members > 1
|
|
26
|
+
return unless @loads && @members == 1
|
|
27
|
+
|
|
28
|
+
"--loads adds when each member's file loads to the whole map, which --member does not print; drop --loads to " \
|
|
29
|
+
"see one member, or --member to see every member's loads"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/principles/version.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The next production release, as major.minor.patch. A production build is versioned with this alone.
|
|
6
|
-
RELEASE = "0.1.
|
|
6
|
+
RELEASE = "0.1.4"
|
|
7
7
|
# The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
|
|
8
8
|
# packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
|
|
9
9
|
# Data::RunningVersion reads the commit this tool runs from instead.
|
|
10
|
-
BUILT_VERSION = "0.1.
|
|
10
|
+
BUILT_VERSION = "0.1.4" #: String?
|
|
11
11
|
end
|
|
@@ -17,43 +17,62 @@ module Principles
|
|
|
17
17
|
freeze
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# The acknowledgement of each of member_ids was accepted, and file holds them all
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
# The acknowledgement of each of member_ids was accepted, and file holds them all; open_findings are the ids of
|
|
21
|
+
# the findings the last audit left open on them, which it leaves open.
|
|
22
|
+
#: (principle_id: String, member_ids: Array[String], file: String, ?open_findings: Array[String])
|
|
23
|
+
#| -> AnsweredRequest
|
|
24
|
+
def several_acknowledged(principle_id:, member_ids:, file:, open_findings: [])
|
|
23
25
|
AnsweredRequest.new(
|
|
24
26
|
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => member_ids,
|
|
25
27
|
"files_to_commit" => [file],
|
|
26
28
|
"next_action" => "Commit #{file}. #{ProseList.new(member_ids)} read as judged until each is edited again.\n" \
|
|
27
|
-
"This no longer lists them: " \
|
|
29
|
+
"#{still_open(principle_id, open_findings)}This no longer lists them: " \
|
|
28
30
|
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
29
31
|
)
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
# The acknowledgement of each of member_ids was accepted for every principle that maps it, each principle's in its
|
|
33
|
-
# file, under its id in files
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
# file, under its id in files; open_findings are, under a principle's id, the ids of the findings its last audit
|
|
36
|
+
# left open on them, which it leaves open.
|
|
37
|
+
#: (member_ids: Array[String], files: Hash[String, String], ?open_findings: Hash[String, Array[String]])
|
|
38
|
+
#| -> AnsweredRequest
|
|
39
|
+
def across_acknowledged(member_ids:, files:, open_findings: {})
|
|
36
40
|
AnsweredRequest.new(
|
|
37
41
|
"status" => "acknowledged", "principle_ids" => files.keys, "member_ids" => member_ids,
|
|
38
42
|
"files_to_commit" => files.values,
|
|
39
43
|
"next_action" => "Commit #{ProseList.new(files.values)}. #{ProseList.new(member_ids)} read as judged until " \
|
|
40
|
-
"each is edited again.\
|
|
44
|
+
"each is edited again.\n#{open_findings.map { |id, ids| still_open(id, ids) }.join}" \
|
|
45
|
+
"This no longer lists them: " \
|
|
41
46
|
"#{@invocation.in_project("list-member-problems", usage: "--short")}"
|
|
42
47
|
)
|
|
43
48
|
end
|
|
44
49
|
|
|
45
|
-
# The acknowledgement was accepted and file holds it
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
# The acknowledgement was accepted and file holds it; open_findings are the ids of the findings the last audit
|
|
51
|
+
# left open on the member, which it leaves open.
|
|
52
|
+
#: (principle_id: String, member_id: String, file: String, ?open_findings: Array[String]) -> AnsweredRequest
|
|
53
|
+
def acknowledged(principle_id:, member_id:, file:, open_findings: [])
|
|
48
54
|
fields = {
|
|
49
55
|
"status" => "acknowledged", "principle_id" => principle_id, "member_ids" => [member_id],
|
|
50
56
|
"files_to_commit" => [file],
|
|
51
57
|
"next_action" => "Commit #{file}. #{member_id} reads as judged until it is edited again.\n" \
|
|
52
|
-
"This no longer lists it: " \
|
|
58
|
+
"#{still_open(principle_id, open_findings)}This no longer lists it: " \
|
|
53
59
|
"#{@invocation.in_project("list-member-problems", principle_id, usage: "--short")}"
|
|
54
60
|
}
|
|
55
61
|
AnsweredRequest.new(fields)
|
|
56
62
|
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
# The line saying that open_findings stay open, since only a full audit of principle_id decides one, with the
|
|
67
|
+
# command that starts it; nothing when there are none.
|
|
68
|
+
#: (String, Array[String]) -> String
|
|
69
|
+
def still_open(principle_id, open_findings)
|
|
70
|
+
return "" if open_findings.empty?
|
|
71
|
+
|
|
72
|
+
stays, each = open_findings.one? ? %w[stays it] : %w[stay each]
|
|
73
|
+
"#{ProseList.new(open_findings)} #{stays} open: an acknowledgement decides no finding, and the next full " \
|
|
74
|
+
"audit decides #{each}: #{@invocation.in_project("start-audit", principle_id)}\n"
|
|
75
|
+
end
|
|
57
76
|
end
|
|
58
77
|
end
|
|
59
78
|
end
|
|
@@ -24,15 +24,17 @@ module Principles
|
|
|
24
24
|
# what the request's context shows beside it, such as the record's findings on the member; and under
|
|
25
25
|
# :placeholders the text the template prints in each field the agent writes. What the agent judges is under
|
|
26
26
|
# context, the question first, so an agent reading the request's head finds what it is asked before the text.
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
# answer_file is the file its next_action saves the answer in, as in each request below.
|
|
28
|
+
#: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped], answer_file: String)
|
|
29
|
+
#| -> Hash[String, untyped]
|
|
30
|
+
def request(request_id:, principle_id:, asked:, answer_file:)
|
|
29
31
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
|
|
30
32
|
"context" => { "principle_id" => principle_id,
|
|
31
33
|
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning"),
|
|
32
34
|
**asked.fetch(:change).to_h, **asked.fetch(:context) },
|
|
33
35
|
"response_template" => answer_to_fill(request_id:, asked:),
|
|
34
36
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
35
|
-
"next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:) }
|
|
37
|
+
"next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:, file: answer_file) }
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
# The answer to the request request_id names, to fill: the request prints it as response_template, and
|
|
@@ -50,15 +52,17 @@ module Principles
|
|
|
50
52
|
# change, the context its own request shows beside it and the placeholders its template prints, as one member's
|
|
51
53
|
# request holds them, under context.members and the template's members in the order the agent named them. The
|
|
52
54
|
# question leads the context, so an agent reading the request's head finds what it is asked before the members.
|
|
53
|
-
#: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]
|
|
54
|
-
|
|
55
|
+
#: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]], answer_file: String)
|
|
56
|
+
#| -> Hash[String, untyped]
|
|
57
|
+
def several_request(request_id:, principle_id:, members:, answer_file:)
|
|
55
58
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
56
59
|
"context" => { "principle_id" => principle_id,
|
|
57
60
|
"question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning"),
|
|
58
61
|
"members" => shown(members) },
|
|
59
62
|
"response_template" => several_to_fill(request_id:, members:),
|
|
60
63
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
61
|
-
"next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id },
|
|
64
|
+
"next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id },
|
|
65
|
+
request_id:, file: answer_file) }
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
# The answer to the request for several members request_id names, to fill: its basis names each member, and
|
|
@@ -74,15 +78,16 @@ module Principles
|
|
|
74
78
|
# judged once for every principle that maps it. keeping_deferred names each principle whose members keep a
|
|
75
79
|
# deferred finding, which the request says only a full audit resolves. The question leads the context, as in
|
|
76
80
|
# one principle's requests.
|
|
77
|
-
#: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]],
|
|
81
|
+
#: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]], answer_file: String,
|
|
78
82
|
#| ?keeping_deferred: Array[String]) -> Hash[String, untyped]
|
|
79
|
-
def across_request(request_id:, principles:, keeping_deferred: [])
|
|
83
|
+
def across_request(request_id:, principles:, answer_file:, keeping_deferred: [])
|
|
80
84
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
81
85
|
"context" => { "question" => across_question, "principles" => shown_once(principles),
|
|
82
86
|
**deferred_findings_kept(keeping_deferred) },
|
|
83
87
|
"response_template" => across_to_fill(request_id:, principles:),
|
|
84
88
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
85
|
-
"next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles),
|
|
89
|
+
"next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles),
|
|
90
|
+
request_id:, file: answer_file) }
|
|
86
91
|
end
|
|
87
92
|
|
|
88
93
|
# The answer to the request for the members several principles map, to fill: its basis names each principle and
|
|
@@ -121,10 +126,10 @@ module Principles
|
|
|
121
126
|
def named_entry(asked, position) = [asked.fetch(:change).member_id, named(asked.fetch(:placeholders), position)]
|
|
122
127
|
|
|
123
128
|
# How to fill the answer to request_id, acknowledging member_ids of principle_ids: saved bare from
|
|
124
|
-
# start-audit --as template to
|
|
125
|
-
#: (Array[String], Array[String], request_id: String) -> String
|
|
126
|
-
def to_fill(principle_ids, member_ids, request_id:)
|
|
127
|
-
AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:)
|
|
129
|
+
# start-audit --as template to file, which the agent edits.
|
|
130
|
+
#: (Array[String], Array[String], request_id: String, file: String) -> String
|
|
131
|
+
def to_fill(principle_ids, member_ids, request_id:, file:)
|
|
132
|
+
AnswerInAFile.new(@invocation).acknowledgement(principle_ids, member_ids, request_id:, file:)
|
|
128
133
|
end
|
|
129
134
|
|
|
130
135
|
# Each member the principles' requests ask about, once, in the order they ask.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation"
|
|
5
|
+
require_relative "member_change_since_baseline"
|
|
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
|
+
# An acknowledgement's answer to fill as start-audit --member --as template prints it alone, where no request
|
|
11
|
+
# stands beside it: the answer its request prints as response_template, with what that request shows beside it
|
|
12
|
+
# for the agent to read, each member's role before its own fields and answer_with, the command that submits the
|
|
13
|
+
# file the request's next_action saves it in. The answer reads neither.
|
|
14
|
+
class AcknowledgementTemplateAlone
|
|
15
|
+
#: (Invocation) -> void
|
|
16
|
+
def initialize(invocation)
|
|
17
|
+
@invocation = invocation
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# answer, whose members asked asks about, each as its member's part of the request holds it, with each role,
|
|
22
|
+
# submitted from answer_file, the file the request's next_action saves it in.
|
|
23
|
+
#: (Hash[String, untyped], Array[Hash[Symbol, untyped]], answer_file: String) -> Hash[String, untyped]
|
|
24
|
+
def of(answer, asked, answer_file:)
|
|
25
|
+
changes = asked.map { it.fetch(:change) } #: Array[MemberChangeSinceBaseline]
|
|
26
|
+
printed(answer, changes.to_h { [it.member_id, { "role" => it.role }] }, answer_file)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# answer for the members several principles map, each principles' members as their part of the request holds
|
|
30
|
+
# them: as of gives it, but with each member's roles, by the principle mapping it with each.
|
|
31
|
+
#: (Hash[String, untyped], Hash[String, Array[Hash[Symbol, untyped]]], answer_file: String)
|
|
32
|
+
#| -> Hash[String, untyped]
|
|
33
|
+
def across(answer, principles, answer_file:)
|
|
34
|
+
roles = {} #: Hash[String, Hash[String, String]]
|
|
35
|
+
principles.each do |principle_id, asked|
|
|
36
|
+
asked.each do |member|
|
|
37
|
+
change = member.fetch(:change) #: MemberChangeSinceBaseline
|
|
38
|
+
(roles[change.member_id] ||= {})[principle_id] = change.role
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
printed(answer, roles.transform_values { { "roles" => it } }, answer_file)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
# answer with each member's read_only fields before its own, and answer_with, submitting answer_file, after them.
|
|
47
|
+
#: (Hash[String, untyped], Hash[String, Hash[String, untyped]], String) -> Hash[String, untyped]
|
|
48
|
+
def printed(answer, read_only, answer_file)
|
|
49
|
+
members = answer.fetch("members").to_h { |id, entry| [id, { **read_only.fetch(id), **entry }] }
|
|
50
|
+
submit = @invocation.submit_answer(answer.fetch("request_id"), file: answer_file)
|
|
51
|
+
{ **answer, "members" => members, "answer_with" => submit }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "invocation"
|
|
5
|
+
require_relative "problem_lines"
|
|
6
|
+
require_relative "shell_word"
|
|
7
|
+
require_relative "../prose_list"
|
|
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 one-member audits list-member-problems offers: by the principles that acknowledge them together, in the
|
|
13
|
+
# order the model gives, the changed members each acknowledgement takes in, one command for each set, and those
|
|
14
|
+
# whose check is this tool's own list-member-problems --short, which the model puts last.
|
|
15
|
+
class AcknowledgementsOffered
|
|
16
|
+
# groups gives, for each set of principle ids, the members they acknowledge together; last, the members whose
|
|
17
|
+
# check is this tool's own --short.
|
|
18
|
+
#: (Hash[Array[String], Array[String]], ?last: Array[String]) -> void
|
|
19
|
+
def initialize(groups, last: [])
|
|
20
|
+
@groups = groups
|
|
21
|
+
@last = last
|
|
22
|
+
freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
NONE = new({}) #: AcknowledgementsOffered
|
|
26
|
+
|
|
27
|
+
# The members an acknowledgement takes in for principle id.
|
|
28
|
+
#: (String) -> Array[String]
|
|
29
|
+
def members_of(id) = @groups.select { |ids, _| ids.include?(id) }.values.flatten
|
|
30
|
+
|
|
31
|
+
# Each acknowledgement's command, filled and shell-quoted so the agent types no id, through invocation; a set
|
|
32
|
+
# holding a member in last after a line asking to acknowledge it last, since its check exits as --short does
|
|
33
|
+
# while it lists a member the answer leaves out.
|
|
34
|
+
#: (Invocation) -> Array[String]
|
|
35
|
+
def lines(invocation)
|
|
36
|
+
@groups.flat_map do |ids, members|
|
|
37
|
+
line = invocation.listed_in_project("start-audit", ids, options: members.flat_map { ["--member", it] })
|
|
38
|
+
own = members & @last
|
|
39
|
+
own.empty? ? [line] : [last_line(own), line]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# The line asking to acknowledge own, members whose check is this tool's own --short, after the others.
|
|
46
|
+
#: (Array[String]) -> String
|
|
47
|
+
def last_line(own)
|
|
48
|
+
"Acknowledge #{ProseList.new(own.map { ShellWord.new(it).to_s })} last: its check, list-member-problems " \
|
|
49
|
+
"--short, exits #{ProblemLines::CHANGED} while it lists a member this acknowledgement leaves out, so first " \
|
|
50
|
+
"acknowledge or audit, and commit, each member listed that it leaves out."
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -3,16 +3,28 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative "lines_shared_with_member"
|
|
5
5
|
require_relative "consecutive_sections_elsewhere"
|
|
6
|
+
require_relative "whole_file_elsewhere"
|
|
7
|
+
require_relative "member_sets_overlap"
|
|
6
8
|
|
|
7
9
|
module Principles
|
|
8
10
|
module Views
|
|
9
|
-
# The member just added: its id, current lines and check, beside its shared
|
|
11
|
+
# The member just added: its id, current lines and check, beside its shared-line facts and the facts of other
|
|
12
|
+
# maps it asks the agent to judge, each printed only when it has some.
|
|
10
13
|
class AddedMember
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
# What the agent decides when other principles hold the new member's file whole or a nearly matching member set,
|
|
15
|
+
# asked once however many of those cues fire.
|
|
16
|
+
SCOPE_OR_JOIN = "Should each hold only the passages that carry it (move-member with " \
|
|
17
|
+
"--section or --starting-at), or are they one principle (join the maps: add one map's " \
|
|
18
|
+
"members to the other, then remove-principle)? " #: String
|
|
19
|
+
|
|
20
|
+
#: (Hash[String, untyped], shared: LinesSharedWithMember,
|
|
21
|
+
#| other_maps: Array[ConsecutiveSectionsElsewhere | WholeFileElsewhere | MemberSetsOverlap])
|
|
22
|
+
#| -> void
|
|
23
|
+
def initialize(added, shared:, other_maps:)
|
|
24
|
+
facts = other_maps.reduce(added.merge(shared.to_h)) { |merged, each| merged.merge(each.to_h) }
|
|
25
|
+
@added = facts #: Hash[String, untyped]
|
|
14
26
|
@shared = shared
|
|
15
|
-
@
|
|
27
|
+
@other_maps = other_maps
|
|
16
28
|
freeze
|
|
17
29
|
end
|
|
18
30
|
|
|
@@ -25,11 +37,15 @@ module Principles
|
|
|
25
37
|
# The same location/remapping opening precedes the map's own after-add guidance.
|
|
26
38
|
#: () -> String
|
|
27
39
|
def opening
|
|
28
|
-
"#{span}#{@shared.note}#{@
|
|
40
|
+
"#{span}#{@shared.note}#{@other_maps.map(&:note).join}#{SCOPE_OR_JOIN if scope_or_join?}" \
|
|
41
|
+
"Add the next member the same way. "
|
|
29
42
|
end
|
|
30
43
|
|
|
31
44
|
private
|
|
32
45
|
|
|
46
|
+
#: () -> bool
|
|
47
|
+
def scope_or_join? = @other_maps.any?(&:asks_scope_or_join?)
|
|
48
|
+
|
|
33
49
|
# The lines a member spans, said so that a passage cut short shows; it ends with a space.
|
|
34
50
|
#: () -> String
|
|
35
51
|
def span
|
|
@@ -24,16 +24,16 @@ module Principles
|
|
|
24
24
|
#: (String, request_id: String) -> String
|
|
25
25
|
def assessment(principle_id, request_id:)
|
|
26
26
|
line(@invocation.in_project("start-audit", principle_id, options: ["--part", ContextParts::TEMPLATE]),
|
|
27
|
-
request_id:)
|
|
27
|
+
request_id:, file: @invocation.answer_file(principle_id, "assessment"))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
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:)
|
|
31
|
+
# bare, to save in file.
|
|
32
|
+
#: (Array[String], Array[String], request_id: String, file: String) -> String
|
|
33
|
+
def acknowledgement(principle_ids, member_ids, request_id:, file:)
|
|
34
34
|
named = member_ids.flat_map { ["--member", it] }
|
|
35
35
|
line(@invocation.listed_in_project("start-audit", principle_ids, options: [*named, "--as", "template"]),
|
|
36
|
-
request_id:)
|
|
36
|
+
request_id:, file:)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
# The line for a decision on principle_id's open findings, whose answer start-audit --open-findings --as template
|
|
@@ -41,21 +41,21 @@ module Principles
|
|
|
41
41
|
#: (String, request_id: String) -> String
|
|
42
42
|
def open_findings(principle_id, request_id:)
|
|
43
43
|
line(@invocation.in_project("start-audit", principle_id, options: %w[--open-findings --as template]),
|
|
44
|
-
request_id:)
|
|
44
|
+
request_id:, file: @invocation.answer_file(principle_id, "deciding"))
|
|
45
45
|
end
|
|
46
46
|
|
|
47
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:,
|
|
48
|
+
# dispositions are the agent's to fill, to save in file.
|
|
49
|
+
#: (String, request_id: String, file: String) -> String
|
|
50
|
+
def correction(principle_id, request_id:, file:)
|
|
51
|
+
line(@invocation.in_project("show-open-correction", principle_id), request_id:, file:,
|
|
52
|
+
what: "only its dispositions")
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
# The line for the answer request_id names, which the printed command save prints bare; what is
|
|
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)
|
|
55
|
+
# The line for the answer request_id names, saved in file, which the printed command save prints bare; what is
|
|
56
|
+
# the part of it the agent fills.
|
|
57
|
+
#: (String, request_id: String, file: String, ?what: String) -> String
|
|
58
|
+
def line(save, request_id:, file:, what: "it")
|
|
59
59
|
Prompts.text("answer-any-judgement-request/fill-the-answer-in-a-file",
|
|
60
60
|
save: "#{save} > #{ShellWord.new(file)}", what:,
|
|
61
61
|
answer_with: @invocation.submit_answer(request_id, file:))
|
|
@@ -11,19 +11,23 @@ module Principles
|
|
|
11
11
|
# request shows of each, the template entry each starts with, and what they carry that the request explains.
|
|
12
12
|
class AssessedMembers
|
|
13
13
|
# What the request shows of each member.
|
|
14
|
-
SHOWN = %w[id role first_line last_line check check_since_last_audit check_hidden_characters
|
|
14
|
+
SHOWN = %w[id role first_line last_line source check check_since_last_audit check_hidden_characters
|
|
15
15
|
acknowledged_since_last_audit carried_forward open_finding_ids judge_because moved_from read_the_change
|
|
16
|
-
mapped_elsewhere].freeze #: Array[String]
|
|
16
|
+
changed_lines mapped_elsewhere].freeze #: Array[String]
|
|
17
17
|
|
|
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
21
|
# assessment_placeholder is the text a fresh member's assessment prints, which an answer may not send back, its
|
|
22
22
|
# %<id>s filled with the member's id, so each slot's is its own and one edit fills one slot.
|
|
23
|
+
# carrier_checks is the check for each carrier kind the members are in, as CarrierChecks prints them.
|
|
23
24
|
#: (Array[Hash[String, untyped]], reviewed_check_placeholders: Hash[String, String],
|
|
24
|
-
#| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String
|
|
25
|
-
|
|
25
|
+
#| unchanged_check_placeholders: Hash[String, String], assessment_placeholder: String,
|
|
26
|
+
#| ?carrier_checks: Hash[String, untyped]) -> void
|
|
27
|
+
def initialize(members, reviewed_check_placeholders:, unchanged_check_placeholders:, assessment_placeholder:,
|
|
28
|
+
carrier_checks: {})
|
|
26
29
|
@assessment_placeholder = assessment_placeholder
|
|
30
|
+
@carrier_checks = carrier_checks
|
|
27
31
|
@members = members
|
|
28
32
|
@reviewed_check_placeholders = reviewed_check_placeholders
|
|
29
33
|
@unchanged_check_placeholders = unchanged_check_placeholders
|
|
@@ -32,7 +36,8 @@ module Principles
|
|
|
32
36
|
|
|
33
37
|
# What the request shows of a carried member no flag fires on: what names it and its check, whose result
|
|
34
38
|
# the template still asks for, and of its carried assessment only its dates and flags.
|
|
35
|
-
COMPACT = %w[id role check check_since_last_audit check_hidden_characters
|
|
39
|
+
COMPACT = %w[id role source check check_since_last_audit check_hidden_characters
|
|
40
|
+
carried_forward].freeze #: Array[String]
|
|
36
41
|
# What a compact member shows of its carried assessment.
|
|
37
42
|
CARRIED_COMPACTLY = %w[assessed_at observed_at observed_at_from_assessed_at evidence_changed
|
|
38
43
|
file_changed_outside_member].freeze #: Array[String]
|
|
@@ -49,6 +54,11 @@ module Principles
|
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
56
|
|
|
57
|
+
# The check for each carrier kind the members are in, under carrier_checks, which the request prints beside
|
|
58
|
+
# them, outside the question a record digests; nothing when there are none.
|
|
59
|
+
#: () -> Hash[String, Hash[String, untyped]]
|
|
60
|
+
def carrier_checks = @carrier_checks.empty? ? {} : { "carrier_checks" => @carrier_checks }
|
|
61
|
+
|
|
52
62
|
# What the template printed alone says of the checks before its members, since it has no context to show it in:
|
|
53
63
|
# the carried members whose template entry in templates still asks for a check_result, under
|
|
54
64
|
# carried_checks_to_run, named before the members so a reader skipping carried markers still runs each, and how
|
|
@@ -70,7 +80,7 @@ module Principles
|
|
|
70
80
|
|
|
71
81
|
# How to run and report the checks of each standing, once, with the ids of the members it is for, under
|
|
72
82
|
# shared_check_instructions, whose own lines check_instructions adds; nothing when none has a check.
|
|
73
|
-
#: () -> Hash[String,
|
|
83
|
+
#: () -> Hash[String, Hash[String, untyped]]
|
|
74
84
|
def shared_check_instructions
|
|
75
85
|
checks = @members.filter_map { |member| check_template(member)&.then { [member.fetch("id"), it] } }
|
|
76
86
|
return {} if checks.empty?
|
|
@@ -150,10 +160,11 @@ module Principles
|
|
|
150
160
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
151
161
|
def carried(member) = { "member_id" => member.fetch("id"), "carried_forward" => true }
|
|
152
162
|
|
|
163
|
+
# A fresh member's slot, naming why it is judged afresh, so the template printed alone says so too.
|
|
153
164
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
154
165
|
def fresh(member)
|
|
155
166
|
id = member.fetch("id")
|
|
156
|
-
{ "member_id" => id, "assessment" => format(@assessment_placeholder, id:),
|
|
167
|
+
{ "member_id" => id, **member.slice("judge_because"), "assessment" => format(@assessment_placeholder, id:),
|
|
157
168
|
"delivery" => "not_observed", "evidence" => member.fetch("evidence") }
|
|
158
169
|
end
|
|
159
170
|
end
|