Skip to content

feat(stream): add streaming CBOR decoder API - #20

Open
onkwon wants to merge 13 commits into
mainfrom
feature/stream
Open

feat(stream): add streaming CBOR decoder API#20
onkwon wants to merge 13 commits into
mainfrom
feature/stream

Conversation

@onkwon

@onkwon onkwon commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces a new streaming CBOR decoder to the codebase, allowing incremental, push-based decoding of CBOR data. It includes the implementation, documentation, public API exposure, and test runner setup for the streaming decoder. Additionally, there are minor improvements to the release workflow and error handling.

Streaming Decoder Implementation and Documentation:

  • Added cbor/stream.h header, defining the streaming decoder API, event types, callback mechanism, and decoder state structures. This enables incremental, event-driven decoding of CBOR data.
  • Updated README.md with a comprehensive section describing the streaming decoder usage, event callbacks, string and container handling, and API summary.

Public API and Error Handling:

  • Included cbor/stream.h in the main cbor.h header to expose the streaming decoder API to users.
  • Extended cbor_error_t enum with CBOR_NEED_MORE and CBOR_ABORTED error codes to support streaming decoder error reporting.

Testing:

  • Added a new test runner makefile tests/runners/stream.mk for the streaming decoder, specifying source files and test configuration.

Release Workflow:

  • Updated .github/workflows/release.yml to use environment variables and the GitHub CLI for release creation, improving compatibility with recent GitHub Actions changes.

@onkwon
onkwon requested a review from Copilot April 1, 2026 04:25
@onkwon onkwon self-assigned this Apr 1, 2026
@onkwon onkwon added the enhancement New feature or request label Apr 1, 2026

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.

Pull request overview

Adds a new push-based, event-driven streaming CBOR decoder API (headers + implementation), along with documentation, unit tests, a dedicated test runner, and a release workflow tweak.

Changes:

  • Introduces cbor_stream_* public API and a state-machine based streaming decoder implementation.
  • Adds comprehensive CppUTest coverage for streaming decoding behavior (scalars, strings, containers, tags, errors, reset).
  • Updates release workflow to use $GITHUB_ENV + gh release create.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/stream.c Implements the streaming decoder state machine and public cbor_stream_* functions.
include/cbor/stream.h Defines the streaming decoder public API, events, callback contract, and decoder state struct.
include/cbor/cbor.h Exposes the streaming API via the umbrella public header.
include/cbor/base.h Extends cbor_error_t with streaming-oriented error codes.
README.md Documents streaming decoder usage and event semantics with an example and API summary.
tests/src/stream_test.cpp Adds unit tests for streaming decoder behavior and error handling.
tests/runners/stream.mk Adds a dedicated test runner configuration for the streaming decoder.
.github/workflows/release.yml Switches version propagation to $GITHUB_ENV and creates releases via GitHub CLI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c
Comment thread src/stream.c
Comment thread src/stream.c
Comment thread src/stream.c
Comment thread src/stream.c
Comment thread include/cbor/cbor.h
Comment thread README.md
Comment thread tests/src/stream_test.cpp Outdated
Comment thread include/cbor/base.h

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c
Comment thread src/stream.c
Comment thread README.md
Comment thread include/cbor/stream.h Outdated
Comment thread tests/src/stream_test.cpp
Comment thread README.md Outdated
Comment thread README.md

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c Outdated
Comment thread src/stream.c
Comment thread README.md Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c
Comment thread src/stream.c
Comment thread include/cbor/stream.h Outdated
Comment thread .github/workflows/release.yml Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.github/workflows/release.yml:31

  • gh release create requires the workflow token to have write access to repository contents. Since this workflow doesn’t set explicit permissions, it may run with the default read-only GITHUB_TOKEN permissions and fail to create the release. Consider adding permissions: contents: write at the workflow or job level.
name: release

on:
  push:
    tags:
      - '*'

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Clone Repository
        uses: actions/checkout@v2
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Compile
        run: make
      - name: Install test framework
        run: make -C tests install
      - name: Unit Test
        run: make -C tests
      - name: Create Release
        run: |
          gh release create "${{ github.ref_name }}" \
            --title "${{ github.ref_name }}" \
            --generate-notes
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c
Comment thread include/cbor/stream.h Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread README.md Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c Outdated
Comment thread README.md Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment thread tests/src/stream_test.cpp Outdated
Comment thread include/cbor/stream.h
Comment thread .github/workflows/release.yml

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/src/stream_test.cpp Outdated
Comment thread include/cbor/stream.h
Comment thread include/cbor/stream.h

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/stream.c Outdated

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.github/workflows/release.yml:31

  • gh release create requires contents: write permissions for the workflow token in repos/orgs with restricted default permissions. Add an explicit permissions: contents: write (either at workflow or job level) to avoid release creation failing with a 403 when GITHUB_TOKEN is read-only.
      - name: Create Release
        run: |
          gh release create "${{ github.ref_name }}" \
            --title "${{ github.ref_name }}" \
            --generate-notes
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/cbor/stream.h
Comment thread tests/src/stream_test.cpp

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/src/stream_test.cpp
Comment on lines +739 to +746
TEST(StreamError, ShouldStickyError_WhenSubsequentFeedAfterError)
{
uint8_t bad[] = { 0xff };
uint8_t good[] = { 0x01 };

LONGS_EQUAL(CBOR_ILLEGAL, cbor_stream_feed(&decoder, bad, sizeof(bad)));
LONGS_EQUAL(CBOR_ILLEGAL, cbor_stream_feed(&decoder, good, sizeof(good)));
LONGS_EQUAL(0, rec.count); /* no extra events */

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

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

Test name has a grammatical typo: "ShouldStickyError_WhenSubsequentFeedAfterError" reads awkwardly and is inconsistent with other test names. Consider renaming to something like "ShouldBeStickyError_WhenSubsequentFeedAfterError" (or similar) to improve readability/searchability.

Copilot uses AI. Check for mistakes.

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@onkwon onkwon closed this Apr 18, 2026
@onkwon onkwon reopened this Apr 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants