Run artifact

workspace/targets/ReadingList/blueprint/DATABASE.md

DATABASE: ReadingList

FieldValue
Version20261023 V1
DescriptionPersistence stores and typed interfaces for ReadingList.
Depends OnARCHITECTURE.md
Providespersistence.books
Build Order1

Persistence Boundary

BoundaryRule
Raw storage accessOnly the generated persistence/ package reaches the store.
Caller dependencyFeatures depend on declared access patterns and their DTOs, not on schemas.
ImplementationGenerated from this file at the DATABASE build step; never written by hand.

Access Patterns

FEATURE-READING-LIST-001 — List books

FieldValue
OwnerFEATURE-READING-LIST.md
Accessread
Repository operationbooks.list
Compatibilityunchanged

Input: BookListInput

FieldTypeRequired
———

Output: BookRow[]

FieldType
idINTEGER
titleTEXT
authorTEXT
insertion_orderINTEGER

FEATURE-ADD-BOOK-001 — Create a book

FieldValue
OwnerFEATURE-ADD-BOOK.md
Accesswrite
Repository operationbooks.create
Compatibilityunchanged

Input: BookCreateInput

FieldTypeRequired
titleTEXTyes
authorTEXTyes
insertion_orderINTEGERyes

Output: BookRow

FieldType
idINTEGER
titleTEXT
authorTEXT
insertion_orderINTEGER

FEATURE-REMOVE-BOOK-001 — Delete a book

FieldValue
OwnerFEATURE-REMOVE-BOOK.md
Accesswrite
Repository operationbooks.delete
Compatibilityunchanged

Input: BookDeleteInput

FieldTypeRequired
idINTEGERyes

Output: DeletedBook

FieldType
idINTEGER

Schemas

books

FieldTypeNotes
idINTEGER PKStable book identifier.
titleTEXT NOT NULLBook title.
authorTEXT NOT NULLBook author.
insertion_orderINTEGER NOT NULL UNIQUEMonotonic order assigned when the book is added.

Migrations

Access PatternRevisionState
FEATURE-READING-LIST-001MIGRATION-FEATURE-READING-LIST-001planned
FEATURE-ADD-BOOK-001MIGRATION-FEATURE-ADD-BOOK-001planned
FEATURE-REMOVE-BOOK-001MIGRATION-FEATURE-REMOVE-BOOK-001planned

Config (.env)

KeyTypeRequiredNotes
DATABASE_URLstringnoOptional database DSN; overrides DATABASE_PATH.
DATABASE_PATHstringnoOptional local database path; defaults to data/app.db.

File Stores

StoreRoot dirNotes
——No file store.

External Services

ServiceWrapperNotes
——No external services.

External Libraries

LibraryOwnershipDistributionConsumer Contract
———No external persistence libraries.

Programmatic Acceptance

=== AC database-books-create ===
Intent: The books create operation returns the declared book row with the supplied values.

from persistence.testing import db_session

title = "The Left Hand of Darkness" author = "Ursula K. Le Guin" insertion_order = 1

with db_session() as db: row = db.books.create( title=title, author=author, insertion_order=insertion_order, ) assert row.title == title assert row.author == author assert row.insertion_order == insertion_order === END AC database-books-create ===

=== AC database-books-list ===
Intent: The books list operation returns books in insertion order.

from persistence.testing import db_session

first_title = "Dune" first_author = "Frank Herbert" second_title = "Kindred" second_author = "Octavia E. Butler"

with db_session() as db: db.books.create( title=first_title, author=first_author, insertion_order=1, ) db.books.create( title=second_title, author=second_author, insertion_order=2, ) rows = db.books.list()

assert [row.title for row in rows] == [first_title, second_title] assert [row.author for row in rows] == [first_author, second_author] === END AC database-books-list ===

=== AC database-books-delete ===
Intent: The books delete operation returns the selected identifier and removes that book from subsequent reads.

from persistence.testing import db_session

title = "A Wizard of Earthsea" author = "Ursula K. Le Guin"

with db_session() as db: created = db.books.create( title=title, author=author, insertion_order=1, ) deleted = db.books.delete(id=created.id) assert deleted.id == created.id

remaining = db.books.list() assert all(row.id != created.id for row in remaining) === END AC database-books-delete ===

User Acceptance

Guardrails