Commit Graph
9 Commits
Author SHA1 Message Date
ruv d09a0e4cbd fix(ci): 5 CI failures — Build V3, Static guards, ADR-112, witness verify, supply-chain audit
Stacked fixes to clear the remaining red CI checks on \`main\` that pre-dated
the #2412 lockfile-cascade fix. Each one verified locally before commit.

1. **Build V3 (ubuntu/macos/windows)** — \`graph-edge-writer.ts\` did a static
   \`await import('better-sqlite3')\` which forces tsc to resolve the package's
   types at build time. \`better-sqlite3\` is in \`optionalDependencies\` (so
   CI doesn't install it) — type resolution failed with TS2307 on every
   platform. Routed the module name through a variable so the static analyzer
   stops trying to resolve it; runtime presence is still gated by the
   existing try/catch.

2. **Static regression guards (#2267)** — \`scripts/smoke-workflows-yaml.mjs\`
   crashed with \`SyntaxError: The requested module 'js-yaml' does not provide
   an export named 'default'\` after js-yaml dropped the synthetic default
   from its package exports. Switched to \`import * as yaml from 'js-yaml'\`.

3. **Tool description discoverability (ADR-112)** — two MCP tools regressed
   the no-guidance baseline (count went from 0 → 2):
     - \`metaharness_bench\` had no Use-when / Prefer / Pair-with hint
     - \`testgen_tdd_repair\` had \"Use when …\" in a *later* string
       fragment of a concatenated description, which the audit regex
       (single-quoted-literal-only) misses
   Added explicit \"Use when …\" guidance to the first fragment of each.
   Audit now reports 340/340 tools with guidance.

4. **witness verify precondition smoke (#1880)** — Root \`package-lock.json\`
   drifted: \`agentdb@3.0.0-alpha.16\` in lock vs \`^3.0.0-alpha.17\` in
   package.json (same root cause as #2412 but for the npm lockfile, not the
   pnpm one fixed last release). Every job that runs \`npm ci\` was failing
   at install. Regenerated via \`npm install --package-lock-only\`. Verified:
   \`npm ci --dry-run --legacy-peer-deps\` now exits 0.

5. **Supply-chain audit (#2046)** — \`plugins/ruflo-graph-intelligence\` had
   1 HIGH/CRITICAL unaccepted direct-dep finding:
     - \`ws@8.20.1\` pulled by \`sublinear-time-solver\` (GHSA-96hv-2xvq-fx4p,
       memory exhaustion DoS) — bumped root override \`ws >=8.18.4\` →
       \`>=8.21.0\` and added the same override to the plugin's own
       package.json so it propagates through the plugin's own npm install
     - \`@claude-flow/cli\` peerDep surfaces every HIGH transitive in cli's
       own tree inside the plugin's audit report — added a tracked,
       expiring accepted-finding (cli ships its own audit pipeline on
       every publish; the plugin doesn't redistribute cli's tree).
   Audit now reports \`OK: no hard-fail findings\`.

Verified locally:
  - \`npm run build\` in v3/@claude-flow/cli: clean
  - \`node scripts/smoke-workflows-yaml.mjs\`: exit 0, 53 workflows parsed
  - \`node scripts/audit-tool-descriptions.mjs\`: 340/340 with guidance, OK
  - \`npm ci --dry-run --legacy-peer-deps\` at repo root: exit 0
  - \`node scripts/audit-supply-chain.mjs\`: OK, no hard-fail findings

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-25 18:18:19 -04:00
ruv 920ba4b04e fix(supply-chain): correct tracking issue ref in vitest accepted-finding (#2270 was a typo for #2268)
Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-02 04:26:52 -04:00
ruv f08318f2c7 fix(ci): green up the 3 audit jobs newly visible after the YAML fix
With #2267's YAML break gone and the pnpm-lock refreshed, the 25 newly-
visible failures collapsed to 3 genuinely-independent audit failures.
Fixing all three.

#2046 — Supply-chain audit (1 unaccepted critical CVE)
  Vitest <4.1.0 UI server arbitrary-file-read/exec (GHSA-5xrq-8626-4rwp,
  CVSS 9.8) was unaccepted in v3/@claude-flow/browser.
  • Bumped `vitest` spec from ^4.0.16 → ^4.1.0 in browser package.json.
  • Refreshed the workspace pnpm-lock.
  • Standalone-publish package-lock.json carries workspace:* refs that
    `npm install` can't resolve in isolation, so I added a time-boxed
    (expires 2026-09-02) accepted-findings entry citing the limited
    exposure (devDependency + UI-server-only attack vector) and pinning
    the next workspace-coordinated lockfile rebuild as the trigger to
    remove it. Tracking: ruflo#2270.

ADR-112 — Tool description discoverability (2 missing "Use when …")
  • hooks_task-completed: added "Use when native TaskUpdate is wrong
    because the runtime also needs to record the outcome as a learning
    signal and emit the standard pipeline event".
  • hooks_intelligence_unified-stats: added "Use when calling the four
    narrow aggregators one at a time is wrong because cross-store drift
    goes silent — this tool surfaces it in the `consistency` block".
  327/327 tools now pass; baseline stays at 0.

#1921 — Hook-command install safety (4 missing invariants)
  Both #1951 and #1989 fixes were silently retired by #2196's statusline
  delegation refactor. Updated scripts/audit-fix-invariants.mjs to track
  the new reality without dropping coverage:
  • #1951 (marketplaces/ruflo) — substring became `path.join(home,
    '.claude', 'plugins', 'marketplaces', 'ruflo', …)` which the literal
    substring check couldn't see. Switched to a regex form that matches
    the path.join breakup.
  • #1989 (SQLite magic-bytes + page-count clamp) — superseded entirely
    by #2196's delegation pattern: statusline-generator no longer reads
    raw memory.db bytes; it shells out to `hooks-statusline --json`
    which queries AgentDB via the typed SDK. The regression vector is
    closed by ARCHITECTURE. Replaced the two #1989 invariants with one
    #2196 invariant that locks in the delegation pattern, so a future
    refactor that reintroduces raw-bytes reading is caught BEFORE the
    SQLite magic check would be relevant. Audit-script convention says
    "do NOT delete without confirming the regression is impossible by
    another mechanism" — this is the documented confirmation.
  37 invariants, all present.

Local: all 3 audits + the 2 new regression smokes pass.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-06-02 04:26:05 -04:00
ruv 90df1d6e8a feat(ci): #2089 ADR-127 Phase 1 — github-safe injection smoke + uses: pin smoke + supply-chain allowed-deps actions block
Creates two new CI smoke scripts and wires them into v3-ci.yml.

smoke-github-safe-injection.mjs
  Generalizes the smoke-pre-bash-hook.mjs pattern (#2017) to the GitHub
  helper surface.  Drives adversarial PR/issue bodies (backticks, $(),
  semicolons, empty) through github-safe.js via a fake-gh shim and
  asserts the body lands verbatim in a temp file with --body-file, not
  inline as --body.  The >256KB cap case is documented as a red→green
  transition for Phase 2 (no cap yet enforced).  Runs against both
  .claude/helpers/github-safe.js (dogfood) and the init-template copy.

smoke-github-actions-pins.mjs
  Static scan of .claude/agents/github/*.md, .claude/skills/github-*/
  SKILL.md, and v3/@claude-flow/cli/.claude/commands/github/*.md.  Every
  uses: ref must be SHA-pinned (40-hex) OR present in the new
  .github/supply-chain/allowed-deps.json "actions" block.  Exits 0 now
  that allowed-deps.json covers the full set of refs in-use.  Phase 3
  upgrades @v3→@v4 across all files; this smoke is the regression gate
  that prevents them drifting back.

.github/supply-chain/allowed-deps.json
  Adds "actions" key with allowed[], minimumVersion, and an explanatory
  comment per ADR-127 §Phase 1.  Lists all GitHub Actions currently
  referenced in scope: checkout, setup-node, pnpm/action-setup, cache,
  upload-artifact, ruvnet/swarm-action, aws-actions/configure-aws-credentials.

.github/workflows/v3-ci.yml
  Adds path-filter entries under both push and pull_request triggers
  covering the 6 ADR-127-specified paths:
    .claude/agents/github/**
    .claude/skills/github-*/**
    v3/@claude-flow/cli/.claude/commands/github/**
    .claude/helpers/github-safe.js
    v3/@claude-flow/cli/.claude/helpers/github-safe.js
    scripts/smoke-github-*.mjs
    .github/supply-chain/allowed-deps.json
  Adds two independent smoke jobs: github-safe-injection-smoke and
  github-actions-pins-smoke, following the ruvllm-wasm-auto-init-smoke
  pattern.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-21 14:03:29 -04:00
ruv 3dbf6074aa fix(deps): #2048 — bump agentic-flow ^2.0.12 → ^2.0.13 (Windows onnxruntime lazy-load)
agentic-flow@2.0.13 moves the onnxruntime-node native binding load out of
module-import time and into an on-demand `loadOrt()` helper called from
`initializeSession()`. This fixes ruflo#2048 — `import('agentic-flow/reasoningbank')`
on Windows crashed with "OS cannot run %1" because router/providers/onnx-local.ts
used a top-level `await import('onnxruntime-node')` which forced the native binding
to load before any user code ran, even when the consumer never intended to run
local ONNX inference.

Upstream PR: ruvnet/agentic-flow#155
Upstream release: agentic-flow@2.0.13 (now `latest` on npm)

Changes
- root package.json + package-lock.json: ^2.0.12 → ^2.0.13
- v3/@claude-flow/browser/package.json + package-lock.json: ^2.0.12 → ^2.0.13
- v3/pnpm-lock.yaml: regen → resolves 2.0.13
- .github/supply-chain/follow-ups.md: mark #2048 as fixed, link upstream PR + this PR
- .github/supply-chain/accepted-findings.json: add fixedDirectly entry for 2.0.13

Verification
- root npm audit: 0 vulnerabilities
- supply-chain audit (5 layers): OK, no hard-fail findings
- @claude-flow/browser tests: 230 passed | 12 skipped
- ruflo-graph-intelligence tests: 104 passed
- Acceptance test (run against published 2.0.13):
    node -e "import('agentic-flow/reasoningbank').then(()=>console.log('OK'))"
    node -e "import('agentic-flow/router').then(()=>console.log('OK'))"
    Both succeed under default install AND under --omit=optional.

Follow-up CI guard (separate PR):
- Add Windows-runner smoke job that imports agentic-flow/reasoningbank under
  --omit=optional to lock the lazy-load contract.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 12:53:04 -04:00
ruv 21e52108d5 fix(kg-extract): #2049 — separate import type from value imports + drop disabled semantic-route + CI guard
Three coupled fixes for ruvnet/ruflo#2049:

1. `kg-extract/SKILL.md` step 3 now declares a separate `type-depends-on`
   relation (weight 0.1) for TypeScript `import type` and inline
   `import { type Foo, value }` specifiers. Includes the regex carve-out
   pattern so future agents implementing the skill correctly classify
   the three import shapes. Previously the skill said "follow
   import/require statements" with no carve-out, and a naive grep
   produced phantom runtime cycles (a 51-service codebase reported a
   non-existent `findings ⇄ finding-actions` cycle driven entirely by
   a one-way `import type { Finding }` edge).

2. `kg-traverse/SKILL.md` step 3 now calls `agentdb_pattern-search`
   (enabled in current AgentDB builds) instead of
   `agentdb_semantic-route` (`enabled: false` — controller is
   compiled out, returns "SemanticRouter not available in current
   agentdb build"). Both skills' `allowed-tools` lines updated to
   drop the disabled controller.

3. New CI smoke at `scripts/smoke-kg-extract-type-imports.mjs` +
   new workflow job `kg-extract type-import classification smoke (#2049)`
   in `.github/workflows/v3-ci.yml`. Two layers:
   - Static contract check on both SKILL.md files — asserts
     `type-depends-on` relation is declared, weight ≤ 0.1, regex
     carve-out is present, and no skill lists the disabled
     `agentdb_semantic-route` in allowed-tools.
   - Behavioural fixture test: writes a tiny TS scenario with one
     type-only cycle + one value-import edge to /tmp, runs the
     documented regex classifier, and asserts the cycle is NOT counted
     as a value edge. If a future PR softens any of these contracts,
     the smoke catches it before merge.

Path filters in v3-ci.yml expanded to include
`plugins/ruflo-knowledge-graph/**` + the new smoke script so the job
fires on every relevant edit.

Plus `.github/supply-chain/follow-ups.md` documents:
- #2047 (witness drift HIGH) — upstream scheduled-runner fix needed +
  the interim CI guards already in place.
- #2048 (agentic-flow Windows onnxruntime binding) — needs the same
  shape of upstream patch as ADR-124 shipped for @xenova/transformers
  in agentic-flow 2.0.12; documented workaround for users and the
  CI guard to add post-patch.

Smoke verified locally: 9/9 checks pass.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 12:19:16 -04:00
ruv f60417352e fix(deps): #2046 ADR-124 — bump agentic-flow to 2.0.12 (xenova optional)
Upstream agentic-flow@2.0.12 shipped today (PR ruvnet/agentic-flow#154,
commit 2c10eb9) moving @xenova/transformers from `dependencies` to
`optionalDependencies`. Five of six call sites in agentic-flow already
used dynamic import; the sixth (src/reasoningbank/utils/embeddings.ts)
was converted to dynamic with try/catch + graceful fallback to the
existing hash-based embedding path.

This commit:

1. ADR-124 — full architectural record of the upstream fix +
   downstream impact + rollout plan.

2. Bump agentic-flow ^2.0.11 → ^2.0.12 in:
   - package.json (root)
   - v3/@claude-flow/browser/package.json

3. Regenerate lockfiles:
   - package-lock.json (root npm)
   - v3/@claude-flow/browser/package-lock.json
   - v3/pnpm-lock.yaml (v3 workspace)

4. Update .github/supply-chain/accepted-findings.json:
   - Add entry to `fixedDirectly[]` documenting the 2.0.12 ship
   - Replace the previous "blocked by upstream" CVE entry with a
     "moot finding" entry. The vulnerable code is no longer installed
     when consumers use `npm install --omit=optional`; `npm audit`
     still reports it because it reads the lockfile graph (which
     includes optionals) — a known npm limitation. Tracking now
     points at the merged upstream PR + ADR-124.

After this commit:
- Root npm audit: 0 vulnerabilities (was 0 already after PR #2050; still 0)
- Browser tests: 230/230 passing
- Graph-intel tests: 104/104 passing
- Supply-chain audit: 0 hard-fail findings (1 accepted, moot)
- Consumers of @claude-flow/browser who pass `--omit=optional` get a
  fully CVE-clean install profile

Closes the upstream half of #2046. ADR-121 Phase 4 still tracks the
long-term Xenova retirement.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 10:16:56 -04:00
ruv 9a8c9c464f fix(supply-chain): #2046 — eliminate all root-level HIGH/CRITICAL CVEs
Before:
  Root npm audit: 13 HIGH/CRITICAL across 25 vulns
  @claude-flow/browser fresh install: similar transitive chain
  Audit script reported 0 unaccepted only because it correctly scopes
  to direct deps — but transitive surface was hostile

Changes:

1. Bump agentdb to 3.0.0-alpha.14 (was alpha.10/13 across repo)
   - 3.0.0-alpha.14 dropped @opentelemetry/sdk-node from its
     dependencies block (still in optionalDependencies; overrides handle
     that). Eliminates the @opentelemetry/sdk-node CVE chain via direct
     dep replacement.
   - Updated: v3/@claude-flow/memory, v3/@claude-flow/cli, root.

2. Bump agentic-flow 2.0.7 → 2.0.11 (root) and ^2.0.3 → ^2.0.11
   (v3/@claude-flow/browser). Latest 2.x; closer to a Xenova-clean
   release when upstream ships it.

3. Add npm overrides at the root + at v3/@claude-flow/browser package
   (overrides do not cascade across separate npm projects, so browser
   needs its own block for standalone publish):
     @opentelemetry/sdk-node              >= 0.218.0  (was <0.217.0 CVE)
     @opentelemetry/auto-instrumentations >= 0.75.0
     @opentelemetry/exporter-prometheus   >= 0.217.0
     axios                                >= 1.13.2
     fast-uri                             >= 3.1.0
     vite                                 >= 6.4.6
     ws                                   >= 8.18.4

   Plus the existing browser-package overrides for hono / undici / tar /
   minimatch / picomatch / flatted / etc. — copied from root to keep
   the standalone npm-published install clean.

After:
  Root npm audit: 0 vulnerabilities (13 HIGH/CRITICAL → 0)
  Supply-chain audit: PASS (0 unaccepted direct-dep findings)
  Browser tests:  230/230 passing
  Graph-intel tests: 104/104 passing

One CVE remains in v3/@claude-flow/browser's STANDALONE fresh install
(end-user `npm install`): @xenova/transformers via agentic-flow direct
dependency. Cannot fix without upstream agentic-flow shipping a Xenova-
free release. agentic-flow@3.0.0-alpha.2 still has it. Documented in
accepted-findings.json under cve[] with:
  tracking: ADR-121 Phase 4
  expiresAt: 2026-08-19 (audit re-fails if upstream still hasn't shipped)
  rationale: browser package does not invoke embedding code paths

This is the right level of triage. The audit doesn't lie about it — it
just doesn't block our shipping while we wait for upstream.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 08:34:23 -04:00
ruv 0181fb85c2 ci: #2046 supply-chain hardening — five-layer audit + dependency review + CODEOWNERS
After ADR-122 + ADR-123 expanded ruflo's published-package surface
(@claude-flow/browser, ruflo-graph-intelligence) the supply-chain attack
surface grew alongside it. This commit puts five layers of defence on
every PR + push that touches package.json, lockfiles, or the audit
itself.

New files:

  .github/supply-chain/allowed-deps.json
    Whitelist of direct deps per audited package (ruflo-graph-intelligence,
    @claude-flow/browser). New top-level deps require an explicit edit here.
    Also lists policies.rejectInRegistry (typosquat block-list — ruflo-graph-
    intellligence, sublinear-time-solvor, agent-browse, etc.) and
    publisherTrust.criticalUpstreamPackages (upstream identities snapshotted
    in CI logs so maintainer takeovers are visible).

  .github/supply-chain/accepted-findings.json
    Triaged findings the audit currently tolerates. Each entry cites a
    tracking issue or ADR and carries an expiresAt date so the audit
    re-fails after triage window closes. CODEOWNER review required to
    edit.

  .github/supply-chain/README.md
    Operator guide: how to run the audit locally, how to triage new
    findings, how to add a new package to coverage.

  .github/CODEOWNERS
    Workflows / lockfiles / plugin manifests / supply-chain config now
    require explicit maintainer review. Pairs with the automated audit.

  scripts/audit-supply-chain.mjs
    Five-layer audit:
      [1/5] CVE — npm audit --audit-level=high, fail on HIGH/CRITICAL in
            DIRECT deps unless accepted
      [2/5] Lockfile integrity — every downloaded entry must carry
            SHA-512 in `integrity` (skip pnpm-shadow + workspace-link
            entries by construction)
      [3/5] Top-level allowlist — package.json deps must match
            allowed-deps.json
      [4/5] Typosquat reject — names matching policies.rejectInRegistry
            fail regardless of upstream status
      [5/5] Publisher trust — npm view maintainers, log-only (informational)

  scripts/__tests__/audit-supply-chain.test.mjs
    Smoke test for the audit itself (full-run / --json / each --scope).

Workflow additions in .github/workflows/v3-ci.yml:

  supply-chain-audit job — runs the audit + the smoke test on every PR
    and push that touches package.json, lockfile, allowed-deps,
    accepted-findings, or the audit script.

  dependency-review job — actions/dependency-review-action@v4 (PR-only)
    flags any new vulnerable dep added by the PR vs base, fails on
    `high` severity, denies known-bad licenses (AGPL/GPL/SSPL) and
    blocks specific compromised versions (event-stream, flatmap-stream,
    ua-parser-js@0.7.29 / 0.8.0 / 1.0.0, colors@1.4.1, faker@6.6.6).

  Path filter expanded to include **/package.json, **/package-lock.json,
    **/pnpm-lock.yaml, .github/supply-chain/**, scripts/audit-supply-chain.mjs

Dependabot additions in .github/dependabot.yml:

  Per-plugin npm stanzas for ruflo-graph-intelligence and
  @claude-flow/browser. Major-version bumps are blocked from auto-PR
  (they require allowlist re-approval); patch + minor auto-PR'd.

One real-world finding the audit caught on first run + how it was
triaged (recorded in accepted-findings.json):

  - HIGH CVE on @claude-flow/browser → agentic-flow (via @xenova/
    transformers, agentdb). Already tracked in ADR-121 Phase 4
    (Xenova retirement migration). Marked accepted with expiresAt
    2026-08-19 so the audit re-fails if the migration hasn't
    landed by then.

Audit run on this branch: PASS (0 unaccepted CVE / 0 lockfile issue
/ 0 allowlist violation / 0 typosquat / 5 publisher-trust entries
logged). Audit smoke test: 5/5 passing.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-19 08:23:30 -04:00