microsoft / microsoft/amplifier
[foundation] Add consolidation API to InstallStateManager
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
-
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 --forcewipes the venv
-
clear() -> None- Convenience method for full state reset
- Equivalent to
invalidate(None)
Enhanced Behavior
- 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)
-
_extract_dependencies_from_pyproject(path) -> list[str]- Parse pyproject.toml for dependency names
-
_check_dependency_installed(dep_name) -> bool- Use
importlib.metadatawith PEP 503 name normalization
- Use
Acceptance Criteria
-
invalidate_modules_with_missing_deps()correctly identifies modules with missing deps -
clear()resets all module state -
is_installed()returnsFalsewhen 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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