freepdfeditor/spike/E_sandbox/ipc.capnp

40 lines
1.7 KiB
Cap'n Proto

# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors
#
# Cap'n Proto schema for the Spike E IPC (engineering plan §2.1, ADR-0004).
# This is the trivial two-message protocol the spike uses to measure the
# round-trip cost of the process split: a Parse request carrying a byte range,
# and a ParseResult carrying back a fixed response (the count of bytes that
# would be "parsed"). The real M2 protocol is far larger (object model, render
# tiles, commands) but the spike only needs to measure the channel cost.
@0x96b8a3f0c1d72e6f;
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("freepdfeditor::spike::e");
# A request from the UI process to the sandboxed document process. The byte
# range is the (offset, length) of a region of a file the UI process has
# already opened and mapped; the document process gets no filesystem access and
# works only with what the UI hands it via shared memory or this message.
struct ParseRequest {
requestId @0 :UInt64;
data @1 :Data; # the bytes to "parse" (trivial: the doc counts them)
}
# The response. The document process validates the request (bounds, counts) —
# per ADR-0004 the IPC is a trust boundary in *both* directions, so the UI
# never indexes or size-computes from a document-supplied number without
# checking it first.
struct ParseResult {
requestId @0 :UInt64;
byteCount @1 :UInt64; # number of bytes the document process saw
ok @2 :Bool;
error @3 :Text; # populated when ok == false
}
# The UI process initiates; the document process replies. Cap'n Proto's
# request/response over a TwoPartyPipe is the transport.
interface DocumentProcess {
parse @0 (request :ParseRequest) -> (result :ParseResult);
}