Skip to content

Application architecture

For new applications, begin with the current Quick Start. The installed runtime’s skillex/references/recommended-application-path.md is the recommended owner → capability → component → declaration → workspace sequence; lower-level APIs remain available.

Kitsune aims to supply an application pattern that agents can refine and extend consistently. Components present state and emit native intent. Behavior declarations connect that intent through contextual boundaries to registered consumers, effects and bindings. The runtime activates and manages those connections; domains own authoritative outcomes and environments own identity, backend and lifetime policy.

Custom capabilities supply application behavior through discoverable contracts. The framework’s general concern is how they register, become ready, consume intent, expose results and release resources. Product protocols such as editor drafts and receipt recovery add optional semantics. Algorithms and domain policy remain custom code behind those interfaces; checking integration contracts does not prove every internal function.

The current module APIs support custom queries, commands, events and lifecycle hooks. The declared behavior API below is still the bounded editor profile. G1 now supplies readKitCapabilityDefinition and createKitCapabilityRegistry for inert registration, readiness/dependencies, scoped cancellation and owned cleanup over a borrowed runtime. G2 supplies a local scoped readiness catalog with discover, reconciled observeDiscovery and epoch-pinned resolve. Explicit scoped dispatch lets identical operation names coexist across environment/scopes; omitted dispatch retains G1 exclusivity. G3 now supplies separate generic native composition with selected capability handles, registered consumers and reconciled property bindings. It requires no editor records. Managed presentation sessions, executable protocols and transported live discovery remain future work.

The authoring direction centers a managed presentation session: a composition in a host outlet, borrowing an environment for a defined lifetime. Routes, declared state and accepted typed tool results are selection sources for the same mechanism. Component packs and inherited theme tokens support reviewed and dynamically generated presentation. Temporary panel cleanup preserves independently owned objects and outstanding operation outcomes.

A scoped theme/selection facade and optional WebMCP capability exposure are design work, not shipped APIs. WebMCP would expose selected contracts through existing validation and product preconditions, with explicit host policy and supported browser profiles. It does not automatically export every registered command or generate executable UI from result text.

The composition root creates owners and lends adapters. It should contain no product click handlers, field patches or storage transactions. Components should not import domain services, persistence, telemetry vendors or a runtime singleton. A review panel requests a draft change through its declared event; the editor receives the working value through a binding. Neither component calls the other.

For the qualified single-title profile, createKitTitleEditorBehavior supplies the complete protocol declaration from explicit application/environment/object, renderer and persistence references, with optional analytics. Its output remains inspectable data. It does not install a backend, validate executable renderer bytes or describe arbitrary multi-field workflows.

createKitBrowserBehaviorApplication from @atheory-ai/kitsune/browser/behavior manages the full desired native selection through replace({ model, components, boundaries }). It stages references, validates composition, activates existing event/module/binding machinery and releases deselected references. DOM/release selection stays with the surface owner. Preflight rejection preserves the previous plan; arbitrary post-preflight side effects cannot be universally rolled back.

The maintained reference application demonstrates this structure with TypeScript/Lit, persisted drafts, revision conflicts, original-receipt recovery without replay, a dynamically imported review panel and optional telemetry. Its eight original native acceptance cases and twelve formatter cases run against a packed runtime in a clean consumer; a fresh-agent extension also passes thirteen independent structure/cleanup/recovery checks. The original qualification/calibration fixtures retain their historical roles.

The runtime ships kitsune-architecture and kitsune-runtime public skills; UI ships kitsune-components. Adapt the runtime’s skillex/assets/AGENTS.md into the application repository and configure its dependency boundary. Agents should query by work path and intent, read selected installed guides, then applicable private product/backend policy. A dependency install makes skills discoverable; it does not automatically make every agent follow them.

Clear source ownership and passing bounded tests are evidence for this reference. They do not prove arbitrary backend correctness, every callback side effect, production durability, or superiority over a disciplined application built with another framework.

The generic composition format selects exact capability implementations, native presentation contracts, semantic routes/consumers and query/property bindings. Derivation checks declared cardinality, payload compatibility, binding writers and feedback cycles; implementation internals remain opaque. Activation validates proposals before replacement, borrows pinned epochs and releases native/subscription resources on readiness loss or disposal. Explicit optional observer loss leaves required application behavior active; restarted providers require fresh resolution without command replay.

The maintained calculator uses this path with a real worker. Its Lit panel owns accessible input and emits intent, its custom capability owns bounded computation/progress/cancel policy, its declaration connects events and bindings, and its root selects owners. Surface removal leaves the borrowed capability usable; environment shutdown separately releases the worker. Reload is explicitly ephemeral. This demonstrates bounded application structure and behavior, not arbitrary-code verification or superiority to other frameworks. Editor-v1 contracts and recovery remain their separate qualified profile.

Managed presentation selection in the current candidate

Section titled “Managed presentation selection in the current candidate”

The unpublished candidate exports createKitPresentationSession from @atheory-ai/kitsune/browser/presentation. A session owns one outlet and its generic composition surface. Registered route, state and typed tool-result sources select exact trusted presentation definitions through explicit arbitration. Captured tool results pin source/outlet context before invocation; obsolete results reject. The explicit History adapter closes old operation admission at URL commit, while reconciled state feeds own their unsubscribe.

Presentation definitions prepare components inside a scoped candidate slot and defer custom cleanup immediately. The environment, domain commands and original save receipts remain independently owned. Layout outside the outlet stays mounted. G8 adds opt-in keyed live participants with explicit release/object identity and declared silent property transactions. Compatible selections preserve native input/resources; property-only changes preserve their integration epoch. Shared layouts, scoped themes and compatible managed layout movement are implemented below; native routing and optional transitions are available through the presentation entry; general ordered collections, portal theming and WebMCP remain separate.

Shared layout and scoped presentation styles

Section titled “Shared layout and scoped presentation styles”

The current candidate adds G9 fixed layout ownership and scoped theme layers above managed sessions and keyed participants. Put shared chrome/theme declarations in a presentation module and source controls in a separate adapter. A layout mounts once into an owned frame and returns its content outlet; the session owns its cleanup. Host-approved base/product/preset/override tokens inherit into dynamic components without changing global roots or sibling sessions. setTheme has its own revision and preserves local input, captured presentation tickets, bindings and running commands. Compatible History retention is explicit: URL commit closes old operation admission, and only the next compatible live region may reuse keys. Leaving for another surface is not a route cache. Selection-owned outlet graph transactions and managed layout replacement are implemented below. Native routing and optional transitions are available through the presentation entry. Portal themes and WebMCP remain separate work.

G10 extends fixed layouts with named, connected, nonoverlapping outlets. The session reserves them and opens children through openOutlet; children can supply their own layouts and named outlets recursively. Primary selection and child input remain independent. Parent disposal closes every descendant immediately, cancels pending work and drains child cleanup before deferred parent releases. Child cleanup failures propagate and block reuse. Native tests and a separate nested workspace qualify retained input, dynamic summary replacement, scoped themes, separate registries and optional original receipt recovery without replay. Arbitrary observation-root migration, route caching and portal theming remain separate.

G11 selection-owned child sessions add pure desired outlet graphs using exact trusted templates, explicit identities and registered source inputs. The runtime prepares the tree before serialized publication, retains compatible native participants, and rolls back owned integrations/property writes on cancellation or failure before commit. Retirement drains child resources before ancestor releases; incomplete cleanup fails closed. Native input, conflicts and original unknown-save receipts survive without command replay. Fixed-layout G10 children remain independent; domain transactions, arbitrary code effects, arbitrary observation-root migration and route caching stay outside graph rollback.

G12 managed layout replacement selects registered exact layouts and transfers same-named outlets with explicit matching continuity contracts. Compatible primary participants and fixed/selection-owned child sessions preserve native input/focus, bindings, running operations, source tickets, themes and drafts. Incompatible occupied outlets reject before transfer; explicit host selection closure precedes incompatible topology changes. Native moveBefore and lifecycle-aware custom elements are required. Interrupted moves restore prior owned placements; retirement serializes publication and failed rollback/cleanup blocks reuse. Domain outcomes and original save receipts remain independently owned.

G13 supplied component moves makes the maintained catalog participate directly: all eleven classes and their factory-generated elements retain native controls, form/ARIA state, modal focus, drafts and toast deadlines during compatible managed layout replacement. No move-specific host recreation or component subclass is needed. Ordinary removal still releases resources; custom/third-party lifecycle effects require separate qualification.