principles 0.0.4 → 0.0.6
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/lib/principles/after_commit_hook_options.rb +4 -1
- data/lib/principles/cli.rb +3 -1
- data/lib/principles/command_line.rb +38 -26
- data/lib/principles/command_routes.rb +11 -4
- data/lib/principles/controllers/acknowledgement.rb +93 -17
- data/lib/principles/controllers/answer.rb +45 -76
- data/lib/principles/controllers/answer_phase.rb +54 -0
- data/lib/principles/controllers/assessment.rb +46 -11
- data/lib/principles/controllers/audit.rb +17 -6
- data/lib/principles/controllers/audit_completion.rb +9 -5
- data/lib/principles/controllers/command.rb +5 -4
- data/lib/principles/controllers/correction.rb +22 -10
- data/lib/principles/controllers/full_audit_request.rb +11 -1
- data/lib/principles/controllers/guidance_search_paths.rb +31 -0
- data/lib/principles/controllers/inventory.rb +15 -29
- data/lib/principles/controllers/mapping.rb +9 -1
- data/lib/principles/controllers/member_addition.rb +65 -0
- data/lib/principles/controllers/member_entries.rb +6 -24
- data/lib/principles/controllers/member_problems_report.rb +13 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
- data/lib/principles/controllers/members_to_assess.rb +21 -13
- data/lib/principles/controllers/meta_principle_setup.rb +1 -1
- data/lib/principles/controllers/repoint.rb +22 -23
- data/lib/principles/controllers/survey.rb +60 -0
- data/lib/principles/data/audit_files.rb +4 -0
- data/lib/principles/data/bounded_file.rb +9 -4
- data/lib/principles/data/candidate_files_found.rb +48 -13
- data/lib/principles/data/command-steps.json +85 -24
- data/lib/principles/data/committed_tree.rb +84 -0
- data/lib/principles/data/first_parent_log.rb +48 -0
- data/lib/principles/data/first_parent_range.rb +122 -0
- data/lib/principles/data/git_command.rb +37 -0
- data/lib/principles/data/guidance_search_paths_file.rb +107 -0
- data/lib/principles/data/map_files.rb +35 -10
- data/lib/principles/data/principles_directory.rb +40 -0
- data/lib/principles/data/principles_subfolder.rb +39 -16
- data/lib/principles/data/project_files.rb +22 -11
- data/lib/principles/data/repository.rb +55 -29
- data/lib/principles/data/requested_candidate_files.rb +43 -0
- data/lib/principles/data/running_version.rb +3 -5
- data/lib/principles/data/schema_check.rb +16 -6
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +18 -5
- data/lib/principles/data/schemas/answer-guide.schema.json +255 -68
- data/lib/principles/data/schemas/audit-record.schema.json +10 -1
- data/lib/principles/data/schemas/command-steps.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +6 -0
- data/lib/principles/data/schemas/guidance-search-paths.schema.json +13 -0
- data/lib/principles/data/schemas/member-map-history.schema.json +20 -0
- data/lib/principles/data/verified_head.rb +162 -0
- data/lib/principles/invocation_options.rb +3 -3
- data/lib/principles/models/acknowledgement.rb +95 -84
- data/lib/principles/models/acknowledgement_left_as_printed.rb +51 -0
- data/lib/principles/models/acknowledgement_refusal.rb +90 -0
- data/lib/principles/models/answer_place.rb +4 -0
- data/lib/principles/models/assessment_answer.rb +0 -45
- data/lib/principles/models/assessment_left_as_printed.rb +81 -0
- data/lib/principles/models/audit_entry_protecting_map.rb +28 -0
- data/lib/principles/models/audit_record.rb +12 -16
- data/lib/principles/models/audit_records.rb +52 -23
- data/lib/principles/models/candidate_files.rb +44 -10
- data/lib/principles/models/candidate_inventory.rb +69 -8
- data/lib/principles/models/candidate_outline.rb +195 -0
- data/lib/principles/models/captured_head.rb +72 -0
- data/lib/principles/models/carried_member.rb +42 -0
- data/lib/principles/models/check_since_last_audit.rb +20 -11
- data/lib/principles/models/command_steps.rb +17 -1
- data/lib/principles/models/declared_map_changes.rb +29 -12
- data/lib/principles/models/declared_member_removals.rb +75 -0
- data/lib/principles/models/disposition.rb +4 -2
- data/lib/principles/models/fix_only_fields.rb +12 -0
- data/lib/principles/models/frontmatter_fields.rb +9 -8
- data/lib/principles/models/guidance_search_path.rb +26 -0
- data/lib/principles/models/guidance_search_paths.rb +57 -0
- data/lib/principles/models/instruction_named.rb +35 -0
- data/lib/principles/models/left_as_printed.rb +39 -0
- data/lib/principles/models/line_span.rb +6 -0
- data/lib/principles/models/loaded_files.rb +1 -2
- data/lib/principles/models/loading_scope.rb +61 -0
- data/lib/principles/models/locator.rb +6 -0
- data/lib/principles/models/mapped_principles.rb +39 -37
- data/lib/principles/models/member_assessments.rb +9 -31
- data/lib/principles/models/member_file.rb +20 -47
- data/lib/principles/models/member_hashes_as_written.rb +10 -6
- data/lib/principles/models/member_history.rb +7 -5
- data/lib/principles/models/member_lines.rb +63 -15
- data/lib/principles/models/member_loading_scopes.rb +49 -0
- data/lib/principles/models/member_loads.rb +4 -0
- data/lib/principles/models/member_mapping_run.rb +30 -0
- data/lib/principles/models/member_moves.rb +4 -0
- data/lib/principles/models/member_problems.rb +63 -33
- data/lib/principles/models/member_region.rb +129 -0
- data/lib/principles/models/member_repair_moves.rb +52 -0
- data/lib/principles/models/member_snapshots.rb +14 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +56 -0
- data/lib/principles/models/meta_principle.rb +14 -0
- data/lib/principles/models/missing_files.rb +2 -2
- data/lib/principles/models/open_findings_elsewhere.rb +4 -0
- data/lib/principles/models/other_templates_placeholders.rb +81 -42
- data/lib/principles/models/outline_budget.rb +142 -0
- data/lib/principles/models/outline_group.rb +31 -0
- data/lib/principles/models/outline_section.rb +56 -0
- data/lib/principles/models/principle.rb +14 -7
- data/lib/principles/models/principle_file_revision.rb +48 -0
- data/lib/principles/models/principle_history.rb +46 -19
- data/lib/principles/models/principle_lineage.rb +118 -0
- data/lib/principles/models/principle_map_revision.rb +39 -0
- data/lib/principles/models/principle_mapping_history.rb +132 -0
- data/lib/principles/models/principle_members.rb +25 -0
- data/lib/principles/models/principle_predecessor.rb +45 -0
- data/lib/principles/models/principle_publication.rb +177 -0
- data/lib/principles/models/principle_revision.rb +104 -0
- data/lib/principles/models/prior_decision_fields.rb +3 -2
- data/lib/principles/models/prior_finding_decision.rb +14 -4
- data/lib/principles/models/problem_report.rb +17 -5
- data/lib/principles/models/project.rb +46 -39
- data/lib/principles/models/project_history.rb +45 -25
- data/lib/principles/models/quoted_change.rb +137 -0
- data/lib/principles/models/record_format.rb +12 -2
- data/lib/principles/models/recorded_entry.rb +6 -0
- data/lib/principles/models/recorded_hashes.rb +7 -3
- data/lib/principles/models/recorded_members.rb +27 -15
- data/lib/principles/models/refusal_before_shape.rb +21 -0
- data/lib/principles/models/repoint.rb +13 -0
- data/lib/principles/models/reported_check.rb +5 -14
- data/lib/principles/models/sent_answer.rb +61 -0
- data/lib/principles/models/shape_problems_beside.rb +40 -0
- data/lib/principles/models/submitted_answer.rb +34 -0
- data/lib/principles/models/survey_search_paths.rb +26 -0
- data/lib/principles/models/template_placeholders.rb +34 -4
- data/lib/principles/models/text_within.rb +55 -0
- data/lib/principles/models/unchecked_members.rb +76 -0
- data/lib/principles/models/uncommitted_files.rb +50 -0
- data/lib/principles/models/unknown_principle.rb +29 -0
- data/lib/principles/models/write_up_opening.rb +21 -4
- data/lib/principles/positional_arguments.rb +37 -0
- data/lib/principles/session_start_options.rb +2 -2
- data/lib/principles/start_audit_options.rb +19 -4
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +23 -11
- data/lib/principles/views/added_member.rb +41 -0
- data/lib/principles/views/answered_request.rb +21 -0
- data/lib/principles/views/assessed_members.rb +43 -10
- data/lib/principles/views/assessment_request.rb +91 -31
- data/lib/principles/views/audit_result.rb +40 -28
- data/lib/principles/views/candidate_files_result.rb +85 -19
- data/lib/principles/views/candidate_outlines_result.rb +25 -0
- data/lib/principles/views/check_notes.rb +44 -0
- data/lib/principles/views/check_result_template.rb +14 -23
- data/lib/principles/views/consecutive_sections_elsewhere.rb +27 -0
- data/lib/principles/views/correction_request.rb +32 -1
- data/lib/principles/views/guidance_search_paths_result.rb +26 -0
- data/lib/principles/views/instruction.rb +74 -0
- data/lib/principles/views/json_with_entries_on_lines.rb +59 -0
- data/lib/principles/views/loads_to_check_result.rb +2 -2
- data/lib/principles/views/map_added_to.rb +56 -2
- data/lib/principles/views/map_result.rb +23 -43
- data/lib/principles/views/maps_needing_members_or_audit.rb +47 -0
- data/lib/principles/views/member_change_since_baseline.rb +23 -5
- data/lib/principles/views/member_repairs.rb +22 -52
- data/lib/principles/views/members_a_commit_changed.rb +16 -6
- data/lib/principles/views/new_loading_scope.rb +31 -0
- data/lib/principles/views/one_member_check_result_template.rb +47 -0
- data/lib/principles/views/open_findings_elsewhere_result.rb +3 -3
- data/lib/principles/views/open_findings_line.rb +77 -23
- data/lib/principles/views/principle_read_result.rb +24 -29
- data/lib/principles/views/principles_with_no_completed_audit.rb +9 -3
- data/lib/principles/views/prior_findings_result.rb +23 -15
- data/lib/principles/views/problem_lines.rb +3 -1
- data/lib/principles/views/problem_result.rb +8 -3
- data/lib/principles/views/prompts/acknowledge-a-change/run-the-check-and-report-it-passing.md +3 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +6 -12
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +67 -48
- data/lib/principles/views/prompts/assess-every-member/assess-each-member-and-the-set.md +0 -4
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +4 -16
- data/lib/principles/views/prompts/assess-every-member/judge-the-set-with-carried-assessments.md +5 -10
- data/lib/principles/views/prompts/assess-every-member/keep-or-change-what-a-deferral-waits-on.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +8 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-trimmed-instruction-whole.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/review-a-new-or-changed-check-before-running-it.md +9 -0
- data/lib/principles/views/prompts/assess-every-member/say-what-observed-means.md +4 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +16 -3
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +4 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +6 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-after-the-table.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-which-principle-to-map.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +11 -5
- data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +11 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/leave-test-data-out-of-the-survey.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-left-out-files.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/survey-a-later-range.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -4
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +5 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +35 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +55 -7
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +9 -8
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +1 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +5 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-guidance-search-path.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-principle.md +25 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +27 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +21 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +5 -5
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +24 -24
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +51 -54
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +7 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +9 -6
- data/lib/principles/views/prompts/start-a-session/see-the-earlier-line.md +2 -0
- data/lib/principles/views/record_waiting_on_an_upgrade.rb +3 -3
- data/lib/principles/views/request_part.rb +16 -8
- data/lib/principles/views/request_parts.rb +4 -0
- metadata +92 -7
- data/lib/principles/models/candidate_listing.rb +0 -32
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-before-mapping.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/the-map-and-audit-skill-says-how-to-audit-these-members.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/set-up-first.md +0 -2
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "time"
|
|
5
|
-
require_relative "
|
|
5
|
+
require_relative "answer_phase"
|
|
6
|
+
require_relative "../models/assessment_left_as_printed"
|
|
6
7
|
require_relative "../models/audit"
|
|
7
8
|
require_relative "../models/request_id"
|
|
9
|
+
require_relative "../models/unchecked_members"
|
|
10
|
+
require_relative "../models/uncommitted_files"
|
|
8
11
|
require_relative "audit_completion"
|
|
12
|
+
require_relative "full_audit_request"
|
|
9
13
|
|
|
10
14
|
module Principles
|
|
11
15
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
@@ -14,11 +18,15 @@ module Principles
|
|
|
14
18
|
# A full audit's assessment, which submit-answer and show-answer-check hand over: this tool checks the request
|
|
15
19
|
# it answers and each member's assessment, then completes an audit with no findings or asks for the correction
|
|
16
20
|
# of its findings (D35, D50).
|
|
17
|
-
class Assessment <
|
|
18
|
-
# The result of answering an assessment request
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
class Assessment < AnswerPhase
|
|
22
|
+
# The result of answering an assessment request, which checked_request found unchanged, with the prior findings
|
|
23
|
+
# it listed, and the record change it makes, not yet written.
|
|
24
|
+
# @override
|
|
25
|
+
#: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
|
|
26
|
+
def answered(submitted)
|
|
27
|
+
response = submitted.response
|
|
28
|
+
prior = submitted.prior_findings
|
|
29
|
+
audit = audit_now(submitted.request_id.principle_id)
|
|
22
30
|
basis = Models::AssessmentBasis.new(response.fetch("basis"))
|
|
23
31
|
judged_against = record_judged_against(audit)
|
|
24
32
|
basis.printed_after.refusing_stale_first(audit.id, @audit_records.find(audit.id)) do
|
|
@@ -27,16 +35,43 @@ module Principles
|
|
|
27
35
|
end
|
|
28
36
|
|
|
29
37
|
# The prior findings the request an answer's head names listed, refused when that request, given the head's
|
|
30
|
-
# basis, no longer matches the project, before the rest of the answer's shape is read
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
# basis, no longer matches the project, before the rest of the answer's shape is read: checked here alone, since
|
|
39
|
+
# its template prints placeholders this release's schema could otherwise refuse first (#1052).
|
|
40
|
+
#: (Models::RequestId, Hash[String, untyped]) -> Models::PriorFindings
|
|
41
|
+
def checked_request(request_id, head)
|
|
42
|
+
audit = audit_now(request_id.principle_id)
|
|
33
43
|
basis = Models::AssessmentBasis.new(head.fetch("basis"))
|
|
34
|
-
audit.check_assessment_request(request_id, basis: basis, committed: committed(basis.base, audit.map),
|
|
35
|
-
|
|
44
|
+
prior = audit.check_assessment_request(request_id, basis: basis, committed: committed(basis.base, audit.map),
|
|
45
|
+
record: @audit_records.find(audit.id),
|
|
46
|
+
loads: loads_to_check(audit))
|
|
47
|
+
principle_history(audit.id).confirm_current_id_since(basis.base)
|
|
48
|
+
prior
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The refusals an answer meets before its shape: first a check_result on a member with no check, which the
|
|
52
|
+
# shape would refuse as lacking its command (#1088), then any phase's, whose template is read first, as before,
|
|
53
|
+
# then a judgement left as its template printed it, named with the shape's problems, so one refusal names both
|
|
54
|
+
# (#1109).
|
|
55
|
+
#: (Models::RequestId) -> Array[Models::RefusalBeforeShape]
|
|
56
|
+
def before_shape(request_id)
|
|
57
|
+
any_phase = super
|
|
58
|
+
[Models::UncheckedMembers.new(@principles.find(request_id.principle_id).members), *any_phase,
|
|
59
|
+
Models::AssessmentLeftAsPrinted.new]
|
|
36
60
|
end
|
|
37
61
|
|
|
38
62
|
private
|
|
39
63
|
|
|
64
|
+
# The placeholders a full audit's template printed, as start-audit --as template prints it now (#1084).
|
|
65
|
+
#: (Models::RequestId) -> Hash[String, untyped]?
|
|
66
|
+
def printed_placeholders(request_id)
|
|
67
|
+
handed(FullAuditRequest, principle_id: request_id.principle_id).to_fill
|
|
68
|
+
rescue Error => e
|
|
69
|
+
# Template construction keeps the start guard, but this caller already has an answer to retry.
|
|
70
|
+
raise unless e.payload.fetch("code") == "uncommitted_files"
|
|
71
|
+
|
|
72
|
+
raise e.including("repair" => Models::UncommittedFiles::ASSESSMENT_REPAIR)
|
|
73
|
+
end
|
|
74
|
+
|
|
40
75
|
# The assessment's fields and its decisions on the prior findings checked, then the audit completed or its
|
|
41
76
|
# correction asked for.
|
|
42
77
|
#: (untyped, Models::Audit, Models::PriorFindings, Models::RecordJudgedAgainst, Models::AssessmentBasis)
|
|
@@ -33,15 +33,25 @@ module Principles
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
35
|
# The audit start-audit's options ask for: a one-member audit with --member, a repoint of the open
|
|
36
|
-
# findings' write-ups with --write-ups (D59), else a full audit
|
|
36
|
+
# findings' write-ups with --write-ups (D59), else a full audit; a full or one-member audit's answer alone with
|
|
37
|
+
# --as template (D81, #773).
|
|
37
38
|
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
38
39
|
def started_audit(id, options)
|
|
39
40
|
naming_the_executable { @audit_records.refuse_newer(id, version: @tool.version) }
|
|
40
|
-
return acknowledge(id, options["member"]) if options["member"]
|
|
41
|
+
return acknowledge(id, options["member"], to_fill: options["as"] == "template") if options["member"]
|
|
41
42
|
return handed(Repoint).start(id) if options["write_ups"]
|
|
42
43
|
|
|
44
|
+
full_audit(id, options)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# A full audit's request, or with --as template its answer alone, or with --instruction one instruction field
|
|
48
|
+
# of it (D81).
|
|
49
|
+
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
50
|
+
def full_audit(id, options)
|
|
43
51
|
naming_the_executable do
|
|
44
52
|
full = handed(FullAuditRequest, principle_id: id)
|
|
53
|
+
next full.instruction(options["instruction"]) if options["instruction"]
|
|
54
|
+
|
|
45
55
|
options["as"] ? full.to_fill : full.printed
|
|
46
56
|
end
|
|
47
57
|
end
|
|
@@ -55,10 +65,11 @@ module Principles
|
|
|
55
65
|
@audit_records.fetch(id).shown.merge(waiting_beside(id), "wrote" => [])
|
|
56
66
|
end
|
|
57
67
|
|
|
58
|
-
# A one-member audit of member_id (D33).
|
|
59
|
-
#: (String, String) -> Hash[String, untyped]
|
|
60
|
-
def acknowledge(id, member_id)
|
|
61
|
-
handed(Acknowledgement)
|
|
68
|
+
# A one-member audit of member_id (D33), or its answer alone to fill (#773).
|
|
69
|
+
#: (String, String, to_fill: bool) -> Hash[String, untyped]
|
|
70
|
+
def acknowledge(id, member_id, to_fill:)
|
|
71
|
+
acknowledgement = handed(Acknowledgement)
|
|
72
|
+
to_fill ? acknowledgement.to_fill(id, member_id) : acknowledgement.start(id, member_id)
|
|
62
73
|
end
|
|
63
74
|
|
|
64
75
|
# The findings the last completed audit of map id, or of every map, deferred or accepted (#292, D35). Across
|
|
@@ -8,6 +8,8 @@ require_relative "../models/commits_since_base"
|
|
|
8
8
|
require_relative "../models/other_principles"
|
|
9
9
|
require_relative "../views/prior_finding_decisions_result"
|
|
10
10
|
|
|
11
|
+
require_relative "../views/answered_request"
|
|
12
|
+
|
|
11
13
|
module Principles
|
|
12
14
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
13
15
|
# controllers/CLAUDE.md owns the boundary.
|
|
@@ -35,7 +37,7 @@ module Principles
|
|
|
35
37
|
written = record(start, audit.outcomes(findings, dispositions, decided), "completed", audit.now)
|
|
36
38
|
changes = @audit_records.changes(written)
|
|
37
39
|
@replacing&.confirm_writable(audit.id, @audit_records.find(audit.id), changes)
|
|
38
|
-
[completion_result(start, audit, dispositions, decided, written), changes]
|
|
40
|
+
[Views::AnsweredRequest.new(completion_result(start, audit, dispositions, decided, written)), changes]
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
# The record an audit writes, made now, saying what its assessments answered, with each assessment carried
|
|
@@ -54,15 +56,17 @@ module Principles
|
|
|
54
56
|
private
|
|
55
57
|
|
|
56
58
|
# What the completed audit prints: its resolved and open findings, as the record it writes holds them, so they
|
|
57
|
-
# agree with list-open-findings (#714); what it changed;
|
|
59
|
+
# agree with list-open-findings (#714); what it changed; each prior finding's decision (D35); and, while
|
|
60
|
+
# principles is not set up, the offer to set it up (D95).
|
|
58
61
|
#: (Models::AuditStart, Models::Audit, Array[Models::Disposition], Models::DecidedPriorFindings,
|
|
59
62
|
#| Models::AuditRecord) -> untyped
|
|
60
63
|
def completion_result(start, audit, dispositions, decided, written)
|
|
61
64
|
decisions = Views::PriorFindingDecisionsResult.new(kept_ids: decided.kept_ids, closed: decided.closed,
|
|
62
65
|
changed: decided.changed)
|
|
63
|
-
audit_result.completion(principle_id: audit.id, resolved: written.resolved_ids(decided),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
completed = audit_result.completion(principle_id: audit.id, resolved: written.resolved_ids(decided),
|
|
67
|
+
open: written.open_ids,
|
|
68
|
+
changes: changes(start, audit, dispositions, written), decisions: decisions)
|
|
69
|
+
@principles.set_up? ? completed : audit_result.offering_set_up(completed)
|
|
66
70
|
end
|
|
67
71
|
|
|
68
72
|
# What the audit changed in the project: the files to commit, in git the commits since the base, the
|
|
@@ -8,6 +8,7 @@ require_relative "../models/audit"
|
|
|
8
8
|
require_relative "../models/carried_assessments"
|
|
9
9
|
require_relative "../models/member"
|
|
10
10
|
require_relative "../models/member_grounds"
|
|
11
|
+
require_relative "../models/member_repair_moves"
|
|
11
12
|
require_relative "../models/principle_history"
|
|
12
13
|
require_relative "../models/members_sharing_lines"
|
|
13
14
|
require_relative "../models/project"
|
|
@@ -52,10 +53,10 @@ module Principles
|
|
|
52
53
|
|
|
53
54
|
private
|
|
54
55
|
|
|
55
|
-
# The history
|
|
56
|
+
# The command's shared history view for principle_id's map.
|
|
56
57
|
#: (String) -> Models::PrincipleHistory
|
|
57
58
|
def principle_history(principle_id)
|
|
58
|
-
|
|
59
|
+
@project.principle_history(principle_id)
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
# Saves the map, and nothing else, then prints the result the block builds from the map as written.
|
|
@@ -96,8 +97,8 @@ module Principles
|
|
|
96
97
|
def repaired(entry, repairs)
|
|
97
98
|
principle = entry["principle"] or return entry
|
|
98
99
|
id = entry["id"] or return entry
|
|
99
|
-
|
|
100
|
-
entry.merge("repair_with" => repairs.commands(principle,
|
|
100
|
+
moves = Models::MemberRepairMoves.new(@principles.find(principle).member(id), code: entry["code"]).to_a
|
|
101
|
+
entry.merge("repair_with" => repairs.commands(principle, id, moves))
|
|
101
102
|
rescue Error
|
|
102
103
|
entry
|
|
103
104
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
4
|
+
require_relative "answer_phase"
|
|
5
5
|
require_relative "../models/audit"
|
|
6
6
|
require_relative "../models/correction_answer"
|
|
7
7
|
require_relative "../models/declared_map_changes"
|
|
@@ -16,31 +16,41 @@ module Principles
|
|
|
16
16
|
# A full audit's correction, which submit-answer and show-answer-check hand over: this tool checks each
|
|
17
17
|
# disposition, and any members moved or whose role or check a fix changed, against the map and hashes the
|
|
18
18
|
# audit began from, and completes the audit (D28, D40).
|
|
19
|
-
class Correction <
|
|
19
|
+
class Correction < AnswerPhase
|
|
20
20
|
# The result of answering a correction request, and the record change it makes, not yet written. A refused
|
|
21
21
|
# answer to a request printed before the record changed is refused as stale, so the agent starts again rather
|
|
22
22
|
# than repairing it (#671).
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
# @override
|
|
24
|
+
#: (Models::SubmittedAnswer) -> [untyped, Array[Models::AuditRecord]]
|
|
25
|
+
def answered(submitted)
|
|
26
|
+
request_id = submitted.request_id
|
|
27
|
+
response = submitted.response
|
|
28
|
+
audit = audit_now(request_id.principle_id)
|
|
25
29
|
Models::CorrectionBasis.new(response.fetch("basis")).printed_after
|
|
26
30
|
.refusing_stale_first(audit.id, @audit_records.find(audit.id)) do
|
|
27
31
|
judged_correction(request_id, response, audit)
|
|
28
32
|
end
|
|
29
33
|
end
|
|
30
34
|
|
|
31
|
-
# What each map entry a fix claims changed, from the map
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
# What each map entry a fix in the answer claims changed, from the map its audit started from and its map now;
|
|
36
|
+
# the audit is built and the base map read only when a fix claims one (#462).
|
|
37
|
+
# @override
|
|
38
|
+
#: (Models::SubmittedAnswer) -> Array[Hash[String, untyped]]
|
|
39
|
+
def map_entry_changes(submitted)
|
|
40
|
+
response = submitted.response
|
|
35
41
|
changes = Models::DeclaredMapChanges.declared_in(response)
|
|
36
42
|
changes.entry_changes do
|
|
37
|
-
audit =
|
|
43
|
+
audit = audit_now(submitted.request_id.principle_id)
|
|
38
44
|
[started_from(Models::CorrectionBasis.new(response.fetch("basis")), audit, changes), audit.map]
|
|
39
45
|
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
private
|
|
43
49
|
|
|
50
|
+
# The placeholders a correction's template printed, its dispositions' (#1084).
|
|
51
|
+
#: (Models::RequestId) -> Hash[String, untyped]?
|
|
52
|
+
def printed_placeholders(_request_id) = Models::Disposition::TEMPLATE_PLACEHOLDERS
|
|
53
|
+
|
|
44
54
|
# The result of judging a correction answer: its basis, moves and dispositions checked, and the audit completed.
|
|
45
55
|
#: (Models::RequestId, untyped, Models::Audit) -> [untyped, Array[Models::AuditRecord]]
|
|
46
56
|
def judged_correction(request_id, response, audit)
|
|
@@ -87,7 +97,9 @@ module Principles
|
|
|
87
97
|
map = started_from(basis, audit, changes)
|
|
88
98
|
base = basis.base_commit
|
|
89
99
|
found = base ? committed(base, map) : @audit_records.find(audit.id)&.base_members
|
|
90
|
-
audit.confirmed_start(request_id, basis, found)
|
|
100
|
+
checked = audit.confirmed_start(request_id, basis, found)
|
|
101
|
+
principle_history(audit.id).confirm_current_id_since(base)
|
|
102
|
+
checked
|
|
91
103
|
end
|
|
92
104
|
|
|
93
105
|
#: (Models::DeclaredMapChanges, Models::CorrectionBasis) -> AuditCompletion
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require_relative "command"
|
|
5
5
|
require_relative "../models/audit"
|
|
6
6
|
require_relative "../models/evidence_lines_since"
|
|
7
|
+
require_relative "../models/instruction_named"
|
|
7
8
|
require_relative "../models/loading_decision"
|
|
8
9
|
require_relative "../models/meta_principle"
|
|
9
10
|
require_relative "../models/other_principles"
|
|
@@ -44,7 +45,7 @@ module Principles
|
|
|
44
45
|
# The request as start-audit prints it, with a notice when the last audit's record was left uncommitted.
|
|
45
46
|
#: () -> Hash[String, untyped]
|
|
46
47
|
def printed
|
|
47
|
-
audit_result.
|
|
48
|
+
audit_result.request(with_record_notice(audit_result.assessment_request(asked))).merge("wrote" => [])
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
# The answer alone, as start-audit --as template prints it, to fill and submit under the request's id (D81).
|
|
@@ -53,6 +54,15 @@ module Principles
|
|
|
53
54
|
audit_result.answer_to_fill(asked)
|
|
54
55
|
end
|
|
55
56
|
|
|
57
|
+
# The instruction field this request prints, read on its own and whole, with the paragraphs for cases the
|
|
58
|
+
# request does not hold (D81 step 2); refused when it prints none by that name.
|
|
59
|
+
#: (String) -> Hash[String, untyped]
|
|
60
|
+
def instruction(field)
|
|
61
|
+
request = asked
|
|
62
|
+
named = Models::InstructionNamed.new(field, principle_id: @id, printed: request.instruction_fields).field
|
|
63
|
+
{ "request_id" => request.request_id, named => request.whole_instruction(named), "wrote" => [] }
|
|
64
|
+
end
|
|
65
|
+
|
|
56
66
|
private
|
|
57
67
|
|
|
58
68
|
# The request and what it asks, listing the findings the last completed audit left to decide, under an id that
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../views/guidance_search_paths_result"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
9
|
+
# controllers/CLAUDE.md owns the boundary.
|
|
10
|
+
module Controllers
|
|
11
|
+
# The writes to the project's recorded guidance search paths, separate from member maps and audits.
|
|
12
|
+
class GuidanceSearchPaths < Command
|
|
13
|
+
COMMANDS = { "add-guidance-search-path" => :adding, "remove-guidance-search-path" => :removing }
|
|
14
|
+
.freeze #: Hash[String, Symbol]
|
|
15
|
+
|
|
16
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
17
|
+
def call(command, _id, options)
|
|
18
|
+
naming_the_executable do
|
|
19
|
+
operation = COMMANDS[command] or unknown(command)
|
|
20
|
+
current = @project.guidance_search_paths
|
|
21
|
+
updated = current.public_send(operation, options.fetch("glob"))
|
|
22
|
+
unchanged = updated.same_as?(current)
|
|
23
|
+
wrote = unchanged ? [] : [updated.save]
|
|
24
|
+
Views::GuidanceSearchPathsResult.new(invocation)
|
|
25
|
+
.result(status: unchanged ? "unchanged" : "guidance_search_paths_updated",
|
|
26
|
+
globs: updated.globs, wrote:)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -2,27 +2,22 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "command"
|
|
5
|
-
require_relative "member_problems_report"
|
|
6
5
|
require_relative "../models/member_state"
|
|
7
6
|
require_relative "../models/meta_principle"
|
|
8
|
-
require_relative "../views/candidate_files_result"
|
|
9
7
|
require_relative "../views/principle_read_result"
|
|
10
8
|
|
|
11
9
|
module Principles
|
|
12
10
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
13
11
|
# controllers/CLAUDE.md owns the boundary.
|
|
14
12
|
module Controllers
|
|
15
|
-
# The reads that show what a project
|
|
16
|
-
#
|
|
17
|
-
# changes anything on disk.
|
|
13
|
+
# The reads that show what a project has mapped: its principles, and each member and how fresh it is against the
|
|
14
|
+
# last audit. None changes anything on disk. Survey runs the survey of candidate files (#1015).
|
|
18
15
|
class Inventory < Command
|
|
19
16
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
20
|
-
def call(command, id,
|
|
17
|
+
def call(command, id, _options)
|
|
21
18
|
naming_the_executable do
|
|
22
19
|
case command
|
|
23
|
-
when "list-candidate-files" then list_candidate_files.merge("wrote" => [])
|
|
24
20
|
when "list-principles" then listing.merge("wrote" => [])
|
|
25
|
-
when "list-member-problems" then handed(MemberProblemsReport).printed(id, options)
|
|
26
21
|
when "show-principle" then members(required_id(id)).merge("wrote" => [])
|
|
27
22
|
else unknown(command)
|
|
28
23
|
end
|
|
@@ -36,15 +31,6 @@ module Principles
|
|
|
36
31
|
|
|
37
32
|
private
|
|
38
33
|
|
|
39
|
-
#: () -> untyped
|
|
40
|
-
def list_candidate_files
|
|
41
|
-
found = @project.candidate_files
|
|
42
|
-
listed = Views::CandidateFilesResult::Found.new(inventory: found.to_h, untracked: found.untracked,
|
|
43
|
-
owner_asks: found.owner_asks)
|
|
44
|
-
Views::CandidateFilesResult.new(invocation).question(listed, existing_maps: @principles.ids,
|
|
45
|
-
map_file: @principles.file("ID"), set_up: set_up?)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
34
|
#: (String) -> untyped
|
|
49
35
|
def members(id)
|
|
50
36
|
principle = @principles.find(id)
|
|
@@ -52,7 +38,7 @@ module Principles
|
|
|
52
38
|
hooks = @project.hook_commands
|
|
53
39
|
members = shown_members(principle, audit, hooks)
|
|
54
40
|
shown = read_result.shown(printed_principle(principle, members: members),
|
|
55
|
-
|
|
41
|
+
repairs: repairs(principle, members), hook_settings_not_read: hooks.not_read,
|
|
56
42
|
loaded_files: @project.loaded_files(principle.members, hooks).to_h)
|
|
57
43
|
return shown unless audit
|
|
58
44
|
|
|
@@ -77,11 +63,15 @@ module Principles
|
|
|
77
63
|
"loads" => loads.to_h)
|
|
78
64
|
end
|
|
79
65
|
|
|
80
|
-
# The
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
# The moves that may repair each shown member whose reference is broken, so an audit would refuse it, by id in the
|
|
67
|
+
# map's order.
|
|
68
|
+
#: (Models::Principle, Array[Hash[String, untyped]]) -> Hash[String, Array[Hash[String, untyped]]]
|
|
69
|
+
def repairs(principle, members)
|
|
83
70
|
members.select { |member| Models::MemberState.new(member.fetch("id"), member.fetch("freshness")).broken? }
|
|
84
|
-
.
|
|
71
|
+
.to_h do |member|
|
|
72
|
+
id = member.fetch("id")
|
|
73
|
+
[id, Models::MemberRepairMoves.new(principle.member(id), code: member.dig("error", "code")).to_a]
|
|
74
|
+
end
|
|
85
75
|
end
|
|
86
76
|
|
|
87
77
|
# The members sharing a line with this one, in its map and in others, as add-member names them, so a member
|
|
@@ -112,19 +102,15 @@ module Principles
|
|
|
112
102
|
def listing
|
|
113
103
|
ids = @principles.ids
|
|
114
104
|
waiting = ids.filter_map { waiting_on_an_upgrade(it) }
|
|
115
|
-
read_result.listing(rows(ids),
|
|
105
|
+
read_result.listing(rows(ids), waiting: waiting, one_to_audit: waiting.size < ids.size)
|
|
116
106
|
end
|
|
117
107
|
|
|
118
|
-
# Whether principles is set up, as MappedPrinciples decides it (D68, D75).
|
|
119
|
-
#: () -> bool
|
|
120
|
-
def set_up? = @principles.set_up?
|
|
121
|
-
|
|
122
108
|
# One map's row; a map this tool cannot read is listed with its refusal, so the others still show (D29), and one
|
|
123
109
|
# whose record a later copy wrote says its audits wait on an upgrade, as show-audit does (#1067).
|
|
124
110
|
#: (String) -> Hash[String, untyped]
|
|
125
111
|
def entry(id)
|
|
126
112
|
map = @principles.find(id)
|
|
127
|
-
row =
|
|
113
|
+
row = map.description_with_id.merge("members_by_freshness" => members_by_freshness(map))
|
|
128
114
|
row = row.merge(read_result.no_members(@principles.file(id))) if map.unstarted?
|
|
129
115
|
row.merge(waiting_on_an_upgrade(id)&.marker || {})
|
|
130
116
|
rescue Error => e
|
|
@@ -135,7 +121,7 @@ module Principles
|
|
|
135
121
|
# record a later copy wrote holds, read-only, when this copy cannot read the rest of it (#1067).
|
|
136
122
|
#: (Models::Principle) -> Hash[String, Integer]
|
|
137
123
|
def members_by_freshness(map)
|
|
138
|
-
|
|
124
|
+
hashes = @audit_records.hashes_to_compare(map.id)
|
|
139
125
|
map.members_shown.map { |member| fresh(member, hashes).fetch("freshness") }.tally.sort.to_h
|
|
140
126
|
end
|
|
141
127
|
end
|
|
@@ -15,7 +15,7 @@ module Principles
|
|
|
15
15
|
# Each command and the method that runs it.
|
|
16
16
|
COMMANDS = {
|
|
17
17
|
"create-principle" => :create_principle, "change-description" => :change_description,
|
|
18
|
-
"change-activation" => :change_activation
|
|
18
|
+
"change-activation" => :change_activation, "remove-principle" => :remove_principle
|
|
19
19
|
}.freeze #: Hash[String, Symbol]
|
|
20
20
|
|
|
21
21
|
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
@@ -28,6 +28,14 @@ module Principles
|
|
|
28
28
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
|
+
#: (String, Hash[String, untyped]) -> Hash[String, untyped]
|
|
32
|
+
def remove_principle(id, options)
|
|
33
|
+
map = @principles.find(id)
|
|
34
|
+
@audit_records.refuse_map_removal(id, confirmed: options["confirm"] == true)
|
|
35
|
+
file = @principles.remove(map)
|
|
36
|
+
map_result.removed(id, file: file)
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
#: (String, Hash[String, untyped]) -> untyped
|
|
32
40
|
def create_principle(id, options)
|
|
33
41
|
map = @principles.create(id) { text(options["description"], "--description") }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "command"
|
|
5
|
+
require_relative "../models/member"
|
|
6
|
+
require_relative "../models/members_in_consecutive_sections"
|
|
7
|
+
require_relative "../models/member_loading_scopes"
|
|
8
|
+
require_relative "../views/map_added_to"
|
|
9
|
+
require_relative "../views/consecutive_sections_elsewhere"
|
|
10
|
+
require_relative "../views/new_loading_scope"
|
|
11
|
+
|
|
12
|
+
module Principles
|
|
13
|
+
module Controllers
|
|
14
|
+
# A located new member and its before-save map, with reminder facts captured before the map is written.
|
|
15
|
+
class MemberAddition < Command
|
|
16
|
+
#: (Models::Project, tool: RunningTool, map: Models::Principle, member: Hash[String, untyped]) -> void
|
|
17
|
+
def initialize(project, tool:, map:, member:)
|
|
18
|
+
super(project, tool: tool)
|
|
19
|
+
@map = map
|
|
20
|
+
@member = Models::Member.new(member) #: Models::Member
|
|
21
|
+
@joined = joined #: Views::MapAddedTo
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Locate and report the added member after the caller saved exactly its new map.
|
|
25
|
+
#: (Views::PrintedPrinciple, added_to: Models::Principle) -> Hash[String, untyped]
|
|
26
|
+
def printed(principle, added_to:)
|
|
27
|
+
added = located_member
|
|
28
|
+
shared = lines_shared(@member, @map)
|
|
29
|
+
joined = joined_for(added_to)
|
|
30
|
+
sections = Models::MembersInConsecutiveSections.new(@project, @member).elsewhere(except: @map.id)
|
|
31
|
+
consecutive = Views::ConsecutiveSectionsElsewhere.new(sections)
|
|
32
|
+
map_result.member_added(principle, added: added, shared: shared, joined: joined, consecutive: consecutive)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
# The updated map's after-save context, keeping the reminder facts captured before the write.
|
|
38
|
+
#: (Models::Principle) -> Views::MapAddedTo
|
|
39
|
+
def joined_for(added_to)
|
|
40
|
+
no_completed = @audit_records.known_no_completed_audit?(@map.id)
|
|
41
|
+
joined = @joined.with_completeness_question(
|
|
42
|
+
asks: added_to.members.asks_about_completeness?(no_completed_audit: no_completed)
|
|
43
|
+
)
|
|
44
|
+
scopes = Models::MemberLoadingScopes.new(@project.member_loads(added_to.members))
|
|
45
|
+
joined.with_loading_scope(Views::NewLoadingScope.new(scopes.introduced_by(@member.id)))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The new member's id, current lines and stored check, located only after its map was saved.
|
|
49
|
+
#: () -> Hash[String, untyped]
|
|
50
|
+
def located_member
|
|
51
|
+
{ "id" => @member.id }.merge(snapshot(@member.locator).slice("first_line", "last_line"))
|
|
52
|
+
.merge(@member.to_h.slice("check"))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# The history must inspect the old map before the write, so a batch repeats its reminders only once.
|
|
56
|
+
#: () -> Views::MapAddedTo
|
|
57
|
+
def joined
|
|
58
|
+
history = principle_history(@map.id)
|
|
59
|
+
Views::MapAddedTo.new(keeps_others_held: @map.keeps_others_held?,
|
|
60
|
+
correction_may_be_open: history.startable_at_head?,
|
|
61
|
+
reminded: history.first_add_since_commit?(@map))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "command"
|
|
5
|
+
require_relative "member_addition"
|
|
5
6
|
|
|
6
7
|
module Principles
|
|
7
8
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
@@ -48,33 +49,14 @@ module Principles
|
|
|
48
49
|
started = !@principles.mapped?(id)
|
|
49
50
|
map = @principles.addable(id)
|
|
50
51
|
member = located(options, { "path" => text(options["path"], "PATH") }).merge(played(options))
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
addition = handed(MemberAddition, map: map, member: member)
|
|
53
|
+
updated = map.adding(member)
|
|
54
|
+
write_map(updated) do |printed|
|
|
55
|
+
added = addition.printed(printed, added_to: updated)
|
|
54
56
|
started ? added.merge(map_result.map_created(printed)) : added
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
|
|
58
|
-
# What add-member reports of the member it added to map: its id, lines and check, and the members, in
|
|
59
|
-
# this map or another, that share a line with it, so the agent sees an edit there shows on each (#383), and,
|
|
60
|
-
# when a correction may be open on map, how a fix claims the member (D72, #1023).
|
|
61
|
-
#: (Views::PrintedPrinciple, Models::Principle, Hash[String, untyped], Views::MapAddedTo) -> Hash[String, untyped]
|
|
62
|
-
def member_added(printed, map, member, joined)
|
|
63
|
-
added = Models::Member.new(member)
|
|
64
|
-
map_result.member_added(printed, added: span(member).merge(member.slice("check")),
|
|
65
|
-
shared: lines_shared(added, map), joined: joined)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# What add-member says of map, read before the member joins it and the map is saved, so the history can say
|
|
69
|
-
# whether this is the first add-member since the map was last committed (#1025).
|
|
70
|
-
#: (Models::Principle) -> Views::MapAddedTo
|
|
71
|
-
def joined(map)
|
|
72
|
-
history = principle_history(map.id)
|
|
73
|
-
Views::MapAddedTo.new(keeps_others_held: map.keeps_others_held?,
|
|
74
|
-
correction_may_be_open: history.startable_at_head?,
|
|
75
|
-
reminded: history.first_add_since_commit?(map))
|
|
76
|
-
end
|
|
77
|
-
|
|
78
60
|
# The part a new member plays, and the check that enforces it when one is named (D30).
|
|
79
61
|
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
80
62
|
def played(options)
|
|
@@ -153,7 +135,7 @@ module Principles
|
|
|
153
135
|
LOCATION_OPTIONS.each { |key, flag| member[key] = text(options[key], flag) if options[key] }
|
|
154
136
|
place = Models::Member.new(member)
|
|
155
137
|
place.check_location
|
|
156
|
-
|
|
138
|
+
@project.locate_for_authoring(place.locator)
|
|
157
139
|
member
|
|
158
140
|
end
|
|
159
141
|
end
|
|
@@ -13,9 +13,18 @@ module Principles
|
|
|
13
13
|
# Each runs one command: reads models, applies their rules and prints through a view.
|
|
14
14
|
# controllers/CLAUDE.md owns the boundary.
|
|
15
15
|
module Controllers
|
|
16
|
-
# list-member-problems
|
|
17
|
-
#
|
|
16
|
+
# list-member-problems: each member of one map or every map checked against its baseline, printed as JSON, as
|
|
17
|
+
# --short's lines, or for the after-commit hook through MembersACommitChanged.
|
|
18
18
|
class MemberProblemsReport < Command
|
|
19
|
+
#: (String, String?, Hash[String, untyped]) -> untyped
|
|
20
|
+
def call(command, id, options)
|
|
21
|
+
naming_the_executable do
|
|
22
|
+
command == "list-member-problems" ? printed(id, options) : unknown(command)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
19
28
|
# list-member-problems' JSON result, or with --short its lines for a trigger (#291), or with --hook-event the
|
|
20
29
|
# after-commit hook's JSON, which MembersACommitChanged prints (D73).
|
|
21
30
|
#: (String?, Hash[String, untyped]) -> untyped
|
|
@@ -33,8 +42,6 @@ module Principles
|
|
|
33
42
|
unassessed_change: problems.unassessed_change?)
|
|
34
43
|
end
|
|
35
44
|
|
|
36
|
-
private
|
|
37
|
-
|
|
38
45
|
# list-member-problems' JSON result for map id, or every map, without the files it wrote.
|
|
39
46
|
#: (String?) -> Hash[String, untyped]
|
|
40
47
|
def checked_report(id) = checked(id).last
|
|
@@ -52,8 +59,8 @@ module Principles
|
|
|
52
59
|
# (#187), and each principle waiting on an upgrade.
|
|
53
60
|
#: (Models::ProblemReport, Array[Views::RecordWaitingOnAnUpgrade]) -> untyped
|
|
54
61
|
def member_problems(problems, waiting)
|
|
55
|
-
report = problems.checked do |map_id, member, baseline, now|
|
|
56
|
-
principle_history(map_id).member_history(member, baseline: baseline, now: now)
|
|
62
|
+
report = problems.checked do |map_id, member, baseline, now, mapping|
|
|
63
|
+
@project.principle_history(map_id, mapping: mapping).member_history(member, baseline: baseline, now: now)
|
|
57
64
|
end
|
|
58
65
|
Views::ProblemResult.new(invocation).checked(report, not_read: @project.unread_older_files,
|
|
59
66
|
no_baseline_files: problems.files_to_commit(@principles),
|
|
@@ -13,7 +13,8 @@ module Principles
|
|
|
13
13
|
# exits 0 whatever it finds, since the host shows the user an error for any other status, and reports a refusal
|
|
14
14
|
# only when those commits could have caused it, so a broken setup does not repeat at every commit (review R8).
|
|
15
15
|
class MembersACommitChanged < Command
|
|
16
|
-
# report gives list-member-problems' result for every map, as
|
|
16
|
+
# report gives list-member-problems' result for every map, as MemberProblemsReport checks it, or raises its
|
|
17
|
+
# refusal.
|
|
17
18
|
#: (Models::Project, tool: RunningTool, report: ^() -> Hash[String, untyped]) -> void
|
|
18
19
|
def initialize(project, tool:, report:)
|
|
19
20
|
super(project, tool: tool)
|