Docs Contracts
Module contract
The contract every business module meets, and how clients and shared components treat modules.
The contract every business module meets, and how clients and shared components treat modules. ARCHITECTURE.md, "Business modules", is the summary. t10-collab is the first module to meet it.
Status: built in t10-collab and workbench. t10-notify, module events and the mobile app's module screens are proposed. t10-knowledge now provides document management and text search (remaining settings/notifications/attention plumbing is deferred); t10-modkit now shares org reads, IDs and cursors, with the remaining extraction pending.
Proposed, chosen Nov 6, 2026: a business application such as property becomes its own web app instead of a folder in workbench. This would narrow decision 4 and "A module builds no admin site" to capability modules. Everything below describes today's system until it's built. See proposals/business-module-apps.md.
Decisions#
A business module is a service that owns one kind of tenant data and the access rules for it. workbench and t10-collab now work this way. workbench's config, proxy and shell name no module, and t10-collab's screens live in web/src/modules/collab/. The digest moved to t10-notify in the designs, so a second module won't need its own connection to a tenant's WeCom or Feishu app.
Five decisions keep it that way:
- One module, one service, one database. Each module is its own repo, deployment and Postgres database. Nothing outside a module reads its tables.
- The contract is network-only. A module meets it over HTTP and MCP, so it can be written in any language. Shared Go code is a convenience, not a requirement.
- Shared components use a module ID, never a module name in code.
workbenchroutes by ID from config. Only each module's own client folder knows its routes. - Screens compile into each client. A client shows a module only if it ships that module's folder and the module's manifest answers. No central registry is needed.
- Anything two modules would both need moves out of them. The first case is the digest, which becomes a small
t10-notifyservice before it's built.
flowchart TB wb["workbench<br/>Proxies by module ID"] mobile["mobile app (partly built)<br/>Module integration planned"] pi["agent-pi<br/>One MCP entry per module"] notify["t10-notify (proposed)<br/>Daily digest"] contract["Module contract<br/>Manifest, actions, notifications, attention counts,<br/>settings, references, MCP tools, traces"] collab["t10-collab<br/>Work items, offers, lists"] deals["Deals (example)"] docs["Documents (example)"] auth["auth-server<br/>Identity, tenants, org facts, grants"] wb -->|user token| contract mobile -.->|user token| contract pi -->|delegated token| contract notify -.->|service token| contract contract --> collab contract -.-> deals contract -.-> docs collab -->|JWKS, org reads| auth deals -.-> auth docs -.-> auth
Modules never call each other's tables, and clients reach them only through the contract. The Deals and Documents boxes are examples, not commitments.
The module contract#
| Part | Every module provides | t10-collab today |
|---|---|---|
| Identity | Service name t10-<id>, with its own auth-server account. Accepts aud=t10 and its own name, and takes the tenant only from tid |
Meets it |
| Manifest | GET /v1/module, described below |
Meets it |
| Access | One policy package for routes and agent tools, applied in SQL before pagination. A hidden record answers 404. The module owns which records an action reaches, field masking and workflow rules. Proposed: which actions a person may take comes from auth-server's business roles, through its entitlement read, for modules that adopt them; see auth-server/docs/design.md, "Business roles" |
Meets it, without business roles |
| Actions | <prefix>:read, write, delete and export, plus any of its own. The auth requirements ask for distinct read, edit, delete and export rights |
work:read, write, delete and send. No export, because it has no export route |
| Notifications | GET /v1/notifications?after= and POST /v1/notifications/read, in a shared shape with kind and a target record reference |
Meets it |
| Attention counts | GET /internal/v1/attention?tenant=&user=, for t10-notify's service token only. Counts through policy, with no titles or names |
Meets it |
| Settings | GET /v1/settings for any member, and PUT /v1/admin/settings for the module admin, who is a tenant admin in v1. The module checks that role itself. See "Administering a module" |
Meets it |
| Departures | A job that handles people leaving, because auth-server publishes no change events. No failed org read may count as someone leaving |
Meets it |
| Agent tools | Optional. /mcp with tools named <prefix>_*, going through the same policy. Other people's text arrives marked as data |
Meets it |
| Telemetry | Exports to OTEL_EXPORTER_OTLP_ENDPOINT, an OTLP/HTTP URL. Continues an incoming traceparent, and marks its span t10.session.id from X-Session-ID. Spans hold no record text. t10-modkit/telemetry does all of this |
Meets it |
| Data | Own database and schema, with tenant_id in composite keys. Migrations embedded and run under an advisory lock, by t10-modkit/pgdb |
Meets it |
| Errors | Every error answers {"error": "<snake_case code>", "message": "<optional sentence>"}, as t10-modkit/httpjson writes it. A client branches on error, never on message |
Meets it |
| Names | Its folder name is its Go module, cmd/<folder>, its image and deploy/k8s/<folder>.yaml. It listens on <PREFIX>_LISTEN_ADDR, its tests read TEST_DATABASE_URL, and its Compose file is compose.yml. The workspace's scripts/check-conventions.py holds this, in make check |
Meets it |
| API docs | docs/openapi.yaml, kept in step by a test. /healthz and /readyz |
Meets it |
| Events | Optional. Event kinds listed in the manifest as trigger_events (events already names what notifications mean), posted from an outbox to t10-automations's POST /v1/events with a service token, at least once, each {id, source, tenant, kind, ref, for, actor, cause_grant, hops, at}. for is the agent account it concerns, cause_grant the grant of the run that caused it, when an agent did, and hops the agent hops since a person last acted. See t10-automations/docs/design.md |
t10-collab, for agent teammates |
The manifest is how a client learns a module is present and compatible. It takes a person's token, so it can answer for that person's tenant.
{ "id": "collab", "api_version": 1, "action_prefix": "work", "enabled": true, "features": ["attention"] }idis the name used in routes and references.action_prefixis separate becauset10-collabalready useswork.api_versionis a major version. Routes and fields can only be added within it, and a client hides a module whose major version it doesn't know.enabledistruein v1. It's the place to add a per-tenant switch, if one is needed. It's the only way for a deployed module to take itself out of a client's menu, because any other failure reads as being down.app, for a module with its own web app, says where it is:{url, label, label_zh, icon_svg, access, nav}.workbenchthen links to it instead of showing compiled screens, and sends/t/<tenant>/<id>/...to the same path there.icon_svgis the menu icon, a 24 by 24 SVG of at most 8 KB that the client uses only as a mask; without one the client shows a generic icon, because no client names a module's icon.accessismemberif every member has some use for the app; otherwiseworkbenchhides it from people with no role in it. Seeproposals/business-module-apps.md.app.navlists every section of the app, in menu order:[{key, to, label, label_zh, group, keys}].tois a path under the app's/t/<tenant>/,groupis one ofdaily,recordsandsetup, so every app's menu sorts the same way, andkeys, optional, name the attention counts that add up to the section's badge. Which sections a person can use is the module's call, so it answersGET /v1/me/navwith{sections}in the same shape, narrowed to that person (a hint for menus; every route still refuses for itself). The app's own rail andworkbench's Apps list both draw from that read, so no client lists another app's sections. A module with nonavshows as one entry.attention, withapp, is Home's rows:[{keys, label, label_zh, to}], each the sum of those keys fromGET /v1/attention, with{count}in the label.eventsis what its notifications mean:{kind: {label, label_zh}}. A module with its own app also gives each notificationto, the page it leads to under the app's/t/<tenant>/, so the bell in any app's frame can link to it without knowing the module's records. A notification may also carrytitle, the reader's own name for what it's about, such as an automation's, which the bell shows after the event's label untranslated, and itstargetmay name another module's record, such as the work item a teammate's run was about. A module whose app has its own assistant listsconversationsinfeaturesand answersGET /v1/me/conversationswith this person's:{conversations: [{id, last_used_at, to, title}]}, latest first, wheretocontinues one in the app andtitleis left out unless it's safe to show anywhere.workbenchlists them with its own conversations and never reads what was said, so a module that keeps resident text from other clients keeps doing so.- A module that lists
ontologyinfeatures, proposed, describes its records, links and actions as data atGET /v1/ontologyand serves the generic object, action, proposal and undo routes and agent tools incontracts/ontology/README.md. A client treats a module without it as having no ontology and calls none of those routes. permissions, proposed, lists the module's business permissions, each with a key underaction_prefix, a description, a catalog version and a lifecycle.auth-serverregisters them from deployment config, checked against the manifest, and tenant admins compose roles from them. A module without business roles omits it.
Clients#
| Concern | workbench |
Mobile app |
|---|---|---|
| Module list | MODULE_URLS=collab=http://…, the same format as AGENT_URLS. Replaces COLLAB_URL |
App config, plus the base URL of the public modules route |
| Reaching a module | /api/modules/{id}/{path...}, which replaces /api/collab/*. The backend adds the token |
HTTPS with the user's token at https://<api-host>/modules/<id>/v1/... |
| Availability | /api/config returns modules, from each manifest, and unavailable_modules, those listed that gave no clear answer. A listed module that's down keeps its menu entry; only leaving MODULE_URLS or answering enabled: false removes it. See module-visibility.md |
Reads each manifest after sign-in and tenant change |
| Screens | web/src/modules/<id>/ exports one WorkbenchModule: routes, nav, palette entries, Home rows, its place in Administration and notification labels |
lib/modules/<id>/ exports one AppModule: routes, nav and notification labels |
| Notifications | One poller per module, about every 30 seconds while open | The same, only while the app is in use |
Module calls and agent turns stay separate paths. Agent traffic goes through a conversation or a room, and module data goes through the module's own API.
Administering a module#
Unless it has its own web app, a module builds no admin site of its own. Tenant admins set it up in workbench's Administration, and platform admins work in the platform console, so a new module adds no address and no sign-in. "Admin surfaces" in ARCHITECTURE.md describes the two places.
| Who | A module provides | Where it shows | State |
|---|---|---|---|
| Tenant admin | Its settings routes, and admin in its WorkbenchModule |
Administration. A module with one or two settings joins the built-in tab they belong with, using joins. One with more takes its own tab, using label and icon, between the built-in tabs and Activity. The tab's ID is the module's, so /t/<tenant>/admin?tab=<id> is a stable link |
Built. collab joins Organization, because who a manager sees follows the org tree. agents joins Agents |
| Tenant admin | A log of its admin changes, as GET /v1/admin/activity in auth-server's audit record shape |
Activity, merged by time with auth-server's records |
Proposed. Module changes appear in no log today. t10-agent-control already keeps tenant_setting_changes, so it can go first |
| Platform admin | Nothing beyond its manifest and /readyz |
A Modules page in the console, read from MODULE_URLS given to t10-console, beside Fleet. It needs no code for each module |
Proposed. Build it with the second module |
| Platform admin | Reads which tenants may use it, and answers enabled: false in its manifest for the rest |
A Modules tab on each tenant in the console | Proposed. Only when a module is sold separately |
Four rules keep this generic:
- Administration holds what applies to everyone in a tenant. A person's own preferences go in Settings, and records stay on the module's pages.
- The module decides, not the page. It checks the admin role on every admin route, from
auth-server, ast10-collabandt10-agent-controldo. Hiding a tab is only presentation. - Platform settings stay in the module's deployment config until a platform admin needs to change one without a deploy. Only then does the console get a section for it.
- The admin pages name no module. Administration builds its tabs from
useModules(), and the console reads manifests. Neither changes for a new module.
Two decisions wait for a real need:
- Module admins who aren't tenant admins are built for a module with its own app, with Property first.
auth-serverholds it as the catalog permission<prefix>:admin. The module checks it, reads its own roles and assignments fromGET /v1/module-roles, and shows its setup in its own app, so they never need Administration. A module admin must not be able to widen their own scope. Modules compiled intoworkbenchhave no such admin yet: their Administration tabs stay with tenant admins. - Where "this tenant has this module" lives. Keep it in
t10-agent-control. It already holds per-tenant settings, answers the console, and publishes a cached snapshot that routers poll withETag. Modules would poll the same way, so a down control plane never stops a module. The governance plan's entitlement belongs there too. Keeping a flag in each module would need a platform route, a platform role check and a console page in every module.
The mobile app has no administration. Tenant admins use workbench.
Where work lives#
A person's work can live in more than one module, so each kind has one home:
- A domain's own work stays in its module. A property work order is assigned, tracked and closed in Property, under Property's business roles. Nothing copies it into
t10-collab. t10-collabholds work across teams, and between people and agent teammates: asks, reviews, follow-ups and hand-offs that belong to no one domain. A work item about a domain record points to it with a link, and copies none of its data.- One place to see it all is Workbench's Home, which takes "Needs you" rows from every module's attention read, and the bell, which lists every module's notifications. Neither needs a module's work to move.
A new module that would assign work checks this first: if the work belongs to its records, it keeps it; if it's a request between people about them, it sends a work item instead.
Links between modules#
A record in one module can point to a record in another, as the collab design expects for Documents. A reference is an opaque string, <module>:<type>:<id>, such as collab:work_item:wi_ab12.
- Stored as text. A reference has no foreign key, and holding one grants nothing.
- Resolved by the owner. A client asks the owning module with the viewer's token, so that module's policy applies. A
404shows as "unavailable". - No calls between modules for a person's data. A module never reads another module to build its own response, so one module's outage can't break another.
- The same form works in
agent-pi. Session metadata storesrefinstead ofworkItemId, and record text reaches the model in one<module_record>tag. Its data-not-instructions rule then covers every module, with no prompt change for each new one.
Digest#
The daily digest belongs in a separate t10-notify service, not in a package inside any module. It isn't built yet, and the workbench design now says the same.
t10-notify owns chat app connections, each person's verified chat identity, send times and vendor adapters. Once a day it reads each module's attention counts and sends one message per person. Every other digest decision stands: a private message, counts and a link, no titles, and a person proves their identity once. A tenant connects WeCom or Feishu once, however many modules it uses.
The workbench screens for connecting stay where they are, and call t10-notify through the same proxy. Because it holds tenant app secrets, its data stays apart from every module's.
Shared code#
t10-collab holds code that every Go module would need: verifier, people, telemetry, page, ids, the route guard and the sweep's lock. Copying that into each module would multiply the existing parity gap.
t10-modkit is the one Go kit for business modules: public at github.com/xiant10/t10-modkit and released by tag, from v0.1.0. It holds people, page, ids, pgdb, telemetry, httpjson, websession, frame, docsmcp, ontology, verifier (a copy of auth-server's, which make check compares) and module, what every module made from t10-template answers. Workspace repos carry a checked source snapshot of it, which scripts/check-modkit.sh holds equal; modules made from t10-template, outside the workspace, import a tag. Guard composition and sweep locks remain to be extracted. It holds only cross-cutting code, never a business rule.
Adding a module#
guides/build-a-module.md is the order of work, from an empty repo to a module people and agents use, with the configuration each step needs in other repos. Most of it is configuration: a new module changes no code in auth-server, agent-pi or t10-livekit-agent, or in workbench outside its own folder.
Changes to get there#
The t10-collab contract changes, the workbench plug-in refactor and ref with <module_record> are done. New workbench conversations use them, and the old forms still read for existing sessions. These remain:
| Repo | Change | When |
|---|---|---|
t10-notify (new) |
Build the digest here, with the design's first chat adapter | When digest work starts |
t10-modkit (new) |
Extract the shared Go code | When the second module starts |
| Deployment | Deploy the optional public modules ingress in deploy/k8s/modules-ingress.yaml |
Before the mobile app uses a module |
Alternatives considered#
| Option | Why not |
|---|---|
New modules as packages in t10-collab |
One deployment is simpler, but every module would share one database and outage, and the service's name and token audience would stop meaning anything |
| A central module registry service | A client can only show modules it ships code for, so it needs its own list anyway. A registry would add a service and tell clients nothing the manifests don't |
| Screens loaded at runtime, or described by the server | No third-party modules are planned, and the workbench design rules out plugins. Either would add a hard loading and security problem to two clients |
| Each module serves its own admin pages | An admin with several modules would be back to one address and sign-in for each, which is what the admin unification removed. Each would also repeat layout, translations and step-up |
| Settings described by a schema, and drawn by Administration | Settings differ too much to describe: agents is a list of switches with a default, and collab one choice with a warning. Screens already compile into the client, so a module draws its own cards |
| Modules exchange events through a broker | t10 runs no broker. A module that has events posts them from an outbox to t10-automations, which is the one reader that needs them |
Keep the digest in t10-collab, and have other modules call it |
Other modules would depend on an unrelated module's uptime, and tenant chat secrets would sit in the tasks database |
Generated from t10’s own docs (bbc3cde). Spotted a problem? Tell us.