Skip to main content

Contracts & DimVerify

Dim can validate component props with contracts (t / contract) and optionally prove obligations in the browser with DimVerify. Framework-level formal gates (npm run verify) run Lean, Rust, and filtered Jest — that path is for the dim repo, not for app authors.


Contracts on define​

const { define, t } = Dim;

const Greeting = (props, { html }) =>
html`<p>Hello, ${props.name}</p>`;

define({
tag: "my-greeting",
component: Greeting,
inputs: t.record({
name: t.string,
}),
});

When inputs is set, props are validated and sanitized before every render. Rejected props render nothing and log a console error.

Also on Dim: contract, fold, validateValue, getValidatorEngine.


Browser: DimVerify​

CDN: https://positive-intentions.github.io/dim/lib/dim.verify.global.js

Exposes window.DimVerify. When loaded with DimTest, it attaches as DimTest.verify:

DimTest.verify.add(sourceText, "notes/lib/vault.js");
DimTest.verify.run(); // JS prover
const summary = DimTest.verify.summary();
// { proved, refuted, unsupported, missing, … }

runTests.html in dimui / dim-boilerplate registers app sources (often those tagged with contract@… obligations) and surfaces a verification summary on window.__DIM_TEST__.verification.


Framework gate: npm run verify​

In the dim repo only:

npm run verify        # Lean + Rust + filtered Jest
npm run verify:lean # Lean proofs only

This is the conformance gate for the framework itself (renderer policies, crypto, contracts). App authors use DimTest + DimVerify in the browser instead.