The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.
TypeScript agent-skillsagentic-aiai-agentsai-videobyokclaude-codecodexdeepseek-harnessdsh-plugingenerative-ailocal-firstmcpmotionmotion-graphicsmultimodalopenmotionreverse-engineeringvideo-editingvideo-generationworkbuddy
fix(tracking): enable reporting by default across release channels (#350)
open-design-crew[bot]93d501f75c07
diff --git a/docs/mcp-phase1-tools.md b/docs/mcp-phase1-tools.mdindex 492d6e59..9d7634b0 100644--- a/docs/mcp-phase1-tools.md+++ b/docs/mcp-phase1-tools.md@@ -116,7 +116,7 @@ The open editor also shows these restore refusals through its shared dismissible### Phase-one API compatibility-`shared/phase1-tools.ts` defines API protocol 1 and the available Tool names. Both editor and preview health advertise these capabilities. A phase-one stdio adapter can forward to another version/build only when the backend explicitly supports the same API protocol and requested Tool and has the same stable/test tracking policy; the backend validates the complete input again before execution. Stable and test clients use separate data directories; cross-policy authority reuse is rejected without stopping the existing service. Service, workspace, instance and authority protocol checks still apply. Internal legacy calls retain exact version/build checks.+`shared/phase1-tools.ts` defines API protocol 1 and the available Tool names. Both editor and preview health advertise these capabilities. A phase-one stdio adapter can forward to another version/build only when the backend explicitly supports the same API protocol and requested Tool; the backend validates the complete input again before execution. Release channels do not impose an additional tracking-policy compatibility gate. DEV packages retain their separate data directories and template routing. Service, workspace, instance and authority protocol checks still apply. Internal legacy calls retain exact version/build checks.Protocol 1 preserves existing request/response shapes and semantics. New Tools and optional fields are additive; incompatible required fields, removed fields or changed semantics must increment the protocol. A supported older connection keeps its project binding, stable request IDs and existing export queries through a compatible plugin or backend replacement without another MCP initialization. Running exports stay with the live authority; recovery does not terminate it or replay an uncertain mutation. An already-closed host transport and an incompatible protocol cannot be repaired by this negotiation.diff --git a/docs/npm-installation.md b/docs/npm-installation.mdindex 2a0a4ae6..ef5c28b1 100644--- a/docs/npm-installation.md+++ b/docs/npm-installation.md@@ -6,7 +6,7 @@ The npm tgz contains the installer, a prebuilt Motion application archive and itSource `package.json` is the development baseline; the published artifact can have a different version. For example, source `0.6.3` can produce `0.6.4-test.6` without a stable `0.6.4` release. Packaging changes output identities only. Manual [candidate builds](release-workflows.md#1-build) accept an empty version and automatically generate the next patch plus a short `test.N` workflow counter (with an attempt suffix on reruns); publication keeps the exact accepted version.-Test/prerelease/local packages never report usage data, even with a saved opt-in or an enable flag. Stable releases collect by default and support persistent opt-out and re-enable in Studio Privacy settings. See [tracking controls](../tracking/README.md#reporting-and-user-control).+All application environments and versions, including test/prerelease/local packages, collect usage data by default and support persistent opt-out and re-enable in Studio Privacy settings. Environment force-off and Do Not Track controls still apply. See [tracking controls](../tracking/README.md#reporting-and-user-control).## Public names and compatibilitydiff --git a/docs/product/architecture.md b/docs/product/architecture.mdindex 0ce53d02..9e01c7b2 100644--- a/docs/product/architecture.md+++ b/docs/product/architecture.md@@ -157,7 +157,7 @@ Asset selection, acquisition and replacement use the shared [material policy](..1. **两类入口共用领域能力。** Studio 与 MCP 使用同一 Gateway 合约和持久化数据。macOS 的 stdio 适配器按数据目录连接唯一后台,共用网关、任务与工程能力;每条连接绑定自己的工程。Windows / Linux 保留原生命周期。唯一后台依赖系统文件锁与私有身份验证,不以固定端口或 PID 文件作为唯一依据,见 [共享编辑器](../shared-editor.md)。- Public phase-one MCP calls negotiate a stable API protocol and supported Tool independently of the editor version/build. Compatible plugin updates within the same stable/test collection policy preserve existing stdio connections, workspace/project bindings and active exports; they do not restart the authority or replay mutations. Private authority identity and protocol checks remain strict, and internal legacy calls retain exact version/build checks. This boundary does not refresh host discovery metadata or revive a transport the host already closed; see [API compatibility](../mcp-phase1-tools.md#phase-one-api-compatibility).+ Public phase-one MCP calls negotiate a stable API protocol and supported Tool independently of the editor version/build. Compatible plugin updates across release channels preserve existing stdio connections, workspace/project bindings and active exports; they do not restart the authority or replay mutations. Private authority identity and protocol checks remain strict, and internal legacy calls retain exact version/build checks. This boundary does not refresh host discovery metadata or revive a transport the host already closed; see [API compatibility](../mcp-phase1-tools.md#phase-one-api-compatibility).2. **作品与执行配置分开。** 原生工程包含作品源文件与媒体;供应商凭据、模型默认路由和生成任务属于工作区。项目包可以交给别人继续编辑,使用者无需继承原作者的 Key。3. **素材成功不自动成为编辑成功。** 生成任务产生候选文件,采用结果才触发原生放置/替换。撤销作品修改不删除候选文件,也不撤销已经发生的供应商调用或费用。4. **上下文不能随等待漂移。** 提交时固定生成工程和参考输入,采用时验证编辑目标;切换工程、合成、删除或改换原素材引用后,旧回调不得覆盖新目标。@@ -275,7 +275,7 @@ Canvas selection checks distinguish missing source files, denied access, failed当前交付标准:连接可验证、模板可定位、工程可继续编辑、预览与源文件一致、导出存在真实文件、检查结果有证据。相关实现由 `tests/`、`npm run test:studio` 的原生单元/DOM 与宿主回归、类型检查、设计检查和按需浏览器验证覆盖;没有执行的检查不能记为通过。-The runtime includes an explicit-event tracking package shared by MCP and Studio. Stable releases collect by default; test/prerelease/local application versions are locked off regardless of the saved preference or launch overrides. The test-build Privacy switch explains the lock without overwriting the saved stable-release choice. Shared-backend discovery rejects test/stable cross-policy reuse rather than allowing a reporting authority to execute test actions. In stable releases, a persistent user preference can stop collection for the whole installation and resume new reports when enabled again; discarded events are not replayed. Environment force-off controls still take priority. Studio submits allowlisted events to the local service; Node adds a random installation identity before asynchronous ingestion into the existing OpenDesign PostHog project. OM events carry product=openmotion; queries must distinguish products. An OM-only transformation preserves coarse country/region/timezone and removes raw IP and precise location after the existing GeoIP transformation, without changing other OpenDesign events or global project settings. The implementation covers tool results, selected domain operations and selected Studio interactions; it does not establish a product analytics baseline or implement every proposed event. See [tracking configuration, privacy and coverage](../../tracking/README.md).+The runtime includes an explicit-event tracking package shared by MCP and Studio. All application environments and versions collect by default, including stable releases and test/prerelease/local builds. Application version and environment remain event properties rather than collection gates. Shared-backend discovery relies on API capabilities without an additional release-channel tracking policy. A persistent user preference can stop collection for the whole installation and resume new reports when enabled again; discarded events are not replayed. Environment force-off controls still take priority. Studio submits allowlisted events to the local service; Node adds a random installation identity before asynchronous ingestion into the existing OpenDesign PostHog project. OM events carry product=openmotion; queries must distinguish products. An OM-only transformation preserves coarse country/region/timezone and removes raw IP and precise location after the existing GeoIP transformation, without changing other OpenDesign events or global project settings. The implementation covers tool results, selected domain operations and selected Studio interactions; it does not establish a product analytics baseline or implement every proposed event. See [tracking configuration, privacy and coverage](../../tracking/README.md).The following product measures still require agreed observation windows and validated evidence:diff --git a/docs/shared-editor.md b/docs/shared-editor.mdindex 00f221f5..f0f84516 100644--- a/docs/shared-editor.md+++ b/docs/shared-editor.md@@ -37,14 +37,14 @@ flowchart LR| 显式打开预览 | 按需启动或复用原生 Studio;返回已有完整/嵌入链接契约 || 全部 MCP 会话退出 | 后台继续服务网页与导出;不会因某个 Agent 退出取消其他人的工作 || 用户停止后台 | 私有停止接口拒绝正在执行的 MCP、视频导出或素材任务;空闲时关闭子服务并退出 |-| Compatible plugin/backend version or build change | Existing phase-one connections continue through the same workspace authority when it advertises the same MCP API protocol, requested Tool and stable/test tracking policy; keep running exports and request IDs intact. |-| Incompatible authority/API protocol, missing Tool, stable/test policy mismatch or legacy version/build mismatch | Refuse before dispatch with expected/actual identity. Never automatically kill or launch a competing backend. |+| Compatible plugin/backend version or build change | Existing phase-one connections continue through the same workspace authority when it advertises the same MCP API protocol and requested Tool; keep running exports and request IDs intact. |+| Incompatible authority/API protocol, missing Tool or legacy version/build mismatch | Refuse before dispatch with expected/actual identity. Never automatically kill or launch a competing backend. || A live MCP client's plugin directory was replaced or removed | Phase-one calls keep their stdio connection and reuse a compatible live backend. Internal legacy connections return `MCP_RUNTIME_RELOAD_REQUIRED`. A transport already closed by the host cannot be revived by the plugin. || 同目录已有旧版预览服务 | 拒绝另外启动共享后台;退出旧服务后重试 |macOS 使用系统 `/usr/bin/perl` 取得 `flock` 后直接 exec Node;Perl 不常驻。锁描述符同时由后台和 Studio 守卫持有。后台死亡后,守卫先清理旧 Studio,再释放锁,新后台才能启动。锁文件保留不等于锁仍被占用;不通过删除锁文件来恢复。-Phase-one compatibility is independent of the editor's implementation build within the same stable/test tracking policy. Authenticated private health and public preview health advertise `mcp.protocol` and `mcp.tools`; forwarding retains service, workspace, instance and authority-protocol validation. Compatible updates reuse the current authority without restarting it or replaying mutations. If an idle authority is separately replaced, the next call discovers or starts the same workspace's compatible replacement using the existing stdio connection. This does not hot-reload the UI, refresh host Tool metadata or automatically install updates. See the [API compatibility contract](mcp-phase1-tools.md#phase-one-api-compatibility).+Phase-one compatibility is independent of the editor's implementation build and release channel. Authenticated private health and public preview health advertise `mcp.protocol` and `mcp.tools`; forwarding retains service, workspace, instance and authority-protocol validation. Compatible updates reuse the current authority without restarting it or replaying mutations. If an idle authority is separately replaced, the next call discovers or starts the same workspace's compatible replacement using the existing stdio connection. This does not hot-reload the UI, refresh host Tool metadata or automatically install updates. See the [API compatibility contract](mcp-phase1-tools.md#phase-one-api-compatibility).显式停止(必须指定同一个数据目录):diff --git a/editor-runtime.ts b/editor-runtime.tsindex fbe95d1e..72d39e7c 100644--- a/editor-runtime.ts+++ b/editor-runtime.ts@@ -9,7 +9,6 @@ import { WorkspaceStore, Conflict } from './workspace.ts';import { isMain } from './shared/entry.ts';import { templateConfig } from './shared/template-config.ts';import { phase1McpCapabilities, supportsPhase1Tool } from './shared/phase1-tools.ts';-import { trackingReleaseEnabled } from './tracking/node.ts';export const sharedEditorEnabled = process.platform === 'darwin';const root = fileURLToPath(new URL('./', import.meta.url));@@ -56,9 +55,7 @@ export async function ensureEditor(directory: string, mcpTool?: string): Promisetry {const health = await editorRequest(registry, '/editor-api/health', undefined, 1200);if (health.service !== service || health.dataDirectory !== data || health.instanceId !== registry.instanceId) throw Object.assign(new Error('编辑器实例身份不匹配'), { terminal: true });- // Test clients must not execute through a stable authority that can report their actions.- const sameReleasePolicy = trackingReleaseEnabled(health.version) === trackingReleaseEnabled(version);- const compatible = sameReleasePolicy && (mcpTool ? supportsPhase1Tool(health, mcpTool) : health.version === version && health.build === editorBuild);+ const compatible = mcpTool ? supportsPhase1Tool(health, mcpTool) : health.version === version && health.build === editorBuild;if (health.protocol !== protocol || !compatible) throw Object.assign(new Error('Editor runtime incompatible. Reconnect the OpenMotion MCP connection to the installed runtime and compare the expected and actual versions/builds. Stop an older editor only after confirming it is idle; do not bypass MCP or switch workspaces to continue.'),{ terminal: true, code: 'EDITOR_RUNTIME_INCOMPATIBLE', details: {diff --git a/preview.ts b/preview.tsindex 13f3b338..43d33fe9 100644--- a/preview.ts+++ b/preview.ts@@ -6,7 +6,6 @@ import { readFileSync } from 'node:fs';import { WorkspaceStore } from './workspace.ts';import { ensureEditor, editorRequest, readEditor, sharedEditorEnabled } from './editor-runtime.ts';import { supportsPhase1Tool } from './shared/phase1-tools.ts';-import { trackingReleaseEnabled } from './tracking/node.ts';const pluginRoot = fileURLToPath(new URL('./', import.meta.url));export const VERSION: string = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version;@@ -121,7 +120,6 @@ export async function openPreview(store = new WorkspaceStore(), environment: Preconst candidates = [...new Set([...(previous ? [previous] : []), ...Array.from({ length: 10 }, (_, i) => firstPort + i)])];let available: number | null = null;const matches = (result: Probe) => result.kind === 'motion' && result.health.service === 'motion-preview' && result.health.protocol === 2 && result.health.ready- && trackingReleaseEnabled(result.health.version) === trackingReleaseEnabled(VERSION)&& (options.mcpTool ? supportsPhase1Tool(result.health, options.mcpTool) : result.health.version === VERSION) && path.resolve(result.health.dataDirectory) === store.directory;async function ready(port: number, health: Health, reused: boolean, pid?: number) {if (options.editor && !health.studioUrl) {diff --git a/server.ts b/server.tsindex 732b7f05..ba69efc3 100644--- a/server.ts+++ b/server.ts@@ -300,7 +300,7 @@ export async function handler(req: IncomingMessage, res: ServerResponse, store =const directory = (store.workspaceStore ?? store).directory;if (req.method === 'PUT') {const reason = trackingLockReason();- if (reason) return json(res, 403, { error: reason === 'test_build' ? 'TRACKING_DISABLED_IN_TEST_BUILD' : 'TRACKING_DISABLED_BY_ENVIRONMENT' });+ if (reason) return json(res, 403, { error: 'TRACKING_DISABLED_BY_ENVIRONMENT' });const data = await input(req, 1024);if (!data || Object.keys(data).length !== 1 || typeof data.enabled !== 'boolean') return json(res, 400, { error: 'INVALID_TRACKING_PREFERENCE' });await saveTrackingPreference(directory, data.enabled);diff --git a/shared/tracking.ts b/shared/tracking.tsindex 0d23cee5..e9ce8784 100644--- a/shared/tracking.ts+++ b/shared/tracking.ts@@ -3,13 +3,12 @@ import { readFileSync, watch } from 'node:fs';import { mkdir, rename, rm, writeFile } from 'node:fs/promises';import { createTracker, uuid } from '../tracking/core.ts';import type { Entry } from '../tracking/core.ts';-import { createNodeTracking, loadIdentity, trackingReleaseEnabled } from '../tracking/node.ts';+import { createNodeTracking, loadIdentity } from '../tracking/node.ts';import { omEvents } from '../tracking/events.ts';import { VERSION } from '../preview.ts';export type OmTracking = ReturnType<typeof createTracker<typeof omEvents>>;export function trackingLockReason() {- if (!trackingReleaseEnabled(VERSION)) return 'test_build' as const;return ['0', 'false', 'off'].includes(process.env.OPENMOTION_TELEMETRY?.toLowerCase() ?? '') || process.env.DO_NOT_TRACK === '1'? 'environment' as const : null;}diff --git a/tests/npm-package.test.ts b/tests/npm-package.test.tsindex 0d1c79e3..191f9d52 100644--- a/tests/npm-package.test.ts+++ b/tests/npm-package.test.ts@@ -12,7 +12,7 @@ import { mcpRegistry } from '../mcp.ts';import { stableReports } from '../.github/scripts/motion-release.mjs';const json = async (file: string) => JSON.parse(await readFile(file, 'utf8'));-async function verifyTrackingPolicy(application: string, mode: 'test' | 'stable') {+async function verifyTrackingPolicy(application: string, mode: 'test' | 'stable' | 'local') {await symlink(path.resolve('node_modules'), path.join(application, 'node_modules'), process.platform === 'win32' ? 'junction' : 'dir');const result = JSON.parse(await runFile(process.execPath, ['--experimental-strip-types', path.resolve('tests/tracking-package.ts'), application, mode]));assert.equal(result.passed, true); assert.equal(result.external_requests, 0);@@ -222,6 +222,8 @@ test('stable artifacts stage publication instead of replacing latest and retainconst localPkg = await json(path.join(directory, 'local-npm/package/package.json'));assert.equal(localPkg.private, true); assert.match(localPkg.version, /-local\.1$/);assert.equal((await json(local.manifest)).version, localPkg.version);+ const localApplication = path.join(directory, 'local-app'); await extractArchive(local.application, localApplication);+ await verifyTrackingPolicy(localApplication, 'local');} finally { await rm(directory, { recursive: true, force: true }); }});diff --git a/tests/preview.test.ts b/tests/preview.test.tsindex a0822a94..fe51e335 100644--- a/tests/preview.test.ts+++ b/tests/preview.test.ts@@ -61,18 +61,20 @@ test('unrelated services and mismatched versions or data directories are left inconst result = await openPreview(store, mock.environment);assert.equal(result.previewUrl, `http://localhost:${port + 3}`); assert.deepEqual(mock.stops, []);}));-test('a phase1 call reuses a compatible newer backend without restarting it or changing workspaces', () => fixture(async store => {- const mock = runtime(store), port = Number(process.env.PORT || 4173);- mock.occupied.set(port, { kind: 'motion', health: { service: 'motion-preview', protocol: 2, version: '0.6.4',- dataDirectory: store.directory, ffmpeg: true, ready: true, mcp: { protocol: 1, tools: ['openmotion_export_request'] } } });- const before = await store.get();- const result = await ensureService(store, mock.environment, 'openmotion_export_request');- assert.equal(result.previewUrl, `http://localhost:${port}`);- assert.equal(result.reused, true);- assert.deepEqual(mock.launches, []); assert.deepEqual(mock.stops, []);- assert.deepEqual(await store.get(), before);- assert.equal(JSON.parse(await readFile(path.join(store.directory, 'preview.json'), 'utf8')).version, '0.6.4');-}, false));+test('a phase1 call reuses compatible stable and prerelease backends without restarting them', async t => {+ for (const version of ['0.6.4', '0.6.4-test.8']) await t.test(version, () => fixture(async store => {+ const mock = runtime(store), port = Number(process.env.PORT || 4173);+ mock.occupied.set(port, { kind: 'motion', health: { service: 'motion-preview', protocol: 2, version,+ dataDirectory: store.directory, ffmpeg: true, ready: true, mcp: { protocol: 1, tools: ['openmotion_export_request'] } } });+ const before = await store.get();+ const result = await ensureService(store, mock.environment, 'openmotion_export_request');+ assert.equal(result.previewUrl, `http://localhost:${port}`);+ assert.equal(result.reused, true);+ assert.deepEqual(mock.launches, []); assert.deepEqual(mock.stops, []);+ assert.deepEqual(await store.get(), before);+ assert.equal(JSON.parse(await readFile(path.join(store.directory, 'preview.json'), 'utf8')).version, version);+ }, false));+});test('phase1 port discovery leaves unrelated services and other workspaces intact', () => fixture(async store => {const mock = runtime(store), port = Number(process.env.PORT || 4173);const health = { service: 'motion-preview', protocol: 2, version: '0.6.4', dataDirectory: store.directory, ffmpeg: true, ready: true, mcp: { protocol: 1, tools: ['openmotion_export_request'] } };@@ -83,7 +85,7 @@ test('phase1 port discovery leaves unrelated services and other workspaces intacassert.deepEqual(mock.stops, []);}, false));test('phase1 port discovery refuses an incompatible same-workspace authority without launching another', async t => {- for (const change of [{ protocol: 999 }, { version: '0.6.4-test.8', mcp: phase1McpCapabilities }, { version: VERSION, mcp: { protocol: 2, tools: ['openmotion_export_request'] } }, { mcp: { protocol: 1, tools: ['openmotion_get_project'] } }, { mcp: undefined }]) await t.test(JSON.stringify(change), () => fixture(async store => {+ for (const change of [{ protocol: 999 }, { version: VERSION, mcp: { protocol: 2, tools: ['openmotion_export_request'] } }, { mcp: { protocol: 1, tools: ['openmotion_get_project'] } }, { mcp: undefined }]) await t.test(JSON.stringify(change), () => fixture(async store => {const mock = runtime(store), port = Number(process.env.PORT || 4173);mock.occupied.set(port, { kind: 'motion', health: { service: 'motion-preview', protocol: 2, version: '0.6.4', dataDirectory: store.directory, ffmpeg: true, ready: true, ...change } });const before = await store.get();diff --git a/tests/tracking-package.ts b/tests/tracking-package.tsindex 88020581..aaec8c27 100644--- a/tests/tracking-package.ts+++ b/tests/tracking-package.ts@@ -7,13 +7,13 @@ import { transport } from './http.ts';// Run only in a child process against an extracted package; never contact a collector.const [root, mode] = process.argv.slice(2);-assert(root && ['test', 'stable'].includes(mode));+assert(root && ['test', 'stable', 'local'].includes(mode));for (const key of ['OPENMOTION_TELEMETRY', 'DO_NOT_TRACK', 'OPENMOTION_POSTHOG_HOST', 'OPENMOTION_POSTHOG_KEY']) delete process.env[key];process.env.OPENMOTION_TRACKING_ENV = 'test'; process.env.OPENMOTION_TRACKING_TEST_RUN_ID = crypto.randomUUID();const directory = await mkdtemp(path.join(tmpdir(), 'motion-tracking-package-'));process.env.MOTION_DATA_DIR = directory;const load = (file: string) => import(pathToFileURL(path.join(root, file)).href);-const { createAppTracking, saveTrackingPreference, trackingLocked, trackingLockReason } = await load('shared/tracking.ts');+const { createAppTracking, trackingLocked } = await load('shared/tracking.ts');const { handler } = await load('server.ts'), { WorkspaceStore } = await load('workspace.ts');const { deviceContext } = await load('tracking/core.ts');const packet = () => ({ event: 'ui_click', event_id: crypto.randomUUID(), occurred_at: new Date().toISOString(), entrypoint: 'studio',@@ -22,52 +22,33 @@ const bodies: any[] = [];globalThis.fetch = async (_url, init) => { bodies.push(JSON.parse(String(init?.body))); return Response.json({ status: 'Ok' }); };const runtimes: any[] = [];try {- if (mode === 'test') await saveTrackingPreference(directory, true);for (const entry of ['mcp', 'worker']) runtimes.push(await createAppTracking(directory, entry));const request = transport(new WorkspaceStore(directory), { tracking: runtimes[1] }, handler);const set = (enabled: boolean) => request('/motion-api/tracking/preferences', { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ enabled }) });const send = () => request('/motion-api/tracking', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ events: [packet()] }) });- if (mode === 'test') {- process.env.OPENMOTION_TELEMETRY = '1';- assert.equal(trackingLocked(), true); assert.equal(trackingLockReason(), 'test_build');- const status = await (await request('/motion-api/tracking/preferences')).json();- assert.deepEqual(status, { enabled: false, preference: true, locked: true, reason: 'test_build' });+ assert.equal(trackingLocked(), false);+ const status = await (await request('/motion-api/tracking/preferences')).json();+ assert.deepEqual(status, { enabled: true, preference: true, locked: false, reason: null });+ assert.equal((await send()).status, 200); await runtimes[1].flush();+ for (let cycle = 0; cycle < 2; cycle++) {+ for (const runtime of runtimes) runtime.ingest(packet());+ assert.equal((await set(false)).status, 200);for (const runtime of runtimes) {- runtime.setEnabled(true);- assert.equal(runtime.ingest(packet()), 'disabled'); assert.equal(await runtime.flush(), 'disabled');+ assert.equal(runtime.enabled(), false);+ assert.equal(runtime.pending(), 0); assert.equal(runtime.ingest(packet()), 'disabled');+ assert.equal(await runtime.flush(), 'disabled');}- for (let cycle = 0; cycle < 2; cycle++) {- assert.equal((await set(true)).status, 403);- assert.deepEqual(await (await send()).json(), { accepted: 0, enabled: false });- }- assert.equal(bodies.length, 0);- await assert.rejects(readFile(path.join(directory, 'tracking/identity.json')), /ENOENT/);- assert.equal(JSON.parse(await readFile(path.join(directory, 'tracking/preferences.json'), 'utf8')).enabled, true);- } else {- assert.equal(trackingLocked(), false);- const status = await (await request('/motion-api/tracking/preferences')).json();- assert.deepEqual(status, { enabled: true, preference: true, locked: false, reason: null });- assert.equal((await send()).status, 200); await runtimes[1].flush();- for (let cycle = 0; cycle < 2; cycle++) {- for (const runtime of runtimes) runtime.ingest(packet());- assert.equal((await set(false)).status, 200);- for (const runtime of runtimes) {- assert.equal(runtime.enabled(), false);- assert.equal(runtime.pending(), 0); assert.equal(runtime.ingest(packet()), 'disabled');- assert.equal(await runtime.flush(), 'disabled');- }- const before = bodies.length;- await send(); assert.equal(bodies.length, before);- const restarted = await createAppTracking(directory, 'mcp'); runtimes.push(restarted);- assert.equal(restarted.enabled(), false);- assert.equal((await set(true)).status, 200);- for (const runtime of runtimes) {- assert.equal(runtime.ingest(packet()), 'queued'); assert.equal(await runtime.flush(), 'accepted');- }- assert.equal(bodies.length, before + runtimes.length);+ const before = bodies.length;+ await send(); assert.equal(bodies.length, before);+ const restarted = await createAppTracking(directory, 'mcp'); runtimes.push(restarted);+ assert.equal(restarted.enabled(), false);+ assert.equal((await set(true)).status, 200);+ for (const runtime of runtimes) {+ assert.equal(runtime.ingest(packet()), 'queued'); assert.equal(await runtime.flush(), 'accepted');}- assert.equal(new Set(bodies.flatMap(body => body.batch.map((event: any) => event.properties.installation_id))).size, 1);+ assert.equal(bodies.length, before + runtimes.length);}+ assert.equal(new Set(bodies.flatMap(body => body.batch.map((event: any) => event.properties.installation_id))).size, 1);if (process.getuid) {const { editorDirectory, ensureEditor } = await load('editor-runtime.ts');const { data, runtime } = await editorDirectory(directory);@@ -81,7 +62,8 @@ try {assert.equal(new URL(String(url)).pathname, '/editor-api/health');return Response.json({ ...registry, mcp: { protocol: 1, tools: ['motion_get_project'] } });};- await assert.rejects(ensureEditor(directory, 'motion_get_project'), { code: 'EDITOR_RUNTIME_INCOMPATIBLE' });+ const editor = await ensureEditor(directory, 'motion_get_project');+ assert.equal(editor.version, registry.version);assert.equal(await readFile(registryFile, 'utf8'), before);}console.log(JSON.stringify({ version: JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')).version,diff --git a/tests/tracking.test.ts b/tests/tracking.test.tsindex a9420bcc..5f0f9c9a 100644--- a/tests/tracking.test.ts+++ b/tests/tracking.test.ts@@ -102,20 +102,29 @@ test('PostHog adapter uses public ingest only, privacy fields and real receipt sassert.equal(Object.hasOwn(enriched[0].batch[0].properties, '$ip'), false);});-test('test and local versions cannot report even when enabled or given a test-run override', async () => {- let sends = 0;+test('all application versions report in development, test and production environments', async t => {const identity = { installation_id: crypto.randomUUID(), utm_source: null, created_at: new Date().toISOString() };- for (const appVersion of ['0.6.4-test.8', '0.6.4-test.42.2', '0.6.4-local.1', '0.6.4-beta.1', 'invalid']) {- const options = { registry: omEvents, identity, appVersion, entrypoint: 'mcp' as const, enabled: true,- env: 'test' as const, testRunId: crypto.randomUUID(), host: 'https://us.i.posthog.com', token: 'phc_test' };- const tracking = createNodeTracking(options);- tracking.setEnabled(true);- assert.equal(tracking.enabled(), false); assert.equal(tracking.ingest(packet()), 'disabled');- assert.equal(await tracking.flush(), 'disabled'); tracking.close();- const sender = createPosthogSender({ ...options, fetch: async () => { sends++; return Response.json({ status: 'Ok' }); } });- assert.equal(await sender([packet()], new AbortController().signal), 'drop');+ for (const appVersion of ['0.6.4', '0.6.4-test.8', '0.6.4-test.42.2', '0.6.4-local.1', '0.6.4-beta.1']) {+ for (const env of ['development', 'test', 'production'] as const) {+ const bodies: any[] = [];+ const options = { registry: omEvents, identity, appVersion, env, entrypoint: 'mcp' as const, enabled: true,+ flushIntervalMs: 0, host: 'https://us.i.posthog.com', token: 'phc_test' };+ t.mock.method(globalThis, 'fetch', async (_url: any, init?: RequestInit) => {+ bodies.push(JSON.parse(String(init?.body))); return Response.json({ status: 'Ok' });+ });+ const tracking = createNodeTracking(options);+ try {+ assert.equal(tracking.enabled(), true); assert.equal(tracking.ingest(packet()), 'queued');+ assert.equal(await tracking.flush(), 'accepted');+ assert.equal(await createPosthogSender(options)([packet()], new AbortController().signal), 'accepted');+ assert.equal(bodies.length, 2);+ for (const body of bodies) {+ assert.equal(body.batch[0].properties.app_version, appVersion);+ assert.equal(body.batch[0].properties.env, env);+ }+ } finally { tracking.close(); }+ }}- assert.equal(sends, 0);});test('browser ingress rejects forged identity, worker events and oversized batches', () => fixture(async store => {diff --git a/tracking/INTEGRATION.md b/tracking/INTEGRATION.mdindex d17a4754..a1dff19b 100644--- a/tracking/INTEGRATION.md+++ b/tracking/INTEGRATION.md@@ -168,15 +168,12 @@ Do not add client IP lookups or collect IP in callers.Device timezone is separate from GeoIP timezone; VPN/proxy egress may differ.See [configuration, privacy and limits](README.md) and [coarse GeoIP](posthog-geoip.hog).-Tracking is on by default in stable releases. Studio **Privacy settings → Share-usage data** disables collection for the installation, including MCP and Studio-across restarts. Re-enabling resumes new reports without replaying discarded events.-Test/prerelease/local application versions are always disabled at runtime, even-with a saved opt-in, `OPENMOTION_TELEMETRY=1`, custom collector or test-run UUID.-Their Privacy switch is locked and explains the test-build policy; opening a test-build does not replace the saved stable-release preference.-Test and stable MCP clients must use separate data directories; shared-backend-discovery rejects cross-policy reuse without stopping or replacing the authority.+Tracking is on by default in every application environment and version, including+stable, test/prerelease and local builds. Studio **Privacy settings → Share usage+data** disables collection for the installation, including MCP and Studio across+restarts. Re-enabling resumes new reports without replaying discarded events.+Application version and environment are event properties, not collection gates.+DEV packages retain their separate installation/data directories and template routing.`OPENMOTION_TELEMETRY=0` or `DO_NOT_TRACK=1` forces it off; browser Do Not Track alsosuppresses browser collection. An added event must respect those controls.@@ -264,9 +261,8 @@ checks and applicable repository gates, not invented product events.## Read back a marked live run-Use a stable-version application, an owned temporary data directory and fresh-runtime processes. A test/prerelease package never reports, even for this check;-do not change its version to bypass the policy. Apply the same+Use an application of any version, an owned temporary data directory and fresh+runtime processes. Apply the sametest environment to every participating MCP/local service process, including oneslaunched by a host. An already-running shared service will not inherit new variables.For a POSIX shell, prepare the environment before starting the normal test runnerdiff --git a/tracking/README.md b/tracking/README.mdindex 419962a1..d31891a7 100644--- a/tracking/README.md+++ b/tracking/README.md@@ -9,14 +9,11 @@ For new events, start with the [integration guide and agent task template](INTEG## Reporting and user control-Reporting is **on by default in stable releases** into the existing OpenDesign project (420348).-Test and other prerelease/local application versions never report. This is enforced-from the packaged application version, independently of CI environment variables,-the saved preference, a custom collector or test-run overrides. The test-build-Privacy switch is locked off and does not overwrite a saved stable-release choice.-Stable and test clients cannot reuse each other's same-workspace backend authority;-use the separate installation/data directories already provided by DEV packages.-Compatible updates within the same release policy retain normal backend reuse.+Reporting is **on by default in every application environment and version**, including+stable releases, test/prerelease packages and local builds, into the existing+OpenDesign project (420348). Application version and environment remain event+properties; they do not disable collection. DEV packages retain their separate+installation/data directories and template routing.OM events carry `product=openmotion`; OM reports must filter by that property,and shared-project reports must distinguish OM from other products. The project'spublic, write-only token and ingestion host are distributed in@@ -29,7 +26,7 @@ to both MCP and Studio, including already-running processes and future restarts.Disabling clears pending queues and aborts in-flight delivery; accepted eventscannot be recalled. A filesystem watcher propagates preference changes, and eachenqueue/flush also checks the saved preference. Corrupt preference files fail closed.-On stable releases, re-enabling resumes collection of new events in MCP and Studio+Re-enabling resumes collection of new events in MCP and Studiowithout restarting. Events discarded while disabled are not buffered or replayed.`OPENMOTION_TELEMETRY=0` (also `false`/`off`) or `DO_NOT_TRACK=1` forces all collection@@ -51,9 +48,9 @@ Use `OPENMOTION_TRACKING_ENV=test` and a UUID inout of product dashboards. Normal environments are `production` and `development`.Node/Vitest tests suppress collection unless explicitly given a test run ID; CIalso forces collection off. No test should silently report into production funnels.-Marked live-ingestion checks require a stable-version application running with-`env=test`; a `-test.N` package cannot be opted into reporting. Deterministic checks-use fake senders and extracted stable/test packages without external requests.+Marked live-ingestion checks use `env=test` with any application version.+Deterministic checks use fake senders and extracted stable/test/local packages+without external requests.Studio retrieves only an enabled flag and submits semantic events to the same-origin`/motion-api/tracking` endpoint. The server validates the complete batch, rejectsdiff --git a/tracking/node.ts b/tracking/node.tsindex 2d950fac..1fdd233e 100644--- a/tracking/node.ts+++ b/tracking/node.ts@@ -6,7 +6,6 @@ import type { Entry, Registry, PendingEvent, Receipt } from './core.ts';export type Identity = { installation_id: string; utm_source: string | null; created_at: string };const sourcePattern = /^[A-Za-z0-9_.-]{1,64}$/;-export function trackingReleaseEnabled(version: string) { return /^\d+\.\d+\.\d+$/.test(version); }export async function loadIdentity(directory: string, source?: string): Promise<Identity> {if (source !== undefined && (typeof source !== 'string' || !sourcePattern.test(source))) throw new Error('INVALID_SOURCE');@@ -41,7 +40,6 @@ export function createPosthogSender(options: {if (!/^phc_[A-Za-z0-9_]+$/.test(options.token)) throw new Error('PUBLIC_PROJECT_TOKEN_REQUIRED');if (options.testRunId && (!uuid.test(options.testRunId) || options.env !== 'test')) throw new Error('INVALID_TEST_RUN');return async (events: readonly PendingEvent[], signal: AbortSignal): Promise<Receipt> => {- if (!trackingReleaseEnabled(options.appVersion)) return 'drop';const batch = events.map(event => ({ event: event.event, uuid: event.event_id, timestamp: event.occurred_at,properties: { ...event.properties, event_schema_version: 1, schema_version: 1, product: 'openmotion',app_version: options.appVersion, env: options.env, channel: 'standalone',@@ -78,8 +76,7 @@ export function createNodeTracking<const R extends Registry>(options: {env: 'development' | 'test' | 'production'; testRunId?: string; entrypoint: Entry;enabled: boolean; timeoutMs?: number; flushIntervalMs?: number; maxQueue?: number; geoip?: boolean; isEnabled?: () => boolean;}) {- const enabled = options.enabled && !!options.token && trackingReleaseEnabled(options.appVersion);+ const enabled = options.enabled && !!options.token;const send = enabled ? createPosthogSender({ ...options, token: options.token! }) : async () => 'drop' as const;- return createTracker({ ...options, enabled, send,- isEnabled: () => trackingReleaseEnabled(options.appVersion) && (options.isEnabled?.() ?? true) });+ return createTracker({ ...options, enabled, send });}