claude-flow 3.7.0-alpha.67 → 3.7.0-alpha.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.7.0-alpha.67",
3
+ "version": "3.7.0-alpha.68",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ADR-121 Phase 26 — `ruflo benchmark cosign` CLI subcommand.
3
+ *
4
+ * Phase 24 shipped the M-of-N cryptographic primitive (`coSign()`).
5
+ * Phase 25 shipped the consumer-facing verify command. This phase
6
+ * closes the loop with the **third-party-verifier workflow**:
7
+ *
8
+ * # vendor publishes ledger.json + a benchmark claim
9
+ * # third party reviews + co-signs
10
+ * npx ruflo benchmark cosign vendor-ledger.json \
11
+ * --entry 11 \
12
+ * --label "independent-auditor" \
13
+ * --out audited-ledger.json
14
+ *
15
+ * # downstream consumers check the audited ledger requires
16
+ * # two signatures per entry
17
+ * npx ruflo benchmark verify audited-ledger.json --threshold 2
18
+ *
19
+ * Auto-generates an ephemeral Ed25519 keypair (writes the public
20
+ * key alongside the cosignature in the output ledger; private key
21
+ * not persisted by default). Pass `--key <path>` to persist the
22
+ * keypair (or read from a previously-persisted file) so the same
23
+ * signer can attest multiple entries / multiple ledgers with a
24
+ * stable identity.
25
+ */
26
+ import type { Command } from '../types.js';
27
+ export declare const benchmarkCosignCommand: Command;
28
+ export default benchmarkCosignCommand;
29
+ //# sourceMappingURL=benchmark-cosign.d.ts.map
@@ -0,0 +1,222 @@
1
+ /**
2
+ * ADR-121 Phase 26 — `ruflo benchmark cosign` CLI subcommand.
3
+ *
4
+ * Phase 24 shipped the M-of-N cryptographic primitive (`coSign()`).
5
+ * Phase 25 shipped the consumer-facing verify command. This phase
6
+ * closes the loop with the **third-party-verifier workflow**:
7
+ *
8
+ * # vendor publishes ledger.json + a benchmark claim
9
+ * # third party reviews + co-signs
10
+ * npx ruflo benchmark cosign vendor-ledger.json \
11
+ * --entry 11 \
12
+ * --label "independent-auditor" \
13
+ * --out audited-ledger.json
14
+ *
15
+ * # downstream consumers check the audited ledger requires
16
+ * # two signatures per entry
17
+ * npx ruflo benchmark verify audited-ledger.json --threshold 2
18
+ *
19
+ * Auto-generates an ephemeral Ed25519 keypair (writes the public
20
+ * key alongside the cosignature in the output ledger; private key
21
+ * not persisted by default). Pass `--key <path>` to persist the
22
+ * keypair (or read from a previously-persisted file) so the same
23
+ * signer can attest multiple entries / multiple ledgers with a
24
+ * stable identity.
25
+ */
26
+ import { promises as fs } from 'node:fs';
27
+ import { resolve } from 'node:path';
28
+ import { generateKeyPairSync, createPrivateKey, createPublicKey } from 'node:crypto';
29
+ import { output } from '../output.js';
30
+ async function loadOrGenerateKeypair(keyPath) {
31
+ if (keyPath) {
32
+ const abs = resolve(process.cwd(), keyPath);
33
+ try {
34
+ const raw = await fs.readFile(abs, 'utf8');
35
+ const parsed = JSON.parse(raw);
36
+ const privateKey = createPrivateKey({ key: Buffer.from(parsed.privateKey, 'hex'), format: 'der', type: 'pkcs8' });
37
+ const publicKey = createPublicKey({ key: Buffer.from(parsed.publicKey, 'hex'), format: 'der', type: 'spki' });
38
+ return { keypair: { privateKey, publicKey }, source: 'loaded' };
39
+ }
40
+ catch (err) {
41
+ // File doesn't exist yet — generate a fresh keypair and persist it.
42
+ const kp = generateKeyPairSync('ed25519');
43
+ const pkcs8 = kp.privateKey.export({ type: 'pkcs8', format: 'der' }).toString('hex');
44
+ const spki = kp.publicKey.export({ type: 'spki', format: 'der' }).toString('hex');
45
+ await fs.writeFile(abs, JSON.stringify({ privateKey: pkcs8, publicKey: spki }, null, 2));
46
+ return { keypair: kp, source: 'persisted' };
47
+ }
48
+ }
49
+ return { keypair: generateKeyPairSync('ed25519'), source: 'generated' };
50
+ }
51
+ export const benchmarkCosignCommand = {
52
+ name: 'cosign',
53
+ description: 'Add a third-party co-signature to an entry in a benchmark ledger (Phase 24 M-of-N attestation)',
54
+ options: [
55
+ {
56
+ name: 'entry',
57
+ short: 'e',
58
+ type: 'number',
59
+ description: 'Entry sequence number to co-sign (1-based). Default: last entry.',
60
+ },
61
+ {
62
+ name: 'label',
63
+ short: 'l',
64
+ type: 'string',
65
+ description: 'Human-readable label for this signer (e.g. "third-party-verifier")',
66
+ },
67
+ {
68
+ name: 'out',
69
+ short: 'o',
70
+ type: 'string',
71
+ description: 'Output path for the updated ledger. Default: overwrite the input.',
72
+ },
73
+ {
74
+ name: 'key',
75
+ short: 'k',
76
+ type: 'string',
77
+ description: 'Path to a JSON keypair file (pkcs8 + spki hex). If missing, a fresh ephemeral key is generated; if path doesn\'t exist, a new key is generated and persisted there.',
78
+ },
79
+ {
80
+ name: 'all',
81
+ type: 'boolean',
82
+ description: 'Co-sign EVERY entry in the ledger (useful for batch attestation by a single signer).',
83
+ default: 'false',
84
+ },
85
+ {
86
+ name: 'json',
87
+ type: 'boolean',
88
+ description: 'Output JSON instead of human-readable',
89
+ default: 'false',
90
+ },
91
+ ],
92
+ examples: [
93
+ { command: 'ruflo benchmark cosign ledger.json --entry 11 --label "auditor-A"', description: 'Co-sign entry 11 with an ephemeral key' },
94
+ { command: 'ruflo benchmark cosign ledger.json --all --label "release-gate" --key ./auditor.key.json', description: 'Co-sign every entry with a persisted key' },
95
+ { command: 'ruflo benchmark cosign ledger.json -e 11 -o audited.json', description: 'Write the cosigned ledger to a new file' },
96
+ ],
97
+ action: async (ctx) => {
98
+ const pathArg = ctx.args[0];
99
+ const asJson = ctx.flags.json === true || ctx.flags.json === 'true';
100
+ const all = ctx.flags.all === true || ctx.flags.all === 'true';
101
+ const entryFlag = ctx.flags.entry !== undefined ? Number(ctx.flags.entry) : undefined;
102
+ const label = ctx.flags.label;
103
+ const outPath = ctx.flags.out;
104
+ const keyPath = ctx.flags.key;
105
+ if (!pathArg || typeof pathArg !== 'string') {
106
+ const err = 'usage: ruflo benchmark cosign <path-to-ledger.json> [--entry N | --all] [--label "name"] [--out path] [--key path] [--json]';
107
+ if (asJson)
108
+ output.printJson({ ok: false, error: err });
109
+ else
110
+ output.printError(err);
111
+ return { success: false, exitCode: 1 };
112
+ }
113
+ if (!all && entryFlag !== undefined && (!Number.isFinite(entryFlag) || entryFlag < 1)) {
114
+ const err = `--entry must be a positive integer, got: ${ctx.flags.entry}`;
115
+ if (asJson)
116
+ output.printJson({ ok: false, error: err });
117
+ else
118
+ output.printError(err);
119
+ return { success: false, exitCode: 1 };
120
+ }
121
+ const inPath = resolve(process.cwd(), pathArg);
122
+ let raw;
123
+ try {
124
+ raw = await fs.readFile(inPath, 'utf8');
125
+ }
126
+ catch (err) {
127
+ const msg = err instanceof Error ? err.message : String(err);
128
+ if (asJson)
129
+ output.printJson({ ok: false, error: `cannot read ${inPath}: ${msg}` });
130
+ else
131
+ output.printError(`Cannot read ${inPath}: ${msg}`);
132
+ return { success: false, exitCode: 1 };
133
+ }
134
+ let ledger;
135
+ try {
136
+ ledger = JSON.parse(raw);
137
+ }
138
+ catch (err) {
139
+ const msg = err instanceof Error ? err.message : String(err);
140
+ if (asJson)
141
+ output.printJson({ ok: false, error: `not valid JSON: ${msg}` });
142
+ else
143
+ output.printError(`Not valid JSON: ${msg}`);
144
+ return { success: false, exitCode: 1 };
145
+ }
146
+ if (typeof ledger.version !== 'number' || !Array.isArray(ledger.entries) || ledger.entries.length === 0) {
147
+ const err = `not a benchmark ledger — expected { version: number, entries: [non-empty] }`;
148
+ if (asJson)
149
+ output.printJson({ ok: false, error: err });
150
+ else
151
+ output.printError(err);
152
+ return { success: false, exitCode: 1 };
153
+ }
154
+ // Load or generate the signing keypair.
155
+ const { keypair, source: keypairSource } = await loadOrGenerateKeypair(keyPath);
156
+ // Determine which entries to co-sign.
157
+ let targetIndices;
158
+ if (all) {
159
+ targetIndices = ledger.entries.map((_, i) => i);
160
+ }
161
+ else {
162
+ const seq = entryFlag ?? ledger.entries[ledger.entries.length - 1].sequence;
163
+ const idx = ledger.entries.findIndex(e => e.sequence === seq);
164
+ if (idx === -1) {
165
+ const err = `entry sequence ${seq} not found in ledger (chain has ${ledger.entries.length} entries with sequences 1..${ledger.entries.length})`;
166
+ if (asJson)
167
+ output.printJson({ ok: false, error: err });
168
+ else
169
+ output.printError(err);
170
+ return { success: false, exitCode: 1 };
171
+ }
172
+ targetIndices = [idx];
173
+ }
174
+ // Lazy-load the cosign primitive from the published embeddings package.
175
+ const { coSign } = await import('@claude-flow/embeddings/witness-ledger');
176
+ // Mutate a copy of the ledger.
177
+ const newEntries = ledger.entries.map((e, i) => targetIndices.includes(i)
178
+ ? coSign(e, keypair, label ? { signerLabel: label } : {})
179
+ : e);
180
+ const newLedger = { ...ledger, entries: newEntries };
181
+ // Write output.
182
+ const writePath = resolve(process.cwd(), outPath ?? pathArg);
183
+ await fs.writeFile(writePath, JSON.stringify(newLedger, null, 2));
184
+ const publicKeyHex = keypair.publicKey.export({ type: 'spki', format: 'der' }).toString('hex');
185
+ if (asJson) {
186
+ output.printJson({
187
+ ok: true,
188
+ inPath,
189
+ outPath: writePath,
190
+ entriesCosigned: targetIndices.length,
191
+ targetSequences: targetIndices.map(i => ledger.entries[i].sequence),
192
+ signerLabel: label ?? null,
193
+ publicKey: publicKeyHex,
194
+ keypairSource,
195
+ });
196
+ return { success: true, exitCode: 0 };
197
+ }
198
+ output.writeln();
199
+ output.writeln(output.bold(`Co-signed ${targetIndices.length} entr${targetIndices.length === 1 ? 'y' : 'ies'}`));
200
+ output.writeln(output.dim('─'.repeat(60)));
201
+ output.writeln(` input: ${inPath}`);
202
+ output.writeln(` output: ${writePath}`);
203
+ output.writeln(` signer label: ${label ?? '(unlabeled)'}`);
204
+ output.writeln(` signer pubkey: ${publicKeyHex.slice(0, 32)}...`);
205
+ output.writeln(` keypair: ${keypairSource}${keyPath ? ` → ${keyPath}` : ''}`);
206
+ output.writeln();
207
+ output.writeln(' entries:');
208
+ for (const i of targetIndices) {
209
+ const e = newEntries[i];
210
+ const cosigCount = Array.isArray(e.cosignatures) ? e.cosignatures.length : 0;
211
+ const hashShort = e.contentHash.slice(0, 12) + '…';
212
+ output.writeln(` [${String(e.sequence).padStart(2)}] ${e.benchmark.padEnd(28)} now ${1 + cosigCount} sigs (${hashShort})`);
213
+ }
214
+ output.writeln();
215
+ output.writeln(`Next: verify the cosigned ledger with the new threshold:`);
216
+ output.writeln(output.dim(` npx ruflo benchmark verify ${writePath} --threshold 2`));
217
+ output.writeln();
218
+ return { success: true, exitCode: 0 };
219
+ },
220
+ };
221
+ export default benchmarkCosignCommand;
222
+ //# sourceMappingURL=benchmark-cosign.js.map
@@ -425,6 +425,8 @@ const allCommand = {
425
425
  // ============================================================================
426
426
  // ADR-121 Phase 25 — `benchmark verify` for the chained witness ledger.
427
427
  import { benchmarkVerifyCommand } from './benchmark-verify.js';
428
+ // ADR-121 Phase 26 — `benchmark cosign` for M-of-N third-party attestation.
429
+ import { benchmarkCosignCommand } from './benchmark-cosign.js';
428
430
  export const benchmarkCommand = {
429
431
  name: 'benchmark',
430
432
  description: 'Performance benchmarking for self-learning and neural systems',
@@ -434,6 +436,7 @@ export const benchmarkCommand = {
434
436
  memoryCommand,
435
437
  allCommand,
436
438
  benchmarkVerifyCommand,
439
+ benchmarkCosignCommand,
437
440
  ],
438
441
  examples: [
439
442
  { command: 'claude-flow benchmark pretrain', description: 'Benchmark pre-training system' },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.67",
3
+ "version": "3.7.0-alpha.68",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",