refactor(persistence): align cwd-derived workspace slug with amplifier-app-cli#57
Merged
Merged
Conversation
…r-app-cli Replace derive_workspace_from_cwd with amplifier-app-cli's get_project_slug algorithm verbatim to ensure ecosystem hooks (hook-context-intelligence) compute identical buckets regardless of which host launched the session. Old behavior: /Users/me/repos/amplifier-agent → amplifier-agent-a1b2c3d4 New behavior: /Users/me/repos/amplifier-agent → -Users-me-repos-amplifier-agent - Updated persistence.py to use path-derived slug format - Replaced hash-based derivation with path normalization - Updated design doc D4 with new algorithm and parity contract - All 29 tests pass; ecosystem parity verified via contract test Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
manojp99
added a commit
that referenced
this pull request
Jun 17, 2026
…#59) * feat(engine): replace built-in bundle with vendored behavioral-anchor Replace the inbuilt amplifier-agent-builtin bundle with a vendored copy of the experimental behavioral-anchor bundle from amplifier-foundation@main: experiments/behavioral-anchor/behavioral-anchor.md. This introduces a new agent set (explorer, architect, builder, debugger, git-ops, researcher) replacing the previous planner/coder/tester pattern. The new bundle uses a parent-level tool inheritance model via tool-delegate's context_inheritance feature, simplifying agent definitions and reducing duplication. Five modifications made to the upstream behavioral-anchor to align with amplifier-agent architecture: 1. Added default_provider: anthropic (engine reads from bundle frontmatter) 2. Dropped behaviors/streaming-ui.yaml and hooks-todo-display (stdout reserved for JSON envelope; engine handles streaming via hook_streaming.py) 3. Dropped behaviors/logging.yaml; kept hook-context-intelligence to preserve workspace JSONL alignment with amplifier-app-cli (PR #57) 4. Dropped hooks-approval (no wire-protocol approval round-trip yet) 5. Added tool-mcp (preserves MCP for existing users + doctor checks) Cache implications: The warm-start prepared bundle is keyed by sha256(bundle.md), which has changed. Users will see 30-90s of cold-start on first run after upgrade (all foundation modules are cloned fresh and cache is repopulated). Compliance: Tests updated for new agent set; protocol unchanged; wrapper SDKs verified as name-agnostic and require no changes. Design doc TBD (can be promoted from PR discussion if desired). Reference: 2026-05-19-baked-in-bundle-decision.md. 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com> * docs(agents): add stale-cache troubleshooting note to Common pitfalls When a module fails with 'No module named' or 'failed validation' errors after a bundle.md change, the cause is usually a stale venv checkout, not a missing dep. Document the diagnostic sequence (cache clear + --refresh reinstall) and the finding that foundation's resolver does follow upstream module transitive deps with fresh git clones. This pitfall was discovered during PR #59 runtime testing where stale module checkouts twice masked missing deps that disappeared with a fresh install. Documented to prevent next contributor hitting the same issue. 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com> --------- Co-authored-by: Manoj Prabhakar Paidiparthy <mpaidiparthy@microsoft.com> Co-authored-by: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
derive_workspace_from_cwdwith amplifier-app-cli'sget_project_slugalgorithm verbatim to ensure ecosystem hooks (notablyhook-context-intelligence) compute identical buckets regardless of which host launched the session.Why: The design (D5 of
docs/designs/2026-06-09-workspace-resolution-and-migration.md) writes the resolved workspace into bothcoordinator.config["workspace"]andcoordinator.config["project_slug"]so ecosystem hooks see a consistent bucket. But the old hash-based algorithm in amplifier-agent ({slugified-basename}-{8-char-sha256-hash}) produced a DIFFERENTproject_slugthan amplifier-app-cli for the same cwd — silently defeating the alias's purpose. Adopting amplifier-app-cli's algorithm verbatim means the same cwd → identicalproject_slugunder both hosts.Old behavior:
/Users/me/repos/amplifier-agent→amplifier-agent-a1b2c3d4New behavior:
/Users/me/repos/amplifier-agent→-Users-me-repos-amplifier-agentChanges
src/amplifier_agent_lib/persistence.py— Replacedderive_workspace_from_cwdbody withstr(cwd.resolve()).replace("/", "-").replace("\\", "-").replace(":", "")+ leading-hyphen guard. Removed now-unusedimport hashliband the_slugifyhelper. Updated docstring to explain the parity contract.tests/test_persistence_workspaces.py— Rewrote the 4 derive_workspace tests to verify the new contract. Added_app_cli_get_project_sluglocal helper as a verbatim port of amplifier-app-cli's algorithm and a parametrizedtest_derive_workspace_matches_app_cli_formatthat asserts byte-equality across 6 cwd inputs.docs/designs/2026-06-09-workspace-resolution-and-migration.md— Updated D4 (Cwd-derived default) to reflect the new algorithm and parity contract.Verification
tests/test_persistence_workspaces.py,tests/test_runtime_workspace.py,tests/cli/test_run_workspace_flag.py)python_checkclean on both modified Python files (ruff-format, ruff-lint, pyright, stub-check)Known follow-ups (not addressed in this PR, user is aware)
docs/plans/2026-06-09-workspace-implementation.mdstill describes the old algorithm — left alone as implementation history