microsoft / microsoft/amplifier

[foundation] Add consolidation API to InstallStateManager

Open
#194 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.1k
Forks
261
Avg merge
3h 28m
Merged PRs (30d)
13

Description

Parent Issue

Part of #193 - Consolidate install-state.json manipulation with InstallStateManager

Summary

Add methods to InstallStateManager in amplifier-foundation to support consolidation of install-state.json manipulation.

Scope: amplifier-foundation

File: amplifier_foundation/modules/install_state.py

Changes Required

New Methods
  1. invalidate_modules_with_missing_deps() -> tuple[int, int]

    • Surgically invalidate only modules whose dependencies are missing
    • Check each tracked module's declared dependencies against what's installed
    • Returns (modules_checked, modules_invalidated) for reporting
    • Useful after uv tool install --force wipes the venv
  2. clear() -> None

    • Convenience method for full state reset
    • Equivalent to invalidate(None)
Enhanced Behavior
  1. Enhance is_installed() to verify dependencies
    • Proactively check that declared dependencies are actually present
    • Auto-heal stale state by invalidating entries with missing deps
    • Catches stale state without needing explicit cleanup calls
Helper Functions (module-level)
  1. _extract_dependencies_from_pyproject(path) -> list[str]

    • Parse pyproject.toml for dependency names
  2. _check_dependency_installed(dep_name) -> bool

    • Use importlib.metadata with PEP 503 name normalization

Acceptance Criteria

  • invalidate_modules_with_missing_deps() correctly identifies modules with missing deps
  • clear() resets all module state
  • is_installed() returns False when dependencies are missing (proactive self-healing)
  • All existing tests pass
  • Shadow test verifies auto-healing works end-to-end

Benefits

  • Users stuck in stale state auto-recover on next session start
  • Provides clean API for app-cli to use instead of direct JSON manipulation
  • Enables follow-up work in #194

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with amplifier_foundation/modules/install_state.py and trace the existing invalidate() and is_installed() behavior. Review the dependency requirements in the issue and run the existing test suite before adding coverage for missing dependencies, clear(), and the end-to-end shadow test. Done means the acceptance criteria pass and all existing tests remain green.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.