Skip to content

Lab tooling: the lab channel, Command File Runner, scripts and the console-iteration skill - #107

Open
dayfine wants to merge 117 commits into
mainfrom
lab/tooling
Open

dayfine wants to merge 117 commits into
mainfrom
lab/tooling

Conversation

@dayfine

@dayfine dayfine commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Base: main (it was base/upstream-main, an older copy of upstream main that main contains), so the diff is the lab tooling alone. Running console automation from scripts needed to select a program, set its options, start and stop it, read its state, and press buttons or check detectors between runs, all without a window click; the lab control folder and the Command File Runner's inbox did parts of that and needed the right program selected and running. The lab channel is one folder per app, <profile>/Lab/: a request is inbox/<name>.txt, one command per line (select, set, start, stop, state, keepawake, owner, plus every Command File Runner command), its journal is outbox/<name>.out, and state says what the app is doing; the Command File Runner's command table runs behind it, the devtools/lab/ scripts (lablock.sh, labctl.sh, cfrun.sh) and the console-iteration skill speak it, and Lab.md is the one document for the files, the commands and a worked run. Tested with the unit tests (request, journal and state formats, the owner lock, the keep-awake schedule, command arguments), the fork CI (Ubuntu, Mac, Windows Clang) and dry runs of the scripts against a fake app serving the Lab folder; a console still has to verify select, set, start/stop, keepawake and the owner rule on a live app. Supersedes fork #105 and #106; #103 still brings the CFR to the fork's main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

dayfine and others added 13 commits October 31, 2026 21:12
When <user files>/LabControl/ exists, the main window polls it every
500 ms. A "start" or "stop" file does what clicking Start/Stop Program
does and is then deleted; "state" holds the program state and the
selected program's identifier. Nothing changes when the folder is absent.

