Fix #22: pr to a file stream is silenced under *hush* (-q)#23
Conversation
The canonical kernel `pr` (klambda/writer.kl) gates ALL output on *hush*:
(defun pr (S ST) (if (value *hush*) S (...write S to ST...)))
so under -q/*hush* a `pr` to a FILE stream wrote nothing, producing a
zero-byte file — a divergence from shen-cl/shen-go/ShenScript, which
write to files regardless of *hush*. *hush* is meant to suppress only the
interactive output that goes to standard output.
Fix: add a native `pr` override (install_native_stdlib in prims.lua) that
consults *hush* ONLY when the target stream is the standard output stream
(*stoutput*); writes to any other stream always occur. The actual write
delegates to the original compiled-KL pr (with *hush* temporarily cleared
and restored) so the write path stays byte-identical. The canonical
kernel sources are untouched.
Tests: updated the test/cli_spec.lua assertion+comment that locked in the
old zero-byte-file behavior to assert the corrected behavior (file gets the
payload under -q), and added focused #22 regression checks that *hush*
still silences pr to standard output.
make test: 447 pass / 0 fail across 11 specs.
make certify: canonical kernel certification 100% (exit 0).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Independent agent review (ratatoskr + ShenSpec deep-dive, post-load native override discipline, 134/134 cert preserved) Code Review: #23 (Fix #22: pr to a file stream is silenced under hush (-q))SummaryThis PR adds a targeted native override for the (See: ratatoskr/README.md:124-130 (hush caveat section calling out exactly that lua/rust needed The fix (only in prims.lua + cli_spec.lua; klambda/ and cert untouched) captures
Stream objects are Lua tables with private This matches the cross-port pattern (shen-cl has a native Tests: cli_spec.lua updated to assert payload is written under Correctness first assessment: The implementation is correct. The temporary clear/restore is exception-safe (restore before the Issues
No correctness, edge-case, race, or error-handling bugs were identified. The pcall restore is before any re-raise (prims.lua:760 then 761-762). The "stdout gate preservation" half of the spec is present and passing by construction. No VerdictReview notes written to Posted automatically by Grok reviewer subagents. See also the PENDING review (if any) for inline comments on the Files tab. |
|
Notes from independent reviewer subagent (ratatoskr/KLambda/writer.kl + sys.kl root cause, boot/ratatoskr-build timing, stream identity, pcall safety, and "other half" test verification): Nit
Suggestion
Nit (out-of-scope but noted)
Other nits around pcall error re-raise level, comment cross-refs to boot sites, and marker name polish. Core: pcall+restore is exception-safe, identity is robust, override timing correct (after kernel chunks), "other half" test (distinct marker + 99 return) correctly proves the stdout gate is preserved. Full review in previous comment. 447/447 + cert 100% confirmed. |
Fixes #22
Problem
The canonical kernel
pr(klambda/writer.kl) gates all output on*hush*:So under
-q/*hush*, aprto a file stream wrote nothing, producing a zero-byte file. This diverges from shen-cl, shen-go, and ShenScript, which write to files regardless of*hush*.*hush*is intended to suppress only the interactive output that goes to standard output.Fix
Add a native
proverride ininstall_native_stdlib(prims.lua) that consults*hush*only when the target stream is the standard output stream (*stoutput*). Writes to any other stream (files, stderr) always occur. The actual write delegates to the original compiled-KLpr(with*hush*temporarily cleared and restored), so the write path stays byte-identical and global state is not perturbed.The canonical/vendored kernel sources (
klambda/, the kernel cert suite, etc.) are untouched.Test changes
test/cli_spec.luaassertion + comment that locked in the old zero-byte-file behavior (commented "WITH -q the file is empty / documented divergence") to assert the corrected behavior: under-q, the file now receives the payload.*hush*still silencesprto standard output (the gate itself is preserved; only file/non-stdout streams are exempt), distinguishing the pr write from the-evalue echo by returning a distinct value.Results
make test: 447 pass / 0 fail across 11 port specs.make certify: canonical Shen kernel certification 100% (exit 0), no regression.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com