Skip to content

Add GifCodec (decode-only) with real-world GIF fixture tests - #19

Merged
Malcolmnixon merged 12 commits into
mainfrom
feature/gif-codec
Sep 26, 2026
Merged

Malcolmnixon merged 12 commits into
mainfrom
feature/gif-codec

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Summary

Adds a new decode-only GifCodec supporting GIF87a/GIF89a parsing, following the same public API shape as BmpCodec/PngCodec/TiffCodec/JpegCodec: Load(Stream), Load(string), GetInfo(Stream), GetInfo(string). No Save - GIF is decode-only in this codec.

Key design points

  • GetInfo/Load parity: both share a single private ReadLogicalScreenDescriptor(Stream) method as their first step, so header parsing/limits cannot drift out of sync (per prior JPEG PR feedback).
  • GIF-native LZW decoder: a new LSB-first bit-packed LZW decoder (GIF's bit order/code-value scheme differs from TIFF's), with standard (non-early-change) code-size growth, KwKwK reconstruction, and tolerant table-overflow handling.
  • Transparency: Graphic Control Extension transparent color index is read from data[3] (byte0=packed fields, byte1-2=delay time LE [ignored], byte3=transparent color index).
  • First-frame-only decode: multi-frame/animated GIFs decode only the first Image Descriptor's frame; subsequent frames are validated/skipped. CanDecode remains rue (default) since a well-formed animated GIF isn't malformed merely because this codec decodes only its first frame - documented in XML remarks.
  • Interlace de-mux: standard 4-pass GIF interlace row ordering.
  • Sub-region (Image Descriptor left/top/width/height) blitting onto the Logical Screen Descriptor canvas, with full bounds validation.

Companion artifacts

  • Design doc: docs/design/canvas-net/codecs/gif-codec.md (+ registration in codecs.md/introduction.md)
  • Reqstream: docs/reqstream/canvas-net/codecs/gif-codec.yaml (+ registration in codecs.yaml/
    equirements.yaml)
  • Verification: docs/verification/canvas-net/codecs/gif-codec.md
  • SysML2: docs/sysml2/model/canvas-net/codecs/gif-codec.sysml (+ registration in codecs.sysml)
  • Review set: .reviewmark.yaml new CanvasNet-Codecs-GifCodec entry
  • Tests: GifCodecTests.cs (30 hand-authored malformed-input/guard-clause tests), GifFixtureTests.cs (conformance tests against 8 real-world GIF fixtures), GifFixtures/README.md (fixture provenance/license)
  • User docs: README.md snippet, docs/user_guide/introduction.md new ### GifCodec section
  • .cspell.yaml: additive new technical terms only

Fixtures

8 real-world GIF files from https://samplelib.com/sample-gif.html (unrestricted license - no attribution required, see GifFixtures/README.md), covering solid-color single-frame and animated multi-frame GIFs at multiple resolutions. Solid-color fixture tests read each file's actual Global Color Table bytes directly rather than hardcoding assumed RGB values.

Verification

  • pwsh ./fix.ps1 (auto-fixers)
  • pwsh ./build.ps1 - build succeeded, 0 warnings/errors, full test suite passing across net8.0/net9.0/net10.0
  • pwsh ./lint.ps1 - all clean (spelling, markdown, YAML, sysml2tools model validation, reqstream/reviewmark lint, dotnet format)
  • Independent quality-agent code review confirmed correctness of the GCE offset, LZW decoder semantics, interlace de-mux pattern, and companion-artifact completeness.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Adds a new decode-only GifCodec supporting GIF87a/GIF89a parsing: shared
header parsing (ReadLogicalScreenDescriptor) for GetInfo/Load parity, global
and local color tables, Graphic Control Extension transparency (data[3]),
Image Descriptor sub-region blitting with interlace de-mux, and a
GIF-native LSB-first LZW decoder. Only the first frame of multi-frame/
animated GIFs is decoded; CanDecode remains true by design.

Includes companion design/reqstream/verification/sysml2 documentation,
.reviewmark.yaml review-set registration, hand-authored malformed-input
tests, and conformance tests against 8 real-world GIF fixtures
(solid-color and animated) sourced from samplelib.com (unrestricted
license, see GifFixtures/README.md).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 26, 2026 00:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address decoder validation and resource-bounding concerns, add local-color-table coverage, and correct stale documentation and requirements traceability.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 7 Low severity

Open (7)
What changed in this PR

Adds a dependency-free, decode-only GifCodec with GIF87a/GIF89a parsing, LZW decoding, transparency, interlacing, and first-frame support.

Changes:

  • Added decoder implementation and unit/conformance tests.
  • Added fixture provenance and deployment configuration.
  • Added documentation, requirements, verification, SysML2, and review registrations.
File Summary
test/​DemaConsulting.CanvasNet.Tests/​GifFixtures/​README.md Fixture provenance and licensing
test/​DemaConsulting.CanvasNet.Tests/​DemaConsulting.CanvasNet.Tests.csproj Fixture deployment configuration
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​GifFixtureTests.cs Real-world GIF fixture tests
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​GifCodecTests.cs Decoder and malformed-input tests
src/​DemaConsulting.CanvasNet/​Codecs/​NamespaceDoc.cs Codec namespace documentation
src/​DemaConsulting.CanvasNet/​Codecs/​ImageInfo.cs Image metadata documentation
src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs GIF parsing and decoding implementation
requirements.yaml Requirements registration
README.md Public GIF codec documentation
docs/​verification/​canvas-net/​codecs/​gif-codec.md GIF verification documentation
docs/​verification/​canvas-net/​codecs.md Codec verification overview
docs/​user_guide/​introduction.md GIF user guide documentation
docs/​sysml2/​model/​canvas-net/​codecs/​gif-codec.sysml GIF SysML2 model
docs/​sysml2/​model/​canvas-net/​codecs.sysml Codec model registration
docs/​reqstream/​canvas-net/​codecs/​gif-codec.yaml GIF requirements
docs/​reqstream/​canvas-net/​codecs.yaml Codec subsystem requirements
docs/​design/​introduction.md Design architecture overview
docs/​design/​canvas-net/​codecs/​gif-codec.md GIF codec design
docs/​design/​canvas-net/​codecs.md Codec subsystem design
.reviewmark.yaml Review registration
.cspell.yaml GIF terminology additions

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/design/canvas-net/codecs.md Resolved
Comment thread docs/design/introduction.md Resolved
Comment thread requirements.yaml Resolved
…udget, LCT-only test coverage

Resolves 7 low-severity findings from the Copilot code review on PR #19:

- DecodeGifLzw now continues until an actual End-of-Information code is read (never
  stops early merely because the declared pixel count was reached), and rejects any
  code that would decode past exactly that count, instead of silently truncating.
- ReadSubBlocks now enforces a shared 64 MiB total budget (MaxTotalSubBlockBytes,
  internal for test-seam access matching the JpegCodec precedent) across every
  extension and Image Descriptor sub-block chain in a file, bounding memory even for
  tiny-dimension GIFs with pathological sub-block counts.
- Added GifCodec_Load_LocalColorTableOnly_DecodesExpectedPixels, positively exercising
  the existing first-frame-Local-Color-Table-only decode path.
- Added GifCodec_Load_LzwStreamMissingEoi_ThrowsInvalidDataException and
  GifCodec_Load_LzwStreamOverrunsExpectedCount_ThrowsInvalidDataException.
- Added GifCodec_Load_ExcessiveSubBlockData_ThrowsInvalidDataException, proving the new
  sub-block budget is enforced.
- Design docs, NamespaceDoc, and reqstream/verification companion artifacts updated to
  stop claiming GifCodec is bidirectional, close an orphaned-requirements traceability
  gap for the new system-level GIF Codec API section, and add unit requirements/tests
  for the sub-block budget and LZW EOI/overrun strictness.
- Added CanvasNet_SystemIntegration_GifLoad_ReturnsExpectedPixel system-integration test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate GIF validation/resource-limit issues and documentation/traceability corrections remain.

Review effort: Lite
Findings: 4 Low severity

Open (4)
Resolved since last review (7)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Enforce exact four-byte GIF GCE data block

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:199

GIF Graphic Control Extensions have one fixed-size data sub-block of exactly 4 bytes followed by the terminator. ReadSubBlocks concatenates arbitrary sub-blocks, so a malformed 0x02 ... 0x02 ... 0x00 GCE totaling four bytes is accepted and applied as valid transparency metadata. Read the first size byte separately and reject any size other than 4 (and any additional data sub-block) before parsing the four fields.

This issue also appears in the following locations of the same file:

  • line 233
  • line 446
Low severity Update codec count in shared ImageInfo documentation

src/​DemaConsulting.CanvasNet/​Codecs/​ImageInfo.cs:14

Adding GIF to this list leaves the later shared-type explanation saying that “all four codecs” report the properties (lines 62-63), which is now stale and contradicts this five-codec list. Update that count so the public ImageInfo documentation consistently covers all six codecs, including the decode-only SVG codec where applicable.

Comment thread docs/design/canvas-net/codecs.md Resolved
Comment thread docs/reqstream/canvas-net.yaml Resolved
Comment thread docs/reqstream/canvas-net/codecs.yaml Resolved
Comment thread docs/verification/canvas-net/codecs.md Resolved
…ystem layer

The initial 'GIF Codec API' system-level section linked CanvasNet-Lib-Gif* directly
to unit-level CanvasNet-Codecs-GifCodec-* requirements, bypassing the existing
subsystem-level CanvasNet-Codecs-Gif* requirements in codecs.yaml (the same pattern
CanvasNet-Lib-JpegLoad etc. already use), which caused CI's reqstream --enforce
orphan check to fail on those 6 pre-existing subsystem requirements.

- canvas-net.yaml: CanvasNet-Lib-Gif* children now point to the subsystem-level
  CanvasNet-Codecs-Gif* requirements, matching every other codec's system section.
- codecs.yaml: added the new LzwRequiresEoi/SubBlockBudget unit requirements as
  children of CanvasNet-Codecs-GifUnsupportedFormatValidation (with their tests),
  and added GifCodec_Load_LocalColorTableOnly_DecodesExpectedPixels to
  CanvasNet-Codecs-GifLoad's tests list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resolve outstanding GIF parser edge cases and documentation/traceability inconsistencies.

Review effort: Lite
Findings: 2 Medium severity · 3 Low severity

Open (5)
Resolved since last review (1)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Reject zero GIF dimensions in shared header parsing

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:442

The shared header parser does not reject a zero logical-screen width or height, so GetInfo returns an ImageInfo for a malformed 0xN GIF while Load rejects the same header at lines 153-156. The other codec header parsers validate non-positive dimensions even when max-dimension enforcement is disabled; apply the positive-dimension check in this shared parser so GetInfo does not accept a malformed GIF header.

Low severity Update shared codec documentation to include GifCodec

src/​DemaConsulting.CanvasNet/​Codecs/​ImageInfo.cs:14

The new paragraph correctly updates the list to five raster codecs, but the following shared description still says that "all four codecs" report the four properties (around ImageInfo.cs:62-63). This leaves the public XML documentation internally inconsistent after adding GifCodec; update the remaining count and related wording to include the new raster codec.

Fixes 5 legitimate findings surfaced by an automated re-review of the
previous fix commits:

- Correct a second stale bidirectional/Save claim in
  docs/design/canvas-net/codecs.md (five raster codecs -> four of the
  five, all but the decode-only GifCodec).
- Fix CanvasNet-Lib-GifGetInfo/GifGetInfoValidation test evidence in
  docs/reqstream/canvas-net.yaml, which referenced the system
  integration test (which never calls GetInfo) instead of the actual
  focused GifCodec_GetInfo_* unit tests.
- Update docs/verification/canvas-net/codecs.md, which still claimed
  GifCodec had no system-integration test coverage.
