Skip to content

feat: add LS Build Week stale-approval trust gate - #895

Draft
safal207 wants to merge 11 commits into
mainfrom
build-week-2026
Draft

feat: add LS Build Week stale-approval trust gate#895
safal207 wants to merge 11 commits into
mainfrom
build-week-2026

Conversation

@safal207

@safal207 safal207 commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What changed

Implements LS — Trust Layer for AI Software Delivery for the OpenAI Build Week Developer Tools track.

The focused story is:

AI approval belongs to SHA-A
        ↓
the pull-request head changes to SHA-B
        ↓
a naive pipeline may still accept the old approval
        ↓
LS verifies exact SHA, reviewer provenance, and required evidence
        ↓
the stale decision is blocked

This PR also adds an exact-source-SHA Docker clean-room path so a judge can reproduce the demo without installing project dependencies.

Type of change

  • Build Week feature slice
  • Security / trust-gate behavior
  • Tests and adversarial fixtures
  • Documentation and evidence
  • Docker reproducibility workflow
  • Broad LS redesign
  • Autonomous delivery or merge behavior

Why it matters

AI review signals can be stale, spoofed, or incomplete. LS proves whether a specific decision belongs to the current code state and came through an allowed evidence-bearing route before that decision can influence delivery.

Fastest judge path

Prerequisite: Docker Engine or Docker Desktop.

./scripts/run_build_week_docker.sh

Native alternative:

./scripts/run_build_week_demo.sh

Expected matrix:

stale approval       BLOCKED  STALE_APPROVAL
spoofed reviewer     BLOCKED  UNTRUSTED_REVIEWER
required lane absent BLOCKED  REQUIRED_LANE_NOT_RUN
current-head review  TRUSTED  ALL_REQUIRED_EVIDENCE_VALID

Evidence

Checks

  • 10/10 focused Build Week tests pass
  • 4/4 demo scenarios match the required verdict and reason-code matrix
  • Docker image builds in a clean GitHub-hosted Ubuntu environment
  • Workflow checks out and verifies the exact source SHA before building
  • Docker container runs the demo and all focused tests successfully
  • Security & CI, regression scan, and HTTP E2E checks are green for the core evidence snapshot
  • Exact-head CodeRabbit review found no issues on the reviewed implementation
  • Open unresolved review threads: 0 at evidence capture

Screenshots / video

Public Build Week demo video: pending. The final recording will show the stale-approval attack, the block, the trusted control, and how Codex + GPT-5.6 were used.

Trust boundary

  • The demo evaluates normalized fixture evidence; live GitHub collection is outside this slice.
  • Fixture oracle data cannot authorize a decision and is excluded from the evidence digest.
  • Unknown, malformed, missing, or stale evidence fails closed.
  • TRUSTED does not perform or authorize autonomous delivery; explicit human authorization remains required.
  • DataHub, CockroachDB, AWS, Alibaba Cloud, Qwen, broad redesign, and commercial UI work remain out of scope.

Status

This PR remains draft while the public video, /feedback Session ID, and Devpost submission are completed.

Refs #897

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a deterministic, dependency-free trust gate that validates reviewer identity, review freshness, commit binding, and required CI lanes. It includes four demo fixtures, a trust policy, CLI reports, unit tests, README documentation, and a Build Week submission plan.

Changes

Trust Gate Demo

Layer / File(s) Summary
Trust-gate validation and evaluation
tools/build_week_trust_gate.py
Validates policy and evidence inputs, computes canonical digests, evaluates review and CI checks, produces deterministic reports, and exposes CLI output and exit modes.
Policy and decision scenarios
build-week/policy/trust-policy.json, build-week/demo/*.json
Defines the trusted reviewer and required lanes, with fixtures for stale approval, spoofed reviewer, missing check, and trusted current-head review.
Tests and Build Week submission materials
tests/test_build_week_trust_gate.py, build-week/README.md, BUILD_WEEK_2026_PLAN.md
Tests verdict determinism, evidence binding, reviewer identity, lane states, and report vocabulary while documenting demo execution and submission requirements.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Trust-gate CLI
  participant Policy as Trust policy
  participant Fixture as Demo fixture
  participant Gate as evaluate
  participant Report as Machine or human report
  CLI->>Policy: Load trusted reviewer and required lanes
  CLI->>Fixture: Load review and CI evidence
  CLI->>Gate: Validate and evaluate evidence
  Gate->>Report: Return verdict, reason code, checks, and digests
  Report-->>CLI: Print or write deterministic output
Loading

Possibly related issues

  • safal207/LS#897 — The PR implements the stale-approval trust-gate demo and its exact-head, fail-closed evaluation scenarios.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and clearly names the main change: adding the LS Build Week trust gate for stale approvals.
Description check ✅ Passed The description covers what changed, why it matters, checks, and evidence, so it is mostly complete despite template differences.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch build-week-2026

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

LS multi-model PR review

  • Exact head: 29f5279c7cbc3c1df5d2614654578a4ebbbdd805
  • Base: caaa5ed758c965127834690dfd248e0496780e74
  • Provider: openrouter
  • Status: PARTIAL
  • Aggregate verdict: COMMENT
  • Mode: advisory
  • High-risk route: true
  • Diff truncated: true
  • Files represented in bounded evidence: 16/20
  • Policy would block: true

Model executions

Role Model Status Verdict
architecture_and_governance_reviewer nvidia/nemotron-3-ultra-550b-a55b:free INVALID -
fast_diff_reviewer cohere/north-mini-code:free INVALID -
deep_implementation_reviewer poolside/laguna-xs-2.1:free INVALID -
independent_challenger tencent/hy3:free INVALID -

Confirmed findings

No finding reached independent two-model confirmation.

Candidate findings

No structured candidate finding was produced.

Incomplete lanes

  • diff\_coverage: {'key': 'diff_coverage', 'reason': 'bounded diff was truncated; the review cannot claim complete PR coverage', 'reviewed_files': ['.dockerignore', '.github/workflows/build-week-docker-smoke.yml', 'BUILD_WEEK_2026_PLAN.md', 'Dockerfile.build-week', 'build-week/README.md', 'build-week/demo/required-check-not-run.json', 'build-week/demo/spoofed-reviewer.json', 'build-week/demo/stale-approval.json', 'build-week/demo/trusted-current-head.json', 'build-week/evidence/attack-matrix.md', 'build-week/evidence/codex-contribution-log.md', 'build-week/evidence/docker-smoke.md', 'build-week/evidence/test-results.json', 'build-week/evidence/trust-report.example.json', 'build-week/policy/trust-policy.json', 'scripts/run_build_week_demo.sh'], 'omitted_files': ['scripts/run_build_week_docker.sh', 'tests/test_build_week_demo.py', 'tests/test_build_week_trust_gate.py', 'tools/build_week_trust_gate.py']}

Authority boundary

This output is evidence for human review. It cannot approve or merge the PR, and a single-model finding remains a candidate rather than a gate decision.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please perform a fresh review of exact head dc2407ef9b1dd2fe9183e8c0482226ee94352b27 for the OpenAI Build Week trust-gate slice. Treat any review or approval for an earlier head as stale. Scope: deterministic stale-approval BLOCKED and current-head TRUSTED fixtures, separate trusted reviewer policy, PASS/FAIL/NOT_RUN preservation, fail-closed validation, human-readable and machine-readable verdicts, and reproducible tests.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="safal207/LS"
pr=895

echo "=== PR info ==="
gh pr view "$pr" --repo "$repo" --json title,body,headRefOid,baseRefOid,state,isDraft,files,additions,deletions

echo "=== Commits ==="
gh pr view "$pr" --repo "$repo" --json commits --jq '.commits[] | {oid: .oid, messageHeadline: .messageHeadline}'

echo "=== Files changed ==="
gh pr diff "$pr" --repo "$repo" --name-only

Length of output: 2948


🏁 Script executed:

#!/bin/bash
set -euo pipefail
repo="safal207/LS"
pr=895

echo "=== build-week/README.md ==="
gh pr view "$pr" --repo "$repo" --json headRefOid --jq .headRefOid

git clone --depth 50 --branch $(gh pr view $pr --repo $repo --json headRefName --jq .headRefName) https://github.com/$repo.git repo_clone 2>&1 | tail -5
cd repo_clone
git checkout dc2407ef9b1dd2fe9183e8c0482226ee94352b27
echo "=== files ==="
for f in build-week/README.md build-week/demo/stale-approval.json build-week/demo/trusted-current-head.json build-week/policy/trust-policy.json tests/test_build_week_trust_gate.py tools/build_week_trust_gate.py; do
  echo "----- $f -----"
  cat "$f"
  echo
done

Length of output: 30395


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone
echo "=== root listing ==="
ls -la
echo "=== tools dir ==="
ls -la tools
echo "=== tests dir ==="
ls -la tests
echo "=== check for __init__.py or pytest config ==="
fd -HI '(setup.cfg|pyproject.toml|pytest.ini|conftest.py)$' .
echo "=== grep for build_week reference elsewhere ==="
rg -n "build_week" --glob '!build-week/**' --glob '!tools/**' --glob '!tests/**' .

Length of output: 22399


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone
echo "=== conftest.py ==="
cat conftest.py
echo "=== pyproject.toml relevant sections ==="
sed -n '1,60p' pyproject.toml
echo "=== check tools/__init__.py existence ==="
fd -HI '__init__.py$' tools
echo "=== check other tools test importing tools package similarly ==="
rg -n "^from tools\." tools/test_*.py | head -20

Length of output: 4283


🏁 Script executed:

#!/bin/bash
set -euo pipefail
gh issue view 897 --repo safal207/LS --json title,state,url 2>&1 || echo "issue 897 not found or inaccessible"

Length of output: 404


@safal207 Fresh review completed against exact head dc2407ef9b1dd2fe9183e8c0482226ee94352b27 (PR #895, base caaa5ed7). Any prior review/approval tied to an earlier head should indeed be treated as stale — this PR's own trust gate would flag that scenario as STALE_APPROVAL.

Scope verification — all requested points confirmed:

  1. Deterministic fixturesbuild-week/demo/stale-approval.json (review bound to a×40, current head b×40) → BLOCKED/STALE_APPROVAL; trusted-current-head.json (review and current head both c×40, lanes PASS at same head) → TRUSTED/ALL_REQUIRED_EVIDENCE_VALID. Both match their embedded expected_outcome oracle, and test_stale_approval_is_deterministically_blocked runs evaluate() twice on deep-copied input/policy to assert identical output — genuinely deterministic, no network/IO/randomness in evaluate().
  2. Separate trusted reviewer policybuild-week/policy/trust-policy.json is a standalone file; identity_passed/provenance_passed are computed only from policy trusted_reviewers, never from the fixture. test_fixture_expectation_cannot_self_authorize explicitly proves a fixture can't override the verdict by editing its own expected_outcome.
  3. PASS/FAIL/NOT_RUN preserved distinctlyCHECK_STATUSES = ("PASS", "FAIL", "NOT_RUN") and STATUS_VOCABULARY keep three real states (missing/absent required lane maps to NOT_RUN, not FAIL); test_machine_report_keeps_three_check_states_distinct locks this in.
  4. Fail-closed validation — malformed/incomplete input hits TrustInputError_invalid_report() forces BLOCKED/UNTRUSTED/INVALID_INPUT regardless of what the input claims; missing or NOT_RUN required lanes block via REQUIRED_LANE_NOT_RUN; default CLI exit code is non-zero on BLOCKED.
  5. Human + machine verdictsrender_human() gives a headline/summary/details string; evaluate() returns a fully structured JSON report (schema_version, digests, checks[], decision_input, status_vocabulary). CLI supports --format human|json|both and --report-out.
  6. Reproducible teststests/test_build_week_trust_gate.py is self-contained unittest, loads fixtures/policy from disk, no network; import path works via root conftest.py inserting repo root on sys.path (implicit namespace package, no __init__.py needed under tools/).

Cross-checked build-week/README.md's reference to issue #897 ("Build Week: ship stale-approval trust-gate demo") — it's open and matches this slice's scope.

Two non-blocking nits for a future follow-up:

  • input_digest_sha256 hashes the full fixture including the test-only expected_outcome field, so the digest shifts if the oracle annotation changes even though the actual decision inputs (PR/review/lanes) are unchanged. If you want the digest to represent only real decision evidence, strip expected_outcome before hashing.
  • No fixture currently exercises an inline lane object with "status": "NOT_RUN" (only the "lane missing from the list" path is exercised); the code path in validate_input/evaluate for that shape is untested.

Nice, clean fail-closed design for a first slice — no bugs found that would affect the stale-approval vs. trusted-head demo behavior.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please perform a fresh review of exact head a4236da2120f52f0d35ce27c1bc40fa5b698531c. Treat the clean review for dc2407ef9b1dd2fe9183e8c0482226ee94352b27 as stale for this new head. Focus on the two new adversarial fixtures (spoofed-reviewer, required-check-not-run), explicit inline NOT_RUN preservation, expected verdicts, and exclusion of fixture-only expected_outcome from the decision-evidence digest.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="safal207/LS"
pr=895

echo "=== PR info ==="
gh pr view "$pr" --repo "$repo" --json headRefOid,baseRefOid,state,isDraft

echo "=== Commits ==="
gh pr view "$pr" --repo "$repo" --json commits --jq '.commits[] | {oid: .oid, messageHeadline: .messageHeadline}'

git clone --depth 100 --branch $(gh pr view $pr --repo $repo --json headRefName --jq .headRefName) https://github.com/$repo.git repo_clone 2>&1 | tail -5
cd repo_clone
git checkout a4236da2120f52f0d35ce27c1bc40fa5b698531c

echo "=== files changed since dc2407e ==="
git diff --name-status dc2407ef9b1dd2fe9183e8c0482226ee94352b27..a4236da2120f52f0d35ce27c1bc40fa5b698531c

echo "=== full diff ==="
git diff dc2407ef9b1dd2fe9183e8c0482226ee94352b27..a4236da2120f52f0d35ce27c1bc40fa5b698531c

Length of output: 10930


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone
echo "=== full tools/build_week_trust_gate.py ==="
cat -n tools/build_week_trust_gate.py

echo "=== run tests ==="
python3 -m unittest -v tests/test_build_week_trust_gate.py 2>&1 || true

echo "=== run fixtures manually ==="
for f in build-week/demo/*.json; do
  echo "--- $f ---"
  python3 tools/build_week_trust_gate.py "$f" --verify-expected --format json 2>&1 | tail -20
done

Length of output: 30656


@safal207 Fresh review completed against exact head a4236da2120f52f0d35ce27c1bc40fa5b698531c. The prior clean review at dc2407ef9b1dd2fe9183e8c0482226ee94352b27 is treated as stale for this head, consistent with this PR's own STALE_APPROVAL semantics.

Focus areas — all confirmed:

  1. spoofed-reviewer.json — login coderabbitai[bot] but account_type: "User" (policy requires "Bot") → review.identity = FAIL, review.exact_head = PASS → verdict BLOCKED / UNTRUSTED_REVIEWER. Matches expected_outcome and is locked in by test_spoofed_reviewer_login_with_user_account_type_is_blocked.
  2. required-check-not-run.json — explicit inline security lane with "status": "NOT_RUN", "head_sha": null, "evidence_id": null (previously only the "lane missing from list" path was exercised; now the inline shape is too). lane.security check resolves to NOT_RUN (not collapsed into PASS/FAIL), decision_input.required_lane_statuses.security == "NOT_RUN", side_effects_performed stays false → verdict BLOCKED / REQUIRED_LANE_NOT_RUN. Verified by test_required_lane_not_run_is_not_collapsed_to_pass_or_fail.
  3. Digest exclusion of expected_outcome — new decision_evidence() helper strips expected_outcome before hashing in both evaluate() and _invalid_report(). test_fixture_expectation_cannot_self_authorize now additionally asserts input_digest_sha256 is byte-identical between the untampered baseline and the fixture with a forged expected_outcome, directly proving the oracle annotation can't shift the decision-evidence digest.
  4. NOT_RUN input validation stays fail-closed: validate_input() rejects a NOT_RUN lane that claims a head_sha/evidence_id, so the new fixture's shape is itself schema-validated, not just accepted blindly.

Ran the full suite and all four fixtures locally:

  • python3 -m unittest -v tests/test_build_week_trust_gate.py → 6/6 pass.
  • python3 tools/build_week_trust_gate.py <fixture> --verify-expected for all four build-week/demo/*.json fixtures → each verdict/reason_code matches its embedded expected_outcome.

Both nits from the previous review are now resolved with dedicated test coverage. No new issues found in this slice — the two adversarial fixtures are deterministic, correctly wired into the trusted-reviewer policy path (not the fixture's own claims), and preserve the three-state PASS/FAIL/NOT_RUN vocabulary end-to-end.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@BUILD_WEEK_2026_PLAN.md`:
- Around line 3-5: Update BUILD_WEEK_2026_PLAN.md to remove provisional and
unpublished-rule placeholders across the status, submission assets, timeline,
and next actions sections. Replace them with the published Devpost rules,
submission requirements, judging criteria, and corresponding dates, while
preserving the plan’s existing structure.

In `@tools/build_week_trust_gate.py`:
- Around line 491-492: Update the report output handling around
args.report_out.write_text to catch OSError, emit a concise diagnostic, and
return exit code 2 through the CLI’s controlled input-error path. Preserve the
existing successful write behavior and JSON output generation.
- Around line 364-383: Update the lane classification logic around the status
and head_sha checks so the current-head comparison runs first. When
lane["head_sha"] differs from current_head, always emit STALE_REQUIRED_LANE,
including when lane["status"] is "FAIL"; only classify matching-head failures as
REQUIRED_LANE_FAILED.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e8ace999-e339-4c96-9b51-a61fa8cabc60

📥 Commits

Reviewing files that changed from the base of the PR and between caaa5ed and a4236da.

📒 Files selected for processing (9)
  • BUILD_WEEK_2026_PLAN.md
  • build-week/README.md
  • build-week/demo/required-check-not-run.json
  • build-week/demo/spoofed-reviewer.json
  • build-week/demo/stale-approval.json
  • build-week/demo/trusted-current-head.json
  • build-week/policy/trust-policy.json
  • tests/test_build_week_trust_gate.py
  • tools/build_week_trust_gate.py

Comment thread BUILD_WEEK_2026_PLAN.md Outdated
Comment thread tools/build_week_trust_gate.py Outdated
Comment thread tools/build_week_trust_gate.py Outdated

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please review exact head 0d4021a769b5c7e5c63c0241d2234eef2b2e537e. Focus on the three repaired areas: published Build Week requirements in the plan, stale-vs-failed required-lane classification, and controlled --report-out write failures. Local validation: 9 Build Week tests pass; all four fixtures reproduce their expected verdicts.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="safal207/LS"
pr=895

echo "=== PR info ==="
gh pr view "$pr" --repo "$repo" --json headRefOid,baseRefOid,state,isDraft

echo "=== Commits ==="
gh pr view "$pr" --repo "$repo" --json commits --jq '.commits[] | {oid: .oid, messageHeadline: .messageHeadline}'

git clone --depth 100 --branch $(gh pr view $pr --repo $repo --json headRefName --jq .headRefName) https://github.com/$repo.git repo_clone 2>&1 | tail -5
cd repo_clone
echo "=== trying to checkout requested sha ==="
git checkout 0d4021a769b5c7e5c63c0241d2234eef2b2e537e 2>&1 || echo "CHECKOUT FAILED"
echo "=== log ==="
git log --oneline -15

Length of output: 3149


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== diff since a4236da ==="
git diff --name-status a4236da2120f52f0d35ce27c1bc40fa5b698531c..0d4021a769b5c7e5c63c0241d2234eef2b2e537e

echo "=== full diff ==="
git diff a4236da2120f52f0d35ce27c1bc40fa5b698531c..0d4021a769b5c7e5c63c0241d2234eef2b2e537e

Length of output: 11722


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== full file for context ==="
sed -n '1,40p' tools/build_week_trust_gate.py
echo "..."
sed -n '330,420p' tools/build_week_trust_gate.py
echo "=== run tests ==="
python3 -m unittest -v tests.test_build_week_trust_gate 2>&1 || true

echo "=== run fixtures manually ==="
for f in build-week/demo/*.json; do
  echo "--- $f ---"
  python3 tools/build_week_trust_gate.py "$f" --verify-expected --format json 2>&1 | tail -20
  echo "exit: $?"
done

echo "=== check argparse for report-out and main structure ==="
sed -n '440,510p' tools/build_week_trust_gate.py

Length of output: 14322


@safal207 Fresh review completed against exact head 0d4021a769b5c7e5c63c0241d2234eef2b2e537e (PR #895). The prior clean review at a4236da2120f52f0d35ce27c1bc40fa5b698531c is treated as stale for this head.

All three repaired areas confirmed:

  1. Published Build Week requirements in the planBUILD_WEEK_2026_PLAN.md now cites the confirmed Devpost requirements (Developer Tools track, YouTube demo under 3 minutes with audio on Codex/GPT-5.6 usage, /feedback Session ID, README/setup guidance, official deadline "July 21, 5:00 PM PT / July 22 03:00 Türkiye time"), replacing the earlier "provisional/pending rules" language. Judging criteria table and timeline were updated consistently.

  2. Stale-vs-failed required-lane classification — this is a real bug fix, not just a nit. In tools/build_week_trust_gate.py, the elif order in the lane-evaluation loop was swapped so the head-binding check (lane["head_sha"] != current_headSTALE_REQUIRED_LANE) now runs before the status == "FAIL" check (→ REQUIRED_LANE_FAILED). Previously, a lane that was both stale and failing would be misclassified as REQUIRED_LANE_FAILED (implying a fresh evidence run that failed) instead of STALE_REQUIRED_LANE (implying the evidence doesn't even belong to the current head, so its outcome is inadmissible regardless). This is a correct commit-binding-first classification: staleness is now checked ahead of outcome, matching the "exact-SHA evidence binding" thesis at the core of this trust gate. Verified by the two new tests:

    • test_stale_failed_lane_is_classified_by_commit_binding_first — stale + FAIL lane → STALE_REQUIRED_LANE, observed = "FAIL at f...f".
    • test_current_head_failed_lane_remains_a_lane_failure — same-head FAIL lane → still correctly REQUIRED_LANE_FAILED.
  3. Controlled --report-out write failuresmain() now wraps args.report_out.write_text(...) in a try/except OSError, printing trust-gate output error: <path>: <exc> to stderr and returning exit code 2 instead of letting an unhandled OSError propagate as a traceback. test_report_write_failure_returns_controlled_exit_code patches Path.write_text to raise and asserts exit code 2, the expected stderr message, and no traceback — this keeps the CLI fail-closed and non-crashing under filesystem errors (e.g., unwritable path, disk full, permission denied).

Local validation reproduced:

  • python3 -m unittest -v tests.test_build_week_trust_gate → 9/9 pass.
  • python3 tools/build_week_trust_gate.py <fixture> --verify-expected for all four build-week/demo/*.json fixtures → each verdict/reason_code matches its embedded expected_outcome (STALE_APPROVAL, ALL_REQUIRED_EVIDENCE_VALID, UNTRUSTED_REVIEWER, REQUIRED_LANE_NOT_RUN), exit code 0 in each case.

No new issues found in this slice. The classification fix in particular closes a real gap between the demo's "stale evidence is inadmissible" thesis and the implementation's prior behavior — good catch and clean fix with dedicated regression coverage.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please review exact head 299db4b239eddad32b621f31bd8b47de25f40fd7. Focus on the new location-independent ./scripts/run_build_week_demo.sh, fail-closed matrix verification, executable packaging, README commands, and the end-to-end subprocess test. Local validation: the one-command demo produces BLOCKED/BLOCKED/BLOCKED/TRUSTED with the four expected reason codes; 10/10 Build Week tests pass.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="safal207/LS"
pr=895

echo "=== PR info ==="
gh pr view "$pr" --repo "$repo" --json headRefOid,baseRefOid,state,isDraft

echo "=== Commits ==="
gh pr view "$pr" --repo "$repo" --json commits --jq '.commits[] | {oid: .oid, messageHeadline: .messageHeadline}'

git clone --depth 100 --branch $(gh pr view $pr --repo $repo --json headRefName --jq .headRefName) https://github.com/$repo.git repo_clone 2>&1 | tail -5
cd repo_clone
echo "=== trying to checkout requested sha ==="
git checkout 299db4b239eddad32b621f31bd8b47de25f40fd7 2>&1 || echo "CHECKOUT FAILED"
echo "=== log ==="
git log --oneline -15

Length of output: 3226


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== diff since 0d4021a ==="
git diff --name-status 0d4021a769b5c7e5c63c0241d2234eef2b2e537e..299db4b239eddad32b621f31bd8b47de25f40fd7

echo "=== full diff ==="
git diff 0d4021a769b5c7e5c63c0241d2234eef2b2e537e..299db4b239eddad32b621f31bd8b47de25f40fd7

Length of output: 6857


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== main() argparse section ==="
sed -n '1,60p' tools/build_week_trust_gate.py | grep -n "argparse\|add_argument\|policy" || true
rg -n "add_argument|--policy|--verify-expected|--report-out|--format" tools/build_week_trust_gate.py

echo "=== permissions ==="
ls -la scripts/run_build_week_demo.sh

echo "=== run tests ==="
python3 -m unittest -v tests/test_build_week_trust_gate.py tests/test_build_week_demo.py 2>&1 || true

echo "=== run demo script directly from repo root ==="
./scripts/run_build_week_demo.sh; echo "exit: $?"

echo "=== run demo script from another cwd ==="
cd /tmp
"$OLDPWD/scripts/run_build_week_demo.sh" 2>&1 || true
cd -

echo "=== run demo script with absolute path from /tmp ==="
mkdir -p /tmp/elsewhere && cd /tmp/elsewhere
bash "$(pwd)/../../repo_clone/scripts/run_build_week_demo.sh" 2>&1 || true
REPO_ROOT=$(cd - >/dev/null && pwd)
echo "repo root: $REPO_ROOT"
bash "$REPO_ROOT/scripts/run_build_week_demo.sh"; echo "exit: $?"

Length of output: 5538


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone
echo "=== git file mode ==="
git ls-files -s scripts/run_build_week_demo.sh
echo "=== check shebang and no external deps besides python3/bash ==="
head -5 scripts/run_build_week_demo.sh
echo "=== check README final content ==="
cat build-week/README.md

Length of output: 3491


@safal207 Fresh review completed against exact head 299db4b239eddad32b621f31bd8b47de25f40fd7 (PR #895). The prior review at 0d4021a769b5c7e5c63c0241d2234eef2b2e537e is treated as stale for this head.

All requested focus areas confirmed:

  1. Location-independent ./scripts/run_build_week_demo.shROOT_DIR is resolved via cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd, which correctly anchors all paths (GATE, POLICY, fixture paths) to the script's own location rather than the caller's cwd. Verified this by running the script from the repo root, from /tmp via a relative-to-$OLDPWD path, and via an absolute path from an unrelated directory — identical output and exit code (0) in every case.

  2. Fail-closed matrix verification — the script calls the gate per scenario with --verify-expected, parses verdict/reason_code out of the JSON report, and compares against the required matrix. Non-zero gate exit is captured (reason_code="GATE_EXIT_${exit_code}") rather than silently ignored, a missing Python interpreter is checked upfront and exits 2, and any single mismatch across the four scenarios causes the whole script to exit 1 with a FAILED summary on stderr — no silent partial success.

  3. Executable packaginggit ls-files -s scripts/run_build_week_demo.sh shows mode 100755, so the executable bit is correctly committed, not just present on the sandbox filesystem.

  4. README commandsbuild-week/README.md's Run and Test sections now match the actual repo state: single ./scripts/run_build_week_demo.sh invocation, the exact expected-summary block, the PYTHON= override note, and the Test section listing both tests/test_build_week_trust_gate.py and tests/test_build_week_demo.py.

  5. End-to-end subprocess testtests/test_build_week_demo.py::test_one_command_demo_reproduces_all_four_scenarios deliberately runs the script via subprocess.run with cwd=ROOT.parent (i.e., not the repo root), which is exactly the right test for location independence — it would fail if the script depended on the caller's working directory. It asserts exit code 0, empty stderr, each scenario row's verdict/reason, and the final 4/4 summary line.

Local validation reproduced exactly:

  • python3 -m unittest -v tests/test_build_week_trust_gate.py tests/test_build_week_demo.py → 10/10 pass.
  • ./scripts/run_build_week_demo.shBLOCKED/STALE_APPROVAL, BLOCKED/UNTRUSTED_REVIEWER, BLOCKED/REQUIRED_LANE_NOT_RUN, TRUSTED/ALL_REQUIRED_EVIDENCE_VALID, exit 0.

No issues found in this slice — the one-command demo wrapper is genuinely portable, fails closed on both scenario mismatches and missing interpreters, and is backed by a real subprocess-level regression test rather than just unit-level coverage of the underlying gate.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Please review exact head 97544c00c83eff70fb10592977173094b92f3d55. This commit is documentation/evidence only. Focus on whether the evidence snapshot is honestly bound to reviewed implementation SHA 299db4b239eddad32b621f31bd8b47de25f40fd7, the saved trust report is reproducible, CI/test claims match their linked runs, the four-scenario attack matrix is accurate, and the Codex/GPT-5.6 contribution log clearly separates human decisions from agent work without fabricating a /feedback Session ID.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="safal207/LS"
pr=895

echo "=== PR info ==="
gh pr view "$pr" --repo "$repo" --json headRefOid,baseRefOid,state,isDraft

echo "=== Commits ==="
gh pr view "$pr" --repo "$repo" --json commits --jq '.commits[] | {oid: .oid, messageHeadline: .messageHeadline}'

git clone --depth 100 --branch $(gh pr view $pr --repo $repo --json headRefName --jq .headRefName) https://github.com/$repo.git repo_clone 2>&1 | tail -5
cd repo_clone
echo "=== trying to checkout requested sha ==="
git checkout 97544c00c83eff70fb10592977173094b92f3d55 2>&1 || echo "CHECKOUT FAILED"
echo "=== log ==="
git log --oneline -15

Length of output: 3321


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== diff since 299db4b ==="
git diff --name-status 299db4b239eddad32b621f31bd8b47de25f40fd7..97544c00c83eff70fb10592977173094b92f3d55

echo "=== full diff ==="
git diff 299db4b239eddad32b621f31bd8b47de25f40fd7..97544c00c83eff70fb10592977173094b92f3d55

Length of output: 16901


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone

echo "=== checkout evidence subject commit 299db4b for reproducibility check ==="
git checkout 299db4b239eddad32b621f31bd8b47de25f40fd7 -- . 2>&1 || true
git status --short | head

echo "=== run gate against stale-approval fixture and diff vs saved example (excluding schema-neutral formatting) ==="
python3 tools/build_week_trust_gate.py build-week/demo/stale-approval.json --policy build-week/policy/trust-policy.json --format json > /tmp/generated_report.json 2>&1 || true
cat /tmp/generated_report.json

echo "=== diff generated vs stored example ==="
git show 97544c00c83eff70fb10592977173094b92f3d55:build-week/evidence/trust-report.example.json > /tmp/stored_example.json
python3 - <<'EOF'
import json
gen = json.load(open("/tmp/generated_report.json"))
stored = json.load(open("/tmp/stored_example.json"))
gen_keys = set(gen.keys())
stored_keys = set(stored.keys())
print("missing in gen:", stored_keys - gen_keys)
print("extra in gen:", gen_keys - stored_keys)
for k in sorted(stored_keys & gen_keys):
    if gen[k] != stored[k]:
        print(f"DIFF at {k}:\n  gen={gen[k]}\n  stored={stored[k]}")
EOF

Length of output: 4382


🏁 Script executed:

#!/bin/bash
set -euo pipefail
repo="safal207/LS"

echo "=== verify github actions run ids belong to head sha 299db4b ==="
for run_id in 29303554682 29303554670 29303554694 29303554693; do
  echo "--- run $run_id ---"
  gh api "repos/$repo/actions/runs/$run_id" --jq '{name, head_sha, status, conclusion, event}' 2>&1 || echo "FAILED to fetch $run_id"
done

echo "=== verify the linked review comment exists ==="
gh api "repos/$repo/issues/comments/4965121921" --jq '{user: .user.login, body: .body[0:200], html_url}' 2>&1 || echo "COMMENT NOT FOUND"

Length of output: 1913


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cd repo_clone
echo "=== search for feedback session id fabrication ==="
rg -ni "session.?id" build-week/evidence/ BUILD_WEEK_2026_PLAN.md build-week/README.md

Length of output: 955


All checks pass, confirming this documentation/evidence commit is honest and internally consistent.

@safal207 Fresh review completed against exact head 97544c00c83eff70fb10592977173094b92f3d55 (PR #895). The prior review at 299db4b239eddad32b621f31bd8b47de25f40fd7 is treated as stale for this head. This commit is documentation/evidence-only (BUILD_WEEK_2026_PLAN.md, build-week/README.md modified; four new files under build-week/evidence/) — no changes to tools/build_week_trust_gate.py, fixtures, or scripts/run_build_week_demo.sh.

All five focus areas confirmed:

  1. Evidence snapshot honestly bound to 299db4b — every evidence file (attack-matrix.md, codex-contribution-log.md, test-results.json, trust-report.example.json) explicitly states its "evidence subject" as 299db4b239eddad32b621f31bd8b47de25f40fd7, and build-week/README.md's new "Evidence snapshot" section pins the same SHA and explains that later documentation commits can't silently rewrite which implementation/CI runs were verified.

  2. Saved trust report is reproducible — I checked out 299db4b and re-ran python3 tools/build_week_trust_gate.py build-week/demo/stale-approval.json --policy build-week/policy/trust-policy.json --format json, then diffed every key against the checked-in build-week/evidence/trust-report.example.json. Result: byte-identical, including input_digest_sha256 and policy_digest_sha256. This is a genuine reproducibility proof, not just a plausible-looking sample.

  3. CI/test claims match their linked runs — verified via gh api repos/safal207/LS/actions/runs/<id> for all four run IDs in test-results.json: head_sha for each matches 299db4b239eddad32b621f31bd8b47de25f40fd7 exactly, and conclusions (success/success/success/skipped for the fork-only causal review job) match what's recorded. The linked CodeRabbit review comment (#issuecomment-4965121921) also resolves to the actual "no issues found" review for that head.

  4. Four-scenario attack matrix is accurate — cross-checked attack-matrix.md's table against the actual fixtures and code paths: stale approval → review.commit_sha == pull_request.current_head_sha mismatch → BLOCKED/STALE_APPROVAL; spoofed reviewer → identity/account-type/provenance check → BLOCKED/UNTRUSTED_REVIEWER; required lane not run → three-state preservation → BLOCKED/REQUIRED_LANE_NOT_RUN; valid current-head → TRUSTED/ALL_REQUIRED_EVIDENCE_VALID. All match prior verified fixture behavior. The "failure-closed properties" bullets (non-zero exit, digest exclusion of expected_outcome, stale-before-outcome classification) are consistent with the actual implementation reviewed in earlier heads.

  5. Codex/GPT-5.6 contribution log separates human vs. agent work, no fabricated Session IDcodex-contribution-log.md has a distinct "Human-owned decisions" section (track choice, scope boundaries, deadline, state-preservation requirements) versus a per-commit table crediting Codex with implementation while explicitly noting what the human retained control over. On the /feedback Session ID specifically: I grepped all evidence/plan files and found only the correct language — "must be copied from the product UI before submission; it is deliberately not fabricated in repository evidence." No placeholder or invented Session ID value appears anywhere.

No issues found in this documentation/evidence slice — the snapshot's claims are independently verifiable against live GitHub state and the local tool, not just self-asserted.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@safal207 safal207 changed the title docs: prepare LS for OpenAI Build Week 2026 feat: add LS Build Week stale-approval trust gate Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant