Guides
Artifact representation
Models, tables, and hypothesis tests published from the Framework packages for R, Python, and Stata carry a structured representation in the framework.artifact/v1 schema. Framework Cloud validates and normalizes it when the artifact is published. The data field of an embed document holds that normalized representation for the model, table, test, code_snippet, and dag kinds. Code snippets and DAGs use the same schema with their own fields. See Code snippets and DAGs.
spec/embed.schema.json defines it formally, and SPEC.md specifies how the reference renderers display each field. Except for the publish inputs noted under Code snippets, this page describes the representation as embed documents deliver it, after normalization. Embed integrations covers fetching and rendering documents.
Top-level fields
{
"schema": "framework.artifact/v1",
"kind": "model",
"source": {"language": "r", "class": ["glm", "lm"]},
"model": {"type": "glm", "family": "binomial", "link": "logit", "response": "am", "exponentiate": "Odds ratio"},
"test": null,
"tables": [{"title": "Coefficients", "role": "coefficients", "columns": ["..."], "rows": ["..."]}],
"metrics": [{"name": "nobs", "value": 32}, {"name": "aic", "value": 16.06}],
"formula": "am ~ wt + hp",
"truncated": false
}
| Field | Contents |
|---|---|
schema |
Always framework.artifact/v1. |
kind |
model, table, or test. Matches the embed document's kind. |
source.language |
r, python, stata, or file for a data file published directly. |
source.class |
The object's classes in the source language, such as ["glm", "lm"] or ["DataFrame"], with 0 to 20 entries. |
model |
Model description, or null. See Models. |
test |
Hypothesis test result for test, otherwise null. See Hypothesis tests. |
tables |
Up to 10 tables. See Tables. |
metrics |
Up to 50 named values. See Metrics. |
formula |
The model formula as text. Optional. |
variables, terms |
The data behind a model's terms. Optional. See Model variables. |
truncated |
true when any table, list, or string was shortened. |
Fields marked optional may be absent. Unknown fields may appear within v1 and should be ignored.
Tables
{
"title": "Table",
"role": "data",
"columns": [
{"name": "species", "type": "string",
"summary": {"count": 60, "missing": 0, "distinct": 3, "top": [{"value": "Chinstrap", "count": 27}]}},
{"name": "bill_length_mm", "type": "number", "label": "Bill length (mm)",
"summary": {"count": 60, "missing": 2, "mean": 44.34, "sd": 4.41, "min": 35, "max": 54.9}}
],
"rows": [["Adelie", 39.1], ["Gentoo", null]],
"precision_note": null,
"row_count": 60,
"column_count": 2,
"truncated": true
}
| Field | Contents |
|---|---|
title |
Table title, used as the caption. |
role |
coefficients, random_effects, importance, smooth_terms, anova, priors, data, or null. |
columns |
Up to 50 columns, each with name and type, and optionally label and summary. |
rows |
Rows as arrays in column order. Embed documents send the first 25 rows. |
row_count |
Rows in the full table. |
column_count |
Columns in the full table, which may exceed the columns sent. |
precision_note |
A note when large integers were converted to text, otherwise null. |
truncated |
true when rows, columns, or strings were cut. |
Column types are number, string, boolean, date, and datetime. Cell values are numbers, strings, booleans, or null. Dates are YYYY-MM-DD strings. Datetimes are YYYY-MM-DDTHH:MM:SS strings, or with a space in place of T, with optional fractional seconds and offset. A number column containing an integer beyond ±2^53 becomes a string column, with every value as text and precision_note set.
A column summary is computed over every row of the published table, including rows the embed document leaves out. In table documents, the reference renderers show a column's label and summary in a tip on its header. Each summary field is optional:
| Field | Contents |
|---|---|
count, missing, distinct |
Rows, missing values among them, and distinct values |
mean, sd, q1, median, q3 |
For numbers |
min, max |
Numbers, or strings for dates and datetimes |
top |
Up to 8 of the most frequent values, as {"value", "count"} |
histogram |
{"edges", "counts"}, with up to 51 ascending edges and one count per bin |
Model tables
In a model, a table with term and estimate columns is a coefficient table when its role is coefficients, or when it is the first table and has no role. Its standard columns are:
| Column | Contents |
|---|---|
term |
Term name as the package prints it, such as wt, speciesChinstrap, or (Intercept) |
estimate |
Estimate on the model's scale, such as log odds |
std_error |
Standard error |
statistic |
Test statistic |
p_value |
p-value |
conf_low, conf_high |
Interval bounds, at the level in the confidence_level metric |
df |
Degrees of freedom, when the package reports them per term |
Other columns, such as a multinomial model's outcome level, may appear and keep their own names.
A random_effects table lists group-level terms with group, term, variance, std_dev, and correlation columns as available. An importance table lists feature and importance for tree ensembles. smooth_terms and anova tables use the package's column names, such as edf and ref_df. A column's label, when present, names it for display.
Metrics
Each metric is {"name", "value"}, where the value is a number, string, boolean, or null. Packages send the names their source objects use. Common metric names:
| Name | Meaning |
|---|---|
nobs |
Observations used |
confidence_level |
Interval level as a proportion, such as 0.95 |
interval_method |
wald-t, wald-normal, profile, bootstrap, or a package's own name |
vcov_type |
Standard error type, such as HC1 |
aic, bic, log_likelihood, llf, deviance, null.deviance |
Fit statistics |
rsquared, r.squared, rsquared_adj, adj.r.squared, pseudo_rsquared |
R² variants |
df_resid, df_model, sigma, dispersion, converged, reml |
Model details |
n_groups.{factor} |
Group count for a random-effects factor |
n_events, concordance |
Survival models |
command |
The Stata command that fit the model, shown in place of a formula |
"Metrics" under the model section of SPEC.md lists every name the reference renderers label. Other names display with _ and . replaced by spaces.
Models
model describes how the model was fit. Every field is optional.
| Field | Contents |
|---|---|
type |
linear, glm, mixed, survival, ordinal, multinomial, additive, fixed_effects, quantile, linear_ml, tree_ensemble, or another value |
family, link |
Distribution family and link function, such as binomial and logit |
response |
Outcome variable name |
exponentiate |
The label of the ratio scale, such as Odds ratio, Hazard ratio, or Rate ratio, when the estimates are on a log scale and exponentiating them gives that ratio |
inference |
frequentist or bayesian. Absent means frequentist. |
"Model names" in SPEC.md maps type, family, and link to the name a reader sees, such as Logistic regression. spec/model-names.json holds test cases for it.
When exponentiate is set, the coefficient table still holds model-scale values. Renderers compute the ratio scale as exp(estimate) and exp of each bound, with the standard error exp(estimate) * std_error.
Model variables
Packages may send variables and terms for the data the model was fit on. Both fields describe only the rows the model used.
"variables": [
{"name": "species", "role": "predictor", "type": "categorical", "label": "Penguin species",
"levels": ["Adelie", "Chinstrap", "Gentoo"], "reference": "Adelie",
"summary": {"count": 342, "missing": 0, "distinct": 3,
"top": [{"value": "Adelie", "count": 151}, {"value": "Chinstrap", "count": 68}]}}
],
"terms": [
{"term": "speciesChinstrap", "parts": [{"variable": "species", "level": "Chinstrap"}]}
]
variables lists up to 100 variables:
| Field | Contents |
|---|---|
name |
The variable's name in the data, before any transformation |
type |
number, categorical, boolean, date, datetime, or string |
role |
response, predictor, group, weight, or offset. Optional. |
label |
The variable label from the data. Optional. |
levels |
A categorical variable's levels in model order, up to 50. Optional. |
reference |
The level coefficients compare against. Optional. |
summary |
A column summary without histogram. Optional. |
terms maps up to 500 coefficient terms to variables. Each term matches a term cell exactly. parts lists 1 to 10 entries: one for a main effect, or one per factor of an interaction, in order. Each entry names a variable, with level for a categorical level. The intercept and terms a package cannot map are left out. Framework Cloud drops terms entries that name a variable missing from variables, and sends terms only when variables is present.
The reference renderers turn these fields into variable tips on coefficient terms. "Variable tips" in SPEC.md gives the text of each tip.
Bayesian models
A model with inference: "bayesian" summarizes posterior draws. Its coefficient and random effects tables use these columns:
| Column | Contents |
|---|---|
estimate |
Posterior mean |
std_error |
Posterior standard deviation |
conf_low, conf_high |
Credible interval bounds, equal-tailed unless interval_method is HDI |
rhat |
R-hat |
ess_bulk, ess_tail |
Bulk and tail effective sample sizes |
ratio_estimate, ratio_std_error, ratio_conf_low, ratio_conf_high |
With exponentiate, the same summaries of the exponentiated draws |
Bayesian tables have no statistic or p_value. Renderers use the ratio_ columns for the ratio scale and never exponentiate posterior summaries themselves. Without ratio_ columns, a Bayesian model shows only the model scale.
Bayesian metrics may include chains, draws, warmup, sampler, divergent_transitions, max_treedepth_hits, bayes_r2, elpd_loo, elpd_loo_se, looic, p_loo, and waic. Stata models may also send rhat_max, acceptance_rate, efficiency_min, efficiency_avg, efficiency_max, dic, and log_marginal_likelihood.
A priors table lists parameter, prior (the distribution as text, such as student_t(3, 0, 2.5)), and source (default or user) when known.
"Bayesian models" in SPEC.md specifies the column labels and the convergence warnings renderers show.
Hypothesis tests
"test": {
"method": "Welch Two Sample t-test",
"alternative": "two.sided",
"statistic": {"name": "t", "value": 1.915},
"parameters": [{"name": "df", "value": 55.31}],
"estimates": [{"name": "mean in group OJ", "value": 20.66}, {"name": "mean in group VC", "value": 16.96}],
"null_value": [{"name": "difference in means between group OJ and group VC", "value": 0}],
"p_value": 0.0606,
"conf_int": {"level": 0.95, "low": -0.171, "high": 7.571}
}
| Field | Contents |
|---|---|
method |
Test name. The only required field. |
alternative |
two.sided, less, or greater |
statistic |
Test statistic as {"name", "value"} |
parameters |
Up to 20 named values, such as degrees of freedom |
estimates |
Up to 20 named estimates |
null_value |
Up to 20 named null hypothesis values |
p_value |
p-value between 0 and 1 |
conf_int |
level between 0 and 1, with low, high, or both. A one-sided interval omits one bound. |
A test may also carry tables and metrics with further details.
Code snippets
A code snippet holds a notebook chunk's code and the text it printed. Clients publish it with kind set to code_snippet:
{
"schema": "framework.artifact/v1",
"kind": "code_snippet",
"source": {"language": "r", "file": "notebooks/analysis.qmd", "label": "fit", "lines": [41, 44],
"commit": "3f2c9e1d4b5a69788796a5b4c3d2e1f0a9b8c7d6", "repository": "https://github.com/example/analysis"},
"snippet": {"width": 80, "blocks": [
{"type": "code", "text": "summary(fit)"},
{"type": "output", "text": "…"}
]},
"display": {"folded": "auto", "links": [{"rel": "notebook", "url": "https://example.org/analysis.html"}, {"rel": "model", "artifact": "fit"}]}
}
| Field | Contents |
|---|---|
source.language |
r, python, or stata. Required. |
source.file, source.label |
The notebook file and the chunk label. Optional. |
source.lines |
First and last line of the chunk in the file, with 1 ≤ first ≤ last. Optional. |
source.commit, source.repository |
A lowercase hex commit hash of 7 to 64 characters and an https://github.com/{owner}/{repo} URL. Optional. With a 40-character commit, a relative file, and lines, Framework Cloud adds source.permalink to those lines on GitHub. |
snippet.width |
The console width the output was printed at, from 20 to 1,000. Optional. |
snippet.blocks |
The blocks in order. Each has a type: code, output, message, warning, or error. At least one must be code. |
Block text |
The block's plain text. At publish, a non-code block may send Stata's SMCL in smcl instead, or include ANSI escape codes in text. |
Block folded |
Non-code blocks only. Whether the block starts closed. Without it, display.folded decides: true, false, or auto, which folds blocks longer than 12 lines. Normalization sets folded on every non-code block and drops display.folded. |
display.links |
Up to 10 links with rel set to notebook or model. A link carries an https url, or for a model, the artifact slug of a model in the same project. |
Framework Cloud highlights the code, converts SMCL and ANSI codes into styled segments, and strips them from text. Each normalized block carries plain text and lines: a list of lines, each a list of [classes, text] segments. An output block sent as SMCL that starts with {err} text becomes an error block. In an embed document, a model link given as artifact resolves to the model's url when the model can be embedded, and is dropped otherwise. ?output=none adds display.output: false. The code_snippet section of SPEC.md lists the classes and the markup.
DAGs
A DAG is a causal diagram with the DAGitty model text that defines it. Publish a .dagitty file as it is, or send JSON with kind set to dag to add labels, the code that built the graph, and what the producer computed from it:
{
"schema": "framework.artifact/v1",
"kind": "dag",
"dagitty": "dag {\nsmoking [exposure]\ncancer [outcome]\nage -> smoking -> cancer\nage -> cancer\n}",
"labels": {"smoking": "Smoking status"},
"code": {"language": "r", "text": "dag <- dagify(cancer ~ smoking + age, smoking ~ age)"},
"analysis": {"effect": "total", "adjustment_sets": [["age"]], "implications": []}
}
| Field | Contents |
|---|---|
dagitty |
DAGitty model text. Required. Node attributes exposure, outcome, latent, adjusted, and selected set roles, and pos="x,y" places a node, with y pointing down. Edges are ->, <-, and <->, chained (a -> b -> c) or grouped ({a b} -> c). Edge attributes and bb are ignored. |
labels |
Display labels by node name. Optional. |
code |
language (r, python, or stata) and text: the code that built the graph, up to 400 lines. Optional. |
analysis.effect |
total or direct. Defaults to total. |
analysis.adjustment_sets |
Minimal sufficient adjustment sets, up to 50. [[]] means no adjustment is needed, and [] means no set of observed variables works. Shown only when the graph has an exposure and an outcome. |
analysis.implications |
Testable conditional independencies, up to 200, each {"x", "y", "given"}. |
A graph of another type (pdag, mag, pag), with an undirected edge or a directed cycle, more than 100 nodes or 400 edges, or more than 64 KB of DAGitty text is refused at publish with a message naming the problem. Names in analysis that aren't nodes are dropped.
Framework Cloud lays the graph out when it normalizes it. With pos on every node, it scales those positions until no boxes overlap. Otherwise it places nodes in columns, left to right, by their longest path from a source. The normalized dag holds the drawing's width and height and each node's box and edge's SVG path, so every renderer draws the same picture. dagitty and code carry text and styled lines, as snippet blocks do, and analysis adds the graph's exposures and outcomes. The dag section of SPEC.md gives the markup.
Limits
Framework Cloud enforces these limits when it normalizes a representation. Entries past a limit are dropped. For tables, rows, columns, metrics, source classes, variables, levels, terms, and strings, truncated is also set.
| Item | Limit |
|---|---|
| Tables | 10 |
| Columns per table | 50 |
| Rows per table in an embed document | 25 |
| Metrics | 50 |
| Source classes | 20 |
| Variables | 100 |
| Levels per variable | 50 |
| Terms | 500 |
| Names, labels, and titles | 200 characters |
String cell, metric, and formula values |
10,000 characters |
top values |
8 entries of up to 80 characters each |
| Parts per term | 10 |
Test parameters, estimates, and null_value |
20 entries each |
Code snippets have their own limits. A snippet over a limit marked rejected fails to publish. Text past a non-code block's limits is cut. The block records the cut lines in truncated.lines, and the snippet's truncated is true.
| Item | Limit |
|---|---|
| Snippet size | 2 MB, rejected |
| Blocks | 200, rejected |
| Lines of code | 400 in total, rejected |
| Lines per non-code block | 500 |
| Characters per non-code block | 100,000 |
| Links | 10 |
source.file and source.label |
300 characters each |