The button's handler moves into start_or_stop_program() so both paths
share it.

Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f6f658f)
The folder, the start/stop files, the state file's lines and when the
error line appears were described only in LabControl.h's header and in
the lab scripts that use it. This says it next to the code, with the
shell sequence a script uses.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
(cherry picked from commit 953ae68)
Answering "does this detector fire on that screen?" or "how far does a
hold move?" meant a rebuild and a full program run. The Command File
Runner runs .txt files dropped into <folder>/inbox against the live
console, one command per line (press, dpad, stick, wait, walk until the
screen holds still, shot, shots, history, detect, wait_for, expect, state,
close_game, help, stop), and writes a timed result file with screenshots
to <folder>/outbox, stopping a file at its first failing line. Games can
register their own commands and detectors. README.md next to the code
documents the file format and every command; unit tests cover the
parsing. Squashed from fork lab/main (fork PRs #58, #84, #92).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…recipes

How a console automation segment goes from idea to three passes in a row:
define, code, observe, hypothesize, verify by hand with one CFR batch per
question, fix one thing, rerun; the Switch as an external machine, hard
stops, what to measure before fixing, and the CFR recipes (launch to a
save from HOME, count tiles by taps, find a wall, talk and answer prompts,
record a human walk, measure a threshold, recover). From the fork's
agents branch (fork PRs #96, #101). Under skills/ because .claude/ is
ignored in this repo.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…om the shell

Three portable sh scripts under devtools/lab that speak the app's two file
protocols: lablock.sh holds one console for one command (a "train") and
hands its token down, so a stray script from an old run cannot touch what
the current run drives; labctl.sh starts, stops and reads the selected
program through the Lab Control folder; cfrun.sh sends one Command File
Runner batch and prints its .out, stopping only the lab's own keep-awake
and refusing any other running program. The README explains the three,
the one-train rule, the folders they use, and the gap that stays out:
the app has no way to select a program from a script.

Tested without a console: sh -n on each, and dry runs against a fake app
that plays both folder protocols (lock nesting, refusal, waiting and
stale clearing; start/stop/state; a passing batch, a failing line, a busy
console, a wrong selected program, keep-awake and the select hook).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The skill described the loop through one game's lab: checkpoint names,
run ids, map names, a traps section and the scripts of one lab folder.
Now it is the loop for any console automation segment, with each rule's
reason kept as one generic clause. The CFR recipes section is gone;
where the loop uses the Command File Runner or the Lab Control folder it
says so inline (read the state file to see what runs, one batch per
question, the lock, the HOME-tile check before a reload) and leaves the
command table to the CFR README and the folder protocol to LabControl.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
The lab channel will run the same commands from a worker thread with no
program running, so the runner's line runner is reachable through free
functions (run_command_file_line, command_file_command_kind, the error
screenshot and help) instead of living inside the program's loop. The
command session takes a console and a controller context rather than a
program environment. Splitting lines, finding the next inbox file and the
two journal lines move to CommonFramework/Windows/LabRequest, which the
channel shares; the journal's failure line is now "error <line> (...)".
Also ports the lab's "taps" command (D-pad taps, each measured against the
frame before it) with its argument parsing and test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…lder

Scripts drove the app through two mechanisms: the LabControl/ folder for
start and stop, and the Command File Runner's inbox for presses and
detectors, which needed that program selected and running. The lab channel
is one folder, <profile>/Lab/, independent of the selected program. A
request is inbox/<name>.txt, one command per line, run in order from a
worker thread and moved to done/; its journal outbox/<name>.out has one
"ok"/"error" line per command and ends with "end"; "state" is rewritten
after every request and whenever the program state changes, with seq,
state, program and the last error.

Commands: start, stop, state, help, and every Command File Runner command.
Presses run only while no program runs; screenshots and detectors any
time. The window actions run on the UI thread through LabChannelHost; the
console commands come from a LabConsoleCommands implementation per console
type (SwitchLabCommands), wired in Main.cpp. A panel change cancels the
command running on the old panel before it is destroyed. LabControl is
removed; its tests move to the channel's, which cover the request and
journal formats and the state text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
"select GAME:PROGRAM" shows that program as clicking it in the program list
does (ProgramSelect::select_program looks the identifier up across the
game lists, PanelListDescriptor exposes its entries for that), and the
request fails if the window did not switch. "set KEY JSON" sets one option
of the selected panel by its key in the settings file, live: the panel's
JSON is taken, the key (a dotted path for groups) replaced, and loaded
back without the ConsoleSetup section, which would reconnect the devices;
the journal prints the value the panel then holds, so a clamped or refused
value is visible. Both are refused while a program runs, and both run on
the UI thread.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Two scripts driving one console interleave their presses, and the lab ran
a Prevent Sleep program between runs just to keep the console awake.
"owner claim TOKEN" claims the channel; after that every request that
changes anything (select, set, start, stop, keepawake, presses) must start
with the line "owner TOKEN" or is refused naming the holder, while
state, help and the screen-reading commands stay open to all. "owner
release" with the token frees it; the lock lives in memory and dies with
the app. "keepawake on|off [seconds]" has the worker press B every N
seconds (default 15) while no program runs, through the console commands'
keep_awake(); a running program pauses it. "state" gains the owner line.
Tests cover the owner line of a request, the lock's rules and the
schedule.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Lab.md documents the channel in one place: turning it on, the request,
journal and state formats, every channel and console command with its
defaults, the detectors, the owner rule, a shell session that launches the
app on a profile, claims the channel, selects a program, sets two options,
starts it, waits for STOPPED and releases, with the request and the
journal it produces, and what remains of the Command File Runner program.
The runner's README keeps its program-specific parts and points at Lab.md
for the commands; LabControl.md says where the old folder went.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
labctl.sh sends one channel request per call and prints its journal:
state, start, stop, select ID, set KEY JSON, owner claim/release,
keepawake, and send NAME for any request from stdin; LAB_OWNER puts the
owner line first. cfrun.sh is the lock plus labctl.sh send: no program
has to be selected or started for a batch any more, and the Prevent Sleep
handling goes (keepawake replaces it), so the CFRUN_SELECT gap closes.
lablock.sh is unchanged. The README follows: the channel instead of the
two folders, a worked run of a program with nothing clicked, how to run a
lab app beside the live app (a second bundle id, open -n, --profile), and
probing between runs. The skill points at Lab.md. Dry-run against a fake
app serving the Lab folder: every command, a failing batch, the lock
refusal and the no-app timeouts behave as documented.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine dayfine changed the title Lab tooling: lab control folder, Command File Runner, and the console-iteration skill Lab tooling: the lab channel, Command File Runner, scripts and the console-iteration skill Nov 1, 2026
The repo's C++ style asks for std::format where a message has several
parts, instead of "+" / std::to_string chains or an ostringstream. Converts
the journal lines, the argument errors, the screenshot labels, the walk
report's change list and the test messages in the runner and the lab
channel: 18 std::to_string sites and one ostringstream, with the same text
as before ({:f} keeps to_string's six decimals). The two ostringstreams
that collect a request's journal stay: they are the std::ostream the
commands print to, not a message.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine
dayfine marked this pull request as ready for review November 1, 2026 05:20

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

delete this file

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Deleted in 842ef8b. Lab.md's "Changes from the lab control folder" section is the one place that says where the old folder went; nothing linked to this file.


MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
MainWindow::MainWindow(std::unique_ptr<LabConsoleCommands> lab_console)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

is it ok to change QMainWindow/ main here?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Changed in 9c4b56f. The channel needs two things only the window has: the panel it shows now (and when that changes) and the program list to select by identifier, so some hook in MainWindow is unavoidable; the alternative, a public accessor for the current panel on PanelHolder, would widen an interface everything implements. The least intrusive form is what is there now: one private member, created by LabChannel::start_if_enabled() with two lambdas, plus the two set_panel() calls where the panel changes; the constructor signature and the public surface are back to upstream's. The call returns nullptr when <user files>/Lab/ does not exist at startup, so a normal app starts no thread and polls nothing.



MainWindow w;
MainWindow w(std::make_unique<NintendoSwitch::SwitchLabCommands>());

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

is this too intruding?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Agreed; Main.cpp is back to upstream's in 9c4b56f (zero diff). The console-command object is made in MainWindow.cpp next to the channel, where PanelLists.h already pulls in every game, so no new layering is introduced there.

"see what happens", and never rerun to "confirm" something a hand batch can
show.

The tools this loop leans on, by path:

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

how to actually use this?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Added a "How to use" section in c23466d: where the skill lives and how it is installed (ln -s into ~/.claude/skills), when it loads, and the exact first commands (labctl.sh state, owner claim, select, set, start, a cfrun.sh batch, lablock.sh run), with Lab.md and devtools/lab/README.md as the references for the command table and the scripts' parameters.

Comment thread skills/console-iteration/SKILL.md Outdated

## 1. Define a segment, then code it

A segment is **one map, or one story event**, never both. A map boundary is

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

this is still a bit too autostory-specific

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reworded in c23466d: a "segment"/"checkpoint" is now "a step the screen can prove", the story layer is the game-event layer, the save rules ask what the program under test saves instead of assuming a checkpoint run that saves at its start, and the BDSP-only phrasing is gone. AutoStory remains only as the named example in the How-to-use command block.

@dayfine

dayfine commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Review of 4151709e3: five correctness findings (two P1, three P2). Posted here because GitHub blocks a second review while the existing pending review is open; that pending review has been left untouched.

1. [P1] Wait for worker completion before destroying the channel

LabChannel.cpp:181

On Windows with Qt > 6.8.3, PA_ENABLE_QT_ADOPTION_WORKAROUND selects Thread_Qt.tpp, whose Thread::join() intentionally releases/leaks the QThread without waiting for run() to return. This destructor therefore does not establish that the worker has finished before its mutexes, condition variable, console, and other members are destroyed. A worker waking from m_idle_cv or returning from poll() can still access this object after destruction. The thread is started even when Lab/ does not exist, so this also affects ordinary app shutdown. Please use an application thread-pool task and wait for the task's actual completion before destroying the channel.

2. [P1] Do not reclaim a lock whose owner is still initializing it

lablock.sh:29

mkdir "$L" succeeds before the PID is written at line 57. During that interval a second caller's held() sees no PID, so clear_stale() deletes the first caller's live lock and allows another acquisition. Both callers then run their protected commands, and either exit trap can remove the other's lock. I reproduced this with the unchanged script, an isolated temporary LAB_DIR, and 20 concurrent callers: two workers were admitted and their protected work overlapped. Lock publication and stale-lock reclamation need to distinguish an initializing owner from a dead owner.

3. [P2] Keep screen-only requests independent of controller completion

NintendoSwitch_LabCommands.cpp:77

This unconditional wait also runs for READS_STREAM commands while a program is RUNNING. ControllerContext::wait_for_all_requests() waits on the shared controller's pending commands, including those issued by the program; LineRunner::current_frame() also waits before taking a snapshot. A long controller hold therefore delays a screenshot/detector request until the program's queue drains, although these commands are documented as available during a run. Since the channel processes requests serially, a subsequent stop request is blocked behind that read too. Please bypass controller queue waits for stream-only commands, including the wait inside current_frame().

4. [P2] Return a rejected start to the request journal

LabChannel.cpp:63

start_or_stop_program() returns void: it sends a start_program()/stop_program() error to UI listeners and discards the error string. Returning an empty string here therefore journals success even when start_program() rejected the start, for example when check_validity() fails. A multi-line request then continues with later commands while the program remains STOPPED. Please propagate the actual ProgramSession operation's error to the channel so the request stops and records an error line.

5. [P2] Preserve the JSON remainder instead of rebuilding it from words

LabChannel.cpp:114

split_command_line() tokenizes on whitespace without tracking JSON quoting, and this loop rejoins tokens with one space. A valid request such as set KEY "a b" silently becomes "a b". A string containing a space followed by #text is truncated by the tokenizer's comment handling and becomes invalid JSON. This prevents set KEY JSON from preserving arbitrary string option values. Please parse the command and key separately and pass the original remaining JSON text to parse_json(), with comment handling that respects quoted strings.

Lab.md's "Changes from the lab control folder" section already says where
the old folder went; a pointer file next to it is one more place to read.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit that referenced this pull request Nov 1, 2026
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 6 commits October 31, 2026 22:36
start_or_stop_program() reports the ProgramSession's error to the UI
listeners and returns nothing, so a start that check_validity() refused
was journaled as "ok" and the request went on with the program still
STOPPED. The channel now calls start_program()/stop_program() itself and
returns their error, which becomes the request's error line.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
…text

The words of a line are split on spaces and cut at '#', so "set KEY
\"a  b\"" reached parse_json() as "a b" and a string with a space and a
'#' was cut into invalid JSON. strip_comment() now respects JSON quotes
(with '\' escapes) and the line's words are split after it; "set" takes
its value from the line itself, line_after_words(), with spaces and '#'
intact. Tests cover both, and "set KEY" without a value is an error.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Main.cpp is back to upstream's and MainWindow's public surface is
unchanged: the window keeps one private member, created by
LabChannel::start_if_enabled() with two callbacks (the current panel, and
select by identifier) and told of panel changes. The call returns nullptr
when "<user files>/Lab/" does not exist at startup, so an app without the
folder starts no worker and polls nothing; the folder is created before
launch (Lab.md, labctl.sh say so). The worker is a pool task whose
completion the destructor waits for, instead of a Thread, whose join()
does not wait under the Qt thread-adoption workaround and could leave the
worker touching a destroyed channel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
A screenshot or detector request while a program ran waited for the
controller's queue to drain, i.e. for the program's own presses, before
taking a frame; a long hold delayed the read, and the stop request queued
behind it. The command session now says whether a frame waits for the
controller: the channel sets it only for commands that drive the console
(where a screenshot must show the state after the press before it); the
Command File Runner program keeps waiting, as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
mkdir publishes the lock before its pid file is written, and a concurrent
caller took the pid-less directory for a dead owner's, cleared it and
took the lock itself: with 20 concurrent callers, 5 or 6 were admitted
and their work overlapped. A lock without a pid now counts as held while
it is younger than 5 s (an owner still writing it) and as stale after
that; the pid is written last, and the exit trap removes the lock only
while its token is ours. lablock_test.sh runs the race: 20 callers, one
admitted, 19 refused, no overlap, three times in a row (the old script
fails it).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
A "How to use" section says where the skill lives, how it is installed,
and the exact labctl.sh / cfrun.sh / lablock.sh commands a session starts
with, pointing at Lab.md for the command table. The AutoStory assumptions
go: a segment or checkpoint is "a step the screen can prove", the story
layer is the game-event layer, the save rules ask what the program under
test saves rather than assuming a checkpoint run; AutoStory stays as the
named example in the command block.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine

dayfine commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

All five findings fixed, as new commits on lab/tooling (head c23466d):

  1. Worker lifetime (P1) — 9c4b56f. The worker is a task on GlobalThreadPools::unlimited_normal() held as an AsyncTask; the destructor sets the stop flag, wakes the idle wait, cancels any running console command and then wait_and_ignore_exceptions(), so the worker has returned before the mutexes, condition variable and console commands are destroyed. The channel is only created when <user files>/Lab/ exists at startup (LabChannel::start_if_enabled() returns nullptr otherwise), so a normal app starts no thread. Same commit: Main.cpp back to upstream's, MainWindow keeps one private member and two lambdas instead of a new constructor and a host interface.
  2. lablock.sh race (P1) — 566ede8. A lock directory without a pid counts as held while it is younger than 5 s (its owner is still writing it) and as stale after that; the pid is written last and the exit trap removes the lock only while its token is ours. devtools/lab/lablock_test.sh runs the race you describe: 20 concurrent callers, exactly one admitted, 19 refused, no overlap, three runs in a row; the previous script admits 5–6 of 20 under the same test.
  3. Screen-only reads vs the controller queue (P2) — e35c859. CommandFileSession gains sync_controller; the channel sets it only for commands that drive the console, so shot/detect/wait_for/expect neither wait in current_frame() nor after the command while a program holds the controller. The Command File Runner program keeps the wait (a screenshot after its own press must show the state after it).
  4. Refused start in the journal (P2) — 8459564. start/stop call start_program()/stop_program() directly and return their error string, which becomes the request's error N (start): ... line and stops the request. (Not unit-testable without a ProgramSession; it is a two-line change.)
  5. set KEY JSON text (P2) — 9c150c1. strip_comment() respects JSON quotes and \ escapes, split_command_line() splits after it, and set takes its value from the line itself via line_after_words(line, 2), so set KEY "a b" and set KEY "a # b" # c reach parse_json() intact. New test LabChannel - line after words covers those plus set KEY with no value; split a line covers # inside a string.

Also 842ef8b deletes LabControl.md. Local: incremental build, 13/13 LabChannel + CommandFileRunner tests pass. Fork CI dispatched on c23466d: Ubuntu https://github.com/dayfine/Arduino-Source/actions/runs/41277667567, Mac https://github.com/dayfine/Arduino-Source/actions/runs/41277668777, Windows Clang https://github.com/dayfine/Arduino-Source/actions/runs/41277670170.

dayfine and others added 30 commits November 14, 2026 18:01
A save-state LOAD or a RESET moves mGBA to another frame under the
pacer's and the key schedule's anchor: old grants would stall the
emulator after a jump ahead or let it run free after a jump back, and
queued KEYS would land on the wrong timeline.

KeySender::jump() stops the pacer, drops states not sent yet, sends
LOAD or RESET, reads the new frame with "GRANT 0", anchors a new clock,
schedule and input log there, releases held keys on that frame and
starts granting again. A refused command keeps the old clock and pacer.
ProController_MgbaLink exposes load_state() and reset_console().

Tests: fake-bridge cases for load ahead, load back, load before any
key, reset, a waiting state dropped by a load, and a refused load.
Lab: describe_program and game_open commands
…ib, not CoreLib

The selector widget header includes <QLineEdit>, which CoreLib (Qt-free) cannot
compile. The descriptor depends on VideoSource_MgbaLink, which is not in CoreLib
either. Both now sit in the main source list, like SysbotBase's.
Ends are placed from app time: three 80 ms states are 14.33 frames, so the
release lands on frame +14. The old expectation rounded each state to 5
frames separately, the drift KeySchedule avoids.
MgbaLink: GRANT pacer and mGBA Pro Controller (slice 2b)
MgbaLink: re-anchor the controller clock across LOAD and RESET
Lab: close the Slice 1 gaps (shot worker, transition source, state.json throttle)
The design doc's Slice 7b said the daemon replaces CFR with an app-wide
console seam (option A). The user chose option B on 2026-11-14: each panel
keeps its own console, and the seam is the lab channel's existing console
commands on the selected, stopped program panel. The section now says so
and why, lists what remains (scripts move off CommandFiles/ and
LabConsole/, the CFR panel goes once they have), and names the tests that
cover the gate.

The gate itself moves out of run_console_command's lambda into
console_command_refusal(state, reads_only) so the unit test
"LabChannel - console command refusal" can cover it: a press is refused in
every state but STOPPED, a read runs in any state.
Lab channel: Slice 7b is option B, test the console command gate
ProgramInstance gains precheck_summaries(): the program's prechecks in the
order it runs them (name, needs, skippable), or nothing when it declares no
list. describe_program prints them under "prechecks", or "unsupported" as
before. No program declares a list on this branch yet; FRLG RNG's list
(fork #485) overrides it once that reaches lab/tooling.
Lab: describe_program lists the program's prechecks (Slice 4)
The channel's "preflight JSON" stages the given options on the program
session (ProgramSession::run_prechecks_only()), runs the program's
prechecks (ConsoleProgramInstance::run_prechecks(); Switch programs
override run_switch_prechecks()) under a scope that makes Start refuse
meanwhile, loads the prior options back and prints one line,
"preflight {JSON}": the verdict, each check, the refused option and
whether the options were restored. Lab/state.json gains
program.options_hash, the SHA-256 of the program's option JSON, also in
the reply. No program declares runnable checks on this branch yet, so
every preflight says "unsupported" until FRLG RNG's list (#485) arrives.
… user drives the console

Lab/hold names the holder. The app puts it on when the user clicks Start or
Stop or presses through the window's keyboard/gamepad input; only hold.sh off
or the server's release-user takes it off. While held only reads run.
…unterReader test names match CommandLineTests
…r's edit

Review of #601. run_only now goes through run_prechecks_only(), which loads
the candidate and puts the prior options back through an OptionsThreadCall;
LabChannel passes run_on_ui (giving up when the panel changes), so options
load on the UI thread like "set" while the checks run on the worker. Before
the restore it compares the options with what it loaded: a user's edit
during the checks is kept, reported as restored:false with the edited keys
("edited_keys" in the reply). The restore never throws (caught and logged),
run_only refuses a session with no instance, and the log names only the
candidate's keys. The merge and refusal helpers move into the .cpp; their
tests now run through run_prechecks_only against a fake program, with new
cases for the user edit, a throwing check and check_validity.
Lab: preflight command and options hash (app side of Slice 5b)
Follow-up to the #601 review. A panel change cancels the console scope
while set_panel() on the UI thread waits for the panel this worker holds,
so the restore's UI call was given up: the candidate stayed loaded, no
reply was written, and the app could save it on exit. The preflight's
options call now runs the body on the worker once the scope is cancelled
(the UI thread is blocked then), and run_prechecks_only() turns cancelled
checks into a run with `cancelled` set after the restore, so the reply
says verdict "cancelled" with `restored`. Tests: ProgramPrecheckRun run
cases for a cancel and a cancel whose restore fails; LabProgramContract
preflight case for the cancelled verdict. read_options_hash() gets a
comment on why it reads on the worker.
Lab preflight: put the options back after a panel change
Lab: user hold on the console (app side)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

game:shared Shared or game-neutral code lab-tooling Lab channel, CFR, scripts, run records, build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants