Documentation
¶
Overview ¶
Package examples embeds the catalogue of runnable Pulse request JSON files and exposes a search/get API over them.
Every embedded JSON carries a top-level _meta block describing the example's name, category, taxonomy tags, the operators it uses, and a one-sentence description. Pulse's types.Request unmarshaler ignores unknown fields by default, so _meta is invisible at execution time — the examples remain runnable verbatim.
Get returns the example with the _meta block stripped, so callers can hand the JSON straight to pulse_process / pulse_predict.
Index ¶
- Variables
- func AllCategories() []string
- func AllTags() []string
- func Capabilities() map[string][]string
- func Count() int
- func DeriveOperators(body []byte) []string
- func Intents() map[string][]string
- func IsCanonicalTag(tag string) bool
- func Parse(data []byte, strict bool) (*Example, Meta, error)
- type Example
- type ExampleSummary
- type Meta
Constants ¶
This section is empty.
Variables ¶
var CanonicalTags = []string{
"time-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",
"hypothesis-test", "t-test", "parametric", "nonparametric", "paired", "one-sample",
"two-sample", "k-sample", "repeated-measures", "post-hoc",
"normality-test", "homogeneity-test", "exact-test",
"regression", "ecological",
"ols", "glm", "logistic", "bayesian",
"regularization", "ridge", "lasso", "elasticnet",
"polynomial", "resampling", "jackknife", "selection", "stepwise",
"tier-1-test", "tier-2-test", "composed", "pre-filter", "feature-pipeline",
"window-operator", "streaming-friendly", "buffered-pipeline",
"matrix", "covariance",
"leakage-risk", "small-sample",
"facet",
"sharded", "anchor",
"overlay",
"byte-equal-test",
"compose",
"crosstab",
"welch",
"welford-triple",
"z",
}
CanonicalTags is the curated taxonomy every annotated example must draw from. Kept here (rather than embedded in a separate file) so the validation gate can compare directly without round-tripping through a disk asset.
var ErrNoMeta = errors.New("missing _meta block")
ErrNoMeta is Parse's error for a JSON object without a _meta block.
Functions ¶
func AllCategories ¶
func AllCategories() []string
AllCategories returns every directory the library indexes, sorted alphabetically.
func AllTags ¶
func AllTags() []string
AllTags returns every taxonomy tag the library currently uses, sorted alphabetically. Derived from the indexed examples — not the canonical allowlist — so callers see exactly what is tagged today.
func Capabilities ¶
Capabilities returns every example's optional _meta.capabilities, keyed by example name; an example without the key is absent. Values are feature-profile spellings of non-operator features (`capability:stream`), validated by internal/descriptor (TestExamples_CapabilitiesFromFeatures), which this package cannot import. The key exists for capabilities a request body carries no structural signal for; internal/descriptor's ontology builder turns each value into an `example requires_capability <feature>` edge.
func DeriveOperators ¶
DeriveOperators returns the sorted, distinct operator names a body carries as a `"type"` value — what `_meta.operators` must equal (TestExamples_OperatorsMatchBody; embedder examples at pulse.New).
func Intents ¶
Intents returns every example's optional _meta.intents, keyed by example name; an example without the key is absent. Values are validated against the intent taxonomy by internal/descriptor (TestExamples_IntentsFromTaxonomy), which this package cannot import.
func IsCanonicalTag ¶
IsCanonicalTag reports whether tag belongs to the curated taxonomy.
func Parse ¶
Parse reads one example file: a JSON object carrying a _meta block plus the request body. It returns the Example — Body is the object minus _meta, re-marshaled deterministically — and the parsed Meta. strict refuses an unknown _meta key (embedder examples); the embedded library parses leniently. Parse does not validate Meta's values.
Types ¶
type Example ¶
type Example struct {
Name string `json:"name"`
Category string `json:"category"`
Tags []string `json:"tags"`
Operators []string `json:"operators"`
Description string `json:"description"`
Body json.RawMessage `json:"body"`
}
Example is the full record returned by Get. Body carries the request JSON with the _meta block stripped, so it can be handed verbatim to pulse_process / pulse_predict.
type ExampleSummary ¶
type ExampleSummary struct {
Name string `json:"name"`
Category string `json:"category"`
Tags []string `json:"tags"`
Operators []string `json:"operators"`
Description string `json:"description"`
}
ExampleSummary is the lightweight projection used by Search results.
func Search ¶
func Search(query string, tags []string, category string) []ExampleSummary
Search returns summaries matching all three filters. An empty filter is treated as "no constraint" for that dimension.
- query (case-insensitive substring) matches against name, description, and every operator. Score = number of distinct matches across the three fields; ties break alphabetically by name.
- tags is ANDed: an example must carry every requested tag.
- category is an exact directory match.
Returns a non-nil empty slice when nothing matches.
type Meta ¶
type Meta struct {
Name string `json:"name"`
Category string `json:"category"`
Tags []string `json:"tags"`
Operators []string `json:"operators"`
Description string `json:"description"`
// Intents is optional; every value must be an intent-taxonomy ID
// (validated by internal/descriptor's TestExamples_IntentsFromTaxonomy,
// since this package cannot import the taxonomy).
Intents []string `json:"intents,omitempty"`
// Capabilities is optional; every value must be a non-operator
// feature name (validated by internal/descriptor's
// TestExamples_CapabilitiesFromFeatures).
Capabilities []string `json:"capabilities,omitempty"`
}
Meta mirrors the _meta block every example JSON carries — built-in and embedder (pulse.Extensions.Examples) alike.