Skip to content

feat(labview): inspect RSRC containers and embedded VI trees - #13337

Merged
morluto merged 36 commits into
morluto:mainfrom
Antruly:feat/labview-rsrc-inspection
Nov 27, 2026
Merged

morluto merged 36 commits into
morluto:mainfrom
Antruly:feat/labview-rsrc-inspection

Conversation

@Antruly

@Antruly Antruly commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

REA has no reader for LabVIEW artifacts. A .vi, .ctl, or .llb file and a LabVIEW-built executable all store their program tree in an RSRC container: a 32-byte header, a data section, and a block-info list. Sections are stored with different codings (none, zlib, XOR), and a built executable commonly keeps only a FLAG block and one LVzp block (the embedded program tree).

This adds inspect_labview_artifact (MCP) and inspect-labview-artifact (CLI): a static, bounded inventory of one selected file. It reports the container header, the LabVIEW version recorded by the vers block, every block and section with its coding and decoded byte count, and whether the block-diagram heap (BDH*) and front-panel heap (FPH*) are present. It reads the file without running it and requires no LabVIEW installation.

Problem and expected behavior

Without this, an agent can only guess at a LabVIEW binary's structure from raw bytes. The expected outcome is an evidence-bearing inventory that names what is stored and, just as importantly, what is not: when a build removed the block diagram, the tool must say so rather than imply that a diagram exists.

Smallest use: select a .vi and ask which blocks and codings it contains. On a LabVIEW-built PE, select the executable and ask which embedded RSRC container it carries.

Change and scope

  • src/labview/LabviewRsrc.ts parses the RSRC header, block-info list, block headers, section starts, and section data with BinaryReader bounds checks. A truncated or non-RSRC container fails with a reason; it does not return a partial inventory.
  • src/labview/LabviewPeContainer.ts walks the PE resource directory (bounded depth and entry counts) and returns embedded payloads that begin with RSRC\r\n. It does not extract or interpret other resources.
  • Section coding is classified as none, zlib (four-byte big-endian length followed by a zlib stream), xor (LVzp), or unknown. zlib sections are decoded only to verify and report the decoded byte count; no payload is returned.
  • The reader bounds its own work and fails rather than returning a partial inventory: the PE resource walk uses the shared readPeResourceLayout owner, visits each directory once, and has total entry and container allowances; RSRC block and total-section counts are capped; each zlib attempt is charged against a container-wide decoded-byte budget. Exceeding one is a typed resource_constraint, not a malformed input.
  • The shared artifact recognizer table now identifies an RSRC file as labview-rsrc, and inspect_artifact on that file reports the format with a next_probe naming inspect_labview_artifact, so a dedicated reader's formats no longer look unsupported.
  • The report preserves each section's declared index (a negative value is not renumbered) and includes container.file_offset, so the container-relative header offsets map onto the selected file.
  • Section names resolve against the one shared name list after every block's start table, and a failure after the read retains the completed snapshot's identity.
  • Only the RCDATA (type 10) resource subtree is walked, and the root type is filtered before either target branch, so another resource type cannot hide it, spend its entry budget, or enter through a direct payload entry. Only the decimally packed major, minor and bugfix fields are validated; the build field is not read. The parser owns the heap and program-tree facts; the provider only decides whether an unobserved heap can be called absent.
  • The LabVIEW version is decoded from the packed four-byte word at the start of a vers record, with version_coverage distinguishing a read version, a container with no vers record, and a record that could not be decoded. A PE payload is accepted only from the RT_RCDATA (type 10) resource type, matching the pe-rcdata-rsrc kind.
  • A direct RSRC container's heap facts are unknown unless a heap block is present: its content does not establish whether it is a VI, a control, or an archive of member VIs, and the caller's spelling is not evidence of format. A PE-embedded application container, which the walk fully examines, can still report absent. Block facts are derived in one pass, and aliased directories and payload ranges are counted once.
  • src/domain/labview/labviewArtifact.ts, src/ports/labview/LabviewArtifactPort.ts, src/application/labview/LabviewArtifactService.ts, src/contracts/labview/labviewToolContracts.ts, src/composition/labview.ts, and src/cli/labviewCommands.ts follow the existing static-format module shape (Go, Rust, IL2CPP, PE resources).
  • The new unit is declared in scripts/lib/module-layers.mjs and scripts/lib/test-projects.mjs; the contract joins the artifact tool family.

