Skip to content

[R14 integration] Full Python port stack + live R cache + source-faithful fixes (DRAFT) - #192

Draft
OVVO-Financial wants to merge 52 commits into
integration/r14-parity-on-python-stack-20261106from
automation/r14-stack-cache-20261106
Draft

OVVO-Financial wants to merge 52 commits into
integration/r14-parity-on-python-stack-20261106from
automation/r14-stack-cache-20261106

Conversation

@OVVO-Financial

@OVVO-Financial OVVO-Financial commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Integration gate — preserving all 41 prior function PRs

Draft / BLOCKED — do not merge. This PR is built on #191, which is built on the complete 41-PR implementation head #189. The full function work is inherited; it has not been abandoned, duplicated, or rewritten. The initial cache-only PR #190 targets main and must not be landed separately.

Verified pre-fix baseline: R14 live cache 2,745 entries in 78 shards; offline parity 88 failed / 2,021 passed; native invariants 14 failed / 694 passed. The newest regression and ARMA changes are pending fresh CI; do not extrapolate those counts.

Active fixes: categorical exact-cell NNS.reg, R14 NNS.ARMA.optim return/bias semantics, corresponding invariant coverage, heterogeneous R codec. Original owners: regression/labels #154/#155; stack/boost #154/#161/#168/#176; ARMA/VAR #150/#159/#166/#174/#182. Full source-to-PR ledger and no-regression landing plan: R14 parity integration gate.


Automatic parity-cache refresh from the R source of truth.
For the one-shot stack audit, this PR targets draft #191 (all port PRs
through #189). Do NOT merge until deterministic parity is verified.

  • R repository: OVVO-Financial/NNS
  • R commit: 7b07a837c130ba7220dbe16c584221508757d5ae
  • NNS version: 14.0
  • Source package: NNS_14.0.tar.gz
  • Windows binary verified: NNS_14.0.zip
  • Live regeneration result: failure
  • Cache-only verification result: failure

The exact R source package was installed and the committed parity cache was regenerated. sync/nns_source.json records this R commit as the behavioral-truth provenance. Any remaining Python/R parity mismatches are retained in the workflow diagnostics and should be repaired against this R-authored baseline.

Cache changes by function

function before after added removed changed
Co.LPM 181 181 120 120 0
Co.UPM 180 180 120 120 0
D.LPM 180 180 120 120 0
D.UPM 180 180 120 120 0
LPM.VaR 18 24 6 0 0
LPM 90 98 8 0 1
LPM.ratio 80 93 13 0 0
NNS.ANOVA.custom 15 50 36 1 0
NNS.ARMA 13 44 31 0 0
NNS.ARMA.optim.custom 2 10 8 0 0
NNS.ARMA.pred_int 2 4 2 0 0
NNS.CDF.custom 24 35 11 0 0
NNS.FSD 12 29 17 0 0
NNS.FSD.uni 4 48 44 0 0
NNS.MC.grid 6 6 0 0 1
NNS.SD.cluster.dendrogram 2 2 1 1 0
NNS.SD.cluster 7 10 3 0 0
NNS.SD.efficient.set 19 43 24 0 0
NNS.SSD 16 27 11 0 0
NNS.TSD 16 35 19 0 0
NNS.VAR.custom 9 9 0 0 5
NNS.boost.numeric 30 32 2 0 5
NNS.caus 18 21 3 0 0
NNS.copula 10 37 27 0 0
NNS.dep 32 52 20 0 0
NNS.diff.custom 5 13 8 0 0
NNS.gravity 6 7 1 0 0
NNS.meboot.diagnostics 4 5 1 0 0
NNS.meboot.stat_summary 1 3 2 0 0
NNS.moments 5 16 11 0 0
NNS.norm 8 10 2 0 0
NNS.part 73 79 6 0 0
NNS.reg.factor_dimred 3 3 0 0 1
NNS.reg 277 284 7 0 9
NNS.seas 11 24 13 0 0
NNS.stack.numeric 33 39 7 1 4
NNS_mreg_predict_path_v2_cpp 3 3 0 0 3
NNS_mreg_predict_v2_cpp 6 6 0 0 4
UPM.VaR 18 24 6 0 0
UPM 89 97 8 0 1
UPM.ratio 13 13 0 0 1
dy.d.scalar 7 11 4 0 0
dy.dx.numeric 2 7 5 0 2
labels.boost.names 1 1 0 0 1
labels.mreg.factor_y 1 1 0 0 1
labels.mreg.raw_factor 1 1 0 0 1
labels.reg.factor_design 1 1 0 0 1
labels.reg.factor_x 2 1 0 1 1
labels.reg.factor_y 1 1 0 0 1
labels.reg.logical_frame 2 1 0 1 1
labels.reg.logical_uni 1 0 0 1 0
labels.reg.numeric_strings 1 1 0 0 1
labels.reg.point_names 1 0 0 1 0
labels.reg.raw_names 1 1 0 0 1
labels.stack.factor_x 1 1 0 0 1
labels.stack.factor_y 1 1 0 0 1
labels.stack.names 1 1 0 0 1
labels.stack.nbest_all 1 1 0 0 1

@OVVO-Financial
OVVO-Financial marked this pull request as draft November 6, 2026 17:29

Copy link
Copy Markdown
Owner Author

R 14.0 failure analysis and corrective commits (2026-11-06)

The cache generator completed 2,713 R 14.0 reference entries across 78 function shards from the exact upstream NNS source commit 7b07a837c130ba7220dbe16c584221508757d5ae. The first full-stack offline CI after cache regeneration reported 581 failures / 1,528 passes / 12 skips on Python 3.11. This is no longer the 1,934 missing-cache-key artifact from draft #191: many are genuine R/Python numerical or return-structure mismatches.

Highest-volume failure categories

  • test_regression.py: 182
  • test_part.py: 53
  • test_stack.py: 49
  • test_dependence.py: 46
  • test_arma.py: 36
  • test_boost.py: 27
  • test_causation.py: 24
  • test_diff.py: 22
  • test_multivariate_regression.py: 21
  • test_seasonality.py: 20

The current R 14.0 NNS.gravity uses type-7 quartiles and observation-centered modal bins, whereas this Python branch originally used the legacy NNS-core 13.3 quartiles and histogram left edges. R 14.0 NNS.mode also handles discrete-valued runs, endpoint peaks and tied modes differently. These were confirmed directly against R's src/central_tendencies.cpp. The Python gravity/mode paths and partition fallback have been updated on this draft audit branch to follow current R behavior, without changing the vendored core. These are provisional integration changes; their full numerical effects remain subject to CI.

Native dependency remains open: NNS-core PR #40 already contains much of the corrected type-7 gravity / observed-center mode implementation but is not merged as an accepted core snapshot. Its companion NNS.dep multi-level changes (core #38) also require a compatible Python binding. Old tests asserting native-vs-Python bit identity against an obsolete core correctly identify a native sync gap, but they must not be skipped to manufacture green.

CI and merge safety

  1. GitHub workflow-baseline enforcement had overwritten this PR's modern Python CI, causing a ModuleNotFoundError: pandas in every Python job. The workflow was restored from the previously green cumulative port branch, with explicit workflow-change-approved authorization.
  2. The updated audit CI records invariants and parity into separate per-version JUnit artifacts, runs both even when one fails, and has a final mandatory failure gate if either fails. Continuing diagnostic collection must never turn a red check green.
  3. PR [R14 integration] Full Python port stack + live R cache + source-faithful fixes (DRAFT) #192 is now draft. Do not merge [R14 integration] Full Python port stack + live R cache + source-faithful fixes (DRAFT) #192, [Audit] Measure full Python port stack against rebuilt R 14.0 parity cache #191 or Regenerate R parity cache for NNS 14.0 #190 until R 14.0 parity and all native/fallback invariants pass. Regenerating cache outputs is not a substitute for fixing Python behavior.

Run: https://github.com/OVVO-Financial/NNS-python/actions/runs/42262104902

Next repairs in source-truth order

(1) Land/validate the R14-compatible NNS-core native port, then re-vendor an accepted snapshot; (2) align NNS.dep multi-level correlation/dependence with core #38 and R14; (3) reconcile partition/gravity-driven regressions; (4) re-run stack/boost/VAR/causation and residual deterministic shards; (5) only then treat stochastic differences and performance. Keep every discrepancy visible, not xfailed or tolerance-widened without a source-backed rationale.

@OVVO-Financial OVVO-Financial changed the title Regenerate R parity cache for NNS 14.0 [R14 parity audit] Rebuilt reference cache, native-boundary fixes and diagnostic CI Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Verified delta: R14 primitive corrections (source-authored, not tolerance changes)

The first full diagnostic matrix run after updating Python gravity/mode/partition paths is 42262104902. Python 3.11 offline R 14.0 parity improved from 581 failures / 1,528 passes to 430 failures / 1,679 passes: 151 fewer mismatches. Coverage is unchanged (12 skips). Changes by source group include regression failures 182 → 114, partition 53 → 14, and multivariate regression 21 → 3. The independent dependence (46), causation (24), and seasonality (20) mismatches remain unchanged, consistent with their substantive R14 algorithm changes.

The same run had 18 invariant failures, many of them tests asserting identity against the outdated C++ NNS-core snapshot rather than against R14; two explicit invariants expecting old R13 mode tie behavior were corrected to assert R14 source semantics in subsequent commits. Native-boundary parity still needs acceptance/port of the newer NNS-core stack (#38–#40), not skipped tests. The invariant/parity diagnostic steps are continue-on-error only to collect both test reports; the mandatory final Enforce R14 invariant and parity gates step fails the overall job on either failure.

Latest head is still a draft integration branch, and merges remain blocked. The next CI run after the two invariant assertion updates is 42262634551.

Copy link
Copy Markdown
Owner Author

R14 source-fidelity repair update (November 6, 2026)

Verified code progress

  • Previous baseline: 581 R14 parity failures, 1,528 passing (3.11).
  • Before this repair pass: 129 failures / 1,980 passing.
  • After the ANOVA population correction and initial nominal-probability stack path: 124 failures / 1,985 passing, 14 invariant failures, on run 42301259329.
  • After faithful R14 dy.d_ polynomial local stencil, local-dependence windows, observed/Weyl contexts, and class-specific nested equation comparison: 106 failures / 2,003 passing, 12 skipped (Python 3.11) on run 42302249292. The invariant count temporarily increased to 16 because two tests explicitly encoded a now-removed R13 behavior: silent mixed-partial fallback on three predictors, and an outdated error string. Those tests have since been updated to R14's explicit rejection contract.

Source-truth details

  1. R/Binary_ANOVA.R: certainty for two identical constant groups of size 100 is ((200-2)/200)^2 = 0.9801; for size 20, ((40-2)/40)^2=0.9025.
  2. R/Classification_Stack.R: class probability vectors are fitted per class; OOF class-probability models select k/dimension counts and probabilities blend with squared objective weights. A separate _stack_class_r14.py source-level port replaces the older ordinal-code regression for the class branch. R14 per-class equations are preserved and compared by class name, variable names and coefficients.
  3. R/dy_d_wrt.R: local finite-difference weights use a scaled Vandermonde system and LPM.VaR degree-1 probability windows capped at 0.25, including endpoint one-sided stencils; finest-cell .nns_dep_local determines widening. A single NNS.reg predicts all requested query coordinates. Ported in src/nns/diff.py; 14 previously failing parity cases turned green (18 net parity improvements).
  4. Strict invariants/parity gates remain in CI, and R14 cached oracle outputs are untouched. No skips, tolerance increases, or fabricated fixtures.

Still blocking

3.11 remaining parity failures by module at run 42302249292: regression 24, stack 22, boost 13, labels 11, arma 11, var 11, diff 4, stochastic_dominance 3, r13_smoke 2, seasonality 2, multivariate_regression 1, noise_mean 1, original_partition 1. The older R13 smoke test expectations need an explicit version-conscious split, not hidden failures. Native core R14 synchronization remains pending (mode/dep, CLASS M.reg expected structure).

PR #192 stays draft and unmerged. Do not merge or claim parity complete until the mandatory gate is genuinely green.

Copy link
Copy Markdown
Owner Author

R 14.0 parity-cache rebuild follow-up (2026-11-06)

  • Fixed tests/_r.py to preserve heterogeneous R lists such as [[1, 2], 2] and re-encode nested numpy arrays before writing JSON (commit 284535553586f0c821c4cdb0ad55e681c6a22b8d). Earlier live-R regeneration lost valid results through ValueError: setting an array element with a sequence in _decode.
  • Added tests/invariants/test_r_cache_codec.py to cover jagged lists, structured R lists, numeric matrices, numeric specials, and shard/version provenance.
  • Rewired the existing R14 regeneration workflow to use the exact pinned OVVO-Financial/NNS@7b07a837c130ba7220dbe16c584221508757d5ae, install mlbench and matplotlib, and commit regenerated fixture changes directly to this audit branch with a fast-forward-only push. It will not reset [R14 integration] Full Python port stack + live R cache + source-faithful fixes (DRAFT) #192 from [Audit] Measure full Python port stack against rebuilt R 14.0 parity cache #191 or open a competing PR.

Audit runs:

Prior baseline (NOT green): 2,713 cache entries/78 shards; 585 live parity failures, 14 invariant failures, 106 cache-only parity failures (30 missing R reference keys), and 115 failures in combined fallback tests. Do not merge until the rebuilt cache and source-faithful test gates pass. Missing R entries, R-side exceptions, numeric discrepancies, and Python regressions must remain distinct; do not invent oracle values or relax tolerances to make CI green.

Copy link
Copy Markdown
Owner Author

R14 integration control point (not merge-ready). All 41 earlier Python port PRs form one linear ancestry chain, represented in #189. #191 is the R14 cache-only audit atop that head; this PR #192 is the single cumulative implementation-fix head. Please see docs/R14_PARITY_INTEGRATION_GATE.md for exact counts, source provenance, function/PR ownership, and strict landing policy.

Current source corrections: R14 exact-cell regression for fully categorical designs (src/nns/_reg_engine.py), R14 NNS.ARMA.optim raw/validation forecast output and split-only bias correction (src/nns/arma.py), R14-class-vs-REG invariant test separation, and codec fixes. These are not substitutes for #154/#155/#159/#161/#166/#174/#176: those implementations remain fully inherited. Do not merge until latest CI proves strict R14 parity, including native and fallback backends; preserve the source-authored cache.

@OVVO-Financial OVVO-Financial changed the title [R14 parity audit] Rebuilt reference cache, native-boundary fixes and diagnostic CI [R14 integration] Full Python port stack + live R cache + source-faithful fixes (DRAFT) Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant