CharaWeave Architecture

A character package defines the character's available actions and artwork. The runtime selects an action, the browser integration executes it, and the application renders the result. The repository is a private workspace. See the package exports and Public API surface.

Runtime flow

flowchart LR
  P[Character Package] --> V[Package validation and Content projection]
  V --> S[CharacterSession / Runtime composition]
  H[Host application] --> A[Host Adapter]
  A --> C[Context and semantic Targets]
  C --> S
  S --> B[Behavior selection]
  B --> W[Selected WHAT]
  W --> L[Execution lifecycle]
  L --> PR[Presentation state and clip]
  PR --> R[Consumer renderer]
  R --> H

Package Runtime checks the manifest, character definition, resource paths and declared assets before Content returns typed data. A character package contains data, not executable code.

WHAT selection

flowchart LR
  R[Authored repertoire] --> C[Capability gate]
  C --> A[Current applicability]
  A --> T[Temporal eligibility]
  T --> M[Base preference and policy contributions]
  M --> RP[Action repetition]
  RP --> TH[Target history / affinity]
  TH --> PS[Presentation and context suppression]
  PS --> EM[Effective finite mass]
  EM --> W[Weighted WHAT selection]

Capability, applicability and timing determine whether an action can be considered. The policy resolver adjusts the weights of eligible actions. An action whose effective weight falls to zero cannot be selected. Read Behavior Selection before interpreting an effective mass.

Lifecycle ownership

stateDiagram-v2
  [*] --> Idle
  Idle --> Action: opportunity selected and accepted
  Action --> Idle: completed terminal
  Action --> Idle: cancelled / failed / invalidated terminal
  Idle --> Touch: user interaction
  Action --> Touch: touch takes ownership
  Action --> Recovery: owned interaction context invalidated
  Touch --> Idle: finite reaction ends
  Recovery --> Idle: recovery terminal

ActivityOwnership determines which activity controls the character's presentation. A touch reaction or recovery can interrupt an autonomous action. The host adapter supplies the interaction context.

Host and adapter boundary

flowchart TD
  DOM[Host DOM / application UI] --> RH[React Host Adapter, when used]
  RH --> BH[Browser Host Adapter]
  BH --> HC[Public Host contract]
  HC --> BR[Browser Runtime composition]
  BR --> CS[CharacterSession and policy]
  CS --> OBS[Semantic observations and commands]
  OBS --> BR
  BR --> RENDER[Application-owned renderer]

Use @charaweave/core with @charaweave/browser for the standard browser integration, and @charaweave/react for React. The lower-level browser and React host adapters are @charaweave/host-browser and @charaweave/react-host-browser. @charaweave/browser-runtime provides execution services. A Consumer supplies target meaning, DOM elements and lifecycle, renders assets and finite clips, and decides whether a Host activation performs a business operation. See Adapter Policy.

Package boundaries

For source-level dependency information, see the public API inventory and architecture baseline. The repository is private.

Current limitations