@cobol-ts/cobolts 0.0.14 → 0.0.16

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.
Files changed (188) hide show
  1. package/README.benchmark-formats.md +52 -0
  2. package/README.benchmark-reporting.md +16 -0
  3. package/README.benchmark.md +199 -0
  4. package/README.cel.md +112 -57
  5. package/README.md +166 -19
  6. package/README.periodic-verification.md +83 -0
  7. package/dist/src/benchmark.access.spec.d.ts +1 -0
  8. package/dist/src/benchmark.access.spec.js +30 -0
  9. package/dist/src/benchmark.access.spec.js.map +1 -0
  10. package/dist/src/benchmark.aggregate.fixture.d.ts +10 -0
  11. package/dist/src/benchmark.aggregate.fixture.js +108 -0
  12. package/dist/src/benchmark.aggregate.fixture.js.map +1 -0
  13. package/dist/src/benchmark.aggregate.fixture.spec.d.ts +1 -0
  14. package/dist/src/benchmark.aggregate.fixture.spec.js +116 -0
  15. package/dist/src/benchmark.aggregate.fixture.spec.js.map +1 -0
  16. package/dist/src/benchmark.allocations.cli.spec.d.ts +1 -0
  17. package/dist/src/benchmark.allocations.cli.spec.js +60 -0
  18. package/dist/src/benchmark.allocations.cli.spec.js.map +1 -0
  19. package/dist/src/benchmark.allocations.d.ts +19 -0
  20. package/dist/src/benchmark.allocations.js +82 -0
  21. package/dist/src/benchmark.allocations.js.map +1 -0
  22. package/dist/src/benchmark.allocations.spec.d.ts +1 -0
  23. package/dist/src/benchmark.allocations.spec.js +64 -0
  24. package/dist/src/benchmark.allocations.spec.js.map +1 -0
  25. package/dist/src/benchmark.cli.functional.spec.d.ts +1 -0
  26. package/dist/src/benchmark.cli.functional.spec.js +370 -0
  27. package/dist/src/benchmark.cli.functional.spec.js.map +1 -0
  28. package/dist/src/benchmark.cli.golden.spec.d.ts +1 -0
  29. package/dist/src/benchmark.cli.golden.spec.js +194 -0
  30. package/dist/src/benchmark.cli.golden.spec.js.map +1 -0
  31. package/dist/src/benchmark.composed.execution.spec.d.ts +1 -0
  32. package/dist/src/benchmark.composed.execution.spec.js +120 -0
  33. package/dist/src/benchmark.composed.execution.spec.js.map +1 -0
  34. package/dist/src/benchmark.composed.fixture.d.ts +4 -0
  35. package/dist/src/benchmark.composed.fixture.js +77 -0
  36. package/dist/src/benchmark.composed.fixture.js.map +1 -0
  37. package/dist/src/benchmark.composed.fixture.spec.d.ts +1 -0
  38. package/dist/src/benchmark.composed.fixture.spec.js +50 -0
  39. package/dist/src/benchmark.composed.fixture.spec.js.map +1 -0
  40. package/dist/src/benchmark.composed.runner.d.ts +13 -0
  41. package/dist/src/benchmark.composed.runner.js +221 -0
  42. package/dist/src/benchmark.composed.runner.js.map +1 -0
  43. package/dist/src/benchmark.composed.two.fixture.d.ts +5 -0
  44. package/dist/src/benchmark.composed.two.fixture.js +111 -0
  45. package/dist/src/benchmark.composed.two.fixture.js.map +1 -0
  46. package/dist/src/benchmark.composed.two.spec.d.ts +1 -0
  47. package/dist/src/benchmark.composed.two.spec.js +86 -0
  48. package/dist/src/benchmark.composed.two.spec.js.map +1 -0
  49. package/dist/src/benchmark.format.cli.functional.spec.d.ts +1 -0
  50. package/dist/src/benchmark.format.cli.functional.spec.js +44 -0
  51. package/dist/src/benchmark.format.cli.functional.spec.js.map +1 -0
  52. package/dist/src/benchmark.format.composition.spec.d.ts +1 -0
  53. package/dist/src/benchmark.format.composition.spec.js +196 -0
  54. package/dist/src/benchmark.format.composition.spec.js.map +1 -0
  55. package/dist/src/benchmark.format.family.cli.functional.spec.d.ts +1 -0
  56. package/dist/src/benchmark.format.family.cli.functional.spec.js +102 -0
  57. package/dist/src/benchmark.format.family.cli.functional.spec.js.map +1 -0
  58. package/dist/src/benchmark.format.fixture.d.ts +26 -0
  59. package/dist/src/benchmark.format.fixture.js +181 -0
  60. package/dist/src/benchmark.format.fixture.js.map +1 -0
  61. package/dist/src/benchmark.format.oracle.d.ts +8 -0
  62. package/dist/src/benchmark.format.oracle.js +30 -0
  63. package/dist/src/benchmark.format.oracle.js.map +1 -0
  64. package/dist/src/benchmark.format.runner.d.ts +6 -0
  65. package/dist/src/benchmark.format.runner.js +271 -0
  66. package/dist/src/benchmark.format.runner.js.map +1 -0
  67. package/dist/src/benchmark.format.source.d.ts +6 -0
  68. package/dist/src/benchmark.format.source.js +15 -0
  69. package/dist/src/benchmark.format.source.js.map +1 -0
  70. package/dist/src/benchmark.format.spec.d.ts +1 -0
  71. package/dist/src/benchmark.format.spec.js +85 -0
  72. package/dist/src/benchmark.format.spec.js.map +1 -0
  73. package/dist/src/benchmark.format.stateful.spec.d.ts +1 -0
  74. package/dist/src/benchmark.format.stateful.spec.js +120 -0
  75. package/dist/src/benchmark.format.stateful.spec.js.map +1 -0
  76. package/dist/src/benchmark.gc.d.ts +26 -0
  77. package/dist/src/benchmark.gc.js +62 -0
  78. package/dist/src/benchmark.gc.js.map +1 -0
  79. package/dist/src/benchmark.gc.spec.d.ts +1 -0
  80. package/dist/src/benchmark.gc.spec.js +26 -0
  81. package/dist/src/benchmark.gc.spec.js.map +1 -0
  82. package/dist/src/benchmark.periodic.execution.spec.d.ts +1 -0
  83. package/dist/src/benchmark.periodic.execution.spec.js +166 -0
  84. package/dist/src/benchmark.periodic.execution.spec.js.map +1 -0
  85. package/dist/src/benchmark.periodic.fixture.d.ts +5 -0
  86. package/dist/src/benchmark.periodic.fixture.js +69 -0
  87. package/dist/src/benchmark.periodic.fixture.js.map +1 -0
  88. package/dist/src/benchmark.periodic.fixture.spec.d.ts +1 -0
  89. package/dist/src/benchmark.periodic.fixture.spec.js +96 -0
  90. package/dist/src/benchmark.periodic.fixture.spec.js.map +1 -0
  91. package/dist/src/benchmark.profile.d.ts +8 -0
  92. package/dist/src/benchmark.profile.js +62 -0
  93. package/dist/src/benchmark.profile.js.map +1 -0
  94. package/dist/src/benchmark.profile.spec.d.ts +1 -0
  95. package/dist/src/benchmark.profile.spec.js +65 -0
  96. package/dist/src/benchmark.profile.spec.js.map +1 -0
  97. package/dist/src/benchmark.report.d.ts +113 -0
  98. package/dist/src/benchmark.report.js +279 -0
  99. package/dist/src/benchmark.report.js.map +1 -0
  100. package/dist/src/benchmark.report.spec.d.ts +1 -0
  101. package/dist/src/benchmark.report.spec.js +271 -0
  102. package/dist/src/benchmark.report.spec.js.map +1 -0
  103. package/dist/src/benchmark.runner.d.ts +74 -0
  104. package/dist/src/benchmark.runner.js +371 -0
  105. package/dist/src/benchmark.runner.js.map +1 -0
  106. package/dist/src/benchmark.runner.spec.d.ts +1 -0
  107. package/dist/src/benchmark.runner.spec.js +241 -0
  108. package/dist/src/benchmark.runner.spec.js.map +1 -0
  109. package/dist/src/benchmark.strategy.spec.d.ts +1 -0
  110. package/dist/src/benchmark.strategy.spec.js +66 -0
  111. package/dist/src/benchmark.strategy.spec.js.map +1 -0
  112. package/dist/src/cel.composition.integration.spec.d.ts +1 -0
  113. package/dist/src/cel.composition.integration.spec.js +110 -0
  114. package/dist/src/cel.composition.integration.spec.js.map +1 -0
  115. package/dist/src/cel.entity.d.ts +12 -0
  116. package/dist/src/cel.entity.js +98 -0
  117. package/dist/src/cel.entity.js.map +1 -0
  118. package/dist/src/cel.entity.spec.d.ts +1 -0
  119. package/dist/src/cel.entity.spec.js +82 -0
  120. package/dist/src/cel.entity.spec.js.map +1 -0
  121. package/dist/src/cel.evaluate.cli.spec.d.ts +1 -0
  122. package/dist/src/cel.evaluate.cli.spec.js +63 -0
  123. package/dist/src/cel.evaluate.cli.spec.js.map +1 -0
  124. package/dist/src/cel.evaluate.integration.spec.d.ts +1 -0
  125. package/dist/src/cel.evaluate.integration.spec.js +128 -0
  126. package/dist/src/cel.evaluate.integration.spec.js.map +1 -0
  127. package/dist/src/cel.integration.spec.js +227 -38
  128. package/dist/src/cel.integration.spec.js.map +1 -1
  129. package/dist/src/cel.result.ownership.spec.d.ts +1 -0
  130. package/dist/src/cel.result.ownership.spec.js +52 -0
  131. package/dist/src/cel.result.ownership.spec.js.map +1 -0
  132. package/dist/src/cel.shared.execution.d.ts +20 -0
  133. package/dist/src/cel.shared.execution.js +49 -0
  134. package/dist/src/cel.shared.execution.js.map +1 -0
  135. package/dist/src/cel.stats.d.ts +5 -0
  136. package/dist/src/cel.stats.js +73 -0
  137. package/dist/src/cel.stats.js.map +1 -0
  138. package/dist/src/cel.stats.spec.d.ts +1 -0
  139. package/dist/src/cel.stats.spec.js +85 -0
  140. package/dist/src/cel.stats.spec.js.map +1 -0
  141. package/dist/src/cli.integration.spec.js +14 -2
  142. package/dist/src/cli.integration.spec.js.map +1 -1
  143. package/dist/src/cli.js +8 -0
  144. package/dist/src/cli.js.map +1 -1
  145. package/dist/src/cli.spec.js +46 -6
  146. package/dist/src/cli.spec.js.map +1 -1
  147. package/dist/src/commands/benchmark.d.ts +3 -0
  148. package/dist/src/commands/benchmark.js +300 -0
  149. package/dist/src/commands/benchmark.js.map +1 -0
  150. package/dist/src/commands/cel.d.ts +1 -1
  151. package/dist/src/commands/cel.js +38 -5
  152. package/dist/src/commands/cel.js.map +1 -1
  153. package/dist/src/commands/characteristics.d.ts +3 -0
  154. package/dist/src/commands/characteristics.js +57 -0
  155. package/dist/src/commands/characteristics.js.map +1 -0
  156. package/dist/src/commands/characteristics.spec.d.ts +1 -0
  157. package/dist/src/commands/characteristics.spec.js +109 -0
  158. package/dist/src/commands/characteristics.spec.js.map +1 -0
  159. package/dist/src/commands/config.validate.js +8 -4
  160. package/dist/src/commands/config.validate.js.map +1 -1
  161. package/dist/src/commands/extract.d.ts +14 -0
  162. package/dist/src/commands/extract.js +85 -0
  163. package/dist/src/commands/extract.js.map +1 -0
  164. package/dist/src/commands/extract.spec.d.ts +1 -0
  165. package/dist/src/commands/extract.spec.js +179 -0
  166. package/dist/src/commands/extract.spec.js.map +1 -0
  167. package/dist/src/commands/periodicity.d.ts +3 -0
  168. package/dist/src/commands/periodicity.js +11 -0
  169. package/dist/src/commands/periodicity.js.map +1 -0
  170. package/dist/src/commands/validate.all.d.ts +7 -0
  171. package/dist/src/commands/validate.all.integration.spec.d.ts +1 -0
  172. package/dist/src/commands/validate.all.integration.spec.js +43 -0
  173. package/dist/src/commands/validate.all.integration.spec.js.map +1 -0
  174. package/dist/src/commands/validate.all.js +75 -0
  175. package/dist/src/commands/validate.all.js.map +1 -0
  176. package/dist/src/commands/validate.all.spec.d.ts +1 -0
  177. package/dist/src/commands/validate.all.spec.js +70 -0
  178. package/dist/src/commands/validate.all.spec.js.map +1 -0
  179. package/dist/src/context.d.ts +37 -6
  180. package/dist/src/context.js +574 -21
  181. package/dist/src/context.js.map +1 -1
  182. package/dist/src/indexed.accumulator.d.ts +18 -0
  183. package/dist/src/indexed.accumulator.js +102 -0
  184. package/dist/src/indexed.accumulator.js.map +1 -0
  185. package/dist/src/indexed.accumulator.spec.d.ts +1 -0
  186. package/dist/src/indexed.accumulator.spec.js +74 -0
  187. package/dist/src/indexed.accumulator.spec.js.map +1 -0
  188. package/package.json +24 -11
