Skip to content

refactor: categorize code_table constants by CSV tag - #57

Merged
acul71 merged 1 commit into
masterfrom
issue-43
Oct 2, 2026
Merged

acul71 merged 1 commit into
masterfrom
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

@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!

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 merged commit e5ea4aa into master Oct 2, 2026
21 checks passed
@acul71
acul71 deleted the issue-43 branch October 2, 2026 09:29
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.

tools/gen_code_table.py uses fragile name-pattern categorization instead of tag data

1 participant