Skip to content

Commit 0b51edd

Browse files
The Architectclaude
andcommitted
release: v1.8.2 — HBit real at the Value level (pervasive dual-band)
Phase 6 step 2: every value can now carry a β (harmonic-shadow) band that rides alongside α through arithmetic. α is always the exact answer; β records harmonic drift. value.rs: HInt gains `beta: Option<i64>` (None = single-band, byte-identical to before; Some = dual-band). with_beta() + Value::beta_band(). PartialEq unchanged (compares α). interpreter.rs: db_int() threads β through Add/Sub/Mul/Div/Mod/Power — no-β path is exactly HInt::new(α), so ordinary code is unaffected (172/172 tests pass). Builtins now real (were stubs): phi_shadow(v) attaches β = nearest Fibonacci attractor; harmony(v) = 1000·harmony(α,β). New: bands(v) -> [α,β], value_divergence(v). Verified (valueband_demo.omc): phi_shadow(10)+3 -> bands [13,11]; (phi_shadow(50)+1)*3 -> [153,105], divergence 933; result == 153 (α exact, β never alters). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 83a50ac commit 0b51edd

6 files changed

Lines changed: 154 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = ["omnimcode-python"]
2121
resolver = "2"
2222

2323
[workspace.package]
24-
version = "1.8.1"
24+
version = "1.8.2"
2525
edition = "2021"
2626
authors = ["The Architect <architect@sovereign-lattice.io>"]
2727
license = "MIT"

experiments/transformerless_lm/AUTONOMOUS_LOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,22 @@ PHASES 1-5 CONTINUATION (no-side-tracks pass, post-v1.8.0, 2026-05-30)
655655
domain (retrieve+compose+verify over a corpus); P1's correctness≈coverage is exact-retrieval (the
656656
held-out/composition gap — generalizing BEYOND the store — is still bounded by generator quality, but
657657
that too is CPU: grammar-gen + verify, not GPU). Task #43 (NEXT-7) DONE on CPU.
658+
659+
PHASE 6 (step 2) — HBit REAL AT THE VALUE LEVEL [DONE + VERIFIED] (pervasive per-value dual-band)
660+
- value.rs: HInt gained `beta: Option<i64>` (β shadow band). None (default for ALL ordinary values)
661+
= single-band, byte-identical to before. with_beta() constructor; Value::beta_band() accessor.
662+
PartialEq still compares α only (no equality breakage). Only 2 struct literals touched; 413
663+
HInt::new callers unaffected.
664+
- interpreter.rs: db_int() helper threads β through ALL six integer ops (Add/Sub/Mul/Div/Mod/Power):
665+
NEITHER operand has β → exactly HInt::new(α) (unchanged); either has β → result β = op(lβ,rβ) with
666+
α-fallback, div/mod zero-guarded. α is ALWAYS exact; β never alters a result — only records drift.
667+
- Builtins now REAL (were stubs): phi_shadow(v) attaches β = nearest Fibonacci attractor of α (was
668+
identity); harmony(v) = 1000·harmony(α,β) if β present else 1000 (was constant 1000). NEW:
669+
bands(v)->[α,β], value_divergence(v)->1000·(1-harmony).
670+
- VERIFIED (valueband_demo.omc): 7+3=10 harmony 1000 (single-band unchanged); phi_shadow(10) bands
671+
[10,8]; phi_shadow(10)+3 → [13,11] (β rode through +); (phi_shadow(50)+1)*3 → [153,105],
672+
value_divergence 933 (off-lattice); w==153 true (α exact). 172/172 core tests pass — the additive
673+
Option<i64> field changed nothing for non-shadowed values.
674+
- The user's HBit dual-band model [[omc_hbit_dualband_vision]] made pervasive at the Value level:
675+
every value CAN carry its β shadow, it propagates through arithmetic, divergence readable anywhere,
676+
α always correct. Next horizons: value-granular SKIP form, then kernel/microcode HBit.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Phase 6 — HBit real at the VALUE level: β shadow rides through arithmetic.
2+
print("-- ordinary values are single-band (β = α): unchanged behavior --");
3+
h x = 7 + 3;
4+
print(x); // 10
5+
print(harmony(x)); // 1000 (in tune with itself — no shadow)
6+
7+
print("-- phi_shadow attaches the harmonic shadow band; it then RIDES through math --");
8+
h s = phi_shadow(10); // α=10, β=nearest attractor of 10 = 8
9+
print(bands(s)); // [10, 8]
10+
h t = s + 3; // α=13, β=8+3=11 (β propagated through +)
11+
print(bands(t)); // [13, 11]
12+
print(value_divergence(t)); // drift of 13 vs 11 (|13-11|=2 is on-lattice → low)
13+
14+
print("-- a chain that DRIFTS off the lattice raises divergence --");
15+
h u = phi_shadow(8) * 7; // α=56, β=8*7=56 ... both same here
16+
print(bands(u)); // [56, 56]
17+
print(value_divergence(u)); // 0 (stayed in tune)
18+
h w = (phi_shadow(50) + 1) * 3; // α: (50+1)*3=153 ; β: (34+1)*3=105
19+
print(bands(w)); // [153, 105]
20+
print(value_divergence(w)); // > 0 (drifted — α is the truth, β shows lattice path)
21+
22+
print("-- α is ALWAYS the exact answer; β never changes a result --");
23+
print(w == 153); // true