Intentionally not included in this PR: section payload extraction, a member list for .llb files, and any reconstruction of a block diagram from compiled code. Those are separate increments if the direction is useful.

Scope fit: static format inspection, which CONTRIBUTING.md lists as supported. This does not involve target execution, injection, mutation, or protection recovery, so no maintainer scope decision is required; the draft is opened for direction. No issue is linked: this adds a capability rather than fixing a reported defect.

  • The branch was merged with main @ 880a2d5d5 (6.10.1, 464 commits). That release extracted the offline inspection bindings out of src/server/serviceToolBindings.ts, so the inspect_labview_artifact binding is declared in src/server/offlineInspectionToolBindings.ts, and the CLI inspectWithService runner moved to src/cli/contractCommandRunners.ts.
  • A second merge with main @ a156d2051 (411 commits) followed: the CLI registrar expressions became cliRegistrar(...), translateArtifactFailure gained the selected path, and the repository began requiring every fixed ceiling in scripts/verify/fixed-ceiling-registry.json. The LabVIEW input and structural allowances are registered there under tracking issue [Feature] Give native readers' fixed structural, text and inventory allowances a control or a stated fixed reason #14235.
  • A third merge with main @ 192177f0c (111 commits) kept the branch mergeable; the fixed-ceiling registry conflict was resolved by keeping both the upstream and LabVIEW entries.
  • A follow-up maintainer commit (d8e288d03) records why each recognized zlib section stays undecoded (preset dictionary, either decode allowance, or failed inflation) and stops describing an unreadable PE tree as an absent container. On top of it, bafc4acfe keeps PE admission separate from an unreadable tree, so a non-PE file is not called malformed.
  • The maintainer then merged this branch into their pr-13337 branch (4eb487a93), which kept the RCDATA constant in the shared PE owner and narrowed the version check to the reported fields; this branch continues on top of that merge.
  • A fourth merge with main @ 412f92736 (136 commits) followed. Upstream added the deb format at the same points this branch added labview-rsrc, so every conflict kept both entries in the shared format table, reader routing, and target-format map.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/labview/LabviewRsrc.ts owns container parsing and src/labview/LabviewPeContainer.ts owns PE resource location. The service consumes those parsed facts; the contract does not reinterpret raw bytes.
  • Contribution scope fit and linked maintainer decision: static format inspection; not applicable for execution/protection review.
  • CLI and MCP/tool-catalog contract: one new tool, inspect_labview_artifact (inspect-labview-artifact). Input is { "path": "<absolute path>" }; output is Evidence whose normalized_result is the inventory. The generated catalog and CLI command list are produced by the build.
  • Provider, bridge, target-format, or platform compatibility: built-in reader; no toolchain, provider session, or platform-specific process.
  • Evidence, artifact, provenance, or reconstruction contract: the subject is the selected file with its exact SHA-256 and byte count. Absent block-diagram and front-panel heaps are explicit limitations. No reconstruction claim is made.
  • Target selection, authority, upstream behavior, and cleanup details: none; the reader opens no long-lived resource and starts no process.
  • Generated metadata: the build regenerates the ignored product catalog and CLI command list; no authored generated file is committed.

Expected effects:

  • 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: src/labview/LabviewRsrc.test.ts builds synthetic RSRC containers and covers block/section inventory, zlib and raw codings, LVzp XOR coding, presence reporting (including unknown when an embedded program tree leaves content unexamined), truncated and non-RSRC rejection, provider identity binding, cancellation that arrives after the read starts, the bounded version scan over a digit-only section, a size refusal that also carries a failed close, and the input refusal for a non-LabVIEW file. tests/boundary/cli/labviewRsrcCli.test.ts drives the same reader through the public CLI and a stdio MCP session and asserts the evidence from both. Synthetic fixtures are used because the repository does not commit binaries.
  • Base reproduction or other evidence: the reader was also exercised against a locally selected LabVIEW 2011 .vi and a LabVIEW-built PE. The .vi reports LVIN/LBVW, version 11.0, 33 blocks including LIvi, VICD, VCTP, and FPHb, with the block diagram absent. The PE reports one embedded container with FLAG and LVzp. Those artifacts are not committed.
  • Re-verified on bafc4acfe against one locally supplied LabVIEW-built PE, which is not committed and whose name and digest are withheld: one embedded container, LVAR/LBVW, format version 3, blocks FLAG and LVzp, version null, and both heap facts unknown because the embedded program tree was not decoded. An independent big-endian parse of the container header matched every reported range, and a non-RSRC DLL beside it was refused as not an RSRC container.
  • Remaining proof gaps: no real-provider lane (none applies), no .llb member listing, and no decoded content for XOR-coded blocks. The zero-mask coding is not implemented; a zlib section that does not decode to its declared length, or one the decode budget did not attempt, is reported as unknown.

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

