Go API Overview
Audience: Go developers embedding Pulse in a binary or a service.
Pulse is library-first. The CLI in cmd/pulse/ is a thin adapter
around the package documented here. If you’re reaching for os/exec
to shell out to the binary from Go, stop and use the library directly
— you’ll skip a process boundary and gain typed responses.
LLM agents using MCP: there is no LLM-facing skill that covers Go embedding directly. Agents speak MCP; this page is for the programs that host them.
Conventions
“Byte-identical” on the pages of this section means the serialized output compared with the output of the same request without the feature (the convention the payload schema page states): the same bytes, so a request that omits the feature gains no field and changes no hash. Where a page compares against something else, it names it.
Module path
import "github.com/frankbardon/pulse"
Sub-packages you’ll commonly touch:
| Package | Purpose |
|---|---|
github.com/frankbardon/pulse | Public facade (Pulse, Options, Request, Response, …) |
github.com/frankbardon/pulse/types | Request/response structs, component-type constants (AGG_*, …) |
github.com/frankbardon/pulse/io (imported as pio) | Jobs (ImportJob, ExportJob, ConvertJob, …), Reader / Writer, and the factory: pio.NewReader(pio.FormatCSV, fs, path, pio.ReaderOptions{}), NewReaderFromBytes, NewWriter, NewWriterToBuffer, FormatFromPath |
github.com/frankbardon/pulse/errors | Typed CodedError system and code constants |
github.com/frankbardon/pulse/descriptor | Result and envelope types for manifest, predict, inspect (Envelope, Manifest, PredictResult, InspectResult) |
github.com/frankbardon/pulse/synth | Synthetic data specs, profiles, Synth / SynthBytes for fixtures |
github.com/frankbardon/pulse/encoding | Schema nouns and the ungrouped raw-byte primitives |
github.com/frankbardon/pulse/mcp/gosdk, .../mcpserve | Mount Pulse’s MCP tools on your server / run a ready-made one |
github.com/frankbardon/pulse/extend | The operator-authoring API for extensions (Writing Operators) |
github.com/frankbardon/pulse/observe (+ /otel, /prom) | Logs, hooks and metrics vocabulary and adapters (Observability) |
.../linalg, .../optimize, .../mcmc | Numerical building blocks Pulse’s estimators use (Linear Algebra, Numerical Optimization, MCMC) |
Everything under internal/ — the engine, the per-format adapters, the
MCP core, the skill pack, the filesystem config — is not importable from
outside the module. The skill pack is reachable through the MCP skill
tools, pulse skills, or the manifest’s skills block.
The facade
Construct a Pulse once per process (or per filesystem boundary) and
re-use it:
p, err := pulse.New(pulse.Options{
DataDir: "/var/data/pulse",
})
if err != nil {
return err
}
The full Options shape (custom afero.Fs, smart-default toggling)
is documented at pulse.New & Options.
Public methods
From pulse.go:
| Method | Purpose |
|---|---|
Open(ctx, path) (*Cohort, error) | Read header + schema, return a typed Cohort handle |
Process(ctx, req) (*Response, error) | Execute one request |
ProcessStream(ctx, req) (RowIter, error) | Same, pull-based iterator over result rows |
Compose(ctx, req) (*ComposedResponse, error) | Execute a batch sequentially; Responses[i] answers Requests[i] |
ComposeParallel(ctx, req, opts) (*ComposedResponse, error) | Execute a batch in parallel with a worker pool |
Import(ctx, job) (*ImportReport, error) | Tabular → .pulse |
Export(ctx, job) (*ExportReport, error) | .pulse → tabular |
Convert(ctx, job) (*ConvertReport, error) | Tabular → tabular, with .pulse as the transparent middle |
Inspect(ctx, path) (*InspectResult, error) | Read header + schema only (no record data) |
InspectEnvelope(ctx, path, opts) (*Envelope, error) | Same read, envelope returned whole — carries the warnings Inspect drops (e.g. a truncated payload tail) and takes descriptor.InspectOptions |
InspectBytes(ctx, data, opts) (*Envelope, error) | Inspect an in-memory cohort (single file or shard archive); envelope returned whole, warnings included |
ListCohorts(ctx, opts) ([]CohortListEntry, error) | Every .pulse cohort under the data root (or opts.Dir), recursively, sorted by root-relative path: record count, fields (name, type, nullable), shard-archive and managed-import flags. Header and schema only; sidecars, hidden entries and an archive’s own shards are skipped, an unreadable .pulse file is listed with its coded Error, and a managed import’s expiry is not slid |
Predict(ctx, req) (*PredictResult, error) | Validate a request without executing |
PredictEnvelope(ctx, req) (*Envelope, error) | Same header-only read as Predict (an archive’s central directory and shard headers, an anchor’s one entry, through the instance filesystem), envelope returned whole — Options.Strict / Options.EchoRequest come from the instance, as for PredictBytes; what pulse api predict calls |
PredictBytes(ctx, data, req) (*Envelope, error) | Validate a request against an in-memory cohort; the extension snapshot, Options.Strict and Options.EchoRequest come from the instance |
PredictCompose(ctx, req) / PredictFacet(ctx, req) / PredictChain(ctx, req) (*Envelope, error) | Validate a Compose batch, facet request or ProcessChain without executing it; the whole envelope comes back, Data a *ComposePredictResult / *FacetPredictResult / *ChainPredictResult with each refusal a coded Errors entry |
CohortArtifacts(ctx, cohort) ([]string, error) | Every Pulse-owned sidecar that exists beside a cohort (point-lookup indexes and Bloom files, .indexes.json, .spss.json, .meta.json, an interrupted-append .append journal), sorted: what must move with it (keep the cohort’s mtime: the index and SPSS sidecars fingerprint it) |
Sample(ctx, path, n) ([]Record, error) | Up to n rows |
Facet(ctx, path, field) ([]string, error) | Distinct values of a field |
Synth(ctx, spec, out, opts) (*SynthResult, error) | Generate a synthetic cohort |
PredictMaterialize(ctx, req) (*Envelope, error) | Validate a Materialize request without executing it (header and schema only, nothing written): Data a *descriptor.MaterializePredictResult — the output columns, derived names and data-dependent risks — with each refusal a coded Errors entry carrying the run’s code — see Materializing Derived Columns |
Materialize(ctx, req, out, opts) (*MaterializeResult, error) | Write a new cohort: the filtered source records plus one nullable f64 column per derived output (features, attributes, windows), or the columns a request output block lays out, as a single file or a shard archive — see Materializing Derived Columns |
Rake(ctx, req) (*RakeResult, error) | Compute rim / cell survey weights to population margins and write them, beside every source column, into a new cohort — see Computing Survey Weights |
Profile(ctx, path, opts) (*Profile, error) | Statistical summary suitable for from-profile synthesis |
WriteExampleData(ctx, dir, opts) (*ExampleDataReport, error) | Write the fixture cohorts the built-in examples read into dir, from data embedded in the binary; an existing fixture file is refused unless opts.Overwrite — see Get the data |
Manifest(ctx) *Manifest | Deterministic root self-description |
Fs() afero.Fs | The underlying filesystem (used by pulse mcp and other embedders) |
Re-exported type aliases let you write pulse.Request instead of
types.Request:
type (
Request = types.Request
Response = types.Response
ComposedRequest = types.ComposedRequest
SynthSpec = synth.Spec
Profile = synth.Profile
// … and so on
)
Minimum viable embed
package main
import (
"context"
"fmt"
"log"
"github.com/frankbardon/pulse"
"github.com/frankbardon/pulse/types"
)
func main() {
ctx := context.Background()
p, err := pulse.New(pulse.Options{DataDir: "/var/data/pulse"})
if err != nil {
log.Fatal(err)
}
resp, err := p.Process(ctx, &pulse.Request{
Cohort: &types.Cohort{Filename: "sales.pulse"},
Aggregations: []*types.Aggregation{
{Type: types.AGG_AVERAGE, Field: "revenue", Label: "avg_revenue"},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Data)
}
Where to go from here
- Embedder Walkthrough — the decisions in order: Options, extensions, profiles, limits, observability, response shaping, MCP serving.
- pulse.New & Options — full
Optionsreference. - Custom Filesystems — in-memory testing pattern, custom storage backends.
- Streaming & ProcessStream — pull-based iteration, what streams vs what buffers.
- Parallel Compose — worker pool, fail-fast, per-request timeout.
- Feature Profiles — declare the instance’s feature set; validation codes and the MCP server entry point.
- Per package: Readers, Writers & Jobs (io), Synthetic Data (synth), Writing Operators (extend), Serving MCP (mcpserve, mcp/gosdk).