Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
808 changes: 808 additions & 0 deletions .claude/backup_README_corrupted_20260504_233240.md

Large diffs are not rendered by default.

1,898 changes: 1,898 additions & 0 deletions .claude/blob_65cf5acbb1de8197ea42e74e03fb9c2505f2808c.txt

Large diffs are not rendered by default.

627 changes: 627 additions & 0 deletions .claude/blob_f3f2a26f0059515eee07afd722cf65dd5b9090d6.txt

Large diffs are not rendered by default.

2,974 changes: 2,974 additions & 0 deletions .claude/blob_f42_sample.txt

Large diffs are not rendered by default.

2,974 changes: 2,974 additions & 0 deletions .claude/blob_f42ff8202c41966786c80f08d59c37b9660d6bc6.txt

Large diffs are not rendered by default.

Binary file added .claude/tmp_exec_from_head_refresh.txt
Binary file not shown.
Binary file added .claude/tmp_obj_EXEC_from_head.txt
Binary file not shown.
Binary file added .claude/tmp_obj_README_from_head.txt
Binary file not shown.
356 changes: 356 additions & 0 deletions .claude/tmp_p2_96_source_snapshot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
"""Phase 2 card P2-97 gate for Linux CI workflow pipeline closure to P2-96.

This script validates that the P2-96 closure verifier contract remains present
and stable for Linux-stage consumers. It emits normalized JSON/Markdown output
and optional GitHub outputs.
"""

from __future__ import annotations

import argparse
import json
import sys
from datetime import datetime, timezone
from pathlib import Path
from typing import Any


REQUIRED_P2_96_CLOSURE_PATTERNS: dict[str, str] = {
"pipeline_closure_card_id_p2_96_missing": '"pipeline_closure_card_id": "P2-96"',
"pipeline_closure_target_card_id_p2_95_missing": '"pipeline_closure_target_card_id": "P2-95"',
"pipeline_closure_status_key_p2_95_missing": "pipeline_closure_to_p2_95_status",
"pipeline_closure_decision_verified_p2_95_missing": "pipeline_closure_to_p2_95_verified",
"pipeline_closure_required_stage_script_ref_missing": (
"scripts/run_p2_linux_ci_workflow_pipeline_closure_p2_85_gate.py"
),
"pipeline_closure_report_json_p2_95_missing": "ci_workflow_pipeline_closure_p2_95.json",
"pipeline_closure_report_markdown_p2_95_missing": "ci_workflow_pipeline_closure_p2_95.md",
}


def _unique(items: list[str]) -> list[str]:
deduped: list[str] = []
seen: set[str] = set()
for item in items:
if item in seen:
continue
seen.add(item)
deduped.append(item)
return deduped


def _read_text(path: Path) -> str:
try:
return path.read_text(encoding="utf-8")
except UnicodeDecodeError as exc:
raise ValueError(f"{path}: invalid utf-8 content ({exc})") from exc


def build_pipeline_closure_to_p2_96_payload(
*,
project_root: Path,
pipeline_closure_p2_95_gate_script: Path,
pipeline_closure_p2_95_runtime_test: Path,
) -> dict[str, Any]:
structural_issues: list[str] = []
missing_artifacts: list[str] = []
reason_codes: list[str] = []

if not pipeline_closure_p2_95_gate_script.is_file():
missing_artifacts.append(str(pipeline_closure_p2_95_gate_script))
p2_96_closure_text = ""
else:
p2_96_closure_text = _read_text(pipeline_closure_p2_95_gate_script)

if not pipeline_closure_p2_95_runtime_test.is_file():
missing_artifacts.append(str(pipeline_closure_p2_95_runtime_test))

for issue_code, pattern in REQUIRED_P2_96_CLOSURE_PATTERNS.items():
if pattern not in p2_96_closure_text:
structural_issues.append(issue_code)

structural_issues = _unique(structural_issues)
missing_artifacts = _unique(missing_artifacts)

if structural_issues or missing_artifacts:
status = "failed"
decision = "hold_pipeline_closure_p2_96_manual_action"
exit_code = 1
should_proceed = False
requires_manual_action = True
channel = "blocker"
reason_codes.extend(structural_issues)
if missing_artifacts:
reason_codes.append("pipeline_closure_required_artifacts_missing")
else:
status = "passed"
decision = "pipeline_closure_to_p2_96_verified"
exit_code = 0
should_proceed = True
requires_manual_action = False
channel = "release"
reason_codes = [
"pipeline_closure_to_p2_96_verified",
"pipeline_closure_p2_96_contract_wired",
]

