Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/docs/estimation/reviews/est01_hostile_review.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / docs / estimation / reviews / est01_hostile_review.md` 76 lines ยท 8164 bytes Raw Blame History Rendered 1 # EST-0/EST-1 hostile review (omega-est, `7dbf33e`) 2 Scratch programs: /a1.c a2.c a3.c a4.c, mutants in tmp/mut/. Nothing in the repo was edited. 3 Build for all: gcc -std=c11 -O2 -Isrc -Isrc/estimation -ffp-contract=off src/estimation/*.c src/sha256.c -lm 4 5 ## Counts: BLOCKER 0, MAJOR 3, MINOR 6, NIT 2 6 7 ## MAJOR 8 9 ### M1. est_kf_update trusts the prediction's contents: a forged prediction with a valid prior digest is accepted 10 File: src/estimation/est_kf.c:167-181 (bind_checks), 190-235 (update). est_check_prediction (est_types.c:167) checks only finiteness/PSD. 11 Nothing verifies the prediction was computed from prior+model: x, P, t_ns, horizon, y_mean, S are free. 12 Evidence (a1.c): forged pred x=42, P=1e-30, t_ns=-77 (before prior t=5000), y_mean=-1e9, S=7, horizon=999: 13 "forged pred update: 0 x=42 P=1e-30 t=-77" (0 = EST_OK; posterior time goes backwards) 14 Also a4.c: horizon=7 with t advanced by 1 step -> update returns 0. 15 Impact: the prior digest / generation "staleness" checks only bind identity, not derivation; an attacker or buggy caller can inject an overconfident state that still carries a valid parent chain and evidence root. 16 Fix: in update/coast, recompute the prediction (est_kf_predict with pred->horizon, same Bu) and require a bit-exact digest match; at minimum check pred->t_ns == prior->t_ns + horizon*step_ns, pred->horizon>=1, and y_mean/S consistency. Add tests for each tampered field. 17 18 ### M2. Known input Bu is not recorded anywhere, so predictions with control input cannot be replayed or verified 19 File: est_kf.c:117-130; est_types.h est_prediction has no Bu field. 20 Evidence (a4.c): predict with Bu=5 gives x=5, digest differs from Bu=0, but prior/model/horizon fields are identical: "any field records Bu? ... equal: 1". 21 Impact: ADR 0020 section 7 (replayable evidence) and M1's fix are impossible for any prediction with input. The prediction digest also cannot be re-derived from its declared inputs. 22 Fix: add Bu (n doubles + a has_input flag) to est_prediction and its encoding, or refuse Bu in EST-1. 23 24 ### M3. A prediction can be passed off as an observation (ADR 2.1 "prediction != observation") 25 File: est_types.c:158-166 (est_check_observation only requires non-zero evidence digest); est_kf.c:190. 26 Evidence (a1.c): observation built with z=p.y_mean, R=p.S, evidence = prediction digest, source = zero: 27 "prediction-as-observation update: 0 nis=0 P=50.2493 (P prior 100.001)" (covariance halved from nothing; double counting) 28 Also observation source zero is accepted ("obs zero source check: 0"), so the observation names no producer. 29 Impact: the layer's core anti-conflation rule holds only by C type, not by data. A serialized/decoded observation whose evidence is a model-derived digest is indistinguishable from real evidence. 30 Fix: require non-zero source; add an evidence-kind/domain (e.g. evidence must be an est_digest over a raw-evidence domain that est_* digests can never produce) and in update refuse obs->evidence equal to pdig, digest(prior), prior->evidence_root, or any digest the estimator produced in this call. State the limit (stateless module cannot know all). 31 32 ## MINOR 33 34 ### m1. Covariance PSD/negative-variance tolerance is relative to the LARGEST diagonal, so tiny variances can be negative 35 File: est_types.c:76-88 (tol = 1e-12*maxd). 36 Evidence (a1.c): diag(1e12,-0.5) -> est_check_covariance returns 0 (accepted). diag(1e12,-100) rejected (-5). 37 Also [[1e6,.5],[.5,0]] (det<0, indefinite) accepted; [[0,1e-170],[1e-170,0]] indefinite accepted (c*c underflows to 0, est_types.c:83-84). 38 Filter-produced covariances did survive: collapse (2e5 steps, Q=0,R=1e-12), scale disparity diag(1e12,1e-6), 1e200 and 1e-200 scales all kept min diag >0 (a2.c). So this is a validator hole, not shown filter breakage. 39 Fix: reject any negative diagonal entry outright (diag < 0), compare c^2 to d*e without underflow (use fabs(c) > sqrt-safe or scaled compare), or scale to unit diagonal before LDL. 40 41 ### m2. Belief/prediction structural invariants are not enforced by est_check_belief 42 File: est_types.c:150-157. A belief with generation=99, zero parent, zero evidence_root passes (a3.c "forged gen99 ...: 0"), though the header says root is zero only for a declared prior. Fix: require (generation==0) iff parent zero; nonzero model digest. 43 44 ### m3. Model with R=0 is accepted and can permanently wedge update 45 File: est_check_model; a2.c "R0-P1e-300 step 1 update err -6" (NOT_PD every later update; coast still works). Refusal is loud, not silent. Fix: reject R with zero diagonal in the model, or document. 46 47 ### m4. Unbounded predict horizon (uint32) is a CPU denial of service 48 est_kf.c:120. a2.c: horizon 1e8 took 0.84s; 4.29e9 is ~35s. Fix: cap horizon (e.g. 1<<20) or use matrix powers. 49 50 ### m5. Asymmetry is accepted (1e-9 relative) and stored/digested as given 51 Evidence (a1.c): [[1e12,1e3],[0,1]] accepted (asym 1e3 absolute on the small entry scale). Digests then depend on the asymmetry. Fix: canonicalize (symmetrize) in est_kf_prior, or tolerance relative to sqrt(Aii*Ajj). 52 53 ### m6. Test gaps found by mutation (tmp/mut/, each mutant compiled with the real tests) 54 - Prediction digest domain set equal to the belief domain: test_est_types PASSES (0 failed). Domain separation is untested; only the kind byte separates them. 55 - est_kf_coast resetting evidence_root to zero (est_kf.c:~331): test_est_kf PASSES. The coast test compares against a prior whose root is already zero (test_est_kf.c:239,356). Evidence laundering by coast is undetected. 56 - Removing the pred->model != prior->model check (est_kf.c:~177): PASSES; never exercised (implementation is right, a4.c returns -9). 57 - Removing symmetrize(S) in predict: PASSES. 58 - test_est_kf.c:506 `b.P[0] < 1e-6 || b.P[0] < 1.0` is just `< 1.0`. 59 - No test tampers pred.t_ns, horizon, x, P, y_mean (see M1). 60 61 ## NIT 62 - n1. mk/estimation.mk:18 EST_FORBIDDEN denylist misses malloc, getenv, time/clock_gettime, rand, read/write/printf, openat. An allowlist (memcpy, memset, sha256_*, est_*, sqrt, __*chk, stack protector) is stronger. Currently nm -u is clean (est-purity PASS). 63 - n2. est_types.c w_f64/r_f64 memcpy double<->u64 assumes IEEE-754 and matching int/float endianness (true on this target); add a static check or comment. -0.0 canonicalization means decode(encode(x)) is not bit-exact for -0.0 (documented). 64 65 ## Tried and HELD UP 66 - Joseph form is used (est_kf.c:250-260); replacing it with (I-KH)P' makes 3 tests fail. Posterior symmetrized; dropping it fails tests. 67 - NaN/Inf anywhere refused (belief, obs, Bu, model); NaN payload in digest refused (-3). 68 - Covariance collapse: 2e5 steps Q=0 R=1e-12, 1e5 steps with 1e12/1e-6 scale disparity and 1e200/1e-200 scales: no invalid P, no error. 69 - Near-singular S (P=1e-300,R=0): loud NOT_PD, outputs untouched on refusal. 70 - Bounds: n,m in {8x8, 8x1, 1x8, 3x5, 1x1} full prior/predict/update/coast/encode/decode under ASan+UBSan (my own program) with 0xAB-filled model padding: no OOB, no UB. n=0, m=0, n=9 refused (-2). Model encoding max 2144 bytes < 2304. 71 - Decode: belief bytes decoded as prediction/observation/model/innovation all -10 (KIND); trailing byte -> -11; all 0..len-1 truncations refused; failed decode leaves output untouched; 1279/1440 single-bit flips are valid different records (expected) and header/kind/version flips refused. Trailing-bytes mutant fails 200 tests. 72 - Determinism: encoders write field by field (no struct memcpy, no padding bytes in digests); garbage beyond n/m does not change digests; -0.0 and +0.0 digest equal; no globals or static state (only const zero byte). 73 - Staleness: swapped prior belief, old prediction vs newer belief, wrong generation with matching digest, wrong model, wrong obs time, units, dims all refused with the right code; the generation and prior-digest mutants are caught. 74 - Digest domains: distinct strings + 0x00 + distinct kind bytes; root domain "omega.est.belief.v1-root" cannot collide with belief domain. 75 - Aliasing: outputs built in locals and copied only on success. 76 - ADR 2.3: no authority, World, file, process or memory-mapping references (nm -u shows only memcpy/memset/strlen/sha256_*/est_*/stack-protector).