okstra 0.234.1 → 0.235.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.
- package/dist/cli-registry.mjs +7 -0
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/implementation-report/implementation-report.d.mts +1 -0
- package/dist/commands/implementation-report/implementation-report.mjs +73 -0
- package/dist/commands/implementation-report/implementation-report.mjs.map +1 -0
- package/dist/commands/trace/comparison.d.mts +39 -0
- package/dist/commands/trace/comparison.mjs +138 -0
- package/dist/commands/trace/comparison.mjs.map +1 -0
- package/dist/commands/trace/document.d.mts +8 -0
- package/dist/commands/trace/document.mjs +37 -0
- package/dist/commands/trace/document.mjs.map +1 -0
- package/dist/commands/trace/line-counts.d.mts +15 -0
- package/dist/commands/trace/line-counts.mjs +107 -0
- package/dist/commands/trace/line-counts.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +2 -1
- package/dist/commands/trace/model.mjs +13 -1
- package/dist/commands/trace/model.mjs.map +1 -1
- package/dist/commands/trace/progression.mjs +7 -3
- package/dist/commands/trace/progression.mjs.map +1 -1
- package/dist/commands/trace/task-link.d.mts +3 -0
- package/dist/commands/trace/task-link.mjs.map +1 -1
- package/dist/commands/trace/trace.mjs +64 -44
- package/dist/commands/trace/trace.mjs.map +1 -1
- package/dist/lib/python-helper.d.mts +1 -1
- package/dist/lib/python-helper.mjs +11 -5
- package/dist/lib/python-helper.mjs.map +1 -1
- package/dist/lib/types.d.mts +1 -0
- package/docs/architecture/storage-model.md +50 -0
- package/docs/cli.md +31 -15
- package/docs/project-structure-overview.md +6 -1
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/operations/trace-tests-review.json +6 -0
- package/runtime/prompts/duties/test-reviewer.json +32 -0
- package/runtime/prompts/lead/report-writer.md +13 -1
- package/runtime/python/okstra_ctl/agent/invocation.py +109 -56
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +17 -0
- package/runtime/python/okstra_ctl/attempt_evidence.py +5 -2
- package/runtime/python/okstra_ctl/code_review_census.py +38 -0
- package/runtime/python/okstra_ctl/code_review_coverage.py +15 -4
- package/runtime/python/okstra_ctl/code_review_prepare.py +15 -3
- package/runtime/python/okstra_ctl/code_review_scope.py +3 -2
- package/runtime/python/okstra_ctl/code_review_target.py +16 -6
- package/runtime/python/okstra_ctl/conformance_evidence.py +44 -21
- package/runtime/python/okstra_ctl/consumers.py +6 -1
- package/runtime/python/okstra_ctl/design_review.py +6 -26
- package/runtime/python/okstra_ctl/design_review_evidence.py +6 -26
- package/runtime/python/okstra_ctl/dispatch_core.py +9 -2
- package/runtime/python/okstra_ctl/dispatch_state.py +5 -0
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/execution_manifest.py +8 -0
- package/runtime/python/okstra_ctl/implementation_comparison/__init__.py +12 -0
- package/runtime/python/okstra_ctl/implementation_comparison/__main__.py +129 -0
- package/runtime/python/okstra_ctl/implementation_comparison/assembly.py +340 -0
- package/runtime/python/okstra_ctl/implementation_comparison/baseline.py +254 -0
- package/runtime/python/okstra_ctl/implementation_comparison/business_reuse.py +118 -0
- package/runtime/python/okstra_ctl/implementation_comparison/commit_source.py +113 -0
- package/runtime/python/okstra_ctl/implementation_comparison/html.py +49 -0
- package/runtime/python/okstra_ctl/implementation_comparison/inputs.py +348 -0
- package/runtime/python/okstra_ctl/implementation_comparison/model.py +47 -0
- package/runtime/python/okstra_ctl/implementation_comparison/preparation.py +195 -0
- package/runtime/python/okstra_ctl/implementation_comparison/publication.py +317 -0
- package/runtime/python/okstra_ctl/implementation_comparison/run_evidence.py +208 -0
- package/runtime/python/okstra_ctl/implementation_comparison/run_integration.py +198 -0
- package/runtime/python/okstra_ctl/implementation_comparison/source.py +342 -0
- package/runtime/python/okstra_ctl/implementation_comparison/target.py +144 -0
- package/runtime/python/okstra_ctl/implementation_comparison/task_assembly.py +333 -0
- package/runtime/python/okstra_ctl/implementation_comparison/task_selection.py +309 -0
- package/runtime/python/okstra_ctl/implementation_generation_evidence.py +134 -0
- package/runtime/python/okstra_ctl/implementation_outcome.py +2 -2
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +1 -0
- package/runtime/python/okstra_ctl/json_boundary.py +28 -8
- package/runtime/python/okstra_ctl/paths.py +7 -4
- package/runtime/python/okstra_ctl/plan_run_root.py +8 -4
- package/runtime/python/okstra_ctl/qa_procedures.py +33 -2
- package/runtime/python/okstra_ctl/render.py +4 -0
- package/runtime/python/okstra_ctl/report_execution_evidence.py +88 -15
- package/runtime/python/okstra_ctl/report_finalize.py +18 -4
- package/runtime/python/okstra_ctl/report_html/render.py +46 -7
- package/runtime/python/okstra_ctl/report_html/validation.py +32 -0
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +37 -3
- package/runtime/python/okstra_ctl/report_view_artifacts.py +12 -0
- package/runtime/python/okstra_ctl/review_verdicts.py +9 -0
- package/runtime/python/okstra_ctl/run.py +16 -0
- package/runtime/python/okstra_ctl/stage_done.py +11 -3
- package/runtime/python/okstra_ctl/stage_ledger.py +2 -2
- package/runtime/python/okstra_ctl/stage_map.py +3 -3
- package/runtime/python/okstra_ctl/trace_review.py +1 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +22 -7
- package/runtime/python/okstra_ctl/verification_dispatch.py +32 -0
- package/runtime/python/okstra_ctl/verification_evidence.py +23 -3
- package/runtime/python/okstra_ctl/verification_generation.py +3 -2
- package/runtime/python/okstra_ctl/verification_inputs.py +3 -2
- package/runtime/python/okstra_ctl/verification_invocation.py +7 -3
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +17 -0
- package/runtime/skills/okstra-code-review/SKILL.md +1 -1
- package/runtime/skills/okstra-code-review/references/census-rules.md +1 -1
- package/runtime/skills/okstra-code-review/references/review-calibration.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +31 -0
- package/runtime/skills/okstra-tdd/SKILL.md +74 -13
- package/runtime/templates/reports/html/assets/implementation-comparison.css +39 -0
- package/runtime/templates/reports/html/assets/implementation-comparison.js +55 -0
- package/runtime/templates/reports/html/i18n/en.json +113 -0
- package/runtime/templates/reports/html/i18n/ko.json +113 -0
- package/runtime/templates/reports/html/implementation-comparison.template.html +77 -0
- package/runtime/templates/reports/implementation-comparison-notes.md +72 -0
- package/runtime/templates/trace/trace.template.md +2 -0
- package/runtime/validators/validate-report-views.py +4 -36
|
@@ -6,6 +6,7 @@ import hashlib
|
|
|
6
6
|
import json
|
|
7
7
|
import math
|
|
8
8
|
import re
|
|
9
|
+
from collections.abc import Mapping
|
|
9
10
|
from dataclasses import dataclass
|
|
10
11
|
from datetime import datetime, timezone
|
|
11
12
|
from pathlib import Path
|
|
@@ -30,7 +31,7 @@ class TraceSource:
|
|
|
30
31
|
digest: str
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def
|
|
34
|
+
def read_trace_source(project_root: Path, trace_path: str, *, budget: ReadBudget | None = None) -> TraceSource:
|
|
34
35
|
root = project_root.resolve()
|
|
35
36
|
relative = Path(trace_path)
|
|
36
37
|
if relative.is_absolute() or len(relative.parts) != 4 or relative.parts[:2] != (*OKSTRA_RELATIVE.parts, "traces"):
|
|
@@ -38,14 +39,31 @@ def read_task_trace(project_root: Path, trace_path: str, task_key: str, *, budge
|
|
|
38
39
|
if trace_path != relative.as_posix() or contained_relative_path(trace_path, root) != trace_path or relative.suffix != ".md":
|
|
39
40
|
raise ValueError("Trace path is not canonical or contained")
|
|
40
41
|
content = read_bounded_bytes(root / relative, max_bytes=TASK_MANIFEST_MAX_BYTES, artifact="implementation trace", budget=budget)
|
|
42
|
+
return parse_trace_source(content)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def parse_trace_source(content: bytes) -> TraceSource:
|
|
41
46
|
text = content.decode("utf-8")
|
|
42
47
|
match = re.match(r"^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)", text)
|
|
43
48
|
header = json.loads(match[1]) if match else None
|
|
44
|
-
if not isinstance(header, dict)
|
|
45
|
-
raise ValueError("Trace
|
|
49
|
+
if not isinstance(header, dict):
|
|
50
|
+
raise ValueError("Trace frontmatter must be a JSON object")
|
|
46
51
|
return TraceSource(header, text, hashlib.sha256(content).hexdigest())
|
|
47
52
|
|
|
48
53
|
|
|
54
|
+
def read_task_trace(project_root: Path, trace_path: str, task_key: str, *, budget: ReadBudget | None = None) -> TraceSource:
|
|
55
|
+
source = read_trace_source(project_root, trace_path, budget=budget)
|
|
56
|
+
if not isinstance(source.frontmatter.get("task"), dict) or source.frontmatter["task"].get("key") != task_key:
|
|
57
|
+
raise ValueError("Trace owner does not match the task")
|
|
58
|
+
return source
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def trace_integration_completed(frontmatter: Mapping[str, object]) -> bool:
|
|
62
|
+
steps = frontmatter.get("steps", {})
|
|
63
|
+
integration = steps.get("integration", {}) if isinstance(steps, dict) else {}
|
|
64
|
+
return isinstance(integration, dict) and integration.get("status") == "done"
|
|
65
|
+
|
|
66
|
+
|
|
49
67
|
def _validate_request(project_root: Path, request: dict) -> dict:
|
|
50
68
|
if not isinstance(request, dict) or len(json.dumps(request, ensure_ascii=False).encode()) > TRACE_REQUEST_MAX_BYTES:
|
|
51
69
|
raise ValueError("Trace request exceeds its input limit")
|
|
@@ -71,10 +89,7 @@ def _validate_request(project_root: Path, request: dict) -> dict:
|
|
|
71
89
|
raise ValueError("Trace creation timestamp does not match its source")
|
|
72
90
|
if source.digest != request.get("digest") or source.frontmatter.get("currentStep") != request["currentStep"]:
|
|
73
91
|
raise ValueError("Trace projection does not match its saved source")
|
|
74
|
-
|
|
75
|
-
integration = steps.get("integration", {}) if isinstance(steps, dict) else {}
|
|
76
|
-
completed = isinstance(integration, dict) and integration.get("status") == "done"
|
|
77
|
-
if request["completed"] != completed:
|
|
92
|
+
if request["completed"] != trace_integration_completed(source.frontmatter):
|
|
78
93
|
raise ValueError("Trace completion projection does not match its source")
|
|
79
94
|
task = source.frontmatter["task"]
|
|
80
95
|
if set(task) != {"key", *TRACE_METADATA_LIST_LIMITS, *TRACE_METADATA_TEXT_LIMITS}:
|
|
@@ -6,6 +6,9 @@ from typing import Any, Mapping
|
|
|
6
6
|
|
|
7
7
|
from .correction_round import completed_round_attempts, correction_round
|
|
8
8
|
from .execution_manifest import read_execution_manifest
|
|
9
|
+
from .execution_identity import ExecutionManifest, build_dispatch_id
|
|
10
|
+
from .attempt_evidence import AttemptEvidenceSeal, read_sealed_artifact
|
|
11
|
+
from .json_boundary import ArtifactByteReader
|
|
9
12
|
from .paths import RunRef
|
|
10
13
|
from .qa_procedures import safe_qa_path
|
|
11
14
|
from .verification_generation import prepare_verification_generation
|
|
@@ -60,6 +63,35 @@ def generation_sealed_after_round(round_number: int) -> int:
|
|
|
60
63
|
return 1 + round_number
|
|
61
64
|
|
|
62
65
|
|
|
66
|
+
def implementation_generation_frontier(execution: ExecutionManifest) -> int | None:
|
|
67
|
+
return max((verification_generation_number(row.dispatch_kind)
|
|
68
|
+
for row in execution.invocations
|
|
69
|
+
if row.duty_id in ("implementation-executor", "implementation-verifier")), default=None)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def read_completed_attempt_result(
|
|
73
|
+
project: Path, execution: ExecutionManifest, invocation_ref: str, attempt: int,
|
|
74
|
+
*, reader: ArtifactByteReader | None = None,
|
|
75
|
+
) -> tuple[Path, bytes]:
|
|
76
|
+
row = next((row for row in execution.attempts if (row.invocation_ref, row.attempt)
|
|
77
|
+
== (invocation_ref, attempt)), None)
|
|
78
|
+
if row is None or row.status != "ok" or row.finished_at is None or not row.result_path:
|
|
79
|
+
raise ValueError("result requires the current completed ok attempt")
|
|
80
|
+
attempt_ref = build_dispatch_id(invocation_ref, attempt)
|
|
81
|
+
seals = [seal for seal in execution.attempt_evidence_seals
|
|
82
|
+
if seal.get("sealRef") == row.evidence_seal_ref and seal.get("attemptRef") == attempt_ref]
|
|
83
|
+
if len(seals) != 1:
|
|
84
|
+
raise ValueError("result requires its attempt evidence seal")
|
|
85
|
+
path = Path(row.result_path)
|
|
86
|
+
relative = path.relative_to(project).as_posix() if path.is_absolute() else path.as_posix()
|
|
87
|
+
if not relative.startswith(".okstra/"):
|
|
88
|
+
raise ValueError("result must remain in project artifacts")
|
|
89
|
+
path = safe_qa_path(project, relative)
|
|
90
|
+
seal = AttemptEvidenceSeal.from_payload(seals[0])
|
|
91
|
+
raw = read_sealed_artifact(seal, path) if reader is None else read_sealed_artifact(seal, path, reader=reader)
|
|
92
|
+
return path, raw
|
|
93
|
+
|
|
94
|
+
|
|
63
95
|
def _seal(
|
|
64
96
|
project: Path, manifest_path: Path, manifest: Mapping[str, Any],
|
|
65
97
|
active_context: Mapping[str, Any], *, audience: str, dispatch_kind: str,
|
|
@@ -23,6 +23,7 @@ from .execution_mutation_audit import (
|
|
|
23
23
|
compare_verification_sources,
|
|
24
24
|
)
|
|
25
25
|
from .json_boundary import (
|
|
26
|
+
ArtifactByteReader, OwnedJsonSnapshot, ReadBudget,
|
|
26
27
|
JsonBoundaryError, load_owned_object, load_owned_object_snapshot,
|
|
27
28
|
write_owned_object_atomic,
|
|
28
29
|
)
|
|
@@ -308,6 +309,17 @@ def roster_verifier_role_execution_ref(
|
|
|
308
309
|
return None
|
|
309
310
|
|
|
310
311
|
|
|
312
|
+
def implementation_verifier_roster(manifest: Mapping[str, Any]) -> list[str]:
|
|
313
|
+
assignments = manifest.get("workerAssignments", [])
|
|
314
|
+
if not isinstance(assignments, list) or any(not isinstance(row, Mapping) for row in assignments):
|
|
315
|
+
raise ValueError("implementation verifier roster is malformed")
|
|
316
|
+
roster = [row.get("workerId") for row in assignments
|
|
317
|
+
if row.get("role") == "verifier"]
|
|
318
|
+
if not roster or any(not isinstance(worker, str) or not worker for worker in roster) or len(set(roster)) != len(roster):
|
|
319
|
+
raise ValueError("implementation requires a distinct verifier roster")
|
|
320
|
+
return roster
|
|
321
|
+
|
|
322
|
+
|
|
311
323
|
def _sealed_conformance_entry(
|
|
312
324
|
project: Path, ref: RunRef, generation: VerificationGenerationRecord,
|
|
313
325
|
check_ref: str, stage_key: str,
|
|
@@ -647,10 +659,18 @@ def _publish(check_run_dir: Path, record: VerificationExecutionRecord) -> None:
|
|
|
647
659
|
|
|
648
660
|
|
|
649
661
|
def read_verification_execution_record(path: Path) -> VerificationExecutionRecord:
|
|
650
|
-
return cast(VerificationExecutionRecord,
|
|
662
|
+
return cast(VerificationExecutionRecord, read_verification_execution_snapshot(path).value)
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
def read_verification_execution_snapshot(
|
|
666
|
+
path: Path, *, reader: ArtifactByteReader | None = None,
|
|
667
|
+
max_bytes: int | None = None, budget: ReadBudget | None = None,
|
|
668
|
+
) -> OwnedJsonSnapshot:
|
|
669
|
+
return load_owned_object_snapshot(
|
|
651
670
|
path, artifact="verification execution record", schema=_RECORD_SCHEMA,
|
|
652
|
-
validate_cross_fields=_record_errors,
|
|
653
|
-
|
|
671
|
+
validate_cross_fields=_record_errors, reader=reader,
|
|
672
|
+
max_bytes=max_bytes, budget=budget,
|
|
673
|
+
)
|
|
654
674
|
|
|
655
675
|
|
|
656
676
|
def _record_errors(record: dict[str, Any]) -> list[str]:
|
|
@@ -12,7 +12,7 @@ from .execution_mutation_audit import (
|
|
|
12
12
|
VerificationSourceSnapshot, capture_verification_source,
|
|
13
13
|
is_generated_verification_path,
|
|
14
14
|
)
|
|
15
|
-
from .json_boundary import load_owned_object_snapshot
|
|
15
|
+
from .json_boundary import ArtifactByteReader, load_owned_object_snapshot
|
|
16
16
|
from .paths import RunRef
|
|
17
17
|
from .qa_commands import (
|
|
18
18
|
QA_COMMAND_EXECUTING_TASK_TYPES, QA_SOURCE_DIGEST_PATTERN, qa_relative_path_valid,
|
|
@@ -267,11 +267,12 @@ def sealed_source_snapshot(
|
|
|
267
267
|
|
|
268
268
|
|
|
269
269
|
def read_verification_generation(
|
|
270
|
-
path: Path, expected_digest: str,
|
|
270
|
+
path: Path, expected_digest: str, *, reader: ArtifactByteReader | None = None,
|
|
271
271
|
) -> VerificationGenerationRecord:
|
|
272
272
|
stored = load_owned_object_snapshot(
|
|
273
273
|
path, artifact=_ARTIFACT, schema=_SCHEMA,
|
|
274
274
|
validate_cross_fields=_generation_errors,
|
|
275
|
+
reader=reader,
|
|
275
276
|
)
|
|
276
277
|
if content_digest(stored.raw_bytes) != expected_digest:
|
|
277
278
|
raise ValueError("verification generation digest mismatch")
|
|
@@ -8,7 +8,7 @@ from typing import Any, Callable, Mapping, cast
|
|
|
8
8
|
|
|
9
9
|
from okstra_project.dirs import OKSTRA_DIR_NAME, json_lock_path, registry_lock
|
|
10
10
|
|
|
11
|
-
from .json_boundary import load_owned_object_snapshot, write_owned_object_atomic
|
|
11
|
+
from .json_boundary import ArtifactByteReader, load_owned_object_snapshot, write_owned_object_atomic
|
|
12
12
|
from .paths import RunRef
|
|
13
13
|
from .review_policy import capture_review_policy, review_policy_errors
|
|
14
14
|
from .qa_commands import (
|
|
@@ -218,10 +218,11 @@ def capture_verification_inputs(
|
|
|
218
218
|
return payload
|
|
219
219
|
|
|
220
220
|
|
|
221
|
-
def read_verification_inputs(path: Path, expected_digest: str) -> VerificationInputs:
|
|
221
|
+
def read_verification_inputs(path: Path, expected_digest: str, *, reader: ArtifactByteReader | None = None) -> VerificationInputs:
|
|
222
222
|
snapshot = load_owned_object_snapshot(
|
|
223
223
|
path, artifact=INPUT_ARTIFACT, schema=INPUT_SCHEMA,
|
|
224
224
|
validate_cross_fields=_verification_input_errors,
|
|
225
|
+
reader=reader,
|
|
225
226
|
)
|
|
226
227
|
if content_digest(snapshot.raw_bytes) != expected_digest:
|
|
227
228
|
raise ValueError("verification input digest mismatch")
|
|
@@ -17,6 +17,7 @@ from .verification_generation import (
|
|
|
17
17
|
from .verification_input_ref import VerificationInputReference
|
|
18
18
|
from .verification_inputs import read_verification_inputs
|
|
19
19
|
from .verification_input_types import DESIGN_REVIEW_INPUT_SCHEMA_VERSION
|
|
20
|
+
from .json_boundary import ArtifactByteReader
|
|
20
21
|
|
|
21
22
|
VERIFICATION_EVIDENCE_VERSION = "1.0"
|
|
22
23
|
VERIFICATION_GENERATION_HEADER_PREFIXES = (
|
|
@@ -63,13 +64,14 @@ def _has_c0_control_characters(value: str) -> bool:
|
|
|
63
64
|
|
|
64
65
|
def read_invocation_generation(
|
|
65
66
|
project: Path, manifest_path: Path | None, manifest: Mapping[str, Any],
|
|
66
|
-
reference: VerificationGenerationReference | None, audience: str,
|
|
67
|
+
reference: VerificationGenerationReference | None, audience: str, *,
|
|
68
|
+
reader: ArtifactByteReader | None = None,
|
|
67
69
|
) -> VerificationGenerationRecord | None:
|
|
68
70
|
if not _generation_required(manifest, reference, audience):
|
|
69
71
|
return None
|
|
70
72
|
if reference is None or manifest_path is None:
|
|
71
73
|
raise ValueError("verifier invocation requires a verification generation")
|
|
72
|
-
return _read_bound_generation(project, manifest_path, manifest, reference)
|
|
74
|
+
return _read_bound_generation(project, manifest_path, manifest, reference, reader=reader)
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
def verification_generation_required(
|
|
@@ -102,11 +104,12 @@ def _generation_required(
|
|
|
102
104
|
def _read_bound_generation(
|
|
103
105
|
project: Path, manifest_path: Path, manifest: Mapping[str, Any],
|
|
104
106
|
reference: VerificationGenerationReference,
|
|
107
|
+
*, reader: ArtifactByteReader | None = None,
|
|
105
108
|
) -> VerificationGenerationRecord:
|
|
106
109
|
task_type = manifest["taskType"]
|
|
107
110
|
project = project.resolve()
|
|
108
111
|
path = safe_qa_path(project, reference.path)
|
|
109
|
-
record = read_verification_generation(path, reference.digest)
|
|
112
|
+
record = read_verification_generation(path, reference.digest, **({"reader": reader} if reader is not None else {}))
|
|
110
113
|
relative_manifest = manifest_path.resolve().relative_to(project).as_posix()
|
|
111
114
|
if (record["runManifestPath"] != relative_manifest
|
|
112
115
|
or record["taskType"] != task_type):
|
|
@@ -116,6 +119,7 @@ def _read_bound_generation(
|
|
|
116
119
|
raise ValueError("verification generation input reference differs from run")
|
|
117
120
|
inputs = read_verification_inputs(
|
|
118
121
|
safe_qa_path(project, expected.relative_path), expected.digest,
|
|
122
|
+
**({"reader": reader} if reader is not None else {}),
|
|
119
123
|
)
|
|
120
124
|
if record["sourceRoot"] != inputs["sourceRoot"]:
|
|
121
125
|
raise ValueError("verification generation source differs from frozen inputs")
|
|
@@ -36,6 +36,23 @@
|
|
|
36
36
|
],
|
|
37
37
|
"additionalProperties": false,
|
|
38
38
|
"properties": {
|
|
39
|
+
"implementationComparison": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"required": ["schemaVersion", "owner", "baselineRef", "targetRef", "notesPath", "generation", "recordIds", "evidence", "notesGuide", "limitations"],
|
|
42
|
+
"additionalProperties": false,
|
|
43
|
+
"properties": {
|
|
44
|
+
"schemaVersion": {"const": "1.0"},
|
|
45
|
+
"owner": {"type": ["object", "null"]},
|
|
46
|
+
"baselineRef": {"type": ["object", "null"]},
|
|
47
|
+
"targetRef": {"type": ["object", "null"]},
|
|
48
|
+
"notesPath": {"type": ["string", "null"]},
|
|
49
|
+
"notesGuide": {"type": ["string", "null"]},
|
|
50
|
+
"generation": {"type": ["string", "null"], "pattern": "^[a-f0-9]{64}$"},
|
|
51
|
+
"recordIds": {"type": "array", "maxItems": 1000, "items": {"type": "string", "minLength": 1}},
|
|
52
|
+
"evidence": {"type": "array", "maxItems": 1000, "items": {"type": "object"}},
|
|
53
|
+
"limitations": {"type": "array", "items": {"type": "string"}}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
39
56
|
"resultPath": {
|
|
40
57
|
"type": "string",
|
|
41
58
|
"minLength": 1
|
|
@@ -102,7 +102,7 @@ pass task manifests, target-CLI JSON, or arbitrary JSON fields to a reviewer.
|
|
|
102
102
|
1. **Read [census rules](references/census-rules.md).** Resolve `<okstraHome>` with `okstra paths --field home`; use its `prompts/coding-preflight/review-rules.json` as `<rules-path>`, without retyping a parallel catalog.
|
|
103
103
|
2. Collect the diff from Step 1's Git root: `git -C <gitRoot> diff --name-status <baseCommit>..<headCommit>` for files and `git -C <gitRoot> diff <baseCommit>..<headCommit>` for hunks. First run `git -C <gitRoot> rev-list --count <headCommit>..<baseCommit>`: a nonzero count is the divergence case in Exceptions. An empty diff dispatches no reviewers.
|
|
104
104
|
3. **Capture and select one policy.** Set `<census-path>` to `<projectRoot>/.okstra/agent-invocations/code-review/<review-id>.census.md`, where `<review-id>` names this review and round (for example `pr<N>-r<round>`). `code-review census` refuses a census whose `.policy.json` would fall outside the project's `.okstra/`, and reuses the immutable policy already published beside an existing `<census-path>`, so give every new review round its own `<review-id>`. Step 3's `code-review prepare` writes the specialists' assigned censuses, slots, brief and batch in the same directory. Run `okstra code-review census --project-root <projectRoot> --base <baseCommit> --head <headCommit> --rules <rules-path> --out <census-path>`. The command captures canonical coding rules, declared project policy and protocol/calibration, then selects resources from the fixed range; declared architecture precedes layout signals. When resolved stage inputs explicitly name a run manifest, add `--run-manifest <run-manifest>` to reuse its author's captured policy. Never infer a latest run or claim policy equality without that source. Additional applied project policy uses repeated `--policy <path>` inputs in the same capture.
|
|
105
|
-
4. Inspect the actual diff for embedded SQL, ORM queries and other resource needs automatic path/manifest routing misses. Add repeated `--resource <pack-relative-id>` inputs for applicable resources present in the archive; do not route again for a specialist. Review selection excludes author-only source-writing procedures. Add `--previous-census <prior-census-path>` only for [ID continuity](references/census-rules.md#follow-up-review). Exit 1
|
|
105
|
+
4. Inspect the actual diff for embedded SQL, ORM queries and other resource needs automatic path/manifest routing misses. Add repeated `--resource <pack-relative-id>` inputs for applicable resources present in the archive; do not route again for a specialist. Review selection excludes author-only source-writing procedures. Add `--previous-census <prior-census-path>` only for [ID continuity](references/census-rules.md#follow-up-review). Exit 1 lists unresolved non-Python function boundaries: rerun with `--function-inventory <projectRoot>/.okstra/agent-invocations/code-review/<review-id>.functions.json`. The first run writes a template naming those files and exits 2; replace each null entry with `functions: [{start, end, name}]` spans read from the frozen head and a nonblank whole-file `rationale` (an empty list still needs one), then run it again. Do not add function cells to the census by hand.
|
|
106
106
|
5. Carry the returned literal `Review policy` path as `<review-policy-path>`; the shared snapshot is `<census-path>.policy.json`. Preserve its `Review policy digest` and `Review resources` metadata lines in every full or assigned census. `-` resources means no explicit additions. Keep the same snapshot and resource values for every specialist and gap-fill, passing additions to `code-review prepare` as the same repeated `--resource` inputs. Materialization routes language and framework bodies from the assignment's own targets, so a specialist can receive fewer packs than the census selection lists; the rule catalog and architecture routing stay identical because architecture detection reads the whole frozen tree. Mutable installed skill or calibration paths are capture inputs, never replacements for delivered frozen guidance.
|
|
107
107
|
6. Verify [both completion criteria](references/census-rules.md#completion-criteria) and follow [What to emit](references/census-rules.md#what-to-emit). Preserve the complete census and policy selection. Report a large census's size without truncation; dispatch follows the [authorization boundary](#authorization-and-recovery), not another confirmation based on size alone.
|
|
108
108
|
|
|
@@ -23,7 +23,7 @@ Membership follows the mechanical tests below, never an expected violation or a
|
|
|
23
23
|
| `state-and-tests` | non-test source file × `state-and-tests`, test file × `state-and-tests` | every changed non-test source file gets one cell; every changed test file gets one cell |
|
|
24
24
|
| `general` | non-test source file × `general` | every changed non-test source file |
|
|
25
25
|
|
|
26
|
-
Test files (the project's test-path or test-suffix convention — `*_test.*`, `*.test.*`, `*.spec.*`, `tests/`, `spec/`) receive `state-and-tests` cells and semantic cells for changed named functions/helpers. Test-case bodies remain subject to test-quality review; named helper readability is not exempt. `code_review_census.py` enumerates Python functions; other supported code suffixes remain unresolved until
|
|
26
|
+
Test files (the project's test-path or test-suffix convention — `*_test.*`, `*.test.*`, `*.spec.*`, `tests/`, `spec/`) receive `state-and-tests` cells and semantic cells for changed named functions/helpers. Test-case bodies remain subject to test-quality review; named helper readability is not exempt. `code_review_census.py` enumerates Python functions; other supported code suffixes remain unresolved until the lead's `--function-inventory` supplies their spans.
|
|
27
27
|
|
|
28
28
|
Intersect frozen signature/body spans with changed lines, including enclosing and nested functions. Use base-side spans for deletion-only changes and map surviving functions to head positions. Removed functions and changes outside functions (imports, wiring, declarations and class-level constants) belong to file-level cells. If boundaries cannot be established, stop before dispatch with an incomplete census. Boundary completeness remains a lead source-inspection check.
|
|
29
29
|
|
|
@@ -64,7 +64,7 @@ Return one compact Coverage Verdicts row per cell under `## Coverage Verdicts`.
|
|
|
64
64
|
| C-CR-0003 | - | T1=no state mutation; T2=non-test source; T3=non-test source; T4=no tests or new branches | - | src/orders/schema.py:1 |
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
`Checked` means inspected with no actionable finding. A criterion includes all applicable subconditions; one inapplicable bullet does not make the whole criterion N/A. List every
|
|
67
|
+
`Checked` means inspected with no actionable finding. A criterion includes all applicable subconditions; one inapplicable bullet does not make the whole criterion N/A. List every rule the Rules table assigns to the cell's Group exactly once across `Checked`, `N/A` (`rule=reason`) and `Findings` (`rule=finding-id`), and no rule of another Group: the parser rejects the whole row. A specialist covering several quality dimensions still records them under its own Group's rules. `all`, counts and ID ranges are invalid. Separate assignments with semicolons and finding IDs for one rule with commas; only a semicolon before the next `RULE=` starts a new assignment. Use `-` for empty fields and never infer omitted rules as clean.
|
|
68
68
|
|
|
69
69
|
Every row supplies one literal repository-relative source `path:line` for that cell's target file. The citation may be backtick-quoted and followed by a short observation, separated by a space or ` — `, before any ` :: ` rule observations. A bare citation remains valid. Do not use line ranges or substitute a rule-pack citation such as `cc:5`, a global alias such as `E01`, or another target's path. The checker verifies the declared source side and location; `base:` requires the frozen `--base`, and line 0 requires an empty regular file. These explicit forms override the head-line default above. Additional definitions and evidence remain in finding bodies. `review_verdicts.py` enforces the source grammar; `tests/verification/test_design_review.py` covers described anchors and invalid source rejection.
|
|
70
70
|
|
|
@@ -350,6 +350,37 @@ After successful preparation of a single run, delete the literal state-file path
|
|
|
350
350
|
If the file disappears before a remaining stage is prepared, stop that chain and report the completed and remaining stages. Reopen the wizard for the remaining scope; do not rebuild its inputs or approval receipt from a previous run. Already prepared runs resume from their run manifest without this file. After an interrupted or uncertain preparation, inspect the task's existing runs before retrying: this command does not promise exactly-once preparation.
|
|
351
351
|
<!-- END FRAGMENT: wizard-render-bundle -->
|
|
352
352
|
|
|
353
|
+
New implementation manifests retain `implementationComparison` for the actual
|
|
354
|
+
stage source and the first task baseline. Preserve its capture limitations when
|
|
355
|
+
reporting progress. Existing runs reuse their saved baseline; runs without this
|
|
356
|
+
declaration retain their original contract without a retrospective capture.
|
|
357
|
+
|
|
358
|
+
For a declared implementation comparison, report-writer materialization preserves
|
|
359
|
+
the current completed verification generation before writing. Its synthesis
|
|
360
|
+
packet supplies the exact optional notes path, common authoring guide, original
|
|
361
|
+
references, observed execution evidence and limitations. Reuse that context;
|
|
362
|
+
do not add a separate implementation, verification, or model round for the
|
|
363
|
+
comparison. Corrective writing reuses the preserved target.
|
|
364
|
+
|
|
365
|
+
After a successful implementation `report-finalize`, present the returned
|
|
366
|
+
`comparison` HTML/status and capture limitations alongside the original report.
|
|
367
|
+
Keep `comparisonWarnings` and `linkStatus` separate from implementation completion:
|
|
368
|
+
an optional comparison or existing-HTML link failure does not undo the completed
|
|
369
|
+
implementation. A source change detected between target preservation and automatic
|
|
370
|
+
publication leaves the previous comparison current. Recover from saved inputs
|
|
371
|
+
with `okstra implementation-report render --run-manifest <RUN_MANIFEST_PATH>`;
|
|
372
|
+
do not repeat implementation, tests, stage completion, or baseline capture.
|
|
373
|
+
|
|
374
|
+
After actual `stage-done`, also present its `comparison` result: the shared publisher
|
|
375
|
+
refreshes the whole-task view from the latest plan, valid stored completions and
|
|
376
|
+
preserved stage evidence. An optional report failure leaves the saved done row
|
|
377
|
+
and carry intact. Recover only that view with
|
|
378
|
+
`okstra implementation-report render --run-manifest <RUN_MANIFEST_PATH> --scope task`.
|
|
379
|
+
It retains separate stage contexts and uses one cumulative target only when stored
|
|
380
|
+
source identities and read-only Git ancestry establish that it includes all selected
|
|
381
|
+
stages. Parallel or unproven targets stay separate; never sum stage effects or run
|
|
382
|
+
merge, rebase, implementation, tests or models to generate this report.
|
|
383
|
+
|
|
353
384
|
<!-- BEGIN FRAGMENT: wizard-lead-takeover -->
|
|
354
385
|
## Step 6: Take over as Okstra lead
|
|
355
386
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: okstra-tdd
|
|
3
|
-
description: Guide one agent through requirements, independently reviewed specification and
|
|
3
|
+
description: Guide one agent through requirements, independently reviewed specification, interfaces and RED tests, implementation and integration GREEN in one resumable Implementation Trace. Use when the user requests okstra-tdd or a single-session test-driven implementation record; resume a task registered by okstra-run through its trace path and task key; cross-verification runs use okstra-run.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# OKSTRA TDD
|
|
@@ -40,6 +40,11 @@ lifecycle; review steps are judged by separate reviewer agents.
|
|
|
40
40
|
|
|
41
41
|
## Task registration and recovery
|
|
42
42
|
|
|
43
|
+
New attempts return `comparison` after preserving the starting source beside the
|
|
44
|
+
trace. Carry its capture limitations into the progress report. Resume through
|
|
45
|
+
`status`, which verifies preserved baseline bytes without collecting current
|
|
46
|
+
source; an unavailable baseline is not a reason to repeat trace creation.
|
|
47
|
+
|
|
43
48
|
The linked task shares ordinary task history without a verification run. Supply
|
|
44
49
|
`--metadata <json-file>` on creation or advance to update `title`, `summary`,
|
|
45
50
|
`tags`, `changedFiles`, `references` and explicit `relatedTasks`. Before final
|
|
@@ -73,15 +78,25 @@ call `status --path <file>` rather than reconstructing state from prose.
|
|
|
73
78
|
- `ask-user-decision`: show the three consecutive failed reviews and remaining
|
|
74
79
|
omissions. Wait for the user's choice to continue revising, narrow scope or
|
|
75
80
|
stop. Record the choice in the review section. For an authorized retry, finish
|
|
76
|
-
the
|
|
81
|
+
the step the review returned to (for `tests-review`, revise the tests and
|
|
82
|
+
record RED again in `tests-red`) and repeat its review once, using the actions for
|
|
77
83
|
those step IDs even while status still reports the failure streak. A passing
|
|
78
84
|
review resets the streak. If narrowing scope changes approved requirements,
|
|
79
85
|
confirm a new attempt with the user and preserve the existing attempt.
|
|
80
86
|
- `run-tests`: implement the current step's work, run the commands recorded in
|
|
81
|
-
`analysis`, and supply their actual evidence as described below.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
`analysis`, and supply their actual evidence as described below. Once
|
|
88
|
+
`implementation` passes, results carry `lineCounts`. When its `exceeded` is
|
|
89
|
+
true, tell the user the added source and test lines and their ratio (when
|
|
90
|
+
`ratio` is null, say that no source line was added), name the tests that
|
|
91
|
+
repeat a unit-tested rule or copy setup, and ask whether to trim them before
|
|
92
|
+
continuing; the warning does not block the step. Counts cover everything since
|
|
93
|
+
`baseCommit`, so a merge or rebase during the trace adds other work to them;
|
|
94
|
+
say so when it happened.
|
|
95
|
+
- `done`: report the trace path, the passing integration result, the added
|
|
96
|
+
source and test lines from `lineCounts` (or its `reason` when `available` is
|
|
97
|
+
false), and any explicitly unverified limitation. Then follow
|
|
98
|
+
[Build the comparison report](#build-the-comparison-report) using the saved
|
|
99
|
+
completion; do not advance integration again.
|
|
85
100
|
|
|
86
101
|
Use `okstra trace advance --path <file> --step <id> [options]` for transitions.
|
|
87
102
|
After any failed `advance`, read its JSON error and call `status --path <file>`:
|
|
@@ -103,15 +118,54 @@ earlier failed command or edit state to bypass a rejection.
|
|
|
103
118
|
| `interface-design` | Record domain boundaries and public signatures. Add a `Use case` / `Requirement` table with `UC-NNN` IDs and each use case's R-IDs. |
|
|
104
119
|
| `interface-review` | Reviewers check that every R-ID has a use case and the boundaries and signatures serve those cases. Record their findings and verdicts. |
|
|
105
120
|
| `interface-code` | Write interface code, record code paths and pass type checking, compilation or the recorded import check. |
|
|
106
|
-
| `tests-red` | Write unit and integration tests. Record `Test` / `Use case` / `Kind` / `Path` rows, using `integration` for integration rows; every UC needs at least one integration test. Unit tests own a rule's variants (each boundary, limit and error kind). An integration test checks that the wired components carry one representative case of its UC and does not repeat a variant a unit test asserts, so a failure-path UC needs one integration case, not one per variant. Reuse the project's existing test setup (mocks, test modules, fixtures) through a shared helper instead of copying it into each new test file. Establish both unit and integration RED caused by missing implementation. |
|
|
121
|
+
| `tests-red` | Write unit and integration tests. Record `Test` / `Use case` / `Kind` / `Path` rows, using `integration` for integration rows and, for `Path`, the test file path relative to the project root without a test-case suffix; every UC needs at least one integration test. Unit tests own a rule's variants (each boundary, limit and error kind). An integration test checks that the wired components carry one representative case of its UC and does not repeat a variant a unit test asserts, so a failure-path UC needs one integration case, not one per variant. Reuse the project's existing test setup (mocks, test modules, fixtures) through a shared helper instead of copying it into each new test file. Establish both unit and integration RED caused by missing implementation. |
|
|
122
|
+
| `tests-review` | Reviewers map every UC to its integration test and every unit test to the rule it asserts, then check for unverified outcomes, assertions repeated across layers, copied setup, self-mocking and RED caused by anything but missing implementation. Record their findings and verdicts. A failed review returns to `tests-red`: revise the tests, run both test commands again and advance `tests-red` with the new RED evidence, which replaces the earlier evidence block. An attempt saved before this step may lack the `## tests-review` heading: add it before `## implementation` before dispatching reviewers, so the review record stays outside the `tests-red` section the binding digests. |
|
|
107
123
|
| `implementation` | Implement the interfaces and reach unit GREEN. Record the integration result even when it remains RED. |
|
|
108
124
|
| `integration` | Reach integration GREEN for every use case. Record paths and results. |
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
Keep implementation sections in this trace; reference code and test files by path.
|
|
127
|
+
Comparison notes and derived HTML live beside it in the returned comparison
|
|
128
|
+
directory and do not replace the trace or task history.
|
|
111
129
|
Follow the project's language and test tools rather than adding a new framework.
|
|
112
130
|
The CLI translates template guidance for `en` and `ko`; other language tags start
|
|
113
131
|
with structural markers only. Author their prose in the frontmatter language.
|
|
114
132
|
|
|
133
|
+
## Build the comparison report
|
|
134
|
+
|
|
135
|
+
After integration has been saved as done, its response includes `comparison`:
|
|
136
|
+
the preserved baseline, `target.targetRef`, `notesPath`, `report` and
|
|
137
|
+
`renderCommand`. A task synchronization failure includes the same comparison
|
|
138
|
+
result in its error details. Read-only `status` returns those references again;
|
|
139
|
+
`sync` repairs task history without collecting another target or generating HTML.
|
|
140
|
+
|
|
141
|
+
1. Read the returned capture limitations. Resolve the bundled notes guide with
|
|
142
|
+
`okstra paths --field workspace`, then read
|
|
143
|
+
`<workspace>/templates/reports/implementation-comparison-notes.md` before writing
|
|
144
|
+
notes. If `notesPath` is null or absent, follow the guide's status recovery
|
|
145
|
+
branch; when it remains unavailable, stop report authoring and give the user
|
|
146
|
+
the saved completion, limitations and report recovery command. Reuse this
|
|
147
|
+
trace's explanation and evidence. Finalize the notes
|
|
148
|
+
against the returned owner, `baselineRef` and `target.targetRef` after capture,
|
|
149
|
+
rather than guessing a future target.
|
|
150
|
+
2. If `notesPath` is available but a capture reference is null, preserve that
|
|
151
|
+
null reference and explain the missing source.
|
|
152
|
+
Prepare a partial report from the existing record; do not recapture the start
|
|
153
|
+
or repeat integration to obtain a different ending target.
|
|
154
|
+
3. Run the returned `renderCommand`. It reads stored originals and notes without
|
|
155
|
+
running tests, reviewers, trace transitions or task synchronization. On
|
|
156
|
+
`stale`, read status and regenerate from the current stored original. On
|
|
157
|
+
`failed`, report its warnings and repair only report generation. Preserve any
|
|
158
|
+
previously published report.
|
|
159
|
+
4. Give the user the independent `htmlPath`, its ready/partial status, the main
|
|
160
|
+
before/after differences and remaining verification limits. Keep implementation
|
|
161
|
+
completion and task synchronization status separate. A report warning does
|
|
162
|
+
not undo integration GREEN.
|
|
163
|
+
|
|
164
|
+
The capture order, reference recovery and report-only regeneration are checked
|
|
165
|
+
by `tests-js/trace.test.mjs` and the common publication tests. The agent authors
|
|
166
|
+
the explanation; these checks validate references and evidence levels, not
|
|
167
|
+
natural-language truth.
|
|
168
|
+
|
|
115
169
|
## Run independent reviewers
|
|
116
170
|
|
|
117
171
|
The writing session never judges its own section. For the current review step:
|
|
@@ -129,8 +183,10 @@ Resolve `<host-runtime>` from the launcher's `OKSTRA_RUNTIME_HOST` when present;
|
|
|
129
183
|
with a unique invocation ID. Include the `binding` text verbatim, the request
|
|
130
184
|
and the sections the review compares (`analysis` for `analysis-review`;
|
|
131
185
|
`analysis` and `spec` for `spec-review`; `spec` and `interface-design` for
|
|
132
|
-
`interface-review`
|
|
133
|
-
|
|
186
|
+
`interface-review`; `interface-design` and `tests-red` for `tests-review`),
|
|
187
|
+
the trace path, and the existing source paths the design touches; for
|
|
188
|
+
`tests-review`, also the test files the `tests-red` table lists and the
|
|
189
|
+
project's existing test helpers. Do not include the writing session's reasoning or a proposed verdict.
|
|
134
190
|
Ask for findings with evidence, then exactly one final line
|
|
135
191
|
`Trace review verdict: pass` or `Trace review verdict: fail`.
|
|
136
192
|
3. Materialize and verify the prompt, then run the slot's provider wrapper:
|
|
@@ -154,15 +210,20 @@ Resolve `<host-runtime>` from the launcher's `OKSTRA_RUNTIME_HOST` when present;
|
|
|
154
210
|
lacks the current binding: the reviewed section, round, step, trace or host
|
|
155
211
|
changed after dispatch, or the binding was not copied verbatim. Review the
|
|
156
212
|
current text again under a new binding rather than editing the trace back.
|
|
157
|
-
A passing review re-reads the reviewed
|
|
158
|
-
`Key` / `Value` table
|
|
213
|
+
A passing review re-reads the section it reviewed: requirement IDs and the
|
|
214
|
+
`Key` / `Value` table of `analysis`, use-case IDs of `interface-design`; later
|
|
215
|
+
edits to those sections are not read. A passing `tests-review` rechecks that
|
|
216
|
+
every use case has an integration row in `tests-red`, which `integration`
|
|
217
|
+
checks again.
|
|
159
218
|
`REVIEWER_NOT_INDEPENDENT` means a registered model from another provider was
|
|
160
219
|
skipped. A failed reviewer execution is retried once with a new invocation ID;
|
|
161
220
|
report a repeated failure as a blocker instead of judging the section yourself.
|
|
162
221
|
|
|
163
222
|
## Record evidence
|
|
164
223
|
|
|
165
|
-
Write an evidence JSON file
|
|
224
|
+
Write an evidence JSON file under `<projectRoot>/.okstra/traces/<slug>/evidence/`,
|
|
225
|
+
so `lineCounts` does not count it as source. It contains one object or an array
|
|
226
|
+
of objects:
|
|
166
227
|
|
|
167
228
|
```json
|
|
168
229
|
{
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.human-report-header, .comparison-report { overflow-wrap: anywhere; }
|
|
2
|
+
.comparison-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
|
3
|
+
.comparison-pair > * { min-width: 0; padding: .8rem; border: 1px solid color-mix(in srgb, CanvasText 20%, transparent); border-radius: .5rem; }
|
|
4
|
+
.comparison-claim { padding-block: .5rem; }
|
|
5
|
+
.comparison-context, .claim-level { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
|
|
6
|
+
.comparison-context dt, .claim-level dt { font-weight: 600; }
|
|
7
|
+
.comparison-context dd, .claim-level dd { margin: 0; }
|
|
8
|
+
.claim-level div { display: flex; flex-wrap: wrap; gap: .3rem; }
|
|
9
|
+
.claim-level { font-size: .88rem; }
|
|
10
|
+
.claim-refs { display: flex; flex-wrap: wrap; gap: .6rem; padding-left: 1rem; }
|
|
11
|
+
.claim-refs li { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
|
|
12
|
+
.comparison-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; padding-block: .5rem 1rem; }
|
|
13
|
+
.comparison-controls label { display: grid; gap: .3rem; max-width: 100%; }
|
|
14
|
+
.comparison-controls input, .comparison-controls select, .comparison-controls button { font: inherit; max-width: 100%; padding: .4rem; }
|
|
15
|
+
.comparison-controls output { width: 100%; }
|
|
16
|
+
.comparison-report [hidden] { display: none !important; }
|
|
17
|
+
.comparison-change + .comparison-change, .comparison-evidence + .comparison-evidence { margin-top: 1rem; }
|
|
18
|
+
.comparison-report summary { cursor: pointer; font-weight: 600; }
|
|
19
|
+
.comparison-report :is(summary, a, input, select, button):focus-visible { outline: 2px solid Highlight; outline-offset: 3px; }
|
|
20
|
+
.comparison-report dd, .comparison-report td { overflow-wrap: anywhere; }
|
|
21
|
+
.comparison-report pre { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
22
|
+
.comparison-report table { width: 100%; table-layout: fixed; }
|
|
23
|
+
@media (max-width: 640px) {
|
|
24
|
+
.comparison-pair { grid-template-columns: minmax(0, 1fr); }
|
|
25
|
+
.comparison-controls label { width: 100%; }
|
|
26
|
+
.comparison-report th, .comparison-report td { min-width: 0; }
|
|
27
|
+
.comparison-files, .comparison-files tbody, .comparison-files tr, .comparison-files td { display: block; }
|
|
28
|
+
.comparison-files thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
|
|
29
|
+
.comparison-files td { width: 100%; }
|
|
30
|
+
.comparison-files td::before { content: attr(data-label); display: block; font-weight: 600; }
|
|
31
|
+
.comparison-files tr + tr { margin-top: 1rem; }
|
|
32
|
+
}
|
|
33
|
+
@media print {
|
|
34
|
+
.comparison-controls, .comparison-no-matches, noscript { display: none !important; }
|
|
35
|
+
.comparison-pair { grid-template-columns: minmax(0, 1fr); }
|
|
36
|
+
.comparison-report [data-search-item][hidden] { display: revert !important; }
|
|
37
|
+
.comparison-report section, .comparison-change { break-inside: auto; }
|
|
38
|
+
.comparison-claim, .comparison-evidence { break-inside: avoid; }
|
|
39
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
"use strict";
|
|
3
|
+
const controls = document.querySelector(".comparison-controls");
|
|
4
|
+
if (!controls) return;
|
|
5
|
+
const search = controls.querySelector("input");
|
|
6
|
+
const affected = controls.querySelector("#comparison-affected");
|
|
7
|
+
const support = controls.querySelector("#comparison-support");
|
|
8
|
+
const stage = controls.querySelector("#comparison-stage");
|
|
9
|
+
const output = controls.querySelector("output");
|
|
10
|
+
const items = [...document.querySelectorAll("[data-search-item]")];
|
|
11
|
+
const noMatches = document.querySelector(".comparison-no-matches");
|
|
12
|
+
function update() {
|
|
13
|
+
const query = search.value.trim().toLocaleLowerCase();
|
|
14
|
+
const visibleEvidence = new Set();
|
|
15
|
+
for (const item of items.filter((row) => row.hasAttribute("data-change"))) {
|
|
16
|
+
const targets = JSON.parse(item.dataset.affected);
|
|
17
|
+
const stages = JSON.parse(item.dataset.stages).map(String);
|
|
18
|
+
const level = !support.value || [...item.querySelectorAll("[data-support]")].some((claim) => claim.dataset.support === support.value);
|
|
19
|
+
item.hidden = !((!query || item.textContent.toLocaleLowerCase().includes(query))
|
|
20
|
+
&& (!affected.value || targets.includes(affected.value)) && (!stage.value || stages.includes(stage.value)) && level);
|
|
21
|
+
if (!item.hidden) for (const link of item.querySelectorAll('a[href^="#evidence-"]')) visibleEvidence.add(link.getAttribute("href").slice(1));
|
|
22
|
+
}
|
|
23
|
+
for (const item of items.filter((row) => !row.hasAttribute("data-change"))) {
|
|
24
|
+
const stages = item.dataset.stages ? JSON.parse(item.dataset.stages).map(String) : null;
|
|
25
|
+
item.hidden = Boolean(stage.value && stages && !stages.includes(stage.value))
|
|
26
|
+
|| (Boolean(query) && !item.textContent.toLocaleLowerCase().includes(query) && !visibleEvidence.has(item.id));
|
|
27
|
+
}
|
|
28
|
+
const visible = items.filter((item) => !item.hidden).length;
|
|
29
|
+
output.textContent = output.dataset.countFormat.replace("{visible}", String(visible)).replace("{total}", String(items.length));
|
|
30
|
+
noMatches.hidden = visible !== 0;
|
|
31
|
+
}
|
|
32
|
+
controls.hidden = false;
|
|
33
|
+
controls.addEventListener("input", update);
|
|
34
|
+
controls.addEventListener("change", update);
|
|
35
|
+
controls.addEventListener("submit", (event) => event.preventDefault());
|
|
36
|
+
controls.addEventListener("reset", () => { search.value = ""; affected.value = ""; support.value = ""; stage.value = ""; update(); });
|
|
37
|
+
document.addEventListener("click", (event) => {
|
|
38
|
+
const link = event.target.closest('a[href^="#"]');
|
|
39
|
+
const target = link && document.getElementById(link.getAttribute("href").slice(1));
|
|
40
|
+
if (!target) return;
|
|
41
|
+
if (target.closest("[data-search-item]")?.hidden) controls.reset();
|
|
42
|
+
const contents = target.querySelector(":scope > details");
|
|
43
|
+
if (contents) contents.open = true;
|
|
44
|
+
for (let parent = target; parent; parent = parent.parentElement) {
|
|
45
|
+
if (parent.tagName === "DETAILS") parent.open = true;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
let closedDetails = [];
|
|
49
|
+
window.addEventListener("beforeprint", () => {
|
|
50
|
+
closedDetails = [...document.querySelectorAll("details:not([open])")];
|
|
51
|
+
for (const detail of closedDetails) detail.open = true;
|
|
52
|
+
});
|
|
53
|
+
window.addEventListener("afterprint", () => { for (const detail of closedDetails) detail.open = false; closedDetails = []; });
|
|
54
|
+
update();
|
|
55
|
+
})();
|