principles 0.0.11 → 0.1.0
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 +31 -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/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/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/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 +13 -1
- data/lib/principles/models/project.rb +8 -3
- data/lib/principles/models/project_at_commit.rb +9 -19
- 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 +9 -4
- 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/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 +14 -7
- 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/repoint-write-ups/point-each-moved-write-up-at-its-new-place.md +0 -10
- data/lib/principles/views/repoint_result.rb +0 -80
|
@@ -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 = "53dd20cf" #: 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,
|
|
@@ -277,6 +277,21 @@
|
|
|
277
277
|
"query": { "type": "string" }
|
|
278
278
|
}
|
|
279
279
|
},
|
|
280
|
+
"changed_since_audit": {
|
|
281
|
+
"type": "array",
|
|
282
|
+
"description": "Each change a decision on this open finding made since the full audit that kept it: the field, its value before and after, when and why. Only principles writes it.",
|
|
283
|
+
"items": {
|
|
284
|
+
"type": "object",
|
|
285
|
+
"required": ["field", "from", "to", "at", "reason"],
|
|
286
|
+
"properties": {
|
|
287
|
+
"field": { "type": "string", "enum": ["waits_on", "action", "recorded_at"] },
|
|
288
|
+
"from": {},
|
|
289
|
+
"to": {},
|
|
290
|
+
"at": { "type": "string", "minLength": 1 },
|
|
291
|
+
"reason": { "type": "string", "minLength": 1 }
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
280
295
|
"repointed": {
|
|
281
296
|
"type": "array",
|
|
282
297
|
"description": "Each repoint of recorded_at since the full audit that kept this finding: where it pointed, where it points, when and why. Only principles writes it.",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"usage": { "$ref": "#/$defs/prose" },
|
|
73
73
|
"group": { "$ref": "#/$defs/slug" },
|
|
74
74
|
"options": { "type": "array", "uniqueItems": true,
|
|
75
|
-
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "confirm", "lines", "open-findings", "history"] } },
|
|
75
|
+
"items": { "enum": ["description", "path", "section", "starting-at", "ending-at", "query", "role", "check", "file", "short", "session-start", "commits-after", "hook-event", "member", "when-files", "when-invoked", "always", "write-ups", "as", "instruction", "part", "also", "only", "confirm", "lines", "open-findings", "history"] } },
|
|
76
76
|
"requires": { "type": "array", "uniqueItems": true, "items": { "enum": ["file"] } },
|
|
77
77
|
"summary": { "$ref": "#/$defs/prose" },
|
|
78
78
|
"help": { "type": "string", "pattern": "^[a-z]+(-[a-z]+)+/[a-z]+(-[a-z]+)+$" },
|
data/lib/principles/data/schemas/{repointing-answer.schema.json → deciding-answer.schema.json}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "
|
|
4
|
-
"title": "
|
|
5
|
-
"description": "What an agent answers
|
|
3
|
+
"$id": "deciding-answer.schema.json",
|
|
4
|
+
"title": "Deciding answer",
|
|
5
|
+
"description": "What an agent answers start-audit ID --open-findings with: the request's id and basis, then a decision per open finding it names, giving only the fields that change and a one-line reason. A field left out keeps its value. Fields this tool does not read are refused. Models::FindingDecision checks each decision.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"additionalProperties": false,
|
|
8
|
-
"required": ["request_id", "basis", "
|
|
8
|
+
"required": ["request_id", "basis", "decisions"],
|
|
9
9
|
"properties": {
|
|
10
10
|
"request_id": { "type": "string" },
|
|
11
11
|
"basis": {
|
|
@@ -16,14 +16,20 @@
|
|
|
16
16
|
"revision": { "type": ["string", "null"] }
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"
|
|
19
|
+
"decision_fields": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"description": "The note start-audit ID --open-findings --as template prints at its head naming each field a decision may give and what it means, which an answer may send back and Models::OpenFindingsDecision ignores, whatever it holds."
|
|
22
|
+
},
|
|
23
|
+
"decisions": {
|
|
20
24
|
"type": "array",
|
|
21
25
|
"items": {
|
|
22
26
|
"type": "object",
|
|
23
27
|
"additionalProperties": false,
|
|
24
|
-
"required": ["finding_id"
|
|
28
|
+
"required": ["finding_id"],
|
|
25
29
|
"properties": {
|
|
26
30
|
"finding_id": { "type": "string", "minLength": 1 },
|
|
31
|
+
"action": { "type": "string" },
|
|
32
|
+
"waits_on": { "type": ["string", "null"] },
|
|
27
33
|
"recorded_at": {
|
|
28
34
|
"type": ["object", "null"],
|
|
29
35
|
"required": ["path"],
|
|
@@ -14,7 +14,7 @@ module Principles
|
|
|
14
14
|
FLAG_OPTIONS = %w[short lines when-invoked always write-ups confirm open-findings history].freeze #: Array[String]
|
|
15
15
|
# The options that may be given more than once, each value kept in order, as change-activation --when-files and
|
|
16
16
|
# start-audit --member and --part.
|
|
17
|
-
LIST_OPTIONS = %w[when-files also member part].freeze #: Array[String]
|
|
17
|
+
LIST_OPTIONS = %w[when-files also only member part].freeze #: Array[String]
|
|
18
18
|
# The words that name an option taking the next word as its value.
|
|
19
19
|
VALUE_WORDS = (VALUE_OPTIONS + LIST_OPTIONS).map { |name| "--#{name}" }.freeze #: Array[String]
|
|
20
20
|
# Every word the parser reads as an option, which an option taking a value refuses as its value.
|
data/lib/principles/launch.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require "tmpdir"
|
|
4
5
|
require_relative "version"
|
|
5
6
|
require_relative "data/running_version"
|
|
6
7
|
require_relative "data/principles_on_path"
|
|
@@ -8,8 +9,8 @@ require_relative "controllers/running_tool"
|
|
|
8
9
|
|
|
9
10
|
module Principles
|
|
10
11
|
# This process as its entry point launched it: the executable that entry point names itself by, the file it was
|
|
11
|
-
# launched as, PATH
|
|
12
|
-
# the same RunningTool.
|
|
12
|
+
# launched as, PATH, the folder it started in and its temporary folder, read here so that no layer reads them. It
|
|
13
|
+
# gives every controller the same RunningTool.
|
|
13
14
|
class Launch
|
|
14
15
|
#: (String) -> void
|
|
15
16
|
def initialize(executable)
|
|
@@ -24,7 +25,8 @@ module Principles
|
|
|
24
25
|
Controllers::RunningTool.new(executable: @executable, version: -> { running_version },
|
|
25
26
|
other_on_path: ->(asking) { on_path.other(asking) },
|
|
26
27
|
launched_on_path: -> { on_path.own_first? },
|
|
27
|
-
cwd: started_in
|
|
28
|
+
folders: Controllers::RunningTool::Folders.new(cwd: started_in,
|
|
29
|
+
temp_directory: Dir.tmpdir))
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
private
|
|
@@ -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 host hands its hook after each shell call, as report-after-commit reads it: the event it ran on,
|
|
9
10
|
# when the call started, and the directories whose repositories the call may have committed in. Input it cannot
|
|
@@ -5,7 +5,7 @@ require_relative "audit_record"
|
|
|
5
5
|
require_relative "last_completed_revision"
|
|
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
|
# What an assessment request prints as its basis, which the agent hands back with the answer: the commit the
|
|
11
11
|
# audit is based on, nil outside git, and the revision of the last completed audit record when the request was
|
|
@@ -17,6 +17,7 @@ require_relative "prior_findings"
|
|
|
17
17
|
require_relative "decided_prior_findings"
|
|
18
18
|
require_relative "disposition"
|
|
19
19
|
require_relative "stale_request"
|
|
20
|
+
require_relative "map_change"
|
|
20
21
|
|
|
21
22
|
module Principles
|
|
22
23
|
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
@@ -61,14 +62,18 @@ module Principles
|
|
|
61
62
|
# now, and, in git, the members are as its base holds them (committed).
|
|
62
63
|
# It returns the findings the last audit, whose record is given, left for this one to decide; loads is
|
|
63
64
|
# what the audit lists to check now, so a change to what lists a member to check makes the request stale.
|
|
65
|
+
# The block gives the map at the base commit, nil when it cannot be read, asked only for a request that no
|
|
66
|
+
# longer matches, so the refusal names a change to the map when that map explains it.
|
|
64
67
|
#: (RequestId, basis: AssessmentBasis, committed: Hash[String, String]?, record: AuditRecord?,
|
|
65
|
-
#| loads: LoadsToCheck) -> PriorFindings
|
|
66
|
-
def check_assessment_request(request_id, basis:, committed:, record:, loads
|
|
68
|
+
#| loads: LoadsToCheck) ?{ () -> Principle? } -> PriorFindings
|
|
69
|
+
def check_assessment_request(request_id, basis:, committed:, record:, loads:, &started_from)
|
|
67
70
|
prior = prior_findings(record)
|
|
68
71
|
now_id = assessment_id(basis, prior.digested, loads.listed)
|
|
69
72
|
return prior if now_id == request_id && (basis.base.nil? || committed == @now)
|
|
70
73
|
|
|
71
|
-
raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false
|
|
74
|
+
raise StaleRequest.new(id, changed_since(committed), correction_open: record&.open? || false,
|
|
75
|
+
map_change: map_change(request_id, basis, record, loads,
|
|
76
|
+
started_from)).refusal
|
|
72
77
|
end
|
|
73
78
|
|
|
74
79
|
# The answer to this audit's assessment request, checked against each member, each member's check
|
|
@@ -216,6 +221,21 @@ module Principles
|
|
|
216
221
|
|
|
217
222
|
#: () -> Error
|
|
218
223
|
def stale_request = StaleRequest.new(id).refusal
|
|
224
|
+
|
|
225
|
+
# How the map differs from the one started_from gives, when the request was printed from that map with the
|
|
226
|
+
# members as they are now; nil when there is no such map, it is this one, it does not give request_id, or the
|
|
227
|
+
# change names nothing.
|
|
228
|
+
#: (RequestId, AssessmentBasis, AuditRecord?, LoadsToCheck, (^() -> Principle?)?) -> MapChange?
|
|
229
|
+
def map_change(request_id, basis, record, loads, started_from)
|
|
230
|
+
base = started_from&.call
|
|
231
|
+
return unless base && base.version != map_version
|
|
232
|
+
|
|
233
|
+
printed = Audit.new(map: base, now: @now)
|
|
234
|
+
return unless printed.assessment_id(basis, printed.prior_findings(record).digested, loads.listed) == request_id
|
|
235
|
+
|
|
236
|
+
change = MapChange.new(base, @map)
|
|
237
|
+
change unless change.empty?
|
|
238
|
+
end
|
|
219
239
|
end
|
|
220
240
|
end
|
|
221
241
|
end
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require_relative "../error"
|
|
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
|
# A current audit entry protects its map from unconfirmed removal, whether the entry is readable or not.
|
|
9
10
|
class AuditEntryProtectingMap
|
|
@@ -10,7 +10,7 @@ require_relative "recorded_findings"
|
|
|
10
10
|
require_relative "record_format"
|
|
11
11
|
require_relative "recorded_members"
|
|
12
12
|
require_relative "json_digest"
|
|
13
|
-
require_relative "
|
|
13
|
+
require_relative "finding_decision"
|
|
14
14
|
require_relative "../data/schema_check"
|
|
15
15
|
|
|
16
16
|
module Principles
|
|
@@ -183,19 +183,10 @@ module Principles
|
|
|
183
183
|
AuditRecord.new(@fields.merge("members" => members.acknowledged(key, change, check_result:).to_h))
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
-
# This record with each
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
AuditRecord.new(@fields.merge("findings" => findings.repointed(repoints, at: at).to_a))
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# The ids of the findings it leaves open whose recorded_at points elsewhere than earlier's did, as a repoint
|
|
194
|
-
# moved them.
|
|
195
|
-
#: (AuditRecord) -> Array[String]
|
|
196
|
-
def write_ups_moved_since(earlier)
|
|
197
|
-
before = earlier.left_open.to_h { |finding| [finding.id, finding.recorded_at] }
|
|
198
|
-
left_open.select { |finding| before.key?(finding.id) && before[finding.id] != finding.recorded_at }.map(&:id)
|
|
186
|
+
# This record with each decision applied at at to the finding it names.
|
|
187
|
+
#: (Array[FindingDecision], at: String) -> AuditRecord
|
|
188
|
+
def decided(decisions, at:)
|
|
189
|
+
AuditRecord.new(@fields.merge("findings" => findings.decided(decisions, at: at).to_a))
|
|
199
190
|
end
|
|
200
191
|
|
|
201
192
|
# Each finding the last completed audit deferred or accepted, which the next full audit must decide:
|
|
@@ -97,7 +97,7 @@ module Principles
|
|
|
97
97
|
#: (String) -> RecordedHashes
|
|
98
98
|
def hashes_to_compare(id)
|
|
99
99
|
audit = find(id) or return RecordedHashes::NONE
|
|
100
|
-
|
|
100
|
+
audit.members.hashes(waiting: RecordFormat.new(audit.to_h).newer?)
|
|
101
101
|
rescue RecordFormat::NewerFormatError
|
|
102
102
|
RecordedHashes.new(member_hashes_as_written(id).by_key, waiting: true)
|
|
103
103
|
end
|
|
@@ -7,7 +7,7 @@ require_relative "located_text"
|
|
|
7
7
|
require_relative "line_span"
|
|
8
8
|
|
|
9
9
|
module Principles
|
|
10
|
-
# The domain logic,
|
|
10
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
11
|
module Models
|
|
12
12
|
# The lines a full audit's members span now, each with its file, against which each evidence item of another
|
|
13
13
|
# principle's open finding is said to share lines or not. These are lines, not a verdict on whether
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require_relative "candidate_outline"
|
|
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 instruction files list-candidate-files offers, shortened without judging what is guidance. A
|
|
10
10
|
# skill's templates, references and examples once filled most of a 10KB inventory (alpha 011
|
|
@@ -9,7 +9,7 @@ require_relative "project_history"
|
|
|
9
9
|
require_relative "survey_search_paths"
|
|
10
10
|
|
|
11
11
|
module Principles
|
|
12
|
-
# The domain logic,
|
|
12
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
13
13
|
module Models
|
|
14
14
|
# What list-candidate-files found: the inventory of candidate files as it lists them, and in git
|
|
15
15
|
# which of them, or of the files their links lead to, git does not track. Each list that names a file is
|
|
@@ -32,9 +32,10 @@ module Principles
|
|
|
32
32
|
def self.read(files, history, search_paths:, after: nil, mapped: [])
|
|
33
33
|
changed = after ? history.changed_after(after) : []
|
|
34
34
|
inventory = files.inventory(also: changed.grep(CandidateFiles::MARKDOWN) | (changed & mapped),
|
|
35
|
-
matching: search_paths.globs
|
|
35
|
+
matching: search_paths.globs, conventional: search_paths.conventional?)
|
|
36
|
+
inventory = inventory.merge(search_paths.recorded_listing)
|
|
36
37
|
inventory = inventory.merge("uncommitted" => uncommitted_markdown(history)) if after
|
|
37
|
-
found(inventory, history, changed:) { |path| files.read_text(path) }
|
|
38
|
+
found(inventory, history, changed:, conventional: search_paths.conventional?) { |path| files.read_text(path) }
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
# An explicit file request uses the survey's entries and budget without its broad search.
|
|
@@ -52,15 +53,16 @@ module Principles
|
|
|
52
53
|
# git does not track.
|
|
53
54
|
# Each listed file's text, which its outline is read from, is what the block gives for its path.
|
|
54
55
|
# changed names the files a range of commits changed, which list first, marked.
|
|
55
|
-
#: (Hash[String, untyped], ProjectHistory, ?changed: Array[String]) { (String) -> String }
|
|
56
|
-
|
|
56
|
+
#: (Hash[String, untyped], ProjectHistory, ?changed: Array[String], ?conventional: bool) { (String) -> String }
|
|
57
|
+
#| -> CandidateInventory
|
|
58
|
+
def self.found(inventory, history, changed: [], conventional: true, &text_of)
|
|
57
59
|
texts = {} #: Hash[String, String]
|
|
58
60
|
files = CandidateFiles.new(inventory.fetch("files"), selected: inventory.fetch("selected_files", []),
|
|
59
61
|
text_of: ->(path) { texts[path] ||= text_of.call(path) })
|
|
60
62
|
hints = inventory.fetch("possibly_test_data")
|
|
61
63
|
listed = listed(inventory, files.listing(hints, changed:))
|
|
62
64
|
new(listed, untracked: history.untracked_excluding_ignored(listed.fetch("files").map { it.fetch("path") }),
|
|
63
|
-
outlines: files.outlines(hints))
|
|
65
|
+
outlines: files.outlines(hints), conventional:)
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
# The inventory as list-candidate-files lists it: the instruction files agent hosts load by convention, the other
|
|
@@ -86,11 +88,13 @@ module Principles
|
|
|
86
88
|
attr_reader :untracked
|
|
87
89
|
|
|
88
90
|
# outlines holds each outlined file's outline, by path, which within_budget cuts by.
|
|
89
|
-
#: (Hash[String, untyped], untracked: Array[String]?, ?outlines: Hash[String, CandidateOutline]
|
|
90
|
-
|
|
91
|
+
#: (Hash[String, untyped], untracked: Array[String]?, ?outlines: Hash[String, CandidateOutline],
|
|
92
|
+
#| ?conventional: bool) -> void
|
|
93
|
+
def initialize(listing, untracked:, outlines: {}, conventional: true)
|
|
91
94
|
@listing = listing
|
|
92
95
|
@untracked = untracked
|
|
93
96
|
@outlines = outlines
|
|
97
|
+
@conventional = conventional
|
|
94
98
|
@lists = listing.merge("untracked" => untracked) #: Hash[String, untyped]
|
|
95
99
|
freeze
|
|
96
100
|
end
|
|
@@ -98,6 +102,10 @@ module Principles
|
|
|
98
102
|
#: () -> Hash[String, untyped]
|
|
99
103
|
def to_h = @listing
|
|
100
104
|
|
|
105
|
+
# Whether the survey looked in the places hosts load by convention, as it does unless --only narrowed it.
|
|
106
|
+
#: () -> bool
|
|
107
|
+
def conventional? = @conventional
|
|
108
|
+
|
|
101
109
|
# This inventory with its files' list items cut to OutlineBudget, the block giving the bytes each inventory tried
|
|
102
110
|
# prints as.
|
|
103
111
|
#: () { (CandidateInventory) -> Integer } -> CandidateInventory
|
|
@@ -118,7 +126,9 @@ module Principles
|
|
|
118
126
|
private
|
|
119
127
|
|
|
120
128
|
#: (Hash[String, untyped]) -> CandidateInventory
|
|
121
|
-
def with(listing)
|
|
129
|
+
def with(listing)
|
|
130
|
+
CandidateInventory.new(listing, untracked: @untracked, outlines: @outlines, conventional: @conventional)
|
|
131
|
+
end
|
|
122
132
|
|
|
123
133
|
# The path one list entry names: a file's path, a folder, or the path itself.
|
|
124
134
|
#: (untyped) -> String
|
|
@@ -8,7 +8,7 @@ require_relative "outline_section"
|
|
|
8
8
|
require_relative "text_within"
|
|
9
9
|
|
|
10
10
|
module Principles
|
|
11
|
-
# The domain logic,
|
|
11
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
12
12
|
module Models
|
|
13
13
|
# One candidate file's outline, as the survey reads it in place of the file: its Markdown headings in order, and
|
|
14
14
|
# under each its top-level list items. One user scripted a heading grep over 45 files to survey them,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require_relative "line_diff"
|
|
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
|
# A long member's changed lines as a request shows them: each run of changed lines with up to context unchanged
|
|
10
10
|
# lines around it, as git shows a hunk, runs whose context would meet joined into one region, and each later
|
|
@@ -5,8 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "../data/command_steps_file"
|
|
6
6
|
|
|
7
7
|
module Principles
|
|
8
|
-
#
|
|
9
|
-
# boundary.
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
10
9
|
module Models
|
|
11
10
|
# The steps each command runs: which are this tool's and which are the agent's, the refusals each of
|
|
12
11
|
# this tool's steps can raise, and where each step leads. Each command's --help and the workflow diagram
|
|
@@ -8,7 +8,7 @@ require_relative "last_completed_revision"
|
|
|
8
8
|
require_relative "recorded_finding"
|
|
9
9
|
|
|
10
10
|
module Principles
|
|
11
|
-
# The domain logic,
|
|
11
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
12
12
|
module Models
|
|
13
13
|
# What a correction request depends on, which it prints as its basis and the agent hands back with the answer:
|
|
14
14
|
# the base commit, the map's version, each finding's members and problem, what the assessment reported beyond its
|
|
@@ -7,8 +7,7 @@ require_relative "member_moves"
|
|
|
7
7
|
require_relative "declared_member_removals"
|
|
8
8
|
|
|
9
9
|
module Principles
|
|
10
|
-
# The domain
|
|
11
|
-
# models/CLAUDE.md owns the boundary.
|
|
10
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
12
11
|
module Models
|
|
13
12
|
# The changes a correction declares it made to the map after the audit began: the members it moved,
|
|
14
13
|
# and the members whose role or check a fix changed, which each fixed disposition lists in
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "../error"
|
|
5
|
+
require_relative "answer_place"
|
|
6
|
+
require_relative "answer_text"
|
|
7
|
+
require_relative "recorded_finding"
|
|
8
|
+
require_relative "waits_on"
|
|
9
|
+
require_relative "write_up_pointer"
|
|
10
|
+
|
|
11
|
+
module Principles
|
|
12
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
13
|
+
module Models
|
|
14
|
+
# One decision an answer to start-audit --open-findings gives on an open finding, between full audits: only the
|
|
15
|
+
# fields that change, each kept beside the finding with when and why. Whether the change is right is the agent's
|
|
16
|
+
# judgement; this tool checks its shape.
|
|
17
|
+
class FindingDecision
|
|
18
|
+
# The actions a decision may leave its finding at: those that keep it open. Closing it judges the problem
|
|
19
|
+
# against the text now, which is a full audit's work.
|
|
20
|
+
OPEN_ACTIONS = %w[deferred accepted].freeze #: Array[String]
|
|
21
|
+
|
|
22
|
+
# Each field a decision may give beside its finding_id, with its one-line meaning, which the template of
|
|
23
|
+
# start-audit --open-findings prints at its head in decision_fields, where an agent filling it reads.
|
|
24
|
+
FIELDS = {
|
|
25
|
+
"waits_on" => "One line, on a deferred finding only: whom it now waits on and to decide what. Or null, " \
|
|
26
|
+
"even on a deferred finding, to drop it.",
|
|
27
|
+
"action" => "deferred or accepted, as when the owner rules; its reason becomes the finding's own.",
|
|
28
|
+
"recorded_at" => "Where its write-up is now, in a committed file: {\"path\": ..., \"heading\": ...}, or null.",
|
|
29
|
+
"reason" => "One line saying why, required with any change. A field left out keeps its value; " \
|
|
30
|
+
"decision_fields may be kept or deleted."
|
|
31
|
+
}.freeze #: Hash[String, String]
|
|
32
|
+
|
|
33
|
+
# decision is one entry of the answer's decisions, at place in the answer, on a finding of principle_id's;
|
|
34
|
+
# recorded_at is its new pointer, already located, or nil when it gives none or null.
|
|
35
|
+
#: (Hash[String, untyped], AnswerPlace, principle_id: String, ?recorded_at: WriteUpPointer?) -> void
|
|
36
|
+
def initialize(decision, place, principle_id:, recorded_at: nil)
|
|
37
|
+
@decision = decision
|
|
38
|
+
@place = place
|
|
39
|
+
@principle_id = principle_id
|
|
40
|
+
@recorded_at = recorded_at
|
|
41
|
+
freeze
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The id of the finding it decides.
|
|
45
|
+
#: () -> String
|
|
46
|
+
def finding_id = @decision.fetch("finding_id")
|
|
47
|
+
|
|
48
|
+
# finding with this decision's changes made at at, its action before its wait, which is checked against the
|
|
49
|
+
# action it leaves; or finding itself when it changes nothing.
|
|
50
|
+
#: (RecordedFinding, at: String) -> RecordedFinding
|
|
51
|
+
def applied_to(finding, at:)
|
|
52
|
+
acted = @decision.key?("action") ? finding.acting(open_action, at:, reason:) : finding
|
|
53
|
+
acted = acted.pointed_at(@recorded_at, at:, reason:) if @decision.key?("recorded_at")
|
|
54
|
+
return acted unless @decision.key?("waits_on")
|
|
55
|
+
|
|
56
|
+
WaitsOn.new(@decision["waits_on"], action: acted.action).check(code: "invalid_answer",
|
|
57
|
+
subject: "Finding #{finding_id}")
|
|
58
|
+
acted.waiting_on(@decision["waits_on"], at:, reason:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# The action it gives, refused unless it keeps the finding open.
|
|
64
|
+
#: () -> String
|
|
65
|
+
def open_action
|
|
66
|
+
action = @decision.fetch("action")
|
|
67
|
+
return action if OPEN_ACTIONS.include?(action)
|
|
68
|
+
|
|
69
|
+
raise @place.refusal(Error.new("invalid_answer",
|
|
70
|
+
"action #{action} closes the finding, which only a full audit judges",
|
|
71
|
+
"Give deferred or accepted, or run a full audit: " \
|
|
72
|
+
"#{Error::EXECUTABLE} start-audit #{@principle_id}"))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Why it changes the finding, which the record keeps beside each change.
|
|
76
|
+
#: () -> String
|
|
77
|
+
def reason
|
|
78
|
+
AnswerText.new(@decision["reason"]).required("decision.reason")
|
|
79
|
+
rescue Error => e
|
|
80
|
+
raise @place.child("reason").refusal(e)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -12,7 +12,8 @@ module Principles
|
|
|
12
12
|
# now.
|
|
13
13
|
class FindingWriteUps
|
|
14
14
|
# What to do about a recorded_at that no longer resolves, worded for a write-up rather than a member.
|
|
15
|
-
REPAIR = "Fix the write-up, or point recorded_at at it again with start-audit --
|
|
15
|
+
REPAIR = "Fix the write-up, or point recorded_at at it again with start-audit --open-findings, without a full " \
|
|
16
|
+
"audit."
|
|
16
17
|
# What the repair adds when git detects a rename for the write-up's missing file.
|
|
17
18
|
RENAMED = " git_detected_rename is git's match for its file, to #{MissingFiles::RENAME_MATCH}".freeze #: String
|
|
18
19
|
|
|
@@ -5,6 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "audit_record"
|
|
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
|
# A principle's first full audit, which one background subagent runs from show-first-audit-brief so the session
|
|
10
11
|
# that starts it spends little of its context on it: its id, and its record, or nil with none.
|
|
@@ -5,7 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "json_path_query"
|
|
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 YAML frontmatter at the head of a Markdown file, read as lines and never parsed as YAML, since a
|
|
11
11
|
# YAML parser over untrusted bytes is attack surface. A field is a top-level `key:` line and the indented,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
require_relative "../error"
|
|
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
|
# A glob the agent names for additional guidance inside this project, never a path outside it.
|
|
10
10
|
class GuidanceSearchPath
|
|
@@ -5,7 +5,7 @@ require_relative "../data/guidance_search_paths_file"
|
|
|
5
5
|
require_relative "guidance_search_path"
|
|
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 additional guidance globs this project records, with one owner for normalized additions and removals.
|
|
11
11
|
class GuidanceSearchPaths
|
|
@@ -42,6 +42,10 @@ module Principles
|
|
|
42
42
|
#: (GuidanceSearchPaths) -> bool
|
|
43
43
|
def same_as?(other) = @globs == other.globs
|
|
44
44
|
|
|
45
|
+
# The glob this list records that other did not, which a survey of just its matches reads; nil when none is.
|
|
46
|
+
#: (GuidanceSearchPaths) -> String?
|
|
47
|
+
def added_since(other) = (@globs - other.globs).first
|
|
48
|
+
|
|
45
49
|
#: () -> String
|
|
46
50
|
def save
|
|
47
51
|
@file.write("format" => Data::GuidanceSearchPathsFile::FORMAT, "globs" => @globs)
|
|
@@ -5,6 +5,7 @@ require_relative "after_commit_input"
|
|
|
5
5
|
require_relative "../data/head_reflog"
|
|
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
|
# Which repositories' HEAD a shell call moved by committing, each named once, in the order the call's
|
|
10
11
|
# directories name them, with the commit HEAD named before the move: what report-after-commit reports on. A
|
|
@@ -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 candidate files git ignores, which this tool names but never reads. A folder git ignores can hold many
|
|
8
8
|
# copies of instruction files written there by specs or builds, and listing each buries a file ignored on
|
|
@@ -5,7 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "../prose_list"
|
|
6
6
|
|
|
7
7
|
module Principles
|
|
8
|
-
# The domain
|
|
8
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
9
9
|
module Models
|
|
10
10
|
# The instruction field start-audit --instruction names, read whole from the request a full audit asks. Only a
|
|
11
11
|
# field the request prints an instruction under can be read: the others explain fields it does not hold.
|
|
@@ -7,7 +7,7 @@ require_relative "json_path_string"
|
|
|
7
7
|
require_relative "json_path_selectors"
|
|
8
8
|
|
|
9
9
|
module Principles
|
|
10
|
-
# The domain logic,
|
|
10
|
+
# The domain logic, and the mediation of persistence. models/CLAUDE.md owns the boundary.
|
|
11
11
|
module Models
|
|
12
12
|
# A query in this tool's own profile of RFC 9535 JSONPath: from $, name selectors in dot or bracket
|
|
13
13
|
# form, wildcards, and filters that keep the children whose relative paths equal strings, joined by &&.
|
|
@@ -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 selector * in a JSONPath query: every member value of an object, or every element of an array.
|
|
8
8
|
class JsonPathWildcard
|
|
@@ -5,7 +5,7 @@ require "strscan"
|
|
|
5
5
|
require_relative "../error"
|
|
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
|
# One quoted name or string in a JSONPath query, read as RFC 9535 writes it: single or double quotes, the
|
|
11
11
|
# escapes it defines, and no raw control character. Anything else refuses the whole query.
|
|
@@ -5,7 +5,7 @@ require_relative "../error"
|
|
|
5
5
|
require_relative "audit_record"
|
|
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 revision of a principle's last completed audit record when a request was printed, or nil when there was
|
|
11
11
|
# none. An assessment's basis and a correction's carry it, so either answer is refused once that record changed,
|