Skip to content

feat(bun): tryWriteTextFile and tryRenamePath, total write and rename - #795

Merged
hyperpolymath merged 1 commit into
mainfrom
feat/bun-try-write-rename
Nov 14, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
feat/bun-try-write-rename

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

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 (metadatastician/kyx) needs both. A review of kyx#3 found two problems: a failed write could escape as a stack trace, and --into both could publish one output before the second failed.

Changes

  • lib/codegen_deno.ml: Bun builtins tryWriteTextFile(path, content) and tryRenamePath(from, to). Each returns true on success and false on 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 beside pathExists, which the builtins↔stdlib consistency test requires.
  • tests/codegen-bun/host_profile.{affine,harness.mjs}: assertions for:
    • a successful write;
    • a write into a missing directory (false);
    • a rename that replaces an existing target;
    • a rename of a missing source (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

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
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 14, 2026 22:24
Repository owner deleted a comment from coderabbitai Bot Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b2082246-fdc6-46e7-bcbf-6d1ff158ddde
Commits

Reviewing files that changed from the base of the PR and between b0336d7 and 0b2a333.

Files selected for processing: 4

  • lib/codegen_deno.ml
  • stdlib/Deno.affine
  • tests/codegen-bun/host_profile.affine
  • tests/codegen-bun/host_profile.harness.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T22:26:12.545173Z 0b2a333 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-14T22:27:17.088040Z 0b2a333 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath merged commit 613e9be into main Nov 14, 2026
11 checks passed
@hyperpolymath
hyperpolymath deleted the feat/bun-try-write-rename branch November 14, 2026 22:24
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.

3 participants