Skip to content

Commit 085fbf8

Browse files
#1912 knip: the publish primitive has no production consumer yet, so tag it instead of blanking the module
The knip check on this PR has two steps. CI's 'Run knip checks' passes; 'Run production Knip checks' failed on 1fb5fcc with one finding, and it reproduces locally on a real install: Unused exports (1) safeWriteText function src/services/file-safety/safeWriteText.ts:392:23 Why: in production mode Knip does not count test usage, and nothing in the shipped extension imports the function. u3's head 9713c4a passed the same step because its src/utils/safeWriteJson.ts imported safeWriteText at line 11 - the JSON writer delegated to the primitive. The seam ruling resolved the safeWriteJson conflict pair to main's replacement protocol instead, so that import is gone and the primitive's only remaining importers are its own unit tests. grep over src, packages and apps at this head finds zero production importers outside the module: observationRegistry.ts and Task.ts perform no file writes at all, and every McpHub write is JSON, which is safeWriteJson's job. So the export is real, the consumer is later in the merge order (the guardedWrite migration), and the missing consumer is the price of the seam ruling rather than a mistake in the graft. What was measured before choosing the fix. knip 5.88.1's schema has no per-symbol ignore: ignoreExports is not a key, and ignoreExportsUsedInFile is already true at the top of knip.json - it does not cover this export because the function is not referenced inside its own file. The only config knob that would clear the finding is ignore, and that blanks this whole 973-line module in both knip views, hiding any future finding in it too. The alternative of shipping the export from the unit that adds its consumer would move 2,323 lines of the primitive's evidence out of this PR, which is the opposite of keeping both feature sets. Chosen fix: tag the export @internal, which is what the repository already does 38 times at main - for example src/api/providers/utils/abort-signal.ts:254, apps/cli/src/lib/task-history/index.ts:11 and apps/cli/src/lib/storage/credentials.ts:16 - and which knip honours by default. The claim is true: the symbol is not part of any shipped API surface, it is repo-internal, and no shipped entry reaches it yet. stripInternal is set nowhere in this repository, so the tag does not remove the declaration from any generated type surface. The tag is a comment: no executable line changed. After it, on the committed tree with the pinned node 22.23.4 and a real install: knip --production exit 0 and knip --treat-config-hints-as-errors exit 0 (measured before this commit, logs S364-knip-production and S364-knip-default), tsc 0 errors, eslint on the file with --max-warnings=0 --prune-suppressions exit 0 with no count moved, prettier unchanged, and the services shard unchanged at 5 failed | 1705 passed | 1 skipped (services/rules EPERM only). The full five-shard gate on the resulting head is in the push report. If the maintainers would rather this PR not carry the tag, the alternatives are the knip.json ignore line or holding the export until the guardedWrite migration lands; both are one decision away and neither changes the graft.
1 parent 22a4ba7 commit 085fbf8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/services/file-safety/safeWriteText.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ export async function resolveLockKey(absoluteFilePath: string): Promise<string>
389389
}
390390
}
391391

392+
/**
393+
* The publish primitive itself. Tagged @internal because nothing in the shipped
394+
* extension reaches it yet: this unit lands the primitive and its evidence, and the
395+
* writer that is meant to call it arrives with the guardedWrite migration. Without the
396+
* tag the production Knip view reports this export as unused, which states the wrong
397+
* reason - the export is deliberate, its consumer is later in the merge order - and the
398+
* alternative is blanking this whole 973-line module in knip.json.
399+
*
400+
* @internal
401+
*/
392402
export async function safeWriteText(
393403
filePath: string,
394404
content: string | Uint8Array,

0 commit comments

Comments
 (0)