Skip to content

feat(ai): dynamic package introspection and multi-source docs ingestion engine - #82

Merged
dan-petty merged 3 commits into
release/v0.2.14from
feat/library-ingestion-engine
Sep 9, 2026
Merged

dan-petty merged 3 commits into
release/v0.2.14from
feat/library-ingestion-engine

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

This PR implements Phase 50.1 (Dynamic Package Introspection & Type Stub Parser) and Phase 50.2 (Multi-Source Documentation & Standards Ingester) for the Multilingual Code Intelligence engine in milestone v0.2.14.

Key Enhancements

  • Dynamic Package Introspector (src/devops_cli/ai/library/introspector.py):
    • Runtime introspection of installed Python distribution packages bounded by --max-depth.
    • Standardized signature extraction (extract_function_signature, extract_class_signature) extracting typed parameters, kinds, defaults, return annotations, docstrings, base classes, methods, and property descriptors.
    • Generates fast lookup symbols_index mapping qualified symbol identifiers to kind (function, class, method, constant).
    • JSON serialization/deserialization via save_to_dir and load_from_dir.
  • Multi-Source Documentation Ingester (src/devops_cli/ai/library/docs_ingester.py):
    • Recursive local file crawler for .md, .markdown, .rst, and .txt documentation.
    • Heading-aware hierarchy chunker generating structured DocChunk objects with breadcrumb headings and estimated token counts.
    • Remote documentation crawler extracting clean markdown from HTML (filtering out navigation, headers, footers, scripts).
    • Strict SSRF egress protection via validate_service_url(allow=False) blocking private, loopback, link-local, and metadata destinations.
  • Contract Models & Exceptions (models/library.py, exceptions/ai.py):
    • Strongly typed Pydantic v2 data models: ParameterSignature, FunctionSignature, ClassSignature, ModuleContract, LibraryContract, DocChunk, IngestDocResult.
    • Domain exceptions LibraryIngestionError, LibraryNotFoundError, DocsIngestionError inheriting from DevOpsCLIError.
  • CLI Subcommands (commands/ai_ingest.py, commands/ai.py):
    • devops ai ingest library <package_name> [--max-depth <int>] [--output-dir <path>] [--format json|table]
    • devops ai ingest docs <source> [--output-dir <path>] [--format json|table]
    • Canonical alias ai_app = app and centralized help strings in src/devops_cli/lang/en/help.py.

Verification

  • TDD Test Suites: 20 comprehensive unit tests across tests/test_library_ingest.py and tests/test_docs_ingester.py (100% pass rate).
  • Code Coverage: 95.39% coverage on ai/library, 100% on commands/ai_ingest.py.
  • Architectural Invariants: Complexity $\le 10$ and nesting $\le 5$ verified via devops scan complexity and tests/test_architectural_invariants.py.
  • CI Quality Gates: 10/10 quality gates passed cleanly via devops ci.

Closes #75
Closes #76

Copilot AI lite review requested due to automatic review settings September 9, 2026 17:00
@dan-petty dan-petty added this to the v0.2.14 milestone Sep 9, 2026
@dan-petty dan-petty added type/feature Type feature: a new function scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Sep 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

src/devops_cli/ai/library/introspector.py contains invalid exception syntax that will raise SyntaxError at import time, blocking the feature from running.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a new AI “ingest” subsystem to generate deterministic library API contracts via runtime introspection and to ingest local/remote documentation into chunked knowledge files, wiring both into the devops ai ingest CLI and updating docs/tests accordingly.

Changes:

  • Added PackageIntrospector + signature extractors and DocsIngester for local/remote docs ingestion with SSRF validation.
  • Introduced new Pydantic v2 models for library contracts and doc chunks, plus new AI ingestion exceptions.
  • Added new devops ai ingest (library|docs) CLI commands and synchronized README/CLI reference/docs + tests.
File summaries
File Description
tests/test_library_ingest.py New unit tests covering signature extraction, serialization round-trip, and CLI behavior for library ingestion.
tests/test_docs_ingester.py New unit tests covering local/remote docs ingestion, chunking, SSRF blocking, and CLI behavior.
src/devops_cli/models/library.py New Pydantic models for library contracts and ingested documentation chunk metadata/results.
src/devops_cli/lang/en/help.py Added help strings for new ai ingest commands/options.
src/devops_cli/exceptions/ai.py Added LibraryIngestionError, LibraryNotFoundError, and DocsIngestionError exception types.
src/devops_cli/exceptions/init.py Re-exported the new AI ingestion exceptions.
src/devops_cli/commands/ai.py Wired the new ingest Typer app into devops ai and added ai_app alias.
src/devops_cli/commands/ai_ingest.py New CLI implementation for devops ai ingest library and devops ai ingest docs.
src/devops_cli/ai/library/introspector.py New package introspection + symbol/signature extraction + contract persistence.
src/devops_cli/ai/library/docs_ingester.py New docs ingestion + markdown chunking + HTML extraction + SSRF guardrail integration.
src/devops_cli/ai/library/init.py New package exports for the library ingestion subsystem.
README.md Added devops ai ingest to the command matrix.
docs/LOG.md Logged the new Phase 50.1/50.2 milestone work.
docs/ERRORS.md Updated error catalog table (currently with issues in the new rows).
docs/commands/ai.md Added documentation for the new devops ai ingest command group.
docs/CLI_REFERENCE.md Added CLI reference entries for the new devops ai ingest commands/options.
docs/agent/task.md Updated agent task tracking to mark phases complete and track PR creation/next phases.
Review details