Run on bafc4acfe with Node.js 24.22.1, the version .nvmrc pins.

  • npm run check:fast — passed (typecheck, lint, architecture guards).

  • npm run build:cached — 3 successful.

  • npx oxfmt --check . — clean over 8625 files.

  • npm run docs:check — passed (8 conformance tests).

  • npm run verify:advertised-schemas — exit 0.

  • npm run test:focused -- src/labview/LabviewRsrc.test.ts tests/boundary/cli/labviewRsrcCli.test.ts tests/evaluation/providerLifecycleCoverage.test.ts tests/conformance/providerCapabilityConformance.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/mcp/advertisedCatalogSummary.test.ts tests/boundary/mcp/advertisedDialect.test.ts — 1198 passed, including the new CLI/stdio-MCP case.

  • node scripts/rea.mjs inspect-labview-artifact <a local LabVIEW-built PE> --json — exit 0, with the identity and container facts above cross-checked against an independent parse; a non-RSRC DLL beside it was refused as invalid_request.

Not run: npm run check:pr (full test:run, Python tests, jscpd, scan:todos). No real LabVIEW artifact is committed or exercised in CI; the reader's real-artifact observation is the one recorded under Evidence and regression coverage.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; the reader starts no process and touches no provider.
  • Package or release metadata impact: one new tool in the artifact family; the generated catalog is rebuilt by CI.
  • Security, privacy, process, or containment review: reads the selected file only. No secrets are included in the change.

Author readiness

Human owner: @Antruly

  • 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.

Before merge

  • 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.

Add inspect_labview_artifact, a static reader for LabVIEW RSRC containers in
.vi/.ctl/.llb files and in LabVIEW-built PE resources. It reports the container
header, the recorded LabVIEW version, the complete block inventory with each
section's coding, and whether the block-diagram and front-panel heaps are
present, without starting LabVIEW or any process.

Only zlib-coded sections are decoded, for their byte count; no payload is
returned. An absent block-diagram heap is reported as a limitation rather than
reconstructed.
Describe the inspect_labview_artifact contract, section codings, and the
block-diagram limitation, and list the target in the supported-targets table
and the documentation index.
@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous page-copy issue is fixed and no new actionable issue was found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; the previous page-copy issue is fixed and no new actionable issue was found.

Summary

Adds static LabVIEW RSRC inspection for direct files and PE resources, with shared CLI/MCP delivery.

  • LabVIEW files now produce a bounded inventory of their RSRC contents.
  • CLI and MCP callers can request the same LabVIEW inventory and page through it.
  • Generic artifact inspection now recognizes LabVIEW RSRC files and points to their reader.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Selected local file] --> B[Stable read and file identity]
  B --> C{Direct RSRC?}
  C -->|Yes| E[Parse RSRC container]
  C -->|No| D[Find PE RCDATA containers]
  D --> F[Select largest container]
  F --> E
  E --> G[Complete Evidence]
  G --> H[Complete inline result]
  G --> I[Summary or requested page]
  I --> J[Reuse cached section index]
Loading

Reviews (30) · Last reviewed commit: "perf(labview): build view rows only for ..." · Reviewed by Greptile

Comment thread src/labview/LabviewPeContainer.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewPeContainer.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/domain/labview/labviewArtifact.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread docs/guides/native/labview-analysis.md Resolved
Add the provider-admission coverage the repository requires for a new
provider, without changing the reader:

- Move the synthetic RSRC container builder into a shared test fixture so
  the unit and boundary tests build the same bytes once.
