/midnight-verify:verify-by-executionfrom midnight-verify
Translates a Compact claim into a minimal test contract, compiles it with Compact CLI, and executes it with @midnight-ntwrk/compact-runtime to verify actual behavior. Covers workspace setup, contract writing, compilation, execution, and result interpretation.
Ships in midnight-verify. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are verifying a Compact claim by writing a minimal test contract, compiling it, running the compiled output, and observing the actual behavior. Follow these steps in order.
Compilation success alone is NEVER sufficient evidence. Code can compile and still not behave as claimed. You MUST run the compiled output and check the actual return values, state changes, or errors.
You may consult these skills to inform how to write your test contract. They contain useful information about Compact syntax, stdlib functions, and patterns. But they are hints only — never cite them as evidence. The test result is your evidence.
Useful hint skills:
compact-core:compact-standard-library skill — expected function signatures, what existscompact-core:compact-structure skill — how to structure a contract (pragma, imports, exports)compact-core:compact-language-ref skill — syntax reference, type system, operatorscompact-core:compact-privacy-disclosure skill — disclosure rules to testmidnight-tooling:compact-cli skill — expected compiler behaviorLoad any of these if they would help you write a better test. Do not load them all — only what's relevant to the claim.
The workspace lives at ~/.midnight-expert/verify/compact-workspace/ in your home directory. It is home-based and independent of the project you are working in.
First time (workspace does not exist):
# Create the workspace
mkdir -p "$HOME/.midnight-expert/verify/compact-workspace"
# Initialize and install runtime
cd "$HOME/.midnight-expert/verify/compact-workspace"
npm init -y
npm install @midnight-ntwrk/compact-runtime
Subsequent times (workspace exists):
Run a quick integrity check:
cd "$HOME/.midnight-expert/verify/compact-workspace"
npm ls @midnight-ntwrk/compact-runtime
If npm ls reports errors (missing or corrupted packages), run npm install to repair. If it's clean, proceed.
Create the job directory:
# Generate a unique job ID
JOB_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
mkdir -p "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID"
All contract files, compilation output, and runner scripts go in this job directory.
Read the claim carefully. Determine:
Prefer export circuit (pure circuits) when possible. Pure circuits are the easiest to call from the runtime — they take inputs, return outputs, and have no side effects. Use them for testing syntax, types, stdlib functions, return values.
When you need state or witnesses, use impure circuits. These are harder to test (require witness implementations and state management) but necessary for claims about ledger behavior, disclosure rules, or stateful operations.
Write a .compact file in the job directory.
Get the current language version:
compact compile --language-version
Or load the midnight-tooling:compact-cli skill for details on version management.
Contract template for pure circuit tests:
pragma language_version <VERSION>;
import CompactStandardLibrary;
export circuit testClaimName(<params>): <ReturnType> {
// Minimal code that tests the claim
// Return the value we want to observe
}
Name the file descriptively: test-tuple-indexing.compact, test-persistent-hash-exists.compact, etc.
Write the file:
cat > "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID/test-<claim>.compact" << 'COMPACT_EOF'
<contract content>
COMPACT_EOF
Load the midnight-tooling:compact-cli skill for compilation flags, version management, and troubleshooting.
compact compile "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID/test-<claim>.compact" --skip-zk
If compilation succeeds: Proceed to Step 5. The compiled output will be in test-<claim>/build/ relative to where you ran the command, or in the contract's output directory. Check for the contract/index.js file.
If compilation fails:
Capture the full compiler output (stdout and stderr) regardless of success or failure.
If the orchestrator requested ZKIR-level evidence alongside execution results, locate the .zkir JSON in the compilation output. It is typically found at:
<contract-name>/build/zkir/<circuit-name>.zkir
If found, note the path in your report so the orchestrator can dispatch @"midnight-verify:zkir-checker (agent)" if needed. Do NOT run the checker yourself — your job is compilation and JS runtime execution.
If no .zkir output is found (some compilation modes may not produce it), note this in your report.
Create the runner script in the job directory:
cat > "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID/run.mjs" << 'RUNNER_EOF'
import { pureCircuits } from './out/contract/index.js';
// Call the test circuit
const result = pureCircuits.testClaimName();
// Output structured JSON
console.log(JSON.stringify({
result: Array.isArray(result) ? result.map(String) : String(result)
}));
RUNNER_EOF
Adjust the import path based on where compact compile placed the output. The compiled output directory structure is typically:
<contract-name>/build/contract/index.js — the main entry pointRun it:
cd "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID"
node run.mjs
Capture stdout and stderr. The structured JSON output is your primary evidence.
If the runner throws: Capture the error. Determine if it's a claim issue (the code genuinely doesn't work as claimed) or a test issue (your runner script has a bug). If it's a test issue, fix and retry once.
Compare the actual output to what the claim predicts.
Your report must include:
Report format:
### Execution Report
**Claim:** [verbatim]
**Test contract:**
\`\`\`compact
[full source]
\`\`\`
**Compilation:** [SUCCESS / FAILED — with error output if failed]
**Runner output:**
\`\`\`json
[stdout]
\`\`\`
**Interpretation:** [Confirmed / Refuted / Inconclusive] — [explanation of why the output matches or contradicts the claim]
Remove the job directory:
rm -rf "$HOME/.midnight-expert/verify/compact-workspace/jobs/$JOB_ID"
Do NOT remove the base workspace — it's shared across jobs.
When dispatched for a ledger/protocol claim, you compile and execute a Compact contract as usual, but after execution you extract ledger-level evidence — cost data, transaction properties, well-formedness results — in addition to the normal runtime output.
When to use this mode: The orchestrator dispatches you with a ledger claim that is testable via compilation. Examples:
What to extract after compilation and execution:
| Claim type | What to extract | How |
|---|---|---|
| Cost model claims | SyntheticCost breakdown | Call cost(LedgerParameters.initialParameters()) on the compiled transaction; reads a SyntheticCost (camelCase bigint fields) |
| Well-formedness claims | Acceptance/rejection | Call wellFormed(refState, new WellFormedStrictness(), tblock); it returns a VerifiedTransaction and throws on invalid |
| Balance claims | Per-segment per-token balance | Inspect transaction structure after construction |
| Transaction structure | Intent/offer properties | Read compiled transaction fields |
| Proof staging | Stage transitions | Construct UnprovenTransaction, call prove(), observe state change |
Extended runner script pattern:
After the normal circuit execution (Step 5), add ledger-level evidence extraction:
import { LedgerParameters, WellFormedStrictness } from '@midnight-ntwrk/ledger-v8';
// ... normal circuit execution from Step 5 ...
// Extract cost data. `cost()` takes LedgerParameters and returns a SyntheticCost
// whose fields are camelCase bigints. (There is no CostModel.calculate(); the
// only CostModel factory is the static CostModel.initialCostModel().)
const cost = transaction.cost(LedgerParameters.initialParameters());
console.log(JSON.stringify({
circuitResult: result,
cost: {
readTime: cost.readTime.toString(),
computeTime: cost.computeTime.toString(),
blockUsage: cost.blockUsage.toString(),
bytesWritten: cost.bytesWritten.toString(),
bytesChurned: cost.bytesChurned.toString(),
},
}));
// Well-formedness. `wellFormed(refState, strictness, tblock)` returns a
// VerifiedTransaction and THROWS if the transaction is not well-formed — it is
// NOT a boolean. Build strictness with `new WellFormedStrictness()` (there is no
// WellFormedStrictness.default()). `refState` is the LedgerState to validate
// against (e.g. `LedgerState.blank(networkId)` for an isolated check).
let wellFormed;
try {
transaction.wellFormed(refState, new WellFormedStrictness(), new Date());
wellFormed = true;
} catch (e) {
wellFormed = { ok: false, error: String(e) };
}
console.log(JSON.stringify({ wellFormed }));
Include the ledger-level evidence in your report alongside the normal execution report. The orchestrator uses both to synthesize the verdict.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub midnightntwrk/midnight-expert --plugin midnight-verify19 skills in this plugin
/verify-by-cli-executionmidnight-verify:verify-by-cli-executionVerification by running Compact CLI commands and observing output. Checks CLI availability, runs commands, captures stdout/stderr/exit code, inspects filesystem changes, and interprets results. Covers flag existence, flag behavior, output structure, error messages, exit codes, version info, and CLI-vs-compactc comparisons. Loaded by the cli-tester agent./verify-by-devnetmidnight-verify:verify-by-devnetVerification by running E2E scripts against a local Midnight devnet. Writes SDK test scripts (raw or using testkit-js) that exercise the full transaction pipeline: deploy, call circuits, observe state. Checks devnet health before proceeding. Loaded by the sdk-tester agent. Loads the `midnight-tooling:devnet` skill for infrastructure management./verify-by-ledger-sourcemidnight-verify:verify-by-ledger-sourceVerification by source code inspection of the Midnight ledger Rust codebase. Searches and reads the actual Rust implementation to verify claims about transaction structure, token mechanics, cost model, on-chain VM, contract execution, and cryptographic primitives. Routes claims to specific crates within the 24-crate workspace. Uses octocode-mcp for quick lookups, falls back to local cloning for deep investigation. Loaded by the source-investigator agent when the claim domain is ledger/protocol.Other plugins' skills for the same job