Skip to content

core: expose matchContextGraphAssertionUri matcher instead of the half-inverse parseContextGraphAssertionUri #1787

Description

@Jurij89

Context

Follow-up from PR #1780 (GH#1778). The PR added parseContextGraphAssertionUri(subject) in packages/core/src/constants.ts, an inverse of contextGraphAssertionUri(...).

Because a context-graph ID may itself contain / (wallet-scoped IDs like 0xabc…/project, permitted by validateContextGraphId) and an optional sub-graph name is also slash-joined, the inverse cannot recover (contextGraphId, subGraphName) from the subject alone. The helper therefore returns a single conflated scope field, and every consumer must compare scope against subGraphName ? contextGraphId + "/" + subGraphName : contextGraphId themselves. The parser is correct (right-anchored on /assertion/<addr>/<name>), but the API name implies a clean inverse that does not exist, and it leaks the grammar into callers.

Suggested refinement (non-blocking, maintainability)

Add a matcher that keeps the unavoidable ambiguity local to core:

matchContextGraphAssertionUri(
  subject: string,
  expected: { contextGraphId: string; subGraphName?: string; name: string },
): { agentAddress: string } | undefined

It returns the author address only when the subject matches the full expected coordinate. This collapses contextGraphAssertionQueryBounds + parse-and-compare into one canonical helper and removes the ambiguous scope from the consumer-facing surface.

Pointers

  • packages/core/src/constants.tsparseContextGraphAssertionUri, contextGraphAssertionQueryBounds, contextGraphAssertionUri
  • Consumers: packages/agent/src/finalized-assertion-author.ts, packages/agent/src/sync/durable-integrity.ts

Filed as a non-blocking maintainability follow-up from PR #1780 review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions