fix: update stale nested bundle URIs when reloaded from different source#83
Conversation
When a parent bundle is overridden to a local path via settings.local.yaml, nested bundles previously persisted with git+ URIs would keep their stale URIs because _load_single() skipped re-registering existing entries. Now the existing entry's URI and local_path are updated when the bundle is reloaded from a different source, ensuring registry.json stays in sync with actual source overrides. Fixes: microsoft-amplifier/amplifier-support#62 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Review: ApproveIndependently verified the root cause by tracing all read sites for The fix correctly adds Verified that Tests are solid: URI update on reload, persistence across save/load cycles, same-URI idempotency. Non-blocking note: LGTM. We recommend merging this PR and not merging the companion app-cli PR #92 -- once this fix lands, the first session corrects all persisted URIs and the display self-heals permanently. |
Summary
Fixes the persistent-state half of microsoft-amplifier/amplifier-support#62.
When a parent bundle (e.g.,
foundation) is overridden to a local path viasettings.local.yaml, nested bundles previously persisted withgit+URIs kept their stale URIs indefinitely. This PR ensures registry entries are refreshed when a bundle is reloaded from a different source.Root Cause
BundleRegistry._load_single()has an update block (lines 506–510) that refreshesversion,loaded_at, andlocal_pathfor known bundles — but it did not updateuri. Combined with persisted state loaded fromregistry.jsonon init, this meant:git+URIs → persisted toregistry.json_load_single()reloads the nested bundle from afile://URI, but the existing entry'surifield is never updatedregistry.jsonretains the stalegit+URI across all subsequent sessionsChange
+5 lines in
amplifier_foundation/registry.py— surgical addition to the existing update block:The URI is only updated when it actually differs, with a debug log for traceability. For same-URI reloads this is a no-op.
Evidence
Diff stats
amplifier_foundation/registry.py: +5 lines (production fix)tests/test_registry.py: +164 lines (3 regression tests)Test results
amplifier-foundationfull suiteNew regression tests (
TestNestedBundleURIUpdate)test_persisted_nested_bundle_uri_updates_on_reloadgit+URI inregistry.jsongets updated tofile://when the same bundle is loaded from a local pathtest_persisted_uri_update_survives_save_reloadsave()→ newBundleRegistrycycletest_same_uri_reload_does_not_change_entryCompanion PR
This is the first of two PRs for issue #62. The companion PR in
amplifier-app-clichangesget_bundle_categories()to read from the in-memory registry instead of staleregistry.jsonon disk. This foundation PR should merge first (it fixes the persistent state that the CLI reads).How to verify end-to-end
After both PRs merge:
bundle.added.foundation: ../../amplifier-foundationtosettings.local.yamlamplifier bundle list --allfile://paths, notgit+GitHub URLs