vouchington-tooling 0.25.0 → 0.27.0

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.
Files changed (34) hide show
  1. package/README.md +4 -1
  2. package/dist/agent-blackboard/feedback-canonical.d.mts +7 -0
  3. package/dist/agent-blackboard/feedback-canonical.mjs +8 -0
  4. package/dist/agent-blackboard/feedback-delivery.mjs +8 -6
  5. package/dist/agent-blackboard/feedback-online.mjs +11 -4
  6. package/dist/agent-blackboard/feedback-outbox.d.mts +8 -1
  7. package/dist/agent-blackboard/feedback-outbox.mjs +17 -4
  8. package/dist/agent-blackboard/feedback-types.d.mts +4 -0
  9. package/dist/agent-blackboard/index.d.mts +1 -1
  10. package/dist/agent-blackboard/index.mjs +1 -1
  11. package/dist/mcp-server/context.d.mts +1 -2
  12. package/dist/mcp-server/dispatch.mjs +6 -12
  13. package/dist/mcp-server/fake-blackboard.test-helpers.d.mts +4 -0
  14. package/dist/mcp-server/fake-blackboard.test-helpers.mjs +7 -1
  15. package/dist/mcp-server/handlers-journal.d.mts +1 -2
  16. package/dist/mcp-server/handlers-journal.mjs +38 -29
  17. package/dist/mcp-server/handlers-outbox.d.mts +11 -0
  18. package/dist/mcp-server/handlers-outbox.mjs +45 -0
  19. package/dist/mcp-server/harness.test-helpers.d.mts +6 -1
  20. package/dist/mcp-server/harness.test-helpers.mjs +14 -2
  21. package/dist/mcp-server/server.mjs +5 -1
  22. package/dist/mcp-server/tools.mjs +15 -11
  23. package/dist/pnpm-install/pnpm-install-fake-pnpm.test-helpers.mjs +2 -2
  24. package/docs/mcp-server.md +65 -14
  25. package/package.json +1 -1
  26. package/skills/blackboard/SKILL.md +69 -22
  27. package/skills/manifest.json +27 -21
  28. package/skills/postgres-node-performance-tuning/references/performance-patterns.md +22 -0
  29. package/skills/postgres-partitioning-uuid-v7/SKILL.md +3 -0
  30. package/skills/postgres-schema-design/SKILL.md +21 -0
  31. package/skills/postgres-schema-design/references/naming.md +34 -0
  32. package/skills/postgres-schema-design/references/relations.md +46 -0
  33. package/skills/postgres-schema-design/references/table-shapes.md +56 -0
  34. package/skills/retrospective-distill/SKILL.md +43 -14
@@ -42,25 +42,52 @@ Every tool takes an explicit `sessionId` (`^[A-Za-z0-9._:-]+$`, at most 256 char
42
42
  server never infers, and an optional `worktree`. Unknown arguments are rejected. Failures come back
43
43
  as MCP tool errors (`isError: true`) with an actionable message rather than crashing the server.
44
44
 
45
- | Tool | Arguments besides `sessionId` and `worktree` | Returns |
46
- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
47
- | `journal_append` | `parentSessionId`, `agent`, `version`, `mode` (`interactive` or `autonomous`), `markdown`, `sourceEventId`, `workOutcome`, `repositories`, `feedbackCoverage`, optional `timestamp`, `category` | `sessionId`, `timestamp`, delivery `status` (`delivered` with a verified receipt, or `pending`) |
48
- | `journal_entries` | none | the session's entries as markdown |
49
- | `outbox_status` | none | `sessionId`, `status`, `pendingCount` |
50
- | `outbox_flush` | none | `sessionId`, `status`, `pendingCount`, `deliveredCount` |
51
- | `session_ensure` | `parentSessionId`, `agent`, `version` | `sessionId`, `status` (`created` or `exists`), `archived` |
52
- | `snapshot_export` | optional `agent`, `version`, `parentSessionId`, `data`, `dataArrayContains`, `inactiveForHours` | `sessionId`, `path`, `counts`, `checksum`, `manifest`, `cleanupToken` |
53
- | `session_archive` | none | `sessionId`, `archived: true` |
45
+ | Tool | Arguments besides `sessionId` and `worktree` | Returns |
46
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
47
+ | `journal_append` | `parentSessionId`, `agent`, `version`, `mode` (`interactive` or `autonomous`), `markdown`, `sourceEventId`, `workOutcome`, `repositories`, `feedbackCoverage`, optional `category` | `sessionId`, `timestamp`, delivery `status` (`delivered` with a verified receipt, or `pending`), `pendingCount`, `worktreePendingCount` |
48
+ | `journal_entries` | none | `sessionId` and `entries`, every entry oldest first |
49
+ | `outbox_status` | none | `sessionId`, `status`, `pendingCount`, `worktreePendingCount` |
50
+ | `outbox_flush` | none | `sessionId`, `status`, `pendingCount`, `worktreePendingCount`, `deliveredCount` |
51
+ | `session_ensure` | `parentSessionId`, `agent`, `version` | `sessionId`, `status` (`created` or `exists`), `archived` |
52
+ | `snapshot_export` | optional `agent`, `version`, `parentSessionId`, `data`, `dataArrayContains`, `inactiveForHours` | `sessionId`, `path`, `counts`, `checksum`, `manifest`, `cleanupToken` |
53
+ | `session_archive` | none | `sessionId`, `archived: true` |
54
54
 
55
55
  `journal_append` validates the whole feedback envelope with `validateFeedbackEnvelope` before
56
56
  anything is written, so a missing required field writes nothing. It returns the verified read-back
57
- result of `writeFeedback`. Delivery is at least once. The envelope includes its timestamp, so when
58
- retrying the same `sourceEventId`, resend the same content and the `timestamp` the first call
59
- returned; the server fixes a default timestamp and returns it for that reason. Markdown is limited
60
- to 12000 bytes.
57
+ result of `writeFeedback`. Delivery is at least once. Markdown is limited to 12000 bytes.
58
+
59
+ The server owns the entry `timestamp`: the tool takes no `timestamp` argument and rejects one, so an
60
+ agent cannot fabricate it, and the result returns the timestamp it reports. An event is identified by
61
+ `sessionId`, `sourceEventId`, and content; the timestamp is not part of that identity. The server
62
+ stamps each attempt with the current time, and the delivery step compares the new attempt with what
63
+ the blackboard or the worktree outbox already holds while ignoring only `timestamp`. To retry, repeat
64
+ the identical call. A retry of an event that is already stored, or already retained in the outbox,
65
+ is the same event: it writes nothing, drops the duplicate retained record, and returns the stored
66
+ record's `timestamp` and `receipt`, so repeated retries report the same timestamp, including after a
67
+ server restart and when the provider was unreachable for the retry. An outbox record that was
68
+ delivered before the retry is recognized the same way when it is flushed, so it drains instead of
69
+ blocking. Any difference in the other envelope fields under the same `sessionId` and
70
+ `sourceEventId` is an `event-conflict` (or a conflict with the retained unsent record) and writes
71
+ nothing. If an autonomous write of the same event lands between the check and the append, both
72
+ entries exist, but the report names the earliest stored one and later retries report it again.
73
+ Admission freshness (`verifyFreshFeedback`) keeps its stricter rule: any earlier record of the event,
74
+ whatever its timestamp, is a conflict.
75
+
76
+ `journal_entries` returns `{ sessionId, entries }`. Each entry is exactly what the `agent-blackboard`
77
+ client returns (`sessionId`, `createdAt`, `data`), so `data` keeps its envelope fields such as
78
+ `repositories`, `sourceEventId`, `workOutcome`, and `feedbackCoverage`. Entries of every type come
79
+ back, including `retrospective` and legacy entries without an envelope. The client documents no
80
+ order, so they are sorted stably by `createdAt`, oldest first. An empty session returns
81
+ `entries: []`. `vouchington agent-blackboard journal entries` still prints journal markdown only.
61
82
 
62
83
  `sessionId` on `outbox_status`, `outbox_flush`, and `snapshot_export` only identifies the caller.
63
- The outbox is per worktree and the status and flush cover every record in it. Flushing an empty
84
+ The outbox is per worktree, so the results name two counts apart. `pendingCount` is the number of
85
+ unsent records of the caller's `sessionId`, and `status` (`empty` or `pending`) follows it.
86
+ `worktreePendingCount` is the number of unsent records of every session in the worktree outbox. Both
87
+ are 0 in autonomous mode, which has no outbox. `outbox_flush` delivers every retained record in the
88
+ worktree, whichever session wrote it, so its `deliveredCount` covers the whole flush while
89
+ `pendingCount` and `worktreePendingCount` report what remains. A record that cannot be delivered, for
90
+ example after an `event-conflict`, stays in the count of the session that wrote it. Flushing an empty
64
91
  outbox does not create the directory. `snapshot_export` never accepts a destination: the
65
92
  `agent-blackboard` client chooses a private file and returns its path. `session_archive` is the one
66
93
  destructive tool; archived metadata is immutable, while entries stay appendable.
@@ -68,6 +95,22 @@ destructive tool; archived metadata is immutable, while entries stay appendable.
68
95
  The outbox lives at `<worktree>/.local/blackboard-outbox` and is used only in interactive mode.
69
96
  Autonomous mode forbids a filesystem outbox, so a failed delivery is an error.
70
97
 
98
+ ### Tool names by harness
99
+
100
+ Each harness names the same tools differently, and some load them on demand. The names in this page
101
+ are the bare tool names; find yours by searching for `journal_append` before concluding the server
102
+ is unavailable.
103
+
104
+ | Harness | `journal_append` is called |
105
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------ |
106
+ | Claude Code | `mcp__vouchington-tooling__journal_append` |
107
+ | Codex | `mcp__vouchington_tooling__journal_append` (the server name's hyphen becomes an underscore) |
108
+ | Cursor | deferred: look it up with `GetDynamicTools` and call it with `CallDynamicTool` under the `vouchington-tooling` namespace |
109
+ | Grok | `vouchington-tooling__journal_append`, found with `search_tool` and called with `use_tool` |
110
+
111
+ The server sends the same list in its MCP `instructions`, so a harness that surfaces server
112
+ instructions shows it to the agent.
113
+
71
114
  ## Worktree validation
72
115
 
73
116
  `worktree` must be an absolute path that, after resolving symlinks, exactly matches an entry of
@@ -112,6 +155,11 @@ Approving every tool of the server at once:
112
155
  - Cursor permission rule: `Mcp(vouchington-tooling:*)`
113
156
  - Codex: `default_tools_approval_mode = "approve"` above
114
157
 
158
+ Cursor also asks each user to approve loading a project server, separately from the permission rule
159
+ above, and the rule does not replace it. Approve it once, interactively, with
160
+ `cursor-agent mcp enable vouchington-tooling`. Headless `cursor-agent -p` does not keep that
161
+ approval: pass `--approve-mcps` on every run.
162
+
115
163
  ## What is verified
116
164
 
117
165
  Covered by this package's tests: the tool list and schemas, every tool's success and rejection
@@ -119,6 +167,9 @@ paths against a faked blackboard client, the worktree gate against real temporar
119
167
  an in-process client and server round trip through the SDK's in-memory transport, and a spawned
120
168
  `vouchington mcp` process driven over real stdio.
121
169
 
170
+ The per-harness tool names and the Cursor approval steps come from headless smoke runs of the
171
+ server in each harness, not from this package's tests.
172
+
122
173
  Not verified, and tracked as the unchecked Phase 0 checklist in
123
174
  [#324](https://github.com/vouchington/vouchington-tooling/issues/324): each harness's approval
124
175
  syntax and whether the rules above take effect, the working directory after entering a worktree,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vouchington-tooling",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Vouchington CLI and extractable tooling libraries.",
5
5
  "homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
6
6
  "bugs": {
@@ -13,38 +13,85 @@ Use when the current repository provides a journal, blackboard, or equivalent du
13
13
  record. Read local `AGENTS.md` for the provider, credential, retention, and
14
14
  subagent-identity rules.
15
15
 
16
+ Journal operations are tools of the `vouchington-tooling` MCP server (`vouchington mcp`):
17
+ `journal_append`, `journal_entries`, `outbox_status`, `outbox_flush`, `session_ensure`,
18
+ `snapshot_export`, and `session_archive`. Harnesses name them differently, so match the bare tool
19
+ name: `mcp__vouchington-tooling__<tool>`, `mcp__vouchington_tooling__<tool>` (the hyphen becomes an
20
+ underscore), or `vouchington-tooling__<tool>` reached through a `search_tool` and `use_tool` pair,
21
+ or the `vouchington-tooling` namespace reached through `GetDynamicTools` and `CallDynamicTool`.
22
+ Every call takes an exact `sessionId`, never inferred, whose meaning depends on the tool:
23
+
24
+ - `journal_append` and `session_ensure`: the session written or ensured, which is the caller's own
25
+ session unless a runner ensures a child identity.
26
+ - `journal_entries` and `session_archive`: the session read or archived, which during distillation
27
+ belongs to another agent.
28
+ - `snapshot_export`, `outbox_status`, and `outbox_flush`: only the caller. The outbox is per
29
+ worktree, so `outbox_status` and `outbox_flush` report two counts: `pendingCount` is the unsent
30
+ records of that `sessionId`, and `worktreePendingCount` is the unsent records of every session in
31
+ the worktree outbox. `outbox_flush` delivers every retained record in the worktree.
32
+
33
+ Every call may take `worktree`, the absolute path of a worktree of the current repository (the
34
+ launch worktree by default). Writing or retrying an entry needs no provider skill, temporary file,
35
+ `--file` flag, or replay command.
36
+ Search for `journal_append` (by bare name, so every prefix matches) before concluding the server is
37
+ unavailable; a deferred harness lists the tool only on request. If the search finds no such tool
38
+ because the server is not registered, not connected, or not approved, stop and report that the
39
+ journal server is unavailable, and name any per-user approval the harness still needs to load
40
+ it (the consumer wrapper documents it). Do not fall back to a CLI command.
41
+
16
42
  1. Capture consequential observations before filing an issue: failed or recovered checks, denied or
17
43
  approved permissions, repeated fixes, scope changes, first-party tool behavior, and architectural
18
44
  findings. Record useful resolved outcomes as well as unresolved gaps. Include bounded evidence,
19
45
  affected areas, an explicit disposition, and an existing tracking reference when present.
20
46
  Journal meaningful skips or bypasses of applicable configured workflows before completion, with
21
47
  the owning workflow or command-catalog entrypoint, reason, and observed result/action.
22
- 2. Use the shared validated envelope with storage `type: journal` or `retrospective`, canonical exact
23
- entry repositories, stable `sourceEventId`, work outcome, and explicit feedback coverage. Category
24
- is optional context; it never changes storage type or distillation eligibility. Generate routine
25
- facts and metadata through the approved composer instead of hand-authoring factual markers.
48
+ 2. Record each observation with one `journal_append` call and pass the note as its `markdown`
49
+ argument (at most 12000 bytes). Required arguments are `sessionId`, `parentSessionId` (null for a
50
+ root session), `agent`, `version`, `mode`, `markdown`, a stable `sourceEventId`, `workOutcome`,
51
+ canonical exact `repositories`, and explicit `feedbackCoverage`. Never pass a `timestamp`: the
52
+ server owns it, rejects the argument, and returns the timestamp it used. Nothing is written
53
+ unless the whole envelope validates. The tool writes journal entries; `category` is optional
54
+ context and never changes storage type or distillation eligibility. Generate routine facts and metadata
55
+ through the approved composer and pass its output as `markdown` instead of hand-authoring
56
+ factual markers. `journal_append` stores only journal entries: save a composed retrospective
57
+ through the retrospective skill's writer, never through `journal_append`.
26
58
  3. Preserve exact provider session and parent identities. Each agent writes only its own session.
27
- Update that session's cumulative repository union before appending; never infer another repository
28
- from prose or create a child identity from a model guess.
29
- 4. Select the repository's trusted mode explicitly. Interactive outages may retain validated,
30
- sanitized feedback in the bounded durable outbox. Report pending count and delivery state, replay
31
- with the same source identity, and continue primary work only after persistence succeeds. A full,
32
- unsafe, or unwritable outbox blocks capture; never evict or silently discard an unsent record.
33
- 5. Autonomous runners require online session ensure, a fresh admission write, and readback before
34
- launching an attempt. Terminal reporting preserves work outcome separately from feedback
35
- coverage and delivery. A filesystem outbox never grants admission or acknowledged completion.
36
- 6. Use at-least-once delivery with consumer deduplication by exact session/source identity. A
37
- transport timeout can leave a late durable write; pending or blocked is never an acknowledged
38
- receipt. Replay verifies matching content before retrying and rejects conflicting source reuse.
39
- 7. Read journal entries oldest-first for retrospectives. Record explicit none-observed with inspected
40
- scope, or not-assessed/unavailable with reason, when evidence does not establish a finding. A
41
- permission request is not proof of approval or denial; localhost refusal is not proof of sandbox
42
- enforcement. Mark partial capture and dropped counts instead of reporting clean evidence.
59
+ `journal_append` ensures that session and merges the entry's `repositories` into the session's
60
+ cumulative repository union, so list every repository the entry concerns. Never infer another
61
+ repository from prose or create a child identity from a model guess. Call `session_ensure` with
62
+ the exact identity only when a runner must confirm the session before work starts.
63
+ 4. Select the repository's trusted `mode` (`interactive` or `autonomous`) explicitly. In interactive
64
+ mode an outage may retain the validated, sanitized record in the bounded durable outbox, and
65
+ `journal_append` reports it as pending. Report `pendingCount` (this session's unsent records),
66
+ and `worktreePendingCount` when other sessions' records are also unsent, from `journal_append`
67
+ or `outbox_status`. Deliver with `outbox_flush` once the provider is reachable, and continue
68
+ primary work only after persistence succeeds. A full, unsafe, or unwritable outbox blocks
69
+ capture; never evict or silently discard an unsent record.
70
+ 5. Autonomous runners require online `session_ensure`, a fresh admission `journal_append`, and
71
+ readback before launching an attempt. Give each attempt's admission entry a `sourceEventId`
72
+ unique to that attempt: reusing an earlier one returns the earlier receipt, which does not
73
+ prove a fresh write. Autonomous mode has no filesystem outbox, so a failed delivery is an error.
74
+ Terminal reporting preserves work outcome separately from feedback coverage and delivery. A
75
+ filesystem outbox never grants admission or acknowledged completion.
76
+ 6. Use at-least-once delivery with consumer deduplication by exact session/source identity. To
77
+ retry a pending or failed append, repeat the identical `journal_append` call with the same
78
+ `sourceEventId` and content. The server's timestamp is not part of an event's identity, so a
79
+ retry of an event already stored or retained reports the stored timestamp, even after a restart
80
+ or an outage. The same `sourceEventId` with different content is rejected as a conflict, so use
81
+ a new `sourceEventId` for a changed note. A transport timeout can leave a late
82
+ durable write; pending or blocked is never an acknowledged receipt.
83
+ 7. Read the session's entries oldest-first with `journal_entries` for retrospectives. It returns
84
+ every entry with its envelope, including its type and repository tags, so a retrospective can
85
+ find an existing retrospective and keep entry-level tags. Record explicit
86
+ none-observed with inspected scope, or not-assessed/unavailable with reason, when evidence does
87
+ not establish a finding. A permission request is not proof of approval or denial; localhost
88
+ refusal is not proof of sandbox enforcement. Mark partial capture and dropped counts instead of
89
+ reporting clean evidence.
43
90
 
44
91
  Never search for, print, invent, or mint credentials. Durable entries and outbox records contain only
45
92
  bounded structured facts or sanitized summaries, never raw command output, transcript content,
46
93
  environment dumps, provider payloads, or secrets. Known-secret redaction supplements the author's
47
94
  minimization responsibility; it cannot prove arbitrary prose contains no undisclosed secret.
48
95
 
49
- Consumer wrappers own service configuration, trusted mode selection, commands, outbox location,
50
- issue routing, and archival authorization.
96
+ Consumer wrappers own service configuration, server registration and approval rules, trusted mode
97
+ selection, issue routing, and archival authorization. The server fixes the outbox location.
@@ -4,7 +4,7 @@
4
4
  {
5
5
  "name": "agent-workflow",
6
6
  "plugin": "vouchington-workflow",
7
- "pluginVersion": "0.9.0",
7
+ "pluginVersion": "0.11.0",
8
8
  "path": "agent-workflow/SKILL.md",
9
9
  "prerequisites": ["github-issue", "pr-description", "review-ci-logs"]
10
10
  },
@@ -18,13 +18,13 @@
18
18
  {
19
19
  "name": "blackboard",
20
20
  "plugin": "vouchington-workflow",
21
- "pluginVersion": "0.9.0",
21
+ "pluginVersion": "0.11.0",
22
22
  "path": "blackboard/SKILL.md"
23
23
  },
24
24
  {
25
25
  "name": "dependabot",
26
26
  "plugin": "vouchington-workflow",
27
- "pluginVersion": "0.9.0",
27
+ "pluginVersion": "0.11.0",
28
28
  "path": "dependabot/SKILL.md",
29
29
  "prerequisites": ["github-actions-checklist"]
30
30
  },
@@ -38,26 +38,26 @@
38
38
  {
39
39
  "name": "git-commit-checklist",
40
40
  "plugin": "vouchington-workflow",
41
- "pluginVersion": "0.9.0",
41
+ "pluginVersion": "0.11.0",
42
42
  "path": "git-commit-checklist/SKILL.md"
43
43
  },
44
44
  {
45
45
  "name": "github-actions-authoring",
46
46
  "plugin": "vouchington-workflow",
47
- "pluginVersion": "0.9.0",
47
+ "pluginVersion": "0.11.0",
48
48
  "path": "github-actions-authoring/SKILL.md",
49
49
  "prerequisites": ["github-actions-checklist"]
50
50
  },
51
51
  {
52
52
  "name": "github-actions-checklist",
53
53
  "plugin": "vouchington-workflow",
54
- "pluginVersion": "0.9.0",
54
+ "pluginVersion": "0.11.0",
55
55
  "path": "github-actions-checklist/SKILL.md"
56
56
  },
57
57
  {
58
58
  "name": "github-issue",
59
59
  "plugin": "vouchington-workflow",
60
- "pluginVersion": "0.9.0",
60
+ "pluginVersion": "0.11.0",
61
61
  "path": "github-issue/SKILL.md"
62
62
  },
63
63
  {
@@ -70,26 +70,26 @@
70
70
  {
71
71
  "name": "npm-publishing",
72
72
  "plugin": "vouchington-workflow",
73
- "pluginVersion": "0.9.0",
73
+ "pluginVersion": "0.11.0",
74
74
  "path": "npm-publishing/SKILL.md"
75
75
  },
76
76
  {
77
77
  "name": "organize-github-issues",
78
78
  "plugin": "vouchington-workflow",
79
- "pluginVersion": "0.9.0",
79
+ "pluginVersion": "0.11.0",
80
80
  "path": "organize-github-issues/SKILL.md",
81
81
  "prerequisites": ["github-issue"]
82
82
  },
83
83
  {
84
84
  "name": "package-json-checklist",
85
85
  "plugin": "vouchington-workflow",
86
- "pluginVersion": "0.9.0",
86
+ "pluginVersion": "0.11.0",
87
87
  "path": "package-json-checklist/SKILL.md"
88
88
  },
89
89
  {
90
90
  "name": "planning",
91
91
  "plugin": "vouchington-workflow",
92
- "pluginVersion": "0.9.0",
92
+ "pluginVersion": "0.11.0",
93
93
  "path": "planning/SKILL.md",
94
94
  "prerequisites": ["github-issue"]
95
95
  },
@@ -103,65 +103,71 @@
103
103
  {
104
104
  "name": "postgres-node-performance-tuning",
105
105
  "plugin": "vouchington-database",
106
- "pluginVersion": "0.2.0",
106
+ "pluginVersion": "0.3.0",
107
107
  "path": "postgres-node-performance-tuning/SKILL.md"
108
108
  },
109
109
  {
110
110
  "name": "postgres-partitioning-uuid-v7",
111
111
  "plugin": "vouchington-database",
112
- "pluginVersion": "0.2.0",
112
+ "pluginVersion": "0.3.0",
113
113
  "path": "postgres-partitioning-uuid-v7/SKILL.md"
114
114
  },
115
+ {
116
+ "name": "postgres-schema-design",
117
+ "plugin": "vouchington-database",
118
+ "pluginVersion": "0.3.0",
119
+ "path": "postgres-schema-design/SKILL.md"
120
+ },
115
121
  {
116
122
  "name": "pr-description",
117
123
  "plugin": "vouchington-workflow",
118
- "pluginVersion": "0.9.0",
124
+ "pluginVersion": "0.11.0",
119
125
  "path": "pr-description/SKILL.md"
120
126
  },
121
127
  {
122
128
  "name": "retrospective",
123
129
  "plugin": "vouchington-workflow",
124
- "pluginVersion": "0.9.0",
130
+ "pluginVersion": "0.11.0",
125
131
  "path": "retrospective/SKILL.md"
126
132
  },
127
133
  {
128
134
  "name": "retrospective-distill",
129
135
  "plugin": "vouchington-workflow",
130
- "pluginVersion": "0.9.0",
136
+ "pluginVersion": "0.11.0",
131
137
  "path": "retrospective-distill/SKILL.md",
132
138
  "prerequisites": ["github-issue"]
133
139
  },
134
140
  {
135
141
  "name": "review-ci-logs",
136
142
  "plugin": "vouchington-workflow",
137
- "pluginVersion": "0.9.0",
143
+ "pluginVersion": "0.11.0",
138
144
  "path": "review-ci-logs/SKILL.md",
139
145
  "prerequisites": ["github-actions-checklist", "pr-description"]
140
146
  },
141
147
  {
142
148
  "name": "review-github-issue-taxonomy",
143
149
  "plugin": "vouchington-workflow",
144
- "pluginVersion": "0.9.0",
150
+ "pluginVersion": "0.11.0",
145
151
  "path": "review-github-issue-taxonomy/SKILL.md",
146
152
  "prerequisites": ["github-issue"]
147
153
  },
148
154
  {
149
155
  "name": "revisit-followups",
150
156
  "plugin": "vouchington-workflow",
151
- "pluginVersion": "0.9.0",
157
+ "pluginVersion": "0.11.0",
152
158
  "path": "revisit-followups/SKILL.md",
153
159
  "prerequisites": ["github-issue"]
154
160
  },
155
161
  {
156
162
  "name": "stacked-prs",
157
163
  "plugin": "vouchington-workflow",
158
- "pluginVersion": "0.9.0",
164
+ "pluginVersion": "0.11.0",
159
165
  "path": "stacked-prs/SKILL.md"
160
166
  },
161
167
  {
162
168
  "name": "static-analysis-checklist",
163
169
  "plugin": "vouchington-workflow",
164
- "pluginVersion": "0.9.0",
170
+ "pluginVersion": "0.11.0",
165
171
  "path": "static-analysis-checklist/SKILL.md",
166
172
  "prerequisites": ["github-actions-checklist"]
167
173
  },
@@ -12,3 +12,25 @@ Check query predicates, joins, ordering, and selected columns against index shap
12
12
  evidence to confirm planner behavior. Add extended statistics only when observed estimates show a
13
13
  correlation problem; verify the statistics are collected and used. Partitioning can reduce scanned
14
14
  data, but it does not replace suitable local indexes or predicates that permit pruning.
15
+
16
+ ## Query shapes
17
+
18
+ Test existence with `EXISTS`, not `COUNT(*) > 0`. Use correlated `NOT EXISTS` rather than
19
+ `NOT IN (SELECT ...)`, whose NULL behavior can silently exclude expected rows. Filter and order
20
+ UUIDv7 rows by `id`, not generated `created_at`, so the key's index supports the query.
21
+ Read and return tables with explicit columns: no `SELECT *`, `alias.*`, or `RETURNING *`.
22
+ A view may use `*` when its reviewed column list is the reader contract.
23
+
24
+ Use keyset pagination, never `OFFSET`. An optimizer fence is a `MATERIALIZED` CTE, not
25
+ `OFFSET 0`. Constrain a partitioned table's partition key, or document the reason for a
26
+ cross-partition query. Choose the partition key from dominant access patterns; a hot reader
27
+ of `RANGE (id)` needs an id or time bound.
28
+
29
+ A UUIDv7 child cannot predate its parent. For a `RANGE (id)` child read by parent id, use a
30
+ shared lower-bound helper equivalent to
31
+ `id >= min_uuidv7(uuid_extract_timestamp(parent_id) - interval '1 hour')` to prune earlier
32
+ partitions; the overlap allows clock skew. Rate limits query an actor-keyed table rather than
33
+ recipient-keyed fan-out rows. Verify actual pruning with EXPLAIN.
34
+
35
+ Generic `jonathanong/no-mistakes` checks include `postgres-no-offset`; inspect available rules
36
+ and configure reviewed cross-partition exceptions rather than treating a rule as plan evidence.
@@ -9,6 +9,9 @@ Read applicable `AGENTS.md` and their declared adapter alias, otherwise
9
9
  `.agents/skills/postgres-partitioning-uuid-v7/SKILL.md` from the repository root if present.
10
10
  Local policy overrides these defaults; do not reload an already-read adapter or canonical skill.
11
11
 
12
+ For schema names, references, and canonical table shapes, read
13
+ [postgres-schema-design](../postgres-schema-design/SKILL.md).
14
+
12
15
  Partition only after lifecycle, retention, and query predicates show that it helps.
13
16
 
14
17
  - Treat a UUIDv7 as time ordered. Where the meaning matters, keep an explicit business timestamp.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: postgres-schema-design
3
+ description: Design PostgreSQL names, relations, history, work queues, and cursors.
4
+ ---
5
+
6
+ # PostgreSQL schema design
7
+
8
+ Read applicable `AGENTS.md` and the repository's local database adapter when present.
9
+ Local policy overrides these portable conventions.
10
+
11
+ - Names explain the stored thing; read [naming](references/naming.md) when naming schema objects.
12
+ - Columns say their type and FK target; finite sets use enums or lookup tables.
13
+ - Joined identities use foreign keys; read [relations](references/relations.md) before modeling references.
14
+ - Split differing shapes, share identical values, and keep history documents as JSON.
15
+ - Use canonical [table shapes](references/table-shapes.md) for revisions, changes, work, and cursors.
16
+ - Reuse parameterized trigger functions instead of copying bodies.
17
+ - Comment every table, column, and view; document reviewed exceptions explicitly.
18
+
19
+ For query shape, read [performance patterns](../postgres-node-performance-tuning/references/performance-patterns.md).
20
+ For partition lifecycle, use [UUIDv7 partitioning](../postgres-partitioning-uuid-v7/SKILL.md).
21
+ Consumer policy owns lifecycle, retention, migration strategy, and enforcement configuration.
@@ -0,0 +1,34 @@
1
+ # Naming
2
+
3
+ Use full words in snake_case. Tables read as `<owner>_<thing>s`, with only the last word
4
+ plural: `account_payment_methods`, not `accounts_payments_methods`. Core entities may use one
5
+ word (`accounts`, `orders`, `invoices`) when local policy permits it. Enum names follow the same
6
+ plural convention. Choose a shorter full-word name when a base identifier would exceed 63 bytes.
7
+
8
+ Indexes use `idx_<table>__<suffix>`; a unique index may use `uq_`. The suffix describes its
9
+ purpose or keys. The table portion may abbreviate only when it expands unambiguously to the
10
+ indexed table: preserve every word, its order, and separators. Each shortened word keeps its
11
+ first letter and at least three letters in their original order; words of three or fewer letters
12
+ stay whole. `idx_ord_line_itms__invoice_id` can name an index on `order_line_items`.
13
+ Initialisms and dropped words cannot. All identifiers stay within 63 bytes.
14
+
15
+ Column names and types imply each other:
16
+
17
+ - `timestamptz` ends in `_at`; dates use `day` or `_on`.
18
+ - Booleans contain a predicate prefix `is_`, `has_`, `can_`, or `should_` at a word boundary.
19
+ - FK columns end in the target's final word, singular: `invoice_id` references `invoices`.
20
+ Drop redundant owner words when the column's table already supplies them.
21
+ - A column referencing a natural key may use that key's name. A retained identity reference
22
+ keeps the entity's name even though the retained table ends in `identities`.
23
+ - Reserve `_user_id` and actor `_by_id` for references to users or retained user identities.
24
+ Adapt the actor convention to the repository's account model; never use an actor suffix for
25
+ an unrelated FK or an opaque token.
26
+
27
+ Trigger functions use `fn_<verb>_<what>` with this closed verb list:
28
+ `reject` (raise on invalid writes), `update` (set the current row), `project` (derived state in
29
+ other rows), `create` (companion rows), `lock`, `register`, and `ensure` (retained identity).
30
+ Ordinary functions use a name that explains their return value.
31
+
32
+ Generic enforcement: `postgres-object-naming`, `postgres-column-naming`, and
33
+ `postgres-identifier-length` in `jonathanong/no-mistakes`. Check the installed rule's supported options before enabling it;
34
+ an upstream rule name does not establish that the installed release includes it.
@@ -0,0 +1,46 @@
1
+ # Relations
2
+
3
+ An identity that readers join is an FK column or an FK child row. JSON holds structured,
4
+ schemaless data and history snapshots, including identities recorded as they were at the time.
5
+ Do not use UUID arrays, JSON ids, or type/id pairs for live relations. A column never names a
6
+ table: use one table per target and generate any per-relation progress enum from the same metadata.
7
+ Cursor positions and random fencing tokens are intentionally not live entity references; record
8
+ their reviewed exception instead of inventing a foreign key.
9
+
10
+ Split tables when their columns or FK targets differ; share a table when only a value differs.
11
+ Identical lookup values share a row without a source discriminator. Put subtype-only columns in
12
+ a subtype table whose primary key also references the base row (`business_accounts.account_id`
13
+ references `accounts.id`). A 1:N child remains an ordinary child table.
14
+
15
+ For one of several sources, use an exclusive arc:
16
+
17
+ ```sql
18
+ CHECK (num_nonnulls(order_id, invoice_id) = 1)
19
+ ```
20
+
21
+ Both source columns have their own FK. If a reference must belong to the same account, enforce
22
+ `FOREIGN KEY (account_id, invoice_id) REFERENCES invoices (account_id, id)` with a corresponding
23
+ unique key on the target. A validation trigger is unnecessary. With nullable `invoice_id`,
24
+ default `MATCH SIMPLE` skips that composite check when the reference is absent.
25
+
26
+ A ledger that survives deletion references a retained identity row with explicit deletion
27
+ behavior. Retained identities preserve history; they do not authorize operations on a deleted
28
+ account, order, or invoice. Index FK columns with a leading key usable by referential checks.
29
+
30
+ Finite code-defined values use enums. Use a lookup table when values carry attributes or arrive
31
+ at runtime. Authenticated vendor-defined values are inserted into a shared lookup on first sight,
32
+ with validation and concurrent insertion handled explicitly. Do not let untrusted strangers
33
+ create unbounded permanent lookup rows; reviewed raw text can be appropriate for their input.
34
+ Free text and a lookup's own natural key are not finite sets.
35
+
36
+ Arrays are for enums or outside-defined lists; live identity collections use FK child rows,
37
+ never `uuid[]`. User-submitted URLs go through one registry with centralized normalization and
38
+ validation, then use URL FKs. Keep exact external protocol identifiers, capability URLs, and
39
+ evidence snapshots unchanged when their contract requires it; document the exception.
40
+ Do not duplicate a child collection into a parent column unless a trigger maintains the projection.
41
+
42
+ Generic enforcement in `jonathanong/no-mistakes`: `postgres-column-naming`,
43
+ `postgres-array-columns`, `postgres-table-shape`, `postgres-fk-index`, and
44
+ `postgres-require-fk-on-delete`. These cover naming, configured shapes, and FK mechanics;
45
+ inspect the installed rule versions and options rather than assuming complete semantic coverage.
46
+ Comments and reviewed exceptions remain necessary.
@@ -0,0 +1,56 @@
1
+ # Table shapes
2
+
3
+ Choose a shape by lifecycle and meaning. Do not store hand-synchronized status beside lifecycle
4
+ timestamps. A final lifecycle derives enum status with an immutable generated expression over
5
+ timestamps such as `claimed_at`, `completed_at`, and `failed_at`. A time-based expiry needs an
6
+ explicit sweeper-written timestamp; `now()` cannot appear in an immutable generated expression.
7
+ When state keeps returning to earlier states, record append-only attempts or changes and derive
8
+ current state from the latest row rather than erasing the previous lifecycle.
9
+
10
+ | Concept | Shape |
11
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
12
+ | Field-diff history | `<entity>_revisions`: UUIDv7 `id`, entity FK, nullable revision actor FK with `ON DELETE SET NULL`, revision-type enum, `changes jsonb`. |
13
+ | Typed lifecycle ledger | `<entity>_changes`: UUIDv7 `id`, entity FK, change-type enum, retained actor identity FK with `ON DELETE RESTRICT`, typed joined payload and JSON for unjoined data. Time comes from `id`. |
14
+ | Current state from a log | Latest change by `id DESC`, projected through a shared trigger or read through a view. |
15
+ | Per-entity work | `<entity>_<job>_work_items`: entity FK, lease and final-outcome columns, claim index, retention. |
16
+ | Job progress | `<job>_cursors`: finite enum key or checked singleton, keyset positions without FKs, optional sweep upper bound. |
17
+ | Inbound or protocol events | Append-only `<source>_events` with `occurred_at` recording the event's business time. |
18
+
19
+ Revisions and changes are append-only through a generic `fn_reject_mutation`, parameterized by
20
+ actor columns that may be erased to NULL. Permit only those erasures; parent-cascade deletion
21
+ may be permitted by policy. A trigger-depth test alone cannot prove a delete came from a parent
22
+ cascade, because another trigger also increases depth. Do not copy the parent into each ledger
23
+ row. Keep historical before/after snapshots as JSON rather than joined history child tables.
24
+ A system change has a NULL actor. Retained actors remain historical identities, without authority.
25
+
26
+ ## Work leases
27
+
28
+ The lease lives on a row that exists only for the work. If an invoice outlives a delivery job,
29
+ use `invoice_delivery_work_items`, with an invoice FK and `ON DELETE CASCADE`, rather than putting
30
+ the lease on the invoice. Do not create a shared polymorphic lease table.
31
+
32
+ Use `lease_token uuid`, `leased_at`, `lease_expires_at`, `attempt_count`, `available_at`, and
33
+ `completed_at` plus timestamps for final outcomes. Add `generation` only when re-enqueue can race
34
+ a running worker. Each claim or reclaim gets a fresh opaque token. Every renewal, completion,
35
+ and failure must include `WHERE lease_token = $mine`; zero affected rows means ownership was lost.
36
+ Keep retries in an optional `_attempts` ledger with `attempt_number` when their lifecycle must
37
+ survive. One-shot compare-and-set claims and human assignments need their own shapes.
38
+
39
+ ## Cursors and shared functions
40
+
41
+ A cursor key names the finite thing being swept. A singleton uses
42
+ `is_singleton boolean PRIMARY KEY DEFAULT true CHECK (is_singleton)`; the job seeds its own row
43
+ with `ON CONFLICT DO NOTHING`. `cursor_<thing>_id` and optional `sweep_upper_bound_<thing>_id` are
44
+ FK-free UUIDv7 positions; NULL means the start. Per-unit work progress belongs in work items.
45
+ A UUIDv7 is assigned at insert, not commit: jobs that must see every committed row re-scan an
46
+ overlap rather than assuming an id high-water mark proves commit order.
47
+
48
+ Use `updated_at` only for mutable rows, always maintained by its trigger; application code never
49
+ writes it. Comment every table, column, and view, including generated objects. Self-explanatory
50
+ columns may have explicit reviewed local exceptions; view comments describe their reader boundary.
51
+ Reuse generic trigger functions with `TG_ARGV` and `TG_TABLE_NAME`; quote dynamic identifiers
52
+ with `format('%I', ...)`. A trigger function and a SQL-callable helper are separate functions.
53
+
54
+ Generic enforcement in `jonathanong/no-mistakes`: `postgres-table-shape` and
55
+ `postgres-duplicate-function-body`. Configure canonical shapes explicitly and verify which
56
+ rules the installed release supports; lifecycle and authority decisions still need review.