principles 0.0.1
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 +7 -0
- data/exe/principles +10 -0
- data/lib/principles/after_commit_hook_options.rb +44 -0
- data/lib/principles/cli.rb +149 -0
- data/lib/principles/command_line.rb +188 -0
- data/lib/principles/command_routes.rb +60 -0
- data/lib/principles/controllers/acknowledgement.rb +106 -0
- data/lib/principles/controllers/answer.rb +172 -0
- data/lib/principles/controllers/audit.rb +203 -0
- data/lib/principles/controllers/audit_completion.rb +113 -0
- data/lib/principles/controllers/command.rb +201 -0
- data/lib/principles/controllers/correction.rb +99 -0
- data/lib/principles/controllers/help.rb +107 -0
- data/lib/principles/controllers/inventory.rb +181 -0
- data/lib/principles/controllers/mapping.rb +56 -0
- data/lib/principles/controllers/member_entries.rb +149 -0
- data/lib/principles/controllers/members_a_commit_changed.rb +43 -0
- data/lib/principles/controllers/members_to_assess.rb +160 -0
- data/lib/principles/controllers/meta_principle_setup.rb +92 -0
- data/lib/principles/controllers/repoint.rb +68 -0
- data/lib/principles/controllers/running_tool.rb +41 -0
- data/lib/principles/data/audit_files.rb +96 -0
- data/lib/principles/data/bounded_file.rb +45 -0
- data/lib/principles/data/candidate_files_found.rb +105 -0
- data/lib/principles/data/command-steps.json +305 -0
- data/lib/principles/data/command_steps_file.rb +50 -0
- data/lib/principles/data/expected_type.rb +71 -0
- data/lib/principles/data/ignored_by_git.rb +54 -0
- data/lib/principles/data/json_text.rb +57 -0
- data/lib/principles/data/known_fields.rb +42 -0
- data/lib/principles/data/linked_path.rb +102 -0
- data/lib/principles/data/map_files.rb +104 -0
- data/lib/principles/data/principle_id.rb +32 -0
- data/lib/principles/data/principles_subfolder.rb +93 -0
- data/lib/principles/data/project_files.rb +109 -0
- data/lib/principles/data/repository.rb +165 -0
- data/lib/principles/data/running_version.rb +44 -0
- data/lib/principles/data/schema_check.rb +139 -0
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +25 -0
- data/lib/principles/data/schemas/answer-guide.schema.json +99 -0
- data/lib/principles/data/schemas/assessment-answer.schema.json +332 -0
- data/lib/principles/data/schemas/audit-record.schema.json +277 -0
- data/lib/principles/data/schemas/command-steps.schema.json +83 -0
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +68 -0
- data/lib/principles/data/schemas/correction-answer.schema.json +306 -0
- data/lib/principles/data/schemas/member-map.schema.json +39 -0
- data/lib/principles/data/schemas/repointing-answer.schema.json +44 -0
- data/lib/principles/error.rb +102 -0
- data/lib/principles/invocation_options.rb +77 -0
- data/lib/principles/models/accepted_loading.rb +36 -0
- data/lib/principles/models/acknowledgement.rb +203 -0
- data/lib/principles/models/activation.rb +64 -0
- data/lib/principles/models/agent_loads.rb +64 -0
- data/lib/principles/models/answer_fields.rb +67 -0
- data/lib/principles/models/answer_place.rb +53 -0
- data/lib/principles/models/answer_text.rb +37 -0
- data/lib/principles/models/answered_time.rb +65 -0
- data/lib/principles/models/assessment_answer.rb +131 -0
- data/lib/principles/models/assessment_basis.rb +47 -0
- data/lib/principles/models/assessment_report.rb +62 -0
- data/lib/principles/models/audit.rb +200 -0
- data/lib/principles/models/audit_record.rb +249 -0
- data/lib/principles/models/audit_records.rb +103 -0
- data/lib/principles/models/audit_start.rb +96 -0
- data/lib/principles/models/audited_member_lines.rb +45 -0
- data/lib/principles/models/candidate_files.rb +66 -0
- data/lib/principles/models/candidate_inventory.rb +67 -0
- data/lib/principles/models/candidate_listing.rb +32 -0
- data/lib/principles/models/carried_assessments.rb +76 -0
- data/lib/principles/models/check_since_last_audit.rb +61 -0
- data/lib/principles/models/cited_files.rb +39 -0
- data/lib/principles/models/command_steps.rb +270 -0
- data/lib/principles/models/commits_brought_in.rb +27 -0
- data/lib/principles/models/commits_since_base.rb +32 -0
- data/lib/principles/models/correction_answer.rb +66 -0
- data/lib/principles/models/correction_basis.rb +70 -0
- data/lib/principles/models/dated_line.rb +29 -0
- data/lib/principles/models/decided_prior_findings.rb +106 -0
- data/lib/principles/models/declared_map_changes.rb +156 -0
- data/lib/principles/models/disposition.rb +233 -0
- data/lib/principles/models/entry_file.rb +65 -0
- data/lib/principles/models/entry_files.rb +46 -0
- data/lib/principles/models/evidence_item.rb +48 -0
- data/lib/principles/models/evidence_lines_since.rb +57 -0
- data/lib/principles/models/evidence_replacements.rb +99 -0
- data/lib/principles/models/finding_write_ups.rb +108 -0
- data/lib/principles/models/findings_left_open.rb +34 -0
- data/lib/principles/models/first_raised_claim.rb +128 -0
- data/lib/principles/models/frontmatter_fields.rb +128 -0
- data/lib/principles/models/hook_commands.rb +100 -0
- data/lib/principles/models/ignored_candidates.rb +46 -0
- data/lib/principles/models/json_digest.rb +35 -0
- data/lib/principles/models/json_path_query.rb +131 -0
- data/lib/principles/models/json_path_selectors.rb +64 -0
- data/lib/principles/models/json_path_string.rb +76 -0
- data/lib/principles/models/kept_prior_finding.rb +70 -0
- data/lib/principles/models/last_completed_revision.rb +70 -0
- data/lib/principles/models/line_span.rb +49 -0
- data/lib/principles/models/loaded_files.rb +60 -0
- data/lib/principles/models/loading_decision.rb +45 -0
- data/lib/principles/models/loading_facts.rb +45 -0
- data/lib/principles/models/loads_to_check.rb +93 -0
- data/lib/principles/models/locate_refusal.rb +23 -0
- data/lib/principles/models/located_text.rb +43 -0
- data/lib/principles/models/locator.rb +52 -0
- data/lib/principles/models/map_members.rb +171 -0
- data/lib/principles/models/markdown_file.rb +92 -0
- data/lib/principles/models/member.rb +171 -0
- data/lib/principles/models/member_assessments.rb +144 -0
- data/lib/principles/models/member_elsewhere.rb +74 -0
- data/lib/principles/models/member_file.rb +156 -0
- data/lib/principles/models/member_grounds.rb +32 -0
- data/lib/principles/models/member_history.rb +68 -0
- data/lib/principles/models/member_lines.rb +95 -0
- data/lib/principles/models/member_loads.rb +197 -0
- data/lib/principles/models/member_map.rb +219 -0
- data/lib/principles/models/member_map_history.rb +143 -0
- data/lib/principles/models/member_maps.rb +185 -0
- data/lib/principles/models/member_moves.rb +95 -0
- data/lib/principles/models/member_problems.rb +253 -0
- data/lib/principles/models/member_sighting.rb +176 -0
- data/lib/principles/models/member_snapshots.rb +36 -0
- data/lib/principles/models/member_state.rb +35 -0
- data/lib/principles/models/members_elsewhere.rb +46 -0
- data/lib/principles/models/members_sharing_lines.rb +116 -0
- data/lib/principles/models/meta_principle.rb +51 -0
- data/lib/principles/models/missing_files.rb +85 -0
- data/lib/principles/models/misspelt_member_id.rb +45 -0
- data/lib/principles/models/open_finding.rb +221 -0
- data/lib/principles/models/open_findings_elsewhere.rb +45 -0
- data/lib/principles/models/other_principles.rb +47 -0
- data/lib/principles/models/placement.rb +42 -0
- data/lib/principles/models/plain_text_file.rb +32 -0
- data/lib/principles/models/principles_folder_move.rb +59 -0
- data/lib/principles/models/principles_package.rb +53 -0
- data/lib/principles/models/prior_finding_decision.rb +162 -0
- data/lib/principles/models/prior_finding_outcomes.rb +60 -0
- data/lib/principles/models/prior_findings.rb +109 -0
- data/lib/principles/models/problem_report.rb +110 -0
- data/lib/principles/models/project.rb +214 -0
- data/lib/principles/models/project_history.rb +203 -0
- data/lib/principles/models/record_judged_against.rb +42 -0
- data/lib/principles/models/recorded_entry.rb +93 -0
- data/lib/principles/models/recorded_finding.rb +97 -0
- data/lib/principles/models/recorded_findings.rb +58 -0
- data/lib/principles/models/recorded_members.rb +149 -0
- data/lib/principles/models/repoint.rb +112 -0
- data/lib/principles/models/reported_check.rb +130 -0
- data/lib/principles/models/request_id.rb +70 -0
- data/lib/principles/models/runs_from.rb +36 -0
- data/lib/principles/models/skill_loads.rb +123 -0
- data/lib/principles/models/still_holds_restatement.rb +87 -0
- data/lib/principles/models/text_size.rb +26 -0
- data/lib/principles/models/uncommitted_outside_the_map.rb +30 -0
- data/lib/principles/models/waits_on.rb +58 -0
- data/lib/principles/models/write_up_opening.rb +93 -0
- data/lib/principles/models/write_up_pointer.rb +50 -0
- data/lib/principles/models/write_up_repoint.rb +39 -0
- data/lib/principles/prose_list.rb +23 -0
- data/lib/principles/supported_ruby.rb +93 -0
- data/lib/principles/version.rb +11 -0
- data/lib/principles/views/acknowledged_since_last_audit.rb +34 -0
- data/lib/principles/views/acknowledgement_result.rb +44 -0
- data/lib/principles/views/activation_in_hand.rb +47 -0
- data/lib/principles/views/assessment_request.rb +131 -0
- data/lib/principles/views/audit_changes.rb +79 -0
- data/lib/principles/views/audit_commit.rb +55 -0
- data/lib/principles/views/audit_result.rb +147 -0
- data/lib/principles/views/candidate_files_result.rb +95 -0
- data/lib/principles/views/check_result_template.rb +75 -0
- data/lib/principles/views/diff_since_last_audit.rb +29 -0
- data/lib/principles/views/findings_result.rb +45 -0
- data/lib/principles/views/help.rb +119 -0
- data/lib/principles/views/invocation.rb +66 -0
- data/lib/principles/views/landed_since_base.rb +27 -0
- data/lib/principles/views/lines_shared_with_member.rb +111 -0
- data/lib/principles/views/loads_to_check_result.rb +45 -0
- data/lib/principles/views/map_result.rb +169 -0
- data/lib/principles/views/member_change_since_baseline.rb +58 -0
- data/lib/principles/views/member_repairs.rb +82 -0
- data/lib/principles/views/members_a_commit_changed.rb +66 -0
- data/lib/principles/views/members_with_no_baseline.rb +56 -0
- data/lib/principles/views/meta_principle_passage.rb +23 -0
- data/lib/principles/views/meta_principle_result.rb +170 -0
- data/lib/principles/views/open_findings_elsewhere_result.rb +32 -0
- data/lib/principles/views/open_findings_line.rb +125 -0
- data/lib/principles/views/other_principles_unjudged_result.rb +32 -0
- data/lib/principles/views/outside_the_map_result.rb +31 -0
- data/lib/principles/views/package_since_last_audit_result.rb +34 -0
- data/lib/principles/views/principle_read_result.rb +86 -0
- data/lib/principles/views/principle_with_changed_members.rb +26 -0
- data/lib/principles/views/principles_with_no_completed_audit.rb +30 -0
- data/lib/principles/views/printed_principle.rb +45 -0
- data/lib/principles/views/prior_finding_decisions_result.rb +35 -0
- data/lib/principles/views/prior_findings_result.rb +80 -0
- data/lib/principles/views/problem_lines.rb +84 -0
- data/lib/principles/views/problem_result.rb +107 -0
- data/lib/principles/views/prompts/acknowledge-a-change/say-whether-the-change-keeps-the-meaning.md +12 -0
- data/lib/principles/views/prompts/answer-any-judgement-request/what-a-self-audit-cannot-show.md +6 -0
- data/lib/principles/views/prompts/assess-every-member/answer-guide.json +63 -0
- data/lib/principles/views/prompts/assess-every-member/assess-each-member-and-the-set.md +12 -0
- data/lib/principles/views/prompts/assess-every-member/check-roles-other-principles-give-these-lines.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-member-loading.md +17 -0
- data/lib/principles/views/prompts/assess-every-member/decide-each-prior-finding.md +38 -0
- data/lib/principles/views/prompts/assess-every-member/give-problem-evidence-at-still-holds.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/give-the-evidence-a-prior-finding-lacks.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/have-a-changed-check-reviewed-before-running-it.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/have-a-new-check-reviewed-before-running-it.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/have-hidden-characters-in-a-check-explained.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/judge-acknowledged-edits-together.md +6 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +7 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-under-the-release-since-the-last-audit.md +10 -0
- data/lib/principles/views/prompts/assess-every-member/judge-the-set-with-carried-assessments.md +10 -0
- data/lib/principles/views/prompts/assess-every-member/keep-the-last-review-basis-unless-you-give-a-new-one.md +1 -0
- data/lib/principles/views/prompts/assess-every-member/name-another-principles-open-finding-rather-than-raise-it.md +9 -0
- data/lib/principles/views/prompts/assess-every-member/read-whether-each-prior-finding-s-evidence-changed.md +12 -0
- data/lib/principles/views/prompts/assess-every-member/run-a-named-check-at-every-full-audit.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/run-the-check-then-report-it.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/run-the-reviewed-check-and-say-what-its-review-rested-on.md +6 -0
- data/lib/principles/views/prompts/assess-every-member/uncommitted-files-outside-the-map.md +4 -0
- data/lib/principles/views/prompts/assess-every-member/why-each-member-is-judged-again.md +24 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +34 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +24 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-before-mapping.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +5 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/owner-ask-ignored-folders.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/owner-ask-ignored.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/owner-ask-possibly-test-data.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/owner-ask-untracked.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/what-each-command-writes.md +4 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/where-the-inventory-looks.md +10 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +45 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-activation.md +21 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-description.md +2 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-check.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +9 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/create-principle.md +6 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +28 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +17 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +73 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +71 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-principles.md +7 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +11 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member-check.md +10 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +6 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +16 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +20 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +52 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +86 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +68 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +56 -0
- data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +10 -0
- data/lib/principles/views/prompts/report-after-a-commit/it-refused-after-the-commits-touched-the-maps.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/others-are-still-listed.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +1 -0
- data/lib/principles/views/prompts/report-the-completed-audit/commit-only-what-the-audit-changed.md +2 -0
- data/lib/principles/views/prompts/report-the-completed-audit/replace-the-default-commit-message.md +4 -0
- data/lib/principles/views/prompts/report-the-completed-audit/what-completion-means.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +3 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +15 -0
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +31 -0
- data/lib/principles/views/prompts/set-principles-up/set-up-first.md +2 -0
- data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +4 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +5 -0
- data/lib/principles/views/prompts/start-a-session/it-returns-after-each-clear-or-compaction-too.md +1 -0
- data/lib/principles/views/prompts/start-a-session/it-returns-at-each-session-start.md +1 -0
- data/lib/principles/views/prompts/start-a-session/raise-them-at-the-next-pause.md +1 -0
- data/lib/principles/views/prompts/start-a-session/raise-them-before-the-first-task.md +1 -0
- data/lib/principles/views/prompts.rb +71 -0
- data/lib/principles/views/repoint_result.rb +80 -0
- data/lib/principles/views/request_part.rb +26 -0
- data/lib/principles/views/request_parts.rb +26 -0
- data/lib/principles/views/shell_word.rb +29 -0
- data/lib/principles/views/visible_text.rb +26 -0
- data/lib/principles/views/workflow_diagram.rb +77 -0
- data/lib/principles.rb +5 -0
- metadata +326 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "command-steps.schema.json",
|
|
4
|
+
"title": "Command steps",
|
|
5
|
+
"description": "The steps each command runs, marked this tool's (cli) or the agent's, with the refusals each cli step can raise and where each step leads. Each command's --help and the workflow diagram are drawn from it.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["groups", "refusal_groups", "commands"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"$defs": {
|
|
10
|
+
"slug": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)*$" },
|
|
11
|
+
"code": { "type": "string", "pattern": "^[a-z]+(_[a-z]+)*$" },
|
|
12
|
+
"prose": { "type": "string", "minLength": 1 },
|
|
13
|
+
"step": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"required": ["id", "actor", "does"],
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"properties": {
|
|
18
|
+
"id": { "$ref": "#/$defs/slug" },
|
|
19
|
+
"actor": { "enum": ["cli", "agent"] },
|
|
20
|
+
"does": { "$ref": "#/$defs/prose" },
|
|
21
|
+
"refuses": { "type": "array", "items": { "$ref": "#/$defs/code" }, "minItems": 1, "uniqueItems": true },
|
|
22
|
+
"refuses_like": { "type": "array", "items": { "$ref": "#/$defs/slug" }, "minItems": 1, "uniqueItems": true },
|
|
23
|
+
"prompt": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
|
24
|
+
"checks": { "$ref": "#/$defs/prose" },
|
|
25
|
+
"cannot_check": { "$ref": "#/$defs/prose" },
|
|
26
|
+
"answer_with": { "$ref": "#/$defs/slug" },
|
|
27
|
+
"answer_when": { "$ref": "#/$defs/prose" },
|
|
28
|
+
"answer_usage": { "$ref": "#/$defs/prose" },
|
|
29
|
+
"next": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"minItems": 2,
|
|
32
|
+
"items": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"required": ["to", "when"],
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": { "to": { "$ref": "#/$defs/slug" }, "when": { "$ref": "#/$defs/prose" } }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"if": { "properties": { "actor": { "const": "agent" } } },
|
|
41
|
+
"then": { "not": { "anyOf": [{ "required": ["refuses"] }, { "required": ["refuses_like"] }] } }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"properties": {
|
|
45
|
+
"groups": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"minItems": 1,
|
|
48
|
+
"items": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"required": ["id", "heading", "writes"],
|
|
51
|
+
"additionalProperties": false,
|
|
52
|
+
"properties": {
|
|
53
|
+
"id": { "$ref": "#/$defs/slug" }, "heading": { "$ref": "#/$defs/prose" }, "writes": { "$ref": "#/$defs/prose" }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"refusal_groups": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": ["any-command"],
|
|
60
|
+
"propertyNames": { "$ref": "#/$defs/slug" },
|
|
61
|
+
"additionalProperties": { "type": "array", "items": { "$ref": "#/$defs/code" }, "minItems": 1, "uniqueItems": true }
|
|
62
|
+
},
|
|
63
|
+
"commands": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"minItems": 1,
|
|
66
|
+
"items": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"required": ["name", "usage", "group", "options", "summary", "help", "steps"],
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"properties": {
|
|
71
|
+
"name": { "$ref": "#/$defs/slug" },
|
|
72
|
+
"usage": { "$ref": "#/$defs/prose" },
|
|
73
|
+
"group": { "$ref": "#/$defs/slug" },
|
|
74
|
+
"options": { "type": "array", "uniqueItems": true,
|
|
75
|
+
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups"] } },
|
|
76
|
+
"summary": { "$ref": "#/$defs/prose" },
|
|
77
|
+
"help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
|
78
|
+
"steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/step" } }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "correction-answer-guide.schema.json",
|
|
4
|
+
"title": "Correction answer guide",
|
|
5
|
+
"description": "Example shapes the correction request shows, one disposition for each action, beside the template, which leaves each action null for the agent to choose (#708).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["disposition"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"disposition": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"required": ["fixed", "deferred", "accepted", "disagreed"],
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"properties": {
|
|
15
|
+
"fixed": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"required": ["action", "reason", "changed_members", "evidence", "reassessment", "recorded_at"],
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"properties": {
|
|
20
|
+
"action": { "const": "fixed" },
|
|
21
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
22
|
+
"changed_members": { "type": "array", "items": { "type": "string" } },
|
|
23
|
+
"evidence": { "type": "array", "items": { "type": "object" } },
|
|
24
|
+
"reassessment": { "type": "string", "minLength": 1 },
|
|
25
|
+
"recorded_at": { "type": ["object", "null"] }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"deferred": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"required": ["action", "reason", "changed_members", "evidence", "recorded_at", "waits_on"],
|
|
31
|
+
"additionalProperties": false,
|
|
32
|
+
"properties": {
|
|
33
|
+
"action": { "const": "deferred" },
|
|
34
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
35
|
+
"changed_members": { "type": "array", "items": { "type": "string" } },
|
|
36
|
+
"evidence": { "type": "array", "items": { "type": "object" } },
|
|
37
|
+
"recorded_at": { "type": ["object", "null"] },
|
|
38
|
+
"waits_on": { "type": "string", "minLength": 1 }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"accepted": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"required": ["action", "reason", "changed_members", "evidence", "recorded_at"],
|
|
44
|
+
"additionalProperties": false,
|
|
45
|
+
"properties": {
|
|
46
|
+
"action": { "const": "accepted" },
|
|
47
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
48
|
+
"changed_members": { "type": "array", "items": { "type": "string" } },
|
|
49
|
+
"evidence": { "type": "array", "items": { "type": "object" } },
|
|
50
|
+
"recorded_at": { "type": ["object", "null"] }
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"disagreed": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"required": ["action", "reason", "changed_members", "evidence", "recorded_at"],
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"properties": {
|
|
58
|
+
"action": { "const": "disagreed" },
|
|
59
|
+
"reason": { "type": "string", "minLength": 1 },
|
|
60
|
+
"changed_members": { "type": "array", "items": { "type": "string" } },
|
|
61
|
+
"evidence": { "type": "array", "items": { "type": "object" } },
|
|
62
|
+
"recorded_at": { "type": ["object", "null"] }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "correction-answer.schema.json",
|
|
4
|
+
"title": "Correction answer",
|
|
5
|
+
"description": "What an agent answers an audit's correction request with: the request's id and basis, one disposition per finding, any members its fixes moved (D28), and in each fix any members whose role or check it changed (D40). Fields this tool does not read are refused, to catch a misspelt field (D29). The rules across fields, such as one disposition per finding, stay in Models::CorrectionAnswer and Models::DeclaredMapChanges.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"request_id",
|
|
10
|
+
"basis",
|
|
11
|
+
"dispositions"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"request_id": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"basis": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"required": [
|
|
21
|
+
"base_commit",
|
|
22
|
+
"map_version",
|
|
23
|
+
"last_completed_revision",
|
|
24
|
+
"findings"
|
|
25
|
+
],
|
|
26
|
+
"properties": {
|
|
27
|
+
"last_completed_revision": {
|
|
28
|
+
"type": [
|
|
29
|
+
"string",
|
|
30
|
+
"null"
|
|
31
|
+
],
|
|
32
|
+
"description": "A digest of the last completed audit record when the correction request was printed, or null when there was none. Copy it as the template gives it."
|
|
33
|
+
},
|
|
34
|
+
"base_commit": {
|
|
35
|
+
"type": [
|
|
36
|
+
"string",
|
|
37
|
+
"null"
|
|
38
|
+
],
|
|
39
|
+
"pattern": "\\A[0-9a-f]{40}([0-9a-f]{24})?\\z",
|
|
40
|
+
"description": "A full commit sha, as start-audit gave it, or null outside git. This tool refuses anything else before running git."
|
|
41
|
+
},
|
|
42
|
+
"map_version": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"findings": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"items": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"required": [
|
|
51
|
+
"id",
|
|
52
|
+
"member_ids"
|
|
53
|
+
],
|
|
54
|
+
"properties": {
|
|
55
|
+
"id": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"member_ids": {
|
|
59
|
+
"type": "array",
|
|
60
|
+
"items": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"problem": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "The finding's problem as the assessment stated it, carried so the completed record keeps it (D34)."
|
|
67
|
+
},
|
|
68
|
+
"evidence": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"description": "The evidence the assessment raised the finding with, carried so the completed record keeps it (D64). Absent from a basis printed before it was kept.",
|
|
71
|
+
"items": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"required": [
|
|
74
|
+
"path"
|
|
75
|
+
],
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"path": {
|
|
79
|
+
"type": "string"
|
|
80
|
+
},
|
|
81
|
+
"heading": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"starting_at": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"ending_at": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"query": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"recent_decision_paths": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": { "type": "string" },
|
|
102
|
+
"description": "The paths the assessment's recent decision cites as evidence, which the record does not keep, carried so the completed audit asks to commit those that differ from HEAD (#860). Copy it as the template gives it."
|
|
103
|
+
},
|
|
104
|
+
"entry_fields": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"description": "By member id, the fields the assessment reported for each member's record entry: its assessment (D49), its check's result (D30) and its accepted loading decision (#355), carried from the assessment so the completed record keeps them.",
|
|
107
|
+
"additionalProperties": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": false,
|
|
110
|
+
"properties": {
|
|
111
|
+
"check_result": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"additionalProperties": false,
|
|
114
|
+
"required": [
|
|
115
|
+
"command"
|
|
116
|
+
],
|
|
117
|
+
"properties": {
|
|
118
|
+
"command": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
},
|
|
121
|
+
"exit_status": {
|
|
122
|
+
"type": "integer"
|
|
123
|
+
},
|
|
124
|
+
"not_run_reason": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
"review_basis": {
|
|
128
|
+
"type": "string"
|
|
129
|
+
},
|
|
130
|
+
"review_basis_since": {
|
|
131
|
+
"type": "string"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"loading_accepted": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"additionalProperties": false,
|
|
138
|
+
"required": [
|
|
139
|
+
"reason",
|
|
140
|
+
"loads"
|
|
141
|
+
],
|
|
142
|
+
"properties": {
|
|
143
|
+
"reason": {
|
|
144
|
+
"type": "string"
|
|
145
|
+
},
|
|
146
|
+
"loads": {
|
|
147
|
+
"type": "object"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"assessment": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"description": "The member's assessment as the assessment gave it, with the grounds it was judged on, which the completed record keeps (D49)."
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"prior_findings": {
|
|
159
|
+
"type": "object",
|
|
160
|
+
"description": "The assessment's decisions on prior findings, carried so the completed record keeps the ones that still hold (D35).",
|
|
161
|
+
"required": [
|
|
162
|
+
"kept",
|
|
163
|
+
"closed",
|
|
164
|
+
"inherited"
|
|
165
|
+
],
|
|
166
|
+
"properties": {
|
|
167
|
+
"kept": {
|
|
168
|
+
"type": "array"
|
|
169
|
+
},
|
|
170
|
+
"closed": {
|
|
171
|
+
"type": "array"
|
|
172
|
+
},
|
|
173
|
+
"inherited": {
|
|
174
|
+
"type": "object"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"dispositions": {
|
|
181
|
+
"type": "array",
|
|
182
|
+
"items": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"additionalProperties": false,
|
|
185
|
+
"required": [
|
|
186
|
+
"finding_id",
|
|
187
|
+
"action",
|
|
188
|
+
"reason",
|
|
189
|
+
"evidence",
|
|
190
|
+
"changed_members"
|
|
191
|
+
],
|
|
192
|
+
"properties": {
|
|
193
|
+
"finding_id": {
|
|
194
|
+
"type": "string"
|
|
195
|
+
},
|
|
196
|
+
"action": {
|
|
197
|
+
"type": ["string", "null"],
|
|
198
|
+
"description": "fixed, deferred, accepted or disagreed, which the agent chooses: the template leaves it null, and Models::CorrectionAnswer refuses null or any other value with invalid_disposition (#708)."
|
|
199
|
+
},
|
|
200
|
+
"reason": {
|
|
201
|
+
"type": "string"
|
|
202
|
+
},
|
|
203
|
+
"evidence": {
|
|
204
|
+
"type": "array",
|
|
205
|
+
"items": {
|
|
206
|
+
"type": "object",
|
|
207
|
+
"required": [
|
|
208
|
+
"path"
|
|
209
|
+
],
|
|
210
|
+
"additionalProperties": false,
|
|
211
|
+
"properties": {
|
|
212
|
+
"path": {
|
|
213
|
+
"type": "string"
|
|
214
|
+
},
|
|
215
|
+
"heading": {
|
|
216
|
+
"type": "string"
|
|
217
|
+
},
|
|
218
|
+
"starting_at": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
},
|
|
221
|
+
"ending_at": {
|
|
222
|
+
"type": "string"
|
|
223
|
+
},
|
|
224
|
+
"query": {
|
|
225
|
+
"type": "string"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"recorded_at": {
|
|
231
|
+
"x-type-refusal-advice": {
|
|
232
|
+
"keys": [
|
|
233
|
+
"heading",
|
|
234
|
+
"starting_at"
|
|
235
|
+
],
|
|
236
|
+
"says": "plus starting_at (or heading) when the file holds more than this finding"
|
|
237
|
+
},
|
|
238
|
+
"type": [
|
|
239
|
+
"object",
|
|
240
|
+
"null"
|
|
241
|
+
],
|
|
242
|
+
"required": [
|
|
243
|
+
"path"
|
|
244
|
+
],
|
|
245
|
+
"additionalProperties": false,
|
|
246
|
+
"properties": {
|
|
247
|
+
"path": {
|
|
248
|
+
"type": "string"
|
|
249
|
+
},
|
|
250
|
+
"heading": {
|
|
251
|
+
"type": "string"
|
|
252
|
+
},
|
|
253
|
+
"starting_at": {
|
|
254
|
+
"type": "string"
|
|
255
|
+
},
|
|
256
|
+
"ending_at": {
|
|
257
|
+
"type": "string"
|
|
258
|
+
},
|
|
259
|
+
"query": {
|
|
260
|
+
"type": "string"
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"changed_members": {
|
|
265
|
+
"type": "array",
|
|
266
|
+
"items": {
|
|
267
|
+
"type": "string"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"changed_map_entries": {
|
|
271
|
+
"type": "array",
|
|
272
|
+
"items": {
|
|
273
|
+
"type": "string"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
"reassessment": {
|
|
277
|
+
"type": "string"
|
|
278
|
+
},
|
|
279
|
+
"waits_on": {
|
|
280
|
+
"type": ["string", "null"],
|
|
281
|
+
"description": "On a deferral, one line saying whom it waits on and to decide what; null on any disposition. Models::CorrectionAnswer refuses a value on another action, or one not one line (D52)."
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"moved_members": {
|
|
287
|
+
"type": "array",
|
|
288
|
+
"items": {
|
|
289
|
+
"type": "object",
|
|
290
|
+
"additionalProperties": false,
|
|
291
|
+
"required": [
|
|
292
|
+
"from",
|
|
293
|
+
"to"
|
|
294
|
+
],
|
|
295
|
+
"properties": {
|
|
296
|
+
"from": {
|
|
297
|
+
"type": "string"
|
|
298
|
+
},
|
|
299
|
+
"to": {
|
|
300
|
+
"type": "string"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "member-map.schema.json",
|
|
4
|
+
"title": "Member map",
|
|
5
|
+
"description": "A principle's committed map, .principles/maps/ID.json: what the principle is, and each member that carries it. Fields this schema does not name are allowed, so an older version can read a map a newer one wrote (D29).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["description", "members"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"format": { "type": "integer", "description": "The oldest map format that can read this map without losing what it says. Missing means 1. This tool writes it only when a member uses a field from a later format, and refuses a map whose format is newer than it knows." },
|
|
10
|
+
"description": { "type": "string", "minLength": 1 },
|
|
11
|
+
"activation": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "When the principle's work is in hand, as the agent declared it with change-activation (D38): when files matching one of its globs are read or changed, when its work is invoked, or always. change-activation writes files only with when files; a hand-edited map is not yet checked for that.",
|
|
14
|
+
"required": ["when"],
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"properties": {
|
|
17
|
+
"when": { "enum": ["files", "invoked", "always"] },
|
|
18
|
+
"files": { "type": "array", "items": { "type": "string", "pattern": "\\S" } }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"members": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"required": ["path", "role"],
|
|
26
|
+
"properties": {
|
|
27
|
+
"path": { "type": "string", "minLength": 1 },
|
|
28
|
+
"section": { "type": "string", "minLength": 1 },
|
|
29
|
+
"starting_at": { "type": "string", "minLength": 1 },
|
|
30
|
+
"query": { "type": "string", "minLength": 1 },
|
|
31
|
+
"ending_at": { "type": "string", "minLength": 1 },
|
|
32
|
+
"role": { "type": "string", "minLength": 1 },
|
|
33
|
+
"key": { "type": "string", "minLength": 1, "description": "What the member is known by across moves, which its audit record files its hash under. Absent, it is the member's id. move-member stores the old id here on a member's first move, and add-member gives a member a key of its own when its id is the key of a member that moved away." },
|
|
34
|
+
"check": { "type": "string", "minLength": 1, "description": "The command that enforces this member, which an audit asks the agent to run and report. This tool never runs it (D30)." }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "repointing-answer.schema.json",
|
|
4
|
+
"title": "Repointing answer",
|
|
5
|
+
"description": "What an agent answers a repoint of a principle's open findings' write-ups with (D59): the request's id and basis, then for each finding a new recorded_at, or null to leave it, and a one-line reason. Fields this tool does not read are refused (D29). Models::Repoint locates each new pointer.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["request_id", "basis", "repoints"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"request_id": { "type": "string" },
|
|
11
|
+
"basis": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": false,
|
|
14
|
+
"required": ["revision"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"revision": { "type": ["string", "null"] }
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"repoints": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"items": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": false,
|
|
24
|
+
"required": ["finding_id", "recorded_at", "reason"],
|
|
25
|
+
"properties": {
|
|
26
|
+
"finding_id": { "type": "string", "minLength": 1 },
|
|
27
|
+
"recorded_at": {
|
|
28
|
+
"type": ["object", "null"],
|
|
29
|
+
"required": ["path"],
|
|
30
|
+
"additionalProperties": false,
|
|
31
|
+
"properties": {
|
|
32
|
+
"path": { "type": "string" },
|
|
33
|
+
"heading": { "type": "string" },
|
|
34
|
+
"starting_at": { "type": "string" },
|
|
35
|
+
"ending_at": { "type": "string" },
|
|
36
|
+
"query": { "type": "string" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"reason": { "type": "string" }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# A refusal: a stable code, what went wrong and how to repair it, printed as one JSON object.
|
|
6
|
+
class Error < StandardError
|
|
7
|
+
# Stands in a model's repair for the running executable, which only the controller knows. The
|
|
8
|
+
# controller puts the executable in with #naming before the refusal is printed.
|
|
9
|
+
EXECUTABLE = "{executable}"
|
|
10
|
+
|
|
11
|
+
# A command a refusal's repair names for values it holds, such as a member id, left unquoted, since a model
|
|
12
|
+
# cannot quote: the controller prints it through Views::Invocation, the one owner of shell quoting, after its
|
|
13
|
+
# purpose and a colon, on a line of its own (D56, #729). options are flags with their values, quoted the same
|
|
14
|
+
# way; usage is this tool's own placeholder text, such as "--role ROLE", left for the agent to fill.
|
|
15
|
+
class RepairCommand
|
|
16
|
+
#: String
|
|
17
|
+
attr_reader :purpose, :command
|
|
18
|
+
#: Array[String]
|
|
19
|
+
attr_reader :values, :options
|
|
20
|
+
#: String?
|
|
21
|
+
attr_reader :usage
|
|
22
|
+
|
|
23
|
+
#: (purpose: String, command: String, values: Array[String], ?options: Array[String], ?usage: String?) -> void
|
|
24
|
+
def initialize(purpose:, command:, values:, options: [], usage: nil)
|
|
25
|
+
@purpose = purpose
|
|
26
|
+
@command = command
|
|
27
|
+
@values = values
|
|
28
|
+
@options = options
|
|
29
|
+
@usage = usage
|
|
30
|
+
freeze
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#: Hash[String, untyped]
|
|
35
|
+
attr_reader :payload
|
|
36
|
+
|
|
37
|
+
# fields are the failing JSON pointers of a malformed file or answer, each with what is wrong there (D29).
|
|
38
|
+
#: (String, String, String, ?String?, ?fields: Array[Hash[String, String]]?) -> void
|
|
39
|
+
def initialize(code, message, repair, path = nil, fields: nil)
|
|
40
|
+
super(message)
|
|
41
|
+
@payload = { "status" => "refused", "code" => code, "message" => message,
|
|
42
|
+
"repair" => repair } #: Hash[String, untyped]
|
|
43
|
+
@payload["path"] = path if path
|
|
44
|
+
@payload["fields"] = fields if fields
|
|
45
|
+
@commands = [] #: Array[RepairCommand]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The repair's commands still to print, which follow its text.
|
|
49
|
+
#: Array[RepairCommand]
|
|
50
|
+
attr_reader :commands
|
|
51
|
+
|
|
52
|
+
# This refusal with commands, which its repair names after its text, for the controller to print.
|
|
53
|
+
#: (Array[RepairCommand]) -> Error
|
|
54
|
+
def ending_with(commands)
|
|
55
|
+
@commands = commands
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# This refusal with more of what it is about, such as the members it lists, each with its own refusal.
|
|
60
|
+
#: (Hash[String, untyped]) -> Error
|
|
61
|
+
def including(details)
|
|
62
|
+
@payload.merge!(details)
|
|
63
|
+
self
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# This refusal with each of its commands printed by the block, after its purpose, a line each after the repair's
|
|
67
|
+
# text (D56).
|
|
68
|
+
#: () { (RepairCommand) -> String } -> Error
|
|
69
|
+
def printing_commands(&)
|
|
70
|
+
return self if @commands.empty?
|
|
71
|
+
|
|
72
|
+
lines = @commands.map { |command| "#{command.purpose}: #{yield(command)}" }
|
|
73
|
+
repaired([payload.fetch("repair"), *lines].reject(&:empty?).join("\n"), [])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# This refusal, when it names under did_you_mean the one mapped id an id it was given nearly matches, with its
|
|
77
|
+
# repair led by the command the block prints for that id; this tool never runs a command on the near miss
|
|
78
|
+
# itself (D56, #729). Otherwise this refusal as it is.
|
|
79
|
+
#: () { (String) -> String } -> Error
|
|
80
|
+
def rerun_with_near_miss(&)
|
|
81
|
+
mapped = payload["did_you_mean"] or return self
|
|
82
|
+
repaired("To run it with that id: #{yield(mapped)}\n#{payload.fetch("repair")}")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# This refusal with executable in place of each EXECUTABLE its repair names.
|
|
86
|
+
#: (String) -> Error
|
|
87
|
+
def naming(executable)
|
|
88
|
+
repaired(payload.fetch("repair").gsub(EXECUTABLE, executable))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
# This refusal with repair in place of its own, keeping everything else.
|
|
94
|
+
#: (String, ?Array[RepairCommand]) -> Error
|
|
95
|
+
def repaired(repair, commands = @commands)
|
|
96
|
+
copy = Error.new(payload.fetch("code"), payload.fetch("message"), repair).including(payload.except("repair"))
|
|
97
|
+
.ending_with(commands)
|
|
98
|
+
copy.set_backtrace(backtrace || [])
|
|
99
|
+
copy
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|