Repository navigation
Package management in Flow: native install/add/sync and flowc package imports - #989
Merged
Merged
Conversation
This was referenced Sep 27, 2026
godofecht
force-pushed
the
port/pkg-native
branch
from
September 29, 2026 07:10
1ddf8ec to
1149cea
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
godofecht
force-pushed
the
port/pkg-native
branch
from
September 29, 2026 07:52
1149cea to
4a08189
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
compiler/src/pkg.flow now holds the package manager that src/flow/package.py was for these commands: registry index reading (FLOW_REGISTRY_PATH and FLOW_REGISTRY_URL included), version selection, path/git/stdlib installs into flow_packages/, and flow.lock written byte for byte as json.dumps(indent=2) wrote it. pkg_json.flow is the value tree with the JSON reader/writer and a TOML reader; semver.flow follows the registry's parse_semver and version_matches exactly. Flow calls system()/popen() with one command line, so git, curl, tar and cp run through scripts/tools/pkg_fetch.sh. Every decision stays in Flow. flow-driver builds the tool with the Stage-A compiler from the checked-in bootstrap C (ensure_flowc.sh --cc-only) and routes add, install, sync, search, info and the install step of flow run to it. Building helper tools through the Python roundtrip recursed without end whenever compiler/src had local edits, because the roundtrip itself calls flow run. scripts/check_pkg_parity.sh compares both implementations on 134 cases: every registry package, path/git/stdlib dependencies, a registry override with several versions, and the error paths. All pass. The unused Stage-A pkg scaffolding (build_pkg.sh, its test, toml.flow, project_config.flow) is removed.
A dotted import whose first segment is a key of the project's [dependencies] (and not of [paths], and not std) now resolves under <project>/flow_packages/<name>/src, then <project>/flow_packages/<name>, longest module prefix first. The project is the nearest flow.toml above the entry file. These are the Python host's module_resolver rules. A declared package that is not installed is an error that names flow sync. check_run_without_python.sh now runs a program that imports json.lib with nothing installed: flow run installs the package with the Flow package manager, writes flow.lock, resolves the import and runs it, all with the python stubs never called. It also runs flow sync, add, pkg install, search, info, and an unknown dependency. The check needs the regenerated bootstrap C to pass from a clean checkout.
src/flow/package.py keeps init, publish, build, clean and the native build/run that flow-driver's demos call. add, install, sync, search, info, the lock helpers, the git helpers and sync_for_program are gone (611 lines). src/flow/registry.py keeps what publish needs: loading the index and publish_local (164 lines less). The unit tests for the removed code now run the Flow package manager through flow-driver with the same assertions. docs/project/package-registry.md says which commands are Flow and how flowc resolves package imports.
shellcheck SC2012 failed Lint. The script reads the mode of a single regular file, where ls -l is the portable choice.
godofecht
force-pushed
the
port/pkg-native
branch
from
September 29, 2026 08:24
4a08189 to
d2167a7
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
Rebased onto main containing #1003, #999, #998 and #989. Carries #1001's parse-only mode, located parse errors (flowc_parser_print_error, which the driver, emit and bundle paths now use), theorem/assume/therefore/claim references, flow blocks, handle, ui layout and pipeline blocks, let without initializer, contextual unit, distinct, effect rows, or-patterns, guards, nested patterns, [T; N], capability types, ?, vector literals, soft names, sort-by keys, entropy policies and module blocks, the parse coverage script and its CI floor, and the Python-grammar parser contract test. The #1001/#1003 reconciliation follows the one in #1012.
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.
What
Package management no longer needs Python, and flowc resolves registry package imports.
This branch contains #960 (first five commits). Merge #960 first, or merge this and close #960.
Package manager in Flow
compiler/src/pkg.flowis the package manager thatsrc/flow/package.pywas foradd,install,sync,search,infoand the install step offlow run:FLOW_REGISTRY_PATH,FLOW_REGISTRY_URL(curl, cached under$FLOW_HOME/cache) and the legacypackets/crateskeys;parse_semver/version_matchesrules (compiler/src/semver.flow);flow_packages/;flow.lockwritten byte for byte asjson.dumps(indent=2)wrote it;flow addrewritesflow.tomlasFlowPackage.to_tomldid.compiler/src/pkg_json.flowis the value tree with a JSON reader/writer and a TOML reader.compiler/src/pkg_main.flowis the CLI with the old argparse interface and exit codes.Flow calls
system()/popen()with one command line, so git, curl, tar and cp run throughscripts/tools/pkg_fetch.sh. The shim only executes; every decision (what to fetch, which ref, what to do on failure, the error text) is in Flow.flow-driverbuilds the tool with the Stage-A compiler and routesadd,sync,install(with aflow.toml),search,info,pkg add|install|sync|search|infoandflow run's install step to it.flowc resolves
import json.libcompiler/src/resolve.flow: a dotted import whose first segment is a key of the project's[dependencies](and not of[paths], and notstd) resolves under<project>/flow_packages/<name>/src, then<project>/flow_packages/<name>, longest module prefix first. The project is the nearestflow.tomlabove the entry. These are the Python host'smodule_resolverrules. A declared package that is not installed is an error that namesflow sync. Bootstrap C regenerated in its own commit.A recursion fixed on the way
With #960,
flow runbuildspkg_syncthroughensure_flowc.sh. Whencompiler/srchas local edits,ensure_flowcstarts the Python roundtrip, which callsflow run, which buildspkg_sync, which callsensure_flowcagain, without end. This hit the AGENTS.md regeneration step. Helper tools are now built withensure_flowc.sh --cc-only, which uses the checked-in bootstrap C and never starts the roundtrip.Python removed
src/flow/package.py: 611 lines. Gone:add,install,install_package,_install_git_dependency,sync_for_program,search,info, the lock and git helpers, and their CLI subcommands. Kept:init,publish,build,run,clean,build_native/run_native(flow-driver's demos call them),FlowPackage.src/flow/registry.py: 164 lines. Kept whatpublishneeds.compiler/scripts/build_pkg.sh(it built the old Stage-A pkg stub through the Python transpiler), its test, and the unusedcompiler/src/toml.flowandproject_config.flow.scripts/python_ratchet.sh --updatetightened the baseline.Proof
Parity,
scripts/check_pkg_parity.sh: each case runs in two fresh copies of a project, one per implementation, with the Python side read from git history (660ff30d). It compares stdout (colours included), exit status,flow.toml,flow.lock, andflow_packages/(file list, contents, modes; for git clones the checked-out commit).Cases: install,
sync --program,addandadd name@^0.1.0for all 19 packages inregistry/packagesplusflow-verify;@latest,>=,==; unknown package (add, install, sync); bad and garbage version constraints; partial failure; existing lock with foreign entries and non-ASCII; malformed lock; path dir/file/missing; stdlib; local file; unsupported spec; git tag/rev/branch+subdir/bad subdir/bad tag; git URL shorthand; a registry override with several versions, a yanked one,v-prefixed and pre-release versions, a git source; search and info.No Python,
scripts/check_run_without_python.shfrom a cleancompiler/buildandbuild/, python and python3 stubbed to log and exit 127:Compiler: fixed point OK;
bootstrap_from_c.sh --verify,self_host_full.sh,roundtrip.sh,selfcompile_audit.shall pass (the new pkg modules compile with 0 diagnostics). Thetests/langbootstrap suite gives the same pass/fail set as origin/main's bootstrap (119/19).pytest tests/unit -m "not slow": 1771 passed; the 2 errors intest_match_exhaustive_returns.pyare on main too (it readsbuild/m.c, butflow runnow builds inbuild/run.XXXXXX).With the packages installed natively and built by flowc, 13 of the 16
examples/ecosystemdemos build and run, including json, toml, serde, http, sqlite and compress.What remains
check_pkg_parity.shis not in CI. A job needsfetch-depth: 0and python3. I did not edit the workflow.init,publish,build,build-native,run-native,cleanare still Python.log_demo,testing_demoandapp_cachedo not build on flowc: thelogpackage uses effects andtestingfails the Stage-A typecheck. Resolution works; the packages hit Stage-A gaps.package.pynever had them, so neither does this.flow.lockor the index are written back as parsed. Python would print its ownrepr. Neither file has floats.