Skip to content

fix(coverage): prefetch locked Rust dependencies for offline evidence - #1391

Draft
seonghobae wants to merge 11 commits into
mainfrom
codex/repair-offline-rust-coverage-20260828
Draft

seonghobae wants to merge 11 commits into
mainfrom
codex/repair-offline-rust-coverage-20260828

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • prefetches each locked Rust manifest from the exact pull-request merge tree before the coverage sandbox loses network access;
  • uses a neutral runner-owned HOME/CARGO_HOME with GitHub credential variables removed and disables Git credential prompts;
  • copies only Cargo's content-addressed registry/ and git/ caches into the reserved sandbox home, rejects PR-controlled collisions, and keeps offline coverage fail-closed;
  • updates the runtime-boundary doctoring record, changelog, and contract/hash tests.

Root-cause evidence

ContextualWisdomLab/OriginWeave#210 at exact head 0341079331f9cea669eb9a5cc21842fd6027431e reproduced the central OpenCode coverage failure in dispatched run 33179004673, coverage-evidence job 98875118407: the networkless container attempted to resolve unicode-normalization from index.crates.io because no Cargo registry/git cache was materialized. The local OriginWeave Rust coverage proof was green; this PR repairs the central evidence boundary rather than weakening the gate.

Verification

  • pre-update exact source head 135106c903da0bbf040d809dcf1147379b984020: focused central contracts/shell checks 33 passed, 1 skipped;
  • pre-update central full suite excluding the pre-existing macOS-only stat -c sidecar tests: 1691 passed, 1 skipped, 17 subtests passed;
  • pre-update git diff --check: passed; local Strix quick gate and full actionlint remain explicitly unclaimed because of the documented macOS fixture failure and timeout;
  • the current branch includes the exact-head hardening commit 36ac3aa71b2580685f84d416a81e42c39dee927c, which disables Git credential prompts during locked-manifest prefetch; current exact PR head is 36ac3aa71b2580685f84d416a81e42c39dee927c;
  • current-head review-thread query returns zero unresolved threads; fresh required checks and OpenCode approval are pending and must be evaluated only for 36ac3aa71b2580685f84d416a81e42c39dee927c;

No branch protection, review, coverage, security, or merge gate is bypassed.


Devin Review

@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: eed7c385-e6b5-45d2-9cbd-8182b3c44198

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8c51d and 7464d9d.

📒 Files selected for processing (5)
  • .github/workflows/opencode-review-dispatch.yml
  • CHANGELOG.md
  • docs/doctoring/opencode-rust-coverage-runtime-boundary.md
  • tests/test_opencode_rust_coverage_toolchain_contract.py
  • tests/test_pr_review_autofix_nvidia_nim_contract.py

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.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae enabled auto-merge (rebase) August 29, 2026 07:09
@opencode-agent
opencode-agent Bot disabled auto-merge August 29, 2026 07:14
Recompute REVIEW_DISPATCH_BLOB_SHA to the merged tree's actual blob
hash for .github/workflows/opencode-review-dispatch.yml, since this
branch's own Cargo-prefetch step is added inside that same workflow
file, so neither side's pre-merge pinned value is correct post-merge.
Verified: pytest tests/test_pr_review_autofix_nvidia_nim_contract.py (23 passed).

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Devin Review

Comment on lines +101 to +149
def test_rust_coverage_prefetches_locked_crates_before_networkless_sandbox() -> None:
"""Materialize only trusted Cargo caches before PR code loses network access."""

dispatch = _dispatch_text()
source_tree_start = dispatch.index(
" - name: Materialize pull request merge tree for coverage measurement\n"
)
source_tree_end = dispatch.index(
" - name: Upload materialized pull request merge tree\n",
source_tree_start,
)
source_tree = dispatch[source_tree_start:source_tree_end]

