principles 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +383 -0
- data/LICENSE +202 -0
- data/NOTICE +4 -0
- data/README.md +111 -0
- data/exe/principles +20 -0
- data/lib/principles/after_commit_hook_options.rb +2 -2
- data/lib/principles/cli.rb +50 -42
- data/lib/principles/command_line.rb +22 -16
- data/lib/principles/command_routes.rb +20 -6
- data/lib/principles/controllers/acknowledgement.rb +29 -74
- data/lib/principles/controllers/acknowledgements.rb +154 -0
- data/lib/principles/controllers/after_commit_report.rb +44 -0
- data/lib/principles/controllers/answer.rb +48 -18
- data/lib/principles/controllers/answer_phase.rb +20 -3
- data/lib/principles/controllers/assessment.rb +32 -11
- data/lib/principles/controllers/audit.rb +43 -19
- data/lib/principles/controllers/audit_completion.rb +21 -12
- data/lib/principles/controllers/command.rb +13 -12
- data/lib/principles/controllers/correction.rb +15 -7
- data/lib/principles/controllers/first_audit_brief.rb +40 -0
- data/lib/principles/controllers/full_audit_request.rb +41 -82
- data/lib/principles/controllers/hook_setup.rb +49 -0
- data/lib/principles/controllers/inventory.rb +10 -8
- data/lib/principles/controllers/mapping.rb +2 -2
- data/lib/principles/controllers/member_acknowledgement.rb +32 -21
- data/lib/principles/controllers/member_entries.rb +4 -4
- data/lib/principles/controllers/member_problems_report.rb +62 -16
- data/lib/principles/controllers/members_a_commit_changed.rb +3 -3
- data/lib/principles/controllers/members_to_assess.rb +23 -20
- data/lib/principles/controllers/meta_principle_setup.rb +5 -6
- data/lib/principles/controllers/open_correction.rb +42 -0
- data/lib/principles/controllers/parts_to_read.rb +117 -0
- data/lib/principles/controllers/repoint.rb +1 -1
- data/lib/principles/controllers/running_tool.rb +56 -6
- data/lib/principles/controllers/session_start_report.rb +62 -0
- data/lib/principles/controllers/survey.rb +2 -2
- data/lib/principles/data/audit_files.rb +7 -7
- data/lib/principles/data/bounded_file.rb +1 -1
- data/lib/principles/data/candidate_files_found.rb +6 -3
- data/lib/principles/data/command-steps.json +61 -6
- data/lib/principles/data/expected_type.rb +3 -3
- data/lib/principles/data/first_parent_log.rb +1 -1
- data/lib/principles/data/head_reflog.rb +74 -0
- data/lib/principles/data/hook_input.rb +59 -0
- data/lib/principles/data/ignored_by_git.rb +2 -2
- data/lib/principles/data/known_fields.rb +1 -1
- data/lib/principles/data/linked_path.rb +1 -1
- data/lib/principles/data/map_files.rb +2 -2
- data/lib/principles/data/principles_on_path.rb +83 -0
- data/lib/principles/data/principles_subfolder.rb +1 -1
- data/lib/principles/data/project_files.rb +10 -3
- data/lib/principles/data/repository.rb +14 -7
- data/lib/principles/data/running_version.rb +10 -8
- data/lib/principles/data/schema_check.rb +5 -5
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +86 -21
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +9 -2
- data/lib/principles/data/schemas/assessment-answer.schema.json +43 -22
- data/lib/principles/data/schemas/audit-record.schema.json +29 -20
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +9 -9
- data/lib/principles/data/schemas/member-map.schema.json +3 -3
- data/lib/principles/data/schemas/repointing-answer.schema.json +1 -1
- data/lib/principles/error.rb +4 -4
- data/lib/principles/failure_refusal.rb +57 -0
- data/lib/principles/invocation_options.rb +4 -4
- data/lib/principles/launch.rb +49 -0
- data/lib/principles/list_open_findings_options.rb +1 -1
- data/lib/principles/models/accepted_loading.rb +2 -2
- data/lib/principles/models/acknowledged_check.rb +23 -11
- data/lib/principles/models/acknowledgement.rb +34 -18
- data/lib/principles/models/acknowledgement_left_as_printed.rb +7 -15
- data/lib/principles/models/acknowledgement_refusal.rb +25 -10
- data/lib/principles/models/acknowledgements.rb +45 -29
- data/lib/principles/models/acknowledgements_across.rb +68 -0
- data/lib/principles/models/activation.rb +2 -2
- data/lib/principles/models/after_commit_input.rb +115 -0
- data/lib/principles/models/agent_loads.rb +1 -1
- data/lib/principles/models/answer_fields.rb +2 -2
- data/lib/principles/models/answer_place.rb +3 -3
- data/lib/principles/models/answer_text.rb +2 -2
- data/lib/principles/models/answered_time.rb +4 -4
- data/lib/principles/models/assessment_answer.rb +10 -10
- data/lib/principles/models/assessment_basis.rb +2 -2
- data/lib/principles/models/assessment_left_as_printed.rb +1 -1
- data/lib/principles/models/assessment_report.rb +6 -7
- data/lib/principles/models/audit.rb +33 -34
- data/lib/principles/models/audit_record.rb +54 -28
- data/lib/principles/models/audit_records.rb +13 -13
- data/lib/principles/models/audit_start.rb +3 -3
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +18 -10
- data/lib/principles/models/candidate_inventory.rb +6 -6
- data/lib/principles/models/candidate_outline.rb +9 -9
- data/lib/principles/models/carried_assessments.rb +18 -3
- data/lib/principles/models/carried_member.rb +5 -5
- data/lib/principles/models/changed_regions.rb +92 -0
- data/lib/principles/models/check_result_guide.rb +50 -0
- data/lib/principles/models/check_since_last_audit.rb +5 -4
- data/lib/principles/models/cited_files.rb +4 -4
- data/lib/principles/models/command_steps.rb +3 -3
- data/lib/principles/models/commits_brought_in.rb +1 -1
- data/lib/principles/models/commits_since_base.rb +1 -1
- data/lib/principles/models/correction_answer.rb +2 -2
- data/lib/principles/models/correction_basis.rb +7 -7
- data/lib/principles/models/dated_line.rb +1 -2
- data/lib/principles/models/decided_prior_findings.rb +6 -6
- data/lib/principles/models/declared_map_changes.rb +5 -5
- data/lib/principles/models/disposition.rb +21 -21
- data/lib/principles/models/entry_file.rb +1 -1
- data/lib/principles/models/entry_files.rb +1 -1
- data/lib/principles/models/evidence_item.rb +1 -1
- data/lib/principles/models/evidence_lines_since.rb +2 -2
- data/lib/principles/models/evidence_replacements.rb +3 -3
- data/lib/principles/models/finding_write_ups.rb +12 -5
- data/lib/principles/models/findings_left_open.rb +4 -4
- data/lib/principles/models/first_full_audit.rb +32 -0
- data/lib/principles/models/first_raised_claim.rb +1 -1
- data/lib/principles/models/fix_only_fields.rb +1 -1
- data/lib/principles/models/head_moves.rb +66 -0
- data/lib/principles/models/hook_commands.rb +49 -4
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +2 -3
- data/lib/principles/models/json_digest.rb +2 -2
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/kept_prior_finding.rb +9 -9
- data/lib/principles/models/last_completed_revision.rb +4 -5
- data/lib/principles/models/left_as_printed.rb +2 -2
- data/lib/principles/models/line_diff.rb +113 -0
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/list_member_problems_check.rb +4 -4
- data/lib/principles/models/listed_members.rb +7 -9
- data/lib/principles/models/loaded_files.rb +4 -5
- data/lib/principles/models/loading_decision.rb +3 -3
- data/lib/principles/models/loading_facts.rb +1 -1
- data/lib/principles/models/loads_to_check.rb +1 -1
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/mapped_principles.rb +2 -2
- data/lib/principles/models/member.rb +31 -4
- data/lib/principles/models/member_assessments.rb +8 -8
- data/lib/principles/models/member_elsewhere.rb +4 -4
- data/lib/principles/models/member_file.rb +4 -4
- data/lib/principles/models/member_grounds.rb +1 -1
- data/lib/principles/models/member_hashes_as_written.rb +1 -1
- data/lib/principles/models/member_lines.rb +29 -61
- data/lib/principles/models/member_loads.rb +2 -2
- data/lib/principles/models/member_moves.rb +1 -1
- data/lib/principles/models/member_problems.rb +14 -15
- data/lib/principles/models/member_repair_moves.rb +15 -9
- data/lib/principles/models/member_sighting.rb +10 -10
- data/lib/principles/models/member_snapshots.rb +1 -1
- data/lib/principles/models/member_state.rb +1 -1
- data/lib/principles/models/members_across_principles.rb +77 -0
- data/lib/principles/models/members_elsewhere.rb +2 -2
- data/lib/principles/models/members_sharing_lines.rb +7 -7
- data/lib/principles/models/meta_principle.rb +11 -4
- data/lib/principles/models/missing_files.rb +3 -3
- data/lib/principles/models/new_findings.rb +4 -4
- data/lib/principles/models/open_correction.rb +57 -0
- data/lib/principles/models/open_finding.rb +36 -31
- data/lib/principles/models/open_findings_elsewhere.rb +2 -2
- data/lib/principles/models/other_principles.rb +2 -2
- data/lib/principles/models/other_templates_placeholders.rb +17 -16
- data/lib/principles/models/outline_budget.rb +7 -7
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +2 -2
- data/lib/principles/models/part_named.rb +41 -0
- data/lib/principles/models/placement.rb +2 -2
- data/lib/principles/models/principle.rb +13 -13
- data/lib/principles/models/principle_history.rb +8 -8
- data/lib/principles/models/principle_members.rb +14 -7
- data/lib/principles/models/principles_folder_move.rb +1 -1
- data/lib/principles/models/principles_on_path.rb +29 -0
- data/lib/principles/models/principles_package.rb +3 -3
- data/lib/principles/models/prior_decision_fields.rb +8 -8
- data/lib/principles/models/prior_finding_decision.rb +8 -8
- data/lib/principles/models/prior_finding_outcomes.rb +1 -1
- data/lib/principles/models/prior_findings.rb +5 -5
- data/lib/principles/models/problem_report.rb +26 -8
- data/lib/principles/models/project.rb +27 -19
- data/lib/principles/models/project_history.rb +18 -12
- data/lib/principles/models/quoted_change.rb +8 -8
- data/lib/principles/models/recent_decision.rb +3 -3
- data/lib/principles/models/record_format.rb +16 -10
- data/lib/principles/models/record_judged_against.rb +4 -4
- data/lib/principles/models/recorded_entry.rb +17 -8
- data/lib/principles/models/recorded_finding.rb +9 -9
- data/lib/principles/models/recorded_findings.rb +2 -2
- data/lib/principles/models/recorded_hashes.rb +2 -2
- data/lib/principles/models/recorded_members.rb +13 -13
- data/lib/principles/models/refusal_before_shape.rb +2 -2
- data/lib/principles/models/repoint.rb +3 -3
- data/lib/principles/models/report_hooks.rb +69 -0
- data/lib/principles/models/reported_check.rb +34 -31
- data/lib/principles/models/request_id.rb +18 -6
- data/lib/principles/models/runs_from.rb +7 -2
- data/lib/principles/models/sent_answer.rb +14 -12
- data/lib/principles/models/sent_prior_decisions.rb +1 -1
- data/lib/principles/models/session_start_input.rb +37 -0
- data/lib/principles/models/shape_problems_beside.rb +1 -1
- data/lib/principles/models/skill_loads.rb +1 -1
- data/lib/principles/models/stale_request.rb +59 -0
- data/lib/principles/models/still_holds_restatement.rb +6 -6
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/template_placeholders.rb +6 -6
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/tracked_paths.rb +38 -0
- data/lib/principles/models/unchecked_members.rb +2 -2
- data/lib/principles/models/uncommitted_files.rb +1 -1
- data/lib/principles/models/uncommitted_outside_the_map.rb +2 -2
- data/lib/principles/models/waits_on.rb +1 -1
- data/lib/principles/models/write_up_opening.rb +5 -5
- data/lib/principles/models/write_up_pointer.rb +3 -3
- data/lib/principles/models/write_up_repoint.rb +2 -3
- data/lib/principles/positional_arguments.rb +13 -6
- data/lib/principles/prose_list.rb +1 -1
- data/lib/principles/session_start_options.rb +1 -1
- data/lib/principles/start_audit_options.rb +46 -12
- data/lib/principles/supported_ruby.rb +24 -7
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_since_last_audit.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +97 -11
- data/lib/principles/views/activation_in_hand.rb +1 -1
- data/lib/principles/views/answered_request.rb +6 -2
- data/lib/principles/views/assessed_members.rb +50 -41
- data/lib/principles/views/assessment_request.rb +39 -36
- data/lib/principles/views/audit_changes.rb +4 -4
- data/lib/principles/views/audit_commit.rb +5 -4
- data/lib/principles/views/audit_result.rb +92 -53
- data/lib/principles/views/candidate_files_result.rb +7 -6
- data/lib/principles/views/check_notes.rb +29 -6
- data/lib/principles/views/check_result_template.rb +45 -34
- data/lib/principles/views/completed_audit_next_step.rb +44 -0
- data/lib/principles/views/context_parts.rb +112 -0
- data/lib/principles/views/correction_request.rb +44 -25
- data/lib/principles/views/diff_since_last_audit.rb +8 -6
- data/lib/principles/views/findings_result.rb +17 -6
- data/lib/principles/views/first_audit_brief.rb +51 -0
- data/lib/principles/views/first_audit_line.rb +45 -0
- data/lib/principles/views/help.rb +4 -4
- data/lib/principles/views/hook_setup_result.rb +91 -0
- data/lib/principles/views/instruction.rb +3 -3
- data/lib/principles/views/invocation.rb +14 -6
- data/lib/principles/views/json_with_entries_on_lines.rb +6 -35
- data/lib/principles/views/landed_since_base.rb +1 -1
- data/lib/principles/views/line_history_since_last_audit.rb +35 -0
- data/lib/principles/views/lines_shared_with_member.rb +6 -6
- data/lib/principles/views/loads_to_check_result.rb +8 -5
- data/lib/principles/views/map_added_to.rb +3 -3
- data/lib/principles/views/map_result.rb +9 -9
- data/lib/principles/views/member_change_since_baseline.rb +44 -23
- data/lib/principles/views/member_lines_beside_text.rb +43 -0
- data/lib/principles/views/member_repairs.rb +3 -2
- data/lib/principles/views/member_row.rb +2 -2
- data/lib/principles/views/members_a_commit_changed.rb +13 -10
- data/lib/principles/views/members_with_no_baseline.rb +3 -3
- data/lib/principles/views/meta_principle_passage.rb +1 -1
- data/lib/principles/views/meta_principle_result.rb +12 -5
- data/lib/principles/views/one_member_check_result_template.rb +7 -7
- data/lib/principles/views/open_findings_elsewhere_result.rb +5 -2
- data/lib/principles/views/open_findings_line.rb +25 -36
- data/lib/principles/views/other_principles_unjudged_result.rb +6 -3
- data/lib/principles/views/outside_the_map_result.rb +5 -2
- data/lib/principles/views/package_since_last_audit_result.rb +29 -6
- data/lib/principles/views/parts_index_result.rb +60 -0
- data/lib/principles/views/principle_read_result.rb +5 -6
- data/lib/principles/views/principle_with_changed_members.rb +1 -1
- data/lib/principles/views/principles_with_no_completed_audit.rb +1 -2
- data/lib/principles/views/printed_json.rb +51 -0
- data/lib/principles/views/printed_principle.rb +1 -1
- data/lib/principles/views/prior_finding_decisions_result.rb +4 -4
- data/lib/principles/views/prior_findings_result.rb +17 -14
- data/lib/principles/views/problem_lines.rb +39 -17
- data/lib/principles/views/problem_result.rb +40 -37
- data/lib/principles/views/prompts/acknowledge-a-change/judge-each-member-once-for-every-principle.md +2 -0
- data/lib/principles/views/prompts/acknowledge-a-change/read-the-deferred-findings-it-keeps.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/resolve-them-in-a-full-audit.md +1 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +3 -3
- data/lib/principles/views/prompts/assess-every-member/confirm-each-write-up-pointer-the-answer-drops.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/judge-a-carried-assessment-citing-a-decided-finding.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/judge-a-submitted-carried-assessment-citing-a-decided-finding.md +5 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/keep-the-printed-review-basis-or-replace-it.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/name-the-commit-that-made-the-check.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +3 -2
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +4 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +6 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/report-after-commit.md +14 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +26 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +20 -18
- data/lib/principles/views/prompts/learn-what-a-command-does/show-first-audit-brief.md +19 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +3 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +21 -22
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +5 -4
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -2
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +18 -0
- data/lib/principles/views/prompts/set-principles-up/offer-the-report-hooks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/wire-the-report-hooks-with-the-user.md +8 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +3 -4
- data/lib/principles/views/prompts/start-a-session/every-loaded-line-costs-every-session.md +1 -1
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +3 -0
- data/lib/principles/views/prompts/start-a-session/run-each-command-above.md +1 -0
- data/lib/principles/views/prompts/start-a-session/start-no-second-first-audit.md +2 -0
- data/lib/principles/views/prompts.rb +1 -1
- data/lib/principles/views/read_the_change.rb +36 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +2 -2
- data/lib/principles/views/repoint_result.rb +1 -1
- data/lib/principles/views/report_hooks_offer.rb +25 -0
- data/lib/principles/views/request_part.rb +5 -5
- data/lib/principles/views/request_parts.rb +1 -1
- data/lib/principles/views/session_start_report.rb +46 -0
- data/lib/principles/views/shell_word.rb +1 -1
- data/lib/principles/views/trimmed_instructions_note.rb +30 -0
- data/lib/principles/views/visible_text.rb +1 -1
- data/lib/principles/views/workflow_diagram.rb +1 -1
- data/principles.gemspec +44 -0
- metadata +83 -14
- data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +0 -1
- data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +0 -1
|
@@ -9,7 +9,7 @@ require_relative "sent_answer"
|
|
|
9
9
|
module Principles
|
|
10
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
11
|
module Models
|
|
12
|
-
# Several members of one principle acknowledged in one request and one answer
|
|
12
|
+
# Several members of one principle acknowledged in one request and one answer: each member's entry is
|
|
13
13
|
# judged as its own one-member answer would be, and the answer is accepted for every member, in one record, or
|
|
14
14
|
# refused for all, so no baseline moves unless each does.
|
|
15
15
|
class Acknowledgements
|
|
@@ -19,6 +19,36 @@ module Principles
|
|
|
19
19
|
#: (String) -> String
|
|
20
20
|
def self.entry_pointer(member_id) = "/members/#{member_id.gsub("~", "~0").gsub("/", "~1")}"
|
|
21
21
|
|
|
22
|
+
# The refusal of an answer whose members leave out each of missing or answer each of extra, which no member of
|
|
23
|
+
# it is acknowledged under, named_by the basis field that names its members; nil when it does neither.
|
|
24
|
+
#: (missing: Array[String], extra: Array[String], ?named_by: String) -> Error?
|
|
25
|
+
def self.unmatched(missing:, extra:, named_by: "basis.member_ids")
|
|
26
|
+
fields = missing.map { problem(it, "is required, since #{named_by} names it") } +
|
|
27
|
+
extra.map { problem(it, "is not a member #{named_by} names") }
|
|
28
|
+
return if fields.empty?
|
|
29
|
+
|
|
30
|
+
Error.new("invalid_answer", "#{SentAnswer::NAMED} does not answer each member it names, so no member is " \
|
|
31
|
+
"acknowledged", SentAnswer::REPAIR, fields:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# The problem with the answer's entry for member_id, at its JSON pointer.
|
|
35
|
+
#: (String, String) -> Hash[String, String]
|
|
36
|
+
def self.problem(member_id, text) = { "pointer" => entry_pointer(member_id), "problem" => text }
|
|
37
|
+
private_class_method :problem
|
|
38
|
+
|
|
39
|
+
# What the block gives for member_id's entry, a refusal of a field in it pointing at that field in the entry,
|
|
40
|
+
# since a member's acknowledgement points from the entry's root, for one member's answer too.
|
|
41
|
+
#: (String) { () -> AuditRecord } -> AuditRecord
|
|
42
|
+
def self.in_entry(member_id, &)
|
|
43
|
+
yield
|
|
44
|
+
rescue Error => e
|
|
45
|
+
fields = e.payload["fields"]
|
|
46
|
+
raise unless fields
|
|
47
|
+
|
|
48
|
+
entry = Acknowledgements.entry_pointer(member_id)
|
|
49
|
+
raise e.including("fields" => fields.map { it.merge("pointer" => entry + it.fetch("pointer")) })
|
|
50
|
+
end
|
|
51
|
+
|
|
22
52
|
# The members as members names them, each id beside its one-member request's id, in the order named; refused
|
|
23
53
|
# when one is named twice, which the answer would then judge once.
|
|
24
54
|
#: (principle_id: String, members: Array[[String, RequestId]]) -> Acknowledgements
|
|
@@ -41,6 +71,15 @@ module Principles
|
|
|
41
71
|
freeze
|
|
42
72
|
end
|
|
43
73
|
|
|
74
|
+
# The members it acknowledges, in the order they were named.
|
|
75
|
+
#: () -> Array[String]
|
|
76
|
+
def member_ids = @requests.keys
|
|
77
|
+
|
|
78
|
+
# The members it acknowledges, each as its principle id and member id, as a member's own list-member-problems
|
|
79
|
+
# check lists them.
|
|
80
|
+
#: () -> Array[[String, String]]
|
|
81
|
+
def acknowledging = member_ids.map { [@principle_id, it] }
|
|
82
|
+
|
|
44
83
|
# The request's id: each member's one-member request id, sorted, so it depends on which members it asks
|
|
45
84
|
# about and on everything each of their requests depends on, not on the order they were named in.
|
|
46
85
|
#: () -> RequestId
|
|
@@ -57,42 +96,19 @@ module Principles
|
|
|
57
96
|
refuse_unmatched(entries.keys)
|
|
58
97
|
ids = @requests.keys
|
|
59
98
|
first = ids.fetch(0)
|
|
60
|
-
|
|
61
|
-
|
|
99
|
+
accepted_first = Acknowledgements.in_entry(first) { accept.call(first, entries.fetch(first), nil) }
|
|
100
|
+
ids.drop(1).reduce(accepted_first) do |record, id|
|
|
101
|
+
Acknowledgements.in_entry(id) { accept.call(id, entries.fetch(id), record) }
|
|
62
102
|
end
|
|
63
103
|
end
|
|
64
104
|
|
|
65
105
|
private
|
|
66
106
|
|
|
67
|
-
# What the block gives for member_id's entry, a refusal of a field in it pointing at that field in the entry,
|
|
68
|
-
# since a member's acknowledgement points from the entry's root as an answer to one member does (#1276).
|
|
69
|
-
#: (String) { () -> AuditRecord } -> AuditRecord
|
|
70
|
-
def in_entry(member_id, &)
|
|
71
|
-
yield
|
|
72
|
-
rescue Error => e
|
|
73
|
-
fields = e.payload["fields"]
|
|
74
|
-
raise unless fields
|
|
75
|
-
|
|
76
|
-
entry = Acknowledgements.entry_pointer(member_id)
|
|
77
|
-
raise e.including("fields" => fields.map { it.merge("pointer" => entry + it.fetch("pointer")) })
|
|
78
|
-
end
|
|
79
|
-
|
|
80
107
|
# Refuses the answer whole unless its members hold an entry for each member its basis names, and for no other.
|
|
81
108
|
#: (Array[String]) -> void
|
|
82
109
|
def refuse_unmatched(answered)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fields = missing + extra
|
|
86
|
-
return if fields.empty?
|
|
87
|
-
|
|
88
|
-
raise Error.new("invalid_answer", "#{SentAnswer::NAMED} does not answer each member it names, so no member " \
|
|
89
|
-
"is acknowledged", SentAnswer::REPAIR, fields:)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# The problem with the answer's entry for member_id, at its JSON pointer.
|
|
93
|
-
#: (String, String) -> Hash[String, String]
|
|
94
|
-
def problem(member_id, text)
|
|
95
|
-
{ "pointer" => Acknowledgements.entry_pointer(member_id), "problem" => text }
|
|
110
|
+
refusal = Acknowledgements.unmatched(missing: @requests.keys - answered, extra: answered - @requests.keys)
|
|
111
|
+
raise refusal if refusal
|
|
96
112
|
end
|
|
97
113
|
end
|
|
98
114
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "acknowledgements"
|
|
5
|
+
require_relative "request_id"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# Members that several principles map, acknowledged for each of them in one request and one answer: one
|
|
11
|
+
# judgement per member, read as each principle's own acknowledgement of it, so one edit is judged once, not once
|
|
12
|
+
# per principle.
|
|
13
|
+
class AcknowledgementsAcross
|
|
14
|
+
# by_principle holds each principle's acknowledgement of the members it maps, under its id, and checked the ids
|
|
15
|
+
# of the members each one gives a check, under its id.
|
|
16
|
+
#: (Hash[String, Acknowledgements], ?checked: Hash[String, Array[String]]) -> void
|
|
17
|
+
def initialize(by_principle, checked: {})
|
|
18
|
+
@by_principle = by_principle.sort.to_h #: Hash[String, Acknowledgements]
|
|
19
|
+
@checked = checked
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The request's id: each principle's own request id for its members, sorted, under the first principle's id, so
|
|
24
|
+
# it depends on which principles and members it asks about, not on the order they were named in.
|
|
25
|
+
#: () -> RequestId
|
|
26
|
+
def request_id
|
|
27
|
+
RequestId.for(principle_id: @by_principle.keys.fetch(0), phase: Acknowledgements::PHASE,
|
|
28
|
+
parts: @by_principle.values.map { it.request_id.to_s }.sort)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Every member some principle acknowledges, each once, in the order the principles name them.
|
|
32
|
+
#: () -> Array[String]
|
|
33
|
+
def member_ids = @by_principle.values.flat_map(&:member_ids).uniq
|
|
34
|
+
|
|
35
|
+
# The members it acknowledges for every principle, each as its principle id and member id, which a member's own
|
|
36
|
+
# list-member-problems check may list beside its own principle's.
|
|
37
|
+
#: () -> Array[[String, String]]
|
|
38
|
+
def acknowledging = @by_principle.values.flat_map(&:acknowledging)
|
|
39
|
+
|
|
40
|
+
# Each principle's record with its members' baselines moved, once the answer holds an entry for each member and
|
|
41
|
+
# no other: accept is given each principle's id, its acknowledgements and the answer as one to its members
|
|
42
|
+
# alone, and gives its record, or refuses the whole answer, so no record is written unless each is accepted. A
|
|
43
|
+
# member's check_result reports one run of its check, which answers each principle that checks the member, and
|
|
44
|
+
# is left out of the answer to a principle that does not.
|
|
45
|
+
#: (untyped) { (String, Acknowledgements, untyped) -> AuditRecord } -> Array[AuditRecord]
|
|
46
|
+
def accepted(answer, &accept)
|
|
47
|
+
entries = answer.fetch("members")
|
|
48
|
+
refusal = Acknowledgements.unmatched(missing: member_ids - entries.keys, extra: entries.keys - member_ids)
|
|
49
|
+
raise refusal if refusal
|
|
50
|
+
|
|
51
|
+
@by_principle.map do |id, several|
|
|
52
|
+
accept.call(id, several, answer.merge("members" => entries_for(id, entries.slice(*several.member_ids))))
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# entries as principle id reads them: a member's check_result left out where id does not check the member.
|
|
59
|
+
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
60
|
+
def entries_for(id, entries)
|
|
61
|
+
checked = @checked.fetch(id, [])
|
|
62
|
+
entries.to_h do |member_id, entry|
|
|
63
|
+
[member_id, checked.include?(member_id) ? entry : entry.except("check_result")]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -6,7 +6,7 @@ require_relative "../error"
|
|
|
6
6
|
module Principles
|
|
7
7
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
|
-
# When a principle's work is in hand, as the agent judged it
|
|
9
|
+
# When a principle's work is in hand, as the agent judged it: when files matching its globs are read or
|
|
10
10
|
# changed, when its work is invoked, or always. This tool stores what the agent declared and does not choose it.
|
|
11
11
|
class Activation
|
|
12
12
|
FORMS = "Give exactly one of --when-files GLOB (repeat it for each glob), --when-invoked, or --always."
|
|
@@ -40,7 +40,7 @@ module Principles
|
|
|
40
40
|
|
|
41
41
|
# What a full audit lists against this activation for the agent to weigh: the members that load at every
|
|
42
42
|
# session start under a files activation; none under always, where the work is in hand in every session; and,
|
|
43
|
-
# under invoked, a listing not built yet
|
|
43
|
+
# under invoked, a listing not built yet.
|
|
44
44
|
#: () -> String
|
|
45
45
|
def full_audit_lists
|
|
46
46
|
case @fields.fetch("when")
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
module Models
|
|
8
|
+
# The JSON a host hands its hook after each shell call, as report-after-commit reads it: the event it ran on,
|
|
9
|
+
# when the call started, and the directories whose repositories the call may have committed in. Input it cannot
|
|
10
|
+
# read names no event, so the hook reports nothing rather than refuse.
|
|
11
|
+
class AfterCommitInput
|
|
12
|
+
# The events a host runs the after-commit hook on: Claude Code both, Codex PostToolUse alone.
|
|
13
|
+
EVENTS = %w[PostToolUse PostToolUseFailure].freeze #: Array[String]
|
|
14
|
+
# How many seconds after the call ended a host may start the hook on a loaded machine. The hook cannot tell a
|
|
15
|
+
# late start from a long call, so a move up to this many seconds, and one more, before the call is reported
|
|
16
|
+
# again: a repeat costs a report, where a miss leaves a commit's change unseen until the next session start.
|
|
17
|
+
LATE_START_S = 5
|
|
18
|
+
# Where a cd or a git -C may start: the command's start, or after ;, &, |, ( or ).
|
|
19
|
+
SEGMENTS = /[;&|()]/ #: Regexp
|
|
20
|
+
# A cd or git -C and its target: one word, or one layer of matching double or single quotes.
|
|
21
|
+
TARGET = /\A\s*(cd|git\s+-C)\s+("[^"]*"|'[^']*'|\S+)/ #: Regexp
|
|
22
|
+
# A target holding any of these, or starting with -, is not read, so no expansion is guessed at.
|
|
23
|
+
UNREAD = /["'$\\`]/ #: Regexp
|
|
24
|
+
|
|
25
|
+
# The event the host ran the hook on, or nil when there is nothing to report.
|
|
26
|
+
#: String?
|
|
27
|
+
attr_reader :event
|
|
28
|
+
|
|
29
|
+
# The second the call started, or earlier: see LATE_START_S.
|
|
30
|
+
#: Integer
|
|
31
|
+
attr_reader :started
|
|
32
|
+
|
|
33
|
+
# The hook's input as the process it runs in reads it, the one owner of that reading for the executable, before
|
|
34
|
+
# the rest of this tool loads, and for the command: started at clock, unless environment's PRINCIPLES_HOOK_NOW,
|
|
35
|
+
# a test seam no session sets, gives the second; with home as ~; and for input naming no cwd, the session's
|
|
36
|
+
# directory, as Claude Code names it in CLAUDE_PROJECT_DIR, or pwd.
|
|
37
|
+
#: (String, Hash[String, String], clock: Integer, home: String, pwd: String) -> AfterCommitInput
|
|
38
|
+
def self.read(text, environment, clock:, home:, pwd:)
|
|
39
|
+
new(text, now: Integer(environment.fetch("PRINCIPLES_HOOK_NOW", clock)), home: home,
|
|
40
|
+
fallback: environment.fetch("CLAUDE_PROJECT_DIR", pwd))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# now is the second the hook started; home is the home directory a leading ~ names; fallback the session's
|
|
44
|
+
# directory, for input naming no cwd.
|
|
45
|
+
#: (String, now: Integer, home: String, fallback: String) -> void
|
|
46
|
+
def initialize(text, now:, home:, fallback:)
|
|
47
|
+
given = parsed(text)
|
|
48
|
+
@event = EVENTS.find { it == given["hook_event_name"] } #: String?
|
|
49
|
+
@started = started_before(now, given["duration_ms"]) #: Integer
|
|
50
|
+
@cwd = text(given["cwd"]) || fallback #: String
|
|
51
|
+
tool_input = given["tool_input"]
|
|
52
|
+
@command = (text(tool_input["command"]) if tool_input.is_a?(Hash)) || "" #: String
|
|
53
|
+
@home = home
|
|
54
|
+
freeze
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# The call's cwd, then each directory its command changed into with cd or ran git in with git -C, in order,
|
|
58
|
+
# each resolved from the cd before it. Targets are read by position, not by the shell's rules, so a cd in a
|
|
59
|
+
# subshell is taken as if it ran in turn, and only the first -C of a git is read.
|
|
60
|
+
#: () -> Array[String]
|
|
61
|
+
def directories
|
|
62
|
+
from = @cwd
|
|
63
|
+
targets = @command.split(SEGMENTS).filter_map do |segment|
|
|
64
|
+
word, target = segment.match(TARGET)&.captures
|
|
65
|
+
next unless word && target
|
|
66
|
+
|
|
67
|
+
resolved = resolved(unquoted(target), from) or next
|
|
68
|
+
from = resolved if word == "cd"
|
|
69
|
+
resolved
|
|
70
|
+
end
|
|
71
|
+
[@cwd, *targets]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
# When a call that ended by now started, from its duration in milliseconds, rounded up to the second, and a
|
|
77
|
+
# second earlier, since a file's time and this clock both count whole seconds, and LATE_START_S earlier
|
|
78
|
+
# still. A duration that is not a positive whole number, or none, as Codex sends, reads as no time.
|
|
79
|
+
#: (Integer, untyped) -> Integer
|
|
80
|
+
def started_before(now, duration)
|
|
81
|
+
duration = 0 unless duration.is_a?(Integer) && duration.positive?
|
|
82
|
+
now - ((duration + 999) / 1000) - 1 - LATE_START_S
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# A text field's value, or nil when it gives none.
|
|
86
|
+
#: (untyped) -> String?
|
|
87
|
+
def text(given) = given.is_a?(String) && !given.empty? ? given : nil
|
|
88
|
+
|
|
89
|
+
#: (String) -> String
|
|
90
|
+
def unquoted(target)
|
|
91
|
+
quoted = target.length > 1 && %w[" '].include?(target[0]) && target[0] == target[-1]
|
|
92
|
+
quoted ? target[1...-1].to_s : target
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# target as a path from the directory from, or nil when it is not read.
|
|
96
|
+
#: (String, String) -> String?
|
|
97
|
+
def resolved(target, from)
|
|
98
|
+
return if target.empty? || target.start_with?("-") || target.match?(UNREAD)
|
|
99
|
+
return target if target.start_with?("/")
|
|
100
|
+
return @home if target == "~"
|
|
101
|
+
return "#{@home}/#{target.delete_prefix("~/")}" if target.start_with?("~/")
|
|
102
|
+
|
|
103
|
+
"#{from}/#{target}"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
#: (String) -> Hash[String, untyped]
|
|
107
|
+
def parsed(text)
|
|
108
|
+
given = JSON.parse(text)
|
|
109
|
+
given.is_a?(Hash) ? given : {}
|
|
110
|
+
rescue JSON::ParserError
|
|
111
|
+
{}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -10,7 +10,7 @@ module Principles
|
|
|
10
10
|
# When Claude Code loads a project subagent's definition. Its description, which Claude reads to decide when
|
|
11
11
|
# to delegate, loads at session start in the main session; its body is the subagent's own system prompt, loaded
|
|
12
12
|
# in the subagent's context when Claude delegates to it. Claude Code reads .claude/agents recursively, from
|
|
13
|
-
# the start folder up to the repository root, as its subagents documentation says;
|
|
13
|
+
# the start folder up to the repository root, as its subagents documentation says; an experiment saw
|
|
14
14
|
# a project subagent's description listed at start.
|
|
15
15
|
class AgentLoads
|
|
16
16
|
# An agent's definition: a Markdown file at any depth in a .claude/agents folder, at the root or below it.
|
|
@@ -21,7 +21,7 @@ module Principles
|
|
|
21
21
|
#: (untyped, String) -> String
|
|
22
22
|
def text(value, field) = AnswerText.new(value).required(field)
|
|
23
23
|
|
|
24
|
-
# value as text, refused as field at its place in the answer, so one of many entries is found
|
|
24
|
+
# value as text, refused as field at its place in the answer, so one of many entries is found.
|
|
25
25
|
#: (untyped, String, AnswerPlace) -> String
|
|
26
26
|
def text_at(value, field, place)
|
|
27
27
|
text(value, field)
|
|
@@ -56,7 +56,7 @@ module Principles
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
# Where a finding is written up, located at its place in the answer, as the value its record keeps
|
|
59
|
+
# Where a finding is written up, located at its place in the answer, as the value its record keeps.
|
|
60
60
|
#: (untyped, AnswerPlace) -> WriteUpPointer
|
|
61
61
|
def write_up_pointer(reference, place)
|
|
62
62
|
pointer(reference, place)
|
|
@@ -8,9 +8,9 @@ module Principles
|
|
|
8
8
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
9
|
module Models
|
|
10
10
|
# A place in an agent's answer: its JSON pointer, and whose part of the answer it is, such as "Finding F1".
|
|
11
|
-
# A refusal about what sits there names both, so the agent can find the one pointer to repair
|
|
11
|
+
# A refusal about what sits there names both, so the agent can find the one pointer to repair.
|
|
12
12
|
class AnswerPlace
|
|
13
|
-
# What a pointer in an answer may do instead of quoting exactly a passage its file does not hold
|
|
13
|
+
# What a pointer in an answer may do instead of quoting exactly a passage its file does not hold.
|
|
14
14
|
ELSEWHERE = " Or point it at text the file holds."
|
|
15
15
|
|
|
16
16
|
#: String
|
|
@@ -35,7 +35,7 @@ module Principles
|
|
|
35
35
|
#: (String | Integer) -> AnswerPlace
|
|
36
36
|
def child(name) = AnswerPlace.new("#{@pointer}/#{name}", @subject)
|
|
37
37
|
|
|
38
|
-
# error, a refusal about what sits here, saying whose it is and where, as a malformed answer's fields do
|
|
38
|
+
# error, a refusal about what sits here, saying whose it is and where, as a malformed answer's fields do.
|
|
39
39
|
#: (Error) -> Error
|
|
40
40
|
def refusal(error)
|
|
41
41
|
payload = error.payload
|
|
@@ -6,7 +6,7 @@ require_relative "../error"
|
|
|
6
6
|
module Principles
|
|
7
7
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
|
-
# A value an agent gave where its answer asks for text, the one owner of whether it wrote any
|
|
9
|
+
# A value an agent gave where its answer asks for text, the one owner of whether it wrote any.
|
|
10
10
|
class AnswerText
|
|
11
11
|
#: (untyped) -> void
|
|
12
12
|
def initialize(value)
|
|
@@ -22,7 +22,7 @@ module Principles
|
|
|
22
22
|
#: () -> bool
|
|
23
23
|
def one_line? = written? && !@value.include?("\n")
|
|
24
24
|
|
|
25
|
-
# The text where field requires it: as written, or refused naming field
|
|
25
|
+
# The text where field requires it: as written, or refused naming field.
|
|
26
26
|
#: (String) -> String
|
|
27
27
|
def required(field)
|
|
28
28
|
unless written?
|
|
@@ -7,7 +7,7 @@ module Principles
|
|
|
7
7
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
9
|
# A time as an agent wrote it in an answer, such as a sighting's observed_at, which the record compares with
|
|
10
|
-
# audited_at only in audited_at's own form: a UTC time to the second
|
|
10
|
+
# audited_at only in audited_at's own form: a UTC time to the second.
|
|
11
11
|
class AnsweredTime
|
|
12
12
|
#: (untyped) -> void
|
|
13
13
|
def initialize(value)
|
|
@@ -35,7 +35,7 @@ module Principles
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# The UTC time in audited_at's form that it names exactly, or nil when it names none: a date alone at its
|
|
38
|
-
# midnight, and a time to the second with an offset as the same instant
|
|
38
|
+
# midnight, and a time to the second with an offset as the same instant. A fraction, or a date no
|
|
39
39
|
# calendar has, names none.
|
|
40
40
|
#: () -> String?
|
|
41
41
|
def exact_utc
|
|
@@ -49,7 +49,7 @@ module Principles
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
# It in audited_at's form when it names a time to the second exactly, with any UTC offset, so a clock's own
|
|
52
|
-
# offset is the same instant
|
|
52
|
+
# offset is the same instant; otherwise as given, a date alone included, for its sighting to refuse.
|
|
53
53
|
#: () -> untyped
|
|
54
54
|
def in_audited_at_form
|
|
55
55
|
return @value if date_alone?
|
|
@@ -58,7 +58,7 @@ module Principles
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# Whether it is later than time, both UTC times in audited_at's form: a sighting is made before the answer that
|
|
61
|
-
# reports it
|
|
61
|
+
# reports it, so a repair never prints one later.
|
|
62
62
|
#: (String) -> bool
|
|
63
63
|
def after?(time) = Time.iso8601(@value) > Time.iso8601(time)
|
|
64
64
|
|
|
@@ -18,18 +18,18 @@ module Principles
|
|
|
18
18
|
# An agent's answer to an assessment request: one assessment per member, an assessment of the set, a
|
|
19
19
|
# recent decision under it, and findings. The block locates each piece of evidence in the project and
|
|
20
20
|
# refuses one that does not resolve. members are the audited members, each checked one's assessment reporting
|
|
21
|
-
# its check's result
|
|
22
|
-
# whose loading it must decide
|
|
23
|
-
# no sighting it reports is after
|
|
21
|
+
# its check's result; judged_against is the principle's record as it stands, which lists the members
|
|
22
|
+
# whose loading it must decide and the assessments it may carry; answered_at is when it came, which
|
|
23
|
+
# no sighting it reports is after.
|
|
24
24
|
class AssessmentAnswer
|
|
25
|
-
# The text the template prints in collective_assessment, which an answer may not send back unchanged
|
|
25
|
+
# The text the template prints in collective_assessment, which an answer may not send back unchanged.
|
|
26
26
|
COLLECTIVE_PLACEHOLDER = "How the members reinforce the principle, and any contradiction or missing " \
|
|
27
27
|
"connection." #: String
|
|
28
28
|
# How a field --as template's answer leaves as printed is read, printed once at the template's head in
|
|
29
|
-
# left_as_printed_rule, where an agent filling it reads, which the answer may send back and this tool ignores
|
|
30
|
-
# (#1043, D88).
|
|
29
|
+
# left_as_printed_rule, where an agent filling it reads, which the answer may send back and this tool ignores.
|
|
31
30
|
LEFT_AS_PRINTED_RULE = "A field left as printed is read as omitted, as is this one: one saying \"else kept\" " \
|
|
32
|
-
"keeps what it had, and null drops it where offered."
|
|
31
|
+
"keeps what it had, and null drops it where offered. A sighting sets delivery to " \
|
|
32
|
+
"\"observed\" and adds observation, and observed_at for one before this audit." #: String
|
|
33
33
|
|
|
34
34
|
#: (untyped, PrincipleMembers, answered_at: String, ?judged_against: RecordJudgedAgainst?)
|
|
35
35
|
#| { (Locator) -> Hash[String, untyped] } -> void
|
|
@@ -58,7 +58,7 @@ module Principles
|
|
|
58
58
|
def check_results = member_assessments.check_results
|
|
59
59
|
|
|
60
60
|
# By member id, the fields this answer reports for each member's record entry: its assessment, which the next
|
|
61
|
-
# full audit may carry forward
|
|
61
|
+
# full audit may carry forward, its check's result and its accepted loading decision, once
|
|
62
62
|
# each listed member's is checked against loads.
|
|
63
63
|
#: () -> Hash[String, Hash[String, untyped]]
|
|
64
64
|
def entry_fields
|
|
@@ -73,7 +73,7 @@ module Principles
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# The paths the recent decision's evidence cites, which the record does not keep but a completed audit asks to
|
|
76
|
-
# commit when they differ from HEAD
|
|
76
|
+
# commit when they differ from HEAD; none when the decision was unavailable.
|
|
77
77
|
#: () -> Array[String]
|
|
78
78
|
def recent_decision_paths
|
|
79
79
|
recent_decision.paths
|
|
@@ -93,7 +93,7 @@ module Principles
|
|
|
93
93
|
|
|
94
94
|
#: () -> Array[untyped]
|
|
95
95
|
def checked_findings
|
|
96
|
-
findings = NewFindings.new(@fields.array(@response
|
|
96
|
+
findings = NewFindings.new(@fields.array(@response.fetch("findings", []), "findings")).raised
|
|
97
97
|
finding_ids = findings.each_with_index.map { |finding, index| finding_id(finding, index) }
|
|
98
98
|
unless finding_ids.uniq == finding_ids
|
|
99
99
|
raise Error.new("duplicate_finding", "Finding ids repeat",
|
|
@@ -9,7 +9,7 @@ module Principles
|
|
|
9
9
|
module Models
|
|
10
10
|
# What an assessment request prints as its basis, which the agent hands back with the answer: the commit the
|
|
11
11
|
# audit is based on, nil outside git, and the revision of the last completed audit record when the request was
|
|
12
|
-
# printed, nil when there was none, so the answer is refused once that record changed
|
|
12
|
+
# printed, nil when there was none, so the answer is refused once that record changed.
|
|
13
13
|
class AssessmentBasis
|
|
14
14
|
# The basis printed for an audit based on base, after record, the principle's audit record now, if any.
|
|
15
15
|
#: (String?, AuditRecord?) -> AssessmentBasis
|
|
@@ -31,7 +31,7 @@ module Principles
|
|
|
31
31
|
def base = @fields["base_commit"]
|
|
32
32
|
|
|
33
33
|
# The last completed record's revision when the request was printed, nil when there was none, which the
|
|
34
|
-
# correction the assessment prints carries forward
|
|
34
|
+
# correction the assessment prints carries forward.
|
|
35
35
|
#: () -> String?
|
|
36
36
|
def revision = @fields["last_completed_revision"]
|
|
37
37
|
|
|
@@ -13,7 +13,7 @@ module Principles
|
|
|
13
13
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
14
14
|
module Models
|
|
15
15
|
# The judgements a full audit's answer, as sent, leaves as its template printed them: the members', the set's,
|
|
16
|
-
# the recent decision's, a raised finding's text fields and a prior finding's decision
|
|
16
|
+
# the recent decision's, a raised finding's text fields and a prior finding's decision. It
|
|
17
17
|
# reads only what it finds in the shape it expects, so it may read an answer whose shape is still to be checked.
|
|
18
18
|
class AssessmentLeftAsPrinted
|
|
19
19
|
include RefusalBeforeShape
|
|
@@ -9,13 +9,13 @@ module Principles
|
|
|
9
9
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
10
10
|
module Models
|
|
11
11
|
# What an assessment reported beyond its findings, which its audit's record and commit carry: by member id, the
|
|
12
|
-
# fields of each member's record entry, such as its assessment
|
|
12
|
+
# fields of each member's record entry, such as its assessment and its check's result, and the paths
|
|
13
13
|
# its recent decision cites, which the record does not keep but the completed audit asks to commit when they
|
|
14
|
-
# differ from HEAD
|
|
15
|
-
# carries only those paths and the record's digest
|
|
14
|
+
# differ from HEAD. The open record keeps it for the correction to read back, and the correction's basis
|
|
15
|
+
# carries only those paths and the record's digest; this is the one owner of how it is carried.
|
|
16
16
|
class AssessmentReport
|
|
17
17
|
# The report of the answer assessed, each assessment it makes, rather than carries, with the grounds it was
|
|
18
|
-
# judged on
|
|
18
|
+
# judged on.
|
|
19
19
|
#: (AssessmentAnswer, MemberGrounds) -> AssessmentReport
|
|
20
20
|
def self.answered(assessed, grounds)
|
|
21
21
|
fields = assessed.entry_fields.to_h do |id, entry|
|
|
@@ -27,8 +27,7 @@ module Principles
|
|
|
27
27
|
|
|
28
28
|
# The report an open record keeps for its correction to read back: each member's entry without the hash and key
|
|
29
29
|
# the record adds, under the ids of any members moves moved, with the recent decision's paths, which the basis
|
|
30
|
-
# carries
|
|
31
|
-
# (D24).
|
|
30
|
+
# carries. A completed record read back so gives the report that completed it, for an identical retry.
|
|
32
31
|
#: (AuditRecord, CorrectionBasis, MemberMoves) -> AssessmentReport
|
|
33
32
|
def self.recorded(record, basis, moves)
|
|
34
33
|
fields = record.to_h.fetch("members").transform_values { |entry| entry.except("sha256", "key") }
|
|
@@ -52,7 +51,7 @@ module Principles
|
|
|
52
51
|
def entry_fields_of(id) = @entry_fields.fetch(id, {})
|
|
53
52
|
|
|
54
53
|
# What a correction basis carries of it: the recent decision's paths, which no record keeps, when there are any.
|
|
55
|
-
# The open record keeps the rest
|
|
54
|
+
# The open record keeps the rest.
|
|
56
55
|
#: () -> Hash[String, untyped]
|
|
57
56
|
def basis_fields = @recent_decision_paths.empty? ? {} : { "recent_decision_paths" => @recent_decision_paths }
|
|
58
57
|
|