Skip to content

One tree per alias expansion, opaque in the state, reuse key from the modes (refactor 3.2, S5, S7) - #241

Merged
sf624 merged 4 commits into
refactor/3.2-splitfrom
refactor/3.2-trees
Oct 23, 2026
Merged

sf624 merged 4 commits into
refactor/3.2-splitfrom
refactor/3.2-trees

Conversation

@sf624

@sf624 sf624 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Step 3.2 of docs/design/refactor.md, layer 2 of 3 (stack: #240 → #241 → #242).

Addresses: S7 (alias part), S5 (reuse key, opaque)

  • S7, alias part: the tree of an alias's text with the rest of the command is the model's (Scripts.expansion), used by the walk where it expands the alias and read by the trust scan at each command named like an alias the script defines (the text as foreign text, the rest of the command where the command is; not an alias inside itself; at most 1,000 trees, then nothing is trusted). treeFacts, Trust.reads and the global cache of alias texts are gone; an alias no command names is read alone, as before. Effect: m[k]=1 in an alias after declare -A m keeps the decisions (before, nothing was trusted). test/trust.test.ts "reads the aliases the walk expands from the walk's own trees…" (with bash), plus an alias 'g,h=f' row.
  • S5, opaque: now ShellState.opaque, merged at joins, and a change that widen passes on (bodies no call reached, traps, recursive calls); the arithmetic memos depend on it instead of being emptied. test/state.test.ts "says so on the paths that ran what the walk does not read, and after they join" (with bash).
  • S5, reuse key: the modes are one record (Walker.mode: dead, quiet) and the key is derived from it (reuseKey). A reused walk now makes its changes again for what collects them, which fixes a contradiction: f() { x=2; }; x=1; f; x=1; trap f USR1 said x is 1 after the trap, where bash has 2 once the signal comes (test/state.test.ts "a walk reused makes its changes again…", with bash; CHANGELOG Fixed).

Probe tests and test/decisions.test.ts unchanged; fixture dumps unchanged. Node 24 coverage 100%, snippets regenerated.

🤖 Generated with Claude Code

@sf624
sf624 added this pull request to stack #243 October 23, 2026 09:17
@sf624 sf624 changed the title One tree per alias expansion, opaque in the state, the reuse key from the walk's modes (refactor 3.2, S5, S7) One tree per alias expansion, opaque in the state, reuse key from the modes (refactor 3.2, S5, S7) Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

sf624 and others added 4 commits October 23, 2026 22:52
… the walk's modes (refactor 3.2, S5, S7)

- The trust scan reads the trees of the aliases the walk expands (an
  alias's text with the rest of the command, Scripts.expansion), at each
  command named like an alias the script defines: the text as foreign
  text, the rest where the command is. treeFacts, Trust.reads and the
  global cache of alias texts are gone; an alias no command names is read
  alone, as before. So `m[k]=1` in an alias after `declare -A m` keeps
  the decisions.
- Whether a path ran what the walk does not read (a sourced file, a
  string not read, startup files) is ShellState.opaque, merged at joins,
  and a change other code may see (widen); the arithmetic memos depend on
  it instead of being emptied.
- The walk's modes are one record (dead, quiet); a function walk is
  reused by a key derived from it, and a reused walk makes its changes
  again for what collects them (a trap's action calling a function now
  widens what it sets, as bash may change it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ript, not over the whole script

A script with many plain uses of aliases (1,200 uses of `ll`) trusted nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f 3.2 trees)

500 commands of a chain of aliases that doubles 9 times asked for 255,500 trees, and V8 ran out of memory. A model now
makes at most 20,000; past them the trust scan trusts nothing and the walk takes the alias as what it does not read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o, in trees shared by text (review of 3.2 trees)

Taking the alias as unread text kept every variable and option as it was: after a capped chain whose last alias runs
`set -f`, `*.txt` was said to expand. The trust scan still trusts nothing then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sf624
sf624 force-pushed the refactor/3.2-trees branch from ec65607 to 50e2801 Compare October 23, 2026 14:20
@sf624
sf624 merged commit 2c99aab into main Oct 23, 2026
16 checks passed
@sf624
sf624 deleted the refactor/3.2-trees branch October 23, 2026 14:41
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