Repository navigation
feat: skip heavy cli imports for bare --version - #8773
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
1 similar comment
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Verified against the base: argparse's version string at Design-Verdict: CONCERNS Merging this alone opens the acknowledged gap: three CI smoke gates stop proving the import chain until a maintainer lands the workflow probes. WatchThe fast-path answers before Suggestions
[DESIGN-REVIEWED] c211945 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- src/kiro_crew/_bootstrap.py:46 -- " |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All contract claims verified against the base tree: output parity holds ( First-Principles-Verdict: CONCERNS Merging this opens an undeclared-dependency blind spot in three CI gates the fork cannot patch; a maintainer must act in the same window. Not justified as shipped
What this change shipsInventory (8 items) — 7 justifiedIntent: make bare
Watch
[FIRST-PRINCIPLES-REVIEWED] c211945 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
c3d5ddc to
821b646
Compare
|
Thanks for the reviews — v2 (
|
821b646 to
425410f
Compare
|
v3 ( Also fixed the |
425410f to
03041f2
Compare
|
v4 (
|
c5c9c30 to
9448950
Compare
|
Happy with the co-authored rebase and the extensions (Dockerfile probe, workflow-lane documentation) — no |
Bare `kirocrew --version` needs none of the ~250ms module-scope imports it currently pays for (apps.builtins, cli_doctor, history chain). Answer it in _bootstrap (console script) and __main__ (python -m, covering the desktop launchers) with output identical to argparse, and restore the self-containment gates that read the flag as import-chain proof with an explicit `import kiro_crew.cli` probe: both `packaging/build-desktop.sh` gates and the wheel-install gate in `docker/Dockerfile`. Only the bare form fast-paths, so `artifact show --version N` keeps its meaning. The pip-install lanes under `.github/workflows/` still read bare `--version` as chain proof; `docs/ci/ci-and-reviews.md` records what that smoke does and does not cover, since a fork PR cannot edit them. Co-authored-by: iamwhatever <12429733+iamwhatever@users.noreply.github.com>
9448950 to
c211945
Compare
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
self-added: yes — the two guards this PR adds are two of the three copies. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
self-added: no — the sites pre-exist; this PR changes what the flag they call proves. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
self-added: no — this PR changes the meaning of pre-existing gate lines. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
self-added: no — the sites and their wording pre-exist this PR. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
self-added: yes — the diff restates the clause on an added line. |
|
Thanks for carrying this over the line — the rebase, the Dockerfile probe, and the recorded workflow gap all look right, and both remaining CONCERNS converge on the same maintainer-only item (the three workflow smokes), which I agree should land via your side since a fork cannot edit or validate One offer on the Design suggestion (argparse-parity pin): happy to push this to the branch, or leave it with you — verified the mechanism locally ( def test_verbose_version_reaches_argparse(self, tmp_path: Path) -> None:
"""A non-bare flag combo must reach argparse and print the same line."""
res = _run_probe(
"import sys; sys.argv = ["kirocrew", "--verbose", "--version"];"
" from kiro_crew.cli import main; main()",
tmp_path,
)
assert res.returncode == 0
assert res.stdout == _EXPECTED_VERSION_LINENote the snippet above needs its inner quotes fixed (I had to flatten quoting for this comment) — the real form is |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Ready for maintainer review — @Arin016 — thanks for the patience on this one. Your v6 was already green but the checks had gone stale and the branch was ~230 commits behind, so I rebased it onto current What changed since v6Your
Worth noting for anyone reading the earlier rounds: GPT's suggested fix for that finding was to delete the Dockerfile hunk. I kept the hunk and fixed the prose instead, because removing it would have re-opened the Design lane's own round-1 request for that probe and deleted real coverage. One decision needed from a maintainerThree sites still read bare
The fix is one line each — Pick whichever you prefer:
Option 1 or 2 is preferable: an undeclared runtime dependency (imported in code, absent from Deferred, tracked
Both carry the VerificationLocal gates run green against base Still one commit on |
|
Thanks for the thorough disposition — the verification list and the two tracked issues (#10557, #10558) look right, and I am fine with both deferrals. On the |
|
Not approving for now: the recorded dispositions still carry three |
Problem / Motivation
Bare
kirocrew --versionpays ~250ms of module-scope imports it never uses (apps.builtins,cli_doctor->aiohttp, thehistory->sandbox/platformchain). Measured on a checkout at upstreammain:python -m kiro_crew --versiontakes ~255ms while doing no work beyond printing a version string.Why it matters
--versionis the cheapest health/probe signal a CLI has: setup flows, installers, and scripts shell out to<tool> --versionto detect executables. Paying a quarter-second of pure import overhead on every probe is waste, and every future top-level import added tocli.pywould make--versionslower still with no upper bound. The fast-path caps it near interpreter-startup cost permanently. If left undone nothing breaks, but the flag stays pointlessly slow.What changed (motivation -> approach -> change)
--versionwithout importingkiro_crew.cliheavy module scope.kirocrew <version>and exiting 0 — chosen over deferring more ofcli.pytop-level imports into functions, which would be a larger, riskier refactor for the same saving on this flag. Only the exact single-arg form fast-paths, becauseartifact show --version Nreuses the flag name for an artifact-version int and must keep argparse semantics. Deliberately nocli.pymodule-scope guard: every desktop/frozen launcher routes throughpython -m kiro_crew(packaging/build-desktop.sh,website/electron/find-bin.js), and the only non-test importer ofkiro_crew.cliis the already-guarded_bootstrap._import_cli— a third guard would protect zero invocations while adding an import-time exit to the most-imported module.src/kiro_crew/_bootstrap.py(skips thecliimport on the console-script path), guard insrc/kiro_crew/__main__.py(python -mpath, which also covers the desktop launchers), spec paragraph indocs/system-specs/modules/cli.mddeclaring--versionthe one pre-dispatch fast-path (including the skipped editable-install self-heal), and newtest/test_cli_version_fastpath.py(3 tests, see Tests).cli.pyitself is untouched; argparse output for every other argv shape is unchanged.Gate coverage: what the fast-path costs, and where it is paid back
Nine sites shell out to
--versionas an install smoke. Because bare--versionnow answers beforekiro_crew.cliis imported, those sites no longer prove the import chain resolves — so an undeclared runtime dependency (imported in code, absent fromsetup.cfg, therefore invisible to pip) could pass a smoke it used to fail. Each site is accounted for:packaging/build-desktop.sh:509(Linux)import kiro_crew.cliprobe addedpackaging/build-desktop.sh:665(Windows)import kiro_crew.cliprobe addeddocker/Dockerfile:137(wheel install in image build)import kiro_crew.cliprobe added.github/workflows/docker-smoke.yml:157test/e2e/scenarios/test_wheel_install.py:132doctorrun.github/workflows/build.yml:68(build-wheel smoke).github/workflows/build.yml:193(Windows backend smoke).github/workflows/nightly.yml:187.github/workflows/ota-test.yml:89|| true)docs/build/desktop-app.mdanddocs/ci/ci-and-reviews.mdare updated so no doc still describes bare--versionas import-chain proof.The four remaining gaps are not deferred by choice. The one-liner that closes each is
python -c "import kiro_crew.cli"appended after the--versionsmoke — the same probe already added to the three sites above. Every one lives under.github/workflows/, which a fork PR cannot edit:fork-workflow-guard.ymlblocks the change until a maintainer appliesallow-fork-workflow-change, and it strips that label again on the next push. So this needs a maintainer decision, either:allow-fork-workflow-changeand I add the three probes to this PR, orkirocrew doctorrun in the wheel-install test).Option 1 or 2 is preferable: the gap is open the moment this ships.
Tests
test/test_cli_version_fastpath.py(subprocess-based, liketest_cli_lazy_imports.py): exact-output parity (kirocrew <version>, exit 0) on the-mand_bootstrapentries, plustest_cli_import_never_exitspinning that importingcliunder a--version-shaped argv simply imports. Allsubprocess.runcalls pinencoding="utf-8"per the subprocess-encoding gate.test_cli_lazy_imports.py+test_cli_version_fastpath.py46 passed. Full suite left to CI.isort,flake8,mypy(1470 files),blackgate,docs-lint,check_comment_history.py,check_brand_name.py,check_feature_map.py,check_changelog_history.py,check_harness_parity.py,check_focus_cue.py,check_testpaths_coverage.py,check_subprocess_encoding.py, andbash -n packaging/build-desktop.sh— all pass.Manual verification
python -m kiro_crew --versionprintskirocrew <version>: ~255ms before -> ~68ms after (3 runs); console-script path (_bootstrap.main,argv=[kirocrew, --version]): ~67ms.artifact show --helpstill offers--version VERSION(int flag); top-level--helpand the bare-run banner are unchanged.bash -npasses on the editedpackaging/build-desktop.sh; new probe lines mirror the adjacent gate lines flag-for-flag (PYTHONNOUSERSITE=1,-son Windows).__version__resolves through the sameBUILD_VERSION-aware resolver inkiro_crew/__init__, so the fast-path keeps distribution-stamp parity.Related Issues
no linked issue: enhancement with no tracking issue.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement