Spring's server-side ideas, rebuilt in LoGOs with no container and no reflection.
spira is a web framework for applications written in LoGOs, a fork of the Go toolchain that compiles .lgo files. It is for a team that wants the server behavior Spring gives (routing, HTML views, htmx fragments, browser islands, checked SQL, sessions, metrics and model calls) without dependency injection or run-time proxies. An application is ordinary statements in main. Where Spring asks a type a question at run time through reflect, spira asks at compile time with a LoGOs comptime generic.
func index(ctx *web.Context) (web.Reply, error) {
return web.Page{Title: "Hello", Body: view.P(view.T("Hello from spira"))}, nil
}
r := web.NewRouter()
r.Layout = layout
r.Handle("GET", "/", index)
// GET / -> <!doctype html><html>...<p>Hello from spira</p></body></html>
// GET / with HX-Request: true -> <p>Hello from spira</p>
- No reflection. No
.lgofile in the module importsreflect;grep -R '"reflect"' --include='*.lgo' .prints nothing. - No container.
app.Runonly orders the start and stop of theapp.Partfields of one struct. Nothing resolves or wires parts. - One runtime module.
golang.org/x/cryptofor Argon2id. The four database drivers ingo.modare imported only by tests. - Plain Go out.
logos ejectwrites the module as Go source that upstream Go 1.27.4 builds.just ejectchecks this. - One handler, page or fragment.
web.Pagewrites the whole document, or only its body when htmx asks.
Contents: Quick start · Installation · Why spira · Usage · What main ships · Development · License
With a LoGOs toolchain already on PATH (see Installation), this app runs in under two minutes. Create a module and add spira:
mkdir hello && cd hello
logos mod init example.com/hello
logos get github.com/gosuda/spira@mainWrite main.lgo in the module directory:
package main
import (
"context"
"fmt"
"os"
"github.com/gosuda/spira/app"
"github.com/gosuda/spira/view"
"github.com/gosuda/spira/web"
)
func layout(ctx *web.Context, p web.Page) view.Node {
return view.Html(
view.Head(view.Title(view.T(p.Title))),
view.Body(view.H1(view.T(p.Title)), p.Body),
)
}
func index(ctx *web.Context) (web.Reply, error) {
return web.Page{Title: "Hello", Body: view.P(view.T("Hello from spira"))}, nil
}
type App struct {
Web *web.Server
}
func main() {
ctx := context.Background()
r := web.NewRouter()
r.Layout = layout
r.Handle("GET", "/", index)
root := &App{Web: &web.Server{Addr: ":18080", Router: r}}
if err := app.Run(ctx, root); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Allow the one package that opens sockets by writing logos.toml next to go.mod:
[capabilities]
transitive_net_allowlist = ["github.com/gosuda/spira/web"]Build and run:
logos build -o hello-bin .
./hello-binThe build prints capabilities::unauthorized_reflect warnings. They are warnings, not errors: the module code imports no reflect, while standard library packages such as fmt reach it.
In a second terminal:
curl -i localhost:18080/HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Vary: HX-Request, HX-Boosted, HX-History-Restore-Request
<!doctype html><html><head><title>Hello</title></head><body><h1>Hello</h1><p>Hello from spira</p></body></html>
layout wraps each page in the document shell. app.Run starts every field of App that implements app.Part, in field order, and stops them in reverse order on SIGINT or SIGTERM.
The system go cannot build this module. You need a LoGOs toolchain built from source; the loGos repository's default branch is release-branch.go1.27, built with the fixes that AGENTS.md lists under "Toolchain environment". A plain default-branch build misses them.
-
Clone and build LoGOs. Go 1.27.4 is known to work as the bootstrap compiler.
git clone https://github.com/gosuda/loGos.git cd loGos unset GOROOT GOTOOLCHAIN bootstrap_root=$(go env GOROOT) (cd src && GOROOT_BOOTSTRAP="$bootstrap_root" ./make.bash)
-
Put the toolchain on
PATHfor every later command. When you run spira's own recipes from another checkout, pointLOGOS_ROOTat your LoGOs build; thejustfiledefault is the maintainer's worktree path.export GOROOT="$PWD" export PATH="$GOROOT/bin:$PATH" export GOTOOLCHAIN=local export LOGOS_ROOT="$PWD"
-
Check the install. The output starts with
logos version go1.27.4, but the version line alone does not prove the listed fixes are present; confirm them in your LoGOs checkout.logos version
-
In an application module, add spira.
logos getresolves the version and writes it intogo.mod. Skip themkdirwhen you already createdhelloin Quick start; the lines below assume a fresh directory.mkdir hello && cd hello logos mod init example.com/hello logos get github.com/gosuda/spira@main
The two repository commands are build-time tools, not runtime dependencies. From a spira checkout, logos build -o /tmp/spira ./cmd/spira builds the dev loop, and logos build -o /tmp/sqlc-gen-spira ./cmd/sqlc-gen-spira builds the sqlc plugin.
- Behavior stays explicit. A route, a stage, a cache and a guard are values in code. There is no annotation, scan, interceptor registry or proxy.
- Compile-time answers.
app.Run,schema.Of,db.Queryand the generated SQL functions inspect types at compile time or before a row is scanned, withoutreflect. - Bounded by construction.
metercaps each metric at 1000 series and folds the 1000th label set intooverflow,bus.Topicdrops for a slow subscriber instead of blocking, andweb.Servercarries a header-read deadline (ReadHeaderTimeout) and a shutdown grace (ShutdownGrace). - Errors keep a public boundary.
faultgives each failure a stable code and a client-safe message; the cause stays in logs. - The exit is real. If the experiment does not fit,
just ejectleaves ordinary Go that upstream Go builds.
A feature is a struct that holds the concrete values it uses, and its methods are the handlers. main builds each feature as a struct literal, registers its methods and ends in app.Run.
One handler serves a full page and an htmx fragment. With the quick start program running:
curl -s localhost:18080/ # the whole document
curl -s -H 'HX-Request: true' localhost:18080/ # <p>Hello from spira</p>The other replies follow the same rule. web.Fragment writes HTML with HX-Retarget, HX-Reswap, HX-Push-Url or HX-Trigger. web.Data writes JSON. web.Redirect answers HX-Redirect for htmx and Location otherwise. web.Problem writes RFC 9457 problem details. web.Delegate hands a request to any http.Handler.
example/shop/db holds the migration pairs and annotated queries of the sample schema; docs/specs/example-shop.md specifies the application around them. db.Open takes the driver name and DSN, db.InTx hands a transaction to the work function, and db.Query/db.One scan rows by col tag. migrate.Apply runs the pending *.up.sql scripts in order, migrate.Rollback runs the matching *.down.sql scripts, and migrate.CheckReversible proves that each down restores the schema.
cmd/sqlc-gen-spira is a sqlc process plugin. It reads sqlc's GenerateRequest and writes table structs plus typed functions for :one, :many, :exec, :execrows and :execlastid queries. The accepted engines are SQLite, PostgreSQL, MySQL and SQL Server. tools/go.mod pins sqlc with a Go tool directive.
spira dev <main-package>startslogos runfor the application andpnpm --dir frontend run dev, gives the serverSPIRA_VITE_ORIGIN=http://localhost:5173andSPIRA_SEED_DEMO_PASSWORD, and restarts the server when an.lgofile changes. It passes an inheritedSPIRA_SEED_DEMO_PASSWORD; otherwise it makes a random one and prints it once. An application fromspira newcreates the userdemowith that password only when the variable is set.sqlc-gen-spiraruns under sqlc as aprocessplugin; it also acceptsgeneratefor manual use and reads a request from standard input.
Each package has a specification under docs/specs. These directories exist on main today.
| Area | Packages | What you get |
|---|---|---|
| Lifecycle and configuration | app, config |
app.Run over one struct; config.Load[T] over ordered environment, map, file and remote sources |
| HTTP core | web, schema, validate, openapi, http3 |
ServeMux method patterns, ordered web.Stage lists, typed context keys, the closed web.Reply union, RFC 9457 problems, web.Server, type schemas, field checks, the OpenAPI document, the HTTP/3 server |
| Pages and browser | view, asset, frontend/, live, bus, websocket |
HTML as values with escaping and a URL scheme filter; Vite manifest tags; React, Svelte 5, Solid and WASM island adapters; server-sent events; in-process topics; RFC 6455 connections |
| Data | db, migrate, orm, cmd/sqlc-gen-spira |
Pools and transactions for four engines, checked scans, a 256-entry statement cache, reversible migration pairs, entity sessions with identity and version checks, generated table types and query functions |
| Security and operations | auth, fault, meter, ops, admin |
Argon2id passwords, cookie sessions, bearer and guard stages, a stable public error vocabulary, Prometheus text, guarded /ops endpoints, an admin console |
| Outbound and background | client, resilience, cache, gateway, job |
Typed JSON calls under timeout, retry and a breaker; one-flight LRU cache; reverse proxy; scheduler, queue and chunked batch |
| Model calls | ai, ai/openai, ai/anthropic, ai/ollama, ai/session, ai/rag, ai/mcp |
Messages, tools, ai.Run, ai.Collect stream merge, layers, structured output, OpenAI-compatible, Anthropic and Ollama providers, sessions, retrieval, an MCP client and server mount |
| Tools | cmd/spira, fault/faulttest |
spira new, spira dev; the spec-backed fault disclosure test kit |
The full map from Spring concepts to spira packages, including what spira does not build, is in scope and lexicon.
- Package contracts: docs/specs
- HTTP: web
- Pages and islands: view, frontend, wire contract
- Data: db, migrate, sqlc-gen-spira
- Login and sessions: auth
- Model calls: ai
- Scope and exclusions: scope and lexicon
- Sample schema contract: example-shop
The module builds with logos, not go. The justfile sets the toolchain environment; LOGOS_ROOT overrides the toolchain path.
just build # logos build ./...
just lint # logos lint ./...
just test # logos test -race -count=1 ./...
just web # wasm fixture, pnpm install, biome + tsc + vitest, vite build
just gate # sql-check build lint test web slop
just eject # logos eject to /tmp/spira-eject, then upstream go buildjust engines runs the TestEngine* tests, selected with -run Engine and failing without their DSN, against digest-pinned PostgreSQL, MySQL and SQL Server containers through scripts/engines.sh; it requires Docker. logos.toml forbids cgo, and the test recipe keeps -race.
Read CONTRIBUTE.md for the steps to land a change and REVIEW.md for what a reviewer checks. AGENTS.md holds the module rules in full. A defect in the LoGOs toolchain is never worked around in silence: it goes through the finding protocol in that file.