Skip to content

[CTX-1186] chore(graphics): wire kitty decode/raster onto seam traits + shared png codec (#2000) - #2053

Merged
Xuepoo merged 4 commits into
mainfrom
carryctx/ctx-1186
Oct 14, 2026
Merged

Xuepoo merged 4 commits into
mainfrom
carryctx/ctx-1186

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Priority: P2 | Area: architecture | Labels: chore,P2,area:architecture | Milestone: v0.1.0 | Task: CTX-1186

Closes #2000

Summary

Wires Core Kitty decode/raster onto the published bitty-graphics seam
contract (bitty-graphics#15) behind a Core-owned trait, and drops the
png edge from Core image features.

  • New bitty-rich::kitty_seam: KittyTransmitFormat mapping with the
    seam spelling (unknown f rejects before the call), KittyDecodeBackend
    / KittyRasterBackend traits freezing signatures/caps/error shapes, and
    the stateless in-repo CoreKittyBackend. Caps are compile-time asserted
    (8192 px/side, 4096^2 area, 64 MiB RGBA, 32 blits, 64 MiB frame).
  • Runtime transmit (5 sites) and present raster paths call through the
    traits via a kitty_graphics backend field; precheck_transmit now
    returns the mapped format so unknown f can never reach a decode entry
    point. Swapping implementations never touches the call sites.
  • Kitty decode_png and background PNG moved from the image facade to
    the shared minimal png codec (same crate+pin as the extension seam,
    png 0.18, already locked at 0.18.1: zero new supply-chain nodes).
    image keeps jpeg+webp for background; background JPEG/WebP
    untouched.
  • New kitty_seam_parity integration suite (public API only, mirrors the
    22 conformance assertions): frozen caps, exact format mapping, pinned
    error displays, backend/free-function agreement, PNG normalization
    fixtures (gray-alpha, palette, 16-bit), oversize-IHDR refusal, raster
    behaviors.

Fence state (verified first, per task)

EXTENSION_CRATES already covers all four extension crates (generalized
by CTX-1086/#1890): no fence change. W-147 9/9 green on this head, plus a
documented trial-fork negative proof (planted bitty_graphics reference
in a Core source: fence fails closed; probe deleted, nothing committed).
No governance test touched. No [dependencies] edge on bitty-graphics
anywhere; the identifier appears in no Core src/ (prose mentions only).

Verification

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings
  • cargo nextest run --workspace --locked: 6607 passed, 0 failed
  • cargo test --workspace --doc: green
  • bitty-rich suites (incl. background PNG/JPEG/WebP + peak-memory),
    full bitty-runtime suite (147 targets): green
  • supply-chain (deny + audit): green
  • cargo check --target x86_64-pc-windows-gnu --workspace --all-targets: green
  • W-147 verify_w147_small_core_graph: 9/9 before push
  • just ci-local: environmentally blocked in this sandbox (act job sets
    SCCACHE_GHA_ENABLED=true + RUSTC_WRAPPER=sccache with no GHA cache;
    cargo metadata fails before compiling any code). Equivalent local
    gates above are green. scratch-paths fails identically on main
    (untouched wsl.rs/component.rs); changed files clean.

Risks / deltas

  • 16-bit Kitty PNG normalization now follows the png-crate scaling
    (seam-identical) instead of the image-facade scaling; outputs may
    differ by LSBs on 16-bit inputs only. No existing Core test pinned
    16-bit kitty bytes; parity fixtures lock the seam outputs.
  • Raster-cache entry cap stays Core-owned at 32 (documented delta vs the
    extension 128); the 64 MiB byte ceiling is shared.
  • Docs sync: no canonical *-docs change (implementation-internal seam;
    noted only per task).

Summary by CodeRabbit

  • Bug Fixes
    • Improved PNG decoding for backgrounds and Kitty graphics, including palette, grayscale, RGB, and 16-bit images.
    • Invalid, truncated, or oversized PNG images are rejected with clearer safeguards.
    • Kitty graphics continue to support clipped and resized rendering.

@Xuepoo Xuepoo added the chore Chore / maintenance label Oct 14, 2026
@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 14, 2026
@Xuepoo Xuepoo added P2 Priority: medium area:architecture labels Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0182dc1a-a955-41a3-8f82-a0e602ebfa7e
📥 Commits

Reviewing files that changed from the base of the PR and between 1e4ddca and defcb29.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 12
  • crates/bitty-rich/Cargo.toml
  • crates/bitty-rich/src/background.rs
  • crates/bitty-rich/src/kitty_decode.rs
  • crates/bitty-rich/src/kitty_raster.rs
  • crates/bitty-rich/src/kitty_seam.rs
  • crates/bitty-rich/src/lib.rs
  • crates/bitty-rich/src/wallpaper_theme.rs
  • crates/bitty-rich/tests/background_peak_memory.rs
  • crates/bitty-rich/tests/kitty_seam_parity.rs
  • crates/bitty-runtime/src/runtime.rs
  • crates/bitty-runtime/src/runtime/kitty_images.rs
  • crates/bitty-runtime/src/runtime/present.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

Core adds bounded PNG decoding and a public Kitty decode/raster seam. The runtime uses a Core-owned backend for Kitty transmission decoding and rasterization. Background JPEG and WebP decoding remains on the image facade.

Changes: Core Kitty graphics

Layer / File(s) Summary
Bounded PNG decoding
crates/bitty-rich/Cargo.toml, crates/bitty-rich/src/background.rs, crates/bitty-rich/src/kitty_decode.rs, crates/bitty-rich/src/wallpaper_theme.rs, crates/bitty-rich/tests/background_peak_memory.rs
bitty-rich adds a direct png dependency. Background PNG decoding and Kitty PNG decoding use the png codec with bounds and output-format checks. JPEG and WebP background decoding remain on image. PNG fixture encoders switch to png.
Core Kitty backend and parity tests
crates/bitty-rich/src/kitty_seam.rs, crates/bitty-rich/src/kitty_raster.rs, crates/bitty-rich/src/lib.rs, crates/bitty-rich/tests/kitty_seam_parity.rs
The rich crate exposes Kitty format, decode-backend, and raster-backend interfaces, with CoreKittyBackend delegating to existing Core functions. The parity tests cover format mappings, decoding, limits, and rasterization.
Runtime Kitty backend wiring
crates/bitty-runtime/src/runtime.rs, crates/bitty-runtime/src/runtime/kitty_images.rs, crates/bitty-runtime/src/runtime/present.rs
Both runtime constructors initialize CoreKittyBackend. Kitty transmission and animation-frame decoding use its decode trait. Raster-cache misses use its raster trait.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to defcb

The checked dependency and format-handling paths preserve their intended behavior. No identified issue blocks merging after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2000 requires Core to use a Core-owned Kitty decode/raster seam, preserve the stated caps, route Runtime paths through the backend, generalize the W-147 fence, and remove png from Core's `ima… Remove png from the crates/bitty-rich image feature list. Keep the direct png = "0.18" dependency for Kitty and background PNG decoding. Verify that background JPEG and WebP decoding remains enabled and that the workspace lockfile a…
Docstring Coverage Warning Docstring coverage is 59.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 11 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the primary changes: routing Kitty decoding and rasterization through seam traits and adopting the shared PNG codec.
Out of Scope Changes check Passed The reported changes remain connected to issue #2000. The direct png dependency and background decoder updates support the PNG feature migration. The seam, Runtime dispatch, raster changes, fence ve…
Full details: Linked Issues check

Explanation

Issue #2000 requires Core to use a Core-owned Kitty decode/raster seam, preserve the stated caps, route Runtime paths through the backend, generalize the W-147 fence, and remove png from Core's image features. The supplied changes show the seam, routing, caps tests, fence verification, and PNG codec migration. However, the crates/bitty-rich/Cargo.toml change summary states that image still has PNG, JPEG, and WebP features. This conflicts with the requirement to remove the png feature. The current PR description does not establish that the dependency declaration was changed as required.

Resolution

Remove png from the crates/bitty-rich image feature list. Keep the direct png = "0.18" dependency for Kitty and background PNG decoding. Verify that background JPEG and WebP decoding remains enabled and that the workspace lockfile and relevant tests pass.

Full details: Docstring Coverage

Explanation

Docstring coverage is 59.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 11 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review verdict — PR #2053 ([CTX-1186] chore(graphics): wire kitty decode/raster onto seam traits + shared png codec (#2000))

Reviewer: independent agent (guard-dispatched, separate session), read-only. Reviewed the PR's own diff at commit 8739fcc5 (local carryctx/ctx-1186; the PR head ecbcff5 is a Merge branch 'main' into carryctx/ctx-1186 whose only delta over 8739fcc5 is main content from #2050/#2051 — no PR-authored lines).

Verdict: APPROVE (no blocking findings).

Checks (all MET):

  • (a) Scope: 12 files, +1027/-170, all plausibly required by the shared-codec + seam wiring (new kitty_seam.rs +239, new tests/kitty_seam_parity.rs +420, decode/raster/lib/Cargo.toml, plus background.rs/background_peak_memory.rs because the png feature moved off the image facade, and runtime.rs/present.rs composition-root threading). No unrelated churn.
  • (b) Seam: kitty_seam.rs adds KittyTransmitFormat (Png/Rgb/Rgba, from_f/f_value/raw_channels), traits KittyDecodeBackend/KittyRasterBackend, and CoreKittyBackend; a const _: () = assert!(...) block pins the seam caps (8192px/side, 4096*4096 px, 64 MiB, 32 blits, 64 MiB/frame, f=100/24/32) to the kitty_place twins so drift fails the build. Traits name no extension crate and use only Core carriers — abstract enough for a non-runtime consumer.
  • (c) Wiring: crates/bitty-runtime/src/runtime/kitty_images.rs now calls self.kitty_graphics.decode_transmit / decode_transmit_owned instead of the free bitty_rich::decode_kitty_payload*; precheck_transmit returns bitty_rich::KittyTransmitFormat and rejects unknown f before decode; the PNG path uses png::Decoder directly (ignore-text-chunk, set_limits(MAX_BYTES), normalize to color8|alpha, bounds-before-alloc). kitty_raster.rs diff is doc-only (in-repo backend behind the seam).
  • (d) Parity test: kitty_seam_parity.rs (420 lines) freezes the seam caps verbatim plus their relationships (MAX_PIXELS*4 == MAX_BYTES, frame cap == decode cap, raster cache 32/64 MiB), exact format mapping, and pinned error Display strings. Independent negative oracle: seam_format_mapping_is_exact asserts KittyTransmitFormat::from_f returns None for [0,1,2,23,25,31,33,99,101,255,u32::MAX]; seam_error_display_is_pinned pins exact error strings. PNG fixtures are hard-coded byte probes, not golden self-comparison.
  • (e) Cargo.lock = 1 line changed (single dependency edge).
  • (f) Gates: all reported checks pass except Windows check and test (pending); local build intentionally not run (host disk at 100%). Re-run after the branch update.

Non-blocking notes for the record:

  1. The PNG edge is not dropped but moved: the image-facade png feature is removed and a direct png = "0.18" dependency is added to crates/bitty-rich/Cargo.toml, reversing the older W-141 "Core retains no PNG edge" comment. Matches the PR title's "shared png codec" goal; flag for the architecture record.
  2. Two defensive throws in the legacy path and the runtime raster call sites (present.rs, runtime.rs) fall outside the sampled diff head and were not independently re-verified.

Gate requires one approving review; recorded here as a comment per the shared-identity constraint (single GitHub identity cannot self-approve).

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Guard verification of the post-review head defcb29f (the recorded APPROVE covered 8739fcc5). Delta beyond main merges = one test-only commit: crates/bitty-rich/src/wallpaper_theme.rs encode_png helper inside #[cfg(test)], swapping the image facade encoder for the direct png crate (consistent with the PR goal of dropping the image png edge). No production-logic change, no new dependency edge beyond the PR's declared png = "0.18". CI fully green on defcb29f (Quality gates, M1/Compat aggregates, Windows, macOS, Linux X11/Wayland, MSRV, Supply chain, CodeQL). Prior independent APPROVE stands; merging under the shared-identity constraint.

@Xuepoo
Xuepoo merged commit 2604cfe into main Oct 14, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the carryctx/ctx-1186 branch October 14, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:architecture chore Chore / maintenance P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core-split] Wire Core kitty decode/raster onto graphics seam + generalize W-147 fence

1 participant