Grigoriy Dobryakov

Howto · breakdown

Breakdown 01 Facebook · 105,399 views · 203 comments

Book-as-context: designing complex architecture with AI through a book substrate

How to ground an agent on an authoritative primary source so it designs event-driven architecture with delivery guarantees — not a naive FTP exchange — from a single prompt.

CTO Head of AI Tech Lead Architect

Problem

Tell Claude or Cursor "build order transfer from an e-commerce system to an ERP" — you get a naive file exchange over FTP and a report saying "done." Engineers laugh and conclude "AI can't handle architecture."

The root isn't the model. The model draws on the "average of the internet" — averaged code from open sources where production-grade integrations are rarer than tutorials. Without a domain knowledge base the agent doesn't know the right answer here is event-driven with delivery guarantees, idempotency, and data consistency across systems.

End-to-end example: store → ERP

Same class of task, two different outcomes.

Without substrate: "Build order transfer from e-commerce to ERP" → CSV, cron, FTP, "done."

With Tanenbaum wiki — real brief: integration 1C-Bitrix → Galaktika ERP → Creatio CRM. The agent walks a concept graph:

"ERP may be down for hours, orders must not be lost"
  → message-oriented middleware (MOM):
    persistent communication — queue holds message until delivered
    vs transient communication — receiver must accept right now
  → message queue systems — not email: delivery guarantees, logging, load balancing
  → AMQP: unsettled → settled → forgotten — three delivery commit steps
  → two-phase commit (2PC) — if two databases must update atomically
Question Without wiki With wiki (actual output)
Sync model REST "sent — done" outbox in DB → broker → adapters (async)
ERP offline "resend manually tomorrow" persistent communication: queue buffers; store stays up
Loss / duplicate "send again" idempotency key, at-least-once, dead letter queue (DLQ)
Transport to ERP FTP as primary path bus/queue → REST/SOAP → file exchange fallback only
ERP + CRM "hope for best effort" state journal, partial success, eventual consistency

What actually came out

Excerpt from a real spec: agent with wiki substrate for 1C-Bitrix → Galaktika ERP → Creatio CRM.

Event source — Bitrix after order commit. Event is recorded via transactional outbox, transformed into a canonical model, and placed in a persistent broker. Adapters deliver asynchronously to ERP and CRM; cross-cutting state in an integration journal. Retries via idempotency, exponential backoff, and DLQ; order updates preserve causal ordering.

Logical diagram from §7.1:

