greentic-types
Shared primitives for Greentic’s next-generation runner, deployer, connectors, packs, and state/session backends.
Every repository in the greentic-ng stack depends on these types to exchange tenant identity, session cursors, state pointers, policy decisions, pack references, and canonical error/outcome envelopes.
Feature flags & MSRV
- Default (
std,serde,time,otel-keys) – the recommended configuration for runners, CLIs, and tooling. schema– pulls inschemars,anyhow, andserde_jsonso you can callwrite_all_schemasor theexport-schemasbinary. (Derives continue to sit behind the lighterschemarsfeature for backwards compatibility.)otel-keys(default) – exposestelemetry::OtlpKeysand the schema for the OTLP attribute constants without requiringtelemetry-autoinit.telemetry-autoinit– bundles the OTLP stack and task-local span helpers.uuid– adds UUID-based constructors forSessionKey.
MSRV: Rust 1.85 (required by the 2024 edition). The MSRV is enforced in CI; when bumping it, update both Cargo.toml and the workflow matrix.
Disable defaults for fully no_std builds:
= { = "0.3.0", = false, = ["serde"] }
Quickstart
use ;
let ctx = new
.with_team
.with_user;
let cursor = new
.with_wait_reason
.with_outbox_marker;
let require_human: = Pending ;
let allow_policy = AllowList ;
assert!;
assert_eq!;
assert!;
Sessions & telemetry
use ;
let session = generate;
let span = new
.with_session
.with_node;
Outcomes & errors
use ;
let outcome = match validate ;
Schema generation & publishing
cargo run --bin export-schemas --all-featuresruns the helper binary and writes JSON Schemas intodist/schemas/v1/.- Published schemas (and canonical URLs) live in SCHEMAS.md; CI pushes them to GitHub Pages automatically.
Telemetry (auto-init)
- Enable with
features = ["telemetry-autoinit"]to bundle the OTLP stack and entry-point macro. #[greentic_types::telemetry::main(...)]wrapstokio::main, installs OTLP once, and forwards to your async main.install_telemetry("name")is available if you need to wire custom runtimes or tests manually.- Uses
OTEL_EXPORTER_OTLP_ENDPOINTwhen set (defaults tohttp://localhost:4317). set_current_tenant_ctx(&TenantCtx)maps the current tenant into the task-local telemetry slot.
use ;
use set_current_tenant_ctx;
async
Flow, component, and pack models
Flow,Node,FlowKinddescribe.ygtcgraphs using insertion-ordered maps so the first node stays the implicit ingress.ComponentManifestcaptures capabilities, configurators, and exposes helpers likesupports_kindandselect_profile.PackManifestbundles flows, component requirements, opaque profile/source/connector metadata for.gtpack, and now includes the optionalPackKindhint (application,deployment, ormixed).HostCapabilitiesexpose generic IaC toggles via theiacblock so deployment components can request template write/execute access without encoding provider details.DeploymentPlanis the shared, provider-neutral description of what needs to run for a tenant/environment; deployers and runners exchange it as JSON when orchestrating deployment flows.
Read MODELS.md for the guiding principles: IDs are opaque strings, capabilities only describe host/WASI interaction, and bindings stay outside of these documents.
use ;
Flow also exposes ingress() to fetch the implicit entrypoint, while ComponentManifest::select_profile handles profile fallback logic without re-implementing it elsewhere.
Harmonised model
- TenantCtx & TenantIdentity – shared across runner, connectors, and state/session stores; keeps legacy (
tenant,team,user) and next-gen (tenant_id,team_id,user_id,impersonation) fields aligned. - SessionKey/SessionCursor – referenced by session routers and state stores.
- StateKey/StatePath – JSON pointer compatible navigation for persisted state.
- Outcome & GreenticError – canonical execution envelope for nodes, adapters, and tools.
- AllowList/NetworkPolicy & PolicyDecision – security model used by deployer and connector sandboxes.
- PackRef/Signature – pack registry references with deterministic semver + base64 signatures.
- SpanContext – OTLP-aligned telemetry context (tenant, flow, node, provider, start/end).
Working with other crates
greentic-runner,greentic-session-store,greentic-state-store,greentic-deployer,greentic-connectors, andgreentic-packsdepend on this crate. Always add new shared types here first to avoid duplication.- ABI/WIT contracts live in greentic-interfaces; never re-define those types here.
Adopt in other repos
- Replace bespoke definitions of
RunResult,RunStatus,NodeStatus,NodeSummary,NodeFailure,Capabilities,Limits,TelemetrySpec, the ID newtypes (PackId,FlowId, etc.), and now the pack/flow/component schemas with the versions exported bygreentic-types. - Hook your manifests, CLIs, and IDE tooling to the canonical schema URLs from SCHEMAS.md for validation.
- Add a dependency on this crate (with the appropriate features) before introducing new shared structs so CI can enforce the no-duplicate rule.
Development workflow
Local CI mirror
Before pushing, run the bundled CI mirror which replicates the GitHub Actions steps:
Toggles:
LOCAL_CHECK_ONLINE=1– enable networked checks (schema URL curl).LOCAL_CHECK_STRICT=1– fail when required tools (rustup, curl, etc.) are missing.LOCAL_CHECK_VERBOSE=1– print every command before it runs.
Example:
LOCAL_CHECK_ONLINE=1 LOCAL_CHECK_STRICT=1
Tip: add a Git hook to run it automatically:
CI (see .github/workflows/publish.yml) enforces the same gates on push/PR. Legacy v* tags still trigger the workflow alongside per-crate tags.
Maintenance notes
- All public structs derive
schemars::JsonSchemawhen the feature is enabled; integration tests assert schema registration and serde round-trips. GResult<T>aliasesResult<T, GreenticError>for consistent error propagation.- Prefer zero-copy APIs; the crate is
#![forbid(unsafe_code)]. - Use feature flags to keep downstream binaries lightweight (e.g., disable
uuidin constrained connectors). - The crate version is exposed at runtime via
greentic_types::VERSIONfor telemetry banners or capability negotiation.
Releases & Publishing
- Versions come directly from each crate’s
Cargo.toml. - Pushing to
mastertags any crate whose version changed in that commit using<crate-name>-v<semver>. - After tagging (or even when no tags are created), the publish workflow attempts to publish all changed crates via
katyo/publish-crates@v2. - Publishing is idempotent; attempting to release the same version again succeeds without errors.
Legacy pack_spec
Legacy pack manifests remain available via greentic_types::pack_spec::{PackSpec, ToolSpec} while older MCP-style packs are migrated. New packs should rely on PackManifest + .ygtc flows instead; once all callers move over we will fully remove pack_spec.
License
MIT License. See LICENSE.