Implement AXIS parity UI and execution baseline
This commit is contained in:
@@ -1,24 +1,38 @@
|
||||
export const HAL_CONFIGURATION_SCHEMA = "hal-configuration-preflight.v1";
|
||||
|
||||
const BUILTIN_THREADS = new Set(["servo-thread", "base-thread"]);
|
||||
export const VIRTUAL_HAL_USER_COMPONENTS = Object.freeze(["hal_manualtoolchange", "lineardelta", "rotarydelta"]);
|
||||
|
||||
function text(value) {
|
||||
return typeof value === "string" && value.length > 0 ? value : null;
|
||||
}
|
||||
|
||||
export function parseHalLine(raw, line = 0) {
|
||||
function expandHalVariables(value, variables = {}) {
|
||||
return value.replace(/\[([^\]]+)\]([A-Za-z_][A-Za-z0-9_.-]*)/g, (match, section, key) => {
|
||||
const sectionValues = variables[section] ?? variables[section.toUpperCase()] ?? {};
|
||||
return Object.prototype.hasOwnProperty.call(sectionValues, key) ? String(sectionValues[key]) : match;
|
||||
});
|
||||
}
|
||||
|
||||
export function parseHalLine(raw, line = 0, variables = {}) {
|
||||
if (typeof raw !== "string") return { status: "blocked", code: "hal_line_invalid", line };
|
||||
const clean = raw.split("#", 1)[0].trim();
|
||||
const clean = expandHalVariables(raw.split("#", 1)[0].trim(), variables);
|
||||
if (!clean) return null;
|
||||
const tokens = clean.split(/\s+/);
|
||||
const command = tokens[0];
|
||||
if (!["loadrt", "loadusr", "addf", "net", "setp", "source", "newsig", "linksp", "linkps", "linkpp"].includes(command)) return null;
|
||||
if (!["loadrt", "loadusr", "addf", "net", "setp", "source", "newsig", "linksp", "linkps", "linkpp", "show", "delsig", "sets", "unlinkp"].includes(command)) {
|
||||
return { schema: HAL_CONFIGURATION_SCHEMA, line, command, status: "blocked", code: "hal_command_unsupported" };
|
||||
}
|
||||
if (command === "loadrt") {
|
||||
const module = tokens[1] ?? "";
|
||||
const namesToken = tokens.find((token) => token.startsWith("names="));
|
||||
return { schema: HAL_CONFIGURATION_SCHEMA, line, command, module, instances: namesToken ? namesToken.slice(6).split(",") : [], status: module.startsWith("[") ? "blocked" : "declared", code: module.startsWith("[") ? "hal_component_variable" : null };
|
||||
}
|
||||
if (command === "loadusr") return { schema: HAL_CONFIGURATION_SCHEMA, line, command, status: "blocked", code: "hal_host_dynamic_loader", program: tokens[1] ?? "" };
|
||||
if (command === "loadusr") {
|
||||
const program = tokens.find((token, index) => index > 0 && !token.startsWith("-")) ?? "";
|
||||
const virtual = VIRTUAL_HAL_USER_COMPONENTS.includes(program);
|
||||
return { schema: HAL_CONFIGURATION_SCHEMA, line, command, status: virtual ? "checked" : "blocked", code: virtual ? null : "hal_host_dynamic_loader", program, ...(virtual ? { capability: "SIM-ADAPTER" } : {}) };
|
||||
}
|
||||
if (command === "addf") {
|
||||
const thread = tokens[2] ?? "";
|
||||
return { schema: HAL_CONFIGURATION_SCHEMA, line, command, function: tokens[1] ?? null, thread, status: text(thread) && BUILTIN_THREADS.has(thread) ? "checked" : "blocked", code: text(thread) && BUILTIN_THREADS.has(thread) ? null : "hal_thread_undeclared" };
|
||||
@@ -26,11 +40,11 @@ export function parseHalLine(raw, line = 0) {
|
||||
return { schema: HAL_CONFIGURATION_SCHEMA, line, command, tokens: tokens.slice(1), status: "checked", code: null };
|
||||
}
|
||||
|
||||
export function preflightHalConfiguration({ lines = [], manifest = [] } = {}) {
|
||||
export function preflightHalConfiguration({ lines = [], manifest = [], variables = {} } = {}) {
|
||||
const declared = new Set((Array.isArray(manifest) ? manifest : []).map((row) => row?.component).filter(Boolean));
|
||||
const records = [];
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
const parsed = parseHalLine(lines[index], index + 1);
|
||||
const parsed = parseHalLine(lines[index], index + 1, variables);
|
||||
if (!parsed) continue;
|
||||
if (parsed.command === "loadrt" && parsed.status === "declared" && !declared.has(parsed.module)) {
|
||||
parsed.status = "blocked";
|
||||
|
||||
Reference in New Issue
Block a user