π 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
ci(guard): fail when a non-bundled @claude-flow/* leaf changes without a publish
ruvnetf02759cd6d21
diff --git a/.github/workflows/v3-ci.yml b/.github/workflows/v3-ci.ymlindex 05c025a7b1..5fd3c9846f 100644--- a/.github/workflows/v3-ci.yml+++ b/.github/workflows/v3-ci.yml@@ -1742,6 +1742,28 @@ jobs:shell: bashrun: node scripts/audit-umbrella-version-lockstep.mjs+ - name: Fetch PR base ref (for the leaf-publish diff check)+ # The leaf-publish audit's diff check needs the base commit to compare+ # against. actions/checkout is shallow by default, so without this the+ # audit reports the diff check as NOT EXERCISED (it says so loudly+ # rather than passing silently) and only the range check runs.+ if: github.event_name == 'pull_request'+ shell: bash+ run: git fetch --no-tags --depth=1 origin "$GITHUB_BASE_REF"++ - name: Run leaf-package publish audit (#3335, #3390)+ # Only four @claude-flow/* components are bundled into the release+ # tarballs (INTERNAL_RUNTIME_PACKAGES). cli-core, neural, shared and+ # memory resolve from the REGISTRY, so a merged source change in one of+ # them does NOT ship with the three-package train β the release carries+ # the last published copy instead. #3334 lost a fix that way (#3335),+ # and #3390's reasoningBank fix would have shipped only its cli half if+ # @claude-flow/memory had not been published alongside v3.42.5. CI goes+ # green on such a change because the leaf's own tests run against+ # workspace source, which is exactly what makes it easy to miss.+ shell: bash+ run: node scripts/audit-leaf-package-publish.mjs+- name: Run better-sqlite3 override audit (#2219)# agentdb pins better-sqlite3 as an OPTIONAL dep at ^11.8.1, which has# no Node 24/25/26 prebuild β the optional native build fails silentlydiff --git a/scripts/audit-leaf-package-publish.mjs b/scripts/audit-leaf-package-publish.mjsnew file mode 100755index 0000000000..dca847e8cf--- /dev/null+++ b/scripts/audit-leaf-package-publish.mjs@@ -0,0 +1,234 @@+#!/usr/bin/env node+/**+ * Static guard for ruvnet/ruflo#3335 and #3390 (#3327 Finding A).+ *+ * The release train is exactly three packages β `@claude-flow/cli`,+ * `claude-flow`, `ruflo`. Four internal components ride along INSIDE those+ * tarballs (`INTERNAL_RUNTIME_PACKAGES` in stage-internal-runtime-bundles.mjs:+ * security, codex, mcp, plugin-agent-federation), so a source change in them+ * ships with the train.+ *+ * Every OTHER `@claude-flow/*` dependency of the CLI β currently cli-core,+ * neural, shared, memory β is resolved from the REGISTRY at the version+ * `v3/@claude-flow/cli/package.json` declares. A merged source change in one of+ * those does NOT ship with the train: the release silently carries the last+ * *published* copy of that leaf.+ *+ * This has now bitten twice:+ *+ * #3335 (2026-09-16) β PR #3334 fixed RUFLO_INTELLIGENCE_MODE in+ * @claude-flow/memory. v3.42.1 shipped cli/claude-flow/ruflo only; memory was+ * last published 2026-08-22, so a fresh consumer install had ZERO references+ * to the fix.+ *+ * #3390 (2026-09-21) β the reasoningBank activation fix spanned+ * cli/src/memory/memory-bridge.ts AND memory/src/controller-registry.ts.+ * Publishing only the train would have shipped the bridge half and left the+ * embedder half unreachable, leaving reasoningBank just as inert as before.+ * Caught by hand; [email protected] was published alongside v3.42.5.+ *+ * The trap is that CI goes GREEN on such a change: the leaf's own package tests+ * run against workspace source, so the fix looks verified while being unshippable.+ *+ * Asserts:+ *+ * 1. For every non-bundled `@claude-flow/*` dep of the CLI that exists as a+ * workspace package, the CLI's declared range must be satisfied by the+ * workspace's own version. A miss means the release resolves to something+ * OLDER than the source in this repo.+ *+ * 2. (diff mode β needs a base ref) If a leaf's publishable source changed+ * relative to the base ref but its package.json `version` did NOT, the+ * release cannot ship that change. Bump the leaf and publish it.+ *+ * Diff mode is skipped, loudly, when no base ref is available β "not exercised"+ * is reported distinctly from "clean" so a skip can never read as a pass.+ *+ * Usage: node scripts/audit-leaf-package-publish.mjs [--base <ref>]+ * GITHUB_BASE_REF is used automatically in PR CI.+ *+ * Exit codes: 0 ok / 1 violations (or the guard inspected nothing).+ */++import { readFileSync, existsSync } from 'node:fs';+import { execFileSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { dirname, join, resolve } from 'node:path';+import semver from 'semver';++import { INTERNAL_RUNTIME_PACKAGES } from './stage-internal-runtime-bundles.mjs';++const __dirname = dirname(fileURLToPath(import.meta.url));+const REPO_ROOT = resolve(__dirname, '..');+const CLI_PKG = 'v3/@claude-flow/cli/package.json';++// Files that actually end up in a published leaf tarball. A change to tests or+// fixtures cannot alter what consumers receive, so it must not trip the guard.+const PUBLISHABLE = /\/(src|bin|scripts)\/|\/package\.json$/;+const NOT_PUBLISHABLE = /(\.test\.|\.spec\.|__tests__\/|\/tests?\/|\/fixtures?\/|\.md$)/;++function readJson(rel) {+ const p = join(REPO_ROOT, rel);+ return existsSync(p) ? JSON.parse(readFileSync(p, 'utf8')) : null;+}++function git(args) {+ return execFileSync('git', args, { cwd: REPO_ROOT, encoding: 'utf8' }).trim();+}++// Time-boxed accepted findings. NOT a mute button: an expired entry is refused+// and fails the guard, so debt has to be revisited rather than quietly inherited.+const ACCEPTED = [+ {+ package: '@claude-flow/shared',+ check: 'range-coverage',+ // Pre-existing when this guard landed (2026-09-21). @claude-flow/[email protected]+ // IS published and is its `latest`, so the CLI is pinned one release behind a+ // package that shipped β stale, not unshippable, and materially different from+ // the #3335/#3390 failure this guard exists to catch. Raising the pin edits+ // v3/@claude-flow/cli deps, which forces a pnpm-lock.yaml regen in the same+ // change (#2540 -> #2552: frozen-lockfile otherwise fails ~25 jobs), so it wants+ // its own PR rather than riding along with a guard.+ reason: 'cli pins shared 3.0.0-alpha.7; workspace is 3.0.0-alpha.8 (published). Needs a pin bump + lockfile regen in its own PR.',+ expires: '2026-10-21',+ },+];++const today = new Date().toISOString().slice(0, 10);+function acceptedFor(pkg, check) {+ const hit = ACCEPTED.find((a) => a.package === pkg && a.check === check);+ if (!hit) return null;+ if (hit.expires < today) return { ...hit, expired: true };+ return hit;+}++const violations = [];+const notes = [];++// ββ 0. resolve the bundled set from its single source of truth βββββββββββββββ+// Imported, never re-typed: a hardcoded copy here would silently go stale the+// moment someone adds a package to the staging script, and this guard would+// then wave through exactly the class of bug it exists to catch.+const bundled = new Set(INTERNAL_RUNTIME_PACKAGES.map((p) => p.name));+if (bundled.size === 0) {+ console.error('β INTERNAL_RUNTIME_PACKAGES is empty β cannot classify deps. Guard aborted.');+ process.exit(1);+}++// ββ 1. enumerate the non-bundled leaves ββββββββββββββββββββββββββββββββββββββ+const cliPkg = readJson(CLI_PKG);+if (!cliPkg) {+ console.error(`β ${CLI_PKG} not found β guard aborted.`);+ process.exit(1);+}++const declared = { ...(cliPkg.dependencies ?? {}), ...(cliPkg.optionalDependencies ?? {}) };+const leaves = [];+for (const [name, range] of Object.entries(declared)) {+ if (!name.startsWith('@claude-flow/')) continue;+ if (bundled.has(name)) continue;+ const dir = `v3/${name}`;+ const pkg = readJson(`${dir}/package.json`);+ if (!pkg) continue; // not a workspace package β nothing in this repo to ship+ leaves.push({ name, range, dir, version: pkg.version });+}++console.log('leaf-package-publish audit β non-bundled @claude-flow/* deps of the CLI');+console.log(` bundled (ship with the train): ${[...bundled].join(', ')}`);++// A guard that inspects nothing must never report success.+if (leaves.length === 0) {+ console.error('β inspected 0 non-bundled leaves β the classifier is broken, not the repo.');+ console.error(' Refusing to report a clean result. Check CLI deps and INTERNAL_RUNTIME_PACKAGES.');+ process.exit(1);+}++// ββ 2. range must cover the workspace version ββββββββββββββββββββββββββββββββ+for (const leaf of leaves) {+ const covered = semver.satisfies(leaf.version, leaf.range, { includePrerelease: true });+ console.log(` ${leaf.name.padEnd(36)} cli pins ${leaf.range.padEnd(22)} source ${leaf.version} ${covered ? 'β' : 'β'}`);+ if (!covered) {+ const waiver = acceptedFor(leaf.name, 'range-coverage');+ if (waiver && !waiver.expired) {+ notes.push(`ACCEPTED until ${waiver.expires} β ${leaf.name}: ${waiver.reason}`);+ continue;+ }+ if (waiver?.expired) {+ violations.push(+ `${leaf.name}: accepted-finding EXPIRED ${waiver.expires} and is no longer honoured. ` ++ `Resolve it or renew the entry with a fresh justification. (${waiver.reason})`+ );+ continue;+ }+ violations.push(+ `${leaf.name}: the CLI pins "${leaf.range}", which does NOT cover the workspace version ` ++ `${leaf.version}. The release would resolve to an OLDER published copy than the source ` ++ `in this repo. Either publish ${leaf.name}@${leaf.version} and widen/raise the range in ` ++ `${CLI_PKG}, or correct the workspace version.`+ );+ }+}++// ββ 3. changed source must come with a version bump ββββββββββββββββββββββββββ+const baseArg = process.argv.indexOf('--base');+const base = baseArg !== -1 ? process.argv[baseArg + 1]+ : process.env.GITHUB_BASE_REF ? `origin/${process.env.GITHUB_BASE_REF}`+ : null;++if (!base) {+ notes.push(+ 'diff check NOT EXERCISED β no base ref (pass --base <ref> or set GITHUB_BASE_REF). ' ++ 'Range coverage above was still checked; this is a skip, not a pass.'+ );+} else {+ let changed = [];+ try {+ changed = git(['diff', '--name-only', `${base}...HEAD`]).split('\n').filter(Boolean);+ } catch {+ notes.push(`diff check NOT EXERCISED β could not diff against '${base}' (shallow clone?).`);+ }++ if (changed.length > 0) {+ for (const leaf of leaves) {+ const touched = changed.filter(+ (f) => f.startsWith(`${leaf.dir}/`) && PUBLISHABLE.test(f) && !NOT_PUBLISHABLE.test(f),+ );+ if (touched.length === 0) continue;++ let baseVersion = null;+ try {+ baseVersion = JSON.parse(git(['show', `${base}:${leaf.dir}/package.json`])).version;+ } catch {+ continue; // new package in this PR β nothing published to go stale+ }++ if (baseVersion === leaf.version) {+ violations.push(+ `${leaf.name}: publishable source changed but the version is still ${leaf.version}.\n` ++ ` changed: ${touched.slice(0, 5).join(', ')}${touched.length > 5 ? `, +${touched.length - 5} more` : ''}\n` ++ ` ${leaf.name} is NOT bundled into the release tarballs β it resolves from the\n` ++ ` registry β so publishing the three train packages will ship the OLD copy and\n` ++ ` this change will reach nobody. Bump ${leaf.dir}/package.json and publish the\n` ++ ` leaf alongside the release. See CLAUDE.md "Publishing Rules".`+ );+ } else {+ console.log(` ${leaf.name}: source changed AND version bumped ${baseVersion} -> ${leaf.version} β`);+ }+ }+ }+}++// ββ 4. report ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+console.log(` inspected ${leaves.length} non-bundled leaf package(s)`);+for (const n of notes) console.log(` NOTE: ${n}`);++if (violations.length === 0) {+ console.log(' ok: every non-bundled leaf is covered by the CLI range and carries a bump if changed');+ process.exit(0);+}++console.error('\nviolations:');+for (const v of violations) console.error(` β ${v}`);+console.error(`\n${violations.length} violation(s) β a release now would ship an incomplete fix.`);+console.error('Reference: ruvnet/ruflo#3335, #3390 (#3327 Finding A).');+process.exit(1);diff --git a/scripts/stage-internal-runtime-bundles.mjs b/scripts/stage-internal-runtime-bundles.mjsindex 34ca29ae31..1bb3aa80cd 100644--- a/scripts/stage-internal-runtime-bundles.mjs+++ b/scripts/stage-internal-runtime-bundles.mjs@@ -17,7 +17,7 @@ import { fileURLToPath } from 'node:url';const scriptDir = dirname(fileURLToPath(import.meta.url));const repoRoot = resolve(scriptDir, '..');-const INTERNAL_RUNTIME_PACKAGES = [+export const INTERNAL_RUNTIME_PACKAGES = [{directory: 'security',name: '@claude-flow/security',