Leanpub Header

Skip to main content

Graph Engineering: The Loop That Remembers

The loop writes code and clears context. The commit log records MAX_RETRIES = 3, but the reason it's three vanished on Friday night. The artifact survived; the decision evaporated.

The Loop That Remembers inverts the premise: memory isn't the sixth piece, it's what the loop exists to produce. Two graphs, a promoted lattice, bounded context, and an evaluator checking claims against edges.

Minimum price

$25.00

$40.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

The Loop That Remembers

Graph Engineering for Multi-Agent Development

Everyone is building loops. Generate, critique, revise. Tools, worktrees, skills, sub-agents. The five pieces are well understood and widely documented — and every version of the list ends with a shrug: and you'll want some kind of memory, a scratchpad, a NOTES.md.

That shrug is the whole problem.

The memory is not the sixth piece of the loop. It is the thing the loop exists to produce.

This mini book takes that inversion seriously and follows it all the way down. It picks up where The Clarity Forge left off — with lat.md/, the lattice of ADRs, vocabulary, invariants, patterns, and principles — and finishes the job: turning a directory of Markdown files into a queryable, typed, provenance-bearing metagraph that many agents read from and write to at once, wired into every stage of the OpenSpec pipeline.

What You Get

  • The two-graph distinction — why every serious agentic system needs a work graph (what happened) and a knowledge graph (what is true), why collapsing them destroys both, and the exactly two predicates that bridge them.
  • The ladder — loop, chain, swarm, DAG, knowledge graph — with what each one externalises and a six-question decision procedure for picking a rung.
  • A complete schema — twelve node types, eleven authored predicates across two planes, two derived relations, four layers, and five graph invariants you can write a linter against.
  • Lattice metagraphs — why the forge lattice was a metagraph from day one, the three reification patterns that matter, and how to implement it in Markdown plus 300 lines of indexer instead of a database that does not exist.
  • Semantic Spacetime for the lattice — the four fundamental relations, the discovery that the forge's five predicates are blind in exactly one direction, and pragmatic proximity as the mechanism that serves seven pipeline stages from one graph.
  • The seven-step context builder — bounded, typed, time-filtered retrieval under a token budget, with stable edge IDs so answers can cite.
  • The grounded evaluator — replacing "looks good" with a structured verdict that names the missing edge.
  • The rewired pipeline — every forge stage with its graph reads and writes, and an archive command extended from mint → touch → resolve to mint → touch → resolve → link → check.
  • Swarm coordination via promise theory — write scopes, correlated errors, reducer contracts, and why worktree isolation is necessary and nowhere near sufficient.
  • A six-step build path with an exit criterion at every step, from one reflective loop on Day 1 to a graph-grounded swarm by Month 2.
  • A full chapter on when not to build any of this.

Who It Is For

  • Engineers running Claude Code, Cursor, Codex, or any coding agent unattended, who have noticed that the loop ships code and loses reasoning.
  • Teams whose lat.md/ lattice has outgrown grep — more than a hundred nodes, more than one writer.
  • Anyone who has come back to forty green commits and could not say why the retry budget is three.
  • Knowledge-graph practitioners who want the agentic-workflow application rather than another survey.

This is a field guide. Every schema is implementable, every prompt is runnable, and the whole thing runs on Markdown files if you want it to — the graph index is disposable and rebuilds in seconds.

What It Is Not

It is not a survey of agent frameworks, a defence of any graph database, or an argument that every team needs a knowledge graph. Chapter 12 spends most of its length arguing the opposite, because the failure mode of this decade is not too little structure — it is structure adopted for its own sake.

If a NOTES.md and a disciplined ADR log already let you trace every important output to an objective, a plan, an artifact, a source, a graph path, an evaluator decision, and a bounded execution record, then you are done, and this book will tell you so.

The Series

📖 Clarity Engineer: Code Is the Side Effect — the discipline.

🔨 The Clarity Forge — the pipeline. 🕸 

The Loop That Remembers — the memory.

