Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Request Example Library

Pulse ships a searchable, embedded library of runnable request JSON files spanning every operator category. They are checked into the repo under internal/examples/, mounted into the binary at compile time via //go:embed, and surfaced through three peer access paths:

Access pathBest for
pulse_examples_search / pulse_examples_get (MCP tools)LLM agents authoring requests against a running Pulse server
pulse examples search / pulse examples show (CLI)Developers exploring at a shell
pulse.ExamplesSearch / pulse.ExampleGet (Go API)Embedders building higher-level UIs

pulse examples data / Pulse.WriteExampleData write the cohorts the examples read (Get the data).

Get the data

The examples (and the Analysis Guide’s worked examples) read a set of fixture cohorts — experiment.pulse, transactions.pulse and the rest. The binary carries their CSVs and schemas and writes them for you:

pulse examples data --out pulse-data      # writes every fixture cohort
cd pulse-data                             # CLI cohort paths resolve against the working directory
pulse examples show t_test_two_sample > req.json
pulse api process -r req.json
pulse mcp --data-dir "$PWD"               # or serve it (from inside pulse-data)

It writes each fixture CSV imported under its schema, the point-lookup index on experiment.pulse (id), the shard archive transactions_sharded.pulse and the synthetic twin customers_twin.pulse (with customers.profile.json). An existing fixture file is refused (SERVICE_VALIDATION, details.reason: "target_exists") unless you pass --overwrite; other files in the directory are left alone. --json lists the cohorts written. The population compose/06_population_score loads is not written: run compose/05_vector_fit_save first, which saves it. From Go, p.WriteExampleData(ctx, dir, pulse.ExampleDataOptions{}) does the same through the instance filesystem.

What the library contains

Every example is a complete types.Request JSON body — the same shape you hand to pulse_process. Each file is annotated with a structured _meta block describing the example. Every request JSON decodes strictly — an unknown key is refused with PULSE_REQUEST_UNKNOWN_FIELD — but a root _meta block is tolerated by the CLI and MCP request decoders, so the file remains runnable verbatim. (A rendered request template does not tolerate it.)

{
  "_meta": {
    "name": "t_test_one_sample",
    "category": "tests",
    "tags": ["hypothesis-test", "t-test", "tier-1-test", "parametric", "one-sample", "streaming-friendly"],
    "operators": ["AGG_AVERAGE", "AGG_COUNT", "TEST_T"],
    "description": "One-sample t-test comparing revenue mean against the hypothesized mu=100."
  },
  "cohort": {...},
  ...
}

Fetching via pulse_examples_get returns the request body with the _meta block already stripped, so you can pass it straight to pulse_process / pulse_predict. The served body (pulse_examples_get, pulse examples show, Pulse.ExampleGet) also drops the files’ repo-relative "data_dir": ".data" (and the .data/ prefix of a facet population’s cohort path), so each cohort filename resolves against the server’s own data directory. The checked-in files keep it, so they run verbatim from the repo root.

A story example also declares _meta.question (the plain-language question it answers) and _meta.interpretation (a qualitative reading of its result); both ride search and get results. Its request sets return.precision, and its response is pinned by a committed golden (internal/examples/README.md, “Story examples”).

Searching the library

Four filters, all optional and combined with AND:

FilterBehaviour
queryPlain words. One word is a case-insensitive substring of the name, description or operators; several words must each match a whole word of the name, description, operators, intents or tags. Operator aliases and intent phrasings match too, then near-miss spellings when nothing matches literally
intentAn intent-taxonomy ID the example must declare (pulse skills show intents lists them); an unknown one is PULSE_RECOMMEND_INTENT_UNKNOWN
tagsAn example must carry every requested tag
categoryExact match against the example’s directory; the manifest’s example_categories lists them

CLI

pulse examples search --query welch                       # find Welch-related examples
pulse examples search --tag time-series --tag tier-2-test # AND tag filter
pulse examples search --intent compare_groups            # examples serving one intent
pulse examples search --category tests --json             # JSON envelope
pulse examples show t_test_one_sample                     # print runnable JSON
pulse examples show t_test_one_sample --json              # full record (with _meta)

MCP

// arguments to pulse_examples_search
{"query": "welch"}
{"tags": ["time-series", "tier-2-test"]}
{"category": "features"}

Go API

p, _ := pulse.New(pulse.Options{DataDir: "/data"})

// Search:
hits := p.ExamplesSearch("welch", []string{"experiment-analysis"}, "")
for _, h := range hits {
    fmt.Println(h.Name, "—", h.Description)
}

// Fetch and run:
ex, ok := p.ExampleGet("t_test_one_sample")
if ok {
    var req pulse.Request
    _ = json.Unmarshal(ex.Body, &req)
    resp, _ := p.Process(ctx, &req)
    _ = resp
}

Tag taxonomy

Tags are curated in internal/examples.CanonicalTags and validated by a CI gate (TestExamples_TagsFromTaxonomy); the table below is held to that list by TestDocsExampleTagTableMatchesCanonicalTags.

DimensionTags
Domain / use casetime-series, cohort-analysis, experiment-analysis, correlation-analysis, comparison, before-after, top-n, distribution-shape, cross-tabulation, proportion-analysis, trend-detection, outlier-detection, cardinality-analysis, data-quality, financial, feature-engineering
Statistical methodhypothesis-test, t-test, parametric, nonparametric, paired, one-sample, two-sample, k-sample, repeated-measures, post-hoc, normality-test, homogeneity-test, exact-test
Regression / modelingregression, ecological, ols, glm, logistic, bayesian, ordinal, regularization, ridge, lasso, elasticnet, polynomial, resampling, jackknife, selection, stepwise, multinomial
Pipeline machinerytier-1-test, tier-2-test, composed, pre-filter, feature-pipeline, window-operator, streaming-friendly, buffered-pipeline
Matrices and multivariate testsmatrix, covariance, multivariate
Risk / edgeleakage-risk, small-sample
Discovery / facetfacet
Cohort shapesharded, anchor
Result decorationoverlay, byte-equal-test, compose, optimize, crosstab, welch, welford-triple, z

The category (directory name) is not repeated in the tags — _meta.category carries that.

Adding a new example

Write the request under internal/examples/<category>/ against one of the fixture cohorts (cohort.data_dir = ".data") and give it a _meta block: name (snake_case, unique), category (the directory), tags from the taxonomy above, operators (every operator type in the body, alphabetized), intents and a one-sentence description. Every key and its rule is in internal/examples/README.md (“The _meta block”). Then run go test -count=1 ./internal/examples/... ./internal/descriptor/...; the TestExamples_* gates (TestExamples_DecodeStrictly, TestExamples_OperatorsMatchBody, TestExamples_IntentsFromTaxonomy, …) name any key that is wrong.