- Rewrite MaxTotalSubBlockBytes' doc comment in GifCodec.cs to stop
  overclaiming that no legitimate file at MaxDimension could ever
  exceed the 64 MiB sub-block budget; a pathological (not just
  malicious) encoder could in principle do so, and this tradeoff is
  now documented honestly instead of asserted away.
- Fix a real validation gap in GifCodec.Load: the local/global color
  table presence check was nested inside if (result is null), so
  only the first frame's Image Descriptor was validated to have a
  resolvable color table. A later frame with neither a Local nor
  Global Color Table was silently accepted even though this codec
  never decodes that frame's pixel data. The check now runs for every
  Image Descriptor.

Adds GifCodec_Load_SecondFrameMissingColorTable_ThrowsInvalidDataException
to prove the fix, and updates the CanvasNet-Codecs-GifCodec-NoColorTable
unit requirement (title, justification, tests) plus its subsystem-level
test list and verification doc subsection accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 01:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate issues remain in GIF validation, requirements evidence, and fixture coverage.

Review effort: Lite
Findings: None

Resolved since last review (5)
Previously missed (3)

In code that hasn't changed since last review

Medium severity Reject zero-dimension GIFs in CanDecode

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:391

This returns CanDecode == true for a GIF whose Logical Screen Descriptor has a zero width or height, but Load rejects the same header at lines 163-166. Since zero dimensions are invalid within the header (and other codecs reject them in GetInfo), validate non-positive dimensions here while continuing to report oversized positive dimensions raw; otherwise the documented GetInfo/Load contract is broken.

Low severity Correct opaque pixel requirement for transparent GIF pixels

docs/​reqstream/​canvas-net/​codecs/​gif-codec.yaml:17

This requirement says every decoded GIF pixel has fully opaque alpha, but the implementation and the linked transparency requirement intentionally produce alpha 0 for the active Graphic Control Extension's transparent index. Leaving the Load requirement as written makes the requirements set contradict the public behavior and its verification.

Low severity Update documentation from four codecs to five

src/​DemaConsulting.CanvasNet/​Codecs/​ImageInfo.cs:14

The new count is updated to five raster codecs here, but the later shared remarks still say that 'all four codecs' report the same properties (line 63). Please update that stale count as part of this GIF addition so the generated API documentation does not contradict itself.

Fixes the last outstanding review finding: ReadSubBlocks' generic
concatenating reader let a Graphic Control Extension's 4 required data
bytes be split across multiple sub-blocks (e.g. two 2-byte sub-blocks)
and still be silently accepted, since only the reassembled total
length was checked. This is not spec-compliant: GIF89a requires the
Graphic Control Extension's data to be exactly one 4-byte sub-block
immediately followed by the block terminator.

Adds a dedicated ReadGraphicControlExtensionData helper that reads the
single declared sub-block size (rejecting anything other than 4),
reads exactly 4 bytes, and then requires the very next byte to be the
zero-length block terminator (rejecting any further sub-block data) -
leaving the generic ReadSubBlocks reader in place, unchanged, for every
other extension type and for image data, where multi-sub-block
chaining remains legitimate.

Adds GifCodec_Load_FragmentedGraphicControlExtension_ThrowsInvalidDataException
and updates the CanvasNet-Codecs-GifCodec-MalformedGraphicControlExtension
unit requirement (title, justification, tests) and its verification doc
subsection accordingly.

Also fixes a stale codec count in ImageInfo.cs's shared doc comment
('all four codecs' -> 'all five raster codecs'), left inconsistent
after GifCodec was added to the codec list earlier in this remarks
block but not to this later summary sentence.

Verified via local ReqStream --enforce: 0 orphaned requirements (the
6-orphan regression from an earlier push was already fixed and
reverified here); dotnet test (4089 tests, all passing); fix.ps1 and
lint.ps1 both clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical resource-budget enforcement and moderate validation issues remain.

Review effort: Lite
Findings: 1 High severity

