Work with brains and blueprints
The job
Answer a question about one subject, such as the business or its website, from the brain that Sasha holds for that subject. Tell the person how complete that brain is, and which documents are still missing.
What a brain is
- A brain is everything Sasha knows about one subject. It is a folder inside a project. The folder holds a
brain.mdcard and a set of ordinary documents. The brain id is<project>/<folder>. A card at the root of a project is not a brain. - A blueprint is the plan for one kind of brain. It ships with Sasha and has a version, for example
site@1. It lists every document that kind of brain should have. Each document has a ring, the Context Spine domains it covers (deepens, numbers 1 to 20), an out-of-date rule (outOfDateAfterDays) and one line on what it should contain (asks). - This release has two blueprints.
business@1is the Context Spine: twenty documents in five rings.site@1describes one website and sits under a business brain. - The five rings are, in order: Public Context (stage Scope), Organisational Knowledge (Land), Proprietary Methodology (Expand), System Integration (Embed) and Flow (Flow). A brain's depth counts its documents in each ring by state.
- The card names the blueprint and lists only the differences.
addgives an extra document with anid,title,ring,deepens,outOfDateAfterDays,asksand areason.dropremoves a blueprint document, with areason. A brain's documents are the blueprint's, minusdrop, plusadd. - A document's state is
missing,filled,checked,declinedorout of date. The state comes from the document's own frontmatter (checked,checkedBy,declined,summary), never from the card. - A card can name a parent brain, for example a site brain under its business brain. When a site brain has no document for a domain, the parent business brain may cover it. A parent that this connection cannot read is reported as no parent.
- A brain in a member's own home has level
tenant. A brain in a shared project has levelsasha.
Prerequisites
- The connection holds
knowledge:read. Admin, staff and member connections can all hold it. - A member sees the brains in their own member home and in each shared project where they hold a grant. Admin and staff see the brains in every active shared project, but in no member home. See listBrains.
- The brain tools only read. A brain document is an ordinary document: to change one, see Write a document in your member home.
Steps
The example question is: "What does the Northwind Advisory website say about discounts, and what is still missing from it?" The instance is your-sasha.example.com.
List the brains that this connection can see.
{}{ "brains": [ { "id": "northwind-advisory/brains/business", "type": "business", "title": "Northwind Advisory", "blueprint": "business@1", "level": "sasha", "parent": null, "card": "northwind-advisory/brains/business/brain.md", "depth": [ { "ring": "Public Context", "stage": "Scope", "documents": 4, "filled": 2, "checked": 1, "declined": 0, "outOfDate": 0, "missing": 2 } ] }, { "id": "northwind-advisory/brains/website", "type": "site", "title": "Northwind Advisory website", "blueprint": "site@1", "level": "sasha", "parent": "northwind-advisory/brains/business", "card": "northwind-advisory/brains/website/brain.md", "depth": [ { "ring": "Public Context", "stage": "Scope", "documents": 10, "filled": 2, "checked": 0, "declined": 0, "outOfDate": 0, "missing": 8 } ] } ], "truncated": false }This response shows only the first ring of each brain. Keep the
idof the brain that matches the subject, herenorthwind-advisory/brains/website. An emptybrainslist means that no folder this person can read holds abrain.mdcard.Learn what this kind of brain should hold. Use the
blueprintvalue from step 1.{ "type": "site@1" }Each document in the result has its
file,title,ring,deepens,outOfDateAfterDaysandasks. Useasksto tell the person what a missing document should contain.Open the brain's contents page.
{ "brain": "northwind-advisory/brains/website" }documentsgives each document with itsstateand apath.droppedgives the documents that the card drops, with the reason. For a missing document,parentCoversnames the parent brain's filled or checked documents for the same domain. An emptyparentCoverslist means that the parent does not cover it either.Search the brain and its parents for the subject.
{ "brain": "northwind-advisory/brains/website", "query": "discount", "includeParents": true }searchedlists the brains that the search covered, in order. Each result has thebrain, thedocumenttitle, thepath, thelineand asnippet. The search is a plain text match, not a semantic search.Read the document before you state a fact. A snippet is one line. Pass the
pathas it is, with noproject.{ "path": "northwind-advisory/brains/website/offer.md" }Give the answer with its source path. Then give the gaps: the documents with state
missing, what each should contain (asksfrom step 2), and any parent document that covers the same domain (parentCoversfrom step 3). If a document from the site brain and a document from the parent brain say different things, tell the person, and give both paths.
Brains for the customers of a product
A product that runs one shared Sasha for many customer accounts can give each account its own brains:
- Each customer account is one Sasha member. The member home is that account's folder, and the account's brains live inside it at level
tenant. - The product calls Sasha with that member's own token. Each check is then the member's: the token reads that one home and the shared projects where the member holds a grant, and nothing else.
- Another member's home reads as
Not found. Admin and staff connections see no member home, so they cannot read a customer's brains over MCP. - Material that every customer may read, such as a product's house rules, goes in one shared project. Each member gets a read grant on it. A tenant brain can name a brain in that project as its parent.
What can go wrong
Error in getBrain: Not foundorError in searchBrain: Not found: there is no brain with this id that this person can read. The answer is the same whether the brain is hidden or does not exist. Use anidfromlistBrains.Error in getBlueprint: Unknown blueprint. Call getBlueprint with no type for the list.: use areffromgetBlueprintwith no arguments.parentisnullalthough the card names one: this person cannot read the parent brain, or it does not exist.searchBrainwithincludeParentsthen searches only the brain itself.warningsanddepth: null: the card names a blueprint that this release does not have.warningsalso namesaddanddropentries that were skipped, and why.truncatedistrue:listBrainsreturns at most 50 brains, andsearchBrainat most 40 results. Name aproject, or make the query narrower.MCP error -32602: Tool listBrains not found: the connection does not holdknowledge:read. Read thepermissionssection of getDocs. Do not tell the person that Sasha has no brains.