story

module
v0.0.0-...-71f1964 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT

README

Story language

Describe business roles and flows as ordinary Go source, before choosing an architecture. Goa evaluates the declarations into expr.Root.Stories. This nested module depends on Goa and the standard library. It loads none of Highbay's server and nothing of Goa-AI.

package design

import . "github.com/goadesign/highbay/story/dsl"

var _ = Story("Incidents", func() {
	Actor("remediation", "Remediation agent")
	Actor("oncall", "On-call engineer")

	Flow("production-rollback-requires-approval", "Production rollback requires on-call approval", func() {
		StartsWith("detect-unhealthy-deploy", "remediation", "Detects an unhealthy production deploy")
		Step("approve-rollback", "oncall", "Approves the production rollback")
		Outcome("service-rolled-back", "remediation", "Rolls back the production service")
	})

	Flow("staging-rollback-policy", "Staging rollback policy", func() {
		StartsWith("detect-staging-regression", "remediation", "Detects an unhealthy staging deploy", func() {
			Question("staging-autonomy", "Should staging rollbacks run autonomously or pause for approval?", func() {
				Option("Autonomous staging rollbacks")
				Option("Approval required everywhere")
			})
		})
	})
})

Keys preserve identity when titles, summaries, or declaration order change. They must match ^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$ and are kept verbatim. Actor keys and flow keys each have their own scope within a Story. Step keys and question keys each have their own scope within a flow; question keys are unique across both flow questions and attached step questions. Step actor references must name an actor in the same Story. Business roles such as warehouse-worker and insurance-agent are valid.

Story(name, fn) appears at the top level. Its function accepts Actor(key, title, fn...), Flow(key, title, fn), and Description(text). A flow accepts StartsWith(key, actorKey, summary, fn...), Step(key, actorKey, summary, fn...), Outcome(key, actorKey, summary, fn...), Question(key, prompt, fn...), and Description(text). A step accepts questions and descriptions. An actor accepts a description. A question accepts Option(label) and a description. Each optional function permits at most one function. Option labels must be nonempty and distinct within the question.

After successful eval.RunDSL(), flow.Complete() reports whether a flow has one start, at least one outcome, and no open questions, including questions attached to steps. A flow may have multiple outcomes but at most one start. Missing starts, missing outcomes, and open questions leave valid unfinished drafts; they do not invalidate other finished flows. Suggested options do not answer a question. Refine the Story with the decision and remove its question declaration when resolved. Duplicate keys, invalid keys, invalid actor references, and misplaced DSL calls remain evaluation errors.

Actors, flows, steps, and each question list retain declaration order. Completion is derived from that tree without generated names or cached status. Like Goa's other DSLs, evaluation uses a process-wide context and must run serially. The language can coexist with ordinary Goa API declarations and can also be evaluated on its own, without any API, service, or model declaration.

This module supplies the language and its expressions only. Highbay, in the module above this one, does the rest with them:

  • The guide (the coding agent the user talks to) writes the Story in its draft: a copy of the project's design that Highbay keeps in the project folder for the guide, so the guide never edits the project's own design files. When the guide calls refresh_story, Highbay's server evaluates the Story in that draft. It keeps the evaluated Story with a change when the guide proposes or revises that change with the evaluation's op_id.
  • When the user builds the change, the build requires one test per finished flow. A separate coding agent, the test writer, writes those tests in its own working copy of the project, and Highbay checks what it reports before the tests count.
  • Highbay verifies the commit of the builder, the coding agent that writes the application code in its own working copy, with the accepted tests.

Story flows and the tests a build requires describes each step. Highbay's page shows a Story's flows; to change a Story, the guide edits its source in its draft.

A project's design imports this module, so the project's go.mod must require it. A starter project made by highbay init does, at the version Highbay itself requires. In another project, a Story refresh that fails for that reason names the command to run: go get github.com/goadesign/highbay/story@<version>.

Run this module's checks from story/:

CI=true go test -race -vet=all ./... </dev/null

Directories

Path Synopsis
Package dsl declares domain Stories as ordinary Go source.
Package dsl declares domain Stories as ordinary Go source.
Package expr defines domain Stories evaluated by Goa's DSL engine.
Package expr defines domain Stories evaluated by Goa's DSL engine.

Jump to

Keyboard shortcuts

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