@@ -0,0 +1,52 @@
1
+ # Single-file format benchmark
2
+
3
+ Five generated benchmark projects use the **same logical rows** and **the same CEL graph**. The physical `input` format can be COBOL, CSV, JSONL, schema-first Protobuf or Indexed Graph State. The accumulator strategy is configured independently in `.cobolts/accumulator.yaml`: `indexed` executes directly against pooled numeric slots (default for these generated projects); `object` retains the previous copy-based executor for a baseline. The Indexed Graph State input file is not the historical accumulator file.
4
+
5
+ The four logical fields are `customerId` (an ordered positive integer), `amountA` and `amountB` (nonnegative integers), and `statusCode` (`A`/`B`). The generator writes **one input record per customer**, with strictly increasing customer IDs and identical logical rows across all five formats. Every graph node reads its own previously accumulated value and updates it, and the first node of each block of ten additionally depends on the preceding block. The graph has either **10 or 1,000 nodes**. The graph-node integer expressions use CEL bigint semantics across formats; the **entity keys used by the indexed merge** use safe-integer JavaScript `number` as configured in `accumulator.yaml`. These are independent choices.
6
+
7
+ Each generated project includes **a separate historical accumulator file** at `data/previous-state.igs`, using the schema of its graph. Every even-numbered customer has existing state (each node starts at 100); odd-numbered customers must acquire new state from the pool (each node starts at 0). This tests the merge-join, history decoding, and per-customer state isolation. Each customer is evaluated exactly once, using its own historical value or a newly acquired pooled record. The historical input is never rewritten during benchmark passes.
8
+
9
+ ## Initialise the five files (PowerShell, repository root)
10
+
11
+ ```powershell
12
+ yarn cobolts benchmark init formats
13
+ ```
14
+
15
+ The family defaults to **10,000 records and a 10-node graph**, with **three measured runs**, in each of the five projects. To change the sizes or select a subset:
16
+
17
+ ```powershell
18
+ yarn cobolts benchmark init formats -n 10000 --graph-nodes 1000 --force
19
+ yarn cobolts benchmark init formats --formats csv,jsonl -n 5000
20
+ ```
21
+
22
+ Each project has `.cobolts/files.yaml`, `data.yaml`, `benchmark.yaml`, `accumulator.yaml`, an **identical** `graph.yaml` and one physical data file. The generated accumulator configuration requires the accompanying historical file at `../data/previous-state.igs`; it is generated alongside the input data. The files are local generated artefacts and ignored by Git. The graph definition and fixture algorithm live in the CLI source. To replace local projects, append `--force` to the `init` commands; this overwrites existing generated files.
23
+
24
+ ## Verify all rows first
25
+
26
+ ```powershell
27
+ yarn cobolts benchmark verify formats
28
+ ```
29
+
30
+ To verify only some formats, use the same selection as initialisation: `yarn cobolts benchmark verify formats --formats csv,jsonl`. Verification fails if any selected generated project is missing or invalid; it does not silently skip a format.
31
+
32
+ Verification checks **every input record** and **every calculated graph-node value on every record**, using an independent arithmetic oracle. Both object and indexed strategies are checked, including the existing state of even customers and fresh pooled state for odd customers. The output reports graph-node count, record count, distinct customers and expected historical matches (one input record per customer). Any mismatch fails with the customer, record and node. Benchmark `run` performs a **21-record preflight**, exercising both historical matches and missing customers before timing. Verification is excluded from throughput results.
33
+
34
+ ## Run the same workload against all five
35
+
36
+ ```powershell
37
+ yarn cobolts benchmark run formats --runs 3
38
+ ```
39
+
40
+ To run a subset: `yarn cobolts benchmark run formats --formats csv,jsonl --runs 3`. The existing `-n`, `--modes`, `--json`, `--gc` and profiling options also work with the family. `run` does not regenerate data; use `init formats --force` when changing the physical fixture size.
41
+
42
+ Each project prints a `WORKLOAD` line with accumulator strategy, compiled node count, customer count and historical matches, then reports throughput in records/second (read-only and with CEL), with CEL execution time in µs/record as a diagnostic; the CLI prints a cross-format `ALL SUMMARY` that also includes projected-field throughput when `project` is selected. By default the generated projects use the indexed executor. For a comparison using the previous plain-object accumulator, pass `--accumulator-strategy object`. **Both strategies invoke the same composed production execution path and preserve the historical-state join.** Object and indexed execution select the existing production graph implementation; neither uses a format-specific graph loop. The previous-state file remains read-only, and each pass starts from the same historical state. Each measured pass consumes the first and last calculated node values for every customer into a **state digest**, which must agree across runs, input formats and accumulator strategies. The digest appears in the individual summary and JSON passes. No accumulator output is written. To isolate physical format costs, compare like-for-like accumulator strategies.
43
+
44
+ Optional `--modes "read,project,cel"` measures compiled scalar-field access as a separate pass on all five formats. For the format suite, `project` means visiting the same configured fields using prepared **physical field accessors**. This is intentionally not the legacy COBOL-specific projected-view traversal, and should not be compared directly with the old `project` mode's cost. GC, JSON reporting and CPU/allocation profiling use the existing benchmark CLI flags.
45
+
46
+ To compare large graphs, use `benchmark init formats --graph-nodes 1000 --force` (add `-n` if the record count should change), then rerun `verify formats` and `run formats`. Do not compare absolute timings from a 10-node project with those from a 1,000-node project or with the older ODO/map benchmark: the work is deliberately different.
47
+
48
+ ## Limitations
49
+
50
+ This initial comparison is scalar-only. It does not benchmark nested records, arrays, variable-length COBOL or joined files, and therefore is not a universal ranking of the formats. COBOL, CSV, JSONL and indexed-state batch readers use synchronous leased cursors and pooled-buffer refills. Protobuf currently retains an asynchronous file adapter. Read-only differences therefore include both format/decoding and I/O/adapter costs; they should not be attributed solely to the physical encoding. Protobuf uses a schema-first message decoder and Indexed Graph State decodes into numeric slots, matching their current implemented reader designs. File sizes can differ substantially; the read-only pass deliberately includes physical decoding and I/O. No result should be interpreted as a difference in CEL computation because the expressions and accumulator semantics are fixed.
51
+
52
+ `benchmark init` without a name retains its standard-project selection, while `benchmark init all` includes all 21 registered projects (including periodic and composed fixtures). `benchmark init formats`, `benchmark verify formats` and `benchmark run formats` are explicit family selections, not aliases for every benchmark in the repository. The `--formats` option is only valid with those family commands. Individual `format-csv` (etc.) commands remain available.
@@ -0,0 +1,16 @@
1
+ # Benchmark reporting
2
+
3
+ `cobolts benchmark run <directory>` displays per-pass loader throughput and complete-pipeline throughput in records/second, as well as loader, CEL and total time in nanoseconds per record.
4
+
5
+ The summary reports medians over the measured passes and the observed range of run-average CEL execution times. The difference between integrated and loader-only throughput is not attributed solely to CEL; the passes are measured independently.
6
+
7
+ For machine-readable output:
8
+
9
+ ```sh
10
+ cobolts benchmark run benchmarks/baseline --json
11
+ cobolts benchmark run benchmarks --all --json
12
+ ```
13
+
14
+ The first command emits a single JSON report. The second emits an array of reports. Both contain unrounded measurements in milliseconds, records/second and nanoseconds/record. The text presentation is rounded for readability.
15
+
16
+ The report is derived from the existing measurements and does not introduce additional timers into record processing.
@@ -0,0 +1,199 @@
1
+ # COBOL-TS benchmarks
2
+
3
+ The benchmark CLI measures input scanning, projection traversal and compiled CEL graph execution. Each benchmark project is a directory containing a `.cobolts/benchmark.yaml` and its corresponding data, file catalogue and (for graph projects) graph and accumulator configuration.
4
+
5
+ ## Quick start
6
+
7
+ Run from `C:\git\cobol-ts` in PowerShell. Build the workspace first so each package's `dist/` entry point exists.
8
+
9
+ ```powershell
10
+ yarn cobolts benchmark list
11
+ yarn cobolts benchmark init all --force
12
+ yarn cobolts benchmark init formats -n 10000 --graph-nodes 1000 --force
13
+ yarn cobolts benchmark composition verify format-composed-two -n 10000
14
+ yarn cobolts benchmark composition run format-composed-two -n 10000 --runs 5 --accumulator-strategy indexed
15
+ ```
16
+
17
+ `benchmark init all --force` regenerates **all 21 registered projects**: 13 standard/graph, `graph-1000-periodic`, five physical-format projects and two composed projects. `benchmark list` shows the same complete set. Without `-n`, defaults are 1,000,000 records for standard/graph projects and 10,000 for periodic, format and composed projects. An omitted name still initialises only standard projects. `init ... --force` **overwrites generated benchmark projects**. Do not use it after editing fixtures unless those edits may be discarded. `run -n` never generates data; the configured files must already contain enough records.
18
+
19
+ ## Which benchmark should I run?
20
+
21
+ | Command | Workload | Main question |
22
+ | --- | --- | --- |
23
+ | `benchmark run format-indexed-graph-state -n 10000 --runs 5 --modes "read,cel" --accumulator-strategy indexed` | One physical input plus sorted historical accumulator, 1,000 graph nodes in the generated fixture | How fast is indexed graph execution for this single-source workload? |
24
+ | `benchmark composition run format-composed-two -n 10000 --runs 5 --accumulator-strategy indexed` | **Two physical files**: a COBOL customer master and a CSV account stream, with direct `manyOptional` matching and historical accumulator | What is the cost of joining two presorted physical streams and evaluating 1,000 graph nodes? |
25
+ | `benchmark composition run -n 10000 --runs 5 --accumulator-strategy indexed` | Five physical source formats, an explicit CSV relationship map, optional one-to-many records and historical accumulator | What is the total composed customer throughput? |
26
+ | `benchmark run graph-1000 -n 10000 --runs 5 --modes "read,cel" --accumulator-strategy indexed` | Legacy COBOL graph fixture, retaining one accumulator across input records | How does the older graph fixture run on the indexed executor? |
27
+
28
+ These **are different workloads**. The legacy `graph-1000` project does not model the same per-customer historical-state join as the generated format or composition projects. Do not interpret throughput differences between them as the cost of one particular data format or accumulator implementation.
29
+
30
+ ### Two-file benchmark
31
+
32
+ `benchmark init formats` now also generates `benchmarks/format-composed-two`. Its `files.yaml` defines exactly **two** physical sources and **no relationship-mapping file**. The COBOL customer master is keyed by `customerId`; the CSV account stream is also keyed by `customerId`, with 0 or 2 rows per customer (1 for the last customer if the generated count is odd). The source file remains on disk and is read by the normal configured CSV cursor through the YAML composition. All records are already sorted by customer ID.
33
+
34
+ ```powershell
35
+ yarn cobolts benchmark init formats -n 10000 --graph-nodes 1000 --force
36
+ yarn cobolts benchmark composition verify format-composed-two -n 10000
37
+ yarn cobolts benchmark composition run format-composed-two -n 10000 --runs 5 --accumulator-strategy indexed
38
+ ```
39
+
40
+ The previously existing `format-composed` five-source, mapped-relationship benchmark remains available as `benchmark composition run format-composed`. The general `benchmark run graph-1000` still measures its original single physical COBOL input: **do not treat it as a two-file composition**. Both composed benchmarks execute the same number of graph nodes, but their expressions and input workloads differ.
41
+
42
+ The timed composition pass includes source scanning, the merge, the historical accumulator join, and CEL. It does not isolate the incremental cost of just the join; compare the same two-file fixture with different accumulator strategies, or separately instrument its stages if that distinction is needed.
43
+
44
+ For a fair object-versus-indexed comparison, run the **same project** twice, changing only `--accumulator-strategy`:
45
+
46
+ ```powershell
47
+ yarn cobolts benchmark run format-indexed-graph-state -n 10000 --runs 5 --modes "read,cel" --accumulator-strategy object
48
+ yarn cobolts benchmark run format-indexed-graph-state -n 10000 --runs 5 --modes "read,cel" --accumulator-strategy indexed
49
+ ```
50
+
51
+ Verify the fixtures before drawing conclusions:
52
+
53
+ ```powershell
54
+ yarn cobolts benchmark composition verify -n 10000
55
+ yarn cobolts benchmark verify format-indexed-graph-state
56
+ ```
57
+
58
+ ## Choosing the accumulator
59
+
60
+ The benchmark's CEL pass uses the same composition, planner, graph executor, and historical accumulator handling as `cel execute`. The normal project configuration is authoritative: `.cobolts/files.yaml`, `graph.yaml` and (when present) `accumulator.yaml`. One-file projects use a one-file composition. There is no second benchmark graph.
61
+
62
+ Generated benchmark `accumulator.yaml` files now select `customerId.type: number`
63
+ for the entity-key representation, independently of the graph node numeric types.
64
+ Existing generated projects retain their old YAML until reinitialised with `--force`
65
+ or edited manually; the historical `.igs` wire format is still signed int64.
66
+
67
+ `--accumulator-strategy indexed|object` selects the execution strategy for a benchmark pass. Without a CLI override, generated standard benchmarks use `indexed`; the format family uses `indexed` by default. The option changes the strategy of the **same composed operation**, not its graph, input records or history.
68
+
69
+ Read-only and projection passes are separate physical-input diagnostics. They do not run the graph and should not be interpreted as timings of the composed merge.
70
+
71
+ ## Understanding measurements
72
+
73
+ The report includes separate **read** and **with CEL** passes. They are independent scans, not additive stages of a single scan. `CEL ns/rec` is the time measured around graph execution per record; it includes per-record accumulator handling and is **not** the exclusive time spent running CEL expressions. `TOTAL ns/rec` and `WITH CEL rec/s` include other pipeline work. The **integrated** elapsed measurement includes composition setup, graph compilation and JSON result serialisation, just as normal CLI execution does, but discards the emitted lines rather than printing them. `CEL ns/rec` is timed at the actual graph-execution calls. Consequently, these timings supersede historical direct-file benchmark results and should not be compared with them as though they measured the same workload.
74
+
75
+ For a 1,000-node graph, dividing `CEL ns/rec` by 1,000 gives an **amortised** time per node (including the measured surrounding overhead); it is not a direct per-node stopwatch measurement.
76
+
77
+ The report shows medians across runs, and may show averages and ranges. Warm-up is performed before measured passes. Prefer several runs with no other significant workload, and compare medians and distributions rather than individual passes. Profiling and detailed graph timing change measurement overhead; use unprofiled runs for throughput claims.
78
+
79
+ ## Other useful options
80
+
81
+ ```powershell
82
+ # Projection traversal (separate from read-only and CEL passes)
83
+ yarn cobolts benchmark run graph-1000 -n 10000 --runs 5 --modes "read,project,cel"
84
+
85
+ # A matching 1,000-node scalar control (no map/reduce):
86
+ # First generate it, then run it with identical record counts and options.
87
+ yarn cobolts benchmark init graph-1000-no-map -n 100000
88
+ yarn cobolts benchmark run graph-1000-no-map -n 100000 --runs 5 --modes "read,cel" --accumulator-strategy indexed
89
+
90
+ # Three diagnostic benchmarks, each with 1,000 nodes and identical generated records:
91
+ # A: constant CEL; B: now-chain + arithmetic; C: input/conditional scalar control.
92
+ yarn cobolts benchmark init graph-1000-constant -n 10000
93
+ yarn cobolts benchmark init graph-1000-chain -n 10000
94
+ yarn cobolts benchmark init graph-1000-input -n 10000
95
+ yarn cobolts benchmark run graph-1000-constant -n 10000 --runs 5 --gc
96
+ yarn cobolts benchmark run graph-1000-chain -n 10000 --runs 5 --gc
97
+ yarn cobolts benchmark run graph-1000-input -n 10000 --runs 5 --gc
98
+
99
+ # Investigate GC (adds overhead)
100
+ yarn cobolts benchmark run graph-1000 -n 10000 --runs 5 --gc
101
+
102
+ # Graph generation timing, sampled every 100 records
103
+ yarn cobolts benchmark run graph-1000 -n 10000 --runs 3 --graph-timing --timing-sample-every 100
104
+
105
+ # CPU sampling profile; not for comparable throughput numbers
106
+ yarn cobolts benchmark run graph-1000 -n 10000 --runs 1 --cpu-profile
107
+
108
+ # JSON report for reproducible analysis
109
+ yarn cobolts benchmark run graph-1000 -n 10000 --runs 5 --json
110
+ ```
111
+
112
+ Options on `benchmark run` include `-n/--records`, `-r/--runs`, `--modes`, `--accumulator-strategy`, `--json`, `--gc`, `--graph-timing`, `--timing-sample-every`, `--cpu-profile`, `--allocation-profile` and `--profile-mode`. `benchmark composition run` is a separate command and has its own narrower options.
113
+
114
+ ## Correctness and limitations
115
+
116
+ `benchmark composition verify` checks every generated graph node against independently calculated expected values, including the mapped one-to-many relationship and both accumulator implementations. The single-format verifier does likewise for its generated format workload. The older `benchmark verify graph-1000` checks the generated data pattern and size; it is **not** an independent all-node oracle for its legacy graph.
117
+
118
+ Synthetic fixtures are deliberately regular and presorted. These timings do not predict production throughput with different graph expressions, skewed relationship cardinalities, varying record sizes or storage. In particular, the future material-change planner ('only update if changed') is not being measured here.
119
+
120
+ ## Check functional execution before measuring timings
121
+
122
+ All generated benchmarks are ordinary composed COBOL-TS projects. For the
123
+ standard and single-format projects, the composition has one physical input;
124
+ `format-composed` and `format-composed-two` use multiple inputs. Check the
125
+ composition in each project's `.cobolts/files.yaml` and validate it:
126
+
127
+ ```powershell
128
+ yarn cobolts -d benchmarks validate all
129
+ yarn cobolts -d benchmarks/baseline config files
130
+ yarn cobolts -d benchmarks/baseline cel validate
131
+ yarn cobolts -d benchmarks/baseline cel execute --count 1 --raw
132
+ yarn cobolts -d benchmarks/baseline cel evaluate 1 --debug
133
+ ```
134
+
135
+ The `benchmark.cli.golden.spec.ts` functional suite exercises all four graph
136
+ inspection stages, validation, normal execution and selected-entity evaluation
137
+ through Commander. The benchmark runner's CEL pass delegates to that same
138
+ production execution service. All benchmark generators emit only
139
+ `.cobolts/graph.yaml`; no `benchmark.graph.yaml` is created. The tests
140
+ require checked-in, reviewed golden outputs as well as independent calculation
141
+ checks. Run the verification suites before timing.
142
+
143
+ ## Mixed daily/monthly rolling-window benchmark
144
+
145
+ `graph-1000-periodic` is included in `benchmark list` and `benchmark init all`.
146
+ It can also be initialised individually. The periodic default is 10,000
147
+ customers; an explicit `-n` on `init all` applies to this project too.
148
+ Its generated `.cobolts/accumulator.yaml` explicitly declares:
149
+
150
+ ```yaml
151
+ customerId:
152
+ field: recordId
153
+ type: number
154
+ ```
155
+
156
+ This selects safe-integer numeric IDs for the indexed merge.
157
+
158
+ ```powershell
159
+ yarn cobolts benchmark init graph-1000-periodic -n 10000
160
+ yarn cobolts benchmark run graph-1000-periodic -n 10000 --runs 5 --periodicity daily --accumulator-strategy indexed
161
+ yarn cobolts benchmark run graph-1000-periodic -n 10000 --runs 5 --periodicity monthly --accumulator-strategy indexed
162
+ ```
163
+
164
+ The graph contains exactly **1,000 nodes**: 100 daily scalar counters (`prev` + 1,
165
+ reset to canonical zero after a monthly run), 100 monthly rolling windows of
166
+ six logical months/seven physical slots, 100 CEL sums of those windows, and
167
+ 700 ordinary scalars. Of the ordinary scalars, 70 add 1 to a dependent monthly
168
+ sum; 630 read an input field. Every customer starts with **seven** persisted
169
+ monthly observations (one expired, six active), daily counters of 31–35, and
170
+ persisted window sums of 27. Thus a monthly run advances a full ring and its
171
+ sum, while a daily run increments only the daily counters. Reset occurs **after**
172
+ all monthly CEL evaluations, without downstream propagation.
173
+
174
+ The two commands are *separate comparative workloads*: every benchmark pass
175
+ reloads the same unchanged historical input file. Running the daily command
176
+ and then the monthly command does **not** commit the daily results as the
177
+ monthly command's input. The fixture is seeded to simulate that prior daily
178
+ history and to exercise both behaviours independently. As before, no period
179
+ identity or once-only replay protection is implemented by this benchmark.
180
+
181
+ ## Native aggregate workload (1,000 graph nodes)
182
+
183
+ The `graph-1000-aggregates` workload consists of 100 daily 7-period windows
184
+ (each with one native sum), 100 monthly 6-period windows (each with a native
185
+ sum and max), and 500 downstream CEL nodes summing the three aggregate outputs.
186
+ It starts from a **persisted, populated** indexed accumulator: daily sums are 28,
187
+ monthly sums 210, monthly maxima 60, and combined results 298. This ensures the
188
+ measured run exercises incremental transitions rather than first-use bootstrap.
189
+
190
+ ```sh
191
+ yarn cobolts benchmark init graph-1000-aggregates -n 10000
192
+ yarn cobolts benchmark run graph-1000-aggregates -n 10000 --runs 5 --periodicity daily --accumulator-strategy indexed
193
+ yarn cobolts benchmark run graph-1000-aggregates -n 10000 --runs 5 --periodicity monthly --accumulator-strategy indexed
194
+ ```
195
+
196
+ Every pass reloads the same committed fixture; daily and monthly numbers should
197
+ be compared separately. The 500 downstream nodes are intentionally shared
198
+ consumers, so measurements include graph propagation as well as native aggregate
199
+ arithmetic. Use `--gc` or `--allocation-profile` to inspect memory behaviour.
package/README.cel.md CHANGED
@@ -1,74 +1,129 @@
1
1
  # CEL dependency graph commands
