Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,80 @@
ingested relationship only when it carries the label `_Ingested` and a key. A query that listed a node's labels
now sees `_Ingested` among them.

4. **The agent tools' address check and globs follow one rule in both packs, and a pattern is matched in bounded time
(the code-quality round of 2026-11-29, in lockstep with the Node.js pack).**
- *Addresses.* The web tools asked the `ipaddress` module which addresses are private, and its lists differ from
one Python version to the next; the Node.js twin kept a shorter list of its own and read an IPv4-mapped IPv6
address written in hex as public. Both packs carry one table now, the same text. An IPv4 address is refused
inside the special-purpose blocks that are not globally reachable and the shared address space
(`100.64.0.0/10`, new here). An IPv6 address is reached only inside the global unicast block `2000::/3`,
outside `2001::/23`, `2001:db8::/32`, `2002::/16` and `3fff::/20`: every other IPv6 address is refused, an
IPv4-mapped one in any spelling among them.
- *Globs.* `file.list` and `file.search` used `Path.glob`, whose reading of `**` changed between Python 3.12 and
3.13, and the twin returned nothing for a pattern that ends in `**`. Both packs compile a glob by one grammar
and walk the workspace themselves: `**` is any run of folders and, at the end of a pattern, everything beneath;
a slash at the end names folders only; a symbolic link is an entry and is never descended into; `..` and an
absolute pattern are a 400 by name. A name is matched item by item, so the time is bounded by the pattern's
length times the name's however many stars the pattern has, and the walk enters only the folders a pattern can
still match beneath. The host patterns of `tools.web.allow` are matched by the same function.
- *Smaller differences.* `file.list` skips a symbolic link whose target is gone; `file.write` under a file is 400
`<path> is not a directory`; an address on a page that cannot be read stays as written and its link is skipped,
and a redirect to one is a 400, where each was a 500; a link's scheme is read in any letter case; `file.search`
counts lines by the line feed; `pages` takes the digits 0 to 9 only; an allowlist entry that starts with a
class (`[ab].example.com`) is a pattern.

**Upgrade note:** the agent tools are in no release yet. For an application that runs them from `main`: an address
in `100.64.0.0/10` and an IPv4-mapped address are refused unless `tools.web.allow.private=true`, and a glob no
longer reaches beneath a symbolic link to a folder.

5. **The LLM helper reads a number, a duration and a page list by one rule in both packs, and a wrong
`llm.transcript.audit.grace` or `llm.transcript.audit.retention` stops the start.** A number in a request or a
setting was read by each pack's own reader: digits of any script were taken here (`"٣"` was 3, and `"²"` raised
while the request was prepared, a 500 where the contract says 400) and the JSON float `16000.0` was refused,
while the Node.js twin, which cannot tell it from `16000`, accepted it. One rule now: a JSON number with a whole
value, or a string of the digits 0 to 9, with white space ignored around it, at most 9007199254740991; a duration
and a page list follow it, and the refusals keep their messages. The audit's grace and retention were read inside
the save of a loop's closing turn - a 503 after the model had been called, the turn unsaved; they are read when
the helper starts, and a wrong value stops the start by name as the other settings do. The shared vectors gain a
`numbers` section of 98 probes. **Upgrade note:** a request that sends a whole number as a float is accepted; one
that sends digits of another script, or a number above 9007199254740991, is a 400.

6. **ask-person and agent-question: one rule for a well-formed ticket, and one for a row id and a stream's cursor.**
The packs answered a mangled ticket differently, and this one verified a part that ended in a newline. A ticket
is well-formed when it has its three parts, the payload and the signature are canonical unpadded base64url from
start to end, and the signature is the 32 bytes of the MAC: anything else is 400 `Ticket is malformed`, and a
well-formed ticket whose MAC does not verify is 403 `Ticket signature is invalid`. A second spelling of a valid
ticket - one that differs only in the unused bits of a last character - was accepted by both packs and is a 400.
In agent-question a row id and `Last-Event-ID` went through `int()` (`" 7 "`, `-3`, `+7` and `1_0` passed); both
packs read 1 to 19 digits from start to end, at most 9223372036854775807, and answer the 400 that was there for
anything else. The shared vectors are `ask-person-vectors.json` version 3 (146 cases) and
`agent-question-vectors.json` version 4 (111 cases). **Upgrade note:** none for a ticket the pack issued or an id
it returned.

7. **REST automation and the host: an entry's flags as the Java engine reads them, the upload bound in bytes, and
the engines' error body where the web framework answered its own.**
- A flag of an entry (`tracing`, `stream`, `upload`) was on only for the YAML boolean, so `tracing: "true"` and
`tracing: ${TRACING:true}` stayed off without a word. The boolean or the text `true` in any letter case turns
it on, as in the Java engine; `false`, no value and an empty one leave it off; any other value, which the
engine reads as off silently, fails the start: `rest[N] 'tracing' must be true or false`.
- The upload bound counted a text field by the length of its text; it counts the bytes of every part as they
arrive.
- A keep-alive comment is written only when a keep-alive interval has passed, so a stream that is not
Server-Sent Events never carries one and `event.stream.keep.alive: 0` writes none.
- A reply the serializer refuses is 500 `Reply cannot be rendered` in the engines' error body, with the edge's
`http.request` record, and a streamed segment fails the stream in band; it was the web framework's own page,
with no record.
- A body over the 16 MiB the host reads into memory is 413 `Request body exceeds 16777216 bytes` in the engines'
error body, and an envelope on `POST /api/event` without REST automation; it was the web framework's
`text/plain` page.
- A part of an upload that is multipart itself is 400
`Upload takes text fields and files, not a nested multipart part`; it failed the upload or was dropped, by its
place in the body.

**Upgrade note:** an entry whose flag is written as anything but `true` or `false` stops the start - write `true`
or `false`. A text field of an upload counts toward `rest.upload.max.bytes` by its bytes, so a long field in
another script counts for more than before.

13. **REST automation: `rest.yaml` as the router of a Python application (RFC-0018 in mercury-composable, build
plan step 1).** With `rest.automation: true` the host reads one `yaml.rest.automation` location (default
`classpath:/rest.yaml`, the `resources/rest.yaml` next to the application file; `file:` an absolute path) in the
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ binding (`flow:` or `service: http.flow.adapter` — flows run in the engines),
form of the engines' streaming upload: the files of a `multipart/form-data` body arrive in the request
map under the engines' keys (`filename`, `file_type`, `file_length`, the `upload` tags, `size`) with
their bytes in `contents`, read with `AsyncHttpRequest.files()`, all together within
`rest.upload.max.bytes` (16 MiB; 413 beyond it); the form's text fields become query parameters.
`rest.upload.max.bytes` (16 MiB; 413 beyond it); the form's text fields become query parameters and
count, in bytes, toward the same bound.
Deferred as in the Rust engine: `custom.content.types`, `mime.types`, XML and request-body
streaming. With the switch off, the default, the host is exactly what it was.

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ keywords: [configuration, reference, keys, substitution, overrides]
| `optional.health.dependencies` | health check routes reported but never affecting status | (empty) |
| `rest.automation` | REST automation on: the entries of `rest.yaml` served in front of the functions ([guide](rest-automation.md)) | `false` |
| `yaml.rest.automation` | the one location of `rest.yaml`: `classpath:` the resources folder, `file:` an absolute path, a relative path under the application file's folder | `classpath:/rest.yaml` |
| `rest.upload.max.bytes` | the bound on the files of one upload entry, together (413 beyond it) | `16777216` |
| `rest.upload.max.bytes` | the bound on one upload: its files and its text fields together, counted in bytes (413 beyond it) | `16777216` |
| `http.trace.id.header` | the trace-id header a traced entry reads when no W3C `traceparent` arrives (`trace.id.header` overrides it per entry) | `X-Trace-Id` |
| `http.correlation.id.header` | the business correlation-id header, always ensured and echoed (`correlation.id.header` per entry) | `X-Correlation-Id` |
| `http.traceparent.header` | a custom name for the W3C `traceparent` header, read only when the standard one is absent (`traceparent.header` per entry) | `traceparent` |
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/http-surface-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Mirrors the engines' `event.api.service`:
| `x-async: true` | drop-n-forget → HTTP 202 with ack envelope `{type: async, delivered: true, time}` |
| Reply | always envelope bytes, `content-type: application/octet-stream` |
| Handler outcome | rides **HTTP 200** with the status inside the envelope (including AppException and unexpected errors) |
| Transport failures | set the HTTP status too: 400 undecodable / missing route field, 403 private target, 404 unknown route (`Route X not found`), 408 timeout (`Timeout for N ms`) |
| Transport failures | set the HTTP status too: 400 undecodable / missing route field, 403 private target, 404 unknown route (`Route X not found`), 408 timeout (`Timeout for N ms`), 413 a body over the 16 MiB the host reads into memory (`Request body exceeds 16777216 bytes`) |
| Header hygiene | inbound `x-event-api` and `my_*` removed; the `my_cid` tag becomes the read-only `my_correlation_id` header (local bus deliveries inject the same view). Outbound, the client stamps the current context's business correlation-id back onto the event as the `my_cid` tag — the engines' PostOffice parity, so the business correlation-id continues across every hop |
| `accept: text/event-stream` | streaming-capable call to an interceptor target: a streamed reply rides the same call as SSE in the envelope-mode dialect; a single-shot reply stays byte-identical; a streaming reply to a NON-accepting caller → 406 `Streaming function requires a caller that accepts text/event-stream`. See [Event Streaming](streaming.md) |

Expand Down Expand Up @@ -57,10 +57,10 @@ first, in the engines' grammar; `POST /api/event` and the actuators are the defa
| Matching | the engines' precedence — the most specific route wins, `{param}` and a trailing `*`; a known path under another method → 405 `Method not allowed`; an unknown path → 404 `Resource not found`; `OPTIONS` → 204 with the entry's CORS `options` lines, 405 without a CORS block |
| Request to the function | the whole request as the `AsyncHttpRequest` map — method, url, headers (lowercased, after the request transform), path and query parameters (a form's fields among them), the body parsed by its content type (JSON → map or list, text types → text, else bytes), cookies, the `session` map an authentication function left; `x-ttl` carries the entry's timeout in ms |
| Reply | a returned value is the body; a returned `EventEnvelope` sets the status and headers (`set-cookie` values split on `\|`); the content type is the function's or negotiated from `Accept` (`text/html` wraps a map in the HTML shell; no `Accept` → no content type); a map or list is pretty-printed JSON with `null` entries omitted |
| Errors | the engines' body below with `content-type: application/json`: an `AppException` from the function or the authentication function (anything but `true` from the latter → 401 `Unauthorized`); 408 `Timeout for N ms` at the entry's timeout (1 s–5 min, 30 s default; an inbound `x-ttl` wins); 503 `Service X not reachable` for an unregistered function; 413 `Upload exceeds N bytes` |
| Errors | the engines' body below with `content-type: application/json`: an `AppException` from the function or the authentication function (anything but `true` from the latter → 401 `Unauthorized`); 408 `Timeout for N ms` at the entry's timeout (1 s–5 min, 30 s default; an inbound `x-ttl` wins); 503 `Service X not reachable` for an unregistered function; 413 `Upload exceeds N bytes`; 413 `Request body exceeds 16777216 bytes` for a body over the 16 MiB the host reads into memory; 500 `Reply cannot be rendered` for a reply the serializer refuses |
| Correlation and tracing | `X-Correlation-Id` (or `http.correlation.id.header`) always ensured and echoed, delivered as `my_correlation_id`; with `tracing: true` a W3C `traceparent`, else `X-Trace-Id` (`http.trace.id.header`), else a fresh id, and the `http.request` record plus the function's round-trip record |
| `stream: true` | an interceptor's segments rendered progressively: Server-Sent Events (`event:`/`data:` frames, `event: done` at the end, `event: error` in band, `: ping` keep-alives every `event.stream.keep.alive`) for a `text/event-stream` head or `Accept`, chunked text or JSON lines otherwise; the entry's timeout is the idle allowance, the head's `x-ttl` overrides it; a keep-alive that cannot be written ends the stream |
| `upload: true` | a `POST` entry's `multipart/form-data` files in the request map (`filename`, `file_type`, `file_length`, `upload`, `size`, bytes in `contents`), the form's text fields as query parameters, no body; all files together within `rest.upload.max.bytes` (16 MiB) |
| `stream: true` | an interceptor's segments rendered progressively: Server-Sent Events (`event:`/`data:` frames, `event: done` at the end, `event: error` in band, `: ping` keep-alives every `event.stream.keep.alive`) for a `text/event-stream` head or `Accept`, chunked text or JSON lines otherwise; the entry's timeout is the idle allowance, the head's `x-ttl` overrides it; a keep-alive that cannot be written ends the stream; a segment the serializer refuses fails it in band with 500 `Reply cannot be rendered` |
| `upload: true` | a `POST` entry's `multipart/form-data` files in the request map (`filename`, `file_type`, `file_length`, `upload`, `size`, bytes in `contents`), the form's text fields as query parameters, no body; the files and the text fields together, counted in bytes, within `rest.upload.max.bytes` (16 MiB); a part that is multipart itself → 400 `Upload takes text fields and files, not a nested multipart part` |
| Precedence | a `rest.yaml` entry, then an extension's mounted routes (`Platform.add_routes`), then the static folder (under the `static-content` block's `no-cache-pages` and `filter`), then the error signature below |

## Static content
Expand Down
29 changes: 20 additions & 9 deletions docs/guides/rest-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ headers:
- "Cache-Control: no-cache, no-store"
```

`${key:default}` in any value resolves against the configuration, as in the engines. At the end
`${key:default}` in any value resolves against the configuration, as in the engines. A flag —
`tracing`, `stream`, `upload` — is `true` or `false`, read as the Java engine reads it: the
boolean, or the text in any letter case, which is what a reference such as `${TRACING:true}`
resolves to. Left out or empty it is off; any other value fails the start by name
(`rest[0] 'tracing' must be true or false`) rather than leave the flag off without a word. At the end
of the boot the host announces every live entry — `REST [GET] /api/hello/{name} -> hello.rest` —
and skips, with a warning, an entry whose function is not registered: never a live URL without a
function behind it.
Expand Down Expand Up @@ -148,8 +152,10 @@ unchanged — a flow binding apart — and behaves the same:
- **Headers** — the entry's `headers` block drops, keeps or adds request and response headers
(`keep` takes precedence over `drop`, the Java rule); its `cors` block's `headers` lines ride
every response.
- **Errors** — 404 `Resource not found`, 405 `Method not allowed`, 401 `Unauthorized`, 408 and
503 `Service X not reachable`, all in the engines' body and `content-type: application/json`.
- **Errors** — 404 `Resource not found`, 405 `Method not allowed`, 401 `Unauthorized`, 408,
503 `Service X not reachable`, 413 `Request body exceeds 16777216 bytes` for a body over the
16 MiB the host reads into memory, and 500 `Reply cannot be rendered` for a reply the serializer
refuses (the log names the reason), all in the engines' body and `content-type: application/json`.

## Authentication

Expand Down Expand Up @@ -216,9 +222,12 @@ async def lines_stream(_headers: dict[str, str], event: EventEnvelope):
```

The entry's `timeout` is the **idle allowance** between segments, not a total bound; the head may
override it with `first(status, content_type, ttl_seconds)`. While the producer is quiet the edge
writes a keep-alive comment every `event.stream.keep.alive` (30 s), and a keep-alive that cannot be
written ends the stream and closes its reply sink. A long-lived producer — a device's feed that is
override it with `first(status, content_type, ttl_seconds)`. While the producer of a Server-Sent
Events stream is quiet the edge writes a keep-alive comment every `event.stream.keep.alive` (30 s)
— a chunked stream has no comment line and gets none — and a keep-alive that cannot be written
ends the stream and closes its reply sink. A segment the serializer refuses fails the stream in
band, as the producer's own failure does: 500 `Reply cannot be rendered`, in the `error` frame under
Server-Sent Events. A long-lived producer — a device's feed that is
quiet for as long as nothing changes — opens the stream at once with a bare first segment
(`out.write(None)` commits the head and writes no frame), follows its source from a task of its
own so the function's workers are never held, and stops when `out.connected` turns false. The
Expand All @@ -239,9 +248,11 @@ rest:
files of a `multipart/form-data` body arrive in the request map under the engines' keys
(`filename`, `file_type`, `file_length`, the `upload` tags, `size`) with their bytes in `contents`,
read with `request.files()` as `UploadedFile(name, content_type, size, tag, content)`; the form's
text fields become query parameters and the body stays absent, as in the Java engine. All the files
of one upload together may not exceed `rest.upload.max.bytes` (16 MiB by default) — 413
`Upload exceeds N bytes` the moment they do, before anything is delivered; a malformed body is 400.
text fields become query parameters and the body stays absent, as in the Java engine. The files and
the text fields of one upload together, counted in bytes, may not exceed `rest.upload.max.bytes`
(16 MiB by default) — 413 `Upload exceeds N bytes` the moment they do, before anything is
delivered. A malformed body is 400, and so is a part that is multipart itself:
`Upload takes text fields and files, not a nested multipart part`.
A non-multipart body on such an entry, and a multipart body on an entry without the flag, dispatch
as any other body. The LLM helper's `llm.upload` — documents saved into the attachments root for a
model to read — is the shipped example.
Expand Down
Loading
Loading