Skip to content

Restructure the core library after NwcIO and RvtIO - #23

Merged
mahach666 merged 3 commits into
mainfrom
refactor/core-architecture
Nov 20, 2026
Merged

mahach666 merged 3 commits into
mainfrom
refactor/core-architecture

Conversation

@mahach666

@mahach666 mahach666 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What

The core package follows the IOExtend reference layout, as requested ("сделай архитектуру ядра чистой, референсы RvtIO/NwcIO"):

  • PlaIO.Model: the document types (FdbHeader, PlaBlock + PlaBlockMode, ObjectDirectory + ObjectDirectoryRecord, CompressedPool, PoolSubgroup, PlaStream) move out of the root namespace into src/PlaIO/Model/, the way RvtIO.Model and NwcIO.Model organize their cores. The root keeps the entry points: PlaDocument, BimxDocument, PlaFile, and the new PlaReaderOptions. Breaking namespace change (0.x preview allows it; CHANGELOG notes it).
  • PlaReaderOptions (with Default, after NwcReaderOptions): caps what the readers decode into memory —
    • MaxGlobalStreamBytes (default: Array.MaxLength, the most one in-memory stream can hold) bounds the decoded global stream and the window a mode-2 ReadPayload builds. Until now OpenStream on a large file decoded with no bound (S-Office: ~588 MB).
    • MaxDecodedPoolBytes (512 MiB) bounds one decoded pool.
    • MaxCoverBytes (64 MiB) replaces the fixed .bimx cover limit; BimxDocument.Open takes the options.
    • A read past a cap throws InvalidDataException naming the cap, checked against the declared sizes before decoding, so a skipped false entry is never mistaken for a cap failure.
  • Internal.GlobalStreamDecoder: the mode-2 global-window decode moves out of PlaDocument (it was a document method plus two privates); the document keeps orchestration only.
  • PlaStream.SkippedBlocks: the false entries of the scan behind UnreliableFrom, in file order.

Deliberately not added: an NwcDiagnostic-style diagnostics subsystem — the lazy container reading has no eager pass that would fill one; the honest signals stay on the types (SkippedBlocks, directory quality pairs, PoolSubgroup.Partial). It lands with element reading.

Verification

  • 195 passed / 16 skipped / 0 failed on both TFMs (5 new tests: defaults match reader limits, global-stream cap rejects before decoding and admits at exactly the cap, pool cap, SkippedBlocks in file order).
  • 0 warnings; docs (public-api.md) and CHANGELOG updated; ADR-007 in the vault.
  • Fixed the stale XML doc on PlaBlockMode.Lz ("cannot be decoded" — mode 2 has decoded since Decode mode 2 (LZ) payloads #17).

The entry points (PlaDocument, BimxDocument, PlaFile, the new
PlaReaderOptions) stay in PlaIO; the document types (FdbHeader, PlaBlock,
ObjectDirectory, CompressedPool, PoolSubgroup, PlaStream) move to
PlaIO.Model, as RvtIO.Model and NwcIO.Model organize their cores.

PlaReaderOptions caps what the readers decode into memory:
MaxGlobalStreamBytes (default: the most one in-memory stream can hold)
bounds the decoded global stream and the window a mode-2 ReadPayload
builds, MaxDecodedPoolBytes (512 MiB) bounds one decoded pool, and
MaxCoverBytes (64 MiB) replaces the fixed .bimx cover limit.

The mode-2 global-window decode moves out of PlaDocument into internal
machinery, and PlaStream exposes SkippedBlocks - the false entries of the
scan behind UnreliableFrom.
Review fixes:

- Open(string) and Open(Stream, bool) keep their 0.1.0 signatures; the
  reader options come through added overloads Open(string,
  PlaReaderOptions?) and Open(Stream, bool, PlaReaderOptions?), so a
  binary built against 0.1.0 keeps finding its entry points.
- PlaReaderOptions is immutable (init-only properties): Default cannot
  be mutated, so one reader never changes the limits of another.
- A mode-2 ReadPayload now checks the requested block's declared size
  against MaxGlobalStreamBytes before its buffer is allocated; the cap
  is a property of the whole window, which the requested block joins.
- The getting-started example gains the PlaIO.Model using.
@mahach666

Copy link
Copy Markdown
Contributor Author

All three points are fixed in 59fe117:

  1. LZ payload vs the cap — ReadPayload now checks the requested block's declared size against MaxGlobalStreamBytes after the prefix window is built and before the block's buffer is allocated, with the same message shape as the window check. New test: ALzBlockItselfCountsAgainstTheGlobalStreamCap (a 4-byte LZ block under a 3-byte cap throws; the raw-block sibling test stays).
  2. Entry-point signatures — Open(string) and Open(Stream, bool) keep their exact 0.1.0 forms; the options come through added overloads Open(string, PlaReaderOptions?) and Open(Stream, bool, PlaReaderOptions?) (the same for BimxDocument), so a binary built against 0.1.0 keeps resolving its calls. The stream overload takes leaveOpen explicitly — a default there makes named-argument calls ambiguous with the 0.1.0 overload. getting-started.md gained using PlaIO.Model.
  3. Mutable Default — the options are now immutable (init-only properties), so Default cannot be mutated and one reader can never change another's limits; the changelog and public-api notes say so. (Chose immutability over an open-time snapshot: simpler contract, and object initializers still compile.)

@mahach666
mahach666 merged commit 66b3abc into main Nov 20, 2026
4 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.

1 participant