@cobol-ts/validation-execution 0.0.0-stage → 0.0.57

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 (174) hide show
  1. package/README.md +256 -3
  2. package/dist/index.d.ts +41 -0
  3. package/dist/index.js +59 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/compaction.prepare.d.ts +10 -0
  6. package/dist/src/compaction.prepare.js +60 -0
  7. package/dist/src/compaction.prepare.js.map +1 -0
  8. package/dist/src/compaction.project.d.ts +28 -0
  9. package/dist/src/compaction.project.js +81 -0
  10. package/dist/src/compaction.project.js.map +1 -0
  11. package/dist/src/compaction.project.memory.d.ts +12 -0
  12. package/dist/src/compaction.project.memory.js +70 -0
  13. package/dist/src/compaction.project.memory.js.map +1 -0
  14. package/dist/src/compaction.project.spec.d.ts +1 -0
  15. package/dist/src/compaction.project.spec.js +44 -0
  16. package/dist/src/compaction.project.spec.js.map +1 -0
  17. package/dist/src/compaction.project.storage.d.ts +21 -0
  18. package/dist/src/compaction.project.storage.js +3 -0
  19. package/dist/src/compaction.project.storage.js.map +1 -0
  20. package/dist/src/identification.candidate.d.ts +16 -0
  21. package/dist/src/identification.candidate.js +40 -0
  22. package/dist/src/identification.candidate.js.map +1 -0
  23. package/dist/src/identification.context.d.ts +8 -0
  24. package/dist/src/identification.context.js +3 -0
  25. package/dist/src/identification.context.js.map +1 -0
  26. package/dist/src/identification.selection.d.ts +4 -0
  27. package/dist/src/identification.selection.js +3 -0
  28. package/dist/src/identification.selection.js.map +1 -0
  29. package/dist/src/identified.state.publication.d.ts +14 -0
  30. package/dist/src/identified.state.publication.js +3 -0
  31. package/dist/src/identified.state.publication.js.map +1 -0
  32. package/dist/src/identified.state.reader.spec.d.ts +1 -0
  33. package/dist/src/identified.state.reader.spec.js +101 -0
  34. package/dist/src/identified.state.reader.spec.js.map +1 -0
  35. package/dist/src/identified.state.source.d.ts +20 -0
  36. package/dist/src/identified.state.source.js +5 -0
  37. package/dist/src/identified.state.source.js.map +1 -0
  38. package/dist/src/projected.entity.d.ts +8 -0
  39. package/dist/src/projected.entity.js +55 -0
  40. package/dist/src/projected.entity.js.map +1 -0
  41. package/dist/src/validation.candidate.execution.d.ts +6 -0
  42. package/dist/src/validation.candidate.execution.js +31 -0
  43. package/dist/src/validation.candidate.execution.js.map +1 -0
  44. package/dist/src/validation.candidate.failure.d.ts +5 -0
  45. package/dist/src/validation.candidate.failure.js +22 -0
  46. package/dist/src/validation.candidate.failure.js.map +1 -0
  47. package/dist/src/validation.candidate.policy.d.ts +16 -0
  48. package/dist/src/validation.candidate.policy.js +43 -0
  49. package/dist/src/validation.candidate.policy.js.map +1 -0
  50. package/dist/src/validation.candidate.policy.spec.d.ts +1 -0
  51. package/dist/src/validation.candidate.policy.spec.js +32 -0
  52. package/dist/src/validation.candidate.policy.spec.js.map +1 -0
  53. package/dist/src/validation.cursors.d.ts +23 -0
  54. package/dist/src/validation.cursors.js +117 -0
  55. package/dist/src/validation.cursors.js.map +1 -0
  56. package/dist/src/validation.display.d.ts +13 -0
  57. package/dist/src/validation.display.js +45 -0
  58. package/dist/src/validation.display.js.map +1 -0
  59. package/dist/src/validation.display.project.d.ts +4 -0
  60. package/dist/src/validation.display.project.js +20 -0
  61. package/dist/src/validation.display.project.js.map +1 -0
  62. package/dist/src/validation.identification.cutoffs.spec.d.ts +1 -0
  63. package/dist/src/validation.identification.cutoffs.spec.js +124 -0
  64. package/dist/src/validation.identification.cutoffs.spec.js.map +1 -0
  65. package/dist/src/validation.identification.execution.d.ts +11 -0
  66. package/dist/src/validation.identification.execution.js +36 -0
  67. package/dist/src/validation.identification.execution.js.map +1 -0
  68. package/dist/src/validation.identification.inspect.recovered.d.ts +9 -0
  69. package/dist/src/validation.identification.inspect.recovered.js +101 -0
  70. package/dist/src/validation.identification.inspect.recovered.js.map +1 -0
  71. package/dist/src/validation.identification.materialise.d.ts +26 -0
  72. package/dist/src/validation.identification.materialise.js +67 -0
  73. package/dist/src/validation.identification.materialise.js.map +1 -0
  74. package/dist/src/validation.identification.observation.d.ts +15 -0
  75. package/dist/src/validation.identification.observation.js +51 -0
  76. package/dist/src/validation.identification.observation.js.map +1 -0
  77. package/dist/src/validation.identification.observation.spec.d.ts +1 -0
  78. package/dist/src/validation.identification.observation.spec.js +29 -0
  79. package/dist/src/validation.identification.observation.spec.js.map +1 -0
  80. package/dist/src/validation.identification.physical.d.ts +26 -0
  81. package/dist/src/validation.identification.physical.js +79 -0
  82. package/dist/src/validation.identification.physical.js.map +1 -0
  83. package/dist/src/validation.identification.prefix.d.ts +27 -0
  84. package/dist/src/validation.identification.prefix.js +62 -0
  85. package/dist/src/validation.identification.prefix.js.map +1 -0
  86. package/dist/src/validation.identification.prefix.spec.d.ts +1 -0
  87. package/dist/src/validation.identification.prefix.spec.js +76 -0
  88. package/dist/src/validation.identification.prefix.spec.js.map +1 -0
  89. package/dist/src/validation.identification.projection.d.ts +6 -0
  90. package/dist/src/validation.identification.projection.js +21 -0
  91. package/dist/src/validation.identification.projection.js.map +1 -0
  92. package/dist/src/validation.identification.replay.d.ts +18 -0
  93. package/dist/src/validation.identification.replay.js +110 -0
  94. package/dist/src/validation.identification.replay.js.map +1 -0
  95. package/dist/src/validation.identification.satisfaction.d.ts +49 -0
  96. package/dist/src/validation.identification.satisfaction.js +116 -0
  97. package/dist/src/validation.identification.satisfaction.js.map +1 -0
  98. package/dist/src/validation.identification.scope.d.ts +7 -0
  99. package/dist/src/validation.identification.scope.js +60 -0
  100. package/dist/src/validation.identification.scope.js.map +1 -0
  101. package/dist/src/validation.identification.shard.d.ts +23 -0
  102. package/dist/src/validation.identification.shard.js +56 -0
  103. package/dist/src/validation.identification.shard.js.map +1 -0
  104. package/dist/src/validation.identification.strategy.d.ts +6 -0
  105. package/dist/src/validation.identification.strategy.js +26 -0
  106. package/dist/src/validation.identification.strategy.js.map +1 -0
  107. package/dist/src/validation.identification.strategy.spec.d.ts +1 -0
  108. package/dist/src/validation.identification.strategy.spec.js +31 -0
  109. package/dist/src/validation.identification.strategy.spec.js.map +1 -0
  110. package/dist/src/validation.identified.state.d.ts +34 -0
  111. package/dist/src/validation.identified.state.js +90 -0
  112. package/dist/src/validation.identified.state.js.map +1 -0
  113. package/dist/src/validation.investigation.d.ts +32 -0
  114. package/dist/src/validation.investigation.js +57 -0
  115. package/dist/src/validation.investigation.js.map +1 -0
  116. package/dist/src/validation.layouts.d.ts +26 -0
  117. package/dist/src/validation.layouts.js +78 -0
  118. package/dist/src/validation.layouts.js.map +1 -0
  119. package/dist/src/validation.manifest.reader.d.ts +16 -0
  120. package/dist/src/validation.manifest.reader.js +37 -0
  121. package/dist/src/validation.manifest.reader.js.map +1 -0
  122. package/dist/src/validation.observation.d.ts +58 -0
  123. package/dist/src/validation.observation.js +234 -0
  124. package/dist/src/validation.observation.js.map +1 -0
  125. package/dist/src/validation.oracle.dependencies.d.ts +29 -0
  126. package/dist/src/validation.oracle.dependencies.js +108 -0
  127. package/dist/src/validation.oracle.dependencies.js.map +1 -0
  128. package/dist/src/validation.oracle.dependencies.spec.d.ts +1 -0
  129. package/dist/src/validation.oracle.dependencies.spec.js +40 -0
  130. package/dist/src/validation.oracle.dependencies.spec.js.map +1 -0
  131. package/dist/src/validation.project.access.d.ts +23 -0
  132. package/dist/src/validation.project.access.js +13 -0
  133. package/dist/src/validation.project.access.js.map +1 -0
  134. package/dist/src/validation.reader.d.ts +17 -0
  135. package/dist/src/validation.reader.js +181 -0
  136. package/dist/src/validation.reader.js.map +1 -0
  137. package/dist/src/validation.reader.types.d.ts +23 -0
  138. package/dist/src/validation.reader.types.js +3 -0
  139. package/dist/src/validation.reader.types.js.map +1 -0
  140. package/dist/src/validation.recovered.shard.d.ts +8 -0
  141. package/dist/src/validation.recovered.shard.js +3 -0
  142. package/dist/src/validation.recovered.shard.js.map +1 -0
  143. package/dist/src/validation.reference.d.ts +5 -0
  144. package/dist/src/validation.reference.js +3 -0
  145. package/dist/src/validation.reference.js.map +1 -0
  146. package/dist/src/validation.replay.d.ts +27 -0
  147. package/dist/src/validation.replay.js +137 -0
  148. package/dist/src/validation.replay.js.map +1 -0
  149. package/dist/src/validation.report.d.ts +59 -0
  150. package/dist/src/validation.report.js +118 -0
  151. package/dist/src/validation.report.js.map +1 -0
  152. package/dist/src/validation.report.spec.d.ts +1 -0
  153. package/dist/src/validation.report.spec.js +75 -0
  154. package/dist/src/validation.report.spec.js.map +1 -0
  155. package/dist/src/validation.run.d.ts +10 -0
  156. package/dist/src/validation.run.js +20 -0
  157. package/dist/src/validation.run.js.map +1 -0
  158. package/dist/src/validation.run.project.d.ts +5 -0
  159. package/dist/src/validation.run.project.js +57 -0
  160. package/dist/src/validation.run.project.js.map +1 -0
  161. package/dist/src/validation.sequence.d.ts +11 -0
  162. package/dist/src/validation.sequence.js +59 -0
  163. package/dist/src/validation.sequence.js.map +1 -0
  164. package/dist/src/validation.sources.d.ts +11 -0
  165. package/dist/src/validation.sources.js +3 -0
  166. package/dist/src/validation.sources.js.map +1 -0
  167. package/dist/src/validation.sources.spec.d.ts +1 -0
  168. package/dist/src/validation.sources.spec.js +36 -0
  169. package/dist/src/validation.sources.spec.js.map +1 -0
  170. package/dist/src/validation.synchronous.spec.d.ts +1 -0
  171. package/dist/src/validation.synchronous.spec.js +173 -0
  172. package/dist/src/validation.synchronous.spec.js.map +1 -0
  173. package/index.ts +48 -0
  174. package/package.json +79 -3
