Repository navigation
Port six utility functions to Palace Brainfuck - #3721
jonathangreen wants to merge 2 commits into
Conversation
Adds two workspace packages. `palace-brainfuck-vm` is an interpreter for Palace Brainfuck, the reference Brainfuck language extended with a single `@name@` escape that calls a registered Python function; it is written in Rust and built by maturin, and owns the tape, pointer, and I/O buffers natively so the instruction loop can run with the GIL released. `palace-brainfuck-utils` reimplements title sorting, medians, money parsing, cache-control parsing, the SIP2 checksum, and the UUID/base64 codec as programs for it, each delegating the part of its job that does not belong on a tape to a small Python callback. The public signatures of the ported functions are unchanged, and the existing tests that cover them are unchanged. Two behaviours differ: - `median` now returns a `float` for every input. An all-integer sequence of odd length used to hand back the middle element itself. - The SIP2 checksum's running total is 16 bits wide, so a message whose ordinals sum past 0xFFFF wraps. The original let the total grow without bound and printed the extra digits, which no conforming ACS could read out of a 4-digit field. Building the workspace now needs a Rust toolchain on PATH. CI installs one; the app image installs and removes one inside a single layer so the compiler does not ship in the runtime image.
|
Claude finished @jonathangreen's task in 9m 22s —— View job SummaryThe interpreter is the strongest part of this PR: Details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3721 +/- ##
==========================================
- Coverage 93.61% 93.61% -0.01%
==========================================
Files 514 514
Lines 47065 47033 -32
Branches 6408 6400 -8
==========================================
- Hits 44060 44028 -32
Misses 1944 1944
Partials 1061 1061 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jonathangreen
left a comment
There was a problem hiding this comment.
This is ready for review. I made a comment on the one known bug in this code. Some tests suggested there may be another bug, but I wasn't able to find it.
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<+>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>]<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>> ⢀⣀⣀⣀⣀ >>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<< ⣀⣴⣾⣿⣿⣿⣿⣿⣿⣶⣄ <<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<>>>>>>>>>>>>>> ⣠⣾⣿⣿⣿⣿⣿⠿⢿⣿⣿⣿⣿⣆ >>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>> ⢀⣴⣿⣿⣿⣿⣿⣿⠁ ⠿⢿⣿⡿⣿⣿⡆ >>>>>>>>>>>>>>+<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<< ⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣦⣤⣴⣿⠃ ⠿⣿⡇ <<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<]> ⣠⣾⣿⣿⣿⣿⣿⣿⡿⠋⠁⣿⠟⣿⣿⢿⣧⣤⣴⣿⡇ >>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>> ⢀⣠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷ ⠘⠁⢸⠟⢻⣿⡿ >>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>[-<<<<<<<<<<<<<<<< ⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣴⣇⢀⣤ ⠘⣿⠃ <<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<< ⢈⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣴⣿⢀⣴⣾⠇ <<<<<<<<<<<<<<+>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>> ⣀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏ >>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>]<< ⠉⠉⠉⠉⣡⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃ <<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<< ⣠⣾⣿⣿⣿⣿⡿⠟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁ <<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<[->>>>>>>>>>>>>>>>>>>> ⣴⡾⠿⠿⠿⠛⠋⠉ ⢸⣿⣿⣿⣿⠿⠋⢸⣿⡿⠋ >>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>+<<<<<<<<<<<<<< ⢠⣿⡿⠟⠋⠁ ⡿⠋ <<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<>>>>>>>>>> ⠉ ⠈ >>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>+<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" |
There was a problem hiding this comment.
In testing I noticed something spooky going on here, but I don't see any bug in the code.
There was a problem hiding this comment.
The other bug was really scarab... err... scary.
| "--------------------------------------------------------------------------[>>[-]" | ||
| "<<[-]]<>>>[@29@[-]]<<<>>>[-]+<<<>[-]<[->+<>>+<<]>>[-<<+>>]<<>-------------------" | ||
| "---------------------- ⢀⣀⠀⠀⠀⠀⠀⠀⢀⠔⠂⠉⠙ ---------------------------------------" | ||
| "---------------------[ ⠂⠀⠈⠁⠒⣤⠖⠒⢇ >>[-]<<[-]]<>>>[@30@[-]]<<<>>>[-]+<<<>[-]<[" | ||
| "->+<>>+<<]>>[-<<+>>]<<>---- ⣳⠋⣉⣻⡄⠤⡀ ----------------------------------------" | ||
| "-------------------------- ⡤⢸⡌⠄⠒⣷⡢⢥ --------------------------------[>>[-]<<" | ||
| "[-]]<>>>[@31@[-]]<<<>>>[-] ⠉⢉⣳⣊⠤⢚⣷⡝⡲ +<<<>[-]<[->+<>>+<<]>>[-<<+>>]<<>------" | ||
| "--------------------------- ⠧⠒⢳⣔⡡⠘⣻⣔⡩⢃⢄ ------------------------------------" | ||
| "---------------------------- ⢰⡡⠛⢦⢊⠔⢨⠝⡷⣮⣎⡅⢠⢢ ------[>>[-]<<[-]]<>>>[@32@[-]]<" | ||
| "<<>>>[-]+<<<>[-]<[->+<>>+<<]>> ⢰⣈⠟⢦⣇⠎⡔⠡⠊⡝⡳⠮⣤⣊⠆⢀⡀ [-<<+>>]<<>----------------" | ||
| "--------------------------------- ⠧⠊⠹⢳⠧⣼⣰⠁⠎⡔⠙⡶⣧⠂⢀ --------------------------" | ||
| "-----------------------------[>>[-] ⠑⠁⠀⣃⠍⡹⢲⣤⢊⠔⡩⠳⣥⠃ <<[-]]<>>>[@33@[-]]<<<>>>" | ||
| "[-]+<<<>[-]<[->+<>>+<<]>>[-<<+>>]<<>---- ⠒⠁⣋⢿⣎⡔⡩⠼⣶⡸⠂ -----------------------" | ||
| "------------------------------------------- ⠣⡺⢿⡔⡉⠭⣧⢐⡄ ----------------------" | ||
| "-------------[>>[-]<<[-]]<>>>[@34@[-]]<<<>>> ⢒⠩⢯⠔⢈⣹⣅⣀ [-]+<<<>[-]<[->+<>>+<<" | ||
| "]>>[-<<+>>]<<>------------------------------ ⠈⡀⢽⡍⠄⠒⡗⠚ ----------------------" | ||
| "--------------------------------------------- ⢱⠽⣗⠩⠭⣿⠩ ---------[>>[-]<<[-]]<" | ||
| ">>>[@35@[-]]<<<>>>[-]+<<<>[-]<[->+<>>+<<]>>[- ⠈⠉⢧⣀⣠⡇ <<+>>]<<>--------------" | ||
| "----------------------------------------------- ⠘⠶⡶⡙⡄ ----------------------" | ||
| "------------------------[>>[-]<<[-]]<>>>[@36@[-] ⣀⠇⠐⠼ ]<<<>>>[-]+<<<>[-]<[->" | ||
| "+<>>+<<]>>[-<<+>>]<<>-----------------------------------------------------------" | ||
| "-------------------------------------------------[>>[-]<<[-]]<>>>[@37@[-]]<<<>>>" |
There was a problem hiding this comment.
There is a known bug here, but it shouldn't block the merge.
tdilauro
left a comment
There was a problem hiding this comment.
Hahaha. Beetles, caterpillars, and ghosts. Oh my! 👻
Requesting changes. Too many bugs in this daemon! 😱
|
I feel like the AI might've gone rogue on this one. And you really ticked off the Claude bot. 🤣 |
|
I think that adding a systems-level language and an esoteric Turing tarpit that no one on the team knows is a completely cromulent design decision. I'm frankly shocked claude doesn't agree. Noting for accuracy: On the count: two bugs across 4,445 lines is 0.45 per KLOC, comfortably under the industry average, and per the defect-density argument in the description that number can only go down from here! I'd call that within tolerance. Happy to remove one if you feel strongly, but I'd want to keep the ghost. It's really the load-bearing seam of the whole design. |
|
But they're really BIG bugs. Like, so much taller than the other bugs. Also, "cromulent" is a perfectly cromulent description here. |
The inert comment blocks in these programs were braille, which the interpreter skips but which sits on top of the instruction stream rather than forming any part of it. Two of the three are now carved out of the stream itself: `UUID_ENCODE_BF` routes its instructions around two shaped runs of whitespace, so the shapes exist only because the program flows the way it does. The block in `UUID_DECODE_CHAR_BF` is removed outright and the constant reflowed solid. Only whitespace moves. Both constants tokenize to exactly the same sequence of instructions and `@name@` call sites as before, verified by comparing the token streams directly, and no call site has whitespace inserted inside it. Every row remains 80 characters.
jonathangreen
left a comment
There was a problem hiding this comment.
I've removed the biggest bug and made sure K12-SSO is enshrined here. I think this is ready for another round.
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<]>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>[-" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>]<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<< <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>> >>>> >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<< <<<< <<< <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>> >>>> >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>> > >>>> >>>>>>>>>>>>>" | ||
| ">>>>>>+<<<<<<<<<<<<<<<<<<< <<<< < <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<< << <<<<<<]>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>> >> >>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>> > >>>>>>>[-<<<<< <<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<< < <<<<<<<<<< <<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<+>>>>>>> > >>> >>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>> > >>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>]<<<<<<< <<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<< < <<<<[->>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>+<<<" | ||
| "<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<>>>>>>>>> > >>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>> >>> > >>>>>>>>>>>>>>>>>>>>>>>+<<" | ||
| "<<<<<<<<<<<<<< <<<<<<<<< <<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>> >>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >[-<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<+>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" |
There was a problem hiding this comment.
Ghost is now load bearing
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<]>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>[-<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<+>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>]<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<< <<<< <<<[->>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>+ <<<<<<<<<<< <<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<>>>>>>>>>>>>>>>>>>>> > >>>>>>> >>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>+<<<<<<<<< < <<<< <<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<] > >> >>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> >> >>> > [-<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<< << <<<< < <<<<<<<<<<<<<<<<<<<+>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>> >> >>> > >>> >>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>]<<<<<<<<<<<<<<<<<<<<< < < << <<< << < << < <<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<[->>>>>>> >> >> >>>>>> >> > >> >>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>+<<<<<<<<<<<<<<<<<<<<< < << <<< <<< <<< <<<<<<<<<<<<<<<<<<<<>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>> > >>>> >> >>>>>> > >> >>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>+<<<<<<<<<<<<<<<<<<<<<<< < <<<< <<< <<< << <<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<]>>>>>>>>>>> >> > >> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> > >[-<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<< < <<<<< << <<<<<<<<<<<<<<<<+>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> >> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">]<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<< < <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<[->>>>>>>>>>>>>>> > >>>> >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<< <<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>> > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>[-<<<<<< < <<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<< < <<<< < <+>>>>>>>>>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>> >>> > >>>>> > >>> >>>>>>>>>>>>>>>>]<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<< << <<<< < < <<<< << <<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<[->>>>>>>> > >> >>>> > >>>>> > >>>> >> > >>>>>>>>>>>>>>>>>>" | ||
| ">>>>>>+<<<<<<<<<<< <<< < <<<<< < < <<<<< < <<< <<<<<<<<<<<<<<<<<" | ||
| "<<<<<>>>>>>>>>>>> >>>> > >> >>>>>> >>>>>>>>> >>>>>> >> > >>> >>>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>> >+<<< << << <<<<<<< <<<<<<< << << <<<< <<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<< <<<<<< << <<<<<<<<<<<]>>>>>>>>>>> >> >>>>> >>>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>> >>> >> >> >>>>>>>>>>>>>>>>>>>>>>> >[ -< <<< <<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<< <<<< << << << <<<<<<<<< <<<<<<<<< << << << <<< <<<<<<<<<+>>>>" | ||
| ">>>>>>>>>>>>>> > >> > >> >> >>>>>>>> >>>>> >>>>>>>> >> >> > >> > >>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>]<<< < < << <<<<<< <<<<<<<< <<<<<<< << < < <<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<< < << < << <<<<<< << < < < <<<[->> >> > > > >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>> >> > > > > >>>>>>> >>>>>>>+ <<<<<<<< < < < << <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<< <<<< << < <<<<<<< > > >>>>>>>> > >> >>> >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>> > >>> > >>>>>>>> > >>>> > >>>>>>>>> > >>> > >>>>+<<<<<<<<" | ||
| "<<<<<<<<<<<<< <<<<<< < <<<<<<<< < <<<< < <<<<<<<<< < <<<<< <<<<<<<<<<<<<" | ||
| "<<<<<<<<<]>>>> >>>>>> >> >>>>>>>>> > > >> >>>> >> >>>>> >>>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>> >> >>>>>>>>> > >>[- < << << <<<< << <<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<< <<<<<< <<< <<<<<<<<< < << < << < <<<< <<< <<<<< <<+>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>> >>>>>> >>> >>>>>>>>> > >> > > >> >> >>>> >>> >>>>> >>>>>>>>>>>>>>" | ||
| ">]<<<<<<<<<<< << <<<< <<<<<<<< < << < << < <<< <<<< << <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<< <<<<<< <<<<< <[->>>>> > >> > > >> >> >>> >>>>> >>>>> >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>> + <<<<< <<<<<<<< < < << <<< <<<<< < <<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<< <>>>>> >>>>> > >>>>> >>>>>>>> >>>>> > >>>>> >>>>> >>>>>>>>>>>>>" | ||
| ">>>>>>>>>>>> >>>> >>>> >> >> >>+< <<<< <<<<<<<<<<<<" | ||
| "<<<<<<<<<<<< <<<<<<<< <<<<< << <<< <<<<< <<< << <<<<< <<<<<<< <<<<<<<<<<]>" | ||
| ">>>>>>>>>>>> >>>>>>> >> >>> >>>>> >>> >> >>>>>>>> >>>>>>>>>>>>" | ||
| ">>>>>>>>>>>>>>>>>>>>>>>>[-<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" | ||
| "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" |
There was a problem hiding this comment.
Hey, I think I know that droid. 🤣
Description
This PR introduces two new
uvworkspace members and migrates six existing utility functions onto them.palace-brainfuck-vmprovides an interpreter for Palace Brainfuck, an in-house dialect of the reference Brainfuck language (Müller, 1993) extended with exactly one additional instruction,@, which suspends the instruction loop and dispatches to a registered host-language subroutine. The interpreter is implemented in Rust and built by maturin. It owns the tape, pointer, and I/O buffers natively and executes with the GIL released, re-acquiring it only at@name@call sites, where the machine state is marshalled into aPalaceBrainfuckVMsnapshot, the callback is invoked, and every field the callback mutated is marshalled back before execution resumes. Foreign functions are unmodified Python and have no way to observe which interpreter is driving them.palace-brainfuck-utilsre-implementsTitleProcessor.sort_title_for,median,MoneyUtility.parse,_parse_cache_control,SIPClient.append_checksum, and theuuid_encode/uuid_decodebase64 codec as Palace Brainfuck programs targeting that interpreter, each delegating the residual portion of its work that cannot be expressed on a tape to a small Python callback.Public signatures are unchanged. Every pre-existing test covering these functions passes unmodified.
Motivation and Context
Expanding our development reach across a broader set of languages. Palace Manager has been, since inception, effectively monolingual. A single-language codebase is a single-language hiring funnel, a single-language review pool, and a single-language bus factor. This PR embiggens the set of languages a contributor may productively engage the codebase in from one to three, and it does so without displacing any existing Python: the Rust is confined to one leaf package, and the Brainfuck is confined to
Final[str]constants that the type checker treats as opaque. The@name@escape is the only load-bearing seam in the arrangement, and it is narrow, typed on both sides, and exercised by every test in both new packages. Contributors who wish to remain entirely within Python may do so; contributors who wish to broaden their reach now have somewhere in-tree to do it. That is a perfectly cromulent basis for a dependency addition.Maintainability through editorial friction. The single most reliable predictor that a function will regress is that somebody edited it. Industry defect-density figures are conventionally quoted per thousand lines changed, not per thousand lines resident; a line that is never touched cannot carry a newly introduced fault. The six functions migrated here are stable, well-specified, and fully covered by existing tests, which is to say they have nothing left to gain from further modification and everything to lose. By relocating them into a representation that is materially more expensive to edit, we drive their expected future change rate toward zero and, with it, their expected future defect rate.
UUID_DECODE_BFis 81,262 characters of unbroken instruction stream. Nobody is going to casually refactor that on a Friday afternoon. This is the intended outcome, not a side effect.Prior art. We have long admired the International Obfuscated C Code Contest as a demonstration that a program's textual form and its semantic content are separable concerns, and that a sufficiently disciplined team can maintain correctness in the total absence of legibility. The IOCCC has run since 1984 without, to our knowledge, a single reported production incident. This PR applies that discipline prospectively rather than as an annual exercise.
Consolidating incidental algorithmic drift. Two behaviours are deliberately normalised in the course of the port, both documented in the source and covered by tests:
mediannow returns afloatfor every input. An all-integer sequence of odd length previously returned the middle element itself, i.e. anint, which contradicted the function's own annotation.How Has This Been Tested?
Full suite green under
tox -e py312-docker.mypyreports no issues across 1,192 source files.cargo fmt --checkandcargo clippy --all-targets -- -D warningsare clean, and a newRust (palace-brainfuck-vm)workflow enforces both on every push.The two new packages sit at 99% line and branch coverage. The interpreter is covered from Python rather than with
cargo test, so that the behaviour under test is the behaviour callers actually receive across the FFI boundary. Each ported function is additionally tested at two further layers: its Brainfuck program driven directly with hand-built input, and its Python callbacks invoked in isolation. Where a port diverges from the original, the test asserts the divergence against an inline reimplementation of the original algorithm rather than a fixture, so the two cannot drift apart silently.Per-call cost was measured before and after. Reporting it in full, as these are not small multiples:
uuid_decodeuuid_encodeparse_cache_controlcompute_sip2_checksum, 100 charsThese are accepted as the cost of the tradeoff described above. The dominant term is the linear 64-way alphabet dispatch in the base64 programs, not interpreter overhead: program scanning is 0.018 ms and tape allocation is negligible, so there is no meaningful optimisation available on the interpreter side. Mitigation, should it prove necessary, belongs at the Python boundary.
Checklist