@robhowley/pi-remembrancer 0.4.0 → 0.5.1

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.
@@ -0,0 +1,275 @@
1
+ import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
2
+ import { matchesKey, SelectList, Text } from '@earendil-works/pi-tui';
3
+ import type { CheckpointStore } from './checkpoints.js';
4
+ import { branchEvidence, readSession } from './evidence.js';
5
+ import { boundedEvidencePage } from './review-pages.js';
6
+ import { type Proposal, type ProposalDraft, validateDraft } from './proposals.js';
7
+ import {
8
+ applyProposal,
9
+ previewProposal,
10
+ requireTui,
11
+ resolveProposal,
12
+ type TaskExecutor,
13
+ type TaskPreview,
14
+ } from './taskwarrior.js';
15
+
16
+ // JSON preserves exact values without sending terminal controls (including C1) to the TUI.
17
+ function exact(value: unknown, indent?: number): string {
18
+ return Array.from(JSON.stringify(value ?? null, null, indent), (character) => {
19
+ const code = character.charCodeAt(0);
20
+ return code >= 0x7f && code <= 0x9f ? `\\u${code.toString(16).padStart(4, '0')}` : character;
21
+ }).join('');
22
+ }
23
+ function project(proposal: Proposal): string {
24
+ const draft = proposal.draft ?? proposal;
25
+ return (
26
+ (draft.change.operation !== 'complete' && draft.change.fields.project !== undefined
27
+ ? draft.change.fields.project
28
+ : draft.expected?.fields.project) ?? '(no project)'
29
+ );
30
+ }
31
+ function savedSourceText(source: Proposal['sources'][number]): string {
32
+ return `${source.role} ${exact(source.timestamp)} ${exact(source.locator)}\n${exact(source.quote)}\nFile: ${exact(source.file)}\nSession: ${exact(source.sessionId)}\nBranch: ${exact(source.branchId)}\nEntry: ${exact(source.entryId)}\nEdit: ${exact(source.editId)}\nExcerpt offset: ${source.offset}`;
33
+ }
34
+ // Called only by the deliberate Source action, never while rendering a preview.
35
+ export function sourceText(proposal: Proposal): string {
36
+ return proposal.sources
37
+ .map((source) => {
38
+ const saved = savedSourceText(source);
39
+ try {
40
+ const tree = readSession(source.file);
41
+ const branch = branchEvidence(tree, {
42
+ file: source.file,
43
+ sessionId: source.sessionId,
44
+ entryId: source.branchId,
45
+ });
46
+ const index = branch.findIndex(
47
+ (item) => item.entryId === source.entryId && item.editId === source.editId,
48
+ );
49
+ const selected = branch[index];
50
+ if (
51
+ !selected ||
52
+ selected.role !== source.role ||
53
+ selected.timestamp !== source.timestamp ||
54
+ selected.text.slice(source.offset, source.offset + source.quote.length) !== source.quote
55
+ )
56
+ throw new Error('Saved reference no longer matches');
57
+ const surrounding = branch.slice(Math.max(0, index - 2), index + 3);
58
+ const page = boundedEvidencePage(surrounding, { index: 0, offset: 0 }, (entries) => ({
59
+ entries,
60
+ }));
61
+ return `${saved}\n\nLocal context (up to two messages before and after, saved branch):\n${exact(page.data)}${page.cursor.index < surrounding.length ? '\nAdditional context omitted at the display limit.' : ''}`;
62
+ } catch {
63
+ return `${saved}\n\nExtra file context is unavailable: source missing, unreadable, over limits, or saved reference no longer matches.`;
64
+ }
65
+ })
66
+ .join('\n\n');
67
+ }
68
+ export function previewText(preview: TaskPreview): string {
69
+ const { proposal, task } = preview;
70
+ const draft = proposal.draft ?? proposal;
71
+ const change = draft.change;
72
+ const state =
73
+ proposal.state === 'applying' ? 'uncertain (unresolved applying claim)' : proposal.state;
74
+ const lines = [
75
+ `${change.operation.toUpperCase()} · ${state} · revision ${proposal.revision}`,
76
+ `Target: ${change.operation === 'add' ? (proposal.claim ?? '(new task)') : change.targetUuid}`,
77
+ `Description: ${exact(change.operation !== 'complete' && change.fields.description !== undefined ? change.fields.description : (task?.['description'] ?? draft.expected?.fields.description))}`,
78
+ `Project: ${exact(change.operation !== 'complete' && change.fields.project !== undefined ? change.fields.project : (task?.['project'] ?? '(no project)'))}`,
79
+ ];
80
+ if (change.operation !== 'complete')
81
+ for (const [field, value] of Object.entries(change.fields))
82
+ lines.push(`${field}: ${exact(task?.[field])} -> ${exact(value)}`);
83
+ lines.push(
84
+ `status: ${exact(task?.['status'])} -> ${exact(change.operation === 'complete' ? 'completed' : (task?.['status'] ?? 'pending'))}`,
85
+ );
86
+ lines.push(
87
+ `annotations: ${exact(task?.['annotations'] ?? [])}`,
88
+ `Append annotations (existing identical text is retained): ${exact(change.annotations)}`,
89
+ );
90
+ if (draft.question) lines.push(`Apply disabled: ${exact(draft.question)}`);
91
+ if (change.operation !== 'add' && !task) lines.push('Apply disabled: target missing');
92
+ lines.push(
93
+ `Why: ${exact(proposal.explanation)}`,
94
+ ...proposal.sources.map(
95
+ (source) =>
96
+ `${source.role} ${exact(source.timestamp)} ${exact(source.locator)}: ${exact(source.quote)}`,
97
+ ),
98
+ );
99
+ lines.push(`Current task: ${exact(task)}`);
100
+ if (proposal.draft)
101
+ lines.push('Edited draft. Press h for the saved proposal and revision history.');
102
+ if (proposal.result) lines.push(`Result: ${exact(proposal.result)}`);
103
+ if (['applying', 'uncertain'].includes(proposal.state))
104
+ lines.push(
105
+ 'No replay. Ctrl+A only verifies the current task and records already satisfied if it matches. Otherwise resolve the task manually.',
106
+ );
107
+ return lines.join('\n');
108
+ }
109
+ export async function openProposals(
110
+ ctx: ExtensionContext,
111
+ store: CheckpointStore,
112
+ execute?: TaskExecutor,
113
+ ): Promise<void> {
114
+ requireTui(ctx.mode);
115
+ let selected = 0;
116
+ let selectedId: string | undefined;
117
+ let message = '';
118
+ for (;;) {
119
+ requireTui(ctx.mode);
120
+ const proposals: Proposal[] = [];
121
+ for (let offset = 0; ; offset += 50) {
122
+ const page = store.proposals(undefined, offset, 50);
123
+ proposals.push(...page);
124
+ if (page.length < 50) break;
125
+ }
126
+ proposals.sort(
127
+ (a, b) =>
128
+ project(a).localeCompare(project(b)) ||
129
+ a.createdAt.localeCompare(b.createdAt) ||
130
+ a.id.localeCompare(b.id),
131
+ );
132
+ if (!proposals.length) {
133
+ ctx.ui.notify('No task proposals', 'info');
134
+ return;
135
+ }
136
+ if (selectedId)
137
+ selected = Math.max(
138
+ 0,
139
+ proposals.findIndex((item) => item.id === selectedId),
140
+ );
141
+ selected = Math.min(selected, proposals.length - 1);
142
+ const proposal = proposals[selected]!;
143
+ selectedId = proposal.id;
144
+ let preview: TaskPreview | undefined;
145
+ let previewError = '';
146
+ try {
147
+ preview = await previewProposal(store, proposal.id, execute);
148
+ } catch (error) {
149
+ previewError = String(error);
150
+ }
151
+ const action = await ctx.ui.custom<'apply' | 'edit' | 'dismiss' | 'navigate' | 'close'>(
152
+ (tui, theme, kb, done) => {
153
+ let detail: 'preview' | 'source' | 'history' = 'preview';
154
+ let sourceBody = '';
155
+ let scroll = 0;
156
+ let total = 0;
157
+ const list = new SelectList(
158
+ proposals.map((item) => {
159
+ const change = (item.draft ?? item).change;
160
+ return {
161
+ value: item.id,
162
+ label: `${exact(project(item))} · ${change.operation} · ${item.state === 'applying' ? 'uncertain' : item.state}`,
163
+ description: exact(
164
+ change.operation !== 'complete'
165
+ ? (change.fields.description ?? (item.draft ?? item).expected?.fields.description)
166
+ : (item.draft ?? item).expected?.fields.description,
167
+ ),
168
+ };
169
+ }),
170
+ 5,
171
+ {
172
+ selectedPrefix: (s) => theme.fg('accent', s),
173
+ selectedText: (s) => theme.fg('accent', s),
174
+ description: (s) => theme.fg('muted', s),
175
+ scrollInfo: (s) => theme.fg('dim', s),
176
+ noMatch: (s) => s,
177
+ },
178
+ );
179
+ list.setSelectedIndex(selected);
180
+ list.onSelectionChange = (item) => {
181
+ selectedId = item.value;
182
+ done('navigate');
183
+ };
184
+ list.onCancel = () => done('close');
185
+ return {
186
+ capturesViewportInput: true,
187
+ render(width: number) {
188
+ const body = new Text(
189
+ detail === 'source'
190
+ ? sourceBody
191
+ : detail === 'history'
192
+ ? `Saved proposal and revision history (drafts do not apply tasks):\n${exact(proposal, 2)}`
193
+ : preview
194
+ ? previewText(preview)
195
+ : `${exact(previewError)}\n${proposal.sources.map(savedSourceText).join('\n\n')}`,
196
+ 0,
197
+ 0,
198
+ ).render(width);
199
+ total = body.length;
200
+ scroll = Math.max(0, Math.min(scroll, Math.max(0, total - 12)));
201
+ return [
202
+ ...new Text(theme.fg('accent', 'Task proposals'), 0, 0).render(width),
203
+ ...list.render(width),
204
+ ...body.slice(scroll, scroll + 12),
205
+ ...new Text(
206
+ theme.fg(
207
+ 'dim',
208
+ `Details ${scroll + 1}-${Math.min(scroll + 12, total)}/${total} · PgUp/PgDn scroll\nCtrl+A Apply / verify unresolved · e Edit · d Dismiss · s Source · h History · Esc back/close\nEnter never applies. ${message ? exact(message) : ''}`,
209
+ ),
210
+ 0,
211
+ 0,
212
+ ).render(width),
213
+ ];
214
+ },
215
+ invalidate() {
216
+ list.invalidate();
217
+ },
218
+ handleInput(data: string) {
219
+ if (matchesKey(data, 'pageDown')) scroll += 12;
220
+ else if (matchesKey(data, 'pageUp')) scroll -= 12;
221
+ else if (data === 's') {
222
+ detail = detail === 'source' ? 'preview' : 'source';
223
+ if (detail === 'source') sourceBody = sourceText(proposal);
224
+ scroll = 0;
225
+ } else if (data === 'h') {
226
+ detail = detail === 'history' ? 'preview' : 'history';
227
+ scroll = 0;
228
+ } else if (detail !== 'preview' && kb.matches(data, 'tui.select.cancel')) {
229
+ detail = 'preview';
230
+ scroll = 0;
231
+ } else if (detail === 'preview' && matchesKey(data, 'ctrl+a')) done('apply');
232
+ else if (detail === 'preview' && data === 'e') done('edit');
233
+ else if (detail === 'preview' && data === 'd') done('dismiss');
234
+ else if (detail === 'preview' && !kb.matches(data, 'tui.select.confirm'))
235
+ list.handleInput(data);
236
+ tui.requestRender();
237
+ },
238
+ };
239
+ },
240
+ );
241
+ if (action === 'close') return;
242
+ message = '';
243
+ try {
244
+ requireTui(ctx.mode);
245
+ if (action === 'apply') {
246
+ if (!preview) throw new Error(previewError);
247
+ const resolved = ['applying', 'uncertain'].includes(preview.proposal.state)
248
+ ? await resolveProposal(store, preview, () => ctx.mode, execute)
249
+ : await applyProposal(store, preview, () => ctx.mode, execute);
250
+ message = resolved.state;
251
+ if (['applied', 'already_satisfied'].includes(resolved.state))
252
+ selectedId = proposals[Math.min(selected + 1, proposals.length - 1)]!.id;
253
+ } else if (action === 'dismiss') store.dismissProposal(proposal.id, proposal.revision);
254
+ else if (action === 'edit') {
255
+ if (proposal.state !== 'pending')
256
+ throw new Error(
257
+ 'Only pending proposals can be edited. Unresolved writes are never retried.',
258
+ );
259
+ const draft = proposal.draft ?? proposal;
260
+ const text = await ctx.ui.editor(
261
+ 'Edit proposal JSON (save draft only; dates use YYYYMMDDTHHMMSSZ)',
262
+ exact({ change: draft.change, expected: draft.expected, question: draft.question }, 2),
263
+ );
264
+ if (text !== undefined) {
265
+ const edited = JSON.parse(text) as ProposalDraft;
266
+ validateDraft(edited);
267
+ store.editProposal(proposal.id, proposal.revision, edited);
268
+ message = 'Draft saved. Review the new preview before applying.';
269
+ }
270
+ }
271
+ } catch (error) {
272
+ message = String(error);
273
+ }
274
+ }
275
+ }
@@ -0,0 +1,290 @@
1
+ import { resolve } from 'node:path';
2
+ import { Type } from '@earendil-works/pi-ai';
3
+ import type { Evidence } from './evidence.js';
4
+
5
+ export type TaskFields = {
6
+ description?: string;
7
+ project?: string | null;
8
+ due?: string | null;
9
+ wait?: string | null;
10
+ scheduled?: string | null;
11
+ priority?: 'H' | 'M' | 'L' | null;
12
+ waitingon?: string | null;
13
+ tags?: string[];
14
+ depends?: string[];
15
+ };
16
+ export type TaskSnapshot = {
17
+ uuid: string;
18
+ status: 'pending' | 'completed' | 'deleted' | 'waiting' | 'recurring';
19
+ fields: TaskFields & { description: string };
20
+ annotations: { entry: string; description: string }[];
21
+ };
22
+ export type TaskChange =
23
+ | { operation: 'add'; fields: TaskFields & { description: string }; annotations: string[] }
24
+ | { operation: 'update'; targetUuid: string; fields: TaskFields; annotations: string[] }
25
+ | { operation: 'complete'; targetUuid: string; annotations: string[] };
26
+ export type ProposalDraft = {
27
+ change: TaskChange;
28
+ expected: TaskSnapshot | null;
29
+ question: string | null;
30
+ };
31
+ export type EvidenceReference = Pick<Evidence, 'sessionId' | 'branchId' | 'entryId' | 'editId'> & {
32
+ offset: number;
33
+ quote: string;
34
+ };
35
+ export type ProposalSource = EvidenceReference &
36
+ Pick<Evidence, 'file' | 'role' | 'timestamp'> & { locator: string };
37
+ export type ProposalSubmission = ProposalDraft & {
38
+ id?: string;
39
+ expectedRevision?: number;
40
+ explanation: string;
41
+ references: EvidenceReference[];
42
+ };
43
+ export type ProposalState =
44
+ | 'pending'
45
+ | 'dismissed'
46
+ | 'applying'
47
+ | 'applied'
48
+ | 'already_satisfied'
49
+ | 'uncertain';
50
+ export type ApplicationResult = { actual?: Record<string, unknown> | null } & (
51
+ | { state: 'applied' | 'already_satisfied'; verified: TaskSnapshot; error: null }
52
+ | { state: 'uncertain'; verified: TaskSnapshot | null; error: string }
53
+ );
54
+ export type Proposal = ProposalDraft & {
55
+ id: string;
56
+ revision: number;
57
+ draft: ProposalDraft | null;
58
+ explanation: string;
59
+ sources: ProposalSource[];
60
+ state: ProposalState;
61
+ claim: string | null;
62
+ applicationBefore?: TaskSnapshot | null;
63
+ result: ApplicationResult | null;
64
+ createdAt: string;
65
+ updatedAt: string;
66
+ history?: Omit<Proposal, 'history'>[];
67
+ };
68
+
69
+ export function stringEnumSchema<const Values extends readonly string[]>(values: Values) {
70
+ return Type.Unsafe<Values[number]>({
71
+ type: 'string',
72
+ enum: values as unknown as Values[number][],
73
+ });
74
+ }
75
+
76
+ const nullableText = Type.Union([Type.String(), Type.Null()]);
77
+ const taskFieldProperties = {
78
+ description: Type.Optional(Type.String()),
79
+ project: Type.Optional(nullableText),
80
+ due: Type.Optional(nullableText),
81
+ wait: Type.Optional(nullableText),
82
+ scheduled: Type.Optional(nullableText),
83
+ priority: Type.Optional(Type.Union([stringEnumSchema(['H', 'M', 'L']), Type.Null()])),
84
+ waitingon: Type.Optional(nullableText),
85
+ tags: Type.Optional(Type.Array(Type.String())),
86
+ depends: Type.Optional(Type.Array(Type.String())),
87
+ };
88
+ const fieldsSchema = Type.Object(taskFieldProperties, { additionalProperties: false });
89
+ const addFieldsSchema = Type.Object(
90
+ { ...taskFieldProperties, description: Type.String() },
91
+ { additionalProperties: false },
92
+ );
93
+ const annotationsSchema = Type.Array(Type.String());
94
+ export const proposalParameters = Type.Object(
95
+ {
96
+ id: Type.Optional(Type.String()),
97
+ expectedRevision: Type.Optional(Type.Integer({ minimum: 1 })),
98
+ change: Type.Union([
99
+ Type.Object(
100
+ { operation: Type.Literal('add'), fields: addFieldsSchema, annotations: annotationsSchema },
101
+ { additionalProperties: false },
102
+ ),
103
+ Type.Object(
104
+ {
105
+ operation: Type.Literal('update'),
106
+ targetUuid: Type.String(),
107
+ fields: fieldsSchema,
108
+ annotations: annotationsSchema,
109
+ },
110
+ { additionalProperties: false },
111
+ ),
112
+ Type.Object(
113
+ {
114
+ operation: Type.Literal('complete'),
115
+ targetUuid: Type.String(),
116
+ annotations: annotationsSchema,
117
+ },
118
+ { additionalProperties: false },
119
+ ),
120
+ ]),
121
+ expected: Type.Union([
122
+ Type.Null(),
123
+ Type.Object(
124
+ {
125
+ uuid: Type.String(),
126
+ status: stringEnumSchema(['pending', 'completed', 'deleted', 'waiting', 'recurring']),
127
+ fields: addFieldsSchema,
128
+ annotations: Type.Array(
129
+ Type.Object(
130
+ { entry: Type.String(), description: Type.String() },
131
+ { additionalProperties: false },
132
+ ),
133
+ ),
134
+ },
135
+ { additionalProperties: false },
136
+ ),
137
+ ]),
138
+ question: nullableText,
139
+ explanation: Type.String(),
140
+ references: Type.Array(
141
+ Type.Object(
142
+ {
143
+ sessionId: Type.String(),
144
+ branchId: Type.String(),
145
+ entryId: Type.String(),
146
+ editId: nullableText,
147
+ offset: Type.Integer({ minimum: 0 }),
148
+ quote: Type.String(),
149
+ },
150
+ { additionalProperties: false },
151
+ ),
152
+ { minItems: 1 },
153
+ ),
154
+ },
155
+ { additionalProperties: false },
156
+ );
157
+
158
+ function object(value: unknown, keys: readonly string[]): asserts value is Record<string, unknown> {
159
+ if (
160
+ !value ||
161
+ typeof value !== 'object' ||
162
+ Array.isArray(value) ||
163
+ Object.keys(value).some((key) => !keys.includes(key))
164
+ )
165
+ throw new Error('Invalid proposal fields');
166
+ }
167
+ function text(value: unknown): asserts value is string {
168
+ if (typeof value !== 'string' || !value.trim()) throw new Error('Expected nonempty text');
169
+ }
170
+ function uuid(value: unknown): asserts value is string {
171
+ if (typeof value !== 'string' || !/^[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12}$/iu.test(value))
172
+ throw new Error('Expected full task UUID');
173
+ }
174
+ function fields(value: unknown) {
175
+ object(value, [
176
+ 'description',
177
+ 'project',
178
+ 'due',
179
+ 'wait',
180
+ 'scheduled',
181
+ 'priority',
182
+ 'waitingon',
183
+ 'tags',
184
+ 'depends',
185
+ ]);
186
+ for (const [key, item] of Object.entries(value)) {
187
+ if (key === 'tags' || key === 'depends') {
188
+ if (!Array.isArray(item)) throw new Error('Expected task field array');
189
+ for (const element of item) {
190
+ if (key === 'depends') uuid(element);
191
+ else text(element);
192
+ }
193
+ } else if (key === 'priority') {
194
+ if (item !== null && !['H', 'M', 'L'].includes(item as string))
195
+ throw new Error('Invalid priority');
196
+ } else if (item !== null || key === 'description') text(item);
197
+ }
198
+ }
199
+ export function validateSnapshot(value: TaskSnapshot): void {
200
+ object(value, ['uuid', 'status', 'fields', 'annotations']);
201
+ uuid(value.uuid);
202
+ if (!['pending', 'completed', 'deleted', 'waiting', 'recurring'].includes(value.status))
203
+ throw new Error('Invalid task status');
204
+ fields(value.fields);
205
+ text(value.fields.description);
206
+ if (!Array.isArray(value.annotations)) throw new Error('Invalid annotations');
207
+ for (const annotation of value.annotations) {
208
+ object(annotation, ['entry', 'description']);
209
+ text(annotation.entry);
210
+ text(annotation.description);
211
+ }
212
+ }
213
+ export function validateDraft(value: ProposalDraft): void {
214
+ object(value, ['change', 'expected', 'question']);
215
+ const change = value.change;
216
+ object(
217
+ change,
218
+ change?.operation === 'add'
219
+ ? ['operation', 'fields', 'annotations']
220
+ : change?.operation === 'complete'
221
+ ? ['operation', 'targetUuid', 'annotations']
222
+ : ['operation', 'targetUuid', 'fields', 'annotations'],
223
+ );
224
+ if (!['add', 'update', 'complete'].includes(change.operation))
225
+ throw new Error('Invalid operation');
226
+ if (!Array.isArray(change.annotations)) throw new Error('Invalid annotations');
227
+ change.annotations.forEach(text);
228
+ if (change.operation !== 'complete') fields(change.fields);
229
+ if (change.operation === 'add') {
230
+ text(change.fields.description);
231
+ if (value.expected !== null) throw new Error('Add cannot have an expected task');
232
+ } else {
233
+ uuid(change.targetUuid);
234
+ if (!value.expected) throw new Error('Existing task requires expected snapshot');
235
+ validateSnapshot(value.expected);
236
+ if (value.expected.uuid !== change.targetUuid)
237
+ throw new Error('Task snapshot does not match target');
238
+ }
239
+ if (value.question !== null) text(value.question);
240
+ }
241
+ export function validateSubmission(
242
+ value: ProposalSubmission,
243
+ evidence: readonly Evidence[],
244
+ ): ProposalSource[] {
245
+ object(value, [
246
+ 'id',
247
+ 'expectedRevision',
248
+ 'change',
249
+ 'expected',
250
+ 'question',
251
+ 'explanation',
252
+ 'references',
253
+ ]);
254
+ validateDraft({ change: value.change, expected: value.expected, question: value.question });
255
+ text(value.explanation);
256
+ if ((value.id === undefined) !== (value.expectedRevision === undefined))
257
+ throw new Error('Revision requires proposal ID');
258
+ if (value.id !== undefined) {
259
+ text(value.id);
260
+ if (!Number.isSafeInteger(value.expectedRevision) || value.expectedRevision! < 1)
261
+ throw new Error('Invalid expected revision');
262
+ }
263
+ if (!Array.isArray(value.references) || !value.references.length)
264
+ throw new Error('Proposal requires eligible evidence');
265
+ return value.references.map((ref) => {
266
+ object(ref, ['sessionId', 'branchId', 'entryId', 'editId', 'offset', 'quote']);
267
+ text(ref.quote);
268
+ const item = evidence.find(
269
+ (item) =>
270
+ item.sessionId === ref.sessionId &&
271
+ item.branchId === ref.branchId &&
272
+ item.entryId === ref.entryId &&
273
+ item.editId === ref.editId,
274
+ );
275
+ if (
276
+ !item ||
277
+ !Number.isSafeInteger(ref.offset) ||
278
+ ref.offset < 0 ||
279
+ item.text.slice(ref.offset, ref.offset + ref.quote.length) !== ref.quote
280
+ )
281
+ throw new Error('Reference does not match frozen eligible evidence');
282
+ return {
283
+ ...ref,
284
+ file: resolve(item.file),
285
+ role: item.role,
286
+ timestamp: item.timestamp,
287
+ locator: `${item.sessionId}/${item.branchId}/${item.entryId}`,
288
+ };
289
+ });
290
+ }