package/README.md CHANGED
@@ -1,3 +1,256 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @cobol-ts/validation-execution
2
+
3
+ Deterministic validation and historical-state reconstruction using authenticated, customer-major production observations. The same execution mechanisms can be used with tutorial data or protected published data. The package does not select AI runners, call an AI provider, register Commander commands or depend on HTTP or GUI delivery.
4
+
5
+ ## Main entry points
6
+
7
+ The application APIs take explicit acquisition, configuration and storage capabilities.
8
+ Directory-based convenience APIs and native assembly live in
9
+ [validation-local](../validation-local/README.md).
10
+
11
+ | API | Responsibility |
12
+ | --- | --- |
13
+ | `compactProjectWith(paths, configName, progress, services)` | Prepare customer-major validation data from configured publications. |
14
+ | `validationShardAccessWith(...)` | Resolve configured validation shard access. |
15
+ | `scanValidationShardWith(configDirectory, sources, readConfig, yaml, visit, ...)` | Stream individual observations from a recovered shard. |
16
+ | `scanValidationCustomersWith(configDirectory, sources, readConfig, yaml, visit, ...)` | Borrow selected observations of one customer in manifest order. |
17
+ | `prepareValidationReplayWith(...)`, `compareRecoveredShardWith(...)` | Prepare and execute comparisons against expected published results. |
18
+ | `runValidationWith(paths, config, options, services, identifiedStorage)` | Recover and compare configured shards, returning a validation report. |
19
+ | `executeIdentificationHistoriesReportWith(...)` | Evaluate a supplied identification candidate against selected histories and cutoff policy. |
20
+ | `prepareIdentificationMaterialisation(...)`, `materialiseIdentificationShardWith(...)` | Prepare and produce reconstructed state for subsequent replay. |
21
+
22
+ ```ts
23
+ import {discoverPaths} from '@cobol-ts/project-context-local';
24
+ import {runValidation} from '@cobol-ts/validation-local';
25
+
26
+ const paths = await discoverPaths({directory: 'modules/examples/init'});
27
+ const report = await runValidation(paths, 'compaction.yaml', {
28
+ characteristic: 'C0100', maxCounterexamples: 0
29
+ });
30
+ ```
31
+
32
+ This requires the configured validation dataset to have been prepared. The report contains comparison statistics; a positive counterexample limit permits customer-level diagnostic values, so callers must choose disclosure policy deliberately. This example requests no counterexamples. The package is not by itself a production security or disclosure boundary.
33
+
34
+ ## Physical ownership and replay
35
+
36
+ The manifest defines replay order and how many physical records belong to each observation. The reader validates the declared cardinalities, customer ordering, participating composition and exact physical consumption on a complete scan. Selection can skip an event or stop early for bounded inspection; a partial scan is not equivalent to complete verification.
37
+
38
+ `scanValidationShardWith` borrows one observation for a synchronous visitor. `scanValidationCustomersWith` retains the physical leases for the selected history of one customer until its synchronous visitor returns. Neither rows nor leases may escape that callback; an incomplete history caused by a read failure is never delivered. Async visitors are rejected. Leases are released before upstream cursors are closed, including exceptional exits. The reader does not detach every input record into a JSON representation.
39
+
40
+ For example, using the local convenience adapter, a recovered shard can be visited without retaining physical data:
41
+
42
+ ```ts
43
+ import {scanValidationCustomers} from '@cobol-ts/validation-local';
44
+
45
+ let count = 0;
46
+ await scanValidationCustomers(configDirectory, recoveredShardDirectory, history => {
47
+ // Use history here, synchronously; do not save its rows or leases.
48
+ count += history.length;
49
+ });
50
+ ```
51
+
52
+ The local convenience API accepts a `ValidationSources` capability or a directory. The application API requires the capability, configuration reader and YAML parser explicitly. The capability supplies the member inventory and prepared physical sources. It does not expose file handles or require a local path. In `validation-local`, `withRecoveredValidationShard` owns the local recovery scope, checks the signed generation before and after use, and disposes of recovered bytes after cursors have closed. The filesystem implementation retains native buffered cursor access. `runValidation` handles recovery and cleanup for normal project-level use, verifies that the selected shard generations have not changed, and returns the report only after the selected scans complete.
53
+
54
+ ### Synchronous streaming boundary
55
+
56
+ See the developer guide [High-performance streaming](../../../docs/developers/streaming-performance.md) for the architectural rules, ownership model, allocation budget and remaining limitations.
57
+
58
+ `scanValidationShard` and `scanValidationCustomers` return one completion Promise each. Configuration, cursor acquisition, reference loading and layout compilation finish before the first manifest event is consumed. The optional `prepare` callback now runs once for **every usable layout**, even when the selection skips or stops before visiting that layout. A preparation failure therefore fails before any visitor runs.
59
+
60
+ The native CSV, JSONL and COBOL adapters advertise `PreparedFileSource.openSynchronousCursor`. Validation requires this capability; an asynchronous-only adapter must acquire or materialise the source outside the traversal. Cursor `take()` (including refills), selection, manifest interpretation, record consumption, visitor calls and lease release are synchronous. Only final cursor cleanup can suspend. This is deliberately not an async iterator. The general-purpose `openCursor` contract is unchanged for other consumers.
61
+
62
+ `validation.layouts.ts` indexes the participating source sets during preparation. `validation.sequence.ts` validates the customer-major stream without JSON-encoded signatures or integer-to-BigInt conversions for comparison. `validation.cursors.ts` reads manifest CSV fields into a single scratch array. `validation.observation.ts` owns read/skip and the two delivery lifetimes; the skip path does not allocate observation containers or decode expected snapshots. Cleanup attempts every close and retains the primary error if cleanup fails too.
63
+
64
+ Selected observations still allocate detached event/count objects, rows, slots and expected result snapshots. Public rows are **not pooled**: once closed, a row remains inactive and its slots remain empty, even after later observations are read. This preserves existing use-after-release diagnostics. Internal physical buffer pools remain in use; allocation reduction is not a claim of zero allocation. Benchmark throughput and GC with representative shards before making further pooling decisions.
65
+
66
+ ### Replay working storage
67
+
68
+ Batch replay reuses its periodicity argument and output lookup instead of allocating arguments, an executor/state pair and a new closure for each observation. The graph executor supplies its own prepared empty indices. The lookup returned by `evaluateOutputs` is borrowed until the next evaluation or reset; consume its results immediately. Identification replay likewise owns one lookup and argument object per replay session, not per observation. Oracle-backed replay also prepares dependency ordinals once and reuses an indexed scalar array. Missing values stay distinct from null, zero and false; conflicts still fail. The array is cleared on success or failure, and placeholder graph runners read their pre-bound ordinal rather than looking up names in a newly constructed map. Diagnostic accumulator snapshots remain detached. These are synchronous, single-owner sessions, not concurrent or reentrant executors.
69
+
70
+ Batch statistics prepare the declared characteristic set and mutable counters once. Comparison traversal no longer constructs `Object.entries` arrays or key/value tuples for each published row, and determines CSV versus native scalar comparison once per source per observation. It deliberately visits each row's actual own enumerable properties: JSONL result fields can vary between observations, and multiple sources can publish the same characteristic. Diagnostic comparisons still materialise their output, and bounded counterexamples remain owned records. No fixed per-source characteristic schema is assumed.
71
+
72
+ ## Identification
73
+
74
+ The caller supplies the business graph, identification context and candidate. Evidence and identification computations fit initial state; deterministic replay evaluates the relevant business outputs against published observations. Cutoff strategies test different available history prefixes. `comparePreparedIdentificationShard` accepts scan, fitting, replay, limit and statistics capabilities; the prefix algorithm is independent of the observation representation. State materialisation is a separate explicit operation, not a side effect of checking a candidate.
75
+
76
+ Project-level application functions consume injected acquisition and storage capabilities. `validation-local` binds filesystem recovery and temporary directories. These packages are not by themselves a standalone remote production worker. Experiment selection and discovery workflows remain outside this deterministic package; command registration and formatting belong to [cli-validation](../cli-validation/README.md) and its composition root.
77
+
78
+ ## Tests and further reading
79
+
80
+ - Compaction and replay integration: [compaction.prepare.integration.spec.ts](../validation-local/src/compaction.prepare.integration.spec.ts), [compaction.replay.integration.spec.ts](../validation-local/src/compaction.replay.integration.spec.ts).
81
+ - Identification, fitting and cutoff behaviour: [validation.identification.integration.spec.ts](../validation-local/src/validation.identification.integration.spec.ts), [validation.identification.prefix.spec.ts](src/validation.identification.prefix.spec.ts), [validation.identification.cutoffs.spec.ts](src/validation.identification.cutoffs.spec.ts).
82
+ - Comparison statistics: [validation.report.spec.ts](src/validation.report.spec.ts).
83
+ - Synchronous boundary, source capability, skip/stop and cleanup tests: [validation.synchronous.spec.ts](src/validation.synchronous.spec.ts).
84
+ - Reader lifetime and project-level workflow tests also live in the root [CLI integration suites](../cobolts/README.md).
85
+
86
+ See the [validation reference](../cobolts/README.validation.md) for compaction configuration, shard publication, validation and reconstruction commands.
87
+
88
+ `validationShardAccessWith` discovers named shard prefixes through the injected object store and authenticates the selected shard. Compaction publishes all verified shards as one scoped object publication. The existing local path-safety and target-ownership checks are retained, as is local physical source staging.
89
+
90
+ Reference acquisition is scoped by `WithValidationReferences`. Candidate
91
+ execution, identification, display and full validation accept this capability
92
+ and use the prepared composition-file factory only while its scope is open.
93
+ The implementation in `validation-local` authenticates the reference publication once,
94
+ shares pending acquisition between concurrent requests and removes the scratch
95
+ area after the operation. A non-local implementation may supply prepared
96
+ reference sources directly without changing replay or comparison.
97
+
98
+ Identified-state materialisation uses `IdentifiedStatePublication` to write
99
+ named shards and calculate their checksums. The local adapter retains the
100
+ existing exclusive destination and restrictive permissions, publishing the
101
+ manifest only after successful joint replay. Failed operations remove the
102
+ uncommitted destination. The workflow shares scoped validation shard and
103
+ reference acquisition; no native writer or directory operations are needed
104
+ in the materialisation coordinator.
105
+
106
+ Identified-state reading accepts `IdentifiedStateStorage` via `runValidationWith`
107
+ and the `readIdentifiedManifestFrom`/`openIdentifiedShardFrom` readers.
108
+ Path-based entry points are provided by `validation-local`. The reader checks the signed-generation binding,
109
+ checksum, schema, entity order and count before accepting reconstructed state.
110
+ The native implementation streams checksums and retains the existing synchronous
111
+ leased cursor; an alternative supplies a prepared cursor over the same immutable
112
+ shard revision. The local publication is assumed not to be modified during a run;
113
+ this contract does not add concurrent reader isolation. Physical-source acquisition is selected by the caller.
114
+
115
+ Compaction preparation can consume `CompactionRunSources` through
116
+ `prepareCompactionRunFromSources`: a prepared composition, catalogue and named
117
+ members determine the physical sources and canonical output names, independently
118
+ of their locators. The path-based preparation function in `validation-local` selects native sources.
119
+ The native compaction adapter owns scratch and target safety checks; the
120
+ prepared merge and output session can be used independently.
121
+
122
+ ### Preparation, compaction and replay are separate scopes
123
+
124
+ The project-level compaction adapter recovers authenticated source packages and
125
+ owns scratch space and destination safety. `prepareCompactionRunFromSources`
126
+ binds the logical catalogue and named members to prepared physical sources.
127
+ `compactRunsTo` / `compactShardsTo` in [cursor-loader-source](../../cursor-loader/cursor-loader-source/README.md)
128
+ merge those sources into an injected output session. The project publishes the
129
+ resulting encrypted dataset using a staged object publication. Closing a shard
130
+ writer is not the same as committing the complete authenticated dataset.
131
+
132
+ For validation, a prepared source must outlive every borrowed record. Scope the
133
+ reference factory to the entire replay, retain each customer history through
134
+ identification and comparison, and close it before advancing or returning.
135
+ An identified-state storage adapter must provide the digest, schema and cursor
136
+ for the same immutable shard revision; validating a checksum against one revision
137
+ and opening another would defeat the verification. The native reader assumes
138
+ no concurrent modification. Only aggregate reports should cross the eventual
139
+ production disclosure boundary; the current diagnostic tooling is not that
140
+ boundary.
141
+
142
+ `compactProjectWith` consumes `CompactionProjectServices`: replay selection, Oracle access and `CompactionProjectStorage`. The preparation scope owns recovered sources and plaintext shard outputs. The coordinator checks the signed generation before preparing each run, then publishes and verifies every shard within the destination's commit scope. The local implementation ([compaction.project.file.ts](../validation-local/src/compaction.project.file.ts)) owns scratch directories, overlap checks and target ownership checks under the publication claim. No native writer or directory operations occur in the coordinator; path-based convenience functions remain available.
143
+
144
+ ## Physical skip policy
145
+
146
+ Validation prefers the synchronous cursor's `skip()` capability for both
147
+ inputs and expected-result files when the selection decision is `skip`, and
148
+ when checking for unexpected trailing records. The native CSV, JSONL and COBOL
149
+ adapters advance physical framing without projection or materialisation. Skipped
150
+ JSONL content is not parsed or semantically validated. CSV framing still
151
+ respects quotes and embedded newlines. Counts, manifest order and physical EOF
152
+ remain checked. Custom synchronous sources that do not expose `skip()` retain
153
+ the take-and-release compatibility path. Selected observations continue through
154
+ the ordinary parser and borrowed-record lifetime contract.
155
+
156
+ The distinction is intentional: do not decode, copy, allocate a view or
157
+ materialise data whose value will immediately be discarded. See the
158
+ [cursor-loader-source README](../../cursor-loader/cursor-loader-source/README.md)
159
+ for the format-specific implementation and [synchronous scanner tests](src/validation.synchronous.spec.ts).
160
+
161
+ ## Compiled manifest traversal
162
+
163
+ After the manifest header is read, `compileManifestReader` allocates one event,
164
+ one named-count dictionary (for compatibility with selection callbacks) and one
165
+ `Float64Array` of counts for the entire scan. Header file ordinals bind the
166
+ composition inputs and expected-result cursors during preparation. The hot loop
167
+ uses indexed counts and prepared cursor arrays rather than looking up filenames
168
+ or allocating map-entry tuples. `-1` represents nonparticipation; zero is an
169
+ empty participating source. Counts remain safe integers, not 32-bit integers.
170
+
171
+ The native CSV adapter decodes only customer ID, date and periodicity as strings;
172
+ ordinary count fields are parsed directly from their existing byte ranges.
173
+ Custom snapshot adapters without indexed access use a reusable string-array
174
+ fallback. ID navigation asks only for column zero on adapters supporting it.
175
+
176
+ Selection callbacks borrow the reusable event synchronously and must copy any
177
+ values they want to retain. A selected observation has its own event and counts
178
+ snapshot, so retained histories cannot be overwritten by the next manifest row.
179
+ Skipping does not allocate an event snapshot. The manifest still checks identity,
180
+ calendar dates, canonical counts, composition membership, execution uniqueness
181
+ and cardinality. The streaming reader reports the first invalid count; the public
182
+ manifest parser retains its aggregate diagnostic contract. No asynchronous work
183
+ or temporary byte views are introduced into traversal.
184
+
185
+ See [compiled reader](src/validation.manifest.reader.ts) and the
186
+ [synchronous scanner tests](src/validation.synchronous.spec.ts).
187
+
188
+
189
+ ## Scan-local reuse and detached diagnostics
190
+
191
+ Each prepared composition layout owns a slot pool. The pool grows only when
192
+ simultaneously borrowed observations require more storage (for example a whole
193
+ customer history), then reuses the slot arrays, slot objects and lease arrays.
194
+ Leases are closed and references cleared before returning storage to the pool.
195
+ The public row handle is not reused: after delivery it is permanently inactive,
196
+ its `slots` is empty, and `entry` and `count` reject access. Slots and their lease
197
+ arrays are borrowed only within the synchronous visitor. Selected manifest events
198
+ and expected-result snapshots remain independent, not pooled.
199
+
200
+ Ordinary validation replay reuses its indexed state across customers. Reset
201
+ clears unseeded fields, applies historical overrides before shared defaults,
202
+ and copies validated rolling-window seeds into existing private rings where
203
+ compatible. Seed rings are never mutated. Missing or incompatible rings may
204
+ still require allocation. Independent identification replay sessions retain
205
+ independent states. No cross-customer state is intentionally retained.
206
+
207
+ The native manifest reader prepares bounded ASCII identity caches for customer
208
+ ID (one entry), date (256 entries) and periodicity (16 entries). Matching uses
209
+ existing byte ranges and exact comparison, including across physical buffers;
210
+ hash collisions only replace cache entries. Unusual Unicode or escaped fields
211
+ use the existing strict decoder. Cache misses still construct strings. ID
212
+ navigation uses only the customer identity cache. No unbounded interning,
213
+ temporary byte views, or promises are introduced.
214
+
215
+ Diagnostic replay now copies indexed values directly into detached display
216
+ snapshots, without stringify/parse round trips. Bigints and non-finite numbers
217
+ remain strings, absent object members remain absent and absent ring slots become
218
+ null, just as in the previous JSON representation. Normal batch evaluation does
219
+ not construct these snapshots.
220
+
221
+ ### Inspection and explicit project acquisition
222
+
223
+ In `validation-local`, `withRecoveredValidationManifest` acquires only the signed
224
+ manifest for ID navigation; `withRecoveredValidationShard` scopes a complete shard
225
+ and checks generation at both boundaries. `openPhysical` borrows synchronous
226
+ physical leases for exact framing lengths. `ValidationProjectAccess` supplies
227
+ shard discovery, generation, recovery, reference acquisition and configuration
228
+ text to `displayValidationWith`, `runValidationWith` and
229
+ `executeCandidateHistoriesWith`. `createValidationProjectAccess` constructs this
230
+ capability from injected configuration, recovery and reference ports.
231
+
232
+ `prepareValidationReplayWith`, `scanValidationShardWith`,
233
+ `compareRecoveredShardWith` and `displayRecoveredValidationWith` require explicit
234
+ configuration and parsing capabilities. Local convenience functions supply these
235
+ at the assembly boundary; the application workflows do not select native defaults.
236
+
237
+ ### Memory-backed integration
238
+
239
+ [validation.memory.integration.spec.ts](../validation-local/src/validation.memory.integration.spec.ts)
240
+ exercises project validation and display using memory configuration and prepared
241
+ physical sources. Mixed daily/monthly histories, explicit accumulator seeds,
242
+ customer reset, comparisons, mismatches and lease cleanup use the real execution
243
+ pipeline. Native text acquisition is denied. This fixture starts at the
244
+ authenticated shard boundary.
245
+
246
+ `compactProjectWith` and `validationShardAccessWith` require acquisition services;
247
+ `projectReplayPlanWith` consumes the supplied Oracle context rather than opening
248
+ a local repository. `createMemoryCompactionStorage` supports small authenticated
249
+ source recovery, physical compaction and staged shard publication.
250
+ `withMemoryValidationShard` acquires all members before replay. The
251
+ [memory lifecycle integration test](../cobolts/src/memory.lifecycle.integration.spec.ts)
252
+ exercises publication through validation with real CSV/JSONL parsers, signatures
253
+ and encryption, daily/monthly histories, reference data, multiple accounts,
254
+ accumulator reset and preservation of an existing dataset on a failed rebuild.
255
+ The memory adapter materialises small authenticated members; use native staged
256
+ streaming for large deliveries. It is not intended for large or untrusted archives.
@@ -0,0 +1,41 @@
1
+ export * from './src/validation.identification.shard';
2
+ export * from './src/validation.investigation';
3
+ export * from './src/validation.identification.projection';
4
+ export * from './src/validation.replay';
5
+ export * from './src/validation.identification.inspect.recovered';
6
+ export * from './src/validation.identification.scope';
7
+ export * from './src/validation.identification.physical';
8
+ export * from './src/validation.identification.observation';
9
+ export * from './src/validation.identification.prefix';
10
+ export * from './src/validation.candidate.policy';
11
+ export * from './src/validation.display';
12
+ export * from './src/validation.run';
13
+ export * from './src/validation.identified.state';
14
+ export * from './src/validation.reader';
15
+ export * from './src/validation.run.project';
16
+ export * from './src/validation.report';
17
+ export * from './src/validation.reference';
18
+ export * from './src/validation.identification.strategy';
19
+ export * from './src/validation.candidate.failure';
20
+ export * from './src/validation.identification.replay';
21
+ export * from './src/validation.identification.materialise';
22
+ export * from './src/validation.display.project';
23
+ export * from './src/validation.oracle.dependencies';
24
+ export * from './src/validation.identification.satisfaction';
25
+ export * from './src/compaction.prepare';
26
+ export * from './src/compaction.project';
27
+ export * from './src/projected.entity';
28
+ export * from './src/identification.candidate';
29
+ export * from './src/identification.context';
30
+ export * from './src/identification.selection';
31
+ export * from './src/validation.identification.execution';
32
+ export * from './src/validation.candidate.execution';
33
+ export * from './src/validation.sources';
34
+ export * from './src/validation.recovered.shard';
35
+ export * from './src/identified.state.publication';
36
+ export type { IdentifiedStateStorage, IdentifiedShardSource, IdentifiedShardCursor } from './src/identified.state.source';
37
+ export { identifiedManifestName } from './src/identified.state.source';
38
+ export { openPhysical } from './src/validation.cursors';
39
+ export * from './src/validation.project.access';
40
+ export * from './src/compaction.project.memory';
41
+ export type { SelectObservation } from './src/validation.reader.types';
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.openPhysical = exports.identifiedManifestName = void 0;
18
+ __exportStar(require("./src/validation.identification.shard"), exports);
19
+ __exportStar(require("./src/validation.investigation"), exports);
20
+ __exportStar(require("./src/validation.identification.projection"), exports);
21
+ __exportStar(require("./src/validation.replay"), exports);
22
+ __exportStar(require("./src/validation.identification.inspect.recovered"), exports);
23
+ __exportStar(require("./src/validation.identification.scope"), exports);
24
+ __exportStar(require("./src/validation.identification.physical"), exports);
25
+ __exportStar(require("./src/validation.identification.observation"), exports);
26
+ __exportStar(require("./src/validation.identification.prefix"), exports);
27
+ __exportStar(require("./src/validation.candidate.policy"), exports);
28
+ __exportStar(require("./src/validation.display"), exports);
29
+ __exportStar(require("./src/validation.run"), exports);
30
+ __exportStar(require("./src/validation.identified.state"), exports);
31
+ __exportStar(require("./src/validation.reader"), exports);
32
+ __exportStar(require("./src/validation.run.project"), exports);
33
+ __exportStar(require("./src/validation.report"), exports);
34
+ __exportStar(require("./src/validation.reference"), exports);
35
+ __exportStar(require("./src/validation.identification.strategy"), exports);
36
+ __exportStar(require("./src/validation.candidate.failure"), exports);
37
+ __exportStar(require("./src/validation.identification.replay"), exports);
38
+ __exportStar(require("./src/validation.identification.materialise"), exports);
39
+ __exportStar(require("./src/validation.display.project"), exports);
40
+ __exportStar(require("./src/validation.oracle.dependencies"), exports);
41
+ __exportStar(require("./src/validation.identification.satisfaction"), exports);
42
+ __exportStar(require("./src/compaction.prepare"), exports);
43
+ __exportStar(require("./src/compaction.project"), exports);
44
+ __exportStar(require("./src/projected.entity"), exports);
45
+ __exportStar(require("./src/identification.candidate"), exports);
46
+ __exportStar(require("./src/identification.context"), exports);
47
+ __exportStar(require("./src/identification.selection"), exports);
48
+ __exportStar(require("./src/validation.identification.execution"), exports);
49
+ __exportStar(require("./src/validation.candidate.execution"), exports);
50
+ __exportStar(require("./src/validation.sources"), exports);
51
+ __exportStar(require("./src/validation.recovered.shard"), exports);
52
+ __exportStar(require("./src/identified.state.publication"), exports);
53
+ var identified_state_source_1 = require("./src/identified.state.source");
54
+ Object.defineProperty(exports, "identifiedManifestName", { enumerable: true, get: function () { return identified_state_source_1.identifiedManifestName; } });
55
+ var validation_cursors_1 = require("./src/validation.cursors");
56
+ Object.defineProperty(exports, "openPhysical", { enumerable: true, get: function () { return validation_cursors_1.openPhysical; } });
57
+ __exportStar(require("./src/validation.project.access"), exports);
58
+ __exportStar(require("./src/compaction.project.memory"), exports);
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wEAAqD;AACrD,iEAA8C;AAC9C,6EAA0D;AAC1D,0DAAuC;AACvC,oFAAiE;AACjE,wEAAqD;AACrD,2EAAwD;AACxD,8EAA2D;AAC3D,yEAAsD;AACtD,oEAAiD;AACjD,2DAAwC;AACxC,uDAAoC;AACpC,oEAAiD;AACjD,0DAAuC;AACvC,+DAA4C;AAC5C,0DAAuC;AACvC,6DAA0C;AAC1C,2EAAwD;AACxD,qEAAkD;AAClD,yEAAsD;AACtD,8EAA2D;AAC3D,mEAAgD;AAChD,uEAAoD;AACpD,+EAA4D;AAC5D,2DAAwC;AACxC,2DAAwC;AACxC,yDAAsC;AACtC,iEAA8C;AAC9C,+DAA4C;AAC5C,iEAA8C;AAC9C,4EAAyD;AACzD,uEAAoD;AACpD,2DAAwC;AACxC,mEAAgD;AAChD,qEAAkD;AAGlD,yEAAoE;AAA5D,iIAAA,sBAAsB,OAAA;AAE9B,+DAAqD;AAA7C,kHAAA,YAAY,OAAA;AAEpB,kEAA+C;AAG/C,kEAA+C"}
@@ -0,0 +1,10 @@
1
+ import { type FileCatalogue } from '@cobol-ts/file-catalogue';
2
+ import { type CompactionRun, type ConfiguredFileSource } from '@cobol-ts/cursor-loader-source';
3
+ import type { CompactionConfig } from '@cobol-ts/project-execution';
4
+ import type { CompactionExecution } from '@cobol-ts/cursor-loader-source';
5
+ export interface CompactionRunSources {
6
+ configured(logicalName: string, member: string): Promise<ConfiguredFileSource>;
7
+ result(member: string, type: 'csv' | 'jsonl', key: CompactionConfig['results'][string]): Promise<ConfiguredFileSource>;
8
+ }
9
+ /** The orchestration binds canonical member identities to prepared physical sources. */
10
+ export declare function prepareCompactionRunFromSources(event: CompactionExecution, filenames: readonly string[], results: CompactionConfig['results'], catalogue: FileCatalogue, definition: import('@cobol-ts/composition-definition').NamedCompositionDefinition, acquisition: CompactionRunSources): Promise<CompactionRun>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareCompactionRunFromSources = prepareCompactionRunFromSources;
4
+ const node_path_1 = require("node:path");
5
+ const file_catalogue_1 = require("@cobol-ts/file-catalogue");
6
+ const composition_definition_1 = require("@cobol-ts/composition-definition");
7
+ const cursor_loader_source_1 = require("@cobol-ts/cursor-loader-source");
8
+ /** The orchestration binds canonical member identities to prepared physical sources. */
9
+ async function prepareCompactionRunFromSources(event, filenames, results, catalogue, definition, acquisition) {
10
+ if (definition.type !== 'relational' || definition.periodicity !== event.periodicity)
11
+ throw new Error(`Invalid production composition ${event.composition}`);
12
+ const master = definition.files[definition.composition.master];
13
+ const names = new Set(filenames), used = new Set(), sources = [];
14
+ const prepared = new Map();
15
+ function open(logicalName) {
16
+ let source = prepared.get(logicalName);
17
+ if (!source) {
18
+ const physical = catalogue.files[logicalName];
19
+ if (!physical)
20
+ throw new Error(`Unknown source ${logicalName}`);
21
+ const filename = (0, file_catalogue_1.physicalFileName)(logicalName, physical);
22
+ if (!names.has(filename))
23
+ throw new Error(`Missing required production file: ${filename}`);
24
+ used.add(filename);
25
+ source = acquisition.configured(logicalName, filename);
26
+ prepared.set(logicalName, source);
27
+ }
28
+ return source;
29
+ }
30
+ for (const [logical, member] of Object.entries(definition.composition.files)) {
31
+ const file = definition.files[logical], source = await open(logical);
32
+ if (file.type && file.type !== source.type)
33
+ throw new Error(`File ${logical}: Incompatible catalogue type`);
34
+ const options = { name: logical, cardinality: member.cardinality, keyPath: (0, composition_definition_1.resolveEntityKeyPath)(source.projection, file.key, file.keyPath) };
35
+ if (!member.mapping)
36
+ sources.push((0, cursor_loader_source_1.withPreparedFileSource)(source, typed => (0, cursor_loader_source_1.asCompactionSource)(typed, options, (0, file_catalogue_1.physicalFileName)(logical, catalogue.files[logical]))));
37
+ else {
38
+ const bridge = definition.mappings[member.mapping], map = await open(member.mapping);
39
+ const foreign = Object.entries(bridge.foreign).filter(([, entity]) => entity === master.key);
40
+ if (foreign.length !== 1)
41
+ throw new Error(`Mapping ${member.mapping}: Expected one foreign field targeting ${master.key}`);
42
+ const mappingOptions = { name: member.mapping, keyPath: (0, composition_definition_1.resolveEntityKeyPath)(map.projection, bridge.key, bridge.keyPath), foreignPath: foreign[0][0].split('.') };
43
+ sources.push((0, cursor_loader_source_1.withPreparedFileSource)(source, typed => (0, cursor_loader_source_1.withPreparedFileSource)(map, mapped => (0, cursor_loader_source_1.asMappedCompactionSource)(typed, options, mapped, mappingOptions, (0, file_catalogue_1.physicalFileName)(logical, catalogue.files[logical])))));
44
+ }
45
+ }
46
+ for (const filename of filenames) {
47
+ if (used.has(filename))
48
+ continue;
49
+ const key = Object.hasOwn(results, filename) ? results[filename] : undefined;
50
+ if (!key)
51
+ throw new Error(`No result key configured for ${filename} in compaction.yaml`);
52
+ const type = (0, node_path_1.extname)(filename).slice(1);
53
+ if (type !== 'csv' && type !== 'jsonl')
54
+ throw new Error(`Unsupported result format: ${filename}`);
55
+ const source = await acquisition.result(filename, type, key);
56
+ sources.push((0, cursor_loader_source_1.withPreparedFileSource)(source, typed => (0, cursor_loader_source_1.asCompactionSource)(typed, { name: filename, cardinality: 'one', keyPath: key.keyPath.split('.') }, filename)));
57
+ }
58
+ return { event, master: definition.composition.master, sources };
59
+ }
60
+ //# sourceMappingURL=compaction.prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction.prepare.js","sourceRoot":"","sources":["../../src/compaction.prepare.ts"],"names":[],"mappings":";;AAcA,0EA4CC;AA1DD,yCAAiC;AACjC,6DAA6E;AAC7E,6EAAqE;AACrE,yEAC+G;AAS/G,wFAAwF;AACjF,K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;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAA;QACjG,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAC,IAAI,EAAC,GAAG,CAAC,CAAA;QAC1D,OAAO,CAAC,IAAI,CAAC,IAAA,6CAAsB,EAAC,MAAM,EAAC,KAAK,CAAA,EAAE,CAAA,IAAA,yCAAkB,EAAC,KAAK,EAAC,EAAC,IAAI,EAAC,QAAQ,EAAC,WAAW,EAAC,KAAK,EAAC,OAAO,EAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAC,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC3J,CAAC;IACD,OAAO,EAAC,KAAK,EAAC,MAAM,EAAC,UAAU,CAAC,WAAW,CAAC,MAAM,EAAC,OAAO,EAAC,CAAA;AAC/D,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ObjectStore } from '@cobol-ts/files';
2
+ import type { YamlParser } from '@cobol-ts/yaml';
3
+ import { type OracleContext } from '@cobol-ts/project-oracle';
4
+ import type { ReplayEvent } from '@cobol-ts/project-replay';
5
+ import type { ProjectPaths } from '@cobol-ts/project-context';
6
+ import type { CompactionProjectStorage } from './compaction.project.storage';
7
+ export type { CompactionProjectStorage, CompactionPreparation, CompactionDestination } from './compaction.project.storage';
8
+ export interface CompactionProjectServices {
9
+ readonly yaml: YamlParser;
10
+ readonly storage: CompactionProjectStorage;
11
+ readonly oracle: (paths: ProjectPaths) => Promise<OracleContext>;
12
+ readonly replay: (paths: ProjectPaths) => Promise<readonly ReplayEvent[]>;
13
+ }
14
+ export declare function compactProjectWith(paths: ProjectPaths, configName: string, progress: (message: string) => void, services: CompactionProjectServices): Promise<{
15
+ target: string;
16
+ shards: number;
17
+ executions: number;
18
+ }>;
19
+ /** Missing configuration or an absent target is not a prepared dataset.
20
+ * An existing but malformed target is not treated as missing. */
21
+ export declare function hasValidationDatasetWith(paths: ProjectPaths, configName: string, storage: CompactionProjectStorage, yaml: YamlParser): Promise<boolean>;
22
+ export declare function validationShardAccessWith(paths: ProjectPaths, configName: string, store: ObjectStore | undefined, storage: CompactionProjectStorage, openOracle: CompactionProjectServices['oracle'], yaml: YamlParser): Promise<{
23
+ packager: import("@cobol-ts/crypto-packager").StreamingCryptoPackager;
24
+ list: () => Promise<string[]>;
25
+ select: (shard: string) => Promise<string>;
26
+ target: string;
27
+ shards: number;
28
+ }>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compactProjectWith = compactProjectWith;
4
+ exports.hasValidationDatasetWith = hasValidationDatasetWith;
5
+ exports.validationShardAccessWith = validationShardAccessWith;
6
+ const node_path_1 = require("node:path");
7
+ const errors_1 = require("@cobol-ts/errors");
8
+ const cursor_loader_source_1 = require("@cobol-ts/cursor-loader-source");
9
+ const project_execution_1 = require("@cobol-ts/project-execution");
10
+ const project_oracle_1 = require("@cobol-ts/project-oracle");
11
+ async function configuration(paths, filename, storage, yaml) {
12
+ return (0, project_execution_1.parseCompactionConfig)((0, errors_1.valueOrThrow)(yaml.parse(await storage.text.read((0, node_path_1.resolve)(paths.directory, filename)))));
13
+ }
14
+ async function compactProjectWith(paths, configName, progress, services) {
15
+ const { storage } = services;
16
+ const config = await configuration(paths, configName, storage, services.yaml);
17
+ const oracle = await services.oracle(paths);
18
+ const { from, through } = config.source.months;
19
+ const events = (await services.replay(paths)).filter(event => event.date.slice(0, 7) >= from && event.date.slice(0, 7) <= through);
20
+ if (!events.length)
21
+ throw new Error(`No observed production executions for ${from} through ${through}`);
22
+ const target = await storage.target(paths, config.target.root, oracle);
23
+ return storage.withPreparation(paths, oracle, config.results, async (preparation) => {
24
+ const runs = [];
25
+ for (const [ordinal, event] of events.entries()) {
26
+ const id = (0, project_oracle_1.productionRunId)(event.composition, event.date);
27
+ progress(`Recovering ${id}`);
28
+ const manifest = await (0, project_oracle_1.verifyProduction)(oracle, event.composition, event.date, false);
29
+ const prepare = await preparation.recover(id, ordinal, event, manifest);
30
+ const after = await oracle.packager.manifest(id);
31
+ if (after.generation !== manifest.generation)
32
+ throw new Error(`Production run changed during recovery: ${id}`);
33
+ runs.push(await prepare());
34
+ }
35
+ progress(`Compacting ${runs.length} executions into ${config.target.shards} shards`);
36
+ const inputs = await preparation.compact(runs, config.target.shards);
37
+ return target.publish(async (packager) => {
38
+ for (let i = 0; i < config.target.shards; i++) {
39
+ const id = (0, cursor_loader_source_1.shardName)(i);
40
+ await packager.publish(id, inputs(id), 'shard');
41
+ await packager.verify(id);
42
+ progress(`Verified ${id}`);
43
+ }
44
+ return { target: target.location, shards: config.target.shards, executions: runs.length };
45
+ });
46
+ });
47
+ }
48
+ /** Missing configuration or an absent target is not a prepared dataset.
49
+ * An existing but malformed target is not treated as missing. */
50
+ async function hasValidationDatasetWith(paths, configName, storage, yaml) {
51
+ if (!await storage.text.exists((0, node_path_1.resolve)(paths.directory, configName)))
52
+ return false;
53
+ const config = await configuration(paths, configName, storage, yaml);
54
+ return storage.datasetExists((0, node_path_1.resolve)(paths.directory, config.target.root));
55
+ }
56
+ async function validationShardAccessWith(paths, configName, store, storage, openOracle, yaml) {
57
+ const config = await configuration(paths, configName, storage, yaml);
58
+ const oracle = await openOracle(paths);
59
+ const target = (0, node_path_1.resolve)(paths.directory, config.target.root);
60
+ const packager = storage.packager(oracle, target, store);
61
+ async function list() {
62
+ const ids = [...new Set((await packager.store.list('')).flatMap(key => {
63
+ const [id, member] = key.split('/');
64
+ return member && /^shard-\d{4}$/.test(id) ? [id] : [];
65
+ }))].sort();
66
+ if (!ids.length)
67
+ throw new Error(`No validation shards: ${target}`);
68
+ return ids;
69
+ }
70
+ async function select(shard) {
71
+ const id = (0, node_path_1.basename)(shard);
72
+ if (!/^shard-\d{4}$/.test(id) || (shard !== id && (0, node_path_1.resolve)(shard) !== (0, node_path_1.join)(target, id)))
73
+ throw new Error(`Invalid validation shard: ${shard}`);
74
+ const manifest = await packager.manifest(id);
75
+ if (manifest.packageKind !== 'shard' || !manifest.files.some(file => file.path === 'manifest.csv'))
76
+ throw new Error(`Not a validation shard: ${id}`);
77
+ return id;
78
+ }
79
+ return { packager, list, select, target, shards: config.target.shards };
80
+ }
81
+ //# sourceMappingURL=compaction.project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction.project.js","sourceRoot":"","sources":["../../src/compaction.project.ts"],"names":[],"mappings":";;AAsBA,gDA+BC;AAID,4DAIC;AAED,8DAqBC;AAnFD,yCAAiD;AACjD,6CAA6C;AAE7C,yEAA4E;AAC5E,mEAAiE;AACjE,6DAA8F;AAM9F,KAAK,UAAU,aAAa,CAAC,KAAmB,EAAE,QAAgB,EAAE,OAAiC,EAAC,IAAe;IACjH,OAAO,IAAA,yCAAqB,EAAC,IAAA,qBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACvH,CAAC;AAQM,KAAK,UAAU,kBAAkB,CAAC,KAAkB,EAAC,UAAiB,EAAC,QAA+B,EAAC,QAAkC;IAC5I,MAAM,EAAC,OAAO,EAAC,GAAG,QAAQ,CAAA;IAC1B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,KAAK,EAAC,UAAU,EAAC,OAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC1E,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC3C,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAA;IAC3C,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA,EAAE,CAAA,KAAK,CAAC,IAA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AAK,UAAU,MAAM,CAAC,KAAa;QAC/B,MAAM,EAAE,GAAG,IAAA,oBAAQ,EAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,KAAG,EAAE,IAAI,IAAA,mBAAO,EAAC,KAAK,CAAC,KAAG,IAAA,gBAAI,EAAC,MAAM,EAAC,EAAE,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAA;QACxI,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC5C,IAAI,QAAQ,CAAC,WAAW,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAA,EAAE,CAAA,IAAI,CAAC,IAAI,KAAG,cAAc,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;QAChJ,OAAO,EAAE,CAAA;IACb,CAAC;IACD,OAAO,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAC,CAAA;AACpE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { MemoryObjectStore, type TextFiles } from '@cobol-ts/files';
2
+ import { StreamingCryptoPackager } from '@cobol-ts/crypto-packager';
3
+ import type { YamlParser } from '@cobol-ts/yaml';
4
+ import type { CompactionProjectStorage } from './compaction.project.storage';
5
+ import type { ValidationSources } from './validation.sources';
6
+ /** Small integration workloads only; no filesystem paths are acquired. */
7
+ export declare function createMemoryCompactionStorage(text: Pick<TextFiles, 'read' | 'exists'>, maxOutputBytes: number, yaml: YamlParser): {
8
+ storage: CompactionProjectStorage;
9
+ repository: MemoryObjectStore;
10
+ };
11
+ /** Acquire a complete authenticated shard before exposing prepared sources. */
12
+ export declare function withMemoryValidationShard<T>(configDirectory: string, text: Pick<TextFiles, 'read'>, packager: StreamingCryptoPackager, id: string, yaml: YamlParser, use: (sources: ValidationSources) => Promise<T>): Promise<T>;