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.
Crate features
serde(default) – enables serde derives and helpers (pullsserde_withfor stable semver + base64 encodings).time(default) – enablestime::OffsetDateTimehelpers for deadlines and telemetry spans.uuid– adds UUID-based constructors for session keys.schemars– emits JSON Schemas for all public types (used by docs and CI conformance tests).std(default) – allows attaching source errors toNodeError/GreenticError.
Disable defaults for fully no_std builds:
= { = "0.1.4", = 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
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
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.
Development workflow
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).
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.
Pack specifications
Legacy pack manifests remain available via greentic_types::pack_spec::{PackSpec, ToolSpec} for backwards compatibility during the MCP migration. New packs should still embed their contracts in greentic-interfaces.
License
MIT License. See LICENSE.