Skip to content

Implement a deterministic resource identifier codec with namespace isolation #388

Description

@Lakes41

Difficulty: Advanced
Type: Feature
Recommended labels (if available in this repo): access-control, backend, type-safety, advanced

Background

GuildPass access-control systems will eventually need to reference many kinds of protected resources, including communities, governance objects, channels, documents or external integrations.

Using unstructured strings for resource identifiers creates ambiguity and makes permission matching harder to validate safely.

This issue introduces a standalone namespaced resource identifier codec.

Problem

There is currently no canonical Core representation for identifiers such as community:abc, document:123 or nested resource paths.

Manual string concatenation can introduce escaping errors, namespace collisions and multiple textual representations for the same logical resource.

Expected Outcome

Implement a strongly typed resource identifier parser and formatter with explicit namespace and segment validation.

Suggested Implementation

A parsed identifier may resemble:

interface ResourceIdentifier {
  namespace: string;
  segments: string[];
}

The module should:

  • define one canonical textual representation;
  • validate namespace syntax;
  • validate resource segments;
  • define escaping or encoding rules for reserved delimiters;
  • reject empty segments;
  • impose maximum namespace, segment and total identifier lengths;
  • support parse/format round trips;
  • provide deterministic equality or canonical comparison helpers;
  • reject malformed encodings;
  • avoid filesystem/path traversal semantics accidentally leaking into resource identifiers;
  • remain independent of actual resource persistence.

For example, if / is used as a segment delimiter, literal / inside a segment must either be forbidden or encoded unambiguously.

Acceptance Criteria

  • Valid identifiers parse into the expected namespace and segments.
  • Formatting produces one canonical representation.
  • Parse/format round trips succeed.
  • Empty namespaces and segments are rejected.
  • Reserved delimiter handling is explicit and tested.
  • Oversized identifiers are rejected.
  • Malformed escaping or encoding is rejected safely.
  • Canonically equivalent identifiers compare equally.
  • Unit tests cover Unicode, reserved delimiters, malformed input and length boundaries.
  • pnpm typecheck passes.
  • pnpm build passes.
  • pnpm test passes.
  • No resource database model, API route or policy integration is introduced.

Likely Affected Files/Directories

packages/resource-id/ or equivalent isolated package
unit tests

Independence Requirement

This issue must be independently implementable from main and must not depend on a resource service, policy engine or another campaign contribution.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesThird CampaignOfficial FWC26 campaign issue — eligible for campaign scoring and rewardsaccess-controlAccess evaluation, permissions, authorisation rules, and protected resource logicadvancedAdvanced difficulty tasks requiring significant domain knowledge and implementation effortbackendBackend services, application logic, persistence integration, and server-side functionalitytype-safetyTypeScript type system improvements and strict type enforcement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions