Skip to content

[GAP queue] Retire the stray-close arm onto Session::run (GAP-2 parked arm) #2860

Closed

Description

@caomengxuan666

[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::run passes the source NAME as
    diagnostic_text (session.rs:527) where the arm passes None
    (→ 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, no ok on 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::run once Q-B/Q-C are
    fixed engine-side; no new face unless the entity lane shows the
    admission condition cannot ride on RunOptions honestly.
  • Q-B → (i) fix the diagnostic_text plumbing: the driver
    route's diagnostic_text must be the INPUT TEXT, made explicit
    (the arm's None → fallback does this today by accident). No new
    Diagnostic echo 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

  1. added this to the 1.5.1 milestone on Nov 6, 2026
  2. added
    enhancement
    area:parser
    on Nov 6, 2026
  3. caomengxuan666 commented on Nov 6, 2026

    @caomengxuan666
    MemberAuthor

    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 -i verified) — 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 — via RunOptions.source_name OR 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, merged b3af6de1 — Session::run hands 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 direct script_driver call, now runs through Session::run with 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.1 run_source_with_line_offset production count 1 → 0 (captain counted directly on niubash master: zero references remain anywhere in the tree), §2.3 Session::run 2 → 3 (three .run(&script, &options) production call sites). Both masters' ledgers byte-identical, md5 56886fc5b816d0c50405bf5e0769a0bf; §6 total unchanged at 281. Host production calls into script_driver for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:parserenhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions