agentic-qe 3.7.21 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/helpers/brain-checkpoint.cjs +4 -1
- package/.claude/helpers/statusline-v3.cjs +3 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +45 -0
- package/README.md +2 -14
- package/assets/helpers/statusline-v3.cjs +3 -1
- package/dist/cli/brain-commands.js +6 -10
- package/dist/cli/bundle.js +7441 -4327
- package/dist/cli/commands/audit.d.ts +43 -0
- package/dist/cli/commands/audit.js +125 -0
- package/dist/cli/commands/hooks.js +29 -6
- package/dist/cli/commands/init.js +1 -73
- package/dist/cli/commands/learning.js +270 -13
- package/dist/cli/commands/ruvector-commands.d.ts +15 -0
- package/dist/cli/commands/ruvector-commands.js +271 -0
- package/dist/cli/handlers/init-handler.d.ts +0 -1
- package/dist/cli/handlers/init-handler.js +0 -6
- package/dist/cli/index.js +4 -2
- package/dist/context/sources/defect-source.js +2 -2
- package/dist/context/sources/memory-source.js +2 -2
- package/dist/context/sources/requirements-source.js +2 -2
- package/dist/coordination/behavior-tree/decorators.d.ts +108 -0
- package/dist/coordination/behavior-tree/decorators.js +251 -0
- package/dist/coordination/behavior-tree/index.d.ts +12 -0
- package/dist/coordination/behavior-tree/index.js +15 -0
- package/dist/coordination/behavior-tree/nodes.d.ts +165 -0
- package/dist/coordination/behavior-tree/nodes.js +338 -0
- package/dist/coordination/behavior-tree/qe-trees.d.ts +105 -0
- package/dist/coordination/behavior-tree/qe-trees.js +181 -0
- package/dist/coordination/coherence-action-gate.d.ts +284 -0
- package/dist/coordination/coherence-action-gate.js +512 -0
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.js +8 -0
- package/dist/coordination/reasoning-qec.d.ts +315 -0
- package/dist/coordination/reasoning-qec.js +585 -0
- package/dist/coordination/task-executor.d.ts +16 -0
- package/dist/coordination/task-executor.js +99 -0
- package/dist/coordination/workflow-orchestrator.d.ts +29 -0
- package/dist/coordination/workflow-orchestrator.js +42 -0
- package/dist/domains/visual-accessibility/cnn-visual-regression.d.ts +135 -0
- package/dist/domains/visual-accessibility/cnn-visual-regression.js +327 -0
- package/dist/domains/visual-accessibility/index.d.ts +1 -0
- package/dist/domains/visual-accessibility/index.js +4 -0
- package/dist/governance/coherence-validator.d.ts +112 -0
- package/dist/governance/coherence-validator.js +180 -0
- package/dist/governance/index.d.ts +1 -0
- package/dist/governance/index.js +2 -0
- package/dist/governance/witness-chain.d.ts +311 -0
- package/dist/governance/witness-chain.js +509 -0
- package/dist/init/index.d.ts +0 -2
- package/dist/init/index.js +0 -1
- package/dist/init/init-wizard-steps.d.ts +10 -0
- package/dist/init/init-wizard-steps.js +87 -1
- package/dist/init/init-wizard.d.ts +1 -9
- package/dist/init/init-wizard.js +3 -69
- package/dist/init/orchestrator.js +0 -1
- package/dist/init/phases/01-detection.js +0 -27
- package/dist/init/phases/07-hooks.js +6 -4
- package/dist/init/phases/phase-interface.d.ts +0 -1
- package/dist/init/settings-merge.js +1 -1
- package/dist/integrations/browser/qe-dashboard/clustering.d.ts +48 -0
- package/dist/integrations/browser/qe-dashboard/clustering.js +183 -0
- package/dist/integrations/browser/qe-dashboard/index.d.ts +12 -0
- package/dist/integrations/browser/qe-dashboard/index.js +15 -0
- package/dist/integrations/browser/qe-dashboard/pattern-explorer.d.ts +165 -0
- package/dist/integrations/browser/qe-dashboard/pattern-explorer.js +260 -0
- package/dist/integrations/browser/qe-dashboard/wasm-vector-store.d.ts +144 -0
- package/dist/integrations/browser/qe-dashboard/wasm-vector-store.js +277 -0
- package/dist/integrations/ruvector/cognitive-container-codec.d.ts +51 -0
- package/dist/integrations/ruvector/cognitive-container-codec.js +180 -0
- package/dist/integrations/ruvector/cognitive-container.d.ts +125 -0
- package/dist/integrations/ruvector/cognitive-container.js +306 -0
- package/dist/integrations/ruvector/coherence-gate.d.ts +309 -0
- package/dist/integrations/ruvector/coherence-gate.js +631 -0
- package/dist/integrations/ruvector/compressed-hnsw-integration.d.ts +176 -0
- package/dist/integrations/ruvector/compressed-hnsw-integration.js +301 -0
- package/dist/integrations/ruvector/dither-adapter.d.ts +122 -0
- package/dist/integrations/ruvector/dither-adapter.js +295 -0
- package/dist/integrations/ruvector/domain-transfer.d.ts +129 -0
- package/dist/integrations/ruvector/domain-transfer.js +220 -0
- package/dist/integrations/ruvector/feature-flags.d.ts +214 -2
- package/dist/integrations/ruvector/feature-flags.js +167 -2
- package/dist/integrations/ruvector/filter-adapter.d.ts +71 -0
- package/dist/integrations/ruvector/filter-adapter.js +285 -0
- package/dist/integrations/ruvector/gnn-wrapper.d.ts +20 -0
- package/dist/integrations/ruvector/gnn-wrapper.js +40 -0
- package/dist/integrations/ruvector/hnsw-health-monitor.d.ts +237 -0
- package/dist/integrations/ruvector/hnsw-health-monitor.js +394 -0
- package/dist/integrations/ruvector/index.d.ts +8 -2
- package/dist/integrations/ruvector/index.js +18 -2
- package/dist/integrations/ruvector/interfaces.d.ts +40 -0
- package/dist/integrations/ruvector/sona-persistence.d.ts +54 -0
- package/dist/integrations/ruvector/sona-persistence.js +162 -0
- package/dist/integrations/ruvector/sona-three-loop.d.ts +392 -0
- package/dist/integrations/ruvector/sona-three-loop.js +814 -0
- package/dist/integrations/ruvector/sona-wrapper.d.ts +97 -0
- package/dist/integrations/ruvector/sona-wrapper.js +147 -3
- package/dist/integrations/ruvector/spectral-math.d.ts +101 -0
- package/dist/integrations/ruvector/spectral-math.js +254 -0
- package/dist/integrations/ruvector/temporal-compression.d.ts +163 -0
- package/dist/integrations/ruvector/temporal-compression.js +318 -0
- package/dist/integrations/ruvector/thompson-sampler.d.ts +61 -0
- package/dist/integrations/ruvector/thompson-sampler.js +118 -0
- package/dist/integrations/ruvector/transfer-coherence-stub.d.ts +80 -0
- package/dist/integrations/ruvector/transfer-coherence-stub.js +63 -0
- package/dist/integrations/ruvector/transfer-verification.d.ts +119 -0
- package/dist/integrations/ruvector/transfer-verification.js +115 -0
- package/dist/kernel/hnsw-adapter.d.ts +52 -1
- package/dist/kernel/hnsw-adapter.js +139 -4
- package/dist/kernel/hnsw-index-provider.d.ts +5 -0
- package/dist/kernel/native-hnsw-backend.d.ts +110 -0
- package/dist/kernel/native-hnsw-backend.js +408 -0
- package/dist/kernel/unified-memory.js +5 -6
- package/dist/learning/aqe-learning-engine.d.ts +2 -0
- package/dist/learning/aqe-learning-engine.js +65 -0
- package/dist/learning/experience-capture-middleware.js +20 -0
- package/dist/learning/experience-capture.d.ts +10 -0
- package/dist/learning/experience-capture.js +34 -0
- package/dist/learning/index.d.ts +2 -2
- package/dist/learning/index.js +4 -4
- package/dist/learning/metrics-tracker.d.ts +11 -0
- package/dist/learning/metrics-tracker.js +29 -13
- package/dist/learning/pattern-lifecycle.d.ts +30 -1
- package/dist/learning/pattern-lifecycle.js +92 -20
- package/dist/learning/pattern-store.d.ts +8 -0
- package/dist/learning/pattern-store.js +8 -2
- package/dist/learning/qe-unified-memory.js +1 -28
- package/dist/learning/regret-tracker.d.ts +201 -0
- package/dist/learning/regret-tracker.js +361 -0
- package/dist/mcp/bundle.js +5915 -474
- package/dist/routing/index.d.ts +4 -2
- package/dist/routing/index.js +3 -1
- package/dist/routing/neural-tiny-dancer-router.d.ts +268 -0
- package/dist/routing/neural-tiny-dancer-router.js +514 -0
- package/dist/routing/queen-integration.js +5 -5
- package/dist/routing/routing-config.d.ts +6 -0
- package/dist/routing/routing-config.js +1 -0
- package/dist/routing/simple-neural-router.d.ts +76 -0
- package/dist/routing/simple-neural-router.js +202 -0
- package/dist/routing/tiny-dancer-router.d.ts +20 -1
- package/dist/routing/tiny-dancer-router.js +21 -2
- package/dist/test-scheduling/dag-attention-scheduler.d.ts +81 -0
- package/dist/test-scheduling/dag-attention-scheduler.js +358 -0
- package/dist/test-scheduling/dag-attention-types.d.ts +81 -0
- package/dist/test-scheduling/dag-attention-types.js +10 -0
- package/dist/test-scheduling/index.d.ts +1 -0
- package/dist/test-scheduling/index.js +4 -0
- package/dist/test-scheduling/pipeline.d.ts +8 -0
- package/dist/test-scheduling/pipeline.js +28 -0
- package/package.json +6 -2
- package/dist/cli/commands/migrate.d.ts +0 -9
- package/dist/cli/commands/migrate.js +0 -566
- package/dist/init/init-wizard-migration.d.ts +0 -52
- package/dist/init/init-wizard-migration.js +0 -345
- package/dist/init/migration/config-migrator.d.ts +0 -31
- package/dist/init/migration/config-migrator.js +0 -149
- package/dist/init/migration/data-migrator.d.ts +0 -72
- package/dist/init/migration/data-migrator.js +0 -232
- package/dist/init/migration/detector.d.ts +0 -44
- package/dist/init/migration/detector.js +0 -105
- package/dist/init/migration/index.d.ts +0 -8
- package/dist/init/migration/index.js +0 -8
- package/dist/learning/v2-to-v3-migration.d.ts +0 -86
- package/dist/learning/v2-to-v3-migration.js +0 -529
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Witness Chain - Hash-Linked Audit Trail for Quality Gate Decisions
|
|
3
|
+
*
|
|
4
|
+
* Implements an append-only, hash-linked witness log for quality gate decisions.
|
|
5
|
+
* Each receipt is cryptographically chained to its predecessor using SHA-256,
|
|
6
|
+
* creating a tamper-evident audit trail.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Append-only witness log with SHA-256 hash linking
|
|
10
|
+
* - Chain integrity verification with tamper detection
|
|
11
|
+
* - SPRT (Sequential Probability Ratio Test) evidence accumulation
|
|
12
|
+
* - Export/import for brain transfer
|
|
13
|
+
* - Feature-flag gated via useWitnessChain
|
|
14
|
+
*
|
|
15
|
+
* @module governance/witness-chain
|
|
16
|
+
* @see ADR-083-coherence-gated-agent-actions.md
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A decision to be witnessed and recorded in the chain.
|
|
20
|
+
*/
|
|
21
|
+
export interface WitnessDecision {
|
|
22
|
+
/** Gate type that produced this decision */
|
|
23
|
+
type: string;
|
|
24
|
+
/** Decision outcome */
|
|
25
|
+
decision: 'PASS' | 'FAIL' | 'INCONCLUSIVE' | 'PERMIT' | 'DEFER' | 'DENY';
|
|
26
|
+
/** Contextual data for the decision */
|
|
27
|
+
context: Record<string, unknown>;
|
|
28
|
+
/** Accumulated SPRT evidence value (optional) */
|
|
29
|
+
evidence?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* An immutable receipt in the witness chain.
|
|
33
|
+
* Each receipt is hash-linked to the previous receipt.
|
|
34
|
+
*/
|
|
35
|
+
export interface WitnessReceipt {
|
|
36
|
+
/** Unique receipt identifier */
|
|
37
|
+
id: string;
|
|
38
|
+
/** Timestamp (ms since epoch) */
|
|
39
|
+
timestamp: number;
|
|
40
|
+
/** SHA-256 hash of the previous receipt (genesis uses '0' x 64) */
|
|
41
|
+
previousHash: string;
|
|
42
|
+
/** SHA-256 hash of this receipt: hash(previousHash + JSON(decision) + timestamp) */
|
|
43
|
+
hash: string;
|
|
44
|
+
/** The decision that was witnessed */
|
|
45
|
+
decision: WitnessDecision;
|
|
46
|
+
/** Position in the chain (0-indexed) */
|
|
47
|
+
chainIndex: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Result of verifying the witness chain integrity.
|
|
51
|
+
*/
|
|
52
|
+
export interface ChainVerificationResult {
|
|
53
|
+
/** Whether the entire chain is valid */
|
|
54
|
+
valid: boolean;
|
|
55
|
+
/** Total number of receipts checked */
|
|
56
|
+
length: number;
|
|
57
|
+
/** Index of the first invalid receipt (-1 if all valid) */
|
|
58
|
+
brokenAt: number;
|
|
59
|
+
/** Human-readable description of the verification outcome */
|
|
60
|
+
message: string;
|
|
61
|
+
/** Hash of the last receipt in the chain */
|
|
62
|
+
lastHash: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Serialized chain format for export/import.
|
|
66
|
+
*/
|
|
67
|
+
export interface WitnessChainExport {
|
|
68
|
+
/** Format version */
|
|
69
|
+
version: '1.0.0';
|
|
70
|
+
/** Export timestamp */
|
|
71
|
+
exportedAt: number;
|
|
72
|
+
/** Number of receipts */
|
|
73
|
+
length: number;
|
|
74
|
+
/** The receipt chain */
|
|
75
|
+
receipts: WitnessReceipt[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sequential Probability Ratio Test accumulator for Pass/Fail decisions.
|
|
79
|
+
*
|
|
80
|
+
* Simplified sequential decision rule with configurable evidence strength.
|
|
81
|
+
* For production use, strength should reflect log-likelihood ratio of the
|
|
82
|
+
* observation under the alternative vs null hypothesis.
|
|
83
|
+
*
|
|
84
|
+
* Accumulates evidence over a sequence of observations to decide between
|
|
85
|
+
* two hypotheses (Pass vs Fail) with controlled error rates.
|
|
86
|
+
*
|
|
87
|
+
* Boundaries:
|
|
88
|
+
* - Upper bound (accept H1 / PASS): ln(1/alpha)
|
|
89
|
+
* - Lower bound (accept H0 / FAIL): ln(beta)
|
|
90
|
+
*
|
|
91
|
+
* Default evidence step: +0.5 for positive, -0.5 for negative.
|
|
92
|
+
* Use addWeightedEvidence() for variable-strength observations.
|
|
93
|
+
*/
|
|
94
|
+
export declare class SPRTAccumulator {
|
|
95
|
+
private logLikelihoodRatio;
|
|
96
|
+
private readonly upperBound;
|
|
97
|
+
private readonly lowerBound;
|
|
98
|
+
private observations;
|
|
99
|
+
/**
|
|
100
|
+
* @param alpha - Type I error rate (false positive). Default: 0.05
|
|
101
|
+
* @param beta - Type II error rate (false negative). Default: 0.05
|
|
102
|
+
*/
|
|
103
|
+
constructor(alpha?: number, beta?: number);
|
|
104
|
+
/**
|
|
105
|
+
* Add a weighted observation and return the current decision.
|
|
106
|
+
*
|
|
107
|
+
* The strength parameter controls the log-likelihood step size.
|
|
108
|
+
* For production use, strength should reflect the log-likelihood ratio
|
|
109
|
+
* of the observation under the alternative vs null hypothesis.
|
|
110
|
+
*
|
|
111
|
+
* @param positive - Whether this observation is positive evidence
|
|
112
|
+
* @param strength - Evidence strength (step size). Default 0.5 for backward compat.
|
|
113
|
+
* @returns Current decision: PASS, FAIL, or INCONCLUSIVE
|
|
114
|
+
*/
|
|
115
|
+
addWeightedEvidence(positive: boolean, strength: number): 'PASS' | 'FAIL' | 'INCONCLUSIVE';
|
|
116
|
+
/**
|
|
117
|
+
* Add an observation with default strength (0.5) and return the current decision.
|
|
118
|
+
*
|
|
119
|
+
* @param positive - Whether this observation is positive evidence
|
|
120
|
+
* @returns Current decision: PASS, FAIL, or INCONCLUSIVE
|
|
121
|
+
*/
|
|
122
|
+
addEvidence(positive: boolean): 'PASS' | 'FAIL' | 'INCONCLUSIVE';
|
|
123
|
+
/**
|
|
124
|
+
* Get the current log-likelihood ratio.
|
|
125
|
+
*/
|
|
126
|
+
getRatio(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Get the total number of observations.
|
|
129
|
+
*/
|
|
130
|
+
getObservations(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Get the SPRT boundaries.
|
|
133
|
+
*/
|
|
134
|
+
getBounds(): {
|
|
135
|
+
upper: number;
|
|
136
|
+
lower: number;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Reset the accumulator to its initial state.
|
|
140
|
+
*/
|
|
141
|
+
reset(): void;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Append-only, hash-linked witness chain for quality gate decisions.
|
|
145
|
+
*
|
|
146
|
+
* Maintains an ordered sequence of witness receipts where each receipt
|
|
147
|
+
* references the hash of its predecessor, forming a tamper-evident chain.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const chain = new WitnessChain();
|
|
152
|
+
* const receipt = chain.appendWitness({
|
|
153
|
+
* type: 'coherence-gate',
|
|
154
|
+
* decision: 'PASS',
|
|
155
|
+
* context: { energy: 0.23, threshold: 0.4 },
|
|
156
|
+
* });
|
|
157
|
+
* const result = chain.verifyChain();
|
|
158
|
+
* console.log(result.valid); // true
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare class WitnessChain {
|
|
162
|
+
private receipts;
|
|
163
|
+
private lastHash;
|
|
164
|
+
private readonly sprtAccumulators;
|
|
165
|
+
/**
|
|
166
|
+
* Append a witness decision to the chain.
|
|
167
|
+
*
|
|
168
|
+
* Creates a new receipt hash-linked to the previous receipt and appends
|
|
169
|
+
* it to the chain. Optionally updates the SPRT accumulator for the
|
|
170
|
+
* decision type.
|
|
171
|
+
*
|
|
172
|
+
* @param decision - The decision to witness
|
|
173
|
+
* @returns The new witness receipt with its chain hash
|
|
174
|
+
*/
|
|
175
|
+
appendWitness(decision: WitnessDecision): WitnessReceipt;
|
|
176
|
+
/**
|
|
177
|
+
* Verify the integrity of the entire witness chain.
|
|
178
|
+
*
|
|
179
|
+
* Walks the chain from genesis to tip, recomputing each receipt's hash
|
|
180
|
+
* and checking it against the stored value. Reports the first breakage.
|
|
181
|
+
*
|
|
182
|
+
* @returns Verification result with validity, length, and break point
|
|
183
|
+
*/
|
|
184
|
+
verifyChain(): ChainVerificationResult;
|
|
185
|
+
/**
|
|
186
|
+
* Get receipts from the chain.
|
|
187
|
+
*
|
|
188
|
+
* @param limit - Maximum number of receipts to return (from most recent).
|
|
189
|
+
* If omitted, returns the entire chain.
|
|
190
|
+
* @returns Array of witness receipts
|
|
191
|
+
*/
|
|
192
|
+
getChain(limit?: number): WitnessReceipt[];
|
|
193
|
+
/**
|
|
194
|
+
* Get the total number of receipts in the chain.
|
|
195
|
+
*/
|
|
196
|
+
getChainLength(): number;
|
|
197
|
+
/**
|
|
198
|
+
* Get the hash of the most recent receipt (chain tip).
|
|
199
|
+
*/
|
|
200
|
+
getLastHash(): string;
|
|
201
|
+
/**
|
|
202
|
+
* Export the chain as a JSON string for brain transfer.
|
|
203
|
+
*
|
|
204
|
+
* @returns JSON string containing the full chain
|
|
205
|
+
*/
|
|
206
|
+
exportChain(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Import a chain from a JSON string.
|
|
209
|
+
*
|
|
210
|
+
* Validates the imported chain integrity before accepting it.
|
|
211
|
+
* Replaces the current chain if valid.
|
|
212
|
+
*
|
|
213
|
+
* @param data - JSON string from exportChain()
|
|
214
|
+
* @returns true if import was successful, false if data was invalid
|
|
215
|
+
*/
|
|
216
|
+
importChain(data: string): boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Get or create an SPRT accumulator for a decision type.
|
|
219
|
+
*
|
|
220
|
+
* @param type - The decision type (e.g., 'coherence-gate')
|
|
221
|
+
* @param alpha - Type I error rate (default: 0.05)
|
|
222
|
+
* @param beta - Type II error rate (default: 0.05)
|
|
223
|
+
* @returns The SPRT accumulator for the given type
|
|
224
|
+
*/
|
|
225
|
+
getSPRT(type: string, alpha?: number, beta?: number): SPRTAccumulator;
|
|
226
|
+
/**
|
|
227
|
+
* Get a receipt by chain index.
|
|
228
|
+
*
|
|
229
|
+
* @param index - The chain index (0-based)
|
|
230
|
+
* @returns The receipt at the given index, or undefined if out of range
|
|
231
|
+
*/
|
|
232
|
+
getReceipt(index: number): WitnessReceipt | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Update the SPRT accumulator based on the decision.
|
|
235
|
+
*/
|
|
236
|
+
private updateSPRT;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Persistence interface for witness chain SQLite backing.
|
|
240
|
+
*
|
|
241
|
+
* Implementations must provide methods to store and retrieve receipts
|
|
242
|
+
* from the unified SQLite database. This keeps WitnessChain decoupled
|
|
243
|
+
* from the database layer.
|
|
244
|
+
*/
|
|
245
|
+
export interface IWitnessChainPersistence {
|
|
246
|
+
/** Store a receipt in SQLite. Called after each appendWitness(). */
|
|
247
|
+
insertReceipt(receipt: WitnessReceipt): void;
|
|
248
|
+
/** Load all receipts from SQLite, ordered by chainIndex. */
|
|
249
|
+
loadAllReceipts(): WitnessReceipt[];
|
|
250
|
+
/** Get the total count of persisted receipts. */
|
|
251
|
+
getReceiptCount(): number;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* SQLite-backed WitnessChain that persists receipts to the unified database.
|
|
255
|
+
*
|
|
256
|
+
* Extends WitnessChain with optional SQLite persistence. When a persistence
|
|
257
|
+
* backend is provided, each witness receipt is written to SQLite on append,
|
|
258
|
+
* and the chain can be restored from SQLite on startup.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const persistence = createWitnessChainSQLitePersistence(db);
|
|
263
|
+
* const chain = createPersistentWitnessChain(persistence);
|
|
264
|
+
* // Chain is automatically loaded from SQLite on creation
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare class PersistentWitnessChain extends WitnessChain {
|
|
268
|
+
private readonly persistence;
|
|
269
|
+
constructor(persistence: IWitnessChainPersistence);
|
|
270
|
+
/**
|
|
271
|
+
* Append a witness and persist it to SQLite.
|
|
272
|
+
*/
|
|
273
|
+
appendWitness(decision: WitnessDecision): WitnessReceipt;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Create a SQLite persistence backend using better-sqlite3.
|
|
277
|
+
*
|
|
278
|
+
* Creates the `witness_chain_receipts` table if it doesn't exist
|
|
279
|
+
* and provides insert/load methods.
|
|
280
|
+
*
|
|
281
|
+
* @param db - better-sqlite3 Database instance (from unified persistence)
|
|
282
|
+
* @returns IWitnessChainPersistence implementation
|
|
283
|
+
*/
|
|
284
|
+
export declare function createWitnessChainSQLitePersistence(db: {
|
|
285
|
+
prepare: (sql: string) => {
|
|
286
|
+
run: (...args: unknown[]) => unknown;
|
|
287
|
+
all: (...args: unknown[]) => unknown[];
|
|
288
|
+
get: (...args: unknown[]) => unknown;
|
|
289
|
+
};
|
|
290
|
+
exec: (sql: string) => void;
|
|
291
|
+
}): IWitnessChainPersistence;
|
|
292
|
+
/**
|
|
293
|
+
* Create a new WitnessChain instance (in-memory).
|
|
294
|
+
*
|
|
295
|
+
* @returns A new empty WitnessChain
|
|
296
|
+
*/
|
|
297
|
+
export declare function createWitnessChain(): WitnessChain;
|
|
298
|
+
/**
|
|
299
|
+
* Create a SQLite-backed WitnessChain that persists receipts.
|
|
300
|
+
*
|
|
301
|
+
* @param persistence - SQLite persistence backend
|
|
302
|
+
* @returns A PersistentWitnessChain loaded from SQLite
|
|
303
|
+
*/
|
|
304
|
+
export declare function createPersistentWitnessChain(persistence: IWitnessChainPersistence): PersistentWitnessChain;
|
|
305
|
+
/**
|
|
306
|
+
* Check if the witness chain feature is enabled.
|
|
307
|
+
*
|
|
308
|
+
* @returns true if the useWitnessChain feature flag is on
|
|
309
|
+
*/
|
|
310
|
+
export declare function isWitnessChainFeatureEnabled(): boolean;
|
|
311
|
+
//# sourceMappingURL=witness-chain.d.ts.map
|