Skip to content

fix(workspace): materialize and classify executables correctly (backport of #338, #339) - #351

Merged
bobtista merged 2 commits into
release/alpha-4from
backport/workspace-executables-alpha-4
Aug 3, 2026
Merged

fix(workspace): materialize and classify executables correctly (backport of #338, #339)#351
bobtista merged 2 commits into
release/alpha-4from
backport/workspace-executables-alpha-4

Conversation

@bobtista

@bobtista bobtista commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Backports #338 and #339 into release/alpha-4.

Both bear on whether a prepared workspace produces a launchable entry point,
which is the A profile can be created and launched box still open for both
platforms in #307.

Why these two

They are the same class of user-facing workspace fix as #346 and #350, both
already backported. The remaining development commits are deliberately left
out:

Backport notes

#339 cherry-picked clean. #338 required one adaptation, worth recording because
a clean textual merge hides it:

On development, #338 merged before #348, the forward-port of #346. This
branch already carries #346, so the cherry-pick applies #338 after it —
reversing the integration order. #348 had amended #338's own tests to coexist
with the workspace-root change, rewriting
Path.Combine(_tempPath, "workspace") to Path.Combine(_tempPath, workspaceId)
so the cached workspace path matches the root-derived path and the recreate
branch does not fire.

Without that adaptation the cherry-pick still compiles and reports no conflict in
WorkspaceManager.cs, but
PrepareWorkspaceAsync_WhenEntryPointBricked_RepairsAndReusesWorkspace fails.
The same two-line adaptation #348 made is folded into the #338 commit here, so
both commits are individually green.

The one genuine conflict was in WorkspaceManagerReuseTests.cs, where #346's
WhenStorageRootChanges test and #338's two new tests landed adjacently. All
three are kept; #338's change to that file is purely additive.

Testing

  • dotnet test GenHub/GenHub.Tests/GenHub.Tests.Core/GenHub.Tests.Core.csproj -c Release
    • At #338: 1,478 passed, 0 failed
    • At #339 (tip): 1,510 passed, 0 failed
  • dotnet build GenHub/GenHub.Linux/GenHub.Linux.csproj -c Release — passed
  • Formatting verification and git diff --check — passed

Risks and rollback

Outstanding

Packaged Windows and Linux validation per #307 still applies; these commits
change workspace materialization, so the profile can be created and launched
checks should be re-run against a build containing them.

Backport of #338 and #339

Greptile Summary

This backport makes Unix executable materialization atomic, repairs stale executable modes when reusing workspaces, and centralizes executable classification around file extensions and magic bytes.

  • Adds private-copy executable swaps to protect hard-linked CAS content.
  • Validates and repairs cached workspace entry points before reuse.
  • Distinguishes native binaries, scripts, libraries, and legacy launch candidates across manifest-generation paths.
  • Adds focused tests for atomic replacement, CAS isolation, path containment, workspace reuse, and executable magic formats.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code defect identified.

The executable swap preserves CAS isolation, workspace reuse repairs only contained entry points, unsafe or missing paths fall back to recreation, and changed classifier callers consistently select content-aware or metadata-only classification according to the available file state.

Important Files Changed

Filename Overview
GenHub/GenHub.Core/Utilities/ExecutableFileClassifier.cs Adds bounded header sniffing for PE, ELF, and Mach-O files while retaining explicit name-only APIs for metadata contexts.
GenHub/GenHub/Features/Workspace/ExecutableFileSwap.cs Introduces unique temporary copies and atomic replacement so execute-mode changes cannot mutate shared hard-link targets.
GenHub/GenHub/Features/Workspace/WorkspaceValidator.cs Adds contained-path entry-point repair with parent-symlink checks and structured failures that trigger recreation.
GenHub/GenHub/Features/Workspace/WorkspaceManager.cs Checks and repairs the entry point before returning a reused workspace, recreating the workspace when repair is unsafe or impossible.
GenHub/GenHub/Features/Workspace/Strategies/WorkspaceStrategyBase.cs Delegates executable materialization to the shared atomic swap helper.
GenHub/GenHub.Core/Models/Manifest/ManifestVariantResolver.cs Explicitly uses name-only legacy launch classification because manifest resolution operates on metadata rather than acquired files.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Prepare workspace] --> B{Reusable cached workspace?}
    B -- No --> C[Materialize files]
    C --> D[Copy executable to unique temporary path]
    D --> E[Apply Unix execute mode]
    E --> F[Atomically replace workspace file]
    B -- Yes --> G[Resolve contained entry point]
    G --> H{Exists and executable?}
    H -- Yes --> I[Reuse workspace]
    H -- Missing or unsafe --> C
    H -- Mode missing --> J[Create executable private copy]
    J --> I
Loading

Reviews (1): Last reviewed commit: "fix(content): classify executables by ma..." | Re-trigger Greptile

Context used (3)

…odes (#338)

* fix(workspace): repair non-executable entry points during validation

* fix(workspace): confine entry-point repair to the workspace root

* fix(workspace): refuse repair through symlinked parents and use unique swap temp names

(cherry picked from commit 06c1596)
…nsionless heuristic (#339)

* fix(content): classify executables by magic bytes instead of the extensionless heuristic

* fix(content): recognise 64-bit fat Mach-O magics and rename name-only classifier overloads

* fix(content): preserve execute permission for shebang scripts

(cherry picked from commit 4fb9ea1)
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • development

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8136e55e-a61e-4e6f-9d8d-7d8f9f122bd9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant