workload

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package workload generates the v4 realistic business workload fixture (docs/design/business-workload-model.md): four business modules rendered from one set of table specs into per-dialect DDL/seed SQL, entity configuration, and expected task results. Every value is a pure function of (seed, table, row index); regenerating with the same Config is byte-identical.

Index

Constants

View Source
const (
	DialectPostgres  = "postgres"
	DialectMySQL     = "mysql"
	DialectOceanBase = "oceanbase"
)

Dialect names accepted by the renderer. MySQL and OceanBase share syntax.

Variables

This section is empty.

Functions

func Artifacts

func Artifacts(cfg Config) map[string]string

Artifacts renders every generated checked-in file keyed by path relative to fixtures/v4. Map iteration order does not matter: each file's content is independently deterministic.

func Expected

func Expected(cfg Config) map[string]Expectation

Expected computes every task expectation from the same deterministic plans that generated the tables. Task IDs match fixtures/v4 task files.

func ExpectedTaskIDs

func ExpectedTaskIDs(cfg Config) []string

ExpectedTaskIDs lists every task id with a computed expectation, sorted.

func Oracles added in v0.1.10

func Oracles(cfg Config) map[string]Oracle

Oracles computes counterfactual values from the same deterministic data as Expected. Task IDs match fixtures/v4/tasks-v5 guided-metadata and additions natural/oracle tasks.

Types

type Anomalies

type Anomalies struct {
	DuplicateCallbacks       bool // duplicate channel callbacks (dedup_of)
	OutOfOrderCallbacks      bool // received_at earlier than a prior event
	ReconciliationMismatches bool // statement items that do not reconcile
	FailedAttempts           bool // failed/retried payment attempts
	PartialRefunds           bool // partial (not full) refunds
	SoftDeletes              bool // logically deleted users/customers
	DuplicateGiftEvents      bool // duplicate gift events (dedup_of)
	UnpostedLedger           bool // payments succeeded but not yet posted
}

Anomalies are the injectable irregular data patterns.

type ColType

type ColType int

ColType is a portable logical column type; renderers map it per dialect.

const (
	ColInt ColType = iota
	ColBigInt
	ColText     // free text (never a key)
	ColCode     // short identifier text, usable as a key
	ColDate     // calendar date
	ColDateTime // wall-clock timestamp, stored as UTC without zone
)

Logical column types shared by all dialect renderers.

type Column

type Column struct {
	Name        string
	Type        ColType
	Nullable    bool
	Description string
}

Column is one physical column with its agent-facing description. The description is the semantic contract surfaced through describe_entities; traps (units, grain, enums, time roles) live here on purpose.

type Config

type Config struct {
	// Seed feeds every pseudo-random choice. Changing it produces a new,
	// equally deterministic dataset (and invalidates expected task results).
	Seed int64
	// Scale multiplies base row counts (1 = reference profile).
	Scale int
	// Anomalies toggles injected irregularities. The reference profile keeps
	// all of them on; disabling one removes that pattern deterministically.
	Anomalies Anomalies
}

Config controls generation. The zero value is invalid; use DefaultConfig.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig is the reference profile: seed 1, scale 1, all anomalies on.

type Confounder added in v0.1.10

type Confounder struct {
	Value           string
	FailureCategory string
}

Confounder is a wrong answer value tied to a specific failure mode.

type Dataset

type Dataset struct {
	Config Config
	Tables []*Table
}

Dataset is the fully generated workload.

func Generate

func Generate(cfg Config) *Dataset

Generate builds the whole dataset. Module builders run in dependency order and read earlier tables' rows, so relationships are consistent by construction.

func (*Dataset) DiagnosticProfile added in v0.1.10

func (d *Dataset) DiagnosticProfile() map[string]any

DiagnosticProfile extends the workload profile with isolated aliases used only by the v5 governance suite, each on its own view of wl_customers (see DiagnosticViews). Keeping them separate preserves the v4 workload baseline and its generated expectations.

func (*Dataset) DiagnosticViews added in v0.1.11

func (d *Dataset) DiagnosticViews() []string

DiagnosticViews renders the views behind DiagnosticProfile's aliases; seed them after Statements.

func (*Dataset) Profile

func (d *Dataset) Profile() map[string]any

Profile renders the runnable combined-profile server configuration for the whole dataset (PostgreSQL datasource, analyst role, all entities). Governance stays deliberately light: masks demonstrate field governance without changing task answers; row-level and denial scenarios remain the regression track's job.

func (*Dataset) Statements

func (d *Dataset) Statements(dialect string) []string

Statements renders DROP/CREATE/INSERT statements for every table of the dataset in the given dialect, one statement per element (MySQL-family drivers reject multi-statement strings).

func (*Dataset) StatementsIn

func (d *Dataset) StatementsIn(dialect, schema string) []string

StatementsIn renders the dataset with every table name qualified by schema (empty schema renders bare names; the MySQL family additionally gets a CREATE DATABASE for the schema).

func (*Dataset) Table

func (d *Dataset) Table(name string) *Table

Table returns a table by physical name or panics (programming error).

type Expectation

type Expectation struct {
	Contains []string
	Result   *ResultTable
}

Expectation is the machine-checkable outcome of one task: substrings the final answer must contain and the full expected result table.

type Oracle added in v0.1.10

type Oracle struct {
	Confounders map[string]Confounder
}

Oracle holds counterfactual wrong answers for diagnostic grading.

type ResultTable

type ResultTable struct {
	Columns []string
	Rows    [][]string
}

ResultTable is a task's expected result in canonical string form, emitted as CSV under fixtures/v4/<module>/expected/ and used by the evidence grading channel. Rows are sorted by their first column.

type Table

type Table struct {
	Module      string // commerce-core | payment-orchestration | ledger-settlement | live-monetization
	Name        string // physical table name (wl_ prefix)
	Entity      string // exposed entity name
	Description string // agent-facing entity description
	PrimaryKey  []string
	Columns     []Column
	Rows        [][]any
}

Table is one physical table spec plus its generated rows.

func (*Table) ColumnIndex

func (t *Table) ColumnIndex(name string) int

ColumnIndex returns the position of a column or panics: table specs and row builders live in this package, so a miss is a programming error.

func (*Table) Qualified

func (t *Table) Qualified(schema string) string

Qualified returns the schema-qualified physical name of the table.

func (*Table) StatementsIn

func (t *Table) StatementsIn(dialect, schema string) []string

StatementsIn renders one table's DDL and seed rows under a schema.

Directories

Path Synopsis
cmd
workloadgen command
Command workloadgen renders the checked-in fixtures/v4 artifacts from the deterministic generator: per-module DDL and seed SQL for every dialect, expected task results (CSV), per-module entity policies, and the runnable combined profile.
Command workloadgen renders the checked-in fixtures/v4 artifacts from the deterministic generator: per-module DDL and seed SQL for every dialect, expected task results (CSV), per-module entity policies, and the runnable combined profile.

Jump to

Keyboard shortcuts

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