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.
@@ -0,0 +1,201 @@
1
+ # WritBase Error Code Reference
2
+
3
+ All WritBase MCP tool errors return a JSON object with the following shape:
4
+
5
+ ```json
6
+ {
7
+ "code": "error_code_string",
8
+ "message": "Human-readable description",
9
+ "recovery": "Suggested recovery action",
10
+ "fields": {},
11
+ "current_version": null,
12
+ "retry_after": null
13
+ }
14
+ ```
15
+
16
+ Optional fields (`fields`, `current_version`, `retry_after`) are present only for specific error codes.
17
+
18
+ ---
19
+
20
+ ## Authentication Errors
21
+
22
+ ### `unauthorized_agent_key`
23
+
24
+ - **Message**: Invalid or missing agent key.
25
+ - **Recovery**: Provide a valid agent key in the Authorization header as `Bearer wb_<key_id>_<secret>`.
26
+ - **Notes**: This is a transport-level error. If you see this, your MCP connection is misconfigured.
27
+
28
+ ### `inactive_agent_key`
29
+
30
+ - **Message**: This agent key has been deactivated.
31
+ - **Recovery**: Contact an admin to reactivate the key or provision a new one.
32
+ - **Notes**: Keys pending human approval also return this error until activated.
33
+
34
+ ---
35
+
36
+ ## Permission Errors
37
+
38
+ ### `scope_not_allowed`
39
+
40
+ - **Message**: Agent does not have "{action}" permission for project "{project}".
41
+ - **Recovery**: Request the needed permission from an admin via the dashboard.
42
+ - **Notes**: Call `writbase:info` to see your current permission scopes.
43
+
44
+ ### `update_not_allowed`
45
+
46
+ - **Message**: Update not allowed: {reason}.
47
+ - **Recovery**: Check agent permissions and task ownership rules.
48
+ - **Notes**: Returned when permission exists but the specific update is blocked (e.g., `can_comment` agent trying to change priority).
49
+
50
+ ### `insufficient_manager_scope`
51
+
52
+ - **Message**: This action requires manager role.
53
+ - **Recovery**: Use a manager-level agent key to perform this action.
54
+ - **Notes**: Manager tools (`writbase:manage_agent_keys`, `writbase:manage_agent_permissions`, etc.) require `role: "manager"`.
55
+
56
+ ### `self_modification_denied`
57
+
58
+ - **Message**: An agent cannot modify its own key.
59
+ - **Recovery**: Ask a different agent or a human admin to make this change.
60
+ - **Notes**: Applies to `writbase:manage_agent_keys` update/deactivate/rotate and `writbase:manage_agent_permissions` grant/revoke on your own key ID.
61
+
62
+ ### `assign_not_allowed`
63
+
64
+ - **Message**: Agent does not have "assign" permission for project "{project}".
65
+ - **Recovery**: Request the `can_assign` permission from an admin via the dashboard.
66
+ - **Notes**: Separate from `can_update`. You need `can_assign` specifically to use the `assign_to` field.
67
+
68
+ ---
69
+
70
+ ## Resource Errors
71
+
72
+ ### `invalid_project`
73
+
74
+ - **Message**: Project "{slug}" does not exist or is archived.
75
+ - **Recovery**: Verify the project slug and ensure it is not archived.
76
+ - **Notes**: Check `writbase:info` output for your list of valid projects.
77
+
78
+ ### `invalid_department`
79
+
80
+ - **Message**: Department "{slug}" does not exist or is archived.
81
+ - **Recovery**: Verify the department slug and ensure it is not archived.
82
+ - **Notes**: Department slugs are scoped to a project. Check `writbase:info` for valid departments.
83
+
84
+ ### `task_not_found`
85
+
86
+ - **Message**: Task "{id}" was not found.
87
+ - **Recovery**: Verify the task ID is correct and that you have read access to its project.
88
+ - **Notes**: Could mean the task does not exist, or you lack `can_read` for its project/department.
89
+
90
+ ### `invalid_assignee`
91
+
92
+ - **Message**: Agent "{name}" does not exist, is inactive, or has no permissions in this project.
93
+ - **Recovery**: Verify the agent key ID or name is correct and the agent is active with project access.
94
+ - **Notes**: The target agent must be active and have at least one permission row in the task's project.
95
+
96
+ ---
97
+
98
+ ## Delegation Errors
99
+
100
+ ### `circular_delegation`
101
+
102
+ - **Message**: This agent has already been in the delegation chain for this task.
103
+ - **Recovery**: Assign the task to a different agent that has not previously handled it.
104
+ - **Notes**: WritBase tracks the `assignment_chain` (array of agent key IDs) and prevents cycles.
105
+
106
+ ### `delegation_depth_exceeded`
107
+
108
+ - **Message**: Maximum delegation depth (3) reached for this task.
109
+ - **Recovery**: This task has been reassigned too many times. Complete it directly or create a new task.
110
+ - **Notes**: The `delegation_depth` field on the task tracks the number of reassignments. Database CHECK constraint enforces max 3.
111
+
112
+ ---
113
+
114
+ ## Validation and Rate Limiting
115
+
116
+ ### `validation_error`
117
+
118
+ - **Message**: One or more fields failed validation.
119
+ - **Recovery**: Fix the listed fields and retry.
120
+ - **Extra fields**: `fields` -- an object mapping field names to error descriptions.
121
+
122
+ **Example error response:**
123
+
124
+ ```json
125
+ {
126
+ "code": "validation_error",
127
+ "message": "One or more fields failed validation.",
128
+ "recovery": "Fix the listed fields and retry.",
129
+ "fields": {
130
+ "description": "Description must be at least 3 characters.",
131
+ "priority": "Priority must be one of: low, medium, high, critical."
132
+ }
133
+ }
134
+ ```
135
+
136
+ **Common mistakes:**
137
+
138
+ ```
139
+ WRONG: { "description": "AB" }
140
+ RIGHT: { "description": "Fix the login bug" }
141
+
142
+ WRONG: { "priority": "urgent" }
143
+ RIGHT: { "priority": "critical" }
144
+
145
+ WRONG: { "due_date": "March 20, 2026" }
146
+ RIGHT: { "due_date": "2026-03-20" }
147
+
148
+ WRONG: { "status": "complete" }
149
+ RIGHT: { "status": "done" }
150
+ ```
151
+
152
+ ### `version_conflict`
153
+
154
+ - **Message**: The task was modified since you last read it.
155
+ - **Recovery**: Re-fetch the task to get the current version, then retry your update with the new version number.
156
+ - **Extra fields**: `current_version` -- the current version number of the task.
157
+
158
+ **Example error response:**
159
+
160
+ ```json
161
+ {
162
+ "code": "version_conflict",
163
+ "message": "The task was modified since you last read it.",
164
+ "recovery": "Re-fetch the task to get the current version, then retry your update with the new version number.",
165
+ "current_version": 7
166
+ }
167
+ ```
168
+
169
+ **Retry pattern:**
170
+
171
+ ```
172
+ # Attempt 1: update with stale version
173
+ writbase:update_task { "task_id": "abc-123", "version": 5, "status": "done" }
174
+ # Error: version_conflict, current_version: 7
175
+
176
+ # Attempt 2: re-fetch, then retry with fresh version
177
+ writbase:get_tasks { "project": "my-project", "search": "abc-123" }
178
+ # Returns version: 7
179
+ writbase:update_task { "task_id": "abc-123", "version": 7, "status": "done" }
180
+ ```
181
+
182
+ If the conflict persists after 3 retries, report it -- another agent may be actively modifying the same task.
183
+
184
+ ### `rate_limited`
185
+
186
+ - **Message**: Rate limit exceeded.
187
+ - **Recovery**: Wait and retry after the indicated time.
188
+ - **Extra fields**: `retry_after` -- number of seconds to wait before retrying.
189
+
190
+ **Example error response:**
191
+
192
+ ```json
193
+ {
194
+ "code": "rate_limited",
195
+ "message": "Rate limit exceeded.",
196
+ "recovery": "Wait and retry after the indicated time.",
197
+ "retry_after": 30
198
+ }
199
+ ```
200
+
201
+ Wait the full `retry_after` duration before your next request. Do not retry immediately.