/** * Lexicographic replication priority tiers (boot-critical paths first). * @param {string[]} paths */ export function prioritizeReplicationPaths(paths) { const boot = ['/boot/', '/etc/bare-os/', '/lib/bare-os/', '/bin/'] /** @type {{ path: string, tier: number }[]} */ const scored = [] for (const p of paths) { const path = String(p || '').replace(/\\/g, '/') let tier = 99 for (let i = 0; i < boot.length; i++) { if (path.startsWith(boot[i])) { tier = i break } } scored.push({ path, tier }) } scored.sort((a, b) => a.tier - b.tier || a.path.localeCompare(b.path)) return scored.map((s) => s.path) }