Skip to content

Crossfield / Documentation

Compare and keep model versions

Run two definitions against the same data, review the difference, and keep earlier rules available for later reporting questions.

Changing a delivery standard can improve a reported percentage even when no additional orders were delivered. Before adopting the change, run the old and proposed definitions against the same data. Reviewers can then decide whether the new result answers the question the business wants to ask.

Save the current and proposed definitions

The fulfillment bundle contains two packages. Each package holds one business revision of the same model:

File Revision Delivery standard
fulfillment-current.package.json 1 Every unit delivered by the original promise
fulfillment-revised.package.json 2 Every unit delivered by the revised promise

Both definitions select the same four orders in this example, originally due January 31, with deliveries observed through February 3. The proposed version changes the deadline used to evaluate each order.

For your own model, keep the current package, author and validate the proposed definition, and publish it as a new revision. A package’s business revision is separate from the Crossfield software version and the package format version.

Attach both versions under different names

Follow the fulfillment setup. It creates the source tables and performs these two attachments; do not repeat them after running setup:

ATTACH 'fulfillment-current.package.json' AS operations
(TYPE crossfield, BINDINGS '{"warehouse":"warehouse"}');
ATTACH 'fulfillment-revised.package.json' AS revised
(TYPE crossfield, BINDINGS '{"warehouse":"warehouse"}');

Each catalog keeps the definition it loaded. Editing a package file later does not change an existing attachment. The two aliases make it possible to select either definition in one DuckDB connection.

If you supply MODEL_VERSION '2', attachment checks that the supplied package has revision 2. It does not fetch an older version, choose a version from a service or select historical source data.

Query the difference

Use semantic mode for this comparison. Strict business queries stay within one attachment.

SET crossfield_mode = 'semantic';
SQL · Compare the delivery definitions
WITH current AS (
    SELECT on_time_percent FROM SEMANTIC operations.fulfillment
), proposed AS (
    SELECT on_time_percent FROM SEMANTIC revised.fulfillment
)
SELECT current.on_time_percent AS original_promise_percent,
       proposed.on_time_percent AS revised_promise_percent,
       proposed.on_time_percent - current.on_time_percent AS percentage_point_change
FROM current CROSS JOIN proposed;
original_promise_percent revised_promise_percent percentage_point_change
50 75 25
Two model revisions. One DuckDB connection.Order fulfillment · Checked example
The same four eligible orders and shipment recordsOriginally due January 31 · Observed through February 3
Current definitionRevision 1
operations.fulfillment

Original delivery promise

An order is on time only if every unit arrived by the original promised date.

50%2 of 4 orders complete and on time
Proposed definitionRevision 2
revised.fulfillment

Revised delivery promise

Evaluate the same orders against their revised promised dates.

75%3 of 4 orders complete and on time
+25percentage points

The reported rate rises because the delivery standard changed. No additional orders were delivered. Reviewers can measure that effect before adopting the new definition.

Both definitions remain queryable under separate catalog names. Compare their results with ordinary SQL in semantic mode. Run this revision comparison →

Order A101 arrived after its original January 31 promise but by its revised February 2 promise. It is the only order whose classification changes. The new rule raises the rate by 25 percentage points; it does not describe an improvement in deliveries.

The subtraction is an ordinary SQL comparison of two semantic results. It is the query author’s analysis, not a newly approved metric. For a second example, compare portfolio scopes.

Choose the version future reports should use

Once the business has reviewed the result, point new reporting sessions at the accepted package. Keep the earlier package available so you can inspect its rules or query it again.

A separate attachment is useful during review because it leaves the current one available. If you explicitly replace an attachment with ATTACH OR REPLACE, affected prepared queries must be prepared again. A failed attachment replacement preserves the previous attachment.

Keep a release history in DuckDB

You can store package files in your existing version-control system. Applications can also use Crossfield’s native release store to keep published packages and validation records in a persistent DuckDB database.

The application stages an attached package, runs its declared checks and publishes the reviewed version. Published revision contents cannot be overwritten. It can later select a previously published version for subsequent activations. Existing sessions keep their attached definitions.

This workflow uses the native host API described in docs/MODEL_PACKAGES.md in the Crossfield checkout. It is not an automatic effect of ATTACH, and the SQL examples above do not initialize or publish to that store. The application remains responsible for administrator access and release selection.

Reproduce the data as well as the definition

An older model can still read today’s data. To reproduce an earlier report exactly, keep the source snapshot, query inputs and filters used at the time as well as its model version. Selecting an earlier definition does not restore old rows.

The examples here use a fixed local dataset. Their expected values and recorded native execution are documented in the fulfillment verification record; this guide reuses that SQL and those results.

NextDiscovery and AI agents