Skip to content

Commit 54ea3f3

Browse files
committed
Merge branch 'codex/oar-deep-fusion-phase3' into codex/oar-deep-fusion-phase4-runtimes
Signed-off-by: song <xinxinsong66@gmail.com>
2 parents 4451fba + ae970a9 commit 54ea3f3

106 files changed

Lines changed: 7211 additions & 646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/python-tests.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ jobs:
216216
run: |
217217
python -m pip install --disable-pip-version-check -e ".[test]"
218218
node apps/presentation/dashboard/smoke/team-task-revalidation-smoke.mjs
219+
- name: Qualify packaged remote task inspection and recovery
220+
if: matrix.shard == 2
221+
working-directory: apps/presentation/dashboard
222+
run: npm run smoke:remote-authority-inspection
223+
- name: Preserve synthetic remote task inspection views
224+
if: always() && matrix.shard == 2
225+
uses: actions/upload-artifact@v7
226+
with:
227+
name: remote-authority-inspection-${{ github.sha }}
228+
path: output/playwright/remote-authority-inspection/
229+
if-no-files-found: ignore
230+
retention-days: 7
219231
- name: Preserve synthetic original-task recovery views
220232
if: always() && matrix.shard == 2
221233
uses: actions/upload-artifact@v7

‎apps/presentation/dashboard/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"smoke:delivery-review": "tsc --ignoreConfig --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck --strict --rootDir src --outDir node_modules/.cache/delivery-review src/data/delivery-review.ts src/data/goal-work-map.ts src/data/goal-acceptance-observation.ts src/features/personal-workspace/delivery-review-copy.ts && node smoke/delivery-review-smoke.mjs",
7676
"smoke:team-artifact-comparison": "tsc --noEmit && vite build --ssr smoke/team-artifact-comparison-smoke.mjs --outDir node_modules/.cache/team-comparison --emptyOutDir && node node_modules/.cache/team-comparison/team-artifact-comparison-smoke.js",
7777
"smoke:settings-target": "vite build --ssr smoke/settings-target-smoke.mjs --outDir node_modules/.cache/settings-target --emptyOutDir && node node_modules/.cache/settings-target/settings-target-smoke.js",
78+
"smoke:remote-authority-inspection": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node smoke/remote-authority-inspection-browser-smoke.mjs",
7879
"smoke:team-report": "node --no-warnings --experimental-strip-types --test src/features/personal-workspace/markdown-blocks.test.mjs && vite build --ssr smoke/team-report-smoke.mjs --outDir node_modules/.cache/team-report --emptyOutDir && node node_modules/.cache/team-report/team-report-smoke.js",
7980
"build:chat:vite": "tsc --noEmit && vite build --config vite.chat.config.ts",
8081
"smoke:chat-upgrade": "LOOPX_PLAYWRIGHT_PACKAGE=\"$PWD/node_modules/playwright\" node ../../../examples/chat-bundle-upgrade-browser-smoke.mjs",
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Packaged App -> real Chat route -> typed inspection -> synthetic HTTPS peer.
2+
import assert from "node:assert/strict";
3+
import {spawn} from "node:child_process";
4+
import {createInterface} from "node:readline";
5+
import {once} from "node:events";
6+
import {mkdtemp, mkdir, rm} from "node:fs/promises";
7+
import {tmpdir} from "node:os";
8+
import {resolve} from "node:path";
9+
import {fileURLToPath} from "node:url";
10+
import {testPythonCommand} from "../../../../scripts/test-python.mjs";
11+
import {launchBrowser, loadPlaywright} from "../../../../examples/dashboard-browser-smoke-support.mjs";
12+
import {openWorkspacePage} from "../../../../examples/personal-workspace-browser/scenario-context.mjs";
13+
14+
const root = fileURLToPath(new URL("../../../../", import.meta.url));
15+
const temporary = await mkdtemp(resolve(tmpdir(), "loopx-remote-inspection-"));
16+
const output = resolve(root, "output/playwright/remote-authority-inspection");
17+
const baseline = process.env.LOOPX_REMOTE_INSPECT_BASELINE_ASSETS;
18+
const arguments_ = ["fixture", "--root", temporary, ...(baseline ? ["--assets", baseline] : [])];
19+
const python = testPythonCommand(`
20+
import runpy
21+
sys.argv = ${JSON.stringify(arguments_)}
22+
runpy.run_module("tests.control_plane.remote_authority_browser_fixture", run_name="__main__")
23+
`);
24+
const server = spawn(python.command, python.args, {cwd: root,
25+
env: {...process.env, LOOPX_USAGE_PING: "0"}, stdio: ["pipe", "pipe", "pipe"]});
26+
const replies = [], waiting = [];
27+
let diagnostics = "", browser, session, release;
28+
const lines = createInterface({input: server.stdout});
29+
lines.on("line", line => {
30+
const reply = JSON.parse(line);
31+
if (waiting.length) waiting.shift().resolve(reply); else replies.push(reply);
32+
});
33+
server.stderr.on("data", chunk => {diagnostics = (diagnostics + chunk).slice(-4000);});
34+
server.on("exit", code => {for (const waiter of waiting.splice(0)) waiter.reject(new Error(`Fixture exited ${code}: ${diagnostics}`));});
35+
function reply() {
36+
return replies.length ? Promise.resolve(replies.shift()) : new Promise((resolveReply, reject) => {
37+
const timer = setTimeout(() => reject(new Error(`Fixture response timed out: ${diagnostics}`)), 20000);
38+
waiting.push({resolve: value => {clearTimeout(timer); resolveReply(value);}, reject: error => {clearTimeout(timer); reject(error);}});
39+
});
40+
}
41+
async function control(value = {}) {server.stdin.write(JSON.stringify(value) + "\n"); return await reply();}
42+
try {
43+
const {origin} = await reply();
44+
await mkdir(output, {recursive: true});
45+
browser = await launchBrowser(loadPlaywright().chromium);
46+
let hold = false, fail = false, requestHeld;
47+
session = await openWorkspacePage(browser, origin + "/chat/?statusUrl=/status.json", {
48+
apiOptions: {fixturePort: Number(new URL(origin).port)},
49+
viewport: {width: 1440, height: 1000}, gotoWaitUntil: "domcontentloaded",
50+
beforeGoto: async (_api, page) => {
51+
await page.addInitScript(() => localStorage.setItem("loopx-pw-locale", "en"));
52+
await page.route("**/api/chat/goal-configuration/remote-authority/inspect", async route => {
53+
if (hold) await new Promise(resolveRequest => {release = resolveRequest; requestHeld();});
54+
if (fail) await route.abort(); else await route.continue();
55+
});
56+
},
57+
});
58+
const {page} = session;
59+
page.setDefaultTimeout(15000);
60+
await page.goto(origin + "/chat/?statusUrl=/status.json&settings_scope=goal&settings_goal=product-release&settings_tab=capabilities",
61+
{waitUntil: "domcontentloaded"});
62+
await page.locator(".personal-capability-settings").waitFor();
63+
assert.equal((await control()).requests, 0, "discovery never contacts the remote service");
64+
if (baseline) {
65+
assert.equal(await page.getByRole("region", {name: "Remote task connection"}).count(), 0);
66+
await page.screenshot({path: resolve(output, "before-desktop.png")});
67+
await page.setViewportSize({width: 390, height: 844});
68+
await page.screenshot({path: resolve(output, "before-narrow.png")});
69+
} else {
70+
const panel = page.getByRole("region", {name: "Remote task connection"});
71+
await panel.getByRole("button", {name: "Check connection", exact: true}).click();
72+
await panel.getByText("Read verified", {exact: true}).waitFor();
73+
await page.screenshot({path: resolve(output, "success-desktop.png")});
74+
assert.equal((await control({mode: "denied"})).requests, 1);
75+
await panel.getByRole("button", {name: "Check again", exact: true}).click();
76+
await panel.getByText("Read unverified", {exact: true}).waitFor();
77+
await page.screenshot({path: resolve(output, "denied-desktop.png")});
78+
assert.equal((await control({mode: "found"})).requests, 2);
79+
await panel.getByRole("button", {name: "Check again", exact: true}).click();
80+
await panel.getByText("Read verified", {exact: true}).waitFor();
81+
assert.equal((await control()).requests, 3);
82+
83+
hold = true;
84+
const held = new Promise(resolveHeld => {requestHeld = resolveHeld;});
85+
const delayedResponse = page.waitForResponse(response => response.url().endsWith("/remote-authority/inspect"));
86+
await panel.getByRole("button", {name: "Check again", exact: true}).click();
87+
await held;
88+
await panel.getByRole("button", {name: "Checking…", exact: true}).waitFor();
89+
assert.equal(await panel.getByRole("button").isDisabled(), true);
90+
const target = page.locator(".personal-settings-goal-choice select");
91+
const other = await target.locator("option").evaluateAll(options => options.find(option => option.value && option.value !== "product-release").value);
92+
await target.selectOption(other);
93+
hold = false;
94+
release();
95+
await (await delayedResponse).finished();
96+
assert.equal(await panel.getByText("Read verified", {exact: true}).count(), 0, "stale results cannot cross Goals");
97+
await target.selectOption("product-release");
98+
fail = true;
99+
await panel.getByRole("button", {name: "Check connection", exact: true}).click();
100+
await panel.getByRole("alert").waitFor();
101+
fail = false;
102+
await control({mode: "denied"});
103+
await panel.getByRole("button", {name: "Check again", exact: true}).click();
104+
await panel.getByText("Read unverified", {exact: true}).waitFor();
105+
await page.setViewportSize({width: 390, height: 844});
106+
await page.screenshot({path: resolve(output, "denied-narrow.png")});
107+
assert.ok(await panel.evaluate(element => element.getBoundingClientRect().right <= innerWidth + 1), "narrow view has no horizontal overflow");
108+
const editor = page.locator(".personal-capability-detail");
109+
await editor.getByRole("heading", {name: "Periodic reports", exact: true}).scrollIntoViewIfNeeded();
110+
assert.ok(await editor.evaluate(element => element.clientHeight >= 200), "inspection preserves a usable settings editor on narrow screens");
111+
await editor.getByRole("combobox").first().click();
112+
await page.keyboard.press("Escape");
113+
await page.screenshot({path: resolve(output, "settings-narrow.png")});
114+
assert.equal((await control()).unchanged, true, "inspection never mutates local authority");
115+
assert.equal(session.errors.filter(error => !error.includes("net::ERR_FAILED")).length, 0, session.errors.join("\n"));
116+
}
117+
console.log(baseline ? "Captured baseline packaged Goal settings" : "Packaged inspection, denial/recovery, scope fencing, network failure and state parity passed");
118+
} finally {
119+
release?.();
120+
await session?.close();
121+
await browser?.close();
122+
const stopped = server.exitCode === null ? once(server, "exit") : Promise.resolve();
123+
server.stdin.end();
124+
server.kill("SIGTERM");
125+
await stopped;
126+
await rm(temporary, {recursive: true, force: true});
127+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {z} from "zod";
2+
import {requestJson} from "./chat";
3+
4+
// Validate the existing owner's safe projection, never interpret a wire reply
5+
// or accept execution authority in the browser.
6+
const inspectionSchema = z.object({
7+
schema_version: z.literal("loopx_remote_authority_inspection_v1"),
8+
ok: z.boolean(), status: z.enum(["verified", "unavailable"]),
9+
stage: z.string(), reason_code: z.string(), message: z.string(), recommended_action: z.string(),
10+
execution_admitted: z.literal(false), http_status: z.number().int().optional(),
11+
}).strict().refine(value => value.ok === (value.status === "verified"));
12+
export type RemoteAuthorityInspection = z.infer<typeof inspectionSchema>;
13+
14+
export async function inspectGoalRemoteAuthority(goalId: string): Promise<RemoteAuthorityInspection> {
15+
const response = z.object({goal_id: z.string(), inspection: inspectionSchema}).strict().parse(
16+
await requestJson<unknown>("/api/chat/goal-configuration/remote-authority/inspect", {
17+
method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({goal_id: goalId}),
18+
}),
19+
);
20+
if (response.goal_id !== goalId) throw new Error("Inspection returned a different Goal");
21+
return response.inspection;
22+
}

‎apps/presentation/dashboard/src/features/personal-workspace/personal-workspace.css‎

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import {useLayoutEffect, useRef, useState} from "react";
2+
import {CheckCircle2, LoaderCircle, RefreshCw, AlertTriangle} from "lucide-react";
3+
import {inspectGoalRemoteAuthority, type RemoteAuthorityInspection} from "../../data/remote-authority";
4+
import {useWorkspaceI18n} from "./i18n";
5+
6+
// Presentation copy only; the existing owner decides the diagnostic and authority.
7+
const chineseDiagnostics: Record<string, string> = {
8+
goal_unregistered: "当前 Goal 未注册,请重新选择已有 Goal。",
9+
actor_unregistered: "远程配置中的成员未在此 Goal 注册,请检查成员配置。",
10+
disabled: "此 Goal 尚未启用远程连接,本地任务不受影响。",
11+
binding_incomplete: "此 Goal 的远程连接配置不完整,请补齐已有配置后重试。",
12+
binding_invalid: "此 Goal 的远程连接配置无效,请检查配置格式。",
13+
actor_mismatch: "当前成员与远程配置不一致,请检查成员配置。",
14+
endpoint_invalid: "远程服务地址无效,请使用不含凭据或路径的 HTTPS 地址。",
15+
credential_required: "缺少服务凭据,请在运行 LoopX 的环境中配置后重试。",
16+
credential_invalid: "服务凭据格式无效,请检查运行 LoopX 的环境配置。",
17+
ca_invalid: "无法读取证书文件,请检查证书文件路径和权限。",
18+
dns: "无法解析远程服务地址,请检查地址和网络连接。",
19+
connection_refused: "远程服务拒绝连接,请检查服务是否运行及端口是否正确。",
20+
tls: "安全连接未通过验证,请检查服务证书、域名和证书有效期。",
21+
connection: "连接中断,请检查网络和服务状态后重试。",
22+
timeout: "检查超时,请检查网络和服务响应后重试。",
23+
http: "远程服务返回 HTTP 错误,请检查服务和代理配置。",
24+
response_invalid: "服务响应无法验证,请检查客户端与服务端的兼容性。",
25+
response_too_large: "服务响应超出读取限制,请检查服务地址是否正确。",
26+
unauthenticated: "服务拒绝了当前凭据,请检查凭据是否有效。",
27+
scope_denied: "当前凭据无权读取此 Goal 的任务,请联系服务管理员核对权限。",
28+
rejected: "服务拒绝读取,请联系服务管理员核对配置和访问策略。",
29+
todo_missing: "未找到配置中的检查任务,请核对任务和访问范围。",
30+
read_unverified: "任务读取未通过验证,请检查服务和连接配置。",
31+
read_verified: "已验证配置中的任务读取。此检查不会启动任务。",
32+
registry_unreadable: "无法读取本地 Goal 注册信息,请检查文件格式和访问权限。",
33+
node_unavailable: "本地运行环境不可用,请运行 LoopX 安装诊断并修复。",
34+
probe_unavailable: "本地检查程序未返回有效结果,请运行 LoopX 安装诊断后重试。",
35+
};
36+
37+
export function GoalRemoteAuthorityInspection({goalId}: Readonly<{goalId: string}>) {
38+
const {locale} = useWorkspaceI18n();
39+
const zh = locale === "zh-CN";
40+
const [result, setResult] = useState<RemoteAuthorityInspection | null>(null);
41+
const [failed, setFailed] = useState(false);
42+
const [busy, setBusy] = useState(false);
43+
const generation = useRef(0);
44+
useLayoutEffect(() => {
45+
generation.current++;
46+
setResult(null); setFailed(false); setBusy(false);
47+
return () => {generation.current++;};
48+
}, [goalId]);
49+
50+
async function inspect() {
51+
const current = ++generation.current;
52+
setBusy(true); setFailed(false); setResult(null);
53+
try {
54+
const value = await inspectGoalRemoteAuthority(goalId);
55+
if (current === generation.current) setResult(value);
56+
} catch {
57+
if (current === generation.current) setFailed(true);
58+
} finally {
59+
if (current === generation.current) setBusy(false);
60+
}
61+
}
62+
63+
const title = zh ? "远程任务连接" : "Remote task connection";
64+
const translated = result && zh ? chineseDiagnostics[result.reason_code.replace(/^remote_authority_/, "")] : null;
65+
return <section className="personal-remote-authority" aria-label={title}>
66+
<div className="personal-remote-authority-heading">
67+
<div><h3>{title}</h3><p>{zh ? "读取此 Goal 的已配置任务,不会启动工作。" : "Read this Goal’s configured task without starting work."}</p></div>
68+
<button type="button" disabled={busy} onClick={() => void inspect()}>
69+
{busy ? <LoaderCircle aria-hidden size={16} className="personal-spin" /> : <RefreshCw aria-hidden size={16} />}
70+
{busy ? (zh ? "检查中…" : "Checking…") : result || failed ? (zh ? "重新检查" : "Check again") : (zh ? "检查连接" : "Check connection")}
71+
</button>
72+
</div>
73+
<div aria-live="polite" aria-busy={busy}>
74+
{failed ? <p className="personal-machine-error" role="alert">{zh ? "未能完成检查,请重试。" : "The check could not finish. Please try again."}</p> : null}
75+
{result ? <div className="personal-remote-authority-result" data-verified={result.ok}>
76+
<strong>{result.ok ? <CheckCircle2 aria-hidden size={16} /> : <AlertTriangle aria-hidden size={16} />}
77+
{result.ok ? (zh ? "读取已验证" : "Read verified") : (zh ? "读取未验证" : "Read unverified")}</strong>
78+
<p>{translated || result.message}</p>
79+
{!result.ok && !translated ? <p>{result.recommended_action}</p> : null}
80+
<details><summary>{zh ? "诊断详情" : "Diagnostic details"}</summary>
81+
<code>{result.reason_code}</code>
82+
{result.http_status !== undefined ? <p>HTTP {result.http_status}</p> : null}
83+
<p>{zh ? "检查结果不会授予任务执行权限。" : "This result does not admit task execution."}</p>
84+
</details>
85+
</div> : null}
86+
</div>
87+
</section>;
88+
}

0 commit comments

Comments
 (0)