principles 0.1.2 → 0.1.3
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 +12 -0
- data/lib/principles/controllers/command.rb +3 -2
- data/lib/principles/controllers/member_acknowledgement.rb +21 -11
- data/lib/principles/controllers/running_tool.rb +6 -4
- data/lib/principles/data/repository.rb +5 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/models/acknowledgement.rb +10 -0
- data/lib/principles/models/acknowledgement_placeholders.rb +43 -18
- data/lib/principles/models/disposition.rb +1 -1
- data/lib/principles/models/disposition_placeholders.rb +15 -7
- data/lib/principles/models/named_placeholder.rb +17 -7
- data/lib/principles/models/project_history.rb +9 -0
- data/lib/principles/models/template_placeholders.rb +10 -9
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledgement_result.rb +23 -16
- data/lib/principles/views/answer_in_a_file.rb +1 -1
- data/lib/principles/views/correction_request.rb +1 -1
- data/lib/principles/views/first_audit_brief.rb +0 -1
- data/lib/principles/views/invocation.rb +4 -3
- data/lib/principles/views/prompts/answer-any-judgement-request/fill-the-answer-in-a-file.md +1 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/show-answer-check.md +3 -3
- data/lib/principles/views/prompts/learn-what-a-command-does/show-open-correction.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +1 -1
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8b04054564dfc79ab583581eeaae27f66204b08442fafe36cca6e394cf7c03a
|
|
4
|
+
data.tar.gz: f50136eab25d56d28763cf45370cc82153b147cb09ff33a3115870bd1f8952c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8046d682bc212a7cc23b758e04475aa865e04bc52c39d8d0152ae84d9103e450e285c10f595dd716d7dd796127e4520e015b7a3c5c6d810a051913be86adb4c
|
|
7
|
+
data.tar.gz: 719dfe66f7590955ea3102a6f5895827b5a3ca4b47c1ba836492fc31dabc351c0bb901b54aaa1e620dcbff546088116d1668fae3c31db94c46985b8258c2f573
|
data/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,18 @@ The agent's mechanics are the means, never the lead: do not open with "An agent
|
|
|
13
13
|
|
|
14
14
|
## Unreleased
|
|
15
15
|
|
|
16
|
+
## [0.1.3] - 2026-11-24
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Answer files land in the project's own ignored scratch folder when it has one, not a system temporary folder the agent may not be able to reach or find again.** When the project has a `tmp/` folder that git ignores, every answer file a printed next step names, from `principles start-audit`, `principles submit-answer` and `principles show-first-audit-brief`, is in it, where each named a system temporary folder; a project with no ignored `tmp/` keeps the temporary folder. The steps now say the file is kept out of git rather than outside the project, and the first-audit brief says to keep it at the one path named and nowhere else.
|
|
21
|
+
- **Choosing a finding's action in a correction means replacing a few words, not a long sentence.** Each disposition's `action` in the correction's answer, as `principles show-open-correction` and `principles show-answer-check --as template` print it, now reads "For F1: fixed, deferred, accepted or disagreed", and the answer guide `principles submit-answer` prints with the correction shows what each action adds. Each finding's action takes 57 bytes instead of 373, so a one-finding correction template takes 721 bytes instead of 1,037. An answer still holding an earlier release's long placeholder is refused as unchosen, as before.
|
|
22
|
+
- **Acknowledging several edited members fills each slot with a file-edit tool, with no script.** In `principles start-audit ID --member MEMBER --member MEMBER --as template`, each member's placeholders now name its entry by position, such as "M2: true only if it still says the same thing" and "M2: why, in one line of your own", where each repeated the member's full id, long and often holding quotes, that an edit had to quote exactly; the id stays the entry's key. A four-member template with long ids takes 1,104 bytes instead of 1,608. An answer still holding a placeholder, as this or an earlier release printed it, is refused as unanswered, as before.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **A member widened over lines its file already held is no longer described as an edit that inserted a line.** After `principles move-member --ending-at` stretches a member over existing text, `principles start-audit ID --member MEMBER` now says in the template that the member's span grew over lines its file already held, which may add a rule, where it said the change inserted a line though the file's text had not changed.
|
|
27
|
+
|
|
16
28
|
## [0.1.2] - 2026-11-24
|
|
17
29
|
|
|
18
30
|
### Added
|
|
@@ -94,10 +94,11 @@ module Principles
|
|
|
94
94
|
controller.new(@project, tool: @tool, **)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
# The executable and project that printed commands name,
|
|
97
|
+
# The executable and project that printed commands name, and the folder a printed answer is saved in, built for
|
|
98
|
+
# each run and never stored.
|
|
98
99
|
#: () -> Views::Invocation
|
|
99
100
|
def invocation
|
|
100
|
-
@tool.invocation(@project.root)
|
|
101
|
+
@tool.invocation(@project.root, answer_folder: @history.ignored_tmp_folder)
|
|
101
102
|
end
|
|
102
103
|
|
|
103
104
|
# Principle id as waiting on an upgrade, when a later copy wrote its record.
|
|
@@ -22,12 +22,13 @@ module Principles
|
|
|
22
22
|
# template prints, and the record with the acknowledgement in it once the answer holds.
|
|
23
23
|
class MemberAcknowledgement < Command
|
|
24
24
|
# The text the template prints in each field the agent writes: its judgement's placeholders, meaning_kept's
|
|
25
|
-
# chosen by whether the change's first_changed_lines is a pure insertion
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
# chosen by whether the change's first_changed_lines is a pure insertion and file_unchanged, whether the
|
|
26
|
+
# member's file text is as at its baseline, and check_result's for a checked member. The quotes the answer
|
|
27
|
+
# reads as first_changed_lines when left out are not printed.
|
|
28
|
+
#: (Hash[String, untyped]?, ?Views::MemberChangeSinceBaseline?, ?file_unchanged: bool) -> Hash[String, untyped]
|
|
29
|
+
def self.placeholders(check_result, change = nil, file_unchanged: false)
|
|
29
30
|
quotes = change&.first_changed_lines.to_h
|
|
30
|
-
{ **Models::AcknowledgementPlaceholders.beside(quotes),
|
|
31
|
+
{ **Models::AcknowledgementPlaceholders.beside(quotes, file_unchanged:),
|
|
31
32
|
**(check_result ? { "check_result" => check_result } : {}) }
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -57,13 +58,11 @@ module Principles
|
|
|
57
58
|
def asked
|
|
58
59
|
baseline, lines = since_baseline
|
|
59
60
|
check = check_template
|
|
60
|
-
change =
|
|
61
|
-
member: shown(baseline), member_lines: lines.shown(taken: bytes_of(check)),
|
|
62
|
-
first_changed_lines: @acknowledgement.first_changed_lines(lines), commits: commits(baseline),
|
|
63
|
-
read_the_change: read_the_change(baseline)
|
|
64
|
-
)
|
|
61
|
+
change = change_since(baseline, lines, check)
|
|
65
62
|
{ change:, context: { **@acknowledgement.open_findings, **instruction_for(check) },
|
|
66
|
-
placeholders: MemberAcknowledgement.placeholders(
|
|
63
|
+
placeholders: MemberAcknowledgement.placeholders(
|
|
64
|
+
check&.to_h, change, file_unchanged: @acknowledgement.file_unchanged_since?(baseline, @project)
|
|
65
|
+
) }
|
|
67
66
|
end
|
|
68
67
|
|
|
69
68
|
# The record with the acknowledgement in it, once its quotes are found at the baseline and now, made to into
|
|
@@ -79,6 +78,17 @@ module Principles
|
|
|
79
78
|
|
|
80
79
|
private
|
|
81
80
|
|
|
81
|
+
# The member's change since baseline as the request shows it, its lines giving up the bytes check takes.
|
|
82
|
+
#: (Models::Placement, Models::MemberLines, Views::OneMemberCheckResultTemplate?)
|
|
83
|
+
#| -> Views::MemberChangeSinceBaseline
|
|
84
|
+
def change_since(baseline, lines, check)
|
|
85
|
+
Views::MemberChangeSinceBaseline.new(
|
|
86
|
+
member: shown(baseline), member_lines: lines.shown(taken: bytes_of(check)),
|
|
87
|
+
first_changed_lines: @acknowledgement.first_changed_lines(lines), commits: commits(baseline),
|
|
88
|
+
read_the_change: read_the_change(baseline)
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
|
|
82
92
|
# What the member's check lists now beside the members the answer acknowledges, when the check is this
|
|
83
93
|
# tool's own list-member-problems --short; nil for any other check.
|
|
84
94
|
#: (Array[[String, String]]) -> Models::ListedMembers?
|
|
@@ -72,10 +72,12 @@ module Principles
|
|
|
72
72
|
# The executable and project that this run's printed commands name, for the project at root. A command line run
|
|
73
73
|
# printed as the bare principles, from root itself, leaves out --project, since a command copied from its
|
|
74
74
|
# output runs there too; any other run names the project, as the plugin's hooks and a checkout's commands may
|
|
75
|
-
# be run from elsewhere.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
# be run from elsewhere. answer_folder is the project's own folder for a printed answer, when it has one, which
|
|
76
|
+
# every answer file is saved in rather than the temporary folder.
|
|
77
|
+
#: (String, ?answer_folder: String?) -> Views::Invocation
|
|
78
|
+
def invocation(root, answer_folder: nil)
|
|
79
|
+
Views::Invocation.new(executable: executable, project: root,
|
|
80
|
+
temp_directory: answer_folder || @folders.temp_directory,
|
|
79
81
|
named: !bare_from_path? || root != @folders.cwd)
|
|
80
82
|
end
|
|
81
83
|
|
|
@@ -109,6 +109,11 @@ module Principles
|
|
|
109
109
|
#: (Array[String]) -> Array[String]
|
|
110
110
|
def untracked_excluding_ignored(paths) = @changes.untracked_excluding_ignored(paths)
|
|
111
111
|
|
|
112
|
+
# Whether git ignores path, relative to the project, a folder ending in "/"; false outside git. check-ignore
|
|
113
|
+
# refuses literal pathspecs, and reads each path as a name, never a glob, without them.
|
|
114
|
+
#: (String) -> bool
|
|
115
|
+
def ignores?(path) = git(["--no-literal-pathspecs", "check-ignore", "-q", "--", path]).last
|
|
116
|
+
|
|
112
117
|
# Which of paths, relative to the project, git does not track, ignored or not.
|
|
113
118
|
#: (Array[String]) -> Array[String]
|
|
114
119
|
def untracked_including_ignored(paths) = @changes.untracked_including_ignored(paths)
|
|
@@ -12,7 +12,7 @@ module Principles
|
|
|
12
12
|
class RunningVersion
|
|
13
13
|
# git archive writes the short sha of the commit it archives here, since .gitattributes marks this file
|
|
14
14
|
# export-subst; a checkout keeps the placeholder as written.
|
|
15
|
-
ARCHIVED_COMMIT = "
|
|
15
|
+
ARCHIVED_COMMIT = "9e955b6b" #: String
|
|
16
16
|
|
|
17
17
|
#: (?String, release: String, ?built: String?, ?archived_commit: String) -> void
|
|
18
18
|
def initialize(checkout = File.expand_path("../../..", __dir__), release:, built: nil,
|
|
@@ -61,6 +61,16 @@ module Principles
|
|
|
61
61
|
#: (Placement) -> Array[String]
|
|
62
62
|
def paths_since(baseline) = baseline.paths_to(@member.path)
|
|
63
63
|
|
|
64
|
+
# Whether the member's file at the base commit holds the text its file held at baseline, so a change to the
|
|
65
|
+
# member is a change to its span alone, as after move-member --ending-at.
|
|
66
|
+
#: (Placement, Project) -> bool
|
|
67
|
+
def file_unchanged_since?(baseline, project)
|
|
68
|
+
base = @base or return false
|
|
69
|
+
|
|
70
|
+
then_text = project.history.at(baseline.commit).text(baseline.reference.fetch("path"))
|
|
71
|
+
!then_text.nil? && then_text == project.history.at(base).text(@member.path)
|
|
72
|
+
end
|
|
73
|
+
|
|
64
74
|
# The commit the member was last judged at, when baseline is later than it, as when the member's own full
|
|
65
75
|
# audit fixed it after its base.
|
|
66
76
|
#: (Placement) -> String?
|
|
@@ -12,23 +12,45 @@ module Principles
|
|
|
12
12
|
# The text a one-member audit's template prints in each field the agent writes, and the refusal of an answer
|
|
13
13
|
# that sends any back as printed.
|
|
14
14
|
class AcknowledgementPlaceholders
|
|
15
|
+
# meaning_kept's placeholder after a pure insertion, for an agent that reads the template alone: an inserted
|
|
16
|
+
# line usually adds a rule.
|
|
17
|
+
INSERTED = NamedPlaceholder.new(
|
|
18
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; this change inserted a line, " \
|
|
19
|
+
"which usually adds a rule",
|
|
20
|
+
before: NamedPlaceholder.new(
|
|
21
|
+
"true only if #{NamedPlaceholder::SLOT} still says the same thing; this change inserted a line, which " \
|
|
22
|
+
"usually adds a rule",
|
|
23
|
+
before: "true only if the member still says the same thing; this change inserted a line, which " \
|
|
24
|
+
"usually adds a rule"
|
|
25
|
+
)
|
|
26
|
+
) #: NamedPlaceholder
|
|
27
|
+
# meaning_kept's placeholder when the member's lines grew and its file's text did not change, as after
|
|
28
|
+
# move-member --ending-at, where no line was inserted; it printed INSERTED before.
|
|
29
|
+
SPAN_GREW = NamedPlaceholder.new(
|
|
30
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing; its span grew over lines its file " \
|
|
31
|
+
"already held, which may add a rule",
|
|
32
|
+
before: INSERTED
|
|
33
|
+
) #: NamedPlaceholder
|
|
15
34
|
# The text the answer's template prints in each field the agent judges, which an answer may not send back, so
|
|
16
35
|
# a template returned as printed acknowledges nothing. It prints no quotes, which an answer leaving them
|
|
17
|
-
# out reads as first_changed_lines. After a pure insertion, meaning_kept's
|
|
18
|
-
#
|
|
19
|
-
# Each names the
|
|
20
|
-
# one
|
|
36
|
+
# out reads as first_changed_lines. After a pure insertion, meaning_kept's is INSERTED, or SPAN_GREW when the
|
|
37
|
+
# file's text did not change.
|
|
38
|
+
# Each names the entry it is printed in by its position, M1 the first, so no two members' slots are alike and
|
|
39
|
+
# one edit fills one, short since an edit tool's old_string quotes it whole; the member's id, which may be long
|
|
40
|
+
# and hold quotes, is the entry's key alone. Any entry's, or the text printed before, naming the member's id or
|
|
41
|
+
# neither, is left as printed.
|
|
21
42
|
PLACEHOLDERS = TemplatePlaceholders.new(
|
|
22
|
-
{ "meaning_kept" => NamedPlaceholder.new(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
{ "meaning_kept" => NamedPlaceholder.new(
|
|
44
|
+
"M#{NamedPlaceholder::SLOT}: true only if it still says the same thing",
|
|
45
|
+
before: NamedPlaceholder.new("true only if #{NamedPlaceholder::SLOT} still says the same thing",
|
|
46
|
+
before: "true only if the member still says the same thing")
|
|
47
|
+
),
|
|
48
|
+
"reason" => NamedPlaceholder.new(
|
|
49
|
+
"M#{NamedPlaceholder::SLOT}: why, in one line of your own",
|
|
50
|
+
before: NamedPlaceholder.new("Why, for #{NamedPlaceholder::SLOT}, in one line of your own",
|
|
51
|
+
before: "Why, in one line of your own")
|
|
52
|
+
) },
|
|
53
|
+
also_printed: { "meaning_kept" => { inserted: INSERTED, span_grew: SPAN_GREW } }
|
|
32
54
|
) #: TemplatePlaceholders
|
|
33
55
|
# The text a checked member's template prints where its check's exit status goes, short since the request's
|
|
34
56
|
# context says how to run the check.
|
|
@@ -38,10 +60,13 @@ module Principles
|
|
|
38
60
|
PLACEHOLDERS, exit_status: EXIT_STATUS_PLACEHOLDER
|
|
39
61
|
) #: AcknowledgementLeftAsPrinted
|
|
40
62
|
|
|
41
|
-
# The placeholders the template prints beside quotes, its first_changed_lines
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
# The placeholders the template prints beside quotes, its first_changed_lines, file_unchanged saying whether
|
|
64
|
+
# the member's file holds the same text as at its baseline, so only its span changed.
|
|
65
|
+
#: (Hash[String, String], ?file_unchanged: bool) -> Hash[String, untyped]
|
|
66
|
+
def self.beside(quotes, file_unchanged: false)
|
|
67
|
+
return PLACEHOLDERS.to_h unless quotes["old_line"] == ""
|
|
68
|
+
|
|
69
|
+
PLACEHOLDERS.with_other_text_in("meaning_kept", file_unchanged ? :span_grew : :inserted)
|
|
45
70
|
end
|
|
46
71
|
end
|
|
47
72
|
end
|
|
@@ -98,7 +98,7 @@ module Principles
|
|
|
98
98
|
action = @disposition["action"]
|
|
99
99
|
return if ACTIONS.include?(action)
|
|
100
100
|
|
|
101
|
-
unchosen = action.nil? || DispositionPlaceholders
|
|
101
|
+
unchosen = action.nil? || DispositionPlaceholders.action_left?(action)
|
|
102
102
|
problem = unchosen ? "is not chosen" : "is #{action.inspect}, not one of the four"
|
|
103
103
|
UnfinishedField.new(@place.child("action"), "action",
|
|
104
104
|
problem:, repair: "Set its action to one of fixed, deferred, accepted or disagreed.")
|
|
@@ -28,21 +28,29 @@ module Principles
|
|
|
28
28
|
}.freeze #: Hash[String, DispositionTextField]
|
|
29
29
|
# The placeholder in each field, which the template prints with the disposition's finding in its slot.
|
|
30
30
|
PLACEHOLDERS = TEXT_FIELDS.transform_values { it.placeholder.slotted }.freeze #: Hash[String, String]
|
|
31
|
-
# What action takes,
|
|
32
|
-
#
|
|
33
|
-
# is left unchosen.
|
|
31
|
+
# What action takes, as the correction's template printed it in action before it named the finding: one long
|
|
32
|
+
# sentence of every action's fields, which the agent replaced whole. It is help, never an action, so an answer
|
|
33
|
+
# still sending it is left unchosen.
|
|
34
34
|
ACTION_PLACEHOLDER = "One of fixed, deferred, accepted or disagreed, each with a reason: fixed lists " \
|
|
35
35
|
"changed_members for current text changes, optional removed_members for map removals, " \
|
|
36
36
|
"and evidence and gives a reassessment; deferred gives recorded_at, " \
|
|
37
37
|
"where the write-up is, and may give waits_on; any other action leaves changed_members, " \
|
|
38
38
|
"evidence and reassessment as printed" #: String
|
|
39
|
-
# The action's placeholder
|
|
40
|
-
|
|
39
|
+
# The action's placeholder as it was printed naming the finding, before it named the four choices alone.
|
|
40
|
+
EARLIER_ACTION = NamedPlaceholder.new("For #{NamedPlaceholder::SLOT}, #{ACTION_PLACEHOLDER.sub(/\AO/, "o")}",
|
|
41
|
+
before: ACTION_PLACEHOLDER) #: NamedPlaceholder
|
|
42
|
+
# The action's placeholder, naming the finding and the four choices alone, short enough to replace with one;
|
|
43
|
+
# the answer guide shows each action's fields.
|
|
44
|
+
ACTION = NamedPlaceholder.new("For #{NamedPlaceholder::SLOT}: fixed, deferred, accepted or disagreed",
|
|
41
45
|
before: ACTION_PLACEHOLDER) #: NamedPlaceholder
|
|
42
|
-
# Every placeholder a slot of a correction's template prints, for any finding.
|
|
43
|
-
NAMED = [*TEXT_FIELDS.values.map(&:placeholder), ACTION].freeze #: Array[NamedPlaceholder]
|
|
46
|
+
# Every placeholder a slot of a correction's template prints, for any finding, or printed before.
|
|
47
|
+
NAMED = [*TEXT_FIELDS.values.map(&:placeholder), ACTION, EARLIER_ACTION].freeze #: Array[NamedPlaceholder]
|
|
44
48
|
# Every placeholder a correction's template prints, each text field's and the action's, each with its slot.
|
|
45
49
|
TEMPLATE_PLACEHOLDERS = PLACEHOLDERS.merge("action" => ACTION.slotted).freeze #: Hash[String, String]
|
|
50
|
+
|
|
51
|
+
# Whether action is the action's placeholder, as this release prints it or an earlier one did, for any finding.
|
|
52
|
+
#: (untyped) -> bool
|
|
53
|
+
def self.action_left?(action) = [ACTION, EARLIER_ACTION].any? { it.left?(action) }
|
|
46
54
|
end
|
|
47
55
|
end
|
|
48
56
|
end
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
module Principles
|
|
5
5
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
6
6
|
module Models
|
|
7
|
-
# A placeholder a template prints naming the id of the slot it fills, a member's or a finding's,
|
|
8
|
-
# are alike and a file-edit tool's one-match replace fills one. Its text for any id, or
|
|
9
|
-
#
|
|
7
|
+
# A placeholder a template prints naming the id of the slot it fills, a member's or a finding's, or the slot's
|
|
8
|
+
# position, so no two slots are alike and a file-edit tool's one-match replace fills one. Its text for any id, or
|
|
9
|
+
# the text it printed before, sent in any slot, is left as printed: a plain text, or an earlier NamedPlaceholder
|
|
10
|
+
# with its own earlier text, so an answer filled from any release's template is read alike.
|
|
10
11
|
class NamedPlaceholder
|
|
11
12
|
# The slot in slotted that each slot's id fills.
|
|
12
13
|
SLOT = "%<id>s" #: String
|
|
13
14
|
|
|
14
|
-
# slotted is the text with SLOT where the id goes; before is the text it printed before
|
|
15
|
-
#: (String, before: String) -> void
|
|
15
|
+
# slotted is the text with SLOT where the id goes; before is the text it printed before, plain or named.
|
|
16
|
+
#: (String, before: String | NamedPlaceholder) -> void
|
|
16
17
|
def initialize(slotted, before:)
|
|
17
18
|
@slotted = slotted
|
|
18
19
|
@before = before
|
|
@@ -24,9 +25,18 @@ module Principles
|
|
|
24
25
|
#: String
|
|
25
26
|
attr_reader :slotted
|
|
26
27
|
|
|
27
|
-
# Whether text is this placeholder, for any id or as it was printed before
|
|
28
|
+
# Whether text is this placeholder, for any id or as it was printed before.
|
|
28
29
|
#: (untyped) -> bool
|
|
29
|
-
def left?(text) =
|
|
30
|
+
def left?(text) = (text.is_a?(String) && @pattern.match?(text)) || earlier?(text)
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# Whether text is the placeholder as it was printed before.
|
|
35
|
+
#: (untyped) -> bool
|
|
36
|
+
def earlier?(text)
|
|
37
|
+
earlier = @before
|
|
38
|
+
earlier.is_a?(NamedPlaceholder) ? earlier.left?(text) : text == earlier
|
|
39
|
+
end
|
|
30
40
|
end
|
|
31
41
|
end
|
|
32
42
|
end
|
|
@@ -49,6 +49,15 @@ module Principles
|
|
|
49
49
|
#: (String) -> bool
|
|
50
50
|
def tracks?(path) = !@repository.inside? || @repository.untracked_including_ignored(through_links([path])).empty?
|
|
51
51
|
|
|
52
|
+
# The project's tmp/ folder, by its full path, when it is there and git ignores it, so an answer saved in it is
|
|
53
|
+
# never committed; nil otherwise, outside git too. Asked once for the command.
|
|
54
|
+
#: () -> String?
|
|
55
|
+
def ignored_tmp_folder
|
|
56
|
+
return @ignored_tmp_folder if defined?(@ignored_tmp_folder)
|
|
57
|
+
|
|
58
|
+
@ignored_tmp_folder = ("#{@files.root}/tmp" if @files.folder?("tmp") && @repository.ignores?("tmp/")) #: String?
|
|
59
|
+
end
|
|
60
|
+
|
|
52
61
|
# Whether the project is in git, so it has a history at all.
|
|
53
62
|
#: () -> bool
|
|
54
63
|
def inside_git? = @repository.inside?
|
|
@@ -16,20 +16,21 @@ module Principles
|
|
|
16
16
|
|
|
17
17
|
# placeholders is the text printed in each field, by field name, or for a field that takes pointers, one pointer
|
|
18
18
|
# whose fields hold that text, so the template shows their shape; empty_lists names the fields a template
|
|
19
|
-
# may instead start as an empty list, which is not given either; also_printed, the other
|
|
20
|
-
# may print in a field, refused alike. A NamedPlaceholder in either prints with its
|
|
21
|
-
# with the id of the entry it prints in, and is left as printed for any id.
|
|
22
|
-
#: (Hash[String, untyped], ?empty_lists: Array[String], ?also_printed: Hash[String, untyped])
|
|
19
|
+
# may instead start as an empty list, which is not given either; also_printed, the other texts a template
|
|
20
|
+
# may print in a field, each by a name saying when, refused alike. A NamedPlaceholder in either prints with its
|
|
21
|
+
# slot, which the view fills with the id of the entry it prints in, and is left as printed for any id.
|
|
22
|
+
#: (Hash[String, untyped], ?empty_lists: Array[String], ?also_printed: Hash[String, Hash[Symbol, untyped]])
|
|
23
|
+
#| -> void
|
|
23
24
|
def initialize(placeholders, empty_lists: [], also_printed: {})
|
|
24
25
|
@placeholders = placeholders.freeze #: Hash[String, untyped]
|
|
25
26
|
@empty_lists = empty_lists.freeze #: Array[String]
|
|
26
|
-
@also_printed = also_printed.freeze #: Hash[String, untyped]
|
|
27
|
+
@also_printed = also_printed.freeze #: Hash[String, Hash[Symbol, untyped]]
|
|
27
28
|
freeze
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
# The text printed in each field, with field's other text in place of its own.
|
|
31
|
-
#: (String) -> Hash[String, untyped]
|
|
32
|
-
def with_other_text_in(field) = to_h.merge(field => shown(@also_printed.fetch(field)))
|
|
31
|
+
# The text printed in each field, with field's other text named name in place of its own.
|
|
32
|
+
#: (String, Symbol) -> Hash[String, untyped]
|
|
33
|
+
def with_other_text_in(field, name) = to_h.merge(field => shown(@also_printed.fetch(field).fetch(name)))
|
|
33
34
|
|
|
34
35
|
# Each placeholder printed in its own field naming its entry's id; a field's other text is printed only by
|
|
35
36
|
# some of its requests, so another template leaving it is not read as this one's.
|
|
@@ -73,7 +74,7 @@ module Principles
|
|
|
73
74
|
# Whether value is a text the template prints in field.
|
|
74
75
|
#: (String, untyped) -> bool
|
|
75
76
|
def printed?(field, value)
|
|
76
|
-
[@placeholders[field],
|
|
77
|
+
[@placeholders[field], *@also_printed.fetch(field, {}).values].compact.any? do |printed|
|
|
77
78
|
printed.is_a?(NamedPlaceholder) ? printed.left?(value) : printed == value
|
|
78
79
|
end
|
|
79
80
|
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.1.
|
|
6
|
+
RELEASE = "0.1.3"
|
|
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.1.
|
|
10
|
+
BUILT_VERSION = "0.1.3" #: String?
|
|
11
11
|
end
|
|
@@ -11,7 +11,7 @@ module Principles
|
|
|
11
11
|
module Views
|
|
12
12
|
# A one-member audit's request and its result.
|
|
13
13
|
class AcknowledgementResult
|
|
14
|
-
# Where a placeholder names the
|
|
14
|
+
# Where a placeholder names the entry it prints in, by its position in the template's members, 1 the first.
|
|
15
15
|
SLOT = "%<id>s" #: String
|
|
16
16
|
|
|
17
17
|
#: (Invocation) -> void
|
|
@@ -43,7 +43,7 @@ module Principles
|
|
|
43
43
|
def answer_to_fill(request_id:, asked:)
|
|
44
44
|
member_id = asked.fetch(:change).member_id
|
|
45
45
|
{ "request_id" => request_id, "basis" => { "member_ids" => [member_id] },
|
|
46
|
-
"members" => { member_id => named(asked.fetch(:placeholders),
|
|
46
|
+
"members" => { member_id => named(asked.fetch(:placeholders), 1) } }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# The request for several members' acknowledgements in one answer: each of members holds a member's
|
|
@@ -66,7 +66,7 @@ module Principles
|
|
|
66
66
|
#: (request_id: String, members: Array[Hash[Symbol, untyped]]) -> Hash[String, untyped]
|
|
67
67
|
def several_to_fill(request_id:, members:)
|
|
68
68
|
{ "request_id" => request_id, "basis" => { "member_ids" => members.map { it.fetch(:change).member_id } },
|
|
69
|
-
"members" => members.to_h { named_entry(
|
|
69
|
+
"members" => members.each_with_index.to_h { |asked, index| named_entry(asked, index + 1) } }
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# The request for the members several principles map in one answer: under context.principles, each
|
|
@@ -91,28 +91,35 @@ module Principles
|
|
|
91
91
|
# print the same field.
|
|
92
92
|
#: (request_id: String, principles: Hash[String, Array[Hash[Symbol, untyped]]]) -> Hash[String, untyped]
|
|
93
93
|
def across_to_fill(request_id:, principles:)
|
|
94
|
-
entries = principles
|
|
95
|
-
id = asked.fetch(:change).member_id
|
|
96
|
-
by_member[id] = named(asked.fetch(:placeholders), id).merge(by_member.fetch(id, {}))
|
|
97
|
-
end
|
|
94
|
+
entries = across_entries(principles)
|
|
98
95
|
{ "request_id" => request_id, "basis" => { "principle_ids" => principles.keys, "member_ids" => entries.keys },
|
|
99
96
|
"members" => entries }
|
|
100
97
|
end
|
|
101
98
|
|
|
102
99
|
private
|
|
103
100
|
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#: (Hash[String, untyped]
|
|
107
|
-
def
|
|
101
|
+
# One entry per member the principles' requests ask about, by its id, with every field any principle's template
|
|
102
|
+
# prints for it, the first principle's text where two print the same field, its placeholders naming its position.
|
|
103
|
+
#: (Hash[String, Array[Hash[Symbol, untyped]]]) -> Hash[String, Hash[String, untyped]]
|
|
104
|
+
def across_entries(principles)
|
|
105
|
+
ids = across_member_ids(principles)
|
|
106
|
+
principles.values.flatten.each_with_object({}) do |asked, by_member|
|
|
107
|
+
id = asked.fetch(:change).member_id
|
|
108
|
+
by_member[id] = named(asked.fetch(:placeholders), ids.index(id).to_i + 1).merge(by_member.fetch(id, {}))
|
|
109
|
+
end
|
|
110
|
+
end
|
|
108
111
|
|
|
109
|
-
#
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
# placeholders with each one's SLOT naming the entry's position, as its entry in the template prints them; any
|
|
113
|
+
# other text, a percent sign included, as it is.
|
|
114
|
+
#: (Hash[String, untyped], Integer) -> Hash[String, untyped]
|
|
115
|
+
def named(placeholders, position)
|
|
116
|
+
placeholders.transform_values { it.is_a?(String) ? it.gsub(SLOT, position.to_s) : it }
|
|
114
117
|
end
|
|
115
118
|
|
|
119
|
+
# The template's entry for the member asked asks about, by its id, its placeholders naming its position.
|
|
120
|
+
#: (Hash[Symbol, untyped], Integer) -> [String, Hash[String, untyped]]
|
|
121
|
+
def named_entry(asked, position) = [asked.fetch(:change).member_id, named(asked.fetch(:placeholders), position)]
|
|
122
|
+
|
|
116
123
|
# How to fill the answer to request_id, acknowledging member_ids of principle_ids: saved bare from
|
|
117
124
|
# start-audit --as template to a file the agent edits.
|
|
118
125
|
#: (Array[String], Array[String], request_id: String) -> String
|
|
@@ -9,7 +9,7 @@ require_relative "shell_word"
|
|
|
9
9
|
module Principles
|
|
10
10
|
# What this tool prints, from plain values a controller hands it. views/CLAUDE.md owns the boundary.
|
|
11
11
|
module Views
|
|
12
|
-
# How to fill an answer this tool prints bare: save it to a file
|
|
12
|
+
# How to fill an answer this tool prints bare: save it to a file kept out of git, named in full, fill it
|
|
13
13
|
# there with the agent's own file-edit tool, and submit that file, with the three characters JSON escapes.
|
|
14
14
|
# Filling a template in a shell heredoc took a script, since prose full of quotes needed escaping for the shell
|
|
15
15
|
# and for JSON.
|
|
@@ -76,7 +76,7 @@ module Principles
|
|
|
76
76
|
assessment_id = acceptable.fetch("request_id")
|
|
77
77
|
file = invocation.answer_file(request_id)
|
|
78
78
|
save = "Once this answer is submitted with the last line's command, save the correction's answer it leads " \
|
|
79
|
-
"to in a file
|
|
79
|
+
"to in a file kept out of git, at this full path, the same from every shell, from this command's " \
|
|
80
80
|
"output: #{alone(assessment_id, answer_file, invocation)} > #{ShellWord.new(file)}\nFill only its " \
|
|
81
81
|
"dispositions, and submit it: #{invocation.submit_answer(request_id, file:)}"
|
|
82
82
|
acceptable.merge("correction_recovery" => recovery(invocation),
|
|
@@ -27,7 +27,6 @@ module Principles
|
|
|
27
27
|
{ "principle" => id,
|
|
28
28
|
"brief" => Prompts.text("run-a-first-audit-in-the-background/follow-the-brief",
|
|
29
29
|
id: id, answer_file: ShellWord.new(@invocation.answer_file(id)).to_s,
|
|
30
|
-
project_root: @invocation.project,
|
|
31
30
|
index: @invocation.in_project("start-audit", id, options: ["--part", "index"]),
|
|
32
31
|
template: @invocation.in_project("start-audit", id, options: ["--as", "template"])),
|
|
33
32
|
"wrote" => [] }
|
|
@@ -16,7 +16,8 @@ module Principles
|
|
|
16
16
|
attr_reader :project
|
|
17
17
|
|
|
18
18
|
# named says whether each command names the project; without_project leaves it out. temp_directory is the
|
|
19
|
-
#
|
|
19
|
+
# folder a printed next step saves an answer in: the project's ignored tmp/ when it has one, else the temporary
|
|
20
|
+
# folder the running tool was given.
|
|
20
21
|
#: (executable: String, project: String, temp_directory: String, ?named: bool) -> void
|
|
21
22
|
def initialize(executable:, project:, temp_directory:, named: true)
|
|
22
23
|
@executable = executable
|
|
@@ -59,8 +60,8 @@ module Principles
|
|
|
59
60
|
in_project("submit-answer", request_id, options: ["--file", file])
|
|
60
61
|
end
|
|
61
62
|
|
|
62
|
-
# The file to save the answer name names in, a request id or a principle id, by its full path in
|
|
63
|
-
#
|
|
63
|
+
# The file to save the answer name names in, a request id or a principle id, by its full path in temp_directory,
|
|
64
|
+
# so every shell that runs the printed commands names the same file: a sandboxed and an unsandboxed one
|
|
64
65
|
# read $TMPDIR as different folders.
|
|
65
66
|
#: (String) -> String
|
|
66
67
|
def answer_file(name) = "#{@temp_directory.chomp("/")}/principles-#{name}-answer.json"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Save the answer alone in a file
|
|
1
|
+
Save the answer alone in a file kept out of git, at this full path, the same from every shell: %{save}
|
|
2
2
|
|
|
3
3
|
Fill %{what} with your own file-edit tool, not a shell heredoc; JSON escapes only a double quote, a backslash and a line
|
|
4
4
|
break, as \", \\ and \n, never an apostrophe.
|
data/lib/principles/views/prompts/dispose-of-each-finding/retain-assessment-and-correction.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Keep a copy of the assessment you submit
|
|
1
|
+
Keep a copy of the assessment you submit where git never commits it (for `--file -`, its exact stdin bytes) until this
|
|
2
2
|
correction completes the audit: the open record keeps it, and only that copy rebuilds it if the record is lost.
|
|
3
3
|
Once the assessment is submitted, print this correction's answer again at any time, in git or outside it and after
|
|
4
4
|
fixes too, with this read-only command:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Checks your answer, to the request its `request_id` or REQUEST_ID names, as `submit-answer` would; writes nothing.
|
|
2
2
|
It prints the refusal `submit-answer` would give, such as a passage that matches twice, or `answer_acceptable`
|
|
3
3
|
with the files submitting would write. Use it instead of searching the project yourself before you submit. Pass
|
|
4
|
-
`--file FILE`, naming the answer written to a FILE
|
|
4
|
+
`--file FILE`, naming the answer written to a FILE kept out of git; `--file -` reads it from stdin instead.
|
|
5
5
|
Its `next_action` ends with `submit-answer`, giving the same `--file` value again.
|
|
6
6
|
|
|
7
7
|
The same current-ID history checks apply to assessment/correction answers with a Git base. For their
|
|
@@ -36,8 +36,8 @@ is allowed when there is nowhere to point, and then `list-open-findings` prints
|
|
|
36
36
|
When a full audit's assessment has findings, `next_action` names the command that prints the correction's answer
|
|
37
37
|
it leads to, `--as template`, with its `request_id` and the `basis` digests filled in, so you never copy them by
|
|
38
38
|
hand; `show-open-correction ID` prints the same answer once the assessment is submitted. Redirect it to the file
|
|
39
|
-
`next_action` names by its full path,
|
|
40
|
-
and what each adds. Submit it after the assessment, as `next_action` says; the assessment writes the open record the
|
|
39
|
+
`next_action` names by its full path, kept out of git, and fill only its `dispositions`: each `action` names the four actions,
|
|
40
|
+
and the answer guide shows what each adds. Submit it after the assessment, as `next_action` says; the assessment writes the open record the
|
|
41
41
|
correction is checked against. `--as template` refuses with `no_correction_to_fill` an answer that leads to none.
|
|
42
42
|
|
|
43
43
|
`correction_recovery` says to keep a copy of the assessment you submit, or for `--file -` its exact stdin bytes,
|
|
@@ -3,7 +3,7 @@ Prints the answer to fill for the correction a full audit's assessment with find
|
|
|
3
3
|
again. It reads principle ID's open audit record and writes nothing.
|
|
4
4
|
|
|
5
5
|
It prints the correction's answer alone: its `request_id` and `basis`, which you hand back unchanged, and one disposition for each finding to fill.
|
|
6
|
-
Redirect it to the file `submit-answer`'s `next_action` names by its full path,
|
|
6
|
+
Redirect it to the file `submit-answer`'s `next_action` names by its full path, kept out of git, fill only
|
|
7
7
|
its `dispositions`, and submit it with `submit-answer --file` and that path. It prints the same answer in git and outside it, and still
|
|
8
8
|
after you fix members, which leaves the correction current; `submit-answer` checks it as usual.
|
|
9
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Gives your answer, filled from its template, to the request its `request_id` names; a REQUEST_ID you give must
|
|
2
|
-
match. Pass a JSON FILE
|
|
2
|
+
match. Pass a JSON FILE kept out of git with `--file FILE`; `--file -` reads stdin. This tool writes audit records
|
|
3
3
|
at `.principles/audits/ID.json`, never member guidance. In a full audit, make each fix after the assessment is accepted
|
|
4
4
|
and before you submit the correction that reports it; earlier fixes cause `stale_request` before an assessment's shape
|
|
5
5
|
check. A completed full audit or acknowledgement after an assessment/correction request causes
|
|
@@ -6,7 +6,7 @@ at a pause, since principles would ask.
|
|
|
6
6
|
2. Read the request in parts, which costs about the bytes of the whole request and its member files. Type
|
|
7
7
|
part_command and then the part as printed, never in a shell variable. Its parts: %{index}
|
|
8
8
|
|
|
9
|
-
3. Keep every answer file at %{answer_file},
|
|
9
|
+
3. Keep every answer file at %{answer_file}, nowhere else. Redirect the template
|
|
10
10
|
below there and edit it, running each member check the request names and no script over this output.
|
|
11
11
|
Check it with show-answer-check, then submit-answer, each with --file and that path; answer a
|
|
12
12
|
correction the same way. On a stale_request refusal, start once more. Its template: %{template}
|