Repository navigation
feat(runtime): stream binary responses to files - #193
Merged
Merged
Conversation
Signed-off-by: samzong <samzong.lu@gmail.com>
Contributor
Merging this PR will improve performance by 11.09%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | json-large |
3.8 ms | 3.4 ms | +11.09% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/stream-binary-responses (bbedc0a) with main (bad7939)
…sponses Signed-off-by: samzong <samzong.lu@gmail.com> # Conflicts: # docs/contracts.md # internal/codegen/render/skill_test.go
samzong
marked this pull request as ready for review
October 3, 2026 19:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #121.
type: file,format: binary) or a known binary media type (application/octet-stream,application/pdf,application/zip,application/gzip,image/*,audio/*,video/*,font/*, excluding+xml). An operation with any 2xx response that declares JSON or a streaming type is not binary.--output-file <new-path>(or-for stdout) and stream the response without buffering it. The flag is required: without it the command fails with usage / exit 2 before resolving a host or sending a request. The catalog exposes the actual flag name asoutput.binary.flag, and__lathe verifychecks that the flag exists.0600temporary file in the target directory and linked into place only after a complete 2xx response, so an existing path is never overwritten. Existing paths, missing directories, and unwritable directories fail before the request. Non-2xx responses, cancellation (Ctrl-C), and read failures remove the temporary file.application/pdf), a 2xx response whose actualContent-Typeis JSON or HTML is rejected withapi_error/ exit 3 before any byte is written. Generic declarations (application/octet-stream, wildcards) accept any stored type.--wait. Workflow steps that call a binary operation fail codegen.runtime.InvokeOperationkeeps buffering the response.--<output.binary.flag>with a new path, or-only when piping to another program.Verification
make checkpassed.go test -race ./pkg/runtime/... ./pkg/lathe/... ./internal/codegen/... ./internal/lathecmd/...passed.examples/richapi:lathe codegen -cache fixtures, build,__lathe verify --jsonreturnedok: true;Reports_Downloadreportsoutput.binary.flag: output-filewithcatalog_schema_version27 after merging main.600;-piped intocmpmatched; an existing target path failed with exit 2 and left the file unchanged; a missing flag failed with exit 2.--debug, and 200 responses with JSON, HTML, andapplication/problem+json. Its findings were fixed and re-verified.Not verified: the
Renamefallback for filesystems without hard links (for example exFAT); termination by a signal other than SIGINT may leave the hidden temporary file next to the target, as documented.Compatibility
runtime.SchemaVersion20 andruntime.CatalogSchemaVersion27; regenerate downstream CLIs.--output-file; the previous default of printing the bytes, or-o raw > file, now fails with exit 2. Use--output-file -to keep writing to stdout.--waitand cannot be used as workflow steps.Checklist
internal/generated/,.cache/, and ad-hocskills/<cli-name>/directories is not committed.