kxray.replay: step through a recorded Tier 1 session - #61
Merged
Conversation
A browser cannot build a kernel, so the sessions that build one are recorded on a real machine and shipped as something a reader can walk through: the command, what came back, how long it took, whether it worked. Adds the recorder, the reader, the widget, and the first recording, which is Linux 7.2.2 built for User Mode Linux and booted, in the container pin.toml names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A reader on Tier 0 has a browser and nothing else. A browser cannot run gcc over a hundred and sixty megabytes of kernel source, so every lesson that builds a kernel has had the same hole in it: the build gets described instead of shown, and a description of a build leaves out the one thing a person who has never done it is missing.
So the build gets recorded on a real machine and shipped as something you step through. The command, the output, how long it took, whether it worked.
The recording
The first one is thirteen commands. A Debian container with no compiler in it becomes a container that has built Linux 7.2.2 and booted it.
Look at step 9 against everything else. Five minutes and eleven seconds, against a minute and a half for the other twelve put together. That shape is what a written transcript throws away, and it is why the widget has a strip across the top with one segment per step, each as wide a share as that step was of the time.
Step 4 is worth more than it looks. The hash it prints is character for character the one in
pin.toml, so the kernel built in step 9 is the kernel this project pins, proved rather than asserted.Step 12 is the point of the session. The kernel built two commands earlier is started as an ordinary program, with no disk image and no virtual machine anywhere, and it says its own version back:
That is User Mode Linux booted with
rootfstype=hostfs, so it uses the container's own filesystem as its root and needs no rootfs image at all.How a recording is made steppable
A terminal recording is one stream of bytes with nothing in it saying where one command ended and the next began. The structure comes from four escape sequences the shell is asked to print, OSC 133, which is an existing convention that iTerm2, kitty and WezTerm already speak. A prompt starts, the prompt ends, the command runs, the command finishes with a status.
The file is asciinema v2, a documented format rather than one invented here, so
asciinema playopens the same file this repository parses.Both of those choices are the same choice. A format nobody else speaks would fit our parser better and would be worth less.
The cases where it degrades, and what it does about them
Each of these has a test, because each of them is a place where a tool could quietly produce something that looks right.
asciinema rechas no marks. It comes back as one step holding the whole session and the widget says so. Looking for a dollar sign to find the prompts would find every dollar sign in a build log too.command startedmark since 4.4, and the machine this was written on has 3.2. Without it the command is everything up to the first newline, which is what the terminal echoed.complete = False, the same way a trace the tracer window cut off is.sleep 10read as zero seconds.... 1472 lines not shown ...in the fold for step 9. A reader who cannot tell a short command from a truncated one is being lied to about the size of a build.The right hand edge of the screen
This one nearly shipped wrong and is worth writing down.
Step 1 is longer than the terminal is wide. A shell echoing a command that does not fit writes the character in the last column and then a carriage return, because the terminal has already moved the cursor down a line on its own. Read those bytes with no idea where the right edge is and the carriage return sends you back to the start of the same line, so the tail of the command lands on top of its own head:
The first of those is a command that does not exist, shown to a reader as though somebody ran it. So the width comes out of the recording, which wrote it down, and a line that fills the screen carries on the row below. The prompt counts too: two characters of prompt means the command wraps two characters earlier.
Files
kxray/replay/record.pywrites the cast, driving one bash under a pseudo terminal. The pseudo terminal is not an implementation detail:makeonly draws its progress over the line above when it thinks a person is watching.kxray/replay/cast.pyreads asciinema v2 and accounts for every line as read, skipped or unparsed.kxray/replay/terminal.pyis deliberately not a terminal emulator. Escapes, carriage return, backspace, tab, and the right edge.kxray/replay/session.pywalks the marks and cuts the stream into steps.kxray/replay/notes.pykeeps the sentences a person wrote about a session next to it, keyed by step number and by command. The recording is evidence and is never edited. A notes file that has drifted raises rather than attaching last week's sentence to this week's step.kxwidgets/replay.pydraws it. No JavaScript, like everything else in that package.corpora/replays/tier1/has the recording, its metadata and its notes, plus a README.tools/baseline.pypins the number of steps as well as the line counts, because the steps are found from marks in the middle of the byte stream and a change to that walk would leave the line counts alone while quietly halving the walkthrough.Checks
pytest41 new tests and the whole suite green,ruff check,ruff format --check,node --test,lintprose, andbaseline,claimledger,coverage,bpc,kconfig,refcheck,lintnb,kxmanim,diagrams --check,nbbuild --check,sitebuild --check,kxbox --check,vendor --check.Closes part of #2.