ruvector/.github
rUv 44a836d57e
feat(emergent-time): calculus of emergent time + Agentic Time primitive (#561)
* feat(emergent-time): calculus of emergent time + Agentic Time primitive

Add `crates/emergent-time`, a dependency-free Rust implementation of the
calculus of emergent/relational time, plus a new agentic-time primitive and
an honest multi-clock benchmark.

Physics formalisms (each verified by tests):
- Wheeler-DeWitt timeless constraint H|Psi>=0 (kernel solver, residual ~1e-15)
- Page-Wootters relational clock: Schrodinger evolution emerges from a static
  entangled state via conditioning (fidelity 1.0)
- Entropic time tau_S=(S-S0)/k (cold-atom analogue; speed tracks dS/dlambda)
- Connes-Rovelli thermal time: modular Hamiltonian K=-ln rho, modular flow
  A(s)=e^{isK}A e^{-isK} (recovers rescaled physical evolution for Gibbs states)

Numerical core: self-contained complex scalars, real symmetric Jacobi
eigensolver, complex unitary evolution via spectral exponentiation, von Neumann
entropy via a real-symmetric Hermitian embedding.

Agentic time:
- Structural Proper Time: internal time as arc length through the state manifold
- Agentic Time tau_a=f(dB,dM,dR,dG,dE,dP) with explainable ticks (class+reason),
  Agentic Time Index, and a 7-state health classifier
- Four-clock benchmark (wall/step/token/agentic). On the bundled synthetic
  traces, structural time warns 2.8x earlier than the entropy clock and agentic
  time gives a 40-step lead where wall/step/token give 0, preserving causal order

Includes a walkthrough example, criterion benches, and ADR-251 documenting
Agentic Time as a proposed Ruflo/RuVector/RuQu runtime primitive.

39 tests passing, clippy clean.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

* fix(emergent-time): M1 correctness + honesty hardening

Five corroborated-review fixes that raise rigor/honesty without touching
the sound numerical core (Jacobi eigensolver, spectral exp, state/complex/
entropy unchanged).

FIX 1 — explain() noise-floor contract (agentic_time.rs): document that
per-channel Tick fields are RAW (pre-floor) weighted contributions while
`delta` is post-floor max(0, Σchannels − noise_floor); the identity
delta==Σchannels holds only when noise_floor==0. New test
explain_delta_is_post_floor_channels_are_pre_floor asserts the floor=0.1
case (delta strictly < Σchannels) and the clamp-to-0 case.

FIX 2 — Wheeler–DeWitt falsifiability (wheeler_dewitt.rs): module doc now
states the kernel is trivial-by-construction for the energy-matched clock;
existing "kernel" tests relabelled as consistency checks; new discriminating
test generic_clock_yields_empty_physical_space builds Ĵ from a generic
H_C ≠ −H_R and asserts NO eigenvalue within 1e-9 of zero (empty physical
space), with a deterministic perturbation guard and an eigenvalue-sum bound.

FIX 3 — entropic non-tautological test (entropic.rs): docstring softened to
"β-swept Gibbs ensemble" (a temperature sweep, not closed-system dynamics);
tautological tau test renamed tau_reparametrization_formula_is_exact; new
internal_time_spacing_tracks_measured_entropy_production verifies the clock
rate against independently finite-differenced gibbs_entropy and that the
entropy curve is non-trivial and correctly signed.

FIX 4 — Page–Wootters honesty docstring (page_wootters.rs): scope is
real-symmetric H; Born-rule weighting holds only for pure global states;
single-time conditional states only — Kuchař two-time objection out of scope.

FIX 5 — fair baseline + de-hype (agentic_time.rs, examples/emergent_time.rs):
new WindowedDeltaClock rolling-window z-score change-point detector (the
non-strawman baseline the constant-rate wall/step/token clocks were missing).
On the designed trace the fair baseline fires at least as early as the agentic
clock; example output and test relabel the headline as a coverage-gap demo,
not a competitive win. Honest finding: agentic clock does NOT beat a fair
baseline on synthetic data — real-trace head-to-head is M3 work.

ADR-251: adds "Honest limitations" section (WD constructive-not-discovery,
entropic β-sweep, benchmark coverage-gap-not-win, PW scope) and prior-art
note (ADWIN; Ostovar 2016 concept-drift in process mining) stating what is
new (physics-grounded composite state-arc-length runtime primitive).

cargo test -p emergent-time: 43 passed (39 baseline + 4 new); build/clippy
clean; example prints the fair baseline.

Co-Authored-By: claude-flow <ruv@ruv.net>

* perf(emergent-time): M2 performance + robustness (P1/P2/R1/R4)

Numerical core unchanged — pure speed (P1/P2) plus guardrails (R1/R4)
that do not alter valid-input results. All 49 tests pass (43 original
+ 6 new); clippy clean; physics fidelity/entropy/modular values
unchanged.

P1 — stop re-diagonalizing (complex_matrix.rs, page_wootters.rs)
  - Add exp_i_from_spectrum / exp_i_apply_from_spectrum: spectral
    exp(iθH) from a PRECOMPUTED (eigvals, V), no re-diagonalization.
    exp_i_symmetric now routes through exp_i_from_spectrum.
  - PageWootters caches |ψ0| and evolves in the cached energy eigenbasis:
    schrodinger_state(t) = Σ_k e^{-iE_k t}⟨E_k|ψ0⟩|E_k⟩, O(n²)/t, no
    propagator matrix. From-scratch path kept as
    schrodinger_state_from_scratch for callers holding only H.
  - Bench (n16): cached 666 ns vs from-scratch 35.3 µs → ~53x.
  - New test cached_evolution_equals_from_scratch_propagator (1e-12).

P2 — hoist t-independent static state (page_wootters.rs)
  - global_static_state |Ψ| (d²) built once in new(), cached; per-t
    conditional_state conditions the cached vector.
  - Bench page_wootters_conditional_n8: 294 ns → 225 ns (~1.3x).

R1 — restore entropy guardrail (entropy.rs)
  - Replace silent `p > 1e-12` clamp with standard von-Neumann `p > 0.0`
    (skips only 0·ln0; keeps legitimate tiny probabilities; roundoff
    negatives contribute 0). Add debug-only PSD + normalization
    validation so a non-PSD/non-normalized ρ surfaces in dev.
  - New tests: roundoff-negative [0.5,0.5,-1e-15]→ln2, tiny-positive not
    clamped, non-PSD/non-normalized trip debug_assert (debug-only).

R4 — relative Jacobi convergence + non-convergence guard (real_matrix.rs)
  - Replace scale-dependent absolute `off < 1e-28` with relative
    off²/‖A‖²_F < tol² (tol=1e-14); sweep cap kept as backstop.
  - debug_assert! fires if the cap is hit without convergence (signature
    unchanged — every caller destructures (Vec<f64>, RealMatrix);
    subsumes the deferred M1 convergence guard).
  - New near-degenerate stress test (diag 1, 1+1e-10, 2 + tiny
    off-diagonals): orthonormal vectors + correct spectrum.

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(emergent-time): M3 real-trace defensibility gate (honest null result)

Run the agentic clock vs the FAIR WindowedDeltaClock baseline (and the
constant-rate strawmen) on REAL recorded agent traces -- the Claude Code
session transcripts for this repo -- with PRE-REGISTERED thresholds and an
honestly-defined event-to-predict. This replaces the circular synthetic
benchmark with the genuine M3 gate from ADR-251 section 4.

THE FINDING (reported honestly, not manufactured): on the 2 real traces the
contradiction-free honest agentic clock scores 0 win / 1 tie / 1 loss vs the
fair windowed baseline. It does NOT beat the fair baseline on real data either.
The defensible value of the primitive is diagnostic (per-channel attribution +
health classifier), not a raw early-warning-lead win. The crate stays honest.

- examples/real_trace_eval.rs: real-trace adapter + pre-registered protocol.
  - Source: ~/.claude/projects/C--Users-ruv-ruvector/*.jsonl (real tool-use
    sequences, retries, is_error events). Deliberately NOT intelligence.json
    (51 flat all-success records, no failure events -- would be dishonest).
  - Documented heuristic channel mapping (tool-type TF -> belief, distinct
    files -> memory, Read/Grep -> retrieval, new user prompt -> goal, is_error
    rate -> contradiction, text+repetition -> plan).
  - Event-to-predict = real error cascade (>=2 is_error in 4 steps), defined
    from the harness is_error flag ONLY (non-circular).
  - Circularity guard: an honest agentic variant with contradiction weight 0
    so it cannot see the signal that defines the event. This is the real gate.
  - Pre-registered (before any lead computed): window=10, k=3sigma, metric=lead.
  - Prints an alive-vs-degenerate diagnostic: the honest signal is NOT flat
    (mean inc ~1.5, max ~4.4) but never clears its own mean+3sigma bar because
    early exploratory churn sets a high baseline -- a real property of real
    traces, not a dead clock.
  - Degrades gracefully (prints [skip], exits 0) when no traces are present,
    so CI without the data still passes.
- agentic_time.rs: add test contradiction_free_weights_blind_to_error_channel
  locking in the M3 circularity guard (50 tests, was 49).
- ADR-251: replace the M3-future-work note with the actual real-trace result;
  mark the Baseline-dominance gate UNMET; full lead table + caveats in Honest
  limitations.

Validation: cargo test -p emergent-time => 50 passed; build + clippy clean;
real_trace_eval runs and prints real numbers (0 win / 1 tie / 1 loss).

Co-Authored-By: claude-flow <ruv@ruv.net>

* feat(emergent-time): M3b adaptive change-point detector (honest null, more robust)

M3 got an honest null on real traces with a fixed-window mean+3σ alarm and
diagnosed the cause: a frozen early baseline poisoned by exploration churn. M3
proposed an adaptive-window detector as the fix. M3b implements that exact fix.

- src/adaptive.rs: Page-Hinkley test (Page 1954 / Hinkley 1970), dependency-free
  pure Rust. Running-mean reference instead of a frozen window; upward + downward
  forms; clock-agnostic adaptive_alarm_step / adaptive_early_warning_lead.
  Documented math + literature citations. 12 unit tests (detects real step-change,
  silent on stationary noise, constant streams never alarm, threshold/tolerance
  monotonicity, slot-0 padding excluded, fair on both clock + baseline).
- examples/real_trace_eval.rs: wires the SAME pre-registered detector (δ=0.15,
  λ=5.0, fixed before any lead) into BOTH the agentic-honest composite AND the
  fair baseline. Prints fixed-window (M3) AND adaptive (M3b) leads side-by-side.

Honest result on the same n=2 real traces: the adaptive detector works as
designed — the fair belief-shift baseline, which never fired under the fixed
window, now leads by 32 and 25 steps. But it does NOT rescue the agentic clock:
the honest composite's adaptive alarms (steps 75, 49) still land AFTER the error
cascades (steps 37, 29), so its lead stays 0. Verdict moves 0/1/1 → 0 win / 0 tie
/ 2 loss. The M3-proposed fix was tried and did not change the verdict; the honest
null is now MORE ROBUST. Defensible value of the primitive remains diagnostic
(per-channel attribution + health classifier), not a raw early-warning-lead win.
n=2 caveat stands; a fair win would have demanded a larger pre-registered corpus.

ADR-251 §3/§4 extended with the adaptive-detector outcome and fixed-vs-adaptive
table. cargo test green (62), clippy clean, examples build, graceful-skip intact.

Co-Authored-By: claude-flow <ruv@ruv.net>

* style(emergent-time): apply rustfmt across the crate

Bring the crate (including the M2/M3/M3b additions) under rustfmt to
satisfy the CI Rustfmt check. Formatting only; no behavior change, 62
tests still pass.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

* fix(emergent-time): make real-trace parser robust to tool_use key order

The M3 real-trace harness silently ingested zero steps from genuine
Claude-Code transcripts because `extract_tool_names` only searched for
`"name":"..."` AFTER the `"type":"tool_use"` marker. Current transcripts
emit the name BEFORE the type (`{"name":"Bash","type":"tool_use",...}`),
so every single-tool step was dropped, `parse_session` fell below
MIN_STEPS and returned None, and the harness reported "No real session
transcripts found" — masquerading a parse failure as missing data.

Verified on a real 531-line session transcript: 0 steps parsed before,
112 after. The session has no error cascade, so it is correctly reported
as descriptive-only (not scoreable) rather than silently skipped.

Changes:
- extract_tool_names: pair each tool_use marker to the nearest "name"
  within a bounded window in EITHER direction (order-independent).
- load_traces: return files-seen / parse-failure counts so main can
  distinguish "no files" from "files present but unparseable" — an
  honesty fix so a silent parser gap can't pose as absence.
- add a regression test covering both key orderings + multi-tool lines.

fmt clean, clippy clean, 62 lib tests + 1 example test pass.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

* feat(emergent-time): learn agentic-time channel weights (honest harness)

Replace hand-set AgenticWeights with weights LEARNED from labelled
outcomes via L2-regularized logistic regression (dependency-free), with
held-out evaluation and a circularity guard (Honest mode drops the
contradiction channel).

Honest finding, reported not hidden: learning matches the hand-set guess
(AUC 0.936 vs 0.935) and yields interpretable importances (plan +0.75
dominant), but does NOT beat the best single channel on this synthetic
data (goal_graph 0.950 / contradiction 0.956) — the signal is
concentrated in one planted channel. Composition only earns its keep
when signal is spread across weak channels (ADR-251 §4), which needs
real traces. This is the reusable apparatus to run that test.

4 new tests; 66 lib tests pass, clippy + fmt clean.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

* feat(emergent-time): trained model + witness-chain provenance

Add a deterministic trained-weight model with tamper-evident, reproducible
provenance, and an honest "beyond baseline, with proof" demonstration.

- weight_learning: make LearnedWeights dimension-generic (store `dim`, add
  `from_params`); add a Gaussian sampler and `diffuse_dataset` — a controlled
  weak-signal benchmark (channels of differing strength + pure-noise channels).
  New test proves the learned composition BEATS both the best single channel
  and the equal-weight baseline in this regime (the one the thesis targets).

- witness: FNV-1a hash-linked WitnessChain (seal/append/verify, text round-trip,
  tamper + reproducibility detection). Proof of *provenance*: the sealed metrics
  correspond to the committed model and re-training reproduces the same hash.

- examples/train_model: trains, seals a witness record, persists the model +
  chain artifact, then verifies (1) chain integrity, (2) committed model matches
  sealed model_hash, (3) reproducibility. On the diffuse benchmark the learned
  model scores AUC 0.759 vs best-single 0.681 vs equal-weight 0.708 and recovers
  the signal structure (noise channels learned to ~0).

- models/agentic_weights.witness.txt: the sealed trained-model artifact.

HONEST SCOPE: this is "beyond baseline, with verifiable proof" in the method's
target regime (distributed weak signal) — NOT a claim of beating real-world
agent-failure SOTA, which still needs real labelled traces (ADR-251 §4).

72 lib tests pass, clippy + fmt clean.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

* docs(emergent-time): add README; release 2.2.4

2.2.3 published without a README (bare crates.io page). Adds a
matter-of-fact README (physics formalisms, Agentic Time, benchmark
results, usage) and decouples the crate version from the workspace so it
can be released independently.

Co-Authored-By: claude-flow <ruv@ruv.net>

* ci(emergent-time): dedicated test + falsifiability guard

Path-filtered CI gate for the emergent-time crate: fmt, clippy -D
warnings, full test suite, example builds + no-data runs, and a
publish-equivalent package check. Plus a guard step that greps for the
falsifiability / pre-registered-evaluation tests (generic-clock empty
kernel, cached-vs-from-scratch equivalence, entropy-rate-vs-measured,
error-blind agentic weights, real_trace_eval harness) so none can be
silently removed without failing CI.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(emergent-time): sync Cargo.lock to crate version 2.2.4

The 2.2.4 version bump updated Cargo.toml but left Cargo.lock at 2.2.3,
failing the lockfile-integrity CI gate. Update the lock to match.

https://claude.ai/code/session_01ApBCSaebKsCzLeA7JhvDvU

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: ruv <ruvnet@users.noreply.github.com>
2026-06-13 13:15:31 -04:00
..
benchmarks feat: Add Neo4j-compatible hypergraph database package (ruvector-graph) 2025-11-25 23:11:54 +00:00
workflows feat(emergent-time): calculus of emergent time + Agentic Time primitive (#561) 2026-06-13 13:15:31 -04:00
dependabot.yml ci(security): add 5-layer supply-chain CI + clear 3 npm criticals 2026-05-19 08:59:46 -04:00