Cotton code
255 lines · 11.7 KB · JSONRaw
{  "pair": "briefing",  "rust": "crates/cotton-core/src/rules/memory_briefing.rs (compile_briefing), crates/cotton-tools/src/mcp/handlers/records_2/memory.rs (brief)",  "worker": "apps/business/src/mcp/tools/memory/briefing.ts (compileBriefing), memory.ts (brief)",  "compiler": {    "fixture": "crates/cotton-core/tests/fixtures/memory_briefing.json",    "rule": "The compiler's goldens are the phone's fixture, read by both suites. The Worker's compiler is compared on every case with no ownerName (the served-* cases and no-owner-name): it takes no owner name, and neither brief tool passes one. A case it answers otherwise is listed here with its answer.",    "differs": [      {        "name": "served-empty",        "why": "The phone's no-project line offers `get_project`; the Worker serves no get_project tool and leaves it out.",        "worker": {          "markdown": "# Briefing for sessions working with the owner — 2026-08-24\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\nNo project is bound to this repo, so there is no memory to brief.\nCall `list_projects`, then `brief { project }` for the one this work belongs to.",          "tokensEstimate": 114,          "overBudget": false,          "dropped": {            "entries": 0,            "procedures": 0,            "procedures_cut": 0          }        }      },      {        "name": "served-procedures-150",        "why": "When the budget trims procedure lines the phone points at `get_project`, the Worker at `search_records { q: \"Trigger:\", table: \"note\" }`.",        "worker": {          "markdown": "# Briefing for sessions working with the owner — 2026-08-24\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Tinmen\n\n- [ferns] The ferns want water on Mondays.\n- [kettle] The kettle is descaled every Sunday.\n\n## Needs attention\n\n- Budget trimmed 4 procedure lines — `search_records { q: \"Trigger:\", table: \"note\" }` finds every procedure note.",          "tokensEstimate": 139,          "overBudget": false,          "dropped": {            "entries": 0,            "procedures": 4,            "procedures_cut": 0          }        }      },      {        "name": "served-procedures-110",        "why": "As served-procedures-150, with entries left out too.",        "worker": {          "markdown": "# Briefing for sessions working with the owner — 2026-08-24\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Tinmen\n\n- 2 more entries are not shown here — read them with `recall { project: \"tinmen\" }`.\n\n## Needs attention\n\n- Budget trimmed 4 procedure lines — `search_records { q: \"Trigger:\", table: \"note\" }` finds every procedure note.",          "tokensEstimate": 138,          "overBudget": true,          "dropped": {            "entries": 2,            "procedures": 4,            "procedures_cut": 0          }        }      }    ]  },  "cases": [],  "differs": [    {      "name": "brief a project by its repo",      "why": "The Worker's brief answers two keys more (database, databaseId); with no project bound, the phone's second line offers `get_project`, which the Worker does not serve (so its tokensEstimate is 4 less).",      "seed": [        {          "kind": "project",          "id": "00000000-0000-4000-8000-000000000001",          "data": {            "slug": "widgets",            "name": "Widgets",            "repos": [              "https://git.example.test/acme/widgets.git"            ],            "status": "active"          }        },        {          "kind": "memory",          "id": "00000000-0000-4000-8000-000000000011",          "data": {            "slug": "tea-first",            "title": "Tea comes before coffee.",            "body": "",            "status": "active",            "visibility": "private",            "origin_kind": "user"          }        },        {          "kind": "memory",          "id": "00000000-0000-4000-8000-000000000012",          "data": {            "slug": "ship-friday",            "title": "Ship on Fridays only after a walk.",            "body": "",            "status": "active",            "visibility": "private",            "origin_kind": "user"          }        },        {          "kind": "memory",          "id": "00000000-0000-4000-8000-000000000013",          "data": {            "slug": "shed-key",            "title": "The shed key hangs by the door.",            "body": "",            "status": "active",            "visibility": "private",            "origin_kind": "user",            "machine": "m1"          }        },        {          "kind": "project_link",          "id": "00000000-0000-4000-8000-000000000101",          "data": {            "project": "00000000-0000-4000-8000-000000000001",            "record_kind": "memory",            "record_id": "00000000-0000-4000-8000-000000000011",            "applied_by": "user",            "pinned": false,            "position": 2000          }        },        {          "kind": "project_link",          "id": "00000000-0000-4000-8000-000000000102",          "data": {            "project": "00000000-0000-4000-8000-000000000001",            "record_kind": "memory",            "record_id": "00000000-0000-4000-8000-000000000012",            "applied_by": "user",            "pinned": true,            "position": 5000          }        },        {          "kind": "project_link",          "id": "00000000-0000-4000-8000-000000000103",          "data": {            "project": "00000000-0000-4000-8000-000000000001",            "record_kind": "memory",            "record_id": "00000000-0000-4000-8000-000000000013",            "applied_by": "user",            "pinned": false,            "position": 1000          }        }      ],      "steps": [        {          "tool": "brief",          "args": {            "repoUrl": "git@git.example.test:acme/widgets.git",            "machine": "m1"          },          "rust": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Widgets\n\n- [ship-friday] Ship on Fridays only after a walk.\n- [shed-key] The shed key hangs by the door.\n- [tea-first] Tea comes before coffee.",              "tokensEstimate": 116,              "overBudget": false,              "projects": [                "widgets"              ],              "generatedAt": "<instant>"            }          },          "worker": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Widgets\n\n- [ship-friday] Ship on Fridays only after a walk.\n- [shed-key] The shed key hangs by the door.\n- [tea-first] Tea comes before coffee.",              "tokensEstimate": 116,              "overBudget": false,              "projects": [                "widgets"              ],              "generatedAt": "<instant>",              "database": "<id1>",              "databaseId": "<id1>"            }          }        },        {          "tool": "brief",          "args": {            "project": "widgets"          },          "rust": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Widgets\n\n- [ship-friday] Ship on Fridays only after a walk.\n- [tea-first] Tea comes before coffee.",              "tokensEstimate": 105,              "overBudget": false,              "projects": [                "widgets"              ],              "generatedAt": "<instant>"            }          },          "worker": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\n## Project: Widgets\n\n- [ship-friday] Ship on Fridays only after a walk.\n- [tea-first] Tea comes before coffee.",              "tokensEstimate": 105,              "overBudget": false,              "projects": [                "widgets"              ],              "generatedAt": "<instant>",              "database": "<id1>",              "databaseId": "<id1>"            }          }        },        {          "tool": "brief",          "args": {            "repoUrl": "https://git.example.test/acme/nothing.git"          },          "rust": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\nNo project is bound to this repo, so there is no memory to brief.\nCall `list_projects`, then `brief { project }` or `get_project` for the one this work belongs to.",              "tokensEstimate": 118,              "overBudget": false,              "projects": [],              "generatedAt": "<instant>"            }          },          "worker": {            "answer": {              "briefing": "# Briefing for sessions working with the owner — <today>\n\nStanding knowledge from Cotton memory, addressed by [slug] — cite entries by slug, never restate them.\nRead beyond this briefing with `recall`; write a fact with `remember` (it reconciles against what exists); log your session with `log_session`.\n\nNo project is bound to this repo, so there is no memory to brief.\nCall `list_projects`, then `brief { project }` for the one this work belongs to.",              "tokensEstimate": 114,              "overBudget": false,              "projects": [],              "generatedAt": "<instant>",              "database": "<id1>",              "databaseId": "<id1>"            }          }        },        {          "tool": "brief",          "args": {            "project": "nope"          },          "expect": {            "refusal": "unknown project \"nope\" — projects are: widgets"          }        },        {          "tool": "brief",          "args": {            "project": "widgets",            "budgetTokens": "lots"          },          "expect": {            "refusal": "budgetTokens must be a number"          }        }      ]    }  ]}