Repository navigation
Standard Interface for Deterministic Panic-Free State Resolution (Chain-Meet) #662
sykomiked
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
NEP: 0000
Title: Standard Interface for Deterministic Panic-Free State Resolution (Chain-Meet)
Author: Michael Laurence Curzi deal@zedec.ai · ZXV (ZEDEC / 36N9 Genetics, LLC)
Status: Draft
Type: Standards Track
Category: Contract
Created: 2026-10-23
Requires: NEP-297
Standard Interface for Deterministic Panic-Free State Resolution (Chain-Meet)
Summary
A standard contract interface for non-aborting state resolution
when asynchronous execution produces conflicting evidence. The standard
defines a 1-byte contention state (
BOTH,0x03) that isolatesconflict, guarantees audit preservation, and structurally blocks
side-effects — instead of invoking
env::panic_str().The interface is a zero-cost invariant:
0x00–0x03)#![no_std]compatible)A working mainnet implementation is live at
zedec.nearandzxv-core(f18889ea8bc108de53b899df3a3417c76995cbb55fb2174ff08d2e0abee99bcf),having survived adversarial mainnet load. This NEP standardizes that
existing interface for the rest of the ecosystem.
The one-sentence pitch: give every NEAR contract a standard way to
say "these two sources disagree — hold the funds, keep the evidence,
do not revert" — a 1-byte state that any contract, oracle, agent, or
DAO can use.
Table of Contents
env::panic_str()is a fragile fallback2. The Problem:
env::panic_str()is a fragile fallback2.1 The operational failure mode, in plain terms
Imagine a contract that asks two oracles what the price of an asset
is. Oracle A says 100. Oracle B says 105. Who is right?
In a classical NEAR contract, you have a few options, and all of them
are bad:
env::panic_str("oracle mismatch"). The whole callreverts. Any work already done in that execution cycle is thrown
away. The gas you prepaid is burned. The only diagnostic is a
string.
first oracle's evidence is silently discarded. If Oracle A was
right, you just settled on a wrong price.
downstream of your contract halts.
All three destroy information. The disagreement itself — which is
often the most valuable signal — is either discarded or frozen.
2.2 Why this is a standards problem, not a project problem
Every NEAR contract that consumes multiple oracles, aggregates agent
intents, awaits cross-shard callbacks, or coordinates multi-sig
decisions faces this. There is currently no standard primitive for
recording "these two sources disagree, hold the funds, preserve the
evidence, do not revert."
Each project either panics (losing state) or implements a bespoke
last-writer-wins (losing evidence). Both are losses. The ecosystem
needs a standard so that:
The NEP is deliberately narrow: the 1-byte state machine. The broader
solutions architecture — the five operational friction points and how
the deployed system addresses them — lives in the companion
docs/ECOSYSTEM_SOLUTIONS.md, so the standard stays focused while thesolutions remain documented.
3. The Proposal: a 1-byte non-aborting contention state
3.1 The interface
3.2 The state encoding
NEITHER0x00TRUE0x01FALSE0x02BOTH0x03The four states are bit patterns in a single byte. No serialization,
no nested allocation, no runtime math.
3.3 The resolution rule (chain-meet)
The total order is
FALSE < NEITHER < BOTH < TRUE. Because TRUE is thetop of the chain, no combination of non-TRUE values can ever yield
TRUE — the invariant is structural, not checked.
3.4 The full conjoin table
(Values:
TRUE=1,FALSE=2,NEITHER=0,BOTH=3; the table followsthe rank order
FALSE < NEITHER < BOTH < TRUE.)4. Why this passes the four working-group criteria
4.1 Gas Predictability
min_rankscalar comparison.nep_conjoinandnep_is_settleableexecute well under1.2 Tgas.
Why reviewers should care: a primitive that costs less than a
storage read and is free to query off-chain is a primitive that
contracts will actually use without gas-budget fear.
4.2 Cross-Contract Reliability
BOTHstate blocks side-effects without reverting thecontract.
trail is preserved, not discarded.
arbitration, instead of catching a panic.
Why reviewers should care: cross-contract calls fail in
unpredictable ways today. A standard contention state makes the failure
mode defined, observable, and recoverable.
4.3 Asynchronous Composability
resolve to
BOTHinstead of panicking.conflict.
log without overhead.
Why reviewers should care: NEAR's sharded, promise-based execution
model means callbacks arrive from unknown shards with unknown timing.
A panic in a callback is a lost cause; a
BOTHstate is a recoverablecondition.
4.4 Storage Overhead
#![no_std]compatible.u8.Why reviewers should care: proposals that add serialized blobs or
nested maps to every contract get rejected for storage overhead. This
interface adds one byte.
5. The NEAR 2026 Narrative: AI Agents & Intent Settlement
5.1 Where the ecosystem is heading
NEAR's strategic direction centers on AI Agents, Intent Settlement,
and Chain Abstraction. Autonomous agents routing intents across
chains and shards constantly encounter contradictory off-chain inputs
and divergent oracle feeds. This is not hypothetical — it is the
everyday reality of agent networks.
5.2 The agent failure mode
When autonomous agents or solver networks submit mismatched state
proofs for an intent, a classical contract fails or gets caught in a
race condition:
TRUEfor a settlement condition.FALSEfor the same condition.5.3 The deterministic intent conjoinment
This interface provides deterministic intent conjoinment: multiple
AI solvers or oracles can assert states simultaneously.
TRUE→ settlement unlocked.BOTH→ funds remain lockedin contract escrow without transaction reversal, enabling
automated arbitration without gas-draining panic loops.
This is the missing primitive for intent settlement: a way to hold a
dispute inside the escrow, rather than exploding the transaction.
5.4 The concrete agent scenario
No panic. No reverts. No gas-draining loops. The dispute is a state,
not an exception.
6. Concrete use cases (the rationale)
6.1 Multi-Oracle Price Feeds
Scenario: Oracle A reports an asset status; Oracle B disputes it.
Without this interface: the contract panics (reverting the call)
or silently overwrites via last-writer-wins (LWW) — losing Oracle A's
evidence.
With this interface: the contract automatically records
BOTH.No panic, no overwrite. The dispute is held, the audit trail is
preserved, and an arbitration path can resolve it.
6.2 Multi-Sig Escrow / Sovereign Decrees
Scenario: signers submit opposing directives for an escrow release.
Without this interface: conflicting votes break transaction
continuity.
With this interface: conflicting votes are acknowledged and
preserved in the append-only state trie. The escrow stays intact; the
conflict is data, not a failure. Governance can hold both decrees as
information (the paraconsistent "forks without forking" pattern).
6.3 Cross-Shard Call Recovery
Scenario: an asynchronous callback from another shard returns
conflicting execution receipts.
Without this interface: the parent contract reverts prior completed
steps.
With this interface: the parent contract resolves to
BOTH,retaining the receipt hash for the next block without reverting
completed work. The next block can arbitrate.
7. The mathematics, explained simply
7.1 The core idea
Most people think of logic as having two answers: yes or no. This
standard uses four answers:
NEITHER) — we haven't seen anything.TRUE) — everyone who matters agrees.FALSE) — someone explicitly says no.BOTH) — we have conflicting evidence.7.2 The chain
The four states are arranged in a line, from "most blocking" to "most
permissive":
FALSEis the bottom: if anyone says no, the answer is no.TRUEis the top: only when everyone agrees does anything settle.BOTHsits belowTRUE: a conflict can never become agreement.7.3 Why the invariant is structural
The resolution rule is: take the state that is lower on the chain.
Because
TRUEis the highest point on the chain, the only way theresult can be
TRUEis if both inputs wereTRUE. No amount ofconfusion, disagreement, or bad input can ever manufacture agreement.
This is why the invariant "only TRUE settles" is not a rule we check
— it is a property of the structure. It cannot be violated.
7.4 The algebra (for the mathematically inclined)
The meet/join pair with the chain rank forms a bounded lattice.
Verified over all combinations (4×4=16, and 64 for associativity):
A semilattice: you can reduce any set of states with a fold, and the
result is order-independent — which matters for concurrent evidence
from many sources.
8. The working proof-of-concept (the de facto standard)
Most NEPs are rejected or delayed because they are purely theoretical.
This standard has a live mainnet implementation that has already
survived adversarial load. The review question shifts from "Is this
technically viable?" to "Should we standardize this existing
interface for the rest of the ecosystem?"
8.1 The live addresses
zedec.nearf18889ea8bc108de53b899df3a3417c76995cbb55fb2174ff08d2e0abee99bcf7eaa2c6f37ef7dd1dc073c4630533b67f303274d31d411e4047eb0d9401ef01a6ca890f766fdaeccd6c934da325f5f06ebc63ca9be4f5f1b44d0686af93c64a88.2 Verify the zero-allocation execution (gas-free view calls)
8.3 The verification record
All of the above were verified live on NEAR mainnet at the time of
writing.
9. The full specification
9.1 Method signatures
9.2 Method semantics
nep_conjoin(inputs: &[u8]) -> u80x00..=0x03.result.
NEITHER(0x00).comparison).
nep_is_settleable(state: u8) -> booltrueif and only ifstate == TRUE(0x01).nep_invariant() -> String"Only TRUE settles. TRUE+FALSE=BOTH — contradictions are recorded, never coerced, never a panic."9.3 View-call neutrality
nep_conjoinandnep_is_settleableare view calls: gas-freewhen invoked via RPC.
< 1.2 Tgasfor the internal envelope bound.u8; no serialization required.9.4 Event emission
When a contract transitions to
BOTH, it SHOULD emit an NEP-297EVENT_JSONevent so indexers and downstream automation can observethe contention. The event MUST follow the NEP-297 schema:
standard,version,event, anddata(an array of objects).9.5 Recommended storage pattern
The contention state is a single
u8. Recommended storage:Adding
pending_state: u8costs 1 byte of storage. No serializationbloat.
10. How to integrate (step by step)
Step 0:
cargo addthe crateThe reference implementation is published as the
near-panic-freecrate (zero dependencies,
#![no_std]):Two integration paths:
near-panic-freecompiled directly into the contract binaryzedec.near/zxv-corekernelStep 1: Implement the interface
Step 2: Use it at your decision points
Step 3: Call the reference implementation for verification
Step 4: Handle the held state
When
pending_state == BOTH, your contract should:contention log).
timelock-based resolution).
Never revert on a held state — that is the whole point.
11. The public utility framing
This standard is offered as a public utility and demonstration,
consistent with NEAR's open, community-owned culture.
through the standard NEP process.
walled garden.
interface works under mainnet conditions.
The companion repository,
https://github.com/sykomiked/zxv-community-utility, contains theuser manual, the demonstration guide, and the multilingual
documentation (30 world languages) — all free and open.
12. Alternatives
The following alternatives were considered and rejected:
env::panic_str(): Destroys transactioncontext and burns gas unnecessarily. A panic rolls back intermediate
receipts, discards the disagreement, and halts downstream automation
— the exact failure mode this standard eliminates.
trails and opens race conditions to miner/validator frontrunning. The
older oracle's evidence is lost, and settlement can be gamed by
submission order.
non-TRUE combinations to return ambiguous states that cannot be
safely mapped to a binary settlement gate in WASM without complex
branching. The chain order (FALSE < NEITHER < BOTH < TRUE) makes the
invariant structural and the implementation a single comparison.
13. Future possibilities
multiple high-throughput solver networks,
chain-meetcould beaccelerated as a host function inside the
nearcoreruntime,reducing even the sub-1.2-Tgas cost further.
support hierarchical multi-party state arbitration without modifying
the 1-byte interface signature — each phase takes the next rank, so
the operators extend with no code change.
14. Security considerations
(a|b) & 3) returns TRUE for out-of-rangeinput; the standard uses the range-checked chain-meet
(
min_rank) instead. Onlymin_rankis used for settlementevidence.
authority.
BOTHblocks side-effects without reverting — this is theintended semantics; implementers must ensure their state machine
handles a held state (funds locked, evidence retained) rather than
expecting a revert.
contention_logto prevent unboundedgrowth (e.g., keep the last N hashes, or a rolling digest).
cross-checks the logic against the kernel C source.
15. Backwards compatibility
No breaking changes to NEAR Core, NEP-141, NEP-171, or NEP-297. The
interface is opt-in: existing contracts continue to work exactly as
before; new contracts may implement
nep_conjoin/nep_is_settleablewhen they choose.16. Frequently asked questions
Q: Is this a token or a commercial product?
A: No. This NEP proposes a logic primitive as a community utility.
The reference implementation is open source, gas-free to read, and
offered for public benefit.
Q: Do I have to use it?
A: No. It is opt-in. Existing contracts are unaffected.
Q: What does it cost to read?
A: Nothing. All reads are gas-free view calls.
Q: How do I verify the claims in this NEP?
A: Directly on-chain, gas-free: call
is_settleable,conjoin,verify_chain, andvm_capabilitieson the addresses in Section 8.Q: What is
zedec.near?A: The canonical router: a live contract that points to the whole
utility (the protocol, the registry, and the gate).
Q: How is this different from Belnap's logic?
A: The reference implementation uses a single totally ordered chain
(FALSE < NEITHER < BOTH < TRUE) rather than Belnap's two-order
lattice, so the invariant is structural and the implementation is a
single comparison.
Q: What happens to my funds when the state is BOTH?
A: They stay locked in the escrow. The contract does not revert; it
holds. Arbitration resolves the dispute, and only then do funds move.
Q: Can I use this with AI agents and intents?
A: Yes — that is the primary use case. Multiple solvers assert states;
agreement unlocks settlement; dispute holds funds without reversal.
17. Glossary
BOTH(0x03) state: conflicting evidence held without reverting.18. Reference implementation repositories
zxv-nep-paraconsistent/): the self-containeddeveloper bundle — the
near-panic-freecrate (the core#![no_std]logic), thenear-panic-free-sdkcrate (NEP-297 eventhelpers), the example contracts (multi-oracle escrow, agent intent
solver, inline resolver, cross-contract resolver), and the kernel
with the actual deployed wasm artifacts + SHA-256 checksums
(fetched from mainnet).
https://github.com/sykomiked/zxv-community-utility
19. The submission attachments
19.1 What is attached to this NEP (Markdown, 6 files)
The NEP platform accepts Markdown attachments only. The following
files accompany this proposal:
01-NEP-Document.mdneps/nep-0000-panic-free-resolution.md)02-Verification-Guide.md03-Ecosystem-Solutions.md04-Submission-Index.md06-Address-Ledger.md07-Tutorial.md19.2 What is in the repository (link only, not attached)
Everything else — the Rust crate, the kernel source, the deployed wasm
artifacts, the SDK, the examples, the deployable closure — is in the
dedicated submission repository (no folders or archives; link it
directly):
https://github.com/sykomiked/zxv-nep-submission
workspace/crates/near-panic-free/#![no_std]crate (cargo add near-panic-free)workspace/crates/near-panic-free-sdk/workspace/examples/workspace/kernel/workspace/tools/verify.sh,verify_mainnet_gate.sh,build_reproducible.shreference-implementation/nep_gate.rsdeploy-repo/DEPLOYMENT.mdcontracts/sdk/The one-line summary for reviewers: the six attached Markdown files
are the proposal and its guides; the repository holds the importable
implementation, the exact deployment, and the ground-truth artifacts —
everything verifies, everything is open.
20. Copyright
Copyright (c) 2024-2026 Michael Laurence Curzi and 36N9 Genetics, LLC ·
SPDX-License-Identifier: Apache-2.0
00-README.md
01-NEP-Document.md
02-Verification-Guide.md
03-Ecosystem-Solutions.md
04-Submission-Index.md
06-Address-Ledger.md
07-Tutorial.md
All reactions