Skip to content

pr_runtime: one environment built at HEAD and one shared validation container limit yield on older PRs #253

Open

Description

@rycerzes

Summary

pr_runtime was run on eight repos to build an RL task batch (149 tasks). Most problems found trace back to a few design choices, so this raises the design before sending fixes. Checked against v0.9.6.

Repo Result Cause
hugo 2 tasks / 185 PRs Base commits need Go modules missing from the image's read-only cache
pydantic 0 / 360 pydantic-core built at HEAD; older bases fail to import
networkx 0 → 26 after a local patch Config guard (#212) rejects a symlinked config, in validation and test.sh
moto 0 Stages alternate between a 600 s timeout and precleanup_failed

Root causes

  1. One environment built at HEAD for every base commit. Validation and task images only reset git; nothing is reinstalled, even though BOOTSTRAP.md says per-PR pipelines reinstall after checkout. Re-bootstrapping per two-week window took hugo from 2 to 19 tasks.
  2. One shared container, no per-PR error boundary.
    • One non-UTF-8 byte in any output ends the whole run: _run decodes strictly.
    • The launcher gets no --timeout, so a timed-out stage keeps running in the container and breaks the next stage.
  3. Hygiene by scrubbing. env_guard: drop unreachable objects after scrubbing a partial clone #247 fixed the git leak but nothing asserts it. Pre-0.9.6 bundles still leak.
  4. Task text from regex cleanup. PR-body instructions keep "Changes" / "Solution" sections: at least 13 of 100 FineEnvs/repo2rlenv-pr-runtime tasks describe the fix.

Network isolation is WIP outside Repo2RLEnv.

Proposed design

1. Environment epochs.

  • Group PRs by the hash of their dependency manifests at base (go.sum, lockfiles, pyproject.toml).
  • Bootstrap once per epoch, starting from the nearest epoch's recipe.
  • Reuse an image for another base only if a reuse check passes (≥80% of the anchor's passing tests, as in RepoLaunch). Otherwise re-bootstrap near that base.

2. Clean images by construction, instead of scrubbing.

  • Build from a fresh single-commit repo at base, with dependencies installed at build time.
  • Then switch offline: GOPROXY=off, PIP_NO_INDEX=1, npm/cargo offline mode.
  • Run the agent as learner with no-network, as the repository recipe already does.
  • The registry gap in Package registries still serve the fix for Go and Rust tasks #160 then closes without a denylist.

3. Each PR is the unit of work.

  • Every candidate ends in exactly one state: ok, dropped(reason), error(kind) or inconclusive.
  • Typed error kinds decide whether to retry or drop.
  • Each validation stage runs in a fresh container.
  • Each run writes a funnel report and resumes from completed candidates.

4. Audit stage (on top of RFC 0027/0033).

  • Image leak check: the reference patch's added lines are searched for across the image and its caches.
  • Controls: gold ×N and empty ×N reruns, including the base state, plus stub and test-tamper variants.
  • Fixed-order judge with executed wrong-fix probes. It checks the instruction last, plus a deterministic leak gate (no hidden test names or gold-only identifiers) and a blind second judge.

Longer term, this converges with the history/repository worker: staged, resumable artifacts, extended beyond Python.

Phasing

  • Phase 0, small PRs:
    • an error boundary per PR;
    • errors="replace";
    • pass --timeout to the launcher;
    • date-ranged PR listing with retry;
    • a symlink-safe guard;
    • a post-scrub assertion.
  • Phase 1: items 1–3.
  • Phase 2: item 4.

Questions

  1. Should this be an RFC (the design above as its outline), or should the phase 0 PRs come first?
  2. Would an offline solve phase with a preinstalled agent be acceptable, as the repository recipe already does?
  3. Should pre-0.9.6 pr_runtime bundles be rebuilt, as Repair published PR-diff tasks after the oracle isolation fix #155 did for pr_diff?

Related: #160, #236, #211, #155, #247. Reproductions and stage logs are available.

Activity

  1. adithya-s-k commented on Nov 16, 2026

    @adithya-s-k
    Collaborator

    Thanks for running this across real repositories; the per-repo breakdown makes the failure modes clear. Let's land the small phase-0 fixes first and use an RFC for environment epochs and the fresh-container lifecycle. I'm reviewing #258 and #259 now. #254 also addresses the bootstrap bytecode leak.

    An offline solve phase with a preinstalled agent is the right direction. The validation must use the same dependency snapshot and network policy the emitted task will use. For epoch reuse, I'd treat a passing-test percentage as supporting evidence, not the acceptance gate by itself: we still need the task's own oracle/no-op and regression controls to work at that base.

    The older published runtime bundles do need rebuilding and revalidation. Upgrading the package alone doesn't change embedded verifiers or remove cached answers. The migration tooling for PR-diff is now merged, but it hasn't republished or revalidated the datasets.

    Please send the remaining phase-0 changes as small PRs: bounded launcher timeouts/cleanup, tolerant output decoding, and per-candidate error reporting. Keep infrastructure failures distinct from task failures. Let's keep this issue open as the design tracker; the two phase-0 PRs won't resolve the HEAD dependency mismatch by themselves.

  2. adithya-s-k commented on Nov 23, 2026

    @adithya-s-k
    Collaborator

    The remaining phase-0 PRs are merged now: #265 handles invalid output bytes, #266 bounds the test launcher and cleans up after host-side timeouts, and #267 records candidate failures separately from infrastructure failures and continues the batch. They passed the combined suite and the real Harbor/container CI controls.

    Post-scrub assertions and task-text leakage checks also remain on this tracker. Keeping it open for the larger design work: revision-aware dependency snapshots and a fresh validation-container lifecycle. These fixes make a batch more resilient, but they do not make a HEAD-built environment correct for every historical PR. We should still require oracle/no-op and regression controls at the candidate's base revision before reusing an image.

  3. adithya-s-k commented on Nov 25, 2026

    @adithya-s-k
    Collaborator

    Opened #278 for the post-scrub assertion from phase 0. I reproduced three cases where cleanup reports success but leaves a custom ref, another remote or a kept pack containing future objects. The final image-build check now rejects these cases and still accepts complete/partial clones with the base and its ancestors intact.

    The focused checks pass; CI is running. This covers the Git object store only. Environment epochs, fresh validation containers, task-text leakage and published-dataset rebuilds remain on this tracker.

  4. adithya-s-k commented on Nov 25, 2026

    @adithya-s-k
    Collaborator

    #278 is now merged after all 14 checks passed, including real Harbor/container controls. This completes the post-scrub assertion: builds reject retained refs, remotes and Git objects outside the base revision’s history.

    Keeping this tracker open for revision-aware dependency snapshots, fresh validation containers, task-text leakage and published-bundle rebuilds. The new guard does not certify other caches or image layers.

  5. adithya-s-k commented on Nov 30, 2026

    @adithya-s-k
    Collaborator

    Merged #279 for opt-in fresh validation stages, including cleanup-failure fixes and real Docker controls for file/process isolation, shared/fresh F2P/P2P and mutant parity, early rejection and exception cleanup. Enable it with --pipeline-opt fresh_validation_stages=true. Shared mode remains the default.

    #281 corrects the bootstrap guide: resetting source does not reinstall historical dependencies, and forcing a new bootstrap alone does not create a dependency environment for every PR.

    I reviewed #280 and left concrete design revisions around clean toolchain construction, cache provenance/invalidation, offline dependency retention, network enforcement and run-wide spend limits. Keeping this tracker open for that implementation, task-text leakage and published-bundle rebuilds. Fresh stage containers do not certify the dependency snapshot or change existing Hub releases.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions