MCPcopy Create free account
hub / github.com/SethGammon/Citadel / markerIsExpired

Function markerIsExpired

scripts/state-hygiene.js:63–72  ·  view source on GitHub ↗

* Decide whether a consent marker file is expired. * A marker that cannot be parsed or has an invalid timestamp can never grant * access again (the read paths treat it as absent), so it counts as expired.

(filePath, ttlMs, nowMs)

Source from the content-addressed store, hash-verified

61 * access again (the read paths treat it as absent), so it counts as expired.
62 */
63function markerIsExpired(filePath, ttlMs, nowMs) {
64 try {
65 const marker = JSON.parse(fs.readFileSync(filePath, 'utf8'));
66 const age = nowMs - new Date(marker.timestamp).getTime();
67 if (Number.isNaN(age)) return true; // invalid timestamp, dead marker
68 return age >= ttlMs;
69 } catch {
70 return true; // unreadable or malformed, dead marker
71 }
72}
73
74/**
75 * Sweep expired consent markers of one kind from the plugin data dir.

Callers 1

sweepMarkersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected