refactor(kernel): migrate the remaining SHA-256 hex digests to sha256Hex and move isRecord into src/kernel (#11571)

* refactor(kernel): migrate the remaining one-shot SHA-256 hex digests to sha256Hex

* refactor(kernel): move isRecord into src/kernel and replace its inline copies (#11574)

* fix(scripts): import isRecord from src/kernel in the managed manifest parser
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 20:53:36 -05:00
1 parent 9ecfb109e8
commit b51ed4c3ec
157 files changed
+397 -589

No files matched your search

@@ -24,7 +24,7 @@ import type {
JavaScriptSemanticProjectionCapacity,
JavaScriptSemanticFileProjection,
} from "../../domain/javascript/javascriptSemanticFileProjection.js";
import { createHash, randomUUID } from "node:crypto";
import { randomUUID } from "node:crypto";
import { readFile, rm, stat } from "node:fs/promises";
import { join } from "node:path";
import { writeJavaScriptAnalysisSourceTransfer } from "./JavaScriptAnalysisSourceTransfer.js";
@@ -100,6 +100,7 @@ import {
type JavaScriptWorkerMessage,
} from "./JavaScriptAnalysisWorkerProtocol.js";
import { errorMessage } from "../../kernel/errorMessage.js";
import { sha256Hex } from "../../kernel/sha256Hex.js";
const OPERATION = "analyze_javascript_application";
const PROVIDER = "javascript-static-analysis";
@@ -392,7 +393,7 @@ export class JavaScriptAnalysisWorker {
this.limits.memberMutationAllowance ??
DEFAULT_JAVASCRIPT_MEMBER_MUTATION_ALLOWANCE,
),
text_sha256: createHash("sha256").update(file.text.value).digest("hex"),
text_sha256: sha256Hex(file.text.value),
file: metadata,
package_type: packageType,
purpose,
@@ -866,10 +867,7 @@ export class JavaScriptAnalysisWorker {
},
);
const checkpoint = await readFile(path);
if (
expected !== undefined &&
createHash("sha256").update(checkpoint).digest("hex") !== expected.sha256
)
if (expected !== undefined && sha256Hex(checkpoint) !== expected.sha256)
throw new AnalysisOutputError(
OPERATION,
"JavaScript static checkpoint digest does not match",
@@ -10,7 +10,6 @@ import type {
JavaScriptSemanticProjectionCapacity,
JavaScriptSemanticFileProjection,
} from "../../domain/javascript/javascriptSemanticFileProjection.js";
import { createHash } from "node:crypto";
import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { getHeapStatistics } from "node:v8";
@@ -38,6 +37,7 @@ import {
type JavaScriptWorkerMessage,
} from "./JavaScriptAnalysisWorkerProtocol.js";
import { errorMessage } from "../../kernel/errorMessage.js";
import { sha256Hex } from "../../kernel/sha256Hex.js";
/** Trusted composition callback; this provider owns framing and temporary I/O. */
export interface JavaScriptSourceWorkerAnalyzer {
@@ -122,9 +122,7 @@ const analyzeJob = async (
try {
let resultBudgetBytes = 0;
const source = await readFile(join(root, `${request.id}.source`), "utf8");
if (
createHash("sha256").update(source).digest("hex") !== request.text_sha256
)
if (sha256Hex(source) !== request.text_sha256)
throw new TypeError(
"JavaScript worker source text digest does not match its request",
);
@@ -180,7 +178,7 @@ const analyzeJob = async (
kind: "static",
id: request.id,
bytes,
sha256: createHash("sha256").update(text).digest("hex"),
sha256: sha256Hex(text),
});
const next = await requests.next();
if (next.done || !next.value.ok)