Also relevant: Semantic Space Time for AI Agent Ready GraphsBeyond Context GraphsTemporal Aware AI memory, and LadybugDB for Edge Agent AI memory.

About the Author

Volodymyr Pavlyshyn writes and builds at the intersection of agent orchestration, knowledge representation, and the durable artifacts that make software teams legible to themselves. He is the author of Clarity EngineerThe Clarity Forge, and a series of books on graph-based memory for AI agents.

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

The Loop That Remembers

  1. Graph Engineering for Multi-Agent Development

Preface — The Loop Ran All Night

  1. What This Book Is
  2. What You Need To Have Read
  3. What This Book Is Not
  4. How To Read It

Part I — The Argument

Chapter 1 — Everyone’s Building Loops. Almost Nobody’s Building the One That Remembers

  1. 1.1 What Loop Memory Actually Captures
  2. 1.2 The Three Honest Risks
  3. 1.3 The Inversion
  4. 1.4 Why Markdown Files Stopped Being Enough
  5. 1.5 What “Graph Engineering” Actually Names
  6. 1.6 The One-Sentence Test

Chapter 2 — The Ladder: Five Architectures, Five Bottlenecks

  1. 2.1 The Five Rungs
  2. 2.2 Rung One: The Loop, And The Four Conditions
  3. 2.3 Rung Two And Three: Chains And Swarms
  4. 2.4 Rung Four: The DAG Is The Graph
  5. 2.5 Rung Five: The Knowledge Graph
  6. 2.6 Choosing A Rung
  7. 2.7 What The Ladder Tells You About This Book

Chapter 3 — Two Graphs, Not One

  1. 3.1 The Two Questions
  2. 3.2 The Two Failure Modes Of Collapsing Them
  3. 3.3 The Bridge
  4. 3.4 You Already Have Both, Badly
  5. 3.5 A Worked Example Of The Split
  6. 3.6 The Rule

Part II — The Structure

Chapter 4 — The Lattice You Already Have

  1. 4.1 The Lattice In One Page
  2. 4.2 What It Gets Right
  3. 4.3 What It Cannot Do
  4. 4.4 The Pattern In The Six
  5. 4.5 What Survives The Promotion

Chapter 5 — Lattice Metagraphs

  1. 5.1 The Three-Level Hierarchy, Briefly
  2. 5.2 Four Places The Lattice Is Already Metagraphic
  3. 5.3 Accidental Metagraphs
  4. 5.4 The Layer Model
  5. 5.5 Homoiconicity, And Why It Matters Here
  6. 5.6 Implementing It Without A Metagraph Database
  7. 5.7 When You Do Not Need Full Metagraph Expressiveness
  8. 5.8 What Chapter 6 Adds

Chapter 6 — Semantic Spacetime for the Lattice

  1. 6.1 The Four Relations
  2. 6.2 Mapping The Forge’s Five
  3. 6.3 What The Missing Relation Costs
  4. 6.4 NEAR Is Computed, Never Authored
  5. 6.5 Pragmatic Proximity Is The Whole Trick
  6. 6.6 Why Not Just Embeddings
  7. 6.7 LEADS_TO And The Temporal Dimension
  8. 6.8 The Extended Vocabulary

Chapter 7 — The Schema

  1. 7.1 Design Constraints
  2. 7.2 Node Types
  3. 7.3 Predicates
  4. 7.4 The Node File Format
  5. 7.5 Reference Syntax
  6. 7.6 A Complete Worked Example
  7. 7.7 The Four Graph Invariants
  8. 7.8 The Directory Layout
  9. 7.9 Migration From A Forge Lattice

Part III — The Mechanism

Chapter 8 — Building the Graph

  1. 8.1 What To Parse And What To Extract
  2. 8.2 Stage 1 — Extraction
  3. 8.3 Stage 2 — Resolution
  4. 8.4 Stage 3 — Assembly
  5. 8.5 Stage 4 — Query
  6. 8.6 This Is Graph Autoresearch
  7. 8.7 Building The Gold Set

