Skip to content

Expose a native SRT shell for virtual pods - #162

Open
horner wants to merge 6 commits into
mainfrom
feat/native-pod-shell-api
Open

horner wants to merge 6 commits into
mainfrom
feat/native-pod-shell-api

Conversation

@horner

@horner horner commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Artipod 0.14.0 exposes native Bash through the CLI. This change gives Linux Node hosts a public API for running the same SRT backend against an existing virtual pod. Pass a confined sandbox to createNativePodShell from @artipod/core/native, then pass the resulting shell to createSandboxTools or call shell.exec() directly.

The library verifies protected working storage, stages the pod's files, captures bounded output and reconciles changes after the native process finishes. It uses the existing Artipod SRT worker and its startup and shutdown acknowledgements. Cancellation, deadlines and loss of the calling worker retire the protected checkout. The embedding application chooses the authorized pod, serializes access to its overlay and decides when to commit its ref.

The package export and CLI were built and checked with TypeScript and ESLint. Tests cover lazy encrypted overlays, binary edits, renames, failed imports, cancellation and worker loss. Linux regression tests cover Ctrl+C cleanup, cancellation while a virtual file read is stalled, and observer notification after reconciliation. Encrypted project tests verify that restricted file and directory modes survive reopening and that a surviving child retains its private ancestors after a concurrent deletion. Hosted native tests · Merge regression

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

⚖ Weighbridge

metric trend value Δ main limit headroom
✅ pack tarball ▁▁▁▁▆▆▆▆▆▆▆████ ● 603.5 KB +13.0 KB 4.77 MB 12%
✅ pack unpacked ▁▁▁▁▆▆▆▆▆▆▆████ ● 2.49 MB +53.2 KB 20.98 MB 12%
✅ pack section dist ▁▁▁▁▆▆▆▆▆▆▆████ ● 2.46 MB +52.9 KB 3.15 MB 78%
✅ pack section dist-ui ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ● 0.0 KB +0.0 KB — —
⚠️ bundle . gzip ▁▁▄▄▇▇▇▇▇▇█████ ● 620.2 KB +0.1 KB 654.3 KB 95%
✅ bundle ./tools gzip ▁▁▁████████████ ● 12.6 KB +0.0 KB 15.6 KB 81%
⚠️ bundle ./sandbox gzip ▁▁▄▄▇▇▇▇▇▇█████ ● 563.2 KB +0.0 KB 595.7 KB 95%
⚠️ bundle ./oci gzip ▁▁▂▂▆▆▆▆▆▆█████ ● 371.4 KB −0.0 KB 400.4 KB 93%
✅ bundle ./apps gzip ▁▁▁▁███████████ ● 19.7 KB +0.0 KB 29.3 KB 67%
✅ import . ▂█▄▁██▂▄▅▄▇▅▄▃▃ ● 232 ms +5 ms 700 ms 33%
✅ import ./tools ▂█▄▁██▂▄▅▄▃▂▁▁▁ ● 8 ms +0 ms 150 ms 5%
✅ import ./sandbox ▁▇▄▁██▂▄▆▄█▅▄▃▃ ● 147 ms +1 ms 500 ms 29%
✅ import ./oci ▁▇▃▁██▂▄▅▃▆▅▃▂▃ ● 173 ms +3 ms 500 ms 35%
✅ import ./apps ▁█▄▁██▁▃▄▃▅▂▂▁▁ ● 25 ms +1 ms 200 ms 13%
✅ cmd cli --help ▂█▄▁██▁▃▆▃█▅▄▃▃ ● 272 ms +7 ms 800 ms 34%

trend = last 14 main weigh-ins, ● = this run · weighbridge

@horner
horner added this pull request to stack #164 December 4, 2026 08:12
@horner
horner marked this pull request as ready for review December 4, 2026 09:14
Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:14

Copilot AI 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.

🟡 Changes recommended

Stalled lazy-file reads ignore aborts, so shell.exec() can remain pending after a timeout, cancellation, or disposal, retaining the protected checkout and keeping the shell busy. Separately, Ctrl+C during staging or reconciliation can terminate the worker without cleanup, leaving the decrypted checkout behind. Directory permissions are also discarded, so restrictive mkdir modes and chmod changes can be silently lost.

3 open issues
What changed in this PR

Adds a Linux Node API for running native Bash against existing virtual pods, reusing the SRT backend and integrating with agent tools.

Changes:

  • Exports createNativePodShell through @artipod/core/native.
  • Adds protected checkout staging, bounded output capture, reconciliation, and lifecycle handling.
  • Documents the API and adds unit, integration, and CI coverage.
File Description
test/​native-pod-shell.test.js Tests the packaged API and checkout lifecycle.
src/​native/​srt-worker.ts Acknowledges command and isolation teardown completion.
src/​native/​runner.ts Adds captured output and completion checks.
src/​native/​runner.test.ts Tests supervisor completion acknowledgements.
src/​native/​project-tree.ts Stages, validates, and reconciles virtual files.
src/​native/​project-tree.test.ts Tests reconciliation, limits, and encrypted overlays.
src/​native/​pod-shell.ts Implements the public native shell factory.
src/​native/​pod-shell-worker.ts Owns protected checkouts and captures command output.
README.md Introduces the programmatic native shell API.
package.json Adds the Node-only native export.
docs/​srt.md Documents usage, limits, and host responsibilities.
CHANGELOG.md Records the new API.
.github/​workflows/​nodejs.yml Runs public API tests in native-shell CI.

Review effort: Balanced

Comment thread src/native/pod-shell-worker.ts Resolved
Comment thread src/native/project-tree.ts Resolved
Comment thread src/native/project-tree.ts Resolved
Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:40

Copilot AI 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.

🔵 Needs a closer look

On unprivileged Linux hosts, a successful command that leaves a regular file with mode 000 causes output inspection to fail with EACCES, discarding all completed edits. Separately, native execution omits the post-reconciliation fs:changed notification for sandboxes created with pod.createSandbox(), leaving event-driven consumers such as TreeSource stale.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Emit fs:changed after native execution reconciliation

src/​native/​pod-shell.ts:92

Native execution bypasses the supplied sandbox's execution path and never emits a command-boundary fs:changed notification after reconciliation. For a sandbox created by pod.createSandbox(), native edits therefore leave event-driven consumers such as TreeSource (src/host/tree-source.ts:39–40) stale, unlike ordinary shell edits. Preserve access to the pod's event bus or add an explicit notification hook, and notify it after reconciliation completes; pushing the ref alone does not invalidate these consumers.

Medium severity Allow inspection of files changed to mode 000

src/​native/​project-tree.ts:137

On an unprivileged Linux host, a valid command such as printf updated > note; chmod 000 note succeeds, but this O_RDONLY open fails with EACCES. Inspection then rejects the entire output, discarding all completed edits instead of importing the file and its mode. Directories already receive temporary traversal permissions; provide similarly safe access to verified single-link regular files while retaining their original mode for reconciliation.

3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:50

Copilot AI 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.

🔵 Needs a closer look

When one head deletes a 0700 directory and its file while the other edits the file after the deletion timestamp, the merge keeps the file but drops the directory metadata. OciViewFS then recreates the directory as 0755 instead of 0700, widening its permissions.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Preserve ancestor directory permissions when descendants survive deletion

src/​manager/​merge.ts:299

When one head deletes /private (mode 0700) and its file while the other only edits that file after the deletion timestamp, this drops the unchanged directory but keeps the file. OciViewFS then recreates /private as 0755, widening its permissions. After choosing winners, retain explicit ancestor-directory metadata for surviving descendants and add a deletion-versus-child-edit regression test.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:56

Copilot AI 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.

🔵 Needs a closer look

Merges and served-folder round trips may lose empty directories or directory metadata, potentially broadening private-directory permissions, so preservation of these properties needs human review.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:04

Copilot AI 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.

🔵 Needs a closer look

Security-sensitive native execution relies on Linux PID-namespace teardown and protected-checkout retirement across worker loss. Those kernel/runtime guarantees still need human validation with real SRT, particularly during cancellation and supervisor failure.

No open issues 🎉

Review effort: Balanced

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.

2 participants