Skip to content

feat(stasis): pass each file's format to readBundle's onFile when it is known - #204

Merged
ChALkeR merged 1 commit into
mainfrom
claude/focused-noether-0q8ffx
Oct 2, 2026
Merged

ChALkeR merged 1 commit into
mainfrom
claude/focused-noether-0q8ffx

Conversation

@exo-nikita

Copy link
Copy Markdown
Collaborator

Follow-up to #184. Newer bundles (since #186) write formats before any file contents, so the streaming reader already knows each file's type when its contents arrive. This passes that type to onFile.

Changes

  • readBundle's onFile is now called as onFile(file, contents, { signal, format }).
    • Newer bundles: formats has already streamed by, so every file gets its format.
    • Older bundles: they put sources and modules first, so format is undefined. The caller reads bundle.formats once the read resolves.
  • The reader records each formats.<file> string as it streams. It treats the root listing's '' key as '.', the same way Bundle.fromJSON does.
  • JSON keeps the last value of a repeated key, so a second formats after the files would replace the one onFile was told about. Every format passed to onFile must therefore match the validated bundle's formats, or the read is rejected. This fits the existing rule that whatever onFile receives is provisional until the read finishes.
  • Docs: the reader section of doc/file-formats.md describes format.

Tests

  • The both-orders test now also checks that each file gets its format when the files come after the metadata, and none when they come first.
  • New test: a second formats key after the files changes a file's format.
    • With onFile, the read is rejected; onFile had been given the first value.
    • Without onFile, the bundle parses as Bundle.parse does.
    • The test also covers the root listing's format keyed as ''.
  • Both new tests fail on main's reader. node --run lint is clean and node --run test passes all 85 suites.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FinLHpaKeRRjstqzMnwj6u


Generated by Claude Code

…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
@ChALkeR
ChALkeR merged commit 7010fd2 into main Oct 2, 2026
5 checks passed
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.

3 participants