@parcha/agentrun-dsl 0.1.0-beta.203 → 0.1.0-beta.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/workflow.d.ts +3 -0
- package/dist/workflow.js +27 -14
- package/package.json +1 -1
package/dist/workflow.d.ts
CHANGED
|
@@ -710,6 +710,9 @@ export type ValidationIssue = {
|
|
|
710
710
|
* output checks remain authoritative. */
|
|
711
711
|
export type ValidateWorkflowOptions = {
|
|
712
712
|
executeCode?: boolean;
|
|
713
|
+
/** The run's input, or only its keys: what the reachability checks (STATE_PATH_UNPRODUCED, STATE_PATH_EXCLUDED) start
|
|
714
|
+
* from, and what they find is an error. Neither given, the input schema's `properties` stand in, and what they find is
|
|
715
|
+
* a warning. */
|
|
713
716
|
input?: Record<string, unknown>;
|
|
714
717
|
inputKeys?: string[];
|
|
715
718
|
probeContext?: {
|
package/dist/workflow.js
CHANGED
|
@@ -465,8 +465,21 @@ export function validateWorkflow(workflow, opts) {
|
|
|
465
465
|
const ptrOf = (path) => pointers.get(path) ?? "";
|
|
466
466
|
const declaredInput = workflow.input && Object.hasOwn(workflow.schemas, workflow.input.schemaId)
|
|
467
467
|
? resolveSchemaForWorkflow(workflow, workflow.schemas[workflow.input.schemaId]) : undefined;
|
|
468
|
-
|
|
468
|
+
// With no input and no inputKeys, an input schema with properties names the keys a run starts with: they are "derived",
|
|
469
|
+
// and what the reachability checks find from them is a warning (`CODE at <pointer>: <message>`), never an error. An
|
|
470
|
+
// input schema that takes extra properties lets a real input carry a key it does not declare; a run's start checks its
|
|
471
|
+
// real input. Derived keys run no authored code: a code node is not probed, as without keys.
|
|
472
|
+
const derived = opts?.input === undefined && opts?.inputKeys === undefined && isRecord(declaredInput) && isRecord(declaredInput.properties);
|
|
473
|
+
const inputKeys = opts?.input !== undefined ? Object.keys(opts.input ?? {}) : opts?.inputKeys ?? (derived ? Object.keys(declaredInput.properties) : undefined);
|
|
469
474
|
const reachability = inputKeys ? { available: new Set(inputKeys), unknowable: false } : null;
|
|
475
|
+
const derivedWarnings = [];
|
|
476
|
+
/** A finding of the reachability checks: an error with the input keys given, a warning with derived ones. */
|
|
477
|
+
const unreached = (code, path, message) => {
|
|
478
|
+
if (derived)
|
|
479
|
+
derivedWarnings.push(`${code}${path ? ` at ${path}` : ""}: ${message}`);
|
|
480
|
+
else
|
|
481
|
+
fail(code, path, message);
|
|
482
|
+
};
|
|
470
483
|
// Closed, typed producers let us reject impossible nested paths without running
|
|
471
484
|
// authored code. Open schemas, unions, references and dynamic control flow stand
|
|
472
485
|
// down; this is a conservative edge check, not a second schema validator.
|
|
@@ -497,7 +510,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
497
510
|
schema = schema.properties[segment];
|
|
498
511
|
else {
|
|
499
512
|
if (schema.additionalProperties === false && !schema.patternProperties)
|
|
500
|
-
|
|
513
|
+
unreached("STATE_PATH_EXCLUDED", node, `${at}: state path "${dotted}" is excluded by the upstream schema at "${head}"; check the producer's as key and declared properties`);
|
|
501
514
|
return;
|
|
502
515
|
}
|
|
503
516
|
}
|
|
@@ -567,7 +580,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
567
580
|
});
|
|
568
581
|
})() : null;
|
|
569
582
|
const probeCodePatches = (code, at) => {
|
|
570
|
-
if (opts?.executeCode === false)
|
|
583
|
+
if (opts?.executeCode === false || derived)
|
|
571
584
|
return [];
|
|
572
585
|
let compiled;
|
|
573
586
|
try {
|
|
@@ -713,7 +726,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
713
726
|
if (!missing)
|
|
714
727
|
return;
|
|
715
728
|
}
|
|
716
|
-
|
|
729
|
+
unreached("STATE_PATH_EXCLUDED", ptrOf(path), `${path} (${label}): predicate path "${when.path}" is not produced by the code node that writes "${head}" (its shape has: ${missingAt && typeof missingAt === "object" ? Object.keys(missingAt).join(", ") : typeof missingAt}); the guard can never fire`);
|
|
717
730
|
};
|
|
718
731
|
// A mechanical predicate reads one state key; when no input key or earlier node writes it, the guard can never fire.
|
|
719
732
|
const checkPredicateHead = (pred, label, path, field, produced) => {
|
|
@@ -729,14 +742,14 @@ export function validateWorkflow(workflow, opts) {
|
|
|
729
742
|
continue;
|
|
730
743
|
const head = page.split(".")[0];
|
|
731
744
|
if (!available.has(head))
|
|
732
|
-
|
|
745
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${label}): ${field}.pages reads "${page}" but no input key or earlier node produces "${head}"; every quote would miss`);
|
|
733
746
|
}
|
|
734
747
|
const read = predicate === "no_new_items" ? key : predicate === "ask" ? undefined : at;
|
|
735
748
|
if (typeof read !== "string" || !read.trim())
|
|
736
749
|
return;
|
|
737
750
|
const head = read.split(".")[0];
|
|
738
751
|
if (!available.has(head))
|
|
739
|
-
|
|
752
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${label}): ${field} reads "${read}" but no input key or earlier node produces "${head}"; the guard can never fire`);
|
|
740
753
|
else if (!produced)
|
|
741
754
|
checkTypedPath(read, `${path} (${label}) ${field}`, ptrOf(path));
|
|
742
755
|
};
|
|
@@ -750,7 +763,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
750
763
|
continue;
|
|
751
764
|
const head = (m[1].startsWith("state.") ? m[1].slice(6) : m[1]).split(".")[0];
|
|
752
765
|
if (!reachability.available.has(head))
|
|
753
|
-
|
|
766
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${label}): interpolates {${m[1]}} but no upstream node produces "${head}"`);
|
|
754
767
|
else
|
|
755
768
|
checkTypedPath(m[1].startsWith("state.") ? m[1].slice(6) : m[1], `${path} (${label})`, ptrOf(path));
|
|
756
769
|
}
|
|
@@ -767,7 +780,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
767
780
|
for (const required of node.requires) {
|
|
768
781
|
const head = String(required).split(".")[0];
|
|
769
782
|
if (!reachability.available.has(head)) {
|
|
770
|
-
|
|
783
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${node.label}): requires "${required}" but no upstream node produces it; state here has only: ${[...reachability.available].join(", ")}`);
|
|
771
784
|
}
|
|
772
785
|
else
|
|
773
786
|
checkTypedPath(required, `${path} (${node.label}) requires`, ptrOf(path));
|
|
@@ -778,7 +791,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
778
791
|
return;
|
|
779
792
|
const head = node.itemsPath.split(".")[0];
|
|
780
793
|
if (!reachability.available.has(head))
|
|
781
|
-
|
|
794
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${node.label}): itemsPath "${node.itemsPath}" has no upstream producer; read the value under the producing node's as key (or its label when as is omitted)`);
|
|
782
795
|
else
|
|
783
796
|
checkTypedPath(node.itemsPath, `${path} (${node.label}) itemsPath`, ptrOf(path));
|
|
784
797
|
};
|
|
@@ -1234,7 +1247,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
1234
1247
|
if (typeof valuePath === "string" && valuePath.trim() && reachability && !reachability.unknowable) {
|
|
1235
1248
|
const head = valuePath.split(".")[0];
|
|
1236
1249
|
if (!reachability.available.has(head))
|
|
1237
|
-
|
|
1250
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${label}): valuePath "${valuePath}" has no upstream producer; route by the key an earlier node writes`);
|
|
1238
1251
|
else
|
|
1239
1252
|
checkTypedPath(valuePath, `${path} (${label}) valuePath`, ptrOf(path));
|
|
1240
1253
|
}
|
|
@@ -1309,7 +1322,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
1309
1322
|
if (typeof node.path !== "string" || !node.path.trim() || node.path.startsWith("/") || node.path.split("/").includes(".."))
|
|
1310
1323
|
fail("NODE_FIELD_INVALID", ptrOf(path), `${path} (${label}): path must be a workspace-relative file`);
|
|
1311
1324
|
else if (reachability && !producedFiles.has(node.path))
|
|
1312
|
-
|
|
1325
|
+
unreached("STATE_PATH_UNPRODUCED", ptrOf(path), `${path} (${label}): path "${node.path}" is not produced by any earlier shell call (declare it in that call's produces)`);
|
|
1313
1326
|
checkRequires({ label, requires: node.requires }, path);
|
|
1314
1327
|
if (reachability) {
|
|
1315
1328
|
reachability.available.add("artifact");
|
|
@@ -1526,7 +1539,7 @@ export function validateWorkflow(workflow, opts) {
|
|
|
1526
1539
|
if (reachability && !reachability.unknowable && !mayEscalate && workflow?.output?.path) {
|
|
1527
1540
|
const head = workflow.output.path.split(".")[0];
|
|
1528
1541
|
if (!reachability.available.has(head))
|
|
1529
|
-
|
|
1542
|
+
unreached("STATE_PATH_UNPRODUCED", "", `output: path "${workflow.output.path}" has no input or upstream producer; select the final node's as key (or label when as is omitted)`);
|
|
1530
1543
|
else
|
|
1531
1544
|
checkTypedPath(workflow.output.path, "output", "");
|
|
1532
1545
|
}
|
|
@@ -1574,14 +1587,14 @@ export function validateWorkflow(workflow, opts) {
|
|
|
1574
1587
|
bestMissing = missing;
|
|
1575
1588
|
}
|
|
1576
1589
|
if (bestMissing?.length) {
|
|
1577
|
-
|
|
1590
|
+
unreached("STATE_PATH_EXCLUDED", "", `output: the code node writing "${workflow.output.path}" never emits required field(s) ${bestMissing.join(", ")} of schema "${workflow.output.schemaId}" — every run would fail output validation`);
|
|
1578
1591
|
}
|
|
1579
1592
|
}
|
|
1580
1593
|
}
|
|
1581
1594
|
if (!errors.length)
|
|
1582
1595
|
for (const issue of workflowShapeIssues(workflow, true))
|
|
1583
1596
|
fail("SHAPE_INVALID", issue.path, issue.message);
|
|
1584
|
-
const warnings = workflowWarnings(workflow);
|
|
1597
|
+
const warnings = [...workflowWarnings(workflow), ...derivedWarnings];
|
|
1585
1598
|
return errors.length ? { ok: false, errors, issues, ...(warnings.length ? { warnings } : {}) } : { ok: true, ...(warnings.length ? { warnings } : {}) };
|
|
1586
1599
|
}
|
|
1587
1600
|
/** The value a `{path}` placeholder reads from state, in interpolation's lookup order: the path as written, else, for a
|