Benxiang · 本象协议 — Origin IR: The Persistent Object Layer for AI

Tagline: Save the origin, project on demand. AI submits semantic transactions; a deterministic compiler validates before anything lands. Every field can answer why.


Inspiration

Every AI agent has a memory problem — not the context window, the state.

Where does an agent's state actually live? In a chat transcript. And transcripts are not state. When the session ends, the state dies with it. When two agents write the same world, they drift. When a model writes chapter 40 of a story, it has already forgotten what happened in chapter 2 — not because it can't read, but because the accumulated state was never written down in any single passage to read.

Vector search fetches passages. But state that has to be accumulated across a whole body of work — a secret set up in chapter 7, a key that changed hands in chapter 11 — is never stated in any one place. Retrieval can't answer it. Only a state machine can.

We built Benxiang to be that state machine: a persistent object layer where AI work becomes auditable, resumable, and verifiable — for stories, spreadsheets, CAD drawings, legal documents, and any long-running agent task.

What it does

Benxiang (本象) is a persistent object representation layer for AI. The model never writes final artifacts directly. It submits compact semantic transactions — what changed, what it depends on, what it asserts. A deterministic compiler validates every transaction against constraints before anything lands:

  • Validation failure writes nothing. Violations come back to the model for a rewrite, with evidence.
  • Current state is a replay of history. Every field can answer "why": origin why <pkg> <object.field>.
  • Six things live in an origin at once: objects, relations, payloads, states, constraints, and provenance.

A .origin package is a single directory you can inspect from the command line, or through the built-in MCP server (handshake verified 16/16 — any MCP client can connect).

Live proof: the same engine runs two public novels (Rule Breakers: Infinite Floors and The Zero Slot), with one chapter committed every day by GitHub Actions. Each chapter is a semantic transaction; the machine verifies state consistency — the zero-slot novel enforces a numeric ledger (stats must sum exactly), and the rule-breakers novel enforces forbidden-zone vocabulary — before a single character is written.

How we built it

The core is a zero-dependency Node.js compiler (compiler/), with five domain dialects (office, xlsx, cad, law, memory) sharing the same core:

  1. Context compiler — projects only what the current task needs to see (budgeted).
  2. Transaction normalizer — turns the model's structured output into a validated form.
  3. Validator — ten general predicates (equals, range, contains, in, count, unchanged…) that express any domain rule as data, not code.
  4. Store — append-only provenance history; graph/objects.jsonl is a birth certificate, never overwritten.
  5. ShadowBench-W — our own benchmark that turned this into a measurable claim.

Two implementations (JS + Python) share 87 language-independent conformance vectors — the spec is the contract, not a story.

Challenges

The biggest one was scientific honesty. Our first benchmark results looked too good — 75% control-arm scores with zero variance. That was the alarm bell, not the proof. The control arms' probe was accidentally printing five of eight answers literally in the question. We withdrew the comparison, rebuilt the probe, and re-ran everything. The headline numbers now (95.8% vs 52.1% vs 58.3%, p=0.0024) are from a probe that gives the control arms everything they wrote, with no answer anywhere in the prompt.

The engineering challenge was making validation fail correctly: zero writes on violation, evidence returned for the rewrite loop — while keeping the whole thing deterministic and dependency-free enough to run in CI, on a laptop, or inside a GitHub Action.

Accomplishments

  • W3 state accuracy 95.8% ± 5.9 vs 52.1% (naive) vs 58.3% (vector RAG), p=0.0024 — the advantage is exactly where the answer is never stated in any passage (ShadowBench-W, 95k chars, n=6 each).
  • Live transaction loop: model → semantic transaction → five deterministic gates → commit. Forbidden zone? Zero writes. Prose contradicts state ("left hand", injured since ch9)? Zero writes.
  • Foreshadowing graph — planted / pending / never planted — machine-verifiable, no reviewer needed.
  • 87 conformance vectors across JS + Python, 13/13 mutation checks (each promise the protocol makes is deliberately broken and caught).
  • Two public novels committing one verified chapter per day, automatically, in public — proof the engine is real and continuous.
  • Apache-2.0, zero dependencies, npm run verify runs 91+44+101+87+18 tests.

What we learned

  • State that's never written is the whole game. Retrieval and long context both fail on exactly the fields that matter most — cross-chapter, cross-session accumulation. A state machine doesn't.
  • A zero-variance 75% is a template's answer key, not a measurement. The honest result had variance, and that's how you know it's real.
  • Validation failure writing nothing is a feature, not a bug. It's the difference between an AI that lies confidently and one that can be corrected before harm.
  • Deterministic checks are cheaper than they look. Ten predicates cover narrative foreshadowing, numeric ledgers, and revenue constraints alike.

What's next

  • ShadowBench-W as a public leaderboard — the state-tracking benchmark nobody has defined yet; the definer gets the standard.
  • Production dialects — office/law/cad/xlsx structure-preserving conversion (no OCR, SHA-256 verifiable) for enterprise document compliance.
  • OriginWriter — the transaction-based writing engine as a real studio product.
  • Multi-agent coordination — origins as the shared state layer under MCP/A2A, with optimistic concurrency and rollback.
  • The White Drum Challenge — an AI-written novel, machine-verified chapter by chapter, racing the human record of 22,400 pages.

Links

Built With

Share this project:

Updates