mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
* feat(agent): add bounded managed dynamic workflows and verified lifecycle observation * feat(plugins): integrate managed workflows with mod policy and capability discovery * feat(managed): unify console runs and verified advisory learning * fix(managed): hydrate native recall receipts validated on ruOS * docs(managed): record authenticated console host blocker * docs(managed): qualify installed console and compatible native host * feat(managed): integrate verified cycles and isolate native memory * fix(managed): enforce offline native models and qualify feedback E2E * fix(managed): independent security and correctness review findings - gate managed_agent_interrupt through the managed_agent_control policy; terminate obeys the allowlist and deletes only its own environment when RUFLO_MANAGED_CONTROL=1 - track only events from the acknowledged message so a later poll cannot report the previous turn as finished - require the canonical base64 verifier signature so one receipt cannot fill the ledger - register RUFLO_MANAGED_AGENTS_BASE_URL as a trust-boundary env var (env-precedence audit) and key the credential scope marker with a per-process HMAC (CodeQL) - best-effort local snapshot writes; report messageId when a prompt fails after it was sent - console: rescheduling is running, budget/action-blocked sessions are active, not finished - document the remaining known limits in ADR 0004 Co-Authored-By: RuFlo <ruv@ruv.net> * docs: user guide section for managed cloud agents; correct ruflo-agent README counts Co-Authored-By: RuFlo <ruv@ruv.net> * fix(managed): scope marker is a generation number, never a hash of the API key (CodeQL) Co-Authored-By: RuFlo <ruv@ruv.net> --------- Co-authored-by: r <r@x>
44 lines
4.4 KiB
JavaScript
44 lines
4.4 KiB
JavaScript
/** CPU-only collector/learning benchmark. Pass the directory compiled by tsc. */
|
|
import { pathToFileURL } from 'node:url';
|
|
import { resolve, join } from 'node:path';
|
|
import { performance } from 'node:perf_hooks';
|
|
import { createHash, generateKeyPairSync, sign } from 'node:crypto';
|
|
import { readFileSync } from 'node:fs';
|
|
const build = resolve(process.argv[2] ?? '/tmp/managed-integration-build');
|
|
const { ManagedRunCollector } = await import(pathToFileURL(join(build, 'managed-run-collector.js')));
|
|
const { canonical, digest, observationOf, recommend, trustedEvidence } = await import(pathToFileURL(join(build, 'managed-learning.js')));
|
|
const event = (id, type, rest = {}) => ({ id, type, processed_at: '2026-10-24T12:00:00Z', ...rest });
|
|
const events = [event('run', 'workflow_run.created', { workflow_run_id: 'wrun_a', phases: [] })];
|
|
for (let i = 0; i < 1000; i++) {
|
|
const s = { workflow_run_id: 'wrun_a', session_thread_id: `thread_${i}` };
|
|
events.push(event(`c${i}`, 'session.thread_created', s), event(`r${i}`, 'session.thread_status_running', s), event(`e${i}`, 'session.thread_status_terminated', s));
|
|
}
|
|
events.push(event('end', 'workflow_run.status_ended', { workflow_run_id: 'wrun_a', result: { type: 'completed' } }), event('idle', 'session.status_idle', { stop_reason: { type: 'end_turn' } }));
|
|
let reads = 0;
|
|
const collector = new ManagedRunCollector();
|
|
const transport = { readEvents: async () => { reads++; return [...events, ...events]; }, readSession: async () => { reads++; return { status: 'idle' }; } };
|
|
const start = performance.now();
|
|
const [one, two] = await Promise.all([collector.refresh('sesn_bench', transport), collector.refresh('sesn_bench', transport)]);
|
|
const collectionMs = performance.now() - start;
|
|
if (reads !== 2 || one.snapshot.threadCount !== 1000 || two.snapshot.verification !== 'unverified') throw Error('Collector invariant failed');
|
|
const pages = [];
|
|
for (let i = 0; i < 100; i++) { const at = performance.now(); collector.page('sesn_bench', (i % 16) * 60); pages.push(performance.now() - at); }
|
|
const before = reads;
|
|
for (let i = 0; i < 1000; i++) collector.snapshots();
|
|
if (reads !== before) throw Error('Inactive traffic');
|
|
const pair = generateKeyPairSync('ed25519'), key = pair.publicKey.export({ format: 'pem', type: 'spki' }).toString();
|
|
const scope = { taskType: 'code-review', policyHash: digest('policy'), evaluatorHash: digest('evaluator') };
|
|
const rows = [];
|
|
for (const id of ['baseline', 'candidate']) for (let i = 0; i < 30; i++) {
|
|
const o = observationOf({ v: 1, attemptId: digest(`${id}-${i}`), taskHash: digest(`train-${i}`), sourceHash: digest('source'), artifactHash: digest('artifact'), corpusHash: digest('train'), ...scope, split: 'train', trial: 0,
|
|
strategy: { id, model: 'claude-fixture', workers: 1, template: 'review' }, budgetCents: 250, costCents: id === 'candidate' ? 50 : 100, durationMs: 100,
|
|
checks: { acceptance: true, safety: true, replay: true, adversarial: true, drift: 0, driftThreshold: .05, rollbackRate: 0 } });
|
|
rows.push({ observation: o, signature: sign(null, Buffer.from(canonical(o)), pair.privateKey).toString('base64') });
|
|
}
|
|
const attestStart = performance.now(), trusted = trustedEvidence(rows, key), signatureVerificationMs = performance.now() - attestStart;
|
|
const samples = [];
|
|
for (let i = 0; i < 100; i++) { const at = performance.now(); const result = recommend(trusted, scope); if (result.selected?.strategy.id !== 'candidate') throw Error('Recommendation invariant'); samples.push(performance.now() - at); }
|
|
const median = xs => [...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)];
|
|
const sourceHashes = Object.fromEntries(['managed-run-collector.ts', 'managed-learning.ts', 'managed-run-store.ts', 'managed-learning-store.ts'].map(f => [f, createHash('sha256').update(readFileSync(`v3/@claude-flow/cli/src/services/${f}`)).digest('hex')]));
|
|
console.log(JSON.stringify({ kind: 'synthetic CPU and contract benchmark', node: process.version, sourceHashes, workers: 1000, replayedEvents: events.length * 2, uniqueEvents: one.events.length, eventReads: 1, sessionReads: 1, inactiveReads: reads - before, collectionMs, workerPageMedianMs: median(pages), signedTrainingRows: trusted.length, signatureVerificationMs, recommendationMedianMs: median(samples), syntheticSelected: 'candidate', limitations: 'Fixture costs and outcomes are synthetic. No live provider quality, dollar savings, native vector backend or GPU/UI performance is measured. Warm console rendering is separately covered by view tests.' }, null, 2));
|