Examples
Audience and Use
This page is for developers using Locus patterns in their own systems.
Use examples to:
- Start from known-good integration patterns.
- Validate behavior quickly in local environments.
- Translate reference workflows into production service code.
Available Example Binaries
- ../locus-sdk/examples/provider_registry_setup.rs
- ../locus-sdk/examples/memory_composition.rs
- ../locus-sdk/examples/recursive_composite_pipeline.rs
- ../locus-sdk/examples/generate_faker_fixture.rs
Run Examples
From repository root:
cargo run -p locus-sdk --example provider_registry_setup
cargo run -p locus-sdk --example memory_composition
cargo run -p locus-sdk --example recursive_composite_pipeline
cargo run -p locus-sdk --example generate_faker_fixture -- --help
Example Coverage
- Provider capability registry wiring.
- Composition workflows and multi-step orchestration.
- Recursive deterministic content construction plus strict parser and validator checks.
- Deterministic fixture generation for load and quality testing.
For domain-specific multi-agent setup patterns, see Agent Blueprints by Domain.
For practical GenAI plus STTP memory orchestration recipes, see Mini Orchestration Cookbooks.
If you want a fast path chooser by outcome and build style, start with Cookbook Overview.
Example Decision Guide
provider_registry_setup
Use when:
- You are wiring provider capability routing for the first time.
- You need to validate task-to-provider matching rules.
Expected outcome:
- Registry contains expected providers and capability visibility.
- Unsupported provider and task combinations fail with explicit errors.
Common failure checks:
- Provider IDs differ between config and runtime registration.
- Required capabilities are missing from selected providers.
Next integration step:
- Wire registry initialization into your service startup path and fail fast on missing capabilities.
memory_composition
Use when:
- You want a reference for multi-step memory workflows.
- You need recall and explain behavior in one composed flow.
Expected outcome:
- Composed workflow returns stable result shapes.
- Explain path aligns with recall outcome.
Common failure checks:
- Request policy settings are implicit instead of explicit.
- Scope filters are omitted, causing noisy result sets.
Next integration step:
- Promote composed request defaults into a shared app-level policy module.
recursive_composite_pipeline
Use when:
- You are building structured content from recursive composition.
- You need deterministic recursion-depth behavior.
Expected outcome:
- Recursive output respects depth and schema constraints.
- Content remains parser and validator compatible.
Common failure checks:
- Recursion depth exceeds configured limits.
- Output shape drifts from expected typed content structure.
Next integration step:
- Add schema-level response assertions in CI to prevent output drift before deployment.
generate_faker_fixture
Use when:
- You need reproducible fixture data for tests and benchmarking.
- You want fast local workload simulation.
Expected outcome:
- Fixture generation is deterministic for the same parameters.
- Generated payloads are valid for ingest and retrieval tests.
Common failure checks:
- Parameter ranges produce unrealistic payload distributions.
- Fixture output is not validated before being used in regression tests.
Next integration step:
- Add fixture generation to CI pre-test setup with deterministic seed controls.
Production Usage Guidance
- Treat examples as reference patterns, not deployment templates.
- Externalize credentials and environment-specific endpoints.
- Keep explicit limits and fallback policies in runtime requests.
- Add environment-specific observability and failure handling before production rollout.
Promotion Checklist
Before promoting an example pattern into production code:
- Add scope controls and policy defaults explicitly.
- Add structured error handling and retry boundaries.
- Add telemetry for latency, fallback behavior, and failures.
- Add regression tests for request and response shape stability.