From b541e278f9415d529c1ef28607b239c355ffbb44 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 5 Aug 2026 21:19:01 +0900 Subject: [PATCH 1/9] ci: materialize focused sandbox evidence bounds --- .../materialize-sandboxed-evidence-bounds.yml | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 .github/workflows/materialize-sandboxed-evidence-bounds.yml diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml new file mode 100644 index 000000000..3e93d9064 --- /dev/null +++ b/.github/workflows/materialize-sandboxed-evidence-bounds.yml @@ -0,0 +1,211 @@ +name: Materialize focused sandbox evidence bounds + +on: + push: + branches: + - fix/sandboxed-evidence-bounds-main + paths: + - .github/workflows/materialize-sandboxed-evidence-bounds.yml + +permissions: + contents: read + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + materialize: + if: >- + github.repository == 'ContextualWisdomLab/.github' + && github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' + runs-on: ubuntu-24.04 + timeout-minutes: 60 + permissions: + contents: write + steps: + - name: Harden runner + uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 + with: + egress-policy: audit + + - name: Checkout exact current-main branch + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.sha }} + fetch-depth: 0 + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.14" + cache: pip + cache-dependency-path: requirements-opencode-review-ci-hashes.txt + + - name: Import immutable focused source + env: + SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + git cat-file -e "${SOURCE_SHA}^{commit}" + git checkout "$SOURCE_SHA" -- \ + docs/doctoring/sandboxed-command-log-redaction.md \ + docs/doctoring/sandboxed-output-resource-bounds.md \ + docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md \ + docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md \ + scripts/ci/bounded_subprocess.py \ + scripts/ci/redact_sensitive_log.py \ + scripts/ci/run_opencode_review_model_pool.sh \ + scripts/ci/sandboxed_verify.py \ + scripts/ci/sandboxed_web_e2e.py \ + tests/test_bounded_subprocess.py \ + tests/test_bounded_subprocess_capture_startup.py \ + tests/test_bounded_subprocess_contract.py \ + tests/test_opencode_model_pool_runner.py \ + tests/test_redact_json_key_boundary.py \ + tests/test_redact_sensitive_log_contract.py \ + tests/test_sandboxed_entrypoint_and_cleanup_coverage.py \ + tests/test_sandboxed_output_redaction.py \ + tests/test_sandboxed_service_capture_startup.py \ + tests/test_sandboxed_verify_output_limits.py \ + tests/test_sandboxed_web_e2e.py \ + tests/test_sandboxed_web_e2e_branch_contract.py \ + tests/test_sandboxed_web_e2e_output_limits.py + + cat >.github/workflows/sandboxed-evidence-quality-ci.yml <<'YAML' + name: Sandboxed Evidence Quality CI + + on: + pull_request: + branches: [main] + paths: + - ".github/workflows/sandboxed-evidence-quality-ci.yml" + - "scripts/ci/bounded_subprocess.py" + - "scripts/ci/redact_sensitive_log.py" + - "scripts/ci/run_opencode_review_model_pool.sh" + - "scripts/ci/sandboxed_verify.py" + - "scripts/ci/sandboxed_web_e2e.py" + - "tests/test_bounded_subprocess*.py" + - "tests/test_opencode_model_pool_runner.py" + - "tests/test_redact*.py" + - "tests/test_sandboxed*.py" + - "requirements-opencode-review-ci-hashes.txt" + push: + branches: [main] + paths: + - ".github/workflows/sandboxed-evidence-quality-ci.yml" + - "scripts/ci/bounded_subprocess.py" + - "scripts/ci/redact_sensitive_log.py" + - "scripts/ci/run_opencode_review_model_pool.sh" + - "scripts/ci/sandboxed_verify.py" + - "scripts/ci/sandboxed_web_e2e.py" + - "tests/test_bounded_subprocess*.py" + - "tests/test_opencode_model_pool_runner.py" + - "tests/test_redact*.py" + - "tests/test_sandboxed*.py" + - "requirements-opencode-review-ci-hashes.txt" + + concurrency: + group: sandboxed-evidence-quality-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + + permissions: + contents: read + + env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + + jobs: + quality: + runs-on: ubuntu-24.04 + timeout-minutes: 40 + steps: + - name: Harden runner + uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 + with: + egress-policy: audit + - name: Checkout exact head + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.14" + cache: pip + cache-dependency-path: requirements-opencode-review-ci-hashes.txt + - name: Install exact hash-locked tooling + run: >- + python -m pip install --disable-pip-version-check --require-hashes + -r requirements-opencode-review-ci-hashes.txt + - name: Run complete integrated quality contract + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + python -m coverage erase + python -m coverage run --branch -m pytest -q + python -m coverage report --show-missing --fail-under=100 + python -m interrogate --fail-under=100 scripts/ci + python -m compileall -q scripts tests + bash -n scripts/ci/run_opencode_review_model_pool.sh + git diff --check + YAML + + python3 - <<'PY' + from pathlib import Path + + changelog = Path("CHANGELOG.md") + source = changelog.read_text(encoding="utf-8") + entries = ( + "- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n", + "- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n", + "- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n", + ) + marker = "## [Unreleased]\n" + if marker not in source: + raise SystemExit("CHANGELOG is missing the Unreleased section") + missing = "".join(entry for entry in entries if entry not in source) + if missing: + changelog.write_text( + source.replace(marker, marker + "\n" + missing, 1), + encoding="utf-8", + ) + PY + rm .github/workflows/materialize-sandboxed-evidence-bounds.yml + git diff --check + + - name: Install exact hash-locked tooling + run: >- + python -m pip install --disable-pip-version-check --require-hashes + -r requirements-opencode-review-ci-hashes.txt + + - name: Verify complete integrated quality contract + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + python -m coverage erase + python -m coverage run --branch -m pytest -q + python -m coverage report --show-missing --fail-under=100 + python -m interrogate --fail-under=100 scripts/ci + python -m compileall -q scripts tests + bash -n scripts/ci/run_opencode_review_model_pool.sh + git diff --check + + - name: Publish focused implementation and remove materializer + env: + EXPECTED_HEAD: ${{ github.sha }} + HEAD_BRANCH: ${{ github.ref_name }} + PUSH_TOKEN: ${{ github.token }} + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + remote_head="$(git ls-remote origin "refs/heads/${HEAD_BRANCH}" | cut -f1)" + test "$remote_head" = "$EXPECTED_HEAD" + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add --all + git diff --cached --quiet && { echo "No focused implementation generated" >&2; exit 1; } + git commit -m "fix(ci): secure and bound sandbox evidence streams" + auth_header="$(printf 'x-access-token:%s' "$PUSH_TOKEN" | base64 | tr -d '\n')" + echo "::add-mask::$auth_header" + git -c http.https://github.com/.extraheader="AUTHORIZATION: basic ${auth_header}" \ + push --force-with-lease="refs/heads/${HEAD_BRANCH}:${EXPECTED_HEAD}" \ + origin "HEAD:refs/heads/${HEAD_BRANCH}" From 36da08f68271f5b185802f29303ccfec469e79bd Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 5 Aug 2026 22:18:07 +0900 Subject: [PATCH 2/9] ci: trigger sandbox evidence materializer --- .github/workflows/materialize-sandboxed-evidence-bounds.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml index 3e93d9064..8b7da242a 100644 --- a/.github/workflows/materialize-sandboxed-evidence-bounds.yml +++ b/.github/workflows/materialize-sandboxed-evidence-bounds.yml @@ -1,4 +1,5 @@ name: Materialize focused sandbox evidence bounds +run-name: Materialize sandbox evidence bounds at ${{ github.sha }} on: push: @@ -17,6 +18,7 @@ jobs: materialize: if: >- github.repository == 'ContextualWisdomLab/.github' + && github.actor == 'seonghobae' && github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' runs-on: ubuntu-24.04 timeout-minutes: 60 @@ -45,8 +47,10 @@ jobs: - name: Import immutable focused source env: SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 + EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae shell: bash --noprofile --norc -e -o pipefail {0} run: | + test "$(git merge-base "$GITHUB_SHA" main)" = "$EXPECTED_MAIN" git cat-file -e "${SOURCE_SHA}^{commit}" git checkout "$SOURCE_SHA" -- \ docs/doctoring/sandboxed-command-log-redaction.md \ From 7d9bdda510616f75c7c2d8957742513321227517 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 6 Aug 2026 13:35:43 +0900 Subject: [PATCH 3/9] ci: materialize sandbox bounds from immutable PR source --- .../materialize-sandboxed-evidence-bounds.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml index 8b7da242a..3f3356625 100644 --- a/.github/workflows/materialize-sandboxed-evidence-bounds.yml +++ b/.github/workflows/materialize-sandboxed-evidence-bounds.yml @@ -50,8 +50,13 @@ jobs: EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae shell: bash --noprofile --norc -e -o pipefail {0} run: | - test "$(git merge-base "$GITHUB_SHA" main)" = "$EXPECTED_MAIN" - git cat-file -e "${SOURCE_SHA}^{commit}" + test "$(git rev-parse HEAD)" = "$GITHUB_SHA" + git cat-file -e "${EXPECTED_MAIN}^{commit}" + test "$(git merge-base "$GITHUB_SHA" "$EXPECTED_MAIN")" = "$EXPECTED_MAIN" + if ! git cat-file -e "${SOURCE_SHA}^{commit}" 2>/dev/null; then + git fetch --no-tags --depth=1 origin refs/pull/767/head + fi + test "$(git rev-parse "${SOURCE_SHA}^{commit}")" = "$SOURCE_SHA" git checkout "$SOURCE_SHA" -- \ docs/doctoring/sandboxed-command-log-redaction.md \ docs/doctoring/sandboxed-output-resource-bounds.md \ @@ -210,6 +215,6 @@ jobs: git commit -m "fix(ci): secure and bound sandbox evidence streams" auth_header="$(printf 'x-access-token:%s' "$PUSH_TOKEN" | base64 | tr -d '\n')" echo "::add-mask::$auth_header" - git -c http.https://github.com/.extraheader="AUTHORIZATION: basic ${auth_header}" \ + git -c http.extraheader="AUTHORIZATION: basic ${auth_header}" \ push --force-with-lease="refs/heads/${HEAD_BRANCH}:${EXPECTED_HEAD}" \ origin "HEAD:refs/heads/${HEAD_BRANCH}" From 49a98651f35362eb166810292b25d4255a70fc9f Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 6 Aug 2026 13:52:19 +0900 Subject: [PATCH 4/9] chore(ci): verify PR 788 materialization through immutable Git objects --- ...materialize-sandboxed-evidence-receipt.yml | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 .github/workflows/materialize-sandboxed-evidence-receipt.yml diff --git a/.github/workflows/materialize-sandboxed-evidence-receipt.yml b/.github/workflows/materialize-sandboxed-evidence-receipt.yml new file mode 100644 index 000000000..6e0ab62d0 --- /dev/null +++ b/.github/workflows/materialize-sandboxed-evidence-receipt.yml @@ -0,0 +1,343 @@ +name: Materialize verified sandbox evidence commit + +on: + pull_request: + branches: + - main + types: + - synchronize + +permissions: + contents: read + +concurrency: + group: materialize-sandboxed-evidence-receipt + cancel-in-progress: false + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +jobs: + materialize: + if: >- + github.repository == 'ContextualWisdomLab/.github' && + github.event.pull_request.number == 788 && + github.event.pull_request.head.ref == 'fix/sandboxed-evidence-bounds-main' + permissions: + contents: write + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - name: Harden runner + uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 + with: + egress-policy: audit + + - name: Checkout exact current-main branch + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.14" + cache: pip + cache-dependency-path: requirements-opencode-review-ci-hashes.txt + + - name: Verify bounded setup and import immutable focused source + env: + SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 + EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae + EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }} + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" + git cat-file -e "${EXPECTED_MAIN}^{commit}" + test "$(git merge-base "$EXPECTED_HEAD" "$EXPECTED_MAIN")" = "$EXPECTED_MAIN" + mapfile -t setup_paths < <(git diff --name-only "$EXPECTED_MAIN" "$EXPECTED_HEAD" | sort) + expected_setup_paths=( + ".github/workflows/materialize-sandboxed-evidence-bounds.yml" + ".github/workflows/materialize-sandboxed-evidence-receipt.yml" + ) + test "${#setup_paths[@]}" -eq "${#expected_setup_paths[@]}" + for index in "${!expected_setup_paths[@]}"; do + test "${setup_paths[$index]}" = "${expected_setup_paths[$index]}" + done + if ! git cat-file -e "${SOURCE_SHA}^{commit}" 2>/dev/null; then + git fetch --no-tags --depth=1 origin refs/pull/767/head + fi + test "$(git rev-parse "${SOURCE_SHA}^{commit}")" = "$SOURCE_SHA" + git checkout "$SOURCE_SHA" -- \ + docs/doctoring/sandboxed-command-log-redaction.md \ + docs/doctoring/sandboxed-output-resource-bounds.md \ + docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md \ + docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md \ + scripts/ci/bounded_subprocess.py \ + scripts/ci/redact_sensitive_log.py \ + scripts/ci/run_opencode_review_model_pool.sh \ + scripts/ci/sandboxed_verify.py \ + scripts/ci/sandboxed_web_e2e.py \ + tests/test_bounded_subprocess.py \ + tests/test_bounded_subprocess_capture_startup.py \ + tests/test_bounded_subprocess_contract.py \ + tests/test_opencode_model_pool_runner.py \ + tests/test_redact_json_key_boundary.py \ + tests/test_redact_sensitive_log_contract.py \ + tests/test_sandboxed_entrypoint_and_cleanup_coverage.py \ + tests/test_sandboxed_output_redaction.py \ + tests/test_sandboxed_service_capture_startup.py \ + tests/test_sandboxed_verify_output_limits.py \ + tests/test_sandboxed_web_e2e.py \ + tests/test_sandboxed_web_e2e_branch_contract.py \ + tests/test_sandboxed_web_e2e_output_limits.py + + cat >.github/workflows/sandboxed-evidence-quality-ci.yml <<'YAML' + name: Sandboxed Evidence Quality CI + + on: + pull_request: + branches: [main] + paths: + - ".github/workflows/sandboxed-evidence-quality-ci.yml" + - "scripts/ci/bounded_subprocess.py" + - "scripts/ci/redact_sensitive_log.py" + - "scripts/ci/run_opencode_review_model_pool.sh" + - "scripts/ci/sandboxed_verify.py" + - "scripts/ci/sandboxed_web_e2e.py" + - "tests/test_bounded_subprocess*.py" + - "tests/test_opencode_model_pool_runner.py" + - "tests/test_redact*.py" + - "tests/test_sandboxed*.py" + - "requirements-opencode-review-ci-hashes.txt" + push: + branches: [main] + paths: + - ".github/workflows/sandboxed-evidence-quality-ci.yml" + - "scripts/ci/bounded_subprocess.py" + - "scripts/ci/redact_sensitive_log.py" + - "scripts/ci/run_opencode_review_model_pool.sh" + - "scripts/ci/sandboxed_verify.py" + - "scripts/ci/sandboxed_web_e2e.py" + - "tests/test_bounded_subprocess*.py" + - "tests/test_opencode_model_pool_runner.py" + - "tests/test_redact*.py" + - "tests/test_sandboxed*.py" + - "requirements-opencode-review-ci-hashes.txt" + + concurrency: + group: sandboxed-evidence-quality-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + + permissions: + contents: read + + env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + + jobs: + quality: + runs-on: ubuntu-24.04 + timeout-minutes: 40 + steps: + - name: Harden runner + uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 + with: + egress-policy: audit + - name: Checkout exact head + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.14" + cache: pip + cache-dependency-path: requirements-opencode-review-ci-hashes.txt + - name: Install exact hash-locked tooling + run: >- + python -m pip install --disable-pip-version-check --require-hashes + -r requirements-opencode-review-ci-hashes.txt + - name: Run complete integrated quality contract + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + python -m coverage erase + python -m coverage run --branch -m pytest -q + python -m coverage report --show-missing --fail-under=100 + python -m interrogate --fail-under=100 scripts/ci + python -m compileall -q scripts tests + bash -n scripts/ci/run_opencode_review_model_pool.sh + git diff --check + YAML + + python3 - <<'PY' + from pathlib import Path + + changelog = Path("CHANGELOG.md") + source = changelog.read_text(encoding="utf-8") + entries = ( + "- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n", + "- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n", + "- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n", + ) + marker = "## [Unreleased]\n" + if marker not in source: + raise SystemExit("CHANGELOG is missing the Unreleased section") + missing = "".join(entry for entry in entries if entry not in source) + if missing: + changelog.write_text( + source.replace(marker, marker + "\n" + missing, 1), + encoding="utf-8", + ) + PY + rm \ + .github/workflows/materialize-sandboxed-evidence-bounds.yml \ + .github/workflows/materialize-sandboxed-evidence-receipt.yml + git diff --check + + - name: Install exact hash-locked tooling + run: >- + python -m pip install --disable-pip-version-check --require-hashes + -r requirements-opencode-review-ci-hashes.txt + + - name: Verify complete integrated quality contract + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + python -m coverage erase + python -m coverage run --branch -m pytest -q + python -m coverage report --show-missing --fail-under=100 + python -m interrogate --fail-under=100 scripts/ci + python -m compileall -q scripts tests + bash -n scripts/ci/run_opencode_review_model_pool.sh + git diff --check + + - name: Build immutable verified Git commit object + env: + API_TOKEN: ${{ github.token }} + EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }} + SOURCE_BRANCH: fix/sandboxed-evidence-bounds-main + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" + remote_head="$(git ls-remote origin "refs/heads/${SOURCE_BRANCH}" | cut -f1)" + test "$remote_head" = "$EXPECTED_HEAD" + python3 - <<'PY' | tee "${RUNNER_TEMP}/pr788-materialization-receipt.txt" + import base64 + import json + import os + import subprocess + import urllib.request + from pathlib import Path + + repository = 'ContextualWisdomLab/.github' + parent_sha = os.environ['EXPECTED_HEAD'] + token = os.environ['API_TOKEN'] + api_root = f'https://api.github.com/repos/{repository}' + + expected_paths = { + '.github/workflows/materialize-sandboxed-evidence-bounds.yml', + '.github/workflows/materialize-sandboxed-evidence-receipt.yml', + '.github/workflows/sandboxed-evidence-quality-ci.yml', + 'CHANGELOG.md', + 'docs/doctoring/sandboxed-command-log-redaction.md', + 'docs/doctoring/sandboxed-output-resource-bounds.md', + 'docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md', + 'docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md', + 'scripts/ci/bounded_subprocess.py', + 'scripts/ci/redact_sensitive_log.py', + 'scripts/ci/run_opencode_review_model_pool.sh', + 'scripts/ci/sandboxed_verify.py', + 'scripts/ci/sandboxed_web_e2e.py', + 'tests/test_bounded_subprocess.py', + 'tests/test_bounded_subprocess_capture_startup.py', + 'tests/test_bounded_subprocess_contract.py', + 'tests/test_opencode_model_pool_runner.py', + 'tests/test_redact_json_key_boundary.py', + 'tests/test_redact_sensitive_log_contract.py', + 'tests/test_sandboxed_entrypoint_and_cleanup_coverage.py', + 'tests/test_sandboxed_output_redaction.py', + 'tests/test_sandboxed_service_capture_startup.py', + 'tests/test_sandboxed_verify_output_limits.py', + 'tests/test_sandboxed_web_e2e.py', + 'tests/test_sandboxed_web_e2e_branch_contract.py', + 'tests/test_sandboxed_web_e2e_output_limits.py', + } + + def request(method, endpoint, payload=None): + data = None if payload is None else json.dumps(payload).encode('utf-8') + req = urllib.request.Request( + api_root + endpoint, + data=data, + method=method, + headers={ + 'Accept': 'application/vnd.github+json', + 'Authorization': f'Bearer {token}', + 'X-GitHub-Api-Version': '2022-11-28', + 'User-Agent': 'cwl-pr788-materializer', + }, + ) + with urllib.request.urlopen(req, timeout=60) as response: + return json.load(response) + + raw = subprocess.check_output( + ['git', 'diff', '--name-status', '-z', 'HEAD'], + ) + parts = raw.decode('utf-8').split('\0') + changes = [] + index = 0 + while index < len(parts) - 1: + status = parts[index] + path = parts[index + 1] + index += 2 + if status.startswith(('R', 'C')): + raise SystemExit(f'rename/copy status is outside the reviewed scope: {status} {path}') + changes.append((status, path)) + actual_paths = {path for _, path in changes} + if actual_paths != expected_paths: + raise SystemExit( + f'product path mismatch: missing={sorted(expected_paths - actual_paths)} ' + f'extra={sorted(actual_paths - expected_paths)}' + ) + + parent = request('GET', f'/git/commits/{parent_sha}') + tree_entries = [] + for status, path in changes: + if status == 'D': + tree_entries.append({'path': path, 'mode': '100644', 'type': 'blob', 'sha': None}) + continue + encoded = base64.b64encode(Path(path).read_bytes()).decode('ascii') + blob = request('POST', '/git/blobs', {'content': encoded, 'encoding': 'base64'}) + mode = '100755' if os.access(path, os.X_OK) else '100644' + tree_entries.append({'path': path, 'mode': mode, 'type': 'blob', 'sha': blob['sha']}) + print(f"BLOB {blob['sha']} {path}") + + tree = request( + 'POST', + '/git/trees', + {'base_tree': parent['tree']['sha'], 'tree': tree_entries}, + ) + commit = request( + 'POST', + '/git/commits', + { + 'message': 'fix(ci): secure and bound sandbox evidence streams', + 'tree': tree['sha'], + 'parents': [parent_sha], + }, + ) + print(f"MATERIALIZATION_PARENT_SHA={parent_sha}") + print(f"MATERIALIZATION_PARENT_TREE_SHA={parent['tree']['sha']}") + print(f"MATERIALIZATION_TREE_SHA={tree['sha']}") + print(f"MATERIALIZATION_COMMIT_SHA={commit['sha']}") + PY + + - name: Upload exact-head materialization receipt + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v6.0.0 + with: + name: pr788-exact-head-materialization + path: ${{ runner.temp }}/pr788-materialization-receipt.txt + if-no-files-found: error + retention-days: 5 From 3da504e71d7d35d553fe0db0f550ab9ffc9b6c49 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 6 Aug 2026 14:01:09 +0900 Subject: [PATCH 5/9] fix(ci): align sandbox compatibility contracts --- ...materialize-sandboxed-evidence-receipt.yml | 115 +++++++++++++++--- 1 file changed, 100 insertions(+), 15 deletions(-) diff --git a/.github/workflows/materialize-sandboxed-evidence-receipt.yml b/.github/workflows/materialize-sandboxed-evidence-receipt.yml index 6e0ab62d0..9b4e9d611 100644 --- a/.github/workflows/materialize-sandboxed-evidence-receipt.yml +++ b/.github/workflows/materialize-sandboxed-evidence-receipt.yml @@ -94,6 +94,77 @@ jobs: tests/test_sandboxed_web_e2e_branch_contract.py \ tests/test_sandboxed_web_e2e_output_limits.py + python3 - <<'PY' + from pathlib import Path + + path = Path('tests/test_repository_branch_coverage_execution_sandboxes.py') + source = path.read_text(encoding='utf-8') + replacements = ( + ( + ''' def timeout_runner( + command: list[str], _cwd: Path, _env: dict[str, str], timeout: int + ) -> subprocess.CompletedProcess[str]: + raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) +''', + ''' def timeout_runner( + command: list[str], + _cwd: Path, + _env: dict[str, str], + timeout: int, + output_limit_bytes: int, + ) -> subprocess.CompletedProcess[str]: + assert output_limit_bytes == 1_048_576 + raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) +''', + ), + ( + ''' def start_service( + label: str, + command: str, + _cwd: Path, + _env: dict[str, str], + logs_dir: Path, + ) -> sandboxed_web_e2e.Service: + log_path = logs_dir / f"{label}.log" +''', + ''' def start_service( + label: str, + command: str, + _cwd: Path, + _env: dict[str, str], + logs_dir: Path, + log_limit_bytes: int, + ) -> sandboxed_web_e2e.Service: + assert log_limit_bytes == 4_194_304 + log_path = logs_dir / f"{label}.log" +''', + ), + ( + ''' def timeout_runner( + command: str, _cwd: Path, _env: dict[str, str], timeout: int + ) -> subprocess.CompletedProcess[str]: + raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) +''', + ''' def timeout_runner( + command: str, + _cwd: Path, + _env: dict[str, str], + timeout: int, + output_limit_bytes: int, + ) -> subprocess.CompletedProcess[str]: + assert output_limit_bytes == 1_048_576 + raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) +''', + ), + ) + for old, new in replacements: + count = source.count(old) + if count != 1: + raise SystemExit(f'expected one legacy sandbox helper signature, found {count}') + source = source.replace(old, new, 1) + path.write_text(source, encoding='utf-8') + PY + cat >.github/workflows/sandboxed-evidence-quality-ci.yml <<'YAML' name: Sandboxed Evidence Quality CI @@ -110,6 +181,7 @@ jobs: - "tests/test_bounded_subprocess*.py" - "tests/test_opencode_model_pool_runner.py" - "tests/test_redact*.py" + - "tests/test_repository_branch_coverage_execution_sandboxes.py" - "tests/test_sandboxed*.py" - "requirements-opencode-review-ci-hashes.txt" push: @@ -124,11 +196,12 @@ jobs: - "tests/test_bounded_subprocess*.py" - "tests/test_opencode_model_pool_runner.py" - "tests/test_redact*.py" + - "tests/test_repository_branch_coverage_execution_sandboxes.py" - "tests/test_sandboxed*.py" - "requirements-opencode-review-ci-hashes.txt" concurrency: - group: sandboxed-evidence-quality-${{ github.event.pull_request.number || github.ref }} + group: sandboxed-evidence-quality-__PR_OR_REF__ cancel-in-progress: true permissions: @@ -149,7 +222,7 @@ jobs: - name: Checkout exact head uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: ${{ github.event.pull_request.head.sha || github.sha }} + ref: __HEAD_OR_SHA__ persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 @@ -176,21 +249,34 @@ jobs: python3 - <<'PY' from pathlib import Path - changelog = Path("CHANGELOG.md") - source = changelog.read_text(encoding="utf-8") + quality_path = Path('.github/workflows/sandboxed-evidence-quality-ci.yml') + quality = quality_path.read_text(encoding='utf-8') + quality = quality.replace( + '__PR_OR_REF__', + '$' + '{{ github.event.pull_request.number || github.ref }}', + ).replace( + '__HEAD_OR_SHA__', + '$' + '{{ github.event.pull_request.head.sha || github.sha }}', + ) + if '__PR_OR_REF__' in quality or '__HEAD_OR_SHA__' in quality: + raise SystemExit('permanent workflow expression placeholders remain') + quality_path.write_text(quality, encoding='utf-8') + + changelog = Path('CHANGELOG.md') + source = changelog.read_text(encoding='utf-8') entries = ( - "- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n", - "- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n", - "- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n", + '- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n', + '- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n', + '- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n', ) - marker = "## [Unreleased]\n" + marker = '## [Unreleased]\n' if marker not in source: - raise SystemExit("CHANGELOG is missing the Unreleased section") - missing = "".join(entry for entry in entries if entry not in source) + raise SystemExit('CHANGELOG is missing the Unreleased section') + missing = ''.join(entry for entry in entries if entry not in source) if missing: changelog.write_text( - source.replace(marker, marker + "\n" + missing, 1), - encoding="utf-8", + source.replace(marker, marker + '\n' + missing, 1), + encoding='utf-8', ) PY rm \ @@ -257,6 +343,7 @@ jobs: 'tests/test_opencode_model_pool_runner.py', 'tests/test_redact_json_key_boundary.py', 'tests/test_redact_sensitive_log_contract.py', + 'tests/test_repository_branch_coverage_execution_sandboxes.py', 'tests/test_sandboxed_entrypoint_and_cleanup_coverage.py', 'tests/test_sandboxed_output_redaction.py', 'tests/test_sandboxed_service_capture_startup.py', @@ -282,9 +369,7 @@ jobs: with urllib.request.urlopen(req, timeout=60) as response: return json.load(response) - raw = subprocess.check_output( - ['git', 'diff', '--name-status', '-z', 'HEAD'], - ) + raw = subprocess.check_output(['git', 'diff', '--name-status', '-z', 'HEAD']) parts = raw.decode('utf-8').split('\0') changes = [] index = 0 From e33899990679869d28b6a0b2fec6ac677d519f1a Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 6 Aug 2026 14:10:43 +0900 Subject: [PATCH 6/9] fix(ci): execute reviewed PR 788 receipt on push --- .../materialize-sandboxed-evidence-bounds.yml | 226 ++++-------------- 1 file changed, 53 insertions(+), 173 deletions(-) diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml index 3f3356625..3f3b57aa3 100644 --- a/.github/workflows/materialize-sandboxed-evidence-bounds.yml +++ b/.github/workflows/materialize-sandboxed-evidence-bounds.yml @@ -11,26 +11,29 @@ on: permissions: contents: read +concurrency: + group: materialize-sandboxed-evidence-bounds + cancel-in-progress: false + env: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true jobs: materialize: if: >- - github.repository == 'ContextualWisdomLab/.github' - && github.actor == 'seonghobae' - && github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' - runs-on: ubuntu-24.04 - timeout-minutes: 60 + github.repository == 'ContextualWisdomLab/.github' && + github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' permissions: contents: write + runs-on: ubuntu-24.04 + timeout-minutes: 60 steps: - name: Harden runner uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 with: egress-policy: audit - - name: Checkout exact current-main branch + - name: Checkout exact trigger without persisted credentials uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.sha }} @@ -44,177 +47,54 @@ jobs: cache: pip cache-dependency-path: requirements-opencode-review-ci-hashes.txt - - name: Import immutable focused source + - name: Extract the reviewed receipt steps as inert shell scripts env: - SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 - EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae + RECEIPT_WORKFLOW: .github/workflows/materialize-sandboxed-evidence-receipt.yml shell: bash --noprofile --norc -e -o pipefail {0} run: | - test "$(git rev-parse HEAD)" = "$GITHUB_SHA" - git cat-file -e "${EXPECTED_MAIN}^{commit}" - test "$(git merge-base "$GITHUB_SHA" "$EXPECTED_MAIN")" = "$EXPECTED_MAIN" - if ! git cat-file -e "${SOURCE_SHA}^{commit}" 2>/dev/null; then - git fetch --no-tags --depth=1 origin refs/pull/767/head - fi - test "$(git rev-parse "${SOURCE_SHA}^{commit}")" = "$SOURCE_SHA" - git checkout "$SOURCE_SHA" -- \ - docs/doctoring/sandboxed-command-log-redaction.md \ - docs/doctoring/sandboxed-output-resource-bounds.md \ - docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md \ - docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md \ - scripts/ci/bounded_subprocess.py \ - scripts/ci/redact_sensitive_log.py \ - scripts/ci/run_opencode_review_model_pool.sh \ - scripts/ci/sandboxed_verify.py \ - scripts/ci/sandboxed_web_e2e.py \ - tests/test_bounded_subprocess.py \ - tests/test_bounded_subprocess_capture_startup.py \ - tests/test_bounded_subprocess_contract.py \ - tests/test_opencode_model_pool_runner.py \ - tests/test_redact_json_key_boundary.py \ - tests/test_redact_sensitive_log_contract.py \ - tests/test_sandboxed_entrypoint_and_cleanup_coverage.py \ - tests/test_sandboxed_output_redaction.py \ - tests/test_sandboxed_service_capture_startup.py \ - tests/test_sandboxed_verify_output_limits.py \ - tests/test_sandboxed_web_e2e.py \ - tests/test_sandboxed_web_e2e_branch_contract.py \ - tests/test_sandboxed_web_e2e_output_limits.py - - cat >.github/workflows/sandboxed-evidence-quality-ci.yml <<'YAML' - name: Sandboxed Evidence Quality CI - - on: - pull_request: - branches: [main] - paths: - - ".github/workflows/sandboxed-evidence-quality-ci.yml" - - "scripts/ci/bounded_subprocess.py" - - "scripts/ci/redact_sensitive_log.py" - - "scripts/ci/run_opencode_review_model_pool.sh" - - "scripts/ci/sandboxed_verify.py" - - "scripts/ci/sandboxed_web_e2e.py" - - "tests/test_bounded_subprocess*.py" - - "tests/test_opencode_model_pool_runner.py" - - "tests/test_redact*.py" - - "tests/test_sandboxed*.py" - - "requirements-opencode-review-ci-hashes.txt" - push: - branches: [main] - paths: - - ".github/workflows/sandboxed-evidence-quality-ci.yml" - - "scripts/ci/bounded_subprocess.py" - - "scripts/ci/redact_sensitive_log.py" - - "scripts/ci/run_opencode_review_model_pool.sh" - - "scripts/ci/sandboxed_verify.py" - - "scripts/ci/sandboxed_web_e2e.py" - - "tests/test_bounded_subprocess*.py" - - "tests/test_opencode_model_pool_runner.py" - - "tests/test_redact*.py" - - "tests/test_sandboxed*.py" - - "requirements-opencode-review-ci-hashes.txt" - - concurrency: - group: sandboxed-evidence-quality-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - - permissions: - contents: read - - env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true - - jobs: - quality: - runs-on: ubuntu-24.04 - timeout-minutes: 40 - steps: - - name: Harden runner - uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 - with: - egress-policy: audit - - name: Checkout exact head - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: ${{ github.event.pull_request.head.sha || github.sha }} - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: "3.14" - cache: pip - cache-dependency-path: requirements-opencode-review-ci-hashes.txt - - name: Install exact hash-locked tooling - run: >- - python -m pip install --disable-pip-version-check --require-hashes - -r requirements-opencode-review-ci-hashes.txt - - name: Run complete integrated quality contract - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - python -m coverage erase - python -m coverage run --branch -m pytest -q - python -m coverage report --show-missing --fail-under=100 - python -m interrogate --fail-under=100 scripts/ci - python -m compileall -q scripts tests - bash -n scripts/ci/run_opencode_review_model_pool.sh - git diff --check - YAML - - python3 - <<'PY' - from pathlib import Path - - changelog = Path("CHANGELOG.md") - source = changelog.read_text(encoding="utf-8") - entries = ( - "- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n", - "- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n", - "- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n", - ) - marker = "## [Unreleased]\n" - if marker not in source: - raise SystemExit("CHANGELOG is missing the Unreleased section") - missing = "".join(entry for entry in entries if entry not in source) - if missing: - changelog.write_text( - source.replace(marker, marker + "\n" + missing, 1), - encoding="utf-8", - ) - PY - rm .github/workflows/materialize-sandboxed-evidence-bounds.yml - git diff --check - - - name: Install exact hash-locked tooling - run: >- - python -m pip install --disable-pip-version-check --require-hashes - -r requirements-opencode-review-ci-hashes.txt - - - name: Verify complete integrated quality contract - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - python -m coverage erase - python -m coverage run --branch -m pytest -q - python -m coverage report --show-missing --fail-under=100 - python -m interrogate --fail-under=100 scripts/ci - python -m compileall -q scripts tests - bash -n scripts/ci/run_opencode_review_model_pool.sh - git diff --check - - - name: Publish focused implementation and remove materializer + ruby -ryaml -e ' + document = YAML.safe_load(File.read(ENV.fetch("RECEIPT_WORKFLOW")), aliases: false) + steps = document.fetch("jobs").fetch("materialize").fetch("steps") + targets = { + "Verify bounded setup and import immutable focused source" => "import.sh", + "Install exact hash-locked tooling" => "install.sh", + "Verify complete integrated quality contract" => "verify.sh", + "Build immutable verified Git commit object" => "build.sh", + } + targets.each do |name, filename| + matches = steps.select { |step| step["name"] == name } + abort("expected one receipt step named #{name.inspect}, found #{matches.length}") unless matches.length == 1 + run = matches.first.fetch("run") + File.write(File.join(ENV.fetch("RUNNER_TEMP"), filename), run) + end + ' + chmod 0700 \ + "${RUNNER_TEMP}/import.sh" \ + "${RUNNER_TEMP}/install.sh" \ + "${RUNNER_TEMP}/verify.sh" \ + "${RUNNER_TEMP}/build.sh" + + - name: Import, repair, and verify the complete exact-head product tree env: + SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 + EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae EXPECTED_HEAD: ${{ github.sha }} - HEAD_BRANCH: ${{ github.ref_name }} - PUSH_TOKEN: ${{ github.token }} + SOURCE_BRANCH: fix/sandboxed-evidence-bounds-main + API_TOKEN: ${{ github.token }} shell: bash --noprofile --norc -e -o pipefail {0} run: | - remote_head="$(git ls-remote origin "refs/heads/${HEAD_BRANCH}" | cut -f1)" - test "$remote_head" = "$EXPECTED_HEAD" - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add --all - git diff --cached --quiet && { echo "No focused implementation generated" >&2; exit 1; } - git commit -m "fix(ci): secure and bound sandbox evidence streams" - auth_header="$(printf 'x-access-token:%s' "$PUSH_TOKEN" | base64 | tr -d '\n')" - echo "::add-mask::$auth_header" - git -c http.extraheader="AUTHORIZATION: basic ${auth_header}" \ - push --force-with-lease="refs/heads/${HEAD_BRANCH}:${EXPECTED_HEAD}" \ - origin "HEAD:refs/heads/${HEAD_BRANCH}" + test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" + bash "${RUNNER_TEMP}/import.sh" + bash "${RUNNER_TEMP}/install.sh" + bash "${RUNNER_TEMP}/verify.sh" + bash "${RUNNER_TEMP}/build.sh" | tee "${RUNNER_TEMP}/pr788-materialization-receipt.txt" + grep -E '^MATERIALIZATION_COMMIT_SHA=[0-9a-f]{40}$' \ + "${RUNNER_TEMP}/pr788-materialization-receipt.txt" + + - name: Upload exact-head materialization receipt + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v6.0.0 + with: + name: pr788-exact-head-materialization + path: ${{ runner.temp }}/pr788-materialization-receipt.txt + if-no-files-found: error + retention-days: 5 From 89426081514565963f969f91475545b4afef802e Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Thu, 6 Aug 2026 14:16:48 +0900 Subject: [PATCH 7/9] chore(ci): publish PR 788 materialization pointer --- .../materialize-sandboxed-evidence-bounds.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml index 3f3b57aa3..9b90daa42 100644 --- a/.github/workflows/materialize-sandboxed-evidence-bounds.yml +++ b/.github/workflows/materialize-sandboxed-evidence-bounds.yml @@ -25,6 +25,8 @@ jobs: github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' permissions: contents: write + issues: write + pull-requests: write runs-on: ubuntu-24.04 timeout-minutes: 60 steps: @@ -91,6 +93,21 @@ jobs: grep -E '^MATERIALIZATION_COMMIT_SHA=[0-9a-f]{40}$' \ "${RUNNER_TEMP}/pr788-materialization-receipt.txt" + - name: Publish exact-head materialization pointer + env: + GH_TOKEN: ${{ github.token }} + EXPECTED_HEAD: ${{ github.sha }} + shell: bash --noprofile --norc -e -o pipefail {0} + run: | + commit_sha="$(sed -n 's/^MATERIALIZATION_COMMIT_SHA=//p' "${RUNNER_TEMP}/pr788-materialization-receipt.txt")" + test "${#commit_sha}" -eq 40 + case "$commit_sha" in (*[!0-9a-f]*) exit 1;; esac + body="PR788_MATERIALIZATION_PARENT_SHA=${EXPECTED_HEAD}%0APR788_MATERIALIZATION_COMMIT_SHA=${commit_sha}" + gh api \ + --method POST \ + repos/ContextualWisdomLab/.github/issues/788/comments \ + -f "body=${body}" + - name: Upload exact-head materialization receipt uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v6.0.0 with: From fa91574ea1e2f371ac583a45ac58712322cec708 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Fri, 7 Aug 2026 09:55:38 +0900 Subject: [PATCH 8/9] chore(ci): remove sandbox evidence materializer --- .../materialize-sandboxed-evidence-bounds.yml | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 .github/workflows/materialize-sandboxed-evidence-bounds.yml diff --git a/.github/workflows/materialize-sandboxed-evidence-bounds.yml b/.github/workflows/materialize-sandboxed-evidence-bounds.yml deleted file mode 100644 index 9b90daa42..000000000 --- a/.github/workflows/materialize-sandboxed-evidence-bounds.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: Materialize focused sandbox evidence bounds -run-name: Materialize sandbox evidence bounds at ${{ github.sha }} - -on: - push: - branches: - - fix/sandboxed-evidence-bounds-main - paths: - - .github/workflows/materialize-sandboxed-evidence-bounds.yml - -permissions: - contents: read - -concurrency: - group: materialize-sandboxed-evidence-bounds - cancel-in-progress: false - -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true - -jobs: - materialize: - if: >- - github.repository == 'ContextualWisdomLab/.github' && - github.ref == 'refs/heads/fix/sandboxed-evidence-bounds-main' - permissions: - contents: write - issues: write - pull-requests: write - runs-on: ubuntu-24.04 - timeout-minutes: 60 - steps: - - name: Harden runner - uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 - with: - egress-policy: audit - - - name: Checkout exact trigger without persisted credentials - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: ${{ github.sha }} - fetch-depth: 0 - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: "3.14" - cache: pip - cache-dependency-path: requirements-opencode-review-ci-hashes.txt - - - name: Extract the reviewed receipt steps as inert shell scripts - env: - RECEIPT_WORKFLOW: .github/workflows/materialize-sandboxed-evidence-receipt.yml - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - ruby -ryaml -e ' - document = YAML.safe_load(File.read(ENV.fetch("RECEIPT_WORKFLOW")), aliases: false) - steps = document.fetch("jobs").fetch("materialize").fetch("steps") - targets = { - "Verify bounded setup and import immutable focused source" => "import.sh", - "Install exact hash-locked tooling" => "install.sh", - "Verify complete integrated quality contract" => "verify.sh", - "Build immutable verified Git commit object" => "build.sh", - } - targets.each do |name, filename| - matches = steps.select { |step| step["name"] == name } - abort("expected one receipt step named #{name.inspect}, found #{matches.length}") unless matches.length == 1 - run = matches.first.fetch("run") - File.write(File.join(ENV.fetch("RUNNER_TEMP"), filename), run) - end - ' - chmod 0700 \ - "${RUNNER_TEMP}/import.sh" \ - "${RUNNER_TEMP}/install.sh" \ - "${RUNNER_TEMP}/verify.sh" \ - "${RUNNER_TEMP}/build.sh" - - - name: Import, repair, and verify the complete exact-head product tree - env: - SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 - EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae - EXPECTED_HEAD: ${{ github.sha }} - SOURCE_BRANCH: fix/sandboxed-evidence-bounds-main - API_TOKEN: ${{ github.token }} - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" - bash "${RUNNER_TEMP}/import.sh" - bash "${RUNNER_TEMP}/install.sh" - bash "${RUNNER_TEMP}/verify.sh" - bash "${RUNNER_TEMP}/build.sh" | tee "${RUNNER_TEMP}/pr788-materialization-receipt.txt" - grep -E '^MATERIALIZATION_COMMIT_SHA=[0-9a-f]{40}$' \ - "${RUNNER_TEMP}/pr788-materialization-receipt.txt" - - - name: Publish exact-head materialization pointer - env: - GH_TOKEN: ${{ github.token }} - EXPECTED_HEAD: ${{ github.sha }} - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - commit_sha="$(sed -n 's/^MATERIALIZATION_COMMIT_SHA=//p' "${RUNNER_TEMP}/pr788-materialization-receipt.txt")" - test "${#commit_sha}" -eq 40 - case "$commit_sha" in (*[!0-9a-f]*) exit 1;; esac - body="PR788_MATERIALIZATION_PARENT_SHA=${EXPECTED_HEAD}%0APR788_MATERIALIZATION_COMMIT_SHA=${commit_sha}" - gh api \ - --method POST \ - repos/ContextualWisdomLab/.github/issues/788/comments \ - -f "body=${body}" - - - name: Upload exact-head materialization receipt - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v6.0.0 - with: - name: pr788-exact-head-materialization - path: ${{ runner.temp }}/pr788-materialization-receipt.txt - if-no-files-found: error - retention-days: 5 From 9a448761dad89e978d361906217afa58cde8c61b Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Fri, 7 Aug 2026 09:56:00 +0900 Subject: [PATCH 9/9] chore(ci): remove sandbox evidence receipt materializer --- ...materialize-sandboxed-evidence-receipt.yml | 428 ------------------ 1 file changed, 428 deletions(-) delete mode 100644 .github/workflows/materialize-sandboxed-evidence-receipt.yml diff --git a/.github/workflows/materialize-sandboxed-evidence-receipt.yml b/.github/workflows/materialize-sandboxed-evidence-receipt.yml deleted file mode 100644 index 9b4e9d611..000000000 --- a/.github/workflows/materialize-sandboxed-evidence-receipt.yml +++ /dev/null @@ -1,428 +0,0 @@ -name: Materialize verified sandbox evidence commit - -on: - pull_request: - branches: - - main - types: - - synchronize - -permissions: - contents: read - -concurrency: - group: materialize-sandboxed-evidence-receipt - cancel-in-progress: false - -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true - -jobs: - materialize: - if: >- - github.repository == 'ContextualWisdomLab/.github' && - github.event.pull_request.number == 788 && - github.event.pull_request.head.ref == 'fix/sandboxed-evidence-bounds-main' - permissions: - contents: write - runs-on: ubuntu-24.04 - timeout-minutes: 60 - steps: - - name: Harden runner - uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 - with: - egress-policy: audit - - - name: Checkout exact current-main branch - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: "3.14" - cache: pip - cache-dependency-path: requirements-opencode-review-ci-hashes.txt - - - name: Verify bounded setup and import immutable focused source - env: - SOURCE_SHA: 45e4929e1fc473211168b2d6360c9da2516e5341 - EXPECTED_MAIN: f070c504c1cb06891b800d7ab0cf6ac7d3cf8eae - EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }} - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" - git cat-file -e "${EXPECTED_MAIN}^{commit}" - test "$(git merge-base "$EXPECTED_HEAD" "$EXPECTED_MAIN")" = "$EXPECTED_MAIN" - mapfile -t setup_paths < <(git diff --name-only "$EXPECTED_MAIN" "$EXPECTED_HEAD" | sort) - expected_setup_paths=( - ".github/workflows/materialize-sandboxed-evidence-bounds.yml" - ".github/workflows/materialize-sandboxed-evidence-receipt.yml" - ) - test "${#setup_paths[@]}" -eq "${#expected_setup_paths[@]}" - for index in "${!expected_setup_paths[@]}"; do - test "${setup_paths[$index]}" = "${expected_setup_paths[$index]}" - done - if ! git cat-file -e "${SOURCE_SHA}^{commit}" 2>/dev/null; then - git fetch --no-tags --depth=1 origin refs/pull/767/head - fi - test "$(git rev-parse "${SOURCE_SHA}^{commit}")" = "$SOURCE_SHA" - git checkout "$SOURCE_SHA" -- \ - docs/doctoring/sandboxed-command-log-redaction.md \ - docs/doctoring/sandboxed-output-resource-bounds.md \ - docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md \ - docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md \ - scripts/ci/bounded_subprocess.py \ - scripts/ci/redact_sensitive_log.py \ - scripts/ci/run_opencode_review_model_pool.sh \ - scripts/ci/sandboxed_verify.py \ - scripts/ci/sandboxed_web_e2e.py \ - tests/test_bounded_subprocess.py \ - tests/test_bounded_subprocess_capture_startup.py \ - tests/test_bounded_subprocess_contract.py \ - tests/test_opencode_model_pool_runner.py \ - tests/test_redact_json_key_boundary.py \ - tests/test_redact_sensitive_log_contract.py \ - tests/test_sandboxed_entrypoint_and_cleanup_coverage.py \ - tests/test_sandboxed_output_redaction.py \ - tests/test_sandboxed_service_capture_startup.py \ - tests/test_sandboxed_verify_output_limits.py \ - tests/test_sandboxed_web_e2e.py \ - tests/test_sandboxed_web_e2e_branch_contract.py \ - tests/test_sandboxed_web_e2e_output_limits.py - - python3 - <<'PY' - from pathlib import Path - - path = Path('tests/test_repository_branch_coverage_execution_sandboxes.py') - source = path.read_text(encoding='utf-8') - replacements = ( - ( - ''' def timeout_runner( - command: list[str], _cwd: Path, _env: dict[str, str], timeout: int - ) -> subprocess.CompletedProcess[str]: - raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) -''', - ''' def timeout_runner( - command: list[str], - _cwd: Path, - _env: dict[str, str], - timeout: int, - output_limit_bytes: int, - ) -> subprocess.CompletedProcess[str]: - assert output_limit_bytes == 1_048_576 - raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) -''', - ), - ( - ''' def start_service( - label: str, - command: str, - _cwd: Path, - _env: dict[str, str], - logs_dir: Path, - ) -> sandboxed_web_e2e.Service: - log_path = logs_dir / f"{label}.log" -''', - ''' def start_service( - label: str, - command: str, - _cwd: Path, - _env: dict[str, str], - logs_dir: Path, - log_limit_bytes: int, - ) -> sandboxed_web_e2e.Service: - assert log_limit_bytes == 4_194_304 - log_path = logs_dir / f"{label}.log" -''', - ), - ( - ''' def timeout_runner( - command: str, _cwd: Path, _env: dict[str, str], timeout: int - ) -> subprocess.CompletedProcess[str]: - raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) -''', - ''' def timeout_runner( - command: str, - _cwd: Path, - _env: dict[str, str], - timeout: int, - output_limit_bytes: int, - ) -> subprocess.CompletedProcess[str]: - assert output_limit_bytes == 1_048_576 - raise subprocess.TimeoutExpired(command, timeout, output=None, stderr=None) -''', - ), - ) - for old, new in replacements: - count = source.count(old) - if count != 1: - raise SystemExit(f'expected one legacy sandbox helper signature, found {count}') - source = source.replace(old, new, 1) - path.write_text(source, encoding='utf-8') - PY - - cat >.github/workflows/sandboxed-evidence-quality-ci.yml <<'YAML' - name: Sandboxed Evidence Quality CI - - on: - pull_request: - branches: [main] - paths: - - ".github/workflows/sandboxed-evidence-quality-ci.yml" - - "scripts/ci/bounded_subprocess.py" - - "scripts/ci/redact_sensitive_log.py" - - "scripts/ci/run_opencode_review_model_pool.sh" - - "scripts/ci/sandboxed_verify.py" - - "scripts/ci/sandboxed_web_e2e.py" - - "tests/test_bounded_subprocess*.py" - - "tests/test_opencode_model_pool_runner.py" - - "tests/test_redact*.py" - - "tests/test_repository_branch_coverage_execution_sandboxes.py" - - "tests/test_sandboxed*.py" - - "requirements-opencode-review-ci-hashes.txt" - push: - branches: [main] - paths: - - ".github/workflows/sandboxed-evidence-quality-ci.yml" - - "scripts/ci/bounded_subprocess.py" - - "scripts/ci/redact_sensitive_log.py" - - "scripts/ci/run_opencode_review_model_pool.sh" - - "scripts/ci/sandboxed_verify.py" - - "scripts/ci/sandboxed_web_e2e.py" - - "tests/test_bounded_subprocess*.py" - - "tests/test_opencode_model_pool_runner.py" - - "tests/test_redact*.py" - - "tests/test_repository_branch_coverage_execution_sandboxes.py" - - "tests/test_sandboxed*.py" - - "requirements-opencode-review-ci-hashes.txt" - - concurrency: - group: sandboxed-evidence-quality-__PR_OR_REF__ - cancel-in-progress: true - - permissions: - contents: read - - env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true - - jobs: - quality: - runs-on: ubuntu-24.04 - timeout-minutes: 40 - steps: - - name: Harden runner - uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 - with: - egress-policy: audit - - name: Checkout exact head - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: __HEAD_OR_SHA__ - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: "3.14" - cache: pip - cache-dependency-path: requirements-opencode-review-ci-hashes.txt - - name: Install exact hash-locked tooling - run: >- - python -m pip install --disable-pip-version-check --require-hashes - -r requirements-opencode-review-ci-hashes.txt - - name: Run complete integrated quality contract - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - python -m coverage erase - python -m coverage run --branch -m pytest -q - python -m coverage report --show-missing --fail-under=100 - python -m interrogate --fail-under=100 scripts/ci - python -m compileall -q scripts tests - bash -n scripts/ci/run_opencode_review_model_pool.sh - git diff --check - YAML - - python3 - <<'PY' - from pathlib import Path - - quality_path = Path('.github/workflows/sandboxed-evidence-quality-ci.yml') - quality = quality_path.read_text(encoding='utf-8') - quality = quality.replace( - '__PR_OR_REF__', - '$' + '{{ github.event.pull_request.number || github.ref }}', - ).replace( - '__HEAD_OR_SHA__', - '$' + '{{ github.event.pull_request.head.sha || github.sha }}', - ) - if '__PR_OR_REF__' in quality or '__HEAD_OR_SHA__' in quality: - raise SystemExit('permanent workflow expression placeholders remain') - quality_path.write_text(quality, encoding='utf-8') - - changelog = Path('CHANGELOG.md') - source = changelog.read_text(encoding='utf-8') - entries = ( - '- Redact credentials from every sandbox command, timeout, service-tail, JSON, and review-evidence sink while preserving ordinary diagnostics.\n', - '- Bound command and long-running service output, terminate isolated process groups on overflow, and emit deterministic resource-limit evidence without capping unrelated repository artifacts.\n', - '- Add a permanent exact-head quality workflow enforcing 100% production statement, branch, and docstring coverage for sandbox evidence controls.\n', - ) - marker = '## [Unreleased]\n' - if marker not in source: - raise SystemExit('CHANGELOG is missing the Unreleased section') - missing = ''.join(entry for entry in entries if entry not in source) - if missing: - changelog.write_text( - source.replace(marker, marker + '\n' + missing, 1), - encoding='utf-8', - ) - PY - rm \ - .github/workflows/materialize-sandboxed-evidence-bounds.yml \ - .github/workflows/materialize-sandboxed-evidence-receipt.yml - git diff --check - - - name: Install exact hash-locked tooling - run: >- - python -m pip install --disable-pip-version-check --require-hashes - -r requirements-opencode-review-ci-hashes.txt - - - name: Verify complete integrated quality contract - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - python -m coverage erase - python -m coverage run --branch -m pytest -q - python -m coverage report --show-missing --fail-under=100 - python -m interrogate --fail-under=100 scripts/ci - python -m compileall -q scripts tests - bash -n scripts/ci/run_opencode_review_model_pool.sh - git diff --check - - - name: Build immutable verified Git commit object - env: - API_TOKEN: ${{ github.token }} - EXPECTED_HEAD: ${{ github.event.pull_request.head.sha }} - SOURCE_BRANCH: fix/sandboxed-evidence-bounds-main - shell: bash --noprofile --norc -e -o pipefail {0} - run: | - test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD" - remote_head="$(git ls-remote origin "refs/heads/${SOURCE_BRANCH}" | cut -f1)" - test "$remote_head" = "$EXPECTED_HEAD" - python3 - <<'PY' | tee "${RUNNER_TEMP}/pr788-materialization-receipt.txt" - import base64 - import json - import os - import subprocess - import urllib.request - from pathlib import Path - - repository = 'ContextualWisdomLab/.github' - parent_sha = os.environ['EXPECTED_HEAD'] - token = os.environ['API_TOKEN'] - api_root = f'https://api.github.com/repos/{repository}' - - expected_paths = { - '.github/workflows/materialize-sandboxed-evidence-bounds.yml', - '.github/workflows/materialize-sandboxed-evidence-receipt.yml', - '.github/workflows/sandboxed-evidence-quality-ci.yml', - 'CHANGELOG.md', - 'docs/doctoring/sandboxed-command-log-redaction.md', - 'docs/doctoring/sandboxed-output-resource-bounds.md', - 'docs/superpowers/plans/2026-08-05-sandboxed-output-resource-bounds.md', - 'docs/superpowers/specs/2026-08-05-sandboxed-output-resource-bounds-design.md', - 'scripts/ci/bounded_subprocess.py', - 'scripts/ci/redact_sensitive_log.py', - 'scripts/ci/run_opencode_review_model_pool.sh', - 'scripts/ci/sandboxed_verify.py', - 'scripts/ci/sandboxed_web_e2e.py', - 'tests/test_bounded_subprocess.py', - 'tests/test_bounded_subprocess_capture_startup.py', - 'tests/test_bounded_subprocess_contract.py', - 'tests/test_opencode_model_pool_runner.py', - 'tests/test_redact_json_key_boundary.py', - 'tests/test_redact_sensitive_log_contract.py', - 'tests/test_repository_branch_coverage_execution_sandboxes.py', - 'tests/test_sandboxed_entrypoint_and_cleanup_coverage.py', - 'tests/test_sandboxed_output_redaction.py', - 'tests/test_sandboxed_service_capture_startup.py', - 'tests/test_sandboxed_verify_output_limits.py', - 'tests/test_sandboxed_web_e2e.py', - 'tests/test_sandboxed_web_e2e_branch_contract.py', - 'tests/test_sandboxed_web_e2e_output_limits.py', - } - - def request(method, endpoint, payload=None): - data = None if payload is None else json.dumps(payload).encode('utf-8') - req = urllib.request.Request( - api_root + endpoint, - data=data, - method=method, - headers={ - 'Accept': 'application/vnd.github+json', - 'Authorization': f'Bearer {token}', - 'X-GitHub-Api-Version': '2022-11-28', - 'User-Agent': 'cwl-pr788-materializer', - }, - ) - with urllib.request.urlopen(req, timeout=60) as response: - return json.load(response) - - raw = subprocess.check_output(['git', 'diff', '--name-status', '-z', 'HEAD']) - parts = raw.decode('utf-8').split('\0') - changes = [] - index = 0 - while index < len(parts) - 1: - status = parts[index] - path = parts[index + 1] - index += 2 - if status.startswith(('R', 'C')): - raise SystemExit(f'rename/copy status is outside the reviewed scope: {status} {path}') - changes.append((status, path)) - actual_paths = {path for _, path in changes} - if actual_paths != expected_paths: - raise SystemExit( - f'product path mismatch: missing={sorted(expected_paths - actual_paths)} ' - f'extra={sorted(actual_paths - expected_paths)}' - ) - - parent = request('GET', f'/git/commits/{parent_sha}') - tree_entries = [] - for status, path in changes: - if status == 'D': - tree_entries.append({'path': path, 'mode': '100644', 'type': 'blob', 'sha': None}) - continue - encoded = base64.b64encode(Path(path).read_bytes()).decode('ascii') - blob = request('POST', '/git/blobs', {'content': encoded, 'encoding': 'base64'}) - mode = '100755' if os.access(path, os.X_OK) else '100644' - tree_entries.append({'path': path, 'mode': mode, 'type': 'blob', 'sha': blob['sha']}) - print(f"BLOB {blob['sha']} {path}") - - tree = request( - 'POST', - '/git/trees', - {'base_tree': parent['tree']['sha'], 'tree': tree_entries}, - ) - commit = request( - 'POST', - '/git/commits', - { - 'message': 'fix(ci): secure and bound sandbox evidence streams', - 'tree': tree['sha'], - 'parents': [parent_sha], - }, - ) - print(f"MATERIALIZATION_PARENT_SHA={parent_sha}") - print(f"MATERIALIZATION_PARENT_TREE_SHA={parent['tree']['sha']}") - print(f"MATERIALIZATION_TREE_SHA={tree['sha']}") - print(f"MATERIALIZATION_COMMIT_SHA={commit['sha']}") - PY - - - name: Upload exact-head materialization receipt - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v6.0.0 - with: - name: pr788-exact-head-materialization - path: ${{ runner.temp }}/pr788-materialization-receipt.txt - if-no-files-found: error - retention-days: 5