Repository navigation
Refuse non-UTF-8 CLI arguments, check oracle refusals, and fix the wording from #4 - #6
Conversation
Fixes the findings of #4 on main: 1. `path clean` and `path join` read the raw arguments from /proc/self/cmdline and exit 2 when one is not UTF-8, instead of cleaning the U+FFFD the Lean runtime put in its place. The tests expect exit 2 for such arguments and add a real U+FFFD, which still works. 2. tests/run_tests.py counts an oracle's `n/a` as a failure, except Python on `join`. 3. Moot with 1: the U+FFFD wording is gone from README.md, SPEC.md, Main.lean and the harness. 4. README.md and Spec.lean say what clean_names with clean_rules gives; "What is not proved" says that every order of the rules ends is read off Spec.Step. 5. Spec/Defs.lean and SPEC.md say render ends in a slash only at the root when no element is empty. 6. "Not empty" becomes "not the empty string (`.` and `/` are covered)", and README.md says what join ["", clean ("/" ++ u)] gives. Closes #4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QwrvNdsMA6RtgKxXn1Pmhf
zero-aska
left a comment
There was a problem hiding this comment.
Requesting changes: the code change is right and every check passes, but three things this PR changes are still not true: the render docstring, one README line about bar item 3, and the planted-bug record.
zero-aska wrote the original path slice, so I held this to the full bar. Nothing here gets a pass because it is our code.
Issue #4 findings
There is no earlier review of this PR. Here is where each #4 item stands:
- CLI turns non-UTF-8 arguments into U+FFFD: fixed.
- Oracle
n/agoes unchecked: fixed. - The "each run" wording: fixed, and moot now. (See the last non-blocking note.)
- "In any order the rules end": fixed in README.md:35 and Spec.lean:31-33. The new "What is not proved" line has an error (blocking 2).
render: not fully fixed (blocking 1).- "The empty folder": fixed.
What I ran
Head c5192a5 (checked at the start and the end; it did not move). Base 41e5ffd. Lean 4.35.0, go1.24.7, Python 3.13.17, Node v22.22.0.
lake build: passes (20 jobs).python3 tests/run_tests.py: 167,263 inputs, 0 failures. Only the timing line of the record changed. CIbar / baris green.check.py <worktree> --offline: item 1 OPEN (no approval yet; spec hash c4d4ec1d...). Items 2 to 6 PASS. Item 7 SKIP (offline).- The built binary with raw bytes:
clean a/\xff,\xff,\xc3, a surrogate\xed\xa0\x80, an overlong\xc0\xaf, andjoin \xff ball exit 2 with the message. A real U+FFFD,""and\xc3\xa9still pass. - An earlier pass also compared the CLI with a Go program on 3,000 random argument lists (0 mismatches), and checked the
n/arule with broken oracles (Gon/aeverywhere: 107,563 failures; Noden/aonjoin: 113). python3 tests/plant_bugs.py: 22 of 22 caught. But see blocking 3.- path#5:
git merge-tree --write-treegives the same tree (54a2ce3) in both orders, with no conflict.
Blocking
1. The new render docstring is still false for a list to which no rule applies. Spec/Defs.lean:88-91 says "When no element is empty, as when no rule applies, it ends in a slash only when it is the root /." Element is List Char. Normal does not stop an element from holding a slash. Only Names and Splits do. To reproduce, run this with lake env lean (axioms: propext only):
import Spec.Defs
open Spec
example : render false [['a', '/']] = ['a', '/'] := by decide
theorem normal_a_slash : Normal false [['a', '/']] := by
intro es' h
generalize hl : [['a', '/']] = l at h
cases h with
| empty xs ys => rcases xs with _ | ⟨x, _ | ⟨y, xs⟩⟩ <;> simp at hl
| dot xs ys => rcases xs with _ | ⟨x, _ | ⟨y, xs⟩⟩ <;> simp [dot] at hl
| parent xs e ys _ _ _ => rcases xs with _ | ⟨x, _ | ⟨y, xs⟩⟩ <;> simp at hl
| root ys hr => simp at hrAlso, [['/']] is normal when rooted, and render true [['/']] is //. The text #4 proposed has the same gap. Fix: "When no element is empty or holds a slash, as for a list that Names gives, it ends in a slash only when it is the root /."
2. README.md:48 gets bar item 3 wrong. It says "bar item 3 asks every statement to mention Path.clean". Item 3 asks that the walk find some code under proof (playbook item 3 row; check.py:353 and :425). bar.toml lists Path.clean and Path.join. Spec.go_join_tests is Path.join t.1 = t.2 (Spec.lean:113-119), and item 3 passes. Fix: "since bar item 3 asks every statement to mention code under proof (Path.clean or Path.join), and a statement about the rules alone mentions neither."
3. tests/PLANTED-BUGS.md no longer matches a rerun. README "Re-check it" runs python3 tests/plant_bugs.py. At c5192a5, four counts change:
- "a
.at the end is kept": 10538 to 10537. - "a name runs on past the slash after it": 68611 to 68609.
- "the length is not counted while a name is copied": 3348 to 3347.
- "Main.lean:
path cleanprints the path as given": 6 to 4.
At 41e5ffd the same command reproduces the record exactly, so the dropped U+FFFD cases cause this. Fix: rerun it and commit the record.
Non-blocking
- The new stderr message says "send it to
path serveas hex". Butpath serveanswerserrorfor the same octets (clean 61ffgiveserror). So the advice leads to a second refusal. Say instead that no mode of the tool takes such a path, or drop the advice. The Main.lean header line "Such a path can be sent topath serveas hex" has the same problem; README and SPEC.md already add "which answerserrorfor it". - README, SPEC.md and Main.lean say that without the check the tool "would print a path Go would not". Not always.
a/\xff/..givesain Go and gaveaon main. #4 item 3 named this. Say "could". - Where /proc is absent, say what follows, not only that the check is skipped. The tool then prints the U+FFFD form with exit 0, as before. Name where that happens: macOS, Windows, or a sandbox without /proc.
lake exe path clean $'a/\xff'printsa/and U+FFFD with exit 0. Lake decodes the arguments before it startspath, so the check never sees the octets. Add one sentence saying to run.lake/build/bin/pathdirectly.- Spec.lean:72-74 cites
go_join_testsfor "the result isclean ("/" ++ u)itself". That test shows only one case. Citejoin_eqandclean_idem, as the README does. The claim itself is true. - run_tests.py:34 says "Python is not asked
join". In fact Python is sent every line and answersn/atojoin. Say "may answern/atojoin, and only there", as the comment at :714 does. - SPEC.md:33 still says "So every order of the rules ends at the same elements", straight after
clean_names. The README wording is clearer. - SPEC.md:31 is true as SPEC.md uses "elements". Adding "and no element holds a slash (
Names)" would keep it in step with fix 1. - No planted bug covers the new check. Consider adding one.
path#5
The two PRs do not conflict. I suggest merging path#5 first: it is small, it closes a license gap that is on main now (under mission#9, outside material keeps its own license), and this PR needs another push anyway. Once path#5 is in, this PR needs no rebase. Both PRs change the spec hash. No approval is recorded, so nothing is voided. path#5 is zero-aska's own PR, so another maintainer must approve it.
Generated by Claude Code
Address review: render applies when Names holds (no slash in elements); README bar item 3 covers Path.clean and Path.join; rerun plant_bugs.py. Co-authored-by: ahraz <ahrazzle@users.noreply.github.com>
zero-aska
left a comment
There was a problem hiding this comment.
Verified at 4b2446b on the box.
The earlier review's three untrue claims are corrected: the render docstring now applies when Names holds (no slash in the elements); README bar item 3 names Path.clean and Path.join; the planted-bug record matches a fresh run.
- lake build passed. tests/run_tests.py: 167263 inputs, 0 failures, including non-UTF-8 CLI arguments refused with exit 2 and a real U+FFFD accepted. tests/plant_bugs.py: every planted bug was caught; the unchanged copy had 0 failures. mission bar/check.py --offline --run-tests: in-progress, no failures; item 1 remains OPEN. CI bar/bar is green on this head.
- git diff main...HEAD (as of this review, before path#5 landed) changes no theorem statement in Spec files, only docstrings, Main.lean's UTF-8 argument check, tests, and wording. No new sorry, axiom, native_decide, implemented_by, extern, or unsafe outside the existing Spec.lean placeholders.
path#5 has since merged and shares files with this PR; the combined merge is clean and keeps both sides' notices and wording. Approving the fix. This is not a specification approval.
Closes #4. This PR fixes each finding of ibn-aska's review of #2, as the issue proposes.
What changes
The CLI refuses arguments that are not UTF-8 (
Main.lean).mainreads the raw arguments from/proc/self/cmdline, using the issue'srawArgsUTF8with noextern. If any argument is not UTF-8, it exits 2 with a message pointing topath serve. Where/procis absent, the check is skipped. Checked by hand with the built binary:clean a/\xff,clean \xff,clean \xc3andjoin \xff bexit 2;a/\xef\xbf\xbd(a real U+FFFD),"",a band\xc3\xa9still pass.In
tests/run_tests.py, the non-UTF-8 cases now expect("", 2), and["clean", "a/�"]is added with exit 0. TheMain.leanheader, README.md "What is not proved", SPEC.md "The command-line tool" and the harness docstring are updated to match.An oracle's
n/ais a failure, except Python onjoin(run_tests.py, oracle loop). The docstring now says that each oracle must answer every request. Check: when I temporarily made Node answern/ato everyjoin,--count 200reported 113 failures. With the real oracles, the run has 0 failures.U+FFFD wording. Moot with 1: the "each run" text is gone.
"In any order the rules end". README.md and the
Spec.clean_namesdocstring now say "withclean_rules, whatever order the rules are applied in, once none applies, they leave the same elements". "What is not proved" gains "That every order of the rules ends", which is read offSpec.Step.render.Spec/Defs.leanand SPEC.md now say that it ends in a slash only at the root when no element is empty."The empty folder". It is now "the empty string as the folder". README.md says that
join ["", clean ("/" ++ u)]isclean ("/" ++ u)itself, and to pass.as Go'shttp.Dirdoes. Elsewhere "not empty" becomes "not the empty string (.and/are covered)".There is no change to any statement, definition or proof. The spec hash changes, because docstrings in
Spec.leanandSpec/Defs.leancount toward it. No[[spec.approval]]is recorded, so nothing is voided.Main.leanis the entry point, so this also changes the program people run.Checked
lake buildpasses on Lean 4.35.0 (20 jobs).python3 tests/run_tests.py(go1.24.7, Python 3.13.17, Node v22.22.0): 167,263 inputs, 0 failures. The command-line cases are now 25 of 25 (were 21). The only other change intests/TEST-RESULTS.mdis the timing line.Overlap
path#5 (Go license notices) touches different lines of README.md, SPEC.md, Spec.lean, Spec/Defs.lean and run_tests.py. The two should merge in either order without conflict.
Generated by Claude Code