(sourceId: string, env?: NodeJS.ProcessEnv)
| 534 | * best-effort cleanup). |
| 535 | */ |
| 536 | export 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 |
no test coverage detected