Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
ci(ok): wire the Turbo remote cache into Open Knowledge CI for PRD-8610 (#4282)
Andrew Mikofalvy4f97f46ebb6f
diff --git a/.gitignore b/.gitignoreindex f6ff26e5f..f1729668a 100644--- a/.gitignore+++ b/.gitignore@@ -4,6 +4,7 @@ packages/desktop/out/packages/desktop/dist-desktop/packages/desktop/dev-app-update.yml.turbo/+turbo-cache-key.jsontmp/.DS_Store*.logdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 7ce54d4f6..c7a4546c1 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -32,7 +32,7 @@ See `.env.example` for optional settings (OpenTelemetry, a custom dev port).### Toolchain-The repo pins **Node.js 24+** and **pnpm 10+** (via `.node-version`, the `packageManager` field, and `engines`). Enable pnpm with `corepack enable pnpm`, or install it standalone (`npm install -g pnpm@10`). With a Node version manager, use `fnm install`, `mise install`, or `volta install node@24`. pnpm enforces the engine range (`engine-strict`), so on older Node `pnpm install` fails fast — pin Node 24+ first.+The repo pins **Node.js >=24.2.0** and **pnpm 10+** (via `.node-version`, the `packageManager` field, and `engines`). The minor matters: `engines.node` is `>=24.2.0`, not `>=24`, because the build scripts use `import.meta.main`, which landed in 24.2. Enable pnpm with `corepack enable pnpm`, or install it standalone (`npm install -g pnpm@10`). With a Node version manager, use `fnm install`, `mise install`, or `volta install node@24`. pnpm enforces the engine range (`engine-strict`), so on 24.0 or 24.1 `pnpm install` fails fast — pin 24.2.0 or newer first.TypeScript is pinned twice on purpose. `@typescript/native` is this repo's alias for `typescript@~7.0.2`, the Go compiler the gates run; it owns the `tsc` binary, so `node_modules/.bin/tsc --version` at the root reports 7. The root's own `typescript` stays on `~6.0.3` only to supply tsserver to your editor, because TypeScript 7 ships none — that is an API resolution, not the compiler. The split means 7.0-only lib typings or an unchecked side-effect import can red a gate your editor calls clean. Open your editor at the repo root, not inside a package, or its language server falls back to a machine-global TypeScript. Any package that runs `tsc` in a script declares `"typescript": "~7.0.2"` of its own; `node scripts/check-typescript-resolution.mjs`, which `pnpm run check:drift:guards` runs, enforces the *resolved* 7.0 line rather than the declared range; the range is a tilde for that reason, because a caret installs clean today and reds once 7.1 ships. Its errors say why.diff --git a/biome.jsonc b/biome.jsoncindex 7294c4aa0..b4fa11705 100644--- a/biome.jsonc+++ b/biome.jsonc@@ -123,6 +123,12 @@// vitest config in the Vite flavour `.source` must never hold."!**/.source-vitest","!**/.turbo",+ // Generated by postinstall (scripts/create-turbo-cache-key.mjs):+ // environment-specific, gitignored, and a CONTENT-HASHED+ // globalDependencies entry, so this exclusion is cache integrity, not+ // formatting taste: a formatter rewrite of the file would invalidate+ // every task hash on every machine whose formatter version differs.+ "!turbo-cache-key.json","!**/tmp","!**/test-results","!**/test-results-packaged",diff --git a/package.json b/package.jsonindex d6095787e..bf6a737ae 100644--- a/package.json+++ b/package.json@@ -5,9 +5,10 @@"type": "module","packageManager": "[email protected]","engines": {- "node": ">=24"+ "node": ">=24.2.0"},"scripts": {+ "postinstall": "node scripts/create-turbo-cache-key.mjs","knip": "turbo run build --filter=@inkeep/open-knowledge-server --filter=@inkeep/open-knowledge-core --output-logs=errors-only && knip","notices": "node scripts/generate-third-party-notices.mjs","schema:dump": "tsx packages/core/scripts/dump-schema.ts",@@ -17,6 +18,7 @@"check:desktop": "turbo run lint typecheck test --filter=@inkeep/open-knowledge-desktop","check:fast": "pnpm run typecheck","check:doc-links": "pnpm --dir docs run validate-link",+ "check:server-test-inputs": "node scripts/check-server-test-inputs.mjs","check:drift": "pnpm run check:drift:guards && vitest run --config vitest.scripts.config.ts","check:drift:guards": "bash scripts/check-husky-prepare-guard.sh && bash scripts/check-knip-clean.sh && bash scripts/check-notices-clean.sh && bash scripts/check-schema-snapshot-clean.sh && bash scripts/check-i18n-drift.sh && node scripts/check-i18n-new-string-translations.mjs && node scripts/check-i18n-picker-completeness.mjs && bash scripts/check-no-major-changeset.sh && node scripts/check-override-floors.mjs && node scripts/check-typescript-resolution.mjs","typecheck": "turbo run typecheck",@@ -28,7 +30,7 @@"lint:oxlint": "oxlint --max-warnings 0 .","format": "pnpm run lint:biome --write --unsafe","check": "pnpm run lint && pnpm exec turbo run build typecheck test",- "check:full:parallel": "pnpm run check:drift:guards && pnpm run lint && pnpm run check:doc-links && vitest run --config vitest.scripts.config.ts && turbo run build typecheck check:dts test test:dom test:integration test:conversion test:perf:regression:unit test:health:unit test:health test:e2e test:visual test:perf test:a11y --concurrency=100% --output-logs=errors-only",+ "check:full:parallel": "pnpm run check:drift:guards && pnpm run check:server-test-inputs && pnpm run lint && pnpm run check:doc-links && vitest run --config vitest.scripts.config.ts && turbo run build typecheck check:dts test test:dom test:integration test:conversion test:perf:regression:unit test:health:unit test:health test:e2e test:visual test:perf test:a11y --concurrency=100% --output-logs=errors-only","tier1": "pnpm run check","tier2": "pnpm run tier1 && turbo run test:perf:regression:unit test:health:unit test:health test:e2e","tier3": "STRESS_FIDELITY=1 pnpm run tier2",diff --git a/packages/native-config/turbo.json b/packages/native-config/turbo.jsonindex 612053b80..538f0d6cd 100644--- a/packages/native-config/turbo.json+++ b/packages/native-config/turbo.json@@ -7,7 +7,7 @@},"test": {"dependsOn": [],- "inputs": ["Cargo.toml", "Cargo.lock", "build.rs", "src/**/*.rs"],+ "inputs": ["$TURBO_DEFAULT$", "!README.md"],"outputs": []}}diff --git a/scripts/check-server-test-inputs.mjs b/scripts/check-server-test-inputs.mjsnew file mode 100644index 000000000..3586876cd--- /dev/null+++ b/scripts/check-server-test-inputs.mjs@@ -0,0 +1,200 @@+#!/usr/bin/env node+import { readdirSync, readFileSync, statSync } from 'node:fs';+import { join, relative, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));+const PKG_REL = 'packages/server';+const TASK = '@inkeep/open-knowledge-server#test';++const RELATIVE_PATH_LITERAL = /'([^'\n]*\.\.\/[^'\n]*)'|"([^"\n]*\.\.\/[^"\n]*)"/g;++const ROOT_JOIN_CALL = /\bjoin\(\s*([A-Za-z_$][\w$]*ROOT[\w$]*)\s*,\s*([^)]*)\)/g;+const QUOTED_SEGMENT = /'([^'\n]*)'|"([^"\n]*)"/g;++const DEPENDENCY_CLOSURE_PREFIXES = ['packages/core/'];++export const KNOWN_UNSWEPT = {+ '../../oxlint.config.ts':+ 'read inside test-support/read-ok-rules-config.test-helper.ts, which the walk does not enter',+ '../../lint-plugins/**':+ 'same helper, plus fixture paths built from a bare root-relative constant',+ '../app/src/editor/observers.ts':+ 'bridge-no-wallclock.test.ts reaches it via a lowercase repoRoot and a root-relative literal',+};++function walkTestFiles(dir, out = []) {+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ if (entry.name === 'node_modules' || entry.name === 'dist') continue;+ const full = join(dir, entry.name);+ if (entry.isDirectory()) walkTestFiles(full, out);+ else if (entry.name.endsWith('.test.ts')) out.push(full);+ }+ return out;+}++function existsOnDisk(absolutePath) {+ try {+ statSync(absolutePath);+ return true;+ } catch (error) {+ if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return false;+ throw error;+ }+}++export function escapingReads(okRoot = OK_ROOT) {+ const packageDir = join(okRoot, PKG_REL);+ const byTarget = new Map();+ for (const file of walkTestFiles(packageDir)) {+ const source = readFileSync(file, 'utf-8');+ for (const match of source.matchAll(RELATIVE_PATH_LITERAL)) {+ const literal = match[1] ?? match[2];+ const absolute = resolve(join(file, '..'), literal);+ const fromPackage = relative(packageDir, absolute);+ const fromOkRoot = relative(okRoot, absolute);+ const staysInsidePackage = !fromPackage.startsWith('..');+ const leavesTheSubtree = fromOkRoot.startsWith('..');+ const isAncestorOfPackage = !relative(absolute, packageDir).startsWith('..');+ if (staysInsidePackage || leavesTheSubtree || isAncestorOfPackage) continue;+ if (!existsOnDisk(absolute)) continue;+ if (!byTarget.has(fromOkRoot)) byTarget.set(fromOkRoot, new Set());+ byTarget.get(fromOkRoot).add(relative(packageDir, file));+ }++ for (const call of source.matchAll(ROOT_JOIN_CALL)) {+ const segments = [...call[2].matchAll(QUOTED_SEGMENT)].map((m) => m[1] ?? m[2]);+ if (segments.length === 0) continue;+ const absolute = resolve(okRoot, ...segments);+ const fromOkRoot = relative(okRoot, absolute);+ const fromPackage = relative(packageDir, absolute);+ if (fromOkRoot.startsWith('..')) continue;+ if (!fromPackage.startsWith('..')) continue;+ if (!relative(absolute, packageDir).startsWith('..')) continue;+ if (!existsOnDisk(absolute)) continue;+ if (!byTarget.has(fromOkRoot)) byTarget.set(fromOkRoot, new Set());+ byTarget.get(fromOkRoot).add(relative(packageDir, file));+ }+ }+ return byTarget;+}++function escapeGlobLiterals(glob) {+ return glob.replace(/[.+^${}()|[\]\\]/g, '\\$&');+}++function globToAnchoredRegex(escaped) {+ const endsWithGlobstar = escaped.endsWith('/**');+ const body = endsWithGlobstar ? escaped.slice(0, -3) : escaped;+ const pattern =+ body+ .replace(/\*\*/g, '[SEGMENTS]')+ .replace(/\*/g, '[^/]*')+ .replace(/\[SEGMENTS\]/g, '.*') + (endsWithGlobstar ? '(?:/.*)?' : '');+ return new RegExp(`^${pattern}(/|$)`);+}++export function packageRelativeGlobCovers(entry, targetFromOkRoot, okRoot = OK_ROOT) {+ const fromOkRoot = relative(okRoot, resolve(join(okRoot, PKG_REL), entry));+ return globToAnchoredRegex(escapeGlobLiterals(fromOkRoot)).test(targetFromOkRoot);+}++export function uncoveredReads(okRoot = OK_ROOT) {+ const turbo = JSON.parse(readFileSync(join(okRoot, 'turbo.json'), 'utf-8'));+ const inputs = (turbo.tasks?.[TASK]?.inputs ?? []).filter(+ (entry) => !entry.startsWith('!') && entry !== '$TURBO_DEFAULT$',+ );+ const globalDependencies = turbo.globalDependencies ?? [];++ const uncovered = [];+ for (const [target, readers] of escapingReads(okRoot)) {+ const declaredAsInput = inputs.some((entry) =>+ packageRelativeGlobCovers(entry, target, okRoot),+ );+ const declaredGlobally = globalDependencies.some((entry) =>+ globalDependencyCovers(entry, target),+ );+ const reachedByDependencyBuild = DEPENDENCY_CLOSURE_PREFIXES.some((prefix) =>+ target.startsWith(prefix),+ );+ if (!declaredAsInput && !declaredGlobally && !reachedByDependencyBuild) {+ uncovered.push({ target, readers: [...readers] });+ }+ }+ return uncovered;+}++export function globalDependencyCovers(entry, target) {+ return globToAnchoredRegex(escapeGlobLiterals(entry)).test(target);+}++export function knownUnsweptWitness(glob) {+ return glob.replace(/\/\*\*$/, '');+}++export function missingKnownUnswept(okRoot = OK_ROOT) {+ const turbo = JSON.parse(readFileSync(join(okRoot, 'turbo.json'), 'utf-8'));+ const inputs = turbo.tasks?.[TASK]?.inputs ?? [];+ return Object.keys(KNOWN_UNSWEPT).filter((glob) => {+ const witness = relative(okRoot, resolve(join(okRoot, PKG_REL), knownUnsweptWitness(glob)));+ return !inputs.some(+ (entry) => entry === glob || packageRelativeGlobCovers(entry, witness, okRoot),+ );+ });+}++function main() {+ const swept = escapingReads().size;+ if (swept === 0) {+ console.error(+ '\ncheck:server-test-inputs FAILED\n\n' ++ 'The sweep found ZERO cross-package reads, which this suite has never had.\n' ++ 'That is a broken sweep reporting a thorough pass, not a clean tree.\n\n' ++ 'Fix: check that packages/server/**/*.test.ts still resolves from the Open\n' ++ 'Knowledge root - the usual causes are a wrong cwd, a moved test tree, or a\n' ++ 'change away from the two literal forms the sweep recognises (a `../` path,\n' ++ 'or join(<*ROOT*>, ...) composition). Do NOT lower the floor to clear this:\n' ++ 'an empty corpus is the one result this guard cannot tell from success.\n',+ );+ process.exit(1);+ }++ const unswept = missingKnownUnswept();+ if (unswept.length > 0) {+ console.error(+ `\ncheck:server-test-inputs FAILED\n\n` ++ `These globs are required but sit in the sweep's BLIND SPOT, so their\n` ++ `deletion cannot be detected by derivation - they are pinned by name instead:\n\n` ++ unswept.map((g) => ` ${g}\n ${KNOWN_UNSWEPT[g]}`).join('\n') ++ `\n\nRe-add them to \`${TASK}\`.inputs, or widen the sweep to see their readers\n` ++ `and drop them from KNOWN_UNSWEPT.\n`,+ );+ process.exit(1);+ }++ const uncovered = uncoveredReads();+ if (uncovered.length > 0) {+ const detail = uncovered+ .map(({ target, readers }) => ` ${target}\n read by: ${readers.slice(0, 4).join(', ')}`)+ .join('\n');+ console.error(+ `\ncheck:server-test-inputs FAILED\n\n` ++ `${TASK} runs suites that read these paths from OUTSIDE packages/server, and\n` ++ `none is matched by its \`inputs\`, by \`globalDependencies\`, or by the \`^build\`\n` ++ `dependency closure. A change confined to one of them yields a cached PASS that\n` ++ `executed nothing, and the remote cache shares that answer with every cell.\n\n` ++ `${detail}\n\n` ++ `Fix: add a matching glob to \`${TASK}\`.inputs in public/open-knowledge/turbo.json.\n`,+ );+ process.exit(1);+ }+ console.log(+ `check:server-test-inputs: OK - ${swept} cross-package path(s) DERIVED from ` ++ `packages/server/**/*.test.ts (quoted '../' literals and statically resolvable ` ++ `join(<*ROOT*>, ...) calls) are declared inputs, plus ` ++ `${Object.keys(KNOWN_UNSWEPT).length} pinned by name because their readers use ` ++ `shapes this sweep does not recognise.`,+ );+}++if (import.meta.main) main();diff --git a/scripts/check-server-test-inputs.test.mjs b/scripts/check-server-test-inputs.test.mjsnew file mode 100644index 000000000..8d7745c80--- /dev/null+++ b/scripts/check-server-test-inputs.test.mjs@@ -0,0 +1,139 @@+import { spawnSync } from 'node:child_process';+import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join } from 'node:path';+import { fileURLToPath } from 'node:url';+import { describe, expect, test } from 'vitest';+import {+ escapingReads,+ globalDependencyCovers,+ KNOWN_UNSWEPT,+ knownUnsweptWitness,+ missingKnownUnswept,+ packageRelativeGlobCovers,+ uncoveredReads,+} from './check-server-test-inputs.mjs';++const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));+const TASK = '@inkeep/open-knowledge-server#test';++function fixtureRootWithout(glob) {+ const turbo = JSON.parse(readFileSync(join(OK_ROOT, 'turbo.json'), 'utf-8'));+ const inputs = turbo.tasks[TASK].inputs;+ expect(inputs, `fixture precondition: ${glob} must be declared`).toContain(glob);+ turbo.tasks[TASK].inputs = inputs.filter((entry) => entry !== glob);++ const root = mkdtempSync(join(tmpdir(), 'ok-server-inputs-'));+ writeFileSync(join(root, 'turbo.json'), JSON.stringify(turbo, null, 2));++ for (const [target, readers] of escapingReads(OK_ROOT)) {+ for (const reader of readers) {+ const dest = join(root, 'packages/server', reader);+ mkdirSync(dirname(dest), { recursive: true });+ writeFileSync(dest, readFileSync(join(OK_ROOT, 'packages/server', reader), 'utf-8'));+ }+ const targetPath = join(root, target);+ mkdirSync(dirname(targetPath), { recursive: true });+ writeFileSync(targetPath, '');+ }+ return root;+}++describe('check-server-test-inputs', () => {+ test('the live tree is clean: every escaping read is a declared input', () => {+ expect(uncoveredReads()).toEqual([]);+ });++ test('the sweep finds a non-trivial corpus, so a green is not vacuous', () => {+ expect(escapingReads().size).toBeGreaterThan(5);+ });++ test.each([+ ['../../docs/content/**', 'docs/content/'],+ ['../*/package.json', 'packages/app/package.json'],+ ['../cli/tsdown.config.ts', 'packages/cli/tsdown.config.ts'],+ ['../plugin/**', 'packages/plugin'],+ ['../../plugins/ok/**', 'plugins/ok'],+ ])('reds when %s is dropped from the task inputs', (glob, expectedTarget) => {+ const uncovered = uncoveredReads(fixtureRootWithout(glob));+ expect(uncovered.length).toBeGreaterThan(0);+ expect(uncovered.map((entry) => entry.target).join('\n')).toContain(expectedTarget);+ });++ test.each(Object.keys(KNOWN_UNSWEPT))(+ 'reds when %s is dropped, even though the sweep cannot see its reader',+ (glob) => {+ const root = fixtureRootWithout(glob);+ expect(missingKnownUnswept(root)).toEqual([glob]);+ },+ );++ test('every KNOWN_UNSWEPT glob is genuinely in the blind spot, not just listed', () => {+ for (const glob of Object.keys(KNOWN_UNSWEPT)) {+ const root = fixtureRootWithout(glob);+ expect(+ uncoveredReads(root),+ `${glob} IS derivable now - drop it from KNOWN_UNSWEPT rather than pinning it twice`,+ ).toEqual([]);+ }+ });++ test('every KNOWN_UNSWEPT entry carries a reason', () => {+ for (const [glob, reason] of Object.entries(KNOWN_UNSWEPT)) {+ expect(reason, glob).toMatch(/\S/);+ }+ });++ test('a trailing /** covers the directory itself, not only paths beneath it', () => {+ expect(packageRelativeGlobCovers('../cli/src/**', 'packages/cli/src')).toBe(true);+ expect(packageRelativeGlobCovers('../cli/src/**', 'packages/cli/src/index.ts')).toBe(true);+ expect(packageRelativeGlobCovers('../cli/src/**', 'packages/cli/tsdown.config.ts')).toBe(false);+ });++ test('a single-segment * does not cross a directory boundary', () => {+ expect(packageRelativeGlobCovers('../*/package.json', 'packages/app/package.json')).toBe(true);+ expect(packageRelativeGlobCovers('../*/package.json', 'packages/app/src/package.json')).toBe(+ false,+ );+ });++ test('globalDependencyCovers escapes glob metacharacters before matching', () => {+ expect(globalDependencyCovers('turbo-cache-key.json', 'turbo-cache-key.json')).toBe(true);+ expect(globalDependencyCovers('turbo-cache-key.json', 'turbo-cache-keyXjson')).toBe(false);+ expect(globalDependencyCovers('patches/*.patch', 'patches/a.patch')).toBe(true);+ expect(globalDependencyCovers('patches/*.patch', 'patches/nested/a.patch')).toBe(false);+ });++ test('globalDependencyCovers honours a trailing globstar like its sibling', () => {+ expect(globalDependencyCovers('generated/**', 'generated')).toBe(true);+ expect(globalDependencyCovers('generated/**', 'generated/a/b.ts')).toBe(true);+ expect(globalDependencyCovers('generated/**', 'generated-other')).toBe(false);+ });++ test('a KNOWN_UNSWEPT pin is satisfied by coverage, not by its exact spelling', () => {+ const root = fixtureRootWithout('../../lint-plugins/**');+ const turboPath = join(root, 'turbo.json');+ const turbo = JSON.parse(readFileSync(turboPath, 'utf-8'));+ turbo.tasks[TASK].inputs.push('../../**');+ writeFileSync(turboPath, JSON.stringify(turbo, null, 2));+ expect(missingKnownUnswept(root)).toEqual([]);+ });++ test('a KNOWN_UNSWEPT pin whose coverage is actually gone still reds', () => {+ expect(missingKnownUnswept(fixtureRootWithout('../../lint-plugins/**'))).toEqual([+ '../../lint-plugins/**',+ ]);+ });++ test('knownUnsweptWitness trims only a trailing globstar', () => {+ expect(knownUnsweptWitness('../../lint-plugins/**')).toBe('../../lint-plugins');+ expect(knownUnsweptWitness('../../oxlint.config.ts')).toBe('../../oxlint.config.ts');+ });++ test('the CLI entry point exits 0 and prints its OK line on the real tree', () => {+ const script = fileURLToPath(new URL('./check-server-test-inputs.mjs', import.meta.url));+ const run = spawnSync(process.execPath, [script], { encoding: 'utf-8' });+ expect(run.status, run.stderr).toBe(0);+ expect(run.stdout).toMatch(/check:server-test-inputs: OK/);+ });+});diff --git a/scripts/create-turbo-cache-key.mjs b/scripts/create-turbo-cache-key.mjsnew file mode 100644index 000000000..79e7883be--- /dev/null+++ b/scripts/create-turbo-cache-key.mjs@@ -0,0 +1,24 @@+#!/usr/bin/env node+import { writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { fileURLToPath } from 'node:url';++const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));++export const CACHE_KEY_FILE = 'turbo-cache-key.json';++export function cacheKey({ platform, arch } = process) {+ return { platform, arch };+}++export function writeCacheKey(root = OK_ROOT, proc = process) {+ const key = cacheKey(proc);+ const path = join(root, CACHE_KEY_FILE);+ writeFileSync(path, `${JSON.stringify(key)}\n`);+ return { path, key };+}++if (import.meta.main) {+ const { path, key } = writeCacheKey();+ console.log(`turbo cache key ${JSON.stringify(key)} -> ${path}`);+}diff --git a/scripts/create-turbo-cache-key.test.mjs b/scripts/create-turbo-cache-key.test.mjsnew file mode 100644index 000000000..95d7bcb63--- /dev/null+++ b/scripts/create-turbo-cache-key.test.mjs@@ -0,0 +1,48 @@+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { fileURLToPath } from 'node:url';+import { describe, expect, test } from 'vitest';+import { CACHE_KEY_FILE, cacheKey, writeCacheKey } from './create-turbo-cache-key.mjs';++const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));++const readJson = (p) => JSON.parse(readFileSync(join(OK_ROOT, p), 'utf-8'));++describe('turbo platform cache key', () => {+ test('the key file is a globalDependency, so platform reaches every task hash', () => {+ expect(readJson('turbo.json').globalDependencies).toContain(CACHE_KEY_FILE);+ });++ test('postinstall regenerates it, so it exists before any turbo invocation', () => {+ expect(readJson('package.json').scripts.postinstall).toBe(+ 'node scripts/create-turbo-cache-key.mjs',+ );+ });++ test('the key carries platform and arch, and nothing else', () => {+ expect(cacheKey({ platform: 'linux', arch: 'x64' })).toEqual({+ platform: 'linux',+ arch: 'x64',+ });+ });++ test('two platforms produce two different payloads', () => {+ const linux = JSON.stringify(cacheKey({ platform: 'linux', arch: 'x64' }));+ const mac = JSON.stringify(cacheKey({ platform: 'darwin', arch: 'arm64' }));+ expect(linux).not.toBe(mac);+ });++ test('writeCacheKey emits the payload the hash reads', () => {+ const dir = mkdtempSync(join(tmpdir(), 'ok-turbo-cache-key-'));+ try {+ const { path } = writeCacheKey(dir, { platform: 'win32', arch: 'arm64' });+ expect(JSON.parse(readFileSync(path, 'utf-8'))).toEqual({+ platform: 'win32',+ arch: 'arm64',+ });+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ });+});diff --git a/turbo.json b/turbo.jsonindex ecf825233..d6b13c43c 100644--- a/turbo.json+++ b/turbo.json@@ -1,6 +1,7 @@{"$schema": "https://turbo.build/schema.json","globalDependencies": [+ "turbo-cache-key.json","test-support/fixtures/share-url-v1-v2.json","test-support/fixtures/codex-legacy-warning-envelopes.json","pnpm-workspace.yaml",@@ -109,6 +110,26 @@"../test-support/*.ts"]},+ "@inkeep/open-knowledge-server#test": {+ "dependsOn": ["^build"],+ "cache": true,+ "inputs": [+ "$TURBO_DEFAULT$",+ "!CHANGELOG.md",+ "!README.md",+ "../../test-support/*.ts",+ "../../oxlint.config.ts",+ "../../lint-plugins/**",+ "../plugin/**",+ "../../plugins/ok/**",+ "../app/src/editor/observers.ts",+ "../cli/src/**",+ "../cli/tsdown.config.ts",+ "../desktop/src/main/**",+ "../*/package.json",+ "../../docs/content/**"+ ]+ },"@inkeep/open-knowledge#test": {"dependsOn": ["^build", "build"],"cache": true,