Repository navigation
Description
[GAP queue] Retire the stray-close arm onto Session::run (GAP-2 parked arm)
Gap
niu crates/niubash-runtime/src/shell.rs:4521 — inside
execute_script_with_options (non-interactive fast path) — calls
rubash::script_driver::run_source_with_line_offset directly. It is
the ONLY remaining direct script-driver call from the host (ledger
§2.1: "run_source_with_line_offset (1; the unclosed-arm call left
the consumed surface with GAP-2, niubash#898 — the stray-close arm's
call remains)"). GAP-2 retired the tracked arm and the unclosed arm
onto Session::run; this one was parked because the host fast path
needs the driver's group-wise read-parse-execute split, and
Session::run could not then reproduce it — and, as the 2026-11-06
scoping round proves, still cannot (prep
~/workspace/wave-a/prep-remainder-scoping.md §2, probes in
~/workspace/prep-remainder/).
Measured deltas (this round, NEW)
- P-S2 — line route echo degrades:
session.run("echo ok\n)")
prints the token reconstruction instead of the verbatim offending
line. Mechanism:Session::runpasses the source NAME as
diagnostic_text(session.rs:527) where the arm passesNone
(→ falls back to the input text, parse_loop.rs:115-117). The GAP-2
pins assert only message + line, so they cannot see the echo. - P-S3 — grouped route: no echo, prefix never executes:
session.run("echo ok; echo )bad")prints only the message — no
echo line, nookon stdout. GNU runs the prefix, then errors,
status 2. The grouped route parses the whole input before
executing, so a stray error anywhere aborts the whole unit.
Migrating the arm to Session::run as-is would regress three
observable behaviors: (a) the offending-line echo, (b) the stderr
prog: -c: line N: shape, (c) prefix execution for
alias/history-bearing stray-close inputs (which take the grouped
route).
Ruling (captain, #863 comment — see there for the full text)
- Q-A → (i) host-only swap onto
Session::runonce Q-B/Q-C are
fixed engine-side; no new face unless the entity lane shows the
admission condition cannot ride onRunOptionshonestly. - Q-B → (i) fix the
diagnostic_textplumbing: the driver
route'sdiagnostic_textmust be the INPUT TEXT, made explicit
(the arm'sNone→ fallback does this today by accident). No new
Diagnosticecho field unless the entity lane shows the host
cannot render from the value. - Q-C → (i) route stray-close inputs to the line route if the
grouped route cannot run the prefix — acceptable on P-S4 byte
parity at 100%. A grouped-route divergence found along the way
becomes a Stage-2 ③ input, not a blocker for this item. - Probe-first gate: the entity lane runs P-S5/P-S6 (echo fidelity
× routes, prefix execution) BEFORE product work; product work
starts only once the probes confirm the fix shape.
Acceptance
P-S4 byte parity at 100% over the arm's input set × {-c, --ec,
script file, piped stdin} × {plain, alias-live, history-bearing} ×
stray shapes, arm-today vs migrated-niu vs GNU 5.3.20 (stdout /
stderr / rc). ~8 pins + host ~20 lines (replace the driver call
with Session::run + syncs). Ledger: the §2.1 row retires when the
call is deleted; Session::run's §2.3 count stays 2 unless Q-A(ii)
adds a row.
Labels: enhancement, area:parser. Milestone: 1.5.1. Fix destination:
Stage 1 (#863 queue tail).
Activity
api: Session::run diagnostic text is the input text, not the source n…
runtime: retire the stray-close arm onto Session::run (Refs unixwin/r…
docs(ledger): stray-close retirement counts — run_source_with_line_of…
docs(ledger): mirror stray-close retirement counts (Refs unixwin/ruba…
caomengxuan666 commentedon Nov 6, 2026
Done — the stray-close arm is retired and the GAP queue's last item is closed. Full chain:
Probe gate first (rulings required P-S5/P-S6 before any code): the oracle work corrected one scoping premise. GNU's reader unit is the LINE — a stray token voids its whole line, so a complete command on the same line before the stray never runs (prep's P-S3 premise does not hold for the same-line shape; complete earlier lines do run). The grouped route's two charges were not defects: no same-line prefix execution is GNU's line-unit rule, and no echo under the GAP-2 pin's interactive options is GNU's own interactive suppression (
printf … | bash -iverified) — under non-interactive options the grouped route is verbatim and GNU-exact on all 12 probe shapes. Q-C therefore closed by evidence: no routing change was made, and no grouped-route divergence goes into the structural programme's inputs.The one real defect (Q-B) was worse than scoped: on
Session::run's line route, a named source — viaRunOptions.source_nameOR the session's argv0 seed, which niubash sets from the script name — passed the name into the driver's diagnostic-text slot: a one-line input echoed`bash'(the name itself) and later lines echoed token reconstructions instead of the verbatim line. Engine fix: PR #2888, mergedb3af6de1—Session::runhands the driver the input text explicitly (GNU parse.y:6814/6833). No public surface change. Captain verification: the 2 new pins pass, mutation-checked (restoring the name fails both), consumer neighbourhood 114/114, session_api 19/19, full lib 1139/0/3.Host adoption: PR niubash#949, merged
d6849872— the stray-close arm, the host's last directscript_drivercall, now runs throughSession::runwith the unclosed arm's stop fold; admission untouched. Captain verification: new stem 4/4, issue431 8/8, issue482 8/8, issue562 6/6, runtime lib 958/3 (the three failures are the known fetch-budget / thread-count environment flake family); CI re-run against the fixed engine master green (macOS red is the pre-existing S8 PTY baseline only). Differential P-S4: 129 legs, migrated ≡ master on every leg, and ≡ GNU except the residual below.Ledger bookkeeping: rubash#2899 (merge
e8f1bb04) + niubash#951 — §2.1run_source_with_line_offsetproduction count 1 → 0 (captain counted directly on niubash master: zero references remain anywhere in the tree), §2.3Session::run2 → 3 (three.run(&script, &options)production call sites). Both masters' ledgers byte-identical, md556886fc5b816d0c50405bf5e0769a0bf; §6 total unchanged at 281. Host production calls intoscript_driverfor script execution: zero.Residual found by the lane, filed and tracked separately: niubash#950 — the tracked (alias/history) stdin feeder arm does not stop on a parse error (its fold lacks the parse-error term the migrated arms have); master and migrated trees are byte-identical there, so it is pre-existing, not a regression of this work.