Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Declare cache-mode none on the daily OK lanes' credentialed jobs (#5832)
Nick Gomez2dfa0e431d41
diff --git a/.github/scripts/cache-mode-shape.test-helper.mjs b/.github/scripts/cache-mode-shape.test-helper.mjsnew file mode 100644index 000000000..d63605312--- /dev/null+++ b/.github/scripts/cache-mode-shape.test-helper.mjs@@ -0,0 +1,152 @@+import { existsSync, readFileSync } from 'node:fs';+import { dirname, join } from 'node:path';+import { fileURLToPath } from 'node:url';+import { parse } from 'yaml';+import { credentialReasons } from './workflow-credentials.test-helper.mjs';++const OK_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');+const MODES = ['none', 'read', 'write-only', 'write'];++const isFalse = (value) => /^false$/i.test(String(value));+const isLiteralTrue = (value) => String(value) === 'true';++const CACHE_FREE = () => [];+const ACTIONS = {+ 'actions/checkout': CACHE_FREE,+ 'actions/upload-artifact': CACHE_FREE,+ 'actions/download-artifact': CACHE_FREE,+ 'actions/create-github-app-token': CACHE_FREE,+ 'actions/github-script': CACHE_FREE,+ 'dtolnay/rust-toolchain': CACHE_FREE,+ 'taiki-e/install-action': CACHE_FREE,+ 'linear/linear-release-action': CACHE_FREE,+ 'actions/cache': () => ['extract', 'save'],+ 'actions/cache/restore': (inputs) =>+ isLiteralTrue(inputs['lookup-only']) ? ['lookup'] : ['extract'],+ 'actions/cache/save': () => ['save'],+ 'actions/setup-node': (inputs) => {+ if (inputs.cache !== undefined) return ['extract', 'save'];+ return isFalse(inputs['package-manager-cache']) ? [] : ['incidental'];+ },+ 'pnpm/action-setup': (inputs) =>+ inputs.cache === undefined || isFalse(inputs.cache) ? [] : ['extract', 'save'],+ 'pnpm/setup': (inputs) =>+ inputs.cache === undefined || isFalse(inputs.cache) ? [] : ['extract', 'save'],+ 'astral-sh/setup-uv': (inputs) => (isFalse(inputs['enable-cache']) ? [] : ['incidental']),+ 'mlugg/setup-zig': (inputs) => [+ 'extract',+ 'save',+ ...(isFalse(inputs['use-cache']) ? [] : ['incidental']),+ ],+ 'actions/stale': () => ['incidental'],+};++const OFF_SWITCHES = {+ 'actions/setup-node': 'package-manager-cache',+ 'pnpm/action-setup': 'cache',+ 'pnpm/setup': 'cache',+ 'astral-sh/setup-uv': 'enable-cache',+ 'mlugg/setup-zig': 'use-cache',+};++const actionName = (uses) => (uses.includes('@') ? uses.slice(0, uses.indexOf('@')) : undefined);++function actionSteps(steps, root = OK_ROOT, seen = []) {+ const found = [];+ for (const step of steps ?? []) {+ const uses = step.uses;+ if (uses === undefined) continue;+ if (uses.startsWith('./')) {+ if (seen.includes(uses)) throw new Error(`composite cycle through ${uses}`);+ const dir = join(root, uses);+ const file = ['action.yml', 'action.yaml'].map((name) => join(dir, name)).find(existsSync);+ if (file === undefined) throw new Error(`local action ${uses} has no action.yml`);+ const action = parse(readFileSync(file, 'utf8'));+ if (action.runs?.using !== 'composite') {+ throw new Error(+ `local action ${uses} runs ${action.runs?.using}, not composite, so this sweep cannot see what cache it touches`,+ );+ }+ found.push(+ ...actionSteps(action.runs.steps, root, [...seen, uses]).map((inner) => ({+ ...inner,+ via: [uses, ...inner.via],+ })),+ );+ continue;+ }+ found.push({ step, via: [] });+ }+ return found;+}++export function cacheOps(steps, root = OK_ROOT) {+ return actionSteps(steps, root).flatMap(({ step, via }) => {+ const classify = ACTIONS[actionName(step.uses)];+ if (classify === undefined) {+ throw new Error(+ `${step.uses} is not classified for cache access; add it to ACTIONS in cache-mode-shape.test-helper.mjs`,+ );+ }+ return classify(step.with ?? {}).map((kind) => ({ kind, step: step.name ?? step.uses, via }));+ });+}++function narrowestMode(ops) {+ const reads = ops.some((op) => op.kind === 'lookup' || op.kind === 'extract');+ const writes = ops.some((op) => op.kind === 'save');+ if (reads && writes) return 'write';+ if (reads) return 'read';+ return writes ? 'write-only' : 'none';+}++export const effectiveMode = (workflow, job) => job['cache-mode'] ?? workflow['cache-mode'] ?? null;++export function cacheModeProblems(workflow, job, root = OK_ROOT) {+ if (credentialReasons(workflow, job).length === 0) return [];+ if (job.uses !== undefined)+ return [`calls the reusable workflow ${job.uses}, which this sweep does not trace`];+ const ops = cacheOps(job.steps, root);+ const mode = effectiveMode(workflow, job);+ const problems = [];+ for (const op of ops.filter((candidate) => candidate.kind === 'extract')) {+ problems.push(`extracts a cache entry at ${[...op.via, op.step].join(' > ')}`);+ }+ if (mode === null) problems.push('declares no cache-mode, so the trigger default applies');+ else if (!MODES.includes(mode))+ problems.push(`declares cache-mode ${mode}, which is not one of ${MODES.join(', ')}`);+ else if (mode !== narrowestMode(ops)) {+ problems.push(+ `declares cache-mode ${mode}, but its cache operations need exactly ${narrowestMode(ops)}`,+ );+ }+ if (mode === 'read' || mode === 'write') {+ for (const op of ops.filter((candidate) => candidate.kind === 'incidental')) {+ problems.push(+ `cache-mode ${mode} lets ${[...op.via, op.step].join(' > ')} restore its own cache`,+ );+ }+ }+ return problems;+}++export function restoresNothingProblems(workflow, job, root = OK_ROOT) {+ if (job.uses !== undefined)+ return [`calls the reusable workflow ${job.uses}, which this sweep does not trace`];+ const problems = [];+ const mode = effectiveMode(workflow, job);+ if (mode === null) problems.push('declares no cache-mode, so the trigger default applies');+ else if (mode !== 'none') problems.push(`declares cache-mode ${mode}, not none`);+ for (const op of cacheOps(job.steps, root)) {+ problems.push(`touches the cache (${op.kind}) at ${[...op.via, op.step].join(' > ')}`);+ }+ for (const { step, via } of actionSteps(job.steps, root)) {+ const input = OFF_SWITCHES[actionName(step.uses)];+ if (input !== undefined && !isFalse(step.with?.[input])) {+ problems.push(+ `does not set ${input}: false at ${[...via, step.name ?? step.uses].join(' > ')}`,+ );+ }+ }+ return problems;+}diff --git a/.github/scripts/cache-mode-shape.test.mjs b/.github/scripts/cache-mode-shape.test.mjsindex 2c42dc6d1..779789161 100644--- a/.github/scripts/cache-mode-shape.test.mjs+++ b/.github/scripts/cache-mode-shape.test.mjs@@ -1,145 +1,20 @@// biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub expression fixtures must remain literal.-import {- existsSync,- mkdirSync,- mkdtempSync,- readdirSync,- readFileSync,- rmSync,- writeFileSync,-} from 'node:fs';+import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import { afterAll, describe, expect, test } from 'vitest';import { parse } from 'yaml';+import {+ cacheModeProblems,+ cacheOps,+ effectiveMode,+ restoresNothingProblems,+} from './cache-mode-shape.test-helper.mjs';import { credentialReasons } from './workflow-credentials.test-helper.mjs';const OK_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');const WORKFLOWS = join(OK_ROOT, '.github', 'workflows');-const MODES = ['none', 'read', 'write-only', 'write'];--const isFalse = (value) => /^false$/i.test(String(value));-const isLiteralTrue = (value) => String(value) === 'true';--const CACHE_FREE = () => [];-const ACTIONS = {- 'actions/checkout': CACHE_FREE,- 'actions/upload-artifact': CACHE_FREE,- 'actions/download-artifact': CACHE_FREE,- 'actions/create-github-app-token': CACHE_FREE,- 'dtolnay/rust-toolchain': CACHE_FREE,- 'taiki-e/install-action': CACHE_FREE,- 'linear/linear-release-action': CACHE_FREE,- 'actions/cache': () => ['extract', 'save'],- 'actions/cache/restore': (inputs) =>- isLiteralTrue(inputs['lookup-only']) ? ['lookup'] : ['extract'],- 'actions/cache/save': () => ['save'],- 'actions/setup-node': (inputs) => {- if (inputs.cache !== undefined) return ['extract', 'save'];- return isFalse(inputs['package-manager-cache']) ? [] : ['incidental'];- },- 'pnpm/action-setup': (inputs) =>- inputs.cache === undefined || isFalse(inputs.cache) ? [] : ['extract', 'save'],- 'pnpm/setup': (inputs) =>- inputs.cache === undefined || isFalse(inputs.cache) ? [] : ['extract', 'save'],- 'astral-sh/setup-uv': (inputs) => (isFalse(inputs['enable-cache']) ? [] : ['incidental']),- 'mlugg/setup-zig': (inputs) => [- 'extract',- 'save',- ...(isFalse(inputs['use-cache']) ? [] : ['incidental']),- ],- 'actions/stale': () => ['incidental'],-};--const OFF_SWITCHES = {- 'actions/setup-node': 'package-manager-cache',- 'pnpm/action-setup': 'cache',- 'pnpm/setup': 'cache',- 'astral-sh/setup-uv': 'enable-cache',- 'mlugg/setup-zig': 'use-cache',-};--const actionName = (uses) => (uses.includes('@') ? uses.slice(0, uses.indexOf('@')) : undefined);--function actionSteps(steps, root = OK_ROOT, seen = []) {- const found = [];- for (const step of steps ?? []) {- const uses = step.uses;- if (uses === undefined) continue;- if (uses.startsWith('./')) {- if (seen.includes(uses)) throw new Error(`composite cycle through ${uses}`);- const dir = join(root, uses);- const file = ['action.yml', 'action.yaml'].map((name) => join(dir, name)).find(existsSync);- if (file === undefined) throw new Error(`local action ${uses} has no action.yml`);- const action = parse(readFileSync(file, 'utf8'));- if (action.runs?.using !== 'composite') {- throw new Error(- `local action ${uses} runs ${action.runs?.using}, not composite, so this sweep cannot see what cache it touches`,- );- }- found.push(- ...actionSteps(action.runs.steps, root, [...seen, uses]).map((inner) => ({- ...inner,- via: [uses, ...inner.via],- })),- );- continue;- }- found.push({ step, via: [] });- }- return found;-}--function cacheOps(steps, root = OK_ROOT) {- return actionSteps(steps, root).flatMap(({ step, via }) => {- const classify = ACTIONS[actionName(step.uses)];- if (classify === undefined) {- throw new Error(- `${step.uses} is not classified for cache access; add it to ACTIONS in cache-mode-shape.test.mjs`,- );- }- return classify(step.with ?? {}).map((kind) => ({ kind, step: step.name ?? step.uses, via }));- });-}--function narrowestMode(ops) {- const reads = ops.some((op) => op.kind === 'lookup' || op.kind === 'extract');- const writes = ops.some((op) => op.kind === 'save');- if (reads && writes) return 'write';- if (reads) return 'read';- return writes ? 'write-only' : 'none';-}--const effectiveMode = (workflow, job) => job['cache-mode'] ?? workflow['cache-mode'] ?? null;--function cacheModeProblems(workflow, job, root = OK_ROOT) {- if (credentialReasons(workflow, job).length === 0) return [];- if (job.uses !== undefined)- return [`calls the reusable workflow ${job.uses}, which this sweep does not trace`];- const ops = cacheOps(job.steps, root);- const mode = effectiveMode(workflow, job);- const problems = [];- for (const op of ops.filter((candidate) => candidate.kind === 'extract')) {- problems.push(`extracts a cache entry at ${[...op.via, op.step].join(' > ')}`);- }- if (mode === null) problems.push('declares no cache-mode, so the trigger default applies');- else if (!MODES.includes(mode))- problems.push(`declares cache-mode ${mode}, which is not one of ${MODES.join(', ')}`);- else if (mode !== narrowestMode(ops)) {- problems.push(- `declares cache-mode ${mode}, but its cache operations need exactly ${narrowestMode(ops)}`,- );- }- if (mode === 'read' || mode === 'write') {- for (const op of ops.filter((candidate) => candidate.kind === 'incidental')) {- problems.push(- `cache-mode ${mode} lets ${[...op.via, op.step].join(' > ')} restore its own cache`,- );- }- }- return problems;-}const SHIPS = ['desktop-release.yml#build-linux',@@ -158,27 +33,6 @@ const QA_BUILDS = ['desktop-build.yml#build-macos-dmg',];-function restoresNothingProblems(workflow, job, root = OK_ROOT) {- if (job.uses !== undefined)- return [`calls the reusable workflow ${job.uses}, which this sweep does not trace`];- const problems = [];- const mode = effectiveMode(workflow, job);- if (mode === null) problems.push('declares no cache-mode, so the trigger default applies');- else if (mode !== 'none') problems.push(`declares cache-mode ${mode}, not none`);- for (const op of cacheOps(job.steps, root)) {- problems.push(`touches the cache (${op.kind}) at ${[...op.via, op.step].join(' > ')}`);- }- for (const { step, via } of actionSteps(job.steps, root)) {- const input = OFF_SWITCHES[actionName(step.uses)];- if (input !== undefined && !isFalse(step.with?.[input])) {- problems.push(- `does not set ${input}: false at ${[...via, step.name ?? step.uses].join(' > ')}`,- );- }- }- return problems;-}-const workflows = readdirSync(WORKFLOWS).filter((name) => /\.ya?ml$/.test(name)).sort()@@ -470,6 +324,9 @@ describe('cache-mode sweep self-tests', () => {expect(kinds({ uses: 'actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f' })).toEqual(['incidental',]);+ expect(+ kinds({ uses: 'actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3' }),+ ).toEqual([]);expect(kinds({ run: 'pnpm install' })).toEqual([]);});diff --git a/knip.config.ts b/knip.config.tsindex d3638888e..65f0e8807 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -147,15 +147,11 @@ export default {'packages/server': {entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],project: 'src/**',- ignoreDependencies: [- '@types/shell-quote',- ],+ ignoreDependencies: ['@types/shell-quote'],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: [- 'yjs',- ],+ ignoreDependencies: ['yjs'],},'packages/desktop': {entry: [diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex 4549c74b3..a50b00123 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,4 +1,3 @@-import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 4fc2c11f9..6fcdc23f2 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 9f2f6feb6..40b5cdfd6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 2a085742b..93666af70 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 878d5196b..867598d34 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,4 +1,3 @@-import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 4ada3cf26..0970ac12f 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex cbe2b705f..b632185e1 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,4 +1,3 @@-import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex 89bc9b4d9..c530ce4ba 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,4 +1,3 @@-import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex a78aeb0e4..d3767adc9 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,4 +1,3 @@-import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex e7cc69c3f..b076f955c 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,4 +1,3 @@-import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 9ddcd0730..7935e35f8 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,4 +1,3 @@-import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex 2a597ec3d..f4cc8a286 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,4 +1,3 @@-import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex 01ef76a9f..8fb428b90 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,4 +1,3 @@-import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fb0ba5a7c..fc267cbea 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,4 +1,3 @@-import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex fa3cfcd86..bfd7e3109 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,4 +1,3 @@-import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 8be632ba4..4d3250d3a 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,4 +1,3 @@-export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');