The 0.4 release rebuilds the package around the Behavioral Trust Clustering architecture validated empirically on Qwen2.5-Coder-7B (companion paper, in preparation).
-
HybridLayer: end-to-end Generator × Governor pipeline with K-sample stochastic decoding and behavioral clustering. -
behavioral_governance: closed-form trust thermodynamic governor exposed as a standalone function for offline analysis. -
trust_thermodynamic: the closed-form trust score,$T = \mathrm{PPV} \cdot \exp(-\sigma_{\text{calib}} \cdot T_{\text{comp}})$ , with adaptive computational temperature. -
cluster_by_behavior: behavioral (output-equivalence) clustering for code candidates. -
make_python_probe_runner: factory for behavioral probe runners that execute candidates in subprocess sandboxes. -
extract_probe_args_from_tests: regex-based extraction of probe arguments from assertion-based test specifications. -
cluster_by_ast: structural clustering, retained for ablation studies. - Backend protocol
LLMBackendwith three reference implementations:OllamaBackend,OpenAIBackend,CallableBackend. - Layer 1 system prompts (
LAYER1_SYSTEM_PROMPT_EN,LAYER1_SYSTEM_PROMPT_IT) with calibrated utility framing. - Strict input validation on
HybridLayerandtrust_thermodynamic. - 35-test pytest suite covering governance, parsing, clustering, and end-to-end integration.
- The trust formula default for
$T_{\text{comp}}$ is now adaptive ($0.5 + (1 - \mathrm{PPV})$) rather than fixed at$1.0$ . The fixed form remains available via thet_compparameter. - Confidence parsing tolerates inline
CONFIDENCE: Xmarkers as well as separate-line markers (regression from 0.3 found during HumanEval validation). - The Shannon entropy normalization for
$\sigma_{\text{calib}}$ now divides by$\log(n_{\text{clusters}})$ rather than$\log(K)$ , eliminating a numerical artefact at perfect agreement.
- Legacy
SubstrateandCascadeclasses from 0.1.x; their functionality is subsumed byHybridLayerand the standalonebehavioral_governance. - The
@verifiedand@with_abstentiondecorators; replaced by directHybridLayer.queryinvocation, which is more flexible and easier to instrument.
-
sigma_calibno longer becomes negative under perfect agreement due to the$\epsilon = 10^{-9}$ inside the logarithm of the 0.3 implementation. - The cascade did not propagate the modal answer correctly when the modal cluster was singleton; this case is now handled.
The 0.1.x API is incompatible with 0.4. The migration is straightforward:
# 0.1.x
from snc_core import Cascade
cascade = Cascade(substrates=[s1, s2, s3], threshold=0.5)
result = cascade.evaluate(prompt)
# 0.4
from snc_core import HybridLayer
from snc_core.adapters import OllamaBackend
hybrid = HybridLayer(OllamaBackend(model="..."), k=5, threshold=0.5)
result = hybrid.query(prompt)Concretely, the 0.4 single-backend / K-sample model replaces the 0.1.x multi-substrate / single-call model. The two are not isomorphic: 0.4 is the architecture validated in the companion paper, and we recommend it for new projects.
Initial public release.