MCPcopy
hub / github.com/garrytan/gstack / safeSourcesRemove

Function safeSourcesRemove

bin/gstack-gbrain-sync.ts:536–555  ·  view source on GitHub ↗
(sourceId: string, env?: NodeJS.ProcessEnv)

Source from the content-addressed store, hash-verified

534 * best-effort cleanup).
535 */
536export function safeSourcesRemove(sourceId: string, env?: NodeJS.ProcessEnv): GuardedRemoveResult {
537 const ap = detectAutopilot(env);
538 if (ap.active) {
539 return {
540 removed: false,
541 skipped: true,
542 reason: `autopilot active (${ap.signal}); refusing destructive remove of ${sourceId}. ` +
543 `Stop autopilot, then re-run /sync-gbrain.`,
544 };
545 }
546 const decision = decideSourceRemove(sourceId, env);
547 if (!decision.allow) {
548 return { removed: false, skipped: true, reason: decision.reason };
549 }
550 const r = spawnGbrain(
551 ["sources", "remove", sourceId, "--confirm-destructive", ...decision.extraArgs],
552 { baseEnv: env },
553 );
554 return { removed: r.status === 0, skipped: false, reason: decision.reason };
555}
556
557/**
558 * Remove an orphaned source. Called only after new-source sync verifies pages

Callers 2

removeOrphanedSourceFunction · 0.85
runCodeImportFunction · 0.85

Calls 3

detectAutopilotFunction · 0.90
decideSourceRemoveFunction · 0.90
spawnGbrainFunction · 0.90

Tested by

no test coverage detected