Repository navigation
Cut ug startup cost: fast --version entry point and lazy heavy imports - #1018
Merged
david-siqi-liu merged 7 commits intoOct 13, 2026
Merged
Conversation
Port the startup-performance patch from universe PR #2741961 onto current main. Keep ordinary CLI dispatch unchanged, defer command-specific dependencies, and verify upgraded commands with --help. Add regression coverage for import boundaries, version lookup and fallback, search-path precedence, and argument compatibility. Co-authored-by: Timothy Tamm <timothy.tamm@databricks.com> Signed-off-by: Harry Yao <harry.yao@databricks.com>
UG reviewThe change introduces a metadata-only version path and defers heavy imports until relevant launches. The metadata scan misses an extracted-egg case that can report the wrong installed version. Major
Automated advisory review of |
david-siqi-liu
approved these changes
Oct 7, 2026
david-siqi-liu
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, nice startup win. One rollout note inline about Isaac's install health check; please land that alongside the Isaac pin bump.
Document --help as the startup-import smoke check and cover intact metadata with missing startup dependencies for both command names and version flags. Signed-off-by: Harry Yao <harry.yao@databricks.com>
This was referenced Oct 8, 2026
Signed-off-by: Harry Yao <harry.yao@databricks.com>
Signed-off-by: Harry Yao <harry.yao@databricks.com>
# Conflicts: # tests/integration/README.md
david-siqi-liu
added a commit
to yaoharry/unity-gateway
that referenced
this pull request
Oct 12, 2026
After this PR, no workflow uses `pull_request_target`. Fork PRs get credentialed CI when an org member (`MEMBER` or `OWNER`) comments a command on the PR. Every comment-triggered run uses the default branch's workflow definitions. Design doc (option B): https://docs.google.com/document/d/1v-6znVBCb8YfGxr12SBd80w3i9n4U0fMEYohyz9Aoyw/edit ## Commands Org members comment these on a PR: - `/integration-test` runs the full Integration workflow with secrets on the PR's current head commit. - `/integration-test <sha>` does the same, but only if the head is still `<sha>` (7 to 40 hex characters). If the fork pushed since, it refuses and replies with the new head. - `/ug-review` runs the UG rubric review. - `/user-journey-check` runs the user-journey gate. For in-repo PRs it also runs automatically, so the command is mostly for forks. Each command posts a commit status and a comment with the run link on the PR. The statuses are `Fork integration` and `User Journey Test Required`. Each new push needs a new command. Anyone else who comments `/integration-test` gets a reply saying only org members can run integration tests. ## Before and after Live integration on fork PRs: - Before: every credentialed job skips, because fork PRs get no secrets on `pull_request`. That covers the E2E CUJs, workspace validation, and the smoke, full, and managed journeys. - After: a member reviews, then comments `/integration-test` or `/integration-test <sha>`. It runs `integration.yml` on the pinned commit with secrets. Live integration on in-repo PRs: - Before: runs automatically. - After: unchanged. `/integration-test` also works as an on-demand rerun, and it never cancels the automatic run. UG review: - Before: adding the `ug-review` label, via `pull_request_target`. - After: a member comments `/ug-review`. It still runs only default-branch code and never executes the PR. User Journey Test Required: - Before: `pull_request_target` on every PR. - After: `pull_request` for in-repo PRs, and `/user-journey-check` for fork PRs. It still reads the PR only through the API. The gate checks the head is unchanged across its diff reads and reports the fork-PR status only on that evaluated commit, so a push during the check never inherits the old verdict. `pull_request_target`: - Before: used by `ug-review.yml` and `user-journey-test-required.yml`. - After: not used anywhere, and a contract test fails if it comes back. No admin event-policy exception is needed before GitHub blocks it on public repos on 2026-11-02. ## Fork safety in `integration.yml` - It takes an optional `ref` input. When the input is empty, existing callers behave exactly as before. - Every checkout pins `ref` and sets `persist-credentials: false`. - setup-uv skips its cache for ref-pinned runs, so fork builds cannot poison it. - Concurrency groups key on the PR number, so runs for different PRs never cancel each other. Concurrency is set per job, so ordinary PR comments never cancel a run. `AGENTS.md` now says workflows must not use `pull_request_target`. The new `fork-integration.yml` call to `integration.yml` carries the same inline `zizmor: ignore[secrets-inherit]` as `ci.yml` (databricks#1089). ## Testing - Contract tests cover the triggers, the member-only gate, and the authorize script, run against a fake `gh`. They also check the non-member reply, the pinned credential-free checkouts, the disabled caches, and the status reports. - `issue_comment` workflows only run from the default branch, so the first live run happens after merge. The plan is to comment `/integration-test` on a fork PR such as databricks#1017 or databricks#1018, and `/ug-review` on any PR. OIDC note: under `issue_comment`, the OIDC subject is the default branch, not a PR ref. If the JFrog trust policy for the Windows installation lane keys on PR refs, that one lane fails on fork runs. The other lanes use secrets, not OIDC. This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
On Windows, sys.path[0] is the launcher file itself (Scripts\ug.exe, Scripts\pytest.exe). os.listdir on it raises NotADirectoryError, which the reader treated as an unhandled entry and returned None, so the fast path never ran on Windows and test_installed_version_matches_importlib_metadata failed once Windows unit tests ran for fork PRs. Skip .exe entries; other files may be zip archives and still fall back. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
|
/integration-test 8739e7a |
|
Fork integration success on 8739e7a: https://github.com/databricks/unity-gateway/actions/runs/38333455051 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ucode.entrypoint:main. A bare--versionor-Vreads installed distribution metadata without importing the full CLI.Other arguments still delegate to
ucode.cli.main, including mixed versionarguments. Existing
ucode.cli:mainandpython -m ucode.cliremain supported.gateway_proxyuntil a relayed Claude or traced Codex launch, andcodex_interposeruntil Codex smart routing, before its app-server is spawned.--helpon the legacy distribution-migrationpath, since the fast version path no longer proves the CLI can import.
distribution-name normalization, search-path precedence, zip/egg fallback,
incomplete metadata, and unchanged argument dispatch.
Command registration, agent
SPECregistration, questionary UI imports,telemetry imports on normal launches, and the skills executor remain eager.
The port keeps the original production patch's intent and adds regression
coverage and coverage documentation.
Startup Timings
Median wall time of 15 interleaved before/after runs after one warm-up, using
CPython 3.12.3 on this Linux VM with frozen dependencies and cached bytecode.
Baseline is
mainat4d8ff8d; after is this port.ug --versionug --helpug claude --helppython -c 'import ucode.cli'Stdout and stderr were byte-identical for every compared invocation. Comparisons
were taken before the port commit, when both installations reported the same
distribution version; post-commit console checks verify the new installed version.
These are local startup measurements, not live agent launch latency.
Verification
just lint: Ruff check, Ruff format check, andty check src/passed.800b75ebase, excludingtests/test_e2e.py: 3,402 passed, six failed, 13 skipped.Unchanged
mainat that base in the same environment:3,373 passed, the same six failures, 13 skipped. JUnit failure sets match
exactly; there are no new failures.
800b75e, lint and all 33 startup/console-script checkspassed again.
PATHto the checkout virtualenv plus
/usr/bin:/bin, avoiding real agentexecution. The six baseline failures depend on Databricks CLI discovery or
authentication that is not available in this isolated environment.
uv.lockis unchanged.Installed-Package Verification
primary entry point
ug/ucode, with MCP 2.2.0/default resolution orMCP 1.28.0 pinned. All 20 selected package/protocol tests passed. Each run
used separate runtime/test virtualenvs, installed real Claude 2.1.280 and
Codex 0.154.0, and verified site-packages provenance.
actionable unconfigured auth, token-only helper stdout, and real local
MCP initialization/tool-list exchanges through both command names.
Below-floor upgrade cases were explicitly excluded; these are not
live inference or backend proxy tests.
uv tool install --reinstalltransition from the800b75ebaseline wheel to the PR wheel regenerated both scripts with the new
entry point. All 28 before/after help, mixed-version-argument, and invalid
argument comparisons matched, accounting only for the installed version.
heavy-module imports for bare version requests, and no deferred heavy
modules on the help path. Median version wall times in the reinstall
probe were 1,258 -> 17 ms (
ug) and 1,414 -> 13 ms (ucode).Live E2E Limits
No authenticated model-inference E2E or live relay/tracing/interposer test has
run. This host has existing OS-managed Claude/Codex settings, so the live runner
refuses it. API-only workspace/config/catalog reads succeeded using the explicitly
selected Isaac profile, but the clean-Arca attempt was blocked by SSH/dbcert
authentication. No agent inference ran. The ambient
Databricks token was not used and developer/OS-managed settings were not changed.
The SDK-backed custom OAuth path has no existing live integration coverage.
It additionally needs a registered client and legitimate browser consent or
cache. The public
ug upgradecommand currently hardcodes upstream, so thepre-merge candidate transition was tested through the documented uv reinstall
path, not a redirected or mocked upgrade source.
Review Follow-Up
faec297documents--helpas the startup-import check and adds four componentcases showing that intact version metadata can still print successfully while
help fails on a missing startup dependency. The focused startup, console-script,
upgrade, and integration-contract selection passed all 92 tests;
just lintpassed again. No dependency or lock-file changes were included.
The companion Isaac fix is
https://github.com/databricks-eng/universe/pull/2760310. It requires a bounded
ucode --helpcheck before accepting a matching installed pin, including Isaac'smetadata shortcut, and after installation. Its unit and installer suites passed,
including real offline uv repair of a deleted dependency at the same pin.
The Isaac wheel pin is unchanged; land the companion before the pin bump that
includes this Gateway change.