fix(reference): retain unknown kind for unsupported source entries

Keep FIFO, socket and device entries unknown instead of projecting unsupported reader entries as ordinary files. Preserve real file read-failure identity.

Fixes #3218

Co-authored-by: Saim Shafique <[email protected]>
This commit is contained in:
morlutoandSaim Shafique committed 2026-10-14 15:20:02 +08:00
1 parent b57a054d5e
commit ada133c256
2 files changed
+59 -1

No files matched your search

@@ -6,6 +6,64 @@ import { parseReferenceSourceEntries } from "./ReferenceSourceImportEntries.js";
import { historicalSourceLanguages } from "../domain/referenceSourceGraph.js";
import type { ReferenceSourceRead } from "../reference/ReferenceSourceReaderTypes.js";
it("projects an unsupported non-regular entry as unknown kind instead of file", () => {
const read: ReferenceSourceRead = {
root: "/selected/source",
entries: [
{
status: "failed",
kind: "other",
path: "src/pipe",
code: "unsupported",
message: "Entry is not a regular file",
size: 0,
},
],
bytesRead: 0,
limitations: [],
};
const parsed = parseReferenceSourceEntries(read, new Set());
expect(parsed.entries).toContainEqual({
path: "src/pipe",
kind: "unknown",
classifications: ["unknown"],
limitations: [
"Entry is not a regular file Exclude this entry or replace it with a regular file.",
],
});
expect(parsed.entries.some((entry) => entry.kind === "file")).toBe(false);
});
it("keeps a failed regular file as file kind", () => {
const read: ReferenceSourceRead = {
root: "/selected/source",
entries: [
{
status: "failed",
kind: "file",
path: "src/broken.ts",
code: "io",
message: "Entry could not be read",
},
],
bytesRead: 0,
limitations: [],
};
const parsed = parseReferenceSourceEntries(read, new Set());
expect(parsed.entries).toContainEqual({
path: "src/broken.ts",
kind: "file",
sha256: null,
size: null,
language: null,
classifications: ["source"],
content_state: "unreadable",
limitations: [
"Entry could not be read This file could not be read. Check its permissions, then try again.",
],
});
});
it("retains Kotlin source identity and language across the inventory projection", () => {
const files = [
[
@@ -75,7 +75,7 @@ const failedEntry = (
classifications,
limitations: [limitation],
};
if (entry.kind === "unknown")
if (entry.kind === "unknown" || entry.kind === "other")
return {
path: entry.path,
kind: "unknown",