Skip to content

feat(artifacts): inspect and extract .NET single-file bundles - #3787

Merged
gensokyo-dev merged 20 commits into
morluto:mainfrom
Zhong-fan:feat/2352-dotnet-single-file
Oct 29, 2026
Merged

gensokyo-dev merged 20 commits into
morluto:mainfrom
Zhong-fan:feat/2352-dotnet-single-file

Conversation

@Zhong-fan

@Zhong-fan Zhong-fan commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem and outcome

Closes #2352. Ordinary .NET single-file apphosts previously appeared as native files without accessible bundled members. Existing inspect-artifact/extract-artifact and MCP equivalents now inventory and materialize PE, ELF and thin Mach-O bundles with v1.0, v2.0 or v6.0 headers, including v6 raw-DEFLATE members. No target execution, assembly loading, new provider or protection recovery is added.

The host retains its whole-file digest; members retain expanded-byte identities, original stored extents and declared version/type metadata. Declarations do not establish assembly validity. Existing summary delivery and filtered/paged inventory views work with the new format, retain provenance and preserve full Evidence. Unsupported versions/flags, malformed paths/ranges/compression and resource limits fail explicitly. Universal Mach-O contents remain unexpanded.

Implementation

A bounded manifest reader and streamed member decoder use the shared artifact factory, file-source ownership, resource scopes and safe output tree. Completed marker observations follow source identity through preflight, inventory and extraction: one scan instead of three. A recognized CArchive bounds the marker search, so an embedded apphost cannot replace the outer container. Closing joins late descriptor admission and retains failed cleanup for retry. Obsolete duplicate reader dispatch/type unions and the downstream native-format repair were removed; current main formats remain supported.

Fixed input failures name the effective ceiling and its units, declare that no runtime override exists, and explain why worker memory, summary delivery and paging do not raise it. The producing artifact error owner supplies the guidance and the explicit capacity boundary to both adapters.

Executed validation

  • 91 distinct focused tests across 9 files passed (three public journeys rerun after review edits): actual CLI and SDK stdio MCP, summary plus exact member/content views, parser/resource boundaries, single-scan extraction, late admission/close and generic inventory projections. Typecheck/lint, docs checks, formatting and discovery of all 2,839 test files passed.
  • Current-head upstream source suite: 21,893 passed / 16 skipped in 1,178 files. Build, static checks, documentation, Linux native package, Windows native controls, APK signatures, EVM, browser, web network, binary layout and four Node-version SQLite lanes passed. All eight built test shards also passed. Current-head CI is green; Greptile reports 5/5 and all five review threads are resolved. No bypass was used.
  • Microsoft SDK 8.0.427 / HostModel 8.0.33 produced 12 PE/ELF/thin-Mach-O hosts spanning v1/v2/plain-v6/compressed-v6. Independent C# BinaryReader/DeflateStream observations verified stored extents, types and source-member digests. Public CLI and MCP inspection/extraction matched all 48 members. A genuine SDK-published Linux application contributed another three matching members. Hosts stayed byte-identical; owned extraction output was verified and removed. Linux performs byte parsing of PE/Mach-O here; Windows/macOS execution and protected/arbitrary-bundle compatibility are unverified.
  • The original reader, ported only to borrow the current tagged source admission, fails the new cleanup and scan-count regressions: it reports closure while a descriptor is open and scans three times. The final reader passes both.

Measured costs

Paired fresh MCP processes performed initialization, named schema validation, tools discovery, open, full inspection, extraction/byte verification and close of the same compressed producer host. Two runs per reader with reversed order; warm filesystem caches, true cold-cache costs unmeasured. Tokenx estimates cover all JSON-RPC frames, including catalog, instructions, text and structured replies; these are not billed-token measurements.

Schema profile Original reader: elapsed / CPU / peak family RSS Final reader: elapsed / CPU / peak family RSS Whole-task estimated tokens, both
Full output (default) 3.02–3.10 s / 4.03–4.27 s / 492–496 MB 3.35–3.43 s / 4.45–4.49 s / 489–491 MB 232,407
Existing compact output 2.20–2.22 s / 3.05–3.07 s / 444–446 MB 2.11–2.18 s / 2.93–3.05 s / 439–440 MB 44,134

Both use compact input and artifact/session families. Compact output is an existing caller option, not a new default or a reader speedup. Catalog startup dominates this small-host workflow; stronger selected-path validation adds checks and no overall speedup is claimed. All eight tasks completed below the 1.5 GiB process-family guard, with no surviving children. Native files without a marker incur one additional streaming pass, and extraction additionally hashes the whole host to bind inventory identity. A separate public CLI capacity task with 1,000 distinct deep paths refused the path-tree budget in 1.94 s / 2.50 CPU s / 341 MB peak family RSS, returned a typed truncated/limit error (322 estimated command/reply tokens), and left no child processes. Metadata, member expansion and path-tree budgets are documented in docs/dotnet-bundles.md.

Author readiness

Human owner: @Zhong-fan

  • 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.
  • Current-head upstream CI has passed.

@Zhong-fan
Zhong-fan marked this pull request as ready for review October 15, 2026 03:34
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T03:34:16.471966Z 9f1391e Draft marked ready
ℹ️ 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.

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

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The follow-up changes appear safe to merge; both numbered findings are fixed and no new blocking issue remains.

Summary

Adds static inspection and extraction of .NET single-file bundles through the existing CLI and MCP tools.

  • Artifact inspection lists files packed inside supported .NET single-file hosts.
  • Artifact extraction streams members from supported .NET single-file hosts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Native host"] --> B["Source-bound marker probe"]
  B --> C["Bounded bundle manifest"]
  C --> D["Stream and decode members"]
  D --> E["Inventory with host and member hashes"]
  E --> F["Verify host identity"]
  F --> G["Write fresh owned output"]
Loading

Reviews (10) · Last reviewed commit: "fix(artifacts): explain fixed bundle lim..." · Reviewed by Greptile

Comment thread src/artifacts/dotnet/DotnetBundle.ts Resolved
Comment thread src/artifacts/inventory/classify.ts Resolved

@baron baron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Integration hold for reviewed head d4ac1c7: all 40 reported checks are successful and the ordinary offline bundle-extraction scope has the linked maintainer acknowledgment, but the human Author readiness declaration remains entirely unchecked while this PR is non-draft. Current main CONTRIBUTING.md (Pull request ownership and readiness) requires the human owner to complete that declaration before requesting maintainer review; CI or automated review does not substitute for it. Please have the human owner complete the declaration, or retain draft status for early feedback. This is not an attestation on their behalf or an approval. Source inspection covered the bounded manifest/member reader and inventory/extraction identity boundary; no new code defect is asserted here. Local compiled-boundary tests were not executed (the source-test runner correctly refused that project; dependency lock differs from the available installation).

@Zhong-fan

Copy link
Copy Markdown
Contributor Author

Integration hold for reviewed head d4ac1c7: all 40 reported checks are successful and the ordinary offline bundle-extraction scope has the linked maintainer acknowledgment, but the human Author readiness declaration remains entirely unchecked while this PR is non-draft. Current main CONTRIBUTING.md (Pull request ownership and readiness) requires the human owner to complete that declaration before requesting maintainer review; CI or automated review does not substitute for it. Please have the human owner complete the declaration, or retain draft status for early feedback. This is not an attestation on their behalf or an approval. Source inspection covered the bounded manifest/member reader and inventory/extraction identity boundary; no new code defect is asserted here. Local compiled-boundary tests were not executed (the source-test runner correctly refused that project; dependency lock differs from the available installation).

Thanks for reviewing the PR and pointing out the Author readiness gap. I’ve now reviewed the final diff and relevant code, checked the validation evidence, and completed all three Author readiness declarations in the PR description. The PR is ready for initial maintainer review.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: The three named test files pass on this branch, 35 of 35 tests. The feature is new, so there is no before result for the main tests. One test on main cannot load, because the new module is missing there.

Results

I ran three test files with Node 24.18.0 on Linux. The branch's changed files sat on top of an extracted main tree. I checked each one matched the head byte for byte.

Test file Tests Result on PR head d4ac1c7
dotnetBundleArtifacts.test.ts 29 pass
ownedArtifactReaderCleanup.test.ts 4 pass
dotnetBundleJourney.test.ts 2 pass

The acceptance test inspects and extracts a bundle. It goes through the public CLI and a local MCP server. It also checks the path depth limit. It ran about 10 seconds. It sets HOME to a temporary folder.

Before: main has no .NET bundle code. The PR's cleanup test fails on main. It cannot find the new reader module. That is expected for a new feature. It shows nothing more.

All three files use the PR's built-in synthetic bundle builder. None makes a network call. None runs doctor.

Not run

  • A real .NET publish. The .NET SDK is not installed here, and the tests do not need it.
  • Bundles from real apps.
  • The Windows and macOS lanes.
  • Any full suite.
  • Real CI. On this PR the repo's own CI ran, and GitHub shows it green. I read that and did not rerun it.

The maintainer review holds this PR. The author declaration in the template is unchecked. I did not test that. It is the author's call.

Thanks, Zhong-fan, for the feature and for the synthetic fixture that makes it testable without a SDK.

Commands
npm ci && npm run build && npm run test:prepare
npm run test:focused -- tests/boundary/filesystem/dotnetBundleArtifacts.test.ts tests/boundary/filesystem/ownedArtifactReaderCleanup.test.ts tests/acceptance/dotnetBundleJourney.test.ts

The focused runner rebuilt the package itself before the tests. Logs are saved with this draft.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0
  • Head / base: d4ac1c7 / c7f6b8b
  • Other: the box was shared with other test agents, and I took no timings.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

…2-dotnet-single-file

# Conflicts:
#	src/artifacts/extraction/ArtifactExtraction.ts
Comment thread src/artifacts/inventory/classify.ts Resolved
@gensokyo-dev gensokyo-dev changed the title feat(artifacts): inventory and extract .NET single-file bundles feat(artifacts): inspect and extract .NET single-file bundles Oct 29, 2026
Comment thread src/artifacts/dotnet/DotnetBundle.ts Resolved
@gensokyo-dev
gensokyo-dev merged commit 22cab82 into morluto:main Oct 29, 2026
47 checks passed
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Inventory and extract ordinary .NET single-file bundles

5 participants