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
|
@@ -7,10 +7,10 @@ module Principles
|
|
|
7
7
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
9
|
# The findings an assessment answer raises, as start-audit --as template prints one to fill: a finding sent back
|
|
10
|
-
# exactly as printed raises none, and one otherwise filled may not keep a text field as printed
|
|
10
|
+
# exactly as printed raises none, and one otherwise filled may not keep a text field as printed.
|
|
11
11
|
class NewFindings
|
|
12
12
|
# The text fields of the printed finding, which their own check accepts as written text, so a field left as
|
|
13
|
-
# printed in a finding otherwise filled is refused here
|
|
13
|
+
# printed in a finding otherwise filled is refused here. A member id or evidence left as printed is
|
|
14
14
|
# refused by its own check.
|
|
15
15
|
TEXT = TemplatePlaceholders.new(
|
|
16
16
|
{ "id" => "Only for a problem you found: an id such as F1. Leave this finding as printed to raise none",
|
|
@@ -20,7 +20,7 @@ module Principles
|
|
|
20
20
|
) #: TemplatePlaceholders
|
|
21
21
|
|
|
22
22
|
# The finding the template printed alone gives to fill, which an answer leaves as printed to raise none; whether
|
|
23
|
-
# to fix, defer or accept a finding is the correction's, so the finding itself carries none
|
|
23
|
+
# to fix, defer or accept a finding is the correction's, so the finding itself carries none.
|
|
24
24
|
TEMPLATE = {
|
|
25
25
|
"id" => TEXT.fetch("id"), "member_ids" => ["The id of each member it concerns"],
|
|
26
26
|
"problem" => TEXT.fetch("problem"), "consequence" => TEXT.fetch("consequence"),
|
|
@@ -40,7 +40,7 @@ module Principles
|
|
|
40
40
|
def raised = @findings.reject { it == TEMPLATE }
|
|
41
41
|
|
|
42
42
|
# Each text field a raised finding leaves as the template printed it, named by the finding's place and the
|
|
43
|
-
# field, with its pointer, which the answer refuses with every other judgement left so
|
|
43
|
+
# field, with its pointer, which the answer refuses with every other judgement left so.
|
|
44
44
|
#: () -> Hash[String, String]
|
|
45
45
|
def left_as_printed
|
|
46
46
|
@findings.each_with_index.flat_map do |finding, index|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "audit_record"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# The correction a full audit's assessment with findings opened, as principle id's audit record keeps it while
|
|
11
|
+
# the audit is open, which show-open-correction prints again: its request id, its basis and the findings that
|
|
12
|
+
# basis asks the correction to dispose of.
|
|
13
|
+
class OpenCorrection
|
|
14
|
+
# The repair while the open record keeps no correction, as one an earlier release wrote.
|
|
15
|
+
SUBMIT_AGAIN = "Submit this audit's assessment again, which prints its correction and keeps it to print " \
|
|
16
|
+
"again." #: String
|
|
17
|
+
|
|
18
|
+
#: String
|
|
19
|
+
attr_reader :request_id
|
|
20
|
+
# The basis as printed, which the answer hands back unchanged.
|
|
21
|
+
#: Hash[String, untyped]
|
|
22
|
+
attr_reader :basis
|
|
23
|
+
|
|
24
|
+
# The correction record keeps, the record of principle id in file; refused when there is none: no record, a
|
|
25
|
+
# completed one, or an open one an earlier release wrote, which keeps none.
|
|
26
|
+
#: (String, AuditRecord?, file: String) -> OpenCorrection
|
|
27
|
+
def self.kept(id, record, file:)
|
|
28
|
+
kept = record&.correction
|
|
29
|
+
return new(kept.fetch("request_id"), kept.fetch("basis")) if kept
|
|
30
|
+
|
|
31
|
+
raise Error.new("no_open_correction", "#{id} has no open correction to print", repair(id, open: record&.open?),
|
|
32
|
+
file)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# How to get a correction to print: submit the open audit's assessment again, which prints it and keeps it in
|
|
36
|
+
# the record, or start a full audit when none is open.
|
|
37
|
+
#: (String, open: bool?) -> String
|
|
38
|
+
def self.repair(id, open:)
|
|
39
|
+
return SUBMIT_AGAIN if open
|
|
40
|
+
|
|
41
|
+
"Start a full audit, whose assessment with findings opens a correction: #{Error::EXECUTABLE} start-audit #{id}"
|
|
42
|
+
end
|
|
43
|
+
private_class_method :repair
|
|
44
|
+
|
|
45
|
+
#: (String, Hash[String, untyped]) -> void
|
|
46
|
+
def initialize(request_id, basis)
|
|
47
|
+
@request_id = request_id
|
|
48
|
+
@basis = basis
|
|
49
|
+
freeze
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# The findings the basis asks the correction to dispose of.
|
|
53
|
+
#: () -> Array[Hash[String, untyped]]
|
|
54
|
+
def findings = @basis.fetch("findings")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -12,10 +12,10 @@ module Principles
|
|
|
12
12
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
13
13
|
module Models
|
|
14
14
|
# One finding an audit record left open, deferred or accepted, with the principle and the time of that audit:
|
|
15
|
-
# what list-open-findings prints of it, and what the next full audit is asked to decide on it
|
|
15
|
+
# what list-open-findings prints of it, and what the next full audit is asked to decide on it.
|
|
16
16
|
# PriorFindings is the next audit's view of all of them, and checks its decisions. It carries the evidence it
|
|
17
17
|
# was raised with, which list-open-findings and the next full audit's request print, and which that audit keeps
|
|
18
|
-
# when it keeps the finding
|
|
18
|
+
# when it keeps the finding.
|
|
19
19
|
class OpenFinding
|
|
20
20
|
# members are the members as the audit that left this finding open recorded them, against which the next
|
|
21
21
|
# audit says whether each changed since.
|
|
@@ -28,9 +28,9 @@ module Principles
|
|
|
28
28
|
freeze
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# The finding as list-open-findings prints it, with its principle, why it was left open
|
|
32
|
-
# was made and when it was first raised, so how long it has waited shows
|
|
33
|
-
# when
|
|
31
|
+
# The finding as list-open-findings prints it, with its principle, why it was left open, when its audit
|
|
32
|
+
# was made and when it was first raised, so how long it has waited shows, what it says it waits on, since
|
|
33
|
+
# when, and the evidence its record keeps, or that it keeps none.
|
|
34
34
|
#: () -> Hash[String, untyped]
|
|
35
35
|
def listed
|
|
36
36
|
{ "principle" => @principle_id, "finding_id" => id, "member_ids" => @finding.member_ids, **problem,
|
|
@@ -39,7 +39,7 @@ module Principles
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# The finding as the next full audit's request lists it, with when it was first raised, and what it waits on,
|
|
42
|
-
# since when, for the agent to confirm
|
|
42
|
+
# since when, for the agent to confirm.
|
|
43
43
|
#: () -> Hash[String, untyped]
|
|
44
44
|
def for_next_audit
|
|
45
45
|
{ "finding_id" => id, "member_ids" => @finding.member_ids, **problem,
|
|
@@ -50,8 +50,8 @@ module Principles
|
|
|
50
50
|
|
|
51
51
|
# The finding as the next full audit's request lists it, against the map's members now and each one's hash
|
|
52
52
|
# now, hashes_now: under its members' ids now, with whether each changed since the audit that left it open,
|
|
53
|
-
# what its record did not keep of it, and the evidence it keeps, so the agent deciding it sees what it rests on
|
|
54
|
-
#
|
|
53
|
+
# what its record did not keep of it, and the evidence it keeps, so the agent deciding it sees what it rests on.
|
|
54
|
+
# Given since, each evidence item also carries what since says of it now.
|
|
55
55
|
#: (PrincipleMembers, Hash[String, String]) ?{ (EvidenceItem) -> Hash[String, bool] }
|
|
56
56
|
#| -> Hash[String, untyped]
|
|
57
57
|
def for_next_audit_against(members_now, hashes_now, &)
|
|
@@ -63,8 +63,8 @@ module Principles
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
# The finding as the next full audit's record keeps it, before that audit's decision on it: under its members'
|
|
66
|
-
# ids now, with why it was left open
|
|
67
|
-
# first_raised_at cited
|
|
66
|
+
# ids now, with why it was left open, its write-up, when it was first raised and the commit an earlier
|
|
67
|
+
# first_raised_at cited.
|
|
68
68
|
#: (PrincipleMembers) -> Hash[String, untyped]
|
|
69
69
|
def kept_against(members_now)
|
|
70
70
|
{ "id" => id, "member_ids" => ids_now(members_now), **problem, "action" => @finding.action,
|
|
@@ -93,19 +93,19 @@ module Principles
|
|
|
93
93
|
#: () -> bool
|
|
94
94
|
def states_problem? = !@finding.problem.nil?
|
|
95
95
|
|
|
96
|
-
# The locators of the evidence it was raised with, or nil when its record keeps none
|
|
96
|
+
# The locators of the evidence it was raised with, or nil when its record keeps none.
|
|
97
97
|
#: () -> Array[Hash[String, untyped]]?
|
|
98
98
|
def evidence = @finding.evidence
|
|
99
99
|
|
|
100
100
|
# The problem it states, and the one a still_holds decision gives in its place, as the completed result names
|
|
101
|
-
# them, or nil when the decision gives none, its record states none or the two are the same
|
|
101
|
+
# them, or nil when the decision gives none, its record states none or the two are the same.
|
|
102
102
|
#: (String?) -> Hash[String, String]?
|
|
103
103
|
def restated(problem)
|
|
104
104
|
stated = @finding.problem
|
|
105
105
|
{ "finding_id" => id, "replaced" => stated, "with" => problem } if stated && problem && problem != stated
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
# Whether its record keeps the evidence it was raised with
|
|
108
|
+
# Whether its record keeps the evidence it was raised with.
|
|
109
109
|
#: () -> bool
|
|
110
110
|
def evidence_kept? = @finding.evidence_kept?
|
|
111
111
|
|
|
@@ -115,8 +115,8 @@ module Principles
|
|
|
115
115
|
def removed_from(members_now) = ids_now(members_now).reject { |member_id| members_now.with_id(member_id) }
|
|
116
116
|
|
|
117
117
|
# The new places a decision's problem_evidence gives the evidence its record keeps, so the check that an item is
|
|
118
|
-
# no longer found and the swap read the same items
|
|
119
|
-
# gives instead
|
|
118
|
+
# no longer found and the swap read the same items; none when its record keeps none, which problem_evidence
|
|
119
|
+
# gives instead.
|
|
120
120
|
#: (Array[Hash[String, untyped]]?) -> EvidenceReplacements
|
|
121
121
|
def replacements(problem_evidence)
|
|
122
122
|
kept = evidence or return EvidenceReplacements.new([], [])
|
|
@@ -125,19 +125,19 @@ module Principles
|
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
# The evidence its next record keeps after a decision gives problem_evidence: the evidence it was raised with,
|
|
128
|
-
# each item the decision gave a new place swapped for it
|
|
129
|
-
# decision gave, kept as plain evidence since the record does not care which audit gave it
|
|
128
|
+
# each item the decision gave a new place swapped for it, or, when its record keeps none, the evidence the
|
|
129
|
+
# decision gave, kept as plain evidence since the record does not care which audit gave it.
|
|
130
130
|
#: (Array[Hash[String, untyped]]?) -> Array[Hash[String, untyped]]?
|
|
131
131
|
def evidence_after(problem_evidence) = evidence ? replacements(problem_evidence).evidence : problem_evidence
|
|
132
132
|
|
|
133
133
|
# Whether it names the member known by key, under whichever id its audit recorded that member, so a member
|
|
134
|
-
# renamed since is still found
|
|
134
|
+
# renamed since is still found.
|
|
135
135
|
#: (String) -> bool
|
|
136
136
|
def on?(key) = @finding.member_ids.any? { |member_id| @members.key_of(member_id) == key }
|
|
137
137
|
|
|
138
138
|
# The finding as another principle's full audit lists it, once, under open_findings_elsewhere, so the same
|
|
139
|
-
# problem is not raised again there
|
|
140
|
-
# lines, that audit's members, where locate finds the item now, or that its record keeps none
|
|
139
|
+
# problem is not raised again there, with each item of its evidence and what its lines are beside
|
|
140
|
+
# lines, that audit's members, where locate finds the item now, or that its record keeps none.
|
|
141
141
|
#: (AuditedMemberLines) { (Locator) -> LocatedText } -> Hash[String, untyped]
|
|
142
142
|
def listed_elsewhere(lines, &)
|
|
143
143
|
located = items&.map { |item| lines.facts_of(item, &) }
|
|
@@ -149,24 +149,29 @@ module Principles
|
|
|
149
149
|
#: () -> Time
|
|
150
150
|
def first_raised_time = Time.iso8601(first_raised_at.to_s)
|
|
151
151
|
|
|
152
|
-
# The finding as the session-start line names it: its principle and
|
|
153
|
-
# was first raised until now, and what it says it waits on, when it says
|
|
152
|
+
# The finding as the session-start line names it: its principle, id and action, the whole days it has waited
|
|
153
|
+
# since it was first raised until now, and what it says it waits on, when it says.
|
|
154
154
|
#: (Time) -> Hash[String, untyped]
|
|
155
155
|
def waited_at(now)
|
|
156
|
-
{ "principle" => @principle_id, "finding_id" => id,
|
|
156
|
+
{ "principle" => @principle_id, "finding_id" => id, "action" => @finding.action,
|
|
157
157
|
"days_open" => ((now - first_raised_time) / 86_400).floor, **present("waits_on", @finding.waits_on) }
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
-
# Whether it records no waits_on, so the session-start line can count those whose line it cannot show
|
|
160
|
+
# Whether it records no waits_on, so the session-start line can count those whose line it cannot show.
|
|
161
161
|
#: () -> bool
|
|
162
162
|
def without_waits_on? = !@finding.waits_on
|
|
163
163
|
|
|
164
|
-
#
|
|
164
|
+
# Whether it is deferred with no waits_on, so the session-start line counts it among those to raise; an
|
|
165
|
+
# accepted one waits on no one by design.
|
|
166
|
+
#: () -> bool
|
|
167
|
+
def waiting_on_no_one_named? = action == "deferred" && without_waits_on?
|
|
168
|
+
|
|
169
|
+
# The one line it says it waits on, or nil when it says it waits on nothing.
|
|
165
170
|
#: () -> String?
|
|
166
171
|
def waits_on = @finding.waits_on
|
|
167
172
|
|
|
168
173
|
# What the finding says it waits on, and since when: its own waits_on_since when an earlier audit asked it, or
|
|
169
|
-
# else this audit's time; nothing when it says it waits on nothing
|
|
174
|
+
# else this audit's time; nothing when it says it waits on nothing.
|
|
170
175
|
#: () -> Hash[String, untyped]
|
|
171
176
|
def waiting
|
|
172
177
|
line = @finding.waits_on or return {}
|
|
@@ -179,7 +184,7 @@ module Principles
|
|
|
179
184
|
|
|
180
185
|
private
|
|
181
186
|
|
|
182
|
-
# Its members' ids now, each member found by key so a member renamed since keeps its new id
|
|
187
|
+
# Its members' ids now, each member found by key so a member renamed since keeps its new id.
|
|
183
188
|
#: (PrincipleMembers) -> Array[String]
|
|
184
189
|
def ids_now(members_now) = @finding.member_ids.map { |id| id_now(members_now, @members.key_of(id)) || id }
|
|
185
190
|
|
|
@@ -192,11 +197,11 @@ module Principles
|
|
|
192
197
|
@members.freshness(member.key, hashes_now.fetch(id))
|
|
193
198
|
end
|
|
194
199
|
|
|
195
|
-
# The commit whose record an audit cited for an earlier first_raised_at, when one did
|
|
200
|
+
# The commit whose record an audit cited for an earlier first_raised_at, when one did.
|
|
196
201
|
#: () -> Hash[String, untyped]
|
|
197
202
|
def raised_in = present("raised_in", @finding.raised_in)
|
|
198
203
|
|
|
199
|
-
# Its evidence items, each with what since says of it now, or as kept without it
|
|
204
|
+
# Its evidence items, each with what since says of it now, or as kept without it.
|
|
200
205
|
#: () ?{ (EvidenceItem) -> Hash[String, bool] } -> Array[Hash[String, untyped]]?
|
|
201
206
|
def evidence_since(&since)
|
|
202
207
|
return @finding.evidence unless since
|
|
@@ -204,7 +209,7 @@ module Principles
|
|
|
204
209
|
items&.map { |item| item.with_facts(since.call(item)) }
|
|
205
210
|
end
|
|
206
211
|
|
|
207
|
-
# The evidence it was raised with, as items, or nil when its record keeps none
|
|
212
|
+
# The evidence it was raised with, as items, or nil when its record keeps none.
|
|
208
213
|
#: () -> Array[EvidenceItem]?
|
|
209
214
|
def items = @finding.evidence&.map { |fields| EvidenceItem.new(fields) }
|
|
210
215
|
|
|
@@ -213,7 +218,7 @@ module Principles
|
|
|
213
218
|
def text_not_kept = states_problem? ? {} : { "text_not_kept" => true }
|
|
214
219
|
|
|
215
220
|
# The evidence its record keeps, as items, which another principle's audit gives with each item's lines, or the
|
|
216
|
-
# mark that it keeps none, as a record written before this tool kept evidence does
|
|
221
|
+
# mark that it keeps none, as a record written before this tool kept evidence does.
|
|
217
222
|
#: (?Array[Hash[String, untyped]]?) -> Hash[String, untyped]
|
|
218
223
|
def kept_evidence(listed = @finding.evidence)
|
|
219
224
|
evidence_kept? ? { "evidence" => listed } : { "evidence_not_kept" => true }
|
|
@@ -10,7 +10,7 @@ module Principles
|
|
|
10
10
|
module Models
|
|
11
11
|
# The findings other principles' records leave open on members sharing lines with a full audit's members, read
|
|
12
12
|
# once per principle: each member's mapped_elsewhere names them by id, and the request lists each once, since a
|
|
13
|
-
# whole file's findings printed in full beside every passage within it
|
|
13
|
+
# whole file's findings printed in full beside every passage within it.
|
|
14
14
|
class OpenFindingsElsewhere
|
|
15
15
|
# sharing gives, under each audited member's id, the other principles' members sharing its lines.
|
|
16
16
|
#: (Hash[String, MembersElsewhere], AuditRecords) -> OpenFindingsElsewhere
|
|
@@ -36,7 +36,7 @@ module Principles
|
|
|
36
36
|
def open_beside?(member_id) = @sharing.fetch(member_id).open_among(@left_open_by_principle).any?
|
|
37
37
|
|
|
38
38
|
# Each finding left open on any of them, once, with its principle, and what its evidence's lines are beside
|
|
39
|
-
# lines, this audit's members, where locate finds each item now
|
|
39
|
+
# lines, this audit's members, where locate finds each item now: a finding is the same one when its
|
|
40
40
|
# principle and id are.
|
|
41
41
|
#: (AuditedMemberLines) { (Locator) -> LocatedText } -> Array[Hash[String, untyped]]
|
|
42
42
|
def listed(lines, &)
|
|
@@ -8,8 +8,8 @@ module Principles
|
|
|
8
8
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
9
|
module Models
|
|
10
10
|
# Every principle of the project but one, each as list-member-problems reports its members, which an audit of
|
|
11
|
-
# that one names when their members need an audit of their own: a completed audit for those its fixes changed
|
|
12
|
-
#
|
|
11
|
+
# that one names when their members need an audit of their own: a completed audit for those its fixes changed,
|
|
12
|
+
# and the meta-principle's full audit for those no audit has judged as they are now.
|
|
13
13
|
class OtherPrinciples
|
|
14
14
|
# Each principle of project but the one id names, its members as MemberProblems gives them; a map this tool
|
|
15
15
|
# cannot read is among them, as list-member-problems lists it.
|
|
@@ -18,14 +18,14 @@ module Principles
|
|
|
18
18
|
# The text in an answer that ends as this tool's placeholders end, "Leave as printed ...", "else leave" or "else
|
|
19
19
|
# kept", or is a placeholder some template of this release prints, but is none the request's own template
|
|
20
20
|
# printed: another template's placeholder, as an answer filled from an older template and repaired field by field
|
|
21
|
-
# keeps it, which no other check refuses in free text
|
|
22
|
-
# into an acknowledgement's
|
|
21
|
+
# keeps it, which no other check refuses in free text, or as a reason copied from a correction's template
|
|
22
|
+
# into an acknowledgement's. It reads the ending alone for older wordings, so the agent's own text ending
|
|
23
23
|
# so is refused too, and the repair says to reword it.
|
|
24
24
|
class OtherTemplatesPlaceholders
|
|
25
25
|
include RefusalBeforeShape
|
|
26
26
|
|
|
27
27
|
# How every placeholder of this tool's templates ends, in this release and earlier ones, one of which said
|
|
28
|
-
# "; leave as printed otherwise" as a clause, which "to leave as printed" in prose is not
|
|
28
|
+
# "; leave as printed otherwise" as a clause, which "to leave as printed" in prose is not.
|
|
29
29
|
ENDING = /((\bLeave|; leave) (\S+ ){0,2}as printed[^.]*|\belse (leave|kept))\.?\z/ #: Regexp
|
|
30
30
|
|
|
31
31
|
# Every string a JSON value holds, at any depth, by its JSON pointer: the one walk over a template and an
|
|
@@ -69,21 +69,25 @@ module Principles
|
|
|
69
69
|
Disposition::TEMPLATE_PLACEHOLDERS, Acknowledgement::PLACEHOLDERS.to_h, Acknowledgement::EXIT_STATUS_PLACEHOLDER
|
|
70
70
|
].then { Strings.new(it).by_pointer.values.to_set }.freeze #: Set[String]
|
|
71
71
|
|
|
72
|
-
# Each string in template, a request's template as printed, which its answer may send back
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
# Each string in template, a request's template as printed, which its answer may send back; start_from says
|
|
73
|
+
# where that template is printed, as RequestId#answer_to_fill gives it.
|
|
74
|
+
#: (untyped, start_from: String) -> OtherTemplatesPlaceholders
|
|
75
|
+
def self.besides(template, start_from:)
|
|
76
|
+
new(Strings.new(template).by_pointer.values, start_from:)
|
|
76
77
|
end
|
|
77
78
|
|
|
78
|
-
# printed is the placeholders the request's own template printed, which an answer may leave as printed
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
# printed is the placeholders the request's own template printed, which an answer may leave as printed, and
|
|
80
|
+
# start_from where that template is printed.
|
|
81
|
+
#: (Array[String], start_from: String) -> void
|
|
82
|
+
def initialize(printed, start_from:)
|
|
81
83
|
@printed = printed
|
|
84
|
+
@repair = "Start from #{start_from}, or replace each field named with your own text; if one is your own " \
|
|
85
|
+
"text, reword its ending" #: String
|
|
82
86
|
end
|
|
83
87
|
|
|
84
88
|
# Refuses answer in one refusal naming every field holding another template's placeholder, as "The answer": the
|
|
85
|
-
# agent holds its file's path, which cost context in every repair
|
|
86
|
-
# another field too, so both slips take one repair
|
|
89
|
+
# agent holds its file's path, which cost context in every repair. It names each of shape_problems at
|
|
90
|
+
# another field too, so both slips take one repair.
|
|
87
91
|
# @override
|
|
88
92
|
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
89
93
|
def refuse_in(answer, _source, shape_problems)
|
|
@@ -92,15 +96,12 @@ module Principles
|
|
|
92
96
|
|
|
93
97
|
elsewhere = ShapeProblemsBeside.new(shape_problems, named: found)
|
|
94
98
|
raise Error.new("invalid_answer", elsewhere.message(MESSAGE),
|
|
95
|
-
"#{elsewhere.repair(
|
|
99
|
+
"#{elsewhere.repair(@repair, "; repair each other field listed")}.",
|
|
96
100
|
fields: found.map { { "pointer" => it, "problem" => PROBLEM } } + elsewhere.fields)
|
|
97
101
|
end
|
|
98
102
|
|
|
99
103
|
MESSAGE = "The answer holds text another template printed as a placeholder" #: String
|
|
100
104
|
|
|
101
|
-
REPAIR = "Start from this request's response_template, or replace each field named with your own text; if one " \
|
|
102
|
-
"is your own text, reword its ending" #: String
|
|
103
|
-
|
|
104
105
|
PROBLEM = "ends as a placeholder does, but is none this request's template printed" #: String
|
|
105
106
|
|
|
106
107
|
private
|
|
@@ -9,14 +9,14 @@ module Principles
|
|
|
9
9
|
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
10
10
|
module Models
|
|
11
11
|
# How much list-candidate-files may print: its listed files' outlines, cut a whole file's list items at a time
|
|
12
|
-
# until the result fits.
|
|
13
|
-
# 37 KB, and no cap on items under each heading both fitted and kept a core list of 8 whole
|
|
12
|
+
# until the result fits. One user's run printed 66,145 B for 45 files, against a ceiling of about
|
|
13
|
+
# 37 KB, and no cap on items under each heading both fitted and kept a core list of 8 whole.
|
|
14
14
|
class OutlineBudget
|
|
15
15
|
# The most bytes the result may print, under the host's inline limit for a tool result. Claude Code's tools
|
|
16
16
|
# reference, "Output limits" (code.claude.com/docs/en/tools-reference, checked 2026-11-16), gives a Bash result
|
|
17
17
|
# inline "up to roughly 30,000 characters by default; past that, the path of a file" and a 2,000-character
|
|
18
|
-
# preview.
|
|
19
|
-
#
|
|
18
|
+
# preview. One user's 40.4 KB result arrived that way, and its agent scripted over the saved file.
|
|
19
|
+
# A character is at least a byte, so 28,000 B stays under 30,000 characters with room.
|
|
20
20
|
BYTES = 28_000
|
|
21
21
|
|
|
22
22
|
# The fields of a file's entry its outline gives, which a cut replaces.
|
|
@@ -35,7 +35,7 @@ module Principles
|
|
|
35
35
|
# The listing with its files' outlines cut, one cut of one file at a time in cut order, until what the block says
|
|
36
36
|
# it prints fits BYTES, each file whose items were cut named under outlines_cut. If every cut is made and it
|
|
37
37
|
# still does not fit, every file cut is named, and range_outlines_bytes gives what the outlines of the files a
|
|
38
|
-
# range changed print, when there are any: they are never left out, and which to drop is the agent's call
|
|
38
|
+
# range changed print, when there are any: they are never left out, and which to drop is the agent's call.
|
|
39
39
|
#: (Hash[String, untyped]) { (Hash[String, untyped]) -> Integer } -> Hash[String, untyped]
|
|
40
40
|
def cut(listing, &printed_bytes)
|
|
41
41
|
shortest = cut_order(listing).reduce(listing) do |shorter, (path, cuts)|
|
|
@@ -60,10 +60,10 @@ module Principles
|
|
|
60
60
|
|
|
61
61
|
# Each cut that shortens a file, as its path and how many of CandidateOutline::CUTS it then has made. Every file
|
|
62
62
|
# but the root entry files and those marked changed_in_range comes first; then the changed files, which a survey
|
|
63
|
-
# of a change is about
|
|
63
|
+
# of a change is about; last the entry files, since a host loads those in every session, so they keep
|
|
64
64
|
# theirs longest, in EntryFiles' order. Within each group, each cut is made across the files in CUTS' order:
|
|
65
65
|
# those with a description first, since the agent still reads what each is for, then the deepest path, then the
|
|
66
|
-
# most bytes the cut saves
|
|
66
|
+
# most bytes the cut saves.
|
|
67
67
|
#: (Hash[String, untyped]) -> Array[[String, Integer]]
|
|
68
68
|
def cut_order(listing)
|
|
69
69
|
outlined = listing.fetch("files").select { |file| @outlines.key?(file.fetch("path")) }
|
|
@@ -7,7 +7,7 @@ module Principles
|
|
|
7
7
|
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
9
|
# One section of a candidate file's outline and the deeper sections under it, which a cut outline folds into it
|
|
10
|
-
# once its headings are cut too
|
|
10
|
+
# once its headings are cut too.
|
|
11
11
|
class OutlineGroup
|
|
12
12
|
#: (OutlineSection, Array[OutlineSection]) -> void
|
|
13
13
|
def initialize(section, deeper)
|
|
@@ -5,7 +5,7 @@ module Principles
|
|
|
5
5
|
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
6
6
|
module Models
|
|
7
7
|
# One heading of a candidate file's outline and the top-level list items under it, with the lines of the file it
|
|
8
|
-
# spans, so an outline whose items are cut can say where to read them back
|
|
8
|
+
# spans, so an outline whose items are cut can say where to read them back.
|
|
9
9
|
class OutlineSection
|
|
10
10
|
# The most items printed under one heading; a longer list says how many more it holds.
|
|
11
11
|
MOST_ITEMS = 20
|
|
@@ -45,7 +45,7 @@ module Principles
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# The section as a cut outline prints it: its heading, then, if it holds items, how many and the lines of the file
|
|
48
|
-
# that hold them, so the agent reads just that section back
|
|
48
|
+
# that hold them, so the agent reads just that section back.
|
|
49
49
|
#: () -> Array[String]
|
|
50
50
|
def cut_lines = [*@heading, *("(#{@items.length} more, lines #{@first_line}-#{@last_line})" if @items.any?)]
|
|
51
51
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "../prose_list"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain of principles and their maps: each model owns its rules and loads and saves itself through data/.
|
|
9
|
+
module Models
|
|
10
|
+
# The part start-audit --part names, printed alone from the request a full audit asks, so an agent that needs one
|
|
11
|
+
# part of it need not read the whole request or script it. Only a part the request has, or leaves
|
|
12
|
+
# out as empty, can be printed.
|
|
13
|
+
class PartNamed
|
|
14
|
+
# empty is each part the request lists only when it holds something, and leaves out now, which is named rather
|
|
15
|
+
# than refused. template is whether the part is read from the answer --as template prints, whose parts are its
|
|
16
|
+
# members' slots, rather than from the request.
|
|
17
|
+
#: (String, principle_id: String, printed: Array[String], ?empty: Array[String], ?template: bool) -> void
|
|
18
|
+
def initialize(part, principle_id:, printed:, empty: [], template: false)
|
|
19
|
+
@part = part
|
|
20
|
+
@id = principle_id
|
|
21
|
+
@printed = printed
|
|
22
|
+
@empty = empty
|
|
23
|
+
@template = template
|
|
24
|
+
freeze
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The part, refused unless the request, or its template, has it or leaves it out as empty.
|
|
28
|
+
#: () -> String
|
|
29
|
+
def part
|
|
30
|
+
return @part if @printed.include?(@part) || @empty.include?(@part)
|
|
31
|
+
|
|
32
|
+
whole = @template ? "template" : "request"
|
|
33
|
+
refusal = Error.new("unknown_part",
|
|
34
|
+
"This #{whole} has no part named #{@part}. It has #{ProseList.new(@printed)}.", "")
|
|
35
|
+
usage = @template ? "--as template --part PART" : "--part PART"
|
|
36
|
+
raise refusal.ending_with([Error::RepairCommand.new(purpose: "To print one part", command: "start-audit",
|
|
37
|
+
values: [@id], usage:)])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -6,7 +6,7 @@ module Principles
|
|
|
6
6
|
module Models
|
|
7
7
|
# Where a member may be read at a commit, and the hash of its text there, nil where it cannot be found. A
|
|
8
8
|
# one-member audit takes as the member's baseline the oldest placement that holds the text the audit record
|
|
9
|
-
# vouches for
|
|
9
|
+
# vouches for.
|
|
10
10
|
class Placement
|
|
11
11
|
#: String
|
|
12
12
|
attr_reader :commit
|
|
@@ -34,7 +34,7 @@ module Principles
|
|
|
34
34
|
def holds?(recorded) = !sha256.nil? && sha256 == recorded
|
|
35
35
|
|
|
36
36
|
# The paths a change from here to the member at now_path spans, this one first, so a diff over them follows
|
|
37
|
-
# a move
|
|
37
|
+
# a move.
|
|
38
38
|
#: (String) -> Array[String]
|
|
39
39
|
def paths_to(now_path) = [reference.fetch("path"), now_path].uniq
|
|
40
40
|
end
|
|
@@ -33,9 +33,9 @@ module Principles
|
|
|
33
33
|
#: (String, Hash[String, untyped]) -> void
|
|
34
34
|
def initialize(id, fields)
|
|
35
35
|
@id = id
|
|
36
|
-
# The principle owns its data: every field, an unknown one too, is copied and frozen down to each string, so
|
|
37
|
-
# change made in place to what it was built from or what it hands out changes its file or version
|
|
38
|
-
#
|
|
36
|
+
# The principle owns its data: every field, an unknown one too, is copied and frozen down to each string, so
|
|
37
|
+
# no change made in place to what it was built from or what it hands out changes its file or version. The copy
|
|
38
|
+
# goes through the JSON its version digests, which a map's file holds anyway.
|
|
39
39
|
owned = JSON.parse(JSON.generate(fields), freeze: true) #: Hash[String, untyped]
|
|
40
40
|
@members = PrincipleMembers.new(id, owned.fetch("members").map { |each| Member.new(each) }) #: PrincipleMembers
|
|
41
41
|
@fields = owned.merge("members" => @members.map(&:to_h).freeze).freeze #: Hash[String, untyped]
|
|
@@ -57,29 +57,29 @@ module Principles
|
|
|
57
57
|
|
|
58
58
|
# Whether this principle's audit keeps the release of principles it ran under, and its next full audit states
|
|
59
59
|
# what changed since: only the meta-principle's, which judges whether the keeping that release ships still
|
|
60
|
-
# works
|
|
60
|
+
# works.
|
|
61
61
|
#: () -> bool
|
|
62
62
|
def keeps_package? = meta_principle?
|
|
63
63
|
|
|
64
64
|
# Whether this principle's full audit states which other principles have members no audit has judged as they
|
|
65
|
-
# are now: only the meta-principle's, whose members are meant to bring those changes to an audit
|
|
65
|
+
# are now: only the meta-principle's, whose members are meant to bring those changes to an audit.
|
|
66
66
|
#: () -> bool
|
|
67
67
|
def keeps_others_held? = meta_principle?
|
|
68
68
|
|
|
69
69
|
# Whether this is the meta-principle with no members, as a setup that wrote its map before the first
|
|
70
70
|
# member, or removing its last member, leaves it. Only this principle's having none is out of the way: setup no
|
|
71
71
|
# longer writes it, and its first add-member creates it with that member (T74), while any other principle has
|
|
72
|
-
# none from create-principle until its first add-member
|
|
72
|
+
# none from create-principle until its first add-member.
|
|
73
73
|
#: () -> bool
|
|
74
74
|
def unstarted? = meta_principle? && @members.empty?
|
|
75
75
|
|
|
76
76
|
# Whether a full audit of this principle can have started, so that a correction may be open while a member is
|
|
77
|
-
# added: start-audit refuses a map with no members
|
|
77
|
+
# added: start-audit refuses a map with no members.
|
|
78
78
|
#: () -> bool
|
|
79
79
|
def auditable? = !@members.empty?
|
|
80
80
|
|
|
81
81
|
# The map's version: the digest of what its JSON says, so any change to it gives a new version, and a hand
|
|
82
|
-
# edit or a formatter that only reorders its keys does not
|
|
82
|
+
# edit or a formatter that only reorders its keys does not.
|
|
83
83
|
#: () -> String
|
|
84
84
|
def version = JsonDigest.new(@fields).to_s
|
|
85
85
|
|
|
@@ -110,7 +110,7 @@ module Principles
|
|
|
110
110
|
Principle.new(id, @fields.merge("description" => description))
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
# When the agent said this principle's work is in hand, as the map stores it, or nil when it has not
|
|
113
|
+
# When the agent said this principle's work is in hand, as the map stores it, or nil when it has not.
|
|
114
114
|
#: () -> Hash[String, untyped]?
|
|
115
115
|
def activation = @fields["activation"]
|
|
116
116
|
|
|
@@ -131,7 +131,7 @@ module Principles
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
# This principle with member_id pointed at the place located names, in the same file. The new place replaces
|
|
134
|
-
# the old one whole, and every other field is kept: its role, and any a newer version wrote
|
|
134
|
+
# the old one whole, and every other field is kept: its role, and any a newer version wrote. It is
|
|
135
135
|
# refused when another member is already there.
|
|
136
136
|
#: (String, Hash[String, untyped]) -> Principle
|
|
137
137
|
def moving(member_id, located)
|
|
@@ -148,7 +148,7 @@ module Principles
|
|
|
148
148
|
#: (String, String) -> Principle
|
|
149
149
|
def changing_role(member_id, role) = changing(member_id, "role" => role)
|
|
150
150
|
|
|
151
|
-
# Names the command that enforces a member, which an audit asks the agent to run
|
|
151
|
+
# Names the command that enforces a member, which an audit asks the agent to run. This tool
|
|
152
152
|
# stores it and never runs it.
|
|
153
153
|
#: (String, String) -> Principle
|
|
154
154
|
def changing_check(member_id, check) = changing(member_id, "check" => check)
|
|
@@ -181,7 +181,7 @@ module Principles
|
|
|
181
181
|
|
|
182
182
|
private
|
|
183
183
|
|
|
184
|
-
# Whether this is the principle that keeps every other one held
|
|
184
|
+
# Whether this is the principle that keeps every other one held.
|
|
185
185
|
#: () -> bool
|
|
186
186
|
def meta_principle? = @id == MetaPrinciple::ID
|
|
187
187
|
|
|
@@ -199,7 +199,7 @@ module Principles
|
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
# A repair command acting on a member of this principle, with the placeholders the agent fills; the controller
|
|
202
|
-
# prints it, quoting the member
|
|
202
|
+
# prints it, quoting the member.
|
|
203
203
|
#: (String, String, String, ?String?) -> Error::RepairCommand
|
|
204
204
|
def repair(purpose, command, member, usage = nil)
|
|
205
205
|
Error::RepairCommand.new(purpose: purpose, command: command, values: [id, member], usage: usage)
|