lmjtfy.git / packages

Chapter 5: packages, the part that only thinks

If chapter 2 was the hands, this is the head. Every crate in here is plain Rust that does no I/O: no network, no clock, no database, no Cloudflare. It cannot, because none of them depend on the Worker's runtime, and Rust will not compile a call to something you do not depend on.

That restriction buys a lot. Each package is tested with cargo test on any machine, in a fraction of a second. The tricky decisions (which rule fires, what Jev was asked, whether a budget can cover a call, what a picture looks like) are all made here, where they are easy to test, and the Worker only carries them out.

flowchart LR
  rules --> ask
  llm --> ask
  ask --> archive
  budget --> archive
  archive --> card
  tree

(An arrow means "is used by". tree stands alone: it is only for the code pages.)

Try it. cargo test --workspace from the repository root runs every package's tests. It needs no network and no account.

The chapters that follow take them in the order a question meets them: the rules decide (6), the questions are put (7), the LLM writes when it must (8), the archive keeps everything (9), the budget keeps it affordable (10), the card draws the answer for a link preview (11), and the tree shows you this page (12).

In this folder

PackageWhat
rules/The rules that decide what happens to a query, compiled into a Rete network, and which facts to ask Jev for together.
ask/The questions put to Jev (one per fact the rules want, and whatever the LLM drafted) and the record each call leaves.
llm/What the LLM is told and given, and how its reply is read.
archive/The messages to the archive, which keeps every answered request and the feed of questions.
budget/The shared daily budgets (hold, then settle) and each visitor's per-minute count.
card/The picture a link unfurls with: the question and Jev's answer as a small PNG.
tree/The code pages' data: GitHub's listing of a path read into types, and markdown as HTML.

← Previous: Chapter 4, view/ · Up: lmjtfy · Next: Chapter 6, rules/ →