Commit Graph
6 Commits
Author SHA1 Message Date
rUv fa13ee4ad6 feat(watermark): add browser/Deno ESM entry (@claude-flow/watermark 0.2.0) (#3041)
Adds a `@claude-flow/watermark/web` ESM entry (wasm-pack `--target web`) so the
package works in browsers, Deno, and bundlers — not just Node. Instantiate once
with `await init()` (auto-fetches the wasm in a browser; accepts bytes/URL/
Response), then the same ergonomic API (Watermarker, detect, detectSelfSync,
detectExact) as the Node build.

- package.json: conditional exports (`.` = Node CJS/ESM, `./web` = browser ESM,
  `./package.json` re-exported); web/ marked ESM via a nested package.json.
- build:wasm now builds both nodejs and web targets.
- Added test/smoke-web.mjs; `npm test` runs Node + web. Both verified, plus a
  fresh dual-entry tarball install (node z=64.7, web z=64.7).

Bumps to 0.2.0 (new capability, backward-compatible). No removal tooling.


Claude-Session: https://claude.ai/code/session_01VYDa3Hah5VJLS2ceEuTLKz
2026-08-15 19:18:24 -04:00
rUv 72fb129397 feat(watermark): @claude-flow/watermark npm package (WASM bindings) (#3040)
Widens the ruflo-watermark WASM surface (src/wasm.rs) to select schemes by
name ("tournament" | "tournament_nd" | "gumbel") and adds the indel-robust
self-sync and exact-Gamma short-text detectors to the bindings.

Adds v3/@claude-flow/watermark: a Node (CommonJS) npm package wrapping the
wasm-pack-generated bindings behind an ergonomic API (Watermarker, detect,
detectSelfSync, detectExact), with a clean .d.ts, a committed 37KB .wasm so
`npm install` needs no Rust toolchain, a regenerate script (build:wasm), a
README, and a smoke test. Verified: all 3 schemes generate+detect, wrong-key
and null streams rejected, and the specialized detectors fire — both in-repo
and from a fresh tarball install.

No watermark-removal tooling is exposed.


Claude-Session: https://claude.ai/code/session_01VYDa3Hah5VJLS2ceEuTLKz
2026-08-15 17:23:30 -04:00
rUv f7d27c3627 feat(watermark): SynthID-Text-style LLM text watermarking crate (Rust/WASM) (#3039)
Adds v3/crates/ruflo-watermark: a self-contained, model-agnostic crate for
LLM text watermarking (generation + detection) in the SynthID-Text / Aaronson
family, plus a robustness-evaluation harness and a governed un-marked path.

Schemes (all keyed on token id so detection needs no candidate set):
- Tournament (SynthID-Text, Nature 2024) — strong, mildly distortionary.
- TournamentNd — key-averaged non-distortionary (measured <0.3% drift).
- Gumbel (Aaronson/Kuditipudi exponential-min) — per-instance distortion-free.

Detection: closed-form (Binomial/Gamma) z/p with a stable erfc + log10 tail;
plus bayes.rs (exact Gamma-tail + Higher Criticism for short/sparse texts);
plus align.rs self-sync detector that closes the indel-robustness gap (the real
failure was repeated-context masking desync in low-entropy text, not the
position lock — measured, documented honestly).

evolve.rs: a Darwin/flywheel-methodology tuner (bounded gens x children, frozen
fitness, retained lineage, no auto-promotion) for the alignment detector, with
held-out re-evaluation to de-bias the winner's-curse in the promotion check
(a fix prompted by ADR-384's own adversarial review).

robustness.rs: substitution/deletion/insertion/paraphrase attacks + an adaptive
worst-case attack (proven to beat uniform editing at equal budget). Measurement
only — reports detection statistics, never laundered text.

unmarked.rs: authorized un-marked GENERATION (never post-hoc stripping) — an
unforgeable authorization MAC, mandatory provenance disclosure to finish, and a
loud audit record on undisclosed abandonment. Structurally cannot target
third-party marked text.

WASM bindings (--features wasm), criterion benches, 46 tests. Deliberately does
NOT include a watermark-removal/laundering tool.

Docs: ADR-383 (this crate) and ADR-384 (generalized bounded-evolution
methodology with error-control proof, from a multi-agent design workflow).


Claude-Session: https://claude.ai/code/session_01VYDa3Hah5VJLS2ceEuTLKz
2026-08-15 16:52:47 -04:00
rUv 1e64c2fd3b ADR-378/379/380: npm Trusted Publishing, statusline segments, AGNTCY/Outshift runtime integration (#2879)
* docs(adr): ADR-378/379/380 — npm trusted publishing, statusline segments, AGNTCY runtime integration

Renumbered from the original 322/323/324 (chosen when this branch was
based on an older main) — origin/main has since merged real, Accepted
ADRs at those numbers (322=metaharness-flywheel-integration,
323=typed-memory-provenance, 324=agentic-policy-engine-codex-swarm).
Content unchanged from the original commit, only the numbers and
filenames moved to the next free slot after ADR-377.

ADR-378: npm Trusted Publishing (OIDC) for CI/CD release automation,
replacing the standing NPM_TOKEN class with per-run short-lived
tokens; pairs GCP WIF for the helpers-signing-secret fetch instead of
a static service-account key.

ADR-379: optional context/session/week usage segments and extra
statusline tip lines for .claude/helpers/statusline.cjs, following
the existing CONFIG.hideCost toggle precedent; session/week/effort
default OFF pending a stdin-schema verification spike.

ADR-380: AGNTCY/Outshift runtime integration (SLIM transport, CASA
enforcement, IOC Layer 9 coordination events) as an optional,
removable augmentation per ADR-150's pattern. Companion to metaharness
repo ADR-237 (agent/adr-237-agntcy-outshift-integration branch), which
owns the build-time half (identity, OASF export, observability).

* feat(agntcy): ADR-380 scaffolding — CASA envelope, SLIM/IOC CLI verbs, Rust crate

Renumbered from the original ADR-324 (origin/main has since merged a
real, unrelated, Accepted ADR-324 — see the companion docs commit).
Content and behavior unchanged; only the ADR number/filename and every
in-file reference to it moved to ADR-380.

Implements the buildable-now portion of ADR-380 (AGNTCY/Outshift
runtime integration) as optional, removable augmentation per ADR-150's
pattern. No AGNTCY/SLIM/Outshift npm or crates.io packages exist yet
under any plausible name (verified live) — every network touchpoint is
a clearly-logged stub gated behind explicit config, never a fake
success.

- plugins/ruflo-agntcy/: CASA envelope schema (Zod) + deterministic
  compiler + enforcement gate (checkAuthorization, deny-by-default) +
  bypass-attempt tests; Ed25519-signed CASA decision receipts
  (.swarm/casa-receipts.jsonl); AGNTCY OTel span attribute constants
  this repo owns (coordination.episode, authorization.decision).
- v3/@claude-flow/cli/src/commands/agntcy/: `ruflo transport use slim`,
  `ruflo agent publish`, `ruflo swarm join <namespace>` — wired into
  the top-level command registry and into agent.ts/swarm.ts's existing
  subcommand arrays (merged alongside main's concurrently-added
  pheromoneCommand); all exit 0 with a clear message when AGNTCY/SLIM
  isn't configured (RUFLO_AGNTCY_SLIM_ENDPOINT unset).
- v3/crates/ruflo-agntcy/: Rust CasaEnvelope + check_authorization
  mirroring the TS enforcement logic exactly, LocalTransport (real,
  working, in-process) + SlimTransport stub behind a non-default
  `slim` Cargo feature. Added to the workspace; also fixed a
  pre-existing `cargo check` blocker (v3/plugins/gastown-bridge's
  nested [workspace] table conflicting with the parent workspace) by
  moving it from `members` to `exclude`.

Adversarial security review (as ADR-380 §3 requires before trusting
this gate) found and this commit fixes two real bugs in the first
pass:
- enforce.ts trusted the erased TS type instead of validating its own
  input — a non-array `allow`/`deny` collapsed `.includes()` into
  JS's substring-match overload, and a malformed `now`/`expires_at`
  silently skipped the expiry check instead of failing closed.
  checkAuthorization now runs CasaEnvelopeSchema.safeParse() on entry,
  requires an explicit timezone offset on all timestamps, and treats
  any unparseable timestamp as expired.
- compile.ts's keyword table matched bare "push"/"publish"/"release"/
  "deploy" with no contextual gate, false-permissively granting
  git.push/deployment.create for objectives like "push notification
  integration" or "review the release notes". Patterns now require a
  co-occurring contextual noun (git/commit/branch for push;
  service/app/production/version/etc. for deploy).

Deferred to a follow-up pass (documented, not silently dropped):
plugins/ruflo-agntcy has no package.json yet (this repo's plugins/
ruflo-* convention is Claude Code plugin content, not an npm
workspace package — unlike @metaharness/agntcy's sibling-package
convention on the metaharness side), so no optionalDependencies entry
was added anywhere; adding one now would reference a package shape
that doesn't exist and break installs.

Companion: metaharness repo ADR-237 (agent/adr-237-agntcy-outshift-
integration branch) — build-time half of this integration.

* docs(agntcy): fix stale companion-ADR cross-reference (metaharness ADR-237 -> ADR-240)

Metaharness's own numbering collided too (ADR-237 was already taken by
evals-math-live-gsm8k-fast-domain on their main) and got renumbered to
ADR-240 — this repo's references to it were stale.

* fix(agntcy): add missing allowed-tools frontmatter to agntcy-status skill

CI's fleet-wide SKILL.md frontmatter audit correctly flagged this —
no implicit 'all tools' is allowed. Scoped to Read since this is a
scaffolding stub (not yet implemented) that will only ever need to
inspect local package.json/config state, never execute commands.
2026-07-30 23:05:44 -04:00
rUvandReuven e0a922eef9 feat(federation-peer): wire real midstreamer-quic@0.3.0 + aimds-core@0.2.0 (ADR-120 Step 3) (#2011)
Replaces the typed `not implemented` placeholders in
`native_transport` and `native_gate` with real implementations that
delegate to the embedding traits published in ruvnet/midstream PR #82.

**Cargo.toml**
- Bumped `midstreamer-quic` 0.2.1 → 0.3.0 (now exposes `QuicTransport`)
- Bumped `aimds-core` 0.1.1 → 0.2.0 (now exposes `SafetyGate` + `SafetyVerdict`)
- Dropped optional `aimds-detection` / `-analysis` / `-response` —
  the peer composes any `aimds_core::SafetyGate` so the concrete
  3-gate pipeline is supplied by the caller (e.g. AIMDS's
  `ComposedGate` or a custom composition)
- Added optional `uuid` + `chrono` (used by the gate adapter to
  build `PromptInput` values)

**lib.rs — `native_transport::MidstreamerTransport<T: QuicTransport>`**
- Generic over any embedder-supplied transport (defaults to `QuicConnection`)
- `connect(addr)`: opens a client connection via `QuicConnection::connect`
- `send(addr, msg)`: opens a bidirectional stream, writes one NDJSON
  line per `FederationMessage`, finishes the stream
- `recv()`: accepts an inbound bidirectional stream, reads to EOF
  (16 MiB cap), parses one JSON value
- `close()`: closes the connection with reason "peer shutdown"

**lib.rs — `native_gate::AimdsGate`**
- Adapter that holds `Arc<dyn aimds_core::SafetyGate>` so it composes
  any 3-gate pipeline (AIMDS's canonical `ComposedGate`, a custom
  composition, or a test stub)
- Converts `FederationMessage` ↔ `PromptInput` (payload-as-string +
  metadata-as-context)
- Converts `aimds_core::SafetyVerdict` ↔ peer-local `SafetyVerdict`,
  preserving routing metadata on `Redact`

**bin.rs**
- Under `--features native`, boots a real tokio runtime that wires
  `MidstreamerTransport::connect()` + `AimdsGate` (with a
  pass-through default gate so the smoke boot path works without
  AIMDS rules) + an NDJSON-stdout dispatcher
- Reads `RUFLO_FEDERATION_REMOTE_ADDR` for the connect target

**Tests**
- New `aimds_gate_adapter_forwards_pass_and_block_verdicts` test
  exercises the real `aimds_core::SafetyGate` trait surface
- 4/4 tests pass under `--features native`; 3/3 pass without

**audit-fix-invariants.mjs**
- Bumped Cargo.toml pin invariants to 0.3.0 / 0.2.0
- Added two new invariants checking the lib.rs imports actually
  reference upstream `QuicTransport` and `aimds_core::SafetyGate` —
  guards against silent reversion to a typed placeholder
- 34/34 invariants pass

Closes ADR-120 Step 3.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 23:35:32 -04:00
rUvandReuven b50d4dd7a2 feat(federation): ADR-120 Step 3 — Rust peer crate + Step 2 path update (#2009)
Lands the remaining ADR-120 work in ruflo now that upstream
ruvnet/midstream#81 shipped midstreamer@0.3.1 with real QUIC.

## Step 3 — `v3/crates/ruflo-federation-peer/`

New Rust crate that composes the QUIC transport (midstreamer-quic
or any TransportProvider impl) with the AIMDS 3-gate safety
pipeline (any SafetyGate impl) into a single Peer<T, G, D> dispatch
loop. Replaces today's Node-bridge → Node-MCP → Rust-crate path
with one process per federation peer.

Surface:
  * `TransportProvider`, `SafetyGate`, `Dispatcher` traits — async,
    Send + Sync, so the Peer can run in any tokio executor.
  * `Peer::run()` — inbound dispatch loop. `Pass` → dispatch;
    `Block` → quarantine (never reaches dispatch); `Redact` →
    dispatch the cleaned variant.
  * `Peer::send()` — outbound through the gate first; Block error
    bubbles back to the caller.
  * `--features native` — pulls in midstreamer-quic@0.2.1 +
    aimds-{core,detection,analysis,response}@0.1.1 from crates.io.
    Without it, the binary builds and the trait surface compiles
    so CI / `cargo check` work in any tree.

Verified:
  * `cargo build` and `cargo test` — 3/3 unit tests pass
    (dispatch loop with PassThroughGate, BlockEverythingGate, and
    outbound-send-blocks-when-gate-blocks).
  * `cargo check --features native` — resolves the upstream deps
    cleanly.

## Step 2 update — `midstream-aware-loader.ts`

Probes `midstreamer/quic` (the new sub-path added in
midstreamer@0.3.1) first, falls back to the root `midstreamer`
import for older versions. Accepts both ESM and CommonJS shapes
(via `.default`) since the upstream sub-path is CJS.

## CI guards

  * New workflow `.github/workflows/federation-peer-rust.yml`:
    two jobs — `stable-noop` (cargo build + cargo test without
    features) and `stable-native` (cargo check --features native).
    Triggers on changes to the crate or this workflow.
  * `scripts/audit-fix-invariants.mjs` gains 4 invariants pinning
    the crate name + the midstreamer-quic version + the two
    pluggable trait names. 31 invariants now present across 18
    files (was 27/16).

## Verification matrix

  * `node scripts/audit-fix-invariants.mjs` → 31/31 ✓
  * `npx vitest run` in plugin-agent-federation → 22 files, 555/555 ✓
  * `cargo test` in v3/crates/ruflo-federation-peer → 3/3 ✓

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 23:01:05 -04:00