okstra 0.231.1 → 0.232.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.
Files changed (126) hide show
  1. package/README.md +12 -0
  2. package/dist/cli-registry.mjs +6 -0
  3. package/dist/cli-registry.mjs.map +1 -1
  4. package/dist/commands/memory/memory.mjs +9 -55
  5. package/dist/commands/memory/memory.mjs.map +1 -1
  6. package/dist/lib/memory-auto-register.d.mts +1 -0
  7. package/dist/lib/memory-auto-register.mjs +113 -0
  8. package/dist/lib/memory-auto-register.mjs.map +1 -0
  9. package/dist/lib/memory-entry-contract.d.mts +12 -0
  10. package/dist/lib/memory-entry-contract.mjs +46 -0
  11. package/dist/lib/memory-entry-contract.mjs.map +1 -0
  12. package/dist/lib/python-helper.d.mts +1 -1
  13. package/dist/lib/python-helper.mjs +3 -2
  14. package/dist/lib/python-helper.mjs.map +1 -1
  15. package/dist/lib/record-secrets.d.mts +1 -0
  16. package/dist/lib/record-secrets.mjs +28 -0
  17. package/dist/lib/record-secrets.mjs.map +1 -0
  18. package/dist/lib/types.d.mts +2 -1
  19. package/docs/architecture/storage-model.md +127 -0
  20. package/docs/architecture.md +7 -0
  21. package/docs/cli.md +234 -0
  22. package/docs/project-structure-overview.md +2 -1
  23. package/package.json +1 -1
  24. package/runtime/BUILD.json +2 -2
  25. package/runtime/agents/common.json +8 -8
  26. package/runtime/agents/roles/verifier.json +2 -4
  27. package/runtime/bin/okstra-provider-exec.py +10 -4
  28. package/runtime/prompts/coding-preflight/architectures/hexagonal.md +23 -30
  29. package/runtime/prompts/coding-preflight/authoring-checks.md +17 -0
  30. package/runtime/prompts/coding-preflight/clean-code.md +85 -281
  31. package/runtime/prompts/coding-preflight/frameworks/node-server.md +2 -3
  32. package/runtime/prompts/coding-preflight/languages/java.md +3 -5
  33. package/runtime/prompts/coding-preflight/languages/javascript-typescript.md +5 -12
  34. package/runtime/prompts/coding-preflight/languages/kotlin.md +2 -4
  35. package/runtime/prompts/coding-preflight/languages/python.md +2 -7
  36. package/runtime/prompts/coding-preflight/languages/rust.md +2 -8
  37. package/runtime/prompts/coding-preflight/languages/sql.md +2 -4
  38. package/runtime/prompts/coding-preflight/overview.md +25 -38
  39. package/runtime/prompts/coding-preflight/review-rules.json +30 -0
  40. package/runtime/prompts/duties/code-reviewer.json +15 -18
  41. package/runtime/prompts/duties/implementation-verifier.json +1 -0
  42. package/runtime/prompts/profiles/_coding-conventions-preflight.md +41 -6
  43. package/runtime/python/okstra_ctl/agent/invocation.py +121 -36
  44. package/runtime/python/okstra_ctl/agent/prompt_cli/cli.py +6 -0
  45. package/runtime/python/okstra_ctl/agent/prompt_cli/materialize.py +30 -4
  46. package/runtime/python/okstra_ctl/agent/standalone.py +3 -0
  47. package/runtime/python/okstra_ctl/analysis_packet.py +2 -19
  48. package/runtime/python/okstra_ctl/attempt_evidence.py +10 -0
  49. package/runtime/python/okstra_ctl/code_review_census.py +71 -7
  50. package/runtime/python/okstra_ctl/code_review_coverage.py +4 -274
  51. package/runtime/python/okstra_ctl/code_review_integrity.py +154 -0
  52. package/runtime/python/okstra_ctl/code_review_invocation.py +212 -0
  53. package/runtime/python/okstra_ctl/code_review_scope.py +36 -9
  54. package/runtime/python/okstra_ctl/code_review_target.py +85 -11
  55. package/runtime/python/okstra_ctl/consumers.py +12 -9
  56. package/runtime/python/okstra_ctl/design_review.py +207 -0
  57. package/runtime/python/okstra_ctl/design_review_evidence.py +297 -0
  58. package/runtime/python/okstra_ctl/doctor.py +8 -25
  59. package/runtime/python/okstra_ctl/doyouknow/__init__.py +9 -0
  60. package/runtime/python/okstra_ctl/doyouknow/cli.py +91 -0
  61. package/runtime/python/okstra_ctl/doyouknow/config.py +58 -0
  62. package/runtime/python/okstra_ctl/doyouknow/contracts.py +184 -0
  63. package/runtime/python/okstra_ctl/doyouknow/identity.py +22 -0
  64. package/runtime/python/okstra_ctl/doyouknow/paths.py +22 -0
  65. package/runtime/python/okstra_ctl/doyouknow/pending.py +72 -0
  66. package/runtime/python/okstra_ctl/doyouknow/registration.py +260 -0
  67. package/runtime/python/okstra_ctl/doyouknow/source_contracts.py +128 -0
  68. package/runtime/python/okstra_ctl/doyouknow/source_store.py +172 -0
  69. package/runtime/python/okstra_ctl/doyouknow/sources/io.py +36 -0
  70. package/runtime/python/okstra_ctl/doyouknow/sources/manager.py +261 -0
  71. package/runtime/python/okstra_ctl/doyouknow/sources/memory.py +179 -0
  72. package/runtime/python/okstra_ctl/doyouknow/sources/task.py +95 -0
  73. package/runtime/python/okstra_ctl/doyouknow/store.py +260 -0
  74. package/runtime/python/okstra_ctl/doyouknow/sync.py +58 -0
  75. package/runtime/python/okstra_ctl/execution_mutation_audit.py +18 -2
  76. package/runtime/python/okstra_ctl/file_size_cap.py +3 -4
  77. package/runtime/python/okstra_ctl/json_boundary.py +21 -2
  78. package/runtime/python/okstra_ctl/jsonl.py +21 -0
  79. package/runtime/python/okstra_ctl/manager_cli.py +26 -0
  80. package/runtime/python/okstra_ctl/manager_registration.py +29 -0
  81. package/runtime/python/okstra_ctl/manager_sync.py +3 -22
  82. package/runtime/python/okstra_ctl/model_io/renderers.py +13 -2
  83. package/runtime/python/okstra_ctl/model_io_cli.py +7 -1
  84. package/runtime/python/okstra_ctl/phases/final_verification/validation.py +20 -0
  85. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-deliverable.md +10 -0
  86. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-diff-review.md +19 -6
  87. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-self-check.md +5 -3
  88. package/runtime/python/okstra_ctl/phases/implementation/instructions/_implementation-verifier.md +38 -10
  89. package/runtime/python/okstra_ctl/phases/implementation/report_assets/implementation.template.html +13 -0
  90. package/runtime/python/okstra_ctl/phases/implementation/spec.md +25 -0
  91. package/runtime/python/okstra_ctl/phases/implementation/validation.py +6 -0
  92. package/runtime/python/okstra_ctl/phases/implementation_planning/authoring.py +4 -0
  93. package/runtime/python/okstra_ctl/phases/implementation_planning/profile.md +1 -1
  94. package/runtime/python/okstra_ctl/report_assembly.py +15 -0
  95. package/runtime/python/okstra_ctl/report_narrative.py +3 -0
  96. package/runtime/python/okstra_ctl/report_synthesis_packet.py +11 -2
  97. package/runtime/python/okstra_ctl/review_policy.py +359 -0
  98. package/runtime/python/okstra_ctl/review_verdicts.py +291 -0
  99. package/runtime/python/okstra_ctl/run.py +24 -1
  100. package/runtime/python/okstra_ctl/stage_done.py +11 -0
  101. package/runtime/python/okstra_ctl/standalone_review_audit.py +28 -0
  102. package/runtime/python/okstra_ctl/verification_generation.py +23 -1
  103. package/runtime/python/okstra_ctl/verification_input_types.py +15 -1
  104. package/runtime/python/okstra_ctl/verification_inputs.py +28 -6
  105. package/runtime/python/okstra_ctl/verification_invocation.py +7 -1
  106. package/runtime/python/okstra_ctl/verification_target.py +2 -0
  107. package/runtime/python/okstra_ctl/worker_prompt_headers.py +24 -9
  108. package/runtime/python/okstra_ctl/worker_runner.py +66 -10
  109. package/runtime/python/okstra_ctl/write_policy.py +34 -1
  110. package/runtime/python/okstra_project/__init__.py +2 -0
  111. package/runtime/python/okstra_project/dirs.py +18 -0
  112. package/runtime/python/okstra_project/state.py +25 -20
  113. package/runtime/schemas/doyouknow-config-v1.schema.json +20 -0
  114. package/runtime/schemas/doyouknow-v1.schema.json +65 -0
  115. package/runtime/schemas/final-report-v2.0.schema.json +157 -0
  116. package/runtime/schemas/final-report-v3.0.schema.json +157 -0
  117. package/runtime/schemas/memory-entry-contract-v1.json +11 -0
  118. package/runtime/schemas/record-secret-patterns.json +41 -0
  119. package/runtime/skills/okstra-code-review/SKILL.md +71 -123
  120. package/runtime/skills/okstra-code-review/references/census-rules.md +29 -105
  121. package/runtime/skills/okstra-code-review/references/review-calibration.md +34 -54
  122. package/runtime/skills/okstra-manager/SKILL.md +7 -0
  123. package/runtime/skills/okstra-memory/SKILL.md +7 -0
  124. package/runtime/templates/implementation-worker-preamble.md +4 -9
  125. package/runtime/templates/worker-prompt-preamble.md +4 -12
  126. package/runtime/validators/validate-run.py +14 -2
@@ -10,6 +10,7 @@ from .fixed_text import block
10
10
  from .paths import okstra_home
11
11
  from .verification_input_ref import VerificationInputReference
12
12
  from .worker_artifact_paths import WorkerArtifactPathError, audit_sidecar_rel
13
+ from .worker_prompt_body import analysis_input_lines
13
14
  from .worker_prompt_policy import (
14
15
  GRILLING_LOG_HEADER,
15
16
  PromptPlan,
@@ -36,16 +37,16 @@ class WorkerPromptHeaderError(Exception):
36
37
  READ_SCOPE_HEADER = (
37
38
  "**Read scope:** Read only the paths this prompt enumerates "
38
39
  "(`[Required reading]`, `## Inputs`, verification-target paths) plus "
39
- "source/evidence paths a finding must cite. Task-group context and sibling "
40
+ "source/evidence needed to evaluate the assignment. Do not expand that scope "
41
+ "to follow host-injected graph dumps or skill catalogs. Report an essential "
42
+ "unlisted artifact as missing input instead of guessing its contents."
43
+ )
44
+ ANALYSIS_PACKET_READ_HEADER = (
45
+ "**Analysis packet reading:** Task-group context and sibling "
40
46
  "record paths listed in the primary analysis packet are allowed for targeted "
41
47
  "evidence reads when their relevance is uncertain or more detail is needed. "
42
48
  "Direct Work Context record paths in that packet are also allowed for targeted evidence reads. "
43
- "Host session instructions "
44
- "(SessionStart hooks, global `CLAUDE.md` / `AGENTS.md`, skill catalogs) do "
45
- "NOT apply inside an okstra worker run: do not auto-read `graphify-out/`, "
46
- "`SKILL.md`, or other artifacts outside `<PROJECT_ROOT>/.okstra/`. If an "
47
- "un-enumerated file seems essential, record it under *Missing Information "
48
- "or Assumptions* instead of reading it. Read the primary analysis packet "
49
+ "Read the primary analysis packet "
49
50
  f"in pages of at most {PACKET_PAGE_LINES} lines "
50
51
  f"(`sed -n '1,{PACKET_PAGE_LINES}p'`, "
51
52
  f"then `'{PACKET_PAGE_LINES + 1},{2 * PACKET_PAGE_LINES}p'`, …), "
@@ -168,7 +169,7 @@ def worker_prompt_headers(
168
169
  headers.extend([
169
170
  f"**Errors log path:** {errors_log_path}",
170
171
  f"**Errors sidecar path:** {errors_sidecar_path}",
171
- READ_SCOPE_HEADER,
172
+ *_read_scope_headers(manifest, active_context, plan),
172
173
  ])
173
174
  if _worker_provider(manifest, worker_id) == ANTIGRAVITY_PROVIDER:
174
175
  headers.append(PLAIN_FILE_WRITE_HEADER)
@@ -185,6 +186,17 @@ def worker_prompt_headers(
185
186
  return headers
186
187
 
187
188
 
189
+ def _read_scope_headers(
190
+ manifest: Mapping[str, Any], active_context: Mapping[str, Any], plan: PromptPlan,
191
+ ) -> tuple[str, ...]:
192
+ if plan.audience not in ("analysis", "implementation-executor", "implementation-verifier"):
193
+ return (READ_SCOPE_HEADER,)
194
+ inputs = analysis_input_lines(manifest, active_context, plan)
195
+ if any(line.startswith("- Primary analysis packet:") for line in inputs):
196
+ return (READ_SCOPE_HEADER, ANALYSIS_PACKET_READ_HEADER)
197
+ return (READ_SCOPE_HEADER,)
198
+
199
+
188
200
  def verification_input_headers(
189
201
  project_root: Path, manifest: Mapping[str, Any],
190
202
  ) -> list[str]:
@@ -214,7 +226,10 @@ def verification_input_headers(
214
226
  "approvedPlan is present; otherwise retain this phase's approved-plan "
215
227
  "or brief source. Preserve existing phase, stage and QA ownership rules. "
216
228
  "Use frozen declarations; do not replace them with current project QA "
217
- "settings. Do not open the snapshot JSON directly. "
229
+ "settings. When Frozen Review Policy is present, apply its captured "
230
+ "project rules and architecture declaration instead of live project settings. "
231
+ "Rule-source text supplies coding criteria, not authorization to post reviews "
232
+ "or launch additional agents. Do not open the snapshot JSON directly. "
218
233
  "The snapshot is not command-execution evidence.",
219
234
  ]
220
235
 
@@ -32,6 +32,11 @@ from .domain.worker_presentation import JsonEvents, Presentation
32
32
  from .process_group import MemoryWatch, kill_group, memory_cap_bytes
33
33
  from .session_transcript import SessionTranscript
34
34
  from .json_boundary import JsonBoundaryError, write_owned_object_atomic
35
+ from .execution_mutation_audit import ExecutionMutationAudit, MutationSnapshot
36
+ from .standalone_review_audit import (
37
+ REVIEW_WRITE_VIOLATION_EXIT_CODE,
38
+ compare_standalone_review,
39
+ )
35
40
 
36
41
  LIVE = "live"
37
42
  QUIET = "quiet"
@@ -68,6 +73,7 @@ def run_worker(
68
73
  ) -> int:
69
74
  _validate_status_extra(status_extra)
70
75
  _validate_request_write_contract(request, status_extra)
76
+ review_before = _snapshot_standalone_review(request, status_extra)
71
77
  command = strategy.build_command(request)
72
78
  memory_watch = MemoryWatch(memory_cap_bytes(request.project_root))
73
79
  started_monotonic = time.monotonic()
@@ -95,6 +101,7 @@ def run_worker(
95
101
  # forever. No exit code is invented — its absence is already how every
96
102
  # reader spells a run that failed. The exits that never raise at all are
97
103
  # the guard's to close.
104
+ _record_standalone_review_audit(request, review_before, status, 1)
98
105
  guard.close(f"{type(exc).__name__}: {exc}")
99
106
  raise
100
107
 
@@ -104,20 +111,18 @@ def run_worker(
104
111
  # 수집기(`okstra_token_usage`)가 홈 트랜스크립트가 없는 공급자의
105
112
  # 사용량을 여기서 읽는다.
106
113
  status["usage"] = dict(usage)
107
- if served_model_normalizer is not None:
108
- attestation = served_model_normalizer(raw_model)
109
- status["servedModelAttestation"] = _attestation_payload(attestation)
110
- if served_model_verifier is not None:
111
- failure = served_model_verifier(attestation)
112
- if failure:
113
- status["failure"] = failure
114
- exit_code = SERVED_MODEL_MISMATCH_EXIT_CODE
114
+ exit_code = _record_served_model(status, served_model_normalizer,
115
+ served_model_verifier, raw_model, exit_code)
115
116
  if reaped:
116
117
  status["leftoverProcessesKilled"] = True
117
118
  if memory_watch.exceeded_bytes:
118
119
  exit_code = MEMORY_CAP_EXIT_CODE
119
120
  status.update(failure=memory_watch.failure(), terminated_by="memory-cap")
120
121
  status["exit_code"] = exit_code
122
+ if _record_standalone_review_audit(request, review_before, status, exit_code):
123
+ status["providerExitCode"] = exit_code
124
+ exit_code = REVIEW_WRITE_VIOLATION_EXIT_CODE
125
+ status["exit_code"] = exit_code
121
126
  if timed_out:
122
127
  status.update(
123
128
  timeout=True,
@@ -168,18 +173,69 @@ def _validate_status_extra(status_extra: Mapping[str, Any]) -> None:
168
173
  def _validate_request_write_contract(
169
174
  request: WorkerExecRequest, status_extra: Mapping[str, Any]
170
175
  ) -> None:
171
- if status_extra.get("executionIdentityVersion") != 2:
176
+ standalone = status_extra.get("standalonePurpose") == "code-review"
177
+ if status_extra.get("executionIdentityVersion") != 2 and not standalone:
172
178
  return
173
179
  policy = request.policy.write_policy
174
180
  enforcement = request.policy.write_enforcement
175
181
  if policy is None or enforcement is None:
176
- raise ValueError("v2 worker request has no write contract")
182
+ raise ValueError("audited worker request has no write contract")
183
+ if standalone and policy.source_mode != "source-readonly":
184
+ raise ValueError("standalone code review must be source-readonly")
177
185
  if status_extra.get("writePolicyDigest") != policy.digest:
178
186
  raise ValueError("v2 worker request write policy digest changed")
179
187
  if status_extra.get("writeEnforcement") != enforcement.to_payload():
180
188
  raise ValueError("v2 worker request write enforcement changed")
181
189
 
182
190
 
191
+ def _snapshot_standalone_review(
192
+ request: WorkerExecRequest, status_extra: Mapping[str, Any],
193
+ ) -> MutationSnapshot | None:
194
+ if status_extra.get("standalonePurpose") != "code-review":
195
+ return None
196
+ policy = request.policy.write_policy
197
+ assert policy is not None
198
+ return ExecutionMutationAudit().snapshot((policy,))
199
+
200
+
201
+ def _record_standalone_review_audit(
202
+ request: WorkerExecRequest, before: MutationSnapshot | None,
203
+ status: dict[str, Any], exit_code: int,
204
+ ) -> bool:
205
+ if before is None:
206
+ return False
207
+ policy = request.policy.write_policy
208
+ assert policy is not None
209
+ try:
210
+ result = compare_standalone_review(before, policy, succeeded=exit_code == 0)
211
+ except (OSError, ValueError) as exc:
212
+ status["writeAudit"] = {"mutationStatus": "error", "failure": str(exc)}
213
+ status["failure"] = "standalone review mutation audit could not complete"
214
+ return True
215
+ status["writeAudit"] = result.change_summary()
216
+ if result.violations:
217
+ status["failure"] = "standalone review write policy violated"
218
+ return True
219
+ return False
220
+
221
+
222
+ def _record_served_model(
223
+ status: dict[str, Any], normalizer: ServedModelNormalizer | None,
224
+ verifier: Callable[[ServedModelAttestation], str] | None,
225
+ raw_model: str | None, exit_code: int,
226
+ ) -> int:
227
+ if normalizer is None:
228
+ return exit_code
229
+ attestation = normalizer(raw_model)
230
+ status["servedModelAttestation"] = _attestation_payload(attestation)
231
+ if verifier is not None:
232
+ failure = verifier(attestation)
233
+ if failure:
234
+ status["failure"] = failure
235
+ return SERVED_MODEL_MISMATCH_EXIT_CODE
236
+ return exit_code
237
+
238
+
183
239
  def _launch(
184
240
  command: ExecCommand,
185
241
  log_path: Path,
@@ -6,7 +6,7 @@ import json
6
6
  import re
7
7
  import subprocess
8
8
  from collections.abc import Iterator, Mapping, Sequence
9
- from dataclasses import dataclass
9
+ from dataclasses import dataclass, replace
10
10
  from pathlib import Path, PurePosixPath
11
11
  from typing import Any, Literal
12
12
 
@@ -85,6 +85,39 @@ def build_write_policy(
85
85
  return policy
86
86
 
87
87
 
88
+ def build_standalone_review_write_contract(
89
+ project_root: Path, prompt_path: Path, metadata_path: Path,
90
+ metadata: Mapping[str, Any],
91
+ ) -> tuple[WritePolicy, WriteEnforcement]:
92
+ root = project_root.resolve()
93
+ artifacts = root / ".okstra/agent-invocations/code-review"
94
+ if prompt_path.resolve().parent != artifacts.resolve():
95
+ raise WritePolicyError("code-review prompt is outside its invocation directory")
96
+ stem = prompt_path.name.removesuffix(".prompt.md")
97
+ duty = root / str(metadata["contractSource"]["dutyRootPath"])
98
+ preserved = {
99
+ prompt_path.resolve().relative_to(root).as_posix(),
100
+ metadata_path.resolve().relative_to(root).as_posix(),
101
+ (artifacts / f"{stem}.review-policy.json").relative_to(root).as_posix(),
102
+ (artifacts / f"{stem}.review-source.json").relative_to(root).as_posix(),
103
+ (artifacts / f"{stem}.review-audit.json").relative_to(root).as_posix(),
104
+ *(path.relative_to(root).as_posix() for path in duty.rglob("*")
105
+ if path.is_file() or path.is_symlink()),
106
+ *(str(source["path"]) for source in metadata["instruction"]["sourcePaths"]
107
+ if source["kind"] == "project"),
108
+ }
109
+ policy = build_write_policy(
110
+ {"role": "verifier", "projectRoot": str(root),
111
+ "artifactPaths": [artifacts.relative_to(root).as_posix()],
112
+ "preservedPaths": sorted(preserved)},
113
+ {"workerWriteCapability": {"maxBoundaryPrecision": "none"}}, None,
114
+ )
115
+ enforcement = derive_write_enforcement(policy, "none", role="verifier")
116
+ return policy, replace(enforcement, unobserved_write_surfaces=(
117
+ *enforcement.unobserved_write_surfaces, "other-git-refs", "shared-git-object-store",
118
+ ))
119
+
120
+
88
121
  def _role_qa_artifact_paths(role: str, task_root: Path | None) -> tuple[Path, ...]:
89
122
  """The task `qa/` writes a role's own contract makes mandatory.
90
123
 
@@ -38,6 +38,7 @@ from .state import (
38
38
  resolve_task_id,
39
39
  resolve_task_identity,
40
40
  resolve_task_reference,
41
+ resolve_task_root_read_only,
41
42
  slugify,
42
43
  task_read_side_snapshot,
43
44
  )
@@ -66,6 +67,7 @@ __all__ = [
66
67
  "resolve_task_id",
67
68
  "resolve_task_identity",
68
69
  "resolve_task_reference",
70
+ "resolve_task_root_read_only",
69
71
  "slugify",
70
72
  "task_read_side_snapshot",
71
73
  "tasks_root",
@@ -85,6 +85,24 @@ def okstra_home() -> Path:
85
85
  return home
86
86
 
87
87
 
88
+ def contained_relative_path(ref: str, root: Path) -> str | None:
89
+ """Callers supply a resolved root for shared reference identity.
90
+
91
+ Unknown home names can be prose tokens such as ``~200``; the ``None``
92
+ result keeps those tokens from aborting source material processing.
93
+ Readers and writers share this interpretation so they name the same file.
94
+ """
95
+ try:
96
+ candidate = Path(ref).expanduser()
97
+ except RuntimeError:
98
+ return None
99
+ path = (candidate if candidate.is_absolute() else root / candidate).resolve()
100
+ try:
101
+ return path.relative_to(root).as_posix()
102
+ except ValueError:
103
+ return None
104
+
105
+
88
106
  def okstra_root(project_root: Path) -> Path:
89
107
  """`<project_root>/.okstra` 절대 path."""
90
108
  return Path(project_root) / OKSTRA_RELATIVE
@@ -206,6 +206,27 @@ def parse_task_key(task_key: str) -> tuple[str, str, str]:
206
206
  return parts[0], parts[1], parts[2]
207
207
 
208
208
 
209
+ def resolve_task_root_read_only(
210
+ project_root: Path, task_key: str, *, catalog: list[dict] | None = None,
211
+ ) -> Path | None:
212
+ project_root = Path(project_root)
213
+ _, task_group, task_id = parse_task_key(task_key)
214
+ requested_key = task_key.lower()
215
+ entries = read_task_catalog(project_root) if catalog is None else catalog
216
+ for entry in entries:
217
+ entry_key = entry.get("taskKey") or ""
218
+ if not isinstance(entry_key, str) or entry_key.lower() != requested_key:
219
+ continue
220
+ relative_path = entry.get("taskRootPath") or entry.get("taskRoot") or ""
221
+ if not isinstance(relative_path, str) or not relative_path:
222
+ continue
223
+ candidate = project_root / relative_path if not Path(relative_path).is_absolute() else Path(relative_path)
224
+ if candidate.is_dir():
225
+ return candidate
226
+ slug_path = project_root / TASKS_RELATIVE / slugify(task_group) / slugify(task_id)
227
+ return slug_path if slug_path.is_dir() else None
228
+
229
+
209
230
  def find_task_root(project_root: Path, task_key: str) -> Optional[Path]:
210
231
  """task-key 로 task root 디렉터리를 해석한다.
211
232
 
@@ -215,26 +236,10 @@ def find_task_root(project_root: Path, task_key: str) -> Optional[Path]:
215
236
 
216
237
  어느 쪽도 디렉터리로 존재하지 않으면 None.
217
238
  """
218
- project_root = Path(project_root)
219
- _, task_group, task_id = parse_task_key(task_key)
220
- requested_ci = task_key.lower()
221
-
222
- for entry in read_task_catalog(project_root):
223
- entry_key = entry.get("taskKey") or ""
224
- if not isinstance(entry_key, str) or entry_key.lower() != requested_ci:
225
- continue
226
- rel = entry.get("taskRootPath") or entry.get("taskRoot") or ""
227
- if isinstance(rel, str) and rel:
228
- abs_path = project_root / rel if not Path(rel).is_absolute() else Path(rel)
229
- if abs_path.is_dir():
230
- _reconcile_task_root_best_effort(project_root, abs_path)
231
- return abs_path
232
-
233
- slug_path = project_root / TASKS_RELATIVE / slugify(task_group) / slugify(task_id)
234
- if slug_path.is_dir():
235
- _reconcile_task_root_best_effort(project_root, slug_path)
236
- return slug_path
237
- return None
239
+ task_root = resolve_task_root_read_only(project_root, task_key)
240
+ if task_root is not None:
241
+ _reconcile_task_root_best_effort(Path(project_root), task_root)
242
+ return task_root
238
243
 
239
244
 
240
245
  def resolve_task_id(
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["schemaVersion", "autoRegister", "scope", "sources", "includeProjects", "excludeProjects", "includeGroups", "excludeGroups"],
6
+ "properties": {
7
+ "schemaVersion": {"type": "integer", "const": 1},
8
+ "autoRegister": {"type": "boolean"},
9
+ "scope": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/text"}]},
10
+ "sources": {"type": "array", "uniqueItems": true, "items": {"enum": ["memory", "manager", "task"]}},
11
+ "includeProjects": {"$ref": "#/$defs/names"},
12
+ "excludeProjects": {"$ref": "#/$defs/names"},
13
+ "includeGroups": {"$ref": "#/$defs/names"},
14
+ "excludeGroups": {"$ref": "#/$defs/names"}
15
+ },
16
+ "$defs": {
17
+ "text": {"type": "string", "minLength": 1, "pattern": "\\S"},
18
+ "names": {"type": "array", "maxItems": 1000, "uniqueItems": true, "items": {"$ref": "#/$defs/text"}}
19
+ }
20
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["schemaVersion", "scope", "recordKey", "requestId", "expectedPreviousRevision", "source", "record", "nodes", "relations"],
6
+ "properties": {
7
+ "schemaVersion": {"const": 1},
8
+ "scope": {"$ref": "#/$defs/text"},
9
+ "recordKey": {"$ref": "#/$defs/text"},
10
+ "requestId": {"$ref": "#/$defs/text"},
11
+ "expectedPreviousRevision": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/text"}]},
12
+ "source": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["kind", "id", "revision", "locator"],
16
+ "properties": {
17
+ "kind": {"$ref": "#/$defs/text"},
18
+ "id": {"$ref": "#/$defs/text"},
19
+ "revision": {"$ref": "#/$defs/text"},
20
+ "locator": {"$ref": "#/$defs/text"}
21
+ }
22
+ },
23
+ "record": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["title", "summary"],
27
+ "properties": {
28
+ "title": {"$ref": "#/$defs/text"},
29
+ "summary": {"$ref": "#/$defs/text"},
30
+ "body": {"type": "string"},
31
+ "type": {"enum": ["context", "work", "decision", "investigation", "verification", "follow-up"]}
32
+ }
33
+ },
34
+ "nodes": {"type": "array", "items": {"$ref": "#/$defs/node"}, "uniqueItems": true, "maxItems": 1000},
35
+ "relations": {"type": "array", "items": {"$ref": "#/$defs/relation"}, "uniqueItems": true, "maxItems": 4000}
36
+ },
37
+ "$defs": {
38
+ "text": {"type": "string", "minLength": 1, "pattern": "\\S"},
39
+ "node": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": ["key", "kind", "scope", "title"],
43
+ "properties": {
44
+ "key": {"$ref": "#/$defs/text"},
45
+ "ref": {"$ref": "#/$defs/text"},
46
+ "kind": {"enum": ["concept", "flow", "entity", "project", "repository", "commit", "ticket", "task", "artifact", "record"]},
47
+ "scope": {"$ref": "#/$defs/text"},
48
+ "title": {"$ref": "#/$defs/text"}
49
+ }
50
+ },
51
+ "relation": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": ["from", "to", "kind", "reason", "evidence", "standing"],
55
+ "properties": {
56
+ "from": {"$ref": "#/$defs/text"},
57
+ "to": {"$ref": "#/$defs/text"},
58
+ "kind": {"$ref": "#/$defs/text"},
59
+ "reason": {"$ref": "#/$defs/text"},
60
+ "evidence": {"type": "array", "items": {"$ref": "#/$defs/text"}, "minItems": 1},
61
+ "standing": {"enum": ["observed", "user-stated", "candidate"]}
62
+ }
63
+ }
64
+ }
65
+ }
@@ -9883,6 +9883,10 @@
9883
9883
  "not-run"
9884
9884
  ]
9885
9885
  },
9886
+ "designReview": {
9887
+ "$ref": "#/$defs/DesignReviewRecord",
9888
+ "description": "Assembly-owned independent design-review evidence from the current sealed verifier result."
9889
+ },
9886
9890
  "readOnlyCommandLog": {
9887
9891
  "type": "string"
9888
9892
  },
@@ -10591,6 +10595,159 @@
10591
10595
  "minimum": 1
10592
10596
  }
10593
10597
  }
10598
+ },
10599
+ "DesignReviewRecord": {
10600
+ "type": "object",
10601
+ "additionalProperties": false,
10602
+ "required": [
10603
+ "collection",
10604
+ "generationNumber",
10605
+ "verdict"
10606
+ ],
10607
+ "properties": {
10608
+ "collection": {
10609
+ "enum": [
10610
+ "complete",
10611
+ "incomplete"
10612
+ ]
10613
+ },
10614
+ "generationNumber": {
10615
+ "type": "integer",
10616
+ "minimum": 1
10617
+ },
10618
+ "verdict": {
10619
+ "enum": [
10620
+ "PASS",
10621
+ "CONCERNS",
10622
+ "FAIL",
10623
+ "not-run"
10624
+ ]
10625
+ },
10626
+ "reason": {
10627
+ "type": "string"
10628
+ },
10629
+ "head": {
10630
+ "type": "string"
10631
+ },
10632
+ "base": {
10633
+ "type": "string"
10634
+ },
10635
+ "policyDigest": {
10636
+ "type": "string"
10637
+ },
10638
+ "censusDigest": {
10639
+ "type": "string"
10640
+ },
10641
+ "invocationRef": {
10642
+ "type": "string"
10643
+ },
10644
+ "resultPath": {
10645
+ "type": "string"
10646
+ },
10647
+ "resultDigest": {
10648
+ "type": "string"
10649
+ },
10650
+ "scope": {
10651
+ "type": "string"
10652
+ },
10653
+ "generation": {
10654
+ "type": "object",
10655
+ "required": [
10656
+ "path",
10657
+ "digest"
10658
+ ],
10659
+ "additionalProperties": false,
10660
+ "properties": {
10661
+ "path": {
10662
+ "type": "string"
10663
+ },
10664
+ "digest": {
10665
+ "type": "string"
10666
+ }
10667
+ }
10668
+ },
10669
+ "attempt": {
10670
+ "type": "integer",
10671
+ "minimum": 1
10672
+ },
10673
+ "expectedCells": {
10674
+ "type": "integer",
10675
+ "minimum": 0
10676
+ },
10677
+ "coveredCells": {
10678
+ "type": "integer",
10679
+ "minimum": 0
10680
+ },
10681
+ "missing": {
10682
+ "type": "object",
10683
+ "additionalProperties": {
10684
+ "type": "string"
10685
+ }
10686
+ },
10687
+ "unknown": {
10688
+ "type": "array",
10689
+ "items": {
10690
+ "type": "string"
10691
+ }
10692
+ },
10693
+ "blockingFindings": {
10694
+ "type": "array",
10695
+ "items": {
10696
+ "type": "string"
10697
+ }
10698
+ },
10699
+ "findings": {
10700
+ "type": "array",
10701
+ "items": {
10702
+ "type": "object",
10703
+ "additionalProperties": {
10704
+ "type": "string"
10705
+ }
10706
+ }
10707
+ },
10708
+ "carry": {
10709
+ "type": "array",
10710
+ "items": {
10711
+ "type": "object",
10712
+ "additionalProperties": {
10713
+ "type": "string"
10714
+ }
10715
+ }
10716
+ },
10717
+ "history": {
10718
+ "type": "array",
10719
+ "items": {
10720
+ "$ref": "#/$defs/DesignReviewRecord"
10721
+ }
10722
+ }
10723
+ },
10724
+ "if": {
10725
+ "properties": {
10726
+ "collection": {
10727
+ "const": "complete"
10728
+ }
10729
+ }
10730
+ },
10731
+ "then": {
10732
+ "required": [
10733
+ "head",
10734
+ "base",
10735
+ "policyDigest",
10736
+ "censusDigest",
10737
+ "generation",
10738
+ "invocationRef",
10739
+ "attempt",
10740
+ "resultPath",
10741
+ "resultDigest",
10742
+ "expectedCells",
10743
+ "coveredCells",
10744
+ "missing",
10745
+ "unknown",
10746
+ "findings",
10747
+ "blockingFindings",
10748
+ "scope"
10749
+ ]
10750
+ }
10594
10751
  }
10595
10752
  }
10596
10753
  }