Chapter 9 — Context Assembly and the Grounded Evaluator

  1. 9.1 The Failure Mode This Prevents
  2. 9.2 The Seven-Step Context Builder
  3. 9.3 Grounding: From Critique To Check
  4. 9.4 The Forge Version
  5. 9.5 What Stays With The Model
  6. 9.6 Multi-Hop Answers Need Path Evaluation
  7. 9.7 The Honest Limit

Chapter 10 — The Swarm Against One Graph

  1. 10.1 The Write Problem
  2. 10.2 Promise Theory: Workers Own Their Promises
  3. 10.3 Worktree Isolation, And Its Limit
  4. 10.4 The Write Protocol
  5. 10.5 The Reducer, And Why It Needs A Contract
  6. 10.6 Making Verification Actually Independent
  7. 10.7 Budgets Are Not Optional
  8. 10.8 When Fan-Out Hurts

Chapter 11 — The Pipeline, Rewired

  1. 11.1 The Full Stage List
  2. 11.2 What Changes At Each Stage
  3. 11.3 The Archive Command, Extended
  4. 11.4 LINK, In Detail
  5. 11.5 Costs, Honestly
  6. 11.6 What Not To Automate

Part IV — Judgment

Chapter 12 — Metrics, Failure Modes, and When Not To Build This

  1. 12.1 Metrics By Layer
  2. 12.2 Metrics Get Gamed, Always
  3. 12.3 Entity Resolution Can Cause Catastrophic Errors
  4. 12.4 The Graph Amplifies Builder Judgment
  5. 12.5 A Graph Reflects Its Corpus
  6. 12.6 The Cost Side
  7. 12.7 When Not To Build A Graph
  8. 12.8 Sketches Are Not Production Software
  9. 12.9 The Test, Again

Chapter 13 — The Build Path

  1. 13.1 Day 1 — Build The Loop
  2. 13.2 Day 2 — Add One Tool
  3. 13.3 Week 1 — Add Planning
  4. 13.4 Week 2 — Go Multi-Agent
  5. 13.5 Month 1 — Wire In The Graph
  6. 13.6 Month 2 — Scale To A Swarm
  7. 13.7 The Reference Architecture
  8. 13.8 The Default Task Loop
  9. 13.9 The Production Checklist
  10. 13.10 Closing

Appendix A — Graph Engineering on One Page

  1. The Claim
  2. The Test
  3. The Ladder
  4. Two Graphs, Not One
  5. The Vocabulary
  6. The Node Types
  7. The Four Semantic Modes
  8. The Five Graph Invariants
  9. The Pipeline
  10. The Seven-Step Context Builder
  11. The Grounded Evaluator
  12. The Build Path
  13. The Iron Rules
  14. When Not To Build This

Appendix B — Schema Reference

  1. B.1 Node Types
  2. B.2 Predicates
  3. B.3 Reference Syntax
  4. B.4 Node File Format
  5. B.5 Reified Assertion Format
  6. B.6 Layers
  7. B.7 The Five Graph Invariants
  8. B.8 Derived Index Schema
  9. B.9 Retrieval Policy (Layer 3)
  10. B.10 Directory Layout
  11. B.11 CLI Surface

Appendix C — The Prompts

  1. G1 — Graph Reconciliation (extends Glue 3¼, Lattice Reconciliation)
  2. G2 — Bounded Context Assembly (replaces the Stage 5 spec-slice selection)
  3. G3 — The Grounded Evaluator (replaces the ADR-alignment portion of Stage 6)
  4. G4 — Extraction (new; Stage: index build)
  5. G5 — Resolution Arbitration (new; Stage: index build)
  6. G6 — Promise Declaration (new; Stage 5, per dispatched worker)
  7. Installation

Further Reading

  1. The Clarity Series
  2. Graph Structures
  3. Foundational Theory
  4. Architecture and Documentation Practice
  5. Agent Workflow Practice
  6. Tooling
  7. A Note On The Paper That Started This

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