@haneinfo/collaboration 0.13.2 → 0.13.3

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/README.md CHANGED
@@ -1,182 +1,182 @@
1
- # Instance collaboration
2
-
3
- Immutable plain-text comments, a read-time activity timeline, and following for StateMachine instances.
4
- Install the collaboration plugin with StateMachine, identity, notification inbox, Prisma and optional
5
- RBAC capabilities. Include `prisma/collaboration.prisma` in the App schema and migrate it normally.
6
- No separate timeline event table is created. See package.json for the current package version.
7
-
8
- Readers and writers must be the submitter, have `state-machine:instance:read`, or hold a reader grant. Comments cannot be
9
- updated or deleted through this package. Text is stored and returned literally: clients render it as
10
- text, without HTML or Markdown interpretation. Mentions use `@{userId}`; recipients must be active
11
- and currently able to read the instance. Agent/MCP comments are always marked `isAiGenerated`.
12
-
13
- HTTP routes under `/state-machine-instances/:id`: GET/POST `comments`, GET `timeline`, POST/DELETE
14
- `follow`. Reads accept offset (default 0) and limit (default 50, maximum 200). Timeline events sort by
15
- ascending timestamp then stable source-prefixed id, and expose `hasMore`. Sources are history,
16
- CHOICE decisions, issued numbers, notification failures and comments. Concurrent additions may
17
- change offset boundaries between separate requests; one request uses a database snapshot.
18
-
19
- Register `CollaborationMcpTools.registerInto(registry, { scopeNamespace })` in the App's existing
20
- internal MCP registry. Tools are `get_instance_comments`, `get_instance_timeline`,
21
- `comment_on_instance`, `follow_instance`, `unfollow_instance`; all require `<namespace>:instance:read`
22
- transport scope plus live instance-read authorization. User text and timeline details use
23
- `$userContent` wrappers. The package creates no public endpoint or new business permission.
24
-
25
- Following is unique per instance/user and covers every subsequent transition and new comment.
26
- The approved `state-machine.transition.recorded` event is consumed through `StateMachineListener.onEvent`
27
- inside the originating transaction, independent of stale state-entry suppression. Transition
28
- notifications use the existing `state-machine-transition:<historyId>` key. Comment notifications use
29
- `collaboration-comment:<commentId>`, union followers, mentions and submitter, exclude the author, and recheck each
30
- recipient's active identity and instance-read permission immediately before delivery. The inbox's
31
- recipient/key unique constraint handles replay and overlap with transition-action notifications.
32
- Transition followers do not add an automatic submitter notification unless that person follows;
33
- existing transition notify actions keep their recipient semantics.
34
-
35
- Configuration: `collaboration: { appName?: string }`. App name defaults to `app`. No subscription
36
- rules, event-type filtering, comment editing, or alternate objects are provided.
37
-
38
- Transactions retry write conflicts and deadlocks up to six attempts with jitter, including
39
- PostgreSQL 40001/40P01 errors wrapped by Prisma raw queries as P2010. Other errors are not retried.
40
-
41
- Mutating tools additionally declare `mutates: true`. Both the generated catalog and MCP wire
42
- annotations then report `readOnlyHint: false`, even for writes authorized by existing read scopes.
43
- This conservative declaration cannot turn a write scope into a read-only operation.
44
-
45
- ## Instance readers and stored query values
46
-
47
- Instance readers have the same discussion and following access as the submitter or a holder of
48
- `state-machine:instance:read`. Apply the state-machine reader-table migration and existing-task
49
- backfill before upgrading. Reader checks use the caller transaction, including mention validation
50
- and delivery; task status does not revoke readership.
51
-
52
- Comment recipients are the deduplicated union of followers, mentions and submitter, excluding
53
- the author even if they follow or mention themselves. Other recipients receive one notification.
54
- Transition notifications keep their existing behavior, including notifications to an actor who
55
- follows the instance. ADMIN has no new special case.
56
-
57
- ## Mechanism compatibility
58
-
59
- Supports state-machine 0.7 as well as 0.6. Instance readership continues to use the existing
60
- StateMachine contract; Collaboration does not implement condition comparison operators.
61
-
62
- ## Frontend contracts
63
-
64
- GET /state-machine-instances/:id/mentionable?q= returns { items: [{ id, name }] }, at most 20 active readers other than the caller. Names may be null. Matching uses case-insensitive name containment; an empty q searches all names. q is at most 200 characters. A nonreader receives INSTANCE_NOT_FOUND (404), exactly like a missing instance.
65
-
66
- IdentityStorePort.searchActiveByName owns database filtering and keyset pages of at most 20 candidates. Upgrade identity-core with collaboration. Missing optional identity search fails closed with IDENTITY_SEARCH_UNAVAILABLE (503). Collaboration evaluates each candidate through the existing effective RBAC authorization and reader grant check; it does not query role tables or reproduce role policy. Memory is bounded by one candidate page plus 20 results; a sparse query can require many bounded queries. Results are ordered by identity id. Comments revalidate mentions when posted.
67
-
68
- GET comments and GET timeline now include following: boolean for the caller, queried in the same transaction as the page. MCP get_instance_comments and get_instance_timeline preserve following. New list_mentionable_users accepts { instanceId, q? }, uses <namespace>:instance:read, is read-only, and wraps each name in $userContent. The manifest declares all six tools; no confirmation or new mutation tool is added.
69
-
70
- ## Instance privacy alignment
71
-
72
- Collaboration already returns identical INSTANCE_NOT_FOUND/404 for missing and unreadable instances before comments, timeline, mentions and follow operations. State-machine now applies the same hiding behavior before human writes; collaboration authorization is unchanged. No general-user people lookup is added.
73
-
74
- ## Delegated transition timeline
75
-
76
- History timeline details optionally include actingUserId and onBehalfOfId from the existing history
77
- decision JSON, allowing clients to display who acted for whom. actorId, triggerRef and every existing
78
- field retain their meanings. No new table, timeline kind, frontend or historical name snapshot is
79
- added. Permanent instance readers, including past delegates, retain read/comment access.
80
-
81
-
82
- ## Instance access lists (implementation)
83
-
84
- Implemented against approved decision 202610-c8e3.
85
-
86
- Comments, mentions, mentionable discovery, follows and notification recipients use the submitter,
87
- effective instance:read, or matching USER/ROLE access (READ or WRITE). Losing manual/role access
88
- immediately blocks new reads, mentions and notifications; old inbox entries are retained.
89
- The existing timeline SQL union classifies triggerType ACCESS as kind ACCESS and preserves the
90
- existing details fields, adding decision.access with the action, principal and previous/new levels.
91
- No state transition, revision bump or follower transition notification is generated for access changes.
92
- MCP wraps decision as $userContent, including access activity. User/grantor names are plain text.
93
-
94
- Upgrade the affected mechanisms together after applying the App migration. The maintained model,
95
- HTTP routes, read-only list_instance_access MCP tool, errors and permission contract are documented
96
- in @haneinfo/state-machine/agent-guide.md. Its prisma/instance-access.sql migrates the existing reader
97
- table to USER/ROLE, READ/WRITE and ASSIGNED/DELEGATED/GRANTED rows while retaining timestamps.
98
- The maintainer selected (instanceId, principalType, principalId, source) uniqueness. Manual grants are
99
- limited to 100 by default; permanent READ entries survive manual removal. See the package repository
100
- validation/equipment-loan/instance-access/report.md for SQL, tests and App restoration evidence.
101
-
102
- ## Optional attachments (approved decision 202610-5f3b)
103
-
104
- Attachment activity uses existing history with triggerType ATTACHMENT and optional decision.attachment (action, id, plain-text fileName). No storage keys, state/revision changes or notifications are introduced. Collaboration classifies these history rows as ATTACHMENT in its existing SQL union; MCP retains decision $userContent wrapping. See @haneinfo/attachments/agent-guide.md for authorization, storage, scanning, migration and retention. Apps adopting the optional package add its reverse instance relation; the core fragment does not depend on attachments.
105
-
106
-
107
- ## Document generation (approved decision 202610-d4f6)
108
-
109
- The optional @haneinfo/document-templates package adds DOCUMENT activity using existing history
110
- and decision.document (templateCode, templateVersion, format), attributed by triggerUserId.
111
- No tables, state/revision changes or notifications are added. Collaboration classifies the row
112
- as DOCUMENT in its existing authorized SQL timeline. Instance history and timeline fields remain
113
- unchanged. Read the document-templates agent guide for fonts, configuration, HTTP and read-only MCP.
114
-
115
-
116
- ## Instance lifecycle (approved decision 202610-f1a8)
117
-
118
- Implemented from approved decision 202610-f1a8. Upgrade state-machine,
119
- list-view, collaboration, attachments, import-export, assignment and timer together. No frontend,
120
- automatic archive or bulk lifecycle operations are included. Permanently purged data cannot be
121
- restored by this API: database and private file backups must cover the entire deletion retention
122
- period and be restored consistently.
123
-
124
- Apply prisma/instance-lifecycle.sql to add ON DELETE CASCADE foreign keys for comments/follows;
125
- add comments CollaborationComment[] and follows CollaborationFollow[] to the App's instance model.
126
- Check and reconcile pre-existing orphan rows before applying these constraints; migration does not
127
- silently delete them. The core fragment does not depend on this optional package. LIFECYCLE history
128
- joins the existing timeline UNION with the original event fields and optional decision.lifecycle.
129
- Actions are ARCHIVED, RESTORED, DELETED, UNDELETED; actorId and at retain who/when. Existing MCP
130
- decision wrapping applies. Deleted-instance comments, timeline, mentions and follows use the same
131
- missing-id 404. Archive does not block them. Lifecycle events produce no collaboration notifications.
132
-
133
-
134
- ## Instance tags (approved decision 202610-2c5d)
135
-
136
- Implemented from approved decision 202610-2c5d. See @haneinfo/tags/agent-guide.md
137
- for data, migration and authorization. The existing timeline SQL classifies TAG activities and retains all original fields/pagination.
138
- decision.tag contains action ADDED/REMOVED, normalizedKey and label; the existing MCP decision
139
- wrapper covers this user text. Each actual tag change has one activity and sends no notification.
140
-
141
- ## Unified search (approved decision 202610-a3d8)
142
-
143
- Implemented under the approved decision. Each comment emits
144
- `collaboration.comment.added` (instanceId, commentId, authorId, isAiGenerated, at; never the body)
145
- in the comment transaction. When the optional `SEARCH_PROVIDERS` registry is present (manifest
146
- optionalRequires `haneinfo.search`), CollaborationService registers `CommentsSearchProvider`: the
147
- newest `commentLimit` (default 200) comments, newest first, AI-generated included, composed with the
148
- shared plugin-api helpers and the configured row limit. Without @haneinfo/search nothing is
149
- registered and comments behave as before. The manifest requires plugin API 1.19.0.
150
-
151
- ## Object references (approved decision 202610-f7a2)
152
-
153
- The timeline SQL classifies `REFERENCE` history entries (written by the optional
154
- @haneinfo/references through state-machine) as the `REFERENCE` kind, with `decision.reference`
155
- (action LINKED or UNLINKED, linkId, kind, direction, other `{ type, id, number }`) in `details`;
156
- original fields, ordering and pagination are unchanged. No notification is sent.
157
-
158
- ## Spaces (approved decision 202610-b1d6)
159
-
160
- The timeline SQL classifies `SPACE` history entries (written by the optional @haneinfo/spaces
161
- through state-machine when an instance is placed, moved or taken out) as the `SPACE` kind, with
162
- `decision.space` (action PLACED, MOVED or REMOVED, nodeId, previousNodeId) in `details`; original
163
- fields, ordering and pagination are unchanged. No notification is sent.
164
-
165
- ## Structured timeline (approved decision 202610-a8d3)
166
-
167
- Implemented under the approved decision. Every timeline entry adds fields a client can turn
168
- into a sentence: `actor: { id, name } | null` (null for the system; names come from one batched
169
- `findActiveNamesByIds` per page and are null when unknown or inactive), `transition`, `fromState`,
170
- `toState` as `{ key, label }` from the instance's pinned machine in the request locale (`?locale=` or
171
- Accept-Language; zh-TW by default), and per kind: START `toState`; TRANSITION `trigger` (USER,
172
- ASSIGNMENT, TIMER, CHOICE) and `onBehalfOf`; CHOICE `outcome` (SELECTED, FAILED) and the selected
173
- target; NUMBER `text` (the number); NOTIFICATION_FAILURE `transition` and `reason`; COMMENT `text`,
174
- `mentions: [{ id, name }]`, `aiGenerated`; ACCESS `action` and `access: { principal: { type, id, name },
175
- level, previousLevel }`; ATTACHMENT and TAG `action` and `text`; REFERENCE `action` and
176
- `reference: { kind, direction, other: { type, id, number } }`; SPACE `action` and `space: { nodeId,
177
- previousNodeId }` (no node names); DOCUMENT `document: { templateCode, templateVersion, format }`;
178
- LIFECYCLE `action`. Link ids, attachment ids, CHOICE evidence and notification error details are not
179
- projected. `id`, `instanceId`, `actorId` and `details` are unchanged and deprecated: the instance
180
- frontend still reads them and they will be removed after it switches. MCP `get_instance_timeline`
181
- uses zh-TW and wraps names, labels and text as `$userContent` (details keep their previous wrapping).
182
- Readership is unchanged. Requires plugin API 1.26.0.
1
+ # Instance collaboration
2
+
3
+ Immutable plain-text comments, a read-time activity timeline, and following for StateMachine instances.
4
+ Install the collaboration plugin with StateMachine, identity, notification inbox, Prisma and optional
5
+ RBAC capabilities. Include `prisma/collaboration.prisma` in the App schema and migrate it normally.
6
+ No separate timeline event table is created. See package.json for the current package version.
7
+
8
+ Readers and writers must be the submitter, have `state-machine:instance:read`, or hold a reader grant. Comments cannot be
9
+ updated or deleted through this package. Text is stored and returned literally: clients render it as
10
+ text, without HTML or Markdown interpretation. Mentions use `@{userId}`; recipients must be active
11
+ and currently able to read the instance. Agent/MCP comments are always marked `isAiGenerated`.
12
+
13
+ HTTP routes under `/state-machine-instances/:id`: GET/POST `comments`, GET `timeline`, POST/DELETE
14
+ `follow`. Reads accept offset (default 0) and limit (default 50, maximum 200). Timeline events sort by
15
+ ascending timestamp then stable source-prefixed id, and expose `hasMore`. Sources are history,
16
+ CHOICE decisions, issued numbers, notification failures and comments. Concurrent additions may
17
+ change offset boundaries between separate requests; one request uses a database snapshot.
18
+
19
+ Register `CollaborationMcpTools.registerInto(registry, { scopeNamespace })` in the App's existing
20
+ internal MCP registry. Tools are `get_instance_comments`, `get_instance_timeline`,
21
+ `comment_on_instance`, `follow_instance`, `unfollow_instance`; all require `<namespace>:instance:read`
22
+ transport scope plus live instance-read authorization. User text and timeline details use
23
+ `$userContent` wrappers. The package creates no public endpoint or new business permission.
24
+
25
+ Following is unique per instance/user and covers every subsequent transition and new comment.
26
+ The approved `state-machine.transition.recorded` event is consumed through `StateMachineListener.onEvent`
27
+ inside the originating transaction, independent of stale state-entry suppression. Transition
28
+ notifications use the existing `state-machine-transition:<historyId>` key. Comment notifications use
29
+ `collaboration-comment:<commentId>`, union followers, mentions and submitter, exclude the author, and recheck each
30
+ recipient's active identity and instance-read permission immediately before delivery. The inbox's
31
+ recipient/key unique constraint handles replay and overlap with transition-action notifications.
32
+ Transition followers do not add an automatic submitter notification unless that person follows;
33
+ existing transition notify actions keep their recipient semantics.
34
+
35
+ Configuration: `collaboration: { appName?: string }`. App name defaults to `app`. No subscription
36
+ rules, event-type filtering, comment editing, or alternate objects are provided.
37
+
38
+ Transactions retry write conflicts and deadlocks up to six attempts with jitter, including
39
+ PostgreSQL 40001/40P01 errors wrapped by Prisma raw queries as P2010. Other errors are not retried.
40
+
41
+ Mutating tools additionally declare `mutates: true`. Both the generated catalog and MCP wire
42
+ annotations then report `readOnlyHint: false`, even for writes authorized by existing read scopes.
43
+ This conservative declaration cannot turn a write scope into a read-only operation.
44
+
45
+ ## Instance readers and stored query values
46
+
47
+ Instance readers have the same discussion and following access as the submitter or a holder of
48
+ `state-machine:instance:read`. Apply the state-machine reader-table migration and existing-task
49
+ backfill before upgrading. Reader checks use the caller transaction, including mention validation
50
+ and delivery; task status does not revoke readership.
51
+
52
+ Comment recipients are the deduplicated union of followers, mentions and submitter, excluding
53
+ the author even if they follow or mention themselves. Other recipients receive one notification.
54
+ Transition notifications keep their existing behavior, including notifications to an actor who
55
+ follows the instance. ADMIN has no new special case.
56
+
57
+ ## Mechanism compatibility
58
+
59
+ Supports state-machine 0.7 as well as 0.6. Instance readership continues to use the existing
60
+ StateMachine contract; Collaboration does not implement condition comparison operators.
61
+
62
+ ## Frontend contracts
63
+
64
+ GET /state-machine-instances/:id/mentionable?q= returns { items: [{ id, name }] }, at most 20 active readers other than the caller. Names may be null. Matching uses case-insensitive name containment; an empty q searches all names. q is at most 200 characters. A nonreader receives INSTANCE_NOT_FOUND (404), exactly like a missing instance.
65
+
66
+ IdentityStorePort.searchActiveByName owns database filtering and keyset pages of at most 20 candidates. Upgrade identity-core with collaboration. Missing optional identity search fails closed with IDENTITY_SEARCH_UNAVAILABLE (503). Collaboration evaluates each candidate through the existing effective RBAC authorization and reader grant check; it does not query role tables or reproduce role policy. Memory is bounded by one candidate page plus 20 results; a sparse query can require many bounded queries. Results are ordered by identity id. Comments revalidate mentions when posted.
67
+
68
+ GET comments and GET timeline now include following: boolean for the caller, queried in the same transaction as the page. MCP get_instance_comments and get_instance_timeline preserve following. New list_mentionable_users accepts { instanceId, q? }, uses <namespace>:instance:read, is read-only, and wraps each name in $userContent. The manifest declares all six tools; no confirmation or new mutation tool is added.
69
+
70
+ ## Instance privacy alignment
71
+
72
+ Collaboration already returns identical INSTANCE_NOT_FOUND/404 for missing and unreadable instances before comments, timeline, mentions and follow operations. State-machine now applies the same hiding behavior before human writes; collaboration authorization is unchanged. No general-user people lookup is added.
73
+
74
+ ## Delegated transition timeline
75
+
76
+ History timeline details optionally include actingUserId and onBehalfOfId from the existing history
77
+ decision JSON, allowing clients to display who acted for whom. actorId, triggerRef and every existing
78
+ field retain their meanings. No new table, timeline kind, frontend or historical name snapshot is
79
+ added. Permanent instance readers, including past delegates, retain read/comment access.
80
+
81
+
82
+ ## Instance access lists (implementation)
83
+
84
+ Implemented against approved decision 202610-c8e3.
85
+
86
+ Comments, mentions, mentionable discovery, follows and notification recipients use the submitter,
87
+ effective instance:read, or matching USER/ROLE access (READ or WRITE). Losing manual/role access
88
+ immediately blocks new reads, mentions and notifications; old inbox entries are retained.
89
+ The existing timeline SQL union classifies triggerType ACCESS as kind ACCESS and preserves the
90
+ existing details fields, adding decision.access with the action, principal and previous/new levels.
91
+ No state transition, revision bump or follower transition notification is generated for access changes.
92
+ MCP wraps decision as $userContent, including access activity. User/grantor names are plain text.
93
+
94
+ Upgrade the affected mechanisms together after applying the App migration. The maintained model,
95
+ HTTP routes, read-only list_instance_access MCP tool, errors and permission contract are documented
96
+ in @haneinfo/state-machine/agent-guide.md. Its prisma/instance-access.sql migrates the existing reader
97
+ table to USER/ROLE, READ/WRITE and ASSIGNED/DELEGATED/GRANTED rows while retaining timestamps.
98
+ The maintainer selected (instanceId, principalType, principalId, source) uniqueness. Manual grants are
99
+ limited to 100 by default; permanent READ entries survive manual removal. See the package repository
100
+ validation/equipment-loan/instance-access/report.md for SQL, tests and App restoration evidence.
101
+
102
+ ## Optional attachments (approved decision 202610-5f3b)
103
+
104
+ Attachment activity uses existing history with triggerType ATTACHMENT and optional decision.attachment (action, id, plain-text fileName). No storage keys, state/revision changes or notifications are introduced. Collaboration classifies these history rows as ATTACHMENT in its existing SQL union; MCP retains decision $userContent wrapping. See @haneinfo/attachments/agent-guide.md for authorization, storage, scanning, migration and retention. Apps adopting the optional package add its reverse instance relation; the core fragment does not depend on attachments.
105
+
106
+
107
+ ## Document generation (approved decision 202610-d4f6)
108
+
109
+ The optional @haneinfo/document-templates package adds DOCUMENT activity using existing history
110
+ and decision.document (templateCode, templateVersion, format), attributed by triggerUserId.
111
+ No tables, state/revision changes or notifications are added. Collaboration classifies the row
112
+ as DOCUMENT in its existing authorized SQL timeline. Instance history and timeline fields remain
113
+ unchanged. Read the document-templates agent guide for fonts, configuration, HTTP and read-only MCP.
114
+
115
+
116
+ ## Instance lifecycle (approved decision 202610-f1a8)
117
+
118
+ Implemented from approved decision 202610-f1a8. Upgrade state-machine,
119
+ list-view, collaboration, attachments, import-export, assignment and timer together. No frontend,
120
+ automatic archive or bulk lifecycle operations are included. Permanently purged data cannot be
121
+ restored by this API: database and private file backups must cover the entire deletion retention
122
+ period and be restored consistently.
123
+
124
+ Apply prisma/instance-lifecycle.sql to add ON DELETE CASCADE foreign keys for comments/follows;
125
+ add comments CollaborationComment[] and follows CollaborationFollow[] to the App's instance model.
126
+ Check and reconcile pre-existing orphan rows before applying these constraints; migration does not
127
+ silently delete them. The core fragment does not depend on this optional package. LIFECYCLE history
128
+ joins the existing timeline UNION with the original event fields and optional decision.lifecycle.
129
+ Actions are ARCHIVED, RESTORED, DELETED, UNDELETED; actorId and at retain who/when. Existing MCP
130
+ decision wrapping applies. Deleted-instance comments, timeline, mentions and follows use the same
131
+ missing-id 404. Archive does not block them. Lifecycle events produce no collaboration notifications.
132
+
133
+
134
+ ## Instance tags (approved decision 202610-2c5d)
135
+
136
+ Implemented from approved decision 202610-2c5d. See @haneinfo/tags/agent-guide.md
137
+ for data, migration and authorization. The existing timeline SQL classifies TAG activities and retains all original fields/pagination.
138
+ decision.tag contains action ADDED/REMOVED, normalizedKey and label; the existing MCP decision
139
+ wrapper covers this user text. Each actual tag change has one activity and sends no notification.
140
+
141
+ ## Unified search (approved decision 202610-a3d8)
142
+
143
+ Implemented under the approved decision. Each comment emits
144
+ `collaboration.comment.added` (instanceId, commentId, authorId, isAiGenerated, at; never the body)
145
+ in the comment transaction. When the optional `SEARCH_PROVIDERS` registry is present (manifest
146
+ optionalRequires `haneinfo.search`), CollaborationService registers `CommentsSearchProvider`: the
147
+ newest `commentLimit` (default 200) comments, newest first, AI-generated included, composed with the
148
+ shared plugin-api helpers and the configured row limit. Without @haneinfo/search nothing is
149
+ registered and comments behave as before. The manifest requires plugin API 1.19.0.
150
+
151
+ ## Object references (approved decision 202610-f7a2)
152
+
153
+ The timeline SQL classifies `REFERENCE` history entries (written by the optional
154
+ @haneinfo/references through state-machine) as the `REFERENCE` kind, with `decision.reference`
155
+ (action LINKED or UNLINKED, linkId, kind, direction, other `{ type, id, number }`) in `details`;
156
+ original fields, ordering and pagination are unchanged. No notification is sent.
157
+
158
+ ## Spaces (approved decision 202610-b1d6)
159
+
160
+ The timeline SQL classifies `SPACE` history entries (written by the optional @haneinfo/spaces
161
+ through state-machine when an instance is placed, moved or taken out) as the `SPACE` kind, with
162
+ `decision.space` (action PLACED, MOVED or REMOVED, nodeId, previousNodeId) in `details`; original
163
+ fields, ordering and pagination are unchanged. No notification is sent.
164
+
165
+ ## Structured timeline (approved decision 202610-a8d3)
166
+
167
+ Implemented under the approved decision. Every timeline entry adds fields a client can turn
168
+ into a sentence: `actor: { id, name } | null` (null for the system; names come from one batched
169
+ `findActiveNamesByIds` per page and are null when unknown or inactive), `transition`, `fromState`,
170
+ `toState` as `{ key, label }` from the instance's pinned machine in the request locale (`?locale=` or
171
+ Accept-Language; zh-TW by default), and per kind: START `toState`; TRANSITION `trigger` (USER,
172
+ ASSIGNMENT, TIMER, CHOICE) and `onBehalfOf`; CHOICE `outcome` (SELECTED, FAILED) and the selected
173
+ target; NUMBER `text` (the number); NOTIFICATION_FAILURE `transition` and `reason`; COMMENT `text`,
174
+ `mentions: [{ id, name }]`, `aiGenerated`; ACCESS `action` and `access: { principal: { type, id, name },
175
+ level, previousLevel }`; ATTACHMENT and TAG `action` and `text`; REFERENCE `action` and
176
+ `reference: { kind, direction, other: { type, id, number } }`; SPACE `action` and `space: { nodeId,
177
+ previousNodeId }` (no node names); DOCUMENT `document: { templateCode, templateVersion, format }`;
178
+ LIFECYCLE `action`. Link ids, attachment ids, CHOICE evidence and notification error details are not
179
+ projected. `id`, `instanceId`, `actorId` and `details` are unchanged and deprecated: the instance
180
+ frontend still reads them and they will be removed after it switches. MCP `get_instance_timeline`
181
+ uses zh-TW and wraps names, labels and text as `$userContent` (details keep their previous wrapping).
182
+ Readership is unchanged. Requires plugin API 1.26.0.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haneinfo/collaboration",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "private": false,
5
5
  "description": "Immutable instance comments, merged timelines and following.",
6
6
  "files": [
@@ -29,7 +29,7 @@
29
29
  "./prisma/collaboration.prisma": "./prisma/collaboration.prisma"
30
30
  },
31
31
  "dependencies": {
32
- "@haneinfo/plugin-api": "1.27.0"
32
+ "@haneinfo/plugin-api": "1.28.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@haneinfo/common": "^0.6.1",
@@ -49,11 +49,11 @@
49
49
  "vitest": "^4.1.11",
50
50
  "zod": "^4.4.0",
51
51
  "@haneinfo/common": "0.6.1",
52
- "@haneinfo/definition-registry": "0.2.6",
53
- "@haneinfo/form": "0.6.0",
54
- "@haneinfo/state-machine": "0.25.1",
55
- "@haneinfo/plugin-host-nest": "2.1.1",
56
- "@haneinfo/plugin-testkit": "2.3.1"
52
+ "@haneinfo/definition-registry": "0.2.7",
53
+ "@haneinfo/form": "0.6.1",
54
+ "@haneinfo/state-machine": "0.25.2",
55
+ "@haneinfo/plugin-testkit": "2.3.1",
56
+ "@haneinfo/plugin-host-nest": "2.1.1"
57
57
  },
58
58
  "license": "UNLICENSED",
59
59
  "publishConfig": {
@@ -1,25 +1,25 @@
1
- /// Immutable plain-text discussion. Mutation routes are deliberately absent. @internal
2
- model CollaborationComment {
3
- id String @id @default(cuid())
4
- instanceId String @map("instance_id")
5
- instance StateMachineInstance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
6
- authorId String @map("author_id")
7
- body String
8
- isAiGenerated Boolean @default(false) @map("is_ai_generated")
9
- mentions String[]
10
- createdAt DateTime @default(now()) @map("created_at")
11
-
12
- @@index([instanceId, createdAt, id])
13
- @@map("collaboration_comments")
14
- }
15
-
16
- /// A single user's interest in all future transitions and comments. @internal
17
- model CollaborationFollow {
18
- instanceId String @map("instance_id")
19
- instance StateMachineInstance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
20
- userId String @map("user_id")
21
- createdAt DateTime @default(now()) @map("created_at")
22
-
23
- @@id([instanceId, userId])
24
- @@map("collaboration_follows")
25
- }
1
+ /// Immutable plain-text discussion. Mutation routes are deliberately absent. @internal
2
+ model CollaborationComment {
3
+ id String @id @default(cuid())
4
+ instanceId String @map("instance_id")
5
+ instance StateMachineInstance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
6
+ authorId String @map("author_id")
7
+ body String
8
+ isAiGenerated Boolean @default(false) @map("is_ai_generated")
9
+ mentions String[]
10
+ createdAt DateTime @default(now()) @map("created_at")
11
+
12
+ @@index([instanceId, createdAt, id])
13
+ @@map("collaboration_comments")
14
+ }
15
+
16
+ /// A single user's interest in all future transitions and comments. @internal
17
+ model CollaborationFollow {
18
+ instanceId String @map("instance_id")
19
+ instance StateMachineInstance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
20
+ userId String @map("user_id")
21
+ createdAt DateTime @default(now()) @map("created_at")
22
+
23
+ @@id([instanceId, userId])
24
+ @@map("collaboration_follows")
25
+ }
@@ -1,4 +1,4 @@
1
- ALTER TABLE collaboration_comments ADD CONSTRAINT collaboration_comments_instance_id_fkey
2
- FOREIGN KEY(instance_id) REFERENCES state_machine_instances(id) ON DELETE CASCADE ON UPDATE CASCADE;
3
- ALTER TABLE collaboration_follows ADD CONSTRAINT collaboration_follows_instance_id_fkey
4
- FOREIGN KEY(instance_id) REFERENCES state_machine_instances(id) ON DELETE CASCADE ON UPDATE CASCADE;
1
+ ALTER TABLE collaboration_comments ADD CONSTRAINT collaboration_comments_instance_id_fkey
2
+ FOREIGN KEY(instance_id) REFERENCES state_machine_instances(id) ON DELETE CASCADE ON UPDATE CASCADE;
3
+ ALTER TABLE collaboration_follows ADD CONSTRAINT collaboration_follows_instance_id_fkey
4
+ FOREIGN KEY(instance_id) REFERENCES state_machine_instances(id) ON DELETE CASCADE ON UPDATE CASCADE;