Files
PaperClipAI/scripts/__tests__
DottaandPaperclip 307eb16c0c perf(ci): avoid duplicate extraction in public install checks (#16460)
## Thinking Path

> - Paperclip manages AI agents for work.
> - Contributors wait for CI before they can deliver changes.
> - After #16434, Build is the longest CI job.
> - Its clean public npm install spends about 90 seconds installing
packed artifacts.
> - npm extracts local archives to read metadata before it installs
them.
> - Serve metadata from those same packed artifacts, then let normal npm
verify and install their bytes once.
> - Preserve the offline lifecycle and runtime checks, and measure the
complete workflow.

## Linked Issues or Issue Description

Refs #16434 and #16429.

**Current behavior:** The Linux Build check installs every staged
package by local tarball path. npm's file fetcher extracts an archive to
obtain its manifest. Installation then extracts it again. In the last
green run, Build took 408 seconds; consumer installation took 89.7
seconds. The full workflow took 8m06s.

**Proposed behavior:** Read manifests directly from the packed archives.
Serve those manifests and their SHA-512-bound tarballs from a temporary
registry on container loopback. Use normal npm installation into the
empty consumer. Other packages still resolve from the public npm
registry.

**Alternatives:** More parallel jobs would add setup and transfer work.
Skipping the install or runtime probes would remove useful coverage.
This change removes duplicate extraction instead. It does not add a
product feature or duplicate a roadmap item.

## What Changed

- Build a registry catalog from the actual tarball manifests and archive
hashes.
- Run the short-lived registry and npm in the existing unprivileged
download container. No host port is exposed.
- Preserve public dependency tarball URLs, archive integrity checks,
disabled initial lifecycle scripts, the offline rebuild, lock checks and
all Codex, Grok and Pi probes.
- Close the registry before offline verification. Keep native ARM and
Mac install qualification unchanged.
- Add real npm parity and failure tests. Record metadata preparation
time in the existing timing receipt.
- Fix an existing policy false positive: the filename
`docker-compose-secrets.test.mjs` is not a workflow credential. Inspect
GitHub expressions and retain rejection of Honeycomb keys, dot/bracket
secret reads and `toJSON(secrets)`.

## Verification

- 31 focused install-contract checks pass on Node 24.21.0. All 16
targeted CI profile-policy tests also pass.
- Real npm file and registry installs produce identical installed files,
bundled dependencies, optional dependencies and executable links. Both
defer lifecycle execution; offline rebuild works after the registry
closes and preserves the lock.
- npm rejects an archive whose gzip header changes while its extracted
payload remains valid. The CLI propagates the failure.
- The permanent real-npm parity test now includes non-catalog
`is-number@7.0.0`. Both paths install it from its official npmjs
tarball, and the test asserts the lock URL. Fetches have a 10-second
bound and no retries. This addresses the first Greptile finding. A
separate live probe also confirmed public provenance.
- The first local run hit the host sandbox's loopback `EPERM`; the same
checks passed with local listener access. An initial corrupted-gzip
negative fixture hit decompression failure before integrity
verification; the final fixture preserves valid gzip and specifically
proves integrity rejection. An old command-shape assertion was updated
for the new entry point without removing its ordering checks.
- The [first CI
run](https://github.com/paperclipai/paperclip/actions/runs/38778371043)
passed all test lanes and Build, but the existing credential-guard false
positive failed policy and both aggregates. Its 7m25s full duration is
**not** counted as a passing performance sample. The guard repair and
public-download regression are on the new head.
- The real Linux install passed all 18 packed packages, the lifecycle
sentinel, offline rebuild, unchanged lock, official Codex payload/lease
checks, Grok missing/present checks and Pi admission. The receipt
confirms `artifactTransport: loopback-registry`. No provider calls ran.
- Compared with the previous green run, consumer install fell **89.72s →
66.29s** (26.1%), including 1.87s to prepare metadata. Build fell **408s
→ 374s**. Both Build hosts were `m7i-flex.xlarge`; these are separate
runs, so registry/cache and upstream changes remain confounders.
- The base advanced since the previous 8m06s run, including runtime and
test changes. Treat that duration as historical context, not an
identical-source control.
- Pre-conflict head `d8f9de1c` [passes all 48 workflow
jobs](https://github.com/paperclipai/paperclip/actions/runs/38779549190),
including both required branch-protection checks. Greptile is **5/5** on
this head; its review thread is resolved. The non-required Superagent
Security Scan is still running.

| Measurement | Previous green run | Final green run | Observed change |
| --- | ---: | ---: | ---: |
| Full CI, workflow creation through final aggregate | 8m06s | **7m35s**
| **31s shorter (6.4%)** |
| Build job execution | 408s | **389s** | **19s shorter** |
| Clean consumer install, including catalog preparation | 89.72s |
**69.69s** | **20.03s less (22.3%)** |

The final catalog preparation took 1.87s and is included in the install
figure. Both Build hosts were `m7i-flex.xlarge`. Build began 42 seconds
after workflow creation instead of 53 seconds in the historical run, so
faster queue/setup admission explains part of the 31-second total.
Upstream code also advanced; these measurements are not a controlled
causal estimate of the complete gain. The two candidate install
measurements (66.29s and 69.69s) support the narrower reduction in
install work. No tests or runtime probes were removed.

- Conflict-resolution head `ea8287b81` [passes all 48 workflow
jobs](https://github.com/paperclipai/paperclip/actions/runs/38789785045),
including both required gates. Greptile re-reviewed this exact head at
5/5, with the sole earlier thread resolved. The conflict was the
independent filename-policy fix; the stronger expression guard is
retained. This run took **8m04s** overall, Build 423s, consumer
installation 80.56s and bundled-server staging 31.17s. This confirms
meaningful run variance: the earlier 7m35s is a sample, not a guaranteed
new wall-clock duration.

- A second independent master update touched the same credential test.
Final head `1c740b73e` resolves that conflict while retaining the same
stronger guard. [All 48 jobs
pass](https://github.com/paperclipai/paperclip/actions/runs/38792983313);
Greptile re-reviewed this exact head at 5/5. This run took **7m32s**
overall, Build **385s**, consumer install **67.62s**. Auto-merge is
enabled but GitHub requires code-owner approval.

## Risks

The initial install now uses registry package specs instead of file
specs. The parity test checks the resulting installed bytes. Full CI
must still exercise real bundled provider graphs and all offline probes.
The temporary consumer lock contains loopback artifact URLs; it is not
exported or reused for another installation. Native release consumers
retain their existing artifact install path. Queue, host and cache
variance limit attribution from separate workflow runs.

## 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
- [x] All Paperclip CI gates are green (48 jobs and both required gates
on conflict-resolution head)
- [x] Greptile is 5/5 with no open P2s, recommendations or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

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