Skip to content

gh: parse_bounty_comment reads the four comment kinds back (Python + JS, shared vectors) - #53

Open
xiaobaiqiao wants to merge 1 commit into
fitzss:mainfrom
xiaobaiqiao:bounty-comments-parse
Open

xiaobaiqiao wants to merge 1 commit into
fitzss:mainfrom
xiaobaiqiao:bounty-comments-parse

Conversation

@xiaobaiqiao

Copy link
Copy Markdown

Closes #17.

parse_bounty_comment (Python) and parseBountyComment (JavaScript) read the four comments this module renders - bounty bill, award receipt, claim payout, PR gate - back as plain text, and answer with the same keys in both languages: ok, code, kind, bill_id, deal_id, counter_id, repo, issue.

Refusals are clean, never silent:

  • non-string -> not_text
  • over COMMENT_MAX (65,536) -> too_long (never truncated)
  • no Valun heading -> not_valun_comment
  • an id that is uppercase or not 16 hex digits -> malformed
  • two different ids of one kind -> ambiguous
  • a bill or award comment without its bill id -> malformed

Where it lives:

  • python/src/valun/gh.py - parse_bounty_comment, plus the two small helpers it reads with
  • js/src/gh.js - parseBountyComment (and the same name in snake case), exported from js/src/index.js; typed in js/src/index.d.ts
  • spec/vectors/bounty-comments.json - 14 positive and adversarial cases, the shared contract
  • spec/vectors/check_bounty_comments.py (+ bounty_comments_runner.mjs) - runs both clients over the vectors and fails on any disagreement
  • python/tests/test_gh_parse_bounty_comment.py and js/test/gh-parse-bounty-comment.test.js - read the same vectors

Verification run here:

python spec/vectors/check_bounty_comments.py    -> 14 cases, 0 disagreements
pytest python/tests/test_gh_parse_bounty_comment.py   -> 17 passed
node --test js/test/gh-parse-bounty-comment.test.js   -> 16 pass, 0 fail

The parsers are pure: no network, no globals written, a non-string or an over-long body refused rather than truncated, and a fresh object returned each call.

Valun-Claim: xiaobaiqiao

@fitzss

fitzss commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Thanks for the genuine cross-runtime PR on #17, @xiaobaiqiao! Clean parser structure and great start on positive + adversarial vectors.

We reviewed the diff against #17's acceptance criteria and CI gates — 5 quick fixes will make this merge-ready:

  1. Keep the full prefixed IDs (\�b_, \�d_, \�ctr_): Bounty Bill (Drop 2 #3 · 5 Credits): Offline GitHub bounty/award markdown parser + Python/JS parity vectors #17 specifies returning validated \�b_<16 lowercase hex>, \�d_<16 lowercase hex>, and \�ctr_<16 lowercase hex>\ (currently \commentIds\ / _comment_ids\ strips the prefix and returns only the 16 hex digits).
  2. Use stdlib \unittest\ (no \pytest\ import) in \python/tests/test_gh_parse_bounty_comment.py: our release & CI Python test lane runs \python -m unittest discover -s tests\ with standard library only (zero third-party deps).
  3. Wire the vectors into \spec/vectors/check_parity.py\ + add round-trip tests against the 4 real renderers: add round-trip coverage against actual
    ender_bounty_bill_markdown,
    ender_award_receipt_markdown,
    ender_claim_payout_markdown, and
    ender_pr_gate_markdown\ outputs, and run the bounty-comment vectors inside \spec/vectors/check_parity.py\ so
    elease.py check\ enforces them automatically.
  4. Strip UTF-8 BOMs (\ufeff) & add amespace gh\ typing: remove the UTF-8 BOM added to \js/src/index.js\ and the 4 new files, and declare \parseBountyComment\ inside \export namespace gh { ... }\ in \js/src/index.d.ts\ as well as top-level (and rebase onto \main\ \�0.9.5).
  5. Tighten ID trailing boundary: ensure a trailing underscore or extra alphanumeric (e.g. \�b_0123456789abcdef_extra) returns \malformed\ rather than matching the first 16 hex chars ((?![0-9A-Za-z_])).

Also, we checked \�alun.tech\ and \xiaobaiqiao\ isn't enrolled yet — whenever you're ready, you can generate your local \secp256k1\ signing key in 30 seconds at https://valun.tech/claim (or via \uvx --from valun==0.9.5 valun join --sandbox --handle xiaobaiqiao) so we can issue your 5 Credits bounty payout as soon as this merges!

…JS, shared vectors)