2
2
 
3
- `cobolts cel` is a command group. It does not execute a graph by itself.
4
- The graph is loaded from the discovered `.cobolts/graph.yaml` by default.
5
- All inspection commands accept `--graph <filename>` to select another YAML
6
- file relative to `.cobolts`.
3
+ The normal CLI execution path uses a composition in `.cobolts/files.yaml`.
4
+ A composition may contain just one physical file. Every source declares its
5
+ entity key with `key` and `keyPath`; the master determines the entity selected
6
+ by `cel evaluate`. Encoding and framing are properties of each COBOL source.
7
+ Neither `generation.yaml` nor generated TypeScript is required for CEL execution.
7
8
 
8
- From the example project:
9
+ From the monorepo root:
9
10
 
10
11
  ```powershell
11
- cobolts -d modules/examples/example/definitions cel graph
12
- cobolts -d modules/examples/example/definitions cel canonical
13
- cobolts -d modules/examples/example/definitions cel sorted
14
- cobolts -d modules/examples/example/definitions cel validate
15
- cobolts -d modules/examples/example/definitions cel validate customers
16
- cobolts -d modules/examples/example/definitions cel execute customers --count 3 --raw
12
+ yarn cobolts -d modules/examples/example/definitions cel graph --short
13
+ yarn cobolts -d modules/examples/example/definitions cel canonical --short
14
+ yarn cobolts -d modules/examples/example/definitions cel sorted --short
15
+ yarn cobolts -d modules/examples/example/definitions cel planned --short
16
+ yarn cobolts -d modules/examples/example/definitions cel validate
17
+ yarn cobolts -d modules/examples/example/definitions cel execute --count 1 --raw
18
+ yarn cobolts -d modules/examples/example/definitions cel evaluate 1001 --debug
17
19
  ```
18
20
 
19
- `graph` prints the parsed authoring graph as pretty JSON in YAML key order.
20
- `canonical` prints the normalised, unsorted canonical node array. This has
21
- normalised CEL text, node names in metadata and inferred/declared dependencies.
22
- `sorted` prints **full canonical nodes** as pretty JSON, grouped under
23
- `generations`. Nodes in the same generation are independent and may be
24
- evaluated together. This is the existing topological sorter, not a separate
25
- ordering algorithm. Inspection doesn't open data records.
26
-
27
- `validate` checks YAML structure, CEL parsing, unknown current-node references
28
- and dependency cycles. `validate customers` also prepares the configured
29
- customer copybook and compiles all CEL node accessors to check projected field
30
- names and types without scanning customer records. Errors identify the file
31
- for YAML parsing problems and the node for CEL/graph problems. YAML syntax
32
- errors also carry parser location information; semantic errors are attributed
33
- to nodes, not guaranteed to have a YAML character position.
34
-
35
- `execute` reuses the existing source-opening logic used by `display`, but does
36
- not materialise records as JSON. The CEL graph is compiled once and then
37
- executed over the borrowed COBOL records. Output is one accumulator per
38
- record in JSONL. It accepts `--count`, `--all`, `--skip`, `--raw`, `--input`,
39
- `--graph`, and `--on-error throw|continue`. A `bigint` is printed as a decimal
40
- string; it remains a native integer during evaluation. In continue mode,
41
- record-level errors are printed as JSON with an `errors` property. A failed record never replaces the previous successful accumulator. In the default `throw` mode, execution stops and returns an error to the CLI (which exits nonzero); it does not print an error JSON record. The filename header appears only after graph compilation succeeds. Execution
42
- currently supports configured COBOL inputs; the CSV and JSONL compiled-access
43
- adapters have not been connected to the CLI scanner yet.
44
-
45
- The existing graph pipeline is used throughout:
21
+ Each of the four graph inspection stages accepts `--graph <filename>` and
22
+ `--short`. Without `--short`, `graph` shows the authored nodes, `canonical`
23
+ shows inferred dependencies, `sorted` groups nodes in topological generations,
24
+ and `planned` shows numeric node IDs and downstream links. The compact output
25
+ shows each node and its dependencies (the planned form shows numeric downstream
26
+ references). Inspection does not scan data records.
27
+
28
+ `cel validate` checks graph structure and the configured compiled accessors.
29
+ For a composed project, it uses all source projections; for a legacy single-file
30
+ project, `cel validate [logical-name]` selects one input. `cel execute` writes
31
+ one accumulator JSON object per processed entity. `--count N`, `--all`,
32
+ `--skip N`, `--raw` and `--graph` are available; `--input` selects a physical
33
+ file only in the single-file mode. `cel evaluate <entity-id> [logical-name]`
34
+ selects an entity by its configured key. `--debug` writes input and execution
35
+ trace to stderr while keeping the accumulator JSON on stdout.
36
+
37
+ ## Temporal references and graph ordering
38
+
39
+ A graph node writes its result to the accumulator under its node name. The expression determines which version of another node it reads:
40
+
41
+ ```yaml
42
+ sourceCustomerId:
43
+ type: cel
44
+ cel: input.customers.customerId
45
+ metadata:
46
+ type: number
47
+ doubleId:
48
+ type: cel
49
+ cel: now.sourceCustomerId * 2
50
+ metadata:
51
+ type: number
52
+ doubleIdByPrev:
53
+ type: cel
54
+ cel: prev.sourceCustomerId * 2
55
+ metadata:
56
+ type: number
57
+ ```
58
+
59
+ - `now.X` reads X after X is calculated in this run. Canonical `dependsOn` contains `[["now", "X"]]`; changes in X may activate its downstream readers.
60
+ - `prev.X` reads X before X is updated in this run. Canonical `mustBeBefore` contains `[["prev", "X"]]` on the reading node, reversed for topological sorting; this is **ordering only**, not change propagation.
61
+ - A node may read its own `prev.X` without a self-edge. Reading its own `now.X` is invalid.
62
+
63
+ For these three nodes the required execution order is `doubleIdByPrev` → `sourceCustomerId` → `doubleId`. They may occupy separate generations. Both `prev` and `now` use the **same** accumulator slots, without copying a second historical state.
64
+
65
+ `cel graph` displays authoring, `cel canonical` shows the inferred path arrays, `cel sorted` shows generations, and `cel planned` shows numeric execution edges. A referenced graph node that is not defined is reported at preparation with its owning node, CEL expression and missing name.
66
+
67
+ The pipeline is:
46
68
 
