Skip to content

constants.py entries lack tag, status, and description metadata from upstream CSV #39

Description

@sumanjeet0012

Each entry in constants.py currently stores only the codec prefix code. The upstream multicodec table.csv has 5 columns (name, tag, code, status, description), but tools/update-table.py discards tag, status, and description during generation.

Problem

Current format in constants.py:

CODECS = {
    "sha2-256": {"prefix": 0x12},
    "dag-pb":   {"prefix": 0x70},
    "ip4":      {"prefix": 0x04},
}

The upstream CSV contains significantly more information per codec:

name tag code status description
sha2-256 multihash 0x12 permanent
dag-pb ipld 0x70 permanent
ip4 multiaddr 0x04 permanent
shake-128 multihash 0x18 draft

This metadata is discarded by tools/update-table.py (line 82), which only writes the prefix:

# tools/update-table.py, line 82:
value = "{'prefix': {code}, },".format(code=codec["code"])

Proposed Solution

  1. Modify tools/update-table.py to include tag, status, and description in the output:

    "sha2-256": {"prefix": 0x12, "tag": "multihash", "status": "permanent", "description": ""},
  2. Regenerate constants.py using the updated script.

  3. Add Code.status and Code.description properties in code.py that read from the enriched CODECS dict.

  4. Update NAME_TABLE and CODE_TABLE derivations to remain backward-compatible (they only need name↔prefix mapping).

  5. Add tests verifying that every codec has tag, status fields populated.

Related

  • Generator script: tools/update-table.py
  • Go equivalent: go-multicodec includes status ("permanent"/"draft") and description in generated code comments

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