Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(ai-team): newest-first lists, complete evidence audit, honest version (0.3.4) (#4467)

rUvd3948da2d569
diff --git a/plugins/ruflo-ai-team/.claude-plugin/plugin.json b/plugins/ruflo-ai-team/.claude-plugin/plugin.json
index eea393dc0e..f5ab38cd8d 100644
--- a/plugins/ruflo-ai-team/.claude-plugin/plugin.json
+++ b/plugins/ruflo-ai-team/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-ai-team",
"description": "Give Claude a tenant-isolated AI team that divides work, coordinates progress, recalls approved context, and returns evidence-backed results.",
- "version": "0.3.3",
+ "version": "0.3.4",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-ai-team/CHANGELOG.md b/plugins/ruflo-ai-team/CHANGELOG.md
index e7817cec46..d3886f7aad 100644
--- a/plugins/ruflo-ai-team/CHANGELOG.md
+++ b/plugins/ruflo-ai-team/CHANGELOG.md
@@ -2,6 +2,12 @@
Newest first. One `## <version> — <date>` heading per version, then `feat:`, `fix:`, `breaking:` and `chore:` bullets (ADR-478). Built from git history; older versions: `git log -- plugins/ruflo-ai-team`.
+## 0.3.4 — 2026-10-24
+- fix: run and team lists read newest first, so a tenant with more than 100 runs sees its latest runs on the board instead of an arbitrary 100
+- fix: evidence exports query audit events by target instead of reading the first 1000 audit records and filtering, which dropped a run's events once a tenant had more audit history than that
+- fix: the service reports the plugin version (package.json was still 0.1.6, so /health could not tell a deployment apart)
+- chore: Firestore store tests with a limit-after-order double
+
## 0.3.3 — 2026-10-22
- fix: `annotation-review.md` documented only 12 of the 14 live tools, missing `team_board` and `run_complete` (added at 0.2.0/0.2.1) from its readOnly/destructive/idempotent/openWorld classification table
- chore: smoke now asserts the doc's tool list matches the live server tool set exactly, so this can't silently drift again
diff --git a/plugins/ruflo-ai-team/deploy/cloud-run.yaml b/plugins/ruflo-ai-team/deploy/cloud-run.yaml
index 76edd187d9..84f5fa758c 100644
--- a/plugins/ruflo-ai-team/deploy/cloud-run.yaml
+++ b/plugins/ruflo-ai-team/deploy/cloud-run.yaml
@@ -13,7 +13,7 @@ spec:
timeoutSeconds: 60
serviceAccountName: ruflo-ai-team@PROJECT_ID.iam.gserviceaccount.com
containers:
- - image: REGION-docker.pkg.dev/PROJECT_ID/ruflo/ruflo-ai-team:0.1.6
+ - image: REGION-docker.pkg.dev/PROJECT_ID/ruflo/ruflo-ai-team:0.3.4
ports: [{ containerPort: 8080 }]
resources:
limits: { cpu: "1", memory: 1Gi }
diff --git a/plugins/ruflo-ai-team/package-lock.json b/plugins/ruflo-ai-team/package-lock.json
index 3c4f18524a..173f16b722 100644
--- a/plugins/ruflo-ai-team/package-lock.json
+++ b/plugins/ruflo-ai-team/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@ruflo/ai-team-service",
- "version": "0.1.6",
+ "version": "0.3.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
diff --git a/plugins/ruflo-ai-team/package.json b/plugins/ruflo-ai-team/package.json
index 453c6a3c90..3da8f0d3a7 100644
--- a/plugins/ruflo-ai-team/package.json
+++ b/plugins/ruflo-ai-team/package.json
@@ -1,6 +1,6 @@
{
"name": "@ruflo/ai-team-service",
- "version": "0.1.6",
+ "version": "0.3.4",
"private": true,
"type": "module",
"description": "Multi-tenant MCP control plane and Claude plugin for coordinated AI teams.",
diff --git a/plugins/ruflo-ai-team/src/store.mjs b/plugins/ruflo-ai-team/src/store.mjs
index ca70c94b25..e466b95d14 100644
--- a/plugins/ruflo-ai-team/src/store.mjs
+++ b/plugins/ruflo-ai-team/src/store.mjs
@@ -27,7 +27,7 @@ export class InMemoryStore {
bucket.runs.set(id, clone(value)); this.#audit(bucket, actor, 'run.created', id); return clone(value);
}
async getRun(tenantId, id) { const value = this.#bucket(tenantId).runs.get(id); return value ? clone(value) : null; }
- async listRuns(tenantId) { return [...this.#bucket(tenantId).runs.values()].map(clone); }
+ async listRuns(tenantId) { return [...this.#bucket(tenantId).runs.values()].reverse().map(clone); }
async updateRun(tenantId, id, patch, actor = '-') {
const bucket = this.#bucket(tenantId); const current = bucket.runs.get(id); if (!current) return null;
const value = { ...current, ...patch, id, updatedAt: now() }; bucket.runs.set(id, clone(value)); this.#audit(bucket, actor, `run.${value.status}`, id); return clone(value);
@@ -78,15 +78,22 @@ export class FirestoreStore {
#tenant(id) { return this.db.collection('ruflo_ai_team_tenants').doc(id); }
async #put(tenantId, kind, value) { await this.#tenant(tenantId).collection(kind).doc(value.id).set(value); return clone(value); }
async #get(tenantId, kind, id) { const snap = await this.#tenant(tenantId).collection(kind).doc(id).get(); return snap.exists ? snap.data() : null; }
- async #list(tenantId, kind, limit = 1000) { const snap = await this.#tenant(tenantId).collection(kind).limit(limit).get(); return snap.docs.map((d) => d.data()); }
+ async #list(tenantId, kind, limit = 1000, newestFirst = false) {
+ // Firestore returns document-id order without orderBy, so a capped read of a larger
+ // collection would keep an arbitrary slice. Order on createdAt (single-field index)
+ // wherever the cap can bite and recency matters.
+ const col = this.#tenant(tenantId).collection(kind);
+ const snap = await (newestFirst ? col.orderBy('createdAt', 'desc') : col).limit(limit).get();
+ return snap.docs.map((d) => d.data());
+ }
async #audit(tenantId, actor, eventType, targetId) { const id = randomUUID(); await this.#put(tenantId, 'audit', { id, at: now(), actor, eventType, targetId }); }
async createTeam(t, i, a='-') { const v={id:`team_${randomUUID()}`,name:i.name,objective:i.objective,roles:i.roles,status:'active',createdAt:now(),updatedAt:now()}; await this.#put(t,'teams',v); await this.#audit(t,a,'team.created',v.id); return v; }
- async listTeams(t) { return this.#list(t,'teams'); }
+ async listTeams(t) { return this.#list(t,'teams',1000,true); }
async getTeam(t,id) { return this.#get(t,'teams',id); }
async updateTeam(t,id,p,a='-') { const c=await this.#get(t,'teams',id); if(!c)return null; const v={...c,...p,id,updatedAt:now()}; await this.#put(t,'teams',v); await this.#audit(t,a,'team.updated',id); return v; }
async createRun(t,i,a='-') { if(!await this.#get(t,'teams',i.teamId))return null; const v={id:`run_${randomUUID()}`,teamId:i.teamId,objective:i.objective,budgetUnits:i.budgetUnits,spentUnits:0,status:'planned',createdAt:now(),updatedAt:now()}; await this.#put(t,'runs',v); await this.#audit(t,a,'run.created',v.id); return v; }
async getRun(t,id) { return this.#get(t,'runs',id); }
- async listRuns(t) { return this.#list(t,'runs',100); }
+ async listRuns(t) { return this.#list(t,'runs',100,true); }
async updateRun(t,id,p,a='-') { const c=await this.#get(t,'runs',id); if(!c)return null; const v={...c,...p,id,updatedAt:now()}; await this.#put(t,'runs',v); await this.#audit(t,a,`run.${v.status}`,id); return v; }
async createTask(t,i,a='-') { const run=await this.#get(t,'runs',i.runId); if(!run||run.status==='complete')return null; const v={id:`task_${randomUUID()}`,runId:i.runId,title:i.title,description:i.description,assigneeRole:i.assigneeRole,status:'open',result:null,createdAt:now(),updatedAt:now()}; await this.#put(t,'tasks',v); await this.#audit(t,a,'task.created',v.id); return v; }
async listTasks(t,runId) { const snap=await this.#tenant(t).collection('tasks').where('runId','==',runId).limit(200).get(); return snap.docs.map(d=>d.data()); }
@@ -94,5 +101,7 @@ export class FirestoreStore {
async remember(t,i,a='-') { const timestamp=now(); const id=i.key||`mem_${randomUUID()}`; const previous=await this.#get(t,'memories',id); const v={id,teamId:i.teamId,runId:i.runId||null,text:i.text,tags:i.tags||[],provenance:i.provenance||'user',actorHash:a,contentHash:createHash('sha256').update(i.text).digest('hex'),safetyStatus:i.safetyStatus||'accepted',embeddingModel:'feature-hash-256',embeddingVersion:'1',createdAt:previous?.createdAt??timestamp,updatedAt:timestamp}; await this.#put(t,'memories',v); await this.#audit(t,a,'memory.remembered',v.id); return v; }
async listMemories(t,{teamId}={}) { let query=this.#tenant(t).collection('memories'); if(teamId)query=query.where('teamId','==',teamId); const snap=await query.limit(1000).get(); return snap.docs.map(d=>d.data()); }
async usage(t) { const [teams,runs,tasks,memories]=await Promise.all(['teams','runs','tasks','memories'].map(k=>this.#list(t,k))); return {teams:teams.length,runs:runs.length,tasks:tasks.length,memories:memories.length,limits:{teams:1,agentsPerTeam:3,monthlyTasks:100,runBudgetUnits:100}}; }
- async evidence(t,runId) { const run=await this.#get(t,'runs',runId); if(!run)return null; const tasks=await this.listTasks(t,runId); const targets=new Set([runId,run.teamId,...tasks.map(task=>task.id)]); return {schema:'ruflo.ai-team.evidence.v1',generatedAt:now(),run,team:await this.#get(t,'teams',run.teamId),tasks,audit:(await this.#list(t,'audit')).filter(x=>targets.has(x.targetId))}; }
+ async evidence(t,runId) { const run=await this.#get(t,'runs',runId); if(!run)return null; const tasks=await this.listTasks(t,runId); const targets=new Set([runId,run.teamId,...tasks.map(task=>task.id)]); const ids=[...targets]; const chunks=[]; for(let i=0;i<ids.length;i+=30)chunks.push(ids.slice(i,i+30)); // Firestore 'in' takes at most 30 values
+ const audit=(await Promise.all(chunks.map(async c=>(await this.#tenant(t).collection('audit').where('targetId','in',c).limit(1000).get()).docs.map(d=>d.data())))).flat().sort((a,b)=>a.at<b.at?-1:a.at>b.at?1:0);
+ return {schema:'ruflo.ai-team.evidence.v1',generatedAt:now(),run,team:await this.#get(t,'teams',run.teamId),tasks,audit}; }
}
diff --git a/plugins/ruflo-ai-team/test/firestore-store.node.mjs b/plugins/ruflo-ai-team/test/firestore-store.node.mjs
new file mode 100644
index 0000000000..17e3b3aede
--- /dev/null
+++ b/plugins/ruflo-ai-team/test/firestore-store.node.mjs
@@ -0,0 +1,68 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { FirestoreStore, InMemoryStore } from '../src/store.mjs';
+
+// Minimal Firestore double. Like the real thing it applies limit() AFTER ordering,
+// and with no orderBy returns documents in document-id order, not creation order.
+function fakeFirestore() {
+ const data = new Map();
+ const query = (path, filters = [], order = null, max = Infinity) => ({
+ where: (field, op, value) => query(path, [...filters, { field, op, value }], order, max),
+ orderBy: (field, dir = 'asc') => query(path, filters, { field, dir }, max),
+ limit: (n) => query(path, filters, order, n),
+ async get() {
+ let rows = [...(data.get(path)?.entries() ?? [])].sort(([a], [b]) => (a < b ? -1 : 1)).map(([, v]) => v);
+ for (const f of filters) {
+ if (f.op === '==') rows = rows.filter((r) => r[f.field] === f.value);
+ else if (f.op === 'in') { assert.ok(f.value.length <= 30, 'Firestore allows at most 30 values in an "in" filter'); rows = rows.filter((r) => f.value.includes(r[f.field])); }
+ else throw new Error(`unsupported op ${f.op}`);
+ }
+ if (order) { rows = rows.filter((r) => r[order.field] !== undefined).sort((a, b) => (a[order.field] < b[order.field] ? -1 : a[order.field] > b[order.field] ? 1 : 0)); if (order.dir === 'desc') rows.reverse(); }
+ return { docs: rows.slice(0, max).map((v) => ({ data: () => v })) };
+ },
+ });
+ const collection = (path) => ({
+ ...query(path),
+ doc: (id) => ({
+ async set(v) { if (!data.has(path)) data.set(path, new Map()); data.get(path).set(id, structuredClone(v)); },
+ async get() { const v = data.get(path)?.get(id); return { exists: v !== undefined, data: () => (v === undefined ? undefined : structuredClone(v)) }; },
+ collection: (name) => collection(`${path}/${id}/${name}`),
+ }),
+ });
+ return { collection };
+}
+
+test('listRuns returns the newest runs once a tenant has more than the page size', async () => {
+ const store = new FirestoreStore(fakeFirestore());
+ const team = await store.createTeam('t1', { name: 'T', objective: 'o', roles: [] });
+ const ids = [];
+ for (let i = 0; i < 105; i++) { const run = await store.createRun('t1', { teamId: team.id, objective: `run ${i}`, budgetUnits: 1 }); await store.updateRun('t1', run.id, { createdAt: new Date(Date.UTC(2026, 0, 1, 0, 0, i)).toISOString() }); ids.push(run.id); }
+ const listed = await store.listRuns('t1');
+ assert.equal(listed.length, 100);
+ assert.equal(listed[0].id, ids[104], 'newest run comes first');
+ assert.ok(!listed.some((r) => r.id === ids[0]), 'the oldest runs are the ones left out');
+});
+
+test('evidence keeps every audit event of the run however much other audit history exists', async () => {
+ const store = new FirestoreStore(fakeFirestore());
+ const team = await store.createTeam('t1', { name: 'T', objective: 'o', roles: [] });
+ const other = await store.createTeam('t1', { name: 'Other', objective: 'o', roles: [] });
+ for (let i = 0; i < 1100; i++) await store.updateTeam('t1', other.id, { name: `n${i}` });
+ const run = await store.createRun('t1', { teamId: team.id, objective: 'r', budgetUnits: 1 });
+ const tasks = [];
+ for (let i = 0; i < 35; i++) tasks.push(await store.createTask('t1', { runId: run.id, title: `t${i}`, description: 'd', assigneeRole: 'x' }));
+ const bundle = await store.evidence('t1', run.id);
+ const targets = new Set([run.id, team.id, ...tasks.map((t) => t.id)]);
+ assert.ok(bundle.audit.every((e) => targets.has(e.targetId)), 'only audit events about this run');
+ assert.ok(bundle.audit.some((e) => e.eventType === 'run.created'), 'run.created survives');
+ assert.equal(bundle.audit.filter((e) => e.eventType === 'task.created').length, 35, 'all task events survive (more than one in-filter chunk)');
+ assert.ok(bundle.audit.every((e, i, a) => i === 0 || a[i - 1].at <= e.at), 'audit is chronological');
+});
+
+test('both stores list runs newest first', async () => {
+ const mem = new InMemoryStore();
+ const team = await mem.createTeam('t', { name: 'T', objective: 'o', roles: [] });
+ const a = await mem.createRun('t', { teamId: team.id, objective: 'a', budgetUnits: 1 });
+ const b = await mem.createRun('t', { teamId: team.id, objective: 'b', budgetUnits: 1 });
+ assert.deepEqual((await mem.listRuns('t')).map((r) => r.id), [b.id, a.id]);
+});