Skip to content

feat(platform): general service functions - #2996

Draft
jeremi wants to merge 81 commits into
mainfrom
feat/reference-host-functions
Draft

jeremi wants to merge 81 commits into
mainfrom
feat/reference-host-functions

Conversation

@jeremi

@jeremi jeremi commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

This is the integration PR for general service functions. It lands in steps on this branch and stays a draft until every step it carries is in and green. Step 1, below, runs every service function on the reference host. The next steps follow on this branch: the per-function declaration and call pass in rstack dev, the call pass in Session, principals, and preview parity. Each one updates this description.

Step 1

The Compose reference host ran only the registration example's prepare export. A service's functions could not run there as they run under rstack dev. The host now serves every function the bundle's manifest names, through each function's own defineFunction export, with the same contract as rstack dev.

What changes

  • Manifest. host.mjs reads the manifest and checks its shape before it imports anything:

    • one JSON object of at most 1 MiB;
    • distinct function names;
    • exactly the page and Coordinator-only functions the preview selects;
    • a relative staticOutput with no empty, . or .. segment;
    • a preview page the host serves;
    • every module present and covered by the bundle digest.
  • Module loading.

    • The host loads each function from the bytes it hashed, under that file's URL with an identity unique to each start, through a module load hook.
    • A function may import only Node builtins. Any other import is refused before Node resolves it.
    • A bundle path reached through a link or a different letter case is refused. So is a link or a non-regular file in the bundle.
  • Page calls. They arrive through Session's Envoy with the person's bearer.

    • The binding gives the function a product client carrying that bearer, plus a copy of the request with only four request headers.
    • The browser gets only a short list of answer headers, so a function cannot set a cookie.
    • These follow rstack dev's gateway policy:
      • a function's redirect answers 502;
      • an answer over 4 MiB answers 502;
      • a request without Accept reaches the function with Accept: */*.
  • Request bodies. Bodies over 32 KiB answer 413 before any function runs.

  • Coordinator listener. With the Coordinator overlay, the host opens a Coordinator listener on private loopback port 8301:

    • it admits only the function host key, read from the regular file FUNCTION_HOST_KEY_FILE, never from the environment, and compared as fixed-size digests in constant time;
    • the function gets a fresh request without credential headers, and a client with no registry authority;
    • a Coordinator-only function answers 404 to a page.
  • Failures and logging.

    • A failing function, or an answer outside 200 to 599, answers a generic 500.
    • Each call logs one line naming the function, the caller kind and the status the caller got, with no value, header or token.
  • Retired host client. The generated host client and its build step are retired from the Dockerfile, Compose, the run scripts, the chart's cluster test, CI and the guides.

  • Networks. In every Compose composition the function host's namespace has no network, and its only route out is its relay to BReg. Machine clients that need the issuer run in their own relay namespace.

  • The network test renders every composition with each runner's own file order. It fails on:

    • a shared network;
    • an unexpected mount, including a parent of the relay sockets;
    • a changed relay command;
    • a relay config with anything beyond static resources.

    CI runs it whenever a recipe file or a release candidate overlay changes.

  • Coordinator proof. CI runs the coordinator profile on pull requests. In that run, a Coordinator workflow calls a function on the reference host through its listener once the host serves. The release candidate's receipt check requires that proof's exact output.

Tests

  • function-parity.test.mjs builds the permit-review functions unchanged, plus a test function that reads BReg. Both rstack dev's function host and the reference host serve them against one stub BReg, directly and through the dev gateway.

    • It compares status, body, answer headers and the BReg calls made, including the bearer BReg received.
    • The cases cover 200, 204, 400, 401, 403, 404, 413, 500 and 502, redirects, a missing Accept and the 4 MiB limit.
  • host.test.mjs covers:

    • manifest refusals;
    • the load hook (builtins only, links, letter case, native addons, an entry imported before start, two hosts on one path);
    • the header policy;
    • the Coordinator listener and its key file.
  • functions.test.mjs, test_coordinator_prepare.py and test_function_host_network.py are new. operator-steps.test.mjs refuses any recipe file, runner or guide that names the host client, and pins the runner order and guide counts.

  • Run locally on the pushed head, all passing:

    Suite Result
    recipe Python, with the client package and Compose required 57
    recipe Node (the CI smoke list) 68, 1 skipped (Playwright)
    host, function and parity suites, Node 24.11 and 24.21 58
    test_ci_changes.py passing
    test_candidate_host_smoke.py 25
    release candidate and release tool suites passing
  • Also clean: shellcheck, actionlint and git diff --check.

  • The Compose and k3d runs, including the coordinator profile and the browser journey, are left to this PR's full CI.

Intended differences from rstack dev

The parity test pins the first five:

  • A non-POST page call answers 405, which the Compose runner probes, where rstack dev answers 404.
  • A page call to a Coordinator-only function answers 404 before the caller is checked.
  • A Coordinator call with a query string answers 404.
  • An oversized Coordinator body answers 413 before the function runs.
  • The reference host does not add the headers rstack dev's HTTP client adds on its own (Accept-Encoding, Accept-Language, Sec-Fetch-Mode, User-Agent).

Not pinned: for Response.error(), rstack dev answers 500 with an empty body, and the reference host answers 500 with its generic message.

Security review notes

This changes the reference host's trust boundary.

  • Before, the function received only two registration fields, and the host called BReg itself.
  • Now, function code holds a product client that carries the caller's token, as it already does under rstack dev.
    • A function can make any call that token and BReg's access profile allow.
    • On this recipe that is the registrar's own token: the function route admits only the registrar sign-in.
  • The recipe README says so and keeps "serve only reviewed function code". The load hook guarantees which source bytes the host imports, and refuses every non-builtin import, data: included. It is not a sandbox: a function has Node builtins, so reviewed code could still build and run source by other means.
  • Function code can also read the host key file. That only lets it make Coordinator calls to this same host.
  • The function host has no network of its own, so a function reaches only BReg, through its relay.
  • A later step on this branch replaces the token in function code with a short-lived pass that Session exchanges, so this PR does not merge before that step.

Not in this PR

  • The @registrystack/client/holder-function export stays. No recipe uses it now.
  • Multi-product clients, function secrets, and webhook and scheduled callers.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…binding

The reference host builds each function the manifest names from its
default export with the rstack dev prepared run, serves page calls on
the relayed listener and Coordinator calls on a separate loopback
listener that admits only the function host key.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The Coordinator overlay gives the host and the serving Coordinator one
function host key, and the products' namespace reaches the host's
Coordinator listener at 127.0.0.1:8301 through an owner-only socket.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…dinator listener

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…host job

That job installs and builds the client package, which the function and
parity tests build their preview bundle with.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…client

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ient

The host serves every function through its own defineFunction binding, so the image, the runners, the guides and the deployment job must stop building or passing a client for it.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ger loads

Every function runs through its own defineFunction binding from the checked bundle, so the image, Compose, the runners, the cluster run, the service preview check, CI and the guides stop generating, checking, archiving or passing a separate client. The deployment job no longer routes on client sources it does not read.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
@jeremi jeremi added the ci:full Run the heavy integration tier on this pull request label Dec 5, 2026
… reference host

The relay to the host's Coordinator listener, the key file and the service function connection were proved only by unit tests. The proof run now has to call register-business and finish with its answer, and pull request CI has to run the coordinator profile.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ence host

The proof workflow calls the bundle's register-business through the products' relay with the function host key and finishes with the function's answer. The runner requires exactly one Coordinator outcome line, and pull request CI now runs the coordinator profile.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…h read

The reference host now runs register-business's default export like rstack dev, so the comments saying it imports only prepare were false and the named export had no reader.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
… the function's status

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
@jeremi jeremi added this to the v0.53.0 milestone Dec 5, 2026
jeremi added 14 commits December 5, 2026 16:09
…unction runs

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
… from the checked bytes

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…e checked bytes

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ay's function header policy

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ack dev relays

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…age and static files

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ck dev does

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…dot segments and links

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…pare key digests

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…in the intended differences

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…o run the reference host job

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
… contract changes

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
jeremi added 29 commits December 5, 2026 16:57
… proof fails

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…efuse a link swapped in after start

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ty and check the path a function asks for

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…dev, and pin its transport headers

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…as the rstack dev gateway does

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…LLOW comment, and list the oversized Coordinator difference

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ition

Each composition now names its runner, the files in that runner's order,
the relay's checked configuration and each member's exact read-only mounts.
The test reads every member's own network mode, requires the relay to join
no network and to run its checked configuration, and evaluates each runner's
own compose_files block to compare the order. Bad fixtures show each check
refusing what it guards, including relay configurations that route through
a second filter chain, filter, endpoint or listener address, which the route
helper still accepts today.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The route helper read only the first filter chain, filter and endpoint of
each loopback listener. It now walks every listener address, filter chain
including the default one, TCP proxy or HTTP route, weighted cluster and
endpoint, and refuses a filter, route or cluster shape it cannot read.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A change to one of the three candidate host Compose overlays alone selects
only the release tool job, so the reference host job that renders every
composition with Compose required never runs.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…nges

The function host network test renders the three candidate host overlays
with Compose required, so a change to any of them alone now runs it.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The order check runs each runner's compose_files block with no PATH, so a
program named in that block fails the check instead of running on the
test machine. Only the Compose render needs Node.js absent from its checks.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The deployment job also runs the function host network test, so a change to
a candidate host overlay alone should run it there too.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The deployment job runs every recipe test, the function host network test
among them, which renders the candidate host overlays.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Three overlays merged after the breg composition and rendered by Compose:
the relay's network mode reset onto the default network, the relay on a
network of its own, and the host mounting the parent of the relay sockets.
The namespace and mount checks refuse each one.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…nfig

The route check reads a relay's static listeners and clusters, so a config
that adds dynamic resources or an admin listener would get past it. The test
now reads the base relay config and runs each runner's generator for the
configs it writes. Every config the compositions mount must hold only
static_resources. Fixtures with dynamic listeners, an admin listener, or
dynamic clusters in flow style fail the check.

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ever case or loader names a bundle file

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ves it, and compare bundle paths after links and letter case

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…r a redirect whose body fails

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…d shape the page answer inside the same error boundary

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…e host serves

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…, so its call cannot race the host's start

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…js or npm when a client package is named

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
… package is named, as the network test fails without Compose

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…e, since Node 24.11 names a function's CommonJS loader without its query

Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the heavy integration tier on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant