Skip to content

feat: add configurable stdout observer destinations - #107

Open
Krastanov wants to merge 2 commits into
mainfrom
Krastanov/codex/stdout-observer-destinations
Open

Krastanov wants to merge 2 commits into
mainfrom
Krastanov/codex/stdout-observer-destinations

Conversation

@Krastanov

Copy link
Copy Markdown
Contributor

StdoutObserver currently captures VM text only in memory. Add buffered(), stdout(), and file(File) constructors so callers can select memory capture, process stdout, or disk output using the same concrete observer type. Default and output() -> &[u8] remain compatible with existing callers; stdout/file destinations retain no extra memory copy and return an empty slice from output().

The caller controls file creation, truncation, and append options. Direct writes and observed effects use the selected destination, preserve UTF-8 bytes, and propagate I/O errors. Add explicit flush(), API and guide documentation, and integration tests using real files and a child process to check stdout isolation. tempfile is a test-only dependency.

This is a separate vihaco change related to QuEraComputing/stellarscope#134; it does not change Corvus or its JSON format.

Validation on macOS with Rust 1.96.0:

  • Passed cargo test -p vihaco-stdlib (5 unit tests and 6 integration tests).
  • Passed cargo test --workspace --doc.
  • Passed cargo clippy --workspace --all-targets -- -D warnings.
  • Passed cargo fmt --all -- --check and hawkeye check.
  • Passed cargo test --workspace --all-targets.
  • Independent implementation, documentation, and test review found no remaining issues.

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/vihaco/pr-preview/pr-107/

Built to branch gh-pages at 2026-09-17 15:20 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@kaihsin kaihsin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instead of having multiple output enum type, just redirect std::io::Cursor to what you want to output? I think Cursor is flexible enough, just need to redirect that Cursor buffer to either stdout or file.

@kaihsin kaihsin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

This branch has not been deployed

No deployments
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.

2 participants