feat(awk): implement phase 4 investigation features#245
Conversation
|
@codex please review this PR. Focus on actionable correctness, security, regression-risk, and missing-test issues for the phase 4 awk implementation. If everything looks good, please say so explicitly. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec88f3c4ac
ℹ️ 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".
|
@codex please review the latest commit |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review please run another pass on the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba15f4d104
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2615aee24c
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d527e4843
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1019232d9
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86d1688cfb
ℹ️ 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".
|
@codex review please re-check the latest commit |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review please run a fresh pass now that this PR is based on Reviewed head: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9f55063c5
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b5a21d195
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b5a21d195
ℹ️ 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".
|
@codex please review the latest phase 4 changes on head |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cb1911d84
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a80598bdc1
ℹ️ 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".
|
@codex review please re-check the latest commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04e1b97cb2
ℹ️ 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".
| b.WriteByte('}') | ||
| return | ||
| } | ||
| b.WriteByte(value) |
There was a problem hiding this comment.
Escape octal regex bytes that are regexp metacharacters
When an awk regex contains an octal escape for a regexp metacharacter, this writes the decoded ASCII byte directly into the Go regexp pattern. For inputs such as awk 'BEGIN { print "*" ~ /\52/ }' or /\134/, gawk treats the octal escape as the literal character, but this normalizes to * or a dangling \, causing a regexp compile error or different matching semantics. The byte escape path should quote regexp metacharacters when the octal escape is meant to denote a literal byte.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I validated this against the pinned GNU awk oracle and this claim does not appear to be valid for the cited cases. GNU awk 5.4.0 does not treat octal escapes for regexp metacharacters as quoted literals here:
gawk 'BEGIN { print "*" ~ /\52/ }'fails with? * + or {interval} not preceded by valid subpattern: /\52/gawk --posix 'BEGIN { print "*" ~ /\52/ }'fails the same waygawk 'BEGIN { print "\\" ~ /\134/ }'fails withinvalid trailing backslash: /\134/gawk 'BEGIN { print "x" ~ /\56/ }'prints1, which shows the decoded.is acting as a regexp metacharacter, not as a quoted literal dot
rshell currently matches that behavior for the cited \52 case by surfacing a regexp compile error, so I did not change code for this thread.
| if len(e.args) == 0 { | ||
| return numberValue(float64(len([]rune(rt.field(0).String())))), nil | ||
| } | ||
| if arg, ok := e.args[0].(*varExpr); ok && rt.isArray(arg.name) { |
There was a problem hiding this comment.
Materialize ENVIRON before length(array) detection
This only treats a bare argument as an array when rt.isArray is already true, but built-in arrays like ENVIRON are lazy and are not present in rt.arrays until ensureEnviron runs. As a result, awk 'BEGIN { print length(ENVIRON) }' falls through to scalar evaluation and errors with cannot use array ENVIRON as scalar, even though the implementation supports both length(array) and ENVIRON; ensure built-in arrays are considered here before falling back to scalar length.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Validated against the pinned GNU awk oracle; this was real. length(ENVIRON) should materialize the lazy built-in array before deciding whether the bare argument is an array, while rshell was falling through to scalar evaluation and erroring.
Fixed in 16f6496a by materializing built-in arrays before the length(var) array check. Added a gawk-oracle regression in tests/scenarios/cmd/awk/basic/environ_numeric_string.yaml that checks length(ENVIRON) without depending on the exact environment size.
Validation run:
make fmt- direct repro via
go run ./cmd/rshell --allow-all-commands -c ... go test ./builtins/awk ./builtins/tests/awk- focused
TestShellScenariosAgainstGawk/cmd/awk/basic/environ_numeric_string make test_against_gawkmake test_awk_rewrittengo test ./...outside the sandbox after the sandboxed run hit unrelated macOSps/sspermission failures
|
@codex please re-check PR #245 from latest head commit The latest update keeps awk output command pipes open across |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3182fdb586
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update removes the disallowed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8540cc761
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update keeps reused awk output command pipes open across intervening stdout writes while still flushing one-shot pipes before observable stdout output. Please focus on actionable correctness, security/sandboxing, regressions, CI failures, or missing tests in the phase 4 delta against |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00b2733666
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update carries future-statement context through nested blocks and loop bodies so output command pipes reused on later loop iterations stay open until |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e88b735ac
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update carries future-statement context into user function bodies and teaches the output-pipe look-ahead to inspect function calls/bodies so command pipes reused across calls remain open until |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e77a79b7e0
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update defers awk input cleanup so main input, getline file sources, and command-input sources are closed on runtime error paths as well as success paths, with a close-tracking regression test. Please focus on actionable correctness, security/sandboxing, regressions, CI failures, or missing tests in the phase 4 delta against |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47847afde6
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update makes |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01543d9c17
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update delays stdout while an open awk output command pipe has a future write or explicit close, so reused pipes match GNU awk ordering without regressing explicit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c151978eb
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update carries future-statement context across normal rule iterations and END actions so output command pipes stay open across input records and explicit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 798982c6d2
ℹ️ 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".
|
@codex please re-check PR #245 from latest head commit The latest update treats non-literal |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Completes the practical awk phase 4 delta on top of phase 3 by adding the last investigation-focused pieces instead of broad GNU awk parity. This phase adds user-defined functions, substitution and matching helpers, composite-key polish,
getlineinput streams, and rshell-interpreted command pipes while tightening parse-time validation and help text around intentionally unsupported awk surfaces.sub,gsub,match,RSTART/RLENGTH,sprintf, ternary expressions, andexit [code]END-rule handling.return, and reserved-name/function-call validation.getline,getline var,getline var < file, and"cmd" | getline varthrough rshell sandbox policy.awk --helpfor supported command pipes, rshell sandbox execution, and unsupported awk file-output redirection.Validation
make fmtgo test ./analysis ./builtins/awk ./builtins/tests/awk ./testsmake test_against_gawkmake test_awk_rewrittengo test -race -v -timeout 10m ./...632d9c79