The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): skip state facts when resolving installed store entries
ethernet9a077628c599
diff --git a/pm/lock.py b/pm/lock.pyindex 9c6215af781..40419dba343 100644--- a/pm/lock.py+++ b/pm/lock.py@@ -202,7 +202,9 @@ class Facts:a fact written before identity existed all count as NOT installedand force a reinstall. ``None`` keeps the version+path check."""fact = self._packages.get(name)- if not fact:+ if not fact or "entry" not in fact:+ # State facts (``record_state``: venv stamp + extras) share this+ # file with tool facts but own no store entry.return Falseif expected_version is not None and fact.get("version") != expected_version:return Falsediff --git a/tests/pm/test_installed_package.py b/tests/pm/test_installed_package.pyindex fb2e7ae5593..c17fa38a20a 100644--- a/tests/pm/test_installed_package.py+++ b/tests/pm/test_installed_package.py@@ -29,3 +29,21 @@ def test_installed_lookup_prefers_current_pin_then_recorded_fallback(pm_env, tmpassert pm.installed_package("faketool", allow_outdated=True) == originaloriginal.binary.unlink()assert pm.installed_package("faketool", allow_outdated=True) is None+++def test_state_fact_in_shared_facts_file_is_not_a_store_install(pm_env):+ """``venv`` is recorded via ``record_state`` (stamp + extras, no entry) into+ the same facts.json as tool facts. Reading the composed env over every+ registered package must skip it, not KeyError on ``fact["entry"]`` —+ that crashed ``activate`` (``hermes_cli.runtime_paths``) after a sync."""+ from pm.ensure import env_for+ from pm.lock import Facts+ from pm.registry import all_packages++ ensure("faketool", explicit=True)+ facts = Facts(paths.facts_path())+ facts.record_state("venv", "stamp", ["all"])++ assert not facts.installed("venv", None, paths.store_root())+ composed = env_for("venv", "faketool", *all_packages())+ assert composed == env_for("faketool")