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

Function cleanState

scripts/state-hygiene.js:159–180  ·  view source on GitHub ↗

* Run the hygiene sweep. * * @param {object} [options] * @param {boolean} [options.dryRun=false] Report what would be removed without deleting * @param {string} [options.pluginDataDir] Override consent marker location (tests) * @param {string} [options.planningDir] Override .planning lo

(options = {})

Source from the content-addressed store, hash-verified

157 * Counts are successful removals, or would-be removals when dryRun is true.
158 */
159function cleanState(options = {}) {
160 const dryRun = options.dryRun === true;
161 const pluginDataDir = options.pluginDataDir || DEFAULT_PLUGIN_DATA_DIR;
162 const planningDir = options.planningDir || DEFAULT_PLANNING_DIR;
163 const nowMs = typeof options.now === 'number' ? options.now : Date.now();
164
165 const result = {
166 dryRun,
167 sessionMarkers: 0,
168 onetimeTokens: 0,
169 lockdirs: 0,
170 errors: 0,
171 removed: [],
172 failed: [],
173 };
174
175 sweepMarkers(pluginDataDir, SESSION_MARKER_RE, SESSION_ALLOW_TTL_MS, nowMs, dryRun, result, 'sessionMarkers');
176 sweepMarkers(pluginDataDir, ONETIME_MARKER_RE, ONETIME_TTL_MS, nowMs, dryRun, result, 'onetimeTokens');
177 sweepLockdirs(planningDir, nowMs, dryRun, result, 0);
178
179 return result;
180}
181
182// -- CLI ----------------------------------------------------------------------
183

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 2

sweepMarkersFunction · 0.85
sweepLockdirsFunction · 0.85

Tested by

no test coverage detected