thevoidforge 21.0.10 → 21.0.12

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 (108) hide show
  1. package/dist/.claude/commands/ai.md +69 -0
  2. package/dist/.claude/commands/architect.md +121 -0
  3. package/dist/.claude/commands/assemble.md +201 -0
  4. package/dist/.claude/commands/assess.md +75 -0
  5. package/dist/.claude/commands/blueprint.md +135 -0
  6. package/dist/.claude/commands/build.md +116 -0
  7. package/dist/.claude/commands/campaign.md +201 -0
  8. package/dist/.claude/commands/cultivation.md +166 -0
  9. package/dist/.claude/commands/current.md +128 -0
  10. package/dist/.claude/commands/dangerroom.md +74 -0
  11. package/dist/.claude/commands/debrief.md +178 -0
  12. package/dist/.claude/commands/deploy.md +99 -0
  13. package/dist/.claude/commands/devops.md +143 -0
  14. package/dist/.claude/commands/gauntlet.md +140 -0
  15. package/dist/.claude/commands/git.md +104 -0
  16. package/dist/.claude/commands/grow.md +146 -0
  17. package/dist/.claude/commands/imagine.md +126 -0
  18. package/dist/.claude/commands/portfolio.md +50 -0
  19. package/dist/.claude/commands/prd.md +113 -0
  20. package/dist/.claude/commands/qa.md +107 -0
  21. package/dist/.claude/commands/review.md +151 -0
  22. package/dist/.claude/commands/security.md +100 -0
  23. package/dist/.claude/commands/test.md +96 -0
  24. package/dist/.claude/commands/thumper.md +116 -0
  25. package/dist/.claude/commands/treasury.md +100 -0
  26. package/dist/.claude/commands/ux.md +118 -0
  27. package/dist/.claude/commands/vault.md +189 -0
  28. package/dist/.claude/commands/void.md +108 -0
  29. package/dist/CHANGELOG.md +1918 -0
  30. package/dist/CLAUDE.md +250 -0
  31. package/dist/HOLOCRON.md +856 -0
  32. package/dist/VERSION.md +123 -0
  33. package/dist/docs/NAMING_REGISTRY.md +478 -0
  34. package/dist/docs/methods/AI_INTELLIGENCE.md +276 -0
  35. package/dist/docs/methods/ASSEMBLER.md +142 -0
  36. package/dist/docs/methods/BACKEND_ENGINEER.md +165 -0
  37. package/dist/docs/methods/BUILD_JOURNAL.md +185 -0
  38. package/dist/docs/methods/BUILD_PROTOCOL.md +426 -0
  39. package/dist/docs/methods/CAMPAIGN.md +568 -0
  40. package/dist/docs/methods/CONTEXT_MANAGEMENT.md +189 -0
  41. package/dist/docs/methods/DEEP_CURRENT.md +184 -0
  42. package/dist/docs/methods/DEVOPS_ENGINEER.md +295 -0
  43. package/dist/docs/methods/FIELD_MEDIC.md +261 -0
  44. package/dist/docs/methods/FORGE_ARTIST.md +108 -0
  45. package/dist/docs/methods/FORGE_KEEPER.md +268 -0
  46. package/dist/docs/methods/GAUNTLET.md +344 -0
  47. package/dist/docs/methods/GROWTH_STRATEGIST.md +466 -0
  48. package/dist/docs/methods/HEARTBEAT.md +168 -0
  49. package/dist/docs/methods/MCP_INTEGRATION.md +139 -0
  50. package/dist/docs/methods/MUSTER.md +148 -0
  51. package/dist/docs/methods/PRD_GENERATOR.md +186 -0
  52. package/dist/docs/methods/PRODUCT_DESIGN_FRONTEND.md +250 -0
  53. package/dist/docs/methods/QA_ENGINEER.md +337 -0
  54. package/dist/docs/methods/RELEASE_MANAGER.md +145 -0
  55. package/dist/docs/methods/SECURITY_AUDITOR.md +320 -0
  56. package/dist/docs/methods/SUB_AGENTS.md +335 -0
  57. package/dist/docs/methods/SYSTEMS_ARCHITECT.md +171 -0
  58. package/dist/docs/methods/TESTING.md +359 -0
  59. package/dist/docs/methods/THUMPER.md +175 -0
  60. package/dist/docs/methods/TIME_VAULT.md +120 -0
  61. package/dist/docs/methods/TREASURY.md +184 -0
  62. package/dist/docs/methods/TROUBLESHOOTING.md +265 -0
  63. package/dist/docs/patterns/README.md +52 -0
  64. package/dist/docs/patterns/ad-billing-adapter.ts +537 -0
  65. package/dist/docs/patterns/ad-platform-adapter.ts +421 -0
  66. package/dist/docs/patterns/ai-classifier.ts +195 -0
  67. package/dist/docs/patterns/ai-eval.ts +272 -0
  68. package/dist/docs/patterns/ai-orchestrator.ts +341 -0
  69. package/dist/docs/patterns/ai-router.ts +194 -0
  70. package/dist/docs/patterns/ai-tool-schema.ts +237 -0
  71. package/dist/docs/patterns/api-route.ts +241 -0
  72. package/dist/docs/patterns/backtest-engine.ts +499 -0
  73. package/dist/docs/patterns/browser-review.ts +292 -0
  74. package/dist/docs/patterns/combobox.tsx +300 -0
  75. package/dist/docs/patterns/component.tsx +262 -0
  76. package/dist/docs/patterns/daemon-process.ts +338 -0
  77. package/dist/docs/patterns/data-pipeline.ts +297 -0
  78. package/dist/docs/patterns/database-migration.ts +466 -0
  79. package/dist/docs/patterns/e2e-test.ts +629 -0
  80. package/dist/docs/patterns/error-handling.ts +312 -0
  81. package/dist/docs/patterns/execution-safety.ts +601 -0
  82. package/dist/docs/patterns/financial-transaction.ts +342 -0
  83. package/dist/docs/patterns/funding-plan.ts +462 -0
  84. package/dist/docs/patterns/game-entity.ts +137 -0
  85. package/dist/docs/patterns/game-loop.ts +113 -0
  86. package/dist/docs/patterns/game-state.ts +143 -0
  87. package/dist/docs/patterns/job-queue.ts +225 -0
  88. package/dist/docs/patterns/kongo-integration.ts +164 -0
  89. package/dist/docs/patterns/middleware.ts +363 -0
  90. package/dist/docs/patterns/mobile-screen.tsx +139 -0
  91. package/dist/docs/patterns/mobile-service.ts +167 -0
  92. package/dist/docs/patterns/multi-tenant.ts +382 -0
  93. package/dist/docs/patterns/oauth-token-lifecycle.ts +223 -0
  94. package/dist/docs/patterns/outbound-rate-limiter.ts +260 -0
  95. package/dist/docs/patterns/prompt-template.ts +195 -0
  96. package/dist/docs/patterns/revenue-source-adapter.ts +311 -0
  97. package/dist/docs/patterns/service.ts +224 -0
  98. package/dist/docs/patterns/sse-endpoint.ts +118 -0
  99. package/dist/docs/patterns/stablecoin-adapter.ts +511 -0
  100. package/dist/docs/patterns/third-party-script.ts +68 -0
  101. package/dist/scripts/thumper/gom-jabbar.sh +241 -0
  102. package/dist/scripts/thumper/relay.sh +610 -0
  103. package/dist/scripts/thumper/scan.sh +359 -0
  104. package/dist/scripts/thumper/thumper.sh +190 -0
  105. package/dist/scripts/thumper/water-rings.sh +76 -0
  106. package/dist/scripts/voidforge.js +1 -1
  107. package/package.json +1 -1
  108. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,297 @@
