lmjtfy.git / packages / README.md
1# Chapter 5: packages, the part that only thinks
2
3If chapter 2 was the hands, this is the head. Every crate in here is plain
4Rust that does no I/O: no network, no clock, no database, no Cloudflare. It
5cannot, because none of them depend on the Worker's runtime, and Rust will
6not compile a call to something you do not depend on.
7
8That restriction buys a lot. Each package is tested with `cargo test` on any
9machine, in a fraction of a second. The tricky decisions (which rule fires,
10what Jev was asked, whether a budget can cover a call, what a picture looks
11like) are all made here, where they are easy to test, and the Worker only
12carries them out.
13
14```mermaid
15flowchart LR
16  rules --> ask
17  llm --> ask
18  ask --> archive
19  budget --> archive
20  archive --> card
21  tree
22```
23
24(An arrow means "is used by". `tree` stands alone: it is only for the code
25pages.)
26
27> **Try it.** `cargo test --workspace` from the repository root runs every
28> package's tests. It needs no network and no account.
29
30The chapters that follow take them in the order a question meets them: the
31rules decide (6), the questions are put (7), the LLM writes when it must
32(8), the archive keeps everything (9), the budget keeps it affordable (10),
33the card draws the answer for a link preview (11), and the tree shows you
34this page (12).
35
36## In this folder
37
38| Package | What |
39| --- | --- |
40| [rules/](rules/) | The rules that decide what happens to a query, compiled into a Rete network, and which facts to ask Jev for together. |
41| [ask/](ask/) | The questions put to Jev (one per fact the rules want, and whatever the LLM drafted) and the record each call leaves. |
42| [llm/](llm/) | What the LLM is told and given, and how its reply is read. |
43| [archive/](archive/) | The messages to the archive, which keeps every answered request and the feed of questions. |
44| [budget/](budget/) | The shared daily budgets (hold, then settle) and each visitor's per-minute count. |
45| [card/](card/) | The picture a link unfurls with: the question and Jev's answer as a small PNG. |
46| [tree/](tree/) | The code pages' data: GitHub's listing of a path read into types, and markdown as HTML. |
47
48← Previous: [Chapter 4, view/](../apps/lmjtfy/src/view/) · Up: [lmjtfy](../) · Next: [Chapter 6, rules/](rules/) →