fix(register): a successful registration must update the identity it registered - #27
Merged
Merged
Conversation
…registered
Reported by salesland-dev-3metas (Salesland iCPA, 3Metas), reproduced against
a local AI Maestro provider.
1. amp-register.sh wrote registrations/<provider>.json and IDENTITY.md but
NEVER touched config.json. Every tool that reads .agent.address therefore
kept reporting the pre-registration identity — amp-statusline, amp-identity
and amp-inbox all showed @default.local for an agent whose registration had
succeeded, apiKey issued and registration file present.
A correctly registered agent looked unregistered everywhere a human would
think to check.
Now patched surgically with jq — .agent.tenant, .agent.address and a
provider block — rather than through save_config, which rebuilds the object
and would drop agent.id, fingerprint and createdAt. That is the same
destructive shape as the old load_config auto-fix and worth not repeating.
config.json carries one address, so it reflects the most recent
registration; registrations/ keeps the authoritative per-provider detail.
2. A first invocation could print "Updating identity file..." and exit 0
having persisted nothing, with registrations/ left empty; only a second run
with --force worked. `set -e` does not catch it, because the failure is a
jq that writes an empty file rather than a command returning non-zero. The
success path now verifies the registration file exists and contains an
apiKey, and exits 1 otherwise. An exit code that does not track whether the
work happened is worse than none: it makes the caller confident about
something nobody checked.
3. Docs: --api-url must include the API base, because the script posts to
{API_URL}/v1/register — http://localhost:23000 gives a 404 that reads like
the provider is down. Documented in --help with a self-hosted example.
Tests: 8 new in tests/unit/register_config_sync.bats, including that the patch
preserves agent id and fingerprint. Full suite 206 passing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Root cause of the second half of the salesland-dev-3metas report — the run that "exited 0 having persisted nothing". amp-helper resolves AMP_DIR from the working directory when nothing more explicit is available: a .claude/settings.local.json hint, else the AI Maestro agent that uniquely owns $PWD. That is an INFERENCE about which agent a directory belongs to, and it was being treated as licence to CREATE that agent's identity. A hint naming an agent with no entry in this home fell through to the raw NAME path and the auto-create manufactured an empty shell — keys/, messages/, registrations/, no config. Reproduced from a clean home: one `amp-init --name foo` inside a project whose settings.local.json names a different agent produced TWO directories, the real uuid one and a stray shell for the unrelated name, because amp-init overrides AMP_DIR only after the helper has already created the wrong one. That is also where salesland's registration went: written under one resolution while they inspected another. The shells are not harmless. A later name-based resolution can select the empty shell over the real identity, which is one of the ways an agent ends up looking unregistered or reading an empty inbox. Fix: the cwd hint resolves only when the identity already exists (index entry or directory). Otherwise the inference was wrong and we fall through. That exposed a latent dependency worth naming: amp-init only worked because SOMETHING resolved, so it relied on a cwd inference firing. On a genuinely clean home with no project hint it would have failed outright. It now sets AMP_ALLOW_UNRESOLVED=1 — every other script keeps refusing to guess. Verified end to end from a clean home: init creates exactly one directory, register updates config.json, and amp-identity reports the registered tenant instead of `default`. Tests: 5 new in tests/unit/no_stray_identity_dirs.bats. Suite 211 passing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jpelaez-23blocks
added a commit
to 23blocks-OS/ai-maestro-plugins
that referenced
this pull request
Sep 3, 2026
…entity dirs (#33) Picks up agentmessaging/claude-plugin#27: - amp-register.sh patches config.json on success, so a registered agent no longer reports @default.local in statusline, amp-identity and amp-inbox - exits non-zero when the registration could not be persisted, instead of printing success it had not earned - a cwd inference no longer manufactures an empty identity directory, which is where a registration could land while the operator inspected another - amp-init sets AMP_ALLOW_UNRESOLVED=1; it previously depended on some inference firing and would fail on a genuinely clean home Until this rebuild and the submodule bump, hosts keep the old scripts — install-plugin.sh reads this built output, not claude-plugin directly. Co-authored-by: Juan Pelaez <juan.pelaez@3metas.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.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.
Reported by salesland-dev-3metas (Salesland iCPA, 3Metas), reproduced against a local AI Maestro provider. Both confirmed by reading the success path.
1. config.json was never updated
amp-register.shwritesregistrations/<provider>.jsonandIDENTITY.md, and calls back to the Maestro API — but never touchesconfig.json. Every tool that reads.agent.addresstherefore keeps reporting the pre-registration identity:amp-statusline.shagent@default.localamp-identity.shTenant: defaultamp-inbox.shYour address: agent@default.localMeanwhile the registration had genuinely succeeded — apiKey issued, registration file present, address
salesland-dev-3metas@rnd23blocks.aimaestro.local. A correctly registered agent looked unregistered in every place a human would think to check.Now patched surgically with
jq—.agent.tenant,.agent.address, and aproviderblock — not throughsave_config, which rebuilds the object and would dropagent.id,fingerprintandcreatedAt. That is precisely the destructive shape of the oldload_configauto-fix (#26) and worth not repeating. Two of the new tests pin exactly that.config.jsoncarries one address, so it reflects the most recent registration;registrations/remains the authoritative per-provider list. Noted in the code for multi-provider agents.2. Exit 0 having persisted nothing
The reporter's first invocation printed
Updating identity file...and exited 0 withregistrations/still empty; only a second run with--forceworked.set -edoes not catch this, because the failure mode is ajqthat writes an empty file rather than a command returning non-zero. The success path now verifies the registration file exists and contains anapiKey, and exits 1 otherwise.An exit code that does not track whether the work happened is worse than no exit code at all — it makes the caller confident about something nobody checked.
3.
--api-urlneeds the/apibaseThe script posts to
{API_URL}/v1/register, sohttp://localhost:23000yields a 404 that reads like the provider is down. Documented in--helpwith a self-hosted example, since only crabmail.ai was listed as supported.Tests
8 new in
tests/unit/register_config_sync.bats, covering the address/tenant/provider patch, that it preserves agent id and fingerprint, thatload_configreports the registered address afterwards, and that--helpdocuments the base path.Full suite: 206 passing.
The reporter offered to test a patch against their agent — worth taking them up on it before this lands anywhere wide.