principles 0.0.7 → 0.0.8
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 +383 -0
- data/LICENSE +202 -0
- data/NOTICE +4 -0
- data/README.md +111 -0
- data/exe/principles +20 -0
- data/lib/principles/after_commit_hook_options.rb +2 -2
- data/lib/principles/cli.rb +50 -42
- data/lib/principles/command_line.rb +22 -16
- data/lib/principles/command_routes.rb +20 -6
- data/lib/principles/controllers/acknowledgement.rb +29 -74
- data/lib/principles/controllers/acknowledgements.rb +154 -0
- data/lib/principles/controllers/after_commit_report.rb +44 -0
- data/lib/principles/controllers/answer.rb +48 -18
- data/lib/principles/controllers/answer_phase.rb +20 -3
- data/lib/principles/controllers/assessment.rb +32 -11
- data/lib/principles/controllers/audit.rb +43 -19
- data/lib/principles/controllers/audit_completion.rb +21 -12
- data/lib/principles/controllers/command.rb +13 -12
- data/lib/principles/controllers/correction.rb +15 -7
- data/lib/principles/controllers/first_audit_brief.rb +40 -0
- data/lib/principles/controllers/full_audit_request.rb +41 -82
- data/lib/principles/controllers/hook_setup.rb +49 -0
- data/lib/principles/controllers/inventory.rb +10 -8
- data/lib/principles/controllers/mapping.rb +2 -2
- data/lib/principles/controllers/member_acknowledgement.rb +32 -21
- data/lib/principles/controllers/member_entries.rb +4 -4
- data/lib/principles/controllers/member_problems_report.rb +62 -16
- data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
- data/lib/principles/controllers/members_to_assess.rb +23 -20
- data/lib/principles/controllers/meta_principle_setup.rb +5 -6
- data/lib/principles/controllers/open_correction.rb +42 -0
- data/lib/principles/controllers/parts_to_read.rb +117 -0
- data/lib/principles/controllers/repoint.rb +1 -1
- data/lib/principles/controllers/running_tool.rb +56 -6
- data/lib/principles/controllers/session_start_report.rb +62 -0
- data/lib/principles/controllers/survey.rb +2 -2
- data/lib/principles/data/audit_files.rb +7 -7
- data/lib/principles/data/bounded_file.rb +1 -1
- data/lib/principles/data/candidate_files_found.rb +6 -3
- data/lib/principles/data/command-steps.json +61 -6
- data/lib/principles/data/expected_type.rb +3 -3
- data/lib/principles/data/first_parent_log.rb +1 -1
- data/lib/principles/data/head_reflog.rb +74 -0
- data/lib/principles/data/hook_input.rb +59 -0
- data/lib/principles/data/ignored_by_git.rb +2 -2
- data/lib/principles/data/known_fields.rb +1 -1
- data/lib/principles/data/linked_path.rb +1 -1
- data/lib/principles/data/map_files.rb +2 -2
- data/lib/principles/data/principles_on_path.rb +83 -0
- data/lib/principles/data/principles_subfolder.rb +1 -1
- data/lib/principles/data/project_files.rb +10 -3
- data/lib/principles/data/repository.rb +14 -7
- data/lib/principles/data/running_version.rb +10 -8
- data/lib/principles/data/schema_check.rb +5 -5
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -21
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
- data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
- data/lib/principles/data/schemas/audit-record.schema.json +29 -20
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +9 -9
- data/lib/principles/data/schemas/member-map.schema.json +3 -3
- data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
- data/lib/principles/error.rb +4 -4
- data/lib/principles/failure_refusal.rb +57 -0
- data/lib/principles/invocation_options.rb +4 -4
- data/lib/principles/launch.rb +49 -0
- data/lib/principles/list_open_findings_options.rb +1 -1
- data/lib/principles/models/accepted_loading.rb +2 -2
- data/lib/principles/models/acknowledged_check.rb +23 -11
- data/lib/principles/models/acknowledgement.rb +34 -18
- data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
- data/lib/principles/models/acknowledgement_refusal.rb +25 -10
- data/lib/principles/models/acknowledgements.rb +45 -29
- data/lib/principles/models/acknowledgements_across.rb +68 -0
- data/lib/principles/models/activation.rb +2 -2
- data/lib/principles/models/after_commit_input.rb +115 -0
- data/lib/principles/models/agent_loads.rb +1 -1
- data/lib/principles/models/answer_fields.rb +2 -2
- data/lib/principles/models/answer_place.rb +3 -3
- data/lib/principles/models/answer_text.rb +2 -2
- data/lib/principles/models/answered_time.rb +4 -4
- data/lib/principles/models/assessment_answer.rb +10 -10
- data/lib/principles/models/assessment_basis.rb +2 -2
- data/lib/principles/models/assessment_left_as_printed.rb +1 -1
- data/lib/principles/models/assessment_report.rb +6 -7
- data/lib/principles/models/audit.rb +33 -34
- data/lib/principles/models/audit_record.rb +54 -28
- data/lib/principles/models/audit_records.rb +13 -13
- data/lib/principles/models/audit_start.rb +3 -3
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +18 -10
- data/lib/principles/models/candidate_inventory.rb +6 -6
- data/lib/principles/models/candidate_outline.rb +9 -9
- data/lib/principles/models/carried_assessments.rb +18 -3
- data/lib/principles/models/carried_member.rb +5 -5
- data/lib/principles/models/changed_regions.rb +92 -0
- data/lib/principles/models/check_result_guide.rb +50 -0
- data/lib/principles/models/check_since_last_audit.rb +5 -4
- data/lib/principles/models/cited_files.rb +4 -4
- data/lib/principles/models/command_steps.rb +3 -3
- data/lib/principles/models/commits_brought_in.rb +1 -1
- data/lib/principles/models/commits_since_base.rb +1 -1
- data/lib/principles/models/correction_answer.rb +2 -2
- data/lib/principles/models/correction_basis.rb +7 -7
- data/lib/principles/models/dated_line.rb +1 -2
- data/lib/principles/models/decided_prior_findings.rb +6 -6
- data/lib/principles/models/declared_map_changes.rb +5 -5
- data/lib/principles/models/disposition.rb +21 -21
- data/lib/principles/models/entry_file.rb +1 -1
- data/lib/principles/models/entry_files.rb +1 -1
- data/lib/principles/models/evidence_item.rb +1 -1
- data/lib/principles/models/evidence_lines_since.rb +2 -2
- data/lib/principles/models/evidence_replacements.rb +3 -3
- data/lib/principles/models/finding_write_ups.rb +12 -5
- data/lib/principles/models/findings_left_open.rb +4 -4
- data/lib/principles/models/first_full_audit.rb +32 -0
- data/lib/principles/models/first_raised_claim.rb +1 -1
- data/lib/principles/models/fix_only_fields.rb +1 -1
- data/lib/principles/models/head_moves.rb +66 -0
- data/lib/principles/models/hook_commands.rb +49 -4
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +2 -3
- data/lib/principles/models/json_digest.rb +2 -2
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/kept_prior_finding.rb +9 -9
- data/lib/principles/models/last_completed_revision.rb +4 -5
- data/lib/principles/models/left_as_printed.rb +2 -2
- data/lib/principles/models/line_diff.rb +113 -0
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/list_member_problems_check.rb +4 -4
- data/lib/principles/models/listed_members.rb +7 -9
- data/lib/principles/models/loaded_files.rb +4 -5
- data/lib/principles/models/loading_decision.rb +3 -3
- data/lib/principles/models/loading_facts.rb +1 -1
- data/lib/principles/models/loads_to_check.rb +1 -1
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/mapped_principles.rb +2 -2
- data/lib/principles/models/member.rb +31 -4
- data/lib/principles/models/member_assessments.rb +8 -8
- data/lib/principles/models/member_elsewhere.rb +4 -4
- data/lib/principles/models/member_file.rb +4 -4
- data/lib/principles/models/member_grounds.rb +1 -1
- data/lib/principles/models/member_hashes_as_written.rb +1 -1
- data/lib/principles/models/member_lines.rb +29 -61
- data/lib/principles/models/member_loads.rb +2 -2
- data/lib/principles/models/member_moves.rb +1 -1
- data/lib/principles/models/member_problems.rb +14 -15
- data/lib/principles/models/member_repair_moves.rb +15 -9
- data/lib/principles/models/member_sighting.rb +10 -10
- data/lib/principles/models/member_snapshots.rb +1 -1
- data/lib/principles/models/member_state.rb +1 -1
- data/lib/principles/models/members_across_principles.rb +77 -0
- data/lib/principles/models/members_elsewhere.rb +2 -2
- data/lib/principles/models/members_sharing_lines.rb +7 -7
- data/lib/principles/models/meta_principle.rb +11 -4
- data/lib/principles/models/missing_files.rb +3 -3
- data/lib/principles/models/new_findings.rb +4 -4
- data/lib/principles/models/open_correction.rb +57 -0
- data/lib/principles/models/open_finding.rb +36 -31
- data/lib/principles/models/open_findings_elsewhere.rb +2 -2
- data/lib/principles/models/other_principles.rb +2 -2
- data/lib/principles/models/other_templates_placeholders.rb +17 -16
- data/lib/principles/models/outline_budget.rb +7 -7
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +2 -2
- data/lib/principles/models/part_named.rb +41 -0
- data/lib/principles/models/placement.rb +2 -2
- data/lib/principles/models/principle.rb +13 -13
- data/lib/principles/models/principle_history.rb +8 -8
- data/lib/principles/models/principle_members.rb +14 -7
- data/lib/principles/models/principles_folder_move.rb +1 -1
- data/lib/principles/models/principles_on_path.rb +29 -0
- data/lib/principles/models/principles_package.rb +3 -3
- data/lib/principles/models/prior_decision_fields.rb +8 -8
- data/lib/principles/models/prior_finding_decision.rb +8 -8
- data/lib/principles/models/prior_finding_outcomes.rb +1 -1
- data/lib/principles/models/prior_findings.rb +5 -5
- data/lib/principles/models/problem_report.rb +26 -8
- data/lib/principles/models/project.rb +27 -19
- data/lib/principles/models/project_history.rb +18 -12
- data/lib/principles/models/quoted_change.rb +8 -8
- data/lib/principles/models/recent_decision.rb +3 -3
- data/lib/principles/models/record_format.rb +16 -10
- data/lib/principles/models/record_judged_against.rb +4 -4
- data/lib/principles/models/recorded_entry.rb +17 -8
- data/lib/principles/models/recorded_finding.rb +9 -9
- data/lib/principles/models/recorded_findings.rb +2 -2
- data/lib/principles/models/recorded_hashes.rb +2 -2
- data/lib/principles/models/recorded_members.rb +13 -13
- data/lib/principles/models/refusal_before_shape.rb +2 -2
- data/lib/principles/models/repoint.rb +3 -3
- data/lib/principles/models/report_hooks.rb +69 -0
- data/lib/principles/models/reported_check.rb +34 -31
- data/lib/principles/models/request_id.rb +18 -6
- data/lib/principles/models/runs_from.rb +7 -2
- data/lib/principles/models/sent_answer.rb +14 -12
- data/lib/principles/models/sent_prior_decisions.rb +1 -1
- data/lib/principles/models/session_start_input.rb +37 -0
- data/lib/principles/models/shape_problems_beside.rb +1 -1
- data/lib/principles/models/skill_loads.rb +1 -1
- data/lib/principles/models/stale_request.rb +59 -0
- data/lib/principles/models/still_holds_restatement.rb +6 -6
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/template_placeholders.rb +6 -6
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/tracked_paths.rb +38 -0
- data/lib/principles/models/unchecked_members.rb +2 -2
- data/lib/principles/models/uncommitted_files.rb +1 -1
- data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
- data/lib/principles/models/waits_on.rb +1 -1
- data/lib/principles/models/write_up_opening.rb +5 -5
- data/lib/principles/models/write_up_pointer.rb +3 -3
- data/lib/principles/models/write_up_repoint.rb +2 -3
- data/lib/principles/positional_arguments.rb +13 -6
- data/lib/principles/prose_list.rb +1 -1
- data/lib/principles/session_start_options.rb +1 -1
- data/lib/principles/start_audit_options.rb +46 -12
- data/lib/principles/supported_ruby.rb +24 -7
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +97 -11
- data/lib/principles/views/activation_in_hand.rb +1 -1
- data/lib/principles/views/answered_request.rb +6 -2
- data/lib/principles/views/assessed_members.rb +50 -41
- data/lib/principles/views/assessment_request.rb +39 -36
- data/lib/principles/views/audit_changes.rb +4 -4
- data/lib/principles/views/audit_commit.rb +5 -4
- data/lib/principles/views/audit_result.rb +92 -53
- data/lib/principles/views/candidate_files_result.rb +7 -6
- data/lib/principles/views/check_notes.rb +29 -6
- data/lib/principles/views/check_result_template.rb +45 -34
- data/lib/principles/views/completed_audit_next_step.rb +44 -0
- data/lib/principles/views/context_parts.rb +112 -0
- data/lib/principles/views/correction_request.rb +44 -25
- data/lib/principles/views/diff_since_last_audit.rb +8 -6
- data/lib/principles/views/findings_result.rb +17 -6
- data/lib/principles/views/first_audit_brief.rb +51 -0
- data/lib/principles/views/first_audit_line.rb +45 -0
- data/lib/principles/views/help.rb +4 -4
- data/lib/principles/views/hook_setup_result.rb +91 -0
- data/lib/principles/views/instruction.rb +3 -3
- data/lib/principles/views/invocation.rb +14 -6
- data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
- data/lib/principles/views/landed_since_base.rb +1 -1
- data/lib/principles/views/line_history_since_last_audit.rb +35 -0
- data/lib/principles/views/lines_shared_with_member.rb +6 -6
- data/lib/principles/views/loads_to_check_result.rb +8 -5
- data/lib/principles/views/map_added_to.rb +3 -3
- data/lib/principles/views/map_result.rb +9 -9
- data/lib/principles/views/member_change_since_baseline.rb +44 -23
- data/lib/principles/views/member_lines_beside_text.rb +43 -0
- data/lib/principles/views/member_repairs.rb +3 -2
- data/lib/principles/views/member_row.rb +2 -2
- data/lib/principles/views/members_a_commit_changed.rb +13 -10
- data/lib/principles/views/members_with_no_baseline.rb +3 -3
- data/lib/principles/views/meta_principle_passage.rb +1 -1
- data/lib/principles/views/meta_principle_result.rb +12 -5
- data/lib/principles/views/one_member_check_result_template.rb +7 -7
- data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
- data/lib/principles/views/open_findings_line.rb +25 -36
- data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
- data/lib/principles/views/outside_the_map_result.rb +5 -2
- data/lib/principles/views/package_since_last_audit_result.rb +29 -6
- data/lib/principles/views/parts_index_result.rb +60 -0
- data/lib/principles/views/principle_read_result.rb +5 -6
- data/lib/principles/views/principle_with_changed_members.rb +1 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
- data/lib/principles/views/printed_json.rb +51 -0
- data/lib/principles/views/printed_principle.rb +1 -1
- data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
- data/lib/principles/views/prior_findings_result.rb +17 -14
- data/lib/principles/views/problem_lines.rb +39 -17
- data/lib/principles/views/problem_result.rb +40 -37
- data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
- data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
- data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +20 -18
- data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +21 -22
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
- data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -1
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
- data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
- data/lib/principles/views/prompts.rb +1 -1
- data/lib/principles/views/read_the_change.rb +36 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
- data/lib/principles/views/repoint_result.rb +1 -1
- data/lib/principles/views/report_hooks_offer.rb +25 -0
- data/lib/principles/views/request_part.rb +5 -5
- data/lib/principles/views/request_parts.rb +1 -1
- data/lib/principles/views/session_start_report.rb +46 -0
- data/lib/principles/views/shell_word.rb +1 -1
- data/lib/principles/views/trimmed_instructions_note.rb +30 -0
- data/lib/principles/views/visible_text.rb +1 -1
- data/lib/principles/views/workflow_diagram.rb +1 -1
- data/principles.gemspec +44 -0
- metadata +83 -14
- data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
- data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
|
@@ -10,6 +10,11 @@ require_relative "controllers/meta_principle_setup"
|
|
|
10
10
|
require_relative "controllers/member_entries"
|
|
11
11
|
require_relative "controllers/audit"
|
|
12
12
|
require_relative "controllers/answer"
|
|
13
|
+
require_relative "controllers/open_correction"
|
|
14
|
+
require_relative "controllers/first_audit_brief"
|
|
15
|
+
require_relative "controllers/session_start_report"
|
|
16
|
+
require_relative "controllers/after_commit_report"
|
|
17
|
+
require_relative "controllers/hook_setup"
|
|
13
18
|
|
|
14
19
|
module Principles
|
|
15
20
|
# Every command this tool runs, each with its route: the positional words it takes, which CommandLine parses, and
|
|
@@ -21,13 +26,17 @@ module Principles
|
|
|
21
26
|
attr_reader :positional
|
|
22
27
|
#: singleton(Controllers::Command)
|
|
23
28
|
attr_reader :controller
|
|
29
|
+
# Whether the command reads a hook's JSON on stdin, as a host passes it to the hook that runs it.
|
|
30
|
+
#: bool
|
|
31
|
+
attr_reader :reads_hook_input
|
|
24
32
|
|
|
25
|
-
# positional names each positional argument in order, a trailing ? marking one the command may leave out
|
|
26
|
-
# rest are named options.
|
|
27
|
-
#: (singleton(Controllers::Command), Array[String]) -> void
|
|
28
|
-
def initialize(controller, positional)
|
|
33
|
+
# positional names each positional argument in order, a trailing ? marking one the command may leave out, and a
|
|
34
|
+
# last NAME... or NAME?... one taking every value from its place on; the rest are named options.
|
|
35
|
+
#: (singleton(Controllers::Command), Array[String], ?reads_hook_input: bool) -> void
|
|
36
|
+
def initialize(controller, positional, reads_hook_input: false)
|
|
29
37
|
@controller = controller
|
|
30
38
|
@positional = positional.freeze #: Array[String]
|
|
39
|
+
@reads_hook_input = reads_hook_input
|
|
31
40
|
freeze
|
|
32
41
|
end
|
|
33
42
|
end
|
|
@@ -53,9 +62,14 @@ module Principles
|
|
|
53
62
|
"change-member-check" => Route.new(Controllers::MemberEntries, %w[id member]),
|
|
54
63
|
"remove-member-check" => Route.new(Controllers::MemberEntries, %w[id member]),
|
|
55
64
|
"remove-member" => Route.new(Controllers::MemberEntries, %w[id member]),
|
|
56
|
-
"start-audit" => Route.new(Controllers::Audit, %w[id]),
|
|
65
|
+
"start-audit" => Route.new(Controllers::Audit, %w[id other_ids?...]),
|
|
57
66
|
"submit-answer" => Route.new(Controllers::Answer, %w[request_id?]),
|
|
58
|
-
"show-answer-check" => Route.new(Controllers::Answer, %w[request_id?])
|
|
67
|
+
"show-answer-check" => Route.new(Controllers::Answer, %w[request_id?]),
|
|
68
|
+
"show-open-correction" => Route.new(Controllers::OpenCorrection, %w[id]),
|
|
69
|
+
"show-first-audit-brief" => Route.new(Controllers::FirstAuditBrief, %w[id?]),
|
|
70
|
+
"show-hook-setup" => Route.new(Controllers::HookSetup, []),
|
|
71
|
+
"report-at-session-start" => Route.new(Controllers::SessionStartReport, [], reads_hook_input: true),
|
|
72
|
+
"report-after-commit" => Route.new(Controllers::AfterCommitReport, [], reads_hook_input: true)
|
|
59
73
|
}.freeze #: Hash[String, Route]
|
|
60
74
|
|
|
61
75
|
# Each command's positional arguments, in order, as CommandLine takes them.
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
require "time"
|
|
5
5
|
require_relative "answer_phase"
|
|
6
|
+
require_relative "../prose_list"
|
|
6
7
|
require_relative "member_acknowledgement"
|
|
7
8
|
require_relative "../models/acknowledgement"
|
|
8
|
-
require_relative "../models/acknowledgements"
|
|
9
9
|
require_relative "../models/reported_check"
|
|
10
10
|
require_relative "../views/acknowledgement_result"
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ module Principles
|
|
|
13
13
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
14
14
|
# controllers/CLAUDE.md owns the boundary.
|
|
15
15
|
module Controllers
|
|
16
|
-
# A one-member audit
|
|
16
|
+
# A one-member audit: start-audit ID --member MEMBER asks whether a committed change keeps that member's
|
|
17
17
|
# meaning, and submit-answer moves its baseline in the audit record when the answer holds.
|
|
18
18
|
class Acknowledgement < AnswerPhase
|
|
19
19
|
# The request for principle id's member.
|
|
@@ -26,8 +26,7 @@ module Principles
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
# The answer alone, as start-audit --member --as template prints it, to fill and submit under the request's id
|
|
30
|
-
# (#773).
|
|
29
|
+
# The answer alone, as start-audit --member --as template prints it, to fill and submit under the request's id.
|
|
31
30
|
#: (String, String) -> Hash[String, untyped]
|
|
32
31
|
def to_fill(id, member_id)
|
|
33
32
|
naming_the_executable(rerun: one_member_audit(id)) do
|
|
@@ -36,45 +35,38 @@ module Principles
|
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
# The request for several of principle id's members in one answer (#1169), or with to_fill its answer alone:
|
|
40
|
-
# each member as its own request shows it.
|
|
41
|
-
#: (String, Array[String], to_fill: bool) -> Hash[String, untyped]
|
|
42
|
-
def several(id, member_ids, to_fill:)
|
|
43
|
-
naming_the_executable(rerun: one_member_audit(id)) do
|
|
44
|
-
members = member_ids.map { of(id, it) }
|
|
45
|
-
request_id = several_of(id, members).request_id.to_s
|
|
46
|
-
asked = members.map(&:asked)
|
|
47
|
-
next view.several_to_fill(request_id:, members: asked) if to_fill
|
|
48
|
-
|
|
49
|
-
view.several_request(request_id:, principle_id: id, members: asked).merge("wrote" => [])
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
38
|
# The result of answering, and the record it changes, not yet written.
|
|
54
39
|
# @override
|
|
55
40
|
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
56
41
|
def answered(submitted)
|
|
57
|
-
return several_answered(submitted) if submitted.request_id.phase == Models::Acknowledgements::PHASE
|
|
58
|
-
|
|
59
42
|
id = submitted.request_id.principle_id
|
|
60
43
|
member = answering(submitted)
|
|
61
44
|
[view.acknowledged(principle_id: id, member_id: member.member.id, file: @audit_records.file(id)),
|
|
62
|
-
[
|
|
45
|
+
[accepted(member, submitted.response)]]
|
|
63
46
|
end
|
|
64
47
|
|
|
65
48
|
# The refusals an answer meets before its shape: any phase's, then a placeholder its template printed left in,
|
|
66
|
-
# which the shape would refuse in meaning_kept without naming it
|
|
67
|
-
# with a repair this template does not take
|
|
49
|
+
# which the shape would refuse in meaning_kept without naming it, or in a checked member's exit_status
|
|
50
|
+
# with a repair this template does not take.
|
|
68
51
|
#: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
|
|
69
|
-
def before_shape(request_id)
|
|
70
|
-
left = Models::Acknowledgement::LEFT_AS_PRINTED
|
|
71
|
-
[*super, request_id.phase == Models::Acknowledgements::PHASE ? left.in_each_member : left]
|
|
72
|
-
end
|
|
52
|
+
def before_shape(request_id) = [*super, left_as_printed]
|
|
73
53
|
|
|
74
54
|
private
|
|
75
55
|
|
|
56
|
+
# The record with member's baseline moved by its entry in response, a refusal of a field in the entry pointing
|
|
57
|
+
# at it there.
|
|
58
|
+
#: (MemberAcknowledgement, untyped) -> Models::AuditRecord
|
|
59
|
+
def accepted(member, response)
|
|
60
|
+
entry = member.acknowledgement.entry_in(response)
|
|
61
|
+
Models::Acknowledgements.in_entry(member.member.id) { member.accepted(entry, at: Time.now.utc.iso8601) }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# The fields an answer may leave as its template printed them, read before its shape.
|
|
65
|
+
#: () -> Models::AcknowledgementLeftAsPrinted
|
|
66
|
+
def left_as_printed = Models::Acknowledgement::LEFT_AS_PRINTED
|
|
67
|
+
|
|
76
68
|
# The placeholders a one-member audit's template prints, which its answer may leave as printed: its own, and
|
|
77
|
-
# check_result's for a check the last audit ran, the only check it acknowledges
|
|
69
|
+
# check_result's for a check the last audit ran, the only check it acknowledges. The member is in the
|
|
78
70
|
# answer, not the request id, so this names the check's whether the member has one.
|
|
79
71
|
# @override
|
|
80
72
|
#: (Models::RequestId) -> Hash[String, untyped]?
|
|
@@ -83,7 +75,7 @@ module Principles
|
|
|
83
75
|
.merge("exit_status" => Models::Acknowledgement::EXIT_STATUS_PLACEHOLDER))
|
|
84
76
|
end
|
|
85
77
|
|
|
86
|
-
# The one-member audit of principle id's member, as a refusal naming a near miss leads its repair with
|
|
78
|
+
# The one-member audit of principle id's member, as a refusal naming a near miss leads its repair with.
|
|
87
79
|
#: (String) -> ^(String) -> String
|
|
88
80
|
def one_member_audit(id)
|
|
89
81
|
->(member) { invocation.in_project("start-audit", id, options: ["--member", member]) }
|
|
@@ -93,61 +85,24 @@ module Principles
|
|
|
93
85
|
#: (Models::SubmittedAnswer) -> MemberAcknowledgement
|
|
94
86
|
def answering(submitted)
|
|
95
87
|
id = submitted.request_id.principle_id
|
|
96
|
-
member = of(id, submitted.response.fetch("basis").fetch("
|
|
88
|
+
member = of(id, submitted.response.fetch("basis").fetch("member_ids").first)
|
|
97
89
|
stale(id, member.member.id) unless member.acknowledgement.request_id == submitted.request_id
|
|
98
90
|
member
|
|
99
91
|
end
|
|
100
92
|
|
|
101
|
-
# The result of answering a request for several members, and the one record their acknowledgements change.
|
|
102
|
-
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
103
|
-
def several_answered(submitted)
|
|
104
|
-
id = submitted.request_id.principle_id
|
|
105
|
-
several, members = answering_several(submitted)
|
|
106
|
-
[view.several_acknowledged(principle_id: id, member_ids: members.map { it.member.id },
|
|
107
|
-
file: @audit_records.file(id)),
|
|
108
|
-
[all_accepted(several, members, submitted.response)]]
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
# The members the answer acknowledges, refused as stale unless their request is still the one it answers.
|
|
112
|
-
#: (Models::SubmittedAnswer) -> [Models::Acknowledgements, Array[MemberAcknowledgement]]
|
|
113
|
-
def answering_several(submitted)
|
|
114
|
-
id = submitted.request_id.principle_id
|
|
115
|
-
members = submitted.response.fetch("basis").fetch("member_ids").map { of(id, it) }
|
|
116
|
-
several = several_of(id, members)
|
|
117
|
-
stale(id, members.map { it.member.id }) unless several.request_id == submitted.request_id
|
|
118
|
-
[several, members]
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# The record with each member's acknowledgement in it, once the answer holds for every one of them.
|
|
122
|
-
#: (Models::Acknowledgements, Array[MemberAcknowledgement], untyped) -> Models::AuditRecord
|
|
123
|
-
def all_accepted(several, members, response)
|
|
124
|
-
at = Time.now.utc.iso8601
|
|
125
|
-
by_id = members.to_h { [it.member.id, it] }
|
|
126
|
-
acknowledging = by_id.keys
|
|
127
|
-
several.accepted(response) do |member_id, entry, into|
|
|
128
|
-
by_id.fetch(member_id).accepted(entry, at:, acknowledging:, into:)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# The acknowledgements of several of principle id's members, each under its member's id, in one request.
|
|
133
|
-
#: (String, Array[MemberAcknowledgement]) -> Models::Acknowledgements
|
|
134
|
-
def several_of(id, members)
|
|
135
|
-
named = members.map { [it.member.id, it.acknowledgement.request_id] }
|
|
136
|
-
Models::Acknowledgements.of(principle_id: id, members: named)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
93
|
# principle_id's member member_id, as its one-member audit asks and answers it.
|
|
140
94
|
#: (String, String) -> MemberAcknowledgement
|
|
141
95
|
def of(id, member_id) = handed(MemberAcknowledgement, principle_id: id, member_id:)
|
|
142
96
|
|
|
143
|
-
# Refuses an answer to a request that no longer matches the project, naming the request for the same
|
|
144
|
-
|
|
145
|
-
|
|
97
|
+
# Refuses an answer to a request that no longer matches the project, naming the request for the same principles
|
|
98
|
+
# and members.
|
|
99
|
+
#: (String | Array[String], String | Array[String]) -> bot
|
|
100
|
+
def stale(ids, member_ids)
|
|
146
101
|
options = Array(member_ids).flat_map { ["--member", it] }
|
|
147
|
-
raise Error.new("stale_request", "This request no longer matches #{
|
|
148
|
-
"commit it was based on has changed since it was printed",
|
|
102
|
+
raise Error.new("stale_request", "This request no longer matches #{ProseList.new(Array(ids))}: the member, " \
|
|
103
|
+
"its baseline or the commit it was based on has changed since it was printed",
|
|
149
104
|
"Start it again and answer the new request: " \
|
|
150
|
-
"#{invocation.
|
|
105
|
+
"#{invocation.listed_in_project("start-audit", Array(ids), options:)}")
|
|
151
106
|
end
|
|
152
107
|
|
|
153
108
|
#: () -> Views::AcknowledgementResult
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "time"
|
|
5
|
+
require_relative "acknowledgement"
|
|
6
|
+
require_relative "../models/acknowledgements"
|
|
7
|
+
require_relative "../models/acknowledgements_across"
|
|
8
|
+
require_relative "../models/members_across_principles"
|
|
9
|
+
|
|
10
|
+
module Principles
|
|
11
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
12
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
13
|
+
module Controllers
|
|
14
|
+
# Several members acknowledged in one request and one answer: start-audit ID with --member given more
|
|
15
|
+
# than once asks about each as its own one-member audit would, and submit-answer moves every baseline or none.
|
|
16
|
+
class Acknowledgements < Acknowledgement
|
|
17
|
+
# The request for several of principle id's members in one answer, or with to_fill its answer alone:
|
|
18
|
+
# each member as its own request shows it.
|
|
19
|
+
#: (String, Array[String], to_fill: bool) -> Hash[String, untyped]
|
|
20
|
+
def several(id, member_ids, to_fill:)
|
|
21
|
+
naming_the_executable(rerun: one_member_audit(id)) do
|
|
22
|
+
members = member_ids.map { of(id, it) }
|
|
23
|
+
request_id = several_of(id, members).request_id.to_s
|
|
24
|
+
asked = members.map(&:asked)
|
|
25
|
+
next view.several_to_fill(request_id:, members: asked) if to_fill
|
|
26
|
+
|
|
27
|
+
view.several_request(request_id:, principle_id: id, members: asked).merge("wrote" => [])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# The request for the members several principles map, each principle acknowledging those of member_ids it maps,
|
|
32
|
+
# in one answer judging each member once, or with to_fill its answer alone.
|
|
33
|
+
#: (Array[String], Array[String], to_fill: bool) -> Hash[String, untyped]
|
|
34
|
+
def across(ids, member_ids, to_fill:)
|
|
35
|
+
naming_the_executable(rerun: across_audit(ids, member_ids)) do
|
|
36
|
+
by_principle = members_by_principle(ids, member_ids)
|
|
37
|
+
request_id = across_of(by_principle).request_id.to_s
|
|
38
|
+
principles = by_principle.transform_values { it.map(&:asked) }
|
|
39
|
+
next view.across_to_fill(request_id:, principles:) if to_fill
|
|
40
|
+
|
|
41
|
+
view.across_request(request_id:, principles:, keeping_deferred: keeping_deferred(by_principle))
|
|
42
|
+
.merge("wrote" => [])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The result of answering a request for several members, and the one record their acknowledgements change.
|
|
47
|
+
# @override
|
|
48
|
+
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
49
|
+
def answered(submitted)
|
|
50
|
+
return across_answered(submitted) if submitted.response.fetch("basis").key?("principle_ids")
|
|
51
|
+
|
|
52
|
+
id = submitted.request_id.principle_id
|
|
53
|
+
several, members = answering_several(submitted)
|
|
54
|
+
[view.several_acknowledged(principle_id: id, member_ids: members.map { it.member.id },
|
|
55
|
+
file: @audit_records.file(id)),
|
|
56
|
+
[all_accepted(several, members, submitted.response)]]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
# The principles in by_principle with a member whose acknowledgement keeps a deferred finding.
|
|
62
|
+
#: (Hash[String, Array[MemberAcknowledgement]]) -> Array[String]
|
|
63
|
+
def keeping_deferred(by_principle)
|
|
64
|
+
by_principle.select { |_, members| members.any? { it.acknowledgement.keeps_deferred_findings? } }.keys
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# The result of answering a request for the members several principles map, and each principle's record, which
|
|
68
|
+
# are written only once every one of them is accepted.
|
|
69
|
+
#: (Models::SubmittedAnswer) -> [Views::AnsweredRequest, Array[Models::AuditRecord]]
|
|
70
|
+
def across_answered(submitted)
|
|
71
|
+
across, by_principle = answering_across(submitted.response.fetch("basis"), submitted.request_id)
|
|
72
|
+
records = across.accepted(submitted.response) do |id, several, answer|
|
|
73
|
+
all_accepted(several, by_principle.fetch(id), answer, acknowledging: across.acknowledging)
|
|
74
|
+
end
|
|
75
|
+
[view.across_acknowledged(member_ids: across.member_ids,
|
|
76
|
+
files: by_principle.keys.to_h { [it, @audit_records.file(it)] }), records]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# The members each principle basis names maps, refused when a later copy wrote any of their records, or as stale
|
|
80
|
+
# unless their request is still the one request_id names.
|
|
81
|
+
#: (Hash[String, untyped], Models::RequestId)
|
|
82
|
+
#| -> [Models::AcknowledgementsAcross, Hash[String, Array[MemberAcknowledgement]]]
|
|
83
|
+
def answering_across(basis, request_id)
|
|
84
|
+
ids = basis.fetch("principle_ids")
|
|
85
|
+
ids.each { @audit_records.refuse_newer(it, version: @tool.version) }
|
|
86
|
+
by_principle = members_by_principle(ids, basis.fetch("member_ids"))
|
|
87
|
+
across = across_of(by_principle)
|
|
88
|
+
stale(ids, basis.fetch("member_ids")) unless across.request_id == request_id
|
|
89
|
+
[across, by_principle]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# The members the answer acknowledges, refused as stale unless their request is still the one it answers.
|
|
93
|
+
#: (Models::SubmittedAnswer) -> [Models::Acknowledgements, Array[MemberAcknowledgement]]
|
|
94
|
+
def answering_several(submitted)
|
|
95
|
+
id = submitted.request_id.principle_id
|
|
96
|
+
members = submitted.response.fetch("basis").fetch("member_ids").map { of(id, it) }
|
|
97
|
+
several = several_of(id, members)
|
|
98
|
+
stale(id, members.map { it.member.id }) unless several.request_id == submitted.request_id
|
|
99
|
+
[several, members]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# The record with each member's acknowledgement in it, once the answer holds for every one of them.
|
|
103
|
+
# acknowledging is the members the whole answer acknowledges, each as its principle id and member id, which a
|
|
104
|
+
# member's own list-member-problems check may list: several's own unless the answer is across principles.
|
|
105
|
+
#: (Models::Acknowledgements, Array[MemberAcknowledgement], untyped, ?acknowledging: Array[[String, String]])
|
|
106
|
+
#| -> Models::AuditRecord
|
|
107
|
+
def all_accepted(several, members, response, acknowledging: several.acknowledging)
|
|
108
|
+
at = Time.now.utc.iso8601
|
|
109
|
+
by_id = members.to_h { [it.member.id, it] }
|
|
110
|
+
several.accepted(response) do |member_id, entry, into|
|
|
111
|
+
by_id.fetch(member_id).accepted(entry, at:, acknowledging:, into:)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# The acknowledgements of the members each principle maps, under its id, in one request.
|
|
116
|
+
#: (Hash[String, Array[MemberAcknowledgement]]) -> Models::AcknowledgementsAcross
|
|
117
|
+
def across_of(by_principle)
|
|
118
|
+
checked = by_principle.transform_values { |members| members.select { it.member.check }.map { it.member.id } }
|
|
119
|
+
Models::AcknowledgementsAcross.new(by_principle.to_h { |id, members| [id, several_of(id, members)] }, checked:)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Each of the principles ids names, in id order, with those of member_ids it maps, as MembersAcrossPrinciples
|
|
123
|
+
# refuses them.
|
|
124
|
+
#: (Array[String], Array[String]) -> Hash[String, Array[MemberAcknowledgement]]
|
|
125
|
+
def members_by_principle(ids, member_ids)
|
|
126
|
+
mapped_across(ids, member_ids).by_principle.to_h { |id, mapped| [id, mapped.map { of(id, it) }] }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# The request across principles ids for member_ids, with the first member none of them maps replaced by member,
|
|
130
|
+
# as a refusal naming a near miss leads its repair with.
|
|
131
|
+
#: (Array[String], Array[String]) -> ^(String) -> String
|
|
132
|
+
def across_audit(ids, member_ids)
|
|
133
|
+
lambda do |member|
|
|
134
|
+
missing = mapped_across(ids, member_ids).unmapped
|
|
135
|
+
named = member_ids.map { it == missing ? member : it }
|
|
136
|
+
invocation.listed_in_project("start-audit", ids.uniq.sort, options: named.flat_map { ["--member", it] })
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# member_ids as the principles ids names map them.
|
|
141
|
+
#: (Array[String], Array[String]) -> Models::MembersAcrossPrinciples
|
|
142
|
+
def mapped_across(ids, member_ids)
|
|
143
|
+
Models::MembersAcrossPrinciples.new(ids.map { @principles.find(it) }, member_ids)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# The acknowledgements of several of principle id's members, each under its member's id, in one request.
|
|
147
|
+
#: (String, Array[MemberAcknowledgement]) -> Models::Acknowledgements
|
|
148
|
+
def several_of(id, members)
|
|
149
|
+
named = members.map { [it.member.id, it.acknowledgement.request_id] }
|
|
150
|
+
Models::Acknowledgements.of(principle_id: id, members: named)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "member_problems_report"
|
|
6
|
+
require_relative "../models/after_commit_input"
|
|
7
|
+
require_relative "../models/head_moves"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
11
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
12
|
+
module Controllers
|
|
13
|
+
# report-after-commit, which a hook runs after each shell call: for the first repository the call committed in,
|
|
14
|
+
# in the order Models::HeadMoves names them, whose commits changed a mapped member, the hook's JSON naming them,
|
|
15
|
+
# as list-member-problems --commits-after prints it; or nothing. It exits 0 whatever it finds.
|
|
16
|
+
class AfterCommitReport < Command
|
|
17
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
18
|
+
def call(command, _id, options)
|
|
19
|
+
naming_the_executable do
|
|
20
|
+
unknown(command) unless command == "report-after-commit"
|
|
21
|
+
|
|
22
|
+
input = Models::AfterCommitInput.read(options["stdin"].to_s, ENV.to_h, clock: Time.now.to_i, home: Dir.home,
|
|
23
|
+
pwd: Dir.pwd)
|
|
24
|
+
event = input.event
|
|
25
|
+
event ? reported(event, Models::HeadMoves.new(input).to_a) : Views::MembersACommitChanged::NOTHING
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# The first output naming a changed member, run for event on each move in turn.
|
|
32
|
+
#: (String, Array[Models::HeadMoves::Move]) -> Views::Lines
|
|
33
|
+
def reported(event, moves)
|
|
34
|
+
moves.each do |move|
|
|
35
|
+
lines = MemberProblemsReport.new(Models::Project.at(move.root), tool: @tool)
|
|
36
|
+
.call("list-member-problems", nil,
|
|
37
|
+
{ "hook_event" => event, "commits_after" => move.before })
|
|
38
|
+
return lines unless lines.stdout.empty?
|
|
39
|
+
end
|
|
40
|
+
Views::MembersACommitChanged::NOTHING
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -6,6 +6,7 @@ require_relative "../models/finding_write_ups"
|
|
|
6
6
|
require_relative "../models/request_id"
|
|
7
7
|
require_relative "../models/submitted_answer"
|
|
8
8
|
require_relative "acknowledgement"
|
|
9
|
+
require_relative "acknowledgements"
|
|
9
10
|
require_relative "correction"
|
|
10
11
|
require_relative "repoint"
|
|
11
12
|
require_relative "assessment"
|
|
@@ -16,20 +17,23 @@ module Principles
|
|
|
16
17
|
module Controllers
|
|
17
18
|
# Answering an audit's requests: this tool checks the answer against the project's files and, when the
|
|
18
19
|
# audit completes, writes the committed audit record. Nothing else is stored: each request id is a
|
|
19
|
-
# digest of what the request depends on, so an answer is checked against the project as it is now
|
|
20
|
+
# digest of what the request depends on, so an answer is checked against the project as it is now.
|
|
20
21
|
class Answer < Command
|
|
21
22
|
# The controller that answers for each phase a request id may name.
|
|
22
23
|
PHASE_CONTROLLERS = {
|
|
23
24
|
"assessment" => Assessment, "correction" => Correction, "acknowledgement" => Acknowledgement,
|
|
24
|
-
"acknowledgements" =>
|
|
25
|
+
"acknowledgements" => Acknowledgements, "repointing" => Repoint
|
|
25
26
|
}.freeze #: Hash[String, Class[AnswerPhase]]
|
|
26
27
|
|
|
27
28
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
28
29
|
def call(command, _id, options)
|
|
29
30
|
naming_the_executable do
|
|
30
31
|
case command
|
|
31
|
-
when "submit-answer" then submit_answer(submitted(options)
|
|
32
|
-
when "show-answer-check"
|
|
32
|
+
when "submit-answer" then submit_answer(submitted(options))
|
|
33
|
+
when "show-answer-check"
|
|
34
|
+
next correction_to_fill(submitted(options)) if options["as"]
|
|
35
|
+
|
|
36
|
+
check_answer(submitted(options), options.fetch("file"))
|
|
33
37
|
else unknown(command)
|
|
34
38
|
end
|
|
35
39
|
end
|
|
@@ -38,9 +42,9 @@ module Principles
|
|
|
38
42
|
private
|
|
39
43
|
|
|
40
44
|
# The answer from --file, where - means it was read from stdin, to the request REQUEST_ID names, or the answer's
|
|
41
|
-
# own request_id when none is given
|
|
45
|
+
# own request_id when none is given, checked against the schema for the phase that id names once its head
|
|
42
46
|
# says it answers a request that still matches the project, with the prior findings a full audit's request
|
|
43
|
-
# listed, which checking its head found
|
|
47
|
+
# listed, which checking its head found.
|
|
44
48
|
#: (Hash[String, untyped]) -> Models::SubmittedAnswer
|
|
45
49
|
def submitted(options)
|
|
46
50
|
sent = @project.answer(options.fetch("file"), stdin: options["stdin"], given: options["request_id"])
|
|
@@ -50,8 +54,8 @@ module Principles
|
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
# Refuses an answer from its head alone: a record a later copy wrote is refused first, read afresh as
|
|
53
|
-
# start-audit reads it, so nothing is written over one that landed mid-audit
|
|
54
|
-
# request, then whatever the phase checks of its request from the head alone
|
|
57
|
+
# start-audit reads it, so nothing is written over one that landed mid-audit, then an answer to another
|
|
58
|
+
# request, then whatever the phase checks of its request from the head alone.
|
|
55
59
|
#: (Models::RequestId, Hash[String, untyped]) -> Models::PriorFindings?
|
|
56
60
|
def checked_head(request_id, head)
|
|
57
61
|
@audit_records.refuse_newer(request_id.principle_id, version: @tool.version)
|
|
@@ -60,22 +64,48 @@ module Principles
|
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
# Accepts the answer and writes the record changes it makes.
|
|
63
|
-
#: (Models::SubmittedAnswer
|
|
64
|
-
def submit_answer(submitted
|
|
67
|
+
#: (Models::SubmittedAnswer) -> untyped
|
|
68
|
+
def submit_answer(submitted)
|
|
65
69
|
output, changes = judged(submitted)
|
|
70
|
+
carried = phase(submitted.request_id).carried_naming_decided(submitted)
|
|
66
71
|
wrote = changes.map { |record| @audit_records.save(record) }
|
|
67
|
-
audit_result.present(output
|
|
68
|
-
|
|
72
|
+
presented = audit_result.present(output)
|
|
73
|
+
audit_result.submitted_citing_decided_findings(presented, carried, submitted.request_id.principle_id)
|
|
74
|
+
.merge("wrote" => wrote)
|
|
69
75
|
end
|
|
70
76
|
|
|
71
|
-
# Runs every check submit-answer would,
|
|
72
|
-
# gives answer_file, the --file value it was
|
|
73
|
-
#
|
|
77
|
+
# Runs every check submit-answer would, says what it would write and each fact to confirm first, such as a
|
|
78
|
+
# write-up pointer it drops, writing nothing; its submit command gives answer_file, the --file value it was
|
|
79
|
+
# checked from, again. An assessment with findings also gives the
|
|
80
|
+
# correction's answer it leads to, to fill.
|
|
74
81
|
#: (Models::SubmittedAnswer, String) -> untyped
|
|
75
82
|
def check_answer(submitted, answer_file)
|
|
76
83
|
output, changes = judged(submitted)
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
checked = to_confirm(acceptable(submitted, answer_file, changes), submitted, changes)
|
|
85
|
+
audit_result.with_correction_to_fill(checked, output, answer_file: answer_file).merge("wrote" => [])
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The acceptable result with each fact to confirm before submitting named first in its next_action: a carried
|
|
89
|
+
# assessment citing a decided finding, a write-up pointer the answer drops, and a deferral the record changes
|
|
90
|
+
# write up nowhere.
|
|
91
|
+
#: (Hash[String, untyped], Models::SubmittedAnswer, Array[Models::AuditRecord]) -> Hash[String, untyped]
|
|
92
|
+
def to_confirm(acceptable, submitted, changes)
|
|
93
|
+
answering = phase(submitted.request_id)
|
|
94
|
+
checked = audit_result.citing_decided_findings(acceptable, answering.carried_naming_decided(submitted))
|
|
95
|
+
checked = audit_result.dropping_pointers(checked, answering.pointers_dropped(submitted))
|
|
96
|
+
audit_result.deferred_written_up_nowhere(checked, answering.deferred_written_up_nowhere(changes))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# The correction's answer an assessment with findings leads to, alone, as show-answer-check --as template prints
|
|
100
|
+
# it to fill; refused for any other answer, which leads to none. Writes nothing.
|
|
101
|
+
#: (Models::SubmittedAnswer) -> Hash[String, untyped]
|
|
102
|
+
def correction_to_fill(submitted)
|
|
103
|
+
output, = judged(submitted)
|
|
104
|
+
output.correction_to_fill or
|
|
105
|
+
raise Error.new("no_correction_to_fill",
|
|
106
|
+
"This answer to #{submitted.request_id} leads to no correction: --as template prints the " \
|
|
107
|
+
"correction's answer that an assessment with findings leads to.",
|
|
108
|
+
"Check it without --as template, which says what submitting it would write.")
|
|
79
109
|
end
|
|
80
110
|
|
|
81
111
|
# The answer passed every check: what submitting it would write, and its submit command.
|
|
@@ -94,7 +124,7 @@ module Principles
|
|
|
94
124
|
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
95
125
|
def claimed_map_entry_changes(submitted) = phase(submitted.request_id).map_entry_changes(submitted)
|
|
96
126
|
|
|
97
|
-
# The result of answering, and each record change the answer makes, not yet written
|
|
127
|
+
# The result of answering, and each record change the answer makes, not yet written.
|
|
98
128
|
#: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
|
|
99
129
|
def judged(submitted) = phase(submitted.request_id).answered(submitted)
|
|
100
130
|
|
|
@@ -16,7 +16,7 @@ module Principles
|
|
|
16
16
|
# @abstract
|
|
17
17
|
class AnswerPhase < Command
|
|
18
18
|
# The result of answering, and each record change the answer makes, not yet written; every phase changes only
|
|
19
|
-
# the request's own principle's record
|
|
19
|
+
# the request's own principle's record. Sorbet refuses a phase that does not define it, and takes an
|
|
20
20
|
# abstract method only with a forwarding super for its body, which RuboCop would otherwise call useless.
|
|
21
21
|
# @abstract
|
|
22
22
|
#: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
|
|
@@ -31,10 +31,27 @@ module Principles
|
|
|
31
31
|
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
32
32
|
def map_entry_changes(_submitted) = []
|
|
33
33
|
|
|
34
|
+
# Each member the answer carries forward whose kept assessment names a prior finding it decides other than
|
|
35
|
+
# still_holds, which only a full audit's assessment decides.
|
|
36
|
+
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
37
|
+
def carried_naming_decided(_submitted) = []
|
|
38
|
+
|
|
39
|
+
# Each prior finding whose write-up pointer the answer drops with null, with the pointer it had, which only a
|
|
40
|
+
# full audit's assessment decides.
|
|
41
|
+
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
42
|
+
def pointers_dropped(_submitted) = []
|
|
43
|
+
|
|
44
|
+
# Each finding the record changes leave deferred with recorded_at null, which only a correction disposes of.
|
|
45
|
+
#: (Array[Models::AuditRecord]) -> Array[String]
|
|
46
|
+
def deferred_written_up_nowhere(_changes) = []
|
|
47
|
+
|
|
34
48
|
# The refusals an answer to the request request_id names meets before its shape, in order; any phase's is a
|
|
35
|
-
# placeholder its template did not print
|
|
49
|
+
# placeholder its template did not print.
|
|
36
50
|
#: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
|
|
37
|
-
def before_shape(request_id)
|
|
51
|
+
def before_shape(request_id)
|
|
52
|
+
[Models::OtherTemplatesPlaceholders.besides(printed_placeholders(request_id),
|
|
53
|
+
start_from: request_id.answer_to_fill)]
|
|
54
|
+
end
|
|
38
55
|
|
|
39
56
|
private
|
|
40
57
|
|