feat(stasis): pass each file's format to readBundle's onFile when it is known - #204
Merged
Merged
Conversation
…is known
Newer bundles write `formats` before any file contents, so the reader
knows each file's type before its contents arrive. onFile now gets it:
`onFile(file, contents, { signal, format })`. In older bundles, which put
the files first, `format` is undefined.
The reader records `formats` entries as they stream, normalizing the
root listing's '' key to '.' as fromJSON does. A repeated `formats` key
after the files would replace the one onFile was told about, so a format
passed to onFile must match the validated bundle's, or the read is
rejected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FinLHpaKeRRjstqzMnwj6u
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.
Follow-up to #184. Newer bundles (since #186) write
formatsbefore any file contents, so the streaming reader already knows each file's type when its contents arrive. This passes that type toonFile.Changes
readBundle'sonFileis now called asonFile(file, contents, { signal, format }).formatshas already streamed by, so every file gets its format.sourcesandmodulesfirst, soformatisundefined. The caller readsbundle.formatsonce the read resolves.formats.<file>string as it streams. It treats the root listing's''key as'.', the same wayBundle.fromJSONdoes.formatsafter the files would replace the oneonFilewas told about. Every format passed toonFilemust therefore match the validated bundle'sformats, or the read is rejected. This fits the existing rule that whateveronFilereceives is provisional until the read finishes.doc/file-formats.mddescribesformat.Tests
formatskey after the files changes a file's format.onFile, the read is rejected;onFilehad been given the first value.onFile, the bundle parses asBundle.parsedoes.''.main's reader.node --run lintis clean andnode --run testpasses all 85 suites.🤖 Generated with Claude Code
https://claude.ai/code/session_01FinLHpaKeRRjstqzMnwj6u
Generated by Claude Code