Skip to content

refactor: categorize code_table constants by CSV tag - #57

Open
acul71 wants to merge 1 commit into
issue-38from
issue-43
Open

refactor: categorize code_table constants by CSV tag#57
acul71 wants to merge 1 commit into
issue-38from
issue-43

Conversation

@acul71

@acul71 acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #43.

Depends on #56 (issue #38) — this PR is stacked on issue-38.

  • Replace name-pattern categorization in tools/gen_code_table.py with CSV tag from enriched CODECS
  • Regenerate multicodec/code_table.py (sections now include softhash, nonce, vlad, etc.)
  • Add unit tests for categorize()

Demo

=== BEFORE (pattern-based excerpt from previous code_table on master) ===
18:# Multihash
577:# Other
Generated /home/luca/Informatica/Learning/PNL_Launchpad_Curriculum/Libp2p/py-multicodec/.worktrees/issue-43/multicodec/code_table.py
Total constants: 651
=== AFTER (tag-based sections) ===
1:# Code generated from constants.py; DO NOT EDIT MANUALLY.
3:# To regenerate, run: python tools/gen_code_table.py
5:# These constants provide type-safe Code values for all known multicodecs,
6:# allowing usage like:
7:#     from multicodec import SHA2_256
8:#     code = SHA2_256  # Code object for sha2-256
10:# Instead of:
11:#     from multicodec import Code
12:#     code = Code(0x12)
18:# multihash
379:# multiaddr
426:# ipld
473:# serialization
488:# multiformat
499:# key
590:# namespace
614:# cid
619:# encryption
622:# filecoin
626:# hash
639:# holochain
647:# libp2p
652:# multikey
655:# multisig
675:# nonce
678:# shelter
685:# softhash
688:# transport
694:# varsig
707:# vlad
710:# zeroxcert
676:NONCE: Code = Code(0x123b)  # nonce
686:ISCC: Code = Code(0xcc01)  # iscc
708:VLAD: Code = Code(0x1207)  # vlad

Test plan

Made with Cursor

Replace fragile name-pattern lists in tools/gen_code_table.py with
tag metadata from enriched CODECS, and regenerate code_table.py.

Closes #43.

Co-authored-by: Cursor <cursoragent@cursor.com>
@acul71

acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@sumanjeet0012 Could you please review this PR when you have a chance? (Depends on #56.) Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant