Skip to content

feat(desktop): suggest managed members for Unity script assemblies - #5511

Merged
morluto merged 20 commits into
morluto:mainfrom
8rulerstar:feat/unity-script-assembly-probes
Nov 4, 2026
Merged

morluto merged 20 commits into
morluto:mainfrom
8rulerstar:feat/unity-script-assembly-probes

Conversation

@8rulerstar

@8rulerstar 8rulerstar commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

For a Unity Mono player, inspect_desktop_application suggests inspect_managed_artifact for every managed DLL (90 probes on a Unity 2022.3.62f3 Win64 sample, almost all UnityEngine.*, System.*, Mono.*) and never inspect_managed_members. This adds one inspect_managed_members probe for each Unity predefined script assembly (Assembly-CSharp.dll, Assembly-CSharp-firstpass.dll), listed first, and the same probe for those assemblies in an IL2CPP build's <Product>_BackUpThisFolder_ButDontShipItWithYourGame/Managed/. Related: #3607 (not a fix for it, so not linked with "Fixes").

Problem and expected behavior

Use case: an agent triaging a Unity game wants the game's own code first. Today the probe list is dominated by engine and BCL assemblies, and the member-level operation that answers "what does this game's code contain" is never suggested.

Expected: when a managed directory has a unity-assembly-reference witness, Assembly-CSharp.dll and Assembly-CSharp-firstpass.dll directly in that directory get an inspect_managed_members probe ahead of every inspect_managed_artifact probe. The same applies to those names in Managed/ of an IL2CPP backup folder, with a rationale stating that correspondence to the shipped native code is unknown. All other probes stay identical and in the same order.

Change and scope

  • desktopPathConventions (src/domain/nativeConvention.ts), which already owns the Unity managed directory rule, also owns the predefined assembly name rule and the backup folder suffix rule (case-folded, non-empty product prefix). The admitted root name is passed in so the root itself can be the backup folder.
  • The projection adds the Mono probe only when the file has the existing pe-cli-directory fact, sits directly in a managed directory that already has a unity-assembly-reference witness, and has a predefined name. The Mono probe is derived from that existing witness fact plus the path, so it records no new fact; the backup probe has no comparable witness, so it records unity-il2cpp-backup-convention. This asymmetry is deliberate.
  • New fact unity-il2cpp-backup-convention (offset: null, backup_directory) is a path convention only. No unity-mono label is added from it.
  • The earlier IL2CPP metadata versions 24 and 27 docs fix is now on main, so this PR no longer carries it.
  • Not included: assemblies built from asmdef files (project-chosen names that the parsed facts cannot separate from plugin or framework DLLs); roots that are the <Product>_Data or Managed folder itself (an existing limit on main, now documented: point the scan at the game folder); DLLs past the probe byte budget, which get no pe-cli-directory fact, same as the ordinary managed probes.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Maintainer scope decision: not applicable (additive probe suggestion within the existing desktop triage boundary; no new provider or capability).

