Repository navigation
tools: port the remaining scripts/*.py to Flow - #971
Merged
Merged
Conversation
This was referenced Sep 27, 2026
Contributor
Author
|
Merge train: rebased onto main (now containing #959, #960, #965, #966 and the Python ratchet from #981). Not merged. Commits added after the port (Jules dispatch backpressure and tool layout checks) add two new Python files, scripts/check_tool_layout.py and tests/integration/test_jules_dispatch.py, so the Python ratchet job fails: "2 new Python file(s). New code is written in Flow." Port them to Flow or shell and this can merge. |
godofecht
force-pushed
the
port/scripts-rest-to-flow
branch
from
September 27, 2026 21:18
1c3739b to
7eb4cec
Compare
scripts/wasm held stale copies of wasm/flow_to_wasm.py, flow_wasm.py, demo_wasm_build.py, wasm_build_system.py, hello_harness.c and the demo pages. Nothing ran them. examples/demos/index.html now points at ./flow wasm, as demos/index.html does.
scripts/check_changelog.sh and scripts/prepare_release.sh run the Flow programs in scripts/tools/changelog_check and scripts/tools/prepare_release. The changelog, release-pr-prepare and finalize-flow-1.0.1 workflows call the shims. Parity against the Python scripts: 11 changelog cases (real tree, missing section, duplicates, Unicode whitespace, headings split over lines) and 18 prepare_release cases run in full copies of the tree (new release, rc suffix, already-present version, bad version, empty or malformed notes, missing Unreleased section, missing current-release paragraph, missing history rows, relative --root from another directory, argparse errors and help). stdout, stderr, exit code and the resulting tree all match.
scripts/update_repo_stats.sh now builds scripts/tools/repo_stats with build_tool.sh (Stage-A flowc from the bootstrap C) instead of the Python transpiler, and no longer cross-checks or falls back to update_repo_stats.py, which is deleted. The counter's messages now match the Python script's (the stale-file list, the source-line total), and the README footer drops the Python link. Parity before deleting: write mode and --check (stale and current) on the real tree gave identical README.md, repository-stats.json, stdout, stderr and exit codes. A missing marker exits 1 in both; Python printed a traceback, Flow prints one line. tests/unit/test_repo_stats.py now runs the Flow counter in a scratch tree and pins the same rules (rounding, component-wise area matching, grouped numbers, marker handling). stats.yml drops setup-python.
scripts/dispatch_uncovered_jules.sh runs scripts/tools/jules_dispatch, which calls gh and jules through the shell, keeps the same jules_dispatch_state.json (sorted keys, two-space indents, ASCII escapes), and holds, retries and gives up exactly as before. Parity with fake gh and jules CLIs on PATH (waits skipped on both sides): 8 cases covering live-session filtering, an existing state file with extra keys, refusals, capacity holds, giving up after 40 refusals with a 200-character detail, an empty queue, a corrupt state file and a failing gh. stdout, the state file, every task text piped to jules and the gh arguments match; so does the exit code. On a failing gh, Python printed a traceback and Flow prints one line.
- record_tetris_gif.py marked itself deprecated: it redrew Tetris in Pillow instead of running the game, and running it overwrote the real recording that record_demos.py produces. Only a ROADMAP.md table row names it. - compile_mlir_examples.py was an ad hoc sweep of every example through `flow.transpiler --mlir`. Nothing runs it: no workflow, script, doc or test names it. verify_examples covers the corpus sweep. - wiki_shots.py took Playwright screenshots of a local wiki server into /tmp/wikishots for one visual review. Nothing references it.
build_demo_overview, build_shader_gallery, sync_demo_nav and gen_abi_bindings are now Flow programs under scripts/tools (demo_overview, shader_gallery, demo_nav, abi_bindings) with .sh shims. Shared helpers (html.escape, argparse-style flags, json.dumps with ensure_ascii=False, Python truthiness) are in scripts/tools/lib/demogen.flow. Parity (stdout, stderr, exit code, written tree): - build_demo_overview: 20 cases, 19 identical; the 20th is a truncated catalog.json, where exit code and tree match and the JSON error wording differs. - build_shader_gallery: 15 of 15 identical. - sync_demo_nav: 13 cases, 12 identical; same JSON wording difference. - gen_abi_bindings: 25 of 25 identical. The checked-in vulkan_abi headers and bindings matched the Python output byte for byte before their "Auto-generated by" line was switched to the shim. Program names in usage lines now say .sh; where Python crashed with a traceback, Flow prints the same final line. tests/unit/test_demo_gallery_docs.py drives the shims' --check modes and adds a nav sync check.
scripts/wasm_build.sh and scripts/build_wasm_gallery.sh run the Flow program in scripts/tools/wasm_build (modes build, gallery, gallery-one). Page text lives in scripts/tools/wasm_build/assets. The gallery builds targets in parallel through xargs -P. The transpile step still runs python3 -m flow.transpiler, as before. ./flow wasm, the integration tests and the docs call the shims; the Python scripts are deleted. Parity against the Python on 29 wasm_build cases (console, gfx, mlir, preload, link, threads, keep-c, broken and unlinkable programs, argparse errors) and 9 gallery cases (list filters, an 8-target --only build with every extras kind, all of morphogenesis): identical stdout, stderr, exit codes and files, with build times masked. One .js built at -O1 embeds an emscripten temp path that differs between any two runs. The manifest's generated_by names the shim. One deliberate change from the Python: the tiny_pointers card note is reworded to drop an "X, not Y" sentence, so that page differs from the Python output on that line. site/wasm/index.html keeps its old footer until the next gallery rebuild (the prose hook blocks edits to it).
scripts/verify_examples.sh and scripts/triage_verify_failures.sh run the Flow programs in scripts/tools/verify_examples and scripts/tools/triage_verify_failures. Shared pieces (argparse emulation, find-based discovery, timed stages, xargs -P fan-out) live in scripts/tools/lib/verify_run.flow. The transpile stage still calls python3 -m flow.transpiler, as the Python scripts did. Parity: full default runs of both tools (1557 and 1054 files) gave the same stdout, stderr, exit code, --json output and examples/STATUS.md (timestamp masked), plus 30 cases covering broken inputs, timeouts, sample limits, file roots, relative --json paths and argparse errors. Triage tags match Python's tag_features on 2235 files. The STATUS.md header and triage prose now name the .sh shims and drop em dashes. Only --jobs 0 differs: Python printed a traceback. examples/STATUS.md is regenerated by the Flow tool.
scripts/build_wiki.sh runs scripts/tools/build_wiki, which replaces build_wiki.py, wiki_nav.py, gen_stdlib_docs.py and the tutorial_lessons path of docs_blocks.py. Shared code is in scripts/tools/lib/wiki_*.flow. gen_stdlib_docs.sh and wiki_nav.sh expose the stdlib page generator and the nav checker on their own. build_pagefind.sh stages its HTML stubs through `build_wiki --pagefind-stage` instead of embedded Python. wiki.yml, check_wiki_links.sh, deploy_wiki.py and RELEASING.md call the shims; test_wiki_nav.py drives wiki_nav.sh. Parity: on the real tree the whole build/wiki output (3,226 files), stdout, stderr and exit code match the Python build, and so does the regenerated stdlib-api.md. 13 mutated trees (dead or orphaned nav entries, missing CHANGELOG and ledger, CRLF and invalid UTF-8 pages, hidden and cache directories, ROADMAP link rewrites, every proof import form, fence edge cases) match on tree, stdout and exit code. The two crash cases, malformed nav.json and an unknown info-string flag, print one line where Python printed a traceback. Pagefind stubs match on the real and an edge-case index. After parity, three generated pages name the new scripts instead of the deleted Python. deploy_wiki.py stays for its legacy VPS path, which reads credentials through the aissh ssh_client Python library. docs_blocks.py stays for check_doc_examples.py and check_doc_flow_snippets.py.
The doc link check fails on the README footer's link to the deleted update_repo_stats.py. Editing README.md meant clearing its two existing prose findings: the toolchain sentence is reworded, and the counter now writes n/a for the registry-packages line count instead of a dash.
The Python ratchet rejects new .py files. check_tool_layout.py becomes check_tool_layout.sh, and the five Jules dispatch backpressure cases move from tests/integration/test_jules_dispatch.py to scripts/tools/jules_dispatch/test.sh with the same fake gh and jules commands. CI runs both in the doc-links job.
godofecht
force-pushed
the
port/scripts-rest-to-flow
branch
from
September 27, 2026 22:56
7eb4cec to
cbb1efc
Compare
shellcheck runs without -x in Lint, so sourcing scripts/tools/wasm_build/env.sh reported SC1091 and failed the job.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
#971 changed a comment in docs/vision/examples/pendulum.flow from verify_examples.py to verify_examples.sh. The ex_ fixture must match its source byte for byte.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
#971 changed a comment in docs/vision/examples/pendulum.flow from verify_examples.py to verify_examples.sh. The ex_ fixture must match its source byte for byte.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
#971 changed a comment in docs/vision/examples/pendulum.flow from verify_examples.py to verify_examples.sh. The ex_ fixture must match its source byte for byte.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the rest of the top-level
scripts/*.pyto Flow, deletes the unused ones, and removesscripts/wasm/. Each port is a Flow program inscripts/tools/<name>/main.flowbehind a bash shim, built byscripts/tools/build_tool.shfrom the bootstrap C.Depends on #959 and #965, which should merge first. Both branches are merged in, and this PR reuses their
build_tool.sh,lib/*.flowand shim pattern. The only conflict was inbuild_tool.shandlib/text.flow, where #959's copy is a superset; I kept it.Ported (Python deleted)
check_changelog.pytools/changelog_check,check_changelog.shprepare_release.pytools/prepare_release,prepare_release.sh--rootfrom another directory, argparse errors, help. stdout, stderr, exit code and the resulting tree all identical.update_repo_stats.pytools/repo_stats(existing),update_repo_stats.sh--check(stale and current) on the real tree: README.md, repository-stats.json, stdout, stderr and exit code identical. The counter's messages were changed to match Python's. It now builds with Stage-A instead of the Python transpiler.tests/unit/test_repo_stats.pyruns the Flow counter in a scratch tree.dispatch_uncovered_jules.pytools/jules_dispatch,dispatch_uncovered_jules.shghandjuleson PATH, waits skipped: 8 cases (live-session filter, existing state with extra keys, refusals, capacity holds, giving up after 40 refusals, empty queue, corrupt state, failing gh). stdout, state file, every task text piped to jules, and gh arguments identical.build_demo_overview.py,build_shader_gallery.py,sync_demo_nav.pytools/demo_overview,tools/shader_gallery,tools/demo_navand shims; helpers inlib/demogen.flow--check, stale and missing output, preview and asset checks, escaping, Unicode, missing keys, argparse). The one difference is a truncated JSON file: exit code and tree match, and the decode-error wording differs.gen_abi_bindings.pytools/abi_bindings,gen_abi_bindings.shdemos/vulkan_abiandexamples/demos/vulkan_abibindings matched byte for byte before their "Auto-generated by" line was switched to the shim.wasm_build.py,build_wasm_gallery.pytools/wasm_build(modes build, gallery, gallery-one),wasm_build.sh,build_wasm_gallery.sh./flow wasm, test_wasm_backends.py, docs/language/wasm.md, .gitignorexargs -P. One deliberate change: the tiny_pointers card note was reworded because the prose rules flag its contrast sentence. The transpile step still callspython3 -m flow.transpiler, as before.verify_examples.py,triage_verify_failures.pytools/verify_examples,tools/triage_verify_failures, shims; helpers inlib/verify_run.flow--jsonoutput and examples/STATUS.md identical with the timestamp masked. Plus 30 cases (broken inputs, timeouts, sample limits, argparse). Triage tags match Python'stag_featureson 2235 files. STATUS.md is regenerated.build_wiki.py,wiki_nav.py,gen_stdlib_docs.py(and thetutorial_lessonspath ofdocs_blocks.py)tools/build_wiki,tools/wiki_nav,tools/gen_stdlib_docs,lib/wiki_*.flow, shimsbuild_wiki --pagefind-stage), deploy_wiki.py, RELEASING.md, test_wiki_nav.pybuild/wikioutput (3,226 files), stdout, stderr and exit code are identical to Python's. So is the regenerated stdlib-api.md. 13 mutated trees (nav problems, missing CHANGELOG or ledger, CRLF and invalid UTF-8, hidden dirs, link rewrites, proof imports, fence edge cases) are identical. Pagefind's own hashed files differ between any two runs.Where the Python crashed with a traceback (a missing file, gh failing, a malformed nav.json,
--jobs 0), the Flow tool prints one line and exits with the same code. Usage lines say.shwhere Python said.py.Deleted without a port
scripts/wasm/(4 .py,hello_harness.c, demo pages)wasm/helpers that #965 retired. Nothing ran them.examples/demos/index.htmlnow points at./flow wasm, asdemos/index.htmldoes.record_tetris_gif.pyrecord_demos.py. Only a ROADMAP row names it.compile_mlir_examples.pywiki_shots.py/tmp/wikishotsfor one visual review, with no references anywhere.Stays in Python, and why
check_doc_examples.py,check_doc_examples_strict.pyflow.parser,flow.c_generator, the type checker).check_doc_flow_snippets.pycheck_doc_examples.verifyin process.docs_blocks.pyverify_browser_interp.py.compile_spirv_metal.py,emit_fsl_wgsl.py,record_shader_gallery.py,run_bench.py,test_lsp_server.pyflow.*(mlir_spirv,shader_codegen_wgsl,shader_codegen,MLIRJIT,lsp_server/type_checker).verify_browser_interp.pyframes_to_gif.py,record_demos.pyplayground_compile_server.py,ws_echo_relay.pywiki_contrast.py,wiki_verify.pydeploy_wiki.pyssh_clientPython library. Its default path now builds withbuild_wiki.sh.Docs left unedited
The house-rules commit hook scans whole staged files. These files already had em dashes or other flagged constructions, so they still name the old
.pyscripts:ROADMAP.mddocs/project/python-in-flow.mddocs/demos/README.md,docs/demos/wasm.md,docs/language/shaders.md,docs/AI_FLOW_HANDBOOK.mdexamples/README.md,Questions.md,docs/project/Questions.md,docs/vision/north-star.md,docs/third-party/flow-verify-parser-status.mddocs/wiki-strategy.md,docs/wiki-roadmap.md,docs/third-party/README.md,docs/third-party/flow-verify.md,docs/third-party/proof-graph.md,site/proof-graph.htmlsite/wasm/index.html. Its footer names the old script until the next gallery rebuild.README.mdwas edited: its stats footer linked the deletedupdate_repo_stats.py, which failed the doc link check. Clearing its two existing findings meant rewording the toolchain sentence and having the counter writen/afor the registry-packages line count.docs/library/stdlib-api.mdpicks up the new header on its next regeneration.Flow gaps found
+on a stringconstcompiles to pointer addition. Workaround: copy the const into a typed local, or return the text from a function.desccompiles to0.extern time()is declared nowhere in the generated C. Workaround:date -uthrough popen.Testing
python3 -m pytest tests/unit: 1795 passed, 4 skipped.test_doc_anchorspasses after the README fix. The two errors intest_match_exhaustive_returns.pycome from./flow runnot leavingbuild/m.cin this worktree; that path is untouched here.scripts/build_wiki.shfollowed byscripts/check_wiki_links.shpasses, andscripts/check_doc_links.shreports no broken links.Agent-loop follow-up
Closes #972.
Closes #973.
Contributes to #975 by treating red main CI as backpressure and deferring low-priority dispatch until the baseline is repaired.