Files
PaperClipAI/scripts
DottaandPaperclip 676d3ec8d4 perf(ci): reuse package downloads and overlap runtime checks (#16474)
## Thinking Path

> - Paperclip contributors wait for CI before delivering changes.
> - Build still finishes last after #16460.
> - CI already downloads the public npm graph while the build runs.
> - Bundled-package preparation ignores that cache and downloads the
same archives again.
> - Reuse the existing cache and overlap independent runtime checks
while preserving fresh installs, integrity, offline lifecycle and
admission verification.
> - Measure staging and the full workflow separately.

## Linked Issues or Issue Description

Refs #16460 and #16434. This is a focused follow-up to merged #16460,
now based directly on master.

**Current behavior:**
The Build workflow warms `PAPERCLIP_PUBLIC_INSTALL_NPM_CACHE`, but
`startBundledInstalls` inherits the host's default npm cache. Server
staging took 31.17 seconds in the latest passing run, before packing and
the clean consumer install.

**Proposed behavior:**
Pass the verifier environment, including the explicitly configured warm
cache, to the three existing staging children. Without an explicit
shared cache, keep the usual producer npm configuration.

**Alternatives considered:**
Copying an installed dependency tree would bypass normal fresh
installation. Adding jobs would add setup cost. This change reuses only
npm's integrity-checked download cache. It does not remove coverage or
change product behavior and does not overlap a roadmap feature. Open PR
title search found no equivalent cache wiring change.

## What Changed

- Initialize the existing consumer cache before package staging and
expose it to producer npm only when explicitly configured.
- Pass that environment to the existing bundled-install children.
- Extend the child orchestration check to verify cache propagation and
document the cache boundary.
- Start Pi setup after the offline lifecycle, in its own download
sandbox, while Codex and Grok probes run in separate offline sandboxes.
Join successful Pi setup before lock verification and Pi admission. Name
and clean up only the verifier-owned setup container.

## Verification

- 33 focused public-install, closure and child-orchestration tests pass
on Node 24.21.0.
- A real server dependency staging experiment used
`prepare-bundled-package.mjs`, its actual manifests, provider overrides
and release patches. Built application payloads were omitted from this
dependency-only measurement.
- Cold cache: **16.139s**. After the actual CI warm-up script:
**6.980s**. A fully warm producer cache took **6.127s**. These are local
sequential measurements, not a CI wall-clock claim; filesystem warmth
and registry timing vary.
- All **28,329 files/links**, including both lockfiles, were
byte-identical between the cold output and the actual-workflow-warm
output.
- The warm-up itself took 49.631s; CI already runs it during Rust
restore/build. This change adds no warm-up operation.
- First follow-up run [passed all 48
jobs](https://github.com/paperclipai/paperclip/actions/runs/38791277425),
and Greptile gave the cache-only head 5/5. Server staging fell **31.172s
→ 17.565s** and total staging **70.169s → 54.869s**. But complete CI was
**8m20s**, slower than the parent's 8m04s; longer Codex/Pi probe times
outweighed that saving. This is not a full-run speed improvement claim.
- The next revision overlaps the independent probes instead of
serializing Pi setup behind them. All 46 focused sandbox, staging,
closure and process-supervision tests pass, including failed background
children, parent exit and cancellation. Pre-retarget head `590873a44`
passes all 48 jobs and Greptile 5/5 with no review findings. After
#16460 merged, head `fe4f8d38e` incorporates master and retargets this
PR directly to master. Its diff remains only four
optimization/documentation/test files; 46 focused checks pass again.
Fresh full CI and review are pending. The unchanged parent
conflict-resolution run passed all 48 jobs in 8m04s:
https://github.com/paperclipai/paperclip/actions/runs/38789785045.

Final paired runs against the same updated master, both on
`m7i-flex.xlarge`:

| Measurement | Parent #16460 | This PR |
| --- | ---: | ---: |
| Bundled server staging | 22.220s | 14.202s |
| All package staging | 61.277s | 48.304s |
| Clean consumer install | 67.617s | 73.490s |
| Pi setup remaining wait | 25.428s (serial setup) | 20.719s |
| Build job | 385s | 368s |
| Build start after workflow creation | 23s | 136s |
| Entire workflow, including admission and aggregates | 452s (7m32s) |
552s (9m12s) |

[Parent
run](https://github.com/paperclipai/paperclip/actions/runs/38792983313),
[final
run](https://github.com/paperclipai/paperclip/actions/runs/38792986392).

Build execution improved by **17s (4.4%)** in this pair. The total
workflow did **not** improve: it waited 113 seconds longer to start
Build, and other lanes/aggregates also contribute. The overlapping setup
ran for 25.667s while Codex/Grok took 4.946s, leaving 20.719s to wait.
Actual installed Codex, Grok and Pi checks all passed with zero provider
calls. These are individual samples with filesystem/network/CPU
variance, not a claimed steady-state average. The earlier slower
cache-only run is retained above. No tests were removed and no jobs were
added.

## Risks

Shared-cache contention can reduce the benefit if warm-up is still
running. npm handles concurrent content-addressed cache writers and
checks integrity; misses still download normally. Two runtime containers
can now overlap and contend for host resources; the full CI run measures
that tradeoff. They retain separate network policies and per-container
bounds. Pi writes only its provider assets and a private receipt; the
other probes inspect Codex/Grok. No installed tree, lock, test result or
build output is reused. The consumer still starts empty and performs the
full lifecycle and runtime checks. Normal unconfigured producer cache
behavior is preserved.

## Model Used

OpenAI GPT-6 through Codex, with repository inspection, execution and
GitHub tools. The serving model suffix and context capacity are not
exposed to this session.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either linked existing issues or described the issue in
this PR
- [x] I have not referenced internal or instance-local Paperclip issues
or links
- [x] My branch name describes the change and contains no private ticket
identifier
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation
- [x] I have considered and documented the risks
- [ ] All Paperclip CI gates are green (prior head passed; rerunning
after master merge)
- [ ] Greptile is 5/5 with no open P2s, recommendations or follow-ups
(prior head 5/5; current head pending)
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-15 15:16:52 -05:00
..