This is the second article in the hands-on series about shaping a real-world problem into code using Ontologic . Each article focuses on one main idea and points to the library-examples repo so you can read, run, and change the code yourself. In this article we pick up the librarian's project from Part 1 and tackle the next thing that lives on paper: the Loan . Along the way we meet invariants rules that must hold true about an entity at all times, not just when a specific command runs. If you haven't read Part 1 yet, I'd recommend starting there. We modeled the Book entity, introduced domain events and typed domain errors. Picking up where we left off In Part 1 the librarian was happy: the staff could add books, mark one as lost, and every change produced an event they could audit later. Now they want to actually lend books. So a staff member opens the "new loan" form. They pick a book, they pick a member, the system proposes a due date three weeks out, and they save. Good.…