Commit Graph

42 Commits

Author SHA1 Message Date
ruv cff24dbff6 perf(guidance): M4 quantization — 1-bit RaBitQ-style signatures, 2.7x at N=1000
Horizon: guidance-sota-2026-05 (M4). The real SOTA win.

## What changed

`ShardRetriever` now maintains a packed Uint32Array of 1-bit sign
signatures alongside the existing Float32 embedding matrix. For
dim=384 that's 12 Uint32 words = 48 bytes per shard (vs 1,536 bytes
for the Float32 embedding — a 32x memory reduction for the index).

`scoreShards` runs the cosine via Hamming-distance over those
signatures when (a) the index is current, (b) shard count ≥ 100 (to
amortise the query-signature build), and (c) dims match. The
sign-random-projection theorem (Charikar 2002) gives:

    cos(θ) ≈ cos(π · hamming(sig_q, sig_s) / dim)

which is accurate enough for the retriever's sort + intent-boost +
risk-boost downstream.

## Microbench (bench-quantization.mjs)

    cosine.dot (float32, 384-d)           3,006,455 ops/s   332.62 ns/pair
    hamming.popcount (uint32, 12 words)  32,862,982 ops/s    30.43 ns/pair
                                                         ────────────
                                          Hamming speedup vs dot: 10.93x

## End-to-end (bench-retriever-scale.mjs)

  N    baseline unfilt   M4 unfilt   speedup
  10        63,910         70,777      1.11x
  100       12,135         26,372      2.17x
  500        2,470          6,468      2.62x
  1000       1,303          3,522    🚀 2.70x

  N    baseline filt     M4 filt     speedup
  10       166,274        198,451     1.19x
  100       46,419         85,311     1.84x
  500       12,974         27,081     2.09x
  1000       6,662         16,073     2.41x

All 1,331 existing tests pass. Build clean.

## Why this works where Phase 1 + M3 didn't

Phase 1 / M3 attacked the dot product's *constants* (eliminate sqrt,
hoist regex, pack memory). Those are all within V8's optimisation
ceiling — the JIT already does most of it. M4 attacks the
*algorithm*: instead of 384 multiplies per pair, we do 12 XOR +
popcount. The instruction count itself drops ~30x, and even with JS's
no-native-popcnt penalty we measure 11x per-pair.

End-to-end speedup is bounded by Amdahl on the non-cosine work
(sorting, intent/risk boosts, result construction), so 2.7x is the
expected ceiling for this fixture. At larger N or with a heavier
embedding model, the cosine fraction grows and the speedup approaches
the full 11x.

## Memory

48 bytes/shard signature vs 1,536 bytes/embedding — a 32x reduction.
At N=10,000 shards: 480KB signatures vs 15MB embeddings. Real for
cold-start RAM on hooks-running daemons.

Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
2026-05-21 23:51:48 -04:00
ruv 12ecb39cbc perf(guidance): M3 substrate — packed embedding matrix + filtered-query bench coverage
Horizon: guidance-sota-2026-05 (M3). Honest report of what works and
what didn't.

## What changed

retriever.ts gains a contiguous Float32Array pack of all shard
embeddings, populated once at indexShards() time. scoreShards then
walks the pack inline (sequential reads, V8-friendly inner loop)
instead of dereferencing per-shard heap Float32Array allocations.

bench-retriever-scale.mjs gains a filtered-query column so we can
measure the effect of risk-filter / repo-scope path. The original code
already does filter-then-continue (skipping cosine on filtered shards),
which is worth ~5x at N=1000 — the bench scaffold now proves that.

## Honest findings

After three iterations of "optimization":

  N | unfilt baseline | unfilt M3v2 | filt baseline | filt M3v2
  --|-----------------|-------------|---------------|----------
  10|         63,910  |     73,187  |     166,274   |   192,414
 100|         12,135  |     12,234  |      46,419   |    47,742
 500|          2,470  |      2,468  |      12,974   |    11,807
