fix(plugin): bound worker capability calls per invocation (H3-A)

- enforce at most 64 capability requests and 64 KiB per serialized request
  in both the worker handler and the host bridge
- return structured capability.budget_exceeded / request_too_large errors and
  kill the worker on a host-side violation
- add a real C loop fixture and CLI test proving a runaway plugin is stopped
  without producing file contents
- update ADR-0018, plugin-abi and STATUS
This commit is contained in:
cflmy committed 2026-11-20 13:11:24 +08:00
1 parent ea41256671
commit f69c563afd
7 files changed
+101 -10

No files matched your search

+18
View File
@@ -51,6 +51,24 @@ static int32_t capability_read(MqCallContext *ctx, MqBytes args_wire,
name.len = sizeof("fs.read") - 1;
request.data = (const uint8_t *)PATH_REQUEST;
request.len = strlen(PATH_REQUEST);
#ifdef MQ_CAPABILITY_LOOP
for (int i = 0; i < 100; i++) {
MqOwnedBytes loop_reply = {NULL, 0};
code = g_host->request_capability(ctx, name, request, &loop_reply);
if (loop_reply.data != NULL) {
g_host->free(g_host->host_data, loop_reply.data);
}
if (code != MQ_OK) {
static const char BUDGET_JSON[] =
"{\"wire_version\":1,\"kind\":\"response\",\"error\":"
"{\"kind\":\"capability\",\"code\":\"capability.budget_exceeded\","
"\"message\":\"capability request budget exceeded\"}}";
return emit(BUDGET_JSON, sizeof(BUDGET_JSON) - 1, error_wire) == MQ_OK
? code
: MQ_ERR_OUT_OF_MEMORY;
}
}
#endif
code = g_host->request_capability(ctx, name, request, &reply);
if (code != MQ_OK) {
static const char ERROR_JSON[] =