sqlapplet

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package sqlapplet makes SQL-defined applets first-class boxer apps (ADR-0132): each applet is one committed markdown document — frontmatter as the manifest, prose as the help page, the first `sql` fence as the play buffer — and the host mints one real app.Manifest per document, serving every instance as an attenuated embedded play (`NewLivePlayApp` with the exploration chrome removed).

Contributing packages register applet books via RegisterBook (an embedded fs.FS of .md documents, mirroring the help facility); the shell calls MintManifests once at startup, before launch resolution, so `--launch <appletId>` and the Apps menu see the minted set.

Index

Constants

View Source
const StoreAppId app.AppIdT = "runtime.appletstore"

StoreAppId is the synthetic identity the applet store service registers under; its SubjectAlias namespaces the persisted documents.

Variables

This section is empty.

Functions

func MintManifests

func MintManifests(logger zerolog.Logger) (minted int, errs []error)

MintManifests parses every registered applet book and registers one factory-backed Manifest per applet with the default app registry (ADR-0132 §SD2). The shell calls it exactly once at startup, after init-time book registrations and before launch resolution, so `--launch <appletId>` and the Apps menu see the minted set.

Minting is best-effort per document — an invalid doc yields an error and mints nothing, valid siblings still mint — because the corpus test (§SD6) is the hard gate; at boot, a partially minted set beats no shell.

func RegisterBook

func RegisterBook(id string, fsys fs.FS) (err error)

RegisterBook contributes an applet book: an fs.FS of markdown documents in the ADR-0132 §SD1 shape. Packages call it from init (the help-facility pattern); MintManifests later parses every registered book. The id names the book in diagnostics and must be unique.

Types

type AppletDef

type AppletDef struct {
	Slug     string
	BookID   string
	Title    string
	Icon     string
	Tabs     []TabSel // nil = auto (all result panels; accept/reject decides at render)
	Endpoint EndpointE
	SQL      string
	BandsSQL string // optional `sql bands` aux fence (Timeline panel-local SQL)
	// Class is the ADR-0132 §SD5 security class of SQL, computed at parse
	// time. It gates AutoRun at mount: only QuerySecurityRead applets run on
	// open.
	Class analysis.QuerySecurityClassE
	// HasUnboundSlots notes whether the buffer carries `{name:Type}`
	// placeholders its SET prelude does not bind — signals, in ADR-0097
	// terms. Such an applet opens with the Live toggle preset
	// (panel-written signals re-run the buffer, ADR-0132 §SD3); a fully
	// prelude-bound buffer does not (its params re-run via the strip's
	// prelude rewrite and an explicit or auto Run).
	HasUnboundSlots bool
}

AppletDef is one parsed applet document, ready to mint.

func ParseBook

func ParseBook(bookID string, fsys fs.FS) (defs []*AppletDef, errs []error)

ParseBook parses every markdown document of one applet book into applet definitions. A document without a role-less `sql` fence is a plain prose page and yields no definition (a book may carry an overview page); every violation of the ADR-0132 §SD1/§SD6 rules yields one error naming the document. defs come back sorted by slug.

func ParseDocSource

func ParseDocSource(bookID string, path string, src []byte) (def *AppletDef, err error)

ParseDocSource parses one applet document from raw markdown — the shared core behind the committed-book path and the runtime store's save gate (ADR-0132 Update "O4"): both submit the identical document shape and are judged by the identical rules. A nil def with a nil error is a prose page.

type EndpointE

type EndpointE uint8

EndpointE selects the server an applet speaks to (ADR-0132 §SD7).

const (
	// EndpointDefault — the env-configured ClickHouse, exactly as play's own
	// launcher resolves it.
	EndpointDefault EndpointE = iota
	// EndpointIntrospection — the in-process ADR-0094 `/query` endpoint.
	// Parameter binding works there since ADR-0133 M3 (the chhttp dialect
	// plus the broker's SET-prelude channel); the remaining parity gaps are
	// read counters and progress headers, recorded in ADR-0133 §SD4.
	EndpointIntrospection
)

type StoreService

type StoreService struct {
	// contains filtered or unexported fields
}

StoreService is the runtime applet store (ADR-0132 Update "O4"): it serves `applet.store.save`, validating each submitted document with the same parser the committed books go through, persisting it through the runtime persist facility, and minting its manifest live. It is the moderation gate between an authoring app and the launcher.

func StartStore

func StartStore(bus *inprocbus.Inst, logger zerolog.Logger) (svc *StoreService, err error)

StartStore loads the stored applet corpus, mints it into the default app registry, and subscribes the save endpoint. Call it once at startup, after MintManifests — committed books must already be minted so the collision rule ("curation outranks runtime state", O4-D3) can read the registry as the source of truth.

func (*StoreService) Stop

func (inst *StoreService) Stop()

Stop unsubscribes the save endpoint. Idempotent, nil-safe.

type TabSel

type TabSel struct {
	ID   string
	Node string
}

TabSel is one entry of an explicit frontmatter `tabs:` list: a result-panel slug, optionally bound to a split node by CTE name (`table:recent`, ADR-0132 §SD4 riding ADR-0097 slice 6c).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL