The Foundation Charter
Choose dependable foundations before delegating substantial work to machines.
The New Programming set out the division of labour: the machine increasingly produces the code, while I define the behaviour, organise the work, and judge the result. This chapter answers the first practical question that follows.
If the machine is going to do the coding, what should I decide before the work begins?
Ask a capable model to start a new project with no constraints and it may recommend several databases, compare frameworks, sketch alternative architectures, and generate configuration before anyone has properly understood the problem. The same tendency can persist throughout development. Each new task becomes an occasion to reopen an architectural decision, introduce an inconsistent pattern, or add a dependency that solves one small problem while creating three larger ones.
The answer is unglamorous: understand the problem, establish the broad solution, and choose foundations I understand well enough to supervise.
Fluency is not judgement. A machine can propose frameworks and compare databases in seconds. I still need a starting point I know well enough to direct, to recognise when the machine has drifted, and to diagnose failure when — not if — it occurs.
I want to constrain the machine’s choices without constraining its ambition. Every architectural decision I settle in advance is one the machine does not have to make again with each task. In my experience, that is how a charter concentrates the machine’s effort on what matters: the behaviour of the software.
My usual starting point is PostgreSQL, Python, ZeroMQ, HTML, and YAML. These are my defaults, not prescriptions for the reader. The important thing is to have a foundation you have chosen deliberately and understand well enough to supervise.
Know the tools you depend upon
A good craftsperson knows their tools. They know what each tool does, what it does well, where it fails, and how to recognise a problem.
Machine coding makes that knowledge more valuable, not less, because I may no longer be writing most of the implementation by hand.
When something goes wrong — and in any real system, something will — I need enough understanding to distinguish a problem in the application logic from one in the database, the messaging layer, the configuration, or the testing environment. A machine can help with each of those diagnoses, but only if I can frame the question and evaluate the answer.
I do not need to know how to build every tool I use. I need to understand it well enough to guide the machine, challenge its explanations, and recognise a proposal that follows every convention but is still wrong for my system.
Start with the problem, not the framework
Before selecting technologies, I establish the shape of the work:
- What problem is being solved, and for whom?
- What is the general solution in broad architectural terms?
- What information must be stored, and for how long?
- What operations might take a long time and should not block the user?
- What components must communicate, and how promptly?
- What will users interact with?
- What behaviour must be verified before a change is accepted?
- What operational constraints matter: backup, recovery, audit, cost, deployment?
The charter grows out of those answers. A small internal tool with one user and modest data has different needs from a multi-user system with long-running operations and audit requirements. Recording those needs gives both me and the machine a basis for later decisions. It also guards against a familiar mistake: building an elaborate architecture for a simple problem.
The charter is not a complete design. It records the decisions that subsequent work should inherit, why those decisions were made, and which constraints a proposed departure must satisfy.
I generally start with PostgreSQL
My preferred general-purpose database is PostgreSQL: a mature relational database with transactional integrity, well-understood indexing and querying, and established backup and recovery tooling. Its documentation is extensive, and its integration with Python and other major languages is well established. When something fails, I can draw on familiar diagnostic procedures and a large body of practical experience. That confidence matters when a machine has just produced several hundred lines of database code I did not write.
Two capabilities of that base deserve attention, because they let one database cover work that might otherwise require additional services.
First, pgvector adds vector similarity search to PostgreSQL, so embeddings can live alongside relational data in ordinary tables. It supports exact and approximate nearest-neighbour search with common distance measures, and it preserves the transactional properties of the surrounding database, including the write-ahead logging used for replication and point-in-time recovery.
Second, PostgreSQL provides built-in full-text search, documented in Chapter 12 of the manual, with parsing, dictionaries, ranking, and index support for textual documents.
The appeal is consolidation. Relational storage, vector similarity, and full-text search can coexist in one database. That can mean fewer integration boundaries, fewer credentials, fewer deployment steps, and fewer ways for the machine to get the interactions between components wrong. It also allows keyword and vector retrieval to complement one another through hybrid queries and re-ranking.
PostgreSQL is not the right answer everywhere, and installing an extension does not by itself produce good search. Retrieval quality still depends on indexing and ranking decisions, and high-throughput time series, demanding graph traversals, embedded use, or managed-service constraints can justify other choices. My rule is to choose the boring option deliberately and to ask for a reason before departing from it.
Python is my default, not my dogma
For this book, assume Python is the primary application language.
I choose Python for concrete reasons. It has longstanding support in machine learning and data tooling, mature testing and web frameworks, broad documentation, and readable syntax that makes review comparatively straightforward. Common patterns, project layouts, and test conventions are widely shared, which helps both humans and coding tools find their bearings. The Python documentation is stable and easy to point both parties towards.
As machines take on more of the implementation, my preference for a language depends less on how quickly I can write it. Its suitability for the system still matters. Someone experienced with Go, Rust, Java, C#, JavaScript, or another language does not need to switch to Python to practise machine coding.
My principle is narrower: choose a language appropriate to the project that you can navigate when problems arise. Familiarity matters for debugging, for reviewing architectural choices, for interpreting error traces, and for maintaining the project after the machine has produced a large volume of code. Choose what you can supervise.
Give long-running work somewhere to go
My preference for ZeroMQ is somewhat unconventional, so I want to explain it carefully — and to separate two problems that are easy to conflate.
The first problem is background work. Calling an external model, processing a document, rebuilding an index, or running a batch of checks can take considerable time. If the interface waits for the operation to finish, a single slow dependency can make the application appear unresponsive. I separate the request from its execution: record or dispatch the work, let a worker carry it out, and keep the interface responsive while the user waits for the result.
The second problem is notification. Once work has completed or state has changed, interested components — a dashboard, a progress view, another service — need to discover that something happened. That is a different job from executing the work itself.
ZeroMQ is a mature messaging library that can support communication between threads, processes, and services in both kinds of design. The ØMQ guide covers its patterns from basic exchanges through reliable request-reply, and treats reliability as a design problem rather than a promise. ZeroMQ supplies the messaging primitives; it does not itself create workers, schedule jobs, or retain state durably. Message loss on restart, reconnect behaviour, retries, idempotency of handlers, and persistence of pending work all need explicit answers.
ALIVE shows one way to divide these responsibilities, as described in its architecture notes. PostgreSQL retains events in a transactional event log. An outbox publisher emits notifications over ZeroMQ PUB/SUB. A subscriber helps wake the dashboard, and the dashboard can reconstruct anything it missed by re-reading the persisted history. Delivery of any single notification is not treated as durable; durability lives in the database.
The distinction is worth remembering:
PostgreSQL preserves what happened. ZeroMQ helps interested components discover that something happened. The notification is not the record.
A simple request-response application with fast handlers may need neither workers nor notifications. I introduce decoupling when long-running work, background processing, or independent components justify it — and I record that decision in the charter, including which problem each mechanism is meant to solve.
Prefer familiar presentation technologies
For many applications I prefer an HTML-based web interface: HTML, CSS, and JavaScript in the browser, communicating with backend services over familiar APIs.
Browser interfaces benefit from established development and debugging tools, extensive libraries, and familiar patterns for forms, tables, navigation, and authentication. Both people and models have a substantial body of examples to draw on. Even for a local-first application, a browser interface over a local backend can avoid much of the friction of native packaging.
I do not mandate a particular JavaScript framework, and native desktop applications remain valid where appropriate. My guidance is to prefer the familiar default and to justify departures from it.
Keep configuration explicit
I use YAML for human-readable configuration: application and development settings, workflow definitions, declarative environment descriptions, and other material that should be version-controlled and reviewed as data rather than buried in implementation code.
Consider a versioned workflow that declares what runs, in what order, and with which parameters. I can review and change the declared sequence without reading the implementation of each operation. The machine and I can refer to the same explicit description of what the workflow is intended to do.
YAML needs care. Types, indentation, parsing subtleties, and schema drift cause real defects, so I validate configuration against a schema, keep the boundary between configuration and executable behaviour explicit, and never put secrets in committed configuration files. Where YAML proves brittle, TOML, JSON, or ordinary code configuration may serve better. The aim is explicit, reviewable configuration — not loyalty to a file format.
Why settled foundations help
The value of these choices is not that any one of them is exceptional. It is that, together, they give the machine a stable environment in which to work.
Widely adopted tools come with documentation, examples, conventions, testing practices, and communities. When a repository follows established patterns, a machine has a familiar structure to work within. I have a reference point too: an unusual proposal is easier to recognise, an error easier to investigate, and an independent review easier to direct.
I think of the charter as leverage. Time spent making and recording a decision once can pay back across dozens of delegated tasks. The more work I delegate, the more valuable that shared starting point becomes.
Testing needs supervision too
Testing belongs in the charter from the beginning, even though verification gets fuller treatment later in the book.
A machine that produces code rapidly also produces tests rapidly, and I have watched the consequences first-hand: the suite grows quickly, slows down, accumulates duplication, and starts consuming more attention than the source code. At that point I am supervising the testing system rather than the product — a strange position to find oneself in, and one worth preventing.
I judge tests by what they establish and what they cost. Tests that cover consequential behaviour earn their place. Duplicates establish little that the suite does not already know. Fragile tests fail on irrelevant changes and teach everyone to ignore red builds. Expensive tests, including live model calls and checks against external services, may provide essential evidence at system boundaries. Their cost is a reason to run them deliberately, not necessarily a reason to remove them.
My working arrangement is two paths. A fast routine suite runs often and stays
quick enough to guide ordinary development. A separate comprehensive path —
integration tests, end-to-end behaviour, live-provider checks — runs on a
stated schedule and guards the properties the fast loop cannot reach. Measured
execution times keep this honest; pytest’s --durations reporting (see
how to invoke pytest)
makes slow tests visible rather than merely felt.
I have seen isolated tests pass while the integrated functionality remained unavailable or incorrectly wired. A green suite tells me that the checks it contains passed; it does not tell me that those checks were sufficient. The charter must establish not only how the software will be tested, but how the testing system itself will be kept useful. Later chapters take up independent verification and quality gates.
A worked example
Here is the kind of charter I would give a machine before delegating the first substantial piece of work. The project is illustrative; it is not a description of ALIVE.
Suppose I am building a local-first assistant that ingests project documents, extracts passages, and answers questions with citations. The users are a small team working with sensitive material that must stay on their machines. The broad architecture is a Python service with a local database, background ingestion workers, and a browser interface.
| Decision | Choice for this project |
|---|---|
| Problem | Team members cannot find or cite passages across a growing set of local documents |
| General solution | Local Python service; ingest and index documents in the background; answer questions through a browser view with citations |
| Primary language | Python, because I can debug and review it confidently |
| Database | PostgreSQL for documents, metadata, and ingest history |
| Semantic retrieval | pgvector for passage embeddings, evaluated against a held-out question set before acceptance |
| Text retrieval | PostgreSQL full-text search for keyword and citation lookup; combined with vector results where evaluation supports it |
| Background work | Separate ingestion workers for parsing, embedding, and indexing, so processing does not block the interface |
| Messaging and notification | Durable ingest state in PostgreSQL; ZeroMQ PUB/SUB notifications to wake the interface when new material is ready; missed updates recovered by re-reading the database |
| User interface | HTML-based local web view; no JavaScript framework mandated for the first version |
| Configuration | Versioned YAML for ingest pipelines and retrieval settings, validated against a schema; secrets kept out of the repository |
| Testing | Fast pytest suite for units and boundaries; separate integration suite for ingestion and retrieval; live model checks marked and run explicitly; --durations reviewed when the suite slows |
| Acceptance principles | Documents can be ingested end to end; cited passages can be traced to stored sources; the interface recovers missed updates by re-reading durable state |
Suppose the machine proposes adding a dedicated vector database. Without a charter, the discussion can easily become a comparison of database features. With a charter, I have a more useful question: what retrieval requirement does PostgreSQL with pgvector fail to meet, and what evaluation would demonstrate that failure and the benefit of the alternative?
The machine is welcome to make that case. A charter should not preserve a bad decision simply because it was made early. If the evidence justifies a departure, I approve it, update the charter, and let subsequent tasks inherit the revised decision. The same discipline applies to a new framework, a new queue, or a new configuration scheme.
Readers building something entirely different should take the shape of this document, not its particular answers. The transferable part is the set of decisions to record and the discipline of referring each proposal back to them.
ALIVE as the running example
Our running system follows this pattern in its present form: a Python application backend, PostgreSQL persistence including an event log, vector and text retrieval where needed, ZeroMQ notifications alongside durable stored events, a browser-based interface, declarative workflow definitions, and testing with independent review.
This is the architecture as it stands, not the architecture as originally conceived. Some choices emerged through development; the later retrospective examines what was tried, replaced, or left experimental. ALIVE illustrates why a charter should record the foundations the system actually rests on rather than preserve an outdated account of its design.
What the charter makes possible
Choosing slowly before building quickly may seem at odds with the speed of machine coding. In practice, the two complement one another. Once the foundations are understood and recorded, the machine can work within them, challenge them where necessary, and devote more of its effort to the problem I am trying to solve.
The charter is how I make a decision once and carry its value into the work of many machines.
Once I know what I am building on, one more decision belongs ahead of the work: which intelligence does which part of it. That is the subject of Configuring Your AI.