Repository navigation
perf(cli): eliminate startup latency, scope distribution checks, and resolve doctor deepfake_guard load - #451
Merged
rosspeili merged 1 commit intoOct 22, 2026
Conversation
…ctor env handling - Lazily initialize Draft7Validator in manifest_schema to avoid 4.8s Lark/RFC 3987 compilation on startup - Optimize iter_skillware_distributions with targeted sys.path globbing to prevent linear site-packages metadata scans - Lazily load requests in cli.py via module __getattr__ to defer urllib3 and certifi import overhead - Cache _package_version_str() to avoid redundant distribution lookups during interactive session - Rename deepfake_guard/guard.py to deepfake_engine.py to prevent sys.modules collisions with deceptive_ui_guard - Distinguish fatal doctor errors (SCHEMA, DEPS, LOAD) from missing runtime secrets (ENVS) to exit 0 on clean code - Update CLI usage docs with missing commits and document doctor ENVS notice behavior
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.
manifest_schema.pyto eliminate 4.8s Lark/RFC 3987 regex compilation on startup.iter_skillware_distributions()inversion_policy.pyto targetedsys.pathglobbing, avoiding linear disk scans across unrelated site-packages.requestsimport incli.pyvia module-level__getattr__to eliminate urllib3/certifi startup overhead while preserving test mock compatibility.skills/security/deepfake_guard/guard.pytodeepfake_engine.pyto resolvesys.modules["guard"]namespace collision withdeceptive_ui_guard.SCHEMA,DEPS,LOAD) from missing runtime secrets (ENVS), printing an informational advisory and exiting0when code is intact.docs/usage/cli.mdhistory table with missing release commits (f522b17,831856d) and document doctor exit code behavior.Description
Resolves CLI cold-start latency (~9.5s down to <1s), eliminates unnecessary full-environment package scans, prevents dynamic skill import namespace collisions in
doctor, and cleans up doctor exit code handling for unconfigured environment keys.Changes Mapped to Files and Tests
CLI Startup Latency (
skillware/core/manifest_schema.py,skillware/cli.py):Draft7Validatorinstantiation triggered Lark RFC 3987 URI grammar compilation on every startup (4.8s). Moved behind lazy getter_get_manifest_validator()with backward-compatible__getattr__.import requestsincli.pydeferred via module__getattr__.tests/test_cli.pyandtests/test_manifest_schema.py.Targeted Install Conflict Resolution (
skillware/version_policy.py):emit_install_conflict_advisoryandemit_upgrade_advisory) ran sequential un-cachedimportlib.metadata.distributions()passes over all installed packages on the interpreter (~1.5s per pass).iter_skillware_distributions()to targeted filesystem globbing matchingskillware*.dist-infoandskillware*.egg-infodirectly acrosssys.path.tests/test_version_policy.py(21/21 passed in 1.1s, down from 5.6s).security/deepfake_guardDynamic Load Collision (skills/security/deepfake_guard/):skillware doctorcollided onsys.modules["guard"]withsecurity/deceptive_ui_guard.skills/security/deepfake_guard/guard.pytodeepfake_engine.pyand updatedskill.py.skills/security/deepfake_guard/test_skill.py(17/17 passed) and sequential diagnosis intests/test_cli.py.Doctor Missing
ENVSError Handling (skillware/cli.py,tests/test_cli.py):failures += 1andexit code 1in doctor.SCHEMA,DEPS,LOAD) from missing runtime secrets (ENVS). Unset keys print an informational notice (Notice: N skill(s) declare required environment variables not set in this environment) and return exit code0.tests/test_cli.py::test_cmd_doctor_reports_missing_env_vars.CLI Documentation & History (
docs/usage/cli.md):f522b17(v0.5.9 release) and831856dto the CLI history table.doctorexit code behavior forENVS.Type of Change
skillware/cli.py,docs/usage/cli.mdskills/Checklist (all PRs)
Refs #433, Refs #440)python -m black --check .,flake8, andpython scripts/sync_extras.py --checkpass locally (206 files clean)pytest skills/andpytest tests/pass locally (100% pass rate)CHANGELOG.mdupdated under[Unreleased]pytest tests/test_registry_docs.py(20/20 passed)pytest tests/test_spdx_headers.py(2/2 passed)New or updated skill
Bundle and metadata
skills/security/deepfake_guard/manifest.yaml:name,version,description,parameters,constitution, realissuer,requirements: [numpy, pillow]Effect, Directive, Assurance
skill.py(Effect; no ad-hoc LLM-generated execution paths)instructions.md(Directive) explains when and how to use the skillcard.json(Presentation) issuer matches manifesttest_skill.py(Assurance) covers execution and schema expectations (17/17 passed)SkillLoader.load_skill("security/deepfake_guard")succeeds cleanly in isolation and sequentially aftersecurity/deceptive_ui_guardRelated Issues
Refs #433, Refs #440