Skip to content

Port the doc and version checkers from Python to Flow - #959

Merged
godofecht merged 6 commits into
mainfrom
port/doc-checkers-to-flow
Sep 27, 2026
Merged

godofecht merged 6 commits into
mainfrom
port/doc-checkers-to-flow

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Ports the Python scripts CI runs for docs and versions to Flow. Each tool is a Flow program under scripts/tools/<name>/main.flow with a bash shim scripts/<name>.sh. The shim runs git, find or gh where Flow cannot, and leaves the results in build/ for the program to read.

No Python is needed. scripts/tools/build_tool.sh builds the Stage-A compiler from compiler/bootstrap/flowc_stage_a.c with cc, then compiles the tool in bundle mode. Binaries are cached in build/flow-tools.

Ported

Python (deleted) Flow program Shim Called from
check_stability_manifest.py tools/stability_manifest check_stability_manifest.sh stability.yml, release.yml
sync_version.py tools/sync_version sync_version.sh ci.yml, release.yml, version-bump.yml, finalize-flow-1.0.1.yml, prepare_release.py
check_wiki_links.py tools/wiki_links check_wiki_links.sh wiki.yml
check_doc_links.py tools/doc_links check_doc_links.sh ci.yml
check_doc_coverage.py tools/doc_coverage check_doc_coverage.sh ci.yml
sync_roadmap.py tools/roadmap_sync sync_roadmap.sh Makefile

Shared helpers are in scripts/tools/lib: text.flow (strings, paths, lists, sets, maps), json.flow (reader and writer), unicode.flow (the str.isalnum, str.isspace and str.lower tables, generated from Unicode 15.0 and checked against Python 3.12 for every code point) and mdtext.flow (UTF-8 decoding with errors ignored, splitlines, split).

tests/unit/test_doc_anchors.py and tests/unit/test_doc_coverage.py now drive the shims. They use new options (--slug, --anchors, --inventory, --map, --mentions, --is-backend) instead of importing module internals.

Parity

Each port was compared with the Python script on stdout, stderr, exit code and any files written.

  • Stability manifest. The real manifest and 22 mutations, each with and without --require-complete: all identical. One case differs on purpose: a non-string kind list crashed Python with a TypeError, and the Flow checker reports the unknown kind. The exit code is the same.
  • sync_version. 25 cases, comparing the resulting tree as well: --check and write on the real tree, drifted mirrors, --set with prerelease and build tags, --release-date, --homebrew --sha256, --sha256-from-release against v1.0.1, a missing mirror, a missing canonical assignment, and argument errors. All identical once the program name in usage lines and the "Fix with" hint are normalised.
  • Wiki links. The built wiki, a wiki with 104 broken links across 70 pages, a single broken link, and no build/wiki. The report order matches Python 3.12's Path.rglob order, which the program rebuilds from find's per-directory order.
  • Doc links. The real tree (with --list-ok), and 4 pages seeded with 26 broken links and anchors, including the difflib closest-heading hints. The anchor set of all 1393 tracked markdown files, plus an edge-case page with invalid UTF-8, matches Python's anchors_in.
  • Doc coverage. The inventory matches entry for entry. 23 cases were run in a copy of the tree outside any dot-directory, because Python's all_doc_pages drops every page when the checkout path has one. They cover the real map, --propose, --write-proposal, broken mappings, new compiler features, Unicode word boundaries and argument errors. All identical, including the rewritten coverage.json.
  • sync_roadmap. A fake gh served the live list of 52 roadmap issues and logged every call. In 16 cases, covering dry runs, syncs that create, adopt and close issues, a failing gh issue list, and extra roadmap rows, the output, the rewritten checklist and the exact gh calls (issue bodies included) all matched.

Left in Python

  • scripts/wiki_nav.py is a library imported by scripts/build_wiki.py and tests/unit/test_wiki_nav.py. It is not an entry point, so it moves when build_wiki.py does.
  • ROADMAP.md still names scripts/sync_roadmap.py in two sentences. The house-rules commit hook scans whole staged files, and ROADMAP.md has 64 pre-existing findings. Rewording it would also change the text the roadmap sync parses. Those two references need a follow-up.

Flow gaps found

The stability manifest checker is now scripts/tools/stability_manifest/main.flow,
run through scripts/check_stability_manifest.sh. The shim builds the Stage-A
compiler from the checked-in bootstrap C with cc, so the check needs no Python.

scripts/tools/lib holds the helpers the ported tools share: byte-string and
path utilities, a string list and set, and a JSON reader.

Parity: stdout, stderr and exit code match the Python checker on the real
manifest and on 22 mutated manifests, with and without --require-complete.
The one difference is a non-string kind list, where Python crashed with a
TypeError and the Flow checker reports the unknown kind.
scripts/tools/sync_version/main.flow now owns version mirroring, run through
scripts/sync_version.sh. The mirror patterns are expressed as literal text
plus one character-class run, matched with Python re semantics (greedy runs
with backtracking, MULTILINE anchors). The shim downloads and hashes the
release tarball for --sha256-from-release, since Flow has no network access.

Workflows, RELEASE-1.0.md, prepare_release.py and the version.py docstring
now call the shim. build_tool.sh prefers clang, because flowc output relies
on clang pragmas that GCC 14 would reject.

