Repository navigation
[codex] shell: publish syntax, expand, and analysis packages - #756
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75c38660fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| r.analysisEmit(analysis.VariableWrite{ | ||
| Name: name, | ||
| Ref: ref, | ||
| Variable: vr, | ||
| Previous: prev, |
There was a problem hiding this comment.
Deep-copy variable values before emitting analysis events
analysisVariableWrite forwards vr/prev directly into analysis.VariableWrite, and those expand.Variable values can still alias live map/slice storage from the shell environment. If an observer mutates event.Variable.Map or event.Previous.List, it can change runtime shell state, which breaks the documented read-only/immutable analysis contract and can alter subsequent command behavior. Emit cloned expand.Variable payloads (deep-copy maps/slices) before calling the observer.
Useful? React with 👍 / 👎.
| var transformErr error | ||
| synthetic, transformErr = transform(file) | ||
| if transformErr != nil { | ||
| r.analysisFileFinish(r.AnalysisStatus()) |
There was a problem hiding this comment.
Emit failing FileFinish status when chunk transform errors
When transform(file) fails (for example via compileChunk returning a compilation/policy error), analysisFileFinish is emitted with r.AnalysisStatus() before any non-zero status is derived from that error. In this path the status is typically still zero, so observers see a successful FileFinish even though the run exits with a compilation failure. Derive the file status from transformErr (or set r.exit accordingly) before emitting FileFinish.
Useful? React with 👍 / 👎.
Summary
shell/syntax,shell/syntax/typedjson, andshell/expandshell/analysisobserver API and wire the internal interpreter to emit read-only semantic eventsWhat changed
internal/shell/syntaxtoshell/syntaxandinternal/shell/syntax/typedjsontoshell/syntax/typedjsoninternal/shell/expandtoshell/expandshell/internal/patternand added an internal-onlyinternal/shellpatterncopy for non-shell/*internal consumersshell/analysiswithObserver,ObserverFunc,Context, immutable context snapshots, and concrete events for run/file, statement, command, scope, variable, and option changesAnalysisObserverthroughgbash.Config,gbash.WithAnalysisObserver, runtime config, shell execution, andinterp.RunnerConfigSPEC.mdto document the new public package paths and the intentionally read-only analysis surfaceValidation
make testmake lint