principles 0.0.6 → 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 +58 -41
- data/lib/principles/command_line.rb +37 -14
- data/lib/principles/command_routes.rb +21 -7
- data/lib/principles/controllers/acknowledgement.rb +50 -118
- data/lib/principles/controllers/acknowledgements.rb +154 -0
- data/lib/principles/controllers/after_commit_report.rb +44 -0
- data/lib/principles/controllers/answer.rb +52 -21
- data/lib/principles/controllers/answer_phase.rb +20 -3
- data/lib/principles/controllers/assessment.rb +41 -28
- data/lib/principles/controllers/audit.rb +59 -15
- data/lib/principles/controllers/audit_completion.rb +25 -12
- data/lib/principles/controllers/command.rb +13 -12
- data/lib/principles/controllers/correction.rb +26 -11
- data/lib/principles/controllers/first_audit_brief.rb +40 -0
- data/lib/principles/controllers/full_audit_request.rb +47 -83
- 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 +148 -0
- data/lib/principles/controllers/member_entries.rb +4 -4
- data/lib/principles/controllers/member_problems_report.rb +84 -30
- 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 +67 -12
- 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 -20
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +95 -0
- data/lib/principles/data/schemas/assessment-answer.schema.json +55 -20
- 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 +14 -62
- 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 +7 -6
- data/lib/principles/launch.rb +49 -0
- data/lib/principles/list_open_findings_options.rb +23 -0
- data/lib/principles/models/accepted_loading.rb +2 -2
- data/lib/principles/models/acknowledged_check.rb +106 -0
- data/lib/principles/models/acknowledgement.rb +51 -53
- data/lib/principles/models/acknowledgement_left_as_printed.rb +18 -5
- data/lib/principles/models/acknowledgement_refusal.rb +25 -10
- data/lib/principles/models/acknowledgements.rb +115 -0
- 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 +12 -3
- 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 +14 -15
- data/lib/principles/models/audit.rb +46 -34
- data/lib/principles/models/audit_record.rb +58 -27
- 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 +19 -10
- 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 +80 -0
- data/lib/principles/models/listed_members.rb +47 -0
- data/lib/principles/models/loaded_files.rb +4 -5
- data/lib/principles/models/loading_decision.rb +19 -10
- data/lib/principles/models/loading_facts.rb +1 -1
- data/lib/principles/models/loads_to_check.rb +1 -2
- 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 +17 -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 +21 -18
- data/lib/principles/models/member_repair_moves.rb +15 -9
- data/lib/principles/models/member_sighting.rb +12 -15
- 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 +42 -9
- data/lib/principles/models/project.rb +29 -20
- 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 +42 -36
- data/lib/principles/models/request_id.rb +19 -7
- data/lib/principles/models/runs_from.rb +7 -2
- data/lib/principles/models/sent_answer.rb +38 -16
- 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 +15 -7
- data/lib/principles/prose_list.rb +1 -1
- data/lib/principles/session_start_options.rb +3 -3
- data/lib/principles/start_audit_options.rb +54 -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 +137 -17
- 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 +68 -38
- data/lib/principles/views/assessment_request.rb +43 -21
- 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 +100 -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 +51 -39
- 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 +49 -33
- data/lib/principles/views/diff_since_last_audit.rb +8 -6
- data/lib/principles/views/findings_result.rb +33 -1
- 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 +32 -9
- 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 +11 -7
- 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 +61 -0
- data/lib/principles/views/members_a_commit_changed.rb +15 -11
- data/lib/principles/views/members_with_no_baseline.rb +10 -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 +24 -12
- data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
- data/lib/principles/views/open_findings_line.rb +26 -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 +70 -45
- data/lib/principles/views/problem_result.rb +75 -43
- 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/report-the-exit-status-its-own-listing-gives.md +3 -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-each-change-keeps-its-meaning.md +8 -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/decide-each-member-loading.md +2 -1
- 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/run-the-check-then-report-it.md +2 -2
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +5 -3
- 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/every-command-and-how-they-chain.md +1 -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 +16 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +65 -61
- 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 +22 -20
- 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 +27 -28
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +39 -38
- 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 -0
- 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/start-a-session/start-with-the-principles-skill.md +1 -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 +95 -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
|
@@ -5,6 +5,7 @@ require_relative "answer_phase"
|
|
|
5
5
|
require_relative "../models/audit"
|
|
6
6
|
require_relative "../models/correction_answer"
|
|
7
7
|
require_relative "../models/declared_map_changes"
|
|
8
|
+
require_relative "../models/finding_write_ups"
|
|
8
9
|
require_relative "../models/request_id"
|
|
9
10
|
require_relative "../views/prompts"
|
|
10
11
|
require_relative "audit_completion"
|
|
@@ -15,11 +16,11 @@ module Principles
|
|
|
15
16
|
module Controllers
|
|
16
17
|
# A full audit's correction, which submit-answer and show-answer-check hand over: this tool checks each
|
|
17
18
|
# disposition, and any members moved or whose role or check a fix changed, against the map and hashes the
|
|
18
|
-
# audit began from, and completes the audit
|
|
19
|
+
# audit began from, and completes the audit.
|
|
19
20
|
class Correction < AnswerPhase
|
|
20
21
|
# The result of answering a correction request, and the record change it makes, not yet written. A refused
|
|
21
22
|
# answer to a request printed before the record changed is refused as stale, so the agent starts again rather
|
|
22
|
-
# than repairing it
|
|
23
|
+
# than repairing it.
|
|
23
24
|
# @override
|
|
24
25
|
#: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
|
|
25
26
|
def answered(submitted)
|
|
@@ -33,7 +34,7 @@ module Principles
|
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
# What each map entry a fix in the answer claims changed, from the map its audit started from and its map now;
|
|
36
|
-
# the audit is built and the base map read only when a fix claims one
|
|
37
|
+
# the audit is built and the base map read only when a fix claims one.
|
|
37
38
|
# @override
|
|
38
39
|
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
39
40
|
def map_entry_changes(submitted)
|
|
@@ -45,9 +46,16 @@ module Principles
|
|
|
45
46
|
end
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
# Each finding the completed record leaves deferred with recorded_at null.
|
|
50
|
+
# @override
|
|
51
|
+
#: (Array[Models::AuditRecord]) -> Array[String]
|
|
52
|
+
def deferred_written_up_nowhere(changes)
|
|
53
|
+
Models::FindingWriteUps.of(@project, changes).deferred_written_up_nowhere
|
|
54
|
+
end
|
|
55
|
+
|
|
48
56
|
private
|
|
49
57
|
|
|
50
|
-
# The placeholders a correction's template printed, its dispositions'
|
|
58
|
+
# The placeholders a correction's template printed, its dispositions'.
|
|
51
59
|
#: (Models::RequestId) -> Hash[String, untyped]?
|
|
52
60
|
def printed_placeholders(_request_id) = Models::Disposition::TEMPLATE_PLACEHOLDERS
|
|
53
61
|
|
|
@@ -59,14 +67,18 @@ module Principles
|
|
|
59
67
|
moves = Models::MemberMoves.new(response["moved_members"])
|
|
60
68
|
before = moves.hashes(confirmed_start(request_id, basis, audit, changes))
|
|
61
69
|
findings = moves.findings(basis.findings)
|
|
62
|
-
start =
|
|
63
|
-
completion(changes, basis).completed(start, audit, dispositions(response, findings, start, audit),
|
|
64
|
-
|
|
70
|
+
start = resumed(audit, basis, before, moves)
|
|
71
|
+
completion(changes, basis, audit).completed(start, audit, dispositions(response, findings, start, audit),
|
|
72
|
+
findings, basis.prior_decided.moved(moves))
|
|
65
73
|
end
|
|
66
74
|
|
|
75
|
+
# What the audit a correction resumes began from, its assessment read back from the record it left.
|
|
76
|
+
#: (Models::Audit, Models::CorrectionBasis, Hash[String, String], Models::MemberMoves) -> Models::AuditStart
|
|
77
|
+
def resumed(audit, basis, before, moves) = audit.resumed(basis, before, moves, @audit_records.find(audit.id))
|
|
78
|
+
|
|
67
79
|
# The packaged answer guide, which the correction request prints, is the one owner of its samples, the text
|
|
68
80
|
# the agent saw, so its sample for each action is handed to the model, which refuses a field given back as
|
|
69
|
-
# its sample
|
|
81
|
+
# its sample. Should the tool be upgraded between request and answer, that answer is checked only
|
|
70
82
|
# against the new guide's samples.
|
|
71
83
|
#: (untyped, Array[untyped], Models::AuditStart, Models::Audit) -> Array[Models::Disposition]
|
|
72
84
|
def dispositions(response, findings, start, audit)
|
|
@@ -102,9 +114,12 @@ module Principles
|
|
|
102
114
|
checked
|
|
103
115
|
end
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
# The completion of a correction, which read its assessment back from the audit's record: the open one or, for
|
|
118
|
+
# an identical retry, the completed one.
|
|
119
|
+
#: (Models::DeclaredMapChanges, Models::CorrectionBasis, Models::Audit) -> AuditCompletion
|
|
120
|
+
def completion(map_changes, basis, audit)
|
|
121
|
+
handed(AuditCompletion, map_changes: map_changes, replacing: basis.printed_after,
|
|
122
|
+
read_back_from: @audit_records.find(audit.id))
|
|
108
123
|
end
|
|
109
124
|
end
|
|
110
125
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../models/first_full_audit"
|
|
6
|
+
require_relative "../models/problem_report"
|
|
7
|
+
require_relative "../views/first_audit_brief"
|
|
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
|
+
# show-first-audit-brief: the instructions for one background subagent to run a principle's first full audit,
|
|
14
|
+
# so the session that starts it spends a few hundred bytes of its context on the audit rather than tens of
|
|
15
|
+
# kilobytes. It writes nothing.
|
|
16
|
+
class FirstAuditBrief < Command
|
|
17
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
18
|
+
def call(command, id, _options)
|
|
19
|
+
naming_the_executable do
|
|
20
|
+
unknown(command) unless command == "show-first-audit-brief"
|
|
21
|
+
|
|
22
|
+
id ? brief(id) : view.awaiting(Models::ProblemReport.for(@project, nil).awaiting_first_audit)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
# The brief for principle id, refused once a full audit of it has completed.
|
|
29
|
+
#: (String) -> Hash[String, untyped]
|
|
30
|
+
def brief(id)
|
|
31
|
+
@principles.find(id)
|
|
32
|
+
Models::FirstFullAudit.new(id, @audit_records.find(id)).refuse_once_completed
|
|
33
|
+
view.result(id)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
#: () -> Views::FirstAuditBrief
|
|
37
|
+
def view = Views::FirstAuditBrief.new(invocation)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -3,23 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
require_relative "command"
|
|
5
5
|
require_relative "../models/audit"
|
|
6
|
-
require_relative "../models/evidence_lines_since"
|
|
7
6
|
require_relative "../models/instruction_named"
|
|
8
|
-
require_relative "../models/loading_decision"
|
|
9
7
|
require_relative "../models/meta_principle"
|
|
10
|
-
require_relative "../models/
|
|
11
|
-
require_relative "../models/prior_decision_fields"
|
|
8
|
+
require_relative "../models/part_named"
|
|
12
9
|
require_relative "../models/recent_decision"
|
|
13
10
|
require_relative "../models/reported_check"
|
|
14
|
-
require_relative "../models/uncommitted_outside_the_map"
|
|
15
11
|
require_relative "../views/assessment_request"
|
|
16
|
-
require_relative "../views/
|
|
17
|
-
require_relative "../views/open_findings_elsewhere_result"
|
|
18
|
-
require_relative "../views/other_principles_unjudged_result"
|
|
19
|
-
require_relative "../views/outside_the_map_result"
|
|
20
|
-
require_relative "../views/package_since_last_audit_result"
|
|
21
|
-
require_relative "../views/prior_findings_result"
|
|
12
|
+
require_relative "../views/parts_index_result"
|
|
22
13
|
require_relative "members_to_assess"
|
|
14
|
+
require_relative "parts_to_read"
|
|
23
15
|
|
|
24
16
|
module Principles
|
|
25
17
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
@@ -27,7 +19,7 @@ module Principles
|
|
|
27
19
|
module Controllers
|
|
28
20
|
# The request a full audit of one principle asks as the project stands, which Audit hands over for start-audit:
|
|
29
21
|
# the commit it is based on, its id and what it asks. Starting writes nothing: the request id is a digest of what
|
|
30
|
-
# the request depends on, so Answer checks the answer against the project as it is then
|
|
22
|
+
# the request depends on, so Answer checks the answer against the project as it is then.
|
|
31
23
|
class FullAuditRequest < Command
|
|
32
24
|
# principle_id names the principle whose full audit is asked for; its map is refused unless it can be audited.
|
|
33
25
|
#: (Models::Project, tool: RunningTool, principle_id: String) -> void
|
|
@@ -48,14 +40,14 @@ module Principles
|
|
|
48
40
|
audit_result.request(with_record_notice(audit_result.assessment_request(asked))).merge("wrote" => [])
|
|
49
41
|
end
|
|
50
42
|
|
|
51
|
-
# The answer alone, as start-audit --as template prints it, to fill and submit under the request's id
|
|
43
|
+
# The answer alone, as start-audit --as template prints it, to fill and submit under the request's id.
|
|
52
44
|
#: () -> Hash[String, untyped]
|
|
53
45
|
def to_fill
|
|
54
46
|
audit_result.answer_to_fill(asked)
|
|
55
47
|
end
|
|
56
48
|
|
|
57
49
|
# The instruction field this request prints, read on its own and whole, with the paragraphs for cases the
|
|
58
|
-
# request does not hold
|
|
50
|
+
# request does not hold; refused when it prints none by that name.
|
|
59
51
|
#: (String) -> Hash[String, untyped]
|
|
60
52
|
def instruction(field)
|
|
61
53
|
request = asked
|
|
@@ -63,11 +55,34 @@ module Principles
|
|
|
63
55
|
{ "request_id" => request.request_id, named => request.whole_instruction(named), "wrote" => [] }
|
|
64
56
|
end
|
|
65
57
|
|
|
58
|
+
# The part of this request --part names, printed alone under the request's id, so the agent need not read the
|
|
59
|
+
# whole request for it, the index with how to answer it, and one it leaves out for listing nothing as empty;
|
|
60
|
+
# refused when the request has no part by that name.
|
|
61
|
+
#: (String) -> Hash[String, untyped]
|
|
62
|
+
def part(name)
|
|
63
|
+
request = asked
|
|
64
|
+
parts = request.context_parts(texts: member_texts, optional: PartsToRead::OPTIONAL)
|
|
65
|
+
named = Models::PartNamed.new(name, principle_id: @id, printed: parts.printable, empty: parts.left_out).part
|
|
66
|
+
shown = { "request_id" => request.request_id, **parts.shown(named) }
|
|
67
|
+
shown = Views::PartsIndexResult.new(invocation).printed(shown, request) if named == Views::ContextParts::INDEX
|
|
68
|
+
shown.merge("wrote" => [])
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# The slot of the answer to fill that --part names beside --as template, a member's as members/ID, printed alone
|
|
72
|
+
# under the request's id; refused when the template has no slot by that name.
|
|
73
|
+
#: (String) -> Hash[String, untyped]
|
|
74
|
+
def slot_to_fill(name)
|
|
75
|
+
request = asked
|
|
76
|
+
slots = request.slots_to_fill
|
|
77
|
+
named = Models::PartNamed.new(name, principle_id: @id, printed: slots.keys, template: true).part
|
|
78
|
+
{ "request_id" => request.request_id, "member_assessments" => [slots.fetch(named)], "wrote" => [] }
|
|
79
|
+
end
|
|
80
|
+
|
|
66
81
|
private
|
|
67
82
|
|
|
68
83
|
# The request and what it asks, listing the findings the last completed audit left to decide, under an id that
|
|
69
|
-
# digests them
|
|
70
|
-
# open on members sharing these lines
|
|
84
|
+
# digests them and the revision of that audit's record, but not the findings other principles leave
|
|
85
|
+
# open on members sharing these lines.
|
|
71
86
|
#: () -> Views::AssessmentRequest
|
|
72
87
|
def asked
|
|
73
88
|
record = @audit_records.find(@id)
|
|
@@ -76,10 +91,11 @@ module Principles
|
|
|
76
91
|
basis = Models::AssessmentBasis.printed(@base, record)
|
|
77
92
|
head = Views::AnswerHead.new(request_id: @audit.assessment_id(basis, prior.digested, loads).to_s,
|
|
78
93
|
basis: basis.to_h)
|
|
79
|
-
request_to_assess(head,
|
|
94
|
+
request_to_assess(head, handed(PartsToRead, audit: @audit, listing: @listing,
|
|
95
|
+
audited_files: audited_files(@audit.map)).listed(prior, loads))
|
|
80
96
|
end
|
|
81
97
|
|
|
82
|
-
# What the agent assesses: the members, with what else it reads beside them
|
|
98
|
+
# What the agent assesses: the members, with what else it reads beside them.
|
|
83
99
|
#: (Views::AnswerHead, Array[Views::RequestPart]) -> Views::AssessmentRequest
|
|
84
100
|
def request_to_assess(head, parts)
|
|
85
101
|
Views::AssessmentRequest.new(principle: { "principle_id" => @id, "description" => @audit.map.description },
|
|
@@ -94,76 +110,19 @@ module Principles
|
|
|
94
110
|
end
|
|
95
111
|
|
|
96
112
|
# The members the request lists, each checked one's template printing the placeholders an answer leaves as
|
|
97
|
-
# printed to give none
|
|
113
|
+
# printed to give none.
|
|
98
114
|
#: () -> Views::AssessedMembers
|
|
99
115
|
def assessed_members
|
|
100
116
|
Views::AssessedMembers.new(@listing.members,
|
|
101
117
|
reviewed_check_placeholders: Models::ReportedCheck::PLACEHOLDERS.to_h,
|
|
102
118
|
unchanged_check_placeholders: Models::ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h,
|
|
103
|
-
assessment_placeholder: Models::MemberAssessments::PLACEHOLDER
|
|
104
|
-
sighting_placeholders: Models::MemberAssessments::SIGHTING.to_h)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
# The part listing the members to check against the activation, each decision's template printing the
|
|
108
|
-
# placeholders an answer leaves as printed to give none (#994); nil when none is listed.
|
|
109
|
-
#: (Hash[String, untyped]?) -> Views::RequestPart?
|
|
110
|
-
def loads_part(loads)
|
|
111
|
-
Views::LoadsToCheckResult.new(invocation, loads, @id, placeholders: Models::LoadingDecision::PLACEHOLDERS.to_h)
|
|
112
|
-
.part
|
|
119
|
+
assessment_placeholder: Models::MemberAssessments::PLACEHOLDER)
|
|
113
120
|
end
|
|
114
121
|
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# since its last audit (D68) and the other principles with members no audit has judged (D71).
|
|
120
|
-
#: (Models::PriorFindings, Hash[String, untyped]?) -> Array[Views::RequestPart]
|
|
121
|
-
def parts_to_read(prior, loads)
|
|
122
|
-
map = @audit.map
|
|
123
|
-
[outside_the_map, prior_findings_part(prior),
|
|
124
|
-
Views::OpenFindingsElsewhereResult.new(@listing.open_findings_elsewhere).part,
|
|
125
|
-
loads_part(loads), package_since_last_audit(map),
|
|
126
|
-
other_principles_unjudged(map)].compact
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
# The part listing each other principle with members no audit has judged as they are now, as
|
|
130
|
-
# list-member-problems reports them, for the principle whose audit states them; nil for any other (D71).
|
|
131
|
-
#: (Models::Principle) -> Views::RequestPart?
|
|
132
|
-
def other_principles_unjudged(map)
|
|
133
|
-
return unless map.keeps_others_held?
|
|
134
|
-
|
|
135
|
-
listed = Models::OtherPrinciples.of(@project, but: map.id).unjudged.map do |other, members|
|
|
136
|
-
Views::PrincipleWithChangedMembers.new(principle_id: other, members: members)
|
|
137
|
-
end
|
|
138
|
-
Views::OtherPrinciplesUnjudgedResult.new(listed).part
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# The part stating the release of principles the last completed audit ran under beside the one now, and
|
|
142
|
-
# whether the passage changed since, for a principle whose audit keeps one; nil for any other (D68).
|
|
143
|
-
#: (Models::Principle) -> Views::RequestPart?
|
|
144
|
-
def package_since_last_audit(map)
|
|
145
|
-
now = @tool.release_kept_by(map) or return
|
|
146
|
-
last = @audit_records.find(map.id)&.last_completed&.package
|
|
147
|
-
Views::PackageSinceLastAuditResult.new(invocation, at_last_audit: last&.version, now: now.version,
|
|
148
|
-
passage_changed: last && now.passage_changed_since?(last))
|
|
149
|
-
.part
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# The part listing the prior findings, in git with each evidence item saying whether its text changed since the
|
|
153
|
-
# commit the audit that left them open was based on, and whether it is found now (#858, #877); nil when there are
|
|
154
|
-
# none.
|
|
155
|
-
#: (Models::PriorFindings) -> Views::RequestPart?
|
|
156
|
-
def prior_findings_part(prior)
|
|
157
|
-
shown = prior.shown { |item, base| Models::EvidenceLinesSince.of(item, since: base, project: @project).facts }
|
|
158
|
-
Views::PriorFindingsResult.new(shown, placeholders: Models::PriorDecisionFields::TEMPLATE_PLACEHOLDERS,
|
|
159
|
-
last_audited_commit: prior.last_audited_commit).part
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
# The part naming the files outside the map that differ from the base commit, or nil when none do.
|
|
163
|
-
#: () -> Views::RequestPart?
|
|
164
|
-
def outside_the_map
|
|
165
|
-
outside = @history.uncommitted_outside(audited_files(@audit.map))
|
|
166
|
-
Views::OutsideTheMapResult.new(outside && Models::UncommittedOutsideTheMap.new(outside).shown).part
|
|
122
|
+
# Each member's lines now, by id, without their line endings, so its part carries the text it is judged on.
|
|
123
|
+
#: () -> Hash[String, Array[String]]
|
|
124
|
+
def member_texts
|
|
125
|
+
@audit.map.members.to_h { [it.id, @project.member_file(it.path).lines_of(it.locator).map(&:chomp)] }
|
|
167
126
|
end
|
|
168
127
|
|
|
169
128
|
# The map's file and every member's file, which the base commit is judged over.
|
|
@@ -172,12 +131,17 @@ module Principles
|
|
|
172
131
|
[@principles.file(@id), *map.members.map(&:path)]
|
|
173
132
|
end
|
|
174
133
|
|
|
175
|
-
# The request, with a notice when the last audit's record was left uncommitted
|
|
134
|
+
# The request, with a notice when the last audit's record was left uncommitted: a completed one to commit, or an
|
|
135
|
+
# open one, which its correction completes, never to commit.
|
|
176
136
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
177
137
|
def with_record_notice(output)
|
|
178
138
|
return output unless @base && uncommitted_record?
|
|
179
139
|
|
|
180
|
-
|
|
140
|
+
file = @audit_records.file(@id)
|
|
141
|
+
record = @audit_records.find(@id)
|
|
142
|
+
left_open = record && !record.completed?
|
|
143
|
+
notice = left_open ? audit_result.open_record_notice(file) : audit_result.uncommitted_record_notice(file)
|
|
144
|
+
output.merge("notice" => notice)
|
|
181
145
|
end
|
|
182
146
|
|
|
183
147
|
# Whether the last audit's record exists but differs from the last commit, so it may be left behind.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../models/report_hooks"
|
|
6
|
+
require_relative "../views/hook_setup_result"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
10
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
11
|
+
module Controllers
|
|
12
|
+
# show-hook-setup: the hook entries that run report-at-session-start and report-after-commit for a user without
|
|
13
|
+
# the principles plugin, on each host. It writes nothing, since the user's settings are theirs: the agent writes
|
|
14
|
+
# the entries once the user agrees.
|
|
15
|
+
class HookSetup < Command
|
|
16
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
17
|
+
def call(command, _id, _options)
|
|
18
|
+
naming_the_executable do
|
|
19
|
+
unknown(command) unless command == "show-hook-setup"
|
|
20
|
+
|
|
21
|
+
Views::HookSetupResult.new(hosts, principles_on_path: principles_on_path).result
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# What PATH says of the principles each entry runs, when it is not this copy: another version first on PATH, or
|
|
28
|
+
# none there that prints a version; nil when a bare principles runs this copy or one of its version.
|
|
29
|
+
#: () -> String?
|
|
30
|
+
def principles_on_path
|
|
31
|
+
other = @tool.other_on_path(asking: Models::ReportHooks::COMMANDS)
|
|
32
|
+
return (Views::HookSetupResult::NONE_ON_PATH unless @tool.launched_on_path?) unless other
|
|
33
|
+
|
|
34
|
+
running = @tool.version
|
|
35
|
+
Views::HookSetupResult.other_on_path(other.path, other.version, running, lacking: other.lacking) if
|
|
36
|
+
other.shadows?(running)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Each host's hooks, as plain values.
|
|
40
|
+
#: () -> Array[Hash[String, untyped]]
|
|
41
|
+
def hosts
|
|
42
|
+
Models::ReportHooks::HOSTS.map do |host|
|
|
43
|
+
{ "host" => host.name, "file" => host.file, "offered" => host.offered_in(@project),
|
|
44
|
+
"hooks" => host.hooks.map { { "event" => it.event, "matcher" => it.matcher, "command" => it.command } } }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -11,7 +11,7 @@ module Principles
|
|
|
11
11
|
# controllers/CLAUDE.md owns the boundary.
|
|
12
12
|
module Controllers
|
|
13
13
|
# The reads that show what a project has mapped: its principles, and each member and how fresh it is against the
|
|
14
|
-
# last audit. None changes anything on disk. Survey runs the survey of candidate files
|
|
14
|
+
# last audit. None changes anything on disk. Survey runs the survey of candidate files.
|
|
15
15
|
class Inventory < Command
|
|
16
16
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
17
17
|
def call(command, id, _options)
|
|
@@ -54,7 +54,7 @@ module Principles
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
# What show-principle prints of one member: where it is now, its freshness and when its file loads
|
|
57
|
+
# What show-principle prints of one member: where it is now, its freshness and when its file loads.
|
|
58
58
|
# The span sits beside the id too, as in add-member's and move-member's results (alpha friction).
|
|
59
59
|
#: (Hash[String, untyped], Models::AuditRecord?, Models::MemberLoads) -> Hash[String, untyped]
|
|
60
60
|
def shown_member(member, audit, loads)
|
|
@@ -70,12 +70,14 @@ module Principles
|
|
|
70
70
|
members.select { |member| Models::MemberState.new(member.fetch("id"), member.fetch("freshness")).broken? }
|
|
71
71
|
.to_h do |member|
|
|
72
72
|
id = member.fetch("id")
|
|
73
|
-
|
|
73
|
+
error = member.fetch("error", {})
|
|
74
|
+
[id, Models::MemberRepairMoves.new(principle.member(id), code: error["code"],
|
|
75
|
+
tracked_as: error["tracked_as"]).to_a]
|
|
74
76
|
end
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
# The members sharing a line with this one, in its map and in others, as add-member names them, so a member
|
|
78
|
-
# whose lines others hold too does not look as if its member_bytes were its alone
|
|
80
|
+
# whose lines others hold too does not look as if its member_bytes were its alone. A member this tool
|
|
79
81
|
# cannot find now shares nothing it can name.
|
|
80
82
|
#: (Hash[String, untyped], map: Models::Principle) -> Hash[String, untyped]
|
|
81
83
|
def shared(member, map:)
|
|
@@ -97,7 +99,7 @@ module Principles
|
|
|
97
99
|
end
|
|
98
100
|
|
|
99
101
|
# Its next_action offers an audit while one principle's audits do not wait on an upgrade; a map listed with its
|
|
100
|
-
# refusal counts, since repairing it leaves it to audit
|
|
102
|
+
# refusal counts, since repairing it leaves it to audit.
|
|
101
103
|
#: () -> untyped
|
|
102
104
|
def listing
|
|
103
105
|
ids = @principles.ids
|
|
@@ -105,8 +107,8 @@ module Principles
|
|
|
105
107
|
read_result.listing(rows(ids), waiting: waiting, one_to_audit: waiting.size < ids.size)
|
|
106
108
|
end
|
|
107
109
|
|
|
108
|
-
# One map's row; a map this tool cannot read is listed with its refusal, so the others still show
|
|
109
|
-
# whose record a later copy wrote says its audits wait on an upgrade, as show-audit does
|
|
110
|
+
# One map's row; a map this tool cannot read is listed with its refusal, so the others still show, and one
|
|
111
|
+
# whose record a later copy wrote says its audits wait on an upgrade, as show-audit does.
|
|
110
112
|
#: (String) -> Hash[String, untyped]
|
|
111
113
|
def entry(id)
|
|
112
114
|
map = @principles.find(id)
|
|
@@ -118,7 +120,7 @@ module Principles
|
|
|
118
120
|
end
|
|
119
121
|
|
|
120
122
|
# How many of map's members are in each freshness state, against its principle's last audit, or the hashes a
|
|
121
|
-
# record a later copy wrote holds, read-only, when this copy cannot read the rest of it
|
|
123
|
+
# record a later copy wrote holds, read-only, when this copy cannot read the rest of it.
|
|
122
124
|
#: (Models::Principle) -> Hash[String, Integer]
|
|
123
125
|
def members_by_freshness(map)
|
|
124
126
|
hashes = @audit_records.hashes_to_compare(map.id)
|
|
@@ -9,7 +9,7 @@ module Principles
|
|
|
9
9
|
# controllers/CLAUDE.md owns the boundary.
|
|
10
10
|
module Controllers
|
|
11
11
|
# The writes to what a principle declares as a whole in its committed map: that it exists, its
|
|
12
|
-
# description, and when its work is in hand
|
|
12
|
+
# description, and when its work is in hand. This tool asks, the agent answers, and this tool writes
|
|
13
13
|
# the map and nothing else. MemberEntries writes each member's entry.
|
|
14
14
|
class Mapping < Command
|
|
15
15
|
# Each command and the method that runs it.
|
|
@@ -48,7 +48,7 @@ module Principles
|
|
|
48
48
|
write_map(map) { |printed| map_result.description_changed(printed) }
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
# Records when the principle's work is in hand, as the agent judged it
|
|
51
|
+
# Records when the principle's work is in hand, as the agent judged it.
|
|
52
52
|
#: (String, Hash[String, untyped]) -> untyped
|
|
53
53
|
def change_activation(id, options)
|
|
54
54
|
activation = Models::Activation.declared(when_files: options["when_files"],
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../models/acknowledgement"
|
|
6
|
+
require_relative "../models/check_since_last_audit"
|
|
7
|
+
require_relative "../models/list_member_problems_check"
|
|
8
|
+
require_relative "../models/listed_members"
|
|
9
|
+
require_relative "../models/member"
|
|
10
|
+
require_relative "../views/member_change_since_baseline"
|
|
11
|
+
require_relative "../views/printed_json"
|
|
12
|
+
require_relative "../views/one_member_check_result_template"
|
|
13
|
+
require_relative "../views/read_the_change"
|
|
14
|
+
|
|
15
|
+
module Principles
|
|
16
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
17
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
18
|
+
module Controllers
|
|
19
|
+
# One member's acknowledgement as a one-member audit asks and answers it, which Acknowledgement hands over:
|
|
20
|
+
# the member's change since its baseline as the request shows it, the context beside it and the placeholders its
|
|
21
|
+
# template prints, and the record with the acknowledgement in it once the answer holds.
|
|
22
|
+
class MemberAcknowledgement < Command
|
|
23
|
+
# The text the template prints in each field the agent writes: its judgement's placeholders, meaning_kept's
|
|
24
|
+
# chosen by whether the change's first_changed_lines is a pure insertion, and check_result's for a
|
|
25
|
+
# checked member. The quotes the answer reads as first_changed_lines when left out are not printed.
|
|
26
|
+
#: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?) -> Hash[String, untyped]
|
|
27
|
+
def self.placeholders(check_result, change = nil)
|
|
28
|
+
quotes = change&.first_changed_lines.to_h
|
|
29
|
+
{ **Models::Acknowledgement.placeholders_beside(quotes),
|
|
30
|
+
**(check_result ? { "check_result" => check_result } : {}) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#: Models::Acknowledgement
|
|
34
|
+
attr_reader :acknowledgement
|
|
35
|
+
#: Models::Member
|
|
36
|
+
attr_reader :member
|
|
37
|
+
|
|
38
|
+
# principle_id's member member_id, refused as a near miss or an unknown id, judged against the principle's
|
|
39
|
+
# record from the commit its map and file were last committed at.
|
|
40
|
+
#: (Models::Project, tool: RunningTool, principle_id: String, member_id: String) -> void
|
|
41
|
+
def initialize(project, tool:, principle_id:, member_id:)
|
|
42
|
+
super(project, tool: tool)
|
|
43
|
+
@id = principle_id
|
|
44
|
+
@member = Models::Member.new(@principles.find(principle_id).member(member_id)) #: Models::Member
|
|
45
|
+
@base = @history.base_commit(principle_id, [@principles.file(principle_id), @member.path]) #: String?
|
|
46
|
+
@acknowledgement = Models::Acknowledgement.new(
|
|
47
|
+
principle_id:, member: @member, record: @audit_records.find(principle_id), base: @base,
|
|
48
|
+
now_sha256: @project.locate(@member.locator).fetch("sha256")
|
|
49
|
+
) #: Models::Acknowledgement
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# The member's part of its request: its change since its baseline, as the request shows it, the context
|
|
53
|
+
# beside it, its findings left open and how to run and report its check, and the placeholders its template
|
|
54
|
+
# prints.
|
|
55
|
+
#: () -> Hash[Symbol, untyped]
|
|
56
|
+
def asked
|
|
57
|
+
baseline, lines = since_baseline
|
|
58
|
+
check = check_template
|
|
59
|
+
change = Views::MemberChangeSinceBaseline.new(
|
|
60
|
+
member: shown(baseline), member_lines: lines.shown(taken: bytes_of(check)),
|
|
61
|
+
first_changed_lines: @acknowledgement.first_changed_lines(lines), commits: commits(baseline),
|
|
62
|
+
read_the_change: read_the_change(baseline)
|
|
63
|
+
)
|
|
64
|
+
{ change:, context: { **@acknowledgement.open_findings, **instruction_for(check) },
|
|
65
|
+
placeholders: MemberAcknowledgement.placeholders(check&.to_h, change) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# The record with the acknowledgement in it, once its quotes are found at the baseline and now, made to into
|
|
69
|
+
# when another member's acknowledgement in the same answer has already changed the record.
|
|
70
|
+
# acknowledging is every member the answer acknowledges, which its check may list, each as its principle id and
|
|
71
|
+
# member id: this member alone unless the answer is to several, of one principle or several.
|
|
72
|
+
#: (untyped, at: String, ?acknowledging: Array[[String, String]], ?into: Models::AuditRecord?)
|
|
73
|
+
#| -> Models::AuditRecord
|
|
74
|
+
def accepted(response, at:, acknowledging: [[@id, @member.id]], into: nil)
|
|
75
|
+
_baseline, lines = since_baseline
|
|
76
|
+
@acknowledgement.accepted(response, lines, at:, into:, listed: listed(acknowledging))
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
# What the member's check lists now beside the members the answer acknowledges, when the check is this
|
|
82
|
+
# tool's own list-member-problems --short; nil for any other check.
|
|
83
|
+
#: (Array[[String, String]]) -> Models::ListedMembers?
|
|
84
|
+
def listed(acknowledging)
|
|
85
|
+
own_listing&.listed(@project, principle_id: @id, acknowledging:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The request's check_instruction for a checked member, how to run and report its check; none without one.
|
|
89
|
+
#: (Views::OneMemberCheckResultTemplate?) -> Hash[String, String]
|
|
90
|
+
def instruction_for(check) = check ? { "check_instruction" => check.instruction } : {}
|
|
91
|
+
|
|
92
|
+
# The bytes the check's template and instruction take as the request prints them, which the member's lines
|
|
93
|
+
# give up.
|
|
94
|
+
#: (Views::OneMemberCheckResultTemplate?) -> Integer
|
|
95
|
+
def bytes_of(check) = check ? Views::PrintedJson.bytes(check.to_h) + check.instruction.bytesize : 0
|
|
96
|
+
|
|
97
|
+
# The check_result a checked member's answer fills, for the check the last audit ran, which a one-member audit
|
|
98
|
+
# requires, asking for a passing run alone; nil for a member without a check.
|
|
99
|
+
#: () -> Views::OneMemberCheckResultTemplate?
|
|
100
|
+
def check_template
|
|
101
|
+
checks = Models::CheckSinceLastAudit.new(principle_history: principle_history(@id),
|
|
102
|
+
record: @audit_records.find(@id))
|
|
103
|
+
Views::OneMemberCheckResultTemplate.for(checks.entry(@member),
|
|
104
|
+
exit_status: Models::Acknowledgement::EXIT_STATUS_PLACEHOLDER,
|
|
105
|
+
own_listing: !own_listing.nil?)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# The member's check read as this tool's own list-member-problems --short; nil for any other.
|
|
109
|
+
#: () -> Models::ListMemberProblemsCheck?
|
|
110
|
+
def own_listing = Models::ListMemberProblemsCheck.of(@member.check.to_s)
|
|
111
|
+
|
|
112
|
+
# The command that shows the member's change from its baseline to the base commit: the history of its own lines
|
|
113
|
+
# where it is now, which the base commit holds, when Member#traced_lines says so, else its file's diff.
|
|
114
|
+
#: (Models::Placement) -> Views::ReadTheChange
|
|
115
|
+
def read_the_change(baseline)
|
|
116
|
+
paths = @acknowledgement.paths_since(baseline)
|
|
117
|
+
lines = @member.traced_lines(paths, @project.located_text(@member.locator).lines)
|
|
118
|
+
Views::ReadTheChange.new(since: baseline.commit, to: @base.to_s, paths:, lines:)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# The member as the request shows it, with where it was at its baseline when it has moved since.
|
|
122
|
+
#: (Models::Placement) -> Hash[String, untyped]
|
|
123
|
+
def shown(baseline)
|
|
124
|
+
moved_from = @acknowledgement.moved_from(baseline)
|
|
125
|
+
{ "id" => @member.id, "role" => @member.role, **(@member.check ? { "check" => @member.check } : {}),
|
|
126
|
+
"evidence" => [@member.reference],
|
|
127
|
+
**(moved_from ? { "evidence_at_baseline" => [moved_from] } : {}) }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# The commits the request names: the baseline's, HEAD, and the audit's base when the baseline is later.
|
|
131
|
+
#: (Models::Placement) -> Hash[String, String]
|
|
132
|
+
def commits(baseline)
|
|
133
|
+
audit_base = @acknowledgement.audit_base(baseline)
|
|
134
|
+
{ "baseline" => baseline.commit, "base" => @base.to_s, **(audit_base ? { "audit_base" => audit_base } : {}) }
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# The member's baseline, the oldest commit from the one it was last judged at that holds the text the audit
|
|
138
|
+
# record vouches for, placed as that commit's map placed it or as it is placed now, and its own
|
|
139
|
+
# lines there and now, which the answer's quotes are checked against.
|
|
140
|
+
#: () -> [Models::Placement, Models::MemberLines]
|
|
141
|
+
def since_baseline
|
|
142
|
+
baseline = @acknowledgement.baseline(@acknowledgement.placements_in(@project))
|
|
143
|
+
lines = @project.member_lines(@member.locator, since: baseline.commit, then_locator: baseline.locator)
|
|
144
|
+
[baseline, @acknowledgement.compared(lines)]
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -35,7 +35,7 @@ module Principles
|
|
|
35
35
|
|
|
36
36
|
# command as the agent ran it on principle id, with member in place of the member id it gave, and its options
|
|
37
37
|
# as given, each quoted for a shell and named as the agent typed it: a location by LOCATION_OPTIONS, any other,
|
|
38
|
-
# such as --path or --role, by its own one-word name
|
|
38
|
+
# such as --path or --role, by its own one-word name.
|
|
39
39
|
#: (String, String, String, Hash[String, untyped]) -> String
|
|
40
40
|
def rerun(command, id, member, options)
|
|
41
41
|
flags = options.except("project", "member").flat_map do |name, value|
|
|
@@ -57,7 +57,7 @@ module Principles
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
# The part a new member plays, and the check that enforces it when one is named
|
|
60
|
+
# The part a new member plays, and the check that enforces it when one is named.
|
|
61
61
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
62
62
|
def played(options)
|
|
63
63
|
role = { "role" => text(options["role"], "--role") }
|
|
@@ -73,7 +73,7 @@ module Principles
|
|
|
73
73
|
|
|
74
74
|
# Points an existing member at a new place (a narrower passage, a renamed heading, an anchor that was
|
|
75
75
|
# lost, or with --path a file that was renamed) without taking it out of the map, so it keeps its key and
|
|
76
|
-
# its audit
|
|
76
|
+
# its audit.
|
|
77
77
|
#: (String, Hash[String, untyped]) -> untyped
|
|
78
78
|
def move_member(id, options)
|
|
79
79
|
map = @principles.find(id)
|
|
@@ -100,7 +100,7 @@ module Principles
|
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
# Names the command that enforces a member, which the audit asks the agent to run
|
|
103
|
+
# Names the command that enforces a member, which the audit asks the agent to run.
|
|
104
104
|
#: (String, Hash[String, untyped]) -> untyped
|
|
105
105
|
def change_member_check(id, options)
|
|
106
106
|
map = @principles.find(id)
|