Skip to content

Migrate fjs/crypto/vdf to .f.mjs - #1486

Merged
sergey-shandar merged 4 commits into
mainfrom
claude/convert-f-ts-to-f-mjs-9
Aug 11, 2026
Merged

Migrate fjs/crypto/vdf to .f.mjs#1486
sergey-shandar merged 4 commits into
mainfrom
claude/convert-f-ts-to-f-mjs-9

Conversation

@sergey-shandar

Copy link
Copy Markdown
Contributor

Summary

  • Migrates fjs/crypto/vdf/module.f.ts (and proof.f.ts) from authored TypeScript to JSDoc-typed .f.mjs, per todo/migrate-typescript-to-mjs.md.
  • Splits the public Sloth type into a sibling types.ts.
  • A dependency leaf: only depends on already-migrated types/prime_field, types/nullable, and types/bigint; nothing else in the repo imports crypto/vdf.
  • Updates the stale module.f.ts line references in fjs/crypto/vdf/todo/iterate-combinator.md to match the new file and line numbers.

Test plan

  • npx tsc --noEmit clean
  • node ./fjs/module.ts t — 2356/2356 pass

Generated by Claude Code

claude added 2 commits August 11, 2026 05:13
Leaf module with no unmigrated dependents; updates the stale line
references in its iterate-combinator todo doc.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
functionalscript 2931e58 Commit Preview URL

Branch Preview URL
Aug 11 2026, 05:28 AM

@o2alexanderfedin o2alexanderfedin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Reviewed at 37df907 against main (e9e34c6). Two modules — fjs/crypto/vdf and fjs/bnf/token_symbol. Nothing to flag.

The 1024-bit modulus is intact

crypto/vdf is the one place in this migration where a silent digit change would be both catastrophic and invisible, so I did not settle for a token diff. Against main's compiled output the module looks different, but the only difference is numeric separators: TypeScript's emitter strips _ from 0xf2346eae06a23388_2814ff16…, while the authored .mjs keeps the grouping exactly as main's source wrote it. Discount separators and the two are identical.

Then I checked the values rather than the text — imported both module versions and compared:

p equal:                 true   (1024 bits)
sloth.p equal:           true
quadRes agree:           true
modSqrt agree:           true
eval(50)(12345) equal:   true
verify agrees:           true  ->  true

So the modulus, the quadratic-residue test, the modular square root, and a full eval/verify round-trip all match main. bnf/token_symbol is token-identical outright.

Everything else

  • npx tsc clean; 2356 pass / 0 fail.
  • Public API unchanged on both axes — 0 removed / 0 added / 0 changed for exported type aliases and for exported const signatures. (I started checking the second of those after eof slipped past the alias-only check on #1485; nothing here.)
  • No any as a type in any emitted declaration.
  • Markdown links: 144 broken on main, 144 here — none added — and 0 label/target mismatches. crypto/vdf's own todo/ doc was updated as part of the change rather than left for review.
  • Both new types.ts files carry the @module header with the blank line, so it survives into the emitted types.js instead of being swallowed by the following import.
  • Both proofs import only .f.mjs runtime modules, so proof.f.mjs is legitimate under §2.
  • CHANGELOG has a correctly-scoped **BREAKING CHANGES:** entry for each, in the short §8.3 form.

One nice detail worth naming: the updated line references in todo/iterate-combinator.md are accurate, not approximate. module.f.mjs:29-37 lands exactly on repeatSeq's JSDoc and body, and 51-57 covers both call sites (squareLoop and modSqrtLoop). Stale line numbers are the easiest thing to hand-wave in a rename; these were actually recomputed.

CI is still running on 37df907; I verified locally at that commit.

@sergey-shandar

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37df907c32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fjs/bnf/token_symbol/proof.f.mjs Outdated
duplicateName: () => { encoding(['a', 'b', 'a'] as const) },
unregisteredName: () => { encoding<string>(['a']).encode('b') },
duplicateName: () => { encoding(['a', 'b', 'a']) },
unregisteredName: () => { encoding(/** @type {readonly string[]} */ (['a'])).encode('b') },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace the inline JSDoc cast with a checked declaration

In the migrated proof, this inline cast replaces an explicit generic argument with a type assertion, so the fixture's initializer is no longer checked against the intended readonly string[] declaration in the repository's preferred way. Declare a separately annotated test value and pass it to encoding; this preserves the deliberate widening needed to call encode('b') without introducing an unsafe cast.

AGENTS.md reference: AGENTS.md:L572-L589

Useful? React with 👍 / 👎.

@@ -1,4 +1,4 @@
import { sloth, p } from './module.f.ts'
import { sloth, p } from './module.f.mjs'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the VDF README for the renamed proof

When this proof is renamed to .f.mjs, fjs/crypto/vdf/README.md:28 still directs readers to proof.f.ts. A repo-wide filename search confirms that path no longer exists in this directory, so the test-vector documentation should be updated to reference proof.f.mjs as part of the rename.

Useful? React with 👍 / 👎.

token_symbol/proof.f.mjs now declares a separately annotated const
instead of an inline JSDoc cast, per AGENTS.md's preferred pattern.
crypto/vdf/README.md pointed at the deleted proof.f.ts.
@sergey-shandar

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 2931e582ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 03126e4 Aug 11, 2026
19 checks passed
@sergey-shandar
sergey-shandar deleted the claude/convert-f-ts-to-f-mjs-9 branch August 11, 2026 05:39
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.

3 participants