goforge.dev/cadence

Package cadence is the serving strategy foundation for server-driven UI. It is host-agnostic: it defines the region model, the content substrate, and the strategy algebra that a transport interpreter serves over the network, but it has no opinion about HTTP, sockets, or any particular client. The region model (Region, LiveRegion, RenderContext) describes a unit of a page as a cheap Skeleton shown immediately and an expensive Render produced afterward. A plain Region is stateless per render; LiveRegion adds server-held State and event handling for regions that stay connected. Both forms produce a Tree. Tree is the static and dynamic content substrate: a rendered region as an interleaving of fixed statics and recomputed dynamics. Tree.Diff compares a tree against its previous render for the same region and returns only the dynamic slots that changed, or reports that the static shape itself changed and the region needs a full replace rather than a patch. This fine-grained diff is what lets a transport ship small patches instead of re-sending whole regions. Strategy and Policy are the serving algebra. A Strategy is a value describing how and when a region's content is produced and delivered: Eager (computed on the server before the first byte), Deferred (a skeleton first, then content after first paint, from a chosen Where and on a chosen Trigger), or Live (server-held state pushing patches as it changes). A Policy assigns a Strategy to a region, statically (Fixed, Uniform) or, later, adaptively from a Profile. Interpretation makes host compatibility explicit. With JavaScript off every strategy becomes Inline, while a plain region can never require LiveTransport. The Semantics class carries generated laws for both invariants, and ReferenceSemantics provides the canonical interpretation. This package pins those laws; it does not implement a real transport. cadence has no runtime dependency beyond the Go standard library. Interpreters that turn a Strategy into actual delivery live above cadence and import it: a net/http transport library such as quicken (currently being rebased onto cadence), and, later, a TEA-style client interpreter. Strategy is the serving algebra, authored in Go+: a strategy is a SUM — Eager, Deferred(where, on), or Live — so a strategy that is not Deferred cannot carry a Where or a Trigger. The fallback law is a class law, rapid-tested automatically for every Interpreter instance.


License
MIT
Install
go get goforge.dev/cadence

Documentation

cadence

goforge.dev/cadence is a target-independent Elm Architecture foundation for Go+ applications. A program defines one model, a closed message algebra, one update function, subscriptions, opaque commands, semantic elements, and immutable semantic styles. Browser, server, terminal, and GUI modules interpret those values without owning application policy.

The coordinated implementation plan is ../docs/superpowers/plans/2026-07-28-cadence-quicken-fullstack-ui.md.

Packages

  • cadence: validated execution plans and the compatibility region algebra.
  • cadence/program: serialized TEA runtime, commands, subscriptions, codecs, and component lifting.
  • cadence/sel: target-capability semantic elements and renderer contracts.
  • cadence/style: immutable semantic style and theme values.

Program

logic := program.Logic[Model, Msg]{
	Init: func() program.Step[Model, Msg] {
		return program.Step[Model, Msg]{Model: initial}
	},
	Update: update,
	Subscriptions: func(Model) program.Subscriptions[Msg] {
		return program.Subs[Msg]()
	},
}

Commands represent emit, batch, sequence, delay, cancellation, and typed target effects. The runtime serializes updates and delegates only capability-specific effects to an interpreter.

Execution plans

Plans separate initial render, state ownership, activation, transport, and fallback. Hosts accept only ValidatedPlan.

hydrated := cadence.Hydrated(cadence.ActivateLoad{})
live := cadence.LiveServer(cadence.ActivateLoad{})
static := cadence.WithoutClient(hydrated)

Interpreters

  • goforge.dev/quicken/web/browser
  • goforge.dev/quicken/tui
  • goforge.dev/quicken/native
  • goforge.dev/quicken

Authorship and license

Semantics are authored in .gp; checked-in generated Go is what consumers build. MIT, Copyright (c) 2026 Goforge.