Initial import of streamline

This commit is contained in:
2026-11-16 17:26:44 -08:00
commit 8e4aec1855
1221 changed files with 274256 additions and 0 deletions
+101
View File
@@ -0,0 +1,101 @@
/**
* One-off op: rebalance a slice of ios queue onto the freshly-added
* `fei-ios-02.shiro0.icu` by RE-EVALUATING (not just re-homing).
*
* Context: existing queued features were `evaluate`d on ios-01, which pinned
* their `executorNodeId` to ios-01 (claim-time binding, see db.claimEvalForNode),
* so only ios-01 would ever schedule them. To move real work to ios-02 the owner
* asked to send a portion BACK to eval on ios-02 — a true re-eval, ending at
* `pending_confirmation` (fresh plan, needs re-confirm), NOT a plan-preserving
* re-home.
*
* Scope (owner-approved): 5 FEATURES from `awaiting_implementation` that were
* NEVER executed (attempts=0, no branch/MR/log/review/startedAt), oldest-first.
* For each we:
* 1. DELETE the existing workspace dir ON ios-01 (its current executor node),
* via the satellite's removeWorkspace endpoint — done BEFORE re-pointing so
* forwardFeatureToNode still resolves to ios-01.
* 2. Reset the row to `initializing` + executorNodeId=ios-02 + cleared plan /
* workspace / timing, so ios-02's eval loop claims and re-evals it. Goes
* through updateFeature → notifyStatusTransition fires (/lifemon ledger +
* status webhooks), unlike a raw SQL UPDATE.
*
* DRY-RUN by default (prints the plan); pass --commit to actually mutate:
* bun scripts/reeval_migrate_ios02.ts # preview only
* bun scripts/reeval_migrate_ios02.ts --commit # execute
*
* Note: this runs as a SEPARATE process from the live control-server, so it
* cannot push WS `feature:updated` events — refresh the board/console to see
* the moved items. The DB is the SSOT, so ios-02's next eval poll picks them up.
*/
import { getFeature, updateFeature } from "../control-server/src/db";
import { forwardFeatureToNode, satPath } from "../control-server/src/cluster";
const COMMIT = process.argv.includes("--commit");
const HOME_NODE = "fei-ios-01.shiro0.icu";
const TARGET_NODE = "fei-ios-02.shiro0.icu";
const MOVABLE_STATUS = "awaiting_implementation";
// The 5 oldest never-executed features on ios-01 (owner-approved slice).
// Hardcoded so the migration acts on EXACTLY the reviewed set, not a live re-query
// that could drift; each is re-validated against the eligibility rule below.
const TARGET_IDS = [
"8613f045-7ed7-4f35-bb1a-182870491cf9", // 视频内流 DM 输入框优化
"db878256-4398-4aac-9f02-fe3812005a29", // 聊天页灰阶优化
"cfea926a-38f2-4bb5-b71d-3b42d28ce5d7", // 视频内流点击输入框后拉起的 DM 回复面板输入框优化
"ffff3280-4dea-48bf-bb7f-25354b3a0bce", // 线上:同个 Story 短时间内多个回复带 story quote 卡
"35908902-4f1b-4d68-95c4-2881a54d01ec", // 聊天页新增震感反馈
];
/** Never-executed + still queued on the home node = safe to re-eval elsewhere. */
function eligibility(f: NonNullable<ReturnType<typeof getFeature>>): string | null {
if (f.status !== MOVABLE_STATUS) return `status=${f.status} (expected ${MOVABLE_STATUS})`;
if (f.executorNodeId !== HOME_NODE) return `executorNodeId=${f.executorNodeId} (expected ${HOME_NODE})`;
if ((f.attempts ?? 0) !== 0) return `attempts=${f.attempts} (expected 0 — already executed)`;
if (f.startedAt || f.branchName || f.mrUrl || f.logPath || (f.reviewHistory?.length ?? 0) > 0)
return "carries execution history (branch/MR/log/review/startedAt)";
return null;
}
/** The re-eval reset patch: back to eval, pinned to ios-02, plan+workspace+clock cleared. */
const resetPatch = {
status: "initializing" as const,
executorNodeId: TARGET_NODE,
executionPlan: null,
workspacePath: null,
regenContext: null,
evalLogPath: null,
failureReason: null,
startedAt: null,
finishedAt: null,
durationMs: null,
totalDurationMs: null,
};
console.log(`[reeval_migrate_ios02] mode=${COMMIT ? "COMMIT" : "DRY-RUN"} ${HOME_NODE} → ${TARGET_NODE}\n`);
let done = 0, skipped = 0;
for (const id of TARGET_IDS) {
const f = getFeature(id);
if (!f) { console.log(` SKIP ${id} — not found`); skipped++; continue; }
const bad = eligibility(f);
if (bad) { console.log(` SKIP ${id.slice(0, 8)} ${f.title}\n reason: ${bad}`); skipped++; continue; }
console.log(` MOVE ${id.slice(0, 8)} ${f.title}`);
console.log(` rm ws on ${HOME_NODE}: ${f.workspacePath ?? "(none)"}`);
console.log(` → ${MOVABLE_STATUS}/@${HOME_NODE} ⇒ initializing/@${TARGET_NODE} (re-eval)`);
if (COMMIT) {
// 1) Remove the ios-01 workspace FIRST — resolves via current executorNodeId.
const removed = await forwardFeatureToNode(f, satPath.feature.removeWorkspace, { method: "DELETE" });
console.log(` workspace delete on ${HOME_NODE}: ${removed ? "ok" : "FAILED (node said no / unreachable)"}`);
// 2) Re-point + reset to eval (fires notifyStatusTransition → ledger + webhooks).
updateFeature(id, resetPatch);
console.log(` db reset: done`);
}
done++;
}
console.log(`\n[reeval_migrate_ios02] ${COMMIT ? "committed" : "planned"} ${done} move(s), ${skipped} skipped.`);
if (!COMMIT) console.log("[reeval_migrate_ios02] DRY-RUN — nothing changed. Re-run with --commit to execute.");