Open (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Cover local tables and transparency in color requirements

docs/​reqstream/​canvas-net/​codecs/​gif-codec.yaml:17

This requirement contradicts the implementation and the separate transparency requirement: it names only a Global Color Table and requires fully opaque alpha, while GifCodec also supports Local Color Tables and sets alpha to zero for the active Graphic Control Extension's transparent index. Reword the requirement so the traceability contract covers both supported table types and the transparency exception.

ReadGraphicControlExtensionData decremented the shared remainingBudget
by its fixed 4-byte payload without first checking that 4 bytes were
actually still available, unlike ReadSubBlocks. If preceding
extension/image data had already exhausted (or nearly exhausted) the
budget, a Graphic Control Extension could still drive remainingBudget
negative and be accepted, and repeated Graphic Control Extensions
could continue to do so past the advertised MaxTotalSubBlockBytes
limit - meaning the total sub-block bound was not actually enforced
for this block type.

Fixed by checking size > remainingBudget and throwing
InvalidDataException before decrementing, exactly as ReadSubBlocks
already does.

Adds
GifCodec_Load_GraphicControlExtensionExceedsRemainingSubBlockBudget_ThrowsInvalidDataException,
which exhausts all but 2 bytes of the shared budget via a preceding
Comment Extension and then supplies an otherwise well-formed 4-byte
Graphic Control Extension, asserting it is now rejected. Updates the
CanvasNet-Codecs-GifCodec-SubBlockBudget unit requirement (title,
justification, tests) and its verification doc subsection
accordingly.

Verified via dotnet test (4092 tests, all passing), local ReqStream
--enforce (0 orphaned requirements), fix.ps1, and lint.ps1 (all
clean).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 02:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the GIF dimension and later-frame LZW validation issues, along with the noted documentation and traceability corrections.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Validate LZW minimum code size in later GIF frames

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:250

minCodeSizeByte is validated only when the first frame reaches DecodeGifLzw; later descriptors merely buffer and discard it. Consequently a multi-frame GIF with a later LZW minimum code size of 0 or 9 is accepted even though GIF requires 2-8 and the Load contract says invalid LZW data is rejected. Validate this field before skipping subsequent frames (and add a regression case).

Medium severity Reject zero GIF logical screen dimensions in GetInfo

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:462

The shared header parser accepts a zero width or height, so GetInfo returns CanDecode == true for a malformed 0xN GIF while Load rejects the exact same 13-byte header at lines 163-166. The other codec header parsers validate non-positive dimensions even when max-dimension enforcement is disabled (for example PngCodec.cs:1777-1780); apply the same validation here so both entry points reject an invalid Logical Screen Descriptor.

…imension GetInfo

- Validate the LZW minimum code size byte (2-8) for every Image Descriptor in
  GifCodec.Load, not just the first frame that DecodeGifLzw range-checks.
- Reject a zero width or height Logical Screen Descriptor in GifCodec.GetInfo,
  matching the identical check Load already performs, while still not
  enforcing Surface.MaxDimension in GetInfo.
- Add unit tests for both new validation paths.
- Update reqstream (unit/subsystem/system level) and verification/design docs
  to reflect the new validation behaviors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 26, 2026 02:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the decoder validation and interlace-test issues, along with documentation and traceability inconsistencies.

Review effort: Lite
Findings: None

Previously missed (3)

In code that hasn't changed since last review

Low severity Add empty-path test evidence to GIF load requirement

docs/​reqstream/​canvas-net.yaml:837

This system requirement claims that GIF load rejects an empty path, but its only listed test is CanvasNet_SystemIntegration_GifLoad_ReturnsExpectedPixel, which never passes an empty path. The focused GifCodec_Load_EmptyPath_ThrowsArgumentException test already exists; list it here (or add a system-level invalid-path test) so this requirement has matching evidence, as the neighboring GetInfo requirements do.

Low severity Align null-argument requirement scope with Load validation

docs/​reqstream/​canvas-net/​codecs.yaml:766

This requirement is titled as covering null arguments to both Load and GetInfo, and its evidence lists the GetInfo null tests, but its only child requirements are LoadNullStream and LoadNullPath. The GetInfo validation is decomposed under the separate GifGetInfoValidation requirement, so narrow this requirement and its evidence to Load (as the sibling codec requirements do) or add a consistent child decomposition.

Low severity Qualify opaque-pixel requirement for GIF transparency

docs/​reqstream/​canvas-net/​codecs/​gif-codec.yaml:17

This unit requirement says every decoded pixel has fully opaque alpha, but the implementation intentionally sets alpha to 0 for the active Graphic Control Extension's transparent index (GifCodec.cs:307-309), and the adjacent TransparentColorIndex requirement documents that behavior. Qualify this requirement so it describes opaque pixels except where GIF transparency applies.

- Add GifCodec_Load_EmptyPath_ThrowsArgumentException evidence to the
  system-level CanvasNet-Lib-GifValidationEmptyPath requirement, which
  previously only cited the unrelated system-integration Load test.
- Narrow CanvasNet-Codecs-GifValidationNull to Load-only null-argument
  validation (title, justification, tests), matching the sibling
  Bmp/Png/Jpeg codec pattern where GetInfo's null validation is
  decomposed separately under CanvasNet-Codecs-GifGetInfoValidation.
- Qualify CanvasNet-Codecs-GifCodec-Load's title so decoded pixels are
  described as opaque except where GIF transparency applies, removing
  the contradiction with CanvasNet-Codecs-GifCodec-TransparentColorIndex.
Copilot AI review requested due to automatic review settings September 26, 2026 02:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two moderate implementation issues and several documentation and traceability nits remain unresolved.

Review effort: Lite
Findings: None

Previously missed (3)

In code that hasn't changed since last review

Low severity Align design documentation with GCE parsing implementation

docs/​design/​canvas-net/​codecs/​gif-codec.md:118

This design description says every extension, including a Graphic Control Extension, is read through ReadSubBlocks, but the implementation intentionally uses the stricter ReadGraphicControlExtensionData path for GCEs and only uses ReadSubBlocks for other extensions and image data. Please update the design text so it does not document a helper path the implementation does not use.

Low severity Add GCE budget regression to subsystem evidence

docs/​reqstream/​canvas-net/​codecs.yaml:829

The subsystem requirement lists CanvasNet-Codecs-GifCodec-SubBlockBudget as a child, whose unit evidence includes both budget tests, but its tests list records only the generic excessive-sub-block case. The dedicated GCE budget regression is therefore omitted from the subsystem-level evidence; add GifCodec_Load_GraphicControlExtensionExceedsRemainingSubBlockBudget_ThrowsInvalidDataException alongside the existing test.

Low severity Document total sub-block limit in exception contract

src/​DemaConsulting.CanvasNet/​Codecs/​GifCodec.cs:150

The new shared sub-block budget is an intentional Load failure mode, but the public XML exception contract lists malformed LZW/data conditions without mentioning that a file exceeding MaxTotalSubBlockBytes is rejected. Add the total sub-block limit here so callers are not surprised when a structurally valid GIF is refused for the documented resource bound.

…ce, document sub-block budget in exception contract

- Correct gif-codec.md design doc: GCEs are parsed via the dedicated
  fixed-size ReadGraphicControlExtensionData path, not the general
  ReadSubBlocks chain used for other extensions/image data.
- Add GifCodec_Load_GraphicControlExtensionExceedsRemainingSubBlockBudget_ThrowsInvalidDataException
  to the CanvasNet-Codecs-GifCodecLoad subsystem requirement's tests list
  in docs/reqstream/canvas-net/codecs.yaml, matching the unit-level
  evidence in docs/reqstream/canvas-net/codecs/gif-codec.yaml.
- Document the MaxTotalSubBlockBytes rejection case in the Load method's
  InvalidDataException XML doc remarks.
Copilot AI review requested due to automatic review settings September 26, 2026 02:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate findings remain in GIF87a coverage, descriptor validation order, and fixture parity testing.

Review effort: Lite
Findings: None

Previously missed (1)

In code that hasn't changed since last review

Low severity Missing null argument tests as verification evidence

docs/​reqstream/​canvas-net.yaml:823

This system requirement is specifically about rejecting null stream/path arguments, but its only listed evidence is the successful-pixel integration test, which never passes null. Link the existing GifCodec_Load_NullStream_ThrowsArgumentNullException and GifCodec_Load_NullPath_ThrowsArgumentNullException tests here, as the child subsystem requirement already does, so the requirement has accurate verification evidence.

This issue also appears on line 857 of the same file.

…lidation requirement

CanvasNet-Lib-GifValidationNull (system-level) previously cited only the
successful-pixel integration test as verification evidence for a
requirement specifically about rejecting null stream/path arguments.
Link the existing focused tests GifCodec_Load_NullStream_ThrowsArgumentNullException
and GifCodec_Load_NullPath_ThrowsArgumentNullException, matching the
pattern already used by the child subsystem-level requirement
CanvasNet-Codecs-GifValidationNull in docs/reqstream/canvas-net/codecs.yaml.
Copilot AI review requested due to automatic review settings September 26, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Address the documented GIF87a coverage gap and correct resource-limit wording and requirements evidence.

Review effort: Lite
Findings: None

Previously missed (2)

In code that hasn't changed since last review

Low severity Remove unsupported empty-path evidence or add a matching test

docs/​reqstream/​canvas-net.yaml:839

This evidence list includes CanvasNet_SystemIntegration_GifLoad_ReturnsExpectedPixel, but that test only loads a valid 1x1 stream and never passes an empty path. The root requirement therefore claims evidence it does not have; keep only the focused empty-path test (or add a test that actually exercises this system requirement).

Low severity Link root requirement to malformed-input verification tests

docs/​reqstream/​canvas-net.yaml:858

The root unsupported-format requirement is linked only to a successful-load integration test, which cannot demonstrate any of the listed InvalidDataException cases. Replace this placeholder with the focused GIF malformed-input tests already listed under CanvasNet-Codecs-GifUnsupportedFormatValidation, so the root requirement's verification evidence is truthful.

- CanvasNet-Lib-GifValidationEmptyPath: remove irrelevant
  CanvasNet_SystemIntegration_GifLoad_ReturnsExpectedPixel evidence (which
  only exercises a valid 1x1 GIF, never an empty path), keeping the
  focused GifCodec_Load_EmptyPath_ThrowsArgumentException test.
- CanvasNet-Lib-GifUnsupportedFormatValidation: replace the same
  successful-load evidence (incapable of demonstrating
  InvalidDataException) with the full set of focused malformed-input
  tests already used as evidence for the child subsystem requirement
  CanvasNet-Codecs-GifUnsupportedFormatValidation in codecs.yaml, matching
  the pattern used by the sibling Bmp requirement.
Copilot AI review requested due to automatic review settings September 26, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues include missing GIF87a coverage and requirements/traceability inconsistencies.

Review effort: Lite
Findings: 2 Low severity

Open (2)
Previously missed (1)

In code that hasn't changed since last review

Low severity Clarify validation is structural, not semantic

docs/​design/​canvas-net/​codecs/​gif-codec.md:132

"Fully parsed and validated" overstates what the implementation does for later frames: it validates their descriptors, tables, dimensions, minimum code size, and sub-block framing, but intentionally does not validate LZW codes or palette indices. Say structurally validated so the design does not promise semantic validation that is not performed.

Comment thread docs/user_guide/introduction.md Resolved
…ation

- Design doc: add cumulative sub-block budget (MaxTotalSubBlockBytes) to
  Load's documented InvalidDataException conditions.
- Design doc: reword later-frame validation from 'fully parsed and
  validated' to 'structurally validated', clarifying LZW codes and
  palette indices are not semantically validated for frames after the
  first.
- User guide: complete the Load(Stream) InvalidDataException list with
  the LZW minimum code size range check, exact-output-count/EOI
  validation, and the cumulative sub-block budget limit.
Copilot AI review requested due to automatic review settings September 26, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate implementation and test-coverage findings remain, along with documentation and requirements alignment nits.

Review effort: Lite
Findings: None

Resolved since last review (2)

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.

2 participants