Skip to content

fix(artifacts): keep uImage coverage unknown when bytes follow the declared payload - #14896

Merged
vincentkoc merged 1 commit into
morluto:mainfrom
Anurag-5ingh:fix/uimage-trailing-coverage
Nov 27, 2026
Merged

vincentkoc merged 1 commit into
morluto:mainfrom
Anurag-5ingh:fix/uimage-trailing-coverage

Conversation

@Anurag-5ingh

@Anurag-5ingh Anurag-5ingh commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The U-Boot legacy uImage reader reported coverage.status: "complete" when the file continued past the declared image (64-byte header plus ih_size). Those bytes belong to no entry and no limitation mentioned them. That is the layout of OpenWrt sysupgrade images, where a squashfs root filesystem follows the kernel uImage. After this change, coverage is unknown, with a limitation giving the length and starting offset of the bytes that were not exposed. Entries, metadata and CRC checks are unchanged.

Fixes #14893

Problem and expected behavior

Smallest trigger: a valid uImage with any bytes appended after its payload. On dc12e5768b it lists . and payload.bin with complete coverage.

Real example: OpenWrt 24.10.0 glinet_gl-ar150-squashfs-sysupgrade.bin (published SHA-256 594bf0fb…ae2d13b) is 6,619,452 bytes. The uImage ends at offset 2,613,261, so 4,006,191 bytes (the rootfs) were hidden behind a complete inventory.

The artifact inventory contract treats complete coverage as every byte accounted for. ZIP reports bytes its central directory does not account for as unknown, and the ESP image reader does the same for undescribed trailing bytes.

Change and scope

  • UImageArtifactReader derives coverage in a new uImageCoverage helper. Coverage is unknown if the size table failed to parse (existing behavior) or if the file has bytes past 64 + ih_size. The helper also builds both limitations, which keeps prepareEntries under the lint function-length limit.
  • U-Boot does not pad a legacy image (mkimage writes header plus data), so no padding allowance is needed. Partition dumps padded with 0xff also report unknown, because REA does not examine or expose those bytes.
  • docs/uimage.md states where the image ends and when coverage is unknown.

Not included:

Contribution scope: not applicable (fix within an existing reader).

Contract and boundary impact

  • Semantic owner and earliest changed stage:
    • Owner: UImageArtifactReader.prepareEntries, which already owns the header facts and the carrier size.
    • Distinguishing case: a uImage with appended bytes. Before, coverage was complete; after, it is unknown. An exact-length uImage stays complete.
  • Contribution scope fit and linked maintainer decision: fix within the existing reader; no decision required.
  • CLI and MCP/tool-catalog contract:
    • inspect-artifact / inspect_artifact and extract-artifact report coverage.status: "unknown" for these files.
    • No schema change.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract:
    • The coverage declaration becomes unknown, with one added limitation.
    • Entries and metadata are unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: UImageArtifactReader.test.ts adds "keeps coverage unknown when bytes follow the declared payload". Through scanCanonicalArtifactInventory, it asserts the exposed child, unknown coverage and the exact limitation. The existing kernel test is the exact-length control and still asserts complete.
  • Base reproduction (executed): with the reader change stashed, the new test fails (16 others pass); with it, the test passes.
  • User-visible CLI output (executed on the downloaded OpenWrt 24.10.0 GL-AR150 images; both digests match the published sha256sums):
File Base coverage.status With change
initramfs-kernel.bin (6,240,763 bytes, exact uImage) complete complete
squashfs-sysupgrade.bin (6,619,452 bytes) complete unknown

Added limitation on the sysupgrade image: 4006191 byte(s) after the uImage payload, starting at offset 2613261, were not exposed as entries.

  • Remaining proof gaps: none known for the uImage path. FIT is out of scope as described above.

Boundary regressions: an unexposed region after the declared extent, an exact-length control, and the existing truncation, CRC and size-table failure paths. No lifecycle stage changes.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/artifacts: 109 files, 2393 tests pass, 19 skipped.
  • npx vitest run on UImageArtifactReader.test.ts, UImageArtifactReader.boundaries.test.ts, tests/boundary/mcp/uImageMcp.test.ts, tests/acceptance/uImageCli.test.ts, OwnedArtifactStream.test.ts, artifactFormatRecognition.test.ts, machoContainer.test.ts, TargetFormatVocabularies.test.ts and dfuse.test.ts after npm run build: all pass.
  • npx vitest run src/artifacts/UImageArtifactReader.test.ts with the reader change reverted: 1 failed (the new test), 16 passed.
  • node scripts/run-typescript.mjs -p tsconfig.json --noEmit: passes.
  • npx oxfmt --check on the changed files: passes.
  • npx oxlint on the changed files: no warnings.
  • node scripts/verify/architecture-guards.mjs: passes.
  • npm run verify:module-boundaries: passes.
  • npm run docs:check: passes.
  • rea inspect-artifact <file> --json on the two OpenWrt images, on the base revision and with the change: results as in the table above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Callers that relied on complete for these files now see unknown, which the contract already allows.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static reader); macOS arm64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new reads; coverage reporting only.

Author readiness

Human owner: @Anurag-5ingh

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Author checklist (completed by the PR author before requesting review)

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.
  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.
  • Documentation is concise and factual, without punchy slogans or promotional language.
  • This change fixes the root cause and follows the engineering rules in AGENTS.md.
  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.
  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.
  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.

…clared payload

U-Boot does not pad a legacy image, so bytes after the 64-byte header and
the declared payload belong to no entry. The reader reported complete
coverage for them, which hid a root filesystem appended after a kernel.
Report unknown coverage with the length and starting offset of those bytes.

Fixes morluto#14893
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T12:27:35.940305Z 64f0c56 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR marks uImage coverage as unknown when bytes follow the declared payload. It reports their length and starting offset without changing entries or CRC checks.

  • uImage coverage is unknown when bytes follow its payload.

Reviews (2) · Last reviewed commit: "fix(artifacts): keep uImage coverage unk..." · Reviewed by Greptile

@vincentkoc
vincentkoc merged commit 99d5ff7 into morluto:main Nov 27, 2026
41 of 42 checks passed
@vincentkoc

Copy link
Copy Markdown
Collaborator

Thanks! Merged with the trailing-byte regression and exact-length control, after clean CI and review.

@Anurag-5ingh
Anurag-5ingh deleted the fix/uimage-trailing-coverage branch November 27, 2026 14:23
vincentkoc added a commit that referenced this pull request Nov 27, 2026
…pgp-633-20261127

* commit '3097263763611eb0c32c502d5a222060cf02f468':
  fix(cli): describe universal Mach-O slice selection without a single-dash flag (#14912)
  fix(iso9660): read Joliet trees whose .. records name their own directory (#14817)
  feat(gpu)!: add per-call object, work, report, metadata, structure, and parser budgets to inspect_gpu_code_objects (#14882)
  fix(macho)!: select arm64e.x1 slices of universal Mach-O files by exact subtype (#14881)
  refactor(views): share bounded parent and report limitations (#14902)
  refactor(desktop): share XML parent pointers in task drafts (#14905)
  feat(ghidra): define function-pointer members and typedefs (#14889)
  refactor(setup): share publication destination checks (#14904)
  perf(ci): skip unused test runtime uploads (#14903)
  fix(nuget): preserve explicitly spaced publisher metadata (#14906)
  fix(artifacts): keep uImage coverage unknown when bytes follow the declared payload (#14896)
  fix(artifacts): report incomplete Android sparse coverage (#14883)
  fix(tar): require both end-of-archive blocks for complete coverage (#14884)
  refactor(views): centralize indexed row paging (#14878)
  refactor(views): reuse optional filters in report projections (#14877)
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.

[Bug] uImage inventory reports complete coverage when bytes follow the declared payload

2 participants