customers table holds the local identity, its associated account, the
requested name and how the CRM answered the latest rename.
Declare the tables
bijection/crm.ts
bijection/schema.ts
crm label, so only frames that clear crm read or
write them. unique: [["external_id"]] makes accounts({ external_id }) a
point. Both tables are protected: the store
keeps only a token of each unique field, so customers({ account }) answers
with the account fixed, and a range or an order over it is read with
ctx.list(selection.atMost(n)).
The tree places both under data, as data.accounts and data.customers.
Tables and indexes cover the
declarations.
Associate and read
customers.associate checks that the account was observed and that no
customer exists for it before inserting one:
bijection/customers.ts
ctx.hasreads only the account’s presence.ctx.getreads a fact, ornull.ctx.insert(customers, fact)mints the key and returns it. It assumes the fact is absent.ctx.refuseleaves the transaction with a code fromrefuses.
customers.directory reads the first 100 customers, each with its observed
account, and answers the CRM’s observed_name beside the app’s
requested_name. Continue to control access.