Parity: 25 cases compared stdout, stderr, exit code and the resulting tree
against the Python script: --check and write on the real tree, drifted
mirrors, --set with prerelease and build tags, --release-date, --homebrew
with --sha256, --sha256-from-release against v1.0.1, a missing mirror, a
missing canonical assignment, extra driver lines, a non-breaking space, and
argument errors (unknown, ambiguous prefix, missing value, bad semver,
--check with --set). All identical once the program name in usage lines
and the 'Fix with' hint are normalised to the shim.
scripts/tools/wiki_links/main.flow validates links in build/wiki, run through
scripts/check_wiki_links.sh. The shim lists the built tree with find(1); the
Flow program rebuilds Python 3.12's Path.rglob order from it, so broken
links are reported, and truncated at 40, in the same order as before.

scripts/tools/lib/unicode.flow adds the Unicode classes the ports need to
match Python exactly: str.isalnum (re \w), str.isspace (re \s) and
str.lower, as range tables generated from Unicode 15.0. The tables were
checked against Python 3.12 for every code point.

Parity: identical stdout, stderr and exit code on the freshly built wiki, on
a wiki with 104 broken links across 70 pages (docs/ prefixes, repo-root
links, example siblings, absolute paths, nested brackets, Unicode spaces,
paths escaping the tree), on a single broken link, and with no build/wiki.
scripts/tools/doc_links/main.flow checks relative links and heading
fragments in tracked markdown, run through scripts/check_doc_links.sh, which
leaves git ls-files output in build/doc-links/. The port covers the link
regex (lazy target, optional title), GitHub heading ids with Unicode \w and
lower(), numbered repeats, id=/name= anchors, and the difflib closest-heading
hint (SequenceMatcher ratio, ties to the larger string).

Two debugging modes replace the Python imports the unit tests relied on:
--slug TEXT prints a heading id and --anchors FILE lists a page's anchors.
tests/unit/test_doc_anchors.py now drives the shim.

Parity: identical output and exit code on the real tree, with --list-ok, and
on 4 pages seeded with 26 broken links and anchors (titles, nested brackets,
directory links, paths outside the repo, Unicode targets, newlines inside
the parentheses), plus single-link cases. The anchor set of every tracked
markdown file, and of a page of edge-case headings with invalid UTF-8,
matches the Python anchors_in exactly (1393 files).
scripts/tools/doc_coverage/main.flow checks that every keyword, attribute,
CLI command, stdlib module and backend has a documented home, run through
scripts/check_doc_coverage.sh. The shim writes the git ls-files and find
listings the program cannot make itself. --propose and --write-proposal are
ported too, including json.dumps(indent=2, sort_keys=True) output.

The attribute list is now read from the frozenset literals that
KNOWN_ATTRIBUTES unions in src/flow/attributes.py, so the checker needs no
Python import. tests/unit/test_doc_coverage.py drives the shim through new
--inventory, --map, --mentions and --is-backend options instead of
monkeypatching module internals.

Parity: the inventory matches the Python one entry for entry. Output, exit
code and the rewritten docs/coverage.json are identical across 23 cases run
in a copy of the tree outside any dot-directory: the real map, --propose,
--write-proposal (with and without an existing map), unmapped features,
missing and silent pages, dropped features, blank and null exemptions, more
than 60 problems, new keywords, attributes, CLI arms, backends and stdlib
modules, Unicode word boundaries, and argument errors.
scripts/tools/roadmap_sync/main.flow extracts open ROADMAP.md items, matches
them to [roadmap] issues and rewrites docs/project/issues-checklist.md.
scripts/sync_roadmap.sh runs it in three phases around the gh calls Flow
cannot make: check arguments, plan (report, or write the gh calls to
build/roadmap-sync/plan.txt), then apply the checklist rewrite with the
numbers of the issues gh created.

The Makefile targets and CONTRIBUTING.md now point at the shim.

Parity: a fake gh on PATH served the live list of 52 roadmap issues and
logged every mutating call. Across 16 cases (dry run, verbose and quiet
syncs that create, adopt and close issues, a failing gh issue list, extra
roadmap rows covering tables, checkboxes, numbered items, en dashes, escaped
pipes and non-ASCII titles, a completed item, a URL-form --repo, missing
files and argument errors) stdout, stderr, exit code, the rewritten
checklist and the exact gh calls, issue bodies included, matched the Python
script.
@godofecht
godofecht force-pushed the port/doc-checkers-to-flow branch from fa7f645 to b4ad09d Compare September 27, 2026 20:50
@godofecht
godofecht merged commit 98a2c3f into main Sep 27, 2026
30 checks passed
godofecht added a commit that referenced this pull request Sep 29, 2026
Dashes, curly quotes and emoji heading markers are gone. Item titles keep
their words, so every roadmap slug is unchanged: a dry run of
scripts/sync_roadmap.sh plans the same creates, adoptions and closes as
before. The sync is named as scripts/sync_roadmap.sh, since the Python
script was deleted in #959.
godofecht added a commit that referenced this pull request Sep 29, 2026
Adds the scripts and tools ported to Flow in #959, #965 and #981, notes
that flow run needs no Python since #960, and lists open pull requests
as in progress. The LSP is Python and the only server; the Flow REPL is
in open PR #987.
godofecht added a commit that referenced this pull request Sep 29, 2026
Dashes, curly quotes and emoji heading markers are gone. Item titles keep
their words, so every roadmap slug is unchanged: a dry run of
scripts/sync_roadmap.sh plans the same creates, adoptions and closes as
before. The sync is named as scripts/sync_roadmap.sh, since the Python
script was deleted in #959.
godofecht added a commit that referenced this pull request Sep 29, 2026
Adds the scripts and tools ported to Flow in #959, #965 and #981, notes
that flow run needs no Python since #960, and lists open pull requests
as in progress. The LSP is Python and the only server; the Flow REPL is
in open PR #987.
@godofecht
godofecht deleted the port/doc-checkers-to-flow branch October 1, 2026 12:50
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