1
+ /**
2
+ * Pattern: Data Pipeline (ETL / Staged Processing)
3
+ *
4
+ * Key principles:
5
+ * - Typed stages with validate/transform/load — each stage is a pure function
6
+ * - Pipeline composes stages sequentially with validation between each step
7
+ * - Checkpoint/resume for long-running pipelines (persist progress to disk)
8
+ * - Idempotent processing — safe to re-run via dedup key
9
+ * - Data quality checks at boundaries: null rates, range validation, freshness
10
+ * - Batch vs streaming mode toggle — same stages, different execution
11
+ * - Error handling: skip-and-log vs fail-fast configurable per pipeline
12
+ * - Progress reporting callback for observability
13
+ *
14
+ * Agents: Stark (backend), Banner (data), L (monitoring)
15
+ *
16
+ * Framework adaptations:
17
+ * Node.js: This file (streams + fs checkpoints)
18
+ * Python: pandas/polars DataFrames, or Apache Beam for distributed
19
+ * SQL: dbt models as stages, incremental materialization as checkpointing
20
+ * Go: Pipeline pattern with channels, errgroup for parallel stages
21
+ */
22
+
23
+ import { createHash } from 'node:crypto';
24
+ import { writeFile, readFile, mkdir } from 'node:fs/promises';
25
+ import { existsSync } from 'node:fs';
26
+ import { join } from 'node:path';
27
+ import { Readable, Transform, Writable } from 'node:stream';
28
+
29
+ // ── Stage Interface ─────────────────────────────────────
30
+
31
+ interface PipelineStage<TIn, TOut> {
32
+ /** Unique name for checkpoint tracking */
33
+ name: string;
34
+ /** Validate input before processing — throw on invalid */
35
+ validate(input: TIn): Promise<void>;
36
+ /** Transform input to output */
37
+ transform(input: TIn): Promise<TOut>;
38
+ /** Optional load step — write to destination (DB, file, API) */
39
+ load?(output: TOut): Promise<void>;
40
+ }
41
+
42
+ // ── Configuration ───────────────────────────────────────
43
+
44
+ type ErrorMode = 'skip-and-log' | 'fail-fast';
45
+ type ExecutionMode = 'batch' | 'streaming';
46
+
47
+ interface PipelineConfig {
48
+ name: string;
49
+ checkpointDir: string;
50
+ errorMode: ErrorMode;
51
+ executionMode: ExecutionMode;
52
+ /** Dedup key extractor — returns a unique key per record to prevent reprocessing */
53
+ dedupKey?: (record: unknown) => string;
54
+ /** Progress callback — called after each stage completes */
55
+ onProgress?: (stage: string, processed: number, total: number) => void;
56
+ /** Maximum acceptable null rate (0.0 - 1.0) before failing quality check */
57
+ maxNullRate?: number;
58
+ }
59
+
60
+ // ── Data Quality ────────────────────────────────────────
61
+
62
+ interface QualityReport {
63
+ stage: string;
64
+ recordCount: number;
65
+ nullRates: Record<string, number>;
66
+ rangeViolations: string[];
67
+ schemaErrors: string[];
68
+ freshness: { oldestRecord: string; newestRecord: string } | null;
69
+ passed: boolean;
70
+ }
71
+
72
+ function checkNullRate(
73
+ records: Record<string, unknown>[],
74
+ fields: string[],
75
+ maxRate: number
76
+ ): { field: string; rate: number }[] {
77
+ const violations: { field: string; rate: number }[] = [];
78
+ for (const field of fields) {
79
+ const nullCount = records.filter(r => r[field] == null).length;
80
+ const rate = records.length > 0 ? nullCount / records.length : 0;
81
+ if (rate > maxRate) {
82
+ violations.push({ field, rate });
83
+ }
84
+ }
85
+ return violations;
86
+ }
87
+
88
+ function checkRange(
89
+ records: Record<string, unknown>[],
90
+ field: string,
91
+ min: number,
92
+ max: number
93
+ ): string[] {
94
+ const violations: string[] = [];
95
+ for (let i = 0; i < records.length; i++) {
96
+ const val = records[i][field];
97
+ if (typeof val === 'number' && (val < min || val > max)) {
98
+ violations.push(`Record ${i}: ${field}=${val} outside [${min}, ${max}]`);
99
+ }
100
+ }
101
+ return violations;
102
+ }
103
+
104
+ // ── Checkpoint Persistence ──────────────────────────────
105
+
106
+ interface Checkpoint {
107
+ pipelineName: string;
108
+ completedStages: string[];
109
+ processedKeys: string[];
110
+ lastUpdated: string;
111
+ intermediateData: unknown;
112
+ }
113
+
114
+ async function saveCheckpoint(dir: string, checkpoint: Checkpoint): Promise<void> {
115
+ if (!existsSync(dir)) {
116
+ await mkdir(dir, { recursive: true });
117
+ }
118
+ const filePath = join(dir, `${checkpoint.pipelineName}.checkpoint.json`);
119
+ await writeFile(filePath, JSON.stringify(checkpoint, null, 2), 'utf-8');
120
+ }
121
+
122
+ async function loadCheckpoint(dir: string, pipelineName: string): Promise<Checkpoint | null> {
123
+ const filePath = join(dir, `${pipelineName}.checkpoint.json`);
124
+ if (!existsSync(filePath)) return null;
125
+ const raw = await readFile(filePath, 'utf-8');
126
+ return JSON.parse(raw) as Checkpoint;
127
+ }
128
+
129
+ // ── Deduplication ───────────────────────────────────────
130
+
131
+ function computeDedupHash(record: unknown): string {
132
+ return createHash('sha256').update(JSON.stringify(record)).digest('hex');
133
+ }
134
+
135
+ // ── Pipeline Engine ─────────────────────────────────────
136
+
137
+ interface StageResult<T> {
138
+ data: T;
139
+ skipped: number;
140
+ errors: Array<{ index: number; error: string }>;
141
+ }
142
+
143
+ class Pipeline {
144
+ private stages: PipelineStage<unknown, unknown>[] = [];
145
+ private config: PipelineConfig;
146
+
147
+ constructor(config: PipelineConfig) {
148
+ this.config = config;
149
+ }
150
+
151
+ /** Add a typed stage — stages chain sequentially */
152
+ addStage<TIn, TOut>(stage: PipelineStage<TIn, TOut>): Pipeline {
153
+ this.stages.push(stage as PipelineStage<unknown, unknown>);
154
+ return this;
155
+ }
156
+
157
+ /** Run pipeline with checkpoint/resume support */
158
+ async run<TIn, TOut>(input: TIn): Promise<StageResult<TOut>> {
159
+ const checkpoint = await loadCheckpoint(this.config.checkpointDir, this.config.name);
160
+ const completedStages = new Set(checkpoint?.completedStages ?? []);
161
+ const processedKeys = new Set(checkpoint?.processedKeys ?? []);
162
+
163
+ let current: unknown = checkpoint?.intermediateData ?? input;
164
+ let totalSkipped = 0;
165
+ const allErrors: Array<{ index: number; error: string }> = [];
166
+
167
+ for (let i = 0; i < this.stages.length; i++) {
168
+ const stage = this.stages[i];
169
+
170
+ // Skip already-completed stages on resume
171
+ if (completedStages.has(stage.name)) {
172
+ continue;
173
+ }
174
+
175
+ try {
176
+ // Validate input to this stage
177
+ await stage.validate(current);
178
+
179
+ // Dedup check — skip records already processed
180
+ if (this.config.dedupKey && Array.isArray(current)) {
181
+ const before = (current as unknown[]).length;
182
+ current = (current as unknown[]).filter(record => {
183
+ const key = this.config.dedupKey!(record);
184
+ return !processedKeys.has(key);
185
+ });
186
+ totalSkipped += before - (current as unknown[]).length;
187
+ }
188
+
189
+ // Transform
190
+ current = await stage.transform(current);
191
+
192
+ // Load (if stage has a load step)
193
+ if (stage.load) {
194
+ await stage.load(current);
195
+ }
196
+
197
+ // Track processed keys for idempotency
198
+ if (this.config.dedupKey && Array.isArray(current)) {
199
+ for (const record of current as unknown[]) {
200
+ processedKeys.add(this.config.dedupKey(record));
201
+ }
202
+ }
203
+
204
+ // Checkpoint after each stage
205
+ await saveCheckpoint(this.config.checkpointDir, {
206
+ pipelineName: this.config.name,
207
+ completedStages: [...completedStages, stage.name],
208
+ processedKeys: [...processedKeys],
209
+ lastUpdated: new Date().toISOString(),
210
+ intermediateData: current,
211
+ });
212
+ completedStages.add(stage.name);
213
+
214
+ // Progress reporting
215
+ const total = Array.isArray(current) ? (current as unknown[]).length : 1;
216
+ this.config.onProgress?.(stage.name, i + 1, this.stages.length);
217
+
218
+ } catch (err) {
219
+ const errorMsg = err instanceof Error ? err.message : String(err);
220
+ allErrors.push({ index: i, error: `${stage.name}: ${errorMsg}` });
221
+
222
+ if (this.config.errorMode === 'fail-fast') {
223
+ throw new Error(`Pipeline failed at stage "${stage.name}": ${errorMsg}`);
224
+ }
225
+ // skip-and-log: continue to next stage with current data
226
+ console.error(JSON.stringify({
227
+ event: 'pipeline.stage.error',
228
+ pipeline: this.config.name,
229
+ stage: stage.name,
230
+ error: errorMsg,
231
+ mode: 'skip-and-log',
232
+ }));
233
+ }
234
+ }
235
+
236
+ return {
237
+ data: current as TOut,
238
+ skipped: totalSkipped,
239
+ errors: allErrors,
240
+ };
241
+ }
242
+ }
243
+
244
+ export type {
245
+ PipelineStage, PipelineConfig, QualityReport, Checkpoint, StageResult,
246
+ ErrorMode, ExecutionMode,
247
+ };
248
+ export {
249
+ Pipeline, saveCheckpoint, loadCheckpoint,
250
+ checkNullRate, checkRange, computeDedupHash,
251
+ };
252
+
253
+ // ── Framework Adaptations ───────────────────────────────
254
+ //
255
+ // === Python (pandas/polars) ===
256
+ //
257
+ // import polars as pl
258
+ //
259
+ // class ExtractStage:
260
+ // def validate(self, path: str) -> None:
261
+ // if not Path(path).exists():
262
+ // raise FileNotFoundError(path)
263
+ //
264
+ // def transform(self, path: str) -> pl.DataFrame:
265
+ // return pl.read_csv(path)
266
+ //
267
+ // class CleanStage:
268
+ // def validate(self, df: pl.DataFrame) -> None:
269
+ // null_rate = df.null_count().sum_horizontal()[0] / (df.height * df.width)
270
+ // if null_rate > 0.3:
271
+ // raise ValueError(f"Null rate {null_rate:.1%} exceeds 30% threshold")
272
+ //
273
+ // def transform(self, df: pl.DataFrame) -> pl.DataFrame:
274
+ // return df.drop_nulls().with_columns(
275
+ // pl.col("timestamp").str.to_datetime()
276
+ // )
277
+ //
278
+ // # Checkpoint: df.write_parquet("checkpoint/clean.parquet")
279
+ // # Resume: pl.read_parquet("checkpoint/clean.parquet")
280
+ // # Dedup: df.unique(subset=["id"])
281
+ //
282
+ // === SQL-based ETL (dbt) ===
283
+ //
284
+ // -- models/staging/stg_orders.sql
285
+ // -- Each model = one pipeline stage. dbt handles DAG ordering.
286
+ // -- Incremental materialization = checkpoint/resume.
287
+ // {{ config(materialized='incremental', unique_key='order_id') }}
288
+ //
289
+ // SELECT order_id, customer_id, amount_cents, created_at
290
+ // FROM {{ source('raw', 'orders') }}
291
+ // {% if is_incremental() %}
292
+ // WHERE created_at > (SELECT MAX(created_at) FROM {{ this }})
293
+ // {% endif %}
294
+ //
295
+ // -- Quality: dbt tests (not_null, unique, accepted_values, relationships)
296
+ // -- Dedup: unique_key in incremental config
297
+ // -- Error handling: dbt test --warn-error for fail-fast, default for skip-and-log