@jive-sh/workflow-platform 1.3.0 → 1.4.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 CHANGED
@@ -79,6 +79,9 @@ worker gives a run only what its step lists.
79
79
  re-opened after its parent moved on is kept on the parent as a note.
80
80
  - **Agents:** `AgentRunner` with no tools, a reading mode or a working mode with write scopes, a cached input, and a
81
81
  turn limit; the organization implements it.
82
+ - **Builds:** `ProgramBuild` builds the whole program, or (1.4.0) compiles one function's unit with
83
+ `compileUnit({ address })`, saying whether it compiles and the compiler's first error; each unit compile counts as
84
+ one of the step's compiles.
82
85
  - **Queues:** requeue with a note, move tasks to the front, an in-progress limit per workflow or per field value (a
83
86
  lock across steps), and retention of records (7 days and the newest 10,000 runs by default).
84
87
  - **Records:** every step run's worker, times, end state, error, spend (tokens by kind, requests, cost, compiles),
@@ -1 +1 @@
1
- {"version":3,"file":"program-build.js","sourceRoot":"","sources":["../../../../src/definition/program-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAA4B,MAAM,QAAQ,CAAA;AAEhE,sHAAsH;AACtH,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAA8B;IACzG,IAAa,OAAO;QAClB,OAAO,6BAA6B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;IAC1D,CAAC;CACF;AAsBD,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAA+B,CAAC,cAAc,CAAC;CAAG"}
1
+ {"version":3,"file":"program-build.js","sourceRoot":"","sources":["../../../../src/definition/program-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAA4B,MAAM,QAAQ,CAAA;AAEhE,sHAAsH;AACtH,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAA8B;IACzG,IAAa,OAAO;QAClB,OAAO,6BAA6B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;IAC1D,CAAC;CACF;AAiCD,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAA+B,CAAC,cAAc,CAAC;CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jive-sh/workflow-platform",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Durable workflows in Convex: one workflow primitive with a task schema, queues on every line, workflow budgets, named end states, events and sub-workflows; worker processes run the steps.",
@@ -17,6 +17,12 @@ export interface ProgramBuildResult {
17
17
  readonly failure: Option.Option<string>
18
18
  }
19
19
 
20
+ /** Whether one function's unit compiles now, and the compiler's first error when it doesn't. */
21
+ export interface UnitCompiled {
22
+ readonly compiles: boolean
23
+ readonly error: Option.Option<string>
24
+ }
25
+
20
26
  /**
21
27
  * The interface a workflow's build step uses to build the program it works on: compile what changed, link it, and
22
28
  * publish the result where the organization serves it. The organization provides the implementation (which toolchain,
@@ -25,6 +31,11 @@ export interface ProgramBuildResult {
25
31
  */
26
32
  export interface IProgramBuild {
27
33
  build(input: { readonly changedFunctions: ReadonlyArray<string> }): Effect.fn.Return<ProgramBuildResult, ProgramBuildFailed>
34
+ /**
35
+ * Compiles the unit of the function at `address` from its source now, alone, against the program's headers, so a step
36
+ * learns whether that one function compiles without a whole build. The worker records it as one compile.
37
+ */
38
+ compileUnit(input: { readonly address: number }): Effect.fn.Return<UnitCompiled, ProgramBuildFailed>
28
39
  }
29
40
 
30
41
  export class ProgramBuild extends Context.Service<ProgramBuild, IProgramBuild>()("ProgramBuild") {}
@@ -0,0 +1,31 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { Effect, Option } from "effect"
3
+ import { type IProgramBuild, ProgramBuildFailed } from "../src/definition/program-build"
4
+ import { StepMeter } from "./step-meter"
5
+
6
+ /** A build whose whole-program builds compile three functions, and whose unit compiles always compile. */
7
+ const build: IProgramBuild = {
8
+ *build() {
9
+ return { linked: true, functions: { total: 3, compiled: 3, failing: 0, excluded: 0 }, failure: Option.none() }
10
+ },
11
+ *compileUnit() {
12
+ return yield* Effect.succeed({ compiles: true, error: Option.none() })
13
+ },
14
+ }
15
+
16
+ describe("a step's compiles", () => {
17
+ test("count a build's compiled functions and one for each unit compile", async () => {
18
+ const meter = new StepMeter()
19
+ const metered = meter.meteredProgramBuild(build)
20
+ const compiles = await Effect.runPromise(
21
+ Effect.gen(function* () {
22
+ yield* metered.build({ changedFunctions: [] })
23
+ yield* metered.compileUnit({ address: 0x401000 })
24
+ yield* metered.compileUnit({ address: 0x401200 })
25
+ return (yield* meter.measurements({ files: [], reported: {}, fingerprint: Option.none() })).spend.compiles
26
+ }),
27
+ )
28
+ expect(compiles).toBe(5)
29
+ expect(new ProgramBuildFailed({ cause: "x" }).message).toBe("the program build failed: x")
30
+ })
31
+ })
@@ -1,6 +1,6 @@
1
1
  import { Effect, Option } from "effect"
2
2
  import type { AgentRunInput, AgentRunResult, IAgentRunner } from "../src/definition/agent-runner"
3
- import type { IProgramBuild, ProgramBuildResult } from "../src/definition/program-build"
3
+ import type { IProgramBuild, ProgramBuildResult, UnitCompiled } from "../src/definition/program-build"
4
4
  import type { TaskFile } from "../src/graph"
5
5
  import { noSpend, type StepMeasurements, type StepSpend } from "../src/graph"
6
6
 
@@ -36,6 +36,11 @@ export class StepMeter {
36
36
  meter.spend = { ...meter.spend, compiles: meter.spend.compiles + result.functions.compiled }
37
37
  return result
38
38
  },
39
+ *compileUnit(input: { readonly address: number }) {
40
+ const result: UnitCompiled = yield* inner.compileUnit(input)
41
+ meter.spend = { ...meter.spend, compiles: meter.spend.compiles + 1 }
42
+ return result
43
+ },
39
44
  }
40
45
  }
41
46