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
|
@@ -37,7 +37,7 @@ module Principles
|
|
|
37
37
|
#: (untyped) -> Hash[String, untyped]?
|
|
38
38
|
def result(answer)
|
|
39
39
|
check = @member.check
|
|
40
|
-
|
|
40
|
+
stray if !check && answer.key?("check_result")
|
|
41
41
|
return unless check
|
|
42
42
|
|
|
43
43
|
sent = answer["check_result"] or missing
|
|
@@ -99,6 +99,16 @@ module Principles
|
|
|
99
99
|
)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
+
# Refuses an answer for a member with no check that reports a check_result, which its acknowledgement is
|
|
103
|
+
# accepted without, rather than dropping it unread.
|
|
104
|
+
#: () -> bot
|
|
105
|
+
def stray
|
|
106
|
+
raise CHECK_RESULT.refusal(
|
|
107
|
+
Error.new("invalid_check_result", "the member has no check, so its acknowledgement takes no check_result",
|
|
108
|
+
"Remove check_result from this acknowledgement.")
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
|
|
102
112
|
#: (String) -> bot
|
|
103
113
|
def refuse(why) = AcknowledgementRefusal.new(@member, @principle_id).refuse(why)
|
|
104
114
|
end
|
|
@@ -61,6 +61,16 @@ module Principles
|
|
|
61
61
|
#: (Placement) -> Array[String]
|
|
62
62
|
def paths_since(baseline) = baseline.paths_to(@member.path)
|
|
63
63
|
|
|
64
|
+
# Whether the member's file at the base commit holds the text its file held at baseline, so a change to the
|
|
65
|
+
# member is a change to its span alone, as after move-member --ending-at.
|
|
66
|
+
#: (Placement, Project) -> bool
|
|
67
|
+
def file_unchanged_since?(baseline, project)
|
|
68
|
+
base = @base or return false
|
|
69
|
+
|
|
70
|
+
then_text = project.history.at(baseline.commit).text(baseline.reference.fetch("path"))
|
|
71
|
+
!then_text.nil? && then_text == project.history.at(base).text(@member.path)
|
|
72
|
+
end
|
|
73
|
+
|
|
64
74
|
# The commit the member was last judged at, when baseline is later than it, as when the member's own full
|
|
65
75
|
# audit fixed it after its base.
|
|
66
76
|
#: (Placement) -> String?
|
|
@@ -99,6 +109,11 @@ module Principles
|
|
|
99
109
|
{ "deferred_findings" => findings_on_member("deferred"), "accepted_findings" => findings_on_member("accepted") }
|
|
100
110
|
end
|
|
101
111
|
|
|
112
|
+
# The ids of the findings the last audit left open on this member, deferred then accepted, which accepting
|
|
113
|
+
# the acknowledgement leaves open, since only a full audit decides a finding.
|
|
114
|
+
#: () -> Array[String]
|
|
115
|
+
def open_finding_ids = open_findings.values.flatten
|
|
116
|
+
|
|
102
117
|
# Whether the last audit deferred a finding on this member, which acknowledging it leaves open for a full audit.
|
|
103
118
|
#: () -> bool
|
|
104
119
|
def keeps_deferred_findings? = findings_on_member("deferred").any?
|
|
@@ -12,23 +12,45 @@ module Principles
|
|
|
12
12
|
# The text a one-member audit's template prints in each field the agent writes, and the refusal of an answer
|
|
13
13
|
# that sends any back as printed.
|
|
14
14
|
class AcknowledgementPlaceholders
|
|
15
|
+
# meaning_kept's placeholder after a pure insertion, for an agent that reads the template alone: an inserted
|
|
16
|
+
# line usually adds a rule.
|
|
17
|
+
INSERTED = NamedPlaceholder.new(
|
|
18
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; this change inserted a line, " \
|
|
19
|
+
"which usually adds a rule",
|
|
20
|
+
before: NamedPlaceholder.new(
|
|
21
|
+
"true only if #{NamedPlaceholder::SLOT} still says the same thing; this change inserted a line, which " \
|
|
22
|
+
"usually adds a rule",
|
|
23
|
+
before: "true only if the member still says the same thing; this change inserted a line, which " \
|
|
24
|
+
"usually adds a rule"
|
|
25
|
+
)
|
|
26
|
+
) #: NamedPlaceholder
|
|
27
|
+
# meaning_kept's placeholder when the member's lines grew and its file's text did not change, as after
|
|
28
|
+
# move-member --ending-at, where no line was inserted; it printed INSERTED before.
|
|
29
|
+
SPAN_GREW = NamedPlaceholder.new(
|
|
30
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; its span grew over lines its file " \
|
|
31
|
+
"already held, which may add a rule",
|
|
32
|
+
before: INSERTED
|
|
33
|
+
) #: NamedPlaceholder
|
|
15
34
|
# The text the answer's template prints in each field the agent judges, which an answer may not send back, so
|
|
16
35
|
# a template returned as printed acknowledges nothing. It prints no quotes, which an answer leaving them
|
|
17
|
-
# out reads as first_changed_lines. After a pure insertion, meaning_kept's
|
|
18
|
-
#
|
|
19
|
-
# Each names the
|
|
20
|
-
# one
|
|
36
|
+
# out reads as first_changed_lines. After a pure insertion, meaning_kept's is INSERTED, or SPAN_GREW when the
|
|
37
|
+
# file's text did not change.
|
|
38
|
+
# Each names the entry it is printed in by its position, M1 the first, so no two members' slots are alike and
|
|
39
|
+
# one edit fills one, short since an edit tool's old_string quotes it whole; the member's id, which may be long
|
|
40
|
+
# and hold quotes, is the entry's key alone. Any entry's, or the text printed before, naming the member's id or
|
|
41
|
+
# neither, is left as printed.
|
|
21
42
|
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
22
|
-
{ "meaning_kept" => NamedPlaceholder.new(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
{ "meaning_kept" => NamedPlaceholder.new(
|
|
44
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing",
|
|
45
|
+
before: NamedPlaceholder.new("true only if #{NamedPlaceholder::SLOT} still says the same thing",
|
|
46
|
+
before: "true only if the member still says the same thing")
|
|
47
|
+
),
|
|
48
|
+
"reason" => NamedPlaceholder.new(
|
|
49
|
+
"M#{NamedPlaceholder::SLOT}: why, in one line of your own",
|
|
50
|
+
before: NamedPlaceholder.new("Why, for #{NamedPlaceholder::SLOT}, in one line of your own",
|
|
51
|
+
before: "Why, in one line of your own")
|
|
52
|
+
) },
|
|
53
|
+
also_printed: { "meaning_kept" => { inserted: INSERTED, span_grew: SPAN_GREW } }
|
|
32
54
|
) #: TemplatePlaceholders
|
|
33
55
|
# The text a checked member's template prints where its check's exit status goes, short since the request's
|
|
34
56
|
# context says how to run the check.
|
|
@@ -38,10 +60,13 @@ module Principles
|
|
|
38
60
|
PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
|
|
39
61
|
) #: AcknowledgementLeftAsPrinted
|
|
40
62
|
|
|
41
|
-
# The placeholders the template prints beside quotes, its first_changed_lines
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
# The placeholders the template prints beside quotes, its first_changed_lines, file_unchanged saying whether
|
|
64
|
+
# the member's file holds the same text as at its baseline, so only its span changed.
|
|
65
|
+
#: (Hash[String, String], ?file_unchanged: bool) -> Hash[String, untyped]
|
|
66
|
+
def self.beside(quotes, file_unchanged: false)
|
|
67
|
+
return PLACEHOLDERS.to_h unless quotes["old_line"] == ""
|
|
68
|
+
|
|
69
|
+
PLACEHOLDERS.with_other_text_in("meaning_kept", file_unchanged ? :span_grew : :inserted)
|
|
45
70
|
end
|
|
46
71
|
end
|
|
47
72
|
end
|
|
@@ -11,7 +11,8 @@ module Principles
|
|
|
11
11
|
# to the full audit, but a member whose text is the one last judged needs nothing at all.
|
|
12
12
|
class AcknowledgementRefusal
|
|
13
13
|
# Why a one-member audit cannot judge member's change against record, or nil when it can: the record must
|
|
14
|
-
# be completed and have assessed the member, the member's text must differ from the one it assessed,
|
|
14
|
+
# be completed and have assessed the member, the member's text must differ from the one it assessed, it must
|
|
15
|
+
# be the project's, since a one-member audit reads its change from git, which holds no plugin's file, its check
|
|
15
16
|
# must be the one the record ran, so none new, changed, removed or last not run escapes a full audit's review.
|
|
16
17
|
# The one owner of these preconditions, which
|
|
17
18
|
# list-member-problems asks before offering the audit that Acknowledgement refuses by them; git is
|
|
@@ -19,21 +20,28 @@ module Principles
|
|
|
19
20
|
#: (AuditRecord, Member, now_sha256: String?) -> AcknowledgementRefusal?
|
|
20
21
|
def self.of(record, member, now_sha256:)
|
|
21
22
|
members = record.members
|
|
22
|
-
recorded = members.hash_for(member.key)
|
|
23
23
|
check = members.check_since(member.key, member.check)
|
|
24
|
-
reason =
|
|
25
|
-
|
|
26
|
-
elsif !recorded then :not_assessed
|
|
27
|
-
elsif recorded == now_sha256 then :unchanged
|
|
28
|
-
elsif check != :unchanged then check
|
|
29
|
-
end
|
|
24
|
+
reason = baseline_missing(record, members.hash_for(member.key), now_sha256) ||
|
|
25
|
+
(:plugin if member.plugin_reference) || (check unless check == :unchanged)
|
|
30
26
|
new(member, record.principle_id, reason, ran: members.check_run_for(member.key)) if reason
|
|
31
27
|
end
|
|
32
28
|
|
|
29
|
+
# Why record gives no baseline to judge a change against, the member's hash it assessed being recorded and
|
|
30
|
+
# its hash now now_sha256: open, not completed, the member not assessed, or unchanged; nil when it gives one.
|
|
31
|
+
#: (AuditRecord, String?, String?) -> Symbol?
|
|
32
|
+
def self.baseline_missing(record, recorded, now_sha256)
|
|
33
|
+
if record.open_after_a_completed_audit? then :open
|
|
34
|
+
elsif !record.completed? then :not_completed
|
|
35
|
+
elsif !recorded then :not_assessed
|
|
36
|
+
elsif recorded == now_sha256 then :unchanged
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
private_class_method :baseline_missing
|
|
40
|
+
|
|
33
41
|
# principle_id is the member's principle, whose full audit each refusal names. reason, which raise! raises, is
|
|
34
|
-
# :open, :not_completed, :not_assessed, :unchanged, or how the member's check stands to the one the
|
|
35
|
-
# ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason
|
|
36
|
-
# only refuses for a reason its caller states.
|
|
42
|
+
# :open, :not_completed, :not_assessed, :unchanged, :plugin, or how the member's check stands to the one the
|
|
43
|
+
# record ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason
|
|
44
|
+
# it only refuses for a reason its caller states.
|
|
37
45
|
#: (Member, String, ?Symbol?, ?ran: String?) -> void
|
|
38
46
|
def initialize(member, principle_id, reason = nil, ran: nil)
|
|
39
47
|
@reason = reason
|
|
@@ -58,6 +66,7 @@ module Principles
|
|
|
58
66
|
when :open then open_audit
|
|
59
67
|
when :not_completed then refuse("#{@principle_id} has no completed audit, so no baseline has been judged")
|
|
60
68
|
when :not_assessed then refuse("no completed audit assessed #{@member.id}")
|
|
69
|
+
when :plugin then refuse("it is read from an installed plugin, whose changes git holds no history of")
|
|
61
70
|
else refuse("#{check_since_record}, so a full audit reviews it")
|
|
62
71
|
end
|
|
63
72
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "list_member_problems_check"
|
|
5
|
+
require_relative "member_problems"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# The one-member audits list-member-problems offers across maps: the changed members each may judge, joined
|
|
11
|
+
# where principles share one, leaving out the principles whose records wait on an upgrade.
|
|
12
|
+
class AcknowledgementsToOffer
|
|
13
|
+
# maps is each map's MemberProblems; except, the principles whose records wait on an upgrade.
|
|
14
|
+
#: (Array[MemberProblems], except: Array[String]) -> void
|
|
15
|
+
def initialize(maps, except:)
|
|
16
|
+
@maps = maps
|
|
17
|
+
@except = except
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Each set of principle ids, in id order, with the members they acknowledge together, those of principles that
|
|
22
|
+
# share one joined in one acknowledgement across them. Each set holding a member last names comes after the
|
|
23
|
+
# others.
|
|
24
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
25
|
+
def together = offered.partition { |_ids, members| !members.intersect?(last) }.flatten(1).to_h
|
|
26
|
+
|
|
27
|
+
# The acknowledgeable members whose check is this tool's own list-member-problems --short, which refuses their
|
|
28
|
+
# acknowledgement while it lists a member the answer leaves out, so they are acknowledged after the others;
|
|
29
|
+
# none whose set holds every member --short lists, since nothing else is to come first.
|
|
30
|
+
#: () -> Array[String]
|
|
31
|
+
def last
|
|
32
|
+
sets = offered.values
|
|
33
|
+
self_checked.select { |id| sets.find { it.include?(id) }&.then { listed_beside?(it) } }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# The sets to offer: those grouped, with every set holding a member --short checks joined into one across their
|
|
39
|
+
# principles, since apart each such member's check lists the other's and none could pass.
|
|
40
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
41
|
+
def offered
|
|
42
|
+
checking, others = grouped.partition { |_ids, members| members.intersect?(self_checked) }
|
|
43
|
+
return grouped if checking.length < 2
|
|
44
|
+
|
|
45
|
+
others.to_h.merge(checking.flat_map(&:first).uniq.sort => checking.flat_map(&:last).uniq)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The members, of every map, whose check is this tool's own list-member-problems --short.
|
|
49
|
+
#: () -> Array[String]
|
|
50
|
+
def self_checked
|
|
51
|
+
@maps.flat_map { |map| map.members.select { ListMemberProblemsCheck.of(it.check.to_s) }.map(&:id) }.uniq
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Each set of principle ids with the members they acknowledge together, in no set order.
|
|
55
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
56
|
+
def grouped
|
|
57
|
+
acknowledgeable.reduce({}) do |joined, (id, members)|
|
|
58
|
+
@except.include?(id) ? joined : joining(joined, id, members)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Whether --short lists a member set leaves out: one changed, or one no audit has assessed, in a map whose
|
|
63
|
+
# record waits on no upgrade.
|
|
64
|
+
#: (Array[String]) -> bool
|
|
65
|
+
def listed_beside?(set)
|
|
66
|
+
acting = @maps.reject { @except.include?(it.principle_id) }
|
|
67
|
+
acting.any? { it.never_assessed.positive? } ||
|
|
68
|
+
acting.flat_map(&:entries).any? { it.fetch("state") == "changed" && !set.include?(it.fetch("id")) }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# For each map with a changed member a one-member audit may judge, the ids of those members.
|
|
72
|
+
#: () -> Hash[String, Array[String]]
|
|
73
|
+
def acknowledgeable
|
|
74
|
+
@maps.to_h { |map| [map.principle_id, map.acknowledgeable_member_ids] }.reject { |_, ids| ids.empty? }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# groups with principle id's members joined into each group that shares one of them, as one group.
|
|
78
|
+
#: (Hash[Array[String], Array[String]], String, Array[String]) -> Hash[Array[String], Array[String]]
|
|
79
|
+
def joining(groups, id, members)
|
|
80
|
+
joined = groups.select { |_ids, others| others.intersect?(members) }
|
|
81
|
+
rest = groups.reject { |ids, _others| joined.key?(ids) }
|
|
82
|
+
rest.merge([*joined.keys.flatten, id].sort => [*joined.values.flatten, *members].uniq)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -31,6 +31,10 @@ module Principles
|
|
|
31
31
|
#: Integer
|
|
32
32
|
attr_reader :started
|
|
33
33
|
|
|
34
|
+
# The session's directory, whose project and its worktrees are the only repositories reported on.
|
|
35
|
+
#: String
|
|
36
|
+
attr_reader :session_directory
|
|
37
|
+
|
|
34
38
|
# The hook's input as the process it runs in reads it, the one owner of that reading for the executable, before
|
|
35
39
|
# the rest of this tool loads, and for the command: started at clock, unless environment's PRINCIPLES_HOOK_NOW,
|
|
36
40
|
# a test seam no session sets, gives the second; with home as ~; and for input naming no cwd, the session's
|
|
@@ -48,6 +52,7 @@ module Principles
|
|
|
48
52
|
given = parsed(text)
|
|
49
53
|
@event = EVENTS.find { it == given["hook_event_name"] } #: String?
|
|
50
54
|
@started = started_before(now, given["duration_ms"]) #: Integer
|
|
55
|
+
@session_directory = fallback
|
|
51
56
|
@cwd = text(given["cwd"]) || fallback #: String
|
|
52
57
|
tool_input = given["tool_input"]
|
|
53
58
|
@command = (text(tool_input["command"]) if tool_input.is_a?(Hash)) || "" #: String
|
|
@@ -18,6 +18,9 @@ module Principles
|
|
|
18
18
|
LINK_REPAIR = "Give recorded_at as {\"url\": \"https://...\"}, the whole link to where it is written up, " \
|
|
19
19
|
"such as an issue, with no other field; or as {\"path\": ..., \"heading\": ...} for a file in " \
|
|
20
20
|
"the project."
|
|
21
|
+
# The two forms a recorded_at takes, which a repair asking for one names.
|
|
22
|
+
WRITE_UP_FORMS = "{\"path\": ..., \"heading\": ...} for a file in the project, or {\"url\": \"https://...\"} " \
|
|
23
|
+
"for a page outside it, such as an issue"
|
|
21
24
|
|
|
22
25
|
#: (^(Locator) -> void) -> void
|
|
23
26
|
def initialize(locate)
|
|
@@ -17,12 +17,19 @@ module Principles
|
|
|
17
17
|
new("base_commit" => base, "last_completed_revision" => record&.last_completed&.revision)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
# audited_change is the commit that last changed the map's file or a member's file at the base, which the id
|
|
21
|
+
# digests in place of the base, so a commit elsewhere leaves the id as it was; the base until given.
|
|
22
|
+
#: (Hash[String, untyped], ?String?) -> void
|
|
23
|
+
def initialize(fields, audited_change = fields["base_commit"])
|
|
22
24
|
@fields = fields
|
|
25
|
+
@audited_change = audited_change
|
|
23
26
|
freeze
|
|
24
27
|
end
|
|
25
28
|
|
|
29
|
+
# This basis, its id digesting commit, the last change to the files the audit reads at its base, nil outside git.
|
|
30
|
+
#: (String?) -> AssessmentBasis
|
|
31
|
+
def audited_at(commit) = AssessmentBasis.new(@fields, commit)
|
|
32
|
+
|
|
26
33
|
#: () -> Hash[String, untyped]
|
|
27
34
|
def to_h = @fields
|
|
28
35
|
|
|
@@ -41,7 +48,7 @@ module Principles
|
|
|
41
48
|
|
|
42
49
|
# What the request id digests of the basis, in a fixed order, so how the answer orders its keys changes nothing.
|
|
43
50
|
#: () -> Array[String?]
|
|
44
|
-
def digested = [
|
|
51
|
+
def digested = [@audited_change, revision]
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
54
|
end
|
|
@@ -16,6 +16,7 @@ require_relative "carried_assessments"
|
|
|
16
16
|
require_relative "prior_findings"
|
|
17
17
|
require_relative "decided_prior_findings"
|
|
18
18
|
require_relative "disposition"
|
|
19
|
+
require_relative "finding_outcomes"
|
|
19
20
|
require_relative "stale_request"
|
|
20
21
|
require_relative "map_change"
|
|
21
22
|
|
|
@@ -69,7 +70,7 @@ module Principles
|
|
|
69
70
|
def check_assessment_request(request_id, basis:, committed:, record:, loads:, &started_from)
|
|
70
71
|
prior = prior_findings(record)
|
|
71
72
|
now_id = assessment_id(basis, prior.digested, loads.listed)
|
|
72
|
-
return prior if now_id == request_id && (basis.base.nil? || committed ==
|
|
73
|
+
return prior if now_id == request_id && (basis.base.nil? || committed == in_project_now)
|
|
73
74
|
|
|
74
75
|
raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false,
|
|
75
76
|
map_change: map_change(request_id, basis, record, loads,
|
|
@@ -149,16 +150,10 @@ module Principles
|
|
|
149
150
|
before
|
|
150
151
|
end
|
|
151
152
|
|
|
152
|
-
#
|
|
153
|
-
# what a deferral says it waits on, if anything.
|
|
154
|
-
# Then each prior finding kept; a new finding that raises one again keeps when it was first raised.
|
|
153
|
+
# The findings the completed audit records, as FindingOutcomes gives them.
|
|
155
154
|
#: (Array[untyped], Array[Disposition], ?DecidedPriorFindings) -> Array[untyped]
|
|
156
155
|
def outcomes(findings, dispositions, prior = DecidedPriorFindings::NONE)
|
|
157
|
-
findings
|
|
158
|
-
id = finding.fetch("id")
|
|
159
|
-
disposition = dispositions.find { |each| each.finding_id == id } or raise KeyError, id
|
|
160
|
-
finding.slice(*RecordedFinding::RAISED_FIELDS).merge(disposition.recorded_outcome, prior.first_raised(id))
|
|
161
|
-
end + prior.kept
|
|
156
|
+
FindingOutcomes.new(findings, dispositions, prior).recorded
|
|
162
157
|
end
|
|
163
158
|
|
|
164
159
|
# What each member's assessment is judged on beside its text, from each member's loads: its map entry and when
|
|
@@ -217,7 +212,12 @@ module Principles
|
|
|
217
212
|
# The ids of the members whose hash now differs from the one committed, the base commit's, gives; none
|
|
218
213
|
# outside git.
|
|
219
214
|
#: (Hash[String, String]?) -> Array[String]
|
|
220
|
-
def changed_since(committed) = committed ?
|
|
215
|
+
def changed_since(committed) = committed ? in_project_now.reject { |id, sha| committed[id] == sha }.keys : []
|
|
216
|
+
|
|
217
|
+
# Each hash now of a member in the project's own files, which a commit can hold, by id; a plugin's member,
|
|
218
|
+
# outside git, is compared only through the request id.
|
|
219
|
+
#: () -> Hash[String, String]
|
|
220
|
+
def in_project_now = members.in_project.ids.to_h { [it, @now.fetch(it)] }
|
|
221
221
|
|
|
222
222
|
#: () -> Error
|
|
223
223
|
def stale_request = StaleRequest.new(id).refusal
|
|
@@ -175,6 +175,11 @@ module Principles
|
|
|
175
175
|
kept ? AuditRecord.new(kept) : nil
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
+
# Whether it holds a completed audit other than written, a record just completed, so written is not the first
|
|
179
|
+
# to complete; a retry of written reads written back, so it is the first still.
|
|
180
|
+
#: (AuditRecord) -> bool
|
|
181
|
+
def completed_other_than?(written) = last_completed&.then { !it.same_as?(written) } || false
|
|
182
|
+
|
|
178
183
|
# This record with the member known by key moved to change's to_sha256, and change kept beside it.
|
|
179
184
|
# Nothing else changes: the map version, base commit and findings stay the audit's own.
|
|
180
185
|
# check_result is the result reported for the member's check, which replaces the one the record kept.
|
|
@@ -204,6 +209,11 @@ module Principles
|
|
|
204
209
|
#: () -> Array[String]
|
|
205
210
|
def open_ids = left_open.map(&:id)
|
|
206
211
|
|
|
212
|
+
# The ids of the findings it leaves open whose action is action, deferred or accepted, which a completed
|
|
213
|
+
# audit's result names apart.
|
|
214
|
+
#: (String) -> Array[String]
|
|
215
|
+
def left_open_ids(action) = left_open.select { it.action == action }.map(&:id)
|
|
216
|
+
|
|
207
217
|
# The ids of the findings it leaves open on the member known by key, which the next full audit decides beside
|
|
208
218
|
# it.
|
|
209
219
|
#: (String) -> Array[String]
|
|
@@ -155,9 +155,10 @@ module Principles
|
|
|
155
155
|
[file(record.principle_id), *record.cited_files(@history).committed_with(changed, reported)]
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
-
# Each file record cites that no longer exists, which files_to_commit leaves out
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
# Each file record cites that no longer exists, which files_to_commit leaves out, a plugin's file asked of
|
|
159
|
+
# plugins.
|
|
160
|
+
#: (AuditRecord, InstalledPlugins) -> Array[String]
|
|
161
|
+
def cited_files_missing(record, plugins) = record.cited_files(@history).missing(plugins)
|
|
161
162
|
|
|
162
163
|
# Writes record's file and names it, relative to the project.
|
|
163
164
|
#: (AuditRecord) -> String
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require_relative "assessment_report"
|
|
5
5
|
require_relative "json_digest"
|
|
6
6
|
require_relative "principle"
|
|
7
|
+
require_relative "stale_request"
|
|
7
8
|
|
|
8
9
|
module Principles
|
|
9
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -86,6 +87,14 @@ module Principles
|
|
|
86
87
|
#: (now: Hash[String, String]) -> Array[String]
|
|
87
88
|
def added(now:) = now.keys.reject { |id| began_with?(id) }
|
|
88
89
|
|
|
90
|
+
# Refuses an answer to this audit as stale once the text of a plugin member in now differs from the text the
|
|
91
|
+
# audit began with: an update to the installed plugin, which no fix can claim.
|
|
92
|
+
#: (now: Hash[String, String]) -> void
|
|
93
|
+
def check_plugin_members_unchanged(now:)
|
|
94
|
+
updated = changed(now:).select { @map.members.with_id(it)&.plugin_reference }
|
|
95
|
+
raise StaleRequest.plugin_updated(id, updated) if updated.any?
|
|
96
|
+
end
|
|
97
|
+
|
|
89
98
|
# The members whose hash in now differs from their hash when the audit began.
|
|
90
99
|
#: (now: Hash[String, String]) -> Array[String]
|
|
91
100
|
def changed(now:)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "locator"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# A new member's locator as its map stores it: its passage's opening without the indent it was quoted with, when
|
|
11
|
+
# that still names one place, so its id does not keep the spaces of a YAML key or a nested list item. The given
|
|
12
|
+
# opening contains the unindented one, so a lone occurrence of the unindented one is at the same place. A member
|
|
13
|
+
# already mapped keeps its locator, since its id is that locator and audit records file it under that id.
|
|
14
|
+
class AuthoredLocator
|
|
15
|
+
#: (Project, Locator) -> void
|
|
16
|
+
def initialize(project, locator)
|
|
17
|
+
@project = project
|
|
18
|
+
@locator = locator
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# The locator to store: the unindented one where it locates, else the one given.
|
|
23
|
+
#: () -> Locator
|
|
24
|
+
def stored
|
|
25
|
+
unindented = @locator.with_opening_unindented or return @locator
|
|
26
|
+
@project.locate_for_authoring(unindented)
|
|
27
|
+
unindented
|
|
28
|
+
rescue Error
|
|
29
|
+
@locator
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -50,9 +50,8 @@ module Principles
|
|
|
50
50
|
# name, which the budget cuts by.
|
|
51
51
|
#: (Array[Hash[String, untyped]]) -> Hash[String, CandidateOutline]
|
|
52
52
|
def outlines(test_data_hints)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(paths - test_data).to_h { |path| [path, CandidateOutline.new(@text_of.call(path))] }
|
|
53
|
+
outlined_paths(test_data_hints).to_h { |path| [path, outline_of(path)] }
|
|
54
|
+
.select { |path, outline| path.match?(MARKDOWN) || outline.sections.any? }
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
# Each Markdown or settings file, with its size, and a skill's entry file spelt otherwise than SKILL.md with its
|
|
@@ -76,6 +75,27 @@ module Principles
|
|
|
76
75
|
|
|
77
76
|
private
|
|
78
77
|
|
|
78
|
+
# The listed files the survey outlines: every one but those the test-data hints name.
|
|
79
|
+
#: (Array[Hash[String, untyped]]) -> Array[String]
|
|
80
|
+
def outlined_paths(test_data_hints)
|
|
81
|
+
test_data = hints(test_data_hints).map { |hint| hint.fetch("path") }
|
|
82
|
+
listed.map { |file| file.fetch("path") } - test_data
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The outline of one listed file, from its text: a Markdown file's by its headings and items, any other's by its
|
|
86
|
+
# comments.
|
|
87
|
+
#: (String) -> CandidateOutline
|
|
88
|
+
def outline_of(path) = CandidateOutline.new(@text_of.call(path), as: reader_for(path))
|
|
89
|
+
|
|
90
|
+
# What reads a file's outline: Markdown by its headings and items, a CI workflow by its jobs and steps, and any
|
|
91
|
+
# other text by its comments.
|
|
92
|
+
#: (String) -> (singleton(MarkdownText) | singleton(ScriptComments) | singleton(WorkflowJobs))
|
|
93
|
+
def reader_for(path)
|
|
94
|
+
return MarkdownText if path.match?(MARKDOWN)
|
|
95
|
+
|
|
96
|
+
path.match?(WorkflowJobs::PATH) ? WorkflowJobs : ScriptComments
|
|
97
|
+
end
|
|
98
|
+
|
|
79
99
|
# files with those changed names first, each marked changed_in_range, and the rest after, each in its order.
|
|
80
100
|
#: (Array[Hash[String, untyped]], Array[String]) -> Array[Hash[String, untyped]]
|
|
81
101
|
def changed_first(files, changed)
|