Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Restore the /readyz drain test and pin Tempo mount isolation (#6182)
Nick Gomez43ae6390b319
diff --git a/knip.config.ts b/knip.config.tsindex 0004a763a..69344114d 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -149,15 +149,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/app/tests/perf/lib/tempo-client.test.ts b/packages/app/tests/perf/lib/tempo-client.test.tsindex ec27323c4..b3b73640d 100644--- a/packages/app/tests/perf/lib/tempo-client.test.ts+++ b/packages/app/tests/perf/lib/tempo-client.test.ts@@ -76,6 +76,33 @@ describe('parseTempoTimings — pure extraction', () => {}});+ test("takes every timing from the queried mount's spans when another mount's spans of the same names share the window", () => {+ const response = buildTempoResponse([+ { name: 'ok.cold-mount', durationMs: 900, mountId: 'mid-other' },+ { name: 'ok.provider-pool.open', durationMs: 90, mountId: 'mid-other' },+ { name: 'ok.mount-promise', durationMs: 400, mountId: 'mid-other' },+ { name: 'ok.sync-promise', durationMs: 800, mountId: 'mid-other' },+ { name: 'sync.handshake', durationMs: 70, mountId: 'mid-other' },+ { name: 'persistence.onLoadDocument', durationMs: 60, mountId: 'mid-other' },+ { name: 'ok.cold-mount', durationMs: 250, mountId: 'mid-a' },+ { name: 'ok.provider-pool.open', durationMs: 5, mountId: 'mid-a' },+ { name: 'ok.mount-promise', durationMs: 40, mountId: 'mid-a' },+ { name: 'ok.sync-promise', durationMs: 240, mountId: 'mid-a' },+ { name: 'sync.handshake', durationMs: 12, mountId: 'mid-a' },+ { name: 'persistence.onLoadDocument', durationMs: 8, mountId: 'mid-a' },+ ]);+ expect(parseTempoTimings(response, 'mid-a')).toEqual({+ kind: 'success',+ clientSpanTimings: {+ coldMountMs: 250,+ providerPoolOpenMs: 5,+ mountPromiseMs: 40,+ syncPromiseMs: 240,+ },+ serverSpanTimings: { syncHandshakeMs: 12, persistenceLoadMs: 8 },+ });+ });+test('returns empty when the response has no traces', () => {const result = parseTempoTimings({ traces: [] }, 'mid-a');expect(result.kind).toBe('empty');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 ffd8fce06..e7e63f43d 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('|');diff --git a/packages/server/src/health-routes.test.ts b/packages/server/src/health-routes.test.tsindex d48ad4c56..89eac2d06 100644--- a/packages/server/src/health-routes.test.ts+++ b/packages/server/src/health-routes.test.ts@@ -6,7 +6,12 @@ import { resolve } from 'node:path';import type { Hocuspocus } from '@hocuspocus/server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import type { BootedServer } from './boot.ts';-import { bootCompositionRig, parseProblem, rawRequest } from './composition-rig.test-helper.ts';+import {+ bootCompositionRig,+ parseProblem,+ type RawResponse,+ rawRequest,+} from './composition-rig.test-helper.ts';import { getFreeLoopbackPort } from './loopback-rig-test-helpers.ts';import { mountMcpAndApi } from './mcp-mount.ts';@@ -91,6 +96,38 @@ describe('/readyz', () => {}}, 30_000);+ test('destroy() flips readiness to draining before the listener closes', async () => {+ const tmp = await mkdtemp(resolve(tmpdir(), 'ok-readyz-drain-'));+ try {+ const draining = await bootCompositionRig(tmp);+ try {+ await draining.ready;+ const { httpServer } = draining;+ const closeListener = httpServer.close.bind(httpServer);+ let probeBeforeClose: Promise<RawResponse> | undefined;+ httpServer.close = ((callback?: (err?: Error) => void) => {+ probeBeforeClose = rawRequest(draining.port, '/readyz');+ const close = () => {+ closeListener(callback);+ };+ void probeBeforeClose.then(close, close);+ return httpServer;+ }) as typeof httpServer.close;++ await draining.destroy();++ expect(probeBeforeClose).toBeDefined();+ const probe = await probeBeforeClose;+ expect(probe?.status).toBe(503);+ expect(JSON.parse(probe?.body ?? '')).toMatchObject({ ready: false, status: 'draining' });+ } finally {+ await draining.destroy();+ }+ } finally {+ await rm(tmp, { recursive: true, force: true });+ }+ }, 30_000);+test('is exempt from the Host gate like /healthz', async () => {const res = await rawRequest(booted.port, '/readyz', {headers: { Host: 'kb.internal:8080' },