Closes fitzss#17.

parse_bounty_comment / parseBountyComment read the four comments this module renders - bounty bill, award receipt,
claim payout, PR gate - back as plain text, and answer with the same keys in both languages: ok, code, kind, bill_id,
deal_id, counter_id, repo, issue. The ids keep their vb_/vd_/vctr_ prefix.

Refusals are clean, never silent: non-string -> not_text, over COMMENT_MAX -> too_long (never truncated), no Valun
heading -> not_valun_comment, an id that is not 16 lowercase hex (or carries a trailing word) -> malformed, two
different bill ids -> ambiguous. A commerce comment legitimately names the deal that funds it and the deal that pays,
so the first deal or counter id is reported; two different bill ids stay a conflict.

Coverage:

- spec/vectors/bounty-comments.json: 15 positive and adversarial cases, the shared contract
- spec/vectors/check_bounty_comments.py (+ bounty_comments_runner.mjs): both clients over the vectors, and it is wired
  into spec/vectors/check_parity.py, so 'python spec/vectors/check_parity.py' runs it with everything else
- python/tests/test_gh_parse_bounty_comment.py: stdlib unittest, the same vectors plus round-trip against what the four
  renderers actually wrote (spec/vectors/wave33.json bounty/award/gate markdown, spec/vectors/gh-payout.json payout
  markdown)
- js/test/gh-parse-bounty-comment.test.js: node --test, the same vectors

Verified on main a658139 (0.9.16): check_parity 267 cases + 15 bounty-comment cases, 0 disagreements; unittest 6 tests
OK; node --test 17 pass, 0 fail.
@xiaobaiqiao
xiaobaiqiao force-pushed the bounty-comments-parse branch from b3f138d to 2fe349f Compare December 5, 2026 05:22
@xiaobaiqiao

Copy link
Copy Markdown
Author

All five review points are in, rebased onto main (a658139, 0.9.16), and pushed (force-updated bounty-comments-parse).

  1. Prefixed ids: bill_id / deal_id / counter_id now come back as vb_<16 hex> / vd_<16 hex> / vctr_<16 hex>.
    One judgement call worth your eyes: a commerce comment legitimately names two deals (the one that funds it and the
    one that pays), so a second vd_ or vctr_ is not treated as a conflict - the first one named is reported. Two
    different vb_ ids still return ambiguous, since a comment is about one bill.

  2. stdlib unittest: python/tests/test_gh_parse_bounty_comment.py imports only unittest now, so
    python -m unittest discover -s tests covers it. No pytest anywhere.

  3. Wired into the gate + round-trip: spec/vectors/check_parity.py now runs the bounty-comment vectors through its
    own runner pair, so python spec/vectors/check_parity.py reports:

    267 cases, 0 disagreements
    15 bounty-comment cases, 0 disagreements
    

    Round-trip tests parse what the four renderers actually wrote (spec/vectors/wave33.json bounty/award/gate
    markdown, spec/vectors/gh-payout.json payout markdown) and compare the ids, repo and issue with the view that was
    rendered.

  4. BOMs and typing: UTF-8 BOMs stripped from js/src/index.js and the new files; parseBountyComment is declared
    both top-level and inside export namespace gh { ... }.

  5. Trailing boundary: _COMMENT_ID_RE / COMMENT_ID_RE carry (?![0-9A-Za-z_]), so vb_0123456789abcdef_extra
    returns malformed instead of matching the first 16 hex digits. There is a vector for it.

Also: valun.tech/claim - noted, I will enrol as xiaobaiqiao before this merges so the payout has somewhere to land.

This branch has not been deployed

No deployments
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.

Bounty Bill (Drop 2 #3 · 5 Credits): Offline GitHub bounty/award markdown parser + Python/JS parity vectors

2 participants