okstra 0.232.0 → 0.233.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/README.md +19 -283
- package/dist/cli-registry.mjs +8 -1
- package/dist/cli-registry.mjs.map +1 -1
- package/dist/commands/execute/render-bundle.d.mts +6 -1
- package/dist/commands/execute/render-bundle.mjs +139 -32
- package/dist/commands/execute/render-bundle.mjs.map +1 -1
- package/dist/commands/lifecycle/config.mjs +6 -74
- package/dist/commands/lifecycle/config.mjs.map +1 -1
- package/dist/commands/trace/capacity.d.mts +12 -0
- package/dist/commands/trace/capacity.mjs +21 -0
- package/dist/commands/trace/capacity.mjs.map +1 -0
- package/dist/commands/trace/model.d.mts +89 -0
- package/dist/commands/trace/model.mjs +251 -0
- package/dist/commands/trace/model.mjs.map +1 -0
- package/dist/commands/trace/progression.d.mts +11 -0
- package/dist/commands/trace/progression.mjs +194 -0
- package/dist/commands/trace/progression.mjs.map +1 -0
- package/dist/commands/trace/review.d.mts +7 -0
- package/dist/commands/trace/review.mjs +51 -0
- package/dist/commands/trace/review.mjs.map +1 -0
- package/dist/commands/trace/task-link.d.mts +18 -0
- package/dist/commands/trace/task-link.mjs +72 -0
- package/dist/commands/trace/task-link.mjs.map +1 -0
- package/dist/commands/trace/trace.d.mts +1 -0
- package/dist/commands/trace/trace.mjs +293 -0
- package/dist/commands/trace/trace.mjs.map +1 -0
- package/dist/lib/bounded-file.d.mts +1 -0
- package/dist/lib/bounded-file.mjs +36 -0
- package/dist/lib/bounded-file.mjs.map +1 -0
- package/dist/lib/config-store.d.mts +34 -0
- package/dist/lib/config-store.mjs +70 -0
- package/dist/lib/config-store.mjs.map +1 -0
- package/dist/lib/file-lock.mjs +4 -5
- package/dist/lib/file-lock.mjs.map +1 -1
- package/dist/lib/input-limit.d.mts +4 -0
- package/dist/lib/input-limit.mjs +8 -0
- package/dist/lib/input-limit.mjs.map +1 -0
- package/dist/lib/memory-auto-register.mjs +2 -17
- package/dist/lib/memory-auto-register.mjs.map +1 -1
- package/dist/lib/report-language-tag.d.mts +1 -0
- package/dist/lib/report-language-tag.mjs +4 -0
- package/dist/lib/report-language-tag.mjs.map +1 -0
- package/dist/lib/report-language.d.mts +1 -0
- package/dist/lib/report-language.mjs +50 -0
- package/dist/lib/report-language.mjs.map +1 -0
- package/dist/lib/skill-catalog.mjs +3 -0
- package/dist/lib/skill-catalog.mjs.map +1 -1
- package/docs/architecture/storage-model.md +36 -5
- package/docs/architecture.md +10 -4
- package/docs/cli.md +279 -2
- package/docs/contributor-change-matrix.md +1 -2
- package/docs/project-structure-overview.md +31 -41
- package/package.json +1 -1
- package/runtime/BUILD.json +2 -2
- package/runtime/agents/operations/trace-interface-review.json +6 -0
- package/runtime/agents/operations/trace-scope-review.json +6 -0
- package/runtime/prompts/coding-preflight/authoring-checks.md +1 -1
- package/runtime/prompts/coding-preflight/clean-code.md +18 -20
- package/runtime/prompts/coding-preflight/overview.md +1 -1
- package/runtime/prompts/duties/code-reviewer.json +1 -1
- package/runtime/prompts/duties/interface-reviewer.json +32 -0
- package/runtime/prompts/host-orchestration/README.md +18 -9
- package/runtime/prompts/launch.template.md +3 -2
- package/runtime/prompts/lead/context-loader.md +2 -0
- package/runtime/prompts/lead/okstra-lead-contract.md +7 -7
- package/runtime/prompts/lead/report-writer.md +6 -6
- package/runtime/prompts/profiles/_coding-conventions-preflight.md +2 -2
- package/runtime/prompts/profiles/_common-contract.md +1 -1
- package/runtime/python/okstra_ctl/agent/invocation.py +1 -0
- package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +66 -26
- package/runtime/python/okstra_ctl/agent/prompt_cli/corrections.py +23 -8
- package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +28 -10
- package/runtime/python/okstra_ctl/agent/prompt_cli/results.py +8 -11
- package/runtime/python/okstra_ctl/agent/standalone.py +12 -0
- package/runtime/python/okstra_ctl/analysis_packet.py +22 -11
- package/runtime/python/okstra_ctl/code_review_census.py +93 -2
- package/runtime/python/okstra_ctl/code_review_prepare.py +381 -0
- package/runtime/python/okstra_ctl/code_review_run.py +384 -0
- package/runtime/python/okstra_ctl/code_review_scope.py +13 -0
- package/runtime/python/okstra_ctl/code_review_supervisor.py +41 -0
- package/runtime/python/okstra_ctl/code_review_target.py +140 -15
- package/runtime/python/okstra_ctl/coverage_census.py +11 -2
- package/runtime/python/okstra_ctl/design_snapshot.py +16 -9
- package/runtime/python/okstra_ctl/direct_work.py +45 -3
- package/runtime/python/okstra_ctl/dispatch_core.py +31 -15
- package/runtime/python/okstra_ctl/dispatch_state.py +9 -2
- package/runtime/python/okstra_ctl/domain/role.py +1 -0
- package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +48 -9
- package/runtime/python/okstra_ctl/final_report_schema.py +37 -34
- package/runtime/python/okstra_ctl/incremental_carry.py +6 -7
- package/runtime/python/okstra_ctl/initial_prompt_materialization.py +9 -2
- package/runtime/python/okstra_ctl/json_boundary.py +33 -6
- package/runtime/python/okstra_ctl/manager_cli.py +122 -1
- package/runtime/python/okstra_ctl/manager_journal.py +126 -0
- package/runtime/python/okstra_ctl/manager_launch.py +3 -3
- package/runtime/python/okstra_ctl/manager_log.py +221 -0
- package/runtime/python/okstra_ctl/manager_paths.py +8 -0
- package/runtime/python/okstra_ctl/manager_resume.py +59 -0
- package/runtime/python/okstra_ctl/manager_split.py +2 -2
- package/runtime/python/okstra_ctl/manager_store.py +116 -17
- package/runtime/python/okstra_ctl/manager_sync.py +42 -3
- package/runtime/python/okstra_ctl/manager_view.py +35 -2
- package/runtime/python/okstra_ctl/material.py +2 -0
- package/runtime/python/okstra_ctl/model_cli.py +64 -14
- package/runtime/python/okstra_ctl/model_defaults.py +22 -0
- package/runtime/python/okstra_ctl/model_io/renderers.py +3 -0
- package/runtime/python/okstra_ctl/operation_invocation.py +207 -28
- package/runtime/python/okstra_ctl/path_hints.py +14 -3
- package/runtime/python/okstra_ctl/paths.py +6 -1
- package/runtime/python/okstra_ctl/phases/catalog.py +24 -7
- package/runtime/python/okstra_ctl/phases/implementation/host-rules.md +3 -3
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +8 -6
- package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/profile.md +1 -1
- package/runtime/python/okstra_ctl/phases/implementation_option_selection/votes.py +11 -11
- package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +12 -9
- package/runtime/python/okstra_ctl/phases/implementation_planning/host-rules.md +3 -6
- package/runtime/python/okstra_ctl/phases/implementation_planning/instructions/plan-body-verification.md +12 -10
- package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +5 -5
- package/runtime/python/okstra_ctl/phases/improvement_discovery/lenses.py +12 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/profile.md +7 -6
- package/runtime/python/okstra_ctl/phases/improvement_discovery/resolved_census.py +159 -0
- package/runtime/python/okstra_ctl/phases/improvement_discovery/spec.md +5 -2
- package/runtime/python/okstra_ctl/phases/improvement_discovery/validation.py +21 -7
- package/runtime/python/okstra_ctl/phases/release_handoff/boundary.json +1 -1
- package/runtime/python/okstra_ctl/phases/release_handoff/profile.md +4 -1
- package/runtime/python/okstra_ctl/plan_verify_cli.py +6 -4
- package/runtime/python/okstra_ctl/render.py +28 -2
- package/runtime/python/okstra_ctl/report_assembly.py +38 -11
- package/runtime/python/okstra_ctl/report_contract.py +26 -0
- package/runtime/python/okstra_ctl/report_corrections.py +36 -20
- package/runtime/python/okstra_ctl/report_inputs.py +1 -0
- package/runtime/python/okstra_ctl/report_language.py +4 -1
- package/runtime/python/okstra_ctl/report_narrative.py +179 -7
- package/runtime/python/okstra_ctl/report_projections.py +64 -18
- package/runtime/python/okstra_ctl/report_synthesis_packet.py +86 -36
- package/runtime/python/okstra_ctl/run.py +43 -35
- package/runtime/python/okstra_ctl/run_context.py +10 -1
- package/runtime/python/okstra_ctl/set_work_status.py +4 -15
- package/runtime/python/okstra_ctl/task_list_cli.py +34 -8
- package/runtime/python/okstra_ctl/task_query.py +239 -0
- package/runtime/python/okstra_ctl/trace_review.py +264 -0
- package/runtime/python/okstra_ctl/trace_tasks.py +197 -0
- package/runtime/python/okstra_ctl/user_authorization.py +14 -0
- package/runtime/python/okstra_ctl/wizard/confirmation.py +7 -3
- package/runtime/python/okstra_ctl/wizard/launch.py +52 -0
- package/runtime/python/okstra_ctl/wizard/launch_cli.py +39 -0
- package/runtime/python/okstra_ctl/wizard/outcome.py +17 -16
- package/runtime/python/okstra_ctl/wizard/registry.py +1 -1
- package/runtime/python/okstra_ctl/wizard/render.py +8 -0
- package/runtime/python/okstra_ctl/wizard/state.py +2 -1
- package/runtime/python/okstra_project/state.py +20 -0
- package/runtime/python/okstra_token_usage/blocks.py +74 -0
- package/runtime/python/okstra_token_usage/cli.py +23 -10
- package/runtime/python/okstra_token_usage/collect.py +25 -22
- package/runtime/python/okstra_token_usage/policy.py +193 -0
- package/runtime/schemas/report-synthesis-packet-v1.0.schema.json +1 -1
- package/runtime/skills/_fragments/wizard-confirm-step.md +1 -1
- package/runtime/skills/_fragments/wizard-preflight.md +1 -1
- package/runtime/skills/_fragments/wizard-prompt-loop.md +3 -5
- package/runtime/skills/_fragments/wizard-relay-protocol.md +1 -1
- package/runtime/skills/_fragments/wizard-render-bundle.md +15 -29
- package/runtime/skills/okstra-brief-gen/SKILL.md +7 -7
- package/runtime/skills/okstra-brief-gen/references/tracker-recursion.md +1 -1
- package/runtime/skills/okstra-code-review/SKILL.md +58 -50
- package/runtime/skills/okstra-code-review/references/census-rules.md +6 -6
- package/runtime/skills/okstra-code-review/references/review-calibration.md +8 -12
- package/runtime/skills/okstra-discussion/SKILL.md +22 -38
- package/runtime/skills/okstra-explain-flow/SKILL.md +6 -2
- package/runtime/skills/okstra-manager/SKILL.md +24 -0
- package/runtime/skills/okstra-memory/SKILL.md +1 -1
- package/runtime/skills/okstra-pr-gen/SKILL.md +1 -1
- package/runtime/skills/okstra-run/SKILL.md +55 -183
- package/runtime/skills/okstra-schedule-gen/SKILL.md +9 -13
- package/runtime/skills/okstra-setup/SKILL.md +3 -2
- package/runtime/skills/okstra-setup/references/project-config.md +2 -4
- package/runtime/skills/okstra-tdd/SKILL.md +187 -0
- package/runtime/skills/okstra-user-response/SKILL.md +4 -2
- package/runtime/templates/manager/view.template.html +4 -0
- package/runtime/templates/report-writer-prompt-preamble.md +15 -3
- package/runtime/templates/trace/trace.template.md +42 -0
- package/runtime/validators/checks/fixtures-02.py +25 -33
- package/runtime/validators/validate-run.py +93 -36
|
@@ -20,7 +20,7 @@ from typing import Any, Mapping, Sequence
|
|
|
20
20
|
|
|
21
21
|
from .convergence_provenance import id_occurs_wordbounded
|
|
22
22
|
from .json_boundary import JsonBoundaryError, load_owned_object
|
|
23
|
-
from .phases.improvement_discovery.lenses import LENSES
|
|
23
|
+
from .phases.improvement_discovery.lenses import LENSES, validate_priority_lenses
|
|
24
24
|
from .scope_provenance import brief_end_state_id_sequence
|
|
25
25
|
|
|
26
26
|
|
|
@@ -89,6 +89,7 @@ def build_census(
|
|
|
89
89
|
aspects: Sequence[Aspect],
|
|
90
90
|
requirement_ids: Sequence[str],
|
|
91
91
|
changed_files: Sequence[str] = (),
|
|
92
|
+
selected_lenses: Sequence[str] | None = None,
|
|
92
93
|
) -> dict[str, Any]:
|
|
93
94
|
"""Every cell for this run, in the order a worker should walk them."""
|
|
94
95
|
cells: list[dict[str, str]] = []
|
|
@@ -114,8 +115,14 @@ def build_census(
|
|
|
114
115
|
for index, path in enumerate(sorted(set(filter(None, changed_files))), start=1):
|
|
115
116
|
for aspect in by_scope["file"]:
|
|
116
117
|
add(f"C-F-{index:03d}-{aspect.slug}", aspect, path)
|
|
118
|
+
lenses = LENSES
|
|
119
|
+
if selected_lenses is not None:
|
|
120
|
+
try:
|
|
121
|
+
lenses = validate_priority_lenses(selected_lenses)
|
|
122
|
+
except ValueError as exc:
|
|
123
|
+
raise CensusError(str(exc)) from exc
|
|
117
124
|
for aspect in by_scope["lens"]:
|
|
118
|
-
for lens in
|
|
125
|
+
for lens in lenses:
|
|
119
126
|
add(f"C-L-{lens}", aspect, lens)
|
|
120
127
|
return {
|
|
121
128
|
"schemaVersion": CENSUS_SCHEMA_VERSION,
|
|
@@ -130,6 +137,7 @@ def census_for_run(
|
|
|
130
137
|
profile_text: str,
|
|
131
138
|
brief_path: Path,
|
|
132
139
|
changed_files: Sequence[str] = (),
|
|
140
|
+
selected_lenses: Sequence[str] | None = None,
|
|
133
141
|
) -> dict[str, Any] | None:
|
|
134
142
|
"""The run's census, or ``None`` when the phase profile declares none."""
|
|
135
143
|
aspects = parse_census_aspects(profile_text)
|
|
@@ -140,6 +148,7 @@ def census_for_run(
|
|
|
140
148
|
aspects=aspects,
|
|
141
149
|
requirement_ids=brief_end_state_id_sequence(brief_path),
|
|
142
150
|
changed_files=changed_files,
|
|
151
|
+
selected_lenses=selected_lenses,
|
|
143
152
|
)
|
|
144
153
|
|
|
145
154
|
|
|
@@ -9,8 +9,7 @@ from typing import Any, Mapping
|
|
|
9
9
|
|
|
10
10
|
from .convergence_store import write_json_atomic
|
|
11
11
|
from .design_surfaces import DesignSurfaceError, detect_design_surfaces
|
|
12
|
-
from .
|
|
13
|
-
from .report_narrative import NarrativeContractError, parse_narrative
|
|
12
|
+
from .report_narrative import NarrativeContractError, load_writer_input
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
def _evidence(trigger: Any) -> list[dict[str, Any]]:
|
|
@@ -102,10 +101,15 @@ def build_design_snapshot(planning: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
|
|
105
|
-
def write_snapshot(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
104
|
+
def write_snapshot(
|
|
105
|
+
narrative_path: Path, output_path: Path, *, run_manifest: Path | None = None,
|
|
106
|
+
) -> dict[str, Any]:
|
|
107
|
+
try:
|
|
108
|
+
narrative = load_writer_input(narrative_path, run_manifest=run_manifest)
|
|
109
|
+
except NarrativeContractError as exc:
|
|
110
|
+
if run_manifest is None:
|
|
111
|
+
raise
|
|
112
|
+
raise DesignSurfaceError(str(exc)) from exc
|
|
109
113
|
planning = narrative.get("implementationPlanning")
|
|
110
114
|
if not isinstance(planning, Mapping):
|
|
111
115
|
raise DesignSurfaceError("implementationPlanning is missing from narrative")
|
|
@@ -115,7 +119,7 @@ def write_snapshot(narrative_path: Path, output_path: Path) -> dict[str, Any]:
|
|
|
115
119
|
|
|
116
120
|
|
|
117
121
|
_CLI_EPILOG = r"""Usage:
|
|
118
|
-
okstra design-snapshot --narrative <
|
|
122
|
+
okstra design-snapshot --run-manifest <path> --narrative <path> --output <design-preparation.json>
|
|
119
123
|
"""
|
|
120
124
|
_CLI_DESCRIPTION = "Write the detector-owned planning snapshot."
|
|
121
125
|
|
|
@@ -127,11 +131,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
127
131
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
128
132
|
prog="okstra design-snapshot")
|
|
129
133
|
parser.add_argument("--narrative", type=Path, required=True)
|
|
134
|
+
parser.add_argument("--run-manifest", type=Path)
|
|
130
135
|
parser.add_argument("--output", type=Path, required=True)
|
|
131
136
|
args = parser.parse_args(argv)
|
|
132
137
|
try:
|
|
133
|
-
snapshot = write_snapshot(
|
|
134
|
-
|
|
138
|
+
snapshot = write_snapshot(
|
|
139
|
+
args.narrative, args.output, run_manifest=args.run_manifest,
|
|
140
|
+
)
|
|
141
|
+
except (OSError, UnicodeError, ValueError) as exc:
|
|
135
142
|
print(f"design-snapshot: {exc}", file=sys.stderr)
|
|
136
143
|
return 2
|
|
137
144
|
print(json.dumps({"ok": True, "surfaces": sum(
|
|
@@ -6,8 +6,8 @@ import json
|
|
|
6
6
|
from datetime import date
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
-
from okstra_project import project_json_path, tasks_root
|
|
10
|
-
from okstra_project.dirs import TASK_CATALOG_RELATIVE
|
|
9
|
+
from okstra_project import parse_task_key, project_json_path, resolve_task_root_read_only, tasks_root
|
|
10
|
+
from okstra_project.dirs import TASK_CATALOG_RELATIVE, contained_relative_path
|
|
11
11
|
|
|
12
12
|
from . import group_context
|
|
13
13
|
from .brief_frontmatter import read_brief_frontmatter
|
|
@@ -17,6 +17,41 @@ from .paths import task_dir, task_manifest_file
|
|
|
17
17
|
from .render import render_task_catalog_discovery
|
|
18
18
|
from .run_context import dir_flock
|
|
19
19
|
|
|
20
|
+
TASK_MANIFEST_MAX_BYTES = 2 * 1024 * 1024
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_direct_task(project_root: Path, entry: dict, *, allow_create: bool) -> tuple[Path, dict]:
|
|
24
|
+
project_root = project_root.resolve()
|
|
25
|
+
project_id, group, task_id = parse_task_key(entry["taskKey"])
|
|
26
|
+
project = load_owned_object(project_json_path(project_root), artifact="project config", max_bytes=TASK_MANIFEST_MAX_BYTES)
|
|
27
|
+
if project.get("projectId") != project_id or not slugify_task_segment(group) or not slugify_task_segment(task_id):
|
|
28
|
+
raise ValueError("Task identity does not belong to this project")
|
|
29
|
+
existing = resolve_task_root_read_only(project_root, entry["taskKey"])
|
|
30
|
+
canonical = task_manifest_file(existing or task_dir(project_root, group, task_id))
|
|
31
|
+
path = Path(entry.get("taskManifestPath") or canonical)
|
|
32
|
+
path = path if path.is_absolute() else project_root / path
|
|
33
|
+
if (contained_relative_path(str(path), project_root) is None
|
|
34
|
+
or contained_relative_path(str(path), tasks_root(project_root).resolve()) is None):
|
|
35
|
+
raise ValueError("Task manifest is outside project tasks")
|
|
36
|
+
if path.exists():
|
|
37
|
+
manifest = load_owned_object(path, artifact="task manifest", max_bytes=TASK_MANIFEST_MAX_BYTES)
|
|
38
|
+
if manifest.get("taskKey") != entry["taskKey"]:
|
|
39
|
+
raise ValueError("Task manifest identity does not match the requested task")
|
|
40
|
+
for field, value in (("projectId", project_id), ("taskGroup", group), ("taskId", task_id)):
|
|
41
|
+
if field in manifest and manifest[field] != value:
|
|
42
|
+
raise ValueError("Task manifest owner is inconsistent")
|
|
43
|
+
return path, manifest
|
|
44
|
+
if not allow_create or (path.parent / "runs").exists() or entry.get("latestRunPath"):
|
|
45
|
+
raise ValueError("Task manifest is missing for a task with existing history")
|
|
46
|
+
return path, {
|
|
47
|
+
"schemaVersion": "1.0", "projectId": project_id, "projectRoot": str(project_root),
|
|
48
|
+
"taskKey": entry["taskKey"], "taskGroup": group, "taskId": task_id,
|
|
49
|
+
"taskGroupPathSegment": slugify_task_segment(group), "taskIdPathSegment": slugify_task_segment(task_id),
|
|
50
|
+
"taskRootPath": path.parent.relative_to(project_root).as_posix(),
|
|
51
|
+
"taskManifestPath": path.relative_to(project_root).as_posix(),
|
|
52
|
+
"taskBriefPath": entry.get("taskBriefPath", ""), "registrationSource": "direct",
|
|
53
|
+
}
|
|
54
|
+
|
|
20
55
|
|
|
21
56
|
def find_brief_tasks(project_root: Path, token: str, task_group: str) -> list[dict]:
|
|
22
57
|
project = load_owned_object(project_json_path(project_root), artifact="project config")
|
|
@@ -63,13 +98,20 @@ def record_direct_work(project_root: Path, manifest_path: Path, manifest: dict)
|
|
|
63
98
|
load_owned_object(project_root / previous_path, artifact="direct work record")
|
|
64
99
|
if previous_path else {}
|
|
65
100
|
)
|
|
66
|
-
|
|
101
|
+
trace_fields = {
|
|
102
|
+
"implementationTracePath": manifest["implementationTracePath"],
|
|
103
|
+
"traceDigest": manifest["traceDigest"],
|
|
104
|
+
"changedFiles": manifest["traceMetadata"].get("changedFiles", []),
|
|
105
|
+
} if manifest.get("traceDigest") else {}
|
|
106
|
+
if (previous.get("summary") == summary and previous.get("statusUpdatedAt") == manifest["workStatusUpdatedAt"]
|
|
107
|
+
and all(previous.get(key) == value for key, value in trace_fields.items())):
|
|
67
108
|
return
|
|
68
109
|
record = {
|
|
69
110
|
"schemaVersion": "1.0", "taskKey": manifest["taskKey"], "source": "direct",
|
|
70
111
|
"summary": summary, "crossVerification": "not-performed",
|
|
71
112
|
"statusUpdatedAt": manifest["workStatusUpdatedAt"],
|
|
72
113
|
"previousRecordPath": previous_path,
|
|
114
|
+
**trace_fields,
|
|
73
115
|
}
|
|
74
116
|
identity = {key: value for key, value in record.items() if key != "statusUpdatedAt"}
|
|
75
117
|
digest = hashlib.sha256(json.dumps(identity, sort_keys=True).encode()).hexdigest()
|
|
@@ -766,7 +766,7 @@ def _dispatch_cli_wrapper_batch(
|
|
|
766
766
|
returncode = port.wait(runtime)
|
|
767
767
|
completed = subprocess.CompletedProcess(handle.job.command, returncode)
|
|
768
768
|
settled = replace(handle, completed_process=completed)
|
|
769
|
-
outcomes.append((settled, attempt, _outcome_from_completed(settled)))
|
|
769
|
+
outcomes.append((settled, attempt, _outcome_from_completed(settled, manifest=plan.manifest)))
|
|
770
770
|
|
|
771
771
|
next_round: list[tuple[WorkerJob, int]] = []
|
|
772
772
|
for handle, attempt, outcome in outcomes:
|
|
@@ -885,7 +885,7 @@ def _abort_cli_batch_start(
|
|
|
885
885
|
continue
|
|
886
886
|
outcome = WorkerOutcome(
|
|
887
887
|
returncode=1,
|
|
888
|
-
missing_completion_paths=_missing_completion_paths(job),
|
|
888
|
+
missing_completion_paths=_missing_completion_paths(job, manifest=plan.manifest),
|
|
889
889
|
pane_id="",
|
|
890
890
|
status_sidecar_path=status_path_for_prompt(job.prompt_path),
|
|
891
891
|
timeout=False,
|
|
@@ -1326,7 +1326,7 @@ def _spawn_job(
|
|
|
1326
1326
|
_record_dispatch(plan.team_state_path, handle, attempt, "running", "")
|
|
1327
1327
|
_append_event(plan, "worker-dispatched", _attempt_details(job, attempt, handle))
|
|
1328
1328
|
if handle.completed_process is not None:
|
|
1329
|
-
outcome = _outcome_from_completed(handle)
|
|
1329
|
+
outcome = _outcome_from_completed(handle, manifest=plan.manifest)
|
|
1330
1330
|
retry_allowed = _finish_attempt(
|
|
1331
1331
|
plan,
|
|
1332
1332
|
job,
|
|
@@ -1720,7 +1720,7 @@ def _dispatch_job_with_retry(plan: DispatchPlan, job: WorkerJob) -> int:
|
|
|
1720
1720
|
handle = _spawn_job(plan, job, attempt)
|
|
1721
1721
|
if handle.completed_process is None:
|
|
1722
1722
|
return await_dispatches(plan, timeout_seconds=None)
|
|
1723
|
-
outcome = _outcome_from_completed(handle)
|
|
1723
|
+
outcome = _outcome_from_completed(handle, manifest=plan.manifest)
|
|
1724
1724
|
if _job_terminal_status(plan, job, attempt) == "completed":
|
|
1725
1725
|
return 0
|
|
1726
1726
|
if _should_retry(outcome, attempt) and handle.mutation_retry_allowed:
|
|
@@ -1835,25 +1835,30 @@ def _opened_cmux_surfaces(team_state_path: Path) -> tuple[str, ...]:
|
|
|
1835
1835
|
return tuple(opened)
|
|
1836
1836
|
|
|
1837
1837
|
|
|
1838
|
-
def _outcome_from_completed(
|
|
1838
|
+
def _outcome_from_completed(
|
|
1839
|
+
handle: WorkerHandle, *, manifest: Mapping[str, Any],
|
|
1840
|
+
) -> WorkerOutcome:
|
|
1839
1841
|
completed = handle.completed_process
|
|
1840
1842
|
if completed is None:
|
|
1841
1843
|
raise DispatchError("completed process missing")
|
|
1842
1844
|
return WorkerOutcome(
|
|
1843
1845
|
returncode=completed.returncode,
|
|
1844
|
-
missing_completion_paths=_missing_completion_paths(handle.job),
|
|
1846
|
+
missing_completion_paths=_missing_completion_paths(handle.job, manifest=manifest),
|
|
1845
1847
|
pane_id=handle.pane_id,
|
|
1846
1848
|
status_sidecar_path=handle.status_sidecar_path,
|
|
1847
1849
|
timeout=False,
|
|
1848
1850
|
terminal_stage="exited",
|
|
1849
1851
|
degraded_from=handle.degraded_from,
|
|
1850
|
-
artifact_defects=_artifact_defects(handle.job),
|
|
1852
|
+
artifact_defects=_artifact_defects(handle.job, manifest=manifest),
|
|
1851
1853
|
)
|
|
1852
1854
|
|
|
1853
1855
|
|
|
1854
|
-
def _artifact_defects(
|
|
1856
|
+
def _artifact_defects(
|
|
1857
|
+
job: WorkerJob, *, manifest: Mapping[str, Any],
|
|
1858
|
+
) -> tuple[str, ...]:
|
|
1855
1859
|
defect = unusable_result_defect(
|
|
1856
1860
|
job.worker_id, job.result_path, job.dispatch_kind,
|
|
1861
|
+
project_root=job.project_root, manifest=manifest,
|
|
1857
1862
|
)
|
|
1858
1863
|
return (defect,) if defect else ()
|
|
1859
1864
|
|
|
@@ -1881,7 +1886,7 @@ def _correct_teardown_marked_dispatches(plan: DispatchPlan) -> None:
|
|
|
1881
1886
|
status = read_wrapper_status(status_path) if status_path else None
|
|
1882
1887
|
if status is None or not status.is_terminal:
|
|
1883
1888
|
continue
|
|
1884
|
-
outcome = _outcome_from_status(record, status)
|
|
1889
|
+
outcome = _outcome_from_status(record, status, project_root=plan.project_root, manifest=plan.manifest)
|
|
1885
1890
|
if outcome.returncode != 0 or outcome.missing_completion_paths or outcome.timeout:
|
|
1886
1891
|
continue
|
|
1887
1892
|
_finish_record(plan, record, outcome)
|
|
@@ -1895,7 +1900,7 @@ def _advance_running_dispatches(plan: DispatchPlan, records: Sequence[Mapping[st
|
|
|
1895
1900
|
if status is not None and _wrapper_process_is_gone(status):
|
|
1896
1901
|
_settle_dead_dispatch(plan, record, status)
|
|
1897
1902
|
continue
|
|
1898
|
-
outcome = _outcome_from_status(record, status)
|
|
1903
|
+
outcome = _outcome_from_status(record, status, project_root=plan.project_root, manifest=plan.manifest)
|
|
1899
1904
|
retry_allowed = _finish_record(plan, record, outcome)
|
|
1900
1905
|
if (
|
|
1901
1906
|
_should_retry(outcome, int(record.get("attempt", 1)))
|
|
@@ -2991,16 +2996,19 @@ def _retry_details(job: WorkerJob, attempt: int, outcome: WorkerOutcome) -> dict
|
|
|
2991
2996
|
}
|
|
2992
2997
|
|
|
2993
2998
|
|
|
2994
|
-
def _outcome_from_status(
|
|
2999
|
+
def _outcome_from_status(
|
|
3000
|
+
record: Mapping[str, Any], status, *, project_root: Path,
|
|
3001
|
+
manifest: Mapping[str, Any],
|
|
3002
|
+
) -> WorkerOutcome:
|
|
2995
3003
|
return WorkerOutcome(
|
|
2996
3004
|
returncode=status.exit_code if status.exit_code is not None else 1,
|
|
2997
|
-
missing_completion_paths=_record_missing_completion_paths(record),
|
|
3005
|
+
missing_completion_paths=_record_missing_completion_paths(record, project_root=project_root, manifest=manifest),
|
|
2998
3006
|
pane_id=_string_value(record.get("paneId")),
|
|
2999
3007
|
status_sidecar_path=status.path,
|
|
3000
3008
|
timeout=status.timeout,
|
|
3001
3009
|
terminal_stage=status.stage,
|
|
3002
3010
|
degraded_from=_string_value(record.get("degradedFrom")),
|
|
3003
|
-
artifact_defects=_record_artifact_defects(record),
|
|
3011
|
+
artifact_defects=_record_artifact_defects(record, project_root=project_root, manifest=manifest),
|
|
3004
3012
|
)
|
|
3005
3013
|
|
|
3006
3014
|
|
|
@@ -3063,7 +3071,10 @@ def _record_completion_paths(record: Mapping[str, Any]) -> list[Path]:
|
|
|
3063
3071
|
return [Path(path) for path in _string_list(record.get("completionPaths"))]
|
|
3064
3072
|
|
|
3065
3073
|
|
|
3066
|
-
def _record_missing_completion_paths(
|
|
3074
|
+
def _record_missing_completion_paths(
|
|
3075
|
+
record: Mapping[str, Any], *, project_root: Path,
|
|
3076
|
+
manifest: Mapping[str, Any],
|
|
3077
|
+
) -> tuple[Path, ...]:
|
|
3067
3078
|
aliases = {Path(path) for path in _string_list(record.get("resultAliases"))}
|
|
3068
3079
|
result_path = Path(_string_value(record.get("resultPath")))
|
|
3069
3080
|
worker_result = Path(_string_value(record.get("workerResultPath")))
|
|
@@ -3074,6 +3085,7 @@ def _record_missing_completion_paths(record: Mapping[str, Any]) -> tuple[Path, .
|
|
|
3074
3085
|
if path.is_file():
|
|
3075
3086
|
if path == result_path and unusable_result_defect(
|
|
3076
3087
|
worker_id, path, dispatch_kind,
|
|
3088
|
+
project_root=project_root, manifest=manifest,
|
|
3077
3089
|
):
|
|
3078
3090
|
missing.append(path)
|
|
3079
3091
|
continue
|
|
@@ -3083,11 +3095,15 @@ def _record_missing_completion_paths(record: Mapping[str, Any]) -> tuple[Path, .
|
|
|
3083
3095
|
return tuple(missing)
|
|
3084
3096
|
|
|
3085
3097
|
|
|
3086
|
-
def _record_artifact_defects(
|
|
3098
|
+
def _record_artifact_defects(
|
|
3099
|
+
record: Mapping[str, Any], *, project_root: Path,
|
|
3100
|
+
manifest: Mapping[str, Any],
|
|
3101
|
+
) -> tuple[str, ...]:
|
|
3087
3102
|
defect = unusable_result_defect(
|
|
3088
3103
|
dispatch_worker_key(record),
|
|
3089
3104
|
Path(_string_value(record.get("resultPath"))),
|
|
3090
3105
|
_string_value(record.get("dispatchKind")),
|
|
3106
|
+
project_root=project_root, manifest=manifest,
|
|
3091
3107
|
)
|
|
3092
3108
|
return (defect,) if defect else ()
|
|
3093
3109
|
|
|
@@ -53,7 +53,7 @@ from .execution_manifest import (
|
|
|
53
53
|
from .execution_mutation_audit import ExecutionMutationAudit, MutationSnapshot
|
|
54
54
|
from .final_report_paths import final_report_data_path
|
|
55
55
|
from .report_inputs import report_narrative_path, uses_report_contract_v3
|
|
56
|
-
from .report_narrative import narrative_structure_defect
|
|
56
|
+
from .report_narrative import narrative_structure_defect, report_narrative_structure_defect
|
|
57
57
|
from .verdict_blocks import finding_vote_defect
|
|
58
58
|
from .worker_prompt_body import REPORT_WRITER_WORKER_ID
|
|
59
59
|
from .worker_prompt_contract import (
|
|
@@ -1656,6 +1656,7 @@ def dispatch_mode(jobs: Sequence[WorkerJob]) -> str:
|
|
|
1656
1656
|
|
|
1657
1657
|
def unusable_result_defect(
|
|
1658
1658
|
worker_id: str, result_path: Path, dispatch_kind: str = "",
|
|
1659
|
+
*, project_root: Path, manifest: Mapping[str, Any],
|
|
1659
1660
|
) -> str | None:
|
|
1660
1661
|
"""산출물이 있어도 소비자가 읽을 수 없으면 없는 것이다 — 서사와 재검증 표.
|
|
1661
1662
|
|
|
@@ -1688,6 +1689,9 @@ def unusable_result_defect(
|
|
|
1688
1689
|
return f"reverify result does not parse: {defect}"
|
|
1689
1690
|
if worker_id != REPORT_WRITER_WORKER_ID:
|
|
1690
1691
|
return None
|
|
1692
|
+
if uses_report_contract_v3(manifest):
|
|
1693
|
+
defect = report_narrative_structure_defect(project_root, manifest, path=result_path)
|
|
1694
|
+
return f"narrative does not parse: {defect}" if defect else None
|
|
1691
1695
|
try:
|
|
1692
1696
|
text = result_path.read_text(encoding="utf-8")
|
|
1693
1697
|
except (OSError, UnicodeDecodeError) as exc:
|
|
@@ -1698,12 +1702,15 @@ def unusable_result_defect(
|
|
|
1698
1702
|
return f"narrative does not parse: {defect}"
|
|
1699
1703
|
|
|
1700
1704
|
|
|
1701
|
-
def missing_completion_paths(
|
|
1705
|
+
def missing_completion_paths(
|
|
1706
|
+
job: WorkerJob, *, manifest: Mapping[str, Any],
|
|
1707
|
+
) -> tuple[Path, ...]:
|
|
1702
1708
|
missing: list[Path] = []
|
|
1703
1709
|
for path in job.completion_paths:
|
|
1704
1710
|
if path.is_file():
|
|
1705
1711
|
if path == job.result_path and unusable_result_defect(
|
|
1706
1712
|
job.worker_id, path, job.dispatch_kind,
|
|
1713
|
+
project_root=job.project_root, manifest=manifest,
|
|
1707
1714
|
):
|
|
1708
1715
|
missing.append(path)
|
|
1709
1716
|
continue
|
|
@@ -13,7 +13,7 @@ from ...json_boundary import JsonBoundaryError
|
|
|
13
13
|
from ...jsonl import parse_jsonl_snapshot
|
|
14
14
|
from ...manager_paths import (
|
|
15
15
|
ManagerPathError, canonical_manager_id, children_json_path,
|
|
16
|
-
directives_jsonl_path, manager_json_path, projects_json_path,
|
|
16
|
+
directives_jsonl_path, journal_jsonl_path, manager_json_path, projects_json_path,
|
|
17
17
|
manager_root, snapshots_json_path, task_groups_root, task_manifest_path,
|
|
18
18
|
)
|
|
19
19
|
from ..config import SourceConfig, includes_project
|
|
@@ -58,14 +58,24 @@ def _manager_projects(home: Path, root: Path, settings: SourceConfig) -> list[di
|
|
|
58
58
|
return rows
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
JOURNAL_NATIVE_ID = "journal"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _optional_jsonl(home: Path, path: Path) -> tuple[list[dict], list[int]]:
|
|
65
|
+
"""Rows and damaged line numbers of an optional JSONL source file."""
|
|
66
|
+
target = safe_source_path(home, path)
|
|
67
|
+
return parse_jsonl_snapshot(read_source_text(home, target)) if target.exists() else ([], [])
|
|
68
|
+
|
|
69
|
+
|
|
61
70
|
def _root_snapshot(home: Path, manager: dict, projects: list[dict], settings: SourceConfig) -> SourceSnapshot:
|
|
62
71
|
manager_id = manager["managerId"]
|
|
72
|
+
metadata = {"manager": manager, "projects": projects}
|
|
63
73
|
nodes = tuple({"kind": "project", "scope": "okstra-project", "key": row["projectId"], "ref": f"project-{index}", "title": row["projectId"]} for index, row in enumerate(projects))
|
|
64
74
|
relations = tuple({"from": "$source", "to": node["ref"], "kind": "includes-project", "reason": "The manager registers this project.", "evidence": [str(projects_json_path(home, manager_id))], "standing": "observed"} for node in nodes)
|
|
65
75
|
snapshot = SourceSnapshot(
|
|
66
76
|
SourceRef("manager", manager_id, "$manager"),
|
|
67
77
|
{"kind": "entity", "scope": "okstra-manager", "key": manager_id, "ref": "primary", "title": manager_id},
|
|
68
|
-
str(manager_json_path(home, manager_id)),
|
|
78
|
+
str(manager_json_path(home, manager_id)), metadata, nodes, relations,
|
|
69
79
|
source_updated_at=manager.get("updatedAt"), scope=settings["scope"],
|
|
70
80
|
)
|
|
71
81
|
return snapshot
|
|
@@ -75,8 +85,7 @@ def _task_records(home: Path, manager_id: str, group: str, task_id: str, setting
|
|
|
75
85
|
children = _project_rows(read_source_object(home, children_json_path(home, manager_id, group, task_id)).get("children"), settings)
|
|
76
86
|
saved = _optional_object(home, snapshots_json_path(home, manager_id, group, task_id), {})
|
|
77
87
|
saved = {**saved, "children": _project_rows(saved.get("children", []), settings)}
|
|
78
|
-
|
|
79
|
-
directives, damaged = parse_jsonl_snapshot(read_source_text(home, directives_path)) if directives_path.exists() else ([], [])
|
|
88
|
+
directives, damaged = _optional_jsonl(home, directives_jsonl_path(home, manager_id, group, task_id))
|
|
80
89
|
if damaged:
|
|
81
90
|
raise DoyouknowError("manager notes contain damaged rows")
|
|
82
91
|
return children, _project_rows(directives, settings), saved
|
|
@@ -115,6 +124,33 @@ def _task_snapshot(home: Path, path: Path, manifest: dict, ref: SourceRef, proje
|
|
|
115
124
|
return snapshot
|
|
116
125
|
|
|
117
126
|
|
|
127
|
+
def _journal_source(home: Path, manager_id: str, settings: SourceConfig) -> tuple[SourceRef | None, SourceSnapshot | None, str | None]:
|
|
128
|
+
"""The manager journal as its own source, so its damage or size cannot stop the root and task sources."""
|
|
129
|
+
path = journal_jsonl_path(home, manager_id)
|
|
130
|
+
if not safe_source_path(home, path).exists():
|
|
131
|
+
return None, None, None
|
|
132
|
+
ref = SourceRef("manager", manager_id, JOURNAL_NATIVE_ID)
|
|
133
|
+
try:
|
|
134
|
+
rows, damaged = _optional_jsonl(home, path)
|
|
135
|
+
except (DoyouknowError, JsonBoundaryError, OSError):
|
|
136
|
+
return ref, None, "manager-journal-unavailable"
|
|
137
|
+
if damaged:
|
|
138
|
+
return ref, None, "manager-journal-damaged"
|
|
139
|
+
snapshot = SourceSnapshot(
|
|
140
|
+
ref,
|
|
141
|
+
{"kind": "entity", "scope": "manager:" + manager_id, "key": JOURNAL_NATIVE_ID, "ref": "primary", "title": "Manager journal"},
|
|
142
|
+
str(path), {"journal": rows},
|
|
143
|
+
({"kind": "entity", "scope": "okstra-manager", "key": manager_id, "ref": "manager", "title": manager_id},),
|
|
144
|
+
({"from": "$source", "to": "manager", "kind": "belongs-to", "reason": "The manager owns this journal.", "evidence": [str(path)], "standing": "observed"},),
|
|
145
|
+
scope=settings["scope"],
|
|
146
|
+
)
|
|
147
|
+
return ref, snapshot, None
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _snapshot_error(snapshot: SourceSnapshot) -> str:
|
|
151
|
+
return "manager-journal-unavailable" if snapshot.ref.native_id == JOURNAL_NATIVE_ID else "manager-task-unavailable"
|
|
152
|
+
|
|
153
|
+
|
|
118
154
|
def _manager_manifest_data(home: Path, path: Path) -> dict:
|
|
119
155
|
manifest = read_source_object(home, path)
|
|
120
156
|
group, task_id = manifest.get("taskGroup"), manifest.get("taskId")
|
|
@@ -156,13 +192,15 @@ def _scan_manager(home: Path, root: Path, settings: SourceConfig, *, validate: b
|
|
|
156
192
|
root_snapshot = _root_snapshot(home, manager, projects, settings)
|
|
157
193
|
snapshots.append(root_snapshot)
|
|
158
194
|
observed.append(SourceRef("manager", manager_id, "$manager"))
|
|
159
|
-
|
|
160
|
-
|
|
195
|
+
child_sources = [_manager_task_source(home, path, manager_id, projects, settings)
|
|
196
|
+
for path in _manager_manifest_candidates(home, root)]
|
|
197
|
+
child_sources.append(_journal_source(home, manager_id, settings))
|
|
198
|
+
for ref, snapshot, error in child_sources:
|
|
161
199
|
if ref is not None:
|
|
162
200
|
observed.append(ref)
|
|
163
201
|
if snapshot is not None:
|
|
164
202
|
snapshots.append(snapshot)
|
|
165
|
-
|
|
203
|
+
elif error is not None:
|
|
166
204
|
errors.append(error)
|
|
167
205
|
except (DoyouknowError, JsonBoundaryError, ManagerPathError, OSError, StateError, TypeError, RecursionError):
|
|
168
206
|
return SourceScan(domain, (), (), "unavailable", ("manager-source-unavailable",)), []
|
|
@@ -194,13 +232,14 @@ def gate_manager_scan(scan: SourceScan, *, gate: Callable[[PreparedSource], bool
|
|
|
194
232
|
except SecretRefusal:
|
|
195
233
|
errors.append("manager-secret-refused")
|
|
196
234
|
except (DoyouknowError, JsonBoundaryError, OSError, StateError, TypeError, RecursionError):
|
|
197
|
-
errors.append(
|
|
235
|
+
errors.append(_snapshot_error(snapshot))
|
|
198
236
|
return replace(scan, snapshots=tuple(snapshots), status="partial" if errors else scan.status, errors=tuple(errors))
|
|
199
237
|
|
|
200
238
|
|
|
201
239
|
def _manager_source_paths(home: Path, root: Path) -> list[tuple[Path, bool]]:
|
|
202
240
|
manager_id = root.name
|
|
203
|
-
paths = [(manager_json_path(home, manager_id), True), (projects_json_path(home, manager_id), False)
|
|
241
|
+
paths = [(manager_json_path(home, manager_id), True), (projects_json_path(home, manager_id), False),
|
|
242
|
+
(journal_jsonl_path(home, manager_id), False)]
|
|
204
243
|
for path in _manager_manifest_candidates(home, root):
|
|
205
244
|
manifest = _manager_manifest_data(home, path)
|
|
206
245
|
group, task_id = manifest["taskGroup"], manifest["taskId"]
|