reason_codes = _unique(reason_codes)

summary = (
"pipeline_closure_card=P2-97 "
f"pipeline_closure_to_p2_96_status={status} "
f"pipeline_closure_to_p2_96_decision={decision}"
)

return {
"generated_at": datetime.now(timezone.utc).isoformat(),
"project_root": str(project_root.resolve()),
"source_pipeline_closure_p2_95_gate_script": str(
pipeline_closure_p2_95_gate_script.resolve()
),
"source_pipeline_closure_p2_95_runtime_test": str(
pipeline_closure_p2_95_runtime_test.resolve()
),
"pipeline_closure_card_id": "P2-97",
"pipeline_closure_target_card_id": "P2-96",
"pipeline_closure_to_p2_96_status": status,
"pipeline_closure_to_p2_96_decision": decision,
"pipeline_closure_to_p2_96_exit_code": exit_code,
"pipeline_closure_to_p2_96_should_proceed": should_proceed,
"pipeline_closure_to_p2_96_requires_manual_action": requires_manual_action,
"pipeline_closure_to_p2_96_channel": channel,
"pipeline_closure_to_p2_96_summary": summary,
"reason_codes": reason_codes,
"structural_issues": structural_issues,
"missing_artifacts": missing_artifacts,
"required_patterns_checked": REQUIRED_P2_96_CLOSURE_PATTERNS,
}


def render_markdown_report(payload: dict[str, Any]) -> str:
lines = [
"# Linux CI Workflow Pipeline Closure to P2-96 Report",
"",
(
"- Pipeline Closure Status: "
f"**{str(payload['pipeline_closure_to_p2_96_status']).upper()}**"
),
(
"- Pipeline Closure Decision: "
f"`{payload['pipeline_closure_to_p2_96_decision']}`"
),
(
"- Pipeline Closure Exit Code: "
f"`{payload['pipeline_closure_to_p2_96_exit_code']}`"
),
(
"- Should Proceed: "
f"`{payload['pipeline_closure_to_p2_96_should_proceed']}`"
),
(
"- Requires Manual Action: "
f"`{payload['pipeline_closure_to_p2_96_requires_manual_action']}`"
),
(
"- Channel: "
f"`{payload['pipeline_closure_to_p2_96_channel']}`"
),
(
"- Source P2-96 Closure Gate: "
f"`{payload['source_pipeline_closure_p2_95_gate_script']}`"
),
(
"- Source P2-96 Runtime Test: "
f"`{payload['source_pipeline_closure_p2_95_runtime_test']}`"
),
f"- Generated At (UTC): `{payload['generated_at']}`",
"",
"## Summary",
"",
f"- {payload['pipeline_closure_to_p2_96_summary']}",
"",
"## Reason Codes",
]

reason_codes = payload["reason_codes"]
if reason_codes:
lines.extend(f"- `{item}`" for item in reason_codes)
else:
lines.append("- none")

lines.extend(["", "## Structural Issues"])
structural_issues = payload["structural_issues"]
if structural_issues:
lines.extend(f"- `{item}`" for item in structural_issues)
else:
lines.append("- none")

lines.extend(["", "## Missing Artifacts"])
missing_artifacts = payload["missing_artifacts"]
if missing_artifacts:
lines.extend(f"- `{item}`" for item in missing_artifacts)
else:
lines.append("- none")

lines.append("")
return "\n".join(lines)


def build_github_output_values(
payload: dict[str, Any], *, output_json: Path, output_markdown: Path
) -> dict[str, str]:
return {
"workflow_pipeline_closure_to_p2_96_status": str(
payload["pipeline_closure_to_p2_96_status"]
),
"workflow_pipeline_closure_to_p2_96_decision": str(
payload["pipeline_closure_to_p2_96_decision"]
),
"workflow_pipeline_closure_to_p2_96_exit_code": str(
payload["pipeline_closure_to_p2_96_exit_code"]
),
"workflow_pipeline_closure_to_p2_96_should_proceed": (
"true"
if payload["pipeline_closure_to_p2_96_should_proceed"]
else "false"
),
"workflow_pipeline_closure_to_p2_96_requires_manual_action": (
"true"
if payload["pipeline_closure_to_p2_96_requires_manual_action"]
else "false"
),
"workflow_pipeline_closure_to_p2_96_channel": str(
payload["pipeline_closure_to_p2_96_channel"]
),
"workflow_pipeline_closure_to_p2_96_reason_codes": json.dumps(
payload["reason_codes"],
ensure_ascii=False,
separators=(",", ":"),
),
"workflow_pipeline_closure_to_p2_96_structural_issues_count": str(
len(payload["structural_issues"])
),
"workflow_pipeline_closure_to_p2_96_missing_artifacts_count": str(
len(payload["missing_artifacts"])
),
"workflow_pipeline_closure_to_p2_96_report_json": str(output_json),
"workflow_pipeline_closure_to_p2_96_report_markdown": str(output_markdown),
}


