repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

extensions/ultra/dynamic-contract.ts

Raw
File outline
export const VALIDATOR_CONTRACT_VERSION = 2;
export const VALIDATOR_WARNING_TARGET_MS = 5_000;
export const VALIDATOR_WATCHDOG_MS = 15_000;
export const MARGINAL_LOAD_BUDGET_MS = 50;

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",
	"checkout_dynamic_extension",
	"validate_dynamic_extension",
]);

export interface DynamicManifest {
	schemaVersion: 1;
	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;
	draftPath: string;
}

export interface ValidationAttestation {
	schemaVersion: 1;
	validatorContractVersion: number;
	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;
}