Contract and boundary impact

  • Semantic owner and earliest changed stage: desktopPathConventions in src/domain/nativeConvention.ts; projection in src/domain/desktopApplicationProjection.ts.
  • Contribution scope fit and linked maintainer decision: within existing desktop triage; not applicable.
  • CLI and MCP/tool-catalog contract: next_probes[].operation gains the additive value inspect_managed_members; new additive fact kind unity-il2cpp-backup-convention in files[].facts.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: new fact is a path convention with offset: null; probe rationale states IL correspondence to shipped IL2CPP code is unknown.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): 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: tests/boundary/filesystem/desktopApplication.test.ts covers probe ordering for predefined assemblies in Game_Data/Managed; positive member probe in a macOS bundle Contents/Resources/Data/Managed; no member probe when the root is Game_Data or Game_Data/Managed itself; no member probes without a Unity reference witness; backup folder probes (including the backup folder as root, case folding, and non-matching names). src/domain/desktopApplicationProjection.test.ts adds unity-il2cpp-backup-convention to the fact list that main's probe fan-out test checks against DESKTOP_PROBES_PER_FACT.

  • Base reproduction or other evidence: executed, on self-built samples at 2e4e51d87, before the main merges. Counts were not re-measured after merging main; the member-probe ordering is covered by committed tests, while "other probes identical" rests on these pre-merge runs only.

    Build Probes before → after Other probes
    Mono 2022.3.62f3 Win64 90 → 91 identical, same order
    Mono 2022.3.62f3 macOS 89 → 90 identical, same order
    Mono 2020.3.49f1 macOS 93 → 94 identical, same order
    IL2CPP 2022.3.62f3 / 2020.3.49f1 macOS 2 → 2 identical
    IL2CPP Build/ with backup folder (2022.3 / 2020.3) 40 → 41 / 39 → 40 member probe first; others identical
    Backup folder alone (2022.3 / 2020.3) 37 → 38 / 36 → 37 same
  • User-visible CLI/MCP output (if applicable): first two next_probes rows for a Game_Data/Managed fixture with Assembly-CSharp.dll (Unity reference) and UnityEngine.CoreModule.dll, captured by running the boundary test's inspect helper on that fixture on Windows 11 (ids shortened with …, local root replaced by <root>, path separators shown as /):

    [
      {
        "probe_id": "dsp_aa7219f7…",
        "operation": "inspect_managed_members",
        "path": "<root>/Game_Data/Managed/Assembly-CSharp.dll",
        "file_id": "dsf_22ced2df…",
        "rationale": "Inventory types, members and user strings of this Unity predefined script assembly; its references and contents are unverified. Start with detail \"summary\" and page rows through inspect_analysis_view.",
        "confidence": "inferred"
      },
      {
        "probe_id": "dsp_664cd29a…",
        "operation": "inspect_managed_artifact",
        "path": "<root>/Game_Data/Managed/Assembly-CSharp.dll",
        "file_id": "dsf_22ced2df…",
        "rationale": "Inspect the declared managed metadata and references.",
        "confidence": "inferred"
      }
    ]

    Response size on the Win64 sample: inspect_managed_artifact 12,977 B, inspect_managed_members 104,955 B default, 12,805 B with detail: "summary"; the rationale points to summary first.

  • Remaining proof gaps: backup folders checked only on macOS builds, not Windows or Linux layouts or a shipped game. No sample contains Assembly-CSharp-firstpass.dll (test only). Not run on Unity 6, Linux players, 32-bit Windows or commercial games. Agent tool selection after the change is unmeasured. How often large games exceed the probe byte budget is unmeasured.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Not applicable: this is a feature, not a boundary fix. The new behavior is covered by the boundary tests listed above.

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

At 5716a2429 (merge of main d48e472fa is 967903f80), Windows 11, Node 24.19.0, below the engines floor 24.22.1 (dependencies installed with --engine-strict=false):

  • npm run check:fast (typecheck and lint): passed.
  • node scripts/run-exact-tests.mjs run tests/boundary/filesystem/desktopApplication.test.ts src/domain/desktopApplicationProjection.test.ts: 91 passed, 3 skipped, 1 failed: does not promote filenames, arbitrary pak files or symlink targets into byte facts fails with EPERM creating a symlink (Windows without symlink privilege). That test already exists on main and is not touched by this PR.
  • npm run test:focused stops before running any test on this machine because its build step needs the Windows native build output (native/windows/build/manifest.json), so the CLI and MCP desktop tests were left to CI. npm run docs:check was not run locally.

CI on 5716a2429: CI required, Build package, Documentation, Portable tests and all eight test shards passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; additive probe operation value and fact kind.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS and Win64 Unity samples as above; no Hopper/Ghidra involvement.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads only files already admitted by the scan; no game executed or executable modified.

Author readiness

Human owner: @8rulerstar

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

…semblies

Unity Mono triage listed only inspect_managed_artifact probes, mostly for
engine and framework assemblies. Assembly-CSharp.dll and
Assembly-CSharp-firstpass.dll directly in a managed directory with a
UnityEngine reference witness now get an inspect_managed_members probe,
ordered before every managed artifact probe.
Unity IL2CPP builds write <Product>_BackUpThisFolder_ButDontShipItWithYourGame
next to the player. When shipped, its Managed/ holds pre-IL2CPP assemblies.
A path convention now records the folder on Assembly-CSharp*.dll directly in
its Managed/, including when the admitted root is the folder itself, and
triage offers inspect_managed_members for those files. Correspondence to
the shipped native code stays unknown.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

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-24T06:32:50.071538Z
We couldn’t complete this review. Comment @codex review to try again.
3ecaab0 Manual request
ℹ️ 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 Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Adds inspect_managed_members suggestions for Unity predefined script assemblies before existing artifact probes.

  • Unity Mono scans suggest member checks for the game’s predefined script assemblies.
  • IL2CPP backup scans suggest member checks for predefined script assemblies.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Recorded managed PE header"] --> B{"Predefined assembly in a Unity managed folder with a reference witness?"}
  B -->|Yes| C["Add member inspection suggestion"]
  B -->|No| D{"Recorded IL2CPP backup convention?"}
  D -->|Yes| C
  D -->|No| E["Keep existing probes"]
  C --> F["List member suggestions before existing probes"]
Loading

Reviews (2) · Last reviewed commit: "test(desktop): check the IL2CPP backup c..." · Reviewed by Greptile

@CassieFox23 CassieFox23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: Main still never suggests inspect_managed_members for a Unity game's own code. This PR adds that suggestion for Assembly-CSharp.dll and Assembly-CSharp-firstpass.dll, the logic reads tight, and CI is green on this head. The body swaps the repo template for its own headings.

Findings

Should fix

  • The body does not keep the repo template as written. Please move the content under the template headings. The material is mostly there in your own words. What changed:
    • Present: Summary and Author readiness, with all three boxes checked.
    • Some parts were swapped out. Three template parts are gone. They are Problem, Change and scope, and Compatibility. In their place are "Behavior and boundaries" and "Coverage limits". And it uses "Executed validation" in place of "Validation performed".
    • The body has no "Problem and expected behavior" part. It has no "Change and scope" part either, so the "Follow the contribution scope" paragraph is gone too.
    • Missing: the seven lines of "Contract and boundary impact". The body does say next_probes[].operation gains an additive value. That belongs on the CLI and MCP/tool-catalog line.
    • Missing: the eight "Expected effects" boxes. The "Read existing files or captured data" box looks like the one that applies.
    • Missing: four labels and three boxes. They sit under "Evidence and regression coverage".
    • Missing: four labels. They sit under "Compatibility, safety, and release".
    • Missing: the eight "Before merge" boxes.

Worth a look

  • The macOS bundle layout has no committed positive test. The member-probe tests use Game_Data/Managed in the ordering test. The Contents/Resources/Data/Managed layout appears only in the no-witness test, where no probe is expected. The body reports macOS probe counts, but a counts table is not a regression test. The existing it.each at line 297 already runs both layouts for the Unity-reference rule. Its result there is negative.
  • The two member probes leave different traces. The backup-folder probe comes from a recorded file fact, unity-il2cpp-backup-convention (reader lines 416 to 426). The Mono probe re-reads the file path inside the projection and records no fact. A reader of files[] can see why the backup probe exists but not the Mono one. Is that intended? Deriving it from the existing unity-assembly-reference fact plus the path is a fair design. I just want the choice to be deliberate.
  • A root that is a Unity data folder gets no Mono probe. The Mono rule needs at least three path segments (nativeConvention.ts line 64). So pointing the tool at Game_Data or at Managed finds no managed directory. The PR does make a root that is itself the backup folder work (lines 81 to 96). I read this in the code and did not run it. The limit exists on main already. A line in the docs saying "point at the game folder" would cover it.
  • The new probe exists only for a DLL the scan actually read. It needs the pe-cli-directory fact, and files past the probe byte budget get none (reader lines 252 to 258; default 8 MiB at desktopApplication.ts line 23). The ordinary managed probes have the same limit. I did not measure how often a large game hits it.
  • The Codex review on this head failed to complete. Its summary comment says it “couldn’t complete this review”. So no Codex findings exist for this head. A maintainer can ask it to retry. Greptile scored it 5/5 with no actionable issues.
  • The branch is far behind main. Since the merge base, main changed four files this PR also changes: docs/desktop-applications.md, DesktopApplicationReader.ts, desktopApplication.ts and the test file. Two examples are 79b3f46 and 992e930. The first is about GameMaker data filenames. The second one is about the coverage of unsupported filenames. GitHub now reports the PR as conflicting with main, so it needs a rebase. The body's CI evidence is from before those commits.
  • The body's npm test run had 9 failures on the author's macOS host, and the body says they were not measured on main. CI on this head is the better signal here: CI required, Portable tests and all eight test shards passed.

Nits

  • nativeConvention.ts lines 57 and 58 stack two /** */ blocks over one function. One block is enough.
  • The docs fix for IL2CPP metadata versions 24 and 27 is a second outcome beside the title. It is separate in commit 2e4e51d, so it is easy to read on its own. It is also right (see below), and Greptile already noted it.

Looks good

  • Main (7fd722e) still lacks the feature. A search of desktopApplicationProjection.ts, desktopApplication.ts and docs/desktop-applications.md on main finds no inspect_managed_members.
  • The Mono rule is narrow on purpose. The probe needs three things. One is the CLI-directory fact. Another is a Unity witness in the same managed directory. The last is a predefined name directly inside it (unityPredefinedAssembly). The ordering test adds look-alikes that must not match. One is a nested copy (too deep). One is a copy in a second _Data folder with no witness. One is under Plugins/, which is not a managed directory.
  • I traced the root-is-backup case. With rootName prefixed, the shift is 1 and the backup index is -1. That matches only a path of exactly two segments with managed first, such as Managed/Assembly-CSharp.dll. The root test checks that and the "." directory value. The backup test checks look-alikes too. They are an empty product prefix, a missing suffix, a nested copy, and the wrong depth.
  • "Listed first" is real. next_probes is built from a Map in insertion order, and the member probes are added before the ordinary ones (lines 64 to 89). The ordering test asserts the first two rows.
  • No new authority. The probes are suggestions with confidence: "inferred". The new fact is a path convention with offset: null. The backup rationale says the match to the shipped native code is unknown. The docs paragraph at lines 112 to 117 says the same.
  • The docs fix is accurate: IL2CPP_METADATA_VERSIONS is [24, 27, 29, 31, 39] on main. Main has since made the same docs fix in 866c72c. So this hunk can drop when you rebase.
  • The body is open about gaps. The backup folder was checked only on macOS builds. Agent tool choice after the change is unmeasured.
  • No competing PR. Searches on #3607 and on the new operation found this PR. They also found #5785, which I did not read. It has the same author and is about il2cpp generic instances. The #3607 thread has the author's list of related PRs.

Not run

  • No checkout, no build, no tests, no formatter.
  • I did not run the tool on any Unity sample. I did not check the layout of a real Unity backup folder, and I did not measure the body's probe counts or response sizes.
  • I did not read desktopApplicationView.ts beyond the probe-grouping loop, and I did not try a merge with main.

Thanks, 8rulerstar, for the careful scope notes. Thanks too for the look-alike tests and the honest coverage limits.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • Head / base: eda62d5 / d0067ba (merge base); main was 7fd722e

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@8rulerstar
8rulerstar force-pushed the feat/unity-script-assembly-probes branch from 74619f4 to 964cd7f Compare October 24, 2026 05:26
@8rulerstar

Copy link
Copy Markdown
Contributor Author

@codex review

@8rulerstar

Copy link
Copy Markdown
Contributor Author

Ready for another look. Head is 3ecaab0. I merged main into the branch and GitHub no longer reports a conflict. CI on this head passed (CI required, Portable tests, all eight shards).

Pending

  • Codex did not finish its review of the earlier head, so I'm requesting it again on this head (comment below). I'll deal with anything it reports.

Should fix

  • Done: the body uses the template headings as written. All Before merge boxes are checked; the "representative output" box now has two next_probes rows from the boundary test fixture, under "User-visible CLI/MCP output".

Worth a look

  • macOS bundle: test added (bc92d83). It asserts that Contents/Resources/Data/Managed/Assembly-CSharp.dll gets the member probe and that the probe is listed first.
  • Different traces: intended. The Mono probe can already be derived from the unity-assembly-reference fact plus the path, so a second fact would only repeat it. The backup-folder probe has no existing fact to derive from, so it records its own. This is now under "Change and scope".
  • Data folder as root: docs line added as you suggested (964cd7f). A test now checks that a root of Game_Data or Game_Data/Managed still gets the managed artifact probe but no member probe (85cc2b4, 3ecaab0). The rule itself is unchanged; main has the same limit.
  • Probe byte budget: unchanged, listed under "not included". It is the same limit as the ordinary managed probes. I haven't measured how often large games hit it.
  • Behind main: merged (90c7490). There was one conflict, in docs/desktop-applications.md. Main already had the paragraph about IL2CPP metadata versions 24 and 27, so I kept main's text. This PR no longer changes that paragraph.

Validation

  • After the merge, tsc --noEmit passed and desktopApplication.test.ts had 59 passed, 1 failed, 3 skipped. The failure is a symlink permission error (EPERM) on my Windows machine, in does not promote filenames, arbitrary pak files or symlink targets. That test already exists on main and this PR doesn't touch it; I expect it to pass on Linux CI.
  • The probe-count table in the body is from before the merge and was not re-measured. Committed tests cover the member-probe ordering. The claim that other probes are identical rests only on those earlier, pre-merge runs.

Nits

  • Done: one /** */ block on desktopPathConventions (d1ce31b).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…ssembly-probes

Resolve the DesktopApplicationReader conflict by keeping main's
pathConventions, which reserves every path-convention fact before the
row is retained, and moving the IL2CPP backup fact and the admitted
root name into it.
@morluto
morluto merged commit abc647b into morluto:main Nov 4, 2026
50 checks passed
@8rulerstar
8rulerstar deleted the feat/unity-script-assembly-probes branch November 6, 2026 01:23
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added enhancement New feature or request area: runtime Process capture and runtime observation labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants