fix: address PR review comments for opensmith tooling#8
Conversation
- Strip trailing `--` from comment bodies in opensmithgen.c - Add raw_len field to ast_node_t for byte-accurate reconstruction - Make reconstruct() and final literal segment handling branchless - Fix shell injection vulnerability in opensmith_parity.sh - Fix executable check (-x vs -f) in opensmith_frontend_check.sh - Fix nested_zip_prefix grep pattern for whitespace handling - Add cosmocc detection logic to opensmithgen-ape Makefile target Co-authored-by: ludoplex <5705162+ludoplex@users.noreply.github.com>
- Skip empty final literal segments to avoid polluting AST - Add null pointer check in reconstruct() for defensive programming Co-authored-by: ludoplex <5705162+ludoplex@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a67ab5ecc5
ℹ️ 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".
| RC=0 | ||
| sh -c "$CMD" > "$OUT_FILE" 2> "$ERR_FILE" || RC=$? | ||
| # Execute engine with fixture as separate argument (avoids shell injection) | ||
| "$ENGINE" "$fixture" > "$OUT_FILE" 2> "$ERR_FILE" || RC=$? |
There was a problem hiding this comment.
Preserve command-template semantics for --engine
Invoking the engine as "$ENGINE" "$fixture" now treats the entire --engine string as a single executable path, so command templates with arguments (including the documented ENGINE="cat {input}" flow in docs/OPENSMITH_PARITY.md) fail with 127 for every fixture instead of actually running the tool. This is a regression from the previous {input} substitution behavior and breaks parity runs that need an interpreter + script or any extra flags.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
refactor with previous {input} substitution behavior
There was a problem hiding this comment.
Pull request overview
Addresses follow-up review feedback for the OpenSmith front-end tooling by improving parser roundtrip fidelity and tightening shell harness correctness/security.
Changes:
- Update
opensmithgenAST handling to strip comment delimiter artifacts and reconstruct using stored byte lengths (avoidsstrlen()truncation issues). - Harden/correct OpenSmith shell harnesses (engine execution, executable checks, JSON whitespace handling in lock parsing).
- Improve
opensmithgen-apeMakefile target with cosmocc detection + actionable error output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/opensmithgen/opensmithgen.c | Adds raw_len for byte-accurate reconstruction and cleans up comment/literal parsing. |
| scripts/opensmith_parity.sh | Changes engine execution to avoid shell injection by passing fixture as a separate argv. |
| scripts/opensmith_frontend_check.sh | Validates tool is executable (-x) rather than merely present (-f). |
| scripts/opensmith_corpus.sh | Makes nested_zip_prefix extraction tolerant to JSON whitespace. |
| Makefile | Adds cosmocc detection/fallback for opensmithgen-ape builds. |
You can also share your feedback on Copilot code review. Take the survey.
| # Execute engine with fixture as separate argument (avoids shell injection) | ||
| "$ENGINE" "$fixture" > "$OUT_FILE" 2> "$ERR_FILE" || RC=$? |
Addresses review feedback from PR #5 on the OpenSmith parser front-end scaffold.
opensmithgen.c
--from comment bodies (was keepingcomment --instead ofcomment)raw_lenfield toast_node_tfor byte-accurate reconstruction—handles embedded NUL bytes thatstrlen()would truncatereconstruct()loopShell security/correctness
sh -c "$ENGINE $fixture"-x(executable) not-f(exists)nested_zip_prefixgrep pattern to handle JSON whitespace ("key": "value"vs"key":"value")Makefile
opensmithgen-apetarget: Add cosmocc detection with fallback to~/.cosmocc/bin/cosmoccand actionable error message (matches existingape:target)No Python removed—scripts were already POSIX sh.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.