@jive-sh/workflow-platform 0.6.2 → 0.7.0
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 +189 -42
- package/dist/budget-states.js +1 -1
- package/dist/budget-states.js.map +1 -1
- package/dist/dashboard/dashboard.css +42 -28
- package/dist/dashboard/drilldown.js +35 -4
- package/dist/dashboard/drilldown.js.map +1 -1
- package/dist/dashboard/run-doing-words.js +29 -0
- package/dist/dashboard/run-doing-words.js.map +1 -0
- package/dist/dashboard/setting-words.js +18 -0
- package/dist/dashboard/setting-words.js.map +1 -0
- package/dist/dashboard/spending-words.js +2 -10
- package/dist/dashboard/spending-words.js.map +1 -1
- package/dist/index.js +76 -13
- package/dist/index.js.map +1 -1
- package/dist/keep-running.js +4 -2
- package/dist/keep-running.js.map +1 -1
- package/dist/pick-wakes.js +2 -2
- package/dist/retention.js +59 -0
- package/dist/retention.js.map +1 -0
- package/dist/settings.js +88 -0
- package/dist/settings.js.map +1 -0
- package/dist/spending-limit.js +15 -21
- package/dist/spending-limit.js.map +1 -1
- package/dist/step-times.js +114 -0
- package/dist/step-times.js.map +1 -0
- package/dist/steps.js +399 -114
- package/dist/steps.js.map +1 -1
- package/dist/storage/agent-claims.js +3 -0
- package/dist/storage/agent-claims.js.map +1 -0
- package/dist/storage/budgets.js +40 -4
- package/dist/storage/budgets.js.map +1 -1
- package/dist/storage/engine-records.js +26 -10
- package/dist/storage/engine-records.js.map +1 -1
- package/dist/storage/sqlite-store.js +198 -20
- package/dist/storage/sqlite-store.js.map +1 -1
- package/dist/storage/task-store.js +11 -5
- package/dist/storage/task-store.js.map +1 -1
- package/dist/system-workflows.js +54 -0
- package/dist/system-workflows.js.map +1 -0
- package/dist/tasks.js +72 -29
- package/dist/tasks.js.map +1 -1
- package/dist/views/runs-now.js +80 -38
- package/dist/views/runs-now.js.map +1 -1
- package/dist/views/step-graph.js +6 -1
- package/dist/views/step-graph.js.map +1 -1
- package/dist/views/workflows-view.js +29 -23
- package/dist/views/workflows-view.js.map +1 -1
- package/package.json +1 -1
- package/src/budget-states.ts +2 -3
- package/src/dashboard/dashboard.css +42 -28
- package/src/dashboard/drilldown.ts +32 -5
- package/src/dashboard/index.tsx +1 -1
- package/src/dashboard/limits-and-runs.tsx +191 -0
- package/src/dashboard/queue-bar.tsx +30 -11
- package/src/dashboard/queue-chart.tsx +1 -2
- package/src/dashboard/run-doing-words.ts +41 -0
- package/src/dashboard/setting-words.ts +30 -0
- package/src/dashboard/spending-limit-control.tsx +5 -8
- package/src/dashboard/spending-words.ts +5 -23
- package/src/dashboard/time-distribution.tsx +61 -0
- package/src/dashboard/workflow-dag.tsx +247 -129
- package/src/dashboard/workflow-drilldown.tsx +13 -71
- package/src/dashboard/workflows-dashboard.tsx +345 -227
- package/src/index.ts +86 -16
- package/src/keep-running.ts +6 -4
- package/src/pick-wakes.ts +2 -2
- package/src/project.ts +12 -0
- package/src/retention.ts +90 -0
- package/src/settings.ts +171 -0
- package/src/spending-limit.ts +25 -42
- package/src/step-times.ts +151 -0
- package/src/steps.ts +512 -135
- package/src/storage/agent-claims.ts +63 -0
- package/src/storage/budgets.ts +43 -4
- package/src/storage/engine-records.ts +28 -11
- package/src/storage/sqlite-store.ts +225 -32
- package/src/storage/step-records.ts +59 -7
- package/src/storage/task-store.ts +29 -29
- package/src/system-workflows.ts +70 -0
- package/src/tasks.ts +69 -30
- package/src/views/runs-now.ts +119 -51
- package/src/views/step-graph.ts +11 -2
- package/src/views/workflows-view.ts +80 -39
- package/src/workflow-dag.test.tsx +89 -0
- package/src/workflow-page.test.tsx +170 -0
- package/dist/views/workflow-flows.js +0 -53
- package/dist/views/workflow-flows.js.map +0 -1
- package/src/dashboard/step-graph.tsx +0 -106
- package/src/views/workflow-flows.ts +0 -97
package/src/index.ts
CHANGED
|
@@ -13,17 +13,28 @@ import type { WorkflowProject } from './project';
|
|
|
13
13
|
import { makePickWakes } from './pick-wakes';
|
|
14
14
|
import { makeStepFiles } from './step-files';
|
|
15
15
|
import { makeStepUsage } from './step-usage';
|
|
16
|
-
import { keptRunningByItsBudget, makeSteps, runLimitOf } from './steps';
|
|
16
|
+
import { keptRunningByItsBudget, makeSteps, runLimitOf, tasksAreRuns } from './steps';
|
|
17
17
|
import { blockedReasons, makeTasks, needsAgentReasons } from './tasks';
|
|
18
18
|
import { buildWorkflowFigures, buildWorkflowsView, type WorkflowFigures, type WorkflowsView, type WorkflowView } from './views/workflows-view';
|
|
19
19
|
import { makeQueueCounts } from './queue-counts';
|
|
20
|
+
import { makeStepTimes } from './step-times';
|
|
20
21
|
import { makeSpendingLimit } from './spending-limit';
|
|
22
|
+
import { makeRetention } from './retention';
|
|
23
|
+
import { checkedSettings, RUNTIME_SETTINGS, settingValueRefusal, stepSetting, workflowSetting, type Effective, type SettingLevel, type SettingName, type SettingsTree, type SettingValues } from './settings';
|
|
24
|
+
|
|
25
|
+
/** Every setting as resolved at one moment (`platform.settings.now`). */
|
|
26
|
+
export interface SettingsNow {
|
|
27
|
+
readonly ofStep: <N extends SettingName>(r: { readonly workflow: string; readonly step: string; readonly name: N }) => Effective<SettingValues[N]>;
|
|
28
|
+
readonly ofWorkflow: <N extends SettingName>(r: { readonly workflow: string; readonly name: N }) => Effective<SettingValues[N]>;
|
|
29
|
+
}
|
|
30
|
+
import { makeSystemWorkflows } from './system-workflows';
|
|
21
31
|
import { sqliteBudgets, type LimitStore } from './storage/budgets';
|
|
22
32
|
import { sqliteEngineRecords, type EngineRecords } from './storage/engine-records';
|
|
23
33
|
import { sqliteStore } from './storage/sqlite-store';
|
|
24
34
|
import type { StepRecords } from './storage/step-records';
|
|
25
35
|
import type { TaskStore } from './storage/task-store';
|
|
26
36
|
import type { InputRecords } from './storage/input-records';
|
|
37
|
+
import type { AgentClaims } from './storage/agent-claims';
|
|
27
38
|
|
|
28
39
|
export * from './failure';
|
|
29
40
|
export * from './outside-failure';
|
|
@@ -44,6 +55,7 @@ export * from './storage/engine-records';
|
|
|
44
55
|
export * from './storage/sqlite-store';
|
|
45
56
|
export * from './storage/step-records';
|
|
46
57
|
export * from './storage/input-records';
|
|
58
|
+
export * from './storage/agent-claims';
|
|
47
59
|
export * from './storage/storage-error';
|
|
48
60
|
export * from './storage/move-store';
|
|
49
61
|
export * from './storage/engine-storage';
|
|
@@ -52,8 +64,11 @@ export * from './reasons';
|
|
|
52
64
|
export * from './views/runs-now';
|
|
53
65
|
export * from './views/step-funnel';
|
|
54
66
|
export * from './views/step-graph';
|
|
67
|
+
export * from './step-times';
|
|
68
|
+
export * from './settings';
|
|
69
|
+
export * from './retention';
|
|
70
|
+
export * from './system-workflows';
|
|
55
71
|
export * from './views/workflows-view';
|
|
56
|
-
export * from './views/workflow-flows';
|
|
57
72
|
export type { NewNote, TaskStore, TextChange } from './storage/task-store';
|
|
58
73
|
export type { AgentUsage, UsageLimit } from './dashboard/agent-usage';
|
|
59
74
|
|
|
@@ -64,6 +79,8 @@ export interface WorkflowStorage {
|
|
|
64
79
|
readonly inputs: InputRecords;
|
|
65
80
|
readonly engine: EngineRecords;
|
|
66
81
|
readonly budgets: LimitStore;
|
|
82
|
+
/** Each run's claim on its top workflow's agents (`storage/agent-claims.ts`). */
|
|
83
|
+
readonly claims: AgentClaims;
|
|
67
84
|
}
|
|
68
85
|
|
|
69
86
|
/**
|
|
@@ -86,15 +103,16 @@ export const sqliteStorage = (options: {
|
|
|
86
103
|
stepRecords: store.stepRecords,
|
|
87
104
|
tasks: store.tasks,
|
|
88
105
|
inputs: store.inputs,
|
|
106
|
+
claims: store.claims,
|
|
89
107
|
engine: sqliteEngineRecords({ file: options.engineFile }),
|
|
90
108
|
budgets: sqliteBudgets({ file: options.budgetsFile }),
|
|
91
109
|
};
|
|
92
110
|
};
|
|
93
111
|
|
|
94
112
|
/**
|
|
95
|
-
* ONE PROJECT'S PLATFORM. `
|
|
113
|
+
* ONE PROJECT'S PLATFORM. `R` is what its workflows' lists of work run under.
|
|
96
114
|
*/
|
|
97
|
-
export const createWorkflowPlatform = <
|
|
115
|
+
export const createWorkflowPlatform = <R>(input: {
|
|
98
116
|
readonly project: WorkflowProject;
|
|
99
117
|
readonly storage: WorkflowStorage;
|
|
100
118
|
}) => {
|
|
@@ -104,15 +122,25 @@ export const createWorkflowPlatform = <Phase extends string, R>(input: {
|
|
|
104
122
|
const stepUsage = makeStepUsage({ variable: project.stepRecordVariable, addStepCompile: (record) => { Effect.runFork(Effect.catchTag(storage.stepRecords.addStepCompile(record), 'StorageError', (e) => Effect.logError(`[step-runs] a compile of step record ${record}: ${e.reason}`))); } });
|
|
105
123
|
const tasks = makeTasks({ store: storage.tasks, engine: storage.engine, stepRecords: storage.stepRecords, wakes, texts: project.texts });
|
|
106
124
|
const spending = makeSpendingLimit({ store: storage.budgets, usage: project.weekUsage === undefined ? null : project.weekUsage, wakes });
|
|
107
|
-
|
|
125
|
+
// The app's platform-wide settings, checked where they enter: what every workflow and step inherits (`settings.ts`).
|
|
126
|
+
const appSettings = checkedSettings({ what: "the app's settings", ...(project.settings ?? {}) });
|
|
127
|
+
const { oneStepSystemWorkflow, ...steps } = makeSteps<R>({
|
|
108
128
|
sourceRoot: project.sourceRoot, stepRecords: storage.stepRecords, engine: storage.engine, tasks, wakes, budgets: storage.budgets, stepFiles,
|
|
109
129
|
CurrentStepUsage: stepUsage.CurrentStepUsage, isTransientFailure: project.isTransientFailure, thisProcess: project.processes.thisProcess, inputs: storage.inputs,
|
|
110
130
|
queueChanged: (workflow) => queueCounts.changed(workflow),
|
|
111
131
|
spendingHoldsAgents: spending.holdsAgents,
|
|
132
|
+
claims: storage.claims,
|
|
133
|
+
appSettings,
|
|
112
134
|
});
|
|
135
|
+
/** Whether a workflow's tasks are its runs (`steps.ts` `tasksAreRuns`), among the workflows declared now. */
|
|
136
|
+
const runsAreTasks = (workflow: string): boolean => {
|
|
137
|
+
const declared = steps.declaredWorkflows();
|
|
138
|
+
const d = declared.find((x) => x.name === workflow);
|
|
139
|
+
return d !== undefined && tasksAreRuns(d, declared);
|
|
140
|
+
};
|
|
113
141
|
const queueCounts = makeQueueCounts({
|
|
114
142
|
store: storage.tasks, tasks, wakes,
|
|
115
|
-
withQueues: () => steps.declaredWorkflows().filter((d) => d.item !== null).map((d) => d.name),
|
|
143
|
+
withQueues: () => steps.declaredWorkflows().filter((d) => d.item !== null || runsAreTasks(d.name)).map((d) => d.name),
|
|
116
144
|
});
|
|
117
145
|
/**
|
|
118
146
|
* Every workflow's limits now, by name, in one read: what a page's controls show. Every workflow has a run limit
|
|
@@ -122,7 +150,7 @@ export const createWorkflowPlatform = <Phase extends string, R>(input: {
|
|
|
122
150
|
const limitsNow = (): Effect.Effect<Readonly<Record<string, NonNullable<WorkflowView['limits']>>>, StorageError> =>
|
|
123
151
|
Effect.map(storage.budgets.storedLimits(), (stored) => (stored === null ? {} : Object.fromEntries(steps.declaredWorkflows().map((d) => {
|
|
124
152
|
const limits = stored.get(d.name) ?? { agents: 0, runs: null };
|
|
125
|
-
return [d.name, { agents: keptRunningByItsBudget(d) ? limits.agents : null, runs: runLimitOf(d, limits), runsSet: limits.runs !== null }] as const;
|
|
153
|
+
return [d.name, { agents: keptRunningByItsBudget(d) ? limits.agents : null, runs: runLimitOf(d, limits), runsSet: limits.runs !== null, agentsSet: stored.has(d.name) }] as const;
|
|
126
154
|
}))));
|
|
127
155
|
|
|
128
156
|
/** Each source file's text, read again only when the file changed: a page's links name the line a definition is on now. */
|
|
@@ -142,27 +170,69 @@ export const createWorkflowPlatform = <Phase extends string, R>(input: {
|
|
|
142
170
|
|
|
143
171
|
/**
|
|
144
172
|
* Every workflow as a dashboard shows it before one is opened, read now (`views/workflows-view.ts` `buildWorkflowsView`).
|
|
145
|
-
* `phases` is the order the project's page shows them in.
|
|
146
173
|
*/
|
|
147
|
-
const view = (r: { readonly now: number; readonly
|
|
174
|
+
const view = (r: { readonly now: number; readonly top: string }): Effect.Effect<WorkflowsView, StorageError> => Effect.gen(function* () {
|
|
148
175
|
const limits = yield* limitsNow();
|
|
149
|
-
return yield* buildWorkflowsView({ declared: steps.declaredWorkflows(),
|
|
176
|
+
return yield* buildWorkflowsView({ declared: steps.declaredWorkflows(), app: appSettings, stored: yield* storage.budgets.storedSettings(), top: r.top, now: r.now, taskStore: storage.tasks, locate, limitsOf: (name) => limits[name] ?? null, spending: yield* spending.state(r.now) });
|
|
150
177
|
});
|
|
151
178
|
|
|
152
179
|
/** One workflow's figures over the `hours` before `now`, read from its own records (`buildWorkflowFigures`); none for one not declared. */
|
|
153
180
|
const figures = (r: { readonly workflow: string; readonly now: number; readonly hours: number }): Effect.Effect<WorkflowFigures | null, StorageError> => {
|
|
154
181
|
const declaration = steps.declaredWorkflows().find((d) => d.name === r.workflow);
|
|
182
|
+
// The workflows whose runs start it as a step (`defineSubWorkflow`), and the step's name in each: their tasks pass through it.
|
|
183
|
+
const asAStepOf = steps.declaredWorkflows().flatMap((p) => p.steps().flatMap((s) => (s.workflow === r.workflow && s.runsOnItsOwnTrigger !== true ? [{ workflow: p.name, step: s.name }] : [])));
|
|
155
184
|
return declaration === undefined ? Effect.succeed(null) : buildWorkflowFigures({
|
|
156
|
-
declaration, now: r.now, hours: r.hours, records: storage.stepRecords, engine: storage.engine, locate,
|
|
157
|
-
reasons: declaration.item === null
|
|
185
|
+
declaration, now: r.now, hours: r.hours, records: storage.stepRecords, engine: storage.engine, locate, asAStepOf,
|
|
186
|
+
reasons: declaration.item === null && !runsAreTasks(r.workflow)
|
|
158
187
|
? Effect.succeed({ blocked: [], needingAnAgent: { reasons: [], passedOverBecause: null } })
|
|
159
|
-
: Effect.map(Effect.all({ summaries: tasks.taskSummaries({ workflow: r.workflow }),
|
|
188
|
+
: Effect.map(Effect.all({ summaries: tasks.taskSummaries({ workflow: r.workflow }), noAgentFree: steps.whyNoAgentIsFree(r.workflow) }), ({ summaries, noAgentFree }) => ({
|
|
160
189
|
blocked: blockedReasons(summaries),
|
|
161
|
-
needingAnAgent: { reasons: needsAgentReasons(summaries), passedOverBecause:
|
|
190
|
+
needingAnAgent: { reasons: needsAgentReasons(summaries), passedOverBecause: noAgentFree },
|
|
162
191
|
})),
|
|
163
192
|
});
|
|
164
193
|
};
|
|
165
|
-
|
|
194
|
+
/** Each step's time distribution over the current version of its workflow, held in memory (`step-times.ts`). */
|
|
195
|
+
const stepTimes = makeStepTimes({
|
|
196
|
+
records: storage.stepRecords, engine: storage.engine, versionOf: steps.versionOf,
|
|
197
|
+
stepsOf: (workflow) => steps.declaredWorkflows().find((d) => d.name === workflow)?.steps().map((s) => s.name) ?? [],
|
|
198
|
+
});
|
|
199
|
+
/** Retention (`retention.ts`): what the platform's own workflow Retention runs to delete the records its workflows keep no longer. */
|
|
200
|
+
const retention = makeRetention({
|
|
201
|
+
declared: steps.declaredWorkflows, app: appSettings, stored: storage.budgets.storedSettings, records: storage.stepRecords, tasks: storage.tasks, engine: storage.engine,
|
|
202
|
+
queueChanged: (workflow) => queueCounts.changed(workflow),
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* THE PLATFORM'S OWN WORKFLOWS (`system-workflows.ts`), defined here, before the app defines any of its own: the app's
|
|
206
|
+
* engine runs `system.layer`, and its scheduler starts each of `system.workflows` on its schedule.
|
|
207
|
+
*/
|
|
208
|
+
const system = makeSystemWorkflows<R>({ define: oneStepSystemWorkflow, retention, schedules: project.systemSchedules });
|
|
209
|
+
/** The settings every workflow and step inherits (`settings.ts`), over every workflow declared now and the app's. */
|
|
210
|
+
const settings = {
|
|
211
|
+
/** An agent step's model and where it is set: set in code alone, so read at once. */
|
|
212
|
+
model: (r: { readonly workflow: string; readonly step: string }): Effective<string | null> =>
|
|
213
|
+
stepSetting({ declared: steps.declaredWorkflows(), app: appSettings, stored: [] }, { ...r, name: 'model' }),
|
|
214
|
+
/** Every setting now, the retention settings set while the app runs read from the store first. */
|
|
215
|
+
now: (): Effect.Effect<SettingsNow, StorageError> => Effect.map(storage.budgets.storedSettings(), (stored): SettingsNow => {
|
|
216
|
+
const tree: SettingsTree = { declared: steps.declaredWorkflows(), app: appSettings, stored };
|
|
217
|
+
return { ofStep: (r) => stepSetting(tree, r), ofWorkflow: (r) => workflowSetting(tree, r) };
|
|
218
|
+
}),
|
|
219
|
+
/**
|
|
220
|
+
* WHY A CHANGE A PAGE ASKS FOR IS REFUSED, none where the project may store it (`storage/budgets.ts`
|
|
221
|
+
* `SET_WORKFLOW_SETTING_SQL`): a retention setting, at a level declared now, to a good value or none (the code's).
|
|
222
|
+
*/
|
|
223
|
+
changeRefusal: (c: { readonly level: SettingLevel; readonly name: string; readonly value: number | null }): string | null => {
|
|
224
|
+
const name = RUNTIME_SETTINGS.find((n) => n === c.name);
|
|
225
|
+
if (name === undefined) return `${c.name} is no setting a page sets: only ${RUNTIME_SETTINGS.join(' and ')}`;
|
|
226
|
+
if (c.level.kind !== 'app') {
|
|
227
|
+
const { level } = c;
|
|
228
|
+
const d = steps.declaredWorkflows().find((x) => x.name === level.workflow);
|
|
229
|
+
if (d === undefined) return `no workflow ${level.workflow} is declared`;
|
|
230
|
+
if (level.kind === 'step' && !d.steps().some((s) => s.name === level.step)) return `${d.name} has no step ${level.step}`;
|
|
231
|
+
}
|
|
232
|
+
return c.value === null ? null : settingValueRefusal(name, c.value);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
return { project, storage, wakes, stepFiles, stepUsage, tasks, steps, view, figures, limitsNow, queueCounts, spending, stepTimes, retention, system, settings };
|
|
166
236
|
};
|
|
167
237
|
|
|
168
|
-
export type WorkflowPlatform<
|
|
238
|
+
export type WorkflowPlatform<R> = ReturnType<typeof createWorkflowPlatform<R>>;
|
package/src/keep-running.ts
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* in its queue (`steps.ts` `whyNoRunCanTakeWork`), it starts none, and a run waiting in its Pick ends. Alex, relayed on 2026-11-20:
|
|
14
14
|
* "if the number of queued tasks that require agents is all of them, and if there is no remaining agentic budget or all
|
|
15
15
|
* agents are in use, then the workflow runner doesn't just continually cycle picking up tasks and moving them to the back
|
|
16
|
-
* of the queue again". The next turn after an agent can be had, a mark clears or new input lands starts runs again.
|
|
16
|
+
* of the queue again". The next turn after an agent can be had, a mark clears or new input lands starts runs again. While
|
|
17
|
+
* its agents are only all in use, runs start: a Pick passes over the marked tasks and waits, with nothing it can take,
|
|
18
|
+
* until an agent step ends (`steps.ts` `whyNoAgentIsFree`), so no run cycles through them either.
|
|
17
19
|
*/
|
|
18
20
|
import { keptRunningByItsBudget, type WorkflowDeclaration } from './steps';
|
|
19
21
|
import { runLimit, type WorkflowLimits } from './storage/budgets';
|
|
@@ -26,12 +28,12 @@ export const TURN_LIMIT_MS = 50_000;
|
|
|
26
28
|
export const START_LIMIT_SECONDS = 20;
|
|
27
29
|
|
|
28
30
|
/** The workflows this trigger keeps running, each with a budget. Pure. */
|
|
29
|
-
export const budgetedWorkflows = <D extends Pick<WorkflowDeclaration<
|
|
31
|
+
export const budgetedWorkflows = <D extends Pick<WorkflowDeclaration<unknown>, 'pending' | 'items' | 'steps'>>(declared: ReadonlyArray<D>): ReadonlyArray<D> =>
|
|
30
32
|
declared.filter(keptRunningByItsBudget);
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* How many runs of one workflow to start now: the runs its run limit keeps above the runs going. Its agents' limit plays
|
|
34
|
-
* no part:
|
|
36
|
+
* no part: a run with a task that finds no agent free at its first agent step gives its task back and ends. Pure.
|
|
35
37
|
*/
|
|
36
38
|
export const runsToStart = (w: { readonly kept: number; readonly running: number }): number => Math.max(w.kept - w.running, 0);
|
|
37
39
|
|
|
@@ -39,7 +41,7 @@ export const runsToStart = (w: { readonly kept: number; readonly running: number
|
|
|
39
41
|
* One turn's plan: for each budgeted workflow, the runs going and how many to start; none where no run could take work
|
|
40
42
|
* (`noWork`, from `steps.ts` `whyNoRunCanTakeWork`), which says why. Pure but for the reads it is given.
|
|
41
43
|
*/
|
|
42
|
-
export const planRunStarts = <D extends Pick<WorkflowDeclaration<
|
|
44
|
+
export const planRunStarts = <D extends Pick<WorkflowDeclaration<unknown>, 'name' | 'pending' | 'items' | 'steps'>>(input: {
|
|
43
45
|
readonly declared: ReadonlyArray<D>;
|
|
44
46
|
readonly limitsOf: (workflow: string) => WorkflowLimits;
|
|
45
47
|
readonly runningRuns: (workflow: string) => number;
|
package/src/pick-wakes.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* WHAT WAKES A PICK THAT FOUND NOTHING IT CAN CLAIM (`steps.ts` `untilPicked`), never a timer. A wake is any event that can
|
|
3
3
|
* change what a Pick can claim: a note on one of its workflow's tasks (new input, a reopen, a release, a hold, an outcome:
|
|
4
4
|
* `tasks.ts`), an item new to its list (`recordListing`), its limits set (which also has the run planner plan
|
|
5
|
-
* again: `runPlanChanged`),
|
|
6
|
-
* claim go. A claim held outside its workflow's runs ending, or a lease running out, wakes nothing: the next of these events
|
|
5
|
+
* again: `runPlanChanged`), an agent step of its runs ending, which frees an agent for a task marked as needing one
|
|
6
|
+
* (`steps.ts` `whyNoAgentIsFree`), or one of its runs ending, which lets that run's claim go. A claim held outside its workflow's runs ending, or a lease running out, wakes nothing: the next of these events
|
|
7
7
|
* re-checks it. Before 2026-11-11 a Pick with nothing picked again each minute, and at budget 0 it ended its run at once:
|
|
8
8
|
* the first project's main workflow then ran Pick and Finish about once a second, 17,844 times in 6 hours.
|
|
9
9
|
*
|
package/src/project.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Effect } from 'effect';
|
|
6
6
|
import type { StorageError } from './storage/storage-error';
|
|
7
|
+
import type { InheritedSettings } from './settings';
|
|
8
|
+
import type { SystemSchedule, SystemWorkflowName } from './system-workflows';
|
|
7
9
|
|
|
8
10
|
/** A process, by its pid and the second it started (as `ps` reports it), so a reused pid is never taken for it. */
|
|
9
11
|
export interface ProcessIdentity {
|
|
@@ -112,4 +114,14 @@ export interface WorkflowProject {
|
|
|
112
114
|
* (`spending-limit.ts`). A project that gives none has no spending limit.
|
|
113
115
|
*/
|
|
114
116
|
readonly weekUsage?: WeekUsage;
|
|
117
|
+
/**
|
|
118
|
+
* THE APP'S PLATFORM-WIDE SETTINGS: what every workflow and step inherits, the platform's own included, where nothing
|
|
119
|
+
* below sets its own (`settings.ts`), over the platform's defaults. Given once, here.
|
|
120
|
+
*/
|
|
121
|
+
readonly settings?: InheritedSettings;
|
|
122
|
+
/**
|
|
123
|
+
* How often each of the platform's own workflows runs, where not its default (`system-workflows.ts`). Its steps are the
|
|
124
|
+
* platform's; its schedule here and its run limit in the limits table are the app's.
|
|
125
|
+
*/
|
|
126
|
+
readonly systemSchedules?: Readonly<Partial<Record<SystemWorkflowName, SystemSchedule>>>;
|
|
115
127
|
}
|
package/src/retention.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RETENTION: A RUN'S RECORDS GO ONCE THE RUN HAS BEEN OVER LONGER THAN ITS STEPS KEEP THEM, AND IS NOT ONE OF EACH STEP'S
|
|
3
|
+
* NEWEST. Alex, 2026-11-21: "time based retention is a good idea. it should be configurable at the highest level with
|
|
4
|
+
* allowed step level overrides ... i think 7 days sounds reasonable." Then, 2026-11-22: "a project might complete or stall
|
|
5
|
+
* but we shouldn't lose run data in that case", and "10k runs". How long, and how many runs at least, is each step's own
|
|
6
|
+
* setting, else its workflow's, from the top down, else the app's (`settings.ts`), stored while the app runs or in code; 7
|
|
7
|
+
* days and 10,000 runs where nothing sets them. There is no most a step keeps.
|
|
8
|
+
*
|
|
9
|
+
* What goes: each step record and its per-item parts (`step_runs`, `step_functions`), once every record of its run has
|
|
10
|
+
* ended that long ago, the engine has the run finished, and the run is none of that step's newest kept at least; and, for a
|
|
11
|
+
* workflow whose tasks are its runs (`steps.ts` `tasksAreRuns`), each run's task with its notes, as its workflow keeps them,
|
|
12
|
+
* its newest kept at least the same way. An item's task (a function Decompile works on: queued, in progress, blocked or done)
|
|
13
|
+
* is the work's state, not its history, and never goes. Records of a step no longer declared go as its workflow keeps them,
|
|
14
|
+
* and those of a workflow no longer declared as the app keeps them.
|
|
15
|
+
*
|
|
16
|
+
* No app runs it: the platform's own workflow Retention does, on a schedule (`system-workflows.ts`), so each pass is
|
|
17
|
+
* measured and recorded like any other step's work.
|
|
18
|
+
*/
|
|
19
|
+
import { Effect } from 'effect';
|
|
20
|
+
import { appSetting, stepSetting, workflowSetting, type InheritedSettings, type SettingName, type SettingsTree, type StoredSetting } from './settings';
|
|
21
|
+
import { tasksAreRuns, type StepDeclaration, type WorkflowDeclaration } from './steps';
|
|
22
|
+
import type { EngineRecords } from './storage/engine-records';
|
|
23
|
+
import type { StepRecords } from './storage/step-records';
|
|
24
|
+
import type { StorageError } from './storage/storage-error';
|
|
25
|
+
import type { TaskStore } from './storage/task-store';
|
|
26
|
+
|
|
27
|
+
/** What one pass deleted: step records, their per-item parts, and the tasks that were runs, with their notes. */
|
|
28
|
+
export interface RetentionPass {
|
|
29
|
+
readonly records: number;
|
|
30
|
+
readonly parts: number;
|
|
31
|
+
readonly runTasks: number;
|
|
32
|
+
readonly runTaskNotes: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SECONDS_A_DAY = 86_400;
|
|
36
|
+
|
|
37
|
+
/** What retention reads of each declared workflow: its name, its item, its settings and its steps'. */
|
|
38
|
+
export type RetentionDeclared = Pick<WorkflowDeclaration<unknown>, 'name' | 'item' | SettingName> & {
|
|
39
|
+
readonly steps: () => ReadonlyArray<Pick<StepDeclaration, 'name' | 'workflow' | 'runsOnItsOwnTrigger' | SettingName>>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const makeRetention = (deps: {
|
|
43
|
+
/** Every workflow declared now. */
|
|
44
|
+
readonly declared: () => ReadonlyArray<RetentionDeclared>;
|
|
45
|
+
/** What the app sets above every workflow (`WorkflowProject.settings`). */
|
|
46
|
+
readonly app: InheritedSettings;
|
|
47
|
+
/** The retention settings set while the app runs, read at each pass (`LimitStore.storedSettings`). */
|
|
48
|
+
readonly stored: () => Effect.Effect<ReadonlyArray<StoredSetting>, StorageError>;
|
|
49
|
+
readonly records: Pick<StepRecords, 'deleteRecordsOfRunsEndedBefore'>;
|
|
50
|
+
readonly tasks: Pick<TaskStore, 'deleteRunTasksEndedBefore'>;
|
|
51
|
+
readonly engine: Pick<EngineRecords, 'unfinishedRuns'>;
|
|
52
|
+
/** A workflow's queue changed: its tasks that were runs went, so its counts are taken again (`queue-counts.ts`). */
|
|
53
|
+
readonly queueChanged: (workflow: string) => void;
|
|
54
|
+
}) => {
|
|
55
|
+
/** One pass at `now`, unix seconds: what each record's step keeps, applied to every declared workflow and the rest. */
|
|
56
|
+
const prune = (now: number): Effect.Effect<RetentionPass, StorageError> => Effect.gen(function* () {
|
|
57
|
+
const declared = deps.declared();
|
|
58
|
+
const tree: SettingsTree = { declared, app: deps.app, stored: yield* deps.stored() };
|
|
59
|
+
// A run the engine has not finished keeps every record and its task, however old: its next step reads them.
|
|
60
|
+
const keepRuns = (yield* deps.engine.unfinishedRuns()).map((u) => u.run);
|
|
61
|
+
const before = (days: number) => now - days * SECONDS_A_DAY;
|
|
62
|
+
let pass: RetentionPass = { records: 0, parts: 0, runTasks: 0, runTaskNotes: 0 };
|
|
63
|
+
const add = (more: Partial<RetentionPass>) => {
|
|
64
|
+
pass = { records: pass.records + (more.records ?? 0), parts: pass.parts + (more.parts ?? 0), runTasks: pass.runTasks + (more.runTasks ?? 0), runTaskNotes: pass.runTaskNotes + (more.runTaskNotes ?? 0) };
|
|
65
|
+
};
|
|
66
|
+
for (const d of declared) {
|
|
67
|
+
const steps = d.steps();
|
|
68
|
+
for (const s of steps) {
|
|
69
|
+
const at = { workflow: d.name, step: s.name };
|
|
70
|
+
add(yield* deps.records.deleteRecordsOfRunsEndedBefore({
|
|
71
|
+
select: at, before: before(stepSetting(tree, { ...at, name: 'retentionDays' }).value), keepRuns, keepNewest: stepSetting(tree, { ...at, name: 'keepAtLeastRuns' }).value,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
const workflowKeeps = { days: workflowSetting(tree, { workflow: d.name, name: 'retentionDays' }).value, atLeastRuns: workflowSetting(tree, { workflow: d.name, name: 'keepAtLeastRuns' }).value };
|
|
75
|
+
add(yield* deps.records.deleteRecordsOfRunsEndedBefore({ select: { workflow: d.name, stepsOtherThan: steps.map((s) => s.name) }, before: before(workflowKeeps.days), keepRuns, keepNewest: workflowKeeps.atLeastRuns }));
|
|
76
|
+
if (tasksAreRuns(d, declared)) {
|
|
77
|
+
const gone = yield* deps.tasks.deleteRunTasksEndedBefore({ workflow: d.name, before: before(workflowKeeps.days), keepItems: keepRuns, keepNewest: workflowKeeps.atLeastRuns });
|
|
78
|
+
add({ runTasks: gone.tasks, runTaskNotes: gone.notes });
|
|
79
|
+
if (gone.tasks > 0) deps.queueChanged(d.name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
add(yield* deps.records.deleteRecordsOfRunsEndedBefore({
|
|
83
|
+
select: { workflowsOtherThan: declared.map((d) => d.name) }, before: before(appSetting(tree, 'retentionDays').value), keepRuns, keepNewest: appSetting(tree, 'keepAtLeastRuns').value,
|
|
84
|
+
}));
|
|
85
|
+
return pass;
|
|
86
|
+
});
|
|
87
|
+
return { prune };
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type Retention = ReturnType<typeof makeRetention>;
|
package/src/settings.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE SETTINGS A WORKFLOW TREE INHERITS: how long its records are kept, the fewest of its runs kept however old, and the
|
|
3
|
+
* model its agent steps run on. Alex, 2026-11-21: "time based retention is a good idea. it should be configurable at the
|
|
4
|
+
* highest level with allowed step level overrides. and the same should be true for model. i think 7 days sounds
|
|
5
|
+
* reasonable." Then, 2026-11-22: "retention is supposed to be configurable at the platform layer and something configurable
|
|
6
|
+
* for all tasks"; "can retention actually be a # of tasks thing or a time thing ... because I realized a project might
|
|
7
|
+
* complete or stall but we shouldn't lose run data in that case" ("10k runs"); and "like it needs to be configurable".
|
|
8
|
+
*
|
|
9
|
+
* The highest level is the app: what it gives the platform once (`WorkflowProject.settings`) holds for every workflow and
|
|
10
|
+
* step, its own and the platform's (`system-workflows.ts`), over the platform's defaults. Below it, each is set, where it is
|
|
11
|
+
* set, on a workflow (`defineWorkflow`) or on a step (`defineStep`, `defineSubWorkflow`, `defineWorkflowStep`). A step's
|
|
12
|
+
* value is its own, else its workflow's. A workflow's is its own, else what the step that holds it in the workflow above
|
|
13
|
+
* sets, else that workflow's, up to the top, else the app's, else the platform's default. So a step that is a workflow
|
|
14
|
+
* hands its value down to every step under it.
|
|
15
|
+
*
|
|
16
|
+
* THE RETENTION SETTINGS ARE ALSO SET WHILE THE APP RUNS (`RUNTIME_SETTINGS`): a value stored on the app, a workflow or a step
|
|
17
|
+
* (`StoredSetting`, the `workflow_settings` table, `storage/budgets.ts`) is that level's own and wins over the code's value
|
|
18
|
+
* there, which is its default. The model is set in code alone. Pure, so a page and a run read the same answer.
|
|
19
|
+
*/
|
|
20
|
+
import type { StepDeclaration, WorkflowDeclaration } from './steps';
|
|
21
|
+
|
|
22
|
+
/** What the app, a workflow or a step may set for the steps under it. */
|
|
23
|
+
export interface InheritedSettings {
|
|
24
|
+
/** How many days a run's records are kept after the run ended (`retention.ts`). */
|
|
25
|
+
readonly retentionDays?: number;
|
|
26
|
+
/** How many of a step's newest runs keep their records however long ago they ended (`retention.ts`). */
|
|
27
|
+
readonly keepAtLeastRuns?: number;
|
|
28
|
+
/** The model an agent step runs on (`AgentStep.model`). */
|
|
29
|
+
readonly model?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SettingName = keyof InheritedSettings;
|
|
33
|
+
|
|
34
|
+
/** Each setting's value once resolved: a model may be set nowhere. */
|
|
35
|
+
export interface SettingValues {
|
|
36
|
+
readonly retentionDays: number;
|
|
37
|
+
readonly keepAtLeastRuns: number;
|
|
38
|
+
readonly model: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Each setting where neither the app nor any workflow or step sets it: records kept 7 days, and each step's newest 10,000
|
|
43
|
+
* runs however old (Alex, 2026-11-22: "10k runs"); no model, which an agent step cannot run without.
|
|
44
|
+
*/
|
|
45
|
+
export const PLATFORM_DEFAULTS: SettingValues = { retentionDays: 7, keepAtLeastRuns: 10_000, model: null };
|
|
46
|
+
|
|
47
|
+
/** The settings a page may set while the app runs; the model is set in code alone. */
|
|
48
|
+
export const RUNTIME_SETTINGS = ['retentionDays', 'keepAtLeastRuns'] as const;
|
|
49
|
+
export type RuntimeSettingName = (typeof RUNTIME_SETTINGS)[number];
|
|
50
|
+
|
|
51
|
+
/** Where a setting is set: the app, one workflow, or one step of one workflow. */
|
|
52
|
+
export type SettingLevel =
|
|
53
|
+
| { readonly kind: 'app' }
|
|
54
|
+
| { readonly kind: 'workflow'; readonly workflow: string }
|
|
55
|
+
| { readonly kind: 'step'; readonly workflow: string; readonly step: string };
|
|
56
|
+
|
|
57
|
+
/** A value set while the app runs, at one level, and when; none (`value: null`) puts that level back to the code's value. */
|
|
58
|
+
export interface StoredSetting {
|
|
59
|
+
readonly level: SettingLevel;
|
|
60
|
+
readonly name: RuntimeSettingName;
|
|
61
|
+
readonly value: number | null;
|
|
62
|
+
readonly changedAt: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Where an effective value is set. */
|
|
66
|
+
export type SetOn = SettingLevel | { readonly kind: 'platform default' };
|
|
67
|
+
|
|
68
|
+
/** A setting's value for a step or a workflow, and where it is set. */
|
|
69
|
+
export interface Effective<A> {
|
|
70
|
+
readonly value: A;
|
|
71
|
+
readonly setOn: SetOn;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** What the resolution reads of each declared workflow. */
|
|
75
|
+
export type SettingsDeclared = Pick<WorkflowDeclaration<unknown>, 'name' | SettingName> & {
|
|
76
|
+
readonly steps: () => ReadonlyArray<Pick<StepDeclaration, 'name' | 'workflow' | SettingName>>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Everything a setting is resolved from: every declared workflow, what the app sets above them all, and the values set while
|
|
81
|
+
* the app runs (none where nothing reads them, as for the model).
|
|
82
|
+
*/
|
|
83
|
+
export interface SettingsTree {
|
|
84
|
+
readonly declared: ReadonlyArray<SettingsDeclared>;
|
|
85
|
+
readonly app: InheritedSettings;
|
|
86
|
+
readonly stored: ReadonlyArray<StoredSetting>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** A level as one comparable text, each part its own segment. Pure. */
|
|
90
|
+
const levelKey = (l: SettingLevel): string => (l.kind === 'app' ? 'app' : l.kind === 'workflow' ? `workflow\u0000${l.workflow}` : `step\u0000${l.workflow}\u0000${l.step}`);
|
|
91
|
+
|
|
92
|
+
/** Whether two levels are one. Pure. */
|
|
93
|
+
export const sameLevel = (a: SettingLevel, b: SettingLevel): boolean => levelKey(a) === levelKey(b);
|
|
94
|
+
|
|
95
|
+
/** The value stored at a level now, where one is and it is not back to the code's. Pure. */
|
|
96
|
+
export const storedAt = (stored: ReadonlyArray<StoredSetting>, level: SettingLevel, name: SettingName): number | null => {
|
|
97
|
+
const found = stored.find((s) => s.name === name && sameLevel(s.level, level));
|
|
98
|
+
return found === undefined ? null : found.value;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** A level's own value: what is stored there now, else what its code sets. */
|
|
102
|
+
const ownAt = <N extends SettingName>(tree: SettingsTree, level: SettingLevel, name: N, code: InheritedSettings[N] | undefined): SettingValues[N] | undefined => {
|
|
103
|
+
const stored = storedAt(tree.stored, level, name);
|
|
104
|
+
return (stored !== null ? stored : code) as SettingValues[N] | undefined;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** A setting above every workflow: the app's, stored or in code, else the platform's default. Pure. */
|
|
108
|
+
export const appSetting = <N extends SettingName>(tree: Pick<SettingsTree, 'app' | 'stored'>, name: N): Effective<SettingValues[N]> => {
|
|
109
|
+
const own = ownAt({ ...tree, declared: [] }, { kind: 'app' }, name, tree.app[name]);
|
|
110
|
+
return own !== undefined ? { value: own, setOn: { kind: 'app' } } : { value: PLATFORM_DEFAULTS[name], setOn: { kind: 'platform default' } };
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Two parents of a workflow that would hand it different values: the declarations are at fault, said once. */
|
|
114
|
+
const faultsSaid = new Set<string>();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A WORKFLOW'S VALUE OF A SETTING: its own, else from the step that holds it in the workflow above (that step's own, else
|
|
118
|
+
* that workflow's), up to the top, else the app's, else the platform's default. A workflow held by two workflows that hand
|
|
119
|
+
* it different values is a fault in their declarations: in tests it throws; live, it is said once, and the first, in the
|
|
120
|
+
* order declared, holds. Pure but for that.
|
|
121
|
+
*/
|
|
122
|
+
export const workflowSetting = <N extends SettingName>(tree: SettingsTree, r: { readonly workflow: string; readonly name: N }, seen: ReadonlySet<string> = new Set()): Effective<SettingValues[N]> => {
|
|
123
|
+
const own = ownAt(tree, { kind: 'workflow', workflow: r.workflow }, r.name, tree.declared.find((x) => x.name === r.workflow)?.[r.name]);
|
|
124
|
+
if (own !== undefined) return { value: own, setOn: { kind: 'workflow', workflow: r.workflow } };
|
|
125
|
+
const fallback = appSetting(tree, r.name);
|
|
126
|
+
if (seen.has(r.workflow)) return fallback;
|
|
127
|
+
const under = new Set([...seen, r.workflow]);
|
|
128
|
+
const fromAbove = tree.declared.flatMap((parent) => parent.steps().filter((s) => s.workflow === r.workflow).map((s): Effective<SettingValues[N]> => {
|
|
129
|
+
const set = ownAt(tree, { kind: 'step', workflow: parent.name, step: s.name }, r.name, s[r.name]);
|
|
130
|
+
return set !== undefined ? { value: set, setOn: { kind: 'step', workflow: parent.name, step: s.name } } : workflowSetting(tree, { workflow: parent.name, name: r.name }, under);
|
|
131
|
+
}));
|
|
132
|
+
const first = fromAbove[0];
|
|
133
|
+
if (first === undefined) return fallback;
|
|
134
|
+
const other = fromAbove.find((x) => x.value !== first.value);
|
|
135
|
+
if (other !== undefined) {
|
|
136
|
+
const fault = `${r.workflow} is a step of workflows that hand it different values of ${r.name}: ${String(first.value)} and ${String(other.value)}`;
|
|
137
|
+
if (process.env.NODE_ENV === 'test') throw new Error(fault);
|
|
138
|
+
if (!faultsSaid.has(fault)) {
|
|
139
|
+
faultsSaid.add(fault);
|
|
140
|
+
console.error(`[settings] ${fault}; the first holds`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return first;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** A step's value of a setting: its own, else its workflow's (`workflowSetting`). */
|
|
147
|
+
export const stepSetting = <N extends SettingName>(tree: SettingsTree, r: { readonly workflow: string; readonly step: string; readonly name: N }): Effective<SettingValues[N]> => {
|
|
148
|
+
const own = ownAt(tree, { kind: 'step', workflow: r.workflow, step: r.step }, r.name, tree.declared.find((x) => x.name === r.workflow)?.steps().find((s) => s.name === r.step)?.[r.name]);
|
|
149
|
+
if (own !== undefined) return { value: own, setOn: { kind: 'step', workflow: r.workflow, step: r.step } };
|
|
150
|
+
return workflowSetting(tree, { workflow: r.workflow, name: r.name });
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/** Why a retention setting's value is refused, none where it is good: days a positive number, runs a whole number from 0. Pure. */
|
|
154
|
+
export const settingValueRefusal = (name: RuntimeSettingName, value: number): string | null =>
|
|
155
|
+
name === 'retentionDays'
|
|
156
|
+
? (Number.isFinite(value) && value > 0 ? null : `its records must be kept a positive number of days, not ${value}`)
|
|
157
|
+
: (Number.isInteger(value) && value >= 0 ? null : `the runs it keeps at least must be a whole number from 0, not ${value}`);
|
|
158
|
+
|
|
159
|
+
/** Settings as written on the app, a workflow or a step, checked there (`settingValueRefusal`), a model a name. */
|
|
160
|
+
export const checkedSettings = (d: { readonly [K in SettingName]?: InheritedSettings[K] | undefined } & { readonly what: string }): InheritedSettings => {
|
|
161
|
+
for (const name of RUNTIME_SETTINGS) {
|
|
162
|
+
const value = d[name];
|
|
163
|
+
const refusal = value === undefined ? null : settingValueRefusal(name, value);
|
|
164
|
+
if (refusal !== null) throw new Error(`${d.what}: ${refusal}`);
|
|
165
|
+
}
|
|
166
|
+
if (d.model !== undefined && d.model.trim() === '') throw new Error(`${d.what}: its model is an empty name`);
|
|
167
|
+
return {
|
|
168
|
+
...(d.retentionDays === undefined ? {} : { retentionDays: d.retentionDays }), ...(d.keepAtLeastRuns === undefined ? {} : { keepAtLeastRuns: d.keepAtLeastRuns }),
|
|
169
|
+
...(d.model === undefined ? {} : { model: d.model }),
|
|
170
|
+
};
|
|
171
|
+
};
|