@danypops/papyrus 0.42.0 → 0.42.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.
Files changed (73) hide show
  1. package/package.json +2 -2
  2. package/src/adapters/sqlite-artifact-scope-store.ts +18 -9
  3. package/src/adapters/sqlite-artifact-store.ts +7 -5
  4. package/src/adapters/sqlite-discussion-round-store.ts +26 -17
  5. package/src/adapters/sqlite-gate-runner.ts +1 -1
  6. package/src/adapters/sqlite-graph-projection-store.ts +14 -10
  7. package/src/adapters/sqlite-log-store.ts +36 -17
  8. package/src/adapters/sqlite-note-event-store.ts +20 -16
  9. package/src/adapters/sqlite-session-identity-store.ts +13 -7
  10. package/src/adapters/sqlite-task-event-store.ts +29 -21
  11. package/src/adapters/sqlite-task-focus-store.ts +36 -10
  12. package/src/adapters/sqlite-task-lease-store.ts +12 -6
  13. package/src/adapters/sqlite-task-scope-store.ts +25 -14
  14. package/src/artifact-relationship-view.ts +3 -3
  15. package/src/artifact-subtree.ts +4 -2
  16. package/src/authority-registry.ts +2 -1
  17. package/src/cli.ts +785 -179
  18. package/src/client.ts +46 -20
  19. package/src/constants.ts +15 -4
  20. package/src/daemon-state.ts +4 -12
  21. package/src/daemon.ts +31 -9
  22. package/src/db.ts +119 -98
  23. package/src/discussion-service.ts +109 -44
  24. package/src/domain/artifact-event.ts +17 -4
  25. package/src/domain/artifact.ts +3 -1
  26. package/src/domain/blueprint-definition.ts +26 -31
  27. package/src/domain/checklist.ts +20 -17
  28. package/src/domain/discussion.ts +37 -18
  29. package/src/domain/gate.ts +7 -7
  30. package/src/domain/log-entry.ts +1 -1
  31. package/src/domain/note-event.ts +20 -7
  32. package/src/domain/task-event.ts +17 -7
  33. package/src/domain-services.ts +241 -110
  34. package/src/graph-projection-service.ts +34 -8
  35. package/src/id-migration.ts +17 -4
  36. package/src/index.ts +16 -11
  37. package/src/log-service.ts +6 -5
  38. package/src/log.ts +19 -0
  39. package/src/modules/discuss.ts +63 -28
  40. package/src/modules/docs.ts +74 -17
  41. package/src/modules/graph-projection.ts +20 -9
  42. package/src/modules/logs.ts +33 -21
  43. package/src/modules/notes.ts +66 -28
  44. package/src/modules/playbooks.ts +88 -29
  45. package/src/modules/rules.ts +57 -15
  46. package/src/modules/session-identity.ts +6 -2
  47. package/src/modules/tasks.ts +142 -67
  48. package/src/note-service.ts +11 -7
  49. package/src/ops.ts +131 -68
  50. package/src/playbook-definition.ts +56 -17
  51. package/src/playbook-execution.ts +13 -3
  52. package/src/ports/note-event-store.ts +6 -4
  53. package/src/ports/task-event-store.ts +9 -6
  54. package/src/ports/task-focus-store.ts +17 -4
  55. package/src/ports/task-lease-store.ts +9 -4
  56. package/src/ports/task-scope-store.ts +3 -1
  57. package/src/service.ts +143 -89
  58. package/src/session-identity-service.ts +10 -2
  59. package/src/task-context.ts +28 -16
  60. package/src/task-execution.ts +4 -12
  61. package/src/task-graph-view.ts +12 -12
  62. package/src/task-relationship-view.ts +1 -3
  63. package/src/task-service.ts +167 -72
  64. package/src/vehicle/artifact-trash-vehicle.ts +25 -13
  65. package/src/vehicle/artifact-vehicle-shared.ts +28 -7
  66. package/src/vehicle/docs-vehicle.ts +48 -16
  67. package/src/vehicle/notes-vehicle.ts +24 -6
  68. package/src/vehicle/papyrus-vehicle.ts +14 -3
  69. package/src/vehicle/playbooks-vehicle.ts +87 -18
  70. package/src/vehicle/rules-vehicle.ts +58 -21
  71. package/src/vehicle/tasks-vehicle.ts +366 -54
  72. package/src/version.ts +1 -1
  73. package/src/workflow-execution.ts +71 -52
@@ -3,10 +3,15 @@
3
3
  * previous extra.noteHistory: a bounded array inside a mutable JSON field, which a later
4
4
  * setExtra from a concurrent operation could overwrite -- a real record can't do that.
5
5
  */
6
- import { NOTE_HISTORY_DEFAULT_LIMIT, NOTE_HISTORY_MAX_LIMIT, NOTE_PROVENANCE_MAX_LENGTH, NOTE_REASON_MAX_CHARACTERS } from "../constants.ts";
6
+ import {
7
+ NOTE_HISTORY_DEFAULT_LIMIT,
8
+ NOTE_HISTORY_MAX_LIMIT,
9
+ NOTE_PROVENANCE_MAX_LENGTH,
10
+ NOTE_REASON_MAX_CHARACTERS,
11
+ } from "../constants.ts";
7
12
 
8
13
  export const NOTE_EVENT_TYPES = ["captured", "consumed", "promoted", "archived"] as const;
9
- export type NoteEventType = typeof NOTE_EVENT_TYPES[number];
14
+ export type NoteEventType = (typeof NOTE_EVENT_TYPES)[number];
10
15
  export type NoteEventDirection = "asc" | "desc";
11
16
 
12
17
  export interface NoteEvent {
@@ -47,7 +52,9 @@ export interface NoteHistoryPage {
47
52
  nextCursor?: number;
48
53
  }
49
54
 
50
- export function normalizeNoteHistoryQuery(query: NoteHistoryQuery = {}): Required<Pick<NoteHistoryQuery, "limit" | "direction">> & Pick<NoteHistoryQuery, "cursor"> {
55
+ export function normalizeNoteHistoryQuery(
56
+ query: NoteHistoryQuery = {},
57
+ ): Required<Pick<NoteHistoryQuery, "limit" | "direction">> & Pick<NoteHistoryQuery, "cursor"> {
51
58
  const limit = query.limit ?? NOTE_HISTORY_DEFAULT_LIMIT;
52
59
  if (!Number.isInteger(limit) || limit < 1 || limit > NOTE_HISTORY_MAX_LIMIT) {
53
60
  throw new Error(`note history limit must be between 1 and ${NOTE_HISTORY_MAX_LIMIT}`);
@@ -62,10 +69,16 @@ export function normalizeNoteHistoryQuery(query: NoteHistoryQuery = {}): Require
62
69
  }
63
70
 
64
71
  export function validateNoteEvent(event: AppendNoteEvent): AppendNoteEvent {
65
- for (const [field, value] of [["actor", event.actor], ["source", event.source]] as const) {
66
- if (!value || value.length > NOTE_PROVENANCE_MAX_LENGTH) throw new Error(`${field} must be between 1 and ${NOTE_PROVENANCE_MAX_LENGTH} characters`);
72
+ for (const [field, value] of [
73
+ ["actor", event.actor],
74
+ ["source", event.source],
75
+ ] as const) {
76
+ if (!value || value.length > NOTE_PROVENANCE_MAX_LENGTH)
77
+ throw new Error(`${field} must be between 1 and ${NOTE_PROVENANCE_MAX_LENGTH} characters`);
67
78
  }
68
- if (event.sessionId !== undefined && event.sessionId.length > NOTE_PROVENANCE_MAX_LENGTH) throw new Error(`sessionId cannot exceed ${NOTE_PROVENANCE_MAX_LENGTH} characters`);
69
- if (event.reason !== undefined && event.reason.length > NOTE_REASON_MAX_CHARACTERS) throw new Error(`reason cannot exceed ${NOTE_REASON_MAX_CHARACTERS} characters`);
79
+ if (event.sessionId !== undefined && event.sessionId.length > NOTE_PROVENANCE_MAX_LENGTH)
80
+ throw new Error(`sessionId cannot exceed ${NOTE_PROVENANCE_MAX_LENGTH} characters`);
81
+ if (event.reason !== undefined && event.reason.length > NOTE_REASON_MAX_CHARACTERS)
82
+ throw new Error(`reason cannot exceed ${NOTE_REASON_MAX_CHARACTERS} characters`);
70
83
  return event;
71
84
  }
@@ -33,7 +33,7 @@ export const TASK_EVENT_TYPES = [
33
33
  "became_ready",
34
34
  ] as const;
35
35
 
36
- export type TaskEventType = typeof TASK_EVENT_TYPES[number];
36
+ export type TaskEventType = (typeof TASK_EVENT_TYPES)[number];
37
37
  export type TaskEventDirection = "asc" | "desc";
38
38
 
39
39
  export interface TaskEventContext {
@@ -105,7 +105,9 @@ export interface TaskEventFeedPage {
105
105
  nextCursor?: number;
106
106
  }
107
107
 
108
- export function normalizeTaskEventFeedQuery(query: TaskEventFeedQuery = {}): Required<Pick<TaskEventFeedQuery, "limit">> & Pick<TaskEventFeedQuery, "cursor" | "eventTypes"> {
108
+ export function normalizeTaskEventFeedQuery(
109
+ query: TaskEventFeedQuery = {},
110
+ ): Required<Pick<TaskEventFeedQuery, "limit">> & Pick<TaskEventFeedQuery, "cursor" | "eventTypes"> {
109
111
  const limit = query.limit ?? TASK_EVENT_FEED_DEFAULT_LIMIT;
110
112
  if (!Number.isInteger(limit) || limit < 1 || limit > TASK_EVENT_FEED_MAX_LIMIT) {
111
113
  throw new Error(`task event feed limit must be between 1 and ${TASK_EVENT_FEED_MAX_LIMIT}`);
@@ -122,7 +124,9 @@ export function normalizeTaskEventFeedQuery(query: TaskEventFeedQuery = {}): Req
122
124
  return { limit, cursor: query.cursor, eventTypes: query.eventTypes };
123
125
  }
124
126
 
125
- export function normalizeTaskHistoryQuery(query: TaskHistoryQuery = {}): Required<Pick<TaskHistoryQuery, "limit" | "direction">> & Pick<TaskHistoryQuery, "cursor"> {
127
+ export function normalizeTaskHistoryQuery(
128
+ query: TaskHistoryQuery = {},
129
+ ): Required<Pick<TaskHistoryQuery, "limit" | "direction">> & Pick<TaskHistoryQuery, "cursor"> {
126
130
  const limit = query.limit ?? TASK_HISTORY_DEFAULT_LIMIT;
127
131
  if (!Number.isInteger(limit) || limit < 1 || limit > TASK_HISTORY_MAX_LIMIT) {
128
132
  throw new Error(`task history limit must be between 1 and ${TASK_HISTORY_MAX_LIMIT}`);
@@ -137,11 +141,17 @@ export function normalizeTaskHistoryQuery(query: TaskHistoryQuery = {}): Require
137
141
  }
138
142
 
139
143
  export function validateTaskEvent(event: AppendTaskEvent): AppendTaskEvent {
140
- for (const [field, value] of [["actor", event.actor], ["source", event.source]] as const) {
141
- if (!value || value.length > TASK_EVENT_ACTOR_MAX_LENGTH) throw new Error(`${field} must be between 1 and ${TASK_EVENT_ACTOR_MAX_LENGTH} characters`);
144
+ for (const [field, value] of [
145
+ ["actor", event.actor],
146
+ ["source", event.source],
147
+ ] as const) {
148
+ if (!value || value.length > TASK_EVENT_ACTOR_MAX_LENGTH)
149
+ throw new Error(`${field} must be between 1 and ${TASK_EVENT_ACTOR_MAX_LENGTH} characters`);
142
150
  }
143
- if (event.sessionId !== undefined && event.sessionId.length > TASK_EVENT_ACTOR_MAX_LENGTH) throw new Error(`sessionId cannot exceed ${TASK_EVENT_ACTOR_MAX_LENGTH} characters`);
144
- if (event.reason !== undefined && event.reason.length > TASK_EVENT_REASON_MAX_LENGTH) throw new Error(`reason cannot exceed ${TASK_EVENT_REASON_MAX_LENGTH} characters`);
151
+ if (event.sessionId !== undefined && event.sessionId.length > TASK_EVENT_ACTOR_MAX_LENGTH)
152
+ throw new Error(`sessionId cannot exceed ${TASK_EVENT_ACTOR_MAX_LENGTH} characters`);
153
+ if (event.reason !== undefined && event.reason.length > TASK_EVENT_REASON_MAX_LENGTH)
154
+ throw new Error(`reason cannot exceed ${TASK_EVENT_REASON_MAX_LENGTH} characters`);
145
155
  if (event.evidence !== undefined && new TextEncoder().encode(JSON.stringify(event.evidence)).byteLength > TASK_EVENT_MAX_EVIDENCE_BYTES) {
146
156
  throw new Error(`task event evidence cannot exceed ${TASK_EVENT_MAX_EVIDENCE_BYTES} bytes`);
147
157
  }