Leanpub Header

Skip to main content

Fact-Based Agents

ORM 2, FORML and Factum for agentic memory.

Fact-Based Agents

Coding agents reconstruct your domain from schemas and code, and nothing on disk disagrees with them. This book gives them something that does: an ORM 2 conceptual schema that verbalizes into checkable English. 18 chapters, 61 diagrams, 38 working models, and a promise graph for multi-agent work.

Minimum price

$27.00

$37.00

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Ask a coding agent what a row in subscription means and you will get a confident, fluent, well-organised account of your domain. Most of it will be right. The parts that are wrong will not be marked, because the agent has no way to know which parts those are — and, on a first reading, neither do you.

This is not a reasoning failure. The agent did the only thing available to it: it inferred a conceptual model from a logical one. The trouble is that many conceptual models are consistent with the same logical one. A nullable column is equally consistent with this is genuinely optional, with this is mandatory but was added later, and with nobody ever decided. The information needed to tell those apart existed once, in a conversation with someone who understood the business. Then it was compressed into DDL, the compression was lossy, and the lossy artifact is the only thing anyone kept.

Object-Role Modeling is a fifty-year-old answer to a problem we have just started calling new. It describes a domain as elementary facts — Person works for Company — that carry no attributes at all. That sounds like a restriction and is in fact the whole mechanism: because there is nowhere to hide a property, every decision has to be stated as an explicit constraint. And because every constraint is explicit, every constraint can be read back as a sentence a domain expert can confirm or reject, and that a language model can consume with almost no ambiguity.

What you will learn

The notation, completely. ORM 2 has about a dozen marks. Every one is drawn here, beside the sentence it generates. Uniqueness, mandatory, frequency, all ten ring types, subset, exclusion, equality, value, cardinality, subtyping and objectification.

FORML, and why it removes the context wall. A dedicated chapter on the formal language that reads like English — its closed fifteen-form vocabulary, why absence of a sentence is information rather than ambiguity, and why a domain that fills forty tables of DDL fits in a prompt as a few hundred sentences.

A design procedure that produces models people actually confirm. Halpin's seven steps worked end to end, plus a chapter of strategies, six named anti-patterns, and the practice — sample populations — that lets a validator tell you your own data contradicts the constraint you just drew.

The Factum toolchain in depth. The VS Code editor, all eight CLI commands, schema drift detection against a pg_dump, model diffs rendered as sentences for code review, and an MCP server that gives Claude Code, Copilot or Cursor eight tools over the model — seven read-only, one guarded write that refuses to commit a broken schema.

Three real schemas, modelled properly. A six-layer agentic memory architecture with an epistemology layer. A promise graph for multi-agent coordination, built on Promise Theory, where rejections are first-class and a witness's assessment can disagree with the agent's own. An audit log whose hash chain and event ordering are stated as one-to-one constraints and an acyclic ring rather than assumed by the code that writes it.

Interoperability, treated separately and honestly. NORMA, the FBM Exchange MetaModel, Apache Ossie and the Unified Modelling Schema: what each can and cannot hold, why a conceptual format and a logical one are not interchangeable, and what the meta and hints objects exist to bridge.

How the book is built

Every ORM diagram in the book is rendered by Factum's own renderer, from a model file that ships with the manuscript — 38 of them, openable in the editor and taken apart. Every FORML sentence, every validator message and every line of generated SQL and Cypher quoted in the text is real tool output, not a paraphrase.

Four figures are deliberately wrong, because the text works through the error the validator reports. The build asserts that they still fail.

Who it is for

Someone building with agents who is tired of re-typing the domain into every prompt. Someone with a database nobody documented and an agent confidently inventing its semantics. Someone who has read about knowledge graphs for agent memory and wants a way to design one that is checkable rather than vibes.

You do not need prior ORM. You do need to have written a schema and regretted it.

What it is not

Factum is a VS Code extension; the book assumes you use it or read the JSON directly. The property graph mapping targets LadybugDB's Cypher DDL, and other graph databases will need small syntax adjustments. Derivation rules are stored and verbalized but not evaluated.

And nothing in the book calls a language model. The verbalizer, the validator and the mappers are deterministic code that would have worked identically in 2005. That is the point: the agent is your agent, running where you already run it, reading a file you own. The job of the fact layer is to make sure the file says something true.

Metagraph for AI Agents asks how to represent agent knowledge — hypergraphs, reification, the bipartite form, six layers of memory. Fact-Based Agents asks how to specify and check it. Where the first book shows you that an n-ary relationship has to become a node, this one draws the ternary fact type and lets the mapper produce the Levi form for you, with the acyclicity constraint carried into the generated script as a rule the application must uphold. The two are complementary; neither repeats the other.

Share this book

Author

About the Author

Volodymyr Pavlyshyn

Hey I am Volodymyr 

Seasoned Developer's Journey from COBOL to Web 3.0, SSI, Privacy First Edge AI, and Beyond

 As a seasoned developer with over 20 years of experience, I have worked with various programming languages, including some that are considered "dead," such as COBOL and Smalltalk. However, my passion for innovation and embracing cutting-edge technology has led me to focus on the emerging fields of Web 5.0, Self-Sovereign Identity (SSI),AI Agents, Knowledge Graphs, Agentiic memory systems, and the architecture of a decentralized world that empowers data democratization.

A firm believer in the potential of agent systems and the concept of a "soft" internet, I am dedicated to exploring and promoting these transformative ideas. In addition to writing, I also enjoy sharing my knowledge and insights through videoblogging. Most of my Medium posts serve as supplementary content to the videos on my YouTube channel, which you can explore here: https://www.youtube.com/c/VolodymyrPavlyshyn. 

Join me on this exciting journey as we delve into the future of technology and the possibilities it holds.

Contents

Table of Contents

Preface

  1. What this book is
  2. How to use it
  3. Who it is for
  4. Conventions
  5. Getting the models
  6. Part I — The Fact Layer

The Fact Layer Your Agent Is Missing

  1. The gap nobody logs
  2. Why a language model cannot leave it blank
  3. A wrong fact never throws
  4. Why retrieval does not close it
  5. What a conceptual model is, exactly
  6. Six properties that happen to suit a language model
  7. The size argument
  8. Where this book goes

The Elementary Fact

  1. No attributes. That is the mechanism.
  2. Elementary means it cannot be split
  3. Roles and readings
  4. Entity types and value types
  5. Arity: unary through n-ary
  6. What you have committed to

FORML, and the End of the Context Wall

  1. What “the context wall” actually is
  2. Formal, in the way that matters
  3. Why this is the right format for a language model
  4. The closed vocabulary, in full
  5. Grounded in examples, not just rules
  6. The whole domain, in a prompt
  7. Why other formal languages did not stick
  8. What this buys you, concretely

What Else Could Hold This

  1. Eight questions
  2. JSON Schema, and the tool definition
  3. TypeScript, Pydantic, GraphQL, OpenAPI
  4. RDF, OWL and SHACL
  5. Property graphs
  6. AGENTS.md, CLAUDE.md and the rules file
  7. Vector memory, and the model itself
  8. Why the facts are different
  9. Where a fact layer does not help
  10. Use both
  11. Part II — The Visual Formalism

Reading the Diagram

  1. The three shapes
  2. Reading a fact type out loud
  3. Constraints attach to roles
  4. The uniqueness bar
  5. The circled glyphs
  6. The ring
  7. The subtype arrow
  8. The objectification frame
  9. Value constraints, in place
  10. Frequency
  11. Alethic and deontic
  12. Putting it together

The Constraint Family

  1. 1. Uniqueness
  2. 2. Mandatory
  3. 3. Frequency
  4. 4. Ring
  5. 5. Set-comparison: subset, exclusion, equality
  6. 6. Value
  7. 7. Cardinality
  8. 8. Subtype set
  9. Modality: alethic and deontic
  10. A summary table

Subtyping and Objectification

  1. Subtyping
  2. Objectification
  3. Choosing between them

Exercises: Reading the Notation

  1. The case study: an on-call domain
  2. Set A — Reading
  3. Set B — Diagnosis
  4. Set C — Drawing
  5. Set D — Agent prompts
  6. Answers
  7. Part III — Building Models That Hold Up

The Design Procedure, Worked

  1. Step 1 — Verbalize familiar examples
  2. Step 2 — Draw the fact types, populated
  3. Step 3 — Check for splittability
  4. Step 4 — Uniqueness constraints, then re-check arity
  5. Step 5 — Mandatory roles, and the entity types you forgot
  6. Step 6 — Value, set-comparison, subtype and other constraints
  7. Step 7 — Check the whole schema
  8. Where the procedure actually gets hard
  9. The procedure in an agentic loop

Strategies, Heuristics and Anti-patterns

  1. Ten heuristics that hold up
  2. Six anti-patterns, in detail
  3. Modelling for agents specifically
  4. A review checklist

Populations: Grounding a Model in Examples

  1. Job 1 — They make the verbalization concrete
  2. Job 2 — They falsify constraints
  3. Job 3 — They prove the fact type exists
  4. How many rows
  5. Populations and derivation
  6. Where populations do not survive
  7. Populations as the agent’s test fixtures

Exercises: Method, Populations and Design

  1. Installment 2: the incidents
  2. Set A — Work the procedure
  3. Set B — Anti-patterns
  4. Set C — Designing populations
  5. Set D — Model this domain
  6. Set E — Agent prompts
  7. Answers
  8. Part IV — Factum

The Editor

  1. Why a custom editor over text matters
  2. Getting started
  3. Keyboard and mouse
  4. The four panels
  5. Problems, live
  6. Commands
  7. Settings
  8. The file format, briefly
  9. Editing by hand, and why you will

The Command Line, in Depth

  1. validate
  2. verbalize
  3. ddl
  4. graph
  5. diff
  6. drift
  7. convert
  8. derive
  9. skills
  10. Workflow 1 — the pull request
  11. Workflow 2 — drift detection in CI
  12. Workflow 3 — the case study, end to end
  13. Exit codes, summarised

