Repository navigation
docs(151-text-encoding-policy): specify one text-encoding policy for every command - #154
Conversation
Factory ledgerWhat the loops spent on this so far, summed from the loop runtime's records. Cost is at API prices; the loops run on a subscription, so it measures plan usage, not a bill.
Updated automatically. |
Verdict: REJECTSpec review round 1 of head The change is inside the intent: #151 is the owner's issue, and it asks for one policy instead of seven fixes, so its size is the size of the ask. Nothing else in it blocks:
I reproduced the "Tools run" probes (below). Three findings: Findings
Notes (not findings)
Evidence— robocop |
aac22e1 to
ccd2ff2
Compare
|
Round 1 answered at
Notes: the trailer-push scenario is retitled "Run with a remote that has a non-ASCII name is not refused"; the design now states that the keyword — bruce-lee |
Verdict: REJECTSpec review, round 2, head The three round-1 findings are fixed:
Findings
Strike 2 of 3 in this spec review. A third REJECT would be an ESCALATE. Evidence— robocop |
ccd2ff2 to
4818557
Compare
|
Round 2 answered at The user's
— bruce-lee |
Verdict: APPROVESpec review, round 3, head FindingsNone. The round-2 finding is fixed:
Notes for code review:
Evidence— robocop |
4818557 to
f3dc2bf
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
f3dc2bf to
ee01bb9
Compare
…every command New capability text-encoding: one module decides every crossing of text, the reproductions of #115, #130, #134, #144, #145, #146 and #150 become scenarios, and the integration specs also run under an ASCII locale in a non-ASCII path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: bruce-lee
…ding `text_io` is the one place that turns bytes into text and back: the tool's text is UTF-8 with `surrogateescape`, `from_os` and `to_os` are the only conversions the locale decides, and files, subprocesses, standard input and the output streams cross there. Nothing uses it yet; the commands move onto it in the next commit. Decisions: - `Completed` (a dataclass) is the result of `run`, so that no other module has to import `subprocess` for a type, which the scan of the next commit bans. - `read_text` and `read_utf8` read line ends as `\n` like `Path.read_text` did; `keep_line_ends` is for `install`, which edited files with `newline=""`. - `run_shell` and `run_shell_captured` (a temporary file, as `doctor` did) are two functions, not a flag that changes the return type. - The `ascii` file system encoding is tested in a child interpreter (integration tier), the rest as unit specs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
…odule `git`, `repo_config`, `checking`, `preflight`, `pass_cache`, `pre_push_hook`, `commit_msg_hook`, `doctor_command`, `strip_command`, `init_command`, `install_command` and `cli` no longer decode, encode, open a stream or start a process themselves; they call `text_io`. A unit spec scans the modules outside `core/` and `text_io.py` and fails on a call, keyword or name that decides an encoding. What the commands print or exit with does not change, except what the policy asks for: a config that is not UTF-8 is one line naming the file and `not valid UTF-8` (`doctor` printed `cannot read …` before), and a failing `interpret-trailers` in the commit-msg hook is a message and exit 1 instead of a traceback. Decisions: - A path from git is turned into a `Path` with `to_path`, a `Path` that goes into text (a script, a report, a git argument) with `text_of`; `git()` converts its arguments and environment itself. - `init` and `cli` read standard input through `text_io` (`stdin_line`, `stdin_text`); the pre-push hook takes a reader instead of a stream, so `run` reads it after the mode is checked as before. - `load_repository_config` reads `pyproject.toml` only when there is no `.prepush-ci.toml` (and `committed_config` likewise): the other file is never parsed, so it cannot be refused. - `init` loads the config through `load_repository_config`, one reader for both. - `Script.text` and `ManagerFacts.text` of `doctor_hooks` are named `content`: the scan bans the keyword `text` on any call. - A hook directory's file names are the tool's text; `install` turns them into names with `_in`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
326948e to
0a12045
Compare
|
Code round 1, answered at 0a12045 (spec commits folded into the proposal and archive commits as asked; the tree equals
CI is green on 0a12045, Windows included: https://github.com/CapeOfGoodCode/prepush-ci/actions/runs/38480547259. The demo in the description now shows — chuck-norris |
Verdict: REJECTCode review, round 2. I reviewed head Findings
Round 1 findings, all fixed
Other checks, all passing
Evidence— robocop |
… ascii variant Every integration spec that uses the `repo` fixture or starts the CLI runs twice: `utf8`, the environment it always ran in, and `ascii`, where the temporary directory has a non-ASCII name and every process gets `LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0`. The ids name the variant. The reproductions of #115, #130, #134, #144, #145, #146 and #150 are specs in `text_encoding_spec.py`, named after the scenarios of the change; `variants_spec.py` holds the variant's own scenarios. Decisions: - The variant is a parametrized fixture that sets the variables for the whole test (`monkeypatch`), so every process a spec starts inherits them, whatever helper starts it. `tmp_path` is overridden in `ascii`, so every repository is below `dé` without any spec asking. - `pytest_generate_tests` doubles a spec when it uses `repo` or its module starts the CLI as `"-m", "prepush_ci"`; pure documentation and asset specs keep running once. - A spec that prints a path asserts on `printed(...)`: in `ascii` a character the output cannot encode is `?`. - pre-commit, the third-party framework, does not run under an ASCII locale in a non-ASCII directory (its own `UnicodeEncodeError`). The specs that drive it (`install_managers_spec`, `pre_commit_pre_push_spec`, `doctor_spec`) give pre-commit's own processes (its install, the commits and pushes that start its hooks) the three variables as they were before the variant; they are not skipped, and the tool is held in `ascii` by every other spec. - A preflight script written for the specs writes bytes (`os.fsencode`), not text: it runs in the hostile environment itself. - A spec starts the CLI by what it does: `python -m prepush_ci` in its source, or the marker `starts_the_cli` for the installed script (`skill_wheel_spec`) and the recording script (`demo_spec`); `variants_spec` fails on a module that does the second without the marker. - The demo recorder runs its steps with `PYTHONIOENCODING=utf-8` and compares paths in the domain of the output, so a scratch directory with a non-ASCII name is replaced under an ASCII locale. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Loop: chuck-norris
0a12045 to
5429ecb
Compare
|
Round 2, head
— chuck-norris |
Verdict: APPROVECode review, round 3. The head is FindingsNone. The round 2 finding is fixed. What changed since round 2
Checks
EvidenceNext station: — robocop |
Attack: PASSHead: 5429ecb · 8 hypotheses · 0 broken Installed with
Pair check: no other pull request is at Not tried: Windows and pre-commit's own processes under Reproduction scriptsScripts are in the workstation of the attack loop ( — terminator |
Closes #151
Implementation also closes #145, #146 and #150 (their reproductions are scenarios of this change); it moves the fixes of #134 and #144 (merged) onto the same module.
What changes
One module,
src/prepush_ci/text_io.py, decides every encoding: the tool's text is UTF-8 withsurrogateescapewhatever the locale, and the locale decides only the operating system's strings (from_os,to_os). Every command (git, config, hooks, doctor, init, install, strip, verify, run, skill) now crosses through it, a unit spec fails on any other module that decides an encoding, and every integration spec that uses a repository or starts the CLI runs a second time in a hostileasciivariant (LC_ALL=C PYTHONUTF8=0 PYTHONCOERCECLOCALE=0, a non-ASCII directory). OpenSpec change151-text-encoding-policy, archived.Proof
Acceptance
test_no_other_module_decides_an_encodingtest_a_remote_with_a_non_ascii_name_matches_the_config(doctor, run: a non-ASCII remote name never matches require_up_to_date under an ASCII locale #146),test_a_message_that_is_not_utf8_gets_the_trailer_with_its_bytes_kept(commit-msg hook: traceback when the commit message is not UTF-8 #144),test_a_non_ascii_argument_reaches_the_config(commit-msg hook: traceback when .prepush-ci.toml is not valid UTF-8 #145),test_a_branch_with_a_non_ascii_name_is_pushed(init: under an ASCII locale the hooks question misses the previous pre-push hook when its directory path is non-ASCII #150), and the rest intests/integration/text_encoding_spec.pyutf8and theasciivariant:test_both_variants_runDemo (a repository in
dé, an ASCII locale; a scratch directory under /tmp)Check: CI on 5429ecb (merged with main e8995ca): 2245 passed on Python 3.11 and 3.14, Windows 2137 passed and 108 skipped, core coverage 100%, 99% overall, specs valid 17/17 (run).
Details for the reviewer
interpret-trailersin the commit-msg hook is one line instead of a traceback); the variant with the reproductions; the archive.-n auto). Windows: the job took 5 min 39 s before and 6 min 38 s after. Locally, a pool of 8 workers: 4 min 50 s for one variant, 10 min 7 s for both.tests/unit/text_io_spec.py,tests/unit/text_encoding_scan_spec.py,tests/integration/text_encoding_spec.py(one per scenario of the requirementsEvery command handles non-ASCII names the same way,A file the tool parses must be UTF-8,A file the tool edits keeps its bytes,A file the tool writes reads back equal,The terminal never makes a command fail),tests/integration/variants_spec.py,tests/integration/text_io_spec.py, andtest_a_message_git_cannot_rewrite_stops_the_commit_with_one_line_and_no_traceback.to_osorfrom_osthe identity; the parsed-file reader lenient (config, committed config, settings); subprocess arguments, environment or shell command not converted; streams left strict; standard input read with the locale;write_textnot exact; line ends not kept; the arguments ofclinot converted; the root path made withPath(...); the record ofinstallunreadable. One equivalent mutant survives: reading the process environment withoutfrom_os(the two texts round-trip).to_osturns a byte that is no UTF-8 into U+FFFD; that case is a POSIX spec only. The specs write and read their files as UTF-8 (a session fixture sets the default ofPath.write_text/read_text),gitoutput is read as UTF-8, andprintedis the identity (the code page holds the characters of the specs).skill_command(Ship the setup skill with the tool: a command and a Claude Code plugin #138, merged meanwhile) crossed with a barePath(...)of git's text: now throughtext_io.Decisions
UnicodeEncodeError): the specs that drive it give its processes the locale the variant replaced, the tool stays hostile in every other spec.Script.textandManagerFacts.textof the doctor are renamedcontent: the scan bans the keywordtexton any call.— chuck-norris