[Bitrix store] --(Outbox/event)--> [Integration service]
                                      |
                    Canonicalization, validation, master data enrichment
                                      |
                         [Message broker (persistent queues)]
                         /                              \
            [Galaktika ERP adapter]            [Creatio CRM adapter]
                         \                              /
                          `--> [State journal / integration DB] <--'

ERP transport priority — file exchange is not the primary path:

Priority Choice
1 Enterprise bus / queue manager
2 HTTPS REST or SOAP
3 (fallback) File exchange — emergency or batch channel only

SLO and resilience (§6.1)

Metric Value in spec
RPO (broker/outbox) 0 — loss unacceptable
RTO ≤ 1 h normal, ≤ 4 h under degradation
End-to-end ERP + CRM P95 ≤ 5 min, P99 ≤ 15 min
Integration availability ≥ 99.9% / month

Partial success ERP + CRM (§12.3)

Eventual consistency without automatic two-phase commit.

Channel security (§8)

Traceability: wiki → spec (Appendix A)

Wiki principle (Tanenbaum term) Reflected in spec
Queues: delivery, persistence, load balancing §6.1, §7.1, §12.1
Fault tolerance: redundancy, failure models §6.1, §7.5
RPC/timeouts: retries, idempotency §7.4, §7.5, §12.1
Eventual consistency, compensation §5.5, §12.3
Security: threats, encryption, DoS §8, §12.4
Scalability: DS fallacies, cache/TTL §6.2, §12.2

§1.2 references wiki: middleware over point-to-point, failure models, retry semantics (at-least-once, etc.). Forbidden assumptions from §6.2 — fallacies of distributed computing: "the network is reliable", "latency is zero", "topology never changes."

Methodology

Ground the agent on a specific authoritative book in the domain.

  1. 1. Choose the book. For architecture / high-load / event-driven systems — Tanenbaum, Distributed Systems: Principles and Paradigms. The "Kotler for marketers" level: rigorous theory with formulas, not a summary.
  2. 2. Chunk into a wiki. olw pipeline (obsidian-llm-wiki): fast model for ingest, heavy for compile. Current Tanenbaum run: 30 source chunks → 116 concept pages in .drafts/.
  3. 3. Parameters. Several iterations over chunk sizes / token counts / models. Full run cost: around $1.50 via OpenRouter. Three olw runs produced 16 + 14 + 23 note(s).
  4. 4. Drop into the project. Wiki lives in the repo. Agent navigates the index — via hybrid-search MCP (breakdown #02) or Cursor indexing. Context doesn't degrade: the agent walks files without loading the entire book into the window.
  5. 5. Agent layer on top of retrieval. Wiki + retrieval is infrastructure. On top — query routing, score interpretation, traversal from business requirement to pattern. Queries use the author's terms:
    Bad query Good query (author's term + plain language)
    "find something about Kafka" reliable multicast + FIFO ordering — delivery order and reliable broadcast
    "how to sync orders" persistent vs transient communication — queue holds vs receiver must be online now
    "delivery guarantees" AMQP: unsettled → settled → forgotten — three delivery commit states
  6. 6. Effect. Work plans, API contracts, infrastructure decisions, and vibe-coding flow through the book's lens. The level holds from a single prompt.

The mechanics transfer: wiki is text, it copies between projects. Different phases get different books: Clean Code for development, Fowler for review, Savin for QA.

Vault anatomy: three layers

Real directory structure of tanenbaum/wiki/:

tanenbaum/wiki/
├── raw/tanenbaum-full_rag_00012.md            # book chunk + YAML
├── wiki/sources/Tanenbaum Full_Rag_00012.md   # summary + Concepts
├── wiki/.drafts/Message transmission.md        # concept article
├── wiki/index.md                               # index of 30 sources
├── wiki/log.md                                 # olw run log
└── wiki.toml                                   # models, ctx, language

Layer 1 — raw chunk

rag_chunk: 12
rag_total_chunks: 30
rag_chunk_size: 51542
rag_overlap: 800

Layer 2 — source page

Concepts (author's chunk index): IBM WebSphere MQ, message channels, routing tables, message transmission — index before reading full text.

Layer 3 — concept article

Excerpt from wiki/.drafts/Message transmission.md:

Message queue systems provide guaranteed delivery,
priorities, logging, [[load balancing]] and [[fault tolerance]]
[[Tanenbaum Full_Rag_00012]].

Message transmission in [[AMQP]] has three stages:
1. Message in "unsettled state" on sender and server.
2. Receiver processed → "settled state".
3. Sender forgets the message, receiver formally marks settled
   [[Tanenbaum Full_Rag_00012]].

## See Also
[[Message-oriented models]] · [[Two-phase commit protocol]]
· [[Tanenbaum Full_Rag_00012]]

Cross-references aren't decoration: the agent goes from "orders must not be lost" to persistent communication (queue holds the message), then to AMQP delivery states (unsettled → settled), and only then — to Kafka/RabbitMQ as implementations.

Frontmatter + quality flags:

confidence: 0.35
status: draft
sources:
  - raw/tanenbaum-full_rag_00012.md

<!-- olw-auto: low-confidence (0.35) — verify before publishing -->
<!-- olw-auto: single-source — cross-reference recommended -->

Run parameters

From the real vault's wiki.toml:

fast = "google/gemini-2.0-flash-lite-001"   # ingest
heavy = "google/gemini-2.5-flash"           # compile
fast_ctx = 24000                            # ≈ 12k chars per chunk
max_concepts_per_source = 25
language = "ru"

olw pipeline: raw/ → ingest → compile → lint → approve. Command: olw run.

Artifact

Tool: obsidian-llm-wiki (olw) — local Karpathy-style LLM Wiki pipeline.

olw init my-book-wiki
# drop chunks into raw/
olw run
Series signature

Where it breaks

For whom and why

If you're building AI-assisted development and want the agent to hold an architectural standard without reminders — this methodology transfers to any domain. The bottleneck isn't code: it's choosing the right primary source and the discipline to apply it.

Want this architectural grounding in your team's AI workflow?

Setting up AI-assisted development so the agent designs at the level of the primary source — not the "internet average."

Email me

Other breakdowns

An engineering breakdown series: real task → methodology → working artifact → honest breakdown of where it fails.

Back to series →