Add offline SQLite database/WAL inspection through the shared CLI/MCP. Use compact inventory, selected-table schema, exact ordered columns and bounded row samples while preserving source identity and lossless values. Retain completed Evidence through late cancellation and private-root cleanup failures, bound concurrent inspections, and recheck journal validity after acquisition. Reuse prepared CI runtime artifacts across supported Node lines. Co-authored-by: Y0UW1SH <29498139+Y0UW1SH@users.noreply.github.com> Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
79 lines
2.7 KiB
TypeScript
79 lines
2.7 KiB
TypeScript
import { z } from "zod";
|
|
import { ANALYSIS_RESOURCE_KINDS } from "../../domain/analysisErrorCore.js";
|
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
import { digestSchema } from "../../domain/digests.js";
|
|
import {
|
|
JAVASCRIPT_ANALYSIS_RESOURCE_DEFAULTS,
|
|
JAVASCRIPT_SEMANTIC_NODE_MAXIMUM,
|
|
} from "../../domain/javascript/javascriptAnalysisResourceControls.js";
|
|
import { javaScriptAnalysisTransferDescriptorSchema } from "./JavaScriptAnalysisTransfer.js";
|
|
|
|
/** Independent worker execution budget; source length is not an admission rule. */
|
|
export const JAVASCRIPT_ANALYSIS_WORKER_DEFAULTS = {
|
|
...JAVASCRIPT_ANALYSIS_RESOURCE_DEFAULTS,
|
|
checkpointBytes: 8 * 1024 * 1024,
|
|
protocolBytes: 64 * 1024,
|
|
} as const;
|
|
|
|
/** Caller-selected artifact identity, separate from the decoded source-text digest. */
|
|
export const javaScriptWorkerRequestSchema = z.strictObject({
|
|
id: z.uuid(),
|
|
node_budget: z.number().int().min(0).max(JAVASCRIPT_SEMANTIC_NODE_MAXIMUM),
|
|
text_sha256: digestSchema,
|
|
file: z.strictObject({
|
|
path: z.string(),
|
|
sha256: digestSchema,
|
|
container_sha256: digestSchema,
|
|
bytes: z.number().int().nonnegative(),
|
|
inventory_artifact_id: z.string(),
|
|
kind: z.literal("javascript"),
|
|
unpacked: z.boolean(),
|
|
}),
|
|
});
|
|
|
|
/** Parent admission after validated static observations have been retained. */
|
|
export const javaScriptWorkerAdmissionSchema = z.strictObject({
|
|
id: z.uuid(),
|
|
semantic_result_budget_bytes: z.number().int().nonnegative(),
|
|
});
|
|
|
|
const identity = { id: z.uuid() };
|
|
|
|
/** Control frames never contain AST, full IR, graph rows or source text. */
|
|
export const javaScriptWorkerMessageSchema = z.discriminatedUnion("kind", [
|
|
z.strictObject({
|
|
kind: z.literal("ready"),
|
|
// Null when the worker runtime (Bun) does not enforce V8 heap flags.
|
|
heap_limit_bytes: z.number().int().positive().nullable(),
|
|
}),
|
|
z.strictObject({
|
|
kind: z.literal("phase"),
|
|
...identity,
|
|
phase: z.enum(["parse", "static", "semantic", "projection", "transfer"]),
|
|
}),
|
|
z.strictObject({
|
|
kind: z.literal("static"),
|
|
...identity,
|
|
bytes: z.number().int().nonnegative(),
|
|
sha256: digestSchema,
|
|
}),
|
|
z.strictObject({
|
|
kind: z.literal("complete"),
|
|
...identity,
|
|
descriptor: javaScriptAnalysisTransferDescriptorSchema.nullable(),
|
|
}),
|
|
z.strictObject({
|
|
kind: z.literal("failure"),
|
|
...identity,
|
|
reason: z.enum(["resource", "output", "io"]),
|
|
resource: z.enum(ANALYSIS_RESOURCE_KINDS).nullable(),
|
|
limits: z.record(z.string(), jsonValueSchema).nullable(),
|
|
message: z.string(),
|
|
}),
|
|
]);
|
|
|
|
/** One decoded control frame from the independently owned worker. */
|
|
export type JavaScriptWorkerMessage = z.output<
|
|
typeof javaScriptWorkerMessageSchema
|
|
>;
|