Skip to content

Refs #2794: expansion-error discard face on RunClassification - #3248

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/E1-2794
Nov 10, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/E1-2794

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Refs #2794

What

RunClassification grows an expansion_error_discard face: whether the run's terminal unit ended in an expansion-error DISCARD — a FATAL-class word-expansion error the executor adjudicated an interactive DISCARD at its raise point instead of a fatal FORCE_EOF jump. Until now that fate (status 1, Flow::Completed, no unwind, every classification flag false) was indistinguishable from an ordinary status-1 completion to a host reading only the classification.

Mechanism

  • GNU basis: the FATAL class takes interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal — ${var:?} (subst.c:10416-10418), nounset unbound (subst.c:11032-11034), bad @-transform (subst.c:8949), arithmetic nounset (expr.c:1208-1216). The error branch is a DISCARD: the unit is dropped with status 1 and the reader lives (eval.c:111-128).
  • The executor notes the verdict at the adjudication points themselves — every FATAL-class arm where expansion_error_is_interactive_discard() selects the DISCARD (15 arms across the simple-command pre-scan, heredoc finish, raise_word_expansion_error, the arithmetic-nounset gates, the bare-arithmetic fast entry, the assignment-only arithmetic consumer, pipeline element gates, and the [[ ]] operand gates plus its arithmetic-comparison nounset trap) — into a per-unit record that mirrors Q6 arm B's unit_signal_discard. No session-layer re-derivation. The arm census was completed at captain review by full enumeration of the predicate's call sites plus producer/consumer tracing of the arithmetic_nounset_error and conditional_expansion_fatal latches: three ruling paths the first pass missed (the bare-(( )) fast entry ruling on its own arm, the assignment-only command consuming the latch itself, and the [[ ]] arith-compare trap ruling at the trap rather than at its downstream conversion) now note at their own arms too.
  • The grouped driver carries the record per group beside terminal_discard (same most-recent-group semantics, same skipped-group reset) into GroupedRunClassification; Session::run's grouped route, outcome_after_driver, and Session::take_classification report it on RunClassification. The startup-file literals report false (a non-reader route, like their signal_discard).
  • The fact can stand alongside errexit_break: the discard dropped the line; the verdict on its status ended the session.
  • Boundary: the lesser expansion classes (bad substitution and kin) carry no interactive/fatal branch in GNU and never set the face — locked by a consumer boundary cell.

Tests

  • The fate matrix stays locked by tests/issue2794_expansion_error_discard_classification.rs (7 cells, unchanged): base and head both 7 passed / 0 failed.
  • New consumer assertions in src/api/consumer_tests.rs ride the field the pin could not reference before it existed: grouped + line routes with survival and per-run clearing, the -e coexistence cell, the non-interactive fatal counter-cell, a nounset member cell, the plain-failure / lesser-class boundary cells, and the three census-completion cells — bare-(( )) arithmetic nounset (both routes), assignment-only arithmetic nounset, and [[ ]] arithmetic-comparison nounset.
  • Lib bilateral failure name sets base vs head: equal (see verification notes in the lane report).

Ledger

docs/api-ledger.md: a dated header addendum records the field, a follow-up addendum records the census completion of the noting-arm set, and the §2.3 Session::take_classification row's value list gains the expansion-error discard. RunClassification rides inside RunOutcome's recorded entry and stays unlisted as its own §6 symbol, so no §6 entry is added and no census count moves; the new executor note/take pair is driver-internal plumbing of the same unrecorded kind as the unit_signal_discard pair.

Merge gate: the niubash copy of docs/api-ledger.md must be synced in the same batch before this merges (the #3145 / niubash#976 pattern), so the two copies stay byte-identical.

本 PR 删除了什么

无删除路径。纯新增:一个分类字段、一条 executor 单元记录及其注记/读取对、15 处裁定点注记、driver 与 session 的同位携带、consumer 断言与账本记录。唯一的删除计数是账本 §2.3 一行括注的原地扩写(+21/−1 中的 −1)。

A FATAL-class word-expansion error (${var:?} subst.c:10416-10418,
nounset unbound subst.c:11032-11034, bad @-transform subst.c:8949,
arithmetic nounset expr.c:1208-1216) adjudicated an interactive
DISCARD was classification-silent: status 1, Completed, every flag
false — indistinguishable from an ordinary status-1 completion.

The executor now notes the verdict at its raise points (every
FATAL-class arm where expansion_error_is_interactive_discard
selects the DISCARD) into a per-unit record mirroring Q6 arm B's
unit_signal_discard; the grouped driver carries it per group and
the session routes report it as
RunClassification::expansion_error_discard. The lesser expansion
classes carry no interactive/fatal branch in GNU and never set
it. Consumer assertions cover the grouped/line routes, the -e
coexistence, the non-interactive fatal counter-cell, nounset,
and the plain-failure/lesser-class boundaries; the fate pin is
unchanged (7/7 on base and head). Ledger: header addendum plus
the take_classification row's value list.

No deletion paths; additions only (the single deletion count is
one ledger row extended in place).
Captain review census (full enumeration of the discard predicate's call sites plus producer/consumer tracing of the arithmetic_nounset_error and conditional_expansion_fatal latches) found three FATAL-class DISCARD ruling paths the first pass left unnoted, none compensated by another arm: the bare-arithmetic fast entry ruling on its own arm, the assignment-only command consuming the arithmetic nounset latch itself, and the [[ ]] arithmetic-comparison nounset trap ruling at the trap (its prepare-side conversion only unwinds the parked status). All three now note at their own DISCARD arms, for 15 noting arms in all. Three consumer cells ride the new paths (the bare-arithmetic cell on the grouped and line routes). Ledger gains a coverage-completion addendum in the same form; no face change.

No deletion paths; additions only.
Formatting only; no semantic change.
caomengxuan666 added a commit to unixwin/niubash that referenced this pull request Nov 10, 2026
本 PR 是 rubash PR #3248 台账面的镜像同步:把 `docs/api-ledger.md` 的 expansion-error discard addendum(两条 Addendum + `Session::take_classification` 行口径更新)字节级同步到 niubash 侧,使两仓台账保持字节一致。这是 rubash 侧合入的前置门(先例:niu PR #976)。

同步验合:

- 同步前:niu 当下 master 台账与 rubash PR #3248 基底(`530d7063`)台账 sha256 同为 `56551e95bffbad7a90ead051aef3965c0ca24c73920022067f2cbfcd79059d32`——基线无漂移。
- 同步后:本 PR 的 `docs/api-ledger.md` sha256 = `09ecf2c203187eaa516ce114be2a783df9b7db81750e04edb12928b5f31b1882`,与 rubash PR #3248 头 `1b8ea5b7` 的台账全文逐字节一致。
- 变更面:仅 `docs/api-ledger.md` 一个文件,+30/−1,不碰任何代码。

本 PR 删除了什么:台账中 `Session::take_classification` 一行旧口径文本(1 行),由含 expansion-error discard 的新口径行替换;无其他删除。

Refs unixwin/rubash#3248
Refs unixwin/rubash#2794
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 15:09
@caomengxuan666
caomengxuan666 merged commit a852b78 into master Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant