30 — L3 shell, runtime and UI
BuiltRendered from 30-l3-shell-runtime-ui.md in the public repository. Edits belong there.
The portal page is described by the shell state machine in micyte/state_machine/, composed per request by the host runtime, and rendered by the JavaScript shell.
Parts
| Part | Location | Role |
|---|---|---|
| Shell state machine | micyte/state_machine/portal_shell/ | Shell dataclasses, the surface catalog, the canonical query, tool eligibility. Pure: no I/O |
| Lenses | micyte/state_machine/lens/ | Encode and decode a datum value for display (81) |
| NIMM and AITAS | micyte/state_machine/nimm/, micyte/state_machine/aitas/ | The staged-mutation contract and its context model |
| Runtime | host application, instances/_shared/runtime/ | Composes the page bundle for a request (portal_shell_runtime.py), the palette endpoints (portal_palette_runtime.py), the mutation lifecycle (portal_datum_workbench_mutation_runtime.py) |
| Flask host | host application, instances/_shared/portal_host/app.py | Routes, page rendering, the host's own shell extension |
| JS shell, page and manifest | micyte/ui/ | The scripts, stylesheet, icons and page (static/, templates/); manifest.py says what the page loads; a host adds its own containers with a ShellExtension |
| Envelope and panel loop | micyte/ui/envelope.py, micyte/ui/panels.py | The frame every shell request is answered in; the loop that builds each tool's panel |
| Local host | micyte/ui/local_host.py | The shell over a store on one machine, with no hosting service (83) |
Surfaces
build_portal_surface_catalog() in shell_registry.py lists 21 surfaces under five roots:
| Root | Route | Children |
|---|---|---|
Compendium (system.root) | /portal/compendium | system.tools.workbench_ui (/portal/system/tools/workbench-ui), which hosts every tool |
Network (network.root) | /portal/network | browser, p2p, inbox, profile |
Gadgets (gadgets.root) | /portal/gadgets | None |
Profile (profile.root) | /portal/profile | None |
Utilities (utilities.root) | /portal/utilities | apps, marketplace, contracts, published, tools, ports, peripherals, wallet, extensions, grantee_profile, tool_exposure |
/portal/system redirects (302) to /portal/compendium with the query preserved.
Three pages
The bar does not draw the five roots. PRIMARY_PAGES in shell_registry.py groups them into three pages, and primary_pages() resolves that declaration against the catalog a request is given:
| Page | Roots | Its switch draws | Its menu | Its views | Pressing its cell opens |
|---|---|---|---|---|---|
| Network | Network | nothing | none | Messages, Notifications | Network |
| Instance | Compendium (drawn as "Docs"), Gadgets, Utilities | Docs, Gadgets | "MiCyte - Instance": Theme, Ports, Extensions | none | Gadgets, or the first of Gadgets, Compendium, Utilities the catalog holds |
| Profile | Profile | nothing | none | none | Profile (the bar's foot) |
A page with no root in the catalog is not drawn, so a catalog built with network_enabled=False has two pages and the Lite set's Instance page is Utilities alone. primary_page_id_for_surface() answers through a surface's root, which is how a child surface lights its page's cell.
A page's roots are its members. The ones a menu entry opens are reached through the menu, and the rest are its segments: a page with two or more segments gets a switch above the workbench, one segment each. On the Instance page that is Docs and Gadgets, and on a Utilities surface both are drawn and neither is lit. It travels in the activity bar's region as page_switch ({} when the open page has one root), so the composition is still two regions. A tool's address is a query on the Compendium root, so an open tool lights the Gadgets segment. No route, label or landing moved: the pages are a grouping the bar draws, not new surfaces.
A page may declare a menu (PrimaryPage.menu_title and .menu, a tuple of PageMenuEntry). An entry is either a control the shell owns (control="theme") or an address: a surface and a query. The Instance page's Ports and Extensions entries open the Utilities root with group=ports and group=extensions. The menu travels beside the switch as page_menu: {page_id, title, current, sections}, each section a label and its rows, each row {id, label, icon_id, href, control, active}, and {} when the open page declares none. current is true on any surface the menu is the way to, which is what lights the menu's button when no segment is lit; a row is active only at its own address. A host may add sections of its own after the page's.
The button is the first thing in the title row and opens the menu as a sheet from the left edge (a native <dialog>: Esc, a press outside it, or its close button shuts it, and focus returns to the button). The theme select is one node. On a page with a menu the renderer moves it into the Theme row; on a page with none it stands in the title row. It is never drawn twice and never recreated.
A page may also declare views (PrimaryPage.views, a tuple of PageView): pages its head opens in the page's own place, each with a way back. A view is the page's root with a query, so it has an address, a reload keeps it, and the bar keeps the page lit. Network declares two, view=messages and view=notifications; network_root_surface_query.NETWORK_ROOT_VIEWS is the vocabulary the address accepts (map is the default, and anything else is read as map). Views travel beside the menu as page_views: {page_id, items, open}, each item {id, label, icon_id, href, active}, and open the open view's {id, label, back_href, back_label} or {}. A view draws no map; until the contract inbox and contract-carried notices fill them, each shows what will arrive there.
Profile declares three, view=accounts, view=settings and view=edit (PROFILE_VIEWS in shell_schemas.py), which are what the profile's tabs and its Session block were until 2026-11-30. The page opens each from its own body rather than from buttons in the head. The head's middle holds the session: the instance's monogram (the registrar's, else the name's initials) and a chevron, which opens Accounts, where the instances this sign-in may open, the accounts the phone app keeps, and Sign out are. The profile's last row opens Account settings (the theme, the privacy policy, the operator's client sign-ins, Delete account), and its Edit profile button opens the two documents a profile is drawn from. Choosing another instance on Accounts lands on that instance's profile (switchSandbox(..., {leave: ["view"]})). The head carries the page's id (data-page-id) for what one page draws differently: Profile's three bars stand at the head's end, and on a phone over the end of its capsule.
A page that declares views has a head of its own (data-page-head="own" on the title row): the page's one search (the network browser's, or on the operator's portal a search over the same map; the map's sheet then draws none; on Profile the session's monogram instead of a search) and the view buttons, and neither the tool search nor the theme select. Instance keeps the tool search, and Theme is a row of its menu; Profile's theme is on Account settings. With a view open (data-page-view) the head is a back button and the view's name. Back is an anchor to the page's address; when this page was loaded by a press of the view's button on the page, moments before, it goes back through history instead (the note is taken once, as the page loads, so it never outlives that entry), so a phone's own back gesture and the button agree. A client door builds the views at its own addresses and keeps view in its address, dropping the default.
group is the Utilities root's one selection key. canonical_query_for_surface_query keeps it only when it names one of UTILITIES_GROUPS (apps, ports, extensions, sandboxes), and the instance diagram carries the answer as open_group: that group is drawn open, or on the static drawing, where every group is open, marked and brought into view.
On a screen 700px wide or narrower the bar is a row at the foot of the page: three equal cells in one capsule, the open page's cell a capsule inside it, all in opaque colours. It stands inside the device's home-indicator band, not a whole band above it: its bottom margin is env(safe-area-inset-bottom) less 12px, and never under 8px. A web view that ends above that band and still reports it would spend the band twice, so inside the phone app installFootBand() in v2_portal_shell_core.js compares the screen's height with the page's; when the app has kept a band back it sets data-foot-band="outside" on the shell, and the bar stands 8px off the page's foot. The capsule is the one shape in the stylesheet that is not the barely rounded --radius: --radius-pill is read by the phone bar and its cells, by the phone's title row, and by nothing else, and test_the_portal_is_plain.py names each reader and holds that.
At the same width the title row has no ground of its own. The menu's button is a circle, the switch a pill with the open segment a capsule inside it, and the search (and, on a page with no switch, the theme select) a capsule beside them: one rule, one opaque colour, one drawn edge and one shadow, all 40px tall, standing on the page. The open segment is lit by the rule that lights the bar's open cell. The one thing the row still paints is the status-bar zone: when the page is drawn under the device's clock (installed to a home screen, or inside the phone app) the row and the open menu's title colour exactly env(safe-area-inset-top) of their height in the bar's colour, so a clock the device draws in white is not lost on a light page; in a browser that keeps its own chrome the inset is 0 and nothing is painted. A desk keeps its title bar and its barely rounded boxes. test_the_phones_top_row_hovers.py holds the rules and test_the_instance_page.py the drawing, in every theme.
On Network at that width the row draws no page name (the browser's tab strip names the page): the search is a capsule taking the row, with Messages and Notifications beside it as bare glyphs in the page's ink. The map's slide-up sheet runs to the page's foot (and stays there when a keyboard opens: the search it rose for is the head's), 8px in from each side, opaque, its top corners rounded by --radius-sheet, and the bar stands inside it: on the map page the workbench takes the bar's row too and the bar is drawn on a level above it. At its lowest the sheet is its grip and the bar's zone (--bar-zone, the numbers the bar is drawn with, beside --bar-foot, the bar's distance from the foot). The drag reads that height from the stylesheet through a probe in the sheet, so it is stated once. test_the_network_page_as_drawn.py holds the drawing, reading the sheet from the pixels.
A request
- The page route calls
_render_surface, which embeds a bootstrap shell request and the JS module manifest (PORTAL_SHELL_MODULE_CONTRACTS) intoportal.html. v2_portal_shell.jsloads the declared modules in order.v2_portal_shell_core.jsposts the request toPOST /portal/api/v2/shell.run_portal_shell_entryresolves the instance scope from the store's portal-authority snapshot, resolves the surface (an unknown surface falls back tosystem.rootwithallowed=False), and builds the surface's bundle.build_shell_composition_payloadassembles two regions: the activity bar and the workbench. The envelope schema ismycite.v2.portal.runtime.envelope.v1.- The client validates the envelope and dispatches each region to its renderer:
v2_portal_shell_region_renderers.js(the activity bar: the page cells, pinned tools, the Profile slot, and the open page's switch and menu) andv2_portal_workbench_renderers.js(everything else: the Compendium, the tool host, document tables, forms).
Navigation is query state
Selection travels as surface_query. canonical_query_for_surface_query in shell.py keeps only the keys each surface names and always adds msn_filter, the instance the page is on. On the Compendium and the tool host the keys include document, mode, sandbox_filter (inferred from an lv. document id when absent), tools (a comma-separated list of open tool ids), view and doc_view.
The reducer (reduce_portal_shell_state) and its transitions are still in the tree but are not used: REDUCER_OWNED_SURFACE_IDS is empty, so no surface is reducer-owned and the client's dispatchTransition does nothing.
Tool palette
The menubar search lists tools that apply to the current selection. It calls GET /portal/api/tools/eligible for a selected datum and GET /portal/api/visualizers/for-sandbox for a sandbox. recognize_applicable_tools in tool_eligibility.py matches a document's archetype and source kind (widened by its hyphae chain) against each tool's applies_to_archetype and applies_to_source_kind. Whether a tool is offered on a sandbox at all is instance_can_use (46).
Writes
POST /portal/api/v2/mutations/<action> runs the mutation lifecycle (stage, validate, preview, apply, discard) for datum workbench and datum document targets. A workbook apply decodes the edited WORKBOOK-YAML, compiles it to ops, plans the migration and applies it (10). Tools post to their own declared routes, and each write is checked against the write policy (micyte/ports/datum_write_policy/).
micyte/state_machine/nimm/ defines the same lifecycle as a contract (StagingArea, NimmDirectiveEnvelope, MutationContractRuntimeHandler). The live mutation runtime implements the lifecycle directly and does not subclass the handler.
Known gaps
shell.pyandshell_state.pyboth definePortalScope,PortalShellChrome,PortalFocusSegment,PortalShellState,PortalShellTransition,PortalShellRequest,PortalSurfaceCatalogEntryandPortalShellResolution.micyte/state_machine/mediation_surface/is an empty scaffold.- The read path renders a SQL projection, not WORKBOOK-YAML (10).