On this page
- Status: Proposed (2026-07-17); deferred by ADR 0060, which keeps the causal service out of scope
- Date: 2026-07-05; revised 2026-07-17
- Context: CLAUDE.md §55/§60/§66, ADR 0004, mso-17 evidence status, mso-19 agentic roadmap
Context#
The TypeScript decision kernel has shipped L1 rule receipts and L2 signal snapshots. It also has useful L3 pre/post, L4 policy/OPE and L5 monitoring prototypes. Those prototypes do not yet prove causal identification, trustworthy off-policy evaluation or a production closed learning loop.
Capabilities such as Bayesian MMM with adstock/saturation, hierarchical partial pooling and conformal
intervals benefit from the Python scientific stack. apps/ml already exists, but is deliberately
experimental/quarantined: its current endpoint is a naive moving-average demonstration, not calibrated
forecasting or causal inference. Creating a parallel services/mso-causal tree would duplicate ownership
before the compute contract is proven.
The former proposal had two invalid assumptions:
- a read-only RLS identity cannot write result tables; and
- reproducing
sim/decision_log.jsonvalidates deterministic decision regression, not causal truth.
Decision (proposed)#
Keep the TypeScript decision kernel and RLS-bound worker as the authority. Evolve apps/ml only after the
following contract is accepted.
1. Immutable job input
Within the owning transaction, the TypeScript worker records/enqueues a durable compute intent referencing an immutable input snapshot or content-addressed artifact. The manifest contains org/brand scope, ICT window, metric/estimand, treatment/control definition, feature schema, source cutoffs, code/model version and content hash. Python receives no ambient tenant authority and never chooses its own data scope.
2. Compute-only Python boundary
Python reads the supplied artifact/input, performs the fit and returns a typed result artifact. It does not write UCIP domain tables and does not mint decisions/actions. The result carries:
- job/input/model/code hashes and deterministic seed;
- diagnostics, uncertainty and failure/abstain reason;
- design-specific evidence (assignment/exposure/contamination for experiments; pre-trend/falsification for quasi-experiments; posterior predictive diagnostics for MMM);
- structured estimates in canonical integer/basis-point units plus raw scientific artifact references.
Long-running compute remains outside request and RLS transactions.
3. Validate and persist in TypeScript
The worker validates schema, scope, hashes, freshness, numerical bounds and required diagnostics. Only then
does it persist an advisory model result inside runWithRlsContext/orgProcedure ownership. Any new table,
RLS policy, runtime identity or brand ownership rule requires the human approval mandated by CLAUDE.md.
The result becomes a versioned signal; the deterministic Rule DSL/guardrails remain the decision authority.
4. Evaluation before influence
No result may affect a proposal until its evaluation report passes:
- causal identification/design review and pre-registered estimand;
- temporal/brand holdout where applicable, baseline comparison and sensitivity/falsification checks;
- calibration/coverage and stability across slices;
- replay from the exact input/artifact hash;
- human approval, rollback target and expiry.
decision_log.json remains a frozen regression oracle for the existing deterministic loop only.
Non-decisions#
- No schema, RLS, runtime-identity or production deployment is approved by this ADR while status is Proposed.
- No per-request inference or Python-to-domain-DB write path.
- No claim that pre/post equals a randomized holdout.
- No new agent framework; orchestration continues through the existing durable worker/outbox boundaries.
Alternatives considered#
- New
services/mso-causal/service immediately. Rejected for now: duplicatesapps/mland hardens an unproven contract. - Python writes
mso_causal_*with a read-only role. Rejected: internally contradictory and splits tenancy/persistence ownership. - Re-implement scientific inference in TypeScript. Rejected: duplicates validated scientific tooling.
- Serverless per-request fitting. Rejected: violates latency and transaction boundaries.
- Push inference into Cube. Rejected: Cube is a semantic read layer, not an inference engine.
Acceptance gate#
Before changing this ADR to Accepted:
- approve one concrete estimand/design and privacy threat model;
- define the versioned input/result schemas and idempotency/retry semantics;
- demonstrate a replayable offline PoC with diagnostics and failure cases;
- review resource budgets, observability, artifact retention/deletion and rollback;
- obtain explicit approval for any schema/RLS/runtime identity changes.
Status of work#
No causal service or production compute contract is implemented. apps/ml is an honest experimental
starting point only. The next safe deliverable is the offline contract/PoC; schema and runtime changes wait
for approval.