principles 0.0.11 → 0.1.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 +4 -4
- data/CHANGELOG.md +38 -0
- data/lib/principles/controllers/answer.rb +2 -2
- data/lib/principles/controllers/assessment.rb +19 -3
- data/lib/principles/controllers/audit.rb +14 -4
- data/lib/principles/controllers/full_audit_request.rb +16 -10
- data/lib/principles/controllers/guidance_search_paths.rb +1 -1
- data/lib/principles/controllers/member_addition.rb +4 -1
- data/lib/principles/controllers/member_problems_report.rb +7 -6
- data/lib/principles/controllers/open_finding_decisions.rb +66 -0
- data/lib/principles/controllers/running_tool.rb +22 -5
- data/lib/principles/controllers/survey.rb +3 -2
- data/lib/principles/data/candidate_files_found.rb +6 -4
- data/lib/principles/data/command-steps.json +17 -17
- data/lib/principles/data/committed_texts.rb +58 -0
- data/lib/principles/data/first_parent_log.rb +50 -10
- data/lib/principles/data/json_text.rb +5 -1
- data/lib/principles/data/parser_message.rb +61 -0
- data/lib/principles/data/project_files.rb +4 -2
- data/lib/principles/data/repository.rb +29 -37
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/audit-record.schema.json +15 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/{repointing-answer.schema.json → deciding-answer.schema.json} +12 -6
- data/lib/principles/data/working_tree_changes.rb +62 -0
- data/lib/principles/invocation_options.rb +1 -1
- data/lib/principles/launch.rb +5 -3
- data/lib/principles/models/after_commit_input.rb +1 -0
- data/lib/principles/models/assessment_basis.rb +1 -1
- data/lib/principles/models/audit.rb +23 -3
- data/lib/principles/models/audit_entry_protecting_map.rb +1 -0
- data/lib/principles/models/audit_record.rb +5 -14
- data/lib/principles/models/audit_records.rb +1 -1
- data/lib/principles/models/audited_member_lines.rb +1 -1
- data/lib/principles/models/candidate_files.rb +1 -1
- data/lib/principles/models/candidate_inventory.rb +19 -9
- data/lib/principles/models/candidate_outline.rb +1 -1
- data/lib/principles/models/changed_regions.rb +1 -1
- data/lib/principles/models/command_steps.rb +1 -2
- data/lib/principles/models/correction_basis.rb +1 -1
- data/lib/principles/models/declared_map_changes.rb +1 -2
- data/lib/principles/models/finding_decision.rb +84 -0
- data/lib/principles/models/finding_write_ups.rb +2 -1
- data/lib/principles/models/first_full_audit.rb +1 -0
- data/lib/principles/models/frontmatter_fields.rb +1 -1
- data/lib/principles/models/guidance_search_path.rb +1 -1
- data/lib/principles/models/guidance_search_paths.rb +5 -1
- data/lib/principles/models/head_moves.rb +1 -0
- data/lib/principles/models/ignored_candidates.rb +1 -1
- data/lib/principles/models/instruction_named.rb +1 -1
- data/lib/principles/models/json_path_query.rb +1 -1
- data/lib/principles/models/json_path_selectors.rb +1 -1
- data/lib/principles/models/json_path_string.rb +1 -1
- data/lib/principles/models/last_completed_revision.rb +1 -1
- data/lib/principles/models/line_diff.rb +1 -1
- data/lib/principles/models/line_span.rb +1 -1
- data/lib/principles/models/loading_scope.rb +1 -0
- data/lib/principles/models/located_text.rb +1 -1
- data/lib/principles/models/map_change.rb +66 -0
- data/lib/principles/models/mapped_principles.rb +4 -0
- data/lib/principles/models/markdown_file.rb +22 -1
- data/lib/principles/models/member.rb +1 -1
- data/lib/principles/models/member_elsewhere.rb +1 -1
- data/lib/principles/models/member_file.rb +6 -1
- data/lib/principles/models/member_hashes_as_written.rb +2 -2
- data/lib/principles/models/member_history.rb +1 -1
- data/lib/principles/models/member_lines.rb +1 -1
- data/lib/principles/models/member_loading_scopes.rb +1 -0
- data/lib/principles/models/member_mapping_run.rb +4 -4
- data/lib/principles/models/member_moves.rb +1 -2
- data/lib/principles/models/member_problems.rb +5 -1
- data/lib/principles/models/member_region.rb +1 -1
- data/lib/principles/models/members_elsewhere.rb +1 -1
- data/lib/principles/models/members_in_consecutive_sections.rb +1 -0
- data/lib/principles/models/members_sharing_lines.rb +1 -1
- data/lib/principles/models/misspelt_member_id.rb +1 -1
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/open_findings_decision.rb +124 -0
- data/lib/principles/models/open_findings_elsewhere.rb +1 -1
- data/lib/principles/models/other_templates_placeholders.rb +1 -0
- data/lib/principles/models/outline_budget.rb +1 -1
- data/lib/principles/models/outline_group.rb +1 -1
- data/lib/principles/models/outline_section.rb +1 -1
- data/lib/principles/models/part_named.rb +1 -1
- data/lib/principles/models/plain_text_file.rb +1 -1
- data/lib/principles/models/principle_history.rb +3 -3
- data/lib/principles/models/principle_members.rb +1 -1
- data/lib/principles/models/problem_report.rb +26 -3
- data/lib/principles/models/project.rb +8 -3
- data/lib/principles/models/project_at_commit.rb +9 -19
- data/lib/principles/models/project_history.rb +8 -0
- data/lib/principles/models/prose_line.rb +36 -0
- data/lib/principles/models/record_format.rb +17 -4
- data/lib/principles/models/recorded_finding.rb +47 -7
- data/lib/principles/models/recorded_findings.rb +7 -7
- data/lib/principles/models/recorded_hashes.rb +1 -1
- data/lib/principles/models/recorded_members.rb +6 -8
- data/lib/principles/models/report_hooks.rb +1 -0
- data/lib/principles/models/request_id.rb +2 -2
- data/lib/principles/models/sent_answer.rb +1 -0
- data/lib/principles/models/session_start_input.rb +1 -0
- data/lib/principles/models/stale_request.rb +22 -8
- data/lib/principles/models/submitted_answer.rb +1 -1
- data/lib/principles/models/survey_search_paths.rb +13 -5
- data/lib/principles/models/text_within.rb +1 -1
- data/lib/principles/models/unchecked_members.rb +1 -0
- data/lib/principles/models/uncommitted_outside_the_map.rb +1 -1
- data/lib/principles/models/unknown_principle.rb +1 -0
- data/lib/principles/models/write_up_opening.rb +5 -31
- data/lib/principles/models/write_up_pointer.rb +2 -1
- data/lib/principles/start_audit_options.rb +25 -18
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +12 -9
- data/lib/principles/views/added_member.rb +10 -1
- data/lib/principles/views/answer_in_a_file.rb +16 -4
- data/lib/principles/views/assessment_answer_guide.rb +59 -0
- data/lib/principles/views/assessment_request.rb +2 -26
- data/lib/principles/views/audit_result.rb +15 -6
- data/lib/principles/views/candidate_files_result.rb +24 -13
- data/lib/principles/views/context_parts.rb +40 -9
- data/lib/principles/views/correction_request.rb +8 -5
- data/lib/principles/views/first_audit_brief.rb +2 -1
- data/lib/principles/views/guidance_search_paths_result.rb +13 -6
- data/lib/principles/views/invocation.rb +14 -4
- data/lib/principles/views/json_on_one_line.rb +18 -0
- data/lib/principles/views/open_findings_decision_result.rb +60 -0
- data/lib/principles/views/problem_facts.rb +46 -0
- data/lib/principles/views/problem_result.rb +42 -31
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +1 -1
- data/lib/principles/views/prompts/assess-every-member/read-the-request-in-parts.md +2 -1
- data/lib/principles/views/prompts/decide-open-findings/give-only-what-changed-of-each.md +6 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/confirm-each-deferral-written-up-nowhere.md +2 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-about-other-guidance-search-paths.md +1 -1
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-in-this-order-after-the-table.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner.md +1 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-which-principle-to-map.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-an-existing-or-new-principle.md +3 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/choose-one-principle.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/compare-with-mapped-principles.md +2 -2
- data/lib/principles/views/prompts/find-a-principle-to-map/group-rules-into-principles.md +3 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/where-a-survey-with-only-looks.md +4 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-guidance-search-path.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +1 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +12 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +11 -12
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +2 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +8 -8
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- metadata +20 -9
- data/lib/principles/controllers/repoint.rb +0 -67
- data/lib/principles/models/repoint.rb +0 -125
- data/lib/principles/models/write_up_repoint.rb +0 -38
- data/lib/principles/views/prompts/find-a-principle-to-map/ask-the-owner-after-the-table.md +0 -1
- data/lib/principles/views/prompts/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +0 -10
- data/lib/principles/views/repoint_result.rb +0 -80
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require_relative "open_finding"
|
|
5
5
|
require_relative "recorded_finding"
|
|
6
6
|
require_relative "recorded_members"
|
|
7
|
-
require_relative "
|
|
7
|
+
require_relative "finding_decision"
|
|
8
8
|
|
|
9
9
|
module Principles
|
|
10
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -38,13 +38,13 @@ module Principles
|
|
|
38
38
|
#: () -> Array[String]
|
|
39
39
|
def fixed_ids = @findings.select(&:fixed?).map(&:id)
|
|
40
40
|
|
|
41
|
-
# These findings with each
|
|
42
|
-
#: (Array[
|
|
43
|
-
def
|
|
44
|
-
by_finding =
|
|
41
|
+
# These findings with each decision applied to the one it names, dated at.
|
|
42
|
+
#: (Array[FindingDecision], at: String) -> RecordedFindings
|
|
43
|
+
def decided(decisions, at:)
|
|
44
|
+
by_finding = decisions.to_h { |decision| [decision.finding_id, decision] }
|
|
45
45
|
moved = @findings.map do |finding|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
decision = by_finding[finding.id]
|
|
47
|
+
decision ? decision.applied_to(finding, at: at) : finding
|
|
48
48
|
end
|
|
49
49
|
RecordedFindings.new(moved.map(&:to_h), principle_id: @principle_id, audited_at: @audited_at,
|
|
50
50
|
members: @members)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
|
-
# The domain logic,
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
6
|
module Models
|
|
7
7
|
# The member hashes a principle's audit record holds, by key, which its members now are compared with, and
|
|
8
8
|
# whether a later copy wrote that record, so its audits wait on an upgrade and the comparison is read-only.
|
|
@@ -43,14 +43,12 @@ module Principles
|
|
|
43
43
|
#: (String, String) -> String
|
|
44
44
|
def freshness(key, sha) = hashes.freshness(key, sha)
|
|
45
45
|
|
|
46
|
-
# The hashes the record assessed, which a member now is compared
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def hashes_by_key
|
|
53
|
-
@entries.to_h { |id, entry| [RecordedEntry.new(id, entry).key, entry.fetch("sha256")] }
|
|
46
|
+
# The hashes the record assessed, each by the key of the member it belongs to, which a member now is compared
|
|
47
|
+
# with; waiting when a later copy wrote the record.
|
|
48
|
+
#: (?waiting: bool) -> RecordedHashes
|
|
49
|
+
def hashes(waiting: false)
|
|
50
|
+
RecordedHashes.new(@entries.to_h { |id, entry| [RecordedEntry.new(id, entry).key, entry.fetch("sha256")] },
|
|
51
|
+
waiting:)
|
|
54
52
|
end
|
|
55
53
|
|
|
56
54
|
# The hash the record assessed for the member known by key, or nil when it assessed no such member.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
5
6
|
module Models
|
|
6
7
|
# The hooks that run this tool's two hook commands for a project without the principles plugin, on each host: the
|
|
7
8
|
# file the project's own hooks go in, and the command each event runs. Claude Code runs a hook after a failed shell
|
|
@@ -5,14 +5,14 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "json_digest"
|
|
6
6
|
|
|
7
7
|
module Principles
|
|
8
|
-
# The domain logic,
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
9
|
module Models
|
|
10
10
|
# The id of a judgement request: the principle, the phase and a digest of everything the request
|
|
11
11
|
# depends on, as ID.PHASE.DIGEST. This tool stores no request, so an answer is matched by recomputing
|
|
12
12
|
# the digest from the project as it is now: a different digest means something the request depended
|
|
13
13
|
# on has changed. The digest has no secret, so it catches mistakes, not forgery.
|
|
14
14
|
class RequestId
|
|
15
|
-
PHASES = %w[assessment correction acknowledgement acknowledgements
|
|
15
|
+
PHASES = %w[assessment correction acknowledgement acknowledgements deciding].freeze
|
|
16
16
|
FORMAT = /\A(?<principle>[a-z0-9]+(?:-[a-z0-9]+)*)\.(?<phase>[a-z]+)\.(?<digest>[0-9a-f]{12})\z/
|
|
17
17
|
|
|
18
18
|
#: String
|
|
@@ -8,6 +8,7 @@ require_relative "refusal_before_shape"
|
|
|
8
8
|
require_relative "request_id"
|
|
9
9
|
|
|
10
10
|
module Principles
|
|
11
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
12
|
module Models
|
|
12
13
|
# An answer an agent sent for a phase's request, read from its source, whose head, the fields every answer hands
|
|
13
14
|
# back as its request printed them, is checked on arrival: they say whether it still answers that request.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require "json"
|
|
5
5
|
|
|
6
6
|
module Principles
|
|
7
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
7
8
|
module Models
|
|
8
9
|
# The JSON a SessionStart hook is given on stdin, as far as report-at-session-start reads it: the source the
|
|
9
10
|
# session started from. Input that is not JSON, or names no source a host sends, reads as a startup, since a
|
|
@@ -4,21 +4,25 @@
|
|
|
4
4
|
require_relative "../error"
|
|
5
5
|
require_relative "../prose_list"
|
|
6
6
|
require_relative "request_id"
|
|
7
|
+
require_relative "map_change"
|
|
7
8
|
|
|
8
9
|
module Principles
|
|
9
10
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
10
11
|
module Models
|
|
11
12
|
# The refusal of an answer to one principle's audit request that no longer matches the project: its cause, the
|
|
12
|
-
# members changed since the request's base commit when any are known, or
|
|
13
|
-
# and its repair: to answer the audit's open correction when members alone
|
|
13
|
+
# members changed since the request's base commit when any are known, or how its map changed since then, or else
|
|
14
|
+
# every input the request depends on, and its repair: to answer the audit's open correction when members alone
|
|
15
|
+
# changed, or else to start again.
|
|
14
16
|
class StaleRequest
|
|
15
17
|
# principle_id is the principle audited; changed names the members whose text differs from the base commit's;
|
|
16
|
-
# correction_open says whether the principle's record is open, its correction asked for and not yet answered
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
# correction_open says whether the principle's record is open, its correction asked for and not yet answered;
|
|
19
|
+
# map_change is how the map differs from the one the request was printed from, when that is known.
|
|
20
|
+
#: (String, ?Array[String], ?correction_open: bool, ?map_change: MapChange?) -> void
|
|
21
|
+
def initialize(principle_id, changed = [], correction_open: false, map_change: nil)
|
|
19
22
|
@principle_id = principle_id
|
|
20
23
|
@changed = changed
|
|
21
24
|
@correction_open = correction_open
|
|
25
|
+
@map_change = map_change
|
|
22
26
|
freeze
|
|
23
27
|
end
|
|
24
28
|
|
|
@@ -29,13 +33,14 @@ module Principles
|
|
|
29
33
|
|
|
30
34
|
private
|
|
31
35
|
|
|
32
|
-
# The members changed since the base commit, which a request is printed only once they are committed;
|
|
33
|
-
# every input that may have changed.
|
|
36
|
+
# The members changed since the base commit, which a request is printed only once they are committed; or else
|
|
37
|
+
# how its map changed since then; otherwise every input that may have changed.
|
|
34
38
|
#: () -> String
|
|
35
39
|
def cause
|
|
36
40
|
unless @changed.empty?
|
|
37
41
|
return "#{ProseList.new(@changed)} #{@changed.one? ? "has" : "have"} changed since its base commit"
|
|
38
42
|
end
|
|
43
|
+
return "its map has changed since its base commit: #{@map_change}" if @map_change
|
|
39
44
|
|
|
40
45
|
"its map, a member, the commit it was based on, or what says when a listed member loads and how big it is " \
|
|
41
46
|
"(project settings, frontmatter or a listed file), has changed since it was printed, or another release " \
|
|
@@ -44,16 +49,25 @@ module Principles
|
|
|
44
49
|
|
|
45
50
|
# To start the audit again; but while its correction is open and only members changed, that correction stays
|
|
46
51
|
# answerable, since it is checked against the members at the base commit, so the repair names the command that
|
|
47
|
-
# prints its answer again from the open record.
|
|
52
|
+
# prints its answer again from the open record; and after a map change alone, the answer stays worth keeping.
|
|
48
53
|
#: () -> String
|
|
49
54
|
def repair
|
|
50
55
|
start = "#{Error::EXECUTABLE} start-audit #{@principle_id}"
|
|
56
|
+
return carried_over(start, @map_change) if @map_change && @changed.empty?
|
|
51
57
|
return "Start the audit again and answer the new request: #{start}" unless @correction_open && @changed.any?
|
|
52
58
|
|
|
53
59
|
"This audit's correction is still open, and fixing members leaves it current: answer it rather than start " \
|
|
54
60
|
"again, saving its answer from this command's output, filling only its dispositions, and submitting it: " \
|
|
55
61
|
"#{Error::EXECUTABLE} show-open-correction #{@principle_id}"
|
|
56
62
|
end
|
|
63
|
+
|
|
64
|
+
# To carry the answer to a new request, judging again what map_change touched, or to undo map_change.
|
|
65
|
+
#: (String, MapChange) -> String
|
|
66
|
+
def carried_over(start, map_change)
|
|
67
|
+
"Keep this answer. To carry it to a new request, copy that request's request_id and basis into it, judge " \
|
|
68
|
+
"#{map_change.to_judge_again}, and submit it; or change the map back as it was at the base commit, " \
|
|
69
|
+
"commit it, and submit this answer unchanged.\nStart the new request: #{start}"
|
|
70
|
+
end
|
|
57
71
|
end
|
|
58
72
|
end
|
|
59
73
|
end
|
|
@@ -5,7 +5,7 @@ require_relative "prior_findings"
|
|
|
5
5
|
require_relative "request_id"
|
|
6
6
|
|
|
7
7
|
module Principles
|
|
8
|
-
# The domain logic,
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
9
|
module Models
|
|
10
10
|
# An answer submitted to the request request_id names, its shape checked, with the prior findings a full
|
|
11
11
|
# audit's request listed, which checking its head found, or nil for any other phase.
|
|
@@ -4,20 +4,28 @@
|
|
|
4
4
|
require_relative "guidance_search_path"
|
|
5
5
|
|
|
6
6
|
module Principles
|
|
7
|
-
# The domain logic,
|
|
7
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
8
|
module Models
|
|
9
9
|
# The project's recorded guidance search paths and this invocation's temporary selections, combined once.
|
|
10
|
+
# Selections made with only replace both the recorded paths and the places hosts load by convention, so a
|
|
11
|
+
# survey after a search path is added reads just the files it matches.
|
|
10
12
|
class SurveySearchPaths
|
|
11
13
|
#: Array[String]
|
|
12
14
|
attr_reader :globs
|
|
13
15
|
|
|
14
|
-
#: (recorded: Array[String], also: Array[String]) -> void
|
|
15
|
-
def initialize(recorded:, also:)
|
|
16
|
-
@
|
|
17
|
-
|
|
16
|
+
#: (recorded: Array[String], also: Array[String], ?only: Array[String]) -> void
|
|
17
|
+
def initialize(recorded:, also:, only: [])
|
|
18
|
+
@conventional = only.empty? #: bool
|
|
19
|
+
kept = @conventional ? recorded : [] #: Array[String]
|
|
20
|
+
@recorded = kept.map { |glob| GuidanceSearchPath.new(glob).glob }.uniq.freeze #: Array[String]
|
|
21
|
+
@globs = (@recorded | (also + only).map { |glob| GuidanceSearchPath.new(glob).glob }).freeze #: Array[String]
|
|
18
22
|
freeze
|
|
19
23
|
end
|
|
20
24
|
|
|
25
|
+
# Whether the survey lists the places hosts load by convention as well as these globs' matches.
|
|
26
|
+
#: () -> bool
|
|
27
|
+
def conventional? = @conventional
|
|
28
|
+
|
|
21
29
|
# Saved provenance is distinct from all match counts; omit it when the project records no search paths.
|
|
22
30
|
#: () -> Hash[String, untyped]
|
|
23
31
|
def recorded_listing = @recorded.empty? ? {} : { "recorded_guidance_search_paths" => @recorded }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
|
-
# The domain logic,
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
6
|
module Models
|
|
7
7
|
# A text cut to at most some characters, as a candidate file's outline prints its items, opening line and
|
|
8
8
|
# description: whole when it fits, else back to a sentence end or a whole word.
|
|
@@ -8,6 +8,7 @@ require_relative "principle_members"
|
|
|
8
8
|
require_relative "refusal_before_shape"
|
|
9
9
|
|
|
10
10
|
module Principles
|
|
11
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
12
|
module Models
|
|
12
13
|
# The members of a principle that name no check, whose assessments take no check_result. An answer is read for
|
|
13
14
|
# one before its shape is checked, since the shape would ask for the command such a check_result lacks, sending
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
|
-
# The domain logic,
|
|
5
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
6
|
module Models
|
|
7
7
|
# The project's files outside a principle's map that differ from the audit's base commit, as an assessment
|
|
8
8
|
# request names them. A project with many untracked files would put every one into each request, so
|
|
@@ -5,6 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "meta_principle"
|
|
6
6
|
|
|
7
7
|
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
8
9
|
module Models
|
|
9
10
|
# An absent principle id, whose repair creates an ordinary map or sets up the keeping principle.
|
|
10
11
|
class UnknownPrinciple
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require_relative "prose_line"
|
|
5
|
+
|
|
4
6
|
module Principles
|
|
5
7
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
8
|
module Models
|
|
@@ -9,41 +11,13 @@ module Principles
|
|
|
9
11
|
class WriteUpOpening
|
|
10
12
|
# The longest opening printed whole; a longer one is cut and marked truncated.
|
|
11
13
|
LIMIT = 200
|
|
12
|
-
# A line that starts a new block, a list item or a heading, rather than continuing the paragraph before it.
|
|
13
|
-
NEW_BLOCK = /\A(([-*+]|\d+[.)])\s|#)/
|
|
14
|
-
# What a heading line starts with, a block of its own line.
|
|
15
|
-
HEADING = "#"
|
|
16
14
|
# The end of a sentence: its mark and any closing quotes or brackets, before a space or the end.
|
|
17
15
|
SENTENCE_END = /[.!?]["')\]]*(?=\s|\z)/
|
|
18
16
|
|
|
19
|
-
# One line of the file, as the opening reads it.
|
|
20
|
-
class Line
|
|
21
|
-
#: (String) -> void
|
|
22
|
-
def initialize(text)
|
|
23
|
-
@text = text
|
|
24
|
-
freeze
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# The line without its indentation or line break.
|
|
28
|
-
#: () -> String
|
|
29
|
-
def text = @text.strip
|
|
30
|
-
|
|
31
|
-
#: () -> bool
|
|
32
|
-
def blank? = text.empty?
|
|
33
|
-
|
|
34
|
-
#: () -> bool
|
|
35
|
-
def heading? = text.start_with?(HEADING)
|
|
36
|
-
|
|
37
|
-
# Whether the line continues the paragraph before it: it is not blank and starts no new block. It keeps its
|
|
38
|
-
# line break, which NEW_BLOCK's \s may match, so a bare "-" line still starts a list item.
|
|
39
|
-
#: () -> bool
|
|
40
|
-
def continues? = !blank? && !@text.lstrip.match?(NEW_BLOCK)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
17
|
# lines are the file's lines; the region runs from index first up to, not including, index last.
|
|
44
18
|
#: (lines: Array[String], first: Integer, last: Integer) -> void
|
|
45
19
|
def initialize(lines:, first:, last:)
|
|
46
|
-
@lines = lines.map { |each|
|
|
20
|
+
@lines = lines.map { |each| ProseLine.new(each) } #: Array[ProseLine]
|
|
47
21
|
@first = first
|
|
48
22
|
@last = last
|
|
49
23
|
freeze
|
|
@@ -103,8 +77,8 @@ module Principles
|
|
|
103
77
|
def closed?(text) = text.count("(") <= text.count(")")
|
|
104
78
|
|
|
105
79
|
# The line at index, or a blank one past the file's end.
|
|
106
|
-
#: (Integer) ->
|
|
107
|
-
def line(index) = @lines[index] ||
|
|
80
|
+
#: (Integer) -> ProseLine
|
|
81
|
+
def line(index) = @lines[index] || ProseLine.new("")
|
|
108
82
|
end
|
|
109
83
|
end
|
|
110
84
|
end
|
|
@@ -25,7 +25,8 @@ module Principles
|
|
|
25
25
|
#: () -> bool
|
|
26
26
|
def starting_at? = !@locator.starting_at.nil?
|
|
27
27
|
|
|
28
|
-
# The same heading or starting_at in the file at path, as a
|
|
28
|
+
# The same heading or starting_at in the file at path, as a decision on open findings checks git's match for a
|
|
29
|
+
# missing file.
|
|
29
30
|
#: (String) -> WriteUpPointer
|
|
30
31
|
def in_file(path) = WriteUpPointer.new(to_h.merge("path" => path))
|
|
31
32
|
|
|
@@ -4,19 +4,21 @@
|
|
|
4
4
|
require_relative "invocation_options"
|
|
5
5
|
|
|
6
6
|
module Principles
|
|
7
|
-
# The options that choose which audit start-audit begins, --member
|
|
8
|
-
# it in, and what is wrong with them as given, which CommandLine refuses as a usage error.
|
|
7
|
+
# The options that choose which audit start-audit begins, --member or --open-findings, and the form
|
|
8
|
+
# --as prints it in, and what is wrong with them as given, which CommandLine refuses as a usage error.
|
|
9
9
|
class StartAuditOptions
|
|
10
10
|
# The part that prints the answer to fill bare, saved as it stands, so no other part may print beside it.
|
|
11
11
|
TEMPLATE_PART = "response_template" #: String
|
|
12
|
+
# Each option that starts an audit other than a full one, by its key among the options, and its flag.
|
|
13
|
+
AUDITS = { "member" => "--member",
|
|
14
|
+
"open_findings" => "--open-findings" }.freeze #: Hash[String, String]
|
|
12
15
|
|
|
13
16
|
# several_ids is whether start-audit was given more than one principle id.
|
|
14
17
|
#: (InvocationOptions, ?several_ids: bool) -> void
|
|
15
18
|
def initialize(options, several_ids: false)
|
|
16
19
|
@several_ids = several_ids
|
|
17
20
|
@members = options.value("member") || [] #: Array[String]
|
|
18
|
-
@
|
|
19
|
-
@write_ups = !options.value("write_ups").nil? #: bool
|
|
21
|
+
@audits = AUDITS.reject { |key, _| options.value(key).nil? }.values #: Array[String]
|
|
20
22
|
@form = options.value("as") #: String?
|
|
21
23
|
@instruction = !options.value("instruction").nil? #: bool
|
|
22
24
|
@parts = options.value("part") || [] #: Array[String]
|
|
@@ -27,17 +29,25 @@ module Principles
|
|
|
27
29
|
# What is wrong with the options as given, or nil when they fit.
|
|
28
30
|
#: () -> String?
|
|
29
31
|
def fault
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
several_ids_fault || member_fault || part_fault || instruction_fault || form_fault
|
|
32
|
+
audits_fault || several_ids_fault || member_fault || part_fault || instruction_fault || form_fault
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
|
+
# Two of the options that each start a different audit; nil when at most one is given.
|
|
38
|
+
#: () -> String?
|
|
39
|
+
def audits_fault
|
|
40
|
+
"#{@audits.first(2).join(" and ")} each start a different audit; give one" if @audits.size > 1
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Whether flag, one of AUDITS, was given.
|
|
44
|
+
#: (String) -> bool
|
|
45
|
+
def audit?(flag) = @audits.include?(flag)
|
|
46
|
+
|
|
37
47
|
# Several principle ids, which only an acknowledgement of members they each map spans; nil otherwise.
|
|
38
48
|
#: () -> String?
|
|
39
49
|
def several_ids_fault
|
|
40
|
-
return unless @several_ids &&
|
|
50
|
+
return unless @several_ids && !audit?("--member")
|
|
41
51
|
|
|
42
52
|
"several principle ids start one acknowledgement of the members they map, with --member; give one id for " \
|
|
43
53
|
"any other audit"
|
|
@@ -74,29 +84,26 @@ module Principles
|
|
|
74
84
|
"--instruction prints one field of a full audit's request, not of #{other}" if other
|
|
75
85
|
end
|
|
76
86
|
|
|
77
|
-
# What --as, --member or --
|
|
78
|
-
# read from; nil when none is given.
|
|
87
|
+
# What --as, --member or --open-findings prints instead of a full audit's request, which --part and --instruction
|
|
88
|
+
# each read from; nil when none is given.
|
|
79
89
|
#: () -> String?
|
|
80
90
|
def other_output
|
|
81
91
|
@form ? "the answer --as template prints" : other_audit
|
|
82
92
|
end
|
|
83
93
|
|
|
84
|
-
# What --member or --
|
|
94
|
+
# What --member or --open-findings starts instead of a full audit; nil when neither is given.
|
|
85
95
|
#: () -> String?
|
|
86
96
|
def other_audit
|
|
87
|
-
if
|
|
88
|
-
elsif
|
|
97
|
+
if audit?("--member") then "the one-member audit --member starts"
|
|
98
|
+
elsif audit?("--open-findings") then "the decision --open-findings starts"
|
|
89
99
|
end
|
|
90
100
|
end
|
|
91
101
|
|
|
92
|
-
# --as template prints
|
|
93
|
-
# built so far; nil when it fits.
|
|
102
|
+
# --as template prints an audit's answer alone, the one form built so far; nil when it fits.
|
|
94
103
|
#: () -> String?
|
|
95
104
|
def form_fault
|
|
96
105
|
form = @form or return
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"--as template prints a full or one-member audit's answer, not one --write-ups starts" if @write_ups
|
|
106
|
+
"--as takes template, the answer alone, not #{form}" unless form == "template"
|
|
100
107
|
end
|
|
101
108
|
end
|
|
102
109
|
end
|
data/lib/principles/version.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The next production release, as major.minor.patch. A production build is versioned with this alone.
|
|
6
|
-
RELEASE = "0.
|
|
6
|
+
RELEASE = "0.1.1"
|
|
7
7
|
# The version a built gem prints. `rake build[production]` stamps RELEASE here, in the copy of lib/ it
|
|
8
8
|
# packages, and `rake build[development]` stamps RELEASE.g<short sha>. A checkout leaves it nil, and
|
|
9
9
|
# Data::RunningVersion reads the commit this tool runs from instead.
|
|
10
|
-
BUILT_VERSION = "0.
|
|
10
|
+
BUILT_VERSION = "0.1.1" #: String?
|
|
11
11
|
end
|
|
@@ -23,12 +23,13 @@ module Principles
|
|
|
23
23
|
# asked is what the request asks of its member: under :change its change since its baseline; under :context
|
|
24
24
|
# what the request's context shows beside it, such as the record's findings on the member; and under
|
|
25
25
|
# :placeholders the text the template prints in each field the agent writes. What the agent judges is under
|
|
26
|
-
# context, the question
|
|
26
|
+
# context, the question first, so an agent reading the request's head finds what it is asked before the text.
|
|
27
27
|
#: (request_id: String, principle_id: String, asked: Hash[Symbol, untyped]) -> Hash[String, untyped]
|
|
28
28
|
def request(request_id:, principle_id:, asked:)
|
|
29
29
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgement",
|
|
30
|
-
"context" => { "principle_id" => principle_id,
|
|
31
|
-
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning")
|
|
30
|
+
"context" => { "principle_id" => principle_id,
|
|
31
|
+
"question" => Prompts.text("acknowledge-a-change/say-whether-the-change-keeps-the-meaning"),
|
|
32
|
+
**asked.fetch(:change).to_h, **asked.fetch(:context) },
|
|
32
33
|
"response_template" => answer_to_fill(request_id:, asked:),
|
|
33
34
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
34
35
|
"next_action" => to_fill([principle_id], [asked.fetch(:change).member_id], request_id:) }
|
|
@@ -47,13 +48,14 @@ module Principles
|
|
|
47
48
|
|
|
48
49
|
# The request for several members' acknowledgements in one answer: each of members holds a member's
|
|
49
50
|
# change, the context its own request shows beside it and the placeholders its template prints, as one member's
|
|
50
|
-
# request holds them, under context.members and the template's members in the order the agent named them.
|
|
51
|
+
# request holds them, under context.members and the template's members in the order the agent named them. The
|
|
52
|
+
# question leads the context, so an agent reading the request's head finds what it is asked before the members.
|
|
51
53
|
#: (request_id: String, principle_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
52
54
|
def several_request(request_id:, principle_id:, members:)
|
|
53
55
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
54
56
|
"context" => { "principle_id" => principle_id,
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
+
"question" => Prompts.text("acknowledge-a-change/say-whether-each-change-keeps-its-meaning"),
|
|
58
|
+
"members" => shown(members) },
|
|
57
59
|
"response_template" => several_to_fill(request_id:, members:),
|
|
58
60
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
59
61
|
"next_action" => to_fill([principle_id], members.map { it.fetch(:change).member_id }, request_id:) }
|
|
@@ -70,13 +72,14 @@ module Principles
|
|
|
70
72
|
# The request for the members several principles map in one answer: under context.principles, each
|
|
71
73
|
# principle's members as its own request for several shows them, and in the template one entry per member,
|
|
72
74
|
# judged once for every principle that maps it. keeping_deferred names each principle whose members keep a
|
|
73
|
-
# deferred finding, which the request says only a full audit resolves.
|
|
75
|
+
# deferred finding, which the request says only a full audit resolves. The question leads the context, as in
|
|
76
|
+
# one principle's requests.
|
|
74
77
|
#: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]],
|
|
75
78
|
#| ?keeping_deferred: Array[String]) -> Hash[String, untyped]
|
|
76
79
|
def across_request(request_id:, principles:, keeping_deferred: [])
|
|
77
80
|
{ "status" => "agent_judgement_required", "request_id" => request_id, "phase" => "acknowledgements",
|
|
78
|
-
"context" => { "principles" => shown_once(principles),
|
|
79
|
-
**deferred_findings_kept(keeping_deferred)
|
|
81
|
+
"context" => { "question" => across_question, "principles" => shown_once(principles),
|
|
82
|
+
**deferred_findings_kept(keeping_deferred) },
|
|
80
83
|
"response_template" => across_to_fill(request_id:, principles:),
|
|
81
84
|
"answer_with" => @invocation.submit_answer(request_id),
|
|
82
85
|
"next_action" => to_fill(principles.keys.uniq.sort, across_member_ids(principles), request_id:) }
|
|
@@ -34,7 +34,16 @@ module Principles
|
|
|
34
34
|
#: () -> String
|
|
35
35
|
def span
|
|
36
36
|
"#{id} spans lines #{@added.fetch("first_line")} to #{@added.fetch("last_line")}; " \
|
|
37
|
-
"if that is not the passage you meant, move it with move-member. "
|
|
37
|
+
"if that is not the passage you meant, move it with move-member. #{runs_on}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# What the agent judges when the paragraph or list item a one-line passage starts runs on past it; it ends with
|
|
41
|
+
# a space, or is empty.
|
|
42
|
+
#: () -> String
|
|
43
|
+
def runs_on
|
|
44
|
+
line = @added["continues_to_line"] or return ""
|
|
45
|
+
"Its paragraph or list item continues to line #{line}; if the member is all of it, move it with " \
|
|
46
|
+
"--ending-at quoting the words that end it. "
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
end
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
require_relative "context_parts"
|
|
5
5
|
require_relative "invocation"
|
|
6
6
|
require_relative "prompts"
|
|
7
|
+
require_relative "shell_word"
|
|
7
8
|
|
|
8
9
|
module Principles
|
|
9
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
10
11
|
module Views
|
|
11
|
-
# How to fill an answer this tool prints bare: save it to a file outside the project,
|
|
12
|
-
# agent's own file-edit tool, and submit that file, with the three characters JSON escapes.
|
|
13
|
-
# in a shell heredoc took a script, since prose full of quotes needed escaping for the shell
|
|
12
|
+
# How to fill an answer this tool prints bare: save it to a file outside the project, named in full, fill it
|
|
13
|
+
# there with the agent's own file-edit tool, and submit that file, with the three characters JSON escapes.
|
|
14
|
+
# Filling a template in a shell heredoc took a script, since prose full of quotes needed escaping for the shell
|
|
15
|
+
# and for JSON.
|
|
14
16
|
class AnswerInAFile
|
|
15
17
|
#: (Invocation) -> void
|
|
16
18
|
def initialize(invocation)
|
|
@@ -34,6 +36,14 @@ module Principles
|
|
|
34
36
|
request_id:)
|
|
35
37
|
end
|
|
36
38
|
|
|
39
|
+
# The line for a decision on principle_id's open findings, whose answer start-audit --open-findings --as template
|
|
40
|
+
# prints bare.
|
|
41
|
+
#: (String, request_id: String) -> String
|
|
42
|
+
def open_findings(principle_id, request_id:)
|
|
43
|
+
line(@invocation.in_project("start-audit", principle_id, options: %w[--open-findings --as template]),
|
|
44
|
+
request_id:)
|
|
45
|
+
end
|
|
46
|
+
|
|
37
47
|
# The line for an open correction, whose answer show-open-correction prints bare, of which only the
|
|
38
48
|
# dispositions are the agent's to fill.
|
|
39
49
|
#: (String, request_id: String) -> String
|
|
@@ -45,8 +55,10 @@ module Principles
|
|
|
45
55
|
# the agent fills.
|
|
46
56
|
#: (String, request_id: String, ?what: String) -> String
|
|
47
57
|
def line(save, request_id:, what: "it")
|
|
58
|
+
file = @invocation.answer_file(request_id)
|
|
48
59
|
Prompts.text("answer-any-judgement-request/fill-the-answer-in-a-file",
|
|
49
|
-
save
|
|
60
|
+
save: "#{save} > #{ShellWord.new(file)}", what:,
|
|
61
|
+
answer_with: @invocation.submit_answer(request_id, file:))
|
|
50
62
|
end
|
|
51
63
|
end
|
|
52
64
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "assessed_members"
|
|
5
|
+
require_relative "instruction"
|
|
6
|
+
require_relative "json_on_one_line"
|
|
7
|
+
require_relative "prompts"
|
|
8
|
+
|
|
9
|
+
module Principles
|
|
10
|
+
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
|
+
module Views
|
|
12
|
+
# The guide to a full audit's answer shapes, printed under answer_guide with the entries whose case the request's
|
|
13
|
+
# members hold.
|
|
14
|
+
class AssessmentAnswerGuide
|
|
15
|
+
#: (AssessedMembers) -> void
|
|
16
|
+
def initialize(members)
|
|
17
|
+
@members = members
|
|
18
|
+
freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The answer guide, showing check_result's fields only when a member has a check, so an audit
|
|
22
|
+
# with no checks costs no more context than before, and delivery's shapes only when a member is judged
|
|
23
|
+
# afresh, since a carried member's marker gives none. check_result's limits say how to review a check
|
|
24
|
+
# before running it only when a check is new or changed, as that check's own template says too.
|
|
25
|
+
#: () -> GuideInstruction
|
|
26
|
+
def instruction
|
|
27
|
+
guide = with_examples_on_lines(Prompts.data("assess-every-member/answer-guide"))
|
|
28
|
+
narrowed = @members.check_to_review? ? {} : guide.slice("check_result")
|
|
29
|
+
GuideInstruction.new("answer_guide", guide.merge("check_result" => reviewed(guide.fetch("check_result"))),
|
|
30
|
+
narrowed:) do |entry|
|
|
31
|
+
case entry
|
|
32
|
+
when "check_result" then @members.checked?
|
|
33
|
+
when "member_delivery" then @members.judged_afresh?
|
|
34
|
+
else true
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
# guide with each entry's examples printing compact, a line each, since the agent copies each one whole.
|
|
42
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
43
|
+
def with_examples_on_lines(guide)
|
|
44
|
+
guide.transform_values do |entry|
|
|
45
|
+
next entry unless entry.is_a?(Hash) && entry.key?("examples")
|
|
46
|
+
|
|
47
|
+
entry.merge("examples" => entry.fetch("examples").transform_values { JsonOnOneLine[it] })
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# check_result's guide entry whole, its limits ending with how to review a new or changed check before running it.
|
|
52
|
+
#: (Hash[String, untyped]) -> Hash[String, untyped]
|
|
53
|
+
def reviewed(check_result)
|
|
54
|
+
review = Prompts.text("assess-every-member/review-a-new-or-changed-check-before-running-it")
|
|
55
|
+
check_result.merge("limits" => "#{check_result.fetch("limits")} #{review}")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|