Infrastructure (Source)
The white-box proof itself — not a description of the system, the actual code. Three files: how documents track their own provenance, how kernels declare what they need before running, and the single source of truth for the four-channel formulas everything else calls.
document_metadata_box.py
Generates the metadata box every page on this site carries. Deliberately reuses the same confidence vocabulary as kernel_registry.py below rather than inventing a separate scale — consistency across the whole system is the actual point.
"""
document_metadata_box.py
Generates the metadata box for site documents, per the multi-level
transparency spec: Status, Supersedes, Built from, Superseded by,
Evidence. Deliberately reuses the SAME confidence vocabulary already
established in kernel_registry.py and CURRENT_UNDERSTANDING.md
(High / Low-Moderate / Untested, plus Verified / Active Development /
Exploratory for document status) rather than inventing a fourth scale --
consistency across the whole system is the actual point of doing this.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List, Optional
VALID_STATUS = {"Verified", "Active Development", "Exploratory", "Retired"}
@dataclass
class DocumentMetadata:
title: str
status: str
supersedes: Optional[str] = None
built_from: List[str] = field(default_factory=list)
superseded_by: Optional[str] = None
evidence: List[str] = field(default_factory=list)
def __post_init__(self):
if self.status not in VALID_STATUS:
raise ValueError("status must be one of %s, got '%s'" % (VALID_STATUS, self.status))
def render(self) -> str:
lines = ["**Status:** %s" % self.status]
if self.supersedes:
lines.append("**Supersedes:** %s" % self.supersedes)
if self.built_from:
lines.append("**Built from:**")
lines.extend("- %s" % item for item in self.built_from)
if self.superseded_by:
lines.append("**Superseded by:** %s" % self.superseded_by)
if self.evidence:
lines.append("**Evidence:**")
lines.extend("- %s" % item for item in self.evidence)
return "\n".join(lines)
if __name__ == "__main__":
example = DocumentMetadata(
title="Fix 5: Estimator Redesign",
status="Active Development",
built_from=["ESTIMATOR_CORRELATION_FINDING.md", "COMPONENT_A_TILT_SPECTRUM_FIXED.py"],
evidence=["200-trial correlation re-measurement (15 to 1 near-duplicate pairs)",
"Real-outcome correlation test (r=0.09 old vs r=-0.05 new, n=30, NOT statistically significant)"],
superseded_by=None,
)
print(example.render())
print()
print("=== Real validation check: rejects an invalid status ===")
try:
DocumentMetadata(title="bad", status="Definitely True")
except ValueError as e:
print("Correctly rejected:", e)
kernel_registry.py
Every kernel declares its actual lifecycle requirements as metadata, not just buried in code comments — so an orchestrator (or a human) can check compatibility before running something, instead of finding out via a crash. That crash already happened once — see the pipeline_front_gate fit() bug in Fix 9 of the Component A changelog — this registry exists specifically to catch that class of error before it happens again. Now includes the Reasoning Chain kernels alongside the original six, plus three real psychology-framework kernels (HiTOP, FFM/PID-5, PPM) — each a structural implementation of a published, peer-reviewed clinical framework (Kotov et al. 2017; DSM-5 Section III; de la Iglesia & Castro Solano 2018), not an original clinical claim.
"""
kernel_registry.py
Real implementation of the registry ChatGPT proposed and my own audit
independently pointed at. Every kernel declares its actual lifecycle
requirements as metadata, not just buried in code comments -- so an
orchestrator (or a human) can check compatibility BEFORE running
something, instead of finding out via a crash (the exact way the
pipeline_front_gate fit() bug was found).
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional, List, Callable
@dataclass(frozen=True)
class KernelSpec:
name: str
purpose: str
input_requirements: str
output_description: str
requires_fit: bool
requires_history: bool
requires_other_kernel_first: Optional[str]
cannot_combine_with: List[str]
validation_method: str
confidence_level: str # High / Low-Moderate / Untested -- matches CURRENT_UNDERSTANDING.md's own scale
callable_ref: Optional[Callable] = None
class KernelRegistry:
def __init__(self):
self._kernels = {}
def register(self, spec: KernelSpec) -> None:
self._kernels[spec.name] = spec
def get(self, name: str) -> KernelSpec:
if name not in self._kernels:
raise KeyError("'%s' is not a registered kernel. Registered: %s" % (name, list(self._kernels.keys())))
return self._kernels[name]
def check_can_run(self, name, has_fit_been_called=False, history_available=False, prior_kernels_run=None):
"""Real, checkable pre-flight validation -- exactly the check that
would have caught the fit() bug before it happened, instead of
after a broken 0.0 showed up in real output."""
spec = self.get(name)
prior_kernels_run = prior_kernels_run or []
problems = []
if spec.requires_fit and not has_fit_been_called:
problems.append("'%s' requires fit() to be called first -- was not." % name)
if spec.requires_history and not history_available:
problems.append("'%s' requires real history (not a single point) -- not available." % name)
if spec.requires_other_kernel_first and spec.requires_other_kernel_first not in prior_kernels_run:
problems.append("'%s' requires '%s' to run first -- it hasn't." % (name, spec.requires_other_kernel_first))
for conflict in spec.cannot_combine_with:
if conflict in prior_kernels_run:
problems.append("'%s' cannot combine with '%s', which already ran." % (name, conflict))
return {"can_run": len(problems) == 0, "problems": problems, "kernel": name}
def list_by_confidence(self, min_confidence="High"):
order = {"Untested": 0, "Low": 1, "Low-Moderate": 2, "Moderate": 3, "High": 4}
threshold = order.get(min_confidence, 0)
return [name for name, spec in self._kernels.items() if order.get(spec.confidence_level, 0) >= threshold]
def build_real_registry():
"""The real, current kernels -- confidence levels pulled directly from
CURRENT_UNDERSTANDING.md, not re-guessed."""
reg = KernelRegistry()
reg.register(KernelSpec(
name="reference_kalman", purpose="Temporal smoothing via adaptive gain",
input_requirements="Sequential numeric observations, one at a time after initial fit",
output_description="Smoothed score + uncertainty estimate",
requires_fit=True, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Compare against baseline under genuinely sequential testing (Fix 8)",
confidence_level="High",
))
reg.register(KernelSpec(
name="reference_baseline", purpose="Exponential smoothing",
input_requirements="Sequential numeric observations, one at a time after initial fit",
output_description="Smoothed score",
requires_fit=True, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Compare against Kalman under genuinely sequential testing (Fix 8)",
confidence_level="High",
))
reg.register(KernelSpec(
name="reference_ensemble", purpose="Bootstrap-resampled ensemble scoring",
input_requirements="A real batch fit() call before any predict() -- silently returns 0.0 without it",
output_description="Score + disagreement across resampled members",
requires_fit=True, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Not yet tested against real outcomes",
confidence_level="Untested",
))
reg.register(KernelSpec(
name="schema_health_linear", purpose="Four-channel structural-gap health score",
input_requirements="A single S/D/I/C reading, no history needed",
output_description="Health score, 0 to 1",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Verified identical to source estimator; NOT verified against real outcomes (see Fix 5 follow-up)",
confidence_level="Low-Moderate",
))
reg.register(KernelSpec(
name="channel_correlation_diagnostic", purpose="Real pairwise correlation between S/D/I/C across history",
input_requirements="A real accumulated run_log with at least 10 entries",
output_description="Pairwise correlation matrix + contamination warning",
requires_fit=False, requires_history=True, requires_other_kernel_first="channel_analysis",
cannot_combine_with=[], validation_method="Ran on real accumulated history, produced real correlations",
confidence_level="High",
))
reg.register(KernelSpec(
name="exploratory_pass_42", purpose="Minimum-N gated exploratory analysis",
input_requirements="At least 42 data points",
output_description="A single exploratory conclusion value, refuses to run below N=42",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Tested: correctly refuses below threshold, correctly detects compatible/incompatible independent passes",
confidence_level="High",
))
reg.register(KernelSpec(
name="hitop_spectra", purpose="Six empirically-derived psychopathology spectra from symptom co-occurrence",
input_requirements="Symptom-level clinical data",
output_description="Score per spectrum, 0-1",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Kotov et al. 2017, replicated across community and patient samples",
confidence_level="High",
))
reg.register(KernelSpec(
name="ffm_pid5_dimensions", purpose="Five-factor personality model, normal-to-pathological continuum",
input_requirements="Personality trait self-report or informant report",
output_description="Score per dimension, -1 (adaptive) to +1 (pathological)",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Replicated in 754-person nonclinical sample; official DSM-5 Section III model",
confidence_level="High",
))
reg.register(KernelSpec(
name="ppm_positive_pole", purpose="Positive-pole mirror of PID-5, five flourishing dimensions",
input_requirements="Self-report, general population",
output_description="Score per dimension, 0 (low) to 1 (high flourishing)",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="de la Iglesia & Castro Solano 2018, n=1902, outperformed FFM alone in predicting mental health variance",
confidence_level="Moderate",
))
reg.register(KernelSpec(
name="three_framework_integration", purpose="Reconciles HiTOP/FFM-PID5/PPM onto 5 shared axes via the real gated tensor",
input_requirements="At least one framework reading per axis",
output_description="D estimate per axis, written through ImmutableNCFCATensor.update_D",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Verified: reconciled D-writes confirmed through the real gated tensor path, not a bare dict",
confidence_level="Low-Moderate",
))
reg.register(KernelSpec(
name="research_state_kernel", purpose="Classify a work item's real current stage from real signals, not narration",
input_requirements="evidence_fraction, contradiction count, verification/replication/forward-validation status",
output_description="One of 8 real stages, Blocked through Production, with a stated reason",
requires_fit=False, requires_history=False, requires_other_kernel_first=None,
cannot_combine_with=[], validation_method="Tested against 3 real, current situations from this session's own work -- correctly classified all three",
confidence_level="Moderate",
))
reg.register(KernelSpec(
name="next_action_kernel", purpose="One recommended next step tied directly to the state kernel's output",
input_requirements="A research_state_kernel result",
output_description="One specific recommended action, not a menu",
requires_fit=False, requires_history=False, requires_other_kernel_first="research_state_kernel",
cannot_combine_with=[], validation_method="Tested alongside research_state_kernel on the same 3 real cases",
confidence_level="Moderate",
))
return reg
four_channel_formulas.py
Single source of truth for the real, tested four-channel formulas. Extracted specifically so nothing else has to re-type these and risk silent drift — exactly the duplication the full system audit found between the nuanced estimators module and pipeline_front_gate.py's own inline lambda copy. Every formula here is verified identical to its origin in the real, tested estimator class — not re-derived, copied exactly.
"""
four_channel_formulas.py
Single source of truth for the real, tested four-channel formulas.
Extracted from COMPONENT_A_NUANCED_ESTIMATORS.py (Fix 5) specifically so
nothing else has to re-type these and risk silent drift -- exactly the
duplication the full system audit found between COMPONENT_A_NUANCED_
ESTIMATORS.py and pipeline_front_gate.py's own inline lambda copy.
Every formula here is verified identical to its origin in the real,
tested estimator class -- not re-derived, copied exactly.
"""
import numpy as np
def schema_health_linear(S, D, I, C):
structural_gap = abs(S - D)
surface_gap = abs(I - C)
health = 1.0 - (structural_gap * 0.7 + surface_gap * 0.3)
return max(0.0, min(1.0, health))
def schema_health_quadratic(S, D, I, C):
structural_gap = (S - D) ** 2
surface_gap = (I - C) ** 2
health = 1.0 - (structural_gap * 0.7 + surface_gap * 0.3)
return max(0.0, min(1.0, health))
def recovery_potential(S, D, C):
expressed_gap = abs(S - D)
recovery = (1.0 - expressed_gap) * (0.5 + 0.5 * C)
return max(0.0, min(1.0, recovery))
def channel_balance_entropy(S, D, I, C):
values = np.clip(np.array([S, D, I, C]), 1e-9, None)
probs = values / values.sum()
entropy = -np.sum(probs * np.log(probs))
max_entropy = np.log(4)
return float(np.clip(entropy / max_entropy, 0, 1))
def cross_channel_coupling(S, D, I, C):
sd_pair = 1.0 - abs(S - D)
di_pair = 1.0 - abs(D - I)
ic_pair = 1.0 - abs(I - C)
coupling = sd_pair * 0.4 + di_pair * 0.35 + ic_pair * 0.25
return max(0.0, min(1.0, coupling))
REGISTRY = {
"schema_health_linear": schema_health_linear,
"schema_health_quadratic": schema_health_quadratic,
"recovery_potential": lambda S, D, I, C: recovery_potential(S, D, C),
"channel_balance_entropy": channel_balance_entropy,
"cross_channel_coupling": cross_channel_coupling,
}
if __name__ == "__main__":
print("Real formula test, same inputs across all five:")
S, D, I, C = 0.7, 0.5, 0.6, 0.4
for name, fn in REGISTRY.items():
print(" %s: %.4f" % (name, fn(S, D, I, C)))