84 — The app frame: a front end that is not the host's
BuiltRendered from 84-the-app-frame.md in the public repository. Edits belong there.
The shell draws a panel with the renderer registered for its container. A host's own renderers load into the shell's page as a ShellExtension and can do anything the page can: read the signed-in person's data, call every route, change any part of the page. That is right for code the host wrote. It is wrong for a front end anyone else wrote.
Such a front end is a framed extension (micyte/ui/app_frame.py). The shell draws each container it claims in an app frame and never loads its script into the page.
What the frame is
- An
<iframe sandbox="allow-scripts">. It never hasallow-same-origin, so its origin is opaque. It has no cookie and no storage, and it cannot reach the shell's page or make a request as the person. - A frame document the host serves at
/portal/app-frame/<extension_id>, with its own policy: default-src 'none'andconnect-src 'none': the frame makes no request at all, so an app draws only from what it is handed;- scripts and styles only under a nonce minted for that response;
frame-ancestors 'self', so no other site can frame it;sandbox allow-scripts, so the document is still sandboxed if someone opens its address directly.- Scripts inline, not files. The frame document carries the bridge and the app's script inline. A file would not load: a request the opaque frame makes is cross-site, so it carries no session cookie, and a host behind a sign-in proxy would answer it with the sign-in page. A script containing
</scriptis refused, because it would end its own tag.
The bridge
The frame and the shell talk over postMessage (micyte/ui/static/v2_portal_app_bridge.js). The same file is both halves: the frame inlines it, and the shell loads it as the app_bridge module the first time a framed container is drawn. Each side reads only messages whose event.source is the other. These are the only verbs:
| From | Verb | Carries | What happens |
|---|---|---|---|
| frame | ready | nothing | The shell answers with payload. |
| shell | payload | The panel payload the server built for the tool. | The app's renderer for payload.container draws it into #app. |
| frame | resize | Its height. | The frame is resized, up to 4000 px. |
| frame | open | A path. | The shell moves to that page only if it is one of the shell's own pages: same origin, under /portal/, and not its API, its static files or another app's frame. |
| frame | write | A write route the app declares (notes/save_note) and a body. | The shell makes the request for the app (below). |
| shell | written | ok, the HTTP status and the host's answer. | MyCiteApp.write(...)'s promise settles with it. |
Writing
An app writes within what the instance configured it for (the operator, 2026-11-26: "apps should be able to write, apps are configured for use of; ports ... sandboxes, etc."). The frame still makes no request itself. It asks, and the shell makes the request:
- The app calls
MyCiteApp.write("notes/save_note", {sandbox_id: ..., ...}). - The shell sends it only if the extension declares that route in
writes, to/portal/api/v2/notes/save_note, marked with the headerX-MyCite-App: <extension_id>. Anything else is answered as refused without a request. - The host refuses a marked write unless all four of these hold: - the extension declares the route; - the sandbox is one the instance installed the app's package on (its install records); - the action is declared by one of that package's own tools, the writes the operator was shown before installing it; - the person signed in may make that write themselves (the host's ordinary write gate).
- A marked request reaches only a route that passes the host's write gate. Every other route, and any route added later that has not been judged, refuses it before it runs.
So an app never writes more than the person using it could, nor anywhere the instance did not configure it for. The app's manifest says what it would like; the instance's configuration says what it may. A frame can still carry away what it is handed, or what a write returns, by navigating itself somewhere else, so a payload holds only what the tool declared it reads (ToolRequirement).
A framed extension may not claim a container kind the package or a host declares (build_shell_asset_manifest refuses it). Claiming one would route that kind's payloads, which were built for the page, into the frame. A renderer in the page also wins over a framed claim.
The version file
Every framed app carries one version file, app.json, beside its script (micyte/ui/app_version.py):
{
"schema": "micyte.app.v1",
"app_id": "board_app",
"version": "1.2.0",
"archetypes": {"natural_entity": "<the archetype document's hash>"},
"archetype_library": "<library_digest of the library it was built against>",
"ui_surface": "mycite.v2.portal.runtime.envelope.v1",
"engine": "0.6"
}| Field | What the host does with it |
|---|---|
archetypes | Each archetype the app reads or writes, pinned by the content hash its document's id carries. The app is refused where one differs or is missing. A change to an archetype it never touches does not stop it, because the datum-document resources are what change most often. |
archetype_library | One hash for the whole library (library_digest). A notice that a newer library exists, never a refusal. |
ui_surface | The shell contract the app is made for. It is refused by a host that does not serve that surface. |
engine | The engine's major.minor. Below 1.0 a minor version may break an app, so an app built for 0.6 opens on any 0.6.x and on nothing else. |
A host serves the frame only when the file is readable and nothing it pins differs. Otherwise the frame address answers 409 and names each difference in place of the app.
Writing one
from micyte.ui.app_frame import FramedExtension
board = FramedExtension(
extension_id="board_app", # [a-z][a-z0-9_]*
label="Board",
containers=("board",), # kinds nothing else declares
directory="path/to/board_app",
script="board.js", # beside its app.json
stylesheet="board.css", # optional
package_id="boards", # the package the instance installs it with
writes=("notes/save_note",), # the write routes it uses, if any
)// board.js: runs in the frame, after the bridge.
MyCiteApp.register("board", function (payload, mount) {
mount.textContent = payload.title;
// MyCiteApp.open("/portal/network") asks the shell to move to one of its pages.
// MyCiteApp.write("notes/save_note", {...}).then(function (r) { ... r.ok ... });
});A host lists its framed extensions in one place: create_local_app(..., framed=(board,)) on the local host, and HOST_FRAMED_EXTENSIONS on FND's portal (none yet). A tool that emits a payload with container: "board" is then drawn in the frame.
The shell page's own policy
The shell page goes out with two policies (micyte/ui/policy.py), and every host sends them with the page and with nothing else.
Enforced (Content-Security-Policy, since 2026-11-26). The browser refuses:
- every script that is not one of the page's own files;
- every inline script, inline event handler and
eval; - plugins, and a
<base>pointing elsewhere.
Styles may come from the page's own origin or be inline. The operator decided to enforce this once a client's own pages showed no reports, and they show none: FND's operator surfaces, the local host, and a client's PIM and profile pages through their own door (fnd_app/tests/e2e/test_the_shell_policy_violations_only_fall.py).
A browser run cannot see every handler: an onerror written into a picture's markup runs only when that picture fails to load. So the shell's scripts are also read (micyte/tests/unit/test_the_shell_writes_no_inline_handler.py), and none writes an inline handler, runs a string as script, or links to javascript:. A picture that fails to load is hidden by one listener in v2_portal_shell.js (<img data-hide-broken>).
Reported only (Content-Security-Policy-Report-Only). Everything above, plus what the page may fetch, frame or post to, and Trusted Types, which would refuse a string handed to an HTML sink. The shell still hands HTML strings to innerHTML in many places, so enforcing Trusted Types would blank the page. Frames may come from any https origin.
The page runs no inline script. What the old inline block set on window (the palette's tool seed and whether it may ask for more) is now a JSON block, #v2-portal-menubar, which the palette reads.
The violations test counts what the browser reports, by distinct place:
- Against the shipped policies, on FND's operator surfaces, on the local host and on a client's own pages. The ceiling is zero.
- Against Trusted Types. The ceiling is the number of places the package shell hands a string to an HTML sink.
Both ceilings may fall, never rise. No endpoint collects reports: an unauthenticated POST sink would be a surface of its own.
Adapters are imported only from the build
A third party's package reaches the server through another door too. A port's fill names the class the host imports (PortFill.adapter_id), and a package installed from a fetched catalogue is a source the build did not write. port_adapters.adapter_class refuses any path outside the build's adapter packages (ADAPTER_ROOTS) before importing it, because importing a module runs it. The package source's loader goes through the same check. fnd_app/tests/unit/test_an_adapter_is_imported_only_from_the_build.py proves that a refused path is never imported.