Test a refund rule against real code

A refund of exactly $100 should be approved. Can your application do that? This short walkthrough checks five cases, introduces one boundary bug, and shows the difference between a passing contract and a passing application.

Start in the browser: Read and try the rule in ThunderLang. No installation needed for that first step.

1. Open the small refund project

Download the refund starter project, unzip it, and open the refund-contract folder in your editor. It contains only a rule, a small refund service, a test adapter, its binding, and a package manifest that installs the tested CLI directly from openthunder.dev.

You need Node.js 20 or later. From that folder, install the pinned CLI and preview:

npm install
npx openthunder intent test-app

This previews the five cases and the code that will run. It deliberately exits with code 2: the application has not been checked. Read src/refunds.cjs and tests/refund.contract.cjs before continuing.

Read the named examples

Open contracts/RefundReview.thunder-human. Each input says what it means; the same arrow is used for a rule's result and an example's expected result.

decision RefundPolicy(amount: number, withinWindow: boolean)
  when amount >= 0 and amount <= 100 and withinWindow -> Approve
  otherwise -> Review

examples RefundPolicy
  case "at limit": (amount: 100, withinWindow: true) -> Approve
  case "above limit": (amount: 101, withinWindow: true) -> Review

This excerpt sits under the starter's contract and purpose lines. Arguments can appear in any order or wrap inside parentheses. The compiler rejects missing, duplicate, unknown, or incorrectly typed example inputs. Existing table examples and canonical ThunderLang contracts still work.

2. Check the application

npx openthunder intent test-app --trust-application

Both sections should report five passing examples: Contract examples checks the rule; Application examples checks the independent implementation. A generated table shows each case, named inputs, expected result, actual result, and status. The adapter calls the independent refund service; OpenThunder compares its actual result to the contract's expected result. No AI or generated implementation supplies the answer.

--trust-application authorizes local code execution. This is not a sandbox. Run projects you trust. Each adapter has a timeout and receives a restricted environment, but still runs with your operating-system account's permissions.

3. Introduce a real bug

In src/refunds.cjs, change amount <= 100 to amount < 100. Keep the contract and adapter unchanged. Run the application check again.

Contract examples: Passed (5/5 passed, 0 failed).
Application examples: Failed (4/5 passed, 1 failed, 0 not checked).
exactly at the limit: expected "Approve" · actual "Review"

The $100 case fails and the command exits with code 1. The other four cases still pass. Run npx openthunder intent prove: the contract itself still passes. That is why application checks matter.

Restore <=, run the application check once more, and all five cases pass again.

4. Bring your own rule

The project's README explains how to bind your application's API and list its implementation files. Use --json for structured results and --base main to require unchanged contracts and adapters against a trusted Git revision.

What the result means: these named cases ran against these listed files. It is not proof of every input, full dependency coverage, or production behavior. Missing, stale, untrusted, or unsupported evidence remains not checked. This example checks eligibility, not currency conversion, payment execution, or retry safety. The current rule accepts zero; change that deliberately if your policy requires a positive amount.

The full intent reference, existing verification flow, and desktop downloads remain available. This application adapter flow currently runs in the CLI.