@reticlehq/core 2.10.0 → 2.12.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.
- package/dist/constants.d.ts +22 -0
- package/dist/constants.js +23 -1
- package/dist/document-identity.d.ts +39 -0
- package/dist/document-identity.js +53 -0
- package/dist/edit-epoch.d.ts +36 -0
- package/dist/edit-epoch.js +40 -0
- package/dist/event-payloads.d.ts +18 -4
- package/dist/event-payloads.js +11 -1
- package/dist/findings.d.ts +62 -0
- package/dist/findings.js +75 -0
- package/dist/flow-types.d.ts +70 -0
- package/dist/flow-types.js +22 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/instrumentation-gap.d.ts +141 -0
- package/dist/instrumentation-gap.js +164 -0
- package/dist/intent.d.ts +332 -0
- package/dist/intent.js +133 -0
- package/dist/journal.d.ts +33 -0
- package/dist/journal.js +20 -0
- package/dist/messages.d.ts +84 -10
- package/dist/messages.js +20 -0
- package/dist/notices.d.ts +5 -3
- package/dist/notices.js +5 -3
- package/dist/project-registry.d.ts +86 -0
- package/dist/project-registry.js +66 -0
- package/dist/run-context.d.ts +122 -0
- package/dist/run-context.js +118 -0
- package/dist/schema/event-message.json +10 -0
- package/dist/schema/event-type.json +1 -0
- package/dist/schema/reticle-event.json +10 -0
- package/dist/schema/reticle-message.json +10 -0
- package/dist/security.js +17 -1
- package/dist/source-constants.cjs +9 -0
- package/dist/source-constants.d.cts +4 -0
- package/dist/telemetry-session.d.ts +2 -2
- package/dist/telemetry.d.ts +6 -98
- package/dist/telemetry.js +0 -41
- package/dist/types.d.ts +70 -0
- package/dist/types.js +14 -0
- package/dist/unreachable-notice.d.ts +19 -0
- package/dist/unreachable-notice.js +26 -0
- package/package.json +6 -2
package/dist/intent.d.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What a change was supposed to make true, captured while somebody still knows.
|
|
4
|
+
*
|
|
5
|
+
* An agent building a feature knows what it is for — which user does what, what should become true,
|
|
6
|
+
* what the failure looks like. That knowledge lives in its context, and then the turn ends. Later, a
|
|
7
|
+
* different turn or a different model drives the app and has to decide whether the feature works,
|
|
8
|
+
* holding the DOM, the diff, and no intent. So it asserts what it can SEE rather than what was
|
|
9
|
+
* MEANT, and what it can see is almost always weaker. That gap is where a false green comes from.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the prose is captured early and the predicate late
|
|
12
|
+
*
|
|
13
|
+
* Intent has two properties that move in opposite directions over the life of a task.
|
|
14
|
+
*
|
|
15
|
+
* **Fidelity** is highest the moment the human asks and decays from there; every later restatement
|
|
16
|
+
* is a lossy re-derivation. **Bindability** — whether it can be written as something checkable — is
|
|
17
|
+
* near zero then, because there is no route, no ref and often no code, and rises as the code
|
|
18
|
+
* appears.
|
|
19
|
+
*
|
|
20
|
+
* Capture at either end alone loses one of them. Demanding a predicate at declare time collects
|
|
21
|
+
* MECHANISMS, which is what assertions already are. Waiting until drive time collects a
|
|
22
|
+
* RE-DERIVATION, which is the weak artifact this exists to replace — by then the agent has already
|
|
23
|
+
* forgotten, and that is the entire premise.
|
|
24
|
+
*
|
|
25
|
+
* So: `statement` is prose and mandatory. `binding` is a predicate, optional, and may arrive later
|
|
26
|
+
* or never. An intent that stays `declared` and never becomes `bound` is not a failure — it is the
|
|
27
|
+
* most interesting row in the ledger, because it names something the team meant that nothing can
|
|
28
|
+
* currently prove.
|
|
29
|
+
*
|
|
30
|
+
* ## Amendments are append-only
|
|
31
|
+
*
|
|
32
|
+
* A long build changes its mind, so an intent must be amendable. But an amendable intent is also how
|
|
33
|
+
* an agent could quietly rewrite what it meant to match what it can already prove. Keeping the
|
|
34
|
+
* previous statement makes a NARROWING visible in the git diff, which is the only real defence —
|
|
35
|
+
* and it is a partial one, stated here rather than papered over.
|
|
36
|
+
*/
|
|
37
|
+
export declare const INTENT_FILE_VERSION = 1;
|
|
38
|
+
export declare const IntentState: {
|
|
39
|
+
/** Prose only. Nothing yet says how it would be proved. */
|
|
40
|
+
readonly DECLARED: "declared";
|
|
41
|
+
/** A predicate exists that would prove it. */
|
|
42
|
+
readonly BOUND: "bound";
|
|
43
|
+
/** A verdict satisfied that predicate. */
|
|
44
|
+
readonly PROVED: "proved";
|
|
45
|
+
};
|
|
46
|
+
export type IntentState = (typeof IntentState)[keyof typeof IntentState];
|
|
47
|
+
/** Where the intent lives, so a later run can find the ones relevant to what it is touching. */
|
|
48
|
+
export declare const IntentSurfaceSchema: z.ZodObject<{
|
|
49
|
+
route: z.ZodOptional<z.ZodString>;
|
|
50
|
+
flow: z.ZodOptional<z.ZodString>;
|
|
51
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
flow?: string | undefined;
|
|
54
|
+
route?: string | undefined;
|
|
55
|
+
files?: string[] | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
flow?: string | undefined;
|
|
58
|
+
route?: string | undefined;
|
|
59
|
+
files?: string[] | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
export type IntentSurface = z.infer<typeof IntentSurfaceSchema>;
|
|
62
|
+
/** Which verdict discharged it, and how strongly. The grade is what makes a later weakening visible. */
|
|
63
|
+
export declare const IntentProofSchema: z.ZodObject<{
|
|
64
|
+
verdictId: z.ZodString;
|
|
65
|
+
grade: z.ZodString;
|
|
66
|
+
at: z.ZodNumber;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
at: number;
|
|
69
|
+
verdictId: string;
|
|
70
|
+
grade: string;
|
|
71
|
+
}, {
|
|
72
|
+
at: number;
|
|
73
|
+
verdictId: string;
|
|
74
|
+
grade: string;
|
|
75
|
+
}>;
|
|
76
|
+
export declare const IntentSchema: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
/** The prose. Survives even when the binding rots, which is most of the point. */
|
|
79
|
+
statement: z.ZodString;
|
|
80
|
+
state: z.ZodEnum<["declared", "bound", "proved"]>;
|
|
81
|
+
declaredAt: z.ZodNumber;
|
|
82
|
+
/** Left as `unknown`: core must not depend on the server's predicate vocabulary. */
|
|
83
|
+
binding: z.ZodOptional<z.ZodUnknown>;
|
|
84
|
+
surface: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
route: z.ZodOptional<z.ZodString>;
|
|
86
|
+
flow: z.ZodOptional<z.ZodString>;
|
|
87
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
flow?: string | undefined;
|
|
90
|
+
route?: string | undefined;
|
|
91
|
+
files?: string[] | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
flow?: string | undefined;
|
|
94
|
+
route?: string | undefined;
|
|
95
|
+
files?: string[] | undefined;
|
|
96
|
+
}>>;
|
|
97
|
+
provenBy: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
verdictId: z.ZodString;
|
|
99
|
+
grade: z.ZodString;
|
|
100
|
+
at: z.ZodNumber;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
at: number;
|
|
103
|
+
verdictId: string;
|
|
104
|
+
grade: string;
|
|
105
|
+
}, {
|
|
106
|
+
at: number;
|
|
107
|
+
verdictId: string;
|
|
108
|
+
grade: string;
|
|
109
|
+
}>>;
|
|
110
|
+
/** Every statement this intent previously carried, oldest first. Append-only, never rewritten. */
|
|
111
|
+
amended: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
112
|
+
statement: z.ZodString;
|
|
113
|
+
at: z.ZodNumber;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
at: number;
|
|
116
|
+
statement: string;
|
|
117
|
+
}, {
|
|
118
|
+
at: number;
|
|
119
|
+
statement: string;
|
|
120
|
+
}>, "many">>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
id: string;
|
|
123
|
+
state: "proved" | "declared" | "bound";
|
|
124
|
+
statement: string;
|
|
125
|
+
declaredAt: number;
|
|
126
|
+
surface?: {
|
|
127
|
+
flow?: string | undefined;
|
|
128
|
+
route?: string | undefined;
|
|
129
|
+
files?: string[] | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
binding?: unknown;
|
|
132
|
+
provenBy?: {
|
|
133
|
+
at: number;
|
|
134
|
+
verdictId: string;
|
|
135
|
+
grade: string;
|
|
136
|
+
} | undefined;
|
|
137
|
+
amended?: {
|
|
138
|
+
at: number;
|
|
139
|
+
statement: string;
|
|
140
|
+
}[] | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
id: string;
|
|
143
|
+
state: "proved" | "declared" | "bound";
|
|
144
|
+
statement: string;
|
|
145
|
+
declaredAt: number;
|
|
146
|
+
surface?: {
|
|
147
|
+
flow?: string | undefined;
|
|
148
|
+
route?: string | undefined;
|
|
149
|
+
files?: string[] | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
binding?: unknown;
|
|
152
|
+
provenBy?: {
|
|
153
|
+
at: number;
|
|
154
|
+
verdictId: string;
|
|
155
|
+
grade: string;
|
|
156
|
+
} | undefined;
|
|
157
|
+
amended?: {
|
|
158
|
+
at: number;
|
|
159
|
+
statement: string;
|
|
160
|
+
}[] | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
export type Intent = z.infer<typeof IntentSchema>;
|
|
163
|
+
export declare const IntentFileSchema: z.ZodObject<{
|
|
164
|
+
version: z.ZodLiteral<1>;
|
|
165
|
+
intents: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
166
|
+
id: z.ZodString;
|
|
167
|
+
/** The prose. Survives even when the binding rots, which is most of the point. */
|
|
168
|
+
statement: z.ZodString;
|
|
169
|
+
state: z.ZodEnum<["declared", "bound", "proved"]>;
|
|
170
|
+
declaredAt: z.ZodNumber;
|
|
171
|
+
/** Left as `unknown`: core must not depend on the server's predicate vocabulary. */
|
|
172
|
+
binding: z.ZodOptional<z.ZodUnknown>;
|
|
173
|
+
surface: z.ZodOptional<z.ZodObject<{
|
|
174
|
+
route: z.ZodOptional<z.ZodString>;
|
|
175
|
+
flow: z.ZodOptional<z.ZodString>;
|
|
176
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
flow?: string | undefined;
|
|
179
|
+
route?: string | undefined;
|
|
180
|
+
files?: string[] | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
flow?: string | undefined;
|
|
183
|
+
route?: string | undefined;
|
|
184
|
+
files?: string[] | undefined;
|
|
185
|
+
}>>;
|
|
186
|
+
provenBy: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
verdictId: z.ZodString;
|
|
188
|
+
grade: z.ZodString;
|
|
189
|
+
at: z.ZodNumber;
|
|
190
|
+
}, "strip", z.ZodTypeAny, {
|
|
191
|
+
at: number;
|
|
192
|
+
verdictId: string;
|
|
193
|
+
grade: string;
|
|
194
|
+
}, {
|
|
195
|
+
at: number;
|
|
196
|
+
verdictId: string;
|
|
197
|
+
grade: string;
|
|
198
|
+
}>>;
|
|
199
|
+
/** Every statement this intent previously carried, oldest first. Append-only, never rewritten. */
|
|
200
|
+
amended: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
201
|
+
statement: z.ZodString;
|
|
202
|
+
at: z.ZodNumber;
|
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
|
204
|
+
at: number;
|
|
205
|
+
statement: string;
|
|
206
|
+
}, {
|
|
207
|
+
at: number;
|
|
208
|
+
statement: string;
|
|
209
|
+
}>, "many">>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
id: string;
|
|
212
|
+
state: "proved" | "declared" | "bound";
|
|
213
|
+
statement: string;
|
|
214
|
+
declaredAt: number;
|
|
215
|
+
surface?: {
|
|
216
|
+
flow?: string | undefined;
|
|
217
|
+
route?: string | undefined;
|
|
218
|
+
files?: string[] | undefined;
|
|
219
|
+
} | undefined;
|
|
220
|
+
binding?: unknown;
|
|
221
|
+
provenBy?: {
|
|
222
|
+
at: number;
|
|
223
|
+
verdictId: string;
|
|
224
|
+
grade: string;
|
|
225
|
+
} | undefined;
|
|
226
|
+
amended?: {
|
|
227
|
+
at: number;
|
|
228
|
+
statement: string;
|
|
229
|
+
}[] | undefined;
|
|
230
|
+
}, {
|
|
231
|
+
id: string;
|
|
232
|
+
state: "proved" | "declared" | "bound";
|
|
233
|
+
statement: string;
|
|
234
|
+
declaredAt: number;
|
|
235
|
+
surface?: {
|
|
236
|
+
flow?: string | undefined;
|
|
237
|
+
route?: string | undefined;
|
|
238
|
+
files?: string[] | undefined;
|
|
239
|
+
} | undefined;
|
|
240
|
+
binding?: unknown;
|
|
241
|
+
provenBy?: {
|
|
242
|
+
at: number;
|
|
243
|
+
verdictId: string;
|
|
244
|
+
grade: string;
|
|
245
|
+
} | undefined;
|
|
246
|
+
amended?: {
|
|
247
|
+
at: number;
|
|
248
|
+
statement: string;
|
|
249
|
+
}[] | undefined;
|
|
250
|
+
}>>;
|
|
251
|
+
}, "strip", z.ZodTypeAny, {
|
|
252
|
+
version: 1;
|
|
253
|
+
intents: Record<string, {
|
|
254
|
+
id: string;
|
|
255
|
+
state: "proved" | "declared" | "bound";
|
|
256
|
+
statement: string;
|
|
257
|
+
declaredAt: number;
|
|
258
|
+
surface?: {
|
|
259
|
+
flow?: string | undefined;
|
|
260
|
+
route?: string | undefined;
|
|
261
|
+
files?: string[] | undefined;
|
|
262
|
+
} | undefined;
|
|
263
|
+
binding?: unknown;
|
|
264
|
+
provenBy?: {
|
|
265
|
+
at: number;
|
|
266
|
+
verdictId: string;
|
|
267
|
+
grade: string;
|
|
268
|
+
} | undefined;
|
|
269
|
+
amended?: {
|
|
270
|
+
at: number;
|
|
271
|
+
statement: string;
|
|
272
|
+
}[] | undefined;
|
|
273
|
+
}>;
|
|
274
|
+
}, {
|
|
275
|
+
version: 1;
|
|
276
|
+
intents: Record<string, {
|
|
277
|
+
id: string;
|
|
278
|
+
state: "proved" | "declared" | "bound";
|
|
279
|
+
statement: string;
|
|
280
|
+
declaredAt: number;
|
|
281
|
+
surface?: {
|
|
282
|
+
flow?: string | undefined;
|
|
283
|
+
route?: string | undefined;
|
|
284
|
+
files?: string[] | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
binding?: unknown;
|
|
287
|
+
provenBy?: {
|
|
288
|
+
at: number;
|
|
289
|
+
verdictId: string;
|
|
290
|
+
grade: string;
|
|
291
|
+
} | undefined;
|
|
292
|
+
amended?: {
|
|
293
|
+
at: number;
|
|
294
|
+
statement: string;
|
|
295
|
+
}[] | undefined;
|
|
296
|
+
}>;
|
|
297
|
+
}>;
|
|
298
|
+
export type IntentFile = z.infer<typeof IntentFileSchema>;
|
|
299
|
+
export declare function emptyIntentFile(): IntentFile;
|
|
300
|
+
export declare function declareIntent(input: {
|
|
301
|
+
id: string;
|
|
302
|
+
statement: string;
|
|
303
|
+
now: number;
|
|
304
|
+
surface?: IntentSurface;
|
|
305
|
+
}): Intent;
|
|
306
|
+
/** Attach the predicate that would prove it. Pure — returns a new intent. */
|
|
307
|
+
export declare function bindIntent(intent: Intent, binding: unknown): Intent;
|
|
308
|
+
/**
|
|
309
|
+
* Record that a verdict proved it.
|
|
310
|
+
*
|
|
311
|
+
* Refuses on an intent with no binding, and returns it unchanged rather than throwing: nothing could
|
|
312
|
+
* have satisfied a predicate that does not exist, so a discharge there would be a claim with no
|
|
313
|
+
* evidence — the shape this whole feature exists to stop. A throw would be the wrong shape too,
|
|
314
|
+
* because discharge runs off the back of a verdict and must never be why one fails to return.
|
|
315
|
+
*/
|
|
316
|
+
export declare function dischargeIntent(intent: Intent, proof: {
|
|
317
|
+
verdictId: string;
|
|
318
|
+
grade: string;
|
|
319
|
+
at: number;
|
|
320
|
+
}): Intent;
|
|
321
|
+
/**
|
|
322
|
+
* Add or amend an intent, keeping what it used to say.
|
|
323
|
+
*
|
|
324
|
+
* An amendment is recorded only when the statement actually changed — re-declaring the same intent
|
|
325
|
+
* unchanged is what a re-run does, and filling the history with identical rows would bury the one
|
|
326
|
+
* amendment somebody needs to see.
|
|
327
|
+
*/
|
|
328
|
+
export declare function upsertIntent(file: IntentFile, intent: Intent): IntentFile;
|
|
329
|
+
/** Everything not yet proved — what an agent asking "am I done?" still owes. */
|
|
330
|
+
export declare function openIntents(file: IntentFile): Intent[];
|
|
331
|
+
/** Parse an intent file, failing soft to empty. Never throws — a cache must not take a daemon down. */
|
|
332
|
+
export declare function parseIntentFile(raw: unknown): IntentFile;
|
package/dist/intent.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* What a change was supposed to make true, captured while somebody still knows.
|
|
4
|
+
*
|
|
5
|
+
* An agent building a feature knows what it is for — which user does what, what should become true,
|
|
6
|
+
* what the failure looks like. That knowledge lives in its context, and then the turn ends. Later, a
|
|
7
|
+
* different turn or a different model drives the app and has to decide whether the feature works,
|
|
8
|
+
* holding the DOM, the diff, and no intent. So it asserts what it can SEE rather than what was
|
|
9
|
+
* MEANT, and what it can see is almost always weaker. That gap is where a false green comes from.
|
|
10
|
+
*
|
|
11
|
+
* ## Why the prose is captured early and the predicate late
|
|
12
|
+
*
|
|
13
|
+
* Intent has two properties that move in opposite directions over the life of a task.
|
|
14
|
+
*
|
|
15
|
+
* **Fidelity** is highest the moment the human asks and decays from there; every later restatement
|
|
16
|
+
* is a lossy re-derivation. **Bindability** — whether it can be written as something checkable — is
|
|
17
|
+
* near zero then, because there is no route, no ref and often no code, and rises as the code
|
|
18
|
+
* appears.
|
|
19
|
+
*
|
|
20
|
+
* Capture at either end alone loses one of them. Demanding a predicate at declare time collects
|
|
21
|
+
* MECHANISMS, which is what assertions already are. Waiting until drive time collects a
|
|
22
|
+
* RE-DERIVATION, which is the weak artifact this exists to replace — by then the agent has already
|
|
23
|
+
* forgotten, and that is the entire premise.
|
|
24
|
+
*
|
|
25
|
+
* So: `statement` is prose and mandatory. `binding` is a predicate, optional, and may arrive later
|
|
26
|
+
* or never. An intent that stays `declared` and never becomes `bound` is not a failure — it is the
|
|
27
|
+
* most interesting row in the ledger, because it names something the team meant that nothing can
|
|
28
|
+
* currently prove.
|
|
29
|
+
*
|
|
30
|
+
* ## Amendments are append-only
|
|
31
|
+
*
|
|
32
|
+
* A long build changes its mind, so an intent must be amendable. But an amendable intent is also how
|
|
33
|
+
* an agent could quietly rewrite what it meant to match what it can already prove. Keeping the
|
|
34
|
+
* previous statement makes a NARROWING visible in the git diff, which is the only real defence —
|
|
35
|
+
* and it is a partial one, stated here rather than papered over.
|
|
36
|
+
*/
|
|
37
|
+
export const INTENT_FILE_VERSION = 1;
|
|
38
|
+
export const IntentState = {
|
|
39
|
+
/** Prose only. Nothing yet says how it would be proved. */
|
|
40
|
+
DECLARED: 'declared',
|
|
41
|
+
/** A predicate exists that would prove it. */
|
|
42
|
+
BOUND: 'bound',
|
|
43
|
+
/** A verdict satisfied that predicate. */
|
|
44
|
+
PROVED: 'proved',
|
|
45
|
+
};
|
|
46
|
+
/** Where the intent lives, so a later run can find the ones relevant to what it is touching. */
|
|
47
|
+
export const IntentSurfaceSchema = z.object({
|
|
48
|
+
route: z.string().optional(),
|
|
49
|
+
flow: z.string().optional(),
|
|
50
|
+
files: z.array(z.string()).optional(),
|
|
51
|
+
});
|
|
52
|
+
/** Which verdict discharged it, and how strongly. The grade is what makes a later weakening visible. */
|
|
53
|
+
export const IntentProofSchema = z.object({
|
|
54
|
+
verdictId: z.string(),
|
|
55
|
+
grade: z.string(),
|
|
56
|
+
at: z.number(),
|
|
57
|
+
});
|
|
58
|
+
export const IntentSchema = z.object({
|
|
59
|
+
id: z.string().min(1),
|
|
60
|
+
/** The prose. Survives even when the binding rots, which is most of the point. */
|
|
61
|
+
statement: z.string().min(1),
|
|
62
|
+
state: z.enum([IntentState.DECLARED, IntentState.BOUND, IntentState.PROVED]),
|
|
63
|
+
declaredAt: z.number(),
|
|
64
|
+
/** Left as `unknown`: core must not depend on the server's predicate vocabulary. */
|
|
65
|
+
binding: z.unknown().optional(),
|
|
66
|
+
surface: IntentSurfaceSchema.optional(),
|
|
67
|
+
provenBy: IntentProofSchema.optional(),
|
|
68
|
+
/** Every statement this intent previously carried, oldest first. Append-only, never rewritten. */
|
|
69
|
+
amended: z.array(z.object({ statement: z.string(), at: z.number() })).optional(),
|
|
70
|
+
});
|
|
71
|
+
export const IntentFileSchema = z.object({
|
|
72
|
+
version: z.literal(INTENT_FILE_VERSION),
|
|
73
|
+
intents: z.record(z.string(), IntentSchema),
|
|
74
|
+
});
|
|
75
|
+
export function emptyIntentFile() {
|
|
76
|
+
return { version: INTENT_FILE_VERSION, intents: {} };
|
|
77
|
+
}
|
|
78
|
+
export function declareIntent(input) {
|
|
79
|
+
return {
|
|
80
|
+
id: input.id,
|
|
81
|
+
statement: input.statement,
|
|
82
|
+
state: IntentState.DECLARED,
|
|
83
|
+
declaredAt: input.now,
|
|
84
|
+
...(input.surface === undefined ? {} : { surface: input.surface }),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Attach the predicate that would prove it. Pure — returns a new intent. */
|
|
88
|
+
export function bindIntent(intent, binding) {
|
|
89
|
+
return { ...intent, state: IntentState.BOUND, binding };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Record that a verdict proved it.
|
|
93
|
+
*
|
|
94
|
+
* Refuses on an intent with no binding, and returns it unchanged rather than throwing: nothing could
|
|
95
|
+
* have satisfied a predicate that does not exist, so a discharge there would be a claim with no
|
|
96
|
+
* evidence — the shape this whole feature exists to stop. A throw would be the wrong shape too,
|
|
97
|
+
* because discharge runs off the back of a verdict and must never be why one fails to return.
|
|
98
|
+
*/
|
|
99
|
+
export function dischargeIntent(intent, proof) {
|
|
100
|
+
if (intent.binding === undefined)
|
|
101
|
+
return intent;
|
|
102
|
+
return { ...intent, state: IntentState.PROVED, provenBy: proof };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Add or amend an intent, keeping what it used to say.
|
|
106
|
+
*
|
|
107
|
+
* An amendment is recorded only when the statement actually changed — re-declaring the same intent
|
|
108
|
+
* unchanged is what a re-run does, and filling the history with identical rows would bury the one
|
|
109
|
+
* amendment somebody needs to see.
|
|
110
|
+
*/
|
|
111
|
+
export function upsertIntent(file, intent) {
|
|
112
|
+
const previous = file.intents[intent.id];
|
|
113
|
+
const changed = previous !== undefined && previous.statement !== intent.statement;
|
|
114
|
+
const amended = changed
|
|
115
|
+
? [...(previous.amended ?? []), { statement: previous.statement, at: previous.declaredAt }]
|
|
116
|
+
: previous?.amended;
|
|
117
|
+
return {
|
|
118
|
+
version: INTENT_FILE_VERSION,
|
|
119
|
+
intents: {
|
|
120
|
+
...file.intents,
|
|
121
|
+
[intent.id]: { ...intent, ...(amended === undefined ? {} : { amended }) },
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Everything not yet proved — what an agent asking "am I done?" still owes. */
|
|
126
|
+
export function openIntents(file) {
|
|
127
|
+
return Object.values(file.intents).filter((intent) => intent.state !== IntentState.PROVED);
|
|
128
|
+
}
|
|
129
|
+
/** Parse an intent file, failing soft to empty. Never throws — a cache must not take a daemon down. */
|
|
130
|
+
export function parseIntentFile(raw) {
|
|
131
|
+
const parsed = IntentFileSchema.safeParse(raw);
|
|
132
|
+
return parsed.success ? parsed.data : emptyIntentFile();
|
|
133
|
+
}
|
package/dist/journal.d.ts
CHANGED
|
@@ -87,3 +87,36 @@ export declare const JournalActionSchema: z.ZodObject<{
|
|
|
87
87
|
} | undefined;
|
|
88
88
|
}>;
|
|
89
89
|
export type JournalAction = z.infer<typeof JournalActionSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* The bounded verdict summary a verification tool writes into a journal action's `effect`.
|
|
92
|
+
*
|
|
93
|
+
* `effect` is deliberately open (`unknown`) and narrowed by its writer; this is that narrowing for
|
|
94
|
+
* the one writer whose record has to be READ back later. Without it a verdict lives only in the tool
|
|
95
|
+
* response, which is exactly the place that disappears when an agent compacts, so "what did this run
|
|
96
|
+
* already prove" would have no ledger to fold and the answer would be silently empty.
|
|
97
|
+
*
|
|
98
|
+
* Three fields and no more: the claim the verdict was about, how it came out, and where in the
|
|
99
|
+
* source it pointed. A transcript here would grow the journal without making the answer better.
|
|
100
|
+
*/
|
|
101
|
+
export declare const JournalVerdictEffectSchema: z.ZodObject<{
|
|
102
|
+
/** What was claimed, in the caller's own words — the subject a later proof supersedes. */
|
|
103
|
+
claim: z.ZodString;
|
|
104
|
+
/** The verdict, as the one field an agent reads. The enum, never a re-typed copy of it. */
|
|
105
|
+
verified: z.ZodNativeEnum<{
|
|
106
|
+
readonly YES: "yes";
|
|
107
|
+
readonly NO: "no";
|
|
108
|
+
readonly UNKNOWN: "unknown";
|
|
109
|
+
readonly NO_FAULT: "no-fault";
|
|
110
|
+
}>;
|
|
111
|
+
/** `file:line` for the element driven, when the page told us one. */
|
|
112
|
+
source: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
claim: string;
|
|
115
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
116
|
+
source?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
claim: string;
|
|
119
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
120
|
+
source?: string | undefined;
|
|
121
|
+
}>;
|
|
122
|
+
export type JournalVerdictEffect = z.infer<typeof JournalVerdictEffectSchema>;
|
package/dist/journal.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { TRANSPORT_LIMITS } from './constants.js';
|
|
3
|
+
import { Verified } from './verified-constants.js';
|
|
3
4
|
/**
|
|
4
5
|
* The durable causal journal. Each session gets an append-only pair on disk:
|
|
5
6
|
* `.reticle/sessions/<id>/events.jsonl` (one `ReticleEvent` per line — already seq/actionId-stamped
|
|
@@ -35,3 +36,22 @@ export const JournalActionSchema = z.object({
|
|
|
35
36
|
/** Elapsed-ms timestamp the action was recorded at (clock injected by the writer). */
|
|
36
37
|
at: z.number().int().min(0),
|
|
37
38
|
});
|
|
39
|
+
/**
|
|
40
|
+
* The bounded verdict summary a verification tool writes into a journal action's `effect`.
|
|
41
|
+
*
|
|
42
|
+
* `effect` is deliberately open (`unknown`) and narrowed by its writer; this is that narrowing for
|
|
43
|
+
* the one writer whose record has to be READ back later. Without it a verdict lives only in the tool
|
|
44
|
+
* response, which is exactly the place that disappears when an agent compacts, so "what did this run
|
|
45
|
+
* already prove" would have no ledger to fold and the answer would be silently empty.
|
|
46
|
+
*
|
|
47
|
+
* Three fields and no more: the claim the verdict was about, how it came out, and where in the
|
|
48
|
+
* source it pointed. A transcript here would grow the journal without making the answer better.
|
|
49
|
+
*/
|
|
50
|
+
export const JournalVerdictEffectSchema = z.object({
|
|
51
|
+
/** What was claimed, in the caller's own words — the subject a later proof supersedes. */
|
|
52
|
+
claim: z.string().min(1).max(TRANSPORT_LIMITS.MAX_STRING_LENGTH),
|
|
53
|
+
/** The verdict, as the one field an agent reads. The enum, never a re-typed copy of it. */
|
|
54
|
+
verified: z.nativeEnum(Verified),
|
|
55
|
+
/** `file:line` for the element driven, when the page told us one. */
|
|
56
|
+
source: z.string().max(TRANSPORT_LIMITS.MAX_URL_LENGTH).optional(),
|
|
57
|
+
});
|