47
69
  ```text
48
- YAML → authoring → canonical → topological generations → compiled CEL → graph executor
70
+ Authored YAML → canonical dependencies and mustBeBefore constraints
71
+ → sorted generations → planned numeric graph
72
+ → compiled CEL → graph executor
49
73
  ```
50
74
 
51
- The compiled CEL engine supports `map`, `filter`, `exists`, `all` and `reduce`; a scalar-producing reduction can be the result of a graph node. Collection-valued graph nodes remain outside this integration. For example, a separate test graph can contain `input.orders.map(o, o.quantity).reduce(total, n, 0, total + n)` without modifying the shared example graph.
75
+ An error in a composed file should report the logical/physical file, record,
76
+ field, and decoder problem. The default execution error policy is `throw`.
77
+ `--on-error continue` is supported only in the legacy single-file mode;
78
+ composed execution rejects it until accumulator rollback is available.
52
79
 
53
- ## Initial accumulator
80
+ ## Accumulator configuration
54
81
 
55
- The optional `.cobolts/accumulator.yaml` is a flat mapping of accumulator names
56
- and initial scalar values. `--accumulator <filename>` overrides its filename
57
- (relative to `.cobolts`). If absent, the initial accumulator is `{}`.
82
+ The optional `.cobolts/accumulator.yaml` selects an execution strategy and
83
+ initial graph-node values. `files.yaml` declares source keys (`key`/`keyPath`);
84
+ the `customerId` option below selects which prepared integer field becomes the
85
+ indexed accumulator identity and its in-memory representation. For example:
58
86
 
