principles 0.1.3 → 0.1.5
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 +151 -1
- data/README.md +10 -6
- data/exe/principles +1 -1
- data/lib/principles/cli.rb +9 -10
- data/lib/principles/command_line.rb +15 -6
- data/lib/principles/command_routes.rb +18 -2
- data/lib/principles/controllers/acknowledgement.rb +19 -4
- data/lib/principles/controllers/acknowledgements.rb +43 -12
- data/lib/principles/controllers/after_commit_report.rb +15 -2
- data/lib/principles/controllers/assessment.rb +7 -3
- data/lib/principles/controllers/audit.rb +17 -8
- data/lib/principles/controllers/audit_completion.rb +34 -9
- data/lib/principles/controllers/carrier_edit_report.rb +40 -0
- data/lib/principles/controllers/carrier_practices.rb +26 -0
- data/lib/principles/controllers/command.rb +36 -5
- data/lib/principles/controllers/context_budget.rb +61 -0
- data/lib/principles/controllers/correction.rb +15 -5
- data/lib/principles/controllers/full_audit_request.rb +38 -42
- data/lib/principles/controllers/inventory.rb +78 -71
- data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
- data/lib/principles/controllers/member_addition.rb +20 -5
- data/lib/principles/controllers/member_entries.rb +50 -39
- data/lib/principles/controllers/member_entry_changes.rb +71 -0
- data/lib/principles/controllers/member_problems_report.rb +26 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
- data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
- data/lib/principles/controllers/members_to_assess.rb +35 -8
- data/lib/principles/controllers/meta_principle_setup.rb +12 -4
- data/lib/principles/controllers/open_correction.rb +3 -2
- data/lib/principles/controllers/parts_to_read.rb +48 -6
- data/lib/principles/controllers/plugin_member_addition.rb +48 -0
- data/lib/principles/controllers/principle_listing.rb +84 -0
- data/lib/principles/controllers/request_logging.rb +65 -0
- data/lib/principles/controllers/running_tool.rb +55 -15
- data/lib/principles/controllers/session_start_report.rb +26 -2
- data/lib/principles/data/branches_bringing_in.rb +52 -0
- data/lib/principles/data/captured_requests.rb +118 -0
- data/lib/principles/data/carrier_page_markers.rb +38 -0
- data/lib/principles/data/changes_since.rb +56 -0
- data/lib/principles/data/claude_code_home.rb +75 -0
- data/lib/principles/data/command-steps.json +139 -23
- data/lib/principles/data/decoded_leaf.rb +63 -0
- data/lib/principles/data/head_reflog.rb +13 -2
- data/lib/principles/data/kept_line.rb +39 -0
- data/lib/principles/data/known_marketplaces.rb +50 -0
- data/lib/principles/data/logged_request_matches.rb +144 -0
- data/lib/principles/data/logged_request_scan.rb +188 -0
- data/lib/principles/data/map_files.rb +18 -4
- data/lib/principles/data/plugin_folder.rb +85 -0
- data/lib/principles/data/plugin_registry.rb +73 -0
- data/lib/principles/data/principles_store.rb +49 -0
- data/lib/principles/data/project_files.rb +15 -0
- data/lib/principles/data/ran.rb +25 -0
- data/lib/principles/data/raw_request_filter.rb +61 -0
- data/lib/principles/data/repository.rb +29 -27
- data/lib/principles/data/request_logging_folder.rb +135 -0
- data/lib/principles/data/request_shape.rb +33 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
- data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +14 -0
- data/lib/principles/data/schemas/member-map.schema.json +12 -1
- data/lib/principles/data/settings_env_keys.rb +26 -0
- data/lib/principles/data/string_counts.rb +39 -0
- data/lib/principles/data/tools_on_path.rb +25 -0
- data/lib/principles/data/user_request_logging_folder.rb +73 -0
- data/lib/principles/invocation_options.rb +5 -3
- data/lib/principles/launch.rb +29 -10
- data/lib/principles/models/acknowledged_check.rb +11 -1
- data/lib/principles/models/acknowledgement.rb +5 -0
- data/lib/principles/models/acknowledgement_refusal.rb +20 -11
- data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
- data/lib/principles/models/after_commit_input.rb +5 -0
- data/lib/principles/models/answer_fields.rb +3 -0
- data/lib/principles/models/assessment_basis.rb +10 -3
- data/lib/principles/models/audit.rb +10 -10
- data/lib/principles/models/audit_record.rb +10 -0
- data/lib/principles/models/audit_records.rb +4 -3
- data/lib/principles/models/audit_start.rb +9 -0
- data/lib/principles/models/authored_locator.rb +33 -0
- data/lib/principles/models/candidate_files.rb +23 -3
- data/lib/principles/models/candidate_outline.rb +18 -125
- data/lib/principles/models/captured_sessions.rb +166 -0
- data/lib/principles/models/carrier_edit_input.rb +56 -0
- data/lib/principles/models/carrier_kind.rb +79 -0
- data/lib/principles/models/carrier_pages_shown.rb +28 -0
- data/lib/principles/models/carved_message_bytes.rb +115 -0
- data/lib/principles/models/cited_files.rb +12 -3
- data/lib/principles/models/context_parts.rb +59 -0
- data/lib/principles/models/decided_prior_findings.rb +5 -0
- data/lib/principles/models/declared_map_changes.rb +22 -13
- data/lib/principles/models/disposition.rb +37 -6
- data/lib/principles/models/disposition_placeholders.rb +12 -0
- data/lib/principles/models/disposition_text_field.rb +4 -0
- data/lib/principles/models/dropped_thinking.rb +73 -0
- data/lib/principles/models/feature.rb +54 -0
- data/lib/principles/models/finding_outcomes.rb +55 -0
- data/lib/principles/models/findings_left_open.rb +9 -11
- data/lib/principles/models/head_moves.rb +27 -10
- data/lib/principles/models/installed_component.rb +55 -0
- data/lib/principles/models/installed_plugins.rb +174 -0
- data/lib/principles/models/kept_sessions.rb +34 -0
- data/lib/principles/models/locator.rb +8 -0
- data/lib/principles/models/logged_request_reach.rb +52 -0
- data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
- data/lib/principles/models/map_format_raise.rb +28 -0
- data/lib/principles/models/mapped_baseline.rb +46 -0
- data/lib/principles/models/mapped_principles.rb +2 -1
- data/lib/principles/models/maps_holding_file_whole.rb +42 -0
- data/lib/principles/models/markdown_text.rb +143 -0
- data/lib/principles/models/member.rb +19 -1
- data/lib/principles/models/member_entry.rb +56 -0
- data/lib/principles/models/member_justification.rb +52 -0
- data/lib/principles/models/member_lines.rb +11 -0
- data/lib/principles/models/member_loads.rb +17 -2
- data/lib/principles/models/member_problems.rb +46 -42
- data/lib/principles/models/member_reach.rb +59 -0
- data/lib/principles/models/member_snapshots.rb +34 -4
- data/lib/principles/models/member_text_as_sent.rb +31 -0
- data/lib/principles/models/member_texts.rb +45 -0
- data/lib/principles/models/members_by_part.rb +67 -0
- data/lib/principles/models/members_in_logged_requests.rb +279 -0
- data/lib/principles/models/meta_principle.rb +4 -4
- data/lib/principles/models/missing_files.rb +41 -16
- data/lib/principles/models/nearly_matching_maps.rb +56 -0
- data/lib/principles/models/open_correction.rb +5 -0
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/outline_budget.rb +10 -1
- data/lib/principles/models/outline_item.rb +25 -0
- data/lib/principles/models/outline_section.rb +15 -4
- data/lib/principles/models/part_named.rb +16 -2
- data/lib/principles/models/part_token_estimates.rb +60 -0
- data/lib/principles/models/plugin_component.rb +37 -0
- data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
- data/lib/principles/models/plugin_install.rb +33 -0
- data/lib/principles/models/plugin_name.rb +23 -0
- data/lib/principles/models/plugin_reference.rb +53 -0
- data/lib/principles/models/principle.rb +7 -4
- data/lib/principles/models/principle_members.rb +22 -0
- data/lib/principles/models/prior_finding_decision.rb +1 -1
- data/lib/principles/models/prior_finding_outcomes.rb +12 -1
- data/lib/principles/models/problem_report.rb +14 -25
- data/lib/principles/models/project.rb +51 -56
- data/lib/principles/models/project_harness.rb +48 -0
- data/lib/principles/models/project_history.rb +19 -5
- data/lib/principles/models/recorded_members.rb +7 -0
- data/lib/principles/models/report_hooks.rb +9 -4
- data/lib/principles/models/request_channel.rb +62 -0
- data/lib/principles/models/request_kind.rb +62 -0
- data/lib/principles/models/request_logging.rb +231 -0
- data/lib/principles/models/request_logging_guard.rb +84 -0
- data/lib/principles/models/request_time.rb +46 -0
- data/lib/principles/models/runs_from.rb +0 -5
- data/lib/principles/models/script_comments.rb +58 -0
- data/lib/principles/models/session_registry.rb +61 -0
- data/lib/principles/models/session_start_input.rb +11 -2
- data/lib/principles/models/session_trend.rb +36 -0
- data/lib/principles/models/stale_request.rb +9 -0
- data/lib/principles/models/turn_opening.rb +83 -0
- data/lib/principles/models/turn_position.rb +43 -0
- data/lib/principles/models/unfixed_part.rb +82 -0
- data/lib/principles/models/unresolved_plugin_members.rb +35 -0
- data/lib/principles/models/user_logged_requests.rb +90 -0
- data/lib/principles/models/user_settings_entries.rb +49 -0
- data/lib/principles/models/whole_file_member_read.rb +48 -0
- data/lib/principles/models/without_prose.rb +20 -0
- data/lib/principles/models/workflow_jobs.rb +92 -0
- data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
- data/lib/principles/show_principle_options.rb +32 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +31 -12
- data/lib/principles/views/acknowledgement_result.rb +18 -13
- data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
- data/lib/principles/views/acknowledgements_offered.rb +54 -0
- data/lib/principles/views/added_member.rb +22 -6
- data/lib/principles/views/answer_in_a_file.rb +15 -15
- data/lib/principles/views/assessed_members.rb +19 -8
- data/lib/principles/views/assessment_request.rb +14 -6
- data/lib/principles/views/audit_changes.rb +14 -8
- data/lib/principles/views/audit_findings.rb +34 -0
- data/lib/principles/views/audit_result.rb +26 -24
- data/lib/principles/views/candidate_files_result.rb +1 -1
- data/lib/principles/views/carrier_checks.rb +40 -0
- data/lib/principles/views/carrier_edit_denial.rb +36 -0
- data/lib/principles/views/carrier_practices_page.rb +49 -0
- data/lib/principles/views/completed_audit_findings.rb +33 -0
- data/lib/principles/views/completed_audit_next_step.rb +12 -4
- data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
- data/lib/principles/views/context_budget_result.rb +99 -0
- data/lib/principles/views/context_parts.rb +129 -25
- data/lib/principles/views/correction_request.rb +32 -17
- data/lib/principles/views/disposition_template.rb +35 -0
- data/lib/principles/views/first_audit.rb +29 -15
- data/lib/principles/views/first_audit_line.rb +4 -5
- data/lib/principles/views/hook_setup_result.rb +3 -1
- data/lib/principles/views/invocation.rb +14 -5
- data/lib/principles/views/last_record_notice.rb +41 -0
- data/lib/principles/views/lines_shared_with_member.rb +16 -22
- data/lib/principles/views/logged_request_status_meanings.rb +29 -0
- data/lib/principles/views/logged_requests_evidence.rb +84 -0
- data/lib/principles/views/map_added_to.rb +14 -12
- data/lib/principles/views/map_format_raised.rb +28 -0
- data/lib/principles/views/map_result.rb +41 -18
- data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
- data/lib/principles/views/member_change_since_baseline.rb +4 -0
- data/lib/principles/views/member_row.rb +13 -4
- data/lib/principles/views/member_sets_overlap.rb +31 -0
- data/lib/principles/views/members_a_commit_changed.rb +42 -25
- data/lib/principles/views/members_changed_during_audit.rb +27 -0
- data/lib/principles/views/members_in_logged_requests_result.rb +123 -0
- data/lib/principles/views/members_too_short_to_scan.rb +45 -0
- data/lib/principles/views/members_with_no_baseline.rb +6 -6
- data/lib/principles/views/meta_principle_result.rb +52 -15
- data/lib/principles/views/open_findings_line.rb +31 -92
- data/lib/principles/views/parts_index_result.rb +9 -5
- data/lib/principles/views/principle_read_result.rb +52 -11
- data/lib/principles/views/prior_findings_result.rb +9 -1
- data/lib/principles/views/problem_facts.rb +5 -3
- data/lib/principles/views/problem_lines.rb +54 -6
- data/lib/principles/views/problem_result.rb +7 -15
- data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
- data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +6 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
- data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +49 -51
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +8 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +62 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +16 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +17 -17
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +18 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +44 -0
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
- data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
- data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
- data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
- data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
- data/lib/principles/views/request_logging_result.rb +108 -0
- data/lib/principles/views/request_part.rb +10 -4
- data/lib/principles/views/request_parts.rb +9 -0
- data/lib/principles/views/set_up_offer_line.rb +43 -0
- data/lib/principles/views/whole_file_elsewhere.rb +30 -0
- metadata +154 -5
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require_relative "request_logging_folder"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# Every file and process this tool reads or writes. data/CLAUDE.md owns the boundary.
|
|
9
|
+
module Data
|
|
10
|
+
# The user-level folder the host writes every project's requests to while request logging is on in the user's own
|
|
11
|
+
# settings: this user's state, outside every repository, so no project's working tree holds another's requests.
|
|
12
|
+
class UserRequestLoggingFolder
|
|
13
|
+
# The folder under the user's state folder: XDG_STATE_HOME when set, or else .local/state in the home directory.
|
|
14
|
+
#: (?Hash[String, String], ?home: String) -> UserRequestLoggingFolder
|
|
15
|
+
def self.from_environment(environment = ENV.to_h, home: Dir.home)
|
|
16
|
+
state = environment["XDG_STATE_HOME"].to_s
|
|
17
|
+
new(File.join(state.empty? ? File.join(home, ".local", "state") : state, "principles", "request-logging"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#: String
|
|
21
|
+
attr_reader :path
|
|
22
|
+
|
|
23
|
+
#: (String) -> void
|
|
24
|
+
def initialize(path)
|
|
25
|
+
@path = path
|
|
26
|
+
freeze
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
#: () -> bool
|
|
30
|
+
def exist? = File.directory?(@path)
|
|
31
|
+
|
|
32
|
+
# Makes the folder and its requests/, each readable only by this user, tightening either that was wider, since
|
|
33
|
+
# the host writes each request readable by every user (022 F2); gives whether the folder was new.
|
|
34
|
+
#: () -> bool
|
|
35
|
+
def create
|
|
36
|
+
made = !exist?
|
|
37
|
+
[@path, requests_path].each do |folder|
|
|
38
|
+
FileUtils.mkdir_p(folder)
|
|
39
|
+
File.chmod(0o700, folder)
|
|
40
|
+
end
|
|
41
|
+
made
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The host's requests/ folder here, where it writes every project's requests.
|
|
45
|
+
#: () -> CapturedRequests
|
|
46
|
+
def requests = CapturedRequests.new(requests_path)
|
|
47
|
+
|
|
48
|
+
# The host's requests/ folder here, by its path, as the user's settings name it.
|
|
49
|
+
#: () -> String
|
|
50
|
+
def requests_path = File.join(@path, RequestLoggingFolder::REQUESTS)
|
|
51
|
+
|
|
52
|
+
# The request-logging folder of the checkout at root, which holds the sessions registered to its repository.
|
|
53
|
+
#: (String) -> RequestLoggingFolder
|
|
54
|
+
def registry_folder(root) = RequestLoggingFolder.new(root)
|
|
55
|
+
|
|
56
|
+
# The main checkouts whose hook registered a session, one root a line, so a prune can read every registry.
|
|
57
|
+
PROJECTS = "projects"
|
|
58
|
+
|
|
59
|
+
# Each main checkout listed, in the order it was added; none while the list is absent.
|
|
60
|
+
#: () -> Array[String]
|
|
61
|
+
def project_roots
|
|
62
|
+
path = File.join(@path, PROJECTS)
|
|
63
|
+
File.file?(path) ? File.readlines(path, chomp: true).reject(&:empty?) : []
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Adds root to the end of the list.
|
|
67
|
+
#: (String) -> void
|
|
68
|
+
def add_project_root(root)
|
|
69
|
+
File.open(File.join(@path, PROJECTS), "a", 0o600) { it.write("#{root}\n") }
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -8,10 +8,12 @@ module Principles
|
|
|
8
8
|
# against what its command takes.
|
|
9
9
|
class InvocationOptions
|
|
10
10
|
# The options that take a value; --help, -h and --version take none.
|
|
11
|
-
VALUE_OPTIONS = %w[project file description path section starting-at ending-at query role
|
|
12
|
-
check session-start commits-after hook-event as instruction
|
|
11
|
+
VALUE_OPTIONS = %w[project file description path section starting-at ending-at query role name
|
|
12
|
+
reason check plugin session-start commits-after hook-event as instruction
|
|
13
|
+
keep-sessions session].freeze #: Array[String]
|
|
13
14
|
# The options that take no value, as list-member-problems --short.
|
|
14
|
-
FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm open-findings history
|
|
15
|
+
FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm open-findings history
|
|
16
|
+
loads findings places for-user].freeze #: Array[String]
|
|
15
17
|
# The options that may be given more than once, each value kept in order, as change-activation --when-files and
|
|
16
18
|
# start-audit --member and --part.
|
|
17
19
|
LIST_OPTIONS = %w[when-files also only member part].freeze #: Array[String]
|
data/lib/principles/launch.rb
CHANGED
|
@@ -5,16 +5,25 @@ require "tmpdir"
|
|
|
5
5
|
require_relative "version"
|
|
6
6
|
require_relative "data/running_version"
|
|
7
7
|
require_relative "data/principles_on_path"
|
|
8
|
+
require_relative "data/tools_on_path"
|
|
9
|
+
require_relative "controllers/command"
|
|
8
10
|
require_relative "controllers/running_tool"
|
|
9
11
|
|
|
10
12
|
module Principles
|
|
11
|
-
# This process as its entry point launched it: the executable that entry point names itself by, the
|
|
12
|
-
# launched as, PATH, the folder it started in and its temporary folder, read here so
|
|
13
|
-
# gives every controller the same RunningTool.
|
|
13
|
+
# This process as its entry point launched it: the executable that entry point names itself by, the Gemfile bundler
|
|
14
|
+
# runs it under, the file it was launched as, PATH, the folder it started in and its temporary folder, read here so
|
|
15
|
+
# that no layer reads them. It gives every controller the same RunningTool.
|
|
14
16
|
class Launch
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
# This process as exe/principles launched it, under bundle exec or not: a BUNDLE_GEMFILE left set with no
|
|
18
|
+
# bundler loaded is not a run under bundler. Only the entry point asks, so a run in process keeps its own.
|
|
19
|
+
#: () -> Launch
|
|
20
|
+
def self.of_this_process = new(bundle_gemfile: (ENV.fetch("BUNDLE_GEMFILE", nil) if defined?(::Bundler)))
|
|
21
|
+
|
|
22
|
+
# bundle_gemfile is the Gemfile bundler runs this process under, or nil when it runs without bundler.
|
|
23
|
+
#: (?String, ?bundle_gemfile: String?) -> void
|
|
24
|
+
def initialize(executable = Controllers::Command::INVOCATION, bundle_gemfile: nil)
|
|
17
25
|
@executable = executable
|
|
26
|
+
@bundle_gemfile = bundle_gemfile
|
|
18
27
|
freeze
|
|
19
28
|
end
|
|
20
29
|
|
|
@@ -22,15 +31,22 @@ module Principles
|
|
|
22
31
|
# each read only when a command needs it.
|
|
23
32
|
#: () -> Controllers::RunningTool
|
|
24
33
|
def running_tool
|
|
25
|
-
Controllers::RunningTool.new(executable: @executable, version: -> { running_version },
|
|
26
|
-
other_on_path: ->(asking) { on_path.other(asking) },
|
|
27
|
-
launched_on_path: -> { on_path.own_first? },
|
|
34
|
+
Controllers::RunningTool.new(executable: @executable, version: -> { running_version }, on_path: path_says,
|
|
28
35
|
folders: Controllers::RunningTool::Folders.new(cwd: started_in,
|
|
29
|
-
temp_directory: Dir.tmpdir)
|
|
36
|
+
temp_directory: Dir.tmpdir),
|
|
37
|
+
bundle_gemfile: @bundle_gemfile)
|
|
30
38
|
end
|
|
31
39
|
|
|
32
40
|
private
|
|
33
41
|
|
|
42
|
+
# What PATH says of this run, each fact read only when a command asks for it.
|
|
43
|
+
#: () -> Controllers::RunningTool::OnPath
|
|
44
|
+
def path_says
|
|
45
|
+
Controllers::RunningTool::OnPath.new(other: ->(asking) { on_path.other(asking) },
|
|
46
|
+
launched: -> { on_path.own_first? },
|
|
47
|
+
tool: ->(tool) { Data::ToolsOnPath.new(path).include?(tool) })
|
|
48
|
+
end
|
|
49
|
+
|
|
34
50
|
# The folder this run was started in, by its real path, as a project's root is given, or nil when it is gone.
|
|
35
51
|
#: () -> String?
|
|
36
52
|
def started_in
|
|
@@ -42,7 +58,10 @@ module Principles
|
|
|
42
58
|
# The principles on PATH, against this run's own file: the plugin's bin or a RubyGems binstub when either
|
|
43
59
|
# launched it, else this tool's executable.
|
|
44
60
|
#: () -> Data::PrinciplesOnPath
|
|
45
|
-
def on_path = Data::PrinciplesOnPath.new(
|
|
61
|
+
def on_path = Data::PrinciplesOnPath.new(path, own: File.expand_path($PROGRAM_NAME))
|
|
62
|
+
|
|
63
|
+
#: () -> String
|
|
64
|
+
def path = ENV.fetch("PATH", "")
|
|
46
65
|
|
|
47
66
|
# The version of this tool that is running, as a build stamped it or a checkout's commit gives it.
|
|
48
67
|
#: () -> String
|
|
@@ -37,7 +37,7 @@ module Principles
|
|
|
37
37
|
#: (untyped) -> Hash[String, untyped]?
|
|
38
38
|
def result(answer)
|
|
39
39
|
check = @member.check
|
|
40
|
-
|
|
40
|
+
stray if !check && answer.key?("check_result")
|
|
41
41
|
return unless check
|
|
42
42
|
|
|
43
43
|
sent = answer["check_result"] or missing
|
|
@@ -99,6 +99,16 @@ module Principles
|
|
|
99
99
|
)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
+
# Refuses an answer for a member with no check that reports a check_result, which its acknowledgement is
|
|
103
|
+
# accepted without, rather than dropping it unread.
|
|
104
|
+
#: () -> bot
|
|
105
|
+
def stray
|
|
106
|
+
raise CHECK_RESULT.refusal(
|
|
107
|
+
Error.new("invalid_check_result", "the member has no check, so its acknowledgement takes no check_result",
|
|
108
|
+
"Remove check_result from this acknowledgement.")
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
|
|
102
112
|
#: (String) -> bot
|
|
103
113
|
def refuse(why) = AcknowledgementRefusal.new(@member, @principle_id).refuse(why)
|
|
104
114
|
end
|
|
@@ -109,6 +109,11 @@ module Principles
|
|
|
109
109
|
{ "deferred_findings" => findings_on_member("deferred"), "accepted_findings" => findings_on_member("accepted") }
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
+
# The ids of the findings the last audit left open on this member, deferred then accepted, which accepting
|
|
113
|
+
# the acknowledgement leaves open, since only a full audit decides a finding.
|
|
114
|
+
#: () -> Array[String]
|
|
115
|
+
def open_finding_ids = open_findings.values.flatten
|
|
116
|
+
|
|
112
117
|
# Whether the last audit deferred a finding on this member, which acknowledging it leaves open for a full audit.
|
|
113
118
|
#: () -> bool
|
|
114
119
|
def keeps_deferred_findings? = findings_on_member("deferred").any?
|
|
@@ -11,7 +11,8 @@ module Principles
|
|
|
11
11
|
# to the full audit, but a member whose text is the one last judged needs nothing at all.
|
|
12
12
|
class AcknowledgementRefusal
|
|
13
13
|
# Why a one-member audit cannot judge member's change against record, or nil when it can: the record must
|
|
14
|
-
# be completed and have assessed the member, the member's text must differ from the one it assessed,
|
|
14
|
+
# be completed and have assessed the member, the member's text must differ from the one it assessed, it must
|
|
15
|
+
# be the project's, since a one-member audit reads its change from git, which holds no plugin's file, its check
|
|
15
16
|
# must be the one the record ran, so none new, changed, removed or last not run escapes a full audit's review.
|
|
16
17
|
# The one owner of these preconditions, which
|
|
17
18
|
# list-member-problems asks before offering the audit that Acknowledgement refuses by them; git is
|
|
@@ -19,21 +20,28 @@ module Principles
|
|
|
19
20
|
#: (AuditRecord, Member, now_sha256: String?) -> AcknowledgementRefusal?
|
|
20
21
|
def self.of(record, member, now_sha256:)
|
|
21
22
|
members = record.members
|
|
22
|
-
recorded = members.hash_for(member.key)
|
|
23
23
|
check = members.check_since(member.key, member.check)
|
|
24
|
-
reason =
|
|
25
|
-
|
|
26
|
-
elsif !recorded then :not_assessed
|
|
27
|
-
elsif recorded == now_sha256 then :unchanged
|
|
28
|
-
elsif check != :unchanged then check
|
|
29
|
-
end
|
|
24
|
+
reason = baseline_missing(record, members.hash_for(member.key), now_sha256) ||
|
|
25
|
+
(:plugin if member.plugin_reference) || (check unless check == :unchanged)
|
|
30
26
|
new(member, record.principle_id, reason, ran: members.check_run_for(member.key)) if reason
|
|
31
27
|
end
|
|
32
28
|
|
|
29
|
+
# Why record gives no baseline to judge a change against, the member's hash it assessed being recorded and
|
|
30
|
+
# its hash now now_sha256: open, not completed, the member not assessed, or unchanged; nil when it gives one.
|
|
31
|
+
#: (AuditRecord, String?, String?) -> Symbol?
|
|
32
|
+
def self.baseline_missing(record, recorded, now_sha256)
|
|
33
|
+
if record.open_after_a_completed_audit? then :open
|
|
34
|
+
elsif !record.completed? then :not_completed
|
|
35
|
+
elsif !recorded then :not_assessed
|
|
36
|
+
elsif recorded == now_sha256 then :unchanged
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
private_class_method :baseline_missing
|
|
40
|
+
|
|
33
41
|
# principle_id is the member's principle, whose full audit each refusal names. reason, which raise! raises, is
|
|
34
|
-
# :open, :not_completed, :not_assessed, :unchanged, or how the member's check stands to the one the
|
|
35
|
-
# ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason
|
|
36
|
-
# only refuses for a reason its caller states.
|
|
42
|
+
# :open, :not_completed, :not_assessed, :unchanged, :plugin, or how the member's check stands to the one the
|
|
43
|
+
# record ran, as RecordedMembers#check_since says; ran is the command that record ran, if any. Without a reason
|
|
44
|
+
# it only refuses for a reason its caller states.
|
|
37
45
|
#: (Member, String, ?Symbol?, ?ran: String?) -> void
|
|
38
46
|
def initialize(member, principle_id, reason = nil, ran: nil)
|
|
39
47
|
@reason = reason
|
|
@@ -58,6 +66,7 @@ module Principles
|
|
|
58
66
|
when :open then open_audit
|
|
59
67
|
when :not_completed then refuse("#{@principle_id} has no completed audit, so no baseline has been judged")
|
|
60
68
|
when :not_assessed then refuse("no completed audit assessed #{@member.id}")
|
|
69
|
+
when :plugin then refuse("it is read from an installed plugin, whose changes git holds no history of")
|
|
61
70
|
else refuse("#{check_since_record}, so a full audit reviews it")
|
|
62
71
|
end
|
|
63
72
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "list_member_problems_check"
|
|
5
|
+
require_relative "member_problems"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# The one-member audits list-member-problems offers across maps: the changed members each may judge, joined
|
|
11
|
+
# where principles share one, leaving out the principles whose records wait on an upgrade.
|
|
12
|
+
class AcknowledgementsToOffer
|
|
13
|
+
# maps is each map's MemberProblems; except, the principles whose records wait on an upgrade.
|
|
14
|
+
#: (Array[MemberProblems], except: Array[String]) -> void
|
|
15
|
+
def initialize(maps, except:)
|
|
16
|
+
@maps = maps
|
|
17
|
+
@except = except
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Each set of principle ids, in id order, with the members they acknowledge together, those of principles that
|
|
22
|
+
# share one joined in one acknowledgement across them. Each set holding a member last names comes after the
|
|
23
|
+
# others.
|
|
24
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
25
|
+
def together = offered.partition { |_ids, members| !members.intersect?(last) }.flatten(1).to_h
|
|
26
|
+
|
|
27
|
+
# The acknowledgeable members whose check is this tool's own list-member-problems --short, which refuses their
|
|
28
|
+
# acknowledgement while it lists a member the answer leaves out, so they are acknowledged after the others;
|
|
29
|
+
# none whose set holds every member --short lists, since nothing else is to come first.
|
|
30
|
+
#: () -> Array[String]
|
|
31
|
+
def last
|
|
32
|
+
sets = offered.values
|
|
33
|
+
self_checked.select { |id| sets.find { it.include?(id) }&.then { listed_beside?(it) } }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# The sets to offer: those grouped, with every set holding a member --short checks joined into one across their
|
|
39
|
+
# principles, since apart each such member's check lists the other's and none could pass.
|
|
40
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
41
|
+
def offered
|
|
42
|
+
checking, others = grouped.partition { |_ids, members| members.intersect?(self_checked) }
|
|
43
|
+
return grouped if checking.length < 2
|
|
44
|
+
|
|
45
|
+
others.to_h.merge(checking.flat_map(&:first).uniq.sort => checking.flat_map(&:last).uniq)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The members, of every map, whose check is this tool's own list-member-problems --short.
|
|
49
|
+
#: () -> Array[String]
|
|
50
|
+
def self_checked
|
|
51
|
+
@maps.flat_map { |map| map.members.select { ListMemberProblemsCheck.of(it.check.to_s) }.map(&:id) }.uniq
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Each set of principle ids with the members they acknowledge together, in no set order.
|
|
55
|
+
#: () -> Hash[Array[String], Array[String]]
|
|
56
|
+
def grouped
|
|
57
|
+
acknowledgeable.reduce({}) do |joined, (id, members)|
|
|
58
|
+
@except.include?(id) ? joined : joining(joined, id, members)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Whether --short lists a member set leaves out: one changed, or one no audit has assessed, in a map whose
|
|
63
|
+
# record waits on no upgrade.
|
|
64
|
+
#: (Array[String]) -> bool
|
|
65
|
+
def listed_beside?(set)
|
|
66
|
+
acting = @maps.reject { @except.include?(it.principle_id) }
|
|
67
|
+
acting.any? { it.never_assessed.positive? } ||
|
|
68
|
+
acting.flat_map(&:entries).any? { it.fetch("state") == "changed" && !set.include?(it.fetch("id")) }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# For each map with a changed member a one-member audit may judge, the ids of those members.
|
|
72
|
+
#: () -> Hash[String, Array[String]]
|
|
73
|
+
def acknowledgeable
|
|
74
|
+
@maps.to_h { |map| [map.principle_id, map.acknowledgeable_member_ids] }.reject { |_, ids| ids.empty? }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# groups with principle id's members joined into each group that shares one of them, as one group.
|
|
78
|
+
#: (Hash[Array[String], Array[String]], String, Array[String]) -> Hash[Array[String], Array[String]]
|
|
79
|
+
def joining(groups, id, members)
|
|
80
|
+
joined = groups.select { |_ids, others| others.intersect?(members) }
|
|
81
|
+
rest = groups.reject { |ids, _others| joined.key?(ids) }
|
|
82
|
+
rest.merge([*joined.keys.flatten, id].sort => [*joined.values.flatten, *members].uniq)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -31,6 +31,10 @@ module Principles
|
|
|
31
31
|
#: Integer
|
|
32
32
|
attr_reader :started
|
|
33
33
|
|
|
34
|
+
# The session's directory, whose project and its worktrees are the only repositories reported on.
|
|
35
|
+
#: String
|
|
36
|
+
attr_reader :session_directory
|
|
37
|
+
|
|
34
38
|
# The hook's input as the process it runs in reads it, the one owner of that reading for the executable, before
|
|
35
39
|
# the rest of this tool loads, and for the command: started at clock, unless environment's PRINCIPLES_HOOK_NOW,
|
|
36
40
|
# a test seam no session sets, gives the second; with home as ~; and for input naming no cwd, the session's
|
|
@@ -48,6 +52,7 @@ module Principles
|
|
|
48
52
|
given = parsed(text)
|
|
49
53
|
@event = EVENTS.find { it == given["hook_event_name"] } #: String?
|
|
50
54
|
@started = started_before(now, given["duration_ms"]) #: Integer
|
|
55
|
+
@session_directory = fallback
|
|
51
56
|
@cwd = text(given["cwd"]) || fallback #: String
|
|
52
57
|
tool_input = given["tool_input"]
|
|
53
58
|
@command = (text(tool_input["command"]) if tool_input.is_a?(Hash)) || "" #: String
|
|
@@ -18,6 +18,9 @@ module Principles
|
|
|
18
18
|
LINK_REPAIR = "Give recorded_at as {\"url\": \"https://...\"}, the whole link to where it is written up, " \
|
|
19
19
|
"such as an issue, with no other field; or as {\"path\": ..., \"heading\": ...} for a file in " \
|
|
20
20
|
"the project."
|
|
21
|
+
# The two forms a recorded_at takes, which a repair asking for one names.
|
|
22
|
+
WRITE_UP_FORMS = "{\"path\": ..., \"heading\": ...} for a file in the project, or {\"url\": \"https://...\"} " \
|
|
23
|
+
"for a page outside it, such as an issue"
|
|
21
24
|
|
|
22
25
|
#: (^(Locator) -> void) -> void
|
|
23
26
|
def initialize(locate)
|
|
@@ -17,12 +17,19 @@ module Principles
|
|
|
17
17
|
new("base_commit" => base, "last_completed_revision" => record&.last_completed&.revision)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
# audited_change is the commit that last changed the map's file or a member's file at the base, which the id
|
|
21
|
+
# digests in place of the base, so a commit elsewhere leaves the id as it was; the base until given.
|
|
22
|
+
#: (Hash[String, untyped], ?String?) -> void
|
|
23
|
+
def initialize(fields, audited_change = fields["base_commit"])
|
|
22
24
|
@fields = fields
|
|
25
|
+
@audited_change = audited_change
|
|
23
26
|
freeze
|
|
24
27
|
end
|
|
25
28
|
|
|
29
|
+
# This basis, its id digesting commit, the last change to the files the audit reads at its base, nil outside git.
|
|
30
|
+
#: (String?) -> AssessmentBasis
|
|
31
|
+
def audited_at(commit) = AssessmentBasis.new(@fields, commit)
|
|
32
|
+
|
|
26
33
|
#: () -> Hash[String, untyped]
|
|
27
34
|
def to_h = @fields
|
|
28
35
|
|
|
@@ -41,7 +48,7 @@ module Principles
|
|
|
41
48
|
|
|
42
49
|
# What the request id digests of the basis, in a fixed order, so how the answer orders its keys changes nothing.
|
|
43
50
|
#: () -> Array[String?]
|
|
44
|
-
def digested = [
|
|
51
|
+
def digested = [@audited_change, revision]
|
|
45
52
|
end
|
|
46
53
|
end
|
|
47
54
|
end
|
|
@@ -16,6 +16,7 @@ require_relative "carried_assessments"
|
|
|
16
16
|
require_relative "prior_findings"
|
|
17
17
|
require_relative "decided_prior_findings"
|
|
18
18
|
require_relative "disposition"
|
|
19
|
+
require_relative "finding_outcomes"
|
|
19
20
|
require_relative "stale_request"
|
|
20
21
|
require_relative "map_change"
|
|
21
22
|
|
|
@@ -69,7 +70,7 @@ module Principles
|
|
|
69
70
|
def check_assessment_request(request_id, basis:, committed:, record:, loads:, &started_from)
|
|
70
71
|
prior = prior_findings(record)
|
|
71
72
|
now_id = assessment_id(basis, prior.digested, loads.listed)
|
|
72
|
-
return prior if now_id == request_id && (basis.base.nil? || committed ==
|
|
73
|
+
return prior if now_id == request_id && (basis.base.nil? || committed == in_project_now)
|
|
73
74
|
|
|
74
75
|
raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false,
|
|
75
76
|
map_change: map_change(request_id, basis, record, loads,
|
|
@@ -149,16 +150,10 @@ module Principles
|
|
|
149
150
|
before
|
|
150
151
|
end
|
|
151
152
|
|
|
152
|
-
#
|
|
153
|
-
# what a deferral says it waits on, if anything.
|
|
154
|
-
# Then each prior finding kept; a new finding that raises one again keeps when it was first raised.
|
|
153
|
+
# The findings the completed audit records, as FindingOutcomes gives them.
|
|
155
154
|
#: (Array[untyped], Array[Disposition], ?DecidedPriorFindings) -> Array[untyped]
|
|
156
155
|
def outcomes(findings, dispositions, prior = DecidedPriorFindings::NONE)
|
|
157
|
-
findings
|
|
158
|
-
id = finding.fetch("id")
|
|
159
|
-
disposition = dispositions.find { |each| each.finding_id == id } or raise KeyError, id
|
|
160
|
-
finding.slice(*RecordedFinding::RAISED_FIELDS).merge(disposition.recorded_outcome, prior.first_raised(id))
|
|
161
|
-
end + prior.kept
|
|
156
|
+
FindingOutcomes.new(findings, dispositions, prior).recorded
|
|
162
157
|
end
|
|
163
158
|
|
|
164
159
|
# What each member's assessment is judged on beside its text, from each member's loads: its map entry and when
|
|
@@ -217,7 +212,12 @@ module Principles
|
|
|
217
212
|
# The ids of the members whose hash now differs from the one committed, the base commit's, gives; none
|
|
218
213
|
# outside git.
|
|
219
214
|
#: (Hash[String, String]?) -> Array[String]
|
|
220
|
-
def changed_since(committed) = committed ?
|
|
215
|
+
def changed_since(committed) = committed ? in_project_now.reject { |id, sha| committed[id] == sha }.keys : []
|
|
216
|
+
|
|
217
|
+
# Each hash now of a member in the project's own files, which a commit can hold, by id; a plugin's member,
|
|
218
|
+
# outside git, is compared only through the request id.
|
|
219
|
+
#: () -> Hash[String, String]
|
|
220
|
+
def in_project_now = members.in_project.ids.to_h { [it, @now.fetch(it)] }
|
|
221
221
|
|
|
222
222
|
#: () -> Error
|
|
223
223
|
def stale_request = StaleRequest.new(id).refusal
|
|
@@ -175,6 +175,11 @@ module Principles
|
|
|
175
175
|
kept ? AuditRecord.new(kept) : nil
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
+
# Whether it holds a completed audit other than written, a record just completed, so written is not the first
|
|
179
|
+
# to complete; a retry of written reads written back, so it is the first still.
|
|
180
|
+
#: (AuditRecord) -> bool
|
|
181
|
+
def completed_other_than?(written) = last_completed&.then { !it.same_as?(written) } || false
|
|
182
|
+
|
|
178
183
|
# This record with the member known by key moved to change's to_sha256, and change kept beside it.
|
|
179
184
|
# Nothing else changes: the map version, base commit and findings stay the audit's own.
|
|
180
185
|
# check_result is the result reported for the member's check, which replaces the one the record kept.
|
|
@@ -204,6 +209,11 @@ module Principles
|
|
|
204
209
|
#: () -> Array[String]
|
|
205
210
|
def open_ids = left_open.map(&:id)
|
|
206
211
|
|
|
212
|
+
# The ids of the findings it leaves open whose action is action, deferred or accepted, which a completed
|
|
213
|
+
# audit's result names apart.
|
|
214
|
+
#: (String) -> Array[String]
|
|
215
|
+
def left_open_ids(action) = left_open.select { it.action == action }.map(&:id)
|
|
216
|
+
|
|
207
217
|
# The ids of the findings it leaves open on the member known by key, which the next full audit decides beside
|
|
208
218
|
# it.
|
|
209
219
|
#: (String) -> Array[String]
|
|
@@ -155,9 +155,10 @@ module Principles
|
|
|
155
155
|
[file(record.principle_id), *record.cited_files(@history).committed_with(changed, reported)]
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
-
# Each file record cites that no longer exists, which files_to_commit leaves out
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
# Each file record cites that no longer exists, which files_to_commit leaves out, a plugin's file asked of
|
|
159
|
+
# plugins.
|
|
160
|
+
#: (AuditRecord, InstalledPlugins) -> Array[String]
|
|
161
|
+
def cited_files_missing(record, plugins) = record.cited_files(@history).missing(plugins)
|
|
161
162
|
|
|
162
163
|
# Writes record's file and names it, relative to the project.
|
|
163
164
|
#: (AuditRecord) -> String
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require_relative "assessment_report"
|
|
5
5
|
require_relative "json_digest"
|
|
6
6
|
require_relative "principle"
|
|
7
|
+
require_relative "stale_request"
|
|
7
8
|
|
|
8
9
|
module Principles
|
|
9
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -86,6 +87,14 @@ module Principles
|
|
|
86
87
|
#: (now: Hash[String, String]) -> Array[String]
|
|
87
88
|
def added(now:) = now.keys.reject { |id| began_with?(id) }
|
|
88
89
|
|
|
90
|
+
# Refuses an answer to this audit as stale once the text of a plugin member in now differs from the text the
|
|
91
|
+
# audit began with: an update to the installed plugin, which no fix can claim.
|
|
92
|
+
#: (now: Hash[String, String]) -> void
|
|
93
|
+
def check_plugin_members_unchanged(now:)
|
|
94
|
+
updated = changed(now:).select { @map.members.with_id(it)&.plugin_reference }
|
|
95
|
+
raise StaleRequest.plugin_updated(id, updated) if updated.any?
|
|
96
|
+
end
|
|
97
|
+
|
|
89
98
|
# The members whose hash in now differs from their hash when the audit began.
|
|
90
99
|
#: (now: Hash[String, String]) -> Array[String]
|
|
91
100
|
def changed(now:)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "locator"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# A new member's locator as its map stores it: its passage's opening without the indent it was quoted with, when
|
|
11
|
+
# that still names one place, so its id does not keep the spaces of a YAML key or a nested list item. The given
|
|
12
|
+
# opening contains the unindented one, so a lone occurrence of the unindented one is at the same place. A member
|
|
13
|
+
# already mapped keeps its locator, since its id is that locator and audit records file it under that id.
|
|
14
|
+
class AuthoredLocator
|
|
15
|
+
#: (Project, Locator) -> void
|
|
16
|
+
def initialize(project, locator)
|
|
17
|
+
@project = project
|
|
18
|
+
@locator = locator
|
|
19
|
+
freeze
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# The locator to store: the unindented one where it locates, else the one given.
|
|
23
|
+
#: () -> Locator
|
|
24
|
+
def stored
|
|
25
|
+
unindented = @locator.with_opening_unindented or return @locator
|
|
26
|
+
@project.locate_for_authoring(unindented)
|
|
27
|
+
unindented
|
|
28
|
+
rescue Error
|
|
29
|
+
@locator
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -50,9 +50,8 @@ module Principles
|
|
|
50
50
|
# name, which the budget cuts by.
|
|
51
51
|
#: (Array[Hash[String, untyped]]) -> Hash[String, CandidateOutline]
|
|
52
52
|
def outlines(test_data_hints)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(paths - test_data).to_h { |path| [path, CandidateOutline.new(@text_of.call(path))] }
|
|
53
|
+
outlined_paths(test_data_hints).to_h { |path| [path, outline_of(path)] }
|
|
54
|
+
.select { |path, outline| path.match?(MARKDOWN) || outline.sections.any? }
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
# Each Markdown or settings file, with its size, and a skill's entry file spelt otherwise than SKILL.md with its
|
|
@@ -76,6 +75,27 @@ module Principles
|
|
|
76
75
|
|
|
77
76
|
private
|
|
78
77
|
|
|
78
|
+
# The listed files the survey outlines: every one but those the test-data hints name.
|
|
79
|
+
#: (Array[Hash[String, untyped]]) -> Array[String]
|
|
80
|
+
def outlined_paths(test_data_hints)
|
|
81
|
+
test_data = hints(test_data_hints).map { |hint| hint.fetch("path") }
|
|
82
|
+
listed.map { |file| file.fetch("path") } - test_data
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The outline of one listed file, from its text: a Markdown file's by its headings and items, any other's by its
|
|
86
|
+
# comments.
|
|
87
|
+
#: (String) -> CandidateOutline
|
|
88
|
+
def outline_of(path) = CandidateOutline.new(@text_of.call(path), as: reader_for(path))
|
|
89
|
+
|
|
90
|
+
# What reads a file's outline: Markdown by its headings and items, a CI workflow by its jobs and steps, and any
|
|
91
|
+
# other text by its comments.
|
|
92
|
+
#: (String) -> (singleton(MarkdownText) | singleton(ScriptComments) | singleton(WorkflowJobs))
|
|
93
|
+
def reader_for(path)
|
|
94
|
+
return MarkdownText if path.match?(MARKDOWN)
|
|
95
|
+
|
|
96
|
+
path.match?(WorkflowJobs::PATH) ? WorkflowJobs : ScriptComments
|
|
97
|
+
end
|
|
98
|
+
|
|
79
99
|
# files with those changed names first, each marked changed_in_range, and the rest after, each in its order.
|
|
80
100
|
#: (Array[Hash[String, untyped]], Array[String]) -> Array[Hash[String, untyped]]
|
|
81
101
|
def changed_first(files, changed)
|