From 3a85fc2920053d1ec7ab05d1de539b9d757d81fa Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 9 Nov 2026 23:12:57 -0600 Subject: [PATCH 1/3] api-model(fix) Keep Clojure bindings local why: Native call forms linked local arguments and fragments of var names to unrelated Java APIs. what: - Preserve complete Clojure var and argument tokens. - Mark native call names and parameters as declarations. - Retain authored references and Java type-hint links. - Cover colliding names through the actual symbol resolver. --- packages/api-model/src/link.ts | 6 +++-- packages/api-model/test/clojure.test.ts | 33 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/api-model/src/link.ts b/packages/api-model/src/link.ts index 36e987cac..9634c5797 100644 --- a/packages/api-model/src/link.ts +++ b/packages/api-model/src/link.ts @@ -1524,7 +1524,7 @@ export class SymbolIndex { ? String.raw`[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*!?` // A number is matched whole, so `1_000` is not a literal followed by a name. : this.lang === 'elixir' ? String.raw`\d[\d_]*(?:\.\d+)?(?:[eE][+-]?\d+)?|[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*[!?]?` - : this.lang === 'clojure' ? String.raw`::?[^\s,()[\]{}"';]+|[A-Za-z_][A-Za-z0-9_.]*(?:::[A-Za-z_][A-Za-z0-9_.]*)*` + : this.lang === 'clojure' ? String.raw`::?[^\s,()[\]{}"';]+|[A-Za-z_][A-Za-z0-9_./?!*+<>=:$%&-]*` : this.lang === 'powershell' ? String.raw`(?:[A-Za-z_][A-Za-z0-9_.]*\\)?[A-Za-z_][A-Za-z0-9_.-]*` : this.lang === 'ts' ? String.raw`[A-Za-z_$][A-Za-z0-9_$.]*` : this.lang === 'rs' ? String.raw`(?:r#)?[A-Za-z_][A-Za-z0-9_.]*(?:::(?:r#)?[A-Za-z_][A-Za-z0-9_.]*)*` @@ -1675,6 +1675,7 @@ export class SymbolIndex { } if (signature && context && (ident === context.name || ident.endsWith(`.${context.name}`)) && (/\b(?:def|fun|class|interface|trait|object|type|val|var|member|let)\s+$/.test(annotation.slice(0, m.index)) || + (this.lang === 'clojure' && annotation === signature.raw && annotation.slice(0, m.index).trim() === '(') || (this.lang === 'julia' && annotation.slice(0, m.index).trim() === '' && /^[{(]/.test(annotation.slice(m.index! + ident.length))))) { const receiver = ident.slice(0, -context.name.length).replace(/\.$/, '') if (receiver) out.push(...this.linkType(receiver, context), { text: '.' }) @@ -1682,7 +1683,8 @@ export class SymbolIndex { continue } if (signature && (signature.params.some((param) => param.name === ident) || signature.receiver?.name === ident) && - (/^\s*\??\s*:(?!:)/.test(annotation.slice(m.index! + ident.length)) || + ((this.lang === 'clojure' && annotation === signature.raw) || + /^\s*\??\s*:(?!:)/.test(annotation.slice(m.index! + ident.length)) || (this.lang === 'julia' && /(?:^|[(,;])\s*$/.test(annotation.slice(0, m.index)) && /^\s*(?:::|[=,;)]|\.\.\.)/.test(annotation.slice(m.index! + ident.length))))) { const parameter = this.lang === 'julia' && context && signature.params.some((param) => param.name === ident) diff --git a/packages/api-model/test/clojure.test.ts b/packages/api-model/test/clojure.test.ts index 5e06fb27b..191b540ac 100644 --- a/packages/api-model/test/clojure.test.ts +++ b/packages/api-model/test/clojure.test.ts @@ -41,6 +41,39 @@ function artifact() { } describe('compiled Clojure artifact', () => { + it('keeps var names and local arguments out of Java signature links', () => { + const input = artifact() + input.symbols.push( + callable('libtmux.control', 'send!', [['connection', 'argv', 'timeout']]), + callable('libtmux.data', 'one-or-none', [['values']]), + callable('libtmux.core', 'join-pane!', [['pane', 'window']]), + callable('libtmux.core', 'ready?', [['timeout-ms']]), + ) + const model = extractClojure(input, revision) + const index = new SymbolIndex(model.symbols, (symbol) => `/${symbol.id}/`, 'clojure') + index.addInventory('/en/java/latest/reference/', ['timeout', 'values', 'join', 'or', 'none'].map((name) => ({ + name, type: 'std:label', priority: 1, uri: `${name}/`, dispname: name, + })), ['clojure'], 'libtmux Java') + index.addInventory('https://docs.oracle.com/en/java/javase/25/docs/api/', [{ + name: 'java.util.concurrent.CompletionStage', type: 'std:label', priority: 1, + uri: 'java.base/java/util/concurrent/CompletionStage.html', dispname: '-', + }], ['clojure'], 'Java SE') + for (const id of ['libtmux.control/send!', 'libtmux.data/one-or-none', 'libtmux.core/join-pane!', 'libtmux.core/ready?']) { + const symbol = model.symbols.find((entry) => entry.id === id)! + const signature = symbol.signatures[0]! + const spans = index.linkType(signature.raw!, symbol, signature) + expect(spans.some((span) => span.link), signature.raw).toBe(false) + expect(spans.map((span) => span.text).join('')).toBe(signature.raw) + expect(spans.find((span) => span.text === symbol.name)?.declaration).toBe(true) + for (const parameter of signature.params) { + expect(spans.find((span) => span.text === parameter.name)?.declaration, parameter.name).toBe(true) + } + } + expect(index.linkType('java.util.concurrent.CompletionStage')[0]?.link?.href) + .toContain('java/util/concurrent/CompletionStage.html') + expect(index.docSpans('See [[libtmux.core/close!]].')[1]?.link?.symbol?.id).toBe('libtmux.core/close!') + }) + it('keeps keywords literal when their names match callable declarations', () => { const input = artifact() input.symbols.push(callable('libtmux.core', 'timeout', [['value']])) From 9e9b9b9b465cebe776684da51179c1ebdba7f493 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Mon, 9 Nov 2026 23:13:19 -0600 Subject: [PATCH 2/3] api-model(test) Verify rendered Clojure arities why: Native signature rendering must preserve callable names and keep local arguments out of the Java parent inventory. what: - Render every public Clojure function arity through Astro. - Check copied source text, declaration names and link destinations. --- site/test/native-signature.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/site/test/native-signature.test.ts b/site/test/native-signature.test.ts index 8cf9abf54..911e9f483 100644 --- a/site/test/native-signature.test.ts +++ b/site/test/native-signature.test.ts @@ -60,6 +60,31 @@ function displayedSignature(element: Element): string { return copy.textContent ?? '' } +it('renders Clojure call arities without linking local bindings to Java methods', async () => { + const model = JSON.parse(readFileSync(new URL('../src/data/api/clojure.json', import.meta.url), 'utf8')) as ApiModel + const href = (symbol: ApiSymbol) => `/reference/${symbol.slug}/` + const index = createApiIndex(model, href) + const component = await (componentPromise ??= signatureComponent()) + const container = await experimental_AstroContainer.create() + const win = new Window() + try { + const functions = model.symbols.filter((symbol) => symbol.kind === 'function') + expect(functions.length).toBeGreaterThan(0) + for (const symbol of functions) { + for (const sig of symbol.signatures) { + win.document.body.innerHTML = await container.renderToString(component, { props: { + symbol, sig, port: 'clojure', language: 'clojure', index, + nameHref: href(symbol), nativeSignatureText, + } }) + const element = win.document.querySelector('.api-native-signature')! + expect(displayedSignature(element)).toBe(sig.raw) + expect(element.querySelector('.api-declaration-name')?.textContent).toBe(symbol.name) + expect(element.querySelectorAll('a.api-type-link'), sig.raw).toHaveLength(0) + } + } + } finally { await win.happyDOM.abort() } +}) + it('renders Erlang compiler references with exact native declarations and Markdown', async () => { const artifact = JSON.parse(readFileSync(new URL('../../packages/api-model/test/fixtures/erlang-native.json', import.meta.url), 'utf8')) const model = extractErlang(artifact) From f58c5b587dd2087d1d39f9c27281f0d60b97a3ac Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 10 Nov 2026 03:53:35 -0600 Subject: [PATCH 3/3] fix(clojure) Rebaseline genuine cross-references why: The corrected renderer removes 53 spurious signature links and adds one valid namespace link, taking the measured count from 695 to 643. All 311 references outside signatures remain unchanged. The old minimum of 673 counted declaration and binding links that should never resolve. what: - Set only the Clojure cross-reference minimum to the measured 643 - Keep every other port minimum and the shared checker unchanged --- scripts/xref-floor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/xref-floor.json b/scripts/xref-floor.json index 43ea21ec1..03841569e 100644 --- a/scripts/xref-floor.json +++ b/scripts/xref-floor.json @@ -11,7 +11,7 @@ "rs": 4330, "go": 13216, "java": 1672, - "clojure": 673, + "clojure": 643, "csharp": 3182, "cxx": 1982, "swift": 3739,