# The Gateway is the math machine

Authority: current product and architecture explanation. The exact runnable surface is generated by `cd harness && npm run precise -- describe`. Deployment status comes from estate coverage and drift, not this page.

## Current answer

The Gateway accepts JSON data, a named mathematical method, a seed, and a resource envelope. It returns and retains the literal output and diagnostics. It does not decide whether the result is persuasive, commercially wise, or allowed by a product policy.

Precise's Harness owns Precise workflows and artifacts. A workflow chooses methods, prepares their inputs, runs useful variants together, interprets disagreement, and appends another cycle when an outcome arrives. The retained continuation workflow is durable execution history, not hidden mathematical state: it keeps full step inputs and outputs, raw Gateway references, outcomes, and earlier cycles, but it does not keep an incrementally updated primitive or model. Another company can build a factory, trading, logistics, or other harness over the same public math without copying it.

The company harness chooses and composes methods from connected sources, an accepted field map, and the person's goal, then reruns them when data changes while the Product keeps the last complete answer visible. Its artifact projector returns the finest supported controllable primitives—with measured contribution, uncertainty, interactions, current size, and marginal value—so each can load into a proposed move. Unsupported dimensions remain missing. That decomposition describes measured evidence; it does not establish a causal effect.

```text
company data and ontology
          |
          v
company workflow and input transforms
          |
          v
Gateway method catalog -> immutable raw run results
          |
          v
company interpretation, artifact, and action adapter
```

Precise owns this Gateway and its reusable math. Boombox may host the application and deliver authenticated calls or events. Hosting does not transfer the product, methods, customer relationship, workflow meaning, or artifact ownership.

That ownership boundary is bookkeeping. It is not a computation gate.

## Raw result and artifact

A Gateway result is the machine's answer:

- tenant-bound run and request identity;
- method and immutable implementation-bound version;
- input and execution-control digests;
- seed and resource envelope;
- `succeeded`, `not_computable`, `failed`, or `cancelled` status;
- literal JSON output and diagnostics;
- digest of the complete retained record.

An artifact is a Harness interpretation of one or more results for a human or another system. It may state findings, compare estimators, name changed outcomes, explain uncertainty, propose a next move, or feed an authorized action adapter. It references the raw run records and never replaces them.

The current Precise cycle artifact contains raw run references, prior-cycle changes, same-cycle adversarial comparisons, and numeric estimate gaps. Customer-specific reports and narratives remain separate artifact builders.

The workflow record is broader than the artifact. It retains the literal input and output for every step, its diagnostics and status, and the raw run ID, method version, and result digest. The artifact intentionally uses references and digests; the workflow history retains enough data to reopen or resume the cycle.

## Public surface

The Gateway child is deliberately small:

- `math methods`
- `math run`
- `math result`
- `math status`
- `math cancel`

The Precise layer exposes workflows rather than dozens of isolated buttons:

- `workflow workflows`
- `workflow start`
- `workflow focus`
- `workflow outcome`
- `workflow result`

Direct method calls remain public for workflow authors, researchers, advanced customers, and new verticals. The catalog supplies each method's exact version, input schema, output schema, and scaling modes.

There are no shadow/recommend/write rungs, required-rung fields, claim ceilings, product-policy checks, or advertised refusal vocabularies in this surface. Authentication, tenant isolation, byte integrity, resource protection, and external-action authority remain separate mechanical controls.

## Connected math

The default development tree has 24 methods. Seventeen are dependency-light and seven need one of two Python workers.

| Family | Methods | What they return |
|-|-|-|
| Calibration | `calibration/split-conformal-band`, `calibration/breadth` | Group-conditional bands and rolling-origin calibration evaluation. |
| Power and reference | `power/holdout`, `par/fit` | Holdout sensitivity and attainable comparable-cell reference fits. |
| Measured capture | `capture/adjusted-reference-point`, `capture/in-band-mass`, `capture/self-mass`, `capture/net-external-mass` | Reference adjustment and the four parts of a measured capture tape. |
| Additive value | `value/additive-fit`, `value/additive-predict` | Seeded additive surrogate, fit error, contribution, and coalition prediction. |
| Curved value | `value/gradient-fit`, `value/gradient-analyze` | Curved response fit, interactions, marginal gradient, action bands, and integrated contribution. |
| Contribution | `contribution/shapley`, `contribution/shapley-intervals`, `contribution/pairwise-interaction`, `contribution/owen` | Exact, sampled, parallel, interval, pairwise, and grouped contribution from the trace-score worker. |
| Caller-evaluated contribution | `contribution/from-observations` | Shapley, Owen, and sparse pair estimates from caller-evaluated permutation or four-corner observations, with variance, standard error, intervals, denominator, and design provenance. |
| Response | `response/saturation`, `response/regime-detection` | Hill response/saturation fits and response-regime analysis. |
| Allocation | `next-dollar/frontier`, `next-dollar/price`, `portfolio/select` | Marginal-value frontier, priced reallocation, and overlap-aware budget selection. |
| Research design | `research/posterior-acquisition`, `research/markov-transition` | Exact finite-posterior information value and held-out first-order or contextual transition models. |

The TypeScript methods and caller-observation reducer are always available in the default composition. The four trace-score and three calibration-breadth methods appear only when their workers are configured. A remote worker URL is insufficient by itself: the standing composition also requires a `sha256:` release binding, verifies the worker's declared core name and version on first use, and puts the bound release into the method version and run identity.

## `n` is data

The Gateway has no global 16-item limit.

Exact finite-game algorithms are exponential, so exact Shapley is bounded at 20 players and exact pair/Owen calculation at 16. Those limits describe particular algorithms. They do not describe the service or the problem size.

For larger work:

- Shapley routes to seeded complementary or parallel sampling;
- pair interaction routes to sampling and can take a sparse pair list;
- Owen contribution routes to group-respecting sampling;
- `contribution/from-observations` lets another vertical evaluate its own value function outside the Gateway and send only sampled prefix or four-corner observations for reduction;
- additive and curved surrogates provide compact fitted value functions when their assumptions suit the problem;
- every result names the requested and completed denominator.

A complete coalition table is still accepted for a small arbitrary finite game. It grows as `2^n`, so it is not the large-`n` API.

The worker bridge has a 16 MiB request-body limit and bounded concurrent POSTs. A caller may also set array-length, sample-count, and time ceilings. These protect the service without hiding items from the analytical denominator.

## Workflow methodology

Precise currently exposes four continuing workflows plus a focused one-cycle workflow.

### Understand the book

Runs exact and sampled Shapley, exact and sampled pair interaction, exact and sampled Owen contribution, caller-observation contribution, additive and curved value fits, par, capture, and regime analysis. Additive prediction consumes the same-cycle additive fit, and gradient analysis consumes the same-cycle gradient fit. The other analyses run independently.

### Find the next move

Fits and analyzes the curved value surface and also runs saturation, next-dollar frontier, pricing, and portfolio selection. Only gradient fit feeds gradient analysis today. Saturation does not feed the frontier, and the frontier does not feed pricing or portfolio selection; those are parallel results for a later Product interpreter.

### Design the test

Runs holdout power, exact posterior information value, and held-out Markov transition scoring as three parallel analyses. It does not yet combine their outputs into one test choice.

### Measure and learn

Recomputes calibration, contribution, interaction, value, and transition results as outcomes arrive. Gradient fit feeds gradient analysis; the other steps are parallel. Each accepted outcome appends a new cycle. Workflow-level patches and per-method overrides are replayed over the original inputs without rewriting earlier cycles.

### Answer a focused question

Runs the smallest caller-selected set of mounted methods once through the same version-bound proxy and result records.

Every continuing cycle keeps the raw Gateway references. When the same method runs in more than one variant, the artifact aligns result keys and reports numeric gaps, uncertainty overlap where available, missing keys, status disagreement, and diagnostics. It also compares each step with its prior outcome cycle.

This adversarial work is evidence, not a gate. A disagreement is returned to the caller; it is not used to suppress a creative or unusual computation.

## Workflow state

Within one cycle, an explicit dependency can pass an earlier result into a later method. The current reusable transport is limited to additive fit into additive prediction and gradient fit into gradient analysis. There is no general current-model slot shared by all primitives.

Across cycles, the workflow reconstructs method inputs from the original `method_inputs`, every earlier outcome's `workflow_input_patch` and method-specific overrides, and the newest outcome. Nested objects merge, while later arrays and scalar values replace earlier ones. It then runs every named step again with a new cycle request. An earlier Markov model, calibration result, contribution estimate, response fit, frontier, or portfolio remains an earlier result; it is not automatically applied to the next cycle.

Durable file and GCS stores retain completed cycles, accepted outcome bytes and values, and pending-cycle progress. After a restart, the workflow reuses steps already saved in the pending cycle and retries only unfinished work. If a Gateway terminal result was saved before the process stopped, the repeated deterministic request retrieves it.

This state is sufficient for math orchestration, result comparison, restart-safe analysis history, and demos that show new results after an outcome. It is not the complete Product state for the Trust Portal or another closed-loop product. Precise Decision Learning remains separate: it owns baseline observations, recommendations, actual exposure, mature outcomes, scores, learning decisions, exact source references, accepted learned-state successors, and authorized actions.

## Outcomes

An authenticated direct outcome call verifies that the supplied parsed JSON matches the supplied exact bytes, deduplicates the event, and appends a successor cycle.

The standing event path is payload-free. An authorized Product adapter writes the exact outcome to tenant-bound create-only file or GCS custody. Boombox delivers a signed head pointer. The reader verifies platform tenant, Product tenant, subject kind, sequence, content digest, exact bytes, and workflow IDs before continuing the workflows. There is no unauthenticated outcome write route.

The resulting workflow cycle currently keeps the event ID, exact outcome bytes, and parsed outcome value. It does not carry the signed subject ID, head sequence, and head digest as a direct source pointer, so a Trust surface must join the separate outcome-custody record to show that lineage.

## Failures and diagnostics

Security and machinery can stop a request:

- unauthenticated or wrong-tenant access;
- changed result, workflow, event, or outcome bytes;
- malformed JSON or a mathematically required missing input;
- non-finite arithmetic that cannot be represented as JSON;
- worker unavailability, resource exhaustion, deadline, or cancellation;
- an external side effect without authenticated action authority.

Analytical limitations stay in the result:

- an exact algorithm above its feasible size is `not_computable`, while an admitted sampled variant can still run;
- thin history, absent support, incomplete samples, unusable intervals, and missing pair observations are diagnostics;
- partial caller observations retain partial estimates and the full requested/computed denominator;
- newer stored schema families and future status names remain readable when their integrity bindings verify.

## Persistence and current limits

Terminal Gateway results are durable in local-file and GCS stores. Workflow cycles and outcome records are durable in local-file and generation-checked GCS stores. Repeated requests, events, and outcome heads are content-bound and duplicate-safe.

`math run` is not a detached durable job queue yet. It returns after the method reaches a terminal state; queued and running state is process-local. Workflow DAGs still run independent steps concurrently, and outcome events can append work indefinitely, but a process restart does not resume an active individual method call. Documentation and status output must keep that distinction explicit.

A waiting continuation workflow can continue only while its exact workflow and method versions remain mounted. A method or workflow version change currently leaves the old record readable but prevents another outcome cycle; there is no old-version registry or migration path yet.

Each settled step writes a complete workflow revision containing all earlier cycles and full step inputs and outputs. File and GCS stores retain those revisions. Written and retained bytes therefore grow quickly with both step count and cycle count; there is no compaction or retention policy yet.

This implementation is connected in the repository. No recorded staging revision contains it. The 2026-09-02 staging observation, `app_rev_4ac0c1d7`, predates the current `math` child and default continuation workflows.
