Skip to content

add Solve It the Flow Way problem gallery - #581

Merged
godofecht merged 10 commits into
mainfrom
agent/solve-it-the-flow-way
Aug 19, 2026
Merged

godofecht merged 10 commits into
mainfrom
agent/solve-it-the-flow-way

Conversation

@godofecht

@godofecht godofecht commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Adds the first problem-first Flow idiom gallery under examples/flow_way/ and surfaces it from the existing Galleries page.

The first executable slice contains sensor calibration expressed as a pipeline with the _ placeholder, plus swappable telemetry expressed with an effect row, capabilities, and scoped handlers. The gallery then points into existing canonical programs for typed forks, choose, hybrid thermostat dynamics, RT safety, channels, and the full effects showcase rather than duplicating those implementations.

A runtime regression test under tests/runtime/test_flow_way_examples.flow pins the two new executable patterns and deliberately causes the strict Tier-2 corpus to run for this PR.

Why

Flow should be demonstrated with problems where its highest-level abstractions change the shape of the solution, rather than only by translating ordinary imperative algorithms. Each gallery entry names the high-level Flow form and the low-level shortcut that should be considered the wrong solution.

Validation

On the latest head, the wiki build, documentation links, documentation coverage, version consistency, and the documentation Flow-snippet compiler are green. Every new fenced flow block in the gallery compiles without ledger exemptions. Strict Tier-2 transpile+clang is also triggered by this PR and is currently in its toolchain-install step.

godofecht added a commit that referenced this pull request Aug 19, 2026
#582)

PR #581 hit this: examples/flow_way/README.md inlined the program from
swappable_telemetry.flow and renamed a variable to `test`, which is a
keyword. The file kept the name that parses, the copy did not, and CI caught
it only because the copy stopped compiling. A rename that still compiled
would have gone unnoticed.

42 blocks sit next to a link to a .flow file. 34 of them no longer appear in
the file they link. Eight are still verbatim copies, and those are now tagged
`from=`, so the checker asserts the block appears in the named file and fails
with which page and which file disagree.

`from=` was listed in docs_blocks as designed but not implemented, alongside
a test asserting it must not parse while it does nothing. That test now
asserts the opposite, which is the point of having written it that way.

Verified by breaking it on purpose: renaming main in examples/book/01_hello.flow
fails the gate with "block no longer appears in examples/book/01_hello.flow".

The remaining 34 are a content job, not a mechanism job: each needs a human
to decide whether the page or the file is the wrong one.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
godofecht and others added 10 commits August 19, 2026 19:46
…eachable

The gallery was in the repository and not on the site. 48 pages under docs/
link to ../../examples/, and every one of those 404'd:

    https://flooooooooooow.github.io/flow/examples/flow_way/README.md  404
    https://flooooooooooow.github.io/flow/examples/README.md           404

The deploy copied docs/ alone. wiki.js was already written for this: it sends
every non-.md file under examples/, lib/, src/ and the rest to GitHub, and
keeps .md as a site page, with a comment saying "a .md under one of these is
still documentation the site may carry". The site just never carried it.

build_wiki.py now copies the 1082 markdown files under examples/ into the
build, and the gallery has a Galleries sidebar entry. Sources still go to
GitHub rather than being served, which is what a reader wants: highlighted
and in context.

check_wiki_links.py needed the same rule the client already had. A copied
page links to its siblings by bare name, so `competitive_lv.flow` from
examples/evoleco/README.md resolves against the repository rather than the
built site. Without that, publishing these pages reported 165 broken links
that are not broken.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht force-pushed the agent/solve-it-the-flow-way branch from 4670a6a to 432cecf Compare August 19, 2026 19:00
@godofecht

Copy link
Copy Markdown
Contributor Author

Rebased onto main and made the gallery actually reachable.

It was published nowhere

The page existed in the repository but not on the site:

https://flooooooooooow.github.io/flow/examples/flow_way/README.md  404
https://flooooooooooow.github.io/flow/examples/README.md           404

The wiki deploy copies docs/ alone, and 48 pages under docs/ link to ../../examples/ — so this is not specific to this PR, it is every one of those links.

wiki.js was already written for this. repoSourceUrl sends non-.md files under examples/, lib/, src/ and the rest to GitHub, and deliberately keeps .md as a site page, with a comment saying "a .md under one of these is still documentation the site may carry". The site just never carried it.

What changed

  • build_wiki.py copies the 1082 markdown files under examples/ into the build. Sources still resolve to GitHub, which is what a reader wants: highlighted, in context, with history.
  • The gallery gets a Galleries sidebar entry. Verified by clicking it in a browser: lands on "Solve It the Flow Way" with all 8 sections, and sensor_calibration.flow links to github.com/.../blob/main/examples/flow_way/sensor_calibration.flow.
  • check_wiki_links.py needed the rule the client already had. A copied page links to siblings by bare name, so competitive_lv.flow from examples/evoleco/README.md has to resolve against the repository rather than the built site. Without it, publishing these pages reported 165 broken links that are not broken.

Verification

Check Result
pytest tests/ 1686 passed, 6 skipped
./flow test --tier2 --strict 690/690
check_wiki_links.py Wiki links OK
check_doc_links.py all links and fragments resolve
check_doc_examples.py --check-ledger no new unverified, 221

The test → quiet_result rename you pushed is in and the gate passes on it.

@godofecht
godofecht marked this pull request as ready for review August 19, 2026 19:44
@godofecht
godofecht merged commit cf4c805 into main Aug 19, 2026
24 checks passed
@godofecht

Copy link
Copy Markdown
Contributor Author

The gallery now runs in the browser.

Why it did not before

In-browser execution was gated to tutorials/ alone:

if (path.startsWith('tutorials/')) {
    initTutorialRunners(content, { autoMain: true });
}

Every other page's examples were listings. Enabled for examples/ pages too.

Effects in the browser interpreter

Most of this gallery is about effects, and the interpreter refused them. It now handles effect declarations, capability declarations in both spellings (capability C for E and capability C { effect E, ... }), handle E with C blocks, effect rows on functions, and Effect.op(...) dispatch through the innermost handler.

Output matches ./flow run byte for byte:

case browser native
swap ConsoleTelemetry / QuietTelemetry control step then 42 42 same
nested handle shadows the outer outer / outer again same
operation returning a value 42 same
no handler installed names the effect, suggests handle —
unknown operation names the effect and the operation —

The three that still cannot run now say why

They used to fail as raw parse errors, which tells a reader nothing:

Error: line 14: unexpected ',' in expression
Error: line 7: unexpected 'flow' at top level

Now:

Not supported in the browser interpreter: '|> Stats { ... }' (a pipeline fork into a struct)
Not supported in the browser interpreter: enum declarations
Not supported in the browser interpreter: flow blocks (continuous dynamics)

The interpreter's stated rule is that it never guesses and names what it cannot run. flow, unit, dsys and field are contextual keywords, so they arrived as identifiers and fell through that rule to the generic top-level error.

Verification

Check Result
verify_browser_interp.py 240 snippets, no new disagreement (pipelines-3 was already failing on main)
pytest tests/ 1686 passed, 6 skipped
gallery in a real browser 2 run with correct output, 3 name their gap

Making the other three run means pipeline forks, enums and a JS ODE solver in the interpreter. Each is its own piece of work rather than something to bolt on here.

godofecht added a commit that referenced this pull request Aug 20, 2026
Two of the five ran. The other three needed features the browser interpreter
did not have, and the gallery teaches idioms, so a reader pressing Run on one
and being told to go and install a compiler is the wrong answer.

Restored first: the effects work from #581 was written but not merged. The
merge took the gallery and the wiki publishing and left site/flow-compile.js
and site/wiki.js behind, so effect declarations, capabilities, handle blocks
and Effect.op dispatch were absent from main. Recovered from the dangling
commit rather than rewritten.

Then three features:

Pipeline forks. `n |> Stats { doubled = twice, plus_ten = add(_, 10) }` runs
each named function over the piped value and collects the results. The `_`
placeholder logic already existed for ordinary stages and is now shared.

Enums and choose. `enum Mode { Double, Triple }` becomes a struct holding a
tag plus one constant per variant, which is what the native compiler lowers
it to, so `Mode { tag: Mode_Double }` and `m.tag` mean the same thing in
both. `|> choose m.tag { Mode_Double => double }` selects which function the
value flows through.

Flow blocks. `flow Thermostat { state ... param ... solver ... evolves as ...
every 100 ms { ... } }` lowers to a struct plus Name_new, Name_default_dt and
Name_step, so the existing struct, pointer and call machinery runs it instead
of a second evaluator living beside the first. Explicit Euler; a method that
is not euler says which one it was asked for.

Checked against the native compiler rather than against a tolerance. 20000
steps of the thermostat with its every-block firing 200 times prints
temp=20.414 heater=1.0 from both.

Top-level constants were parsed and never installed as globals, so every
reference to one was an undefined variable. Enum variants are constants,
which is how that surfaced.

verify_browser_interp.py: 240 snippets, unsupported 13 -> 12, no new
disagreement.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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