feat(plugin): bridge worker capability requests to the host broker (H3-A)

- add request-scoped capability_request/capability_reply/capability_error
  frames to the worker transport (ADR-0018); no C ABI change
- worker routes its capability handler through stdin/stdout, the host serves
  requests inside the existing invoke deadline and binds identity from the
  spawned worker, never from frame text
- both native and worker plugins now execute a granted fs.read through
  ProjectFs with audit; unsupported capabilities return capability.unavailable
- add a real C capability plugin and CLI test for granted read and denial
- document the bridge and that strict OS isolation (H3-B) is still refused
This commit is contained in:
cflmy committed 2026-11-20 13:08:56 +08:00
1 parent 47a2e1883f
commit 0f01a69048
11 files changed
+720 -64

No files matched your search

+18
View File
@@ -374,6 +374,24 @@ Worker → host responses are `{"kind":"response","response":<wire response>}` o
`{"kind":"error","code":...,"message":...}`. The worker validates that the
declared manifest exports exactly match the library's registrations.
While an invoke is in flight, the worker may also request host capabilities
(ADR-0018):
```text
worker → host {"kind":"capability_request","id":7,"capability":"fs.read",
"request":{"path":"data/allowed.txt"}}
host → worker {"kind":"capability_reply","id":7,"data":"<utf-8 text>"}
host → worker {"kind":"capability_error","id":7,"code":"permission.denied",
"message":"..."}
```
The id must match and is request-scoped; requests carry no trusted identity
(the host binds package/session from the spawned worker). Non-JSON requests,
unknown/mismatched ids, non-text replies and other frame kinds are protocol
errors. The invoke deadline covers the whole exchange. In this build only
granted `fs.read` executes; other capabilities return `capability.unavailable`.
These frames do not change the C ABI.
## 10. SDK usage (`crates/marqdo-plugin-sdk`)
The SDK hides the raw C layout and exports the entry symbol with
+6 -5
View File
@@ -276,11 +276,12 @@ Neither command executes project code. Specifically:
3. Network capability exists in the model but no host operation uses it; there
is no `--allow-net` flag.
4. Write-path symlink TOCTOU (see §2.1).
5. Plugin **worker crash isolation** is implemented, but the worker capability
bridge is not: worker capability requests are still denied. Only trusted
in-process native plugins can use the broker's `fs.read` execution. No
vendor-executing handler is shipped, and broker execution is a cooperative
API contract, not an OS sandbox.
5. Plugin **worker crash isolation** and the worker capability bridge are
implemented: both native and worker plugins can reach the broker's
`fs.read` execution when granted. Other core capabilities and vendor
handlers remain unavailable. Broker execution is a cooperative API
contract, not an OS sandbox; a worker and a native plugin can still issue
direct syscalls.
6. `plugin_handle` wire values are structurally reconstructable, but host
authority comes only from the `PluginHandleTable` owner/run/generation
check; untrusted plugin/foreign output containing a handle is rejected