MCPcopy Create free account
hub / github.com/EvoMap/evolver / recordMarkedSession

Function recordMarkedSession

src/adapters/scripts/evolver-session-start.js:407–426  ·  view source on GitHub ↗
(sessionId, info = {})

Source from the content-addressed store, hash-verified

405// NOT read-modify-write to dedupe here — that would race across concurrent
406// sessions; append-only is safe and the file is bounded by session count.
407function recordMarkedSession(sessionId, info = {}) {
408 const sid = String(sessionId || '').trim();
409 if (!sid) return false;
410 const file = getMarkedSessionsPath();
411 try {
412 fs.mkdirSync(path.dirname(file), { recursive: true });
413 const record = {
414 session_id: sid,
415 ...(info.cwd ? { cwd: String(info.cwd) } : {}),
416 ...(info.source ? { source: String(info.source) } : {}),
417 marked_at: new Date().toISOString(),
418 };
419 fs.appendFileSync(file, JSON.stringify(record) + '\n', { encoding: 'utf8', mode: 0o600 });
420 return true;
421 } catch (_) {
422 // Never let a registry write failure break session-start: the context
423 // injection (stdout JSON) must always be emitted.
424 return false;
425 }
426}
427
428// TTL throttle keyed by an arbitrary string. Returns true if `key` fired within
429// the last `ttlMs` (caller should suppress); otherwise records "now" for `key`

Callers 1

finishWithInputFunction · 0.85

Calls 1

getMarkedSessionsPathFunction · 0.85

Tested by

no test coverage detected