principles 0.0.4 → 0.0.5
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/cli.rb +3 -1
- data/lib/principles/command_line.rb +35 -7
- data/lib/principles/command_routes.rb +4 -3
- data/lib/principles/controllers/acknowledgement.rb +80 -14
- data/lib/principles/controllers/answer.rb +42 -75
- data/lib/principles/controllers/answer_phase.rb +54 -0
- data/lib/principles/controllers/assessment.rb +33 -9
- data/lib/principles/controllers/audit.rb +17 -6
- data/lib/principles/controllers/audit_completion.rb +6 -4
- data/lib/principles/controllers/command.rb +3 -2
- data/lib/principles/controllers/correction.rb +19 -9
- data/lib/principles/controllers/full_audit_request.rb +10 -0
- data/lib/principles/controllers/inventory.rb +25 -20
- data/lib/principles/controllers/member_problems_report.rb +11 -4
- data/lib/principles/controllers/members_a_commit_changed.rb +2 -1
- data/lib/principles/controllers/members_to_assess.rb +20 -12
- data/lib/principles/controllers/repoint.rb +18 -22
- data/lib/principles/data/bounded_file.rb +9 -4
- data/lib/principles/data/command-steps.json +9 -9
- data/lib/principles/data/project_files.rb +11 -8
- data/lib/principles/data/schema_check.rb +16 -6
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +17 -3
- data/lib/principles/data/schemas/answer-guide.schema.json +5 -10
- 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/invocation_options.rb +1 -1
- data/lib/principles/models/acknowledgement.rb +73 -84
- 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_record.rb +9 -17
- data/lib/principles/models/audit_records.rb +19 -16
- data/lib/principles/models/candidate_files.rb +30 -7
- data/lib/principles/models/candidate_inventory.rb +23 -6
- data/lib/principles/models/candidate_listing.rb +12 -3
- data/lib/principles/models/candidate_outline.rb +195 -0
- data/lib/principles/models/carried_member.rb +42 -0
- data/lib/principles/models/check_since_last_audit.rb +16 -3
- data/lib/principles/models/command_steps.rb +17 -1
- data/lib/principles/models/declared_map_changes.rb +5 -4
- data/lib/principles/models/frontmatter_fields.rb +9 -8
- data/lib/principles/models/instruction_named.rb +35 -0
- data/lib/principles/models/left_as_printed.rb +39 -0
- data/lib/principles/models/member_assessments.rb +9 -31
- data/lib/principles/models/member_file.rb +35 -11
- data/lib/principles/models/member_hashes_as_written.rb +10 -6
- data/lib/principles/models/member_lines.rb +63 -15
- data/lib/principles/models/member_problems.rb +24 -18
- data/lib/principles/models/member_repair_moves.rb +54 -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 +127 -0
- data/lib/principles/models/outline_group.rb +31 -0
- data/lib/principles/models/outline_section.rb +56 -0
- data/lib/principles/models/principle_members.rb +11 -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/project.rb +10 -19
- data/lib/principles/models/quoted_change.rb +137 -0
- data/lib/principles/models/record_format.rb +6 -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 +3 -13
- data/lib/principles/models/sent_answer.rb +51 -0
- data/lib/principles/models/shape_problems_beside.rb +40 -0
- data/lib/principles/models/submitted_answer.rb +34 -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/write_up_opening.rb +21 -4
- 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 +15 -7
- data/lib/principles/views/assessed_members.rb +43 -10
- data/lib/principles/views/assessment_request.rb +89 -30
- data/lib/principles/views/audit_result.rb +19 -2
- data/lib/principles/views/candidate_files_result.rb +41 -19
- data/lib/principles/views/check_notes.rb +44 -0
- data/lib/principles/views/check_result_template.rb +14 -23
- data/lib/principles/views/instruction.rb +74 -0
- data/lib/principles/views/json_with_entries_on_lines.rb +51 -0
- data/lib/principles/views/loads_to_check_result.rb +2 -2
- data/lib/principles/views/map_result.rb +2 -2
- data/lib/principles/views/member_change_since_baseline.rb +22 -5
- data/lib/principles/views/member_repairs.rb +21 -52
- data/lib/principles/views/members_a_commit_changed.rb +16 -6
- data/lib/principles/views/one_member_check_result_template.rb +43 -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 +20 -28
- data/lib/principles/views/prior_findings_result.rb +23 -15
- 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 +5 -10
- 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/fix-or-record-each-finding.md +4 -3
- 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-one-principle.md +9 -5
- 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/learn-what-a-command-does/list-candidate-files.md +21 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +4 -4
- 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/show-answer-check.md +1 -1
- 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 +3 -3
- 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 +39 -5
- 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,32 +2,77 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require_relative "../error"
|
|
5
|
+
require_relative "acknowledgement"
|
|
6
|
+
require_relative "assessment_answer"
|
|
7
|
+
require_relative "disposition"
|
|
8
|
+
require_relative "loading_decision"
|
|
9
|
+
require_relative "member_assessments"
|
|
10
|
+
require_relative "prior_decision_fields"
|
|
11
|
+
require_relative "recent_decision"
|
|
12
|
+
require_relative "refusal_before_shape"
|
|
13
|
+
require_relative "reported_check"
|
|
14
|
+
require_relative "shape_problems_beside"
|
|
5
15
|
|
|
6
16
|
module Principles
|
|
7
17
|
module Models
|
|
8
18
|
# The text in an answer that ends as this tool's placeholders end, "Leave as printed ...", "else leave" or "else
|
|
9
|
-
# kept",
|
|
10
|
-
#
|
|
11
|
-
#
|
|
19
|
+
# kept", or is a placeholder some template of this release prints, but is none the request's own template
|
|
20
|
+
# printed: another template's placeholder, as an answer filled from an older template and repaired field by field
|
|
21
|
+
# keeps it, which no other check refuses in free text (#1084), or as a reason copied from a correction's template
|
|
22
|
+
# into an acknowledgement's (#1114). It reads the ending alone for older wordings, so the agent's own text ending
|
|
23
|
+
# so is refused too, and the repair says to reword it.
|
|
12
24
|
class OtherTemplatesPlaceholders
|
|
13
|
-
|
|
14
|
-
ENDING = /(\bLeave (\S+ ){0,2}as printed[^.]*|\belse (leave|kept))\.?\z/ #: Regexp
|
|
25
|
+
include RefusalBeforeShape
|
|
15
26
|
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
# How every placeholder of this tool's templates ends, in this release and earlier ones, one of which said
|
|
28
|
+
# "; leave as printed otherwise" as a clause, which "to leave as printed" in prose is not (#1085).
|
|
29
|
+
ENDING = /((\bLeave|; leave) (\S+ ){0,2}as printed[^.]*|\belse (leave|kept))\.?\z/ #: Regexp
|
|
30
|
+
|
|
31
|
+
# Every string a JSON value holds, at any depth, by its JSON pointer: the one walk over a template and an
|
|
32
|
+
# answer alike.
|
|
33
|
+
class Strings
|
|
34
|
+
#: (untyped) -> void
|
|
35
|
+
def initialize(value)
|
|
36
|
+
@by_pointer = {} #: Hash[String, String]
|
|
37
|
+
gather(value, "")
|
|
38
|
+
@by_pointer.freeze
|
|
39
|
+
freeze
|
|
40
|
+
end
|
|
21
41
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
#: Hash[String, String]
|
|
43
|
+
attr_reader :by_pointer
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
#: (untyped, String) -> void
|
|
48
|
+
def gather(value, pointer)
|
|
49
|
+
case value
|
|
50
|
+
when String then @by_pointer[pointer] = value
|
|
51
|
+
when Hash then value.each { |key, each| gather(each, "#{pointer}/#{escaped(key)}") }
|
|
52
|
+
when Array then value.each_with_index { |each, index| gather(each, "#{pointer}/#{index}") }
|
|
53
|
+
end
|
|
30
54
|
end
|
|
55
|
+
|
|
56
|
+
# key as a JSON pointer writes it.
|
|
57
|
+
#: (String) -> String
|
|
58
|
+
def escaped(key) = key.gsub("~", "~0").gsub("/", "~1")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Every placeholder a template of this release prints, from the model that owns each: the full audit's member
|
|
62
|
+
# assessment, collective assessment, recent decision, check result, loading decision and prior finding
|
|
63
|
+
# decision, the correction's disposition, and the one-member audit's acknowledgement. Its spec fails on a
|
|
64
|
+
# placeholder constant in models/ missing here.
|
|
65
|
+
KNOWN = [
|
|
66
|
+
MemberAssessments::PLACEHOLDER, AssessmentAnswer::COLLECTIVE_PLACEHOLDER, RecentDecision::PLACEHOLDERS.to_h,
|
|
67
|
+
ReportedCheck::PLACEHOLDERS.to_h, ReportedCheck::UNCHANGED_PLACEHOLDERS.to_h,
|
|
68
|
+
LoadingDecision::PLACEHOLDERS.to_h, PriorDecisionFields::TEMPLATE_PLACEHOLDERS,
|
|
69
|
+
Disposition::TEMPLATE_PLACEHOLDERS, Acknowledgement::PLACEHOLDERS.to_h
|
|
70
|
+
].then { Strings.new(it).by_pointer.values.to_set }.freeze #: Set[String]
|
|
71
|
+
|
|
72
|
+
# Each string in template, a request's template as printed, which its answer may send back.
|
|
73
|
+
#: (untyped) -> OtherTemplatesPlaceholders
|
|
74
|
+
def self.besides(template)
|
|
75
|
+
new(Strings.new(template).by_pointer.values)
|
|
31
76
|
end
|
|
32
77
|
|
|
33
78
|
# printed is the placeholders the request's own template printed, which an answer may leave as printed.
|
|
@@ -36,39 +81,33 @@ module Principles
|
|
|
36
81
|
@printed = printed
|
|
37
82
|
end
|
|
38
83
|
|
|
39
|
-
# Refuses answer
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
84
|
+
# Refuses answer in one refusal naming every field holding another template's placeholder, as "The answer": the
|
|
85
|
+
# agent holds its file's path, which cost context in every repair (#1112). It names each of shape_problems at
|
|
86
|
+
# another field too, so both slips take one repair (#1109).
|
|
87
|
+
# @override
|
|
88
|
+
#: (untyped, String, Array[Hash[String, String]]) -> void
|
|
89
|
+
def refuse_in(answer, _source, shape_problems)
|
|
90
|
+
found = Strings.new(answer).by_pointer.select { |_, text| other?(text) }.keys
|
|
43
91
|
return if found.empty?
|
|
44
92
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
93
|
+
elsewhere = ShapeProblemsBeside.new(shape_problems, named: found)
|
|
94
|
+
raise Error.new("invalid_answer", elsewhere.message(MESSAGE),
|
|
95
|
+
"#{elsewhere.repair(REPAIR, "; repair each other field listed")}.",
|
|
96
|
+
fields: found.map { { "pointer" => it, "problem" => PROBLEM } } + elsewhere.fields)
|
|
49
97
|
end
|
|
50
98
|
|
|
99
|
+
MESSAGE = "The answer holds text another template printed as a placeholder" #: String
|
|
100
|
+
|
|
101
|
+
REPAIR = "Start from this request's response_template, or replace each field named with your own text; if one " \
|
|
102
|
+
"is your own text, reword its ending" #: String
|
|
103
|
+
|
|
51
104
|
PROBLEM = "ends as a placeholder does, but is none this request's template printed" #: String
|
|
52
105
|
|
|
53
106
|
private
|
|
54
107
|
|
|
55
|
-
#
|
|
56
|
-
#: (untyped, String) -> Array[String]
|
|
57
|
-
def pointers(value, pointer)
|
|
58
|
-
case value
|
|
59
|
-
when String then other?(value) ? [pointer] : []
|
|
60
|
-
when Hash then value.flat_map { |key, each| pointers(each, "#{pointer}/#{escaped(key)}") }
|
|
61
|
-
when Array then value.each_with_index.flat_map { |each, index| pointers(each, "#{pointer}/#{index}") }
|
|
62
|
-
else []
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
108
|
+
# Whether text ends as a placeholder does, or is one another template prints, but is none printed.
|
|
66
109
|
#: (String) -> bool
|
|
67
|
-
def other?(text) = text.match?(ENDING) && !@printed.include?(text)
|
|
68
|
-
|
|
69
|
-
# key as a JSON pointer writes it.
|
|
70
|
-
#: (String) -> String
|
|
71
|
-
def escaped(key) = key.gsub("~", "~0").gsub("/", "~1")
|
|
110
|
+
def other?(text) = (text.match?(ENDING) || KNOWN.include?(text)) && !@printed.include?(text)
|
|
72
111
|
end
|
|
73
112
|
end
|
|
74
113
|
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "json"
|
|
5
|
+
require_relative "candidate_outline"
|
|
6
|
+
require_relative "entry_files"
|
|
7
|
+
|
|
8
|
+
module Principles
|
|
9
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
10
|
+
module Models
|
|
11
|
+
# How much list-candidate-files may print: its listed files' outlines, cut a whole file's list items at a time
|
|
12
|
+
# until the result fits. The second alpha user's run printed 66,145 B for 45 files, against a ceiling of about
|
|
13
|
+
# 37 KB, and no cap on items under each heading both fitted and kept a core list of 8 whole (#1155).
|
|
14
|
+
class OutlineBudget
|
|
15
|
+
# The most bytes the result may print, under the host's inline limit for a tool result. Claude Code's tools
|
|
16
|
+
# reference, "Output limits" (code.claude.com/docs/en/tools-reference, checked 2026-11-16), gives a Bash result
|
|
17
|
+
# inline "up to roughly 30,000 characters by default; past that, the path of a file" and a 2,000-character
|
|
18
|
+
# preview. The second alpha user's 40.4 KB result arrived that way, and its agent scripted over the saved file
|
|
19
|
+
# (22645b61, #1155). A character is at least a byte, so 28,000 B stays under 30,000 characters with room.
|
|
20
|
+
BYTES = 28_000
|
|
21
|
+
|
|
22
|
+
# The fields of a file's entry its outline gives, which a cut replaces.
|
|
23
|
+
OUTLINE_FIELDS = %w[description opening_line outline].freeze
|
|
24
|
+
|
|
25
|
+
# The lists naming the files cut: those whose outline's lines were cut, and those whose whole outline was.
|
|
26
|
+
NAMING_LISTS = %w[outlines_cut outlines_left_out].freeze
|
|
27
|
+
|
|
28
|
+
# Each outlined file's outline, by path.
|
|
29
|
+
#: (Hash[String, CandidateOutline]) -> void
|
|
30
|
+
def initialize(outlines)
|
|
31
|
+
@outlines = outlines
|
|
32
|
+
freeze
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# The listing with its files' outlines cut, one cut of one file at a time in cut order, until what the block says
|
|
36
|
+
# it prints fits BYTES, each file whose items were cut named under outlines_cut. If every cut is made and it
|
|
37
|
+
# still does not fit, every file cut is named.
|
|
38
|
+
#: (Hash[String, untyped]) { (Hash[String, untyped]) -> Integer } -> Hash[String, untyped]
|
|
39
|
+
def cut(listing, &printed_bytes)
|
|
40
|
+
cut_order(listing).reduce(listing) do |shorter, (path, cuts)|
|
|
41
|
+
return shorter if printed_bytes.call(shorter) <= BYTES
|
|
42
|
+
|
|
43
|
+
cut_file(shorter, path, cuts)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
# Each cut that shortens a file, as its path and how many of CandidateOutline::CUTS it then has made. Every file
|
|
50
|
+
# but the root entry files comes first, since a host loads those in every session, so they keep theirs longest,
|
|
51
|
+
# in EntryFiles' order. Within each group, each cut is made across the files in CUTS' order: those with a
|
|
52
|
+
# description first, since the agent still reads what each is for, then the deepest path, then the most bytes
|
|
53
|
+
# the cut saves (#1155, review F5).
|
|
54
|
+
#: (Hash[String, untyped]) -> Array[[String, Integer]]
|
|
55
|
+
def cut_order(listing)
|
|
56
|
+
outlined = listing.fetch("files").select { |file| @outlines.key?(file.fetch("path")) }
|
|
57
|
+
outlined.group_by { |file| entry_rank(file.fetch("path")) }.sort.flat_map do |rank, files|
|
|
58
|
+
(1..most_cuts(rank)).flat_map { |cuts| cuts_across(files, cuts) }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# How many of CUTS are made on a file of this entry rank: on an entry file every one but leaving its outline out.
|
|
63
|
+
#: (Integer) -> Integer
|
|
64
|
+
def most_cuts(rank) = rank.zero? ? CandidateOutline::CUTS.length : CandidateOutline::ENTRY_FILE_CUTS
|
|
65
|
+
|
|
66
|
+
# The files the cuts'th cut shortens, in the order it is made across them.
|
|
67
|
+
#: (Array[Hash[String, untyped]], Integer) -> Array[[String, Integer]]
|
|
68
|
+
def cuts_across(files, cuts)
|
|
69
|
+
files.select { |file| saved(file.fetch("path"), cuts).positive? }
|
|
70
|
+
.sort_by { |file| cut_rank(file, cuts) }.map { |file| [file.fetch("path"), cuts] }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Where a file comes among those one cut shortens: described or not, depth, bytes saved, then path.
|
|
74
|
+
#: (Hash[String, untyped], Integer) -> [Integer, Integer, Integer, String]
|
|
75
|
+
def cut_rank(file, cuts)
|
|
76
|
+
path = file.fetch("path")
|
|
77
|
+
[file.key?("description") ? 0 : 1, -path.count("/"), -saved(path, cuts), path]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# 0 for a file that is not a root entry file, then each entry file in EntryFiles::PATHS reversed, so the first,
|
|
81
|
+
# CLAUDE.md, keeps its items longest.
|
|
82
|
+
#: (String) -> Integer
|
|
83
|
+
def entry_rank(path)
|
|
84
|
+
index = EntryFiles::PATHS.index(path) or return 0
|
|
85
|
+
|
|
86
|
+
EntryFiles::PATHS.length - index
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# The bytes the cuts'th cut of path's outline saves over the cuts made before it.
|
|
90
|
+
#: (String, Integer) -> Integer
|
|
91
|
+
def saved(path, cuts)
|
|
92
|
+
outline = @outlines.fetch(path)
|
|
93
|
+
JSON.generate(outline.to_h(cuts: cuts - 1)).bytesize - JSON.generate(outline.to_h(cuts:)).bytesize
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# The listing with path's outline cut to its first `cuts` cuts, and the file named as its cuts say.
|
|
97
|
+
#: (Hash[String, untyped], String, Integer) -> Hash[String, untyped]
|
|
98
|
+
def cut_file(listing, path, cuts)
|
|
99
|
+
outline = @outlines.fetch(path)
|
|
100
|
+
files = listing.fetch("files").map do |file|
|
|
101
|
+
file.fetch("path") == path ? file.except(*OUTLINE_FIELDS).merge(outline.to_h(cuts:)) : file
|
|
102
|
+
end
|
|
103
|
+
named(listing.merge("files" => files), path, outline, cuts)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# The listing naming path under outlines_cut once its outline's lines are cut, and under outlines_left_out instead
|
|
107
|
+
# once its whole outline is; a cut description says so in its own text. A list that names no path is left out.
|
|
108
|
+
#: (Hash[String, untyped], String, CandidateOutline, Integer) -> Hash[String, untyped]
|
|
109
|
+
def named(listing, path, outline, cuts)
|
|
110
|
+
named_in = naming_list(outline, cuts)
|
|
111
|
+
lists = NAMING_LISTS.to_h do |list|
|
|
112
|
+
[list, listing.fetch(list, []) - [path] + (list == named_in ? [path] : [])]
|
|
113
|
+
end
|
|
114
|
+
listing.except(*NAMING_LISTS).merge(lists.reject { |_, paths| paths.empty? })
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# The one of NAMING_LISTS a file with these cuts made belongs in, the whole outline left out moving it from the
|
|
118
|
+
# first to the second; nil while only its description is cut.
|
|
119
|
+
#: (CandidateOutline, Integer) -> String?
|
|
120
|
+
def naming_list(outline, cuts)
|
|
121
|
+
return "outlines_left_out" if outline.left_out?(cuts)
|
|
122
|
+
|
|
123
|
+
"outlines_cut" if outline.outline_cut?(cuts)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "outline_section"
|
|
5
|
+
|
|
6
|
+
module Principles
|
|
7
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
8
|
+
module Models
|
|
9
|
+
# One section of a candidate file's outline and the deeper sections under it, which a cut outline folds into it
|
|
10
|
+
# once its headings are cut too (#1155).
|
|
11
|
+
class OutlineGroup
|
|
12
|
+
#: (OutlineSection, Array[OutlineSection]) -> void
|
|
13
|
+
def initialize(section, deeper)
|
|
14
|
+
@section = section
|
|
15
|
+
@deeper = deeper
|
|
16
|
+
freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# The group as a cut outline prints it once its deeper headings are folded: the section's heading, then how many
|
|
20
|
+
# items it and they hold under how many headings, and the lines they span.
|
|
21
|
+
#: () -> Array[String]
|
|
22
|
+
def folded_lines
|
|
23
|
+
last = @deeper.last or return @section.cut_lines
|
|
24
|
+
|
|
25
|
+
items = @section.item_count + @deeper.sum(&:item_count)
|
|
26
|
+
headings = "#{@deeper.length} heading#{"s" unless @deeper.one?}"
|
|
27
|
+
[*@section.heading, "(#{items} more under #{headings}, lines #{@section.first_line}-#{last.last_line})"]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Principles
|
|
5
|
+
# The domain logic, which loads and saves itself through data/. models/CLAUDE.md owns the boundary.
|
|
6
|
+
module Models
|
|
7
|
+
# One heading of a candidate file's outline and the top-level list items under it, with the lines of the file it
|
|
8
|
+
# spans, so an outline whose items are cut can say where to read them back (#1155).
|
|
9
|
+
class OutlineSection
|
|
10
|
+
# The most items printed under one heading; a longer list says how many more it holds.
|
|
11
|
+
MOST_ITEMS = 20
|
|
12
|
+
# A heading's marks, as many as its level.
|
|
13
|
+
MARKS = /\A#+/
|
|
14
|
+
|
|
15
|
+
# The heading as Markdown; nil for the items before a file's first heading.
|
|
16
|
+
#: String?
|
|
17
|
+
attr_reader :heading
|
|
18
|
+
|
|
19
|
+
# The file's lines the section spans, from its heading, counted from 1.
|
|
20
|
+
#: Integer
|
|
21
|
+
attr_reader :first_line
|
|
22
|
+
|
|
23
|
+
#: Integer
|
|
24
|
+
attr_reader :last_line
|
|
25
|
+
|
|
26
|
+
# The heading's level, its number of #s; 0 for the items before a file's first heading.
|
|
27
|
+
#: Integer
|
|
28
|
+
attr_reader :level
|
|
29
|
+
|
|
30
|
+
#: (heading: String?, items: Array[String], first_line: Integer, last_line: Integer) -> void
|
|
31
|
+
def initialize(heading:, items:, first_line:, last_line:)
|
|
32
|
+
@heading = heading
|
|
33
|
+
@level = heading.to_s[MARKS].to_s.length #: Integer
|
|
34
|
+
@items = items
|
|
35
|
+
@first_line = first_line
|
|
36
|
+
@last_line = last_line
|
|
37
|
+
freeze
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The section as the outline prints it: its heading, its items up to MOST_ITEMS, then how many more.
|
|
41
|
+
#: () -> Array[String]
|
|
42
|
+
def lines
|
|
43
|
+
more = @items.length - MOST_ITEMS
|
|
44
|
+
[*@heading, *@items.first(MOST_ITEMS), *("(#{more} more)" if more.positive?)]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# The section as a cut outline prints it: its heading, then, if it holds items, how many and the lines of the file
|
|
48
|
+
# that hold them, so the agent reads just that section back (#1155, review F2).
|
|
49
|
+
#: () -> Array[String]
|
|
50
|
+
def cut_lines = [*@heading, *("(#{@items.length} more, lines #{@first_line}-#{@last_line})" if @items.any?)]
|
|
51
|
+
|
|
52
|
+
#: () -> Integer
|
|
53
|
+
def item_count = @items.length
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -71,6 +71,17 @@ module Principles
|
|
|
71
71
|
#: (untyped) -> String?
|
|
72
72
|
def check(member_id) = with_id(member_id)&.check
|
|
73
73
|
|
|
74
|
+
# The id of each member that names a check, in the map's order (#1090).
|
|
75
|
+
#: () -> Array[String]
|
|
76
|
+
def checked_ids = @list.select(&:check).map(&:id)
|
|
77
|
+
|
|
78
|
+
# Whether a member has member_id and names no check, so its assessment takes no check_result (#1088).
|
|
79
|
+
#: (untyped) -> bool
|
|
80
|
+
def unchecked?(member_id)
|
|
81
|
+
member = with_id(member_id)
|
|
82
|
+
!member.nil? && member.check.nil?
|
|
83
|
+
end
|
|
84
|
+
|
|
74
85
|
# Each key more than one member is known by, a member with no stored key being known by its id, with the ids of
|
|
75
86
|
# the members that share it. An audit record files each member under its key, so one would stand for the other.
|
|
76
87
|
#: () -> Hash[String, Array[String]]
|
|
@@ -22,13 +22,14 @@ module Principles
|
|
|
22
22
|
# The placeholder printed in each field a decision may give: only which decision takes it, and what, since that
|
|
23
23
|
# a field left as printed is not given is stated once, at the template's head, and each finding printed every
|
|
24
24
|
# field's whole help (#1033). Each says what to do otherwise: "else kept" where omission keeps what the finding
|
|
25
|
-
# has, "else leave" where it gives nothing (#1043).
|
|
25
|
+
# has, "else leave" where it gives nothing (#1043). action's says instead that it is a change, which only
|
|
26
|
+
# still_holds may make, since naming the decision read as a request to restate the action (dogfood D6).
|
|
26
27
|
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
27
28
|
{
|
|
28
29
|
"reason" => "resolved, withdrawn, new action: why, in a line; else leave",
|
|
29
30
|
"as" => "raised_again: the new finding's id; else leave",
|
|
30
31
|
"evidence" => [{ "path" => "resolved: where the fix shows, with heading; else leave" }],
|
|
31
|
-
"action" => "
|
|
32
|
+
"action" => "to change it: deferred or accepted; else kept",
|
|
32
33
|
"recorded_at" => "still_holds: a write-up pointer or null; else kept",
|
|
33
34
|
"waits_on" => "deferral: whom it waits on, for what, or null; else kept",
|
|
34
35
|
"problem" => "still_holds: restated if renamed or moved; else kept",
|
|
@@ -20,6 +20,9 @@ module Principles
|
|
|
20
20
|
class PriorFindingDecision
|
|
21
21
|
KINDS = %w[still_holds resolved withdrawn raised_again].freeze
|
|
22
22
|
CLOSING = %w[resolved withdrawn].freeze
|
|
23
|
+
# The actions a still_holds decision may keep a finding open with, each with what changing to it needs.
|
|
24
|
+
OPEN_ACTIONS = { "deferred" => "a reason and recorded_at, null when written up nowhere",
|
|
25
|
+
"accepted" => "a reason" }.freeze #: Hash[String, String]
|
|
23
26
|
# What the completed result shows of each closed finding.
|
|
24
27
|
CLOSED_FIELDS = %w[finding_id decision reason evidence].freeze
|
|
25
28
|
REPAIR = "Decide it still_holds, raised_again with as, or resolved or withdrawn with a one-line reason."
|
|
@@ -98,19 +101,26 @@ module Principles
|
|
|
98
101
|
unless @decision["decision"] == "still_holds"
|
|
99
102
|
invalid("only still_holds may give action", "Drop action from #{@id}'s decision, or decide it still_holds.")
|
|
100
103
|
end
|
|
101
|
-
invalid("still_holds may make it only deferred or accepted") unless
|
|
104
|
+
invalid("still_holds may make it only deferred or accepted") unless OPEN_ACTIONS.key?(action)
|
|
102
105
|
changed_action(action)
|
|
103
106
|
end
|
|
104
107
|
|
|
105
108
|
#: (String) -> void
|
|
106
109
|
def changed_action(action)
|
|
107
|
-
if action == @finding.action
|
|
108
|
-
invalid("it is already #{action}", "Drop action from #{@id}'s decision; it is already #{action}.")
|
|
109
|
-
end
|
|
110
|
+
already(action) if action == @finding.action
|
|
110
111
|
invalid("a new action needs a one-line reason") unless one_line_reason?
|
|
111
112
|
unrecorded_deferral if action == "deferred" && !@decision.key?("recorded_at")
|
|
112
113
|
end
|
|
113
114
|
|
|
115
|
+
# The template prints action for every finding, so it may be given the action its finding has: the repair
|
|
116
|
+
# names both ways on, keeping it or changing it to the other (dogfood D6).
|
|
117
|
+
#: (String) -> bot
|
|
118
|
+
def already(action)
|
|
119
|
+
other, needs = OPEN_ACTIONS.find { |open, _| open != action }
|
|
120
|
+
invalid("it is already #{action}", "To keep #{@id} #{action}, leave action as printed or drop it; " \
|
|
121
|
+
"to change it, give #{other} with #{needs}.")
|
|
122
|
+
end
|
|
123
|
+
|
|
114
124
|
#: () -> bot
|
|
115
125
|
def unrecorded_deferral
|
|
116
126
|
invalid("deferring it needs recorded_at, or null when it is written up nowhere",
|
|
@@ -24,7 +24,7 @@ require_relative "locate_refusal"
|
|
|
24
24
|
require_relative "audit_records"
|
|
25
25
|
require_relative "project_history"
|
|
26
26
|
require_relative "principles_folder_move"
|
|
27
|
-
require_relative "
|
|
27
|
+
require_relative "sent_answer"
|
|
28
28
|
|
|
29
29
|
module Principles
|
|
30
30
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -191,29 +191,20 @@ module Principles
|
|
|
191
191
|
#: () -> EntryFiles
|
|
192
192
|
def entry_files = EntryFiles.read(@files, history)
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
# to a request that no longer matches before the rest of its shape is read (#1052), and gives the placeholders
|
|
203
|
-
# that request's template printed, so every field holding another template's is refused next, whole (#1084).
|
|
204
|
-
#: (String, stdin: String?, phase: String) ?{ (Hash[String, untyped]) -> OtherTemplatesPlaceholders } -> untyped
|
|
205
|
-
def answer(file, stdin:, phase:, &)
|
|
206
|
-
parsed = file == "-" ? @files.parse_json(stdin.to_s, "-") : @files.read_json(file)
|
|
207
|
-
check = Data::SchemaCheck.new("#{phase}-answer")
|
|
208
|
-
check.only(ANSWER_HEAD).checked(parsed, code: "invalid_answer", source: file, repair: ANSWER_REPAIR)
|
|
209
|
-
yield(parsed.slice(*ANSWER_HEAD)).refuse_in(parsed, file) if block_given?
|
|
210
|
-
check.checked(parsed, code: "invalid_answer", source: file, repair: ANSWER_REPAIR)
|
|
194
|
+
# An answer to a phase's request from file, where - means it was read from stdin, its head checked against
|
|
195
|
+
# the phase's answer schema (D29) and the rest left to check once its request is known (#1052).
|
|
196
|
+
#: (String, stdin: String?, phase: String) -> SentAnswer
|
|
197
|
+
def answer(file, stdin:, phase:)
|
|
198
|
+
parsed = if file == "-" then @files.parse_json(stdin.to_s, "-", named: SentAnswer::NAMED)
|
|
199
|
+
else @files.read_json(file, named: SentAnswer::FILE_NAMED)
|
|
200
|
+
end
|
|
201
|
+
SentAnswer.new(parsed, file, Data::SchemaCheck.new("#{phase}-answer"))
|
|
211
202
|
end
|
|
212
203
|
|
|
213
204
|
# What list-candidate-files found: the candidate files as it lists them, and which git does not track.
|
|
214
205
|
#: () -> CandidateInventory
|
|
215
206
|
def candidate_files
|
|
216
|
-
CandidateInventory.found(@files.inventory, history)
|
|
207
|
+
CandidateInventory.found(@files.inventory, history) { |path| @files.read_text(path) }
|
|
217
208
|
end
|
|
218
209
|
|
|
219
210
|
private
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "member_lines"
|
|
6
|
+
|
|
7
|
+
module Principles
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
|
+
module Models
|
|
10
|
+
# A one-member audit's change as its answer quotes it (D33): a line of the member before the change and one after,
|
|
11
|
+
# each a whole line of its side or a fragment long enough to show the edit that only its side reads (#352, #379).
|
|
12
|
+
class QuotedChange
|
|
13
|
+
# One side of the change a quote is checked against: the member's lines then, and when they read.
|
|
14
|
+
class SideOfTheChange
|
|
15
|
+
#: String
|
|
16
|
+
attr_reader :reads_at
|
|
17
|
+
|
|
18
|
+
#: (Array[String], String) -> void
|
|
19
|
+
def initialize(lines, reads_at)
|
|
20
|
+
@lines = lines.map(&:chomp) #: Array[String]
|
|
21
|
+
@reads_at = reads_at
|
|
22
|
+
freeze
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#: (String) -> bool
|
|
26
|
+
def whole_line?(quote) = @lines.include?(quote)
|
|
27
|
+
|
|
28
|
+
#: (String) -> bool
|
|
29
|
+
def holds?(text) = @lines.any? { |line| line.include?(text) }
|
|
30
|
+
|
|
31
|
+
# Its first line the other side lacks, or "" when it has none, as after a pure insertion on the other side.
|
|
32
|
+
#: (SideOfTheChange) -> String
|
|
33
|
+
def first_line_absent_from(other) = @lines.find { |line| !other.whole_line?(line) } || ""
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The fewest characters a quoted fragment of a line may have, so it shows which edit was read (#352).
|
|
37
|
+
FRAGMENT_LENGTH = 30
|
|
38
|
+
|
|
39
|
+
# The longest changed line the hint gives whole, beyond which it gives the span the edit changed (#1103).
|
|
40
|
+
LONG_LINE = 200
|
|
41
|
+
|
|
42
|
+
# lines holds the member's lines at its baseline commit and at HEAD; member_id names it in a refusal.
|
|
43
|
+
#: (MemberLines, member_id: String) -> void
|
|
44
|
+
def initialize(lines, member_id:)
|
|
45
|
+
@then = SideOfTheChange.new(lines.at_baseline, "before the change") #: SideOfTheChange
|
|
46
|
+
@now = SideOfTheChange.new(lines.now, "at HEAD") #: SideOfTheChange
|
|
47
|
+
@member_id = member_id
|
|
48
|
+
freeze
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The first line on each side the other lacks, which the request hints the quotes from (#1016); of a pair with a
|
|
52
|
+
# line over LONG_LINE characters, the span each side's edit changed, so a small edit is found without comparing
|
|
53
|
+
# two long lines by eye, and the request does not carry them again (#1103).
|
|
54
|
+
#: () -> Hash[String, String]
|
|
55
|
+
def first_changed_lines
|
|
56
|
+
old_line = @then.first_line_absent_from(@now)
|
|
57
|
+
new_line = @now.first_line_absent_from(@then)
|
|
58
|
+
whole = { "old_line" => old_line, "new_line" => new_line }
|
|
59
|
+
return whole if whole.values.all? { it.length <= LONG_LINE }
|
|
60
|
+
|
|
61
|
+
{ "old_line" => changed_span(old_line, new_line, @then, @now),
|
|
62
|
+
"new_line" => changed_span(new_line, old_line, @now, @then) }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Refuses an old_line not found before the change, or a new_line not found after it.
|
|
66
|
+
#: (old_line: String, new_line: String) -> void
|
|
67
|
+
def check(old_line:, new_line:)
|
|
68
|
+
quoted(old_line, @then, @now)
|
|
69
|
+
quoted(new_line, @now, @then)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
# line's characters between those it shares with other_line from the start and from the end, with
|
|
75
|
+
# FRAGMENT_LENGTH more on each side, widened to whole words, when that fragment is a quote only side holds; else
|
|
76
|
+
# the whole line.
|
|
77
|
+
#: (String, String, SideOfTheChange, SideOfTheChange) -> String
|
|
78
|
+
def changed_span(line, other_line, side, other)
|
|
79
|
+
edit = edited(line, other_line)
|
|
80
|
+
from = word_start(line, [edit.begin - FRAGMENT_LENGTH, 0].max)
|
|
81
|
+
span = line[from...word_end(line, edit.end + FRAGMENT_LENGTH)].to_s
|
|
82
|
+
only_on?(span, side, other) ? span : line
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The start of the word at index in line, when it starts within FRAGMENT_LENGTH before it; else index, so a
|
|
86
|
+
# span of a line without spaces keeps its context (#1144).
|
|
87
|
+
#: (String, Integer) -> Integer
|
|
88
|
+
def word_start(line, index)
|
|
89
|
+
return index if index.zero?
|
|
90
|
+
|
|
91
|
+
start = (line.rindex(" ", index - 1) || -1) + 1
|
|
92
|
+
index - start <= FRAGMENT_LENGTH ? start : index
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# The end of the word at index in line, when it ends within FRAGMENT_LENGTH after it; else index.
|
|
96
|
+
#: (String, Integer) -> Integer
|
|
97
|
+
def word_end(line, index)
|
|
98
|
+
finish = line.index(" ", index) || line.length
|
|
99
|
+
finish - index <= FRAGMENT_LENGTH ? finish : index
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# The characters of line between those it shares with other_line from the start and from the end, which never
|
|
103
|
+
# overlap, as an insertion repeating its neighbour would make them.
|
|
104
|
+
#: (String, String) -> Range[Integer]
|
|
105
|
+
def edited(line, other_line)
|
|
106
|
+
head = common_length(line, other_line)
|
|
107
|
+
tail = common_length(line[head..].to_s.reverse, other_line[head..].to_s.reverse)
|
|
108
|
+
head...(line.length - tail)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# How many characters two strings share from their start.
|
|
112
|
+
#: (String, String) -> Integer
|
|
113
|
+
def common_length(one, other) = one.each_char.zip(other.each_char).take_while { |a, b| a == b }.length
|
|
114
|
+
|
|
115
|
+
# A quote is a whole line, or a fragment long enough to show the edit, that only this side reads; or "" when
|
|
116
|
+
# this side has no line the other lacks, as before a pure insertion (#1070).
|
|
117
|
+
#: (String, SideOfTheChange, SideOfTheChange) -> void
|
|
118
|
+
def quoted(line, side, other)
|
|
119
|
+
return if line == side.first_line_absent_from(other)
|
|
120
|
+
return if !line.empty? && only_on?(line, side, other)
|
|
121
|
+
|
|
122
|
+
raise Error.new("quote_not_found",
|
|
123
|
+
"#{line.inspect} is not a line of #{@member_id} #{side.reads_at} that the change touched",
|
|
124
|
+
"Quote a whole line of the member as it reads #{side.reads_at}, as first_changed_lines " \
|
|
125
|
+
"shows, or at least #{FRAGMENT_LENGTH} characters of one that the member #{other.reads_at} " \
|
|
126
|
+
"does not hold; quote \"\" only where first_changed_lines does.")
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Whether a quote is a whole line of side, or a fragment of at least FRAGMENT_LENGTH, that other does not hold.
|
|
130
|
+
#: (String, SideOfTheChange, SideOfTheChange) -> bool
|
|
131
|
+
def only_on?(line, side, other)
|
|
132
|
+
(side.whole_line?(line) && !other.whole_line?(line)) ||
|
|
133
|
+
(line.length >= FRAGMENT_LENGTH && side.holds?(line) && !other.holds?(line))
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|