Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/store.api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ PeopleStore · interface · similar(name: string, options?: {
PeopleStore · interface · limit?: number;
PeopleStore · interface · }): Promise<SimilarPerson[]>;
PeopleStore · interface · ties(people: readonly string[]): Promise<Record<string, ShownBecause[]>>;
PeopleStore · interface · listBots(options: BotListOptions): Promise<BotList>;
PeopleStore · interface · showBot(bot: string): Promise<SenderBotDetails>;
PeopleStore · interface · moveToBot(subject: string | IdentityRef, by: Decider, options?: {
PeopleStore · interface · bot?: string;
PeopleStore · interface · name?: string;
Expand Down
19 changes: 19 additions & 0 deletions changes/feat-bot-entity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Added

- **`store.people.listBots` and `showBot`** read the sender bots: by name, by part of a name, address or username, or by
the organization they send for (`organization:<id>`). `showBot` adds every move to or from the bot. memo and Desktop
build their bots list on them.

### Changed — experimental

- **Bots are their own entity, apart from people (store version 75).** A sender bot (`sender-bot:<id>`) now holds its
identities itself, in `sender_bot_identities`: an identity belongs to one person or one bot, never both. Its messages
and mail keep pointing at the identity. A bot never appears in `people.list`, its counts, `people.similar` or
`people.ties`; `people list kind:automated` keeps the people a name or a bulk mailbox marks. The upgrade moves every
version 74 bot's identities off its person row. That row stays, hidden, so a move back gives its uid back, and its
`person:` ref still names the bot in a move. `minCompatible` stays 73: triggers keep a 1.0 build from giving a bot's
identity a person again, and the next list settles a bot such a build sorts.
- **`SenderBot` describes the bot itself**: its name, identities, organization, author, reason, counts, reach and
signals, and no longer `person`. `moveToPerson` gives each identity back to the person it came from unless `person` is
named. Both moves take `sender-bot:<id>`, `person:<uid>` or an identity.
- **`people.list` rows lose `bot`**, and `KindSignal` loses `owner-choice`: no listed row is a bot.
44 changes: 28 additions & 16 deletions docs/dev/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,27 +692,39 @@ proposes them instead. A no-reply address (`isNoReplyAddress`) is no one's: it n
tie; mail the owner wrote them or a private chat both wrote in makes it `direct`, and with no mail a one-to-one chat
or a small group does. `null` when nothing says. The page reads the List-Ids of its people's mail, and the senders of
those lists through the index `emails_by_list_id` (version 74).
- **Sender bots** (`sender-bots.ts`, version 74): a program that writes to the owner is a `sender_bots` row, not a
person. A bot keeps the person row it was sorted from: its identities stay linked there, so ingest, merges, purges and
`people show person:<uid>` work as before, and `people.list` lists it as `automated` under that ref with
`bot: "sender-bot:<id>"` and no ties. Kept kinds move a person to a bot by rule when their kind is `automated` by a
program's signal (`PROGRAM_SIGNALS`: the platform's bot flag, a no-reply or notification address, a signed
`Auto-Submitted`, an empty Return-Path, `bulk_never_replied`), the owner wrote them nothing (no mail tie, no private
chat both wrote in; the platform's flag holds against both), no `ALWAYS_SHOWN` reason holds, and every identity of
theirs is the program's, or they have one. A name or a bulk mailbox alone marks a person `automated` and moves
nothing: a newsletter a human writes stays a person. A rule's bot goes back to a person when those rules stop holding.
The owner's `moveToBot` and `moveToPerson` move a person, a bot or one identity (one of several gets a person row of
its own first) for its whole history, and win over the rules and every `KIND_RULES` bump: a bot the owner made has
`author = 'owner'`, and an identity whose latest move is the owner's to a person is never moved by a rule. Every move
is a `sender_bot_moves` row. A bot is never joined to anyone by the matcher (`identity.not-a-person`), never assigned a
task (`sender-bot.assignee`), never offered by `people.similar` and has no ties in `people.ties`. Neither table has a
foreign key, so an older build erasing a person or purging an account still can; triggers drop their rows.
- **Sender bots** (`sender-bots.ts`, versions 74 and 75): a program that writes to the owner is a sender bot
(`sender-bot:<id>`, a `sender_bots` row), an entity apart from people. Its identities are `sender_bot_identities` rows
and leave `identity_links`: an identity belongs to one person or one bot, never both, and its messages and mail keep
pointing at the identity. A bot has a name, identities and an optional organization; it has no ties, no tasks, no
merge review, and never appears in `people.list`, its counts, `people.similar` or `people.ties`. `people.listBots` and
`people.showBot` read them (`showBot` with every move). `bot:` stays the agents' ref (the `bots` table). Kept kinds
move a person's identities to a new bot by rule when their kind is `automated` by a program's signal
(`PROGRAM_SIGNALS`: the platform's bot flag, a no-reply or notification address, a signed `Auto-Submitted`, an empty
Return-Path, `bulk_never_replied`), the owner wrote them nothing (no mail tie, no private chat both wrote in; the
platform's flag holds against both), no `ALWAYS_SHOWN` reason holds, and every identity of theirs is the program's, or
they have one. A name or a bulk mailbox alone marks a person `automated` and moves nothing: a newsletter a human
writes stays a person. A rule's bot goes back to the people its identities came from once the owner writes to it
(`ruleBotsBack`). The owner's `moveToBot` and `moveToPerson` move a person, a bot or one identity for its whole
history, and win over the rules and every `KIND_RULES` bump: a bot the owner made has `author = 'owner'`, and an
identity whose latest move is the owner's to a person is never moved by a rule. Every move is a `sender_bot_moves`
row. **The person row a bot emptied stays**, stored with kind `merged` and hidden as a merge's emptied person is
(`mergedAwaySql`), so a move back gives its uid back and the rows that name it keep their meaning; its `person:` ref
still names the bot in a move, `tasks.assign` refuses it (`sender-bot.assignee`), and the matcher never sees a bot's
identities. `sender_bots.person_id` only keeps builds before version 75 from reading a bot as a person: negative
since. Those builds still write to a migrated store, so triggers keep them apart: a bot's identity gets no link to a
person (`RAISE(IGNORE)`), the person row their ingest made for it goes again, a bot holding identities is not deleted,
a re-keyed link onto a bot's identity moves to the bot, and a hidden person's kind stays `merged` (checked against
cli-core 1.0.0 itself). A re-key of a bot's identity onto a person's gives the bot the one that stays
(`rekeyIntoBot`), and a purge removes the person rows its bots emptied. A positive `person_id` is a bot such a build
sorted after the upgrade; the next writable list moves its identities to it (`settleLegacyBots`), even when every
stored kind is current. No table has a foreign key, so an older build purging an account still can; triggers drop a
bot's rows with its last identity.
- **Organizations from mail domains** (`domain-organizations.ts`, plan step 5): when kinds are kept, a bot or a shared
mailbox (every address a role address) at a company domain joins the organization of its registrable domain
(`registrableOf`, so `mail.bank.example` is `bank.example`): the organization already holding an address there, else
a new `company` named by the sender when the name is a company's or the domain's own word, else by the domain. Its
addresses go to `organization_identities` with method `domain`, author `rules`, and a bot's `sender_bots.organization_id`
is set. A human with an address there gets a `member-of` link (author `rule`), never a merge and never a proposal; a
is set (`people.listBots` filters by it). A human with an address there gets a `member-of` link (author `rule`), never a merge and never a proposal; a
human alone makes no organization. Free mail (`FREE_MAIL`), throwaway mail (`disposable-email-domains-js`) and
sending platforms (`SENDING_PLATFORMS`) are never a company domain. Two organizations holding one domain leave it
ungrouped. Each organization holding a company domain takes that domain's `metadata.sector` (`Organization.sector`:
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/COORDINATION.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dev/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Verbs used but not in cli-base's vocabulary, by CLI (2026-10-12). Each needs a r
| project | the owner's work unit with a task key | entity | `entity:` references still parse for old files |
| organization | a company, team, family or community | entity | none |
| person | one human, across every messenger and mail (`person:<uid>`) | user, people | tg bot help: "user:<id> for a person", "the person's user id"; drive `people` |
| bot | a program that writes to the owner: a no-reply or alert address, a messenger's bot, a service's mail; an entity apart from people, with a name, identities and an optional organization, and no ties, tasks or merge review (`sender-bot:<id>`, the `sender_bots` table). Not an agent: `bot:<id>` and the `bots` table are agents that work here | automated person, sender (for a bot) | `people list kind:automated` still lists people a name or a bulk mailbox marks; memo's `{ bot }` author and `bot list` mean agents and a messenger's bot account |
| contact | one person as one source knows them: a mail correspondent, a Telegram user, a Drive owner, a calendar attendee; an `identities` row | user | none found beyond the above |
| entity | the thing the owner means — a person, an event, a document; it carries no provider id ([WC-DATA-2](https://github.com/WireCatLabs/cli-base/blob/main/docs/standards/data-model.md)) | record, object | none |
| source record | one source's copy of an entity, keyed by account and `external_id`: a contact, a Zoom meeting, an email, a message | entity, item | none |
Expand Down
5 changes: 3 additions & 2 deletions docs/reasons.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,9 @@ headings.
| `selection.invalid` | `validation_error` | the selection is not valid | |
| `selection.out-of-scope` | `permission_error` | the selection reaches outside what this profile may read | |
| `sender-bot.assignee` | `validation_error` | a sender bot is no one's assignee; move it to a person first | |
| `sender-bot.not-a-person` | `validation_error` | the person named is a sender bot; name a person | |
| `sender-bot.not-found` | `not_found` | no sender bot has that id; people list kind:automated lists them | |
| `sender-bot.empty` | `validation_error` | the person or bot named holds no identity to move | |
| `sender-bot.not-a-person` | `validation_error` | the identity named is a sender bot's, not a person's; name a person | |
| `sender-bot.not-found` | `not_found` | no sender bot has that id; the bots list names them | |
| `sender-bot.owner` | `validation_error` | the owner's own person is never a bot | |
| `serve.outdated` | `configuration_error` | the store or the installed version is newer than this serve; it stopped so its unit starts the installed one | |
| `session.duplicate` | `conflict` | another profile here already signs in to this account as this user | |
Expand Down
20 changes: 16 additions & 4 deletions docs/storage/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Every table of the shared store (tg, max, memo, zm) as its migrations create it.
`drizzle/` must agree with it. `pnpm schema:check` fails when they do not, and `src/store/sqlite/schema.test.ts`
checks every table and column of a new store against this page.

147 tables, 28 full-text indexes.
148 tables, 28 full-text indexes.

## Conventions

Expand Down Expand Up @@ -335,19 +335,31 @@ An AI agent or a script that works here: it registers itself, owns projects and

### `sender_bots`

A program that writes to the owner: a no-reply or alert address, a messenger bot, a service's mail. Not a person, so it is never proposed as the same person, has no ties and is no task's assignee. Its identities are those of the person row it was sorted from, which `people list` shows as `automated`. Not the `bots` table, which holds agents that work here.
A program that writes to the owner: a no-reply or alert address, a messenger bot, a service's mail. An entity of its own beside `persons` (`sender-bot:<id>`): it holds its identities in `sender_bot_identities`, never in `identity_links`, so it is never listed or proposed as a person, has no ties and is no task's assignee. Not the `bots` table, which holds agents that work here.

| Column | Type | Constraints | References | Meaning |
|---|---|---|---|---|
| `id` | integer | PK | | |
| `person_id` | integer | not null, unique | | the person row whose identities are this bot's; its `person:` uid stays the bot's handle in lists. No foreign key: an older build erasing the person does not know this table, and a trigger drops the bot with it |
| `person_id` | integer | not null, unique | | kept for builds before version 75, which read a bot as this person row: negative for every bot since, so it names no person. A positive one is a bot such a build sorted after the upgrade, whose identities the next list moves here |
| `name` | text | | | the owner's name for it; null shows its identities' name |
| `organization_id` | integer | | | the organization it sends for; no foreign key, a trigger clears it when the organization row goes |
| `author` | text | not null | | `rules` or `owner`: the owner's bot never goes back by a rule |
| `reason` | text | | | what sorted it: the kind signals, such as `no-reply`, or the owner's words |
| `created_at` | integer | not null | | when this row was saved here |
| `updated_at` | integer | not null | | when this row last changed here |

### `sender_bot_identities`

The identities a sender bot holds. An identity is here or in `identity_links`, never both: a trigger refuses its link to a person while a bot holds it, so an older build's sync gives it no person again. Its messages and mail keep pointing at the identity.

| Column | Type | Constraints | References | Meaning |
|---|---|---|---|---|
| `identity_id` | integer | PK | | no foreign key, as the other bot tables: an older build purging an account does not know this table, and a trigger drops the row with the identity |
| `bot_id` | integer | not null | | the `sender_bots` row; the bot goes when its last identity does |
| `created_at` | integer | not null | | when the bot took it |

*Keys and indexes:* `INDEX (bot_id)`

### `sender_bot_moves`

Every move of an identity between a person and a sender bot, by the rules or by the owner. An identity whose latest move is the owner's is never moved by a rule again. A trigger drops an identity's rows with it.
Expand All @@ -364,7 +376,7 @@ Every move of an identity between a person and a sender bot, by the rules or by
| `reason` | text | | | the kind signals of a rule's move, or the owner's words |
| `created_at` | integer | not null | | when it moved |

*Keys and indexes:* `INDEX (identity_id)`
*Keys and indexes:* `INDEX (identity_id)`, `INDEX (from_person_id)`

## Chats and messages

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE `sender_bot_identities` (
`identity_id` integer PRIMARY KEY,
`bot_id` integer NOT NULL,
`created_at` integer NOT NULL
);
--> statement-breakpoint
CREATE INDEX `sender_bot_identities_by_bot_id` ON `sender_bot_identities` (`bot_id`);--> statement-breakpoint
CREATE INDEX `sender_bot_moves_by_from_person_id` ON `sender_bot_moves` (`from_person_id`);
Loading
Loading