writbase 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/writbase.js +307 -146
- package/package.json +3 -2
- package/skills/manager/SKILL.md +138 -0
- package/skills/manager/references/agent-provisioning.md +251 -0
- package/skills/manager/references/permission-model.md +156 -0
- package/skills/worker/SKILL.md +130 -0
- package/skills/worker/references/error-handling.md +201 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: manager
|
|
3
|
+
description: Patterns for managing agents, permissions, projects, and departments in WritBase (writbase:manage_agent_keys, writbase:manage_agent_permissions, writbase:manage_projects, writbase:manage_departments, writbase:get_provenance, writbase:subscribe, writbase:discover_agents). Use when connected as a manager-role agent.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WritBase Manager Patterns
|
|
7
|
+
|
|
8
|
+
All manager tools require `role: "manager"` on your agent key. Worker keys cannot access these tools.
|
|
9
|
+
|
|
10
|
+
## Agent Provisioning Flow
|
|
11
|
+
|
|
12
|
+
The standard sequence for onboarding a new agent:
|
|
13
|
+
|
|
14
|
+
1. **Create the key** with `writbase:manage_agent_keys` (action: `create`)
|
|
15
|
+
2. **Grant permissions** with `writbase:manage_agent_permissions` (action: `grant`)
|
|
16
|
+
3. **Verify** with `writbase:discover_agents` to confirm the agent appears with correct capabilities
|
|
17
|
+
|
|
18
|
+
Store the `full_key` from step 1 securely -- it is shown only once.
|
|
19
|
+
|
|
20
|
+
## Key Management
|
|
21
|
+
|
|
22
|
+
Use `writbase:manage_agent_keys` with these actions:
|
|
23
|
+
|
|
24
|
+
| Action | Required Params | Notes |
|
|
25
|
+
|--------|----------------|-------|
|
|
26
|
+
| `list` | -- | Paginated. Optional `limit` (max 50), `cursor` |
|
|
27
|
+
| `create` | `name` | Returns `full_key` (shown once). Optional: `special_prompt`, `project_id`, `department_id` |
|
|
28
|
+
| `update` | `key_id` | Update `name`, `special_prompt`, `is_active`, `project_id`, `department_id` |
|
|
29
|
+
| `deactivate` | `key_id` | Sets `is_active: false`. Immediate effect |
|
|
30
|
+
| `rotate` | `key_id` | Generates new secret. Old secret invalidated immediately. Returns new `full_key` |
|
|
31
|
+
|
|
32
|
+
Constraints:
|
|
33
|
+
- Managers can only create worker keys (not other managers)
|
|
34
|
+
- You cannot modify your own key (`self_modification_denied`)
|
|
35
|
+
- If `require_human_approval_for_agent_keys` is enabled in workspace settings, new keys start as inactive until an admin activates them
|
|
36
|
+
|
|
37
|
+
## Permission Management
|
|
38
|
+
|
|
39
|
+
Use `writbase:manage_agent_permissions` with these actions:
|
|
40
|
+
|
|
41
|
+
| Action | Required Params | Notes |
|
|
42
|
+
|--------|----------------|-------|
|
|
43
|
+
| `list` | `key_id` | Shows all permission rows for the target agent |
|
|
44
|
+
| `grant` | `key_id`, `permissions` | Upserts permission rows (idempotent on project+department) |
|
|
45
|
+
| `revoke` | `key_id`, `permissions` | Deletes matching permission rows |
|
|
46
|
+
|
|
47
|
+
Permission flags per row: `can_read`, `can_create`, `can_update`, `can_assign`, `can_comment`, `can_archive`.
|
|
48
|
+
|
|
49
|
+
### Dominance Rule
|
|
50
|
+
|
|
51
|
+
You can only grant permissions you yourself have. This is enforced per-row: a single row of your permissions must be a superset of each granted row. Permissions are never combined across your rows.
|
|
52
|
+
|
|
53
|
+
See [permission-model.md](references/permission-model.md) for detailed rules and examples.
|
|
54
|
+
|
|
55
|
+
### `can_comment` as Restricted Update
|
|
56
|
+
|
|
57
|
+
`can_comment` allows changing only `notes` and `status`. It blocks changes to `priority`, `description`, `department`, `due_date`, and `assign_to`. Use this for agents that should report progress but not modify task scope.
|
|
58
|
+
|
|
59
|
+
## Project and Department Management
|
|
60
|
+
|
|
61
|
+
### `writbase:manage_projects`
|
|
62
|
+
|
|
63
|
+
| Action | Required Params | Notes |
|
|
64
|
+
|--------|----------------|-------|
|
|
65
|
+
| `create` | `name` | Creates project, auto-generates slug |
|
|
66
|
+
| `rename` | `project_id`, `name` | Updates display name |
|
|
67
|
+
| `archive` | `project_id` | Archived projects hide from active views, permissions become inert |
|
|
68
|
+
|
|
69
|
+
### `writbase:manage_departments`
|
|
70
|
+
|
|
71
|
+
| Action | Required Params | Notes |
|
|
72
|
+
|--------|----------------|-------|
|
|
73
|
+
| `create` | `name` | Creates department, auto-generates slug |
|
|
74
|
+
| `rename` | `department_id`, `name` | Updates display name |
|
|
75
|
+
| `archive` | `department_id` | Archived departments hide from active views |
|
|
76
|
+
|
|
77
|
+
## Webhook Subscriptions
|
|
78
|
+
|
|
79
|
+
Use `writbase:subscribe` to register webhooks for task event notifications:
|
|
80
|
+
|
|
81
|
+
| Action | Required Params | Notes |
|
|
82
|
+
|--------|----------------|-------|
|
|
83
|
+
| `create` | `project`, `url` | HTTPS-only. Optional `event_types` (default: `["task.completed"]`) |
|
|
84
|
+
| `list` | -- | Lists all subscriptions for your agent key |
|
|
85
|
+
| `delete` | `subscription_id` | Removes the subscription |
|
|
86
|
+
|
|
87
|
+
Valid event types: `task.created`, `task.updated`, `task.completed`, `task.failed`, `task.assigned`, `task.reassigned`.
|
|
88
|
+
|
|
89
|
+
The `secret` for HMAC-SHA256 signature verification is returned only on creation -- store it securely.
|
|
90
|
+
|
|
91
|
+
## Provenance and Audit
|
|
92
|
+
|
|
93
|
+
Use `writbase:get_provenance` to view the event log:
|
|
94
|
+
|
|
95
|
+
- `project` (required): scopes events to a specific project
|
|
96
|
+
- `target_type` (optional): filter by `task`, `agent_key`, `project`, or `department`
|
|
97
|
+
- `event_category` (optional): filter by `task`, `admin`, or `system`
|
|
98
|
+
- Paginated with `limit` (max 50) and `cursor`
|
|
99
|
+
|
|
100
|
+
## Agent Discovery
|
|
101
|
+
|
|
102
|
+
Use `writbase:discover_agents` to list agents with access to a project:
|
|
103
|
+
|
|
104
|
+
- `project` (required): the project slug
|
|
105
|
+
- `skill` (optional): filter agents by declared skill/capability
|
|
106
|
+
|
|
107
|
+
## Example: Full Agent Provisioning
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
# Step 1: Create a worker key
|
|
111
|
+
writbase:manage_agent_keys {
|
|
112
|
+
"action": "create",
|
|
113
|
+
"name": "deploy-bot",
|
|
114
|
+
"special_prompt": "You handle deployment tasks. Mark tasks done only after verifying the deployment succeeded."
|
|
115
|
+
}
|
|
116
|
+
# Response includes full_key: "wb_<key_id>_<secret>" -- store this securely
|
|
117
|
+
|
|
118
|
+
# Step 2: Grant permissions (use project_id UUID from writbase:info)
|
|
119
|
+
writbase:manage_agent_permissions {
|
|
120
|
+
"action": "grant",
|
|
121
|
+
"key_id": "<key_id from step 1>",
|
|
122
|
+
"permissions": [
|
|
123
|
+
{
|
|
124
|
+
"project_id": "<project-uuid>",
|
|
125
|
+
"department_id": "<ops-dept-uuid>",
|
|
126
|
+
"can_read": true,
|
|
127
|
+
"can_create": true,
|
|
128
|
+
"can_update": true
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Step 3: Verify the agent appears
|
|
134
|
+
writbase:discover_agents { "project": "my-project" }
|
|
135
|
+
# Confirm "deploy-bot" is listed with expected permissions
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
See [agent-provisioning.md](references/agent-provisioning.md) for more provisioning patterns including cross-department and delegation setups.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Agent Provisioning Guides
|
|
2
|
+
|
|
3
|
+
Step-by-step guides for common agent provisioning patterns. All examples assume you are connected as a manager-role agent.
|
|
4
|
+
|
|
5
|
+
Before provisioning, call `writbase:info` to get your project and department UUIDs from the `permissions.scopes` array.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Single-Project Worker
|
|
10
|
+
|
|
11
|
+
A worker that can read, create, and update tasks in one project.
|
|
12
|
+
|
|
13
|
+
### Step 1: Create the agent key
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
writbase:manage_agent_keys {
|
|
17
|
+
"action": "create",
|
|
18
|
+
"name": "build-agent",
|
|
19
|
+
"special_prompt": "You handle build and CI tasks. Always include build logs in task notes when marking done."
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Response:
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"key_id": "a1b2c3d4-...",
|
|
27
|
+
"full_key": "wb_a1b2c3d4-..._secrethere",
|
|
28
|
+
"name": "build-agent",
|
|
29
|
+
"role": "worker",
|
|
30
|
+
"is_active": true,
|
|
31
|
+
"warning": "Store this key securely. It will NOT be shown again."
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Step 2: Grant permissions
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
writbase:manage_agent_permissions {
|
|
39
|
+
"action": "grant",
|
|
40
|
+
"key_id": "a1b2c3d4-...",
|
|
41
|
+
"permissions": [
|
|
42
|
+
{
|
|
43
|
+
"project_id": "<your-project-uuid>",
|
|
44
|
+
"can_read": true,
|
|
45
|
+
"can_create": true,
|
|
46
|
+
"can_update": true
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This grants project-wide access (no department restriction) with read, create, and update.
|
|
53
|
+
|
|
54
|
+
### Step 3: Verify
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
writbase:discover_agents { "project": "my-project" }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Confirm "build-agent" appears in the results with the expected permissions.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. Cross-Department Agent
|
|
65
|
+
|
|
66
|
+
An agent that operates across multiple departments with different permission levels.
|
|
67
|
+
|
|
68
|
+
### Step 1: Create the agent key
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
writbase:manage_agent_keys {
|
|
72
|
+
"action": "create",
|
|
73
|
+
"name": "triage-agent",
|
|
74
|
+
"special_prompt": "You triage incoming tasks: read from intake, create in the appropriate department."
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 2: Grant separate permission rows per department
|
|
79
|
+
|
|
80
|
+
Each department needs its own permission row. Rows are evaluated independently.
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
writbase:manage_agent_permissions {
|
|
84
|
+
"action": "grant",
|
|
85
|
+
"key_id": "<triage-agent-key-id>",
|
|
86
|
+
"permissions": [
|
|
87
|
+
{
|
|
88
|
+
"project_id": "<project-uuid>",
|
|
89
|
+
"department_id": "<intake-dept-uuid>",
|
|
90
|
+
"can_read": true,
|
|
91
|
+
"can_update": true
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"project_id": "<project-uuid>",
|
|
95
|
+
"department_id": "<engineering-dept-uuid>",
|
|
96
|
+
"can_read": true,
|
|
97
|
+
"can_create": true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"project_id": "<project-uuid>",
|
|
101
|
+
"department_id": "<design-dept-uuid>",
|
|
102
|
+
"can_read": true,
|
|
103
|
+
"can_create": true
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This agent can:
|
|
110
|
+
- Read and update tasks in the "intake" department (move them through triage statuses)
|
|
111
|
+
- Read tasks and create new tasks in "engineering" and "design" departments
|
|
112
|
+
- Cannot update tasks in engineering/design (intentional -- triage only creates, doesn't modify)
|
|
113
|
+
|
|
114
|
+
### Step 3: Verify
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
writbase:manage_agent_permissions {
|
|
118
|
+
"action": "list",
|
|
119
|
+
"key_id": "<triage-agent-key-id>"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Confirm all three permission rows are present with correct flags.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 3. Delegation Setup
|
|
128
|
+
|
|
129
|
+
An agent that can assign tasks to other agents. This requires `can_assign` permission and an understanding of delegation constraints.
|
|
130
|
+
|
|
131
|
+
### Step 1: Create the coordinating agent
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
writbase:manage_agent_keys {
|
|
135
|
+
"action": "create",
|
|
136
|
+
"name": "coordinator-agent",
|
|
137
|
+
"special_prompt": "You coordinate work across the team. Assign tasks to the most appropriate agent based on their skills."
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Step 2: Grant permissions with `can_assign`
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
writbase:manage_agent_permissions {
|
|
145
|
+
"action": "grant",
|
|
146
|
+
"key_id": "<coordinator-key-id>",
|
|
147
|
+
"permissions": [
|
|
148
|
+
{
|
|
149
|
+
"project_id": "<project-uuid>",
|
|
150
|
+
"can_read": true,
|
|
151
|
+
"can_create": true,
|
|
152
|
+
"can_update": true,
|
|
153
|
+
"can_assign": true
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Step 3: Create worker agents that can be assigned to
|
|
160
|
+
|
|
161
|
+
The workers do not need `can_assign` themselves -- they just need permissions in the same project.
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
writbase:manage_agent_keys {
|
|
165
|
+
"action": "create",
|
|
166
|
+
"name": "frontend-agent"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
writbase:manage_agent_permissions {
|
|
170
|
+
"action": "grant",
|
|
171
|
+
"key_id": "<frontend-agent-key-id>",
|
|
172
|
+
"permissions": [
|
|
173
|
+
{
|
|
174
|
+
"project_id": "<project-uuid>",
|
|
175
|
+
"department_id": "<frontend-dept-uuid>",
|
|
176
|
+
"can_read": true,
|
|
177
|
+
"can_update": true
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Delegation constraints
|
|
184
|
+
|
|
185
|
+
WritBase enforces two safety mechanisms on task assignment:
|
|
186
|
+
|
|
187
|
+
**`delegation_depth` (max 3)**: Each time a task is reassigned, the depth increments. After 3 reassignments, further delegation is blocked with `delegation_depth_exceeded`. The agent must either complete the task directly or create a new task.
|
|
188
|
+
|
|
189
|
+
**`assignment_chain` (cycle detection)**: The database tracks every agent key ID that has been assigned the task. If an agent appears in the chain already, `circular_delegation` is returned. This prevents A -> B -> A loops.
|
|
190
|
+
|
|
191
|
+
### How the coordinator assigns work
|
|
192
|
+
|
|
193
|
+
Once provisioned, the coordinator uses `writbase:update_task` with the `assign_to` param:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
writbase:update_task {
|
|
197
|
+
"task_id": "<task-uuid>",
|
|
198
|
+
"version": 2,
|
|
199
|
+
"assign_to": "frontend-agent"
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The `assign_to` field accepts either the agent's name or key ID.
|
|
204
|
+
|
|
205
|
+
To unassign a task (return it to the pool), pass an empty string:
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
writbase:update_task {
|
|
209
|
+
"task_id": "<task-uuid>",
|
|
210
|
+
"version": 3,
|
|
211
|
+
"assign_to": ""
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 4. Comment-Only Observer
|
|
218
|
+
|
|
219
|
+
An agent that can monitor and report on tasks but cannot change their scope.
|
|
220
|
+
|
|
221
|
+
### Step 1: Create the key
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
writbase:manage_agent_keys {
|
|
225
|
+
"action": "create",
|
|
226
|
+
"name": "status-reporter",
|
|
227
|
+
"special_prompt": "You monitor task progress and add status notes. Do not change task priorities or descriptions."
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Step 2: Grant `can_read` + `can_comment`
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
writbase:manage_agent_permissions {
|
|
235
|
+
"action": "grant",
|
|
236
|
+
"key_id": "<reporter-key-id>",
|
|
237
|
+
"permissions": [
|
|
238
|
+
{
|
|
239
|
+
"project_id": "<project-uuid>",
|
|
240
|
+
"can_read": true,
|
|
241
|
+
"can_comment": true
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This agent can:
|
|
248
|
+
- Read all tasks in the project
|
|
249
|
+
- Change `status` (e.g., mark tasks `in_progress` or `done`)
|
|
250
|
+
- Add/update `notes`
|
|
251
|
+
- Cannot change `priority`, `description`, `department`, `due_date`, or `assign_to`
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# WritBase Permission Model
|
|
2
|
+
|
|
3
|
+
## Permission Grant Structure
|
|
4
|
+
|
|
5
|
+
Each permission row contains:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"project_id": "<uuid>",
|
|
10
|
+
"department_id": "<uuid or null>",
|
|
11
|
+
"can_read": false,
|
|
12
|
+
"can_create": false,
|
|
13
|
+
"can_update": false,
|
|
14
|
+
"can_assign": false,
|
|
15
|
+
"can_comment": false,
|
|
16
|
+
"can_archive": false
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- `project_id` is always required
|
|
21
|
+
- `department_id` is optional -- when null, the permission applies project-wide
|
|
22
|
+
- All boolean flags default to `false` if omitted
|
|
23
|
+
|
|
24
|
+
## Dominance Check Rules
|
|
25
|
+
|
|
26
|
+
When a manager grants permissions to another agent, the system verifies that the manager's own permissions are a superset. This is the **dominance check**.
|
|
27
|
+
|
|
28
|
+
### Key principle: single-row dominance
|
|
29
|
+
|
|
30
|
+
A single row of the manager's permissions must fully cover each granted row. Permissions are **never combined across the manager's rows**.
|
|
31
|
+
|
|
32
|
+
### Rules evaluated per granted row:
|
|
33
|
+
|
|
34
|
+
1. **Same project**: The manager must have a permission row for the same `project_id`
|
|
35
|
+
2. **Department coverage**: The manager's row must have `department_id = null` (project-wide) or the same `department_id` as the granted row
|
|
36
|
+
3. **Action superset**: Every `true` flag in the granted row must also be `true` in the manager's covering row
|
|
37
|
+
|
|
38
|
+
### Examples
|
|
39
|
+
|
|
40
|
+
**Manager has:**
|
|
41
|
+
```
|
|
42
|
+
Row A: { project_id: "P1", department_id: null, can_read: true, can_create: true, can_update: true }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Granting to worker:**
|
|
46
|
+
```
|
|
47
|
+
CORRECT: { project_id: "P1", department_id: "D1", can_read: true, can_create: true }
|
|
48
|
+
-- Row A covers this (project-wide includes all departments, read+create are both true)
|
|
49
|
+
|
|
50
|
+
WRONG: { project_id: "P1", department_id: "D1", can_read: true, can_assign: true }
|
|
51
|
+
-- Row A does not have can_assign, so dominance check fails
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Manager has two rows:**
|
|
55
|
+
```
|
|
56
|
+
Row A: { project_id: "P1", department_id: "D1", can_read: true, can_create: true }
|
|
57
|
+
Row B: { project_id: "P1", department_id: "D2", can_read: true, can_update: true }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Granting to worker:**
|
|
61
|
+
```
|
|
62
|
+
WRONG: { project_id: "P1", department_id: "D1", can_read: true, can_update: true }
|
|
63
|
+
-- Row A has D1 but no can_update. Row B has can_update but is scoped to D2.
|
|
64
|
+
-- No single row covers both D1 + can_update. Dominance check fails.
|
|
65
|
+
|
|
66
|
+
CORRECT: { project_id: "P1", department_id: "D1", can_read: true, can_create: true }
|
|
67
|
+
-- Row A covers this entirely.
|
|
68
|
+
|
|
69
|
+
CORRECT: { project_id: "P1", department_id: "D2", can_read: true, can_update: true }
|
|
70
|
+
-- Row B covers this entirely.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## `can_comment` as Restricted Update
|
|
74
|
+
|
|
75
|
+
`can_comment` is intentionally separate from `can_update`. An agent with only `can_comment`:
|
|
76
|
+
|
|
77
|
+
- **Can change**: `notes`, `status`
|
|
78
|
+
- **Cannot change**: `priority`, `description`, `department`, `due_date`, `assign_to`
|
|
79
|
+
|
|
80
|
+
Use `can_comment` for agents that should report progress (e.g., set status to `done` and add completion notes) but should not modify task scope or reassign work.
|
|
81
|
+
|
|
82
|
+
An agent with `can_update` can change all task fields (except assignment, which requires `can_assign`).
|
|
83
|
+
|
|
84
|
+
## Department Scoping Per Action
|
|
85
|
+
|
|
86
|
+
### `writbase:add_task`
|
|
87
|
+
|
|
88
|
+
- With `department` param: checks `can_create` for that specific department
|
|
89
|
+
- Without `department` param: requires project-wide `can_create` (a permission row with `department_id = null`)
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
WRONG setup: Agent has can_create only for department "eng"
|
|
93
|
+
writbase:add_task { "project": "my-project", "description": "New task" }
|
|
94
|
+
-- Fails: no project-wide can_create
|
|
95
|
+
|
|
96
|
+
CORRECT: Either specify the department:
|
|
97
|
+
writbase:add_task { "project": "my-project", "department": "eng", "description": "New task" }
|
|
98
|
+
|
|
99
|
+
Or grant project-wide can_create:
|
|
100
|
+
{ "project_id": "P1", "department_id": null, "can_create": true }
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `writbase:update_task`
|
|
104
|
+
|
|
105
|
+
Permission is checked against the task's **current** department, not the new department being set:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
Task is currently in department "eng".
|
|
109
|
+
Agent has can_update for department "eng" only.
|
|
110
|
+
|
|
111
|
+
CORRECT: writbase:update_task { "task_id": "...", "version": 3, "department": "ops" }
|
|
112
|
+
-- Allowed because the agent has can_update for the task's current department ("eng")
|
|
113
|
+
|
|
114
|
+
If the task were in department "ops", the same agent could NOT update it,
|
|
115
|
+
even though they are trying to move it to "eng" where they have permissions.
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Common Permission Mistakes
|
|
119
|
+
|
|
120
|
+
### Mistake: Granting more than you have
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Manager has: { can_read: true, can_create: true }
|
|
124
|
+
Tries to grant: { can_read: true, can_create: true, can_update: true }
|
|
125
|
+
Result: insufficient_manager_scope error
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Mistake: Assuming rows combine
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Manager has:
|
|
132
|
+
Row 1: { project_id: "P1", can_read: true }
|
|
133
|
+
Row 2: { project_id: "P1", can_create: true }
|
|
134
|
+
|
|
135
|
+
Tries to grant: { project_id: "P1", can_read: true, can_create: true }
|
|
136
|
+
Result: insufficient_manager_scope error
|
|
137
|
+
-- Neither row alone covers both can_read AND can_create
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Mistake: Department mismatch
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
Manager has: { project_id: "P1", department_id: "D1", can_read: true, can_create: true }
|
|
144
|
+
Tries to grant: { project_id: "P1", department_id: "D2", can_read: true }
|
|
145
|
+
Result: insufficient_manager_scope error
|
|
146
|
+
-- Manager's row is scoped to D1, cannot cover a grant for D2
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Correct: Project-wide covers all departments
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
Manager has: { project_id: "P1", department_id: null, can_read: true, can_create: true }
|
|
153
|
+
Tries to grant: { project_id: "P1", department_id: "D2", can_read: true }
|
|
154
|
+
Result: Success
|
|
155
|
+
-- department_id: null means project-wide, which covers any specific department
|
|
156
|
+
```
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worker
|
|
3
|
+
description: Patterns for working with WritBase task management MCP tools (writbase:info, writbase:get_tasks, writbase:get_top_tasks, writbase:add_task, writbase:update_task). Use when connected to a WritBase MCP server.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# WritBase Worker Patterns
|
|
7
|
+
|
|
8
|
+
## Session Start
|
|
9
|
+
|
|
10
|
+
Always begin a session by calling `writbase:info`. This returns:
|
|
11
|
+
|
|
12
|
+
- Your agent name, role, home project, and home department
|
|
13
|
+
- Your permission scopes (which projects/departments you can access and what actions are allowed)
|
|
14
|
+
- A `special_prompt` field with workspace-specific instructions -- follow these if present
|
|
15
|
+
|
|
16
|
+
Do not skip this step. Your permissions determine which tools will succeed.
|
|
17
|
+
|
|
18
|
+
## Tool Selection
|
|
19
|
+
|
|
20
|
+
| Goal | Tool | Notes |
|
|
21
|
+
|------|------|-------|
|
|
22
|
+
| "What should I work on?" | `writbase:get_top_tasks` | Priority-sorted, excludes done/cancelled/failed/blocked by default, max 25 (default 10) |
|
|
23
|
+
| Browse/filter/search tasks | `writbase:get_tasks` | Supports status, priority, department, search, date filters, pagination |
|
|
24
|
+
| Create a task | `writbase:add_task` | Requires `can_create` permission |
|
|
25
|
+
| Update a task | `writbase:update_task` | Requires `can_update` or `can_comment` permission |
|
|
26
|
+
|
|
27
|
+
## Compact vs Verbose Shape
|
|
28
|
+
|
|
29
|
+
By default, task queries return a compact 9-field shape:
|
|
30
|
+
|
|
31
|
+
`id`, `version`, `status`, `priority`, `description`, `due_date`, `department`, `created_at`, `updated_at`
|
|
32
|
+
|
|
33
|
+
Set `verbose: true` only when you need additional fields: `notes`, `assigned_to_agent_key_id`, `requested_by_agent_key_id`, `delegation_depth`, `assignment_chain`, `project_id`, `is_archived`, or full audit metadata.
|
|
34
|
+
|
|
35
|
+
## Version Conflict Handling
|
|
36
|
+
|
|
37
|
+
`writbase:update_task` uses optimistic concurrency. You must pass the `version` number from your last fetch:
|
|
38
|
+
|
|
39
|
+
1. Fetch the task (via `writbase:get_tasks` or `writbase:get_top_tasks`)
|
|
40
|
+
2. Pass the returned `version` value when calling `writbase:update_task`
|
|
41
|
+
3. On `version_conflict` error, re-fetch the task and retry with the `current_version` from the error response
|
|
42
|
+
4. Retry up to 3 times before reporting a conflict to the user
|
|
43
|
+
|
|
44
|
+
## Validation Rules
|
|
45
|
+
|
|
46
|
+
- `description`: minimum 3 characters
|
|
47
|
+
- `priority`: one of `low`, `medium`, `high`, `critical`
|
|
48
|
+
- `status`: one of `todo`, `in_progress`, `blocked`, `done`, `cancelled`, `failed`
|
|
49
|
+
- `due_date`: valid ISO 8601 string (`YYYY-MM-DD` or `YYYY-MM-DDThh:mm:ssZ`)
|
|
50
|
+
|
|
51
|
+
## Department Scoping
|
|
52
|
+
|
|
53
|
+
- `writbase:add_task` without a `department` param requires project-wide `can_create` (a permission row with `department_id` = null)
|
|
54
|
+
- `writbase:update_task` checks permissions against the task's current department, not the new one
|
|
55
|
+
- With only `can_comment` permission: you can change `notes` and `status` only -- changes to `priority`, `description`, `department`, `due_date`, or `assign_to` are rejected
|
|
56
|
+
|
|
57
|
+
## Error Recovery Quick Reference
|
|
58
|
+
|
|
59
|
+
| Error | Action |
|
|
60
|
+
|-------|--------|
|
|
61
|
+
| `version_conflict` | Re-fetch the task, retry with `current_version` from the error |
|
|
62
|
+
| `rate_limited` | Wait `retry_after` seconds, then retry |
|
|
63
|
+
| `scope_not_allowed` | Check your permissions with `writbase:info` |
|
|
64
|
+
| `invalid_assignee` | Verify the agent name or key ID is correct and active |
|
|
65
|
+
| `validation_error` | Read the `fields` object for per-field error messages |
|
|
66
|
+
| `task_not_found` | Verify the task ID and your read access |
|
|
67
|
+
|
|
68
|
+
See [error-handling.md](references/error-handling.md) for the full error code reference.
|
|
69
|
+
|
|
70
|
+
## Example Workflows
|
|
71
|
+
|
|
72
|
+
### 1. Session start, pick up work, complete a task
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
# Step 1: Learn your context
|
|
76
|
+
writbase:info {}
|
|
77
|
+
|
|
78
|
+
# Step 2: Find top priority work
|
|
79
|
+
writbase:get_top_tasks { "project": "my-project" }
|
|
80
|
+
|
|
81
|
+
# Step 3: Mark a task in progress (use version from step 2)
|
|
82
|
+
writbase:update_task {
|
|
83
|
+
"task_id": "abc-123",
|
|
84
|
+
"version": 4,
|
|
85
|
+
"status": "in_progress"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# Step 4: Complete the task after doing the work
|
|
89
|
+
writbase:update_task {
|
|
90
|
+
"task_id": "abc-123",
|
|
91
|
+
"version": 5,
|
|
92
|
+
"status": "done",
|
|
93
|
+
"notes": "Implemented the feature and verified tests pass."
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 2. Adding a task with department
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
writbase:add_task {
|
|
101
|
+
"project": "my-project",
|
|
102
|
+
"department": "engineering",
|
|
103
|
+
"description": "Add rate limiting to the /api/upload endpoint",
|
|
104
|
+
"priority": "high",
|
|
105
|
+
"due_date": "2026-03-20"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 3. Version conflict retry pattern
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
# First attempt -- fails because another agent updated the task
|
|
113
|
+
writbase:update_task {
|
|
114
|
+
"task_id": "abc-123",
|
|
115
|
+
"version": 4,
|
|
116
|
+
"status": "done"
|
|
117
|
+
}
|
|
118
|
+
# Error: { "code": "version_conflict", "current_version": 5 }
|
|
119
|
+
|
|
120
|
+
# Re-fetch to see what changed
|
|
121
|
+
writbase:get_tasks { "project": "my-project", "search": "abc-123" }
|
|
122
|
+
# Returns task with version: 5
|
|
123
|
+
|
|
124
|
+
# Retry with correct version
|
|
125
|
+
writbase:update_task {
|
|
126
|
+
"task_id": "abc-123",
|
|
127
|
+
"version": 5,
|
|
128
|
+
"status": "done"
|
|
129
|
+
}
|
|
130
|
+
```
|