Skip to content

fix(ai): skip private submodules and __main__ during package introspection #84

Closed

Description

@dan-petty

Problem Statement

When running devops ai ingest library <package> on packages with executable __main__.py entrypoints (such as typer), _discover_submodules() uses pkgutil.iter_modules() and unconditionally imports every discovered submodule, including <package>.__main__. Importing __main__.py executes CLI entrypoints against current sys.argv, causing subprocess crash (Could not import as Python module: ai).

Steps to Reproduce

devops ai ingest library typer

Root Cause Analysis

_discover_submodules() in src/devops_cli/ai/library/introspector.py does not filter out private submodules or __main__ before calling importlib.import_module(sub_name).

Proposed Solution

Filter out any submodule where the leaf module name starts with _ (including __main__, _vendor, _internal). Add regression test in tests/test_library_vector_tier.py or dedicated introspector test.

Activity

  1. added this to the v0.2.14 milestone on Sep 9, 2026
  2. added
    type/bug
    scope/ai
    priority/p1-high
    on Sep 9, 2026
  3. added a commit that references this issue on Sep 9, 2026
    841fd80
  4. dan-petty commented on Sep 9, 2026

    @dan-petty
    OwnerAuthor

    Resolved in commit 841fd80 on branch release/v0.2.14. Private submodules and __main__ modules are now safely skipped during discovery in _discover_submodules(), preventing CLI execution hazards during package introspection.

  5. added a commit that references this issue on Sep 10, 2026
    ee87b4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions