Commit Graph

5 Commits

Author SHA1 Message Date
Claude 46b4d63dad feat(ruview-gamma): centralize claim-gate invariant + add HIL acceptance contract
Two of the "what to optimize next" items, as enforced code:

1. Hard claim gate: extract the release rule into a single
   acceptance::claim_allowed(entrainment, safety, adherence, repeatability)
   = strict AND of all four, used by every path. A test proves every 3-of-4
   subset is denied, so no path can silently weaken the gate to an OR/subset.

2. Hardware-in-the-loop contract (new hil module): verify_hil grades a
   captured actuator bench measurement against fixed targets — LED frequency
   +/-0.1 Hz, audio-visual sync < 5 ms, stop-signal -> actuator-off < 100 ms,
   session-hash reproducibility 100%, EEG entrainment lift >= 20% over fixed
   40 Hz. Every failure mode fails closed (missing/NaN stop measurement, no
   replay, any hash mismatch). The crate stays a deterministic leaf: firmware
   records the measurements, this module grades them.

README: benchmark table (safety tick ~8 ns, recommend ~15 us, cohort kNN/500
~15 us, calibration ~115 us, acceptance grading ~425 us enrollment-only) and
the positioning line — "a governed personalization engine that refuses to
overpromise."

9 new tests; crate now 97 + 1 doctest; pinned witness 13cb164c... preserved.
Workspace gate: 2,898 passed / 0 failed.

https://claude.ai/code/session_01MjBucx95K4BuUxZi8NWwRH
2026-06-10 04:31:28 +00:00
Claude d55e3659be feat(ruview-gamma): generalize to adaptive sensory neuromodulation platform
40 Hz becomes one prior in one program, not the product. The engine is a
personal neural-rhythm optimization platform: RuView is the feedback signal,
RuVector the personal response map, the device the actuator, RuFlo the
governed/auditable loop (ADR-250 section 23).

New "program" module: NeuroProgram catalog of 7 use cases (Alzheimer's
research, post-stroke cognition, sleep optimization, attention/working-memory,
mood/arousal, home wellness, drug+device trial infrastructure), each with its
own SafetyEnvelope, prior, ObjectiveWeights, physiological-state gating
(sleep permits Asleep + near-dark brightness cap; attention requires
wakefulness), EvidenceLevel, and a single non-disease claim.

New "acceptance" module: makes "measurable entrainment, safety, adherence,
repeatability before any disease claim" executable. AcceptanceHarness grades
a program over >=3 repeats; ClaimGate releases the program's claim ONLY when
all four pass, else the research-only NO_CLAIM string. The marketing claim is
unreadable except through the gate.

Governor: enroll_program (per-program envelope/objective), program(), prior(),
state_eligible(). The bare enroll() path is unchanged, so the pinned witness
13cb164c... is preserved.

88 crate tests + 1 doctest; workspace gate 2,889 passed / 0 failed. Benches:
program grading ~425us; hot paths unchanged (recommend ~15us, calibration
~115us, kNN/500 ~15us).

https://claude.ai/code/session_01MjBucx95K4BuUxZi8NWwRH
2026-06-10 04:19:45 +00:00
Claude 2aac160067 feat(ruview-gamma): RuVector self-learning layer (ADR-250 §10 items 3-6)
New ruvector module: anonymized ProfileStore (one-way SHA-256 hashed tags,
safe-session scores only), deterministic exact kNN, cohort warm-start (a new
person's optimizer seeded from the k nearest responders as down-weighted GP
pseudo-observations), physiological drift detection (Welford centroid with
stimulus-input fields masked out of the distance), and deterministic k-means
response clustering.

Honesty guarantees, asserted in tests: cohort priors carry >=25x the
real-observation noise, are excluded from the EI incumbent, the audit log,
and the clinician report — borrowed expectations never masquerade as this
person's measured response. The GP gains per-observation noise; the real
path is arithmetically unchanged (pinned witness 13cb164c... preserved).

Governor wiring: seed_from_cohort, export_anonymized_profile, per-session
drift_status. Integration tests: cohort warm-start beats the cold 40 Hz
prior for a detuned subject; collapsed physiology flags Drifted.

Crate: 75 tests + 1 doctest. Workspace gate: 2,876 passed, 0 failed.
Benches: kNN/500 profiles ~15us, warm-start ~16us; no regression on
existing paths (recommend ~15us, calibration sweep ~111us).

https://claude.ai/code/session_01MjBucx95K4BuUxZi8NWwRH
2026-06-10 04:08:47 +00:00
Claude 3413a74228 perf(ruview-gamma): factorize GP once per recommendation (-81%)
BayesianOptimizer::recommend evaluated Expected Improvement at every 0.1 Hz
grid candidate, and each predict() rebuilt the kernel matrix and re-ran
Cholesky — ~82 factorizations per call — though K and alpha=K^-1 y depend
only on the observations, not the query point. Fit the GP once (GpFit:
cached L + alpha, lower-triangle-only K build) and reuse it across the grid.

Bit-identical arithmetic: the pinned deterministic witness and all 64 tests
are unchanged; pure work elimination. Measured (criterion, paired):
gamma_bayesian_recommend 105us -> 19us (-81%); gamma_calibration_sweep
466us -> 135us (-71%).

https://claude.ai/code/session_01MjBucx95K4BuUxZi8NWwRH
2026-06-10 03:36:07 +00:00
Claude 3408883f79 feat(ruview-gamma): implement ADR-250 Adaptive Gamma Entrainment crate
Governed, deterministic, safety-constrained personalization of 40 Hz-prior
light+sound stimulation (RuView sensing + RuVector response modeling + RuFlo
audit). 40 Hz is the starting prior, not the hard-coded answer.

11 modules: stimulus/SafetyEnvelope, safety (exclusion screen + latched
monitor), response (20-field PersonResponseVector + optional EEG), objective
(safe-entrainment score, safety as hard gate), simulator (deterministic
ChaCha20 frequency_response_curve), optimizer (calibration sweep + GP/EI +
closed-loop), bandit (LinUCB), session (reproducible SHA-256 witness), ruflo
(consent/exclusion/envelope/audit/trial-sham/clinician-export/claim-discipline),
proof (deterministic bundle witness), math.

Safety invariant asserted in tests: no emitted stimulus can ever leave the
SafetyEnvelope; non-finite inputs clamp to the conservative floor. Claim
discipline: only 'personalized entrainment optimization', never Alzheimer's
treatment (ADR-250 §19). Standalone leaf, publish=false pending safety sign-off.

Validation: 64 unit/integration + 1 doctest pass; full workspace gate green
(2,862 passed, 0 failed); deterministic witness pinned; criterion benches
(safety-stop tick ~9.3 ns vs the ADR §17 500 ms bound).

Adds ADR-250 doc, registers the crate, updates CLAUDE.md crate table and
CHANGELOG.

https://claude.ai/code/session_01MjBucx95K4BuUxZi8NWwRH
2026-06-10 03:30:28 +00:00