Skip to content

probe: prove the fork CI lane executes (throwaway, do not merge) - #26

Closed
danielmeza wants to merge 5 commits into
mainfrom
probe/fork-lane
Closed

danielmeza wants to merge 5 commits into
mainfrom
probe/fork-lane

Conversation

@danielmeza

Copy link
Copy Markdown
Owner

Throwaway probe for PR #25. Both the CONFIGURATION expression and the downgrade guard compare against a different repository name, so this same-repository pull request takes exactly the path a fork PR takes: fork detected, Debug chosen, run untrusted. Opened only to show the fork lane running rather than being skipped, then closed.

The 2026-10-07 Six Labors advisory batch leaves no patched 2.x or 3.x
release: the five findings that reach 3.1.12 (GHSA-jjfr-hcj7-qf5w,
GHSA-j9gm-c75j-xc9q and GHSA-j3p4-wp97-rph4 high, plus
GHSA-wmxv-xphr-5c9g and GHSA-gwg2-r3hj-4w44 moderate) are all first
patched in 4.1.2. With NuGetAuditMode=all and warnings-as-errors, that
made the repository itself stop building, and consumers could not
restore without suppressing all five.

Moving is not a version edit. ImageSharp 4.x drops the implicit
Color -> Rgba32 operator and Color.FromRgba, and ImageSharp.Drawing 3.x
(the line paired with 4.x, and the only one that depends on 4.1.2)
replaces the per-context drawing extensions and the ambient
SetDrawingTransform with a retained-mode DrawingCanvas entered through
Paint. The replacements used here, each checked against the shipped
assemblies rather than assumed:

  Color.FromRgba(r,g,b,a)      -> Color.FromPixel(new Rgba32(...))
  (Rgba32)someColor            -> the Rgba32 components directly, since
                                  Color.ToPixel<Rgba32>() would only
                                  round-trip 8-bit RGBA we already hold
  ctx.SetDrawingTransform(m)   -> DrawingOptions.Transform, per paint
                                  pass, widened to Matrix4x4
  ctx.DrawText/Fill/DrawLine   -> DrawingCanvas.DrawText/Fill/DrawLine
  RectangularPolygon           -> RectanglePolygon
  clone-then-Resize for a
  scaled DrawImage             -> DrawImage's own source/destination
                                  resampling

The public surface is untouched: all six Graphics interfaces, the
Matrix3x2 transform stack and the per-primitive anti-aliasing (off for
filled rectangles so barcode modules stay crisp) behave as before.

CrossEscPos.Transports carried a second, independent copy of the same
problem: an explicit SixLabors.ImageSharp 2.1.13 pin, added to lift
ESCPOS_NET's transitive 2.1.3, which the same five advisories now reach.
It moves to 4.1.2 as well. That project uses no ImageSharp API itself,
and ESCPOS_NET's single ImageSharp-dependent member is called from
nowhere in this repository.

A new end-to-end test drives every canvas primitive from ESC/POS bytes
to an encoded PNG and asserts the decoded IHDR geometry, the colour
type, the closing IEND chunk and that the page carries real ink -
geometry alone cannot tell a correct render from a silently blank one.

ImageSharp 4.x and Drawing 3.x also add a build-time licence check that
only warns for Debug and fails for Release, which is what CI uses. The
workflows now pass $(SixLaborsLicenseKey) from a repository secret; the
check itself is untouched, so Release stays red until that secret
exists.
Review of the migration turned up two real defects.

The underline stopped being ink. ImageSharp.Drawing 3.x centres a stroke
on its geometric coordinate, so the one-dot underline landed exactly on
a pixel boundary and rasterised as two rows at 50% grey instead of one
solid row. Measured on a one-dot underline, 60 px wide:

  ImageSharp 4.1.2 + Drawing 3.1.2   0 pixels below 50% luminance
  Skia (the reference backend)      48 pixels