assert "prefetch_manifests=\"$(git -C \"$COVERAGE_SOURCE_WORKDIR\" ls-files 'Cargo.toml' '*/Cargo.toml')\"" in source_tree
assert "cargo fetch --locked" in source_tree
assert "--manifest-path \"$COVERAGE_SOURCE_WORKDIR/$prefetch_manifest\"" in source_tree
assert 'cd "$prefetch_home"' in source_tree
assert 'HOME="$prefetch_home"' in source_tree
assert 'CARGO_HOME="$prefetch_home/.cargo"' in source_tree
assert 'CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git' in source_tree
assert 'GIT_TERMINAL_PROMPT=0' in source_tree
assert "env -u GH_TOKEN -u GITHUB_TOKEN" in source_tree
assert ".opencode-sandbox-home" in source_tree
assert "refusing to mix it with trusted Cargo caches" in source_tree
assert 'for prefetch_cache_dir in registry git; do' in source_tree
assert 'CARGO_NET_OFFLINE=true' in dispatch
assert "docker run --rm --init --network=none" in dispatch


def test_reserved_sandbox_path_is_rejected_without_cargo() -> None:
"""Reject PR-controlled sandbox state even when the runner lacks Cargo."""

dispatch = _dispatch_text()
source_tree_start = dispatch.index(
" - name: Materialize pull request merge tree for coverage measurement\n"
)
source_tree_end = dispatch.index(
" - name: Upload materialized pull request merge tree\n",
source_tree_start,
)
source_tree = dispatch[source_tree_start:source_tree_end]

reserved_path_guard = (
'if [ -e "$COVERAGE_SOURCE_WORKDIR/.opencode-sandbox-home" ] ||'
)
cargo_gate = (
'if [ -n "$prefetch_manifests" ] && command -v cargo >/dev/null 2>&1; then'
)
assert source_tree.index(reserved_path_guard) < source_tree.index(cargo_gate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Cache transfer lacks executable coverage

The new tests only match workflow text. They cannot catch failures spanning Cargo fetch, cache copying, archive validation, and offline resolution.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

seonghobae pushed a commit that referenced this pull request Aug 30, 2026
- Clean-merge subtotal said 5 but named 6 PRs; corrected to 6, and added
  the omitted #1391 to the trivial-conflicts list so 6+7+2=15 reconciles
  with the stated total.
- Compact cross-repo references to the owner/repo#num binding convention:
  ContextualWisdomLab/contextual-orchestrator#857 and
  ContextualWisdomLab/LineageWeave#667.

Co-Authored-By: Claude <noreply@anthropic.com>
seonghobae added a commit that referenced this pull request Aug 30, 2026
* docs(gaps): restore section dropped by #1423's merge, correct stale claim

PR #1423 merged (ebd1b8b) using a merge-conflict resolution that kept
only its own branch's dated section and silently dropped main's
already-published '2026-08-30 sidecar pin staleness recurrence'
section (the #1422 fix's own record) from the file entirely. That
merge also left #1423's own section claiming #1413/#1422 'have not
merged' even though both are its own git ancestors.

Restore the dropped section verbatim, annotate the stale section as
superseded, and append an accurate dated entry recording this cycle's
backlog-refresh work: 15 PRs merged/retriggered against the new main,
8 left untouched for real conflicts, one independent sidecar/review-
dispatch defect newly observed on #1420, and a Gap ID collision
(G-15) renumbered to G-16 on #1348.

Verified: git diff against origin/main shows this change is purely
additive (no main content removed); pytest
tests/test_product_technical_gap_baseline.py
tests/test_pr_governance_audit_contract.py (8 passed).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015Gs7KmNvH75nxz1sL8mKjw

* docs(gaps): fix Devin-flagged count/reference errors in #1424

- Clean-merge subtotal said 5 but named 6 PRs; corrected to 6, and added
  the omitted #1391 to the trivial-conflicts list so 6+7+2=15 reconciles
  with the stated total.
- Compact cross-repo references to the owner/repo#num binding convention:
  ContextualWisdomLab/contextual-orchestrator#857 and
  ContextualWisdomLab/LineageWeave#667.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
claude added 2 commits August 30, 2026 09:51
…line-rust-coverage-20260828

# Conflicts:
#	CHANGELOG.md
…rust-coverage-20260828

# Conflicts:
#	CHANGELOG.md
#	tests/test_pr_review_autofix_nvidia_nim_contract.py

Copy link
Copy Markdown
Contributor Author

Resolved the stale merge conflict against current main (merge commit a475dc40, pushed to this PR's head branch).

Conflicts (2 files):

  1. CHANGELOG.md — same additive-prepend pattern as other recent PRs: both branches independently added entries under ## [Unreleased]. Kept this PR's "Repair Rust coverage dependency materialization by prefetching locked Cargo sources…" entry at the top, followed by all of main's newer entries (sidecar ORCHESTRATOR_CATALOG_FAMILY_CAP bump, Strix orchestrator/free switch, NVIDIA NIM ZDR citation), nothing dropped.

  2. tests/test_pr_review_autofix_nvidia_nim_contract.py's REVIEW_DISPATCH_BLOB_SHA constant — this pins the exact git blob SHA of .github/workflows/opencode-review-dispatch.yml. Both this PR and main had independently edited that workflow (this PR's Cargo-prefetch step; main's unrelated sidecar/Strix changes), and git merge auto-merged the workflow file itself cleanly with no conflict markers — but that meant neither branch's old pinned SHA (50752bfe… here, 2aa245e7… on main) matched the new merged blob. Recomputed the actual hash of the merged file with git hash-object .github/workflows/opencode-review-dispatch.yml → b157ab2d9892102d28e2ff59505efef7156905fa and used that. Verified the merged workflow file contains both sides' content intact: the Cargo prefetch block (cargo fetch --locked, .opencode-sandbox-home guard, CARGO_NET_OFFLINE=true) and main's independent changes (ORCHESTRATOR_CATALOG_FAMILY_CAP default 8, 30c6d716 sidecar pin). tests/test_opencode_rust_coverage_toolchain_contract.py::test_review_dispatch_blob_sha_stays_paired_with_trusted_workflow independently recomputes this hash at test time, so it self-validates going forward.

No independent fix on main supersedes anything this PR does — main's changes are all unrelated (sidecar model-pool cap, Strix model routing, ZDR citation), so the full Cargo-prefetch/offline-Rust-coverage repair from this PR is preserved as-is.

Test evidence (post-merge, in an isolated worktree):

  • python3 -m pytest tests/test_opencode_rust_coverage_toolchain_contract.py tests/test_pr_review_autofix_nvidia_nim_contract.py -q → 33 passed, 1 skipped
  • PYTHONPATH=. python3 -m pytest tests -q → 1899 passed, 1 skipped, 21 subtests passed
  • coverage run -m pytest tests -q && coverage report --include="scripts/ci/*" --show-missing → 100% statements and branches (this PR touches no scripts/ci/*.py)
  • interrogate -v on both touched test files → 100% (36/36)
  • merged .github/workflows/opencode-review-dispatch.yml parses as valid YAML (yaml.safe_load)
  • git diff --check → clean, no conflict markers remain

No security gate, network-isolation boundary, or credential-handling logic was touched or weakened.


Generated by Claude Code

# Conflicts:
#	CHANGELOG.md
#	tests/test_pr_review_autofix_nvidia_nim_contract.py

Copy link
Copy Markdown
Contributor Author

Stale base resolved — merged current main

Branch was dirty against current main (base recorded here was 1d8e872, from 2026-08-23). git fetch origin main && git merge --no-edit produced two conflicts:

  • CHANGELOG.md: purely additive — isolated this PR's actual unique contribution via git diff against its own recorded base (one 8-line bullet about the Rust coverage prefetch repair) and inserted it into current main's CHANGELOG.md, dropping nothing from either side.
  • tests/test_pr_review_autofix_nvidia_nim_contract.py: a byte-for-byte REVIEW_DISPATCH_BLOB_SHA pin on .github/workflows/opencode-review-dispatch.yml (a file this PR itself modifies, +60 lines). Since that workflow file auto-merged cleanly (both this PR's and main's independent changes to it landed together with no textual overlap), neither side's old pinned hash was correct any more for the merged content. Ran git hash-object .github/workflows/opencode-review-dispatch.yml on the post-merge file and used that fresh value (254df8e0... — full hash in the commit) rather than either conflict side. Confirmed this is exactly what the test itself checks (test_independent_review_agent_workflow_matches_reviewed_blob runs git hash-object live and compares).

Net diff versus current main after the merge: 5 files, 147 insertions / 3 deletions — matches this PR's own stated scope (144/3, 5 files).

Verified before pushing (head confirmed unchanged at a475dc40 immediately prior):

  • .github/workflows/opencode-review-dispatch.yml re-parses as valid YAML
  • Full suite: coverage run -m pytest tests -q → 2763 passed, 1 skipped, 21 subtests (excluding the 2 pre-existing Python-3.11-vs-3.12+ sandbox-incompatible files, unrelated to this diff)
  • coverage report --include="scripts/ci/*" → 100% (12339 statements / 4992 branches)
  • interrogate --fail-under=100 scripts/ci → 100%
  • git diff --check — clean

Pushed non-force as cf5e2139 (two-parent merge commit, a475dc40..cf5e2139). Fresh exact-head checks and review are now required per this repo's governance model.


Generated by Claude Code

Two conflicts:

- CHANGELOG.md — kept both sides, this branch's entry above main's, matching
  the file's newest-first convention.
- REVIEW_DISPATCH_BLOB_SHA — this pin is `git hash-object` over
  `.github/workflows/opencode-review-dispatch.yml`, so both sides' values are
  correct only for their own tree (branch 77401c6…, main ade10b3…) and both
  are wrong for the merge. Recomputed against the merged file:
  bcf7446.

Verified after resolution: 2892 passed, 1 skipped, coverage 100%,
interrogate 100%; zero conflict markers; `ruff check --select F821` clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
#1932 changed `.github/workflows/opencode-review-dispatch.yml`, which
REVIEW_DISPATCH_BLOB_SHA pins by whole-file `git hash-object`. The workflow
auto-merged cleanly; only the pin line conflicted, and neither side's value is
right for the merge:

  this branch  bcf7446…  (its own tree)
  main         26e8555…  (after #1932)
  merged       f1a9eb0…  (recomputed)

Verified: 2893 passed, 1 skipped, coverage 100%, interrogate 100%; zero
conflict markers; `ruff check --select F821` clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@seonghobae seonghobae added bug Something isn't working priority: medium Normal-priority or P2 work type: bug Defect or incorrect behavior labels Sep 7, 2026 — with ChatGPT Codex Connector

Copy link
Copy Markdown
Contributor Author

Fresh unchanged-consumer reproduction confirms that this PR still owns a live protected-main defect and also shows exactly why a current-main adoption is needed.

OriginWeave consumer: ContextualWisdomLab/OriginWeave#229@3c0e8eb318db98eafdb477e726f77ecdf92883e8, base 87c4daa1830bac5a5228b6036752ad5633232085.

Central OpenCode dispatch 34701932468, coverage-evidence job 103575361404, trusted workflow SHA fb17ef556f94f673234aa557254ae52779e9a7b0:

  • source artifact download and digest verification succeeded;
  • PR-head replay guard passed with zero post-merge commits/removals/reversions;
  • changed-file syntax gate passed 10 checked, 43 skipped, 0 failed;
  • Python test coverage completed with TOTAL 2267 / 221 missed / 90% and was recorded PASS by the central contract; Python docstring advisory also passed at 91.7% against 80%;
  • the actual fatal boundary was Rust coverage: cargo llvm-cov --workspace --all-features --fail-under-lines 100 --show-missing-lines tried Updating crates.io index inside the network-disabled sandbox and failed to resolve index.crates.io; first concrete dependency was unicode-normalization for originweave-core; both cargo clean/test paths then exited 101. The final Coverage Decision was FAIL.

That is the exact defect #1391 is designed to repair: current protected .github/main@91be6442906c7b6b4f600272c953699708394327 still has no locked Cargo prefetch path, while this branch contains cargo fetch --locked, strips GitHub/runtime credentials during the networked prefetch, carries only Cargo content-addressed registry/git caches forward, and forces CARGO_NET_OFFLINE=true in the sandbox.

However, live PR state is now head=7464d9d57c8434c6347125b7ed1070836ef460a3, mergeable=false, with merge base 6f8c51d7389c22ebaf294fe8fe9ef495257883c0; compared with current protected main it is 11 ahead / 131 behind. The body’s 36ac3aa... current-head statement is stale. Treat the stale base/conflict as a repair finding, not a close condition: re-read current .github authority, adopt the current protected delta through an ordinary non-force successor/restack, preserve the credential-stripping/cache-integrity/offline fail-closed contracts, then replay the unchanged OriginWeave #229 head as an acceptance canary. Do not transfer predecessor checks/reviews or weaken the networkless boundary.

Copy link
Copy Markdown
Contributor Author

One additional repair finding remains before this owner PR should be revived against current main: review thread PRRT_kwDOS_C14s6dfRHR is still unresolved and is valid. At live head 7464d9d57c8434c6347125b7ed1070836ef460a3, test_rust_coverage_prefetches_locked_crates_before_networkless_sandbox() only asserts workflow text (cargo fetch --locked, cache-copy loop, CARGO_NET_OFFLINE=true, --network=none); it does not execute the prefetch → cache transfer/archive boundary → offline Cargo resolution path.

The new OriginWeave #229 log makes this especially material because the production failure occurs exactly at that cross-boundary behavior, not at the presence/absence of those strings. A current-main successor should therefore preserve the existing static contract and add an executable hermetic fixture for the helper/boundary: create a tiny locked Rust graph against a test-owned local registry/cache source, run the same bounded prefetch with neutral HOME/CARGO_HOME and credential stripping, pass only the allowed Cargo registry//git/ state through the archive validator, then run Cargo with network disabled and assert dependency resolution/test execution succeeds; include a negative case where the cache is absent/corrupted and resolution fails closed. The live unchanged OriginWeave #229 replay remains the post-integration real-consumer acceptance and must not substitute for the repository-level regression test.

This is not a request to weaken .cargo/config isolation or enable network in the sandbox. It is the missing executable contract needed to close the existing review finding while preserving the security boundary.

Copy link
Copy Markdown
Contributor Author

Exact-head admission audit: 7464d9d57c8434c6347125b7ed1070836ef460a3 (base main@6f8c51d7389c22ebaf294fe8fe9ef495257883c0, 11 ahead / 0 behind).

현재 blocker:

  • GitHub mergeability=false, compare=ahead
  • terminal workflow blocker: CodeQL PR:failure
  • 미해결 review thread 1개

유효 commit·diff·review evidence를 보존한 채 Draft/Proposed로 교정합니다. Base 이동이나 queue 대기만으로 Close하지 않으며 Force Push·synthetic status/approval·manual rerun·bypass를 사용하지 않습니다. Blocker 수리 후 새 exact head에서 Checks와 review admission을 다시 받아야 합니다.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exact-head P1 acceptance-evidence finding for 36ac3aa71b2580685f84d416a81e42c39dee927c (COMMENT because GitHub does not permit an author's self REQUEST_CHANGES).

The production change spans a multi-component boundary—trusted cargo fetch, selective registry/git cache copy, archive validation/materialization, and an offline coverage container—but the current regression evidence only inspects workflow text. That cannot detect incompatible Cargo cache formats, omitted cache members, copy/permission mistakes, archive rejection, or a runtime that still reaches dependency resolution without consuming the transferred cache. The cited OriginWeave run proves the pre-fix failure, not an exact-head end-to-end GREEN.

Repair this at the canonical owner with an executable fixture that uses a minimal locked Rust workspace and isolated runner-owned HOME/CARGO_HOME: prefetch while network is available, pass only the admitted registry/ and git/ cache through the same archive validator/materializer, then resolve/build with CARGO_NET_OFFLINE=true and no network. Include RED cases for a missing required cache member, a rejected non-regular/archive member, and PR-controlled reserved-home collision; assert no credentials or PR Cargo config enter the trusted prefetch. Keep the existing fail-closed custom-registry boundary and protocol pin.

The PR body currently says the current-head review-thread query returns zero unresolved threads, but live review state contains the unresolved executable-coverage thread at tests/test_opencode_rust_coverage_toolchain_contract.py:152; update that ledger only after the executable acceptance evidence exists.

GitHub REST reads are temporarily rate-limited (403), so I am not promoting any hosted Check or predecessor result. Keep Draft/Proposed; no merge, auto-merge, bypass, or rerun is authorized.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: medium Normal-priority or P2 work type: bug Defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants