Workflows

Outcomes and shadow learning

Learn how durable outcome state machines and reporting-only cohort analysis preserve attribution without changing production behavior.

GTM Brain records outcomes through versioned Temporal commands. Touch response, account relationship, and sales opportunity are separate state machines so a delivery event cannot silently become a sales-stage claim.

Versioned states

State modelValuesAuthority
Touch outcomedelivered/no reply, positive, negative, not now, bounce, unsubscribe, spamauthenticated provider event or governed human command
Account relationshipcold, contacted, replied, meeting, suppressedderived from governed touch outcomes; corrections are explicit
Opportunitynone, qualified, proposal, won, lostgoverned human command; CRM source deferred until an adapter exists

Corrections reference the exact prior transition and record actor, source, reason, and gtm-outcome-state-v1. Duplicate, conflicting, cross-account, and invalid transitions fail closed. These mutations use gtmActionWorkflowV2; they never write directly from an API route.

The authenticated API exposes three explicit durable commands:

POST /gtm/outcomes/v2
POST /gtm/outcomes/v2/correct
POST /gtm/opportunities/v2/transition

For example, a manual opportunity transition supplies its current state and an idempotent transition ID. The server derives source: manual, the actor from the session, the accepted state-model version, and forces the V2 Temporal route:

{
	"organizationId": "org_123",
	"commandId": "01J...",
	"transition": {
		"transitionId": "01J...",
		"companyId": "company_123",
		"fromState": "none",
		"toState": "qualified",
		"occurredAt": "2026-07-13T20:00:00.000Z"
	}
}

Immutable cohort attribution

Each new touch snapshots signal subtype, service-play and offer versions, normalized buyer function, outreach play, prompt version, proof version, and scoring-policy version. Lakebase migration 11 adds the immutable snapshot additively; historical rows retain an explicit legacy fallback so an older draining worker remains write-compatible during rollout.

Shadow reports group those snapshots, count attributed positive outcomes, and compute a Beta-smoothed rate. Dry-run touches are excluded. Reports can suggest what deserves investigation, but cannot select a contact, score, offer, proof, or copy variant.

const report = await computeShadowCohortReport(store);
// Reporting only. There is intentionally no production apply method.

Learning safety

gtm-learning-policy-v1 is fail-closed: mode is shadow_only, production activation is false, and environment variables cannot enable it. Production drafting stays pinned to the accepted control variant. adjustWeights may emit a shadow report, but may not persist weights that affect judging.

A future activation requires a separate accepted decision with calibration thresholds, minimum samples, rollout/rollback rules, and isolation tests.

Next: Replies, Evidence and scoring, and Databricks analytics.

On this page