- Add a CLI and stdio MCP boundary test for inspect_labview_artifact.
- Register `rea-labview-rsrc` lifecycle coverage for operation and cancel.
- Declare the `labviewArtifact` conformance case.
- Regenerate the advertised catalog summary for inspect_labview_artifact.
`inspect_labview_artifact` admitted a relative `path`, while every other
caller-path contract requires an absolute one. The CLI/contract parity
check caught it: the CLI resolves a relative argument before admission,
so the contract must hold the absolute rule alone.

Use `absoluteLocalPathStringSchema`, the schema the other caller-path
contracts already use.
Address the review findings on the RSRC reader:

- Bound the PE resource walk with a visited set, a total visit budget,
  directory-entry and container allowances, and a typed limit failure
  instead of a silently partial scan.
- Check the resource directory and its data against the declared resource
  range rather than the whole file.
- Cap zlib inflation at its declared length, add a total decoded-work
  budget, and recognise any valid zlib header instead of three byte pairs.
- Check nested RSRC records against their declared data/info sections and
  cap the total section count across blocks.
- Read the artifact through readStableArtifact so identity, bounds and
  cancellation bind to the bytes actually inspected.
- Carry parse failures as ParseFailureError facts: malformed input keeps
  its kind/offset/field, and a limit becomes a typed fixed-allowance
  refusal instead of invalid_format.
- Report heap presence as `unknown` when an embedded program tree or an
  unexamined container could still hold it, not as `absent`.
- Cover cancellation that arrives after the read starts.
- Move the analyst guide under docs/guides/native/.
@Antruly

Antruly commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

All twelve findings are addressed in 1dd2a9b6e, along with the two inline P1s from the same review.