59
87
  ```yaml
60
- totalCustomers: 0
88
+ strategy: indexed
89
+ file: ../data/previous-state.igs
90
+ optional: true
91
+ removed: reject
92
+ customerId:
93
+ field: customerId
94
+ type: number
95
+ initial:
96
+ totalCustomers: 0
97
+ ```
98
+
99
+ `customerId.field` is the configured integer key accessor for the indexed merge;
100
+ it must agree with the source key declared in `files.yaml`. `type: number` makes
101
+ input keys, historical keys and merge comparisons use safe JavaScript integers.
102
+ The older string form (`customerId: customerId`) is still accepted and defaults
103
+ to `bigint`. Both modes persist signed int64 keys, and numeric decoding rejects
104
+ IDs outside the safe-integer range rather than rounding them. `customerId` is
105
+ reserved in indexed-state storage and cannot also be a graph node. Existing state is read-only and wins over initial values. Initial values apply to new entities. For the object strategy, `initial` also defines starting node values. An absent default accumulator file is allowed; an explicitly selected missing file is not.
106
+
107
+ **Missing previous values are not automatically defaulted.** For example, the three-node graph above reads `prev.sourceCustomerId` before `sourceCustomerId` executes, so a new entity needs `initial: {sourceCustomerId: 0}` (or a matching historical value) for successful evaluation. A missing value produces a CEL evaluation error; adding sensible per-type defaults is separate work.
108
+
109
+ An initial accumulator may contain fields absent from the selected graph. Object-strategy validation allows these because partial graphs are legitimate. In the indexed strategy, however, the current join rejects unknown initial fields; persisted fields absent from the active schema are rejected with the default `removed: reject` policy. `removed: ignore` allows reading such historical files **but discards those fields from the active indexed record**; it is not lossless subset execution. This distinction matters when selecting partial graphs. In addition, the indexed one-entity evaluation path without a history file currently requires an explicit seed for **every active graph node**, even those that would be calculated from input; this is stricter than normal pooled, composed execution.
110
+
111
+ The normal output materialises a JSON accumulator for display, not for the
112
+ performance-critical execution loop. `bigint` values are rendered as decimal
113
+ strings. CEL supports scalar computations and collection operations such as
114
+ `map`, `filter`, `exists`, `all`, `reduce` and `sum`, where permitted by the
115
+ projection's types.
116
+
117
+ ## Test and example workflow
118
+
119
+ ```powershell
120
+ yarn cobolts -d modules/examples validate all
121
+ yarn cobolts -d benchmarks validate all
122
+ cd modules/cobolts/cobolts
123
+ yarn jest src/benchmark.cli.golden.spec.ts --runInBand
61
124
  ```
62
125
 
63
- YAML integers become CEL `bigint` values (only safe integers are accepted),
64
- while fractional numbers parse as doubles. Seed values for numeric graph nodes
65
- must currently be integers because `acc` numeric fields compile as CEL `int`. Strings, booleans and null are parsed
66
- as their native scalar types. Nested lists and objects are rejected. `cel validate`
67
- checks the YAML and matching graph-node types. It also rejects a missing initial value for every `acc.<name>` dependency inferred from the canonical graph, because the first record has no previous accumulator. `config validate` also checks
68
- its scalar structure. `config list` and `config view` include the file when present.
69
-
70
- For `cel execute`, the first record sees the seed through `acc`. Subsequent
71
- records see the previous result, while `current` is built anew for each record.
72
- Initial keys are not automatically copied into later accumulators. The example
73
- increments `totalCustomers` using `acc.totalCustomers + 1` and prints one
74
- accumulator per processed customer.
126
+ The command suite tests successful execution and first-record/selected-entity
127
+ agreement. Approved 1,000-character expected-output snapshots are a separate
128
+ check, documented in `src/golden/benchmark-cli/README.md`. The independent
129
+ benchmark verifiers remain responsible for calculation correctness.