Skip to content

feat: let extensions contribute host commands - #95

Merged
sdirix merged 3 commits into
mainfrom
feat/extension-host-commands
Oct 2, 2026
Merged

sdirix merged 3 commits into
mainfrom
feat/extension-host-commands

Conversation

@sdirix

@sdirix sdirix commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What it does

An installed extension's commands/host/ executables become enclave <name> verbs, so an extension can ship something that has to run outside the sandbox, like a VNC viewer. Names resolve after the user's own commands/ trees, so an install never takes over a name already in use.

These are the only thing an extension ships that executes outside a container. The capability summary leads with them, the diff an update renders repeats the risk, and the result envelope and list carry them under --json, where there is no narration to read.

commands/ is excluded from the build context and the image identity hash like the provenance sidecar, but the tree hash still covers it, so the rebuild hint now asks whether a change reached the image at all.

Implements #87

How to test

Install the vnc feature of https://github.com/sdirix/enclave-extensions which makes use of hostCommand to offer enclave vnc-viewer command.

enclave features add sdirix/enclave-extensions

Follow-ups

Breaking changes

  • This PR introduces breaking changes and has been coordinated with maintainers.

Review checklist

An installed extension's commands/host/ executables become `enclave <name>`
verbs, so an extension can ship something that has to run outside the sandbox,
like a VNC viewer. Names resolve after the user's own commands/ trees, so an
install never takes over a name already in use.

These are the only thing an extension ships that executes outside a container.
The capability summary leads with them, the diff an update renders repeats the
risk, and the result envelope and `list` carry them under --json, where there
is no narration to read.

commands/ is excluded from the build context and the image identity hash like
the provenance sidecar, but the tree hash still covers it, so the rebuild hint
now asks whether a change reached the image at all.

Implements #87

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

Note

Autonomous AI review.

This review was done by an AI agent and therefore may contain mistakes. Feel free to ignore any comment you disagree with. A thumbs-down reaction on a comment marks it as rejected for follow-up reviews. Noting why in a reply helps, since replies are read too.

Resolving all AI comments does not lead to an automatic approval. A maintainer still needs to review and sign off on the overall architecture and design.

To get an updated review after pushing changes, a maintainer may re-request a review from this account.

Running in Eclipse Enclave, submitted via review-guard-mcp

Adds a third source for enclave <verb>: an installed extension's commands/host/ executables. usercmd.Discover scans the user extension root after the user's own host//session/ trees, so an install can never take a name already in use, and every loser gets a warning. commands/ is excluded from the build context and the image identity hash (overlayNamedExtensionDirs), while TreeHash still covers it, with changesReachImage keeping an update confined to that tree from promising a rebuild. The capability surface is extended consistently: a leading "host commands" row in the summary, a diff entry that repeats the risk on update, hostCommands in the list --json and add/update/remove envelopes, and a text [host: ...] suffix.

The approach fits the existing extension machinery well and the test coverage is solid. Points to focus on:

  • scanExtensions filters extension directories with entry.IsDir() only, which pulls in the installer's dot-prefixed .replaced-* leftovers. I reproduced it: a leftover from an interrupted update contributes a working host verb that list and remove cannot see. This is the one I would fix before merge.
  • extinstall.hostCommandNames duplicates the file filter that usercmd.scanDir already implements, and the doc comment claims it is the single definition.
  • The summary and remove report verbs that may never register (built-in or user-command collisions).

Also a docs-size nit on the new ARCHITECTURE.md bullet.

Comment thread internal/usercmd/usercmd.go Outdated
Comment thread internal/extinstall/hostcommands.go Outdated
Comment thread internal/extinstall/capabilities_render.go
Comment thread docs/ARCHITECTURE.md Outdated
Skip installer staging directories when scanning extensions, share the command filter between usercmd and extinstall, and stop promising verbs that a built-in or the user's own command already takes.

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

Note

Autonomous AI review.

This review was done by an AI agent and therefore may contain mistakes. Feel free to ignore any comment you disagree with. A thumbs-down reaction on a comment marks it as rejected for follow-up reviews. Noting why in a reply helps, since replies are read too.

Resolving all AI comments does not lead to an automatic approval. A maintainer still needs to review and sign off on the overall architecture and design.

To get an updated review after pushing changes, a maintainer may re-request a review from this account.

Running in Eclipse Enclave, submitted via review-guard-mcp

Follow-up review of commit b0e18ea, which addresses all four points from my last pass.

  • .replaced-* staging dirs are excluded from scanExtensions via config.IsExtensionDir (shared with validate_extensions.go), with a regression test (TestDiscoverIgnoresInstallerStagingDirs).
  • extinstall.hostCommandNames is gone; usercmd.ExtensionCommandNames is now the single filter used by capabilities, Inventory, and (indirectly, via Resolving) remove.
  • Names shadowed by a built-in or the user's own command are no longer promised: usercmd.Shadowed backs a ShadowedHostCommands map that both the capability summary/diff (addedHostCommands()) and the remove note (usercmd.Resolving) respect, each covered by new tests.
  • The ARCHITECTURE.md bullet is trimmed to the architectural facts and links to extensions/README.md#host-commands.

Verified go build ./... and go test ./internal/usercmd/... ./internal/extinstall/... ./internal/cli/... all pass on the merged tree. Didn't find anything new to flag in this commit; scope is tight and matches its stated purpose.

These previous comments can be resolved as they are now handled:

I can't resolve them myself as I would need write permission on this repository.

@tortmayr
tortmayr self-requested a review September 28, 2026 10:37

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

Changes look good to me and i tested the PR in combination with eclipse-enclave/enclave-extensions#5.
Work like a charm.

@xai You mentioned that you have some security concerns regarding this feature. Do you want to have a second look. Otherwise we could merge this.

@xai
xai self-requested a review October 1, 2026 13:50

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

Looks good to me as well, and works as intended 👍

Regarding the security concern: It makes the attack significantly surface larger, but the user is made aware of the risk before the installation of an extension with host commands, so IMHO that is ok.

@xai xai mentioned this pull request Oct 1, 2026
1 of 2 tasks
@sdirix
sdirix merged commit 52187ec into main Oct 2, 2026
9 checks passed
@sdirix
sdirix deleted the feat/extension-host-commands branch October 2, 2026 06:13
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.

4 participants