Repository navigation
feat(bun): tryWriteTextFile and tryRenamePath, total write and rename - #795
Conversation
writeTextFile throws on any host error (permission, missing directory, disk full), and the Bun host has no rename. So a program can neither report a failed write as an ordinary result nor publish several outputs all or none. kyX needs both: a review of kyx#3 found that a failed write could escape as a stack trace, and that `--into both` could publish one output before the second failed. tryWriteTextFile(path, content) and tryRenamePath(from, to) return true on success and false on any host error, and never throw. A caller writes every output to a temporary path with the first, and only when all succeed renames each into place with the second. Both are declared in stdlib/Deno.affine beside pathExists, as the builtins<->stdlib consistency test requires. Tests: host_profile asserts success, a write into a missing directory (false), a rename replacing an existing target, and a rename of a missing source (false). tools/run_codegen_bun_tests.sh fails without the builtins and passes with them; dune build @test/runtest is green (570 tests). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0136P7ZnvMV5Ghe7LUf3oc6N
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |



Summary
writeTextFilethrows on any host error (permission, missing directory, disk full), and the Bun host has no rename. So a program can neither report a failed write as an ordinary result nor publish several outputs all-or-none. kyX (metadatastician/kyx) needs both. A review of kyx#3 found two problems: a failed write could escape as a stack trace, and--into bothcould publish one output before the second failed.Changes
lib/codegen_deno.ml: Bun builtinstryWriteTextFile(path, content)andtryRenamePath(from, to). Each returnstrueon success andfalseon any host error, and never throws. A caller stages every output with the first and, only when all succeed, renames each into place with the second.stdlib/Deno.affine: declarations besidepathExists, which the builtins↔stdlib consistency test requires.tests/codegen-bun/host_profile.{affine,harness.mjs}: assertions for:false);false).Testing
tools/run_codegen_bun_tests.sh: fails without the builtins, passes with them.dune build @test/runtest: green, 570 tests.Generated by Claude Code