fix(fasl): replay per-form value echo on a warm load hit (#40)#41
Merged
Conversation
`(load FILE)` prints each top-level form's evaluated value (klambda/load.kl shen.eval-and-print / shen.work-through) before returning `loaded`. On a warm FASL-cache hit boot.lua returned `loaded` straight out of fasl_replay without re-running the kernel `load`, so that echo was dropped: `(load ...)` stdout depended on cache state — a cross-port divergence (shen-rust/shen-go always echo) and an intra-port nondeterminism (cold != warm). Capture the echo faithfully instead of re-deriving it. During a miss, the per-form echo is the only pr to (stoutput) that fires while inside shen.load-help with rec.in_chunk false (the form's own (output ...) side effects fire with in_chunk true and already replay via the chunk). Record those bytes as a new "e" record in stream order, right after each form's "c" chunk, and re-pr them on replay. Interleaving with side-effect output is preserved for free, and going through the live `pr` keeps *hush* gating at replay time (a -q hit stays silent, like a -q cold load). The cosmetic "run time"/"typechecked in N inferences" banners are emitted by `load` OUTSIDE shen.load-help, so rec.echoing excludes them — they stay dropped by design (per-run timing noise breaks cross-port comparison). FASL_FORMAT bumped 3 -> 4 (old caches miss and recompile cleanly). Verified: warm == cold == shen-rust == shen-go for the probe (raw and tc paths); -q hit stays silent; kernel tests 134/134; port specs 489/489 (cli_spec grows a #40 regression that drives a private-dir miss -> hit). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
(load FILE)prints each top-level form's evaluated value (klambda/load.kl→shen.eval-and-printon the raw path,shen.work-throughon the tc path) before returningloaded. On a warm FASL-cache hit,boot.luareturnedloadedstraight out offasl_replaywithout re-running the kernelload, so that echo was dropped.(load ...)stdout therefore depended on cache state:SHEN_FASL=off) ≠ shen-lua warm.Fixes #40. Surfaced by Bifrost
cases/divergences.json → load-toplevel-echo.Fix
Capture the echo faithfully rather than re-deriving it:
prto(stoutput)that fires while insideshen.load-helpwithrec.in_chunkfalse. (A form's own(output ...)side effects fire within_chunktrue and already replay by re-running the chunk.) Record those bytes as a new"e"record in stream order, right after each form's"c"chunk.fasl_replayre-prs each"e"record to(stoutput).Consequences that fall out for free:
prkeeps*hush*gating at replay time — a-qhit stays silent, exactly like a-qcold load. Bytes are captured even under*hush*(the string is computed regardless), so a miss recorded under-qstill replays correctly to a non-hushed hit.run time:/typechecked in N inferencesbanners are emitted byloadoutsideshen.load-help, sorec.echoingexcludes them — they stay dropped by design (per-run timing noise that would break cross-port comparison).FASL_FORMATbumped3 → 4; stale caches miss and recompile cleanly.Verification
==cold==shen-rust==shen-go for the probe, on both the raw and the(tc +)paths.-qhit stays silent (matches-qcold).SHEN_FASL_DEBUG=1still shows ahiton the second run — the fast path is intact.cli_specgains a load: warm FASL-cache hit drops canonical per-form value echo (cross-port divergence + nondeterminism) #40 regression that drives a private-SHEN_FASL_DIRmiss → hit and asserts the value echo returns while the run-time banner stays dropped).🤖 Generated with Claude Code