refactor(kernel): give error-message, byte-hex and SHA-256 hex helpers one owner in a new src/kernel layer (#11542)

* refactor(kernel): give error-to-message text one owner in a new src/kernel layer

* fix(kernel): keep the regex worker's own error text inside its isolated source

* refactor(kernel): exclude copies that run in another realm from the error-message guard by name

The regex worker's source string and the page.evaluate fetch in PlaywrightScenarioRequest cannot import errorMessage. The guard now names them, so the counted baseline does not invite a later slice to rewrite them.

* refactor(kernel): migrate the long tail of inline error-message copies to errorMessage (#11552)

Every provider and adapter folder with six or fewer copies now calls errorMessage from src/kernel. Local helpers whose whole body was the copy (failureMessage, gdbErrorMessage, message, describe, reasonOf, recoveryFailureMessage and four local errorMessage definitions) are removed and their call sites call the owner.

Refs #11548

* refactor(kernel): give byte-to-hex formatting one owner in src/kernel (#11560)

byteToHex returns the two lowercase hexadecimal digits of one byte. All eight inline copies (native, contracts, domain firmware and desktop, pcap) call it, keeping their own 0x, % or \x notation, and a counted guard with an empty baseline keeps new copies out.

Refs #11548

* refactor(kernel): give one-shot SHA-256 hex digests one owner in src/kernel (#11562)

sha256Hex digests one in-memory value. A counted guard records the one-shot createHash("sha256").update(x).digest("hex") chains (115 in 101 files) and the first slice migrates domain, contracts and process (35 copies), removing local wrappers (sha256, sha256Text, hash) and the exported sha256Text. Incremental and streamed hashing is not counted.

Refs #11548

* refactor(kernel): migrate the application layer's inline error-message copies to errorMessage (#11563)

All 69 copies in src/application call errorMessage from src/kernel. Local helpers whose whole body was the copy (errorDetail, causeReason and five local errorMessage definitions) are removed and their call sites call the owner.

Refs #11548

* refactor(kernel): migrate the native provider's inline error-message copies to errorMessage (#11567)

All 49 copies in src/native call errorMessage from src/kernel. The local errorReason helpers in LldbCallTracer and LldbRetainedObservations, whose whole body was the copy, are removed and their call sites call the owner.

Refs #11548

* refactor(kernel): migrate the remaining inline error-message copies to errorMessage (#11569)
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 07:05:30 +08:00
1 parent ff0176256a
commit 5f718ce30e
291 files changed
+976 -978

No files matched your search

+2 -1
View File
@@ -39,6 +39,7 @@ import {
classifyProviderFailure,
type ProviderFailureDialect,
} from "../providers/classifyProviderFailure.js";
import { errorMessage } from "../kernel/errorMessage.js";
/** Keep typed cleanup history and one canonical output owner, including after resolution. */
export const createSqliteCleanupError = (
@@ -177,7 +178,7 @@ export const sqliteDatabaseDialect = (
diagnostics: {
phase,
path,
reason: cause instanceof Error ? cause.message : String(cause),
reason: errorMessage(cause),
...(cause instanceof OwnedCommandFailure && cause.snapshot !== null
? {
failure_kind: cause.reason,
+7 -6
View File
@@ -17,6 +17,7 @@ import {
SqliteInspectionFailure,
sqlitePrimaryResultCode,
} from "./SqliteDatabaseLimits.js";
import { errorMessage } from "../kernel/errorMessage.js";
/** SQLite's generic SQL error, raised while compiling or evaluating an expression. */
const SQLITE_ERROR = 1;
@@ -192,7 +193,7 @@ const decodeSchemaText = (
} catch (cause: unknown) {
throw new SqliteInspectionFailure(
"format",
`SQLite schema ${label} contains malformed ${encoding} text: ${cause instanceof Error ? cause.message : String(cause)}`,
`SQLite schema ${label} contains malformed ${encoding} text: ${errorMessage(cause)}`,
);
}
};
@@ -749,9 +750,9 @@ const resultColumnLimitFailure = (
)
return undefined;
return new SqliteColumnLimitFailure(
`SQLite cannot return ${String(selectedColumns)} selected result columns; this connection permits at most ${String(engineColumnLimit)}: ${
cause instanceof Error ? cause.message : String(cause)
}`,
`SQLite cannot return ${String(selectedColumns)} selected result columns; this connection permits at most ${String(engineColumnLimit)}: ${errorMessage(
cause,
)}`,
selectedColumns,
engineColumnLimit,
);
@@ -784,7 +785,7 @@ const rowEvaluationFailure = (
if (sqlitePrimaryResultCode(cause) !== SQLITE_ERROR) return cause;
const unavailable = new SqliteInspectionFailure(
"row-evaluation",
`SQLite cannot prepare or evaluate rows of table ${JSON.stringify(table.name)} on REA's read-only connection: ${cause instanceof Error ? cause.message : String(cause)}`,
`SQLite cannot prepare or evaluate rows of table ${JSON.stringify(table.name)} on REA's read-only connection: ${errorMessage(cause)}`,
);
const generated = new Set(
table.columns
@@ -845,7 +846,7 @@ const rowEvaluationFailure = (
]
.map(
([name, failure]) =>
`${JSON.stringify(name)}: ${failure instanceof Error ? failure.message : String(failure)}`,
`${JSON.stringify(name)}: ${errorMessage(failure)}`,
)
.join("; ")}`,
remaining.length > 0 ? remaining : readableStoredColumns(),
+2 -1
View File
@@ -56,6 +56,7 @@ import {
sqliteReplyFinalizationFailure,
type SqliteWorkerLauncher,
} from "./SqliteDatabaseWorkerExecution.js";
import { errorMessage } from "../kernel/errorMessage.js";
const operation = "inspect_sqlite_database";
type SqliteOutcome = Result<AnalysisExecution, AnalysisError>;
@@ -505,7 +506,7 @@ const cleanupSqliteRoot = async (
return err(
sqliteCleanupFailure(
[root.path],
cause instanceof Error ? cause.message : String(cause),
errorMessage(cause),
result,
input,
output,
+2 -1
View File
@@ -9,6 +9,7 @@ import {
SqliteInspectionFailure,
sqlitePrimaryResultCode,
} from "./SqliteDatabaseLimits.js";
import { errorMessage } from "../kernel/errorMessage.js";
const requestSchema = z.strictObject({
snapshot_path: z.string(),
@@ -33,7 +34,7 @@ const main = async (): Promise<void> => {
};
} catch (cause: unknown) {
const code = sqlitePrimaryResultCode(cause);
const message = cause instanceof Error ? cause.message : String(cause);
const message = errorMessage(cause);
reply =
cause instanceof SqliteColumnEvaluationFailure
? {
+2 -1
View File
@@ -45,6 +45,7 @@ import {
SQLITE_INSPECTION_REASONS,
SQLITE_STRUCTURED_INSPECTION_REASONS,
} from "./SqliteDatabaseLimits.js";
import { errorMessage } from "../kernel/errorMessage.js";
const operation = "inspect_sqlite_database";
const {
@@ -304,7 +305,7 @@ const sqliteReplyReadDialect = (
unclassified: (cause, details) =>
new AnalysisOutputError(
operation,
`Owned SQLite worker reply is missing or malformed: ${cause instanceof Error ? cause.message : String(cause)}`,
`Owned SQLite worker reply is missing or malformed: ${errorMessage(cause)}`,
{ ...details, cause, capturedOutput },
),
});