feat: materialize canonical foaf:name per agent into trust + spaces graphs (#62)#90
Merged
feat: materialize canonical foaf:name per agent into trust + spaces graphs (#62)#90
Conversation
…raphs (#62) Consumes the per-account name + nameCreatedAt fields newly added by nanopub-registry#113 and turns them into one canonical foaf:name triple per approved agent, locally readable from the trust-state graph and the mirrored spaces state graph (no SERVICE to /repo/full). Resolution policy across approved keys: pick the row with MAX(ratio) (ties → MIN(name) lex). Per-(agent, pubkey) resolution (latest declaring intro supplies the name) lives on the registry side; this layer only folds across keys. Changes: - TrustStateSnapshot.AccountEntry gains name + nameCreatedAt (nullable). Parser handles MongoDB extended JSON {"$date": "..."}, plain ISO-8601 strings, plain numeric epoch-ms, and treats absent fields as null so the consumer works against either pre- or post-#113 registry versions (additive non-breaking schema). - TrustStateLoader.resolveCanonicalNames + materialize: emits one <agent> foaf:name "..." triple in the trust state graph per approved agent. - AuthorityResolver.mirrorTrustState: copies foaf:name triples for approved agents into the new spaces state graph alongside the AccountState rows. Tests cover the resolver policy (MAX(ratio), MIN(name) tiebreak, unapproved-status skip, no-name absent, toLoad accepted) and the parser (extended-JSON $date, plain ISO string, missing fields tolerated, existing tests updated to the new 9-arg AccountEntry constructor). 177/177 pass locally. Doc update of the worked-example query (drop the SERVICE clause) will follow once both #89 and this PR are merged. Co-Authored-By: Claude Opus 4.7 (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.
Status
Draft — depends on
nanopub-registry#113, which adds the per-account `name` + `nameCreatedAt` fields to the trust-state snapshot JSON. The schema parser is forward-compatible so this PR is safe to merge before the registry change ships (consumers running against an older registry simply produce no `foaf:name` triples), but the live effect only kicks in once both are deployed.Pairs with
nanopub-query#89(observer-tier permissive grants) — that PR's worked-example query in `design-space-repositories.md` will need a small follow-up doc update to drop the `SERVICE <…/full>` clause, which is intentionally not in this PR (the doc edit only makes sense after #89 lands).Summary
Consumes the per-account `name` + `nameCreatedAt` fields from the trust-state snapshot and folds them, at materialisation time, into one canonical `foaf:name` triple per approved agent — emitted in the trust-state named graph and mirrored into each new spaces state graph at full-build time.
Result: any consumer reading the trust or spaces state graph gets `?agent foaf:name ?n` directly, with no cross-repo `SERVICE` to `/repo/full`.
Resolution policy
The two layers were decided up front (see PR #89's discussion) to keep the on-disk schema minimal:
Composed: "the most-trusted key's freshest declaration".
Changes
Parser — `TrustStateSnapshot`
Resolver — `TrustStateLoader`
Mirror — `AuthorityResolver.mirrorTrustState`
Tests
Test plan
Compatibility
🤖 Generated with Claude Code