-
Notifications
You must be signed in to change notification settings - Fork 0
docs: use grammar-v2 URNs in CLAUDE.md and help-text examples #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package access | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/hadron-memory/hadron-cli/internal/exitcode" | ||
| ) | ||
|
|
||
| // The suggested example must compose with the separator the caller used, so a | ||
| // single-colon shorthand isn't handed back a "::"-shaped v1 prefix. | ||
| func TestMemoryURNExampleMatchesSeparator(t *testing.T) { | ||
| cases := []struct{ in, want string }{ | ||
| {"acme.com:kb", "hrn:mem:acme.com:kb"}, // v2 short form → canonical prefix | ||
| {"acme.com::kb", "hrn:memory:acme.com::kb"}, // v1 short form → legacy prefix | ||
| {"acme.com::kb::start-here", "hrn:memory:acme.com::kb::start-here"}, | ||
| } | ||
| for _, tc := range cases { | ||
| if got := memoryURNExample(tc.in); got != tc.want { | ||
| t.Errorf("memoryURNExample(%q) = %q, want %q", tc.in, got, tc.want) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestNormalizeResourceRef(t *testing.T) { | ||
| // Any scheme-prefixed ref passes through verbatim — the server dispatches | ||
| // on its type, and it accepts v2 and legacy spellings alike. | ||
| for _, ref := range []string{ | ||
| "hrn:mem:acme.com:kb", | ||
| "hrn:memory:acme.com::kb", | ||
| "hrn:node:acme.com:kb:start-here", | ||
| "hrn:node:acme.com::kb::start-here", | ||
| "hrn:app:acme.com::support", | ||
| "urn:memory:acme.com::kb", | ||
| } { | ||
| got, err := normalizeResourceRef(ref) | ||
| if err != nil { | ||
| t.Errorf("%q should pass through, got error %v", ref, err) | ||
| } | ||
| if got != ref { | ||
| t.Errorf("%q was rewritten to %q", ref, got) | ||
| } | ||
| } | ||
|
|
||
| // A colon-free id is an AiServiceConfig id. | ||
| if got, err := normalizeResourceRef("cfg_123"); err != nil || got != "cfg_123" { | ||
| t.Errorf("bare id: got %q, %v", got, err) | ||
| } | ||
|
|
||
| // An under-qualified shorthand is rejected with guidance that composes. | ||
| for _, ref := range []string{"acme.com:kb", "acme.com::kb"} { | ||
| _, err := normalizeResourceRef(ref) | ||
| if err == nil { | ||
| t.Fatalf("%q should be rejected", ref) | ||
| } | ||
| if got := exitcode.FromError(err); got != exitcode.Usage { | ||
| t.Errorf("%q should be a usage error, got %d", ref, got) | ||
| } | ||
| if !strings.Contains(err.Error(), memoryURNExample(ref)) { | ||
| t.Errorf("%q: the error should suggest %q, got %q", ref, memoryURNExample(ref), err.Error()) | ||
| } | ||
| } | ||
|
|
||
| if _, err := normalizeResourceRef(" "); err == nil { | ||
| t.Error("an empty ref should be rejected") | ||
| } | ||
| } |
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After declaring the flat v2 forms canonical here, the separately exposed
hadron agentic-usagecontract still documents onlyhrn:memory:<org>::<slug>and the double-colon node form (internal/cmd/agentic/agentic-usage.md:120-126), and itsaccess checksection still lists onlyhrn:memory:(:578-583). Agents using that command rather than Cobra help will therefore continue generating the legacy spelling and are not told that server-emitted flat node URNs are accepted; update the embedded contract alongside these help changes. CLAUDE.mdL63-L63Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, and this was the more consequential of the two — fixed in 651abb1.
agentic-usage.mdis the filehadron agentic-usageprints, and its own header calls it "the single reference an agent needs to drive the CLI". Leaving it on v1 while declaring v2 canonical in cobra help would have meant agents reading the documented contract keep emitting the legacy spelling and never learn that the server-emitted flat URNs are accepted at all — exactly the loop that put v1 in CLAUDE.md in the first place.Both places you flagged are updated:
hrn:mem:<root>:<slug>,hrn:node:<root>:<slug>:<loc…>), with every legacy spelling still listed as accepted. The node bullet also explains why scheme-less single-colon stays ambiguous while the flat v2 form is not — thehrn:node:prefix is what disambiguates.access checknow listshrn:mem:…alongside the legacy prefix.Verified in the rendered output: