Compiler
The compiler is the step between an approved scenario and a run. Its input is a scenario specification, the typed description of a question. Its output is a run manifest: the full specification of one run, with a hash of its own content. For a specification with an error, the output is a list of typed errors without a manifest.
Inputs
The first input is a scenario specification. It is a typed document, and a key outside its schema is an error.
| Field | Content |
|---|---|
| Place | A bounding box in latitude and longitude. For a place name, the coordinates are a condition of compilation. A model with no location, such as a stock-and-flow model, has a nonspatial reference in place of the box. |
| Time | A start and an end in ISO 8601 form, and the length of one tick in seconds. |
| Models | A list of invocations. Each invocation has an identifier, the name of a capability, the exact version of the capability's contract, an input document, a configuration document and a list of its dependencies. |
| Branches | Named sets of invocations for a comparison, such as one branch for the streets of today and one for the streets after a change. Every invocation is in exactly one branch. |
| Limits | The largest number of simulated agents, the longest run time, the compute time and the storage. |
| Seed | The seed for random numbers. |
| Outputs | The format of the results. |
A capability is one method of one model under a versioned contract. The contract has a schema for the input, a schema for the configuration and the exact method behind the name.
The second input is the capability registry, the platform's list of capabilities. A capability is found there by its name and the exact version of its contract.
On an AI assistant's path and in the browser, the source of a specification is a setup with your approval. An approval is bound to a digest of the setup, and a setup with a different digest is refused before compilation.
Outputs
A successful compilation has a run manifest as its output. A manifest has these parts:
- the place and the time range in resolved form, with the duration in seconds;
- the models in execution order, each with its capability, the exact version and a digest of the contract, the exact method, and the validated input and configuration;
- the seed of the run;
- a complete copy of the source specification, with its SHA-256 digest;
- the time of compilation;
- the manifest hash.
The manifest hash is the SHA-256 digest of the manifest in canonical JSON (RFC 8785, the JSON Canonicalization Scheme). The time of compilation and the audit context of the call are outside the hash.
A failed compilation has a list of errors as its output. Each error has a code, the stage of the compiler and the location in the document. A trace is part of both outcomes: the completed stages, and each resolved value with its reason.
Guarantees and their checks
Each guarantee has a mechanism in the compiler and at least one test in the platform's test suite.
| Guarantee | Mechanism | Check |
|---|---|---|
| One specification has one manifest hash. | Canonical JSON and SHA-256, with the time of compilation outside the hash. | In a test, one specification is compiled twice, and the two hashes are equal. In a second test, two manifests with different compilation times have the same hash. |
| The execution order is independent of the order of the models in the document. | A topological sort of the dependencies, with the invocation's identifier as the tie-break. | In a test, one set of independent models is compiled from two document orders, under several hash seeds of the Python interpreter, each time in a new process. The execution order is identical in every case. |
| Every resolved field of a model is inside the hash. | The hash is over the whole manifest. | In a test, each resolved field of a model is changed in turn, and the hash is different each time. |
| Every run has a seed. | A seed in the specification is the seed of the run, without any change. For a specification without one, the seed is the first 32 bits of the SHA-256 digest of the scenario's identifier. A setup for review has a missing seed on its list of open choices. | In tests, a given seed is unchanged in the manifest, a second derivation has the same seed, and two scenarios with different names have different seeds. |
| A capability is matched by name and exact version. | A lookup in the registry. | In tests, an unknown name, a different version and an inactive capability each have a typed error as their result, and no manifest. |
| An error has a code and a location. | The result of every stage is success or a list of typed errors. | The tests are of an unknown key at the root of the document, an invalid input for a capability, a duplicate identifier, a cycle of dependencies, a place without coordinates and an invalid time. The result of each is a typed error at the right location. |
| Branches are separate. | Every invocation belongs to exactly one branch, and each dependency is inside the same branch. | In tests, a dependency across two branches, an invocation outside every branch and an invocation with two owners are each an error. |
Place in the path of a question
- You ask a question, and your AI assistant proposes a scenario. In the browser, you can also change a proposed setup by hand.
- You approve the setup in your browser.
- The approved setup is compiled, and the result is the run manifest.
- The manifest is the input of the engine. Before the first model, the manifest's hash is computed again, and the source specification inside the manifest is compiled a second time against the current registry. A manifest with a different hash is refused before any computation.
- The manifest's hash is part of the run's receipt, so the record of a run has a link to its exact specification.