Giving an Agent the Fact Layer

  1. One line of config
  2. Eight tools
  3. The guarded write
  4. The loop
  5. What changes in practice
  6. Where it pays off
  7. Prompting notes
  8. Knowing whether it worked
  9. It is not an AI feature

Teaching an Agent the Method

  1. What a skill is
  2. Two skills
  3. The references
  4. Examples, and a second validator
  5. Ten commands
  6. The refusals
  7. Why this is not the MCP server again
  8. A first session
  9. Installing it

Export to LadybugDB and Graph-Powered Memory

  1. Why start from ORM rather than drawing the graph
  2. The mapping rules
  3. Reification, done for you
  4. What the graph cannot enforce, and what happens to it
  5. Turning the unenforced constraints into checks
  6. Hints: steering the mapping without changing the model
  7. Graph-powered memory: what you actually get
  8. The honest limits
  9. Round-tripping through UMS

Schema Evolution and Migration

  1. What changes, and what the model does about it
  2. Migration one: a fact type that was never elementary
  3. Migration two: a relationship that grew properties
  4. What happens to the sample population
  5. A migration checklist
  6. Part V — Modelling the Agent

Agentic Memory as a Conceptual Schema

  1. L0 and L1 — entity and semantic memory
  2. L2 and L3 — episodic memory and causality
  3. L4 — epistemology
  4. L5 — meta-cognition
  5. Semantic Spacetime as a coverage checklist
  6. What you have when you are done

A Promise Graph for Multi-Agent Interaction

  1. The five principles, and what each one costs you in a schema
  2. The promise itself
  3. The lifecycle
  4. The exchange
  5. Assessment
  6. The whole model
  7. The six layers, mapped
  8. What it maps to
  9. Queries the schema makes possible
  10. Reputation without enforcement
  11. Meta-promises

The Audit Log as an ORM 2 Model

  1. Attempt one, and why the validator refuses it
  2. Attempt two: elementary
  3. The chain
  4. The whole model
  5. Where the three schemas meet
  6. What it maps to
  7. Queries
  8. A note on deontic constraints in an audit log

Actions and Rules

  1. The rule that has nowhere to live
  2. Reify the transition
  3. The three transaction shapes
  4. Preconditions that belong to two parties
  5. Ordering, and who guarantees it
  6. The whole action ledger
  7. The guarded write
  8. What this still cannot say
  9. Checklist

Exercises: Modelling the Agent

  1. Set A — Reification
  2. Set B — The chain
  3. Set C — Promises
  4. Set D — Putting it together
  5. Set E — Agent prompts
  6. Answers
  7. Part VI — Interoperability

Interoperability

  1. The four formats
  2. One fact type, four ways
  3. What each format carries
  4. Why Factum keeps its own format
  5. Which standard Factum is closest to
  6. Importing and exporting
  7. What each conversion has to reconcile
  8. Status and the gaps
  9. Practical advice

Metadata, Hints and Extension Points

  1. meta
  2. hints
  3. x- extensions
  4. Versioning
  5. The multilingual case
  6. A worked example: annotating for an agent
  7. When to reach for which
  8. Appendices

Appendix A — FORML Quick Reference

  1. Reference schemes
  2. Fact types
  3. Mandatory
  4. Frequency
  5. Ring
  6. Set comparison
  7. Value
  8. Cardinality
  9. Objectification
  10. Subtyping
  11. Modality
  12. Sample population
  13. Reading the output as a whole

Appendix B — CLI and MCP Reference

  1. factum
  2. factum-mcp
  3. The skill pack
  4. Editor commands
  5. Settings
  6. Keyboard

Appendix C — Validation Codes

  1. Structural — the model does not hold together
  2. Identification — the model cannot say what a thing is
  3. Elementarity — the model says the wrong number of things
  4. Readings
  5. Constraint compatibility
  6. Subtyping
  7. Population — the constraints disagree with your examples
  8. Hygiene
  9. Working with the codes

Appendix D — Glossary

Appendix E — Answers

  1. the notation exercises
  2. the method exercises
  3. the agent exercises

Appendix F — Sources and Further Reading

  1. Fact-oriented modelling
  2. Promise Theory
  3. Agentic memory and knowledge representation
  4. The formats compared in the alternatives chapter
  5. Interoperability targets
  6. A note on what is not cited

Appendix G — Porting the Graph Mapping

  1. What the emitted DDL is
  2. Construct by construct
  3. A worked translation
  4. Turning the unenforced list into checks
  5. Other stores, briefly
  6. Generating a dialect Factum does not emit

Appendix H — The Fact-Layer Benchmark

  1. What is being measured, and what is not
  2. The three conditions
  3. Designing questions that discriminate
  4. The citation check
  5. Running it
  6. What a negative result would look like

Appendix I — What Factum Supports

  1. Object types and fact types
  2. Constraints
  3. Derivation
  4. What this means for the claims in this book

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub