@re-cinq/floor-studio 0.8.0 → 0.11.2
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/README.md +46 -4
- package/dist/backend/agent-run.d.ts +13 -0
- package/dist/backend/agent-run.js +32 -0
- package/dist/backend/collection-view.d.ts +2 -0
- package/dist/backend/collection-view.js +18 -8
- package/dist/backend/in-order.d.ts +1 -0
- package/dist/backend/in-order.js +10 -0
- package/dist/backend/last-tests.d.ts +10 -0
- package/dist/backend/last-tests.js +40 -0
- package/dist/backend/past-test-run-state.d.ts +2 -0
- package/dist/backend/past-test-run-state.js +19 -0
- package/dist/backend/past-test-runs.d.ts +2 -0
- package/dist/backend/past-test-runs.js +31 -0
- package/dist/backend/read-collection-view.d.ts +4 -0
- package/dist/backend/read-collection-view.js +19 -0
- package/dist/backend/read-test-line.d.ts +2 -0
- package/dist/backend/read-test-line.js +10 -0
- package/dist/backend/requests.d.ts +11 -1
- package/dist/backend/requests.js +4 -1
- package/dist/backend/run-cancel-request.d.ts +2 -1
- package/dist/backend/run-cancel-request.js +6 -3
- package/dist/backend/run-preview-request.d.ts +3 -2
- package/dist/backend/run-preview-request.js +6 -4
- package/dist/backend/run-start-request.js +2 -27
- package/dist/backend/start-studio.d.ts +4 -0
- package/dist/backend/start-studio.js +7 -13
- package/dist/backend/test-last-requests.d.ts +6 -0
- package/dist/backend/test-last-requests.js +6 -0
- package/dist/backend/test-list-requests.d.ts +9 -0
- package/dist/backend/test-list-requests.js +15 -0
- package/dist/backend/test-run-agent-visit.d.ts +13 -0
- package/dist/backend/test-run-agent-visit.js +73 -0
- package/dist/backend/test-run-folder.d.ts +5 -0
- package/dist/backend/test-run-folder.js +25 -0
- package/dist/backend/test-run-requests.d.ts +34 -0
- package/dist/backend/test-run-requests.js +112 -0
- package/dist/backend/test-run-session.d.ts +23 -0
- package/dist/backend/test-run-session.js +218 -0
- package/dist/backend/test-run-snapshot.d.ts +3 -0
- package/dist/backend/test-run-snapshot.js +25 -0
- package/dist/backend/test-run-supplied-files.d.ts +5 -0
- package/dist/backend/test-run-supplied-files.js +35 -0
- package/dist/backend/test-run-timeline.d.ts +6 -0
- package/dist/backend/test-run-timeline.js +13 -0
- package/dist/backend/test-run-visit-files.d.ts +8 -0
- package/dist/backend/test-run-visit-files.js +28 -0
- package/dist/cli.js +2 -2
- package/dist/folder-listing.d.ts +6 -0
- package/dist/folder-listing.js +2 -0
- package/dist/protocol.d.ts +179 -4
- package/dist/protocol.js +30 -4
- package/dist/run/result-line.d.ts +6 -0
- package/dist/run/result-line.js +18 -0
- package/dist/run/run-cost.d.ts +6 -0
- package/dist/run/run-cost.js +17 -0
- package/dist/run/run-outcome.d.ts +2 -0
- package/dist/run/run-outcome.js +4 -20
- package/dist/run/run-preview.d.ts +2 -0
- package/dist/run/run-preview.js +15 -6
- package/dist/run/run-process.d.ts +5 -3
- package/dist/run/run-process.js +13 -2
- package/dist/run/run-produces.d.ts +4 -0
- package/dist/run/run-produces.js +6 -1
- package/dist/run/run-records.d.ts +11 -0
- package/dist/run/run-result.js +15 -3
- package/dist/run/station-fixtures.d.ts +2 -1
- package/dist/run/station-fixtures.js +11 -0
- package/dist/shell/open-browser.d.ts +3 -3
- package/dist/shell/open-browser.js +7 -7
- package/dist/test-run/agent-report.d.ts +3 -0
- package/dist/test-run/agent-report.js +21 -0
- package/dist/test-run/brief.d.ts +6 -0
- package/dist/test-run/brief.js +25 -0
- package/dist/test-run/entered-value.d.ts +1 -0
- package/dist/test-run/entered-value.js +6 -0
- package/dist/test-run/event-answer.d.ts +13 -0
- package/dist/test-run/event-answer.js +13 -0
- package/dist/test-run/folder-names.d.ts +2 -0
- package/dist/test-run/folder-names.js +18 -0
- package/dist/test-run/next-transition.d.ts +3 -0
- package/dist/test-run/next-transition.js +10 -0
- package/dist/test-run/outcome-fields.d.ts +10 -0
- package/dist/test-run/outcome-fields.js +40 -0
- package/dist/test-run/past-listing.d.ts +3 -0
- package/dist/test-run/past-listing.js +5 -0
- package/dist/test-run/past-state.d.ts +5 -0
- package/dist/test-run/past-state.js +26 -0
- package/dist/test-run/run-bag.d.ts +5 -0
- package/dist/test-run/run-bag.js +12 -0
- package/dist/test-run/run-summary.d.ts +13 -0
- package/dist/test-run/run-summary.js +23 -0
- package/dist/test-run/stand-in-actions.d.ts +17 -0
- package/dist/test-run/stand-in-actions.js +26 -0
- package/dist/test-run/stand-in-report.d.ts +13 -0
- package/dist/test-run/stand-in-report.js +34 -0
- package/dist/test-run/start-blockers.d.ts +3 -0
- package/dist/test-run/start-blockers.js +21 -0
- package/dist/test-run/start-items.d.ts +12 -0
- package/dist/test-run/start-items.js +18 -0
- package/dist/test-run/test-line.d.ts +16 -0
- package/dist/test-run/test-line.js +24 -0
- package/dist/test-run/test-preview.d.ts +11 -0
- package/dist/test-run/test-preview.js +7 -0
- package/dist/test-run/test-run-state.d.ts +30 -0
- package/dist/test-run/test-run-state.js +2 -0
- package/dist/test-run/test-visit.d.ts +24 -0
- package/dist/test-run/test-visit.js +2 -0
- package/dist/test-run/timeline.d.ts +32 -0
- package/dist/test-run/timeline.js +4 -0
- package/dist/test-run/totals.d.ts +20 -0
- package/dist/test-run/totals.js +26 -0
- package/dist/test-run/visit-kind.d.ts +3 -0
- package/dist/test-run/visit-kind.js +10 -0
- package/dist/test-run/visit-record.d.ts +22 -0
- package/dist/test-run/visit-record.js +27 -0
- package/dist/view.d.ts +2 -0
- package/dist/web/assets/index-C5eUTmhR.css +1 -0
- package/dist/web/assets/index-mRcd501r.js +195 -0
- package/dist/web/index.html +2 -2
- package/package.json +5 -5
- package/dist/web/assets/index-ChyDvQtL.css +0 -1
- package/dist/web/assets/index-In7XfxsK.js +0 -195
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
export const agentStation = { kind: "agent", outcomes: [], needs: [], produces: [] };
|
|
2
2
|
export const stationNeeding = (needs) => ({ ...agentStation, needs });
|
|
3
|
+
export const workLine = {
|
|
4
|
+
entry: "work",
|
|
5
|
+
exit: "done",
|
|
6
|
+
fail: "fail",
|
|
7
|
+
args: {},
|
|
8
|
+
nodes: [{ id: "work", station: "worker" }, { id: "done" }, { id: "fail" }],
|
|
9
|
+
edges: [
|
|
10
|
+
{ from: "work", to: "done", on: "success" },
|
|
11
|
+
{ from: "work", to: "fail", on: "failed" },
|
|
12
|
+
],
|
|
13
|
+
};
|
|
3
14
|
//# sourceMappingURL=station-fixtures.js.map
|
|
@@ -2,6 +2,6 @@ export interface Opener {
|
|
|
2
2
|
command: string;
|
|
3
3
|
args: string[];
|
|
4
4
|
}
|
|
5
|
-
export declare function openerOf(platform: NodeJS.Platform,
|
|
6
|
-
/** Failing to open
|
|
7
|
-
export declare function
|
|
5
|
+
export declare function openerOf(platform: NodeJS.Platform, target: string): Opener;
|
|
6
|
+
/** Opens a url in the browser or a path in the file manager. Failing to open is not an error: the url is printed, and the person can open it. */
|
|
7
|
+
export declare function openOnDesktop(target: string): void;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
export function openerOf(platform,
|
|
2
|
+
export function openerOf(platform, target) {
|
|
3
3
|
if (platform === "darwin")
|
|
4
|
-
return { command: "open", args: [
|
|
4
|
+
return { command: "open", args: [target] };
|
|
5
5
|
// cmd reads & as the end of a command, and the url's fragment holds one.
|
|
6
6
|
if (platform === "win32")
|
|
7
|
-
return { command: "cmd", args: ["/c", "start", "",
|
|
8
|
-
return { command: "xdg-open", args: [
|
|
7
|
+
return { command: "cmd", args: ["/c", "start", "", target.replaceAll("&", "^&")] };
|
|
8
|
+
return { command: "xdg-open", args: [target] };
|
|
9
9
|
}
|
|
10
|
-
/** Failing to open
|
|
11
|
-
export function
|
|
12
|
-
const { command, args } = openerOf(process.platform,
|
|
10
|
+
/** Opens a url in the browser or a path in the file manager. Failing to open is not an error: the url is printed, and the person can open it. */
|
|
11
|
+
export function openOnDesktop(target) {
|
|
12
|
+
const { command, args } = openerOf(process.platform, target);
|
|
13
13
|
const opener = spawn(command, args, { stdio: "ignore", detached: true });
|
|
14
14
|
opener.on("error", () => undefined);
|
|
15
15
|
opener.unref();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const cleanExitCode = 0;
|
|
2
|
+
const cancelledError = "the agent run was cancelled";
|
|
3
|
+
const noOutcomeError = "the agent run gave no outcome";
|
|
4
|
+
export function agentReportOf(ending, savedOutputs) {
|
|
5
|
+
const unfinished = whyUnfinished(ending);
|
|
6
|
+
if (unfinished !== undefined)
|
|
7
|
+
return { outcome: "failed", error: unfinished };
|
|
8
|
+
const { outcome, error } = ending;
|
|
9
|
+
if (outcome === "failed")
|
|
10
|
+
return { outcome, ...(error !== undefined && { error }) };
|
|
11
|
+
if (outcome === undefined)
|
|
12
|
+
return { outcome: "failed", error: noOutcomeError };
|
|
13
|
+
const produced = { ...ending.producedValues, ...savedOutputs };
|
|
14
|
+
return Object.keys(produced).length === 0 ? { outcome } : { outcome, produced };
|
|
15
|
+
}
|
|
16
|
+
function whyUnfinished({ exitCode, error }) {
|
|
17
|
+
if (exitCode === null)
|
|
18
|
+
return error ?? cancelledError;
|
|
19
|
+
return exitCode === cleanExitCode ? undefined : `the agent exited with code ${exitCode}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=agent-report.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The brief of a visit: what a station receives when a node of a line is opened in a local test run.
|
|
2
|
+
import { needItemsOf, previousErrorNeed, previousFailuresNeed, visitIdsSincePersonActed } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
import { bagOfRun } from "./run-bag.js";
|
|
4
|
+
import { stationAt, walkGraphOfLine } from "./test-line.js";
|
|
5
|
+
import { visitKindOf } from "./visit-kind.js";
|
|
6
|
+
export function briefOf(run, nodeId) {
|
|
7
|
+
const { node, station } = stationAt(run.line, nodeId);
|
|
8
|
+
const bag = bagOfRun(run);
|
|
9
|
+
const fresh = visitIdsSincePersonActed(walkGraphOfLine(run.line), run.visits);
|
|
10
|
+
const { items: supplied, missing } = needItemsOf(station.needs, node.bind, bag, fresh);
|
|
11
|
+
const declared = Object.fromEntries(Object.entries(supplied).map(([name, found]) => [name, found.ref]));
|
|
12
|
+
const failureContext = visitKindOf(run.line, nodeId) === "agent" ? failureContextOf(run, nodeId) : {};
|
|
13
|
+
return { needs: { ...declared, ...failureContext }, missing };
|
|
14
|
+
}
|
|
15
|
+
function failureContextOf(run, nodeId) {
|
|
16
|
+
const failedVisits = run.visits.filter((visit) => visit.nodeId === nodeId && visit.report?.outcome === "failed");
|
|
17
|
+
const priorErrors = failedVisits.map((visit) => visit.report?.error).reverse();
|
|
18
|
+
const previousError = previousErrorNeed(priorErrors[0]);
|
|
19
|
+
const previousFailures = previousFailuresNeed(priorErrors);
|
|
20
|
+
return {
|
|
21
|
+
...(previousError === undefined ? {} : { previous_error: previousError }),
|
|
22
|
+
...(previousFailures === undefined ? {} : { previous_failures: previousFailures }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=brief.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function enteredValue(entered: Readonly<Record<string, string>>, name: string): string | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The value a person typed for a name, or undefined when it is absent or blank.
|
|
2
|
+
export function enteredValue(entered, name) {
|
|
3
|
+
const value = Object.hasOwn(entered, name) ? entered[name] : undefined;
|
|
4
|
+
return value?.trim() ? value : undefined;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=entered-value.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Payload } from "@re-cinq/floor-assembly-lines";
|
|
2
|
+
import type { TestLine } from "./test-line.js";
|
|
3
|
+
import type { VisitState } from "./test-visit.js";
|
|
4
|
+
export interface SentEvent {
|
|
5
|
+
name: string;
|
|
6
|
+
payload: Payload;
|
|
7
|
+
}
|
|
8
|
+
export declare function eventOutcomeOf(line: TestLine, nodeId: string, sent: SentEvent): string | undefined;
|
|
9
|
+
export interface AnsweredVisit {
|
|
10
|
+
visit: VisitState;
|
|
11
|
+
outcome: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function answeredVisitsOf(line: TestLine, visits: readonly VisitState[], sent: SentEvent): AnsweredVisit[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The outcome an event a person sends gives a waiting node: the floor's kernel decides, never Studio.
|
|
2
|
+
import { answersOf } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
export function eventOutcomeOf(line, nodeId, sent) {
|
|
4
|
+
return answersOf(line.body, sent.name, sent.payload).find((answer) => answer.nodeId === nodeId)?.outcome;
|
|
5
|
+
}
|
|
6
|
+
export function answeredVisitsOf(line, visits, sent) {
|
|
7
|
+
const waiting = visits.filter(({ report, kind }) => report === null && kind === "stand-in");
|
|
8
|
+
return waiting.flatMap((visit) => {
|
|
9
|
+
const outcome = eventOutcomeOf(line, visit.nodeId, sent);
|
|
10
|
+
return outcome === undefined ? [] : [{ visit, outcome }];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=event-answer.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The folders of a test run and of its station visits, named so no line id or node id can leave them.
|
|
2
|
+
import { enforce } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
const SEQUENCE_WIDTH = 3;
|
|
4
|
+
const SAFE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
5
|
+
const UTC_STAMP_PARTS = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d).*$/;
|
|
6
|
+
const COMPACT_UTC_STAMP = "$1$2$3-$4$5$6";
|
|
7
|
+
export function visitFolderName(sequence, nodeId, iteration) {
|
|
8
|
+
enforceSafeName("node", nodeId, "visit folder");
|
|
9
|
+
return `${String(sequence).padStart(SEQUENCE_WIDTH, "0")}-${nodeId}-${iteration}`;
|
|
10
|
+
}
|
|
11
|
+
export function runFolderName(lineId, startedAt) {
|
|
12
|
+
enforceSafeName("line", lineId, "run folder");
|
|
13
|
+
return `${lineId}-${startedAt.toISOString().replace(UTC_STAMP_PARTS, COMPACT_UTC_STAMP)}`;
|
|
14
|
+
}
|
|
15
|
+
function enforceSafeName(subject, name, purpose) {
|
|
16
|
+
enforce(SAFE_NAME.test(name), `${subject} ${JSON.stringify(name)} cannot name a ${purpose}: a name may hold letters, digits, ".", "_" and "-", and starts with a letter or digit`);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=folder-names.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// What happens next in a local test run: the floor's routing kernel decides, never Studio.
|
|
2
|
+
import { getNextTransition } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
import { walkGraphOfLine } from "./test-line.js";
|
|
4
|
+
export function nextTransitionOf(run) {
|
|
5
|
+
return getNextTransition(walkGraphOfLine(run.line), run.visits.map(nodeVisitOf));
|
|
6
|
+
}
|
|
7
|
+
function nodeVisitOf(visit) {
|
|
8
|
+
return { nodeId: visit.nodeId, iteration: visit.iteration, outcome: visit.report?.outcome ?? null };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=next-transition.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProduceSpec } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type TestLine } from "./test-line.js";
|
|
3
|
+
export interface OutcomeField {
|
|
4
|
+
name: string;
|
|
5
|
+
kind: "value" | "file";
|
|
6
|
+
required: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function outcomeFieldsOf(line: TestLine, nodeId: string, outcome: string): OutcomeField[];
|
|
10
|
+
export declare function otherOutputsOf(produces: ProduceSpec[], fields: OutcomeField[]): OutcomeField[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { selectEdge } from "@re-cinq/floor-assembly-lines";
|
|
2
|
+
import { nodeAt, stationAt, stationBodyOf, walkGraphOfLine } from "./test-line.js";
|
|
3
|
+
export function outcomeFieldsOf(line, nodeId, outcome) {
|
|
4
|
+
const edge = selectEdge(walkGraphOfLine(line), nodeId, outcome);
|
|
5
|
+
if (!edge) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const reads = needsReadBy(line, edge.to);
|
|
9
|
+
const { produces } = stationAt(line, nodeId).station;
|
|
10
|
+
return produces
|
|
11
|
+
.filter((produce) => reads.has(produce.name))
|
|
12
|
+
.map(({ name, kind, path }) => ({
|
|
13
|
+
name,
|
|
14
|
+
kind,
|
|
15
|
+
required: isRequired(reads.get(name)),
|
|
16
|
+
...(path === undefined ? {} : { path }),
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
export function otherOutputsOf(produces, fields) {
|
|
20
|
+
const named = new Set(fields.map((field) => field.name));
|
|
21
|
+
return produces
|
|
22
|
+
.filter((produce) => !named.has(produce.name))
|
|
23
|
+
.map(({ name, kind }) => ({ name, kind, required: false }));
|
|
24
|
+
}
|
|
25
|
+
function needsReadBy(line, targetId) {
|
|
26
|
+
const target = nodeAt(line, targetId);
|
|
27
|
+
const reads = new Map();
|
|
28
|
+
for (const need of stationBodyOf(line, target)?.needs ?? []) {
|
|
29
|
+
reads.set(bagNameOf(target, need), need);
|
|
30
|
+
}
|
|
31
|
+
return reads;
|
|
32
|
+
}
|
|
33
|
+
function bagNameOf(node, need) {
|
|
34
|
+
const { bind } = node;
|
|
35
|
+
return bind && Object.hasOwn(bind, need.name) ? bind[need.name] : need.name;
|
|
36
|
+
}
|
|
37
|
+
function isRequired(need) {
|
|
38
|
+
return !need.optional || need.fresh === true;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=outcome-fields.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function pastListingOf(folder, { line, startedAt, status, ending }) {
|
|
2
|
+
const settled = status === "settled";
|
|
3
|
+
return { run: folder, line, folder, status: settled ? status : "stopped", startedAt, ...(settled && ending && { ending }) };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=past-listing.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RunSummary } from "./run-summary.js";
|
|
2
|
+
import type { TimelineEntry } from "./timeline.js";
|
|
3
|
+
import type { TestRunState } from "./test-run-state.js";
|
|
4
|
+
import type { VisitRecord } from "./visit-record.js";
|
|
5
|
+
export declare function pastStateOf(folder: string, summary: RunSummary, timeline: TimelineEntry[], records: Record<string, VisitRecord>): TestRunState;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function pastStateOf(folder, summary, timeline, records) {
|
|
2
|
+
const settled = summary.status === "settled";
|
|
3
|
+
const opened = timeline.filter((entry) => entry.type === "visit_opened");
|
|
4
|
+
return {
|
|
5
|
+
folder,
|
|
6
|
+
lineId: summary.line,
|
|
7
|
+
status: settled ? summary.status : "stopped",
|
|
8
|
+
...(settled && summary.ending && { ending: summary.ending }),
|
|
9
|
+
visits: opened.map((entry) => visitOf(entry, records[entry.visit])),
|
|
10
|
+
actions: {},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function visitOf({ visit, node, iteration, at: openedAt, mode }, record) {
|
|
14
|
+
return {
|
|
15
|
+
id: visit,
|
|
16
|
+
nodeId: node,
|
|
17
|
+
iteration,
|
|
18
|
+
station: record?.station ?? null,
|
|
19
|
+
kind: mode === "local" ? "agent" : "stand-in",
|
|
20
|
+
needs: {},
|
|
21
|
+
openedAt,
|
|
22
|
+
report: record ? { outcome: record.outcome, produced: record.produced, error: record.error } : null,
|
|
23
|
+
...(record && { reportedAt: record.reportedAt, agentDurationMs: record.agentDurationMs, costUsd: record.costUsd }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=past-state.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Item } from "@re-cinq/floor-contracts";
|
|
2
|
+
import type { BagEntry } from "./test-run-state.js";
|
|
3
|
+
import type { TestRun } from "./test-visit.js";
|
|
4
|
+
export declare function bagOfRun(run: TestRun): Record<string, Item>;
|
|
5
|
+
export declare function bagEntriesOf(run: TestRun): BagEntry[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The bag of a local test run: start items folded with each visit's produced items, a station name standing in for its hash.
|
|
2
|
+
import { bagOf } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
export function bagOfRun(run) {
|
|
4
|
+
const { startItems, visits } = run;
|
|
5
|
+
const { stations } = run.line;
|
|
6
|
+
const producing = visits.map(({ id, station, report }) => ({ id, stationHash: station, report }));
|
|
7
|
+
return bagOf(startItems, producing, (name) => stations.get(name)?.produces);
|
|
8
|
+
}
|
|
9
|
+
export function bagEntriesOf(run) {
|
|
10
|
+
return Object.entries(bagOfRun(run)).map(([name, { kind, ref, by }]) => ({ name, kind, ref, by }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=run-bag.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Item } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type RunTotals } from "./totals.js";
|
|
3
|
+
import type { TestRunState } from "./test-run-state.js";
|
|
4
|
+
export interface RunSummary {
|
|
5
|
+
line: string;
|
|
6
|
+
startedAt: string;
|
|
7
|
+
startItems: Record<string, Item>;
|
|
8
|
+
status: TestRunState["status"];
|
|
9
|
+
ending?: TestRunState["ending"];
|
|
10
|
+
totals: RunTotals;
|
|
11
|
+
}
|
|
12
|
+
export type RunProgress = Pick<TestRunState, "lineId" | "status" | "ending" | "visits">;
|
|
13
|
+
export declare function runSummaryOf(startedAt: string, startItems: Record<string, Item>, progress: RunProgress): RunSummary;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { modeOf } from "./timeline.js";
|
|
2
|
+
import { totalsOf } from "./totals.js";
|
|
3
|
+
import { wallTimeOf } from "./visit-record.js";
|
|
4
|
+
export function runSummaryOf(startedAt, startItems, progress) {
|
|
5
|
+
const { lineId, status, ending, visits } = progress;
|
|
6
|
+
return {
|
|
7
|
+
line: lineId,
|
|
8
|
+
startedAt,
|
|
9
|
+
startItems,
|
|
10
|
+
status,
|
|
11
|
+
...(ending ? { ending } : {}),
|
|
12
|
+
totals: totalsOf(visits.map(measureOf)),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function measureOf({ nodeId, kind, openedAt, reportedAt, costUsd }) {
|
|
16
|
+
return {
|
|
17
|
+
nodeId,
|
|
18
|
+
mode: modeOf(kind),
|
|
19
|
+
durationMs: reportedAt === undefined ? undefined : wallTimeOf(openedAt, reportedAt),
|
|
20
|
+
costUsd,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=run-summary.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WhenValue } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type OutcomeField } from "./outcome-fields.js";
|
|
3
|
+
import { type TestLine } from "./test-line.js";
|
|
4
|
+
import type { VisitState } from "./test-visit.js";
|
|
5
|
+
export type StandInAction = {
|
|
6
|
+
kind: "report";
|
|
7
|
+
outcome: string;
|
|
8
|
+
fields: OutcomeField[];
|
|
9
|
+
others: OutcomeField[];
|
|
10
|
+
} | {
|
|
11
|
+
kind: "event";
|
|
12
|
+
outcome: string;
|
|
13
|
+
event: string;
|
|
14
|
+
payload: Record<string, WhenValue>;
|
|
15
|
+
};
|
|
16
|
+
export declare function standInActionsOf(line: TestLine, nodeId: string): StandInAction[];
|
|
17
|
+
export declare function waitingActionsOf(line: TestLine, visits: VisitState[]): Record<string, StandInAction[]>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { otherOutputsOf, outcomeFieldsOf } from "./outcome-fields.js";
|
|
2
|
+
import { stationAt } from "./test-line.js";
|
|
3
|
+
export function standInActionsOf(line, nodeId) {
|
|
4
|
+
const { node, station } = stationAt(line, nodeId);
|
|
5
|
+
const reports = node.reports ?? [];
|
|
6
|
+
return [...eventActionsOf(reports), ...reportActionsOf(line, nodeId, station.outcomes, reports)];
|
|
7
|
+
}
|
|
8
|
+
export function waitingActionsOf(line, visits) {
|
|
9
|
+
const waiting = visits.filter(({ kind, report }) => kind === "stand-in" && report === null);
|
|
10
|
+
return Object.fromEntries(waiting.map(({ id, nodeId }) => [id, standInActionsOf(line, nodeId)]));
|
|
11
|
+
}
|
|
12
|
+
function eventActionsOf(reports) {
|
|
13
|
+
return reports.map((entry) => ({ kind: "event", outcome: entry.outcome, event: entry.on, payload: entry.when ?? {} }));
|
|
14
|
+
}
|
|
15
|
+
function reportActionsOf(line, nodeId, outcomes, reports) {
|
|
16
|
+
const answered = reports.map((entry) => entry.outcome);
|
|
17
|
+
return outcomes
|
|
18
|
+
.filter((outcome) => !answered.includes(outcome))
|
|
19
|
+
.map((outcome) => reportActionOf(line, nodeId, outcome));
|
|
20
|
+
}
|
|
21
|
+
function reportActionOf(line, nodeId, outcome) {
|
|
22
|
+
const fields = outcomeFieldsOf(line, nodeId, outcome);
|
|
23
|
+
const others = otherOutputsOf(stationAt(line, nodeId).station.produces, fields);
|
|
24
|
+
return { kind: "report", outcome, fields, others };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=stand-in-actions.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Report } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type TestLine } from "./test-line.js";
|
|
3
|
+
export type SuppliedFile = {
|
|
4
|
+
picked: string;
|
|
5
|
+
} | {
|
|
6
|
+
pasted: string;
|
|
7
|
+
};
|
|
8
|
+
export interface StandInAnswer {
|
|
9
|
+
outcome: string;
|
|
10
|
+
produced: Readonly<Record<string, string>>;
|
|
11
|
+
files?: Readonly<Record<string, SuppliedFile>>;
|
|
12
|
+
}
|
|
13
|
+
export declare function standInReport(line: TestLine, nodeId: string, answer: StandInAnswer): Report;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { enforce } from "@re-cinq/floor-assembly-lines";
|
|
2
|
+
import { enteredValue } from "./entered-value.js";
|
|
3
|
+
import { outcomeFieldsOf } from "./outcome-fields.js";
|
|
4
|
+
import { stationAt } from "./test-line.js";
|
|
5
|
+
export function standInReport(line, nodeId, answer) {
|
|
6
|
+
const { node, station } = stationAt(line, nodeId);
|
|
7
|
+
const { outcome } = answer;
|
|
8
|
+
enforceStationHasOutcome(node, station, outcome);
|
|
9
|
+
enforceRequiredFieldsEntered(line, nodeId, answer);
|
|
10
|
+
enforceSuppliedFilesAreDeclared(node, station, answer);
|
|
11
|
+
const produced = enteredProduces(station.produces, answer.produced);
|
|
12
|
+
return Object.keys(produced).length === 0 ? { outcome } : { outcome, produced };
|
|
13
|
+
}
|
|
14
|
+
function enforceStationHasOutcome(node, station, outcome) {
|
|
15
|
+
enforce(station.outcomes.includes(outcome), `${node.id} cannot report ${outcome}: its station ${node.station} has the outcomes ${station.outcomes.join(", ")}`);
|
|
16
|
+
}
|
|
17
|
+
function enforceRequiredFieldsEntered(line, nodeId, answer) {
|
|
18
|
+
for (const field of outcomeFieldsOf(line, nodeId, answer.outcome)) {
|
|
19
|
+
enforce(!field.required || isEntered(answer, field.name), `${field.name} is required when ${nodeId} reports ${answer.outcome}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function isEntered(answer, name) {
|
|
23
|
+
return enteredValue(answer.produced, name) !== undefined || Object.hasOwn(answer.files ?? {}, name);
|
|
24
|
+
}
|
|
25
|
+
function enforceSuppliedFilesAreDeclared(node, station, answer) {
|
|
26
|
+
for (const name of Object.keys(answer.files ?? {})) {
|
|
27
|
+
enforce(station.produces.some((declared) => declared.name === name && declared.kind === "file"), `${name} is not a file output of station ${node.station}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function enteredProduces(declared, entered) {
|
|
31
|
+
const pairs = declared.map(({ name }) => [name, enteredValue(entered, name)]);
|
|
32
|
+
return Object.fromEntries(pairs.filter((pair) => pair[1] !== undefined));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=stand-in-report.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The reasons an assembly line cannot be started as a local test run.
|
|
2
|
+
import { enforce, validateLine } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
export function startBlockers(line) {
|
|
4
|
+
return [...validatorProblems(line), ...pinRefusals(line), ...fanOutRefusals(line)];
|
|
5
|
+
}
|
|
6
|
+
export function enforceStartable(lineId, line, missing) {
|
|
7
|
+
const reasons = [...startBlockers(line), ...(missing.length > 0 ? [`${missing.join(", ")} is missing`] : [])];
|
|
8
|
+
enforce(reasons.length === 0, `${lineId} cannot start: ${reasons.join("; ")}`);
|
|
9
|
+
}
|
|
10
|
+
function validatorProblems({ body, stations }) {
|
|
11
|
+
return validateLine(body, { stations: new Set(stations.keys()), bodies: stations });
|
|
12
|
+
}
|
|
13
|
+
function pinRefusals({ body }) {
|
|
14
|
+
return body.nodes.flatMap((node) => node.station?.includes("@")
|
|
15
|
+
? [`node ${node.id} pins station ${node.station}, and a local test run only has the station its file defines: remove the pin to test it`]
|
|
16
|
+
: []);
|
|
17
|
+
}
|
|
18
|
+
function fanOutRefusals({ body }) {
|
|
19
|
+
return body.nodes.flatMap((node) => node.fanout ? [`node ${node.id} fans out to ${node.fanout.to}, and a local test run cannot fan out yet`] : []);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=start-blockers.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Item } from "@re-cinq/floor-contracts";
|
|
2
|
+
import type { TestLine } from "./test-line.js";
|
|
3
|
+
export interface StartItems {
|
|
4
|
+
items: Record<string, Item>;
|
|
5
|
+
missing: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface AskedItem {
|
|
8
|
+
name: string;
|
|
9
|
+
kind: Item["kind"];
|
|
10
|
+
}
|
|
11
|
+
export declare function startItemsOf(line: TestLine, entered: Readonly<Record<string, string>>): StartItems;
|
|
12
|
+
export declare function askedOf(line: TestLine): AskedItem[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { enteredValue } from "./entered-value.js";
|
|
2
|
+
export function startItemsOf(line, entered) {
|
|
3
|
+
const asked = askedOf(line);
|
|
4
|
+
const missing = asked.filter(({ name }) => enteredValue(entered, name) === undefined).map(({ name }) => name);
|
|
5
|
+
if (missing.length > 0)
|
|
6
|
+
return { items: {}, missing };
|
|
7
|
+
const entries = asked.map(({ name, kind }) => [name, startItem(kind, enteredValue(entered, name))]);
|
|
8
|
+
return { items: Object.fromEntries(entries), missing };
|
|
9
|
+
}
|
|
10
|
+
export function askedOf(line) {
|
|
11
|
+
const args = Object.entries(line.body.args).map(([name, arg]) => ({ name, kind: arg.kind }));
|
|
12
|
+
const fileNames = Object.keys(line.body.files ?? {}).filter((name) => !Object.hasOwn(line.body.args, name));
|
|
13
|
+
return [...args, ...fileNames.map((name) => ({ name, kind: "file" }))];
|
|
14
|
+
}
|
|
15
|
+
function startItem(kind, ref) {
|
|
16
|
+
return { kind, ref, by: "start" };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=start-items.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LineBody, LineNode, StationBody } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type WalkGraph } from "@re-cinq/floor-assembly-lines";
|
|
3
|
+
export interface TestLine {
|
|
4
|
+
id: string;
|
|
5
|
+
body: LineBody;
|
|
6
|
+
stations: ReadonlyMap<string, StationBody>;
|
|
7
|
+
}
|
|
8
|
+
export interface NodeStation {
|
|
9
|
+
node: LineNode;
|
|
10
|
+
station: StationBody;
|
|
11
|
+
}
|
|
12
|
+
export declare function walkGraphOfLine(line: TestLine): WalkGraph;
|
|
13
|
+
export declare function nodeAt(line: TestLine, nodeId: string): LineNode;
|
|
14
|
+
export declare function stationAt(line: TestLine, nodeId: string): NodeStation;
|
|
15
|
+
export declare function stationOfNode(line: TestLine, node: LineNode): StationBody;
|
|
16
|
+
export declare function stationBodyOf(line: TestLine, node: LineNode): StationBody | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { enforce, walkGraphOf } from "@re-cinq/floor-assembly-lines";
|
|
2
|
+
export function walkGraphOfLine(line) {
|
|
3
|
+
const { stations } = line;
|
|
4
|
+
return walkGraphOf(line.id, line.body, (stationRef) => stations.get(stationRef)?.kind);
|
|
5
|
+
}
|
|
6
|
+
export function nodeAt(line, nodeId) {
|
|
7
|
+
const { nodes } = line.body;
|
|
8
|
+
const node = nodes.find((candidate) => candidate.id === nodeId);
|
|
9
|
+
enforce(node, `node ${nodeId} is not in the line`);
|
|
10
|
+
return node;
|
|
11
|
+
}
|
|
12
|
+
export function stationAt(line, nodeId) {
|
|
13
|
+
const node = nodeAt(line, nodeId);
|
|
14
|
+
return { node, station: stationOfNode(line, node) };
|
|
15
|
+
}
|
|
16
|
+
export function stationOfNode(line, node) {
|
|
17
|
+
const station = stationBodyOf(line, node);
|
|
18
|
+
enforce(station, `node ${node.id} names no station of the line`);
|
|
19
|
+
return station;
|
|
20
|
+
}
|
|
21
|
+
export function stationBodyOf(line, node) {
|
|
22
|
+
return node.station === undefined ? undefined : line.stations.get(node.station);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=test-line.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Item } from "@re-cinq/floor-contracts";
|
|
2
|
+
import { type AskedItem } from "./start-items.js";
|
|
3
|
+
import type { TestLine } from "./test-line.js";
|
|
4
|
+
export interface TestPreview {
|
|
5
|
+
asked: AskedItem[];
|
|
6
|
+
missing: string[];
|
|
7
|
+
blockers: string[];
|
|
8
|
+
startItems: Record<string, Item>;
|
|
9
|
+
definitions: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function testPreviewOf(line: TestLine, entered: Readonly<Record<string, string>>, definitions: string[]): TestPreview;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { startBlockers } from "./start-blockers.js";
|
|
2
|
+
import { askedOf, startItemsOf } from "./start-items.js";
|
|
3
|
+
export function testPreviewOf(line, entered, definitions) {
|
|
4
|
+
const { items: startItems, missing } = startItemsOf(line, entered);
|
|
5
|
+
return { asked: askedOf(line), missing, blockers: startBlockers(line), startItems, definitions };
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=test-preview.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Item } from "@re-cinq/floor-contracts";
|
|
2
|
+
import type { StandInAction } from "./stand-in-actions.js";
|
|
3
|
+
import type { VisitState } from "./test-visit.js";
|
|
4
|
+
export interface TestRunState {
|
|
5
|
+
folder: string;
|
|
6
|
+
lineId: string;
|
|
7
|
+
status: "running" | "waiting" | "settled" | "stopped";
|
|
8
|
+
ending?: TestRunEnding;
|
|
9
|
+
visits: VisitState[];
|
|
10
|
+
actions: Record<string, StandInAction[]>;
|
|
11
|
+
bag?: BagEntry[];
|
|
12
|
+
}
|
|
13
|
+
export interface BagEntry {
|
|
14
|
+
name: string;
|
|
15
|
+
kind: Item["kind"];
|
|
16
|
+
ref: string;
|
|
17
|
+
by: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TestRunListing {
|
|
20
|
+
run: string;
|
|
21
|
+
line: string;
|
|
22
|
+
folder: string;
|
|
23
|
+
status: TestRunState["status"];
|
|
24
|
+
startedAt: string;
|
|
25
|
+
ending?: TestRunEnding;
|
|
26
|
+
}
|
|
27
|
+
export interface TestRunEnding {
|
|
28
|
+
outcome: "finished" | "iteration_max" | "error" | "failed" | "cancelled";
|
|
29
|
+
reason?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Item, Report } from "@re-cinq/floor-contracts";
|
|
2
|
+
import type { TestLine } from "./test-line.js";
|
|
3
|
+
import type { VisitKind } from "./visit-kind.js";
|
|
4
|
+
export interface TestVisit {
|
|
5
|
+
id: string;
|
|
6
|
+
nodeId: string;
|
|
7
|
+
iteration: number;
|
|
8
|
+
station: string | null;
|
|
9
|
+
report: Report | null;
|
|
10
|
+
}
|
|
11
|
+
export interface VisitState extends TestVisit {
|
|
12
|
+
kind: VisitKind;
|
|
13
|
+
needs: Record<string, string>;
|
|
14
|
+
report: Report | null;
|
|
15
|
+
openedAt: string;
|
|
16
|
+
reportedAt?: string;
|
|
17
|
+
agentDurationMs?: number;
|
|
18
|
+
costUsd?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TestRun {
|
|
21
|
+
line: TestLine;
|
|
22
|
+
startItems: Record<string, Item>;
|
|
23
|
+
visits: readonly TestVisit[];
|
|
24
|
+
}
|