1000|          1,303  |      1,333  |       6,662   |     6,646

All speedups vs baseline are within ±5% (noise band). The package was
already well-tuned:
  - cosineSimilarity was the dominant cost at scale (~400µs of 760µs
    at N=1000)
  - The existing filter-then-continue ordering already short-circuits
    cosine on 80% of shards in the typical riskFilter case
  - V8's JIT optimizes the original filter-chain patterns nearly as
    well as the manually-unrolled forms

## What this proves

The benchmark infrastructure (multi-trial median, four scale points,
both filtered and unfiltered query paths) IS the SOTA scaffold. It
establishes:

  1. Reproducible per-N measurement at ±2% variance
  2. The filter optimization is real (5.1x at N=1000)
  3. The cosine dominates at scale — further gains require RaBitQ-style
     1-bit-per-dim quantization (M4) or algorithmic change (true HNSW
     with logarithmic graph traversal, requires sidecar dep)

This commit lands the substrate for M4 to measure against. M3 closure
is "infrastructure + filter-baseline proven", not "package made faster"
— V8 already did most of the work that's easily expressible in JS.

## Verification

- All 1,331 tests pass (`npm test` in v3/@claude-flow/guidance)
- Build clean
- 5-trial median benchmarks reproducible at ±2%

Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
2026-05-21 23:27:23 -04:00
ruv 6d6d659ca9 perf(guidance): Phase 1 — hot-path cleanup + scaling benchmark infrastructure
Horizon: guidance-sota-2026-05 (M1 + M2). First commit on the path to
SOTA-with-proof for @claude-flow/guidance.

## What changed

Three localized hot-path cleanups + a benchmark infrastructure that
exposes the real opportunity (M3, HNSW substrate).

### Code changes (no public API surface change)

1. **analyzer.ts extractMetrics** — replace 6 separate `lines.filter()`
   passes + 2 `for-of` loops with a single iteration that accumulates
   every line-derived metric. Hoist 11 in-body regex literals to module
   scope. Net: cleaner code, no measurable speedup on V8 (the JIT
   already optimizes filter chains well).

2. **compiler.ts parseRule** — replace 4 `new RegExp(PATTERN.source, 'gi')`
   constructions per call with `text.matchAll(PATTERN)` against the
   existing module-level global patterns. Net: cleaner code, no
   measurable speedup (V8 internalizes the regex objects).

3. **retriever.ts cosineSimilarity** — drop the 3-accumulator
   sqrt-div-clamp form to a pure dot product. The embeddings this
   retriever consumes are always unit-normalised (HashEmbeddingProvider
   divides by L2 norm at line 134, ONNX providers emit unit vectors by
   design), so `sqrt(normA)*sqrt(normB) === 1` and the result already
   lies in [-1, 1]. Net: +8.2% at N=1000 shards, +10.9% at N=500.

### Benchmark infrastructure (new)

- `scripts/bench-phase-1.mjs` — multi-trial median microbenchmarks for
  the 3 hot paths. Stable to ~2%.
- `scripts/bench-retriever-scale.mjs` — end-to-end `retriever.retrieve()`
  at N ∈ {10, 100, 500, 1000}. Reveals the real scaling cliff.
- `scripts/README.md` — how to run + findings.
- `docs/benchmarks/guidance-{baseline,phase-1}.json` — captured runs.
- `docs/benchmarks/guidance-retriever-scale-{baseline,phase-1}.json` —
  scaling curves at four shard counts.

## Honest M2 status

Original target: ≥2x speedup or ≥30% reduction. Phase 1 delivers ~1.1x
at scale — short of the bar. **But the baseline benchmarks revealed
what the real lever is**: `scoreShards` linear scan goes from 14µs at
N=10 to 760µs at N=1000 — a 55x latency growth that's pure O(n).

M3 (HNSW substrate) targets that bottleneck directly. The infrastructure
landing here is the proof scaffold M3 will measure against.

## Verification

- `npm test` in v3/@claude-flow/guidance: all 1,331 tests pass
- `npm run build`: clean
- Bench scripts runnable end-to-end with JSON artifacts under
  `docs/benchmarks/`

Co-Authored-By: RuFlo <ruflo-bot@users.noreply.github.com>
2026-05-21 23:21:29 -04:00
Reuven c67fa393de fix(3.7.0-alpha.13): persist headless results + ab-test guard
Closes #1793, #1652.

#1793 — services/worker-daemon.ts: headless worker runs now persist their
  parsedOutput / output to the same metrics files the local fallback
  workers write to (.claude-flow/metrics/<name>.json). Previously the
  AI-mode branch returned the result and exited, leaving rich findings
  trapped in `.claude-flow/logs/headless/*_result.log` and invisible to
  `npx ruflo memory stats` and downstream consumers. Mapping mirrors the
  *Local methods: audit→security-audit.json, optimize→performance.json,
  testgaps→test-gaps.json, document→documentation.json, etc.

  Persisted record schema: { timestamp, mode:'headless', workerType,
  model, durationMs, tokensUsed, executionId, success, findings (=
  parsedOutput), rawOutputPreview (first 2KB), rawOutputLength }.

  Persistence is wrapped in try/catch so a write failure logs a warning
  but doesn't break the worker.

#1652 — @claude-flow/guidance/src/analyzer.ts: abBenchmark now throws an
  actionable error when the provided executor is not content-aware
  instead of silently producing a guaranteed zero-delta verdict that
  costs ~$23 per run. The DefaultHeadlessExecutor IS content-aware as of
  @claude-flow/guidance@3.0.0-alpha.2 (it has `setContext` and physically
  swaps CLAUDE.md with backup/restore), so the guard only fires for
  caller-injected bare IHeadlessExecutor implementations.

Verification:
- @claude-flow/cli: 1963 tests pass / 0 fail / 46 skipped
- @claude-flow/guidance: 1331 tests pass / 0 fail
- Builds clean for both packages

Published @claude-flow/cli@3.7.0-alpha.13, claude-flow@3.7.0-alpha.13,
ruflo@3.7.0-alpha.13, and @claude-flow/guidance@3.0.0-alpha.3 with all
dist-tags.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-08 09:46:35 -04:00
Reuven c2c21f6ae5 fix: browser --args flag + AppArmor detect + guidance ab-test executor (v3.6.7)
Bug D: --arg → --args (agent-browser CLI expects plural flag with
joined args string, not per-arg iteration).

Bug E: needsNoSandbox now checks apparmor_restrict_unprivileged_userns
in addition to unprivileged_userns_clone for Ubuntu 24.04+.

Issue #1652: DefaultHeadlessExecutor now implements IContentAwareExecutor
with setContext(). Config A removes CLAUDE.md, Config B writes provided
content. Backup/restore ensures original file is preserved.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-28 00:38:58 -04:00
rUv 8f7889de97 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:51:13Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:51:13 +00:00
rUv 0f306a13cc Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:51:09Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:51:09 +00:00
rUv e0113f28a7 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:51:07Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:51:07 +00:00
rUv 2b8a60968a Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:51:02Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:51:02 +00:00
rUv 420331b1a4 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:50:45Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:50:45 +00:00
rUv 010943b83d Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:50:43Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:50:43 +00:00
rUv 5a73c9af58 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:50:40Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:50:40 +00:00
rUv 57cfd462cc Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:50:38Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:50:38 +00:00
rUv 9654d471d7 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:48:48Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:48:48 +00:00
rUv 4af75bec42 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:48:42Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:48:42 +00:00
rUv c9b35d3574 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:48:23Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:48:23 +00:00
rUv 7504d63488 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:54Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:54 +00:00
rUv 11f5c09387 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:48Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:48 +00:00
rUv 9cca2290ab Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:42Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:42 +00:00
rUv ca0640db10 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:35Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:36 +00:00
rUv 28662fb34d Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:26Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:26 +00:00
rUv c1e0627b6f Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:19Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:19 +00:00
rUv 538abab577 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:16Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:16 +00:00
rUv 28b5bdd247 Checkpoint: File edits
Automatic checkpoint created by Claude Code
- Branch: claude/guidance-control-plane-uhmR3
- Timestamp: 2026-02-02T03:47:11Z
- Changes: 3 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 03:47:11 +00:00
Claude 3e5f92ef8b security: eliminate hardcoded HMAC keys, fix timing attacks, remove command injection
- Remove hardcoded DEFAULT_SIGNING_KEY from proof.ts, artifacts.ts, evolution.ts
  Constructors now require explicit signingKey (fail-closed)
- Add timingSafeEqual() XOR-based constant-time comparison to proof.ts,
  artifacts.ts, authority.ts (prevents HMAC timing side-channels)
- Fix command injection in headless.ts: replace execFile('sh', ['-c', cmd])
  with direct arg-array execFile('claude', ['-p', prompt, ...])
- Fix command injection in analyzer.ts: same shell-free pattern
- Remove dead code: unused toLowerCase() in analyzer.ts extractMetrics
  and scoreCompleteness
- Hoist gates.ts GATE_DECISION_SEVERITY to module-level constant
- Add ConformanceRunner signingKey parameter for explicit key propagation
- Update tests: 3 new "should throw without key" assertions
- Add flight build report (docs/reports/flight-build-report.md)

1,331 tests passing.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-02 01:51:26 +00:00
Claude 671831dacd feat: add A/B benchmark harness with 20 tasks, gate simulation, and composite scoring
Implements the Measurement Plan: Config A (no control plane) vs Config B
(Phase 1 guidance) across 20 representative tasks from Claude Flow repo
history spanning 7 task classes (bug-fix, feature, refactor, security,
deployment, test, performance).

KPIs: success rate, tool calls, token spend, violations, human
interventions. Composite score formula:
score = success_rate - 0.1*cost - 0.2*violations - 0.1*interventions

Category shift detection: B beats A by ≥0.2 on composite across ≥3 task
classes. Gate simulation detects destructive commands, hardcoded secrets,
force push, unsafe types, skipped hooks, missing tests, policy violations.

1,328 tests passing across 26 files (38 new AB benchmark tests).

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 22:22:17 +00:00
Claude 047bd1e562 feat: add content-aware executor, Spearman rho, and Cohen's d to validation suite
Fix fundamental flaw where mock executors were static and produced
identical adherence for before/after phases. The new
IContentAwareExecutor interface receives CLAUDE.md content via
setContext(), allowing executors to vary behavior based on guidance
quality. DifferentialMockExecutor analyzes content for security rules,
enforcement statements, build/test commands, and architecture sections
to produce realistic compliance variation.

Statistical improvements:
- Spearman rank correlation (non-parametric alternative to Pearson)
- Cohen's d effect size with interpretation labels
- Multi-trial averaging with majority-vote pass/fail
- Dual-correlation verdict using average of Pearson r and Spearman rho

1,290 tests passing across 26 files.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 21:28:08 +00:00
Claude 00018ac0dd feat: add empirical validation suite proving score-to-behavior correlation
Add validateEffect() that empirically measures whether score improvements
produce actual agent behavioral improvements:

- 15 compliance tasks covering all 6 scoring dimensions (Structure,
  Coverage, Enforceability, Compilability, Clarity, Completeness)
- Severity-weighted assertion evaluation (critical/major/minor)
- Per-dimension adherence rate computation
- Pearson correlation coefficient between score deltas and adherence deltas
- Per-dimension concordance analysis (did score and behavior move together?)
- Statistical significance testing with critical r-value tables
- Verdict classification: positive-effect, negative-effect, no-effect, inconclusive
- Formatted report with task breakdown, remaining failures, and interpretation
- Proof chain integration for tamper-evident audit trail
- Injectable executor interface for testing without real Claude CLI

1,278 tests passing across 26 test files.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 21:12:54 +00:00
Claude ebf7575af0 feat: add context-size-aware optimizer and headless Claude benchmarking
Add optimizeForSize() with compact/standard/full context presets that
restructure CLAUDE.md content through rule extraction, section splitting,
constitution trimming, and duplicate removal to achieve 88%+ scores.

Add headlessBenchmark() for automated compliance testing via claude -p
with injectable executor interface, proof chain verification, and
formatted before/after reports.

1,252 tests passing across 26 test files.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 21:02:44 +00:00
Claude e06f273a1b feat: add CLAUDE.md generators, analyzer, and auto-optimizer
Generators (src/generators.ts):
- generateClaudeMd() - structured CLAUDE.md from project profile with
  language-specific invariants (TS, JS, Python, Rust, Go, Java) and
  framework rules (React, Next.js, Express, Django, etc.)
- generateClaudeLocalMd() - CLAUDE.local.md for personal overrides
  with machine notes, editor prefs, and experimental rules
- generateSkillMd() - Claude Code skills with YAML frontmatter
- generateAgentMd() - Agent definitions with YAML frontmatter
- generateAgentIndex() - Agent index.yaml grouped by category
- scaffold() - Full .claude/ directory structure generation

Analyzer (src/analyzer.ts):
- 6-dimension scoring (0-100 each, weighted composite):
  Structure (20%), Coverage (20%), Enforceability (25%),
  Compilability (15%), Clarity (10%), Completeness (10%)
- benchmark() - before/after comparison with per-dimension deltas
- autoOptimize() - iteratively applies high-priority suggestions
  with concrete patches, re-scores to verify improvement
- formatReport() / formatBenchmark() - human-readable output

Analysis of existing CLAUDE.md files:
- Root CLAUDE.md: 73/100 (C) -> 77/100 after optimization
- v3/CLAUDE.md: 64/100 (D) -> 78/100 after optimization
- Key findings: low rule density, oversized constitution section,
  missing Architecture section

Tests: 141 new tests (68 generators + 73 analyzer), 1229 total passing

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 20:48:36 +00:00
Claude 2dd2bb891f feat: add Rust WASM policy kernel with SIMD128 acceleration
Two-layer architecture: Layer A (Rust→WASM kernel for pure functions) +
Layer B (Node host bridge with transparent JS fallback).

Kernel modules:
- proof: SHA-256, HMAC-SHA256, content hashing, chain verification
- gates: secret scanning (8 patterns), destructive command detection (12 patterns)
- scoring: shard relevance scoring with domain/risk/keyword bonuses
- batch: 9-operation batch API to minimize WASM boundary crossings

Performance (SIMD128 enabled, 10k events):
- SHA-256 throughput: 1.80x faster (910k/s vs 505k/s)
- Secret scan (dirty): 1.96x faster (362k/s vs 185k/s)
- Secret scan (clean): 1.68x faster (676k/s vs 402k/s)
- Proof chain: 1.25x faster (61ms vs 76ms)

Includes:
- Pre-built wasm-pkg/ with SIMD+O2 optimization
- 15 acceptance tests (parity + 10k throughput benchmarks)
- ADR-G025 documenting architecture and performance
- README updated with WASM kernel docs and KPIs
- Wired exports into index.ts and package.json

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 17:44:35 +00:00
Claude 20529c7f6f perf: add 22-benchmark suite with before/after report
Add comprehensive benchmark suite covering 11 modules:
- ContinueGate, ThreatDetector, CollusionDetector, MemoryQuorum
- Gateway, MemoryWriteGate, CoherenceScheduler, TrustAccumulator
- AuthorityGate, IrreversibilityClassifier, MetaGovernor

Key improvements vs commit a57ea60:
- CollusionDetector: +37% (1k interactions, single graph build)
- MemoryQuorum.propose: +73% (O(n) eviction vs O(n log n) sort)
- MemoryQuorum.vote+resolve: +186% (single-pass vote counting)
- Gateway.evaluate: +8% (batch cleanup interval)
- ContinueGate cooldown: -29% (intentional: safety checks added)

Additional optimization: MemoryQuorum.resolve() now counts votes
in a single pass instead of two Array.filter() calls.

Full suite: 23 files, 1073 tests passing.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 17:17:59 +00:00
Claude ce0da62054 fix: security hardening and performance optimization across 4 modules
Security fixes:
- continue-gate: check critical stop conditions (coherence, budget)
  during cooldown to prevent bypass via step timing
- gateway: add maxCacheSize (default 10k) to idempotency cache to
  prevent unbounded memory growth under high-throughput unique calls
- authority: add ReDoS protection to addPattern() — rejects nested
  quantifiers and enforces 500-char max pattern length

Performance fixes:
- adversarial: MemoryQuorum eviction from O(n log n) sort to O(n)
  linear min-find
- adversarial: CollusionDetector.detectCollusion() builds interaction
  graph once and passes to ring/frequency detectors (was rebuilding 3x)
- gateway: batch idempotency cache cleanup on 30s interval instead of
  every evaluate() call

Tests:
- Add 42-test continue-gate.test.ts covering all decision paths,
  cooldown bypass protection, history, stats, slope detection, and
  edge cases
- Full suite: 22 files, 1050 tests passing

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 17:13:00 +00:00
Claude a57ea60aab feat: add ContinueGate, wire all exports, rewrite README
- Add ContinueGate (ADR-G024): step-level gate that evaluates whether
  long-running agents should continue, using budget slope detection,
  rework ratio tracking, and coherence/uncertainty thresholds
- Wire 5 missing wave 3 module exports into index.ts (trust,
  truth-anchors, uncertainty, temporal, authority)
- Add 8 missing sub-export paths to package.json (trust, truth-anchors,
  uncertainty, temporal, authority, adversarial, meta-governance,
  continue-gate)
- Rewrite README with product-oriented introduction, mermaid architecture
  diagram, 28-module reference table, ship phases, acceptance tests,
  decision matrix, and failure modes

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 17:05:45 +00:00
Claude cfcb25b7d0 feat: add wave 3 civilization-grade primitives (trust, truth, uncertainty, time, authority, adversarial, meta-governance)
8 new modules with 4 test suites (332 new tests, 1008 total):
- trust.ts: per-agent trust accumulation, decay, tiers, rate multipliers
- truth-anchors.ts: immutable HMAC-signed external facts, conflict resolution
- uncertainty.ts: first-class belief tracking, confidence intervals, evidence
- temporal.ts: bitemporal assertions, validity windows, supersession chains
- authority.ts: human/institutional authority boundaries, irreversibility
- adversarial.ts: threat detection, collusion analysis, memory quorum
- meta-governance.ts: constitutional invariants, amendment lifecycle
- ruvbot-integration.ts: bridge to ruvbot AIDefence and memory adapter

README updated with all wave 3 modules, impact metrics, and architecture.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 14:32:40 +00:00
Claude ee3c182b79 feat: complete wave 2 with conformance kit, exports, ADRs, and README
- Add conformance-kit.ts: Memory Clerk acceptance test with SimulatedRuntime,
  MemoryClerkCell, and ConformanceRunner for replay verification
- Add manifest-validator.test.ts: 59 tests for fails-closed admission
- Add conformance-kit.test.ts: 42 tests for cell runtime and replay
- Wire all wave 2 modules into index.ts (capabilities, conformance-kit,
  proof, memory-gate, coherence)
- Add 8 new export paths to package.json (proof, memory-gate, coherence,
  artifacts, capabilities, evolution, conformance-kit)
- Write ADR-G010 through G016 covering capability algebra, artifact ledger,
  manifest validator, evolution pipeline, conformance kit,
  coherence-driven throttling, and agentic container integration
- Add package README with quantified impact, API reference, tutorials,
  architecture diagram, and full test matrix
- 639 tests passing across 17 test files

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 12:04:55 +00:00
Claude db9cedc5ea feat: add manifest validator and evolution pipeline tests
Manifest validator: fails-closed admission checking for agent cell
manifests. Validates digest format, budget sanity, network allowlists,
risk scoring, and lane selection per the Agentic Container Spec v0.1.

Includes ConformanceSuite with golden trace validation and default
test traces for destructive commands, secrets, budget exceeded,
evidence-less writes, and valid operations.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 11:45:12 +00:00
Claude 4d68d8b47a feat: add capability algebra and evolution pipeline
Capability algebra: typed capability objects with grant, restrict,
delegate, expire, revoke, attest operations. Permissions are composable
data, not scattered config. Supports delegation chains, constraint
intersection, and subset checking.

Evolution pipeline: signed change proposals with simulation, replay
comparison, staged rollout, and automatic rollback on divergence.
Every change to rules/policies/tools follows:
propose → simulate → compare → stage → promote/rollback.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 11:44:31 +00:00
Claude c0e708a8d3 feat: add artifact ledger for signed production records
ArtifactLedger with HMAC-signed artifacts, content hashing, lineage
tracking, verification, and search. Every production output (code,
reports, datasets, memory deltas) is signed, versioned, and replayable.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 11:43:18 +00:00
Claude 794c489cf6 fix: hooks test secret pattern and agent refinements
- Update hooks test to use sk- pattern that survives JSON.stringify
- Agent refinements to persistence.ts and vitest.config.ts

All 379 tests passing across 12 test files.

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 11:31:33 +00:00
Claude d43d6e1b22 feat: add wave 1 guidance primitives - proof, gateway, memory-gate, coherence, hooks, persistence
Seven concurrent agents built the core guidance control plane primitives:

- hooks.ts: GuidanceHookProvider wiring gates + retriever into
  HookRegistry lifecycle (PreCommand, PreToolUse, PreEdit, PreTask, PostTask)
- proof.ts: ProofChain with hash-chained envelopes, HMAC signing,
  tool call hashes, and memory lineage tracking
- gateway.ts: DeterministicToolGateway with idempotency cache,
  schema validation, and budget metering wrapping EnforcementGates
- memory-gate.ts: MemoryWriteGate with authority scope, rate limiting,
  TTL/decay, confidence scoring, and contradiction detection
- persistence.ts: PersistentLedger with NDJSON event storage,
  compaction, index maintenance, and file locking
- coherence.ts: CoherenceScheduler (drift detection, privilege throttling)
  and EconomicGovernor (token/tool/storage/time/cost budgets)
- Updated index.ts exports and package.json for new modules

Tests: 6 new test files covering all wave 1 components

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 11:29:03 +00:00
Claude fab6d72ff8 feat: add @claude-flow/guidance control plane package
Implements a complete guidance control plane that sits beside Claude Code
to compile, retrieve, enforce, and optimize guidance rules.

Components:
- Compiler: Parses CLAUDE.md into constitution + shards + manifest
  with regex-based rule extraction, risk/intent/domain inference,
  and root/local overlay merging
- Retriever: Intent classifier with weighted pattern matching and
  shard retriever with hash-based embeddings, contradiction resolution,
  and diversity-aware selection
- Gates: 4 enforcement gates (destructive ops, tool allowlist,
  diff size, secrets) with configurable patterns and remediation
- Ledger: Run event logging with 5 built-in evaluators (tests pass,
  forbidden commands, forbidden deps, violation rate, diff quality)
- Optimizer: Weekly optimization loop with violation ranking, rule
  change proposals, A/B testing simulation, ADR generation, and
  promotion tracking (win-twice-to-promote)
- Headless: Test harness for Claude Code headless mode with task
  suites, assertion checking, and compliance testing
- CLI: guidance command with compile/retrieve/gates/status/optimize
  subcommands registered in CLI command index

Tests: 105 passing across 6 test files (compiler, retriever, gates,
ledger, optimizer, integration)

https://claude.ai/code/session_01HLi9WmfvFgkDLJxLKGAUTf
2026-02-01 10:58:53 +00:00