Nothing a 1-bit thermal printer threshold would burn, and lighter than
both the Skia backend and ImageSharp 3.x. An axis-aligned line is now
filled as a hard-edged rectangle of the same extent, which is what a dot
row physically is. Doing it as geometry rather than as a half-pixel
nudge keeps it right under the canvas transform, where a nudge in local
coordinates would scale into a full-pixel displacement. Ink now matches
Skia exactly at every combination tested - one-dot and two-dot
underlines, at normal and double height: 48, 96, 96 and 192 pixels on
both backends. Diagonals keep the anti-aliased stroke the contract
specifies.

The end-to-end test could not have caught that, or much else. Mutation
testing it - replacing each primitive's body with an empty one - showed
every single primitive could be disabled with the test still green,
because one surviving primitive satisfied its "some ink on the page"
assertion. It is replaced by per-primitive assertions that each isolate
one drawing member: text puts ink on the page, double-size text draws
more than twice the normal-size ink (the only path with a non-identity
transform), an underline adds ink over the same text plain, barcode
modules and raster images draw, an oversize raster is scaled to the
paper width, and blank paper has none. Clear is covered directly,
because the receipt pipeline never calls it. Re-running the same seven
mutations now fails a test on every one.

Also corrected: the Transports comment named the wrong ESCPOS_NET
member. ToSingleBitPixelByteArray still works on 4.1.2; the member that
breaks is Image.Load<TPixel>(byte[]), reached through the public
PrintImage emitter - and it already breaks on 3.1.12, so the boundary is
2.x to 3.x, not 3.x to 4.x. The comment now records what was measured.

docs/Building-and-Testing.md gains the licence-key instructions a
developer needs for a local Release build, and the canvas class comment
records two deliberate side effects of the move: image draws now honour
the canvas transform, and a fractional image origin is resampled rather
than truncated. Both match the Skia backend more closely than the old
code did, and no current call site exercises either.
A pull request from a fork is never handed repository secrets, so the
Six Labors licence key cannot reach it and a Release build there can
only fail — a red an external contributor has no way to fix, on a public
MIT repository.

CI now picks its configuration from who is running it: a fork PR builds
Debug, where the same licence check only warns, so the compiler and the
full test suite still give a real signal. Every trusted run (push,
same-repository PR) stays on Release and keeps covering the licence gate
and the packing path.

It is deliberately one job that always runs, with the configuration
chosen in an expression, rather than two lanes gated by `if:`. A skipped
job reports as success, so a mistake in the condition would read as
green while building nothing. A "Refuse to downgrade a trusted run"
step is the other half of that guard: it fails loudly if a push or a
same-repository PR ever lands on anything but Release, instead of
silently skipping the licence gate. A "Report the lane" step prints the
event, both repository names and the resolved configuration, so which
lane ran is visible in every log rather than inferred.

The licence check itself is untouched: no suppression, no NoWarn, no
placeholder key. What a fork lane does not cover is stated in
docs/Packages.md and the PR: the licence validation (warning only, which
is the point) and Release codegen. There is no `#if DEBUG` or `#if
RELEASE` anywhere in the tree and no configuration-conditional MSBuild
logic, so nothing else differs between the lanes.

The uploaded package artifact is now named after its configuration, so a
fork lane's Debug packages cannot be mistaken for a releasable set.

docs/Packages.md also records the dependency floors 1.4.0 changes, for
the consumer rather than only in a csproj comment: Rendering.ImageSharp
3.1.12 to 4.1.2 and Transports 2.1.13 to 4.1.2, with the one
combination that regresses (Transports plus ESCPOS_NET's own image
printing) and the measurement showing it breaks at 3.x rather than 4.x.
Two "byte-compatible with Skia" claims are corrected to "same ink,
within sub-pixel antialiasing", which is what the backends actually
produce.
…fork lane

Throwaway. Both the CONFIGURATION expression and the downgrade guard compare
against a different repository name, so this same-repository pull request takes
exactly the path a fork PR takes: fork detected, Debug chosen, run untrusted.
Used once to prove the fork lane executes rather than being skipped.
@danielmeza

Copy link
Copy Markdown
Owner Author

Probe complete — the fork lane ran end to end in Debug (run 37735796672): trusted=false, configuration=Debug, 140 tests passed, the Six Labors check emitted 4 warnings and 0 errors, and all 11 steps executed with none skipped. Closing; the branch is deleted. The real change is in #25.

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