@shardworks/guild-starter-kit 0.1.16 → 0.1.17
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.
|
@@ -71,16 +71,21 @@ Tools that animas wield during work. Each tool ships with instructions delivered
|
|
|
71
71
|
- **dispatch** — post and dispatch commissions
|
|
72
72
|
- **instantiate** — create new animas with assigned training and roles
|
|
73
73
|
- **nexus-version** — report the installed Nexus framework version
|
|
74
|
+
- **signal** — signal a custom guild event for the Clockworks
|
|
74
75
|
|
|
75
76
|
### Engines
|
|
76
77
|
|
|
77
|
-
Automated mechanical processes with no AI involvement.
|
|
78
|
+
Automated mechanical processes with no AI involvement. Two kinds:
|
|
79
|
+
|
|
80
|
+
**Static engines** — bespoke APIs called by framework code. Not triggerable by standing orders.
|
|
78
81
|
|
|
79
82
|
- **manifest** — composes anima instructions from codex, training, and tool instructions at session start
|
|
80
83
|
- **mcp-server** — runs the MCP server that exposes tools to animas during sessions
|
|
81
84
|
- **worktree-setup** — creates and manages git worktrees for commissions
|
|
82
85
|
- **ledger-migrate** — applies database migrations to the Ledger
|
|
83
86
|
|
|
87
|
+
**Clockwork engines** — purpose-built to respond to events via standing orders. Use the `engine()` SDK factory from `@shardworks/nexus-core`. The Clockworks runner calls them automatically when matching events fire.
|
|
88
|
+
|
|
84
89
|
## The Codex
|
|
85
90
|
|
|
86
91
|
The guild's institutional body of policy and procedure — the employee handbook. Lives in `codex/` in the guildhall. Every anima receives the codex when manifested. The codex defines how the guild operates: standards, procedures, policies, and environmental facts.
|
|
@@ -89,7 +94,139 @@ Role-specific codex entries live in `codex/roles/` and are delivered only to ani
|
|
|
89
94
|
|
|
90
95
|
## The Ledger
|
|
91
96
|
|
|
92
|
-
The guild's operational database (SQLite). Holds anima records, roster, commission history, compositions, and the audit trail. Lives at `.nexus/nexus.db` in the guildhall. Managed by the ledger-migrate engine.
|
|
97
|
+
The guild's operational database (SQLite). Holds anima records, roster, commission history, compositions, events, and the audit trail. Lives at `.nexus/nexus.db` in the guildhall. Managed by the ledger-migrate engine.
|
|
98
|
+
|
|
99
|
+
## The Clockworks
|
|
100
|
+
|
|
101
|
+
The Clockworks is the guild's event-driven nervous system — it connects things that happen to things that should happen in response. It turns the guild from a purely imperative system into a reactive one.
|
|
102
|
+
|
|
103
|
+
### Events
|
|
104
|
+
|
|
105
|
+
An event is an immutable fact: *this happened*. Events are recorded in the Ledger and processed by the Clockworks runner.
|
|
106
|
+
|
|
107
|
+
Two kinds:
|
|
108
|
+
|
|
109
|
+
- **Framework events** — signaled automatically by the system (`commission.sealed`, `tool.installed`, `anima.instantiated`, etc.). Animas cannot signal these.
|
|
110
|
+
- **Custom events** — declared by the guild in `guild.json` under `clockworks.events`. Animas signal these using the `signal` tool.
|
|
111
|
+
|
|
112
|
+
### Standing Orders
|
|
113
|
+
|
|
114
|
+
A standing order is a registered response to an event — guild policy that says "when X happens, do Y." Standing orders live in `guild.json` under `clockworks.standingOrders`.
|
|
115
|
+
|
|
116
|
+
Three verbs:
|
|
117
|
+
|
|
118
|
+
| Verb | What it does |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| **`run`** | Invokes a clockwork engine. No AI involved — deterministic automation. |
|
|
121
|
+
| **`summon`** | Manifests an anima (by role) and delivers the event as urgent context. The anima is expected to act. |
|
|
122
|
+
| **`brief`** | Manifests an anima (by role) and delivers the event as informational context. The anima decides whether to act. |
|
|
123
|
+
|
|
124
|
+
Standing orders target **roles**, not named animas — durable across anima turnover.
|
|
125
|
+
|
|
126
|
+
Example `guild.json` configuration:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"clockworks": {
|
|
131
|
+
"events": {
|
|
132
|
+
"code.reviewed": {
|
|
133
|
+
"description": "Signaled when an artificer completes a code review"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"standingOrders": [
|
|
137
|
+
{ "on": "commission.sealed", "run": "cleanup-worktree" },
|
|
138
|
+
{ "on": "commission.failed", "summon": "advisor" },
|
|
139
|
+
{ "on": "code.reviewed", "brief": "guildmaster" }
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Signaling Events
|
|
146
|
+
|
|
147
|
+
Use the **signal** tool to signal custom events:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
signal({ name: "code.reviewed", payload: { pr: 42, issues_found: 0 } })
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The event name must be declared in `guild.json clockworks.events`. Framework namespaces (`anima.*`, `commission.*`, `tool.*`, `migration.*`, `guild.*`, `standing-order.*`) are reserved.
|
|
154
|
+
|
|
155
|
+
### Processing Events
|
|
156
|
+
|
|
157
|
+
Events are not processed automatically. The operator controls when the Clockworks runs:
|
|
158
|
+
|
|
159
|
+
| Command | What it does |
|
|
160
|
+
|---------|-------------|
|
|
161
|
+
| `nsg clock list` | Show all pending (unprocessed) events |
|
|
162
|
+
| `nsg clock tick [id]` | Process the next pending event, or a specific one by id |
|
|
163
|
+
| `nsg clock run` | Process all pending events until the queue is empty |
|
|
164
|
+
|
|
165
|
+
### Error Handling
|
|
166
|
+
|
|
167
|
+
When a standing order fails, the system signals a `standing-order.failed` event. Guilds can respond to this with their own standing orders. A loop guard prevents cascading failures.
|
|
168
|
+
|
|
169
|
+
### Hello World Walkthrough
|
|
170
|
+
|
|
171
|
+
To test the Clockworks from scratch:
|
|
172
|
+
|
|
173
|
+
**1. Declare a custom event** in `guild.json`:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"clockworks": {
|
|
178
|
+
"events": {
|
|
179
|
+
"hello.world": {
|
|
180
|
+
"description": "A test event for verifying the Clockworks"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"standingOrders": []
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**2. Signal the event:**
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
nsg signal hello.world --payload '{"message": "greetings from the Clockworks"}'
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**3. Check the queue:**
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
nsg clock list
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
You should see the pending event with its id, name, payload, and timestamp.
|
|
201
|
+
|
|
202
|
+
**4. Process it:**
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
nsg clock tick
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Since there are no standing orders, the event is marked as processed with no dispatches.
|
|
209
|
+
|
|
210
|
+
**5. Add a standing order** to `guild.json`:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"clockworks": {
|
|
215
|
+
"standingOrders": [
|
|
216
|
+
{ "on": "hello.world", "brief": "advisor" }
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**6. Signal again and process:**
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
nsg signal hello.world
|
|
226
|
+
nsg clock tick
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The Clockworks matches the event to the standing order and dispatches it — the advisor is briefed.
|
|
93
230
|
|
|
94
231
|
## Training
|
|
95
232
|
|
|
@@ -117,3 +254,7 @@ The primary interface is the `nsg` command:
|
|
|
117
254
|
| `nsg anima manifest <name>` | Generate an anima's full instructions |
|
|
118
255
|
| `nsg status` | Show guild status |
|
|
119
256
|
| `nsg consult <name>` | Consult a standing anima (e.g., the advisor) |
|
|
257
|
+
| `nsg signal <name>` | Signal a custom guild event |
|
|
258
|
+
| `nsg clock list` | Show pending events |
|
|
259
|
+
| `nsg clock tick [id]` | Process next pending event (or specific id) |
|
|
260
|
+
| `nsg clock run` | Process all pending events |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- Clockworks tables: event log and dispatch tracking.
|
|
2
|
+
-- Part of Pillar 5 — the guild's event-driven nervous system.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE events (
|
|
5
|
+
id INTEGER PRIMARY KEY,
|
|
6
|
+
name TEXT NOT NULL,
|
|
7
|
+
payload TEXT,
|
|
8
|
+
emitter TEXT NOT NULL,
|
|
9
|
+
fired_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
10
|
+
processed INTEGER NOT NULL DEFAULT 0
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CREATE TABLE event_dispatches (
|
|
14
|
+
id INTEGER PRIMARY KEY,
|
|
15
|
+
event_id INTEGER NOT NULL REFERENCES events(id),
|
|
16
|
+
handler_type TEXT NOT NULL,
|
|
17
|
+
handler_name TEXT NOT NULL,
|
|
18
|
+
target_role TEXT,
|
|
19
|
+
notice_type TEXT,
|
|
20
|
+
started_at TEXT,
|
|
21
|
+
ended_at TEXT,
|
|
22
|
+
status TEXT,
|
|
23
|
+
error TEXT
|
|
24
|
+
);
|