Odysseus
Part VI · A worked application
Chapter 21

A firm's database: layout, intake and plans

How to give an empty customer database a shape, tell the model its layout, and file a whole source as one plan the program checks and the owner approves once, with lookups, before-and-after changes and a second look at the moment of acting.

After this chapter you should be able to
  • Say what changes when a product's first customer is named, and what does not.
  • Give an empty customer database a shape for venture work, and explain why current practice must be checked before designing one.
  • Hand a model a workspace's layout read from the service, and predict what that can break.
  • Design filing from a source as a plan the program checks and one approval for exactly that plan.
  • Treat a source as evidence of what someone wrote on a day, and keep an owner's house rules in memory rather than in code.
  • Decide which plans may run unasked and which must still be approved.
This unit
Week
13 of 14
Before it
Chapter 8, Chapter 13 and Chapter 9; Definitions 2, 5, 6 and 8 and Property 2 of the model, and Property 5 of Chapter 8.
Read first
[Fellegi and Sunter 1969]; [Elmagarmid et al. 2007].
Laboratory
None; these units feed the project
Problem set
None; assessed through the project

21.1The problem: a forwarded email names five things

This part of the book follows one application from start to finish: an assistant for an early-stage venture capital firm, one assistant per partner, with the firm's customer database as its memory. The program is the same one the earlier parts describe. What changes is what "working" means.

A partner forwards this, from a colleague: "Met Sam Okafor, founder of Orbit Labs (orbitlabs.example). They make scheduling software for satellite ground stations. Raising a $1.5M pre-seed. Introduced by Asha Verma at Northwind. I thought he was sharp. Next step: I will send him our deck by Friday." (All companies and people in this chapter are invented.)

The email names a company, a founder, an introducer who may already be on file, a deal, a next step with a date, and an opinion worth keeping in the colleague's words. Entered one record at a time through a gate that asks before every change, it is five or six approval questions in a row. And "Northwind" is not the name of anything on file: the firm holds "Northwind Robotics", and a program that looks names up exactly will create a second company. This chapter is about doing that errand well.

21.2A first customer

Definition
Customer database
Software in which a business keeps records of the companies and people it deals with, the deals in progress and how far each has got, and the notes, emails, meetings and calls behind them. Often called a CRM (customer relationship management). For a venture fund it is the firm's memory: who a founder is, what was last said, what is in the pipeline.

Naming the first customer changed three things. The errands are a partner's: who is this founder, what is at diligence, file this email. The system is fixed: the firm's database, Attio, reached through its own server (Chapter 13). And the evaluation needs errands of this kind, because those of Chapter 17 are a private person's.

It did not change the design. Asked whether the firm wanted one assistant for the firm or one for each partner, the owner answered "One per partner". One copy per person, acting with that person's own permissions, is what the program already was (Chapter 1). Reading decks (Chapter 22) and finding companies (Chapter 23) build on the database this chapter sets up.

21.3Giving an empty database a shape

The first read of the workspace found it new. It held the three objects every workspace starts with (companies, people, deals) and no lists. Verified, one live run. An empty database cannot answer "what is in the pipeline". The first useful act was therefore to lay one out.

Definitions
Object, record, field
An object is a kind of thing (companies, people, deals); a record is one of them; a field (Attio says attribute) is one value a record holds. A field has a type: text, a choice from a fixed set, a sum of money, a date, or a link to another record.
Deal
One possible investment in one company, from first contact to investing or passing. It links to the company and its people.
Stage
A choice field on a deal saying how far it has got. The ordered set of stages is the pipeline.
List
A collection of records with fields of its own that belong to the entry, not the record: a company's ownership percentage belongs to its place in the portfolio, not to the company.

The stand-in workspace used in the evaluation has eight stages: Sourced, Contacted, Met, Diligence, IC (investment committee), Term sheet, Invested, Passed. Its deal fields separate three sums of money that a careless design merges: Deal value, described as "Our cheque"; Round size; and Allocation offered, "What we were offered or asked for, which may differ from our cheque". It also has the round, the source, who introduced it (a link to a person), the next step and its due date, and pass reasons as a multiple choice.

Check current practice before designing

A layout should be checked against how practitioners lay one out. Checking the vendor's own guide for venture firms and one consultancy's write-up (sales material) against a design made from the firm's earlier layout and common sense found six gaps: no rule for when a deal leaves a stage; missing fields such as allocation offered and committee date; one reason for passing where several are needed; nothing about a holding after investing; nothing for the fund's own investors; and no automation.

Case note

The first draft of the layout was made without that check. The owner asked: "Is this SOTA for early-stage VC workflows?" Nobody had checked. The six gaps above came from checking. A second draft closed what could be closed within one constraint: the plan the workspace appeared to be on allowed three kinds of record, all in use, so the portfolio became a list of companies and the fund's own investors were left out. (The workspace was in fact on a trial of the paid plan; a layout made for the free plan survives the trial ending.)

Check current practice first

Look up how the thing is done before designing it. A design made from first principles reads as complete to the person who made it. The same was found of tests (Chapter 17) and of a whole program (Chapter 19).

On the owner's approval of the written draft, 21 fields were created in one all-or-nothing change (15 on deals, 4 on companies, 2 on people) and a Portfolio list was created; all of it was read back afterwards. Verified This was done by a script through the same connection, on the owner's approval given in conversation, not by the assistant in the chat; the assistant's own approval button was not used.

The server can add an object, a field, a link or a list, but cannot rename or remove a field or change the stages a workspace starts with (a sales team's "Lead", "In Progress", "Won", "Lost"). It also refused the list's own ten fields. A layout made through it cannot be undone through it, which is why the draft was written out twice for the owner to read before anything was created. The stages and the list's fields were set by hand in Attio's settings page and read back through the server. Seven saved views (filtered tables, such as deals with an overdue next step, or deals new this week) were then created through the server. Verified

Case note

The money fields were made in US dollars, to match Attio's existing one, without asking which currency the fund counts in. The owner confirmed dollars afterwards; the guess happened to be right.

21.4Telling the model the layout

A model begins each conversation knowing nothing of the workspace. Without being told the layout, it spent about twenty reads for five writes in live runs finding out which objects, lists and fields exist, and once filled Attio's built-in "Job title" with "Founder" where the firm's own "Role" field was meant, because it had not seen that there was one. It said so in its reply, which is how the slip was found.

So the program reads the layout from Attio and hands it over with the list of tools. It is read, not written by hand, so it stays true when the firm changes its layout. From odysseus/attio_layout.py:

def render(shape: dict[str, Any], limit: int = 12000) -> str:
    """The layout as a page of plain lines for the model."""
    me = shape.get("me") or {}
    lines = [f"The workspace is \"{me.get('workspace_name')}\". The owner is signed in as {me.get('name')}, workspace member "
             f"{me.get('workspace_member_id')}; use that id wherever an owner or member is wanted and the owner means themselves."]
    for slug, obj in (shape.get("objects") or {}).items():
        lines.append(f"\nObject `{slug}` ({obj.get('plural')}). Fields you can set:")
        lines += _fields(obj.get("attrs") or [])
    for slug, lst in (shape.get("lists") or {}).items():
        lines.append(f"\nList `{slug}` (\"{lst.get('name')}\"), a list of {', '.join(map(str, lst.get('parents') or ['?']))}. "
                     "Fields that belong to an entry in this list, not to the record:")
        lines += _fields(lst.get("attrs") or [])
    text = "\n".join(lines)
    return text if len(text) <= limit else text[:limit] + "\n[Cut. List the attributes of an object yourself if a field you need is not shown.]"

Each field becomes one line with its exact name, type and choices in order; fields Attio fills itself are listed as not settable. The layout came to about 1,400 tokens. It is read at start, used for thirty minutes, re-read in the background when older, and dropped after any tool that reshapes the workspace. Attio answers in a compact text format of its own, in two shapes (indented blocks, and tables with a header row), and parse reads both; an earlier check had quietly miscounted because it understood only one.

With the layout, a lookup of founders used the firm's own Role field, and "what stages are there, and how many deals?" went from 52 seconds to 23 (partly from keeping one session open). Verified, one run each.

What the faster version broke

Giving the model the layout made it skip the one lookup that mattered: with the layout, it asked to create the company at once. Without it, the model had searched because it was looking everything up anyway; told not to look things up needlessly, it dropped the necessary search with the needless ones, and a duplicate cannot be deleted through this server. It also filled the company's stage from the deal's round, which nobody asked for. Instructions repaired both (search before creating; set only what the owner gave). A change to the instructions is a change to the program: re-run the same requests and read everything that comes back.

Who knows whom: a feature that was already paid for

A partner asks: "Who here knows this founder best?" Dedicated relationship databases sell the answer as their main feature. The plan was to build it: count each person's emails and meetings with each partner, weight them by how recent they are, and write a score to the person's record. That is ordinary code over mail and calendar data the program already reads, and no model is needed.

Before writing it, the fields of the firm's own database were listed. Attio already fills in, on every person and company, a connection strength (six steps from No connection to Very strong), the colleague with the strongest connection, and the first, last and next interaction. It works them out from the mail and calendars that members sync to it, for the whole firm and not one mailbox, and nobody can overwrite them. A read of twenty-five people in the real workspace showed the fields filled. Verified, one read.

So nothing was computed and nothing is written. The layout the model is given gains one paragraph, and only if the workspace has the fields:

def knows_note(shape: dict[str, Any]) -> str:
    """One paragraph on the relationship fields, only if this workspace has them. Bought, not built: Attio computes them."""
    where = [slug for slug, obj in (shape.get("objects") or {}).items()
             if set(KNOWS) <= {a.get("api_slug") for a in obj.get("attrs") or [] if isinstance(a, dict) and a.get("is_archived") is not True}]
    return KNOWS_NOTE.format(where=" and ".join(where)) if where else ""

odysseus/attio_layout.py

The paragraph names the fields, says that the colleague comes back as a member id to be turned into a name with one more read, and says two things the model would not otherwise do: do not count emails yourself, and if the fields are empty say that the database has nothing on record. The second matters more. An empty field on a founder the firm has plainly backed is a fact about what was synced, not about the relationship.

Two errands in the evaluation cover it, on invented records. Asked who knows a founder best where a colleague does, the assistant named the colleague and the strength in three runs of three, each in about fourteen seconds for 1.4 cents. Asked about a founder whose fields are empty, it said the database had nothing on record in three of three, named nobody as knowing her, and pointed to the deal's owner as the nearest link; those runs took about twenty seconds and 2.3 to 2.8 cents, because the assistant also read the deal and its notes. The first version of both checks failed every run on correct answers: one matched the colleague's name inside the word "same", and a later one could not tell "Sam knows her" from "nothing shows that Sam knows her". Both were found by reading the replies, and the second clause was removed, since a word match cannot make that distinction; whether a reply wrongly names a colleague is read by a person (Chapter 17). With the new paragraph in the layout, the other seventeen errands each passed in one run. Verified, three runs each. Asked once in the real chat ("which three people do we have the strongest connection with, and who knows each best?"), the assistant read the fields from the real workspace, gave one connection at Strong and three tied at Good, said the tie was the database's and the choice among them its own, and noted that the workspace has a single member, so "who knows them best" could only be that member. Thirty seconds and nine cents, as the first message of a new conversation. Verified, one real question.

This is Chapter 3 at its smallest scale: list what a service you already pay for returns before writing code to produce it. The check took one read.

Case note

The plan that files a source checks each new company and person against names already in the database that are close without being the same, and stops if it finds one. Deals were left out of that check. It did not matter until the wording of the assistant's instructions changed for an unrelated reason, after which, sent a deck for a company that already had a deal, it filed a second deal named after the round beside the first, in two runs of two. The check now covers deals, so a new deal whose name is close to the name of a deal on file (one contains the other, or they share a first word) is stopped at the plan, and goes ahead only if the assistant marks it as deliberate and the owner approves it. The check compares deal names and nothing else: it does not look at which company a deal is linked to, so a second deal for the same company under a name with nothing in common with the first is not stopped. Where code can refuse a duplicate, it is not left to an instruction, because an instruction's effect can change when a sentence elsewhere does.

21.5One approval for a whole source

Three investments were entered live, one request each. Verified, three live runs, read back afterwards with the right stages, amounts and links. Each took five approvals. A partner forwards several such emails a day, and a run of questions teaches an owner to stop reading them (Chapter 8). The obvious fix, one approval for "whatever the model does next in Attio", approves an intention while the calls themselves go unseen. The design used instead approves one finished, checked object.

Definition: plan, then file

Plan. The model states everything it would file from one source as one plan: records, their links, list entries and notes. The program checks the plan, looks every record up, and returns the page the owner will see. Nothing is changed. File. The owner approves that page once, by an identifier the program issued. The program carries the plan out step by step.

Model Program Owner Attio attio_plan (records, links, notes) check against layout; refuse near-duplicate names look each record up (reads only) plan id + the page, word for word attio_file (plan id) the same page approve once look again; create, link, change on failure: stop, say how far it got
Figure 21.1. Plan, then file. The page the owner approves is laid out by the program from a plan it has checked and holds, not composed by the model, and the approval is for that plan's identifier, once.

Every rule that makes one approval safe is in code, not in the model. The plan is checked against the layout: an unknown field, a choice that is not a choice, or a link to a record outside the plan is refused with its reason. Every record is looked up by the program (a company by website, then name; a person by email address or profile link, then name), and one that exists is linked to and left as it is. A near-duplicate name is refused unless the model names the existing record exactly or marks the record as new. The program keeps the plan, which cannot be altered, and its identifier is good for twenty minutes and used once. A value already there is changed only as a shown before-and-after. The program looks again at the moment of acting. And a failure stops filing and is reported exactly.

21.6The mechanism

Links the owner can read

From odysseus/attio_intake.py, inside the check of each value:

for r in _links(value):           # only a whole value "@ref" is a link; an email address is not
    if r[1:] not in refs:
        raise AppError(f"{where}: {slug} points at {r}, and no record in this plan has that ref.")
kind = str(a.get("type"))
if kind == "record-reference" and len(_links(value)) != len(value if isinstance(value, list) else [value]):
    # An id cannot be shown to the owner as anything they could check. Every link is to a record named in the plan.
    raise AppError(f"{where}: {slug} must point at a record in this plan, as \"@ref\". If the record is already in Attio, "
                   "add it to `records` with its name (and website or email address): it will be found, linked to and left unchanged.")

A link inside a plan is always @ref, the short name of another record in the same plan. Without this rule, a live run's page said "Introduced by:" followed by a raw record identifier, because the model had looked the introducer up and passed the id. That is correct for the machine and useless to the person approving. With the rule, an existing record goes into the plan by name and the page says "the person Asha Verma". The comment about email addresses records a fault the unit tests caught: a looser match took "jo@orbitlabs" for a link to "orbitlabs".

Names that are close

async def _similar(self, obj: str, name: str) -> list[str]:
    want = _norm(name)
    words = [w for w in re.split(r"[^a-z0-9]+", want) if len(w) >= 4]
    if not want or not words:
        return []
    found = parse(await self._attio._call(self._attio._b.call("search-records", {"object": obj, "query": words[0], "limit": 8})))
    near = []
    for hit in found.get("results") or found.get("records") or []:
        got = _show((hit.get("attributes") or {}).get("name")) if isinstance(hit, dict) else ""
        have = _norm(got)
        if have and have != want and (want in have or have in want or have.split(" ")[0] == want.split(" ")[0]):
            near.append(got)
    return near

A name is close if one contains the other or they share a first word. When the exact lookup finds nothing and this finds something, planning stops, naming both, until the model gives the existing record's exact name or puts "new": true on the record. The rule is crude and errs towards asking: a needless question costs a sentence, while a missed double cannot be deleted from here.

Look again at the moment of acting

From the loop that carries a plan out:

rid = step["found"]
if not rid:                     # look again at the moment of acting: someone may have added it since the plan was made
    rid, _ = await self._existing(step["object"], step["match"])
    if rid:
        done.append(f"{step['label']}: appeared in Attio since the plan was made; linked, not created")
elif step.get("updates"):
    # Look again at the moment of acting. The owner approved "Met → Diligence"; if it no longer says Met,
    # somebody has changed it since, and what was approved is no longer what would happen.
    now, attrs, apply, moved = await self._now(step["object"], rid), self._attrs("objects", step["object"]), {}, []
    for slug, wanted in step["updates"].items():
        if _norm(self._was(now.get(slug))) == _norm(step["before"][slug]):
            apply[slug] = wanted
        else:
            moved.append(f"{attrs[slug].get('title')} was {step['before'][slug]} when you approved and is now "
                         f"{self._was(now.get(slug))}, so it was left alone")

Minutes pass between plan and approval, and colleagues use the same database: the lesson of Chapter 18, applied to writes. A record that appeared meanwhile is linked to, not created again. A field changed meanwhile is left alone and reported; the other approved changes go ahead.

Say exactly how far it got

raise AppError(f"Filing stopped at a step that failed: {e}\nDone before that, and still in Attio: {'; '.join(done) or 'nothing'}.\n"
               f"Not done: that step and the {max(left - 1, 0)} after it. Tell the owner exactly this. Do not file the plan again as it was; "
               "make a new plan for what is missing.") from None

Nothing can be undone through Attio's server, so the owner must know about a half-filed plan. The approved plan is deleted from the program's store before the first step runs, so it cannot be run again; a new plan looks everything up afresh and finds what the failed run did create.

21.7A worked example: the forwarded email

This is the errand file_new in evals/partner.py, against a stand-in database seeded with Northwind Robotics (a portfolio company), its founder Asha Verma, and two other companies.

  1. The model plans, of the kind seen in these runs: company c1 Orbit Labs with its domain; person p1 Sam Okafor linked to @c1, Role Founder; person p2 Asha Verma; company c2 "Northwind"; deal d1 linked to @c1, introduced by @p2, with a next step and date; and a note on @d1 quoting "I thought he was sharp", with who said it and when.
  2. The program checks every field and choice against the layout, then looks each record up. Asha Verma is found by name. "Northwind" is not found exactly, but "Northwind Robotics" is close, so planning stops: "Attio has nothing called exactly 'Northwind', but it has 'Northwind Robotics'..."
  3. The model corrects or asks. It replans with the exact name, or (in three evaluation runs) asks the owner, whose stand-in answers "Yes, that is Northwind Robotics. Go ahead."
  4. The page has lines such as "Company Orbit Labs: NEW. Name: Orbit Labs; Domains: orbitlabs.example" and "Person Asha Verma: ALREADY IN ATTIO (found by name Asha Verma). It will be linked to and left exactly as it is.", a deal line naming "the person Asha Verma" as introducer and "you (Pat Owner)" as owner, and the note in full.
  5. Filing. Each new record is looked for once more, then created; ids are filled into the links; the note goes on the deal. The reply says what was created, what was there already, and what was left out (the deck is promised, not received).

The check counts exactly one of each company, person and deal and a new note mentioning "sharp". The deal value stays empty: nobody mentioned a cheque.

A plan that changes something

From the unit tests: a deal Orbit Labs is on file at Sourced, pass reason "Too early", value 250,000. A plan from a second call sets Term sheet, a next step, value 250,000 and pass reason "Team". The page reads: "Deal Orbit Labs: ALREADY IN ATTIO (found by name Orbit Labs). CHANGES: Deal stage: Sourced → Term sheet; Next step: (empty) → Send the term sheet; Pass reasons: add Team (now: Too early). Everything else on it stays as it is." The value is not listed, because it would not change. The pass reason is added beside the existing one, never in its place. If a colleague moves the stage to Passed before approval, the stage is left at Passed and the reply says so; the next step is still set.

Live, against the real workspace with the real model: a note of a call on a deal at Term sheet produced a plan that set the next step and its due date and left the stage alone, the model explaining that the documents were not yet signed. Verified, one run, declined, 25 seconds, 5 cents.

21.8Capture without a forward

Everything so far begins with the owner forwarding something and saying "file this". Most of what a partner does is never forwarded: a call that was only ever in the calendar, a founder who wrote in and got a two-line answer. A database fed only by forwards holds what the owner remembered to send. The funds that describe their own systems in public have an agent reconcile the calendar with the database every morning for this reason.

The obvious design is a morning routine in which a model reads yesterday's mail and calendar and files what it finds. Two rules of this book forbid it. An unattended run may only read (Chapter 6), and a model reading a day of strangers' mail with a database to write to is the arrangement Chapter 9 exists to avoid. So the work is split at the point where judgement is needed.

  • The morning's pass is code, and only reads. It lists meetings that have ended with a guest from outside the owner's own domain, and messages in the inbox from a person: not a machine's address, not a newsletter, not anything the mail service has itself sorted into notifications or promotions. It looks each address up in the database and drops anyone already there. No model runs, so it costs nothing.
  • The owner is asked once. One message lists who is not in the database and how each came up, with two buttons. A person is proposed once: approved, declined or ignored, they are not proposed again.
  • The filing is an ordinary task. On Approve, the list is handed to the conversation as material that other people wrote, and filed through the same plan, checks and report as a forwarded email. It asks for the person, their company and a note of how they came up, and for no deal: whether someone met yesterday is a deal is the owner's call.
        if _MACHINE.match(email.split("@", 1)[0]) or "list-unsubscribe" in {str(k).lower() for k in (m.get("headers") or {})}:
            continue
        if NOT_PERSONAL & {str(x).upper() for x in (m.get("labelIds") or [])}:
            continue

odysseus/capture.py, wrote

The names, meeting titles and subject lines in the list are strangers' words. A meeting can be titled with an instruction. That is why the list is not the owner's message when it reaches the model, and why every rule for a task that has read outside material applies to the filing: the count of unasked changes and the second reading in Chapter 8 among them.

A read-only run against the real calendar, inbox and database, over three days: ten calendar events, none with an outside guest; forty-five inbox messages, of which one was a person writing from outside; that person was not in the database and would have been proposed. Nineteen seconds, no model call. Verified, one run. The first version asked the mail service for its main tab by name and got nothing back, on a mailbox with forty-five messages in it; the marks the service puts on each message are read now instead. Not tested: the question has not yet been sent at its hour, nobody has tapped Approve on a real one, and no meeting with an outside guest has passed through it.

21.9A memory of the firm's own decisions

A deck comes in, the assistant gives a take, the partner decides. Until this was built only the take was kept. The decision, and the reason for a pass, stayed in the partner's head. Of everything in this chapter it is the one record that cannot be bought or rebuilt later: which companies the firm saw, what it thought, what it decided, and what happened next. A fund that describes its own system in public names that history as its advantage.

It has four small parts, and the model writes none of the record.

  • The verdict. After each take on a deck that was filed, the owner gets one question with one button for each answer: take the call, pass for one of the firm's own reasons, or decide later. The reasons are read from the database's layout if it keeps a list of them. One tap. Nothing is recorded without it.
  • The record. The tap is written to a file, and as a note on the deal, by code: what the owner decided, the reason, and what the assistant's view had been. If the database has a field for pass reasons, the reason is added there. The deal's stage is left alone.
  • The watch. Once a week a read-only run on the small model looks up the companies passed on in the last year and reports only what is new and material: a round raised, a notable customer, a shutdown. Usually it says nothing, and with nobody passed on it does not run at all.
  • The table. On request (/decisions) and at the start of each quarter: how many decks, how many calls and passes and why, how often the two views agreed, and each case where they differed, with whatever the watch found afterwards.

The assistant's own view has to be read by code, so that the table compares two recorded facts and not an impression. The instructions for a take now ask for a last line that begins "My view: take a first call" or "My view: pass for now", and code reads only a line that begins so:

VIEW = re.compile(r"(?im)^\s*my view:\s*(take a first call|pass for now)")

odysseus/decisions.py

A deck that itself contained the words would not count unless they began a line of the assistant's reply, and the tap is the owner's in any case. In six runs of the three deck errands against the real model, every take ended with a line code could read. Verified, six runs. The rest is proven by unit tests with invented decisions (tests/test_decisions.py, six tests). Not tested: no real verdict has been tapped, the watch has not run at its hour, and a table needs months of decisions before it says anything.

What the table will and will not show should be said in advance. It records where the partner and the assistant disagreed and what happened to companies that were passed on. It cannot show what happened to companies nobody sent, and a pass that later raised money is not thereby a mistake.

21.10People to keep in touch with

A firm keeps a short list of people worth speaking to every month or two: the founders it rates most, and the people who tend to know who is good. Each has an owner inside the firm. The list is easy to write and the speaking is easy to forget, and a partner asked what they most want from an assistant will describe exactly this: remind the person whose job it is until they confirm they did it, and put what they learned back in the system.

None of that needs a model. The only judgement in it is the owner's, at the start, about who belongs on the list. So the model's part is to set an entry up from a plain request, and everything after that is code.

  • The list. An entry is a person, how often to speak to them, what to ask, and whose job it is: the owner's, or a named colleague's with an address.
  • The owner's own. When one is due, on a working day, the owner gets one message with three buttons: done, in a week, skip this round. If nothing is tapped it is asked again after three days. At most three such messages go out in a day; the rest come the next day. The button carries the entry and the round it belongs to, so a tap on an old message does nothing and a restart in between loses nothing.
  • What came of it. After "done" the owner is asked what came of it. Whether their next message is the answer or something unrelated is the one thing here code cannot tell, so the next message, and only that one, reaches the model with a note that the question is open. The model records the answer with a tool or ignores the note.
  • A colleague's. When one is due, code sends the colleague a fixed email from the owner's mailbox, and again every three days, until they reply. The reply is the confirmation. Its words are kept with the entry, added as a note on the person's record if their address is known, and passed to the owner. After five reminders with no reply the owner is told and the round ends.

One approval for a standing rule

An entry that is the owner's own job only ever sends the owner a message, as a reminder does, so the gate lets it run. An entry that is a colleague's job is a standing rule that sends email in the owner's name for as long as it exists. It is approved once, when it is set up, and the question shows the whole email:

gate.rule(CHECKIN_ADD, lambda a: ASK if str(a.get("assignee_email") or "").strip() else ALLOW, checkin_question)

odysseus/tools.py

What makes one approval enough is that nothing in the email can change afterwards. Its words are a template in the code plus the entry's own name and question, which the owner saw. No model writes it and nothing read later is put into it. A unit test asserts that the email sent is, character for character, the one in the question.

The colleague's reply is other people's writing. The search for it is the mail service's, so who wrote a message and when is checked again in code, the quoted reminder beneath it is cut off, and what remains is quoted to the owner and stored. No model reads it in this path, so an instruction inside it has nothing to act on. It does become a note in the database without a question. That follows the rule this chapter already uses for additions: a note can be removed, it overwrites nothing, and the owner is told in the same message.

Verified, one run against the real model with an invented list, an invented colleague, a stand-in mailbox and a clock moved by the script: two entries set up from two plain sentences, the owner asked once (for the colleague's emails), the due message and its tap, the answer recorded, two reminders sent, and a reply that ended them; about three cents. Ten unit tests (tests/test_checkins.py), among them a message from a look-alike address that is not taken for the colleague's reply. Not tested: no real email has been sent by this path, no real colleague has replied, and nothing has yet come due at its hour.

Two limits apply. The list lives in the assistant's own file and not in the database, so a colleague cannot see or edit it there. And a colleague is reached only by email: confirming from a chat of their own needs an assistant of their own.

21.11Who to ask them about

An investor ends a good conversation with "who is the most impressive person you know?". The question works better with names in it: "do you know her, and would you introduce us?". A partner will ask for exactly this from an assistant, usually in the form "look at who the founder follows and engages with, and guess". The request is right about the goal and wrong about the evidence.

Who follows whom is the weakest public sign that two people know each other. It is also the most expensive to read: the one large network that sells the data prices it by the name returned, so one person's list costs more than the whole of the rest of this feature, and the other large network sells nothing and restricts accounts that read it from a signed-in page. Having founded a company together, having put money into someone's round, or having shipped a project with them is stronger evidence, and it is on ordinary public pages a search can find. So the first version reads no follower lists at all.

  • The research. One unattended run on an agent that can search the public web and do nothing else. It is given the contact's name and where they work. It is not given, and cannot reach, the owner's mail, calendar or database, so nothing private can leave in a query.
  • The form. It must answer in lines of four fields: the name, what they are doing now, how the contact is connected to them, and the address of the page that shows the connection. Code reads the lines. A line without an address is dropped.
  • The filter. Code removes the contact themselves, anyone suggested for this contact before, and anyone already in the firm's database. The model never sees the database.
  • The question. Up to three names are added to the message the owner gets when a check-in with that person is due, under the words "each may or may not know them". They can also be asked for at any time. The answer to "do you know her?" is the owner's to get.
NAME | what they are doing now | how the contact is connected to them | the address of the page that shows the connection

odysseus/leads.py

The same names are added to the brief before a meeting with someone from outside the firm, for the first guest the calendar names. The search runs after the brief is written and sees none of it. Because the same person is often met twice in a month, what was found for a contact is kept in a file and given back unpaid for thirty days; a search after that is told the earlier names so that it finds others.

The suggestions are an extra. If the day's budget is spent, the run fails, or it finds nobody, the check-in message goes out without them, and a repeat of the same question does not pay for the search again.

The instructions forbid inferring anything about a person that the page does not say, and name private life, health, beliefs, origin and gender. That is a rule for the whole system and not only this run: a database that guesses such things about people from their names or photographs is wrong often enough to do harm, and a firm that wants to find, say, founders who are women should record it when a founder says so.

Verified, one trial on one well-known founder, run on each of the two models. The small model named two long-standing colleagues; the main model named three early founders whose rounds the person had joined, which is the answer an investor wants. Both took about half a minute and nine searches. The model's part cost under one cent on the small model and about seven on the main one; the searches are billed separately by their vendor. One of the main model's three pages was opened by hand and did show the connection claimed. The main model is used. Six unit tests (tests/test_leads.py) and one for the brief. Not tested: no real brief has carried the names yet; one person on each model is an anecdote and not a measurement; the other two pages were not opened; a person with little public record; a common name; and whether the people named are ones a contact really knows, which only asking can show.

21.12A source is evidence of what someone wrote on a day

Case note

The first source the owner pointed at was the firm's weekly review thread, found by paging through 761 synced emails and matching the subject in code. It named three investments with their terms, a company under evaluation, and a dozen founders with a colleague's verdict on each. It was months old, so a "to be determined" may since have been determined. And one sentence attached the wrong website to a founder, a slip that a program copying from email would have turned into a wrong record. The extraction was shown to the owner and nothing was created until the owner chose what to file.

The rule that follows is written into the filing instructions: "A source is evidence of what someone wrote on a day, not of what is true now: if it is old, or says something is still to be decided, say so to the owner before filing and do not record the undecided thing as settled. Leave out anything you would have to guess." Opinions go into a note in the source's own words, with who said it and when, not into fields. When a passage said only that the firm was "evaluating closely" and named no stage, the model filed a company, its founder and a note, and no deal. Verified, once, through the owner's real chat: plan, approval tap, three steps filed, read back. The tap was made on the owner's instruction, not by the owner's hand.

21.13A house rule kept in memory

The model decides what a source supports, and it varied: the amount a founder asked the firm for went into the note in one run and into Allocation offered in the next. Asked which, the owner chose the field. That choice belongs neither in the program, where it would bind every firm, nor in the standing instructions, which every owner shares. It was saved as one line in the assistant's memory (Chapter 5), which the model reads in every conversation. The evaluation seeds it as:

HOUSE_RULE = ("In Attio, when a founder asks us for a specific amount, record it in the deal's Allocation offered field, as well as in the note. "
              "It is not our cheque: Deal value stays empty until we decide.")

The errand house_rule forwards "Raising a $3M seed and asking us for $400K" and passes only if Allocation offered is 400,000 and Deal value is empty. Live, after the rule was saved, the amount went to the field in both runs and the firm's own cheque stayed empty. Verified, two runs.

21.14Plans that only add, and plans that change

A plan that could only add would leave the database describing the day each record was made, though after a first meeting nearly everything a partner learns is about a record already on file. Hence changes. The owner also asked for as little asking as possible (Chapter 8 sets out the policy), so the program separates plans by what they can lose:

def decide(self, a: dict[str, Any]) -> str:
    plan = self._plans.get(str(a.get("plan", "")).strip())
    if not getattr(self._attio, "auto", False) or plan is None or plan.get("doubt") or plan.get("unnamed"):
        return ASK
    return ASK if any(s.get("updates") for s in plan["steps"]) else ALLOW

A plan that only adds runs unasked, which is the default (setting ODYSSEUS_ASK_EVERY_CHANGE restores a question before every change), and is reported line by line, "without asking"; an approved plan is reported as a count, since the owner just read every line. A plan that overwrites a value is always asked about, because what was there disappears from view once changed; so is one that adds a record beside a similarly named one, one that makes records of two or more companies the owner did not name (unnamed, the subject of the next section), and one the program does not hold. The cost is that a planted instruction the model obeyed can add a record or note that the owner learns of only from the reply. It still could not overwrite, send, share or delete. An unattended routine gets neither kind of plan: it may only read the database (Chapter 23).

21.15A mention is not a record

A source names more companies than it is about. A review of the pipeline names the companies under discussion, and also their competitors, their customers, the investors behind them, a comparable that was sold last year, and one somebody heard is raising and nobody will call. An instruction to file "everything the source supports" asks for recall, and recall in a shared database is paid for by everybody who later scrolls past records nobody meant to keep. A record there cannot be deleted by the program, and is seen by the whole firm, so by Definition 2 creating one is not strictly an add: it reaches other people, and the owner cannot remove it from here. The program still lets a plan that creates records run unasked, as a judgment about the cost of asking (Chapter 8); this section is about where that judgment stops.

Three things now stand between a name and a record, two of them code.

  • The instruction asks for precision. A plan holds the companies the source is about. The test given to the model is whether it can quote the sentence that gives a company a part in the firm's work: being considered, looked at and passed on, run by a founder the firm met, held by the firm. A pass counts, by the owner's decision: a firm keeps the companies it decided against, with the reason, so that whoever next hears of one finds the decision. A company nobody at the firm has looked at is not a pass. Everything else is a mention, kept in a note's text on the record it was said about, and named to the owner as left out.
  • Code requires that sentence. A company not yet in the database must come with the words that give it its part, and the words must name it; a plan without them is refused with the reason. The owner's page shows the sentence under the record, so the judgment is made on evidence and not on a bare name.
  • Code decides when to ask. A filing that would make records of two or more companies whose names the owner did not type is always put to the owner, whatever else is switched on. One such company is the ordinary case of a deck or a forwarded message, whose subject is named in the material and not in the owner's "file this", and is filed and reported as before.

The rule about two or more is a proxy, and it is worth saying for what. What should be asked about is a record the owner did not intend. Intent cannot be read, so the program reads two things it can: whether the owner typed the name, and how many untyped names one filing would create. A single stray company from a meeting's notes still gets through unasked, with its sentence in the report.

Verified, on six invented errands run three times each against the real model (evals/fund.py, group "a mention is not a record"): two review meetings and a pasted note that between them name two companies to file, one of them a pass, and ten not to. In eighteen runs of eighteen the two were recorded, the pass was recorded as a pass, no record was made of a mention, and the companies left out were named in the reply.

Not shown: that the rule changed anything. Nineteen runs of the earlier form of these errands on the code as it was before also made no record of a mention. The instruction's old wording did not produce the fault on these errands, so they measure that the guard does no harm and nothing more. The rule rests on the argument above and on the owner's report of stray companies in the real database, whose origin had not been established when this was written: the program's own journal showed three companies created in all, one from a pasted email and approved.

21.16The theory

A plan as one call. Write a plan as π = (R, N, E): records with their links, notes, and list entries. attio_plan only looks things up, so its effect is a read (Definition 2): σ′ = σ, and its result is the page q(π) the owner would see. attio_file takes one input, x = {plan: i}. The program holds a store S mapping each identifier i to a stored plan, and the gate (Definition 6) asks about x with the question q(S[i]). Property 5 of Chapter 8 binds the owner's yes to the exact call x; the store binds x to one plan.

Property: an approved plan does no more than its page says

Suppose (i) S[i] cannot be altered after it is stored, (ii) the question is computed from S[i] alone, (iii) filing deletes S[i] before its first step, and (iv) a record found at planning is written only in fields listed with a before-and-after on the page. Then for every model, one yes causes at most one execution of S[i]; no record that existed when filing ran is changed except in a shown field; and a shown field is written only if it still holds the shown "before" value when it is read again just before writing.

Argument. The model's only handle on the plan is i, so by Property 5 the approval runs one call, and by (iii) a second call with the same i finds nothing. Inside the call, each step either creates a record not found (and looks for it once more first, linking if it now exists), links to a found record without writing to it, or writes the subset of shown fields whose present value equals the shown one. Nothing else in the filing loop writes. The argument never inspects the model, so it holds for a model that has read a planted instruction.

The hypotheses fail in two places, and failed in a third before notes were shown whole. The page used to show a note's text only up to 1,200 characters while up to 8,000 were filed, so for a long note the owner approved a set of plans and not one. A note is now shown whole and filed exactly as shown, and one longer than 4,000 characters is refused with a request to shorten or split it. Of the two that remain, first, the second look and the write are two calls to the service, so a colleague's change between them is not seen; the window is narrowed from minutes to one round trip, not closed. Second, under "ask less" a plan that only adds is in A(T), unless it adds a record beside a similarly named one or new records of two or more companies the owner did not name: no question is asked, and the property shrinks to the statement that the report lists every line. For a new company the page, asked or not, carries the sentence given for it, which code has checked names the company; code checks that it names it, not that it is true.

Doubles as record linkage. Each record r in a plan is compared with the database D and put in one of three classes:

link if some d ∈ D equals r on an identifying field; ask if not, and some d ∈ B(r) has near(r, d); create otherwise

Here the identifying fields are tried in order (website, email address or profile link, then name), B(r) is what the service's search returns for the first word of four or more letters in the name, and near(a, b) holds when the names differ and one contains the other or they share a first word. The two errors of linkage have different prices here. A false non-match (a variant name created as new) is a double that cannot be deleted through this server. A false match (a different entity linked as the same) is quieter: a second founder with the name of one on file is linked to the first, and only the page's "found by name" line shows it. The rule trades false non-matches for questions, since a question costs a sentence. Recall is bounded by the search: a variant that B(r) does not return is never compared.

What was measured is separate: with exact names only, 5 of 5 approved runs of one errand made a second company while every check passed; before deals were covered, a second deal appeared in 2 runs of 2.

Claim in this chapterKindHow it is known
One approval runs one stored plan oncePropertyArgued from the store and the second lock; unit tests with a stand-in server
A record already on file changes only in shown fields that still hold the shown valuePropertyArgued from the filing loop; tested by moving a stage before approval
The owner sees everything an approved plan filesProperty, since notes are shown whole up to 4,000 charactersArgued; a test with a note of about 3,000 characters, and one just over 4,000 refused
Near-duplicate names are refused until named exactly or marked new, and then asked aboutProperty of the rule, within what the search returnsUnit tests; its recall on real variants is unmeasured
A new company comes with a sentence that names it, and two or more the owner did not name are always asked aboutPropertyArgued from _part and decide; unit tests (tests/test_mentions.py)
The real model files without doublesMeasurement39 of 42 runs, two or three per errand
Running adding plans unasked cut questionsMeasurement6 asked in 28 runs, against 16

21.17What goes wrong

Case note: two defects behind one green row

The partner evaluation's first round passed 28 of 28 while every approved run of file_new had created a second "Northwind": the product's lookup and the check both compared exact names, so they shared one blind spot and agreed. Chapter 17 works through it. Both were repaired: _similar here, and a check that counts a name plus a word as a double.

  • A faster model skipped the lookup that mattered, along with the needless ones.
  • A similar built-in field was used: "Job title" for "Role".
  • An approval page showed ids, until code made unreadable approvals impossible.
  • A parser silently read nothing. A single record came back as a list with no name, a shape the reader had not met, so every "before" would have said "(empty)". It was caught because the parsed result was printed.
  • The model varies: one run made a deal, another did not.

21.18How to test it

A test of filing must show that a plan changes nothing; that an approved plan runs once and expires; that an existing record is never changed except by a shown change; that a record appearing between plan and approval is not created twice; that a change is skipped when the record no longer says what was shown; that every misfit with the layout is refused with a reason; and that a failure stops and reports exactly. The 37 unit tests in tests/test_attio.py, tests/test_attio_intake.py and tests/test_attio_layout.py cover these with a stand-in server, and pass.

evals/partner.py runs seventeen partner errands (fourteen in the rounds reported here; the three deck errands of Chapter 22 were added afterwards) against the real model with a stand-in database (evals/crm.py) that answers in Attio's text format, so the layout reading, plan checking and gate are the real ones. Every run is held to five properties: nothing overwritten without approval, nothing twice, no deal's stage or value changed unless allowed, no claim of filing when nothing was filed, and a normal end. Three rounds, 112 runs, about $2.60: 28 of 28 (wrongly, as above), 38 of 42, then 39 of 42 with no doubles, the three failures being the model rightly asking about Northwind with nobody to answer. With plans that only add running unasked, 28 runs for $0.60 all passed, and the owner was asked in 6 runs instead of 16. Verified. No planted instruction was acted on in 16 chances in the first three rounds. Two or three runs an errand is too few for a rate, and nothing is reworded and no tool fails. Decks are tested in Chapter 22.

What is proven and what is not

Verified: the layout created and read back; three investments entered live and read back; plans drawn up live against the real workspace and declined (two for a new company, one for a change); one plan filed from the real chat; the house rule followed twice; the partner evaluation as reported above.

Not tested: a plan with changes approved and carried out against the real server (unit tests with a stand-in only); a colleague changing a record between plan and approval, live; whether the saved views select what their names say, since there were no deals to select; and how often a model obeys a planted instruction to add something, which two runs cannot say. Outside a plan, "search before creating" a single record is still only an instruction.

21.19Where this sits in the literature

The problem of the second "Northwind" is old. [Fellegi and Sunter 1969] gave the theory for deciding whether two records describe the same entity: each pair of records is scored by how much its agreements on each field are more likely among true matches than among non-matches, and the pair is linked, left apart, or sent to a person for review according to where the score falls. Two thresholds fix the three regions, and they are chosen to hold the two kinds of error, false matches and false non-matches, at stated levels. The rule in this chapter has the same three regions (link, ask, create) and the same reviewer, the owner. It has none of the rest. It gives every field the same weight, it has no estimate of either error rate, and its thresholds were set by argument about costs and not by any measured distribution. Here the published work is plainly stronger than the program: it could say how many doubles to expect, and this program cannot.

The comparison itself is crude by the standards [Elmagarmid et al. 2007] survey. Field matching in that literature measures how alike two strings are, by characters, by tokens or by sound, and combines field scores with learned or hand-set weights. Containment and a shared first word are two of the simplest token tests, and the problems in this chapter's Analysis set show what they miss: a name written as one word, a different first word, a person known by two spellings. The program defends its crude test by the asymmetry of its errors.

Before any comparison, the program asks the service's own search for one word of the name and compares only what comes back. That is blocking in the sense of [Papadakis et al. 2020]: a cheap step that cuts the pairs compared, at the price that a true match outside the block is never seen. Their survey treats blocking as a deliberate design with measurable recall. Here the blocking step belongs to the vendor, its behaviour is not documented in this book, and its recall is unknown. A firm's database of a few hundred companies could be compared in full; the choice to block was made by the service's interface, not by the size of the data.

The approval of a plan's identifier is a capability in the sense of [Hardy 1988]: the authority travels with a token that names one stored object, and the model, the confusable party, holds only the name. Filing is a long transaction of many steps across a service with no transaction of its own. [Garcia-Molina and Salem 1987] proposed that such a transaction be split into steps each with a compensating step, so that a failure partway can be undone. This program cannot do that, since nothing can be deleted through the server, and does the weaker thing: it stops, says exactly how far it got, and refuses to run the plan again. The "look again" before each change is the check-then-write pattern whose limits [Kleppmann 2017] sets out for concurrent writers: without a conditional write in the service, a change between the read and the write is lost.

The reason for one approval per source is the evidence that frequent, generic warnings are clicked through [Sunshine et al. 2009]. Five questions an email is the regime that evidence warns against. Whether one longer question, read once, is read better than five short ones is not settled by any work cited here, and is the empirical question behind the design.

The works cited here assume files large enough to estimate how often fields agree among matches and non-matches. A firm's database is small, grows by a few records a day through one reviewer, and has no labelled pairs. How to set the threshold for asking in that setting, and how to tell whether it is set well, is not settled by them.

Summary
  • Naming a first customer changed what "working" means, not how the program is built: one copy per partner is what it already was.
  • An empty database needs a shape first. Check how practitioners do it before designing; a first-principles design looks complete to its author.
  • Read the layout from the service and give it to the model; then re-run everything, because a faster model may skip the one lookup that mattered.
  • One-at-a-time approvals become a run nobody reads. Approve one checked plan, by an identifier, once, with the safety in code: look up first, refuse near-duplicates, show changes as before and after, look again when acting, report exactly how far a failure got.
  • A source is evidence of what someone wrote on a day. An owner's preference belongs in memory, not in code.
  • Plans that only add can run unasked and be reported line by line; plans that overwrite must be approved.
Problems

Review

  1. Why is the approval for a plan's identifier and not for "filing this email"? What could go wrong with the second?
  2. A plan names a company "Kestrel" and the database holds "Kestrel Bio". Trace what attio_plan does, and the two ways the model can continue.
  3. A colleague changes a deal's stage from Met to Passed between plan and approval, and the plan also sets the next step. What does filing do, and what does the reply say?
  4. _similar already treats "Northwind Robotics Inc." and "Northwind Robotics" as close, since one contains the other. It does not treat "Orbit-Labs" and "Orbit Labs" as close: neither contains the other, and splitting on spaces gives them different first words. Extend it so that they are, and write a unit test in the style of tests/test_attio_intake.py. What new false alarms might your rule raise?
  5. Add an errand to evals/partner.py in which a forwarded email is a year old and says the round size is "to be decided". Write a check that fails if the round size field is filled.

Analysis

  1. Prove the property "an approved plan does no more than its page says" from its four hypotheses. Then drop hypothesis (ii) as the code once did for notes, when the page showed only a note's first 1,200 characters: construct two plans, each with one note of 3,000 characters, that produce the same page and file different text. Say which sentence of your proof fails, and compare the change the code made to restore it (notes shown whole, and refused above 4,000 characters) with the alternative of filing only what is shown.
  2. Over a quarter a firm files 120 sources that each name one company. Of these, 30 name a company already on file under a variant of its name and 90 name a new company. Rule A asks about 24 of the 30 and about 9 of the 90; rule B asks about 28 of the 30 and 30 of the 90. A missed variant becomes a double that costs 15 minutes to merge by hand; a question costs the owner half a minute. (a) For each rule give the rate of false non-matches, the fraction of its questions that were needed, and the expected minutes per quarter. (b) At what cost per question, in minutes, do the two rules cost the same? (c) Name the kind of linkage error this calculation leaves out, and say for which object in this program it is most likely, given the fields each object is looked up by (MATCH_BY).
  3. Give a pair of company names that _similar fails to call close although they are the same company, and a pair it calls close although they are different. For the first, say whether the miss happens in the search (the block) or in the comparison. State an assumption about the service's search under which every variant made by adding words after the end of a name on file is caught, when that name has a word of four or more letters, and show that each part of the assumption is needed.
  4. The second look before a change narrows the window in which a colleague's edit is lost; it does not close it. State precisely the interval of time in which a concurrent edit is still overwritten, and say what the service would have to offer for the property's last clause to hold without that interval.

Design

  1. Suppose the service could merge two records, and the firm asks the assistant to merge doubles it finds. Design the plan step for a merge: what the page shows, which effect class of Definition 2 it falls in, whether a plan holding one may ever run unasked, and what an unattended run may do about a double it notices. Say what is guaranteed and what is given up.
  2. A weekly thread names a dozen founders, each with a company and a colleague's verdict, and the plan for all of it is too large for one plan. Design how it is split: one approval for each plan or one for the set, what the owner sees, and what the reply says if the third plan of five fails. State which part of the chapter's property survives across several plans and which does not.

Reading

  1. [Fellegi and Sunter 1969]. In about four hundred words: what the theory claims about the best rule for linking records; why it matters for the choice between "ask" and "create" in this chapter; where you were not convinced it applies to a database of a few hundred records kept by one person; and what you would measure or build next to give this program an estimate of its own error rates.
  2. [Elmagarmid et al. 2007]. In about four hundred words: what the survey claims about field matching and duplicate detection; why it matters for _similar; where you were not convinced that a better string measure would help when the comparison only sees what the service's search returns; and which one technique from the survey you would add first, with the test that would show it helped.

Open

  1. Hard, open: plans that only add run unasked by default. Design a measurement of how often a planted instruction in a forwarded email leads to an unwanted addition, with enough runs to state a rate and a ceiling, and say what you would change if the rate were one in fifty.
  2. Find a way to estimate the false match and false non-match rates of a small database kept by one reviewer, with no labelled pairs to start from and no more than a few extra questions to the owner a week. Progress would be an estimator whose interval, after a stated number of weeks, covers the rates found by labelling a held-out sample by hand.