engineering-platform 2.2.0__py3-none-any.whl
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.
- engineering_platform/ENGINEERING_PLATFORM_CONFIG.json +32 -0
- engineering_platform/ENGINEERING_PLATFORM_VERSION.json +15 -0
- engineering_platform/__init__.py +1 -0
- engineering_platform/__main__.py +7 -0
- engineering_platform/agent_state.py +530 -0
- engineering_platform/agent_trust.py +174 -0
- engineering_platform/assets/dashboard.css +1317 -0
- engineering_platform/assets/dashboard.js +8534 -0
- engineering_platform/assets/dashboard_locales.mjs +4049 -0
- engineering_platform/assets/dashboard_status_store.mjs +41 -0
- engineering_platform/assets/operations-console/apple-touch-icon-dark.png +0 -0
- engineering_platform/assets/operations-console/apple-touch-icon-light.png +0 -0
- engineering_platform/assets/operations-console/icon-dark.png +0 -0
- engineering_platform/assets/operations-console/icon-light.png +0 -0
- engineering_platform/assets/operations-console/icon-transparent.png +0 -0
- engineering_platform/assets/operations-console/manifest.webmanifest +11 -0
- engineering_platform/capability_preflight.py +285 -0
- engineering_platform/capability_review.py +261 -0
- engineering_platform/central_data_transfer.py +195 -0
- engineering_platform/central_database.py +245 -0
- engineering_platform/central_store_migration.py +1672 -0
- engineering_platform/codex_capacity.py +81 -0
- engineering_platform/codex_chat.py +226 -0
- engineering_platform/codex_observability.py +153 -0
- engineering_platform/component_lock.py +40 -0
- engineering_platform/component_logging.py +420 -0
- engineering_platform/console_presentation.py +14 -0
- engineering_platform/console_route_ownership.py +83 -0
- engineering_platform/contracts/__init__.py +38 -0
- engineering_platform/contracts/ep_consumer.py +391 -0
- engineering_platform/contracts/models.py +105 -0
- engineering_platform/contracts/projection.py +401 -0
- engineering_platform/dashboard_browser_validation.py +206 -0
- engineering_platform/dashboard_state.py +630 -0
- engineering_platform/dashboard_supervisor.swift +105 -0
- engineering_platform/dashboard_translation.py +129 -0
- engineering_platform/dependabot_producer.py +349 -0
- engineering_platform/drift_diagnostics.py +144 -0
- engineering_platform/emergency_recovery.py +268 -0
- engineering_platform/engineering_memory.py +139 -0
- engineering_platform/ep_consumer_credentials.py +473 -0
- engineering_platform/evidence_projection.py +213 -0
- engineering_platform/execution_activity.py +218 -0
- engineering_platform/execution_context.py +132 -0
- engineering_platform/execution_errors.py +42 -0
- engineering_platform/execution_evidence.py +24 -0
- engineering_platform/execution_executor.py +730 -0
- engineering_platform/execution_finalization.py +44 -0
- engineering_platform/execution_host.py +3306 -0
- engineering_platform/execution_lease.py +365 -0
- engineering_platform/execution_lifecycle.py +447 -0
- engineering_platform/execution_models.py +43 -0
- engineering_platform/execution_readiness.py +166 -0
- engineering_platform/execution_reporting.py +1607 -0
- engineering_platform/execution_repository.py +253 -0
- engineering_platform/execution_timeout_policy.py +56 -0
- engineering_platform/execution_timing.py +440 -0
- engineering_platform/execution_transaction.py +28 -0
- engineering_platform/external_producer_binding.py +235 -0
- engineering_platform/file_inbox.py +249 -0
- engineering_platform/forensic_attribution.py +338 -0
- engineering_platform/forensic_attribution_v2.py +134 -0
- engineering_platform/forensic_delta.py +299 -0
- engineering_platform/golden_scenario.py +63 -0
- engineering_platform/historical_dashboard_configuration.py +171 -0
- engineering_platform/host_admin.py +199 -0
- engineering_platform/host_preflight.py +231 -0
- engineering_platform/installation_relocation.py +122 -0
- engineering_platform/investigation_ledger.py +89 -0
- engineering_platform/legacy_inbox_migration.py +79 -0
- engineering_platform/lifecycle_worker.py +223 -0
- engineering_platform/live_status.py +267 -0
- engineering_platform/local_api.py +209 -0
- engineering_platform/local_api_keychain.py +51 -0
- engineering_platform/local_repository_binding.py +138 -0
- engineering_platform/managed_autonomy.py +509 -0
- engineering_platform/managed_codex_runtime.py +105 -0
- engineering_platform/parity_context.py +203 -0
- engineering_platform/parity_lifecycle_dispatcher.py +488 -0
- engineering_platform/platform_admin.py +13 -0
- engineering_platform/platform_api.py +428 -0
- engineering_platform/platform_bootstrap.py +385 -0
- engineering_platform/platform_components.py +65 -0
- engineering_platform/platform_version.py +171 -0
- engineering_platform/pr_check_repair.py +276 -0
- engineering_platform/pr_evidence_backfill.py +278 -0
- engineering_platform/producer.py +209 -0
- engineering_platform/project_agent.py +366 -0
- engineering_platform/project_agent_service.py +244 -0
- engineering_platform/project_topology.py +126 -0
- engineering_platform/prompt_history.py +591 -0
- engineering_platform/provider_context.py +136 -0
- engineering_platform/provider_context_benchmark.py +41 -0
- engineering_platform/provider_context_scope.py +90 -0
- engineering_platform/provider_interruption.py +168 -0
- engineering_platform/provider_process_identity.py +80 -0
- engineering_platform/provider_readiness.py +138 -0
- engineering_platform/provider_recovery.py +647 -0
- engineering_platform/provider_usage.py +497 -0
- engineering_platform/providers.py +471 -0
- engineering_platform/qualification.py +220 -0
- engineering_platform/recommendation_handoff.py +238 -0
- engineering_platform/report_analysis.py +193 -0
- engineering_platform/repository_attachment.py +171 -0
- engineering_platform/repository_handoff.py +95 -0
- engineering_platform/resources.py +38 -0
- engineering_platform/reviewer_evidence.py +70 -0
- engineering_platform/schemas/repository-attachment.schema.json +61 -0
- engineering_platform/server.py +3679 -0
- engineering_platform/server_console_services.py +2024 -0
- engineering_platform/server_relay.py +172 -0
- engineering_platform/server_service.py +122 -0
- engineering_platform/status_model.py +135 -0
- engineering_platform/status_reconciliation.py +34 -0
- engineering_platform/storage.py +2440 -0
- engineering_platform/submission_cli.py +77 -0
- engineering_platform/submission_intake.py +45 -0
- engineering_platform/submission_service.py +317 -0
- engineering_platform/telemetry.py +951 -0
- engineering_platform/templates/workspace-config.json +25 -0
- engineering_platform/validation_identity.py +50 -0
- engineering_platform/validation_profile.py +211 -0
- engineering_platform/workspace_preflight.py +263 -0
- engineering_platform/worktree_provenance.py +147 -0
- engineering_platform/worktree_tooling.py +18 -0
- engineering_platform-2.2.0.dist-info/METADATA +18 -0
- engineering_platform-2.2.0.dist-info/RECORD +130 -0
- engineering_platform-2.2.0.dist-info/WHEEL +5 -0
- engineering_platform-2.2.0.dist-info/entry_points.txt +6 -0
- engineering_platform-2.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1607 @@
|
|
|
1
|
+
"""Terminal-report persistence coordination for the Execution Host."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
# Report formatting is deliberately pure: lifecycle only supplies the persisted
|
|
5
|
+
# transaction and evidence inputs.
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
import re
|
|
10
|
+
from typing import Callable, Mapping
|
|
11
|
+
|
|
12
|
+
from .agent_state import TransactionState, redact_diagnostic
|
|
13
|
+
from .drift_diagnostics import summary as drift_summary
|
|
14
|
+
from .execution_evidence import TerminalEvidenceBundle
|
|
15
|
+
from .execution_errors import RunnerError
|
|
16
|
+
from .execution_lease import history as lease_history, liveness as lease_liveness
|
|
17
|
+
from .execution_timing import timing_summary
|
|
18
|
+
from .execution_models import PullRequestEvidence, RepositoryEvidence
|
|
19
|
+
from .execution_repository import github_repository_slug
|
|
20
|
+
from .host_preflight import latest as latest_host_preflight
|
|
21
|
+
from .workspace_preflight import latest as latest_workspace_preflight
|
|
22
|
+
from .capability_preflight import latest as latest_capability_preflight
|
|
23
|
+
from .platform_version import EngineeringPlatformManifest
|
|
24
|
+
from .resources import package_path
|
|
25
|
+
from .producer import ProducerMetadata, parse_producer_metadata
|
|
26
|
+
from .providers import GitProvider
|
|
27
|
+
from .qualification import latest_qualification
|
|
28
|
+
from .recommendation_handoff import ForgeGovernanceHandoff, report_lines as recommendation_handoff_report_lines
|
|
29
|
+
from .storage import EngineeringStorageError, load_readiness_evaluation, load_run_qualification_snapshot, load_submission_for_run, load_run_lineage, load_validation_context
|
|
30
|
+
from .provider_usage import provider_usage_summary
|
|
31
|
+
from .provider_recovery import load_recovery_state
|
|
32
|
+
from .execution_activity import build_terminal_activity_summary, persist_terminal_activity_summary, terminal_activity_summary
|
|
33
|
+
from .managed_autonomy import terminal_snapshot as managed_autonomy_snapshot
|
|
34
|
+
from .validation_identity import is_canonical_dashboard_command
|
|
35
|
+
from .execution_executor import load_validation_failure_diagnostic
|
|
36
|
+
from .dashboard_browser_validation import load_dashboard_evidence
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ReportingCoordinator:
|
|
40
|
+
"""Own report delivery and validation; lifecycle remains caller-owned."""
|
|
41
|
+
|
|
42
|
+
def deliver(
|
|
43
|
+
self,
|
|
44
|
+
*,
|
|
45
|
+
path: Path,
|
|
46
|
+
body: str,
|
|
47
|
+
validate: Callable[[str], tuple[str, ...]],
|
|
48
|
+
terminal_matches: Callable[[str], bool],
|
|
49
|
+
) -> Path:
|
|
50
|
+
errors = validate(body)
|
|
51
|
+
if not terminal_matches(body) or errors:
|
|
52
|
+
details = "; ".join(errors) or "terminal state validation failed"
|
|
53
|
+
raise RunnerError(f"Engineering Report consistency validation failed: {details}")
|
|
54
|
+
path.write_text(body, encoding="utf-8")
|
|
55
|
+
return path
|
|
56
|
+
|
|
57
|
+
RETRY_REPORT_HEADERS = {
|
|
58
|
+
"retry_of": re.compile(r"(?mi)^retry[ _-]of\s*:\s*(inbox-[a-z0-9-]{6,64})\s*$"),
|
|
59
|
+
"original_run_id": re.compile(r"(?mi)^original[ _-]run[ _-]id\s*:\s*(inbox-[a-z0-9-]{6,64})\s*$"),
|
|
60
|
+
"retry_generation": re.compile(r"(?mi)^retry[ _-]generation\s*:\s*(\d+)\s*$"),
|
|
61
|
+
"retry_timestamp": re.compile(r"(?mi)^retry[ _-]timestamp\s*:\s*([^\n]{1,80})\s*$"),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _retry_relationship(state: TransactionState) -> tuple[str, ...]:
|
|
66
|
+
"""Render only explicit retry lineage, never the submitted prompt body."""
|
|
67
|
+
try:
|
|
68
|
+
prompt = Path(state.prompt_path).read_text(encoding="utf-8")
|
|
69
|
+
except OSError:
|
|
70
|
+
return ()
|
|
71
|
+
values = {key: pattern.search(prompt) for key, pattern in RETRY_REPORT_HEADERS.items()}
|
|
72
|
+
parent = values["retry_of"]
|
|
73
|
+
if parent is None:
|
|
74
|
+
return ()
|
|
75
|
+
original = values["original_run_id"].group(1) if values["original_run_id"] else parent.group(1)
|
|
76
|
+
generation = values["retry_generation"].group(1) if values["retry_generation"] else "1"
|
|
77
|
+
timestamp = values["retry_timestamp"].group(1).strip() if values["retry_timestamp"] else "not recorded"
|
|
78
|
+
return (
|
|
79
|
+
"## Retry Relationship",
|
|
80
|
+
f"- Retry Of: `{parent.group(1)}`",
|
|
81
|
+
f"- Original Run: `{original}`",
|
|
82
|
+
f"- Retry Generation: `{generation}`",
|
|
83
|
+
f"- Retry Timestamp: {timestamp}",
|
|
84
|
+
f"- Current Run: `{state.run_id}`",
|
|
85
|
+
f"- Terminal State: `{state.phase}`",
|
|
86
|
+
f"- Repository Context: `{state.repository}`",
|
|
87
|
+
"",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
REPORT_REQUIREMENT_EXCLUDED_HEADINGS = frozenset({"context", "canonical principle"})
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _component_inventory(bundle: TerminalEvidenceBundle) -> tuple[tuple[str, tuple[str, ...]], ...]:
|
|
95
|
+
"""Derive architectural components from changed implementation files."""
|
|
96
|
+
components: dict[str, list[str]] = {}
|
|
97
|
+
for path in bundle.changed_files:
|
|
98
|
+
if path.startswith("tests/") or path.endswith(".md"):
|
|
99
|
+
continue
|
|
100
|
+
lower = path.casefold()
|
|
101
|
+
if path == "src/engineering_platform/execution_host.py":
|
|
102
|
+
name = "Engineering Report Generator"
|
|
103
|
+
elif path.startswith("src/engineering_platform/assets/") or path == "src/engineering_platform/server_console_services.py":
|
|
104
|
+
name = "Engineering Evidence Dashboard"
|
|
105
|
+
elif "report_analysis" in lower:
|
|
106
|
+
name = "Engineering Report Analysis"
|
|
107
|
+
elif path.startswith("src/engineering_platform/"):
|
|
108
|
+
name = Path(path).stem.replace("_", " ").title()
|
|
109
|
+
else:
|
|
110
|
+
name = Path(path).stem.replace("_", " ").title()
|
|
111
|
+
components.setdefault(name, []).append(path)
|
|
112
|
+
return tuple((name, tuple(sorted(paths))) for name, paths in sorted(components.items()))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _objective_requirements(objective: str) -> tuple[str, ...]:
|
|
116
|
+
"""Extract reportable requirements from prompt sections without manual metadata."""
|
|
117
|
+
heading: str | None = None
|
|
118
|
+
requirements: list[str] = []
|
|
119
|
+
for line in objective.splitlines():
|
|
120
|
+
if line.startswith("#"):
|
|
121
|
+
heading = line.lstrip("#").strip().casefold()
|
|
122
|
+
continue
|
|
123
|
+
value = re.sub(r"^\s*(?:[-*]|\d+\.)\s+", "", line).strip()
|
|
124
|
+
if (
|
|
125
|
+
heading
|
|
126
|
+
and heading not in REPORT_REQUIREMENT_EXCLUDED_HEADINGS
|
|
127
|
+
and value
|
|
128
|
+
and not value.startswith("```")
|
|
129
|
+
and not re.match(r"^(?:execution mode|target repository):", value, re.IGNORECASE)
|
|
130
|
+
):
|
|
131
|
+
requirements.append(value)
|
|
132
|
+
if requirements:
|
|
133
|
+
return tuple(dict.fromkeys(requirements))
|
|
134
|
+
first = next((line.strip() for line in objective.splitlines() if line.strip()), "Objective unavailable.")
|
|
135
|
+
return (first,)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _deliverable_answer(objective: str, state: TransactionState) -> str:
|
|
139
|
+
"""Answer explicit binary delivery requests from the persisted terminal state."""
|
|
140
|
+
requested = re.search(r"\bYES\b|\bPASS\b|\bGO\b|\bNO-GO\b", objective, re.IGNORECASE)
|
|
141
|
+
if not requested:
|
|
142
|
+
return "Not explicitly requested by the prompt."
|
|
143
|
+
if state.phase == "COMPLETE":
|
|
144
|
+
return "YES / PASS / GO — the persisted terminal checkpoint is COMPLETE."
|
|
145
|
+
if state.phase == "BLOCKED":
|
|
146
|
+
return "NO / FAIL / NO-GO — the persisted terminal checkpoint is BLOCKED."
|
|
147
|
+
return "NO / FAIL / NO-GO — the persisted terminal checkpoint is FAILED."
|
|
148
|
+
|
|
149
|
+
def _next_action_message(action: str) -> str:
|
|
150
|
+
return {
|
|
151
|
+
"external_action_required": "Resolve the reported external dependency, then resume the run.",
|
|
152
|
+
"external_merge_authorization_required": "Obtain the required merge authorization.",
|
|
153
|
+
"required_checks_failed": "Inspect and resolve the failed required CI check.",
|
|
154
|
+
"inspect_codex_cli": "Inspect the redacted Codex CLI details above, then resume after correction.",
|
|
155
|
+
}.get(action, "Inspect current repository and GitHub evidence before resuming.")
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _format_terminal_report(state: TransactionState) -> str:
|
|
159
|
+
return f"{state.phase}\n\nReason:\n{state.diagnostic or 'No safe diagnostic was available.'}\n\nNext action:\n{_next_action_message(state.next_action)}"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _persisted_producer_submission(
|
|
163
|
+
root: Path, state: TransactionState, fallback_prompt: str, *,
|
|
164
|
+
central_database: Path | None = None,
|
|
165
|
+
) -> tuple[ProducerMetadata, dict[str, object] | None]:
|
|
166
|
+
"""Use immutable Producer submission evidence before legacy prompt compatibility."""
|
|
167
|
+
try:
|
|
168
|
+
submission = load_submission_for_run(root, state.run_id, central_database=central_database)
|
|
169
|
+
except EngineeringStorageError:
|
|
170
|
+
submission = None
|
|
171
|
+
if submission is None:
|
|
172
|
+
return parse_producer_metadata(fallback_prompt), None
|
|
173
|
+
return ProducerMetadata(
|
|
174
|
+
producer_id=str(submission["producer_id"]), producer_type=str(submission["producer_type"]),
|
|
175
|
+
producer_version=submission.get("producer_version") if isinstance(submission.get("producer_version"), str) else None,
|
|
176
|
+
correlation_id=submission.get("correlation_id") if isinstance(submission.get("correlation_id"), str) else None,
|
|
177
|
+
mission_id=submission.get("mission_id") if isinstance(submission.get("mission_id"), str) else None,
|
|
178
|
+
engineering_action_id=submission.get("engineering_action_id") if isinstance(submission.get("engineering_action_id"), str) else None,
|
|
179
|
+
), submission
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _producer_submission_contract_lines(
|
|
183
|
+
submission: dict[str, object] | None, state: TransactionState, root: Path | None = None,
|
|
184
|
+
) -> tuple[str, ...]:
|
|
185
|
+
context = submission.get("execution_context") if isinstance(submission, dict) else None
|
|
186
|
+
profile = context.get("validation_profile") if isinstance(context, dict) else None
|
|
187
|
+
validation_context = None
|
|
188
|
+
if root is not None:
|
|
189
|
+
try:
|
|
190
|
+
validation_context = load_validation_context(root, state.run_id)
|
|
191
|
+
except EngineeringStorageError:
|
|
192
|
+
validation_context = None
|
|
193
|
+
profile_source = (
|
|
194
|
+
validation_context.get("profile_selection_source", "not recorded")
|
|
195
|
+
if isinstance(validation_context, dict) and isinstance(profile, dict)
|
|
196
|
+
else "not supplied by Producer"
|
|
197
|
+
)
|
|
198
|
+
return (
|
|
199
|
+
"## Producer Submission Contract",
|
|
200
|
+
f"- Submission ID: `{submission.get('submission_id') if submission else 'legacy'}`",
|
|
201
|
+
f"- Contract Version: `{submission.get('contract_version') if submission else 'legacy prompt'}`",
|
|
202
|
+
"- Submission Status: `PERSISTED_IMMUTABLY`",
|
|
203
|
+
"",
|
|
204
|
+
"## Execution Context Contract",
|
|
205
|
+
f"- Execution Context Status: `{'SUPPLIED_BY_PRODUCER' if isinstance(context, dict) else 'NOT_SUPPLIED_BY_PRODUCER'}`",
|
|
206
|
+
f"- Execution Context Version: `{submission.get('execution_context_version') if isinstance(context, dict) else 'not supplied'}`",
|
|
207
|
+
f"- Execution Context Reference: `execution-submission:{submission.get('submission_id') if isinstance(context, dict) else 'legacy'}`",
|
|
208
|
+
f"- Action Intent: `{context.get('action_intent', 'not supplied') if isinstance(context, dict) else 'not supplied'}`",
|
|
209
|
+
f"- Validation Profile: `{profile.get('tier', 'not supplied') if isinstance(profile, dict) else 'not supplied'}`",
|
|
210
|
+
f"- Validation Profile Source: `{profile_source}`",
|
|
211
|
+
"- Snapshot: " + (json.dumps(context, sort_keys=True) if isinstance(context, dict) else "Not supplied by Producer."),
|
|
212
|
+
f"- Execution Status: `{state.phase}`",
|
|
213
|
+
"",
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _repository_summary(evidence: RepositoryEvidence) -> str:
|
|
218
|
+
return redact_diagnostic(
|
|
219
|
+
f"branch={evidence.branch}; head={evidence.head_sha}; clean={evidence.clean}; main_contains_head={evidence.main_contains_head}"
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _pull_request_summary(evidence: PullRequestEvidence) -> str:
|
|
224
|
+
failed = ",".join(evidence.failed_checks) or "none"
|
|
225
|
+
return redact_diagnostic(
|
|
226
|
+
f"pr={evidence.number}; state={evidence.state}; terminal={evidence.checks_terminal}; passed={evidence.checks_passed}; failed_checks={failed}"
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _git_output(root: Path, *args: str) -> str | None:
|
|
231
|
+
"""Return bounded Git output without allowing evidence collection to affect a run."""
|
|
232
|
+
try:
|
|
233
|
+
result = GitProvider().execute(root, "git", *args)
|
|
234
|
+
except OSError:
|
|
235
|
+
return None
|
|
236
|
+
return result.stdout.strip() if result.returncode == 0 else None
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _target_workspace(root: Path, state: TransactionState) -> Path:
|
|
240
|
+
"""Resolve the engineering target without changing execution selection."""
|
|
241
|
+
return Path(state.genesis_repository_path).expanduser().resolve() if state.execution_mode == "GENESIS" and state.genesis_repository_path else root.resolve()
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _target_repository_name(target: Path, fallback: str) -> str:
|
|
245
|
+
remote = _git_output(target, "remote", "get-url", "origin")
|
|
246
|
+
if remote:
|
|
247
|
+
return github_repository_slug(remote)
|
|
248
|
+
return fallback
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _evidence_baseline(state: TransactionState, target: Path, target_commit: str) -> str | None:
|
|
252
|
+
"""Find the parent preceding the terminal transaction when Git can prove it."""
|
|
253
|
+
first_commit = (
|
|
254
|
+
state.genesis_commit_sha
|
|
255
|
+
if state.execution_mode == "GENESIS"
|
|
256
|
+
else state.implementation_merge_commit or state.finalization_merge_commit
|
|
257
|
+
)
|
|
258
|
+
if not first_commit:
|
|
259
|
+
return None
|
|
260
|
+
parent = _git_output(target, "rev-parse", f"{first_commit}^")
|
|
261
|
+
return parent if parent and _git_output(target, "rev-parse", target_commit) else None
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def collect_terminal_evidence(root: Path, state: TransactionState) -> TerminalEvidenceBundle:
|
|
265
|
+
"""Collect a bounded, read-only target-repository evidence bundle."""
|
|
266
|
+
target = _target_workspace(root, state)
|
|
267
|
+
branch = _git_output(target, "branch", "--show-current") or "unavailable"
|
|
268
|
+
commit = state.genesis_commit_sha or _git_output(target, "rev-parse", "HEAD") or "unavailable"
|
|
269
|
+
status = _git_output(target, "status", "--porcelain", "--untracked-files=all")
|
|
270
|
+
worktree = "unavailable" if status is None else ("clean" if not status else "dirty")
|
|
271
|
+
baseline = _evidence_baseline(state, target, commit)
|
|
272
|
+
root_genesis_commit = state.execution_mode == "GENESIS" and state.genesis_commit_sha == commit
|
|
273
|
+
names = (
|
|
274
|
+
_git_output(target, "diff", "--name-status", "-M", baseline, commit)
|
|
275
|
+
if baseline
|
|
276
|
+
else _git_output(target, "diff-tree", "--root", "--no-commit-id", "-r", "--name-status", commit)
|
|
277
|
+
if root_genesis_commit
|
|
278
|
+
else None
|
|
279
|
+
)
|
|
280
|
+
added: list[str] = []
|
|
281
|
+
modified: list[str] = []
|
|
282
|
+
removed: list[str] = []
|
|
283
|
+
renamed: list[tuple[str, str]] = []
|
|
284
|
+
if names:
|
|
285
|
+
for row in names.splitlines():
|
|
286
|
+
fields = row.split("\t")
|
|
287
|
+
status_code = fields[0] if fields else ""
|
|
288
|
+
if len(fields) < 2:
|
|
289
|
+
continue
|
|
290
|
+
path = fields[1]
|
|
291
|
+
if status_code.startswith("R") and len(fields) >= 3:
|
|
292
|
+
renamed.append((fields[1], fields[2]))
|
|
293
|
+
continue
|
|
294
|
+
if status_code.startswith("A"):
|
|
295
|
+
added.append(path)
|
|
296
|
+
elif status_code.startswith("D"):
|
|
297
|
+
removed.append(path)
|
|
298
|
+
else:
|
|
299
|
+
modified.append(path)
|
|
300
|
+
changed = tuple(sorted(set(added + modified + removed + [path for pair in renamed for path in pair])))
|
|
301
|
+
diff = (
|
|
302
|
+
_git_output(target, "diff", "--check", baseline, commit)
|
|
303
|
+
if baseline
|
|
304
|
+
else _git_output(target, "diff-tree", "--root", "--check", commit)
|
|
305
|
+
if root_genesis_commit
|
|
306
|
+
else _git_output(target, "diff", "--check")
|
|
307
|
+
)
|
|
308
|
+
diff_check = "PASS" if diff == "" else "FAIL" if diff is not None else "UNAVAILABLE"
|
|
309
|
+
resulting_commit = (
|
|
310
|
+
state.genesis_commit_sha if state.execution_mode == "GENESIS" else
|
|
311
|
+
state.finalization_merge_commit or state.implementation_merge_commit or state.implementation_head_sha
|
|
312
|
+
)
|
|
313
|
+
return TerminalEvidenceBundle(
|
|
314
|
+
target_workspace=str(target),
|
|
315
|
+
# Genesis evidence belongs to the selected local target, never to the
|
|
316
|
+
# Engineering Platform host repository when that target has no origin.
|
|
317
|
+
target_repository=_target_repository_name(
|
|
318
|
+
target,
|
|
319
|
+
target.name if state.execution_mode == "GENESIS" else state.repository,
|
|
320
|
+
),
|
|
321
|
+
target_branch=branch,
|
|
322
|
+
target_commit=commit,
|
|
323
|
+
worktree_state=worktree,
|
|
324
|
+
changed_files=changed,
|
|
325
|
+
files_added=tuple(added),
|
|
326
|
+
files_modified=tuple(modified),
|
|
327
|
+
files_removed=tuple(removed),
|
|
328
|
+
files_renamed=tuple(renamed),
|
|
329
|
+
diff_check=diff_check,
|
|
330
|
+
transaction_baseline="AVAILABLE" if baseline or root_genesis_commit else "UNAVAILABLE",
|
|
331
|
+
transaction_baseline_sha=baseline,
|
|
332
|
+
resulting_commit=resulting_commit,
|
|
333
|
+
lease=lease_history(root, state.run_id),
|
|
334
|
+
readiness=load_readiness_evaluation(root, state.run_id),
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _evidence_lines(label: str, values: tuple[str, ...]) -> tuple[str, ...]:
|
|
339
|
+
if not values:
|
|
340
|
+
return (f"- {label}: none recorded",)
|
|
341
|
+
return tuple(f"- {label}: `{value}`" for value in values)
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def _implementation_evidence(bundle: TerminalEvidenceBundle) -> str:
|
|
345
|
+
"""Classify file-level evidence without inferring unrecorded implementation intent."""
|
|
346
|
+
changed = bundle.changed_files
|
|
347
|
+
groups = {
|
|
348
|
+
"Implemented components": tuple(path for path in changed if path.startswith("src/engineering_platform/")),
|
|
349
|
+
"Updated models": tuple(path for path in changed if "model" in path.casefold() or "state" in path.casefold()),
|
|
350
|
+
"Updated documentation": tuple(path for path in changed if path.endswith(".md")),
|
|
351
|
+
"Updated tests": tuple(path for path in changed if path.startswith("tests/") or "/test_" in path),
|
|
352
|
+
"Updated contracts": tuple(path for path in changed if any(token in path.casefold() for token in ("contract", "schema", "openapi"))),
|
|
353
|
+
"Updated schemas": tuple(path for path in changed if path.endswith((".json", ".yaml", ".yml"))),
|
|
354
|
+
}
|
|
355
|
+
lines: list[str] = []
|
|
356
|
+
for label, files in groups.items():
|
|
357
|
+
lines.extend(_evidence_lines(label, files))
|
|
358
|
+
return "\n".join(lines)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def _component_inventory_lines(bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
362
|
+
inventory = _component_inventory(bundle)
|
|
363
|
+
if not inventory:
|
|
364
|
+
return ("- No implementation components were detected from changed repository files.",)
|
|
365
|
+
lines: list[str] = []
|
|
366
|
+
for component, files in inventory:
|
|
367
|
+
lines.append(f"- Component: `{component}`")
|
|
368
|
+
lines.extend(f" - Repository file: `{path}`" for path in files)
|
|
369
|
+
lines.extend(
|
|
370
|
+
f" - Change classification: `{classification}`"
|
|
371
|
+
for classification, candidates in (
|
|
372
|
+
("added", bundle.files_added),
|
|
373
|
+
("modified", bundle.files_modified),
|
|
374
|
+
("removed", bundle.files_removed),
|
|
375
|
+
)
|
|
376
|
+
if any(path in candidates for path in files)
|
|
377
|
+
)
|
|
378
|
+
lines.append("- Generated Components: none recorded by repository evidence.")
|
|
379
|
+
return tuple(lines)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def _commit_strategy(state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
383
|
+
if state.execution_mode == "GENESIS":
|
|
384
|
+
return (
|
|
385
|
+
"- Strategy: `Genesis Local Commit`",
|
|
386
|
+
f"- Resulting local commit: `{state.genesis_commit_sha or bundle.target_commit}`",
|
|
387
|
+
)
|
|
388
|
+
if state.finalization_merge_commit:
|
|
389
|
+
strategy = "Managed Merge"
|
|
390
|
+
elif state.implementation_pull_request:
|
|
391
|
+
strategy = "Managed Pull Request"
|
|
392
|
+
else:
|
|
393
|
+
strategy = "Finalization" if state.transaction_kind == "FINALIZATION" else "Managed execution"
|
|
394
|
+
return (
|
|
395
|
+
f"- Strategy: `{strategy}`",
|
|
396
|
+
f"- Implementation PR: `{state.implementation_pull_request or 'not recorded'}`",
|
|
397
|
+
f"- Implementation merge: `{state.implementation_merge_commit or 'not recorded'}`",
|
|
398
|
+
f"- Finalization PR: `{state.finalization_pull_request or 'not recorded'}`",
|
|
399
|
+
f"- Finalization merge: `{state.finalization_merge_commit or 'not recorded'}`",
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _branch_traceability(state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
404
|
+
preflight = state.branch or "not recorded"
|
|
405
|
+
execution = state.implementation_branch or state.branch or bundle.target_branch
|
|
406
|
+
final_branch = bundle.target_branch
|
|
407
|
+
transition = "unchanged" if preflight == execution == final_branch else "recorded lifecycle transition"
|
|
408
|
+
mutation = "NONE" if bundle.resulting_commit is None else ("NONE" if not bundle.changed_files else "RECORDED")
|
|
409
|
+
return (
|
|
410
|
+
f"- Initial Repository Baseline: `{bundle.transaction_baseline}`",
|
|
411
|
+
f"- Repository Mutation: `{mutation}`",
|
|
412
|
+
"- Files Changed By Provider Execution: UNAVAILABLE (provider-stage mutation is not persisted by the terminal checkpoint).",
|
|
413
|
+
f"- Files Changed In Run Delivery Diff: `{len(bundle.changed_files)}`",
|
|
414
|
+
f"- Run Delivery Files: {', '.join(f'`{path}`' for path in bundle.changed_files) or 'NONE'}",
|
|
415
|
+
"- Generated / Projection Files: UNAVAILABLE unless classified by repository evidence.",
|
|
416
|
+
"- Pre-existing Local Changes: NONE when the terminal worktree is clean; otherwise UNAVAILABLE.",
|
|
417
|
+
f"- Preflight branch: `{preflight}`",
|
|
418
|
+
f"- Execution branch: `{execution}`",
|
|
419
|
+
f"- Final repository branch: `{final_branch}`",
|
|
420
|
+
f"- Final repository commit: `{bundle.target_commit}`",
|
|
421
|
+
f"- Resulting New Commit: `{bundle.resulting_commit or 'NONE'}`",
|
|
422
|
+
f"- Target Commit: `{bundle.target_commit}`",
|
|
423
|
+
f"- Repository state transition: {transition}.",
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def _requirement_traceability(objective: str, state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
428
|
+
requirements = _objective_requirements(objective)
|
|
429
|
+
components = _component_inventory(bundle)
|
|
430
|
+
component_names = ", ".join(f"`{name}`" for name, _ in components) or "No implementation component detected"
|
|
431
|
+
files = ", ".join(f"`{path}`" for path in bundle.changed_files) or "No changed files recorded"
|
|
432
|
+
tests = ", ".join(f"`{path}`" for path in bundle.changed_files if path.startswith("tests/")) or "No regression test file recorded"
|
|
433
|
+
validation = "; ".join(item["result"] for item in state.validation_evidence) or "Not recorded by the runner"
|
|
434
|
+
lines: list[str] = []
|
|
435
|
+
for requirement in requirements:
|
|
436
|
+
lines.extend((
|
|
437
|
+
f"- Requirement: {requirement}",
|
|
438
|
+
f" - Implemented component: {component_names}",
|
|
439
|
+
f" - Repository files: {files}",
|
|
440
|
+
f" - Runtime evidence: run `{state.run_id}`; execution mode `{state.execution_mode}`.",
|
|
441
|
+
f" - Execution evidence: terminal checkpoint `{state.phase}`.",
|
|
442
|
+
f" - Regression tests: {tests}",
|
|
443
|
+
f" - Validation evidence: {validation}",
|
|
444
|
+
" - Report evidence: this immutable Engineering Report.",
|
|
445
|
+
))
|
|
446
|
+
return tuple(lines)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _validation_traceability(state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
450
|
+
# Command summaries returned by an agent are advisory only. The canonical
|
|
451
|
+
# control section below projects the persisted invocation/terminal lineage;
|
|
452
|
+
# repeating an independently inferred inclusion state here caused Proof v5's
|
|
453
|
+
# AVAILABLE/UNAVAILABLE contradiction.
|
|
454
|
+
return (
|
|
455
|
+
"- Executed Validation Command: `Documentation validation`",
|
|
456
|
+
" - Result: report documentation is rendered from the canonical reporting contract",
|
|
457
|
+
) + tuple(
|
|
458
|
+
line
|
|
459
|
+
for record in state.validation_evidence
|
|
460
|
+
if not is_canonical_dashboard_command(record["command"])
|
|
461
|
+
for line in (
|
|
462
|
+
f"- Executed Validation Command: `{record['command']}`",
|
|
463
|
+
f" - Result: {record['result']}",
|
|
464
|
+
)
|
|
465
|
+
) + (
|
|
466
|
+
"- Individual validation inclusion and results are projected only from persisted Validation Control Results.",
|
|
467
|
+
f"- Transaction Baseline Availability: `{bundle.transaction_baseline}` (repository evidence; not a validation control).",
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
_VALIDATION_CONTROLS = (
|
|
472
|
+
("full_regression", "Full regression suite", "Regression", "LOCAL", ("unittest", "pytest", "regression")),
|
|
473
|
+
("ruff", "Ruff", "Lint", "LOCAL", ("ruff",)),
|
|
474
|
+
("bandit", "Bandit", "Security", "LOCAL", ("bandit",)),
|
|
475
|
+
("dependency_audit", "Dependency audit", "Security", "LOCAL", ("pip-audit", "dependency audit", "safety")),
|
|
476
|
+
("codeql", "CodeQL", "Security", "GITHUB_CI", ("codeql",)),
|
|
477
|
+
("semgrep", "Semgrep", "Security", "GITHUB_CI", ("semgrep",)),
|
|
478
|
+
("dashboard_browser", "Dashboard/browser tests", "Browser", "LOCAL", ("playwright", "browser", "dashboard.spec")),
|
|
479
|
+
("git_diff_check", "git diff --check", "Repository", "LOCAL", ("git diff --check",)),
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def _validation_control_projection(root: Path, state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
484
|
+
"""Render every required control without promoting absent evidence to PASS."""
|
|
485
|
+
records = tuple(state.validation_evidence) + ({"command": "git diff --check", "result": bundle.diff_check},)
|
|
486
|
+
try:
|
|
487
|
+
validation_context = load_validation_context(root, state.run_id)
|
|
488
|
+
except EngineeringStorageError:
|
|
489
|
+
validation_context = None
|
|
490
|
+
stored_controls = validation_context.get("controls", {}) if isinstance(validation_context, dict) else {}
|
|
491
|
+
required_controls = validation_context.get("required_validation_controls", ()) if isinstance(validation_context, dict) else ()
|
|
492
|
+
bindings = validation_context.get("control_bindings", ()) if isinstance(validation_context, dict) else ()
|
|
493
|
+
binding_by_id = {
|
|
494
|
+
binding.get("validation_id"): binding
|
|
495
|
+
for binding in bindings
|
|
496
|
+
if isinstance(binding, dict) and isinstance(binding.get("validation_id"), str)
|
|
497
|
+
}
|
|
498
|
+
lines = ["## Validation Control Results", "- Engineering Platform Qualification is reported separately from these individual controls."]
|
|
499
|
+
if isinstance(required_controls, tuple) and required_controls:
|
|
500
|
+
controls = tuple(
|
|
501
|
+
(
|
|
502
|
+
control_id,
|
|
503
|
+
f"Required control {control_id}",
|
|
504
|
+
str(binding_by_id.get(control_id, {}).get("category") or "Unspecified").title(),
|
|
505
|
+
"PERSISTED_PROFILE",
|
|
506
|
+
(),
|
|
507
|
+
)
|
|
508
|
+
for control_id in required_controls
|
|
509
|
+
)
|
|
510
|
+
else:
|
|
511
|
+
controls = _VALIDATION_CONTROLS
|
|
512
|
+
for control_id, name, category, source, markers in controls:
|
|
513
|
+
stored = stored_controls.get(control_id) if isinstance(stored_controls, dict) else None
|
|
514
|
+
# The terminal Evidence Bundle is appended last and therefore wins over
|
|
515
|
+
# historical checkpoint entries for the current projection.
|
|
516
|
+
match = next((
|
|
517
|
+
record for record in reversed(records)
|
|
518
|
+
if (
|
|
519
|
+
is_canonical_dashboard_command(record["command"])
|
|
520
|
+
if control_id == "dashboard_browser"
|
|
521
|
+
else any(marker in record["command"].casefold() for marker in markers)
|
|
522
|
+
)
|
|
523
|
+
), None)
|
|
524
|
+
if isinstance(stored, dict):
|
|
525
|
+
result = str(stored.get("result") or "UNAVAILABLE")
|
|
526
|
+
reference = str(stored.get("control_identity") or "not recorded")
|
|
527
|
+
execution_status = str(stored.get("execution_status") or "UNAVAILABLE")
|
|
528
|
+
# The persisted control binding is authoritative. Re-parsing a
|
|
529
|
+
# provider's shell transport here can disagree with the command
|
|
530
|
+
# receipt that produced this control.
|
|
531
|
+
included = "AVAILABLE" if execution_status == "EXECUTED" else "UNAVAILABLE"
|
|
532
|
+
elif match is None:
|
|
533
|
+
result, reference = "NOT_EXECUTED", "not recorded"
|
|
534
|
+
execution_status, included = "NOT_EXECUTED", "UNAVAILABLE"
|
|
535
|
+
else:
|
|
536
|
+
raw = match["result"].casefold()
|
|
537
|
+
result = (
|
|
538
|
+
"NOT_APPLICABLE" if "not applicable" in raw else
|
|
539
|
+
"UNAVAILABLE" if "unavailable" in raw else
|
|
540
|
+
"FAIL" if any(value in raw for value in ("fail", "error", "blocked")) else "PASS"
|
|
541
|
+
)
|
|
542
|
+
reference = match["command"]
|
|
543
|
+
execution_status = "EXECUTED"
|
|
544
|
+
included = "AVAILABLE" if execution_status == "EXECUTED" else "UNAVAILABLE"
|
|
545
|
+
lines.extend((
|
|
546
|
+
f"- {name}: `{result}` — `{source}`",
|
|
547
|
+
f" - Validation ID: `{control_id}`; Category: `{category}`; Check: `{reference}`.",
|
|
548
|
+
f" - Execution status: `{execution_status}`.",
|
|
549
|
+
" - Start/End/Duration: bounded by the canonical validation span when recorded.",
|
|
550
|
+
f" - Evidence Reference: `{stored.get('evidence_ref', 'UNAVAILABLE')}`." if isinstance(stored, dict) else " - Evidence Reference: persisted terminal checkpoint and Evidence Bundle.",
|
|
551
|
+
f" - Execution inclusion: `{included}`.",
|
|
552
|
+
))
|
|
553
|
+
if isinstance(stored, dict) and stored.get("exit_code") is not None:
|
|
554
|
+
lines.append(f" - Authoritative Exit Code: `{stored['exit_code']}`.")
|
|
555
|
+
if isinstance(stored, dict) and result != "PASS":
|
|
556
|
+
diagnostic_reference = str(stored.get("diagnostic_evidence_ref") or "UNAVAILABLE")
|
|
557
|
+
diagnostic = load_validation_failure_diagnostic(root, diagnostic_reference)
|
|
558
|
+
lines.append(f" - Failure Diagnostic Evidence: `{diagnostic_reference}`.")
|
|
559
|
+
if isinstance(diagnostic, dict):
|
|
560
|
+
identities = diagnostic.get("failing_test_identities")
|
|
561
|
+
identity_text = ", ".join(f"`{identity}`" for identity in identities) if isinstance(identities, list) and identities else "`UNAVAILABLE`"
|
|
562
|
+
lines.extend((
|
|
563
|
+
f" - Failing Test Identities: {identity_text}.",
|
|
564
|
+
f" - Failure Diagnostic Capture: `{diagnostic.get('capture_status', 'UNAVAILABLE')}`; Redaction: `{diagnostic.get('redaction_applied', False)}`; Truncation: `stdout={diagnostic.get('stdout_truncated', False)}, stderr={diagnostic.get('stderr_truncated', False)}`.",
|
|
565
|
+
))
|
|
566
|
+
summary = redact_diagnostic(
|
|
567
|
+
str(diagnostic.get("stderr_tail") or diagnostic.get("stdout_tail") or "(empty)"), limit=600
|
|
568
|
+
)
|
|
569
|
+
lines.append(f" - Bounded Failure Summary: `{summary}`.")
|
|
570
|
+
if control_id == "dashboard_browser" and isinstance(stored, dict):
|
|
571
|
+
shard_evidence = load_dashboard_evidence(root, state.run_id)
|
|
572
|
+
if str(stored.get("evidence_ref", "")).startswith("artifact:") and shard_evidence is not None:
|
|
573
|
+
shard_results = ", ".join(
|
|
574
|
+
f"{item['shard']}={item['result']}" for item in shard_evidence["shards"]
|
|
575
|
+
)
|
|
576
|
+
lines.extend((
|
|
577
|
+
f" - Shard Topology: `{shard_evidence['actual_shard_count']}/{shard_evidence['expected_shard_count']}` shards; `{shard_evidence['workers_per_shard']}` worker per shard.",
|
|
578
|
+
f" - Shard Results: `{shard_results}`.",
|
|
579
|
+
f" - Cleanup Evidence: `{shard_evidence['cleanup']}` (separate from the canonical terminal result).",
|
|
580
|
+
))
|
|
581
|
+
lines.extend((
|
|
582
|
+
f"- Transaction Baseline Availability: `{bundle.transaction_baseline}` (repository evidence; not a validation control).",
|
|
583
|
+
"- Qualification and individual-control results are intentionally independent.",
|
|
584
|
+
))
|
|
585
|
+
return tuple(lines)
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def _execution_statistics(
|
|
589
|
+
state: TransactionState, bundle: TerminalEvidenceBundle, timing: Mapping[str, object]
|
|
590
|
+
) -> tuple[str, ...]:
|
|
591
|
+
validation_duration = (
|
|
592
|
+
f"`{int(timing['validation_time_ms']) / 1000:.3f}` seconds"
|
|
593
|
+
if timing.get("phase_telemetry_available") and isinstance(timing.get("validation_time_ms"), int)
|
|
594
|
+
else "not measured"
|
|
595
|
+
)
|
|
596
|
+
return (
|
|
597
|
+
"- Execution Count: `1`",
|
|
598
|
+
f"- Engineering Actions: `{len(bundle.changed_files) + len(state.validation_evidence)}` evidence-backed action(s)",
|
|
599
|
+
"- Mission Count (Forge): `0` (Forge is outside this reporting increment)",
|
|
600
|
+
f"- Repair Iterations: `{state.repair_iterations}`",
|
|
601
|
+
f"- Provider Execution Time: `{state.agent_execution_seconds if state.agent_execution_seconds is not None else 'not measured'}` seconds",
|
|
602
|
+
"- Execution Duration (legacy): Provider Execution Time.",
|
|
603
|
+
f"- Validation Time: {validation_duration} ({len(state.validation_evidence)} recorded validation(s))",
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def _statistics_projection(state: TransactionState, bundle: TerminalEvidenceBundle) -> tuple[str, ...]:
|
|
608
|
+
"""Project separately scoped metrics without inferring mission completion."""
|
|
609
|
+
return (
|
|
610
|
+
"### Mission Statistics",
|
|
611
|
+
"- Mission Count: `0` (Forge mission state is not inferred by Engineering Platform).",
|
|
612
|
+
"### Execution Statistics",
|
|
613
|
+
"- Execution Count: `1`",
|
|
614
|
+
f"- Provider Execution Time: `{state.agent_execution_seconds if state.agent_execution_seconds is not None else 'not measured'}` seconds",
|
|
615
|
+
"- Execution Duration (legacy): Provider Execution Time.",
|
|
616
|
+
"### Engineering Action Statistics",
|
|
617
|
+
f"- Evidence-backed actions: `{len(bundle.changed_files) + len(state.validation_evidence)}`",
|
|
618
|
+
"### Runtime Statistics",
|
|
619
|
+
"- Runtime execution count: `1` for this report-bound Run ID.",
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
def _deliverable_projection(
|
|
624
|
+
objective: str,
|
|
625
|
+
state: TransactionState,
|
|
626
|
+
bundle: TerminalEvidenceBundle,
|
|
627
|
+
handoff: ForgeGovernanceHandoff | None = None,
|
|
628
|
+
) -> tuple[str, ...]:
|
|
629
|
+
"""Project requested outcomes and repository artefacts without claiming intent."""
|
|
630
|
+
requested = _objective_requirements(objective)
|
|
631
|
+
delivered = bundle.changed_files if state.phase == "COMPLETE" else ()
|
|
632
|
+
documentation = tuple(path for path in delivered if path.endswith(".md"))
|
|
633
|
+
validation = tuple(path for path in delivered if path.startswith("tests/"))
|
|
634
|
+
runtime = tuple(path for path in delivered if path.startswith("src/engineering_platform/"))
|
|
635
|
+
projection = (
|
|
636
|
+
"### Requested Deliverables",
|
|
637
|
+
*(f"- Requested: {item}" for item in requested),
|
|
638
|
+
"### Delivered Artefacts",
|
|
639
|
+
*_evidence_lines("Delivered artifact", delivered),
|
|
640
|
+
"### Undelivered Artefacts",
|
|
641
|
+
*(
|
|
642
|
+
("- None recorded: terminal checkpoint is COMPLETE.",)
|
|
643
|
+
if state.phase == "COMPLETE"
|
|
644
|
+
else ("- Requested deliverables are not claimed as delivered by this terminal checkpoint.",)
|
|
645
|
+
),
|
|
646
|
+
"### Runtime Deliverables",
|
|
647
|
+
*_evidence_lines("Runtime deliverable", runtime),
|
|
648
|
+
"### Documentation Deliverables",
|
|
649
|
+
*_evidence_lines("Documentation deliverable", documentation),
|
|
650
|
+
"### Validation Deliverables",
|
|
651
|
+
*_evidence_lines("Validation deliverable", validation),
|
|
652
|
+
)
|
|
653
|
+
if handoff is None:
|
|
654
|
+
return projection
|
|
655
|
+
return (
|
|
656
|
+
*projection,
|
|
657
|
+
"### Forge Governance Handoff Deliverable",
|
|
658
|
+
"- Governance values are rendered only in the dedicated read-only handoff section.",
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def _qualification_projection(
|
|
663
|
+
state: TransactionState,
|
|
664
|
+
qualification_status: object,
|
|
665
|
+
runtime_provider: str,
|
|
666
|
+
) -> tuple[str, ...]:
|
|
667
|
+
"""Keep execution, qualification, runtime and governance outcomes distinct."""
|
|
668
|
+
validation = "recorded" if state.validation_evidence else "not recorded"
|
|
669
|
+
return (
|
|
670
|
+
f"- Execution Status: `{state.phase}`",
|
|
671
|
+
f"- Platform Qualification Status: `{qualification_status or 'not recorded'}`",
|
|
672
|
+
f"- Runtime Status: `{'reported' if runtime_provider != 'unavailable' else 'not reported'}`",
|
|
673
|
+
f"- Validation Status: `{validation}`",
|
|
674
|
+
"- Governance Status: see the Forge Governance Handoff projection above.",
|
|
675
|
+
)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def _runtime_projection(
|
|
679
|
+
state: TransactionState,
|
|
680
|
+
producer: ProducerMetadata,
|
|
681
|
+
runtime_provider: str,
|
|
682
|
+
reported_model: str,
|
|
683
|
+
) -> tuple[str, ...]:
|
|
684
|
+
"""Render only persisted runtime provenance and Producer references."""
|
|
685
|
+
return (
|
|
686
|
+
f"- Runtime Instance: `{state.run_id}`",
|
|
687
|
+
f"- Runtime Identity: provider `{runtime_provider}`; model `{reported_model}`",
|
|
688
|
+
f"- Mission State: `{producer.mission_id or 'not recorded'}`",
|
|
689
|
+
"- Dispatcher: `not recorded by the runner`",
|
|
690
|
+
"- Queue: `not recorded by the runner`",
|
|
691
|
+
f"- Execution Receipt Reference: `{state.run_id}`",
|
|
692
|
+
f"- Decision Evidence Reference: `{producer.correlation_id or producer.engineering_action_id or 'not recorded'}`",
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
def _execution_receipt_projection(root: Path, state: TransactionState, producer: ProducerMetadata) -> tuple[str, ...]:
|
|
697
|
+
"""Render receipt qualification fields only from the persisted terminal snapshot."""
|
|
698
|
+
try:
|
|
699
|
+
snapshot = load_run_qualification_snapshot(root, state.run_id) or {}
|
|
700
|
+
except EngineeringStorageError:
|
|
701
|
+
snapshot = {}
|
|
702
|
+
conflicts = snapshot.get("projection_conflicts", [])
|
|
703
|
+
activity = terminal_activity_summary(root, state.run_id)
|
|
704
|
+
activity_total = activity.get("activity", {}).get("overall_activity_total", "UNAVAILABLE") if isinstance(activity, dict) else "UNAVAILABLE"
|
|
705
|
+
delivery_paths = activity.get("terminal_delivery_diff", {}).get("total_unique_changed_paths", "UNAVAILABLE") if isinstance(activity, dict) else "UNAVAILABLE"
|
|
706
|
+
conflicts_text = ", ".join(conflicts) if isinstance(conflicts, list) and conflicts else "NONE"
|
|
707
|
+
recovery = load_recovery_state(root, state.run_id) or {}
|
|
708
|
+
submission = load_submission_for_run(root, state.run_id) or {}
|
|
709
|
+
return (
|
|
710
|
+
f"- Receipt ID: `{state.run_id}`",
|
|
711
|
+
"- Execution Host: `Engineering Platform`",
|
|
712
|
+
f"- Run ID: `{state.run_id}`",
|
|
713
|
+
f"- Correlation ID: `{producer.correlation_id or 'not recorded'}`",
|
|
714
|
+
f"- Producer ID: `{producer.producer_id}`",
|
|
715
|
+
f"- Producer Type: `{producer.producer_type}`",
|
|
716
|
+
f"- Submission ID: `{submission.get('submission_id', 'NOT_RECORDED')}`",
|
|
717
|
+
f"- Receipt Status: `{state.phase}`",
|
|
718
|
+
f"- Receipt Resolution: `{state.terminal_condition}`",
|
|
719
|
+
f"- Recovery State: `{recovery.get('state', 'NOT_RECORDED')}`",
|
|
720
|
+
f"- Recovery Result: `{recovery.get('result', 'NOT_RECORDED')}`",
|
|
721
|
+
f"- Recovery Triggering Invocation ID: `{recovery.get('triggering_invocation_id', 'NOT_RECORDED')}`",
|
|
722
|
+
f"- Recovery Replacement Invocation ID: `{recovery.get('replacement_invocation_id', 'NOT_RECORDED')}`",
|
|
723
|
+
f"- Recovery Attempt / Budget: `{recovery.get('recovery_ordinal', 'NOT_RECORDED')}/{recovery.get('maximum_attempts', 'NOT_RECORDED')}`",
|
|
724
|
+
f"- Qualification Snapshot: `{snapshot.get('qualification_snapshot_id', 'UNAVAILABLE')}`",
|
|
725
|
+
f"- Required Validation State: `{snapshot.get('required_validation_state', 'UNAVAILABLE')}`",
|
|
726
|
+
f"- Implementation Delivery: `{snapshot.get('implementation_delivery', 'UNAVAILABLE')}`",
|
|
727
|
+
f"- Finalization Delivery: `{snapshot.get('finalization_delivery', 'UNAVAILABLE')}`",
|
|
728
|
+
f"- Cleanup Outcome: `{snapshot.get('cleanup_outcome', 'UNAVAILABLE')}`",
|
|
729
|
+
f"- Repository State: `{snapshot.get('reconciliation_evidence', {}).get('repository_state', 'UNAVAILABLE')}`",
|
|
730
|
+
f"- Workspace State: `{snapshot.get('reconciliation_evidence', {}).get('workspace_state', 'UNAVAILABLE')}`",
|
|
731
|
+
f"- Run Qualification: `{snapshot.get('run_qualification', 'UNAVAILABLE')}`",
|
|
732
|
+
f"- Projection Conflicts: `{conflicts_text}`",
|
|
733
|
+
f"- Execution Activity Summary: `{'v' + str(activity.get('summary_version')) if isinstance(activity, dict) else 'UNAVAILABLE'}`",
|
|
734
|
+
f"- Receipt Activity Total: `{activity_total}`",
|
|
735
|
+
f"- Receipt Terminal Delivery Paths: `{delivery_paths}`",
|
|
736
|
+
)
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
def _decision_evidence_projection(producer: ProducerMetadata) -> tuple[str, ...]:
|
|
740
|
+
if not any((producer.correlation_id, producer.mission_id, producer.engineering_action_id)):
|
|
741
|
+
return ("- No Decision Evidence reference was recorded by the Producer.",)
|
|
742
|
+
return (
|
|
743
|
+
f"- Decision Evidence ID: `{producer.correlation_id or 'not recorded'}`",
|
|
744
|
+
f"- Decision Type: `{producer.producer_type}` provenance reference",
|
|
745
|
+
f"- Mission: `{producer.mission_id or 'not recorded'}`",
|
|
746
|
+
"- Confidence: `not recorded by Engineering Platform`",
|
|
747
|
+
f"- Reasoning Reference: `{producer.engineering_action_id or 'not recorded'}`",
|
|
748
|
+
)
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
def _evidence_summary(state: TransactionState, bundle: TerminalEvidenceBundle, objective: str) -> str:
|
|
752
|
+
"""Return a compact, machine-readable summary derived only from report evidence."""
|
|
753
|
+
return json.dumps(
|
|
754
|
+
{
|
|
755
|
+
"repository_commit": bundle.target_commit,
|
|
756
|
+
"implemented_components": [name for name, _ in _component_inventory(bundle)],
|
|
757
|
+
"regression_coverage": [path for path in bundle.changed_files if path.startswith("tests/")],
|
|
758
|
+
"deliverable_answer": _deliverable_answer(objective, state),
|
|
759
|
+
"commit_strategy": _commit_strategy(state, bundle)[0].removeprefix("- Strategy: `").removesuffix("`"),
|
|
760
|
+
"execution_strategy": state.execution_mode,
|
|
761
|
+
"repository_state": bundle.worktree_state,
|
|
762
|
+
},
|
|
763
|
+
indent=2,
|
|
764
|
+
sort_keys=True,
|
|
765
|
+
)
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
def report_consistency_errors(body: str, state: TransactionState, bundle: TerminalEvidenceBundle, objective: str) -> tuple[str, ...]:
|
|
769
|
+
"""Validate mandatory Evidence 2.0 sections before a report is published."""
|
|
770
|
+
required = (
|
|
771
|
+
"## Component Inventory",
|
|
772
|
+
"## Deliverable Projection",
|
|
773
|
+
"## Qualification Projection",
|
|
774
|
+
"## Runtime Projection",
|
|
775
|
+
"## Execution Receipt Projection",
|
|
776
|
+
"## Decision Evidence Projection",
|
|
777
|
+
"## Statistics Projection",
|
|
778
|
+
"## Commit Strategy",
|
|
779
|
+
"## Branch Traceability",
|
|
780
|
+
"## Requirement Traceability",
|
|
781
|
+
"## Validation Traceability",
|
|
782
|
+
"## Execution Statistics",
|
|
783
|
+
"## Engineering Evidence Summary",
|
|
784
|
+
)
|
|
785
|
+
errors = [f"missing required section: {section}" for section in required if section not in body]
|
|
786
|
+
if "Implemented Components:\n\nnone recorded" in body:
|
|
787
|
+
errors.append("component inventory is missing")
|
|
788
|
+
if re.search(r"\bYES\b|\bPASS\b|\bGO\b|\bNO-GO\b", objective, re.IGNORECASE) and _deliverable_answer(objective, state) not in body:
|
|
789
|
+
errors.append("explicit deliverable answer is missing")
|
|
790
|
+
if bundle.target_commit not in body:
|
|
791
|
+
errors.append("repository commit is missing")
|
|
792
|
+
if state.phase == "COMPLETE" and "## Evidence Bundle" not in body:
|
|
793
|
+
errors.append("complete report is missing Evidence Bundle")
|
|
794
|
+
fresh = re.search(r"^- Fresh Submission: `([^`]+)`$", body, re.MULTILINE)
|
|
795
|
+
retry = re.search(r"^- Retry Parent: `([^`]+)`$", body, re.MULTILINE)
|
|
796
|
+
resume = re.search(r"^- Resume Parent: `([^`]+)`$", body, re.MULTILINE)
|
|
797
|
+
if fresh and fresh.group(1) == "YES" and (
|
|
798
|
+
not retry or retry.group(1) != "NONE" or not resume or resume.group(1) != "NONE"
|
|
799
|
+
):
|
|
800
|
+
errors.append("fresh submission conflicts with retry or resume parent")
|
|
801
|
+
for role in ("IMPLEMENTATION", "FINALIZATION"):
|
|
802
|
+
pattern = rf"- PR Role: `{role}`(?P<details>.*?)(?=^- PR Role:|^- Autonomous EP Action Count:|\Z)"
|
|
803
|
+
match = re.search(pattern, body, re.MULTILINE | re.DOTALL)
|
|
804
|
+
if match and "- Current PR State: `MERGED`" in match.group("details"):
|
|
805
|
+
checks = re.search(r"- Required Checks State: `([^`]+)`", match.group("details"))
|
|
806
|
+
reference = re.search(r"- Required Checks Evidence Reference: `([^`]+)`", match.group("details"))
|
|
807
|
+
if checks and checks.group(1) == "PASS" and (not reference or reference.group(1) == "UNAVAILABLE"):
|
|
808
|
+
errors.append(f"{role.lower()} required checks pass lacks evidence")
|
|
809
|
+
if bundle.changed_files and re.search(r"^- Files Modified: `0`$", body, re.MULTILINE):
|
|
810
|
+
errors.append("ambiguous zero changed-file projection")
|
|
811
|
+
diff_states = set(re.findall(r"^- git diff --check: `(PASS|FAIL)`", body, re.MULTILINE))
|
|
812
|
+
if len(diff_states) > 1:
|
|
813
|
+
errors.append("current git diff --check state conflicts")
|
|
814
|
+
return tuple(errors)
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
def _validation_evidence_lines(state: TransactionState) -> tuple[str, ...]:
|
|
818
|
+
if not state.validation_evidence:
|
|
819
|
+
return ("- Executed tests: not recorded by the runner.", "- Test results: not recorded by the runner.")
|
|
820
|
+
return tuple(
|
|
821
|
+
line
|
|
822
|
+
for item in state.validation_evidence
|
|
823
|
+
for line in (
|
|
824
|
+
f"- Executed test: `{item['command']}`",
|
|
825
|
+
f" - Result: {item['result']}",
|
|
826
|
+
)
|
|
827
|
+
)
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
def _repair_audit_lines(state: TransactionState) -> tuple[str, ...]:
|
|
831
|
+
if not state.repair_audit:
|
|
832
|
+
return ("No repair iterations were required.",)
|
|
833
|
+
return tuple(line for item in state.repair_audit for line in (
|
|
834
|
+
f"### Repair iteration {item['iteration']}", f"- Observed at: {item['observed_at']}",
|
|
835
|
+
f"- Failed checks: {item['failed_checks']}", f"- Proposed action: {item['proposed_action']}",
|
|
836
|
+
f"- AI repair summary: {item['agent_summary']}", f"- Commit: `{item['commit_sha']}`", f"- Outcome: `{item['outcome']}`",
|
|
837
|
+
))
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
def _local_validation_audit_lines(state: TransactionState) -> tuple[str, ...]:
|
|
841
|
+
"""Render bounded local-validation repair evidence in terminal reports."""
|
|
842
|
+
if not state.local_validation_audit:
|
|
843
|
+
return ("No local repository validation iterations were required.",)
|
|
844
|
+
return tuple(line for item in state.local_validation_audit for line in (
|
|
845
|
+
f"### Local validation iteration {item['iteration']}",
|
|
846
|
+
f"- Observed at: {item['observed_at']}",
|
|
847
|
+
f"- Failed checks: {item['failed_checks']}",
|
|
848
|
+
f"- Proposed action: {item['proposed_action']}",
|
|
849
|
+
f"- AI repair summary: {item['agent_summary']}",
|
|
850
|
+
f"- Commit: `{item['commit_sha']}`",
|
|
851
|
+
f"- Outcome: `{item['outcome']}`",
|
|
852
|
+
))
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
def _reconciliation_evidence(objective: str, state: TransactionState, bundle: TerminalEvidenceBundle) -> str:
|
|
856
|
+
if "reconcil" not in objective.casefold():
|
|
857
|
+
return ""
|
|
858
|
+
changed = ", ".join(f"`{path}`" for path in bundle.changed_files) or "no changed files recorded"
|
|
859
|
+
return "\n".join(
|
|
860
|
+
(
|
|
861
|
+
"## Reconciliation Evidence",
|
|
862
|
+
"- Initial classification: not separately persisted by the runner.",
|
|
863
|
+
f"- Final classification: `{state.phase}`.",
|
|
864
|
+
"- Required assessment items: target identity, repository evidence, validation evidence and terminal checkpoint are included in this report.",
|
|
865
|
+
f"- Changes made: {changed}.",
|
|
866
|
+
"- Remaining limitations: historical assessment and per-test execution details are not persisted by the runner.",
|
|
867
|
+
"",
|
|
868
|
+
)
|
|
869
|
+
)
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
def format_management_summary(state: TransactionState) -> str:
|
|
873
|
+
"""Return a checkpoint-only completion summary without exposing prompt text."""
|
|
874
|
+
return "\n".join(
|
|
875
|
+
(
|
|
876
|
+
"COMPLETE — IMPLEMENTATION_AND_FINALIZATION_RECONCILED",
|
|
877
|
+
"Objective: bounded objective recorded at the supplied prompt path.",
|
|
878
|
+
f"Implementation: branch={state.implementation_branch or state.branch}; PR={state.implementation_pull_request}; merge={state.implementation_merge_commit}.",
|
|
879
|
+
f"Repair iterations: {state.repair_iterations}.",
|
|
880
|
+
f"Finalization: branch={state.finalization_branch}; PR={state.finalization_pull_request}; merge={state.finalization_merge_commit}.",
|
|
881
|
+
"Repository Cleanup: fetched and pruned; local main synchronized; transaction branches removed or already absent; workspace clean.",
|
|
882
|
+
"Authority: owner-authorized bounded lifecycle; ready-for-review and Finalization automated, pull-request merge operator-owned.",
|
|
883
|
+
"No release, deployment or publication performed. Rolling Horizon unchanged.",
|
|
884
|
+
)
|
|
885
|
+
)
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
def format_terminal_management_summary(state: TransactionState) -> str:
|
|
889
|
+
"""Return evidence bounded by the persisted terminal checkpoint phase."""
|
|
890
|
+
if state.phase == "COMPLETE":
|
|
891
|
+
return format_management_summary(state)
|
|
892
|
+
outcome = (
|
|
893
|
+
_blocked_management_outcome(state)
|
|
894
|
+
if state.phase == "BLOCKED"
|
|
895
|
+
else "FAILED — the engineering transaction did not complete successfully."
|
|
896
|
+
)
|
|
897
|
+
target = state.genesis_repository_path or state.repository
|
|
898
|
+
codex = (
|
|
899
|
+
"not started"
|
|
900
|
+
if state.terminal_condition in {"genesis_workspace_preflight", "execution_context_resolution"}
|
|
901
|
+
else "not confirmed by the terminal checkpoint"
|
|
902
|
+
)
|
|
903
|
+
return "\n".join(
|
|
904
|
+
(
|
|
905
|
+
outcome,
|
|
906
|
+
f"Execution mode: {state.execution_mode}.",
|
|
907
|
+
f"Target repository: {target}.",
|
|
908
|
+
f"Terminal checkpoint: {state.phase}.",
|
|
909
|
+
f"Codex execution: {codex}.",
|
|
910
|
+
f"Implementation: branch={state.implementation_branch}; PR={state.implementation_pull_request}; merge={state.implementation_merge_commit}.",
|
|
911
|
+
f"Finalization: branch={state.finalization_branch}; PR={state.finalization_pull_request}; merge={state.finalization_merge_commit}.",
|
|
912
|
+
"No release, deployment or publication was performed.",
|
|
913
|
+
)
|
|
914
|
+
)
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
def _blocked_management_outcome(state: TransactionState) -> str:
|
|
918
|
+
"""State a verified implementation merge without overstating final delivery."""
|
|
919
|
+
if state.implementation_merge_commit:
|
|
920
|
+
return (
|
|
921
|
+
"BLOCKED — implementation merge was verified, but Finalization and "
|
|
922
|
+
"end reconciliation did not complete."
|
|
923
|
+
)
|
|
924
|
+
return "BLOCKED — no engineering changes were executed or delivered."
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
def terminal_report_matches_state(body: str, state: TransactionState) -> bool:
|
|
928
|
+
"""Reject report prose that conflicts with its immutable terminal checkpoint."""
|
|
929
|
+
if f"- Terminal state: `{state.phase}`" not in body:
|
|
930
|
+
return False
|
|
931
|
+
required_sections = (
|
|
932
|
+
"## Initial Repository Assessment",
|
|
933
|
+
"## Engineering Outcome",
|
|
934
|
+
"## Reviewer Findings",
|
|
935
|
+
"## Repository Truth",
|
|
936
|
+
"## Management Summary",
|
|
937
|
+
)
|
|
938
|
+
if any(section not in body for section in required_sections):
|
|
939
|
+
return False
|
|
940
|
+
if "## Execution Target Identity" not in body:
|
|
941
|
+
return False
|
|
942
|
+
if state.phase == "COMPLETE" and "## Evidence Bundle" not in body:
|
|
943
|
+
return False
|
|
944
|
+
if state.phase == "BLOCKED":
|
|
945
|
+
return _blocked_management_outcome(state) in body and "COMPLETE —" not in body
|
|
946
|
+
if state.phase == "FAILED":
|
|
947
|
+
return "FAILED — the engineering transaction did not complete successfully." in body and "COMPLETE —" not in body
|
|
948
|
+
return state.phase == "COMPLETE" and "COMPLETE —" in body
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
def corrected_terminal_report(state: TransactionState) -> str:
|
|
952
|
+
"""Generate a minimal replacement when richer report assembly is inconsistent."""
|
|
953
|
+
try:
|
|
954
|
+
producer_prompt = Path(state.prompt_path).read_text(encoding="utf-8")
|
|
955
|
+
except OSError:
|
|
956
|
+
producer_prompt = ""
|
|
957
|
+
producer = parse_producer_metadata(producer_prompt)
|
|
958
|
+
submission = None
|
|
959
|
+
return "\n".join(
|
|
960
|
+
(
|
|
961
|
+
"# Engineering Report",
|
|
962
|
+
"",
|
|
963
|
+
f"- Run ID: `{state.run_id}`",
|
|
964
|
+
f"- Terminal state: `{state.phase}`",
|
|
965
|
+
"",
|
|
966
|
+
"## Producer",
|
|
967
|
+
f"- Producer ID: `{producer.producer_id}`",
|
|
968
|
+
f"- Producer Type: `{producer.producer_type}`",
|
|
969
|
+
f"- Producer Version: `{producer.producer_version or 'not supplied'}`",
|
|
970
|
+
f"- Correlation ID: `{producer.correlation_id or 'not supplied'}`",
|
|
971
|
+
f"- Mission ID: `{producer.mission_id or 'not supplied'}`",
|
|
972
|
+
f"- Engineering Action ID: `{producer.engineering_action_id or 'not supplied'}`",
|
|
973
|
+
f"- Execution Constraint Version: `{producer.execution_constraint_version or 'not supplied'}`",
|
|
974
|
+
"",
|
|
975
|
+
*_producer_submission_contract_lines(submission, state),
|
|
976
|
+
"## Execution Target Identity",
|
|
977
|
+
f"- Execution Host Repository: `{state.repository}`",
|
|
978
|
+
f"- Execution Mode: `{state.execution_mode}`",
|
|
979
|
+
"- Target Workspace: unavailable",
|
|
980
|
+
"- Target Repository: unavailable",
|
|
981
|
+
"- Target Branch: unavailable",
|
|
982
|
+
"- Target Commit: unavailable",
|
|
983
|
+
"",
|
|
984
|
+
"## Initial Repository Assessment",
|
|
985
|
+
"Assessment evidence is unavailable. This section describes only the repository before any attempted implementation.",
|
|
986
|
+
"",
|
|
987
|
+
"## Engineering Outcome",
|
|
988
|
+
format_terminal_management_summary(state),
|
|
989
|
+
"",
|
|
990
|
+
*_retry_relationship(state),
|
|
991
|
+
"## Reviewer Findings",
|
|
992
|
+
"No reviewer findings were retained. Reviewer observations are advisory initial observations only.",
|
|
993
|
+
"",
|
|
994
|
+
"## Repository Truth",
|
|
995
|
+
"Execution Host, Target Repository, Target Commit, Repository Evidence and Evidence Bundle are canonical repository truth.",
|
|
996
|
+
"Priority: persisted repository state, resulting commits, validation results, then reviewer observations.",
|
|
997
|
+
"",
|
|
998
|
+
*(
|
|
999
|
+
(
|
|
1000
|
+
"## Evidence Bundle",
|
|
1001
|
+
"Repository evidence is unavailable because the richer report assembly was inconsistent.",
|
|
1002
|
+
"",
|
|
1003
|
+
)
|
|
1004
|
+
if state.phase == "COMPLETE"
|
|
1005
|
+
else ()
|
|
1006
|
+
),
|
|
1007
|
+
"## Management Summary",
|
|
1008
|
+
format_terminal_management_summary(state),
|
|
1009
|
+
"",
|
|
1010
|
+
"## Diagnostics",
|
|
1011
|
+
state.diagnostic or "No terminal diagnostic.",
|
|
1012
|
+
"",
|
|
1013
|
+
)
|
|
1014
|
+
)
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
def _format_reviewer_records(records: tuple[dict[str, object], ...], phase: str) -> str:
|
|
1018
|
+
if not records:
|
|
1019
|
+
return "No specialist reviewers required. Any future reviewer observations remain advisory initial observations."
|
|
1020
|
+
lines: list[str] = []
|
|
1021
|
+
for record in records:
|
|
1022
|
+
lines.extend(
|
|
1023
|
+
(
|
|
1024
|
+
f"- Reviewer: {record['reviewer']}",
|
|
1025
|
+
f" - Capability: {record.get('capability', 'engineering')}",
|
|
1026
|
+
f" - Selected because: {record['selected_because']}",
|
|
1027
|
+
f" - Initial observation: {record['contribution']}",
|
|
1028
|
+
f" - Accepted recommendations: {record['accepted_recommendations']}",
|
|
1029
|
+
f" - Rejected recommendations: {record['rejected_recommendations']}",
|
|
1030
|
+
" - Resolved by: implementation evidence, changed components and repository evidence in the Evidence Bundle below."
|
|
1031
|
+
if phase == "COMPLETE"
|
|
1032
|
+
else " - Outcome: Not a final repository statement; consult the terminal checkpoint and diagnostics.",
|
|
1033
|
+
)
|
|
1034
|
+
)
|
|
1035
|
+
return "\n".join(lines)
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
def _format_engineering_outcome(state: TransactionState) -> str:
|
|
1039
|
+
"""Describe final delivery from checkpoint and repository evidence, never advice."""
|
|
1040
|
+
if state.phase != "COMPLETE":
|
|
1041
|
+
completed_work = (
|
|
1042
|
+
"- Completed work: implementation merge was verified; this is not a complete delivery."
|
|
1043
|
+
if state.implementation_merge_commit
|
|
1044
|
+
else "- Completed work: no successful engineering delivery is claimed."
|
|
1045
|
+
)
|
|
1046
|
+
return "\n".join(
|
|
1047
|
+
(
|
|
1048
|
+
f"- Final checkpoint: `{state.phase}`",
|
|
1049
|
+
completed_work,
|
|
1050
|
+
f"- Remaining limitation: {state.diagnostic or 'Terminal outcome requires follow-up.'}",
|
|
1051
|
+
)
|
|
1052
|
+
)
|
|
1053
|
+
return "\n".join(
|
|
1054
|
+
(
|
|
1055
|
+
"- Final checkpoint: `COMPLETE`",
|
|
1056
|
+
"- Completed work: implementation and any required reconciliation completed according to the persisted checkpoint.",
|
|
1057
|
+
f"- Resulting commits: implementation `{state.implementation_merge_commit or 'not applicable'}`; finalization `{state.finalization_merge_commit or 'not applicable'}`.",
|
|
1058
|
+
f"- Repository state: {state.latest_repository_evidence or 'Recorded by the terminal COMPLETE checkpoint.'}",
|
|
1059
|
+
"- Remaining limitations: none recorded by the terminal checkpoint.",
|
|
1060
|
+
)
|
|
1061
|
+
)
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
def _managed_autonomy_projection(root: Path, state: TransactionState, bundle: TerminalEvidenceBundle, reviewer_records: tuple[dict[str, object], ...]) -> tuple[str, ...]:
|
|
1065
|
+
"""Project canonical evidence only; legacy runs intentionally fail closed."""
|
|
1066
|
+
try:
|
|
1067
|
+
lineage = load_run_lineage(root, state.run_id)
|
|
1068
|
+
except EngineeringStorageError:
|
|
1069
|
+
lineage = None
|
|
1070
|
+
try:
|
|
1071
|
+
submission = load_submission_for_run(root, state.run_id)
|
|
1072
|
+
except EngineeringStorageError:
|
|
1073
|
+
submission = None
|
|
1074
|
+
snapshot = managed_autonomy_snapshot(
|
|
1075
|
+
root, run_id=state.run_id, execution_outcome=state.phase,
|
|
1076
|
+
implementation_pr=state.implementation_pull_request, finalization_pr=state.finalization_pull_request,
|
|
1077
|
+
repository_state="MERGED_RECONCILED" if state.phase == "COMPLETE" and (state.finalization_merge_commit or state.action_intent == "VALIDATION_ONLY") else "UNAVAILABLE",
|
|
1078
|
+
workspace_state="WORKSPACE_READY" if state.phase == "COMPLETE" and bundle.worktree_state == "clean" else "UNAVAILABLE",
|
|
1079
|
+
main_origin_sync="YES" if bundle.target_branch == "main" else "UNAVAILABLE",
|
|
1080
|
+
worktree_state=bundle.worktree_state.upper(), active_blocker="NONE" if state.phase == "COMPLETE" else "UNAVAILABLE",
|
|
1081
|
+
recovery_required="NO" if state.phase == "COMPLETE" else "UNAVAILABLE",
|
|
1082
|
+
retry_parent=lineage.get("retry_parent") if lineage else None,
|
|
1083
|
+
# Resume reuses the canonical run ID. No separate resume parent is persisted
|
|
1084
|
+
# by the existing lifecycle, so retain an explicit unavailable boundary.
|
|
1085
|
+
resume_parent=None,
|
|
1086
|
+
submission_id=str(submission["submission_id"]) if submission else None,
|
|
1087
|
+
lineage_available=lineage is not None,
|
|
1088
|
+
reviewer_records=reviewer_records,
|
|
1089
|
+
execution_mode=state.execution_mode,
|
|
1090
|
+
action_intent=state.action_intent,
|
|
1091
|
+
persist=True,
|
|
1092
|
+
)
|
|
1093
|
+
validation_profile = snapshot.get("validation_profile")
|
|
1094
|
+
validation_profile = validation_profile if isinstance(validation_profile, dict) else {}
|
|
1095
|
+
def pr_lines(role: str) -> tuple[str, ...]:
|
|
1096
|
+
item = snapshot["pr_checks"].get(role, {})
|
|
1097
|
+
not_required = state.action_intent == "VALIDATION_ONLY"
|
|
1098
|
+
return (
|
|
1099
|
+
f"- PR Role: `{role}`",
|
|
1100
|
+
f" - PR Number: `{item.get('pr_number') or snapshot[f'{role.lower()}_pr'] or ('NOT_REQUIRED' if not_required else 'UNAVAILABLE')}`",
|
|
1101
|
+
f" - Current PR State: `{item.get('pr_state', 'NOT_REQUIRED' if not_required else 'UNAVAILABLE')}`",
|
|
1102
|
+
f" - Merge State: `{item.get('merge_state', 'UNAVAILABLE')}`",
|
|
1103
|
+
f" - Merge Commit: `{item.get('merge_commit') or 'UNAVAILABLE'}`",
|
|
1104
|
+
f" - Required Checks State: `{item.get('required_checks_state', 'UNAVAILABLE')}`",
|
|
1105
|
+
f" - Required Checks Observed At: `{item.get('observed_at', 'UNAVAILABLE')}`",
|
|
1106
|
+
f" - Required Checks Evidence Reference: `{item.get('evidence_ref', 'UNAVAILABLE')}`",
|
|
1107
|
+
f" - Historical Check Observations: `{item.get('historical_observation_count', 'UNAVAILABLE')}`",
|
|
1108
|
+
)
|
|
1109
|
+
return (
|
|
1110
|
+
"## Run Qualification",
|
|
1111
|
+
f"- Execution: `{snapshot['terminal_execution_state']}`",
|
|
1112
|
+
f"- Action Intent: `{snapshot['action_intent']}`",
|
|
1113
|
+
f"- Execution Mode: `{snapshot['execution_mode']}`",
|
|
1114
|
+
f"- Run Qualification: `{snapshot['run_qualification']}`",
|
|
1115
|
+
"- Platform Qualification is reported separately and cannot upgrade this run.",
|
|
1116
|
+
f"- Fresh Submission: `{snapshot['fresh_submission']}`",
|
|
1117
|
+
f"- Retry Parent: `{snapshot['retry_parent']}`",
|
|
1118
|
+
f"- Resume Parent: `{snapshot['resume_parent']}`",
|
|
1119
|
+
f"- Submission Lineage / Submission ID: `{snapshot['submission_id']}`",
|
|
1120
|
+
"### Current Terminal Required Checks",
|
|
1121
|
+
*pr_lines("IMPLEMENTATION"),
|
|
1122
|
+
*pr_lines("FINALIZATION"),
|
|
1123
|
+
f"- Autonomous EP Action Count: `{snapshot['autonomous_ep_action_count']}`",
|
|
1124
|
+
f"- Expected Operator Gates: `{snapshot['expected_operator_gate_count']}`",
|
|
1125
|
+
f"- External Platform Event Count: `{snapshot['external_platform_event_count']}`",
|
|
1126
|
+
f"- Unexpected Manual Interventions: `{snapshot['unplanned_manual_intervention_count']}`",
|
|
1127
|
+
f"- Unknown Authority Actions: `{snapshot['unknown_authority_count']}`",
|
|
1128
|
+
f"- Required Validation State: `{snapshot['required_validation_state']}`",
|
|
1129
|
+
f"- Selected Validation Profile: `{validation_profile.get('selected_validation_tier', 'UNAVAILABLE')}`",
|
|
1130
|
+
f"- Validation Profile Version: `{validation_profile.get('validation_profile_version', 'UNAVAILABLE')}`",
|
|
1131
|
+
f"- Validation Profile Reference: `{validation_profile.get('profile_reference', 'UNAVAILABLE')}`",
|
|
1132
|
+
f"- Validation Profile Source: `{validation_profile.get('profile_selection_source', 'UNAVAILABLE')}`",
|
|
1133
|
+
f"- Required-control Snapshot: `{snapshot.get('required_control_snapshot_ref', 'UNAVAILABLE')}`",
|
|
1134
|
+
f"- Implementation Delivery: `{snapshot.get('implementation_delivery', 'UNAVAILABLE')}`",
|
|
1135
|
+
f"- Finalization Delivery: `{snapshot.get('finalization_delivery', 'UNAVAILABLE')}`",
|
|
1136
|
+
f"- Cleanup Outcome: `{snapshot.get('cleanup_outcome', 'UNAVAILABLE')}`",
|
|
1137
|
+
f"- Repository State: `{snapshot.get('reconciliation_evidence', {}).get('repository_state', 'UNAVAILABLE')}`",
|
|
1138
|
+
f"- Workspace State: `{snapshot.get('reconciliation_evidence', {}).get('workspace_state', 'UNAVAILABLE')}`",
|
|
1139
|
+
f"- Projection Conflicts: `{', '.join(snapshot.get('projection_conflicts', [])) or 'NONE'}`",
|
|
1140
|
+
f"- Qualification Snapshot: `{snapshot.get('qualification_snapshot_id', 'UNAVAILABLE')}`",
|
|
1141
|
+
f"- Qualification Reasons: `{', '.join(snapshot['qualification_failure_reasons']) or 'none'}`",
|
|
1142
|
+
"",
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
def generate_terminal_report(
|
|
1147
|
+
root: Path,
|
|
1148
|
+
state: TransactionState,
|
|
1149
|
+
manifest: EngineeringPlatformManifest | None = None,
|
|
1150
|
+
detected_cli: str | None = None,
|
|
1151
|
+
reviewer_records: tuple[dict[str, object], ...] = (),
|
|
1152
|
+
runtime_metadata: Mapping[str, str] | None = None,
|
|
1153
|
+
execution_metadata: Mapping[str, int] | None = None,
|
|
1154
|
+
central_database: Path | None = None,
|
|
1155
|
+
) -> Path:
|
|
1156
|
+
"""Write an immutable report beneath the explicitly bound authority."""
|
|
1157
|
+
reports = (
|
|
1158
|
+
central_database.resolve().parent / "artifacts" / "reports"
|
|
1159
|
+
if central_database is not None else root / ".engineering" / "reports"
|
|
1160
|
+
)
|
|
1161
|
+
reports.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
1162
|
+
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H-%M-%SZ")
|
|
1163
|
+
path = reports / f"{timestamp}_{state.run_id}.md"
|
|
1164
|
+
objective = "Objective unavailable because the prompt file is no longer local."
|
|
1165
|
+
try:
|
|
1166
|
+
objective = Path(state.prompt_path).read_text(encoding="utf-8").strip()
|
|
1167
|
+
except OSError:
|
|
1168
|
+
pass
|
|
1169
|
+
# The submitted prompt is immutable input, not execution evidence. Keep
|
|
1170
|
+
# using it internally for traceability, but never splice its arbitrary
|
|
1171
|
+
# multi-line content into the report header where requested outcomes can
|
|
1172
|
+
# visually resemble the terminal result.
|
|
1173
|
+
objective_header = (
|
|
1174
|
+
"Submitted runtime prompt retained at the supplied prompt path; "
|
|
1175
|
+
"non-authoritative input."
|
|
1176
|
+
)
|
|
1177
|
+
producer, submission = _persisted_producer_submission(
|
|
1178
|
+
root, state, objective, central_database=central_database,
|
|
1179
|
+
)
|
|
1180
|
+
raw_handoff = submission.get("forge_governance_handoff") if isinstance(submission, dict) else None
|
|
1181
|
+
handoff = ForgeGovernanceHandoff.from_snapshot(raw_handoff) if isinstance(raw_handoff, dict) else None
|
|
1182
|
+
manifest = manifest or EngineeringPlatformManifest.load(
|
|
1183
|
+
package_path("ENGINEERING_PLATFORM_VERSION.json")
|
|
1184
|
+
)
|
|
1185
|
+
qualification = latest_qualification(root)
|
|
1186
|
+
qualification_summary = (
|
|
1187
|
+
"No local Engineering Platform Qualification evidence is available."
|
|
1188
|
+
if qualification is None
|
|
1189
|
+
else f"Version: `{qualification.get('engineering_platform_version')}`\n- Latest Qualification: `{qualification.get('qualification')}`\n- Executed: `{qualification.get('executed_at')}`\n- Qualification Coverage: `{qualification.get('coverage_percent')}%`"
|
|
1190
|
+
)
|
|
1191
|
+
runtime_metadata = runtime_metadata or {"runtime_provider": "codex_cli"}
|
|
1192
|
+
runtime_provider = runtime_metadata.get("runtime_provider", "unavailable")
|
|
1193
|
+
reported_model = runtime_metadata.get("model", "not reported")
|
|
1194
|
+
reported_reasoning = runtime_metadata.get("reasoning_profile", "not reported")
|
|
1195
|
+
reported_configuration = runtime_metadata.get("configuration_profile", "not reported")
|
|
1196
|
+
reported_cli_installation_path = (
|
|
1197
|
+
runtime_metadata.get("codex_cli_installation_path", "not reported")
|
|
1198
|
+
if runtime_provider == "codex_cli" else "not applicable"
|
|
1199
|
+
)
|
|
1200
|
+
raw_execution_metadata = execution_metadata or {}
|
|
1201
|
+
safe_execution_metadata = {
|
|
1202
|
+
key: max(0, value)
|
|
1203
|
+
for key in ("modified", "created", "deleted", "codex_commands_executed")
|
|
1204
|
+
for value in (raw_execution_metadata.get(key, 0),)
|
|
1205
|
+
if isinstance(value, int) and not isinstance(value, bool)
|
|
1206
|
+
}
|
|
1207
|
+
bundle = collect_terminal_evidence(root, state)
|
|
1208
|
+
activity_summary = persist_terminal_activity_summary(
|
|
1209
|
+
root, build_terminal_activity_summary(root, state, bundle)
|
|
1210
|
+
)
|
|
1211
|
+
timing = timing_summary(root, state.run_id, central_database=central_database)
|
|
1212
|
+
provider_usage = provider_usage_summary(root, state.run_id, central_database=central_database)
|
|
1213
|
+
churn = provider_usage.get("context_churn") if isinstance(provider_usage.get("context_churn"), dict) else {}
|
|
1214
|
+
provider_usage_lines = (
|
|
1215
|
+
"## Provider Usage",
|
|
1216
|
+
f"- Provider Invocations: `{provider_usage.get('provider_invocation_count', 0)}`",
|
|
1217
|
+
f"- Run Cumulative Input Tokens: `{provider_usage.get('input_tokens', 'UNAVAILABLE')}`",
|
|
1218
|
+
f"- Cached Input Tokens: `{provider_usage.get('cached_input_tokens', 'UNAVAILABLE')}`",
|
|
1219
|
+
f"- Uncached Input Tokens: `{provider_usage.get('uncached_input_tokens', 'UNAVAILABLE')}`",
|
|
1220
|
+
f"- Output Tokens: `{provider_usage.get('output_tokens', 'UNAVAILABLE')}`",
|
|
1221
|
+
f"- Maximum Provider Invocation Cumulative Input: `{provider_usage.get('max_input_tokens_per_invocation', 'UNAVAILABLE')}`",
|
|
1222
|
+
f"- Observed Final Usage Snapshots: `{provider_usage.get('usage_snapshot_count') or 'UNAVAILABLE'}`",
|
|
1223
|
+
f"- Intermediate Usage Delta Available: `{'yes' if provider_usage.get('intermediate_usage_delta_available') else 'no'}`",
|
|
1224
|
+
f"- Maximum Intermediate Input Delta: `{provider_usage.get('maximum_incremental_input_tokens') or 'UNAVAILABLE'}`",
|
|
1225
|
+
"- Actual Single-Request Context Size: `UNAVAILABLE` (not emitted by Codex CLI JSONL).",
|
|
1226
|
+
"- Active Context Size: `UNAVAILABLE` (not emitted by Codex CLI JSONL).",
|
|
1227
|
+
f"- Estimated Credits: `{provider_usage.get('estimated_credits', 'UNAVAILABLE')}`",
|
|
1228
|
+
f"- Estimated EUR: `{provider_usage.get('estimated_eur', 'UNAVAILABLE')}` (derived estimate; not account billing)",
|
|
1229
|
+
f"- Rate Table Version: `{provider_usage.get('rate_table_version', 'UNAVAILABLE')}`",
|
|
1230
|
+
f"- Usage Authority: `{provider_usage.get('usage_authority', 'UNAVAILABLE')}`",
|
|
1231
|
+
f"- Speed State: `{provider_usage.get('speed_state', 'UNKNOWN')}`",
|
|
1232
|
+
"",
|
|
1233
|
+
"## Observable Provider Input Correlation",
|
|
1234
|
+
f"- File Reads: `{churn.get('file_read_count', 'UNAVAILABLE')}`",
|
|
1235
|
+
f"- Repeated File Reads: `{churn.get('repeated_file_read_count', 'UNAVAILABLE')}`",
|
|
1236
|
+
f"- Tool Output Bytes: `{churn.get('tool_output_bytes', 'UNAVAILABLE')}`",
|
|
1237
|
+
f"- Test Output Bytes: `{(churn.get('passing_test_output_bytes', 0) + churn.get('failed_test_diagnostic_bytes', 0)) if churn else 'UNAVAILABLE'}`",
|
|
1238
|
+
"- Dominant Churn Indicators: derived only from bounded invocation counters; raw prompts and outputs are not retained.",
|
|
1239
|
+
"",
|
|
1240
|
+
"## Provider Context Scope",
|
|
1241
|
+
f"- Policy: `{churn.get('context_scope_policy', 'UNAVAILABLE')}`",
|
|
1242
|
+
f"- Initial Scope: `{churn.get('context_scope_initial', 'UNAVAILABLE')}`",
|
|
1243
|
+
f"- Effective Scope: `{churn.get('context_scope_effective', 'UNAVAILABLE')}`",
|
|
1244
|
+
f"- Context Escalations: `{churn.get('context_escalation_count', 'UNAVAILABLE')}`",
|
|
1245
|
+
f"- Escalation Reasons: `{churn.get('context_escalation_reasons', 'NONE')}`",
|
|
1246
|
+
f"- Historical PRs Inspected: `{provider_usage.get('historical_pr_results') if provider_usage.get('historical_context_metrics_authority') != 'UNAVAILABLE' else 'UNAVAILABLE'}`",
|
|
1247
|
+
f"- Historical Commits Inspected: `{provider_usage.get('historical_commit_results') if provider_usage.get('historical_context_metrics_authority') != 'UNAVAILABLE' else 'UNAVAILABLE'}`",
|
|
1248
|
+
f"- Historical Context Bytes: `{provider_usage.get('historical_context_bytes') if provider_usage.get('historical_context_metrics_authority') != 'UNAVAILABLE' else 'UNAVAILABLE'}`",
|
|
1249
|
+
"",
|
|
1250
|
+
)
|
|
1251
|
+
timing_lines = ["## Execution Phase Timing"]
|
|
1252
|
+
if timing.get("phase_telemetry_available"):
|
|
1253
|
+
occurred = set(timing.get("occurred_phases", ()))
|
|
1254
|
+
timing_lines.extend((
|
|
1255
|
+
f"- Total Wall Time: `{timing['total_wall_time_ms'] / 1000:.3f}` s",
|
|
1256
|
+
f"- Active EP Processing Time: `{timing['active_ep_processing_time_ms'] / 1000:.3f}` s",
|
|
1257
|
+
))
|
|
1258
|
+
for phase, label, value, share in (
|
|
1259
|
+
("PROVIDER_EXECUTION", "Provider Execution Time", "provider_execution_time_ms", "provider_share_percent"),
|
|
1260
|
+
("VALIDATION", "Validation Time", "validation_time_ms", "validation_share_percent"),
|
|
1261
|
+
("EXTERNAL_CI_WAIT", "External Wait Time", "external_wait_time_ms", "external_wait_share_percent"),
|
|
1262
|
+
("QUEUE_WAIT", "Queue Wait Time", "queue_wait_time_ms", "queue_share_percent"),
|
|
1263
|
+
("REPORT_GENERATION", "Report Generation Time", "report_generation_time_ms", None),
|
|
1264
|
+
("EVIDENCE_PERSISTENCE", "Evidence Persistence Time", "evidence_persistence_time_ms", None),
|
|
1265
|
+
("REPOSITORY_FINALIZATION", "Repository Finalization Time", "repository_finalization_time_ms", None),
|
|
1266
|
+
):
|
|
1267
|
+
if phase in occurred:
|
|
1268
|
+
suffix = f" ({timing[share]:.3f}%)" if share else ""
|
|
1269
|
+
timing_lines.append(f"- {label}: `{timing[value] / 1000:.3f}` s{suffix}")
|
|
1270
|
+
timing_lines.extend((
|
|
1271
|
+
f"- Overhead Time: `{timing['overhead_time_ms'] / 1000:.3f}` s ({timing['overhead_share_percent']:.3f}%)",
|
|
1272
|
+
"### Top Phase Categories",
|
|
1273
|
+
*(f"- {index}. {item['phase']} — `{item['duration_ms'] / 1000:.3f}` s" for index, item in enumerate(timing["top_phase_categories"], 1)),
|
|
1274
|
+
"### Longest Individual Spans",
|
|
1275
|
+
*(f"- {index}. {item['label']} — `{item['duration_ms'] / 1000:.3f}` s" for index, item in enumerate(timing["longest_individual_spans"], 1)),
|
|
1276
|
+
"- Aggregation: category totals suppress only a same-category ancestor; ties sort by canonical phase name. Individual spans are independently retained and ranked by duration, phase name and ordinal.",
|
|
1277
|
+
"- Overhead: Total Wall Time excludes Queue Wait; it subtracts only External Wait and outer provider/validation processing coverage, so nested spans are not double-counted.",
|
|
1278
|
+
))
|
|
1279
|
+
else:
|
|
1280
|
+
timing_lines.append("- Phase-level telemetry: unavailable for this historical run.")
|
|
1281
|
+
if timing.get("historical_total_available"):
|
|
1282
|
+
timing_lines.append(
|
|
1283
|
+
f"- Historical Total Wall Time: `{timing['total_wall_time_ms'] / 1000:.3f}` s (phase telemetry incomplete)."
|
|
1284
|
+
)
|
|
1285
|
+
qualification_status = qualification.get("qualification") if qualification else "not recorded"
|
|
1286
|
+
qualification_summary_line = (
|
|
1287
|
+
f"`{qualification_status}`" if qualification else "not recorded"
|
|
1288
|
+
)
|
|
1289
|
+
evidence_bundle = "\n".join(
|
|
1290
|
+
(
|
|
1291
|
+
"## Evidence Bundle",
|
|
1292
|
+
"### Repository Evidence",
|
|
1293
|
+
f"- Target repository: `{bundle.target_repository}`",
|
|
1294
|
+
f"- Target commit: `{bundle.target_commit}`",
|
|
1295
|
+
f"- Worktree state: `{bundle.worktree_state}`",
|
|
1296
|
+
*_evidence_lines("Changed file", bundle.changed_files),
|
|
1297
|
+
*_evidence_lines("File added", bundle.files_added),
|
|
1298
|
+
*_evidence_lines("File modified", bundle.files_modified),
|
|
1299
|
+
*_evidence_lines("File removed", bundle.files_removed),
|
|
1300
|
+
"",
|
|
1301
|
+
"### Validation Evidence",
|
|
1302
|
+
*_validation_evidence_lines(state),
|
|
1303
|
+
f"- Qualification status: {qualification_summary_line}.",
|
|
1304
|
+
"- Schema validation: persisted terminal checkpoint accepted by the report generator.",
|
|
1305
|
+
"- Example validation: not recorded by the runner.",
|
|
1306
|
+
f"- git diff --check result: {bundle.diff_check}.",
|
|
1307
|
+
"",
|
|
1308
|
+
"### Implementation Evidence",
|
|
1309
|
+
_implementation_evidence(bundle),
|
|
1310
|
+
"",
|
|
1311
|
+
)
|
|
1312
|
+
) if state.phase == "COMPLETE" else ""
|
|
1313
|
+
preflight = latest_host_preflight(root)
|
|
1314
|
+
if preflight.get("run_id") not in {None, state.run_id}:
|
|
1315
|
+
preflight = {}
|
|
1316
|
+
preflight_checks = preflight.get("checks") or [] if isinstance(preflight, dict) else []
|
|
1317
|
+
if not isinstance(preflight_checks, (list, tuple)):
|
|
1318
|
+
preflight_checks = ()
|
|
1319
|
+
preflight_outcome = preflight.get("outcome", "unavailable") if isinstance(preflight, dict) else "unavailable"
|
|
1320
|
+
preflight_timestamp = preflight.get("timestamp", "unavailable") if isinstance(preflight, dict) else "unavailable"
|
|
1321
|
+
preflight_duration = preflight.get("duration_ms", "unavailable") if isinstance(preflight, dict) else "unavailable"
|
|
1322
|
+
preflight_summary = ", ".join(
|
|
1323
|
+
f"{item.get('identifier')}={item.get('outcome')}"
|
|
1324
|
+
for item in preflight_checks
|
|
1325
|
+
if isinstance(item, dict) and isinstance(item.get("identifier"), str)
|
|
1326
|
+
) or "unavailable"
|
|
1327
|
+
workspace_preflight = latest_workspace_preflight(root)
|
|
1328
|
+
if workspace_preflight.get("run_id") not in {None, state.run_id}:
|
|
1329
|
+
workspace_preflight = {}
|
|
1330
|
+
workspace_checks = workspace_preflight.get("checks") or [] if isinstance(workspace_preflight, dict) else []
|
|
1331
|
+
if not isinstance(workspace_checks, (list, tuple)):
|
|
1332
|
+
workspace_checks = ()
|
|
1333
|
+
workspace_summary = ", ".join(
|
|
1334
|
+
f"{item.get('identifier')}={item.get('outcome')}"
|
|
1335
|
+
for item in workspace_checks
|
|
1336
|
+
if isinstance(item, dict) and isinstance(item.get("identifier"), str)
|
|
1337
|
+
) or "unavailable"
|
|
1338
|
+
capability_preflight = latest_capability_preflight(root)
|
|
1339
|
+
if capability_preflight.get("run_id") not in {None, state.run_id}:
|
|
1340
|
+
capability_preflight = {}
|
|
1341
|
+
drift_evidence = [
|
|
1342
|
+
item for preflight in (preflight, workspace_preflight, capability_preflight)
|
|
1343
|
+
for item in preflight.get("drift_evidence", [])
|
|
1344
|
+
if isinstance(item, dict)
|
|
1345
|
+
]
|
|
1346
|
+
liveness = lease_liveness(root, state.run_id)
|
|
1347
|
+
terminal_reconciled = state.phase == "COMPLETE" and liveness.get("lease_state") == "RELEASED"
|
|
1348
|
+
recovery = (
|
|
1349
|
+
"Resume available under the existing lifecycle policy."
|
|
1350
|
+
if liveness.get("reconciliation_outcome") == "RECOVERABLE"
|
|
1351
|
+
else "Terminal evidence reconciled."
|
|
1352
|
+
if liveness.get("reconciliation_outcome") == "TERMINAL_EVIDENCE_PRESENT"
|
|
1353
|
+
else "No recovery action is required."
|
|
1354
|
+
)
|
|
1355
|
+
body = "\n".join(
|
|
1356
|
+
(
|
|
1357
|
+
"# Engineering Report",
|
|
1358
|
+
"",
|
|
1359
|
+
f"- Timestamp: {timestamp}",
|
|
1360
|
+
f"- Run ID: `{state.run_id}`",
|
|
1361
|
+
f"- Prompt: `{state.prompt_path}`",
|
|
1362
|
+
f"- Terminal state: `{state.phase}`",
|
|
1363
|
+
f"- Terminal Execution State: `{state.phase}`",
|
|
1364
|
+
f"- Execution lifecycle: `{state.phase}`",
|
|
1365
|
+
f"- Execution liveness: `{liveness.get('state', 'UNAVAILABLE')}` (historical compatibility)",
|
|
1366
|
+
f"- Current / Final Lease State: `{liveness.get('lease_state', 'UNAVAILABLE')}`",
|
|
1367
|
+
f"- Historical Liveness Event: `{'STALE detected and reconciled' if terminal_reconciled and liveness.get('state') == 'STALE' else liveness.get('state', 'UNAVAILABLE')}`",
|
|
1368
|
+
f"- Recovery Required: `{'NO' if terminal_reconciled else 'YES' if liveness.get('reconciliation_outcome') == 'RECOVERABLE' else 'NO'}`",
|
|
1369
|
+
f"- Recovery action: {recovery}",
|
|
1370
|
+
f"- Objective: {objective_header}",
|
|
1371
|
+
f"- Submitted Prompt Characters: `{len(objective)}`",
|
|
1372
|
+
"",
|
|
1373
|
+
"## Producer",
|
|
1374
|
+
"Forge owns Producer Contract semantics. Engineering Platform consumes this metadata for auditability only.",
|
|
1375
|
+
f"- Producer ID: `{producer.producer_id}`",
|
|
1376
|
+
f"- Producer Type: `{producer.producer_type}`",
|
|
1377
|
+
f"- Producer Version: `{producer.producer_version or 'not supplied'}`",
|
|
1378
|
+
f"- Correlation ID: `{producer.correlation_id or 'not supplied'}`",
|
|
1379
|
+
f"- Mission ID: `{producer.mission_id or 'not supplied'}`",
|
|
1380
|
+
f"- Engineering Action ID: `{producer.engineering_action_id or 'not supplied'}`",
|
|
1381
|
+
f"- Execution Constraint Version: `{producer.execution_constraint_version or 'not supplied'}`",
|
|
1382
|
+
"",
|
|
1383
|
+
*_producer_submission_contract_lines(submission, state, root),
|
|
1384
|
+
"## Execution Target Identity",
|
|
1385
|
+
"- Execution Host: `Engineering Platform`",
|
|
1386
|
+
f"- Execution Host Repository: `{state.repository}`",
|
|
1387
|
+
f"- Execution Mode: `{state.execution_mode}`",
|
|
1388
|
+
f"- Target Workspace: `{bundle.target_workspace}`",
|
|
1389
|
+
f"- Target Repository: `{bundle.target_repository}`",
|
|
1390
|
+
f"- Target Branch: `{bundle.target_branch}`",
|
|
1391
|
+
f"- Target Commit: `{bundle.target_commit}`",
|
|
1392
|
+
f"- Execution Host Version: `{manifest.platform_version}`",
|
|
1393
|
+
f"- Runner Version: `{manifest.runner_version}`",
|
|
1394
|
+
f"- Lease Host: `{bundle.lease.get('host_identity', 'unavailable')}`",
|
|
1395
|
+
f"- Lease Instance: `{bundle.lease.get('host_instance_id', 'unavailable')}`",
|
|
1396
|
+
f"- Lease State: `{bundle.lease.get('lease_state', 'unavailable')}`",
|
|
1397
|
+
f"- Readiness Profile: `{(bundle.readiness or {}).get('profile_id', 'unavailable')}`",
|
|
1398
|
+
f"- Readiness Profile Version: `{(bundle.readiness or {}).get('profile_version', 'unavailable')}`",
|
|
1399
|
+
f"- Readiness Decision: `{(bundle.readiness or {}).get('result', 'unavailable')}`",
|
|
1400
|
+
f"- Readiness Failed Requirements: `{', '.join((bundle.readiness or {}).get('failed_requirements', [])) or 'none'}`",
|
|
1401
|
+
f"- Bootstrap Contract: `{manifest.bootstrap_contract}`",
|
|
1402
|
+
f"- Checkpoint Format: `{manifest.checkpoint_format}`",
|
|
1403
|
+
"",
|
|
1404
|
+
"## Engineering Platform",
|
|
1405
|
+
f"- Platform Version: `{manifest.platform_version}`",
|
|
1406
|
+
f"- Runner Version: `{manifest.runner_version}`",
|
|
1407
|
+
f"- Bootstrap Contract: `{manifest.bootstrap_contract}`",
|
|
1408
|
+
f"- Checkpoint Format: `{manifest.checkpoint_format}`",
|
|
1409
|
+
f"- Memory Format: `{manifest.memory_format}`",
|
|
1410
|
+
f"- Report Format: `{manifest.report_format}`",
|
|
1411
|
+
f"- Runtime Provider: `{runtime_provider}`",
|
|
1412
|
+
f"- AI Model: `{reported_model}`",
|
|
1413
|
+
f"- Reasoning Profile: `{reported_reasoning}`",
|
|
1414
|
+
f"- Configuration Profile: `{reported_configuration}`",
|
|
1415
|
+
f"- Codex CLI Version: `{detected_cli or 'unavailable'}`",
|
|
1416
|
+
f"- Codex CLI Installation Path: `{reported_cli_installation_path}`",
|
|
1417
|
+
"",
|
|
1418
|
+
"## Execution Metadata",
|
|
1419
|
+
f"- Provider-Stage Files Modified: `{safe_execution_metadata.get('modified', 0)}`",
|
|
1420
|
+
f"- Provider-Stage Files Created: `{safe_execution_metadata.get('created', 0)}`",
|
|
1421
|
+
f"- Provider-Stage Files Deleted: `{safe_execution_metadata.get('deleted', 0)}`",
|
|
1422
|
+
f"- Files Changed In Run Delivery Diff: `{len(bundle.changed_files)}`",
|
|
1423
|
+
f"- Codex Commands Executed: `{safe_execution_metadata.get('codex_commands_executed', 0)}`",
|
|
1424
|
+
"",
|
|
1425
|
+
"## Execution Activity Summary",
|
|
1426
|
+
f"- Summary Version: `{activity_summary['summary_version']}`",
|
|
1427
|
+
"- Scope: terminal persisted activity and repository delivery evidence; the live worktree snapshot is volatile and is not a terminal result.",
|
|
1428
|
+
f"- Codex Command Definition: {activity_summary['activity']['codex_command_definition']}",
|
|
1429
|
+
f"- Primary Codex Commands: `{activity_summary['activity']['primary_codex_commands_total']}`",
|
|
1430
|
+
f"- Reviewer Codex Commands: `{activity_summary['activity']['reviewer_codex_commands_total']}`",
|
|
1431
|
+
f"- Host Validation Commands: `{activity_summary['activity']['host_validation_commands_total']}`",
|
|
1432
|
+
f"- Overall Activity Total: `{activity_summary['activity']['overall_activity_total']}`",
|
|
1433
|
+
f"- Terminal Delivery Baseline SHA: `{activity_summary['terminal_delivery_diff']['transaction_baseline_sha']}`",
|
|
1434
|
+
f"- Terminal Delivery Target SHA: `{activity_summary['terminal_delivery_diff']['terminal_target_sha']}`",
|
|
1435
|
+
f"- Terminal Delivery Unique Changed Paths: `{activity_summary['terminal_delivery_diff']['total_unique_changed_paths']}`",
|
|
1436
|
+
f"- Terminal Delivery Added / Modified / Removed / Renamed: `{len(activity_summary['terminal_delivery_diff']['added'])}` / `{len(activity_summary['terminal_delivery_diff']['modified'])}` / `{len(activity_summary['terminal_delivery_diff']['removed'])}` / `{len(activity_summary['terminal_delivery_diff']['renamed'])}`",
|
|
1437
|
+
"- Per-PR Changed Files: GitHub evidence scoped to each pull request; never summed into the terminal run delivery diff.",
|
|
1438
|
+
"",
|
|
1439
|
+
"## Engineering Platform Qualification",
|
|
1440
|
+
qualification_summary,
|
|
1441
|
+
"",
|
|
1442
|
+
"## Execution Host Preflight",
|
|
1443
|
+
f"- Outcome: `{preflight_outcome}`",
|
|
1444
|
+
f"- Timestamp: `{preflight_timestamp}`",
|
|
1445
|
+
f"- Duration: `{preflight_duration}` ms",
|
|
1446
|
+
f"- Checks: {preflight_summary}",
|
|
1447
|
+
"",
|
|
1448
|
+
"## Workspace Preflight",
|
|
1449
|
+
f"- Outcome: `{workspace_preflight.get('outcome', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1450
|
+
f"- Workspace: `{workspace_preflight.get('workspace', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1451
|
+
f"- Target repository: `{workspace_preflight.get('target_repository', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1452
|
+
f"- Canonical target path: `{workspace_preflight.get('canonical_target_path', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1453
|
+
f"- Authorization match: `{workspace_preflight.get('authorization_match', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1454
|
+
f"- Authorization policy: `{workspace_preflight.get('authorization_policy', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1455
|
+
f"- Branch: `{workspace_preflight.get('branch', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1456
|
+
f"- Execution mode: `{workspace_preflight.get('execution_mode', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1457
|
+
f"- Timestamp: `{workspace_preflight.get('timestamp', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}`",
|
|
1458
|
+
f"- Duration: `{workspace_preflight.get('duration_ms', 'unavailable') if isinstance(workspace_preflight, dict) else 'unavailable'}` ms",
|
|
1459
|
+
f"- Checks: {workspace_summary}",
|
|
1460
|
+
"",
|
|
1461
|
+
"## Capability Preflight",
|
|
1462
|
+
f"- Outcome: `{capability_preflight.get('outcome', 'unavailable') if isinstance(capability_preflight, dict) else 'unavailable'}`",
|
|
1463
|
+
f"- Recoverability: `{capability_preflight.get('recoverability', 'unavailable') if isinstance(capability_preflight, dict) else 'unavailable'}`",
|
|
1464
|
+
f"- Failure Origin: `{capability_preflight.get('failure_origin', 'none') if isinstance(capability_preflight, dict) else 'none'}`",
|
|
1465
|
+
f"- Recommendation: {capability_preflight.get('recommendation', 'unavailable') if isinstance(capability_preflight, dict) else 'unavailable'}",
|
|
1466
|
+
"",
|
|
1467
|
+
"## Development Host Drift Diagnostics",
|
|
1468
|
+
"- Detected Drift: " + (str(len(drift_evidence)) if drift_evidence else "none"),
|
|
1469
|
+
*(
|
|
1470
|
+
line
|
|
1471
|
+
for item in drift_evidence
|
|
1472
|
+
for line in (
|
|
1473
|
+
f"- Drift ID: `{item.get('drift_id', 'unavailable')}`",
|
|
1474
|
+
f" - Category: `{item.get('category', 'unavailable')}`; Severity: `{item.get('severity', 'unavailable')}`",
|
|
1475
|
+
f" - Expected State: {item.get('expected_value', 'unavailable')}",
|
|
1476
|
+
f" - Observed State: {item.get('observed_value', 'unavailable')}",
|
|
1477
|
+
f" - Blocking Reason: {item.get('affected_component', 'unavailable')}",
|
|
1478
|
+
f" - Recommended Resolution / Required Action: {item.get('resolution_recommendation', 'unavailable')}",
|
|
1479
|
+
f" - Affected Component: `{item.get('affected_component', 'unavailable')}`; Affected Repository: `{item.get('affected_repository', 'unavailable')}`; Affected Runtime: `{item.get('affected_runtime', 'unavailable')}`",
|
|
1480
|
+
)
|
|
1481
|
+
),
|
|
1482
|
+
"- Resume Guidance: " + (
|
|
1483
|
+
"Resolve the listed prerequisite, then retry; resume is not appropriate while drift remains."
|
|
1484
|
+
if drift_evidence else "No current development-host drift is recorded."
|
|
1485
|
+
),
|
|
1486
|
+
"",
|
|
1487
|
+
"## Authorization",
|
|
1488
|
+
f"- Owner authorization: `{state.owner_authorized}`",
|
|
1489
|
+
"- Ready for Review, merge and Finalization authority remain runner-controlled.",
|
|
1490
|
+
"",
|
|
1491
|
+
"## Lifecycle Timeline",
|
|
1492
|
+
f"`INITIALIZE → CAPABILITY_REVIEW → IMPLEMENTATION → VALIDATION → REPAIR ({state.repair_iterations}) → MERGE → FINALIZATION → REPOSITORY_CLEANUP → {state.phase}`",
|
|
1493
|
+
"",
|
|
1494
|
+
*timing_lines,
|
|
1495
|
+
"",
|
|
1496
|
+
*provider_usage_lines,
|
|
1497
|
+
"## Pull Requests",
|
|
1498
|
+
f"- Implementation: branch `{state.implementation_branch}`, PR `{state.implementation_pull_request}`, merge `{state.implementation_merge_commit}`",
|
|
1499
|
+
f"- Finalization: branch `{state.finalization_branch}`, PR `{state.finalization_pull_request}`, merge `{state.finalization_merge_commit}`",
|
|
1500
|
+
"",
|
|
1501
|
+
*_retry_relationship(state),
|
|
1502
|
+
"## Initial Repository Assessment",
|
|
1503
|
+
"This assessment describes the repository before implementation. Reviewer observations are advisory and cannot describe the final repository state.",
|
|
1504
|
+
"",
|
|
1505
|
+
"## Engineering Outcome",
|
|
1506
|
+
_format_engineering_outcome(state),
|
|
1507
|
+
"",
|
|
1508
|
+
*_managed_autonomy_projection(root, state, bundle, reviewer_records),
|
|
1509
|
+
"## Reviewer Findings",
|
|
1510
|
+
"Initial observations only. They are not final repository claims.",
|
|
1511
|
+
_format_reviewer_records(reviewer_records, state.phase),
|
|
1512
|
+
"",
|
|
1513
|
+
"## Repository Truth",
|
|
1514
|
+
"Execution Host, Target Repository, Target Commit, Repository Evidence and Evidence Bundle are the canonical engineering outcome.",
|
|
1515
|
+
"Priority: persisted repository state, resulting commits, validation results, then reviewer observations.",
|
|
1516
|
+
"The Engineering Outcome and Management Summary above are derived from that priority order.",
|
|
1517
|
+
"",
|
|
1518
|
+
"## Component Inventory",
|
|
1519
|
+
"Automatically derived from changed implementation files in the Repository Evidence; it is not manually authored.",
|
|
1520
|
+
*_component_inventory_lines(bundle),
|
|
1521
|
+
"",
|
|
1522
|
+
"## Deliverable Projection",
|
|
1523
|
+
*_deliverable_projection(objective, state, bundle, handoff),
|
|
1524
|
+
"",
|
|
1525
|
+
*recommendation_handoff_report_lines(handoff, state.phase),
|
|
1526
|
+
"## Qualification Projection",
|
|
1527
|
+
*_qualification_projection(state, qualification_status, runtime_provider),
|
|
1528
|
+
"",
|
|
1529
|
+
"## Runtime Projection",
|
|
1530
|
+
*_runtime_projection(state, producer, runtime_provider, reported_model),
|
|
1531
|
+
"",
|
|
1532
|
+
"## Execution Receipt Projection",
|
|
1533
|
+
*_execution_receipt_projection(root, state, producer),
|
|
1534
|
+
"",
|
|
1535
|
+
"## Decision Evidence Projection",
|
|
1536
|
+
*_decision_evidence_projection(producer),
|
|
1537
|
+
"",
|
|
1538
|
+
"## Deliverable Answer",
|
|
1539
|
+
f"- Final Deliverable Answer: {_deliverable_answer(objective, state)}",
|
|
1540
|
+
"",
|
|
1541
|
+
"## Commit Strategy",
|
|
1542
|
+
*_commit_strategy(state, bundle),
|
|
1543
|
+
"",
|
|
1544
|
+
"## Branch Traceability",
|
|
1545
|
+
*_branch_traceability(state, bundle),
|
|
1546
|
+
"",
|
|
1547
|
+
"## Requirement Traceability",
|
|
1548
|
+
"Each row links the prompt requirement to repository-derived implementation, test and validation evidence.",
|
|
1549
|
+
*_requirement_traceability(objective, state, bundle),
|
|
1550
|
+
"",
|
|
1551
|
+
"## Validation Traceability",
|
|
1552
|
+
*_validation_traceability(state, bundle),
|
|
1553
|
+
"",
|
|
1554
|
+
"## Execution Statistics",
|
|
1555
|
+
*_execution_statistics(state, bundle, timing),
|
|
1556
|
+
"",
|
|
1557
|
+
"## Statistics Projection",
|
|
1558
|
+
*_statistics_projection(state, bundle),
|
|
1559
|
+
"",
|
|
1560
|
+
"## Engineering Evidence Summary",
|
|
1561
|
+
"```json",
|
|
1562
|
+
_evidence_summary(state, bundle, objective),
|
|
1563
|
+
"```",
|
|
1564
|
+
"",
|
|
1565
|
+
evidence_bundle,
|
|
1566
|
+
*_validation_control_projection(root, state, bundle),
|
|
1567
|
+
"",
|
|
1568
|
+
_reconciliation_evidence(objective, state, bundle),
|
|
1569
|
+
"## Validation",
|
|
1570
|
+
"Repository validation is recorded by the runner and required GitHub Actions; inspect the linked PR evidence for durations."
|
|
1571
|
+
if state.phase == "COMPLETE"
|
|
1572
|
+
else "No successful engineering validation or delivery is claimed for this terminal transaction.",
|
|
1573
|
+
"",
|
|
1574
|
+
"## Repair History",
|
|
1575
|
+
*_repair_audit_lines(state),
|
|
1576
|
+
"",
|
|
1577
|
+
"## Local Repository Validation History",
|
|
1578
|
+
*_local_validation_audit_lines(state),
|
|
1579
|
+
"",
|
|
1580
|
+
"## Repository Cleanup",
|
|
1581
|
+
state.latest_repository_evidence or "Cleanup evidence unavailable.",
|
|
1582
|
+
"",
|
|
1583
|
+
"## Specialist Agent Reviews",
|
|
1584
|
+
"Specialist review agents are read-only advisory helpers. Their initial observations are listed above; the primary runner retains lifecycle authority.",
|
|
1585
|
+
"",
|
|
1586
|
+
"## Management Summary",
|
|
1587
|
+
"Final repository outcome; it does not restate initial reviewer observations as current state.",
|
|
1588
|
+
format_terminal_management_summary(state),
|
|
1589
|
+
"",
|
|
1590
|
+
"## Diagnostics",
|
|
1591
|
+
state.diagnostic or drift_summary(drift_evidence),
|
|
1592
|
+
f"Resume: `engineering-execution-host {state.prompt_path} --run-id {state.run_id} --resume`",
|
|
1593
|
+
"",
|
|
1594
|
+
"## Metrics",
|
|
1595
|
+
f"- Codex CLI execution time: {state.agent_execution_seconds if state.agent_execution_seconds is not None else 'not measured'} seconds",
|
|
1596
|
+
f"- Repair iterations: {state.repair_iterations}",
|
|
1597
|
+
f"- PRs created: {sum(value is not None for value in (state.implementation_pull_request, state.finalization_pull_request))}",
|
|
1598
|
+
f"- Merges performed: {sum(value is not None for value in (state.implementation_merge_commit, state.finalization_merge_commit))}",
|
|
1599
|
+
"",
|
|
1600
|
+
)
|
|
1601
|
+
)
|
|
1602
|
+
return ReportingCoordinator().deliver(
|
|
1603
|
+
path=path,
|
|
1604
|
+
body=body,
|
|
1605
|
+
validate=lambda value: report_consistency_errors(value, state, bundle, objective),
|
|
1606
|
+
terminal_matches=lambda value: terminal_report_matches_state(value, state),
|
|
1607
|
+
)
|