def write_github_output(path: Path, values: dict[str, str]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("a", encoding="utf-8") as handle:
for key, value in values.items():
handle.write(f"{key}={value}\n")


def main() -> int:
parser = argparse.ArgumentParser(
description="Validate Linux CI workflow pipeline closure to P2-96 wiring"
)
parser.add_argument(
"--project-root",
default=".",
help="Project root containing scripts/ and tests/ (default: current directory)",
)
parser.add_argument(
"--pipeline-closure-p2-95-gate-script",
default="scripts/run_p2_linux_ci_workflow_pipeline_closure_p2_95_gate.py",
help="P2-96 closure verifier script path (P2-95 pipeline closure gate)",
)
parser.add_argument(
"--pipeline-closure-p2-95-runtime-test",
default="tests/test_p2_linux_ci_workflow_pipeline_closure_p2_95_gate_runtime.py",
help="P2-96 runtime test path",
)
parser.add_argument(
"--output-json",
default=".claude/reports/linux_unified_gate/ci_workflow_pipeline_closure_p2_96.json",
help="Output JSON report path",
)
parser.add_argument(
"--output-markdown",
default=".claude/reports/linux_unified_gate/ci_workflow_pipeline_closure_p2_96.md",
help="Output Markdown report path",
)
parser.add_argument(
"--github-output",
default=None,
help="Optional GitHub Actions output file path",
)
parser.add_argument(
"--print-report",
action="store_true",
help="Print report JSON to stdout",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Validate and print summary without writing report files",
)
args = parser.parse_args()

project_root = Path(args.project_root)
pipeline_closure_p2_95_gate_script = project_root / Path(
args.pipeline_closure_p2_95_gate_script
)
pipeline_closure_p2_95_runtime_test = project_root / Path(
args.pipeline_closure_p2_95_runtime_test
)

try:
payload = build_pipeline_closure_to_p2_96_payload(
project_root=project_root,
pipeline_closure_p2_95_gate_script=pipeline_closure_p2_95_gate_script,
pipeline_closure_p2_95_runtime_test=pipeline_closure_p2_95_runtime_test,
)
except ValueError as exc:
print(
f"[p2-linux-ci-workflow-pipeline-closure-p2-96-gate] {exc}",
file=sys.stderr,
)
return 2

output_json = Path(args.output_json)
output_markdown = Path(args.output_markdown)

if not args.dry_run:
output_json.parent.mkdir(parents=True, exist_ok=True)
output_json.write_text(
json.dumps(payload, indent=2, ensure_ascii=False),
encoding="utf-8",
)

output_markdown.parent.mkdir(parents=True, exist_ok=True)
output_markdown.write_text(render_markdown_report(payload), encoding="utf-8")

print(f"pipeline closure report json: {output_json}")
print(f"pipeline closure report markdown: {output_markdown}")

if args.github_output:
values = build_github_output_values(
payload,
output_json=output_json,
output_markdown=output_markdown,
)
write_github_output(Path(args.github_output), values)
print(f"github output: {args.github_output}")

print(
"pipeline closure summary: "
f"pipeline_closure_to_p2_96_status={payload['pipeline_closure_to_p2_96_status']} "
f"pipeline_closure_to_p2_96_decision={payload['pipeline_closure_to_p2_96_decision']} "
f"pipeline_closure_to_p2_96_exit_code={payload['pipeline_closure_to_p2_96_exit_code']}"
)

if args.print_report or args.dry_run:
print(json.dumps(payload, indent=2, ensure_ascii=False))

return int(payload["pipeline_closure_to_p2_96_exit_code"])


if __name__ == "__main__":
raise SystemExit(main())


Loading