omnimcode-core/src/interpreter.rs

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,7 @@ impl Interpreter {
21042104
} else if lv.is_float() || rv.is_float() {
21052105
Ok(Value::HFloat(lv.to_float() + rv.to_float()))
21062106
} else {
2107-
Ok(Value::HInt(HInt::new(lv.to_int().wrapping_add(rv.to_int()))))
2107+
Ok(db_int(&lv, &rv, lv.to_int().wrapping_add(rv.to_int()), |a, b| a.wrapping_add(b)))
21082108
}
21092109
}
21102110
Expression::Sub(l, r) => {
@@ -2113,7 +2113,7 @@ impl Interpreter {
21132113
if lv.is_float() || rv.is_float() {
21142114
Ok(Value::HFloat(lv.to_float() - rv.to_float()))
21152115
} else {
2116-
Ok(Value::HInt(HInt::new(lv.to_int().wrapping_sub(rv.to_int()))))
2116+
Ok(db_int(&lv, &rv, lv.to_int().wrapping_sub(rv.to_int()), |a, b| a.wrapping_sub(b)))
21172117
}
21182118
}
21192119
Expression::Mul(l, r) => {
@@ -2122,7 +2122,7 @@ impl Interpreter {
21222122
if lv.is_float() || rv.is_float() {
21232123
Ok(Value::HFloat(lv.to_float() * rv.to_float()))
21242124
} else {
2125-
Ok(Value::HInt(HInt::new(lv.to_int().wrapping_mul(rv.to_int()))))
2125+
Ok(db_int(&lv, &rv, lv.to_int().wrapping_mul(rv.to_int()), |a, b| a.wrapping_mul(b)))
21262126
}
21272127
}
21282128
Expression::Div(l, r) => {
@@ -2148,7 +2148,7 @@ impl Interpreter {
21482148
context: "div".to_string(),
21492149
})
21502150
} else {
2151-
Ok(Value::HInt(HInt::new(lv.to_int() / divisor)))
2151+
Ok(db_int(&lv, &rv, lv.to_int() / divisor, |a, b| if b == 0 { 0 } else { a / b }))
21522152
}
21532153
}
21542154
}
@@ -2167,7 +2167,7 @@ impl Interpreter {
21672167
if divisor == 0 {
21682168
Ok(Value::HInt(HInt::new(0)))
21692169
} else {
2170-
Ok(Value::HInt(HInt::new(lv.to_int() % divisor)))
2170+
Ok(db_int(&lv, &rv, lv.to_int() % divisor, |a, b| if b == 0 { 0 } else { a % b }))
21712171
}
21722172
}
21732173
}
@@ -2181,7 +2181,7 @@ impl Interpreter {
21812181
if e < 0 {
21822182
Ok(Value::HFloat((bv.to_int() as f64).powi(e as i32)))
21832183
} else {
2184-
Ok(Value::HInt(HInt::new(bv.to_int().pow(e as u32))))
2184+
Ok(db_int(&bv, &ev, bv.to_int().pow(e as u32), |a, b| a.wrapping_pow(b.max(0) as u32)))
21852185
}
21862186
}
21872187
}
@@ -2512,6 +2512,8 @@ impl Interpreter {
25122512
| "gen_omc" | "gen_at"
25132513
// HBit dual-band gate (Phase 6) — real two-band resonance/divergence
25142514
| "hbit_harmony" | "hbit_divergence" | "band_divergence" | "band_route"
2515+
// Value-level dual-band (Phase 6 — HBit real at the Value level)
2516+
| "bands" | "value_divergence"
25152517
// Traced variants — return [result, probe_indices_array]
25162518
| "phi_pi_fib_search_traced" | "phi_pi_fib_nearest_traced"
25172519
// Split-channel stats (explicit vs background substrate work)
@@ -11666,34 +11668,64 @@ impl Interpreter {
1166611668
// observation" so subsequent ops carry both bands through
1166711669
// computation. A later harmony() check decides whether
1166811670
// the value is behaving as predicted.
11671+
// phi_shadow(value) — Phase 6: HBit real at the Value level. Attaches the harmonic
11672+
// SHADOW band β = nearest Fibonacci attractor of α. The returned value carries BOTH
11673+
// bands: α (the exact value, unchanged) and β (the "on-lattice" companion). β then
11674+
// rides alongside α through arithmetic (db_int); harmony()/band_divergence() read the
11675+
// accumulated α/β drift. Was an identity stub; now the real dual-band entry point.
1166911676
"phi_shadow" => {
1167011677
if args.is_empty() {
1167111678
return Err("phi_shadow requires (value)".to_string());
1167211679
}
1167311680
let v = self.eval_expr(&args[0])?;
11674-
Ok(v)
11675-
}
11676-
// harmony(x) - HBit harmony reading.
11677-
//
11678-
// Tree-walk semantics: returns 1000 unconditionally. With
11679-
// no β to compare against, harmony is trivially perfect.
11680-
// The value's semantic content fits this — in tree-walk
11681-
// mode, "harmony" can be read as "agreement between α and
11682-
// α" which is always exact.
11683-
//
11684-
// Dual-band JIT semantics (omnimcode-codegen, Session G):
11685-
// intercepted as an intrinsic that emits a call to the
11686-
// extern Rust helper computing harmony from the two lanes.
11687-
//
11688-
// Return convention: i64 in [0, 1000]. 1000 = perfect
11689-
// harmony, 0 = maximally divergent. Floats avoided to
11690-
// keep the calling convention pure-i64.
11681+
let a = v.to_int();
11682+
let (att, _) = crate::phi_pi_fib::nearest_attractor_with_dist(a);
11683+
Ok(Value::HInt(HInt::with_beta(a, att)))
11684+
}
11685+
// harmony(x) -> int 0..1000 — Phase 6: REAL dual-band reading. If x carries a β shadow
11686+
// (from phi_shadow + dual-band arithmetic), returns 1000·harmony(α,β) = how in-tune the
11687+
// computation stayed with the attractor lattice. If single-band (no β), returns 1000
11688+
// (a value is in perfect harmony with itself). Was a constant 1000 stub.
1169111689
"harmony" => {
1169211690
if args.is_empty() {
1169311691
return Err("harmony requires (value)".to_string());
1169411692
}
11695-
let _ = self.eval_expr(&args[0])?;
11696-
Ok(Value::HInt(HInt::new(1000)))
11693+
let v = self.eval_expr(&args[0])?;
11694+
match v.beta_band() {
11695+
Some(b) => {
11696+
let h = crate::value::HBit::harmony(v.to_int(), b);
11697+
Ok(Value::HInt(HInt::new((h * 1000.0).round() as i64)))
11698+
}
11699+
None => Ok(Value::HInt(HInt::new(1000))),
11700+
}
11701+
}
11702+
// bands(x) -> [α, β] — Phase 6: inspect both bands of a value. β = α when single-band.
11703+
"bands" => {
11704+
if args.is_empty() {
11705+
return Err("bands requires (value)".to_string());
11706+
}
11707+
let v = self.eval_expr(&args[0])?;
11708+
let a = v.to_int();
11709+
let b = v.beta_band().unwrap_or(a);
11710+
Ok(Value::Array(HArray::from_vec(vec![
11711+
Value::HInt(HInt::new(a)),
11712+
Value::HInt(HInt::new(b)),
11713+
])))
11714+
}
11715+
// value_divergence(x) -> int 0..1000 — Phase 6: the per-value drift = 1000·(1-harmony).
11716+
// 0 = on the lattice (trust the β skip); high = dissonant (α is the truth). The gate.
11717+
"value_divergence" => {
11718+
if args.is_empty() {
11719+
return Err("value_divergence requires (value)".to_string());
11720+
}
11721+
let v = self.eval_expr(&args[0])?;
11722+
match v.beta_band() {
11723+
Some(b) => {
11724+
let h = crate::value::HBit::harmony(v.to_int(), b);
11725+
Ok(Value::HInt(HInt::new(((1.0 - h) * 1000.0).round() as i64)))
11726+
}
11727+
None => Ok(Value::HInt(HInt::new(0))),
11728+
}
1169711729
}
1169811730
// phi_pi_fib_search_v2(sorted_arr, target) -> int
1169911731
// F(k)/φ^(π·k) split-point search. Same return convention
@@ -15633,6 +15665,23 @@ pub(crate) fn stmts_contain_return(stmts: &[Statement]) -> bool {
1563315665
false
1563415666
}
1563515667

15668+
/// Dual-band integer arithmetic (Phase 6 — HBit real at the Value level). When NEITHER operand
15669+
/// carries a β shadow (the default for all ordinary values), returns exactly `HInt::new(alpha)` —
15670+
/// byte-identical to single-band behavior. When either carries β, the shadow rides alongside:
15671+
/// result β = op(lβ, rβ), with missing bands falling back to the operand's α. α is ALWAYS the exact
15672+
/// answer the caller already computed; β never alters it — it only records harmonic drift.
15673+
#[inline]
15674+
fn db_int(lv: &Value, rv: &Value, alpha: i64, op: impl Fn(i64, i64) -> i64) -> Value {
15675+
match (lv.beta_band(), rv.beta_band()) {
15676+
(None, None) => Value::HInt(HInt::new(alpha)),
15677+
(lb, rb) => {
15678+
let la = lb.unwrap_or_else(|| lv.to_int());
15679+
let ra = rb.unwrap_or_else(|| rv.to_int());
15680+
Value::HInt(HInt::with_beta(alpha, op(la, ra)))
15681+
}
15682+
}
15683+
}
15684+
1563615685
/// Builtins whose evaluation has a side effect or is nondeterministic. `@memo`
1563715686
/// refuses a function that directly calls any of these (best-effort purity gate).
1563815687
const MEMO_IMPURE: &[&str] = &[
@@ -15979,6 +16028,7 @@ pub(crate) const HEAL_BUILTIN_NAMES: &[&str] = &[
1597916028
"gen_omc", "gen_at",
1598016029
// HBit dual-band gate (Phase 6)
1598116030
"hbit_harmony", "hbit_divergence", "band_divergence", "band_route",
16031+
"bands", "value_divergence",
1598216032
"phi_pi_fib_search_traced", "phi_pi_fib_nearest_traced",
1598316033
"phi_pi_fib_stats_bg", "phi_pi_fib_stats_all",
1598416034
// HBit dual-band intrinsics (Sessions F+G)

omnimcode-core/src/value.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ pub struct HInt {
1414
pub resonance: f64,
1515
pub him_score: f64,
1616
pub is_singularity: bool,
17+
/// β band (Phase 6): the harmonic SHADOW of this value — the "what if we'd stayed on the
18+
/// Fibonacci attractor lattice" companion. `None` (the default for all ordinary values)
19+
/// means single-band: behaves EXACTLY as before. `Some(β)` is attached by `phi_shadow` and
20+
/// rides alongside α through arithmetic; `harmony`/`band_divergence` read the α/β drift.
21+
/// α (the `value` field) is ALWAYS the exact answer — β never changes a result.
22+
pub beta: Option<i64>,
1723
}
1824

1925
impl HInt {
@@ -26,9 +32,18 @@ impl HInt {
2632
resonance,
2733
him_score,
2834
is_singularity: false,
35+
beta: None,
2936
}
3037
}
3138

39+
/// Construct a dual-band HInt: exact α `value` + harmonic shadow `beta` (Phase 6).
40+
#[inline]
41+
pub fn with_beta(value: i64, beta: i64) -> Self {
42+
let mut h = Self::new(value);
43+
h.beta = Some(beta);
44+
h
45+
}
46+
3247
/// Compute resonance (0-1) based on distance to nearest Fibonacci number.
3348
///
3449
/// Substrate-routed: goes through `phi_pi_fib::nearest_attractor_with_dist`,
@@ -66,6 +81,7 @@ impl HInt {
6681
resonance: 0.0,
6782
him_score: 0.0,
6883
is_singularity: true,
84+
beta: None,
6985
}
7086
}
7187
}
@@ -344,6 +360,16 @@ impl Value {
344360
h
345361
}
346362

363+
/// The β (harmonic-shadow) band of this value, if it carries one (Phase 6). Only dual-band
364+
/// HInts (created via phi_shadow / dual-band arithmetic) return Some; everything else is None.
365+
#[inline]
366+
pub fn beta_band(&self) -> Option<i64> {
367+
match self {
368+
Value::HInt(h) => h.beta,
369+
_ => None,
370+
}
371+
}
372+
347373
#[inline]
348374
pub fn to_int(&self) -> i64 {
349375
match self {

0 commit comments

Comments
 (0)