Skip to content

Commit 84ca602

Browse files
test: certify synthetic future OpenClaw releases
Add a generator for future OpenClaw packages with new SDK entrypoints and declaration shapes (implicit exports, minified re-exports, default exports, declaration merging, generic and conditional aliases, destructured bindings, global augmentation, typeof, namespace exports) and an optional computed-name variant that takes the exact fallback. Gate the future release at 50% of 0.4.5 in CI and verify certificates on it. Certificates now follow typeof, global declarations, export default of an identifier and module-namespace exports, ignore destructuring-annotation member names, and no longer walk a class's instance type from its value (prototype has no declaration, so the type check never does).
1 parent b7c5468 commit 84ca602

5 files changed

Lines changed: 272 additions & 12 deletions

File tree

‎.github/workflows/publish-memory.yml‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,31 @@ jobs:
7676
--baseline "$BASELINE/node_modules/@openclaw/plugin-inspector/src/index.js"
7777
--runs 3 --max-ratio 0.5 --diagnose --json publish-memory-unseen.json
7878
79+
# A later release adds new SDK entrypoints and declaration shapes; nothing
80+
# about it is known in advance. 0.4.5 type-checks it fully, so identical
81+
# outputs prove the certificates answered exactly.
82+
- name: Future OpenClaw release with new SDK surface, at most 50% of 0.4.5
83+
if: success() || failure()
84+
run: |
85+
node scripts/make-future-openclaw-fixture.mjs --from "$FIXTURES/openclaw/package" --out "$RUNNER_TEMP/future/package"
86+
node scripts/publish-memory-benchmark.mjs --target "$RUNNER_TEMP/future/package" \
87+
--plugin @openclaw/discord="$FIXTURES/plugins/discord/package" \
88+
--plugin @openclaw/matrix="$FIXTURES/plugins/matrix/package" \
89+
--plugin @openclaw/whatsapp="$FIXTURES/plugins/whatsapp/package" \
90+
--baseline "$BASELINE/node_modules/@openclaw/plugin-inspector/src/index.js" \
91+
--runs 3 --max-ratio 0.5 --diagnose --json publish-memory-future.json
92+
93+
# Computed (template literal) replacement names cannot be certified; the
94+
# exact type-checked fallback answers them. Outputs must still be identical.
95+
- name: Future release with computed names takes the exact fallback
96+
if: success() || failure()
97+
run: |
98+
node scripts/make-future-openclaw-fixture.mjs --from "$FIXTURES/openclaw/package" --out "$RUNNER_TEMP/future-computed/package" --computed-names
99+
node scripts/publish-memory-benchmark.mjs --target "$RUNNER_TEMP/future-computed/package" \
100+
--plugin @openclaw/whatsapp="$FIXTURES/plugins/whatsapp/package" \
101+
--baseline "$BASELINE/node_modules/@openclaw/plugin-inspector/src/index.js" \
102+
--runs 1 --json publish-memory-future-computed.json
103+
79104
# ClawHub's Convex actions run the inspector from an esbuild bundle, so a
80105
# dependency hidden from bundlers would only fail after deploy.
81106
- name: Bundled like ClawHub's Convex actions, at most 50% of 0.4.5
@@ -101,7 +126,11 @@ jobs:
101126
# snapshot spells, not only the retirement inventory.
102127
- name: Retirement certificates agree with the full type check
103128
if: success() || failure()
104-
run: node --max-old-space-size=4096 scripts/verify-packed-sdk-certificates.mjs --target "$FIXTURES/openclaw/package"
129+
run: >-
130+
node --max-old-space-size=4096 scripts/verify-packed-sdk-certificates.mjs
131+
--target "$FIXTURES/openclaw/package"
132+
--target "$RUNNER_TEMP/future/package"
133+
--target "$RUNNER_TEMP/future-computed/package"
105134
106135
- name: Upload measurements
107136
if: always()

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

5-
- Halve publish-time memory for packed OpenClaw targets, for any OpenClaw release and without per-release data, while producing byte-identical target surfaces and findings. SDK-retirement qualification now decides each replacement name from the packed declarations without a type checker: certified available names are exact and certified unavailable names are sound (verified against the full type check for every name spelled in 18 OpenClaw releases); any name the certificates cannot decide still goes to the reduced type check. Load TypeScript on first use through a CommonJS re-export, read SDK-usage files excluded from analysis only when an analyzed file imports them, and parse each file once for both runtime-import passes. A CI gate measures the ClawHub publish path, plain and esbuild-bundled, on the large official channel plugins against 0.4.5.
5+
- Halve publish-time memory for packed OpenClaw targets, for any OpenClaw release and without per-release data, while producing byte-identical target surfaces and findings. SDK-retirement qualification decides each replacement name from the packed declarations without a type checker: certified available names are exact and certified unavailable names are sound (verified against the full type check for every name spelled in 18 OpenClaw releases and in synthetic future releases with new SDK surface); names the certificates cannot decide, such as computed template-literal names, still go to the reduced type check. Free each file's import analysis as soon as it is finished so its syntax tree is not promoted by later collections, load TypeScript on first use, read SDK-usage files excluded from analysis only when imported, and parse each file once for both runtime-import passes. A CI gate measures the ClawHub publish path, plain and esbuild-bundled, on the large official channel plugins and a synthetic future release against 0.4.5.
66

77
- Keep enum-containing TypeScript import classification compatible with Node 26 while preserving source offsets and conservative malformed-source handling.
88

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env node
2+
// Builds a synthetic "future" OpenClaw package from a real packed one: the same
3+
// declarations plus a new ./plugin-sdk entrypoint and new chunks that expose
4+
// SDK retirement replacements the source release does not, through the
5+
// declaration shapes a later release could use. Retirement qualification of
6+
// the result must match the full type check (0.4.5 computes it), and the
7+
// publish path must stay within its memory budget without any per-release data.
8+
//
9+
// node scripts/make-future-openclaw-fixture.mjs --from <unpacked openclaw package> --out <dir> [--computed-names]
10+
//
11+
// --computed-names adds a mapped type whose keys come from a template literal,
12+
// so one replacement name is computed rather than spelled. Certificates cannot
13+
// decide such a name; it exercises the exact type-checked fallback.
14+
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
15+
import path from "node:path";
16+
import { parseArgs } from "node:util";
17+
18+
const { values } = parseArgs({
19+
options: { from: { type: "string" }, out: { type: "string" }, "computed-names": { type: "boolean" } },
20+
});
21+
if (!values.from || !values.out) {
22+
console.error("Usage: node scripts/make-future-openclaw-fixture.mjs --from <unpacked openclaw package> --out <dir> [--computed-names]");
23+
process.exit(2);
24+
}
25+
const from = path.resolve(values.from);
26+
const out = path.resolve(values.out);
27+
await mkdir(out, { recursive: true });
28+
await cp(from, out, { recursive: true });
29+
const packageJson = JSON.parse(await readFile(path.join(out, "package.json"), "utf8"));
30+
packageJson.version = `${packageJson.version.replace(/-.*$/, "")}-future.1`;
31+
32+
const files = {
33+
// A rolled-up chunk in the style of the real ones: minified export aliases.
34+
"dist/future-sessions-Fz9.d.ts": `import { t as FutureLinkStore } from "./future-links-Ab1.js";
35+
//#region src/sessions/future-session-manager.d.ts
36+
/** A session manager whose persistence is asynchronous. */
37+
declare class SessionManager {
38+
static openAsync(sessionKey: string): Promise<SessionManager>;
39+
appendMessageAsync(message: unknown): Promise<void>;
40+
persistAsync(): Promise<void>;
41+
get links(): FutureLinkStore;
42+
}
43+
interface FutureWorkspaceGrant {
44+
acquireManagedWorkspaceAsync(owner: string): Promise<{ assertCurrentAsync(): Promise<void>; release(): void }>;
45+
}
46+
type FutureVersioned<Version extends 1 | 2 = 1> = Version extends 2 ? { statusAsync(): Promise<string> } : { selectV1(): void };
47+
type FutureBox<T> = { value: T; cancelAsync(): Promise<void> };
48+
declare const { readAsync, writeBack }: { readAsync: () => Promise<FutureRecorder>; writeBack: () => void };
49+
interface FutureRecorder { recordTurnAsync(): Promise<void> }
50+
declare enum FutureMode { selectAsync = "selectAsync" }
51+
//#endregion
52+
export { SessionManager as a, FutureWorkspaceGrant as i, FutureVersioned as n, FutureBox as o, readAsync as r, FutureMode as s, writeBack as u };
53+
`,
54+
"dist/future-links-Ab1.d.ts": `//#region src/sessions/future-links.d.ts
55+
interface FutureLinkStore {
56+
listLinksAsync(): Promise<string[]>;
57+
linkAsync(id: string): Promise<void>;
58+
unlinkAsync(id: string): Promise<void>;
59+
}
60+
//#endregion
61+
export { FutureLinkStore as t };
62+
`,
63+
// An entry with no export declarations: every declaration is exported.
64+
"dist/plugin-sdk/future-runtime.d.ts": `import { a as SessionManager, i as FutureWorkspaceGrant, n as FutureVersioned, o as FutureBox, r as readAsync, s as FutureMode } from "../future-sessions-Fz9.js";
65+
type FutureRuntime = {
66+
sessions: typeof SessionManager;
67+
workspace: FutureWorkspaceGrant;
68+
versioned: FutureVersioned<2>;
69+
boxed: FutureBox<string>;
70+
read: typeof readAsync;
71+
mode: typeof FutureMode;
72+
};
73+
declare function createFutureRuntime(): FutureRuntime;
74+
declare global {
75+
interface FutureGlobalHook { resolveConfigAsync(): Promise<unknown> }
76+
}
77+
export declare const futureHook: FutureGlobalHook;
78+
`,
79+
"dist/plugin-sdk/future-default.d.ts": `declare const runtime: { openAsync(): Promise<void> };
80+
export default runtime;
81+
export { a as SessionManager } from "../future-sessions-Fz9.js";
82+
`,
83+
};
84+
if (values["computed-names"]) {
85+
files["dist/plugin-sdk/future-computed.d.ts"] = `type Verbs = "unlink" | "personalStatus";
86+
export type FutureComputed = { [K in Verbs as \`\${K}Async\`]: () => Promise<void> };
87+
`;
88+
packageJson.exports["./plugin-sdk/future-computed"] = { types: "./dist/plugin-sdk/future-computed.d.ts", default: "./dist/plugin-sdk/future-computed.js" };
89+
}
90+
for (const [name, source] of Object.entries(files)) await writeFile(path.join(out, name), source);
91+
packageJson.exports["./plugin-sdk/future-runtime"] = { types: "./dist/plugin-sdk/future-runtime.d.ts", default: "./dist/plugin-sdk/future-runtime.js" };
92+
packageJson.exports["./plugin-sdk/future-default"] = { types: "./dist/plugin-sdk/future-default.d.ts", default: "./dist/plugin-sdk/future-default.js" };
93+
await writeFile(path.join(out, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`);
94+
console.log(`${out}: openclaw@${packageJson.version}`);

0 commit comments

Comments
 (0)