(logicalKey: string, pinned: boolean)
| 179 | } |
| 180 | |
| 181 | async setPinned(logicalKey: string, pinned: boolean): Promise<void> { |
| 182 | await this.mutate((entries) => { |
| 183 | const current = entries[logicalKey] ?? EMPTY_ENTRY; |
| 184 | if (pinned) { |
| 185 | // Pinning counts as a use: it is an explicit signal the file matters, |
| 186 | // and it feeds the same recency/frequency ranking as reads/writes. |
| 187 | entries[logicalKey] = { |
| 188 | ...current, |
| 189 | pinned: true, |
| 190 | accessCount: current.accessCount + 1, |
| 191 | lastAccessedAt: Date.now(), |
| 192 | }; |
| 193 | } else { |
| 194 | // Unpinning preserves usage stats; mutate() drops the entry if empty. |
| 195 | entries[logicalKey] = { ...current, pinned: false }; |
| 196 | } |
| 197 | }); |
| 198 | } |
| 199 | |
| 200 | /** Record a use (read or write) of a memory file at the MemoryService chokepoint. */ |
| 201 | async recordAccess(logicalKey: string, options: { write: boolean }): Promise<void> { |
no test coverage detected