mirror of
https://github.com/bitbaum/openclaw.git
synced 2026-12-04 22:17:28 +01:00
* fix(sessions): preserve participant identity and input provenance Keep profile, agent, remote, observed, and legacy identities distinct in the existing participant table. Record accepted input at admission, including steering, instead of inferring a person from the session creator. Preserve historical membership and counts while leaving ambiguous profile timestamps unknown through stopped-writer Doctor migration. Project full visibility-filtered person membership before preview limits so Activity does not misattribute channel identities or omit people outside the facepile. Keep participant membership separate from authorization and expose raw-selector ambiguity to memory operators. Repair Doctor readiness reporting, generic Swift inline-union generation, direct-dispatch metadata handling, and fixture-owned database lifetimes. Verify namespace collisions, real provider input, accepted steering, visibility, backup/migration/reopen boundaries, native decoding, and the built-CLI lifecycle. Fixes #130661 * fix(macos): isolate readiness and discovery lifecycles Keep readiness fixtures private for their entire lifetime and give health readiness one deadline owner. Start and cancel slow host discovery with active discovery, not model construction. Make native protocol, callback, onboarding, and process-cleanup tests observe their intended lifecycle phases without expanding deadlines or weakening assertions. Correct the documented signing default. Validated with 1,839 parallel native tests, the release product build, causal negative controls, pinned Swift lint/format checks, and fresh isolated autoreview. Native production delta: -5 lines. * docs(macos): clarify app profile isolation boundaries * build(protocol): refresh generated Swift install models * fix(protocol): preserve optional literal field presence * fix(ci): bound SDK declarations and isolate test lifecycles Discover the current declaration source graph in a joined child before normal eager emission, and track its complete source-bearing cache inputs. Repair shared jsdom focus teardown and native worker fixture request ordering without changing UI focus ownership or execution fallback policy. * test(sessions): prove Goal participant upgrade boundaries
112 lines
4.6 KiB
TypeScript
112 lines
4.6 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { build } from "tsdown";
|
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
import { discoverDeclarationSources } from "../../scripts/lib/declaration-source-index.mts";
|
|
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
|
|
|
|
describe("declaration source discovery", () => {
|
|
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
|
|
let root: string;
|
|
let tsconfig: string;
|
|
|
|
function write(relativePath: string, contents: string) {
|
|
const file = path.join(root, relativePath);
|
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
fs.writeFileSync(file, contents);
|
|
return file;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
root = fs.realpathSync(tempDirs.make("declaration-source-index-"));
|
|
write("package.json", '{"type":"module"}');
|
|
fs.symlinkSync(path.resolve("node_modules"), path.join(root, "node_modules"), "junction");
|
|
tsconfig = write(
|
|
"tsconfig.plugin-sdk.dts.json",
|
|
JSON.stringify({
|
|
compilerOptions: {
|
|
target: "ES2022",
|
|
module: "NodeNext",
|
|
moduleResolution: "NodeNext",
|
|
strict: true,
|
|
types: [],
|
|
declaration: true,
|
|
emitDeclarationOnly: true,
|
|
paths: { "@fixture/*": ["./contracts/*.ts"] },
|
|
},
|
|
include: ["entries/**/*.ts"],
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("emits aliases and transitive type-only sources outside the selected entry roots", async () => {
|
|
const entry = write(
|
|
"entries/sdk.ts",
|
|
'export { createValue } from "../runtime.js"; export type { Contract } from "@fixture/types";',
|
|
);
|
|
const runtime = write(
|
|
"runtime.ts",
|
|
'import type { Contract } from "@fixture/types"; export function createValue(label: string): Contract { return { label }; }',
|
|
);
|
|
const contract = write("contracts/types.ts", "export type Contract = { label: string };");
|
|
write("entries/unselected.ts", "export type Unselected = never;");
|
|
|
|
const files = discoverDeclarationSources(tsconfig, [entry]);
|
|
expect(files).toEqual([entry, runtime, contract].toSorted());
|
|
const outDir = path.join(root, "output");
|
|
await build({
|
|
config: false,
|
|
entry: { sdk: entry },
|
|
tsconfig,
|
|
dts: { emitDtsOnly: true, eager: true, tsconfigRaw: { files, include: [] } },
|
|
outDir,
|
|
outExtensions: () => ({ dts: ".d.ts" }),
|
|
format: "esm",
|
|
logLevel: "error",
|
|
report: false,
|
|
});
|
|
const declaration = fs.readFileSync(path.join(outDir, "sdk.d.ts"), "utf8");
|
|
expect(declaration).toContain("label: string");
|
|
expect(declaration).toContain("createValue");
|
|
expect(declaration).toContain("Contract");
|
|
expect(fs.readdirSync(outDir).every((file) => file.endsWith(".d.ts"))).toBe(true);
|
|
});
|
|
|
|
it("rediscovers fresh membership deterministically without an inventory or include glob", () => {
|
|
const entry = write("entries/sdk.ts", 'export type { Value } from "../first.js";');
|
|
const first = write("first.ts", "export type Value = string;");
|
|
write("entries/unselected.ts", "export type Unselected = never;");
|
|
expect(discoverDeclarationSources(tsconfig, [entry])).toEqual([entry, first].toSorted());
|
|
|
|
const second = write("second.ts", "export type Value = number;");
|
|
write("entries/sdk.ts", 'export type { Value } from "../second.js";');
|
|
expect(discoverDeclarationSources(tsconfig, [entry])).toEqual([entry, second].toSorted());
|
|
});
|
|
|
|
it.each(["missing entry", "invalid config"])(
|
|
"propagates %s from discovery before replacing declarations or stamping success",
|
|
(failure) => {
|
|
const declaration = write("dist/plugin-sdk/previous.d.ts", "previous declaration");
|
|
const stamp = write("dist/plugin-sdk/.boundary-entry-shims.stamp", "previous stamp");
|
|
if (failure === "invalid config") {
|
|
write("tsconfig.plugin-sdk.dts.json", '{"compilerOptions":{"unknownOption":true}}');
|
|
}
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
["--import", "tsx", path.resolve("scripts/write-plugin-sdk-entry-dts.ts")],
|
|
{
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
env: { ...process.env, OPENCLAW_PLUGIN_SDK_CANONICAL_DTS: "0" },
|
|
},
|
|
);
|
|
expect(result.status).not.toBe(0);
|
|
expect(result.stderr).toContain("[declaration-source-index] FAILED (exit 1)");
|
|
expect(fs.readFileSync(declaration, "utf8")).toBe("previous declaration");
|
|
expect(fs.readFileSync(stamp, "utf8")).toBe("previous stamp");
|
|
expect(fs.existsSync(path.join(root, "packages/plugin-sdk/dist"))).toBe(false);
|
|
},
|
|
);
|
|
});
|