Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
64fba2a
Merge 684-etat-du-pont into 686-documentation-inspecteurs (#686)
ambroise-leclerc Nov 27, 2026
cf63ae3
Inspectors guide: access and containers per frontend, enabling them w…
ambroise-leclerc Nov 27, 2026
576b607
Tell agents that a callback that acts checks ui.isLocalClient(), and …
ambroise-leclerc Nov 27, 2026
eb225cc
Project status and changelog: the inspectors, their limitations and t…
ambroise-leclerc Nov 27, 2026
af24836
Changelog: keep the Breaking entry of the guard within the entry limi…
ambroise-leclerc Nov 27, 2026
5333e29
Agents: the state grant needs bootstrap("developer") before enableAut…
ambroise-leclerc Nov 27, 2026
a7ea1aa
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
078face
Merge 682-observateurs into 686-documentation-inspecteurs (#686)
ambroise-leclerc Nov 27, 2026
575fbb9
Merge 684-etat-du-pont into 686-documentation-inspecteurs (#686)
ambroise-leclerc Nov 27, 2026
c15b5a1
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
3ec66bd
Merge origin/develop into 686-documentation-inspecteurs (#686)
ambroise-leclerc Nov 27, 2026
a1b8b3c
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
efb3746
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
9bce7b2
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
96db983
Merge 685-outils-mcp-inspecteur into 686-documentation-inspecteurs (#…
ambroise-leclerc Nov 27, 2026
25f2f1e
Merge origin/develop into 686-documentation-inspecteurs (#686)
ambroise-leclerc Nov 28, 2026
c222b0c
Inspectors guide: the Bridge panel detaches like the others, and C++ …
ambroise-leclerc Nov 28, 2026
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The HTTP server connections and the WebSocket read/write loops are coroutines (`

Filesystems implement `open(std::filesystem::path) -> std::optional<fs::File>` and are composed with `fs::Multi<>`; the first provider returning a file wins. `NativeDebugFS` is development-only and must not be presented as a production sandbox.

Bridge calls are asynchronous, and the two directions differ. `webFront.cppFunction(name)(...)` always returns a JavaScript Promise (also for `void` callbacks), so tests and examples must await or handle it. On the C++ side, only the untyped `ui.jsFunction(name)(...)` is fire-and-forget; `ui.jsFunction<R>(name)(...)` returns a `std::future<R>`. `ui.jsFunctionSender<R>(name)(...)` owns encoded arguments and dispatches at sender start; co_await propagates the receiver stop token. Cancellation completes stopped locally and discards a late reply; JavaScript continues running. See `docs/ASYNC_EXECUTION.md` for lifetime and completion-thread rules. On missing functions, callback exceptions, malformed returns, and disconnects, a C++ future completes exceptionally (`get()` throws) and a JavaScript Promise rejects. Result types are limited to the bridge's scalar, string, tuple, numeric typed-array, packed `std::bitset<N>` and list types. A list is a `std::vector` of strings, tuples, typed arrays or bitsets (JavaScript: `webFront.list(items)` of strings, typed arrays or tuples, received as an `Array`; numbers go as typed arrays; a plain short array is a tuple that a `std::vector` destination also accepts); elements are homogeneous and lists do not nest. Bitsets use `Uint8Array` with exactly `ceil(N / 8)` bytes, least-significant bit first in each byte, and zero high padding bits; decoding rejects wrong types, sizes and padding. JavaScript must know the logical bit count from the application contract. Strings of 65,536 bytes or more use the `longString` code (32-bit length), chosen by the encoder; the only bound is the buffers policy's `maxMessageSize` (64 MiB by default, JavaScript's `maxMessageBytes`): beyond it C++ throws `std::length_error` when it encodes, which rejects the Promise when it is a callback's result, and JavaScript throws a `RangeError` before sending. A `cppFunction` callback may return a sender (a `webfront::ResultTask<R>` coroutine): the Promise settles when it completes, the browser's disconnection stops it and drops its answer, and shutdown joins it. Callback signatures are deduced for ordinary lambdas, function pointers, and `std::function`; generic lambdas and overloaded call operators need explicit `cppFunction<R, Args...>`. Do not write tests or documentation that present JavaScript calls as fire-and-forget, imply an untyped C++ call returns a value, or suggest that richer objects cross the bridge (only the types above do). Registered callback objects must outlive their registration through owned storage; never capture a forwarding-reference parameter by reference in a stored handler.
Bridge calls are asynchronous, and the two directions differ. `webFront.cppFunction(name)(...)` always returns a JavaScript Promise (also for `void` callbacks), so tests and examples must await or handle it. On the C++ side, only the untyped `ui.jsFunction(name)(...)` is fire-and-forget; `ui.jsFunction<R>(name)(...)` returns a `std::future<R>`. `ui.jsFunctionSender<R>(name)(...)` owns encoded arguments and dispatches at sender start; co_await propagates the receiver stop token. Cancellation completes stopped locally and discards a late reply; JavaScript continues running. See `docs/ASYNC_EXECUTION.md` for lifetime and completion-thread rules. On missing functions, callback exceptions, malformed returns, and disconnects, a C++ future completes exceptionally (`get()` throws) and a JavaScript Promise rejects. Result types are limited to the bridge's scalar, string, tuple, numeric typed-array, packed `std::bitset<N>` and list types. A list is a `std::vector` of strings, tuples, typed arrays or bitsets (JavaScript: `webFront.list(items)` of strings, typed arrays or tuples, received as an `Array`; numbers go as typed arrays; a plain short array is a tuple that a `std::vector` destination also accepts); elements are homogeneous and lists do not nest. Bitsets use `Uint8Array` with exactly `ceil(N / 8)` bytes, least-significant bit first in each byte, and zero high padding bits; decoding rejects wrong types, sizes and padding. JavaScript must know the logical bit count from the application contract. Strings of 65,536 bytes or more use the `longString` code (32-bit length), chosen by the encoder; the only bound is the buffers policy's `maxMessageSize` (64 MiB by default, JavaScript's `maxMessageBytes`): beyond it C++ throws `std::length_error` when it encodes, which rejects the Promise when it is a callback's result, and JavaScript throws a `RangeError` before sending. A `cppFunction` callback may return a sender (a `webfront::ResultTask<R>` coroutine): the Promise settles when it completes, the browser's disconnection stops it and drops its answer, and shutdown joins it. Callback signatures are deduced for ordinary lambdas, function pointers, and `std::function`; generic lambdas and overloaded call operators need explicit `cppFunction<R, Args...>`. Do not write tests or documentation that present JavaScript calls as fire-and-forget, imply an untyped C++ call returns a value, or suggest that richer objects cross the bridge (only the types above do). Registered callback objects must outlive their registration through owned storage; never capture a forwarding-reference parameter by reference in a stored handler. Names starting with `webfront.inspector.` are reserved to the inspectors (ADR-027). WebFront guards only its own reserved functions: an example or test callback that writes the project or what the server serves, starts a process or exposes a sensitive state takes the calling `UI` and checks `ui.isLocalClient()`, and documentation must not present the application's callbacks as guarded by WebFront.

The embedded `WebFront.js` wire format and C++ `Messages.hpp` implementation must evolve together. Any protocol change requires encoding/decoding unit tests and a real-browser regression test.

Expand Down
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ these entries stays in the GitHub releases and the Git history.
### Breaking
- A custom frontend whose `open()` takes `const ViewLaunch&` declares `static bool providesViewProof()`, `true` when it gives the proof to its view and `false` otherwise, or the developer environment no longer compiles with it: undeclared, its proven view would leave project writes and C++ commands unguarded (#680, ADR-027, `docs/FRONTENDS.md`).
- `cppFunction` (and `Space::cppFunction`) refuses the names starting with `webfront.inspector.`, reserved to the inspectors, with `std::invalid_argument`: rename such a function, and its `webFront.cppFunction(...)` calls in the page, to a name of your own (#680, ADR-027).
- An external tool that writes the project (`webfront.developer.*` writes) or starts terminal commands (`webfront.commands.start`, `cancel`) through the bridge is refused with `webfront.inspector.denied` when the frontend proves its view: run it in that view, use MCP automation, or set `trustLoopbackClients` knowingly (#680, ADR-027, `docs/DEVELOPER_ENVIRONMENT.md`).

### Added
- Open the inspectors from the WebFront tab's menu of the developer environment: each panel shows in a floating window of the page and can be detached to a native secondary window (WebKitGTK, WKWebView, WebView2) or, with `trustLoopbackClients`, a tab of the system browser; the choice and the place are kept per project (#680, ADR-027, `docs/DEVELOPER_ENVIRONMENT.md`).
Expand Down Expand Up @@ -41,7 +42,8 @@ these entries stays in the GitHub releases and the Git history.

### Changed
- Destroying the handle of a watch (`inspect::Watch`) waits for an operation of the inspectors in progress on another thread: destroy it outside every lock its source takes, or declare the watch with the state it owns (#682, ADR-027, `docs/WATCHES.md`).
- The inspectors show where each `cppFunction` was registered; existing calls of `cppFunction` and `Space::cppFunction` compile unchanged (#681, ADR-027).
- `cppFunction` and `Space::cppFunction` take a last, defaulted `std::source_location`, which the inspectors show; existing calls compile unchanged, the explicit `cppFunction<R, Args...>` form included (#681, ADR-027).
- Document the security contract of the application's callbacks: one that writes the project or what the server serves, starts a process or exposes a sensitive state takes the calling `UI` and checks `ui.isLocalClient()`, since WebFront guards only its own functions (#686, ADR-027, `docs/DEVELOPING_WITH_AGENTS.md`).
- `WebFront.js` opens its WebSocket on the directory of the page (`ws://host/dir/` instead of `ws://host`), which tells the server a page's space (#671) and lets an application be deployed under a sub-path of a site (#672).
- A request whose path holds a control character (`%00`...) is refused with 400, as a `..` already was, instead of being looked up as a file (#672).
- A `+` in the path of a file request is a literal `+`, as for the routes, the spaces and `ui.path()`: `/a+b.html` serves `a+b.html`, no longer `a b.html`, which `/a%20b.html` names (#672).
Expand Down
67 changes: 60 additions & 7 deletions docs/DEVELOPER_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,30 @@ environment's `mount`, not to the embedded bootstrap page):
with the mouse or with the arrow keys on its title bar), whose frame opens no connection of its own and borrows the page's
bridge, since the adapters give the proof of the view to the main frame only. **Detach** moves the panel to a window of its
own, and the next opening of that panel goes there again; **Attach**, in that window, brings it back to the floating
window, where it then opens:
window, where it then opens. The containers follow the access each frontend actually gives, never its name alone:

| Frontend of the page | Detached container |
| --- | --- |
| WebKitGTK, WKWebView, WebView2 | a native secondary window (`webfront.inspector.openWindow`, `openSecondaryWindow`), which carries the proof of the view; opening the panel again brings it to the front, and closing the main window closes it |
| System browser with `trustLoopbackClients` | a tab of the system browser (`window.open`), with its own loopback connection; when the pop-up blocker refuses it, the panel stays in the floating window and a message offers to try again; the tab closes when the page that opened it is gone |
| CEF, or an embedded view without secondary windows | none: Detach is greyed, with the reason in its tooltip (`window.open` there would open a frame without the proof) |
| Frontend of the page | Inspectors | Panel opens in | Detached container |
| --- | --- | --- | --- |
| WebKitGTK, WKWebView, WebView2 | admitted: the view proves itself | the floating window | a native secondary window (`webfront.inspector.openWindow`, `openSecondaryWindow`), which carries the proof of the view; opening the panel again brings it to the front, and closing the main window closes it |
| CEF | admitted: the view proves itself | the floating window | none: CEF opens no secondary window, and `window.open` there would open a frame without the proof; Detach is greyed, with the reason in its tooltip |
| System browser (default of `webfront::WebFront`) | **refused by default**: the entries are greyed and say how to enable them | none | none |
| System browser with `trustLoopbackClients` | admitted: any loopback page | the floating window | a tab of the system browser (`window.open`), with its own loopback connection; when the pop-up blocker refuses it, the panel stays in the floating window and a message offers to try again; the tab closes when the page that opened it is gone |

`NativeOrBrowserFrontend` behaves as its native engine while it opens a native window, and as the system browser once it
falls back to it. A custom frontend gives the proof only if it implements the `open(..., const ViewLaunch&)` overload and
declares `providesViewProof()` ([frontends](FRONTENDS.md#view-association)).

**Enabling the inspectors with the system browser.** Prefer an embedded frontend (`webfront::NativeApp`, or
`WebFrontWithFrontend<...>`): its view proves itself and nothing else is admitted. Otherwise, set `trustLoopbackClients`
in a development build only, on a machine with one user and no local proxy or tunnel:

```cpp
webfront::BasicDeveloperApp<> app{"my-project", {.trustLoopbackClients = true}}; // system browser
app.bootstrap("developer");
```

Every loopback connection is then a local client: it reads the inspectors, and it also passes the `ui.isLocalClient()`
check of the application's own callbacks (below). The option is the application's choice; the environment never sets it.

Attach brings the panel back to the page that detached it only, even when other pages of the application are open on
the same origin. A page keeps its identifier across a reload through Web Locks; in a browser without them, a reloaded
Expand Down Expand Up @@ -522,7 +539,10 @@ environment's `mount`, not to the embedded bootstrap page):
The inspectors' own calls are not shown. Attached, the panel reads the page directly; detached, its window does not
see the page, so the page publishes the same state to C++ every 250 ms while the panel reads, and stops within
fifteen seconds of its last read (`webfront.inspector.bridgeSource`, `publishBridge` and `bridge`, admitted pages
only).
only). The panel detaches like the others, to a native secondary window with WebKitGTK, WKWebView and WebView2. C++
knows 256 connected pages at most, and keeps the published state of 16 of them: beyond 256 connected pages, a page's
announcement is refused with `webfront.inspector.unavailable`, and its detached panel says that the page is not
connected.

The tab is a button (`aria-expanded`, `aria-haspopup="menu"`, 44 px target), its menu a `menu` of `menuitem`s of 44 px,
and the window a non-modal dialog. The interface stays in the preview
Expand All @@ -532,6 +552,39 @@ or the tab first). This is a layout, not a
sandbox (see [limitations](#dependencies-storage-and-limitations)). A page that mounts the terminal itself (`runtime.mount`) with a preview frame gets
the same layout; `workspace: false` keeps the page as it is.

### The inspectors and the application's callbacks

The inspectors exist only in the developer environment: `bootstrap("developer")` registers the reserved
`webfront.inspector.*` functions, an application without it has none, and a distribution build
(`WEBFRONT_DISTRIBUTION=ON`) compiles none of them; `app.watch` then returns an empty handle. They read what the application
shows them and write only the [watched values](WATCHES.md#writing-a-value) that the application made writable. They are
not a sandbox: an admitted page shares the authority of the bridge.

When the frontend proves its view, WebFront guards its own entry points that change what the view runs or what the server
serves: the project writes (`webfront.developer.begin`, `beginNew`, `write`, `commit`, `commitGroup`, `abort`) and
starting or cancelling a terminal command (`webfront.commands.start`, `cancel`) require an admitted page, like the
inspectors, and are refused with `webfront.inspector.denied` otherwise. The reads of the project and
`webfront.commands.list` keep the origin check. With the system browser no view is proven, so these operations stay open
to every connection that the [content policy](CONTENT_POLICY.md) admits.

**The callbacks of the application are its own contract** (ADR-027, section 2). WebFront does not know what a
`cppFunction` does and does not guard it. A callback that writes the project or what the server serves, starts a process,
or exposes a state the application would not show to an unproven client takes the calling `UI` as its first parameter and
checks it before acting:

```cpp
app.cppFunction("app.saveScript", [&](webfront::NativeApp::UI ui, std::string text) {
if (!ui.isLocalClient()) // not the application's view, nor a trusted loopback page
throw std::runtime_error("app.saveScript requires the application's view"); // the Promise rejects
saveScript(text);
});
```

Without that check, such a callback opens again the door the guard above closes: a local process could call it, then let
the proven view load what it wrote. The **Caller** column of the Functions panel shows which callbacks receive the `UI`,
and so can make the check. An agent reads the same state through MCP, with the `state` grant, and never writes it
([Developing with an agent](DEVELOPING_WITH_AGENTS.md#reading-the-running-application-webfrontstate)).

## The terminal and the application's commands

The terminal of the environment (developer distribution 0.5.0, #308) is the only WebFront terminal; it is served
Expand Down
23 changes: 23 additions & 0 deletions docs/DEVELOPING_WITH_AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ not how the interface is shipped. An application that serves a document root wit
line on stderr at its first `show()` saying so. Only [scalars, strings, tuples, typed arrays, bitsets and lists](../README.md#contracts-and-limitations)
cross the bridge.

### A callback that acts checks its caller

WebFront guards its own functions, not the application's: it does not know what a `cppFunction` does. **A callback that
writes the project or what the server serves, starts a process, or exposes a state the application would not show to any
client takes the calling `UI` as its first parameter and checks `ui.isLocalClient()` before acting** (ADR-027, section 2).
`isLocalClient()` is true for the view of an embedded frontend, which proves itself, and for a loopback page only when the
application sets `trustLoopbackClients`.

```cpp
app.cppFunction("app.saveScript", [&](webfront::NativeApp::UI ui, std::string text) {
if (!ui.isLocalClient())
throw std::runtime_error("app.saveScript requires the application's view"); // the Promise rejects
saveScript(text);
});
```

The calling `UI` is not a parameter on the JavaScript side: the page still calls `webFront.cppFunction('app.saveScript')(text)`.
A callback that only computes and returns a value needs no check. Without it, a callback that acts can be called by a
local process that forges the page's origin (the origin check alone cannot tell it from the page), then the proven view
may load what it wrote. The Functions panel of the
[inspectors](DEVELOPER_ENVIRONMENT.md#the-inspectors-and-the-applications-callbacks) shows which callbacks receive the
caller.

## The development loop

`wf create <starter>` takes the name of a **starter**, not the name of your project: `app` is a minimal TypeScript
Expand Down
Loading
Loading