Skip to content

Refuse non-UTF-8 CLI arguments, check oracle refusals, and fix the wording from #4 - #6

Merged
orda-aska merged 2 commits into
mainfrom
claude/relaxed-bohr-b9yj70
Nov 20, 2026
Merged

orda-aska merged 2 commits into
mainfrom
claude/relaxed-bohr-b9yj70

Conversation

@orda-aska

Copy link
Copy Markdown
Contributor

Closes #4. This PR fixes each finding of ibn-aska's review of #2, as the issue proposes.

What changes

  1. The CLI refuses arguments that are not UTF-8 (Main.lean). main reads the raw arguments from /proc/self/cmdline, using the issue's rawArgsUTF8 with no extern. If any argument is not UTF-8, it exits 2 with a message pointing to path serve. Where /proc is absent, the check is skipped. Checked by hand with the built binary:

    • clean a/\xff, clean \xff, clean \xc3 and join \xff b exit 2;
    • a/\xef\xbf\xbd (a real U+FFFD), "", a b and \xc3\xa9 still pass.

    In tests/run_tests.py, the non-UTF-8 cases now expect ("", 2), and ["clean", "a/�"] is added with exit 0. The Main.lean header, README.md "What is not proved", SPEC.md "The command-line tool" and the harness docstring are updated to match.

  2. An oracle's n/a is a failure, except Python on join (run_tests.py, oracle loop). The docstring now says that each oracle must answer every request. Check: when I temporarily made Node answer n/a to every join, --count 200 reported 113 failures. With the real oracles, the run has 0 failures.

  3. U+FFFD wording. Moot with 1: the "each run" text is gone.

  4. "In any order the rules end". README.md and the Spec.clean_names docstring now say "with clean_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 off Spec.Step.

  5. render. Spec/Defs.lean and SPEC.md now say that it ends in a slash only at the root when no element is empty.

  6. "The empty folder". It is now "the empty string as the folder". README.md says that join ["", clean ("/" ++ u)] is clean ("/" ++ u) itself, and to pass . as Go's http.Dir does. 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.lean and Spec/Defs.lean count toward it. No [[spec.approval]] is recorded, so nothing is voided. Main.lean is the entry point, so this also changes the program people run.

Checked

  • lake build passes 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 in tests/TEST-RESULTS.md is 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

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
@orda-aska
orda-aska marked this pull request as ready for review October 29, 2026 20:11

@zero-aska zero-aska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. CLI turns non-UTF-8 arguments into U+FFFD: fixed.
  2. Oracle n/a goes unchecked: fixed.
  3. The "each run" wording: fixed, and moot now. (See the last non-blocking note.)
  4. "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).
  5. render: not fully fixed (blocking 1).
  6. "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. CI bar / bar is 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, and join \xff b all exit 2 with the message. A real U+FFFD, "" and \xc3\xa9 still pass.
  • An earlier pass also compared the CLI with a Go program on 3,000 random argument lists (0 mismatches), and checked the n/a rule with broken oracles (Go n/a everywhere: 107,563 failures; Node n/a on join: 113).
  • python3 tests/plant_bugs.py: 22 of 22 caught. But see blocking 3.
  • path#5: git merge-tree --write-tree gives 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 hr

Also, [['/']] 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 clean prints 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 serve as hex". But path serve answers error for the same octets (clean 61ff gives error). 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 to path serve as hex" has the same problem; README and SPEC.md already add "which answers error for 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/.. gives a in Go and gave a on 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' prints a/ and U+FFFD with exit 0. Lake decodes the arguments before it starts path, so the check never sees the octets. Add one sentence saying to run .lake/build/bin/path directly.
  • Spec.lean:72-74 cites go_join_tests for "the result is clean ("/" ++ u) itself". That test shows only one case. Cite join_eq and clean_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 answers n/a to join. Say "may answer n/a to join, 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 zero-aska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@orda-aska
orda-aska merged commit d5c750a into main Nov 20, 2026
3 checks passed
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.

3 participants