Suppressed comments (1)

docs/ERRORS.md:55

  • These rows introduce duplicate entries for the same error code (DEVOPS_CLI_ERROR), which doesn’t add actionable information and can confuse consumers of the error-code catalog. Either introduce dedicated error codes in code (preferred) or don’t list per-exception rows here until unique codes exist.
| `LLM_INFERENCE_ERROR` | `10` | Ai | Base exception for LLM provider invocation failures. |
| `DEVOPS_CLI_ERROR` | `1` | Ai | Base exception for package introspection and library ingestion errors. |
| `DEVOPS_CLI_ERROR` | `1` | Ai | Raised when target package cannot be imported or found in the environment. |
  • Files reviewed: 17/17 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/devops_cli/exceptions/ai.py Resolved
Comment thread docs/ERRORS.md Resolved
@dan-petty
dan-petty merged commit e77dc7b into release/v0.2.14 Sep 9, 2026
4 checks passed
@dan-petty
dan-petty deleted the feat/library-ingestion-engine branch September 9, 2026 17:23
@dan-petty dan-petty mentioned this pull request Sep 10, 2026
dan-petty added a commit that referenced this pull request Sep 10, 2026
* chore(release): initialize release/v0.2.14 branch and configure Dependabot

* fix(docs): scrub private configuration values, internal hostnames, and homelab references

* feat(ai): dynamic package introspection and multi-source docs ingestion engine (#82)

* feat(ai): add dynamic package introspection and multi-source docs ingestion engine

* fix(ai): enforce fully-qualified symbol index and dedicated error codes for library ingestion

* fix(ai): filter built-in descriptors from class method extraction

* feat(rag): dedicated library vector tier and valkey symbol cache store (#83)

* feat(rag): dedicated library vector tier, valkey symbol cache, and routine observability audit

* docs(roadmap): define v0.2.16 and v0.2.17 milestones for sandbox application lifecycle

* feat(gh): integrate github pages, issues, projects, and views with fastmcp and agent instructions

* docs(roadmap): enrich task context, technical specifications, and reprioritize milestones

* docs: compact v0.1 release documentation and codify automated compaction policy

* fix(rag): address code review feedback on library store and CLI client wiring

* feat(gh): enhance project sync with rest resolution, rate-limit guards, and issue reconciliation

* refactor(security): consolidate in-place security checks into canonical submodules

* feat(gh): add pr review threads management and project custom fields reconciler

* feat(ai): add ast prompt grounding and fastmcp library intelligence tools

- Filter out private submodules and __main__ in package introspection to eliminate CLI execution hazard (Fixes #84).
- Expose FastMCP library intelligence tools (ai_ingest_library, ai_query_library, ai_inspect_symbol) and resource://libraries/indexed dynamic resource (Closes #80).
- Implement import-driven AST prompt grounding and API contract injection in review pipeline (Closes #78).
- Add comprehensive contract, regression, and injection unit tests and sync roadmap.

* feat(ai): integrate tree-sitter multilingual ast engine and library drift auditor

Implement polyglot concrete syntax tree parsing, S-expression AST query
execution, and cross-file code graph synthesis for Python, TypeScript,
Go, Rust, Java, and HCL with zero-crash fallback parsers. Expose CLI
commands `devops ai ast parse` and `devops ai ast graph`, add
`--multilingual` support to `devops ai repomap`, and register FastMCP tools
`ai_ast_parse` and `ai_ast_graph`.

Implement workspace library API drift and deprecation usage auditor
`devops ai audit-library-usage` comparing AST call sites against indexed
library contracts to detect removed methods, unknown attributes,
unrecognized kwargs, and deprecated calls. Flatten nesting depth to satisfy
architectural invariant gates.

Closes #74
Closes #79

* feat(ai): integrate ai context packing and symbol-pruned prompt synthesizer

Implement `ContextPacker` in `src/devops_cli/ai/context_packer.py` to rank
imported symbols, strip unreferenced private methods/docstrings, and
skeletonize function/class bodies with ellipsis while preserving public
interfaces, parameters, defaults, and type annotations.

Expose CLI command `devops ai pack-context` and FastMCP tool `ai_pack_context`,
and integrate context packing into `_collect_linked_snippets` in the review
pipeline. Enforce strict cyclomatic complexity <= 10 and nesting depth <= 2.

Closes #85

* feat(rag): autonomous rag index drift detection and auto-reindexing engine

Closes #81

* chore(release): bump version to v0.2.14

* fix(docs): align jekyll configuration file naming to _config.yaml

* fix(review): remediate copilot findings and enhance project tracking instructions

- Harden security sanitizer with -p= and --token= sensitive argument prefixes
- Implement non-mutating thread-safe DNS resolution with fail-closed non-public IP validation
- Scope docs ingester chunk slugs to file relative paths, mask credentials in errors, and support multi-page crawling
- Fully qualify introspected function and class symbol signatures and filter private submodules
- Namespace Valkey cache keys and Qdrant vector point IDs with package qualification
- Integrate Tree-Sitter native CST parsing fallback and S-expression query filtering
- Disambiguate AST call graph edges against symbol bodies to prevent parameter shadowing
- Enforce valid Python AST pruning under context budgets without arbitrary string truncation
- Support module-level imports and alias attribute lookups in library drift auditor
- Forward multi-label filters in GitHub client and paginate review threads via GraphQL
- Align project custom field inference with declarative taxonomy label mappings
- Enhance agent instructions, routine tasks, and knowledge base for proactive project bootstrap and card tracking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/feature Type feature: a new function

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants