Skip to content

Add Code.status and Code.description properties #47

Description

@sumanjeet0012

The Code class exposes name and tag() but not status (permanent/draft) or description metadata. go-multicodec includes this information in generated code comments.

Problem

from multicodec import Code

code = Code(0x12)
code.name    # "sha2-256" ✅
code.tag()   # "multihash" ✅
code.status  # ❌ Not available
code.description  # ❌ Not available

go-multicodec includes this metadata in generated comments:

// Sha2_256 is a permanent code tagged "multihash".
Sha2_256 Code = 0x12 // sha2-256

// Shake128 is a draft code tagged "multihash".
Shake128 Code = 0x18 // shake-128

Knowing whether a codec is permanent vs draft is useful for applications that want to enforce stability guarantees.

Proposed Solution

  1. Prerequisite: constants.py must include status and description fields (see related issue).

  2. Add properties to Code class in code.py:

    @property
    def status(self) -> str:
        """Return 'permanent', 'draft', or '<unknown>'."""
        info = CODECS.get(CODE_TABLE.get(self._value, ""), {})
        return info.get("status", "<unknown>")
    
    @property
    def description(self) -> str:
        """Return the codec description from the multicodec table."""
        info = CODECS.get(CODE_TABLE.get(self._value, ""), {})
        return info.get("description", "")
  3. Add tests in tests/test_code.py.

Related

  • Issue: constants.py entries lack status and description metadata
  • Issue: tools/update-table.py discards CSV columns
  • Go equivalent: Generated code comments in code_table.go

Activity

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

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