Warrior_EA/Expert/Persistence/IPersistenceView.mqh
AnimateDread d9092a2408 fix(vote): persist the member's skill verdict - a converged model was ruled no-skill on every restart
SP500 resumed converged at era 136 with its tier ladder correctly restored and still
swept 4999 bars reporting "0 had a snapshot, drew 0 arrow(s)" while the other five
charts drew 221-312.

HasDemonstratedEdge() - added with the no-skill exclusion - compares m_eraStatPrecPct
against m_eraStatChancePct. Both are written once per era by EnsembleStashEraStats. A
converged model runs no eras, so after a restart both sat at their -1 ctor defaults,
every member was ruled no-skill, ReconstructionWeight() returned 0 for all four, and
the overlay divisor was zero on every bar. Exactly the failure the WST7 ladder
persistence fixed one level down: the ladder says how much a member votes, this says
whether it may.

RankTiersFromOos already computes the pair (pooled holdout precision and the
zero-skill reference rate) and now records it as the CERTIFIED edge. That path is
reached by the era end AND by the deployed replay, which is the only measurement a
converged model will ever make. Persisted as WST8; HasDemonstratedEdge() prefers the
era pair and falls back to it.

The census line also had to be fixed: it reported "NOT ONE of those bars had a single
member snapshot ... no enrolled member has published m_overlaySigSnap" for a condition
that was purely a skill verdict. The snapshots were there. It now counts the two causes
separately and names the one that fired.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-26 16:53:16 -04:00

99 lines
5.8 KiB
MQL5

//+------------------------------------------------------------------+
//| Warrior_EA |
//| AnimateDread |
//| |
//| The read/write surface CModelPersistence needs from the signal. |
//| Same shape as Chart\IChartView.mqh - abstract, pure `= 0`, no |
//| signal include. This view is READ+WRITE (unlike CChartView, |
//| which is read-only) because Persistence's whole job is loading |
//| saved state BACK into the signal. |
//+------------------------------------------------------------------+
class CPersistenceView
{
public:
virtual ~CPersistenceView(void) { }
//--- IDENTITY (reused via the signal's existing Data*()/Chart*() getters)
virtual string Id(void) = 0;
virtual string FileName(void) = 0;
virtual int NeuronsCount(void) = 0;
virtual long CumIsCorrect(void) = 0;
virtual long CumIsTotal(void) = 0;
virtual long CumOosCorrect(void) = 0;
virtual long CumOosTotal(void) = 0;
//--- EnforceTopologyContract()
virtual bool NetLoaded(void) = 0;
virtual bool UsesConvStage(void) = 0;
virtual uint NetFirstConvWindow(void) = 0;
virtual int ConvReceptiveFieldBars(void) = 0;
virtual ENUM_ACTIVATION OutputLayerActivation(void) = 0;
virtual bool NetEnforceOutputActivation(const ENUM_ACTIVATION intended, ENUM_ACTIVATION &stale) = 0;
virtual void SetTopologySuperseded(const bool v) = 0;
//--- SaveModelStats()/LoadModelStats() - one scalar getter+setter per on-disk field, in WST6 order
virtual double PriorBuy(void) = 0;
virtual void SetPriorBuy(const double v) = 0;
virtual double PriorSell(void) = 0;
virtual void SetPriorSell(const double v) = 0;
virtual double PriorNeutral(void) = 0;
virtual void SetPriorNeutral(const double v) = 0;
virtual double ConfidenceCalScale(void) = 0;
virtual void SetConfidenceCalScale(const double v) = 0;
virtual bool MqlInferenceValidated(void) = 0;
virtual void SetMqlInferenceValidated(const bool v) = 0;
virtual datetime OnlineLearnedUpToTime(void) = 0;
virtual void SetOnlineLearnedUpToTime(const datetime v) = 0;
virtual double OnlineRollingAcc(void) = 0;
virtual void SetOnlineRollingAcc(const double v) = 0;
virtual long OnlineSamples(void) = 0;
virtual void SetOnlineSamples(const long v) = 0;
virtual int LastBuyFiredPrecPct(void) = 0;
virtual void SetLastBuyFiredPrecPct(const int v) = 0;
virtual int LastSellFiredPrecPct(void) = 0;
virtual void SetLastSellFiredPrecPct(const int v) = 0;
virtual int LastBuyRecallPct(void) = 0;
virtual void SetLastBuyRecallPct(const int v) = 0;
virtual int LastSellRecallPct(void) = 0;
virtual void SetLastSellRecallPct(const int v) = 0;
virtual int LastBuyFired(void) = 0;
virtual void SetLastBuyFired(const int v) = 0;
virtual int LastSellFired(void) = 0;
virtual void SetLastSellFired(const int v) = 0;
virtual void SetCumIsCorrect(const long v) = 0;
virtual void SetCumIsTotal(const long v) = 0;
virtual void SetCumOosCorrect(const long v) = 0;
virtual void SetCumOosTotal(const long v) = 0;
//--- THE TIER LADDER (WST7). The four confidence-tier win rates, the module trust weight, and the
//--- flag saying they were measured rather than assumed. Produced ONLY by a completed pass 3, so
//--- without persistence a converged model loses its entire vote on restart - see
//--- CExpertSignalAIBase::LiveVoteContribution for why an unranked member returns 0.
virtual int TierWeight(const int tier) = 0;
virtual void SetTierWeight(const int tier, const int v) = 0;
virtual double ModuleTrustWeight(void) = 0;
virtual void SetModuleTrustWeight(const double v) = 0;
virtual bool TiersSelfRanked(void) = 0;
virtual void SetTiersSelfRanked(const bool v) = 0;
//--- THE MEMBER'S CERTIFIED PRECISION AND ITS CHANCE RATE (WST8). Exactly the same failure mode as
//--- the ladder above, one level up: HasDemonstratedEdge() compares these two, VoteCapableWeight()
//--- and ReconstructionWeight() return 0 when it says no, and both numbers were era-only state.
//--- A converged model runs no eras, so on restart they stayed at their -1 ctor defaults, every
//--- member reported no skill, and the overlay divisor was zero on every bar.
virtual double CertifiedPrecPct(void) = 0;
virtual double CertifiedChancePct(void) = 0;
virtual void SetCertifiedEdge(const double precPct, const double chancePct) = 0;
//--- ValidateCpuInference() - the whole Net-pointer/throwaway-clone core, consolidated (see
//--- ChartScoreBarForRescan for the same "irreducible pointer work, not signal state" precedent)
virtual bool RunCpuInferenceSelfCheck(double &maxDiff) = 0;
//--- SaveTopologyConfiguration()/LoadAndCompareTopologyConfiguration() - fields beyond the params
//--- every caller already passes
virtual void SetDirConfThreshold(const double v) = 0;
virtual double BestDirConfThreshold(void) = 0;
virtual void SetBestDirConfThreshold(const double v) = 0;
virtual string CrossAssetPairsPinned(void) = 0;
virtual void SetCrossAssetPairsPinned(const string v) = 0;
virtual void SetCrossAssetCfgSaved(const bool v) = 0;
virtual string AltDataNamesPinned(void) = 0;
virtual void SetAltDataNamesPinned(const string v) = 0;
virtual void ApplyAltDataPinnedNames(const string v) = 0;
//--- LoadNetWithRetry()
virtual bool LoadNetOnce(double &indicatorParams[]) = 0;
};
//+------------------------------------------------------------------+