Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

extensions/ultra/dynamic-contract.ts

Raw
export const VALIDATOR_WARNING_TARGET_MS = 5_000;
export const VALIDATOR_WATCHDOG_MS = 15_000;

export const BUILTIN_TOOL_NAMES: ReadonlySet<string> = new Set([
	"bash",
	"edit",
	"find",
	"grep",
	"ls",
	"powershell",
	"read",
	"write",
]);

export const ULTRA_RESERVED_TOOL_NAMES: ReadonlySet<string> = new Set([
	"run_workflow",
	"structured_output",
	"search_dynamic_extensions",
	"create_dynamic_extension",
	"copy_dynamic_extension",
	"validate_dynamic_extension",
]);

export interface DynamicManifest {
	name: string;
	description: string;
	topic?: string;
	scope?: string;
	nonGoals?: string[];
	tags?: string[];
	capabilities?: string[];
	requiredExecutables?: string[];
	optionalExecutables?: string[];
	overrides?: string[];
	benchmarkBudgets?: Record<string, { hotPathMs: number }>;
}

export interface ValidationDiagnostic {
	gate: string;
	code: string;
	status: "error" | "warning" | "blocked";
	path?: string;
	line?: number;
	expected?: unknown;
	actual?: unknown;
	output?: string;
	limitMs?: number;
	elapsedMs?: number;
	remediation: string;
	workingCopyPath: string;
}

export interface ValidationAttestation {
	sourceHash: string;
	validatedAt: string;
	platform: NodeJS.Platform;
	testedPlatforms: NodeJS.Platform[];
	nodeVersion: string;
	warningTargetMs: number;
	gates: string[];
}

export interface WorkerValidationResult {
	ok: boolean;
	diagnostics: ValidationDiagnostic[];
	manifest?: DynamicManifest;
	hash?: string;
	attestation?: ValidationAttestation;
	durationMs: number;
}