# Finding Disposition
1 Repeated directories freeze inspection Each resource directory is visited once, under a 1024-visit budget, and exceeding it fails with a typed limit instead of continuing.
2 Compressed sections exhaust memory inflateSync is called with maxOutputLength equal to the declared length, and the container has a 64 MiB total decoded-work budget.
3 Shared tables exhaust memory Block and section limits are now one total allowance of 4096 sections, checked before any section object is built.
4 Malformed ranges appear valid Nested records are checked against the container's declared dataBytes/infoBytes, and PE directory and data targets against resourceBytes, not the whole file.
5 Later containers disappear The walk returns an explicit limit failure; a partial scan is never reported as success.
6 Changed files bypass admission The artifact is read through readStableArtifact with an ArtifactResourceScope, so identity, bounds and cancellation bind to the bytes inspected.
7 Unexamined content appears absent Presence is present, absent, or unknown; unknown when an embedded LVzp tree or another unexamined container could still hold the heap.
8 Compressed sections appear raw zlib headers are validated by their format rule (method 8, `(CMF<<8
9 Cancellation coverage skips active work The registered case now starts the inspection and aborts while the read is in flight.
10 Relative MCP paths slip through The contract uses absoluteLocalPathStringSchema; the CLI still resolves caller-relative arguments.
11 Parse failures lose their meaning Parse failures are ParseFailureErrors: malformed/truncated keep kind, offset and field through parseFailureAnalysisError, and a limit becomes a resource_constraint with a fixed-allowance recovery via parseLimitConstraint.
12 Guide bypasses the required layout Moved to docs/guides/native/labview-analysis.md, with the README, navigation source and supported-targets link updated.

The two inline P1s are also resolved: labviewArtifact has a public CLI/stdio-MCP conformance case (tests/boundary/cli/labviewRsrcCli.test.ts), and the tracked advertised-catalog summary is committed.

Validation on 1dd2a9b6e with Node 24.22.1: check:fast, build:cached, verify:advertised-schemas (exit 0), docs:check, and oxfmt --check . all pass; the focused set covering the reader, the CLI/MCP boundary, lifecycle coverage, capability conformance, CLI/contract parity, and the advertised-schema checks is 1087 passed. npm run check:pr was not run locally. There is still no real LabVIEW artifact in CI; the synthetic fixtures are the evidence there.

Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread docs/guides/native/labview-analysis.md Resolved
- Own the artifact resource scope and run each read through it, so a
  retained failed close is retried before later work and reported at
  shutdown.
- Translate the read failure as recorded instead of replacing it with the
  signal's current state; the stable read owns its cancellation facts.
- State the 256 MiB input ceiling as a fixed allowance so an oversized
  artifact keeps its structured maximum and recovery.
- Match the guide to the decoded-byte behavior: a section over the budget
  is reported `unknown` and the inventory continues.
@Antruly

Antruly commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

The four second-pass findings are addressed in 51304a60d.

# Finding Disposition
1 Failed closes never retry The provider owns its ArtifactResourceScope, runs every read through scope.run() so retained cleanup is retried before later work, and close() now closes the scope. A caller-supplied scope is left to its owner.
2 Cancellation hides read failures The read failure is translated as recorded; the signal's current state no longer replaces it. Cancellation is projected from the read's own facts.
3 File ceiling loses recovery An oversized artifact is refused with artifactFixedLimitFailure and the 256 MiB input allowance on the file-size boundary, so the maximum and fixed-ceiling recovery survive translation.
4 Budget outcome is misstated The guide now matches the reader: a section whose decode would exceed the container's decoded-byte budget is reported unknown and is not decoded, and the inventory continues. The failing budgets are the block, total-section, and directory-walk allowances.

Validation on 51304a60d with Node 24.22.1: check:fast (typecheck, lint, architecture guards), build:cached, verify:advertised-schemas (exit 0), docs:check, and oxfmt --check . all pass; the focused reader, CLI/stdio-MCP, lifecycle, conformance, and CLI/contract-parity set is 1045 passed, and the LabVIEW unit file including the post-read cancellation case is 7 passed.

Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
@morluto morluto added the enhancement New feature or request label Nov 22, 2026
- Replace the unbounded `\d+\.\d+` scan with a bounded single-pass search
  over the first 64 KiB of each vers section; a digit-only section no
  longer drives quadratic matching work in the shared server.
- Classify read failures through the shared provider classifier with a
  LabVIEW dialect, so the size ceiling is restated as a fixed allowance
  and the read's cleanup, partial observation and cancellation facts
  survive the refusal.
- Cover both with regressions.
@Antruly

Antruly commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Both third-pass findings are addressed in d7dbe5201.

# Finding Disposition
1 Version search stalls the server versionOf no longer uses a regex. It reads the first 64 KiB of each vers section in one forward pass, advancing past each digit run without backtracking. A 200,000-digit section is now covered by a regression.
2 Size refusal hides failed cleanup Read failures are classified through the shared classifyProviderFailure with a LabVIEW dialect. The fileSize entry restates the 256 MiB ceiling as a fixed allowance while the shared classifier retains the read's cleanup, partial observation and recorded cancellation. A regression builds a size-limit failure that also carries a failed close and asserts the cleanup stays pending and its resource is retained.

Validation on d7dbe5201 with Node 24.22.1: check:fast (typecheck, lint, architecture guards), build:cached, verify:advertised-schemas (exit 0), docs:check, and oxfmt --check . pass; the focused reader, CLI/stdio-MCP, lifecycle, conformance, and CLI/contract-parity set is 1048 passed, and the LabVIEW unit file is 10 passed.

…pection

# Conflicts:
#	src/server/serviceToolBindings.ts
@Antruly
Antruly marked this pull request as ready for review November 23, 2026 05:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-27T21:59:49.800154Z 499413a New commits
ℹ️ 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.

Comment thread src/labview/LabviewPeContainer.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f763270c5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewPeContainer.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
- Walk PE resources through readPeResourceLayout, so RVA lookup is indexed,
  a payload may map through any admitted section, and the home-grown
  section scan is gone. Add a total entry budget.
- Charge every attempted inflation against the container's decode budget,
  including failed and length-mismatched attempts.
- Bound block records by the list's declared extent, clamped to the
  container because real LabVIEW-built PEs declare more than the resource
  payload holds.
- Reject a named section whose name leaves the list instead of reporting
  it as unnamed.
- Pass the selected container to the parser without copying it.
- Cover the PE path and the over-declared list extent with regressions.
@Antruly

Antruly commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

All six findings are addressed in 479a87ccf.

# Finding Disposition
1 PE scans freeze other requests The PE walk now uses the shared readPeResourceLayout, whose indexPeSectionRvas lookup replaces the per-entry section scan, and it carries a total entry budget (4096) in addition to the per-directory and visit allowances.
2 Charge failed inflations against the decode budget Each attempt charges its declared length against the container budget before inflating, so a failed or length-mismatched attempt is still accounted for.
3 Resolve PE payload RVAs outside the directory span Payload RVAs now map through layout.map, which admits any file-backed section; the resource span bounds only directory metadata.
4 Reject invalid named-section offsets A non-sentinel name offset that leaves the declared list is a truncated parse failure; null is reserved for the 0xffffffff unnamed sentinel.
5 Avoid copying the selected container buffer The selected container is passed to the parser directly.
6 Bound block records by the declared list size Records are bounded by the list's declared extent, clamped to the container end. The clamp is deliberate: the LabVIEW-built PE I re-verified declares more list bytes than its resource payload holds (its used records still fit), so a strict declared-extent bound would reject a real artifact. A regression covers that shape.

Re-verified after the refactor against the same locally supplied LabVIEW-built PE (name and digest withheld): one embedded container, LVAR/LBVW, FLAG and LVzp, version null, both heap facts unknown, unchanged from before.

Validation on 479a87ccf with Node 24.22.1: check:fast (typecheck, lint, architecture guards), build:cached, verify:advertised-schemas (exit 0), docs:check, and oxfmt --check . pass; the focused reader, CLI/stdio-MCP, lifecycle, conformance, and CLI/contract-parity set is 1052 passed.

Comment thread src/labview/LabviewRsrc.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 479a87ccfe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewRsrc.ts Resolved
- Charge compressed input bytes as well as declared output, and memoize
  the decoding of one stored section, so records that share a stream do
  not repeat its work.
- Keep a zlib-coded `vers` section's decoded bytes for the version scan.
- Cap list records by both the declared extent and the info section.
- Report PE walk coverage, and keep heap presence `unknown` for a `.llb`
  archive or an unreadable PE resource branch.
@Antruly

Antruly commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

All five findings are addressed in 0cf3cd62a.

# Finding Disposition
1 Repeated decoding blocks requests (Greptile P1) Decoding is memoized per stored section, keyed by its data-section offset, so records that share a stream reuse one result. Each attempt also charges its compressed input bytes against a container-wide 64 MiB input budget, in addition to the declared output.
2 Bound compressed-input work across zlib attempts (Codex P1) Same fix: the input budget bounds a stream with a zero or tiny declared length, and memoization removes the repeated traversal of a shared section.
3 Keep heap presence unknown for unexamined artifacts (Codex P2) findEmbeddedRsrcContainers now reports whether the walk was complete. The provider treats a direct .llb archive or an incomplete PE walk as unexamined and reports both heap facts unknown; the guide records both cases.
4 Keep block metadata inside the info section (Codex P2) listEnd is now the smaller of the declared list end and infoEnd, so records outside the declared info section are rejected. The over-declared-list regression still passes because its used records remain inside the info range.
5 Parse versions from decoded zlib bytes (Codex P2) decodeSection retains the decoded payload for vers sections, and the version scan reads it. A regression covers a zlib-coded vers reporting its version.

Re-verified after these changes against the same locally supplied LabVIEW-built PE (name and digest withheld): one embedded container, LVAR/LBVW, FLAG and LVzp, version null, both heap facts unknown, unchanged.

Validation on 0cf3cd62a with Node 24.22.1: check:fast (typecheck, lint, architecture guards), build:cached, verify:advertised-schemas (exit 0), docs:check, and oxfmt --check . pass; the focused reader, CLI/stdio-MCP, lifecycle, conformance, and CLI/contract-parity set is 1054 passed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/labview/LabviewRsrc.ts Resolved
A file that does not declare `MZ` is not a PE, so it must not be reported
as a malformed PE resource tree. The scan reports whether the file was
admitted as a PE separately from whether the walk was complete.
Comment thread src/labview/LabviewArtifactProvider.ts Resolved
Comment thread src/labview/LabviewRsrc.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bafc4acfea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
Comment thread src/labview/LabviewPeContainer.ts Resolved
…bles

A two-byte MZ check treated plain DOS MZ and NE/LE/LX images as declared
PEs, so an ordinary non-LabVIEW file was reported as an unreadable PE
resource tree. PE identity now comes from observeMzWindowsHeader: only a
PE signature at e_lfanew declares a PE. The unused admitted field is
removed.

A section-start offset inside the count word or block-header rows was
accepted and could fabricate an inventory from block metadata. Tables must
start at or after the end of every block header; blocks may still share a
later table.

The refusal tests now assert the error type unconditionally.
@Antruly

Antruly commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

A short coordination note so we do not step on each other on this branch.

I verified 56ba7d8d9 locally: check:fast, the focused set (1202 passed), build:cached, verify:advertised-schemas, docs:check, and oxfmt --check . all pass, and the locally supplied LabVIEW-built PE still reports one embedded container (FLAG, LVzp, version null, both heap facts unknown). The observeMzWindowsHeader identity check and the section-table bound both look right.

I will hold pushes while you are iterating. One of your commits already landed ahead of mine and I dropped the duplicate rather than reconcile two versions of the same fix, so the branch is currently at your head. If you want any thread taken, name it and I will handle it; otherwise I will keep verifying each new head and report anything that fails.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56ba7d8d9a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labview/LabviewArtifactProvider.ts Resolved
A malformed RSRC embedded in a PE failed with container-relative offsets,
but the refusal names the selected executable and carries no
container.file_offset, so callers could not locate the failure. The
parser now takes the container origin and moves a failure offset into the
selected file's coordinates; successful results keep container-relative
ranges with container.file_offset.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce838579fc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
# Conflicts:
#	src/domain/native/peOverlay.ts
A damaged container declaring an impossible block or section count was
refused as a capacity limit before its table extent was checked, so a
truncated target surfaced as resource_constraint. Each table is now framed
first; a fully framed table over its allowance is still a capacity
refusal.
@morluto
morluto enabled auto-merge (squash) November 27, 2026 18:53

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd19b92ae9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labview/LabviewPeContainer.ts Resolved
Comment thread src/labview/LabviewPeContainer.ts Resolved
@morluto
morluto disabled auto-merge November 27, 2026 18:56
…absence

A nonzero resource RVA whose file-backed run cannot hold one directory
header returned complete coverage without reading anything, so the file
was reported as carrying no embedded RSRC. Only a zero RVA is observed
absence now; a short declared root is an unread tree.

Directory rows were checked against the entry allowances before their
extent, so a damaged directory declaring impossible counts surfaced as
resource_constraint. Rows are framed first; a fully framed directory over
its allowance is still a capacity refusal.
# Conflicts:
#	scripts/lib/test-projects.mjs

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3af535ea4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
A data offset inside the 32-byte RSRC header let a section's stored-length
word be read from header fields, returning a fabricated empty section as a
successful inventory. A data offset below the header is now malformed.
Comment thread src/labview/LabviewRsrc.test.ts Resolved
# Conflicts:
#	docs/reference/supported-targets.md
#	src/application/binary/TargetFormatVocabularies.test.ts
#	src/artifacts/artifactFormats.ts
#	src/domain/artifactFormatRecognition.ts
#	src/domain/artifactGraph.ts
#	src/domain/artifactInspection.ts
#	src/domain/native/peOverlay.ts
#	src/domain/targetFormats.ts
… RSRC magic once

The allowance test froze the delivered sentence. It now checks the parser's
decodeOmissions fact and the effective allowance, and compares the public
limitation with the provider's own formatter output.

The RSRC magic was declared again in artifact recognition; it now has one
owner in the LabVIEW domain contract, used by recognition, the parser, the
PE scan and the provider.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c4176964c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/labview/LabviewRsrc.ts Resolved
…idence

inspect_labview_artifact returned every block and section inline, so an
admitted container with 4096 named sections could exceed a megabyte and
bypass the agent result budget. The tool now takes detail: complete keeps
the inline inventory; summary, or omitted detail over the budget, returns
container, version and heap facts with block and section counts, and the
complete inventory is paged with inspect_analysis_view kind
labview-artifact (blocks, sections, optional block filter) or read with
evidence-json. The CLI delivers the same way.

RSRC data and info ranges that intersect are refused as malformed rather
than reading list metadata as section data.
The advertised output now admits complete or summary detail, so the test
parses the complete report schema explicitly.
Each view call copied every section before reading the request, so a
summary or one-row page did work proportional to the whole inventory. A
section index (block and section position, and positions per block) is
built once per immutable retained report and reused; summaries read
counts from it, and section pages build objects only for selected rows.
@morluto
morluto enabled auto-merge (squash) November 27, 2026 21:57
@morluto
morluto merged commit f25312a into morluto:main Nov 27, 2026
54 checks passed
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