Flip tool-settings to ApplyMode live (archie-core-zfb0.3): the daemon now watches the kind, diffs the stored MCP server set against the running providers -- connecting added servers, disconnecting removed ones and reconnecting changed ones while an unchanged server keeps running -- and rebuilds the web_fetch and minimax entries, whose config is captured at construction. A changed server whose replacement fails to start is rolled back to the one running, and the refusal is reported through apply status. toolprovider.Registry grows running-state Add/Remove/Replace beside Register, Start and Stop, isolating a provider's failure the way the plugin host's Add/Replace do. The chat turn model resolves its tool-output policy per turn instead of capturing it at construction, and the boot registration reads the running holder so a stored update that lands during boot is not lost.
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
applyStateLabel,
|
|
applyStateTone,
|
|
restartPendingTitles,
|
|
} from "../src/settings/apply-status.ts";
|
|
import type { ApplyStatusRow } from "../src/stores/control-plane.ts";
|
|
|
|
const resource = (
|
|
kind: string,
|
|
title: string,
|
|
apply_mode: "live" | "restart-required" | "domain-managed",
|
|
) => ({ kind, title, apply_mode });
|
|
|
|
const behind: ApplyStatusRow[] = [
|
|
{ process: "archie-gateway", state: "pending-restart", version: 6, error: "" },
|
|
];
|
|
const current: ApplyStatusRow[] = [
|
|
{ process: "archied", state: "running", version: 7, error: "" },
|
|
];
|
|
|
|
test("the restart banner names a process-binding change but never a live one", () => {
|
|
const rowsFor = (kind: string) =>
|
|
kind === "plugin-settings" ? behind : kind === "channel-settings" ? behind : current;
|
|
|
|
// Both resources are behind; only the restart-required one is a restart.
|
|
assert.deepEqual(
|
|
restartPendingTitles(
|
|
[
|
|
resource("plugin-settings", "Plugin settings", "live"),
|
|
resource("channel-settings", "Channel settings", "restart-required"),
|
|
],
|
|
rowsFor,
|
|
),
|
|
["Channel settings"],
|
|
);
|
|
|
|
// A live-apply kind behind on a process never earns the banner at all.
|
|
assert.deepEqual(
|
|
restartPendingTitles(
|
|
[resource("plugin-settings", "Plugin settings", "live")],
|
|
() => behind,
|
|
),
|
|
[],
|
|
);
|
|
});
|
|
|
|
test("a live kind reads as applied, and a process-binding change as a restart", () => {
|
|
assert.equal(applyStateLabel("running", "live"), "Applied");
|
|
assert.equal(applyStateLabel("pending-restart", "restart-required"), "Restart pending");
|
|
});
|
|
|
|
test("a live kind's lag never reads as a restart and is not a warning", () => {
|
|
const liveLag = applyStateLabel("pending-restart", "live");
|
|
assert.ok(
|
|
!liveLag.toLowerCase().includes("restart"),
|
|
`a live kind must not be told to restart, got "${liveLag}"`,
|
|
);
|
|
|
|
// A live kind that is behind is not a warning: nothing is broken and no
|
|
// restart is owed, so the row stays neutral.
|
|
assert.equal(applyStateTone("pending-restart", "live"), "idle");
|
|
assert.equal(applyStateTone("pending-restart", "restart-required"), "warn");
|
|
});
|