Skip to content

Port the last Python to Flow; ratchet at total 0 - #1076

Merged
godofecht merged 2 commits into
mainfrom
port/last-python
Sep 30, 2026
Merged

godofecht merged 2 commits into
mainfrom
port/last-python

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Builds on #1072 (base is selfhost/mlir-finish; it retargets to main when #1072 merges, and I will rebase then).

Ports the last 64 tracked Python files (6,930 lines). After this, the only .py files are benchmark subjects and the Python side of the interop demo, both excluded by name in the ratchet. The baseline is total 0, and any other .py fails scripts/python_ratchet.sh.

Per file

Was Now
12 pytest files in tests/unit, tests/integration, 3 __init__.py, tests/conftest.py, pytest.ini Shell tests in tests/scripts/ (same assertions and skip conditions), ./flow test-scripts. Pillow is replaced by scripts/tools/gif_check, a GIF89a reader in Flow
tests/unit/test_benchmarks.py tests/bench_harness/run.sh
benchmarks/run_benchmarks.py scripts/tools/bench_harness behind benchmarks/run_benchmarks.sh
29 benchmark subjects (cross_harness, publish/python, suite/python, record_numpy.py) Moved to benchmarks/baselines/python/. Harnesses run them when python3 is present and skip them otherwise
wasm/flow_to_wasm.py scripts/tools/flow_to_wasm behind scripts/flow_to_wasm.sh (flow wasm --legacy)
examples/interop/simple_interop.py, examples/wasm/python/flow_demo.py Moved to examples/interop/python/
site/wasm-crossings/python/flow_demo.py Deleted; the page hands Pyodide the listing it already embeds
examples/bench/pymatmul.py Deleted (no callers)
scripts/frames_to_gif.py scripts/tools/frames_to_gif, median cut and Floyd-Steinberg in scripts/tools/lib/gifclip.flow, indexed frames in lib/stdlib/gif.flow
scripts/record_demos.py scripts/tools/record_demos behind scripts/record_demos.sh
scripts/playground_compile_server.py scripts/tools/playground_server behind scripts/playground_compile_server.sh
scripts/ws_echo_relay.py scripts/tools/ws_echo_relay behind scripts/ws_echo_relay.sh (RFC 6455, SHA-1 and base64 in scripts/tools/lib/digest.flow)
scripts/wiki_contrast.py, scripts/wiki_verify.py scripts/tools/wiki_browser: drives headless Chrome over the DevTools Protocol from Flow; scripts/wiki_serve.sh replaces python3 -m http.server
scripts/deploy_wiki.py Folded into scripts/deploy_wiki.sh (ssh/scp)
tools/audio/*.py scripts/tools/lattice_allpass (WAV and SVG from Flow, DSP through lib/stdlib/audio/lattice_allpass.flow)
tools/discord-welcome/*.py, requirements.txt scripts/tools/discord_welcome: Gateway and REST over TLS through OpenSSL, with a --replay mode for offline tests

Parity

Each port recorded the Python outputs and exit codes before deletion.

  • Byte-identical: the legacy wasm converter (11 cases, including real emcc), the playground server and relay (48 exchanges), the wiki checks (three builds, including one broken on purpose), the demo table (122 demos) and the audio demo's printed numbers and input.wav.
  • Structural: GIFs match in frame count, size, delay, loop and disposal, but the bytes differ from Pillow's quantiser. Colour error is comparable, except on one clip where the Flow output is about twice Pillow's.
  • Last bit: the audio WAVs from the f32 stdlib lattice differ by at most 1 LSB.
  • Discord bot: checked for env errors, TLS (real host and badssl rejects), the live gateway handshake and a replay. There was no real token, so a live welcome post is untested.

CI

  • The pytest job is now conformance (the corpus step only).
  • native-tools runs tests/scripts/run.sh and also triggers on tests, lib and runtime changes. tests/tools/run.sh now covers the wasm converter, the network tools, frames_to_gif, the audio tools and the bot.
  • doc-links runs tests/bench_harness/run.sh.
  • flow test-python is now flow test-scripts.
  • The lint and security jobs still run ruff, mypy and bandit on src/, which selfhost: finish the MLIR port and delete src/flow #1072 deleted. I left them for a follow-up.

Gates

All run with python and python3 stubbed out of PATH. No gate called Python.

  • Pass:
    • Bootstrap and self-host: bootstrap_from_c.sh --verify, self_host_full.sh, roundtrip.sh.
    • parse_coverage.sh --check, fmt_check.sh --check, tests/cgen/run.sh (102).
    • ./flow test-lang (216), corpus_parity.sh --check.
    • parity_* for dap, dynamics_dsl, effects, field_dsl, flow_blocks, lowering, mlir (1252), project_test, proofs and targets.
    • tests/mlir_commands/run.sh (72).
    • Converted and new tests: tests/scripts/run.sh, tests/tools/run.sh, tests/bench_harness/run.sh (43), tests/pywheel/run.sh (18).
    • Checks: the ratchet, doc coverage, doc links and tool layout.
  • Not passing:
  • Updated goldens: three corpus.txt digests. They cover gif.flow and its two users; flowc and the Python generator at bb23f19 agree on their MLIR.

Issues

Rebuilt on main from port/last-python (#1076) after #1072. The new
scripts/tools programs pass the strict type check; record_demos keeps
its cached root in a ptr<u8> static, since module statics cannot be
strings.
gcc in GNU mode predefines linux as 1, so the generated C read
bool 1 = net_is_linux() and the Linux build failed.
@godofecht
godofecht merged commit 6bdd116 into main Sep 30, 2026
34 checks passed
godofecht added a commit that referenced this pull request Sep 30, 2026
…pty list

tests/scripts/repo_stats.sh (from #1076) runs the counter in a scratch
tree with a hand-written file list and no git. repo_stats now takes
--inputs DIR to read files.txt, meta.txt and mode.txt from DIR, and the
test passes it. ./flow test-scripts passes.

With the ratchet baseline at total 0, git lists no Python and the file
list was a read-only string literal that split_lines wrote into (SIGBUS).
The list is now always a heap copy. The ratchet carries #1076's two
excluded trees in its git call.
godofecht added a commit that referenced this pull request Sep 30, 2026
…pty list

tests/scripts/repo_stats.sh (from #1076) runs the counter in a scratch
tree with a hand-written file list and no git. repo_stats now takes
--inputs DIR to read files.txt, meta.txt and mode.txt from DIR, and the
test passes it. ./flow test-scripts passes.

With the ratchet baseline at total 0, git lists no Python and the file
list was a read-only string literal that split_lines wrote into (SIGBUS).
The list is now always a heap copy. The ratchet carries #1076's two
excluded trees in its git call.
@godofecht
godofecht deleted the port/last-python 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