Skip to content

feat(ai): context packing and symbol-pruned prompt synthesizer #85

Closed

Description

@dan-petty

Problem or Motivation

Large prompt contexts in multi-file reviews and RAG grounding consume substantial token budgets and induce LLM attention degradation on irrelevant class methods, internal helpers, and verbose comments.

Proposed Solution & Architectural Design

  • Implement ContextPacker in src/devops_cli/ai/context_packer.py to rank imported symbols by usage density.
  • Strip unreferenced private methods, non-contract docstrings, and compress verbose type annotations.
  • Integrate context packing into prompt synthesis for code reviews and LLM payloads, cutting token overhead by 40-60% while preserving strict type fidelity.

Acceptance Criteria

  • Context packer strips unreferenced private symbols and simplifies docstrings based on prompt budget.
  • Preserves public interface signatures and referenced type hints without syntax corruption.
  • Unit tests in tests/test_context_packer.py pass with >= 90% coverage.
  • Strict cyclomatic complexity <= 10 and nesting depth <= 5.

Activity

  1. added this to the v0.2.14 milestone on Sep 9, 2026
  2. added
    type/feature
    scope/ai
    priority/p2-medium
    on Sep 9, 2026
  3. added a commit that references this issue on Sep 9, 2026
    476df9f
  4. dan-petty commented on Sep 9, 2026

    @dan-petty
    OwnerAuthor

    Completed in commit 476df9f:

    • Implemented ContextPacker and PackedContext in src/devops_cli/ai/context_packer.py to rank imported symbols, strip unreferenced private methods/docstrings, and skeletonize function/class bodies with ellipsis (...).
    • Supported zero-crash fallback for unparseable or non-Python code with bounded token truncation via truncate_to_token_limit.
    • Added CLI command devops ai pack-context <path> [--referenced <syms>] [--max-tokens <int>] [--json].
    • Registered FastMCP tool ai_pack_context in src/devops_cli/ai/mcp/server.py and exported 116 schemas.
    • Integrated context packing into _collect_linked_snippets in src/devops_cli/ai/review/pipeline.py.
    • Enforced architectural invariants: cyclomatic complexity <= 10 and maximum nesting depth <= 2.
    • 10/10 unit tests in tests/test_context_packer.py and 9/9 FastMCP contract tests in tests/test_fastmcp_contracts.py.
  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/p2-mediumscope/aitype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions