Skip to content

refactor(persistence): align cwd-derived workspace slug with amplifier-app-cli#57

Merged
manojp99 merged 1 commit into
mainfrom
workspace-slug-ecosystem-parity
Jun 15, 2026
Merged

refactor(persistence): align cwd-derived workspace slug with amplifier-app-cli#57
manojp99 merged 1 commit into
mainfrom
workspace-slug-ecosystem-parity

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

Summary

Replace derive_workspace_from_cwd with amplifier-app-cli's get_project_slug algorithm verbatim to ensure ecosystem hooks (notably hook-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 both coordinator.config["workspace"] and coordinator.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 DIFFERENT project_slug than amplifier-app-cli for the same cwd — silently defeating the alias's purpose. Adopting amplifier-app-cli's algorithm verbatim means the same cwd → identical project_slug under both hosts.

Old behavior: /Users/me/repos/amplifier-agentamplifier-agent-a1b2c3d4
New behavior: /Users/me/repos/amplifier-agent-Users-me-repos-amplifier-agent

Changes

  • src/amplifier_agent_lib/persistence.py — Replaced derive_workspace_from_cwd body with str(cwd.resolve()).replace("/", "-").replace("\\", "-").replace(":", "") + leading-hyphen guard. Removed now-unused import hashlib and the _slugify helper. 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_slug local helper as a verbatim port of amplifier-app-cli's algorithm and a parametrized test_derive_workspace_matches_app_cli_format that 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

  • 29 tests pass (tests/test_persistence_workspaces.py, tests/test_runtime_workspace.py, tests/cli/test_run_workspace_flag.py)
  • python_check clean 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.md still describes the old algorithm — left alone as implementation history
  • No migration for existing workspace-bucketed sessions under the old hashed format; resume-by-ID still works (it walks workspaces)

…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 manojp99 merged commit 7eec53b into main Jun 15, 2026
2 of 3 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant