Skip to content

fix: allow Nix store plugin hardlinks - #79344

Merged
joshp123 merged 3 commits into
mainfrom
codex/nix-store-plugin-hardlinks
May 8, 2026
Merged

joshp123 merged 3 commits into
mainfrom
codex/nix-store-plugin-hardlinks

Conversation

@joshp123

@joshp123 joshp123 commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route plugin hardlink decisions through one shared policy helper
  • allow external plugin roots under /nix/store only when OPENCLAW_NIX_MODE=1
  • keep normal external plugin hardlink rejection unchanged and covered by tests
  • align an existing early-startup test stub with the current removeChatRun return contract so the touched core-test gate typechecks

Real Behavior Proof

  • Behavior addressed: Nix-packaged external OpenClaw plugin roots under /nix/store were rejected as unsafe hardlinks before OpenClaw could load them. Normal non-Nix external plugin hardlink rejection remains unchanged.
  • Real environment tested: macOS OpenClaw source checkout, OPENCLAW_NIX_MODE=1, disabled bundled plugins, and an actual Nix-store plugin root at /nix/store/ingn1s4xpz25j9dzi01zs5xi80z70qyl-openclaw-weixin-runtime-plugin-2.4.2.
  • Exact steps or command run after this patch:
OPENCLAW_NIX_MODE=1 \
OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 \
OPENCLAW_BUNDLED_PLUGINS_DIR="$tmp/empty-bundled" \
nix-shell -p nodejs_22 pnpm --run 'node -e "import { createJiti } from \"jiti\"; const jiti = createJiti(import.meta.url); const { loadOpenClawPlugins } = jiti(\"./src/plugins/loader.ts\"); const root = \"/nix/store/ingn1s4xpz25j9dzi01zs5xi80z70qyl-openclaw-weixin-runtime-plugin-2.4.2\"; const registry = loadOpenClawPlugins({ cache: false, config: { plugins: { enabled: true, load: { paths: [root] }, allow: [\"openclaw-weixin\"], entries: { \"openclaw-weixin\": { enabled: true } } } } }); const record = registry.plugins.find((entry) => entry.id === \"openclaw-weixin\"); console.log(JSON.stringify({ plugin: record && { id: record.id, status: record.status, origin: record.origin, rootDir: record.rootDir, channelIds: record.channelIds }, diagnostics: registry.diagnostics.map((diag) => ({ level: diag.level, message: diag.message })) }, null, 2)); if (!record || record.status !== \"loaded\") process.exit(1);"'
  • Evidence after fix: terminal output from the live command:
{
  "plugin": {
    "id": "openclaw-weixin",
    "status": "loaded",
    "origin": "config",
    "rootDir": "/nix/store/ingn1s4xpz25j9dzi01zs5xi80z70qyl-openclaw-weixin-runtime-plugin-2.4.2",
    "channelIds": ["openclaw-weixin"]
  },
  "diagnostics": [
    {
      "level": "warn",
      "message": "memory slot plugin not found or not marked as memory: memory-core"
    }
  ]
}
  • Observed result after fix: OpenClaw loaded the external Nix-store plugin as openclaw-weixin with status: "loaded" and origin: "config". Before this patch, the same Nix-store root was rejected during plugin manifest validation as an unsafe hardlink alias.
  • What was not tested: I did not run a full end-to-end OpenClaw chat session with this plugin. The live proof exercises the plugin loader path that was rejecting the Nix-store plugin root before runtime loading.

Tests

  • pnpm check:changed
  • pnpm test src/secrets/channel-contract-api.external.test.ts src/plugins/hardlink-policy.test.ts
  • pnpm test src/plugins/manifest-registry.test.ts src/plugins/loader.test.ts
  • pnpm test src/plugins/discovery.test.ts src/plugins/channel-catalog-registry.test.ts
  • pnpm exec oxfmt --check --threads=1 src/plugins/channel-catalog-registry.ts src/plugins/discovery.ts src/plugins/hardlink-policy.ts src/plugins/loader.ts src/plugins/manifest-registry.ts src/secrets/channel-contract-api.ts src/plugins/hardlink-policy.test.ts src/plugins/manifest-registry.test.ts src/secrets/channel-contract-api.external.test.ts src/gateway/server-startup-early.test.ts
  • pnpm check:changelog-attributions
  • git diff --check

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels May 8, 2026
@clawsweeper

clawsweeper Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds a shared plugin hardlink policy, applies it to plugin discovery, manifest loading, runtime loading, channel catalog, and channel secret-contract paths, adds regression coverage and a changelog entry, and updates one gateway test stub.

Reproducibility: yes. source-reproducible. Current main routes non-bundled plugin discovery, manifest, runtime, catalog, and external secret-contract reads through hardlink rejection, while the PR body gives a concrete Nix-store loader command with after-fix terminal output.

Real behavior proof
Sufficient (terminal): The PR body includes after-fix terminal output from a real Nix-store plugin root showing the external plugin loaded successfully.

Next step before merge
No repair lane: this is a protected maintainer-labeled PR with sufficient proof and no narrow defect found; maintainer review and queued CI are the remaining gates.

Security
Cleared: The diff touches plugin code-loading policy, but I found no concrete security regression because the exception is gated by existing Nix mode and a resolved /nix/store root while default external hardlink rejection remains.

Review details

Best possible solution:

Land a maintainer-reviewed, current-main version that preserves default external hardlink rejection and scopes the Nix exception to existing Nix mode plus resolved /nix/store plugin roots.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible. Current main routes non-bundled plugin discovery, manifest, runtime, catalog, and external secret-contract reads through hardlink rejection, while the PR body gives a concrete Nix-store loader command with after-fix terminal output.

Is this the best way to solve the issue?

Yes. A shared policy helper reused by all touched plugin-loading surfaces is the narrowest maintainable solution I found, and the PR keeps normal external plugin hardlink rejection unchanged.

What I checked:

  • Current main rejects non-bundled plugin runtime hardlinks: Current main passes rejectHardlinks: candidate.origin !== "bundled" to plugin runtime loading, so config/global/workspace plugin entries are rejected when fs-safe detects hardlink aliases. (src/plugins/loader.ts:2009, 7ff5e0928981)
  • Current main rejects non-bundled manifest and discovery hardlinks: Discovery and manifest registry both derive rejectHardlinks solely from origin !== "bundled", which explains why an external Nix-store plugin package is rejected before loading. (src/plugins/discovery.ts:687, 7ff5e0928981)
  • Nix mode is an existing documented runtime mode: The Nix install docs define OPENCLAW_NIX_MODE=1 for deterministic Nix-managed installs, so the PR reuses an existing public runtime mode rather than adding a new config surface. Public docs: docs/install/nix.md. (docs/install/nix.md:53, 7ff5e0928981)
  • Patch scopes the exception through a shared helper: The PR adds shouldRejectHardlinkedPluginFiles, preserving bundled allowance and default external rejection while allowing external roots only when Nix mode is active and the resolved root is under /nix/store. (src/plugins/hardlink-policy.ts:1, bf533f8654bc)
  • Real behavior proof is present: The PR body includes after-fix terminal output from a real /nix/store/...openclaw-weixin... plugin root showing status: "loaded", origin: "config", and channel id openclaw-weixin. (bf533f8654bc)
  • Exact-head CI is not complete yet: The GitHub check-runs API for the PR head reported 41 successful, 11 skipped, and 36 queued check runs at review time. (bf533f8654bc)

Likely related people:

  • steipete: Recent history for the loader, discovery, manifest registry, and secret-contract paths includes fs-safe refactors and the current hardlink rejection call sites. (role: recent maintainer of plugin file-access and hardlink guard paths; confidence: high; commits: b85b1c68d175, 538605ff44d2, 06056926a099; files: src/plugins/loader.ts, src/plugins/discovery.ts, src/plugins/manifest-registry.ts)
  • vincentkoc: Recent plugin manifest, discovery, and channel catalog work touches the same plugin control-plane and external catalog surfaces affected by the PR. (role: recent plugin registry and manifest maintainer; confidence: medium; commits: 89a15fddaf84, b520e40cf6d4, b5affa64b3bb; files: src/plugins/manifest-registry.ts, src/plugins/discovery.ts, src/plugins/channel-catalog-registry.ts)
  • joshp123: Beyond authoring this PR, prior merged work established Nix-mode behavior and macOS Nix defaults that this change builds on. (role: Nix-mode adjacent owner; confidence: medium; commits: d4b46600269c, 69aa3df116d3; files: docs/install/nix.md, src/config/paths.ts)

Remaining risk / open question:

  • Exact-head CI still had queued runs at review time.
  • Because this relaxes a plugin code-loading guard, maintainer review should confirm the /nix/store trust boundary is intended.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 7ff5e0928981.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 8, 2026
@joshp123
joshp123 force-pushed the codex/nix-store-plugin-hardlinks branch 3 times, most recently from 3da5484 to 0d7993d Compare May 8, 2026 11:29
@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

/clawsweeper

@clawsweeper

clawsweeper Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper status:

  • Current PR: 79344
  • Branch: codex/nix-store-plugin-hardlinks
  • ClawSweeper PR: no
  • Automerge: not-enabled
  • Automerge job: jobs/openclaw/inbox/automerge-openclaw-openclaw-79344.md
  • Merge state: UNKNOWN
  • Checks: SKIPPED:48 SUCCESS:7

@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@joshp123
joshp123 force-pushed the codex/nix-store-plugin-hardlinks branch from 0d7993d to 8e532f7 Compare May 8, 2026 11:59
@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 8, 2026
@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

1 similar comment
@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@joshp123
joshp123 force-pushed the codex/nix-store-plugin-hardlinks branch from 8e532f7 to 1fa50c4 Compare May 8, 2026 13:37
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 8, 2026
joshp123 and others added 2 commits May 8, 2026 22:02
Nix packages materialize plugin files as hardlinks in immutable store roots. Route discovery, manifest validation, channel catalogs, channel secret contracts, and runtime loading through one plugin hardlink policy so OPENCLAW_NIX_MODE accepts /nix/store plugin roots while normal external plugin hardlink rejection stays unchanged.

Tests:
- pnpm test src/secrets/channel-contract-api.external.test.ts src/plugins/hardlink-policy.test.ts
- pnpm test src/plugins/manifest-registry.test.ts src/plugins/loader.test.ts
- pnpm test src/plugins/discovery.test.ts src/plugins/channel-catalog-registry.test.ts
- pnpm exec oxfmt --check --threads=1 src/plugins/channel-catalog-registry.ts src/plugins/discovery.ts src/plugins/hardlink-policy.ts src/plugins/loader.ts src/plugins/manifest-registry.ts src/secrets/channel-contract-api.ts src/plugins/hardlink-policy.test.ts src/plugins/manifest-registry.test.ts src/secrets/channel-contract-api.external.test.ts
- pnpm check:changelog-attributions
- git diff --check

Co-authored-by: Codex <[email protected]>
Return undefined from the early-startup test stub so it satisfies the current chat run registry removal contract during core test typechecking.

Tests:
- pnpm check:changed
- git diff --check

Co-authored-by: Codex <[email protected]>
@joshp123
joshp123 force-pushed the codex/nix-store-plugin-hardlinks branch from 1fa50c4 to 7a8c089 Compare May 8, 2026 14:11
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label May 8, 2026
@joshp123
joshp123 marked this pull request as ready for review May 8, 2026 14:12
@joshp123
joshp123 requested a review from a team as a code owner May 8, 2026 14:12
@joshp123 joshp123 self-assigned this May 8, 2026
@joshp123
joshp123 merged commit 954d20e into main May 8, 2026
111 checks passed
@joshp123
joshp123 deleted the codex/nix-store-plugin-hardlinks branch May 8, 2026 14:59
@joshp123

joshp123 commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Thanks @joshp123!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: bf533f8

Co-authored-by: Codex <[email protected]>
Reviewed-by: @joshp123
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: bf533f8

Co-authored-by: Codex <[email protected]>
Reviewed-by: @joshp123
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Merged via squash.

Prepared head SHA: bf533f8

Co-authored-by: Codex <[email protected]>
Reviewed-by: @joshp123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant