Skip to content

perf(kits): reuse pinned fetches within one invocation - #631

Merged
wz-gsa merged 1 commit into
mainfrom
perf/586-invocation-kit-fetch
Oct 26, 2026
Merged

wz-gsa merged 1 commit into
mainfrom
perf/586-invocation-kit-fetch

Conversation

@mogul

@mogul mogul commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the delegated within-invocation fetch-reuse increment in #586. A private invocation root shares one verified source per URL + full lowercase 40-character commit ID; callers receive independent kit directories materialized from committed objects. Symbolic and abbreviated refs keep per-call fetch behavior.

The foreground ACQ process retains its PID, stdin, TTY, signal behavior, and backend exec semantics. A private guardian cleans sources when EXIT handlers are replaced or the process execs; normal exits clean synchronously. Fallback cleanup normally occurs within the one-second polling interval. Nested invocations receive fresh roots. No persistent cache or new dependency is introduced.

Anonymous fetch, authenticated retry, credential-URL rejection, subdirectory validation, and suppressed Git diagnostics remain in place. Commit identity is checked before publishing the invocation-local verified marker. Materialization preserves executable bits, symlinks, tracked index/marker filenames, and export-ignore payloads; consumer edits do not modify the shared source.

Evidence and limitations

  • Supplied original host trace: eight remote kit fetches totaled 11.81 seconds, individually 1.28–1.84 seconds. This is prior host evidence, not a measurement made by this PR.
  • Measured offline with real Git repositories: eight same-pin materializations require one fetch; a ninth read of another kit subdirectory also uses that source. URL and revision changes fetch separately.
  • No live wall-clock saving is claimed. Host MSB create/reattach timing and authenticated transport remain unverified. Track the post-PR sandbox-capable-host run under feat(acq): investigate routinely fast new sandbox launches #586: compare the same pinned configuration, count fetches, and retain verification overhead in timing.
  • Bash 3.2/macOS/BSD runtime validation remains for CI/host verification. Local execution used Linux Bash 5.3.
  • Reuse targets the existing sequential ACQ fetch flow; this does not introduce parallel fetch coordination.

Plan and architecture

Changes: acq lifecycle ownership; acq.backends/kit-translate.sh reuse/materialization; offline transport fixture adaptation; focused real-Git and lifecycle tests. This is an implementation optimization under ADR-0011 and ADR-0030, with no new composition or distribution architecture.

Verification transcript

  • PASS: ./scripts/test-acq-bats test/bats/102-kit-fetch-reuse.bats test/bats/103-kit-fetch-lifecycle.bats test/bats/100-kit-translate.bats test/bats/50-kit-list-completeness.bats test/bats/140-opencode-migration-gate.bats — 76 tests passed, including 21 Python lifecycle scenarios covering success/failure, trap replacement, exec, signals, spinner, stdin, PTY, nesting, and owner SIGKILL.
  • PASS after final marker/BSD-sed hardening: ./scripts/test-acq-bats test/bats/102-kit-fetch-reuse.bats test/bats/103-kit-fetch-lifecycle.bats — 10 tests passed, including the 21 lifecycle scenarios.
  • PASS: shellcheck --severity=warning acq acq.backends/kit-translate.sh scripts/test-acq-lib.sh test/bats/102-kit-fetch-reuse.bats test/bats/103-kit-fetch-lifecycle.bats.
  • PASS: separate bash -n checks for acq, kit-translate.sh, and test-acq-lib.sh; git diff --check and staged diff whitespace check.
  • Security scan: gitleaks unavailable locally; used the code-review skill fallback, searching tracked diff and new tests for secrets/token/password/credential/API-key/private-key patterns and reviewing matches. Only explanatory text and synthetic credential-rejection fixtures were found. No dependency changes; ShellCheck supplied shell static analysis.
  • Full suite attempt timed out at 240 seconds, with no complete verdict. User then directed focused testing only; it was not repeated. CI remains authoritative for broader checks.
  • Adversarial review found lifecycle and subdirectory blockers in the initial version. They were fixed, focused tests added, and an independent re-review plus final-delta review found no blockers.

Security impact and rollback

Trust boundaries and secret mechanisms remain unchanged. Only verified committed objects are reused within the invocation; no raw ref is added to debug output. Roll back by reverting this commit to restore per-call fetching.

AI assistance

AI-assisted implementation, tests, and review by OpenCode (gpt-6-astra), including independent adversarial sub-agent review. Human review is pending and required before merge. No merge requested.

Materialize independent kit directories from verified Git objects and clean\ninvocation-owned sources through a foreground-safe lifecycle guardian.\n\nRefs: #586\n\nCo-authored-by: OpenCode [gpt-6-astra] <[email protected]>
@mogul
mogul requested a review from a team as a code owner October 24, 2026 19:10
@mogul

mogul commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Host measurement update

Human-run host measurement completed from an isolated checkout of this PR at be830b95f1b0bfacead75f339bab51e261626a4c, using a normal MSB acq run opencode flow with the configured kit set.

Observed result

  • Exactly one fetch: remote kit -> ... debug event occurred.
  • The same pinned Patterns revision subsequently supplied provider facts, built-in agent selection, configured extra-kit resolution, and all applied kit directories.
  • Sandbox creation, provisioning, USAi validation, and Paseo web UI readiness completed successfully.
  • The first fetch began at 12:39:00; provisioning reported all kits applied at 12:39:38. That 38-second interval includes picker interaction, provider validation, create/boot, file staging, kit startup, and other work. It is not a fetch-only or comparable end-to-end timing claim.

Comparison boundary

The prior trace used to motivate this PR observed eight remote fetches totaling 11.81 seconds. That run used a different Quickstart/Patterns revision and host configuration state. This PR run proves the fetch-count reduction from eight to one in the normal flow; it does not independently prove an exact wall-clock saving. The one observed remote fetch took roughly two wall-clock seconds based on terminal timestamps, but that is not a controlled comparison.

No credential values were displayed or recorded. AI-assisted measurement analysis by OpenCode; the human executed the host command.

@wz-gsa wz-gsa 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.

Adversarial fixed-head static review of be830b95f1b0bfacead75f339bab51e261626a4c: reuse is limited to full immutable commit refs within an invocation-local private root; the fetched HEAD is checked before marking it verified, and consumer payloads are materialized from committed objects into independent directories. I inspected the lifecycle guardian, signal/exec cleanup, credential-URL rejection, fallback fetch path, and the real-Git/PTY/signal offline fixtures. No blocker found. All three required current-head checks pass. This is not a claim of measured live MSB speedup or authenticated-transport verification; those remain tracked under #586. No reviewed-repository code was executed on the host. AI-assisted static review (OpenCode); approval does not authorize merge.

@wz-gsa
wz-gsa added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit b433a61 Oct 26, 2026
5 checks passed
@wz-gsa
wz-gsa deleted the perf/586-invocation-kit-fetch branch October 26, 2026 21:59
mogul pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[4.2.0](v4.1.1...v4.2.0)
(2026-11-05)


### Features

* **acq:** project provider inputs read-only
([#608](#608))
([bd11c77](bd11c77))
* **sbx:** trust host state for built-in kit heal; add MSB forged-marker
and legacy-sandbox coverage
([#637](#637))
([ef24965](ef24965))
* **scripts:** add summarize-bats-timing for bats TAP timings
([#652](#652))
([5bf9398](5bf9398))


### Bug Fixes

* **agents:** move the default OpenCode image to devenv-shell 2.1.0
([#668](#668))
([dbd8a76](dbd8a76))
* **common:** canonicalize macOS /var,/tmp,/etc aliases before
O_NOFOLLOW traversal
([#622](#622))
([1135fcc](1135fcc))
* **install:** package provider validator runtime
([#619](#619))
([5192fa1](5192fa1))
* **msb:** distinguish denied probe writes from writable mounts
([#670](#670))
([049931c](049931c))
* **msb:** strip CR from jq output in acq ports (Windows)
([#663](#663))
([7ad6e56](7ad6e56))
* **release:** use supported macOS wheelhouse runners
([#674](#674))
([9dbc9aa](9dbc9aa))


### Performance Improvements

* **acq:** stop the kit-fetch guardian tick from delaying exit
([#664](#664))
([fe686ea](fe686ea))
* **kits:** reuse pinned fetches within one invocation
([#631](#631))
([b433a61](b433a61))
* **msb:** reduce foreground node kit invocation latency
([#616](#616))
([ec73abd](ec73abd))
* **test:** eliminate redundant bats fetches and waits
([#621](#621))
([dda5fe1](dda5fe1))
* **test:** shorten hostport and cli-kits test tail
([#654](#654))
([a3acc7b](a3acc7b))
* **test:** shorten port fixtures and parallelize shellcheck
([#624](#624))
([8eb3ff8](8eb3ff8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants