@takk/bayesoutputgate 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/LICENSE +190 -0
- package/NOTICE +45 -0
- package/README.md +403 -0
- package/SECURITY.md +98 -0
- package/SPEC.md +467 -0
- package/dist/adapter/index.cjs +411 -0
- package/dist/adapter/index.d.cts +29 -0
- package/dist/adapter/index.d.ts +29 -0
- package/dist/adapter/index.js +404 -0
- package/dist/audit/index.cjs +82 -0
- package/dist/audit/index.d.cts +40 -0
- package/dist/audit/index.d.ts +40 -0
- package/dist/audit/index.js +77 -0
- package/dist/bayesfactor/index.cjs +152 -0
- package/dist/bayesfactor/index.d.cts +15 -0
- package/dist/bayesfactor/index.d.ts +15 -0
- package/dist/bayesfactor/index.js +149 -0
- package/dist/beta/index.cjs +180 -0
- package/dist/beta/index.d.cts +45 -0
- package/dist/beta/index.d.ts +45 -0
- package/dist/beta/index.js +178 -0
- package/dist/calibration/index.cjs +339 -0
- package/dist/calibration/index.d.cts +53 -0
- package/dist/calibration/index.d.ts +53 -0
- package/dist/calibration/index.js +333 -0
- package/dist/cli/index.cjs +968 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +966 -0
- package/dist/dimensions/index.cjs +106 -0
- package/dist/dimensions/index.d.cts +33 -0
- package/dist/dimensions/index.d.ts +33 -0
- package/dist/dimensions/index.js +104 -0
- package/dist/edge/index.cjs +1141 -0
- package/dist/edge/index.d.cts +12 -0
- package/dist/edge/index.d.ts +12 -0
- package/dist/edge/index.js +1109 -0
- package/dist/gate/index.cjs +803 -0
- package/dist/gate/index.d.cts +77 -0
- package/dist/gate/index.d.ts +77 -0
- package/dist/gate/index.js +799 -0
- package/dist/hypothesis/index.cjs +268 -0
- package/dist/hypothesis/index.d.cts +38 -0
- package/dist/hypothesis/index.d.ts +38 -0
- package/dist/hypothesis/index.js +266 -0
- package/dist/index.cjs +1141 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +1109 -0
- package/dist/likelihood/index.cjs +137 -0
- package/dist/likelihood/index.d.cts +23 -0
- package/dist/likelihood/index.d.ts +23 -0
- package/dist/likelihood/index.js +132 -0
- package/dist/node/index.cjs +1282 -0
- package/dist/node/index.d.cts +24 -0
- package/dist/node/index.d.ts +24 -0
- package/dist/node/index.js +1246 -0
- package/dist/policy/index.cjs +88 -0
- package/dist/policy/index.d.cts +11 -0
- package/dist/policy/index.d.ts +11 -0
- package/dist/policy/index.js +85 -0
- package/dist/types-bMjn1j4e.d.cts +159 -0
- package/dist/types-bMjn1j4e.d.ts +159 -0
- package/package.json +142 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@takk/bayesoutputgate` are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every entry carries a UTC timestamp.
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-06-23T22:58:26Z
|
|
8
|
+
|
|
9
|
+
Initial stable release. A universal, zero-runtime-dependency NPM library and CLI for calibrated output validation with the Bayes Factor, the validation layer for Massive Intelligence (IM) systems and non-human entities (NHEs). Feed the per-dimension quality scores of an output, from an LLM-as-judge, a classifier, or a regex; BayesOutputGate weighs a high-quality hypothesis against a low-quality one, computes the Bayes Factor between them, interprets it on the Jeffreys scale, and returns a calibrated pass, fail, or escalate decision, the principled answer to "is this output good enough to ship" instead of an arbitrary threshold.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
#### The calibrated Beta engine
|
|
14
|
+
|
|
15
|
+
- Beta model (`@takk/bayesoutputgate/beta`): `BetaModel`, a calibrated Beta distribution over a quality score in [0, 1] that both Bayes Factor modes are built on. It is fit from labeled scores by method of moments, regularized by a prior Beta treated as pseudo-observations carrying the prior's own mean and variance, and updated online from sufficient statistics, so a cold model returns its prior and a warm model is data-driven. `fromSamples`, `fromSnapshot`, `observe`, `params`, `mean`, `logDensity`, and `snapshot` make it serializable across processes.
|
|
16
|
+
|
|
17
|
+
#### Hypotheses and likelihoods
|
|
18
|
+
|
|
19
|
+
- Hypothesis manager (`@takk/bayesoutputgate/hypothesis`): `HypothesisManager` keeps a high-quality and a low-quality `BetaModel` per dimension plus a weight, calibrated from labeled observations and updatable online. The weakly-informative defaults, Beta(2, 1) for high and Beta(1, 2) for low with only a few pseudo-observations of concentration, let labeled data dominate quickly. `models()` snapshots the calibration as the dimension models the Bayes Factor consumes.
|
|
20
|
+
- Likelihoods (`@takk/bayesoutputgate/likelihood`): `logScoreLikelihood` (the Beta log-density of a continuous score), `logBinaryMarginalLikelihood` (the Beta-Binomial marginal for binary pass/fail outcomes), `toScoreMap`, and `logVectorLikelihood` (the weighted per-dimension log-likelihood of a score vector under one hypothesis, with a matched-dimension count).
|
|
21
|
+
|
|
22
|
+
#### The Bayes Factor and the decision policy
|
|
23
|
+
|
|
24
|
+
- Bayes Factor (`@takk/bayesoutputgate/bayesfactor`): `bayesFactor` computes the combined natural-log Bayes Factor in favor of high quality as the weighted sum of per-dimension Beta log-density differences, over the dimensions that have both a score and a model, with boundary scores clamped inward so a 0 or 1 never produces a non-finite density. `jeffreysStrength` maps the log-Bayes-Factor to a seven-way Jeffreys-scale category using the symmetric boundaries 3, 10, and 100 (Kass and Raftery, 1995).
|
|
25
|
+
- Decision policy (`@takk/bayesoutputgate/policy`): `decide` and `posteriorHighQuality`. The Bayes Factor policy passes at or above `passAbove`, fails at or below `failBelow`, and escalates in between. The decision-theoretic policy converts the Bayes Factor to a posterior probability of high quality through an explicit prior (posterior log-odds equal log-Bayes-Factor plus prior log-odds, via a numerically stable logistic), then chooses the action that minimizes expected loss under the asymmetric costs of a false pass, a false fail, and escalation, which makes the gate utility-aware rather than a re-skinned threshold.
|
|
26
|
+
|
|
27
|
+
#### Trust diagnostics
|
|
28
|
+
|
|
29
|
+
- Dependence diagnostic (`@takk/bayesoutputgate/dimensions`): `dependenceDiagnostic` measures pairwise Pearson correlation between dimensions across a history of score vectors and flags pairs at or above a threshold, because correlated dimensions double-count evidence and inflate the Bayes Factor. It surfaces whether the conditional-independence assumption behind the summed log-Bayes-Factors is safe.
|
|
30
|
+
- Calibration measurement (`@takk/bayesoutputgate/calibration`): `goodnessOfFit` (the Kolmogorov-Smirnov statistic of observed scores against a fitted Beta, with an asymptotic critical value), `brierScore`, `expectedCalibrationError`, `reliability`, and `assessAssumptions` (the per-dimension fit and the dependence diagnostic combined into one report the gate guards consult). Goodness-of-fit comes first, because if the Beta assumption fails the Bayes Factor is optimizing the wrong model; decision calibration then measures whether the posterior probabilities match realized outcomes. Calibration is measured, never asserted.
|
|
31
|
+
|
|
32
|
+
#### The gate, the audit trail, and the tool
|
|
33
|
+
|
|
34
|
+
- Gate orchestrator (`@takk/bayesoutputgate/gate`): `evaluate` ties the calibrated models, the Bayes Factor, and the policy into one call returning a `GateDecision`. `OutputGate` wraps fixed models and a fixed policy. `OutputGateMonitor` wraps the same pipeline with a tamper-evident audit chain and online recalibration: it seals each decision, folds labeled outcomes back into the calibration, and returns the sealed chain.
|
|
35
|
+
- Assumption guards (`GateGuards`, `AssumptionReport`): `evaluate`, `OutputGate`, and `OutputGateMonitor` accept guards that escalate to human review rather than trusting a Bayes Factor from a misspecified model. With `requireGoodnessOfFit` or `requireIndependence`, a violated assumption forces the action to `escalate` with rationale `"assumption-violated"`, and the report is attached to every `GateDecision`. The monitor reassesses the report from the history on each batch `fit`.
|
|
36
|
+
- Tamper-evident audit trail (`@takk/bayesoutputgate/audit`): an append-only `AuditChain` with a SHA-256 hash chain you `append` to and `verifyChain`, plus `sha256Hex` and `GENESIS_HASH`. Each entry hashes its canonical JSON with the previous entry's hash, so any later edit breaks every link after it. It uses the Web Crypto API, not `node:crypto`, so the surface stays node-free, and timestamps are caller-supplied so hashing is deterministic.
|
|
37
|
+
- Tool adapter (`@takk/bayesoutputgate/adapter`): `bayesOutputGateTool`, `runTool`, and `describeTool`, a framework-agnostic tool definition (name `bayes_output_gate`, description, JSON Schema, handler) matching what MCP servers and LLM tool-calling APIs expect, so a non-human entity (NHE) can validate its own output before acting. Input arriving from a model is parsed defensively and the output is made JSON-safe.
|
|
38
|
+
|
|
39
|
+
#### Persistence and CLI
|
|
40
|
+
|
|
41
|
+
- `@takk/bayesoutputgate/node` ships `readJsonFile`, `loadLabeledObservations`, `parseCsvScores`, and `loadScores` over `node:fs`, defensively validated, and re-exports the full core. It is the only entry point that touches a Node built-in.
|
|
42
|
+
- Binary `bayesoutputgate` exposed via `package.json#bin`. `bayesoutputgate gate` fits from labeled history and decides each output, `bayes-factor` computes the Bayes Factor against explicit dimension models, `calibrate` reports goodness-of-fit per dimension and the dependence diagnostic, and `audit-verify` checks a sealed decision chain. Flags `--pass-above`, `--fail-below`, and `--json`. Single-process exit codes: 0 ok, 2 usage or input error, 30 a fail decision, 40 an escalate decision, 20 a broken audit chain.
|
|
43
|
+
|
|
44
|
+
#### Distribution
|
|
45
|
+
|
|
46
|
+
- Thirteen entry points, each a subpath export with split `import`/`require` conditions: the root facade plus `beta`, `hypothesis`, `likelihood`, `bayesfactor`, `dimensions`, `policy`, `calibration`, `gate`, `audit`, `adapter`, `node`, and `edge`.
|
|
47
|
+
- Dual ESM + CJS bundles built with tsup 8 in a single neutral-platform pass, with separate `.d.ts` and `.d.cts` type files per entry point, and the CLI shebang preserved from source.
|
|
48
|
+
- Node-free, platform-neutral core importable in Node, edge runtimes, and the browser; `@takk/bayesoutputgate/edge` re-exports it verbatim, audit trail included, since Web Crypto is present there too.
|
|
49
|
+
- Zero required runtime dependencies. `@takk/keymesh` and `@takk/modelchain` are optional peer dependencies, integration points the core takes no dependency on.
|
|
50
|
+
|
|
51
|
+
#### Documentation and project site
|
|
52
|
+
|
|
53
|
+
- A complete project site (`index.html`, `404.html`) and documentation set (`README.md`, `SPEC.md`, `SECURITY.md`, `PRIVACY.md`, `CLA.md`, `CODE_OF_CONDUCT.md`, `.github/CONTRIBUTING.md`, `.github/RELEASING.md`), with five JSON-LD structured-data blocks, an Open Graph card, a bespoke hero diagram that traces the flow from per-dimension scores through the Bayes Factor and the Jeffreys scale to a pass, fail, or escalate decision sealed in the audit trail, and a robots and sitemap pair. Every claim is phrased honestly: the Bayes Factor is calibrated from the user's own labeled data, the goodness-of-fit and dependence checks are diagnostics the caller inspects, the gate returns a recommendation an orchestrator consumes rather than acting itself, and "calibrated" is backed by the metrics the library measures.
|
|
54
|
+
|
|
55
|
+
#### Examples and benchmark
|
|
56
|
+
|
|
57
|
+
- Five runnable, offline, deterministic examples under `examples/`, executed end-to-end against the compiled `dist`: the basic gate, the decision-theoretic policy, the assumption guards, the MCP tool adapter, and node-free edge usage with a verifiable audit chain.
|
|
58
|
+
- A value benchmark (`benchmarks/value.ts`) executed against the compiled `dist`, scoring the gate against fairly-tuned fixed thresholds (on the mean and on the min of two dimensions) on a held-out test set the gate never calibrates on, under an asymmetric loss (false pass 10, false fail 2, escalation 1), with a "masking" low-quality output that scores high on factuality but low on safety. When the Beta assumption holds, the calibrated multi-dimension gate cuts average loss to 0.456 against the best tuned threshold's 0.619 (accuracy 93.7% against 78.6%), escalating the ambiguous 23.7% to review. When the assumption is violated (a strongly bimodal score distribution), goodness-of-fit detects it, the gate keeps the lowest loss (0.869 against about 0.986) with zero false passes, and the goodness-of-fit guard escalates every output rather than acting on a model it knows is misspecified. The gate sustains roughly 2.7 million two-dimension decisions per second. Every number is from real execution, never invented.
|
|
59
|
+
|
|
60
|
+
### Quality
|
|
61
|
+
|
|
62
|
+
- 90 tests across 15 suites passing under Vitest 4, including the special functions verified against closed forms, the Beta-Binomial marginal verified against its uniform-prior identity, the calibrated Beta fit and online update, the Bayes Factor verified against the Jeffreys boundaries, the decision-theoretic policy verified against expected loss, the goodness-of-fit and dependence diagnostics, the assumption guards that escalate on a violated assumption, and the audit chain verified against a known SHA-256 digest and to detect tampering and broken links.
|
|
63
|
+
- Coverage: statements 94.64%, branches 87.58%, functions 96.24%, lines 95.91%.
|
|
64
|
+
- Lint clean under Biome 2.5. Typecheck clean under TypeScript 6 in maximum strict mode (`exactOptionalPropertyTypes`, `noUncheckedIndexedAccess`, `verbatimModuleSyntax`, `noPropertyAccessFromIndexSignature`, `isolatedModules`).
|
|
65
|
+
- `publint` clean and `@arethetypeswrong/cli` green across all thirteen subpaths and `package.json`.
|
|
66
|
+
- `size-limit` under budget on every bundle (brotli core facade 5.29 kB against an 8 kB limit, bayes factor 1.03 kB, gate 3.01 kB, edge barrel 5.29 kB, node entry 5.95 kB).
|
|
67
|
+
- Distribution smoke test exercising the compiled ESM and CJS artifacts and every subpath, with the compiled CLI spawned as a single Node process. The full suite, the smoke test, and the CLI are re-verified on Node 24.
|
|
68
|
+
|
|
69
|
+
### Security
|
|
70
|
+
|
|
71
|
+
- Every release is published to the npm registry with `npm publish --provenance`, carrying a SLSA provenance attestation generated by GitHub Actions over OIDC. Consumers can verify with `npm view @takk/bayesoutputgate --json | jq .dist.attestations`.
|
|
72
|
+
- Tamper-evident audit trail backed by a SHA-256 hash chain, suitable as compliance evidence (EU AI Act) that the recorded decisions were not altered after sealing. It is an integrity seal, not a signature.
|
|
73
|
+
- Zero runtime dependencies, the smallest possible supply-chain surface. The node-free core uses the Web Crypto API, not `node:crypto`.
|
|
74
|
+
|
|
75
|
+
### Licensing
|
|
76
|
+
|
|
77
|
+
- Licensed under the Apache License, Version 2.0. The `NOTICE` file ships in the tarball alongside `LICENSE`.
|
|
78
|
+
|
|
79
|
+
### Engines
|
|
80
|
+
|
|
81
|
+
- Node `>=20.0.0`. Verified locally on Node 22 and Node 24; the continuous integration matrix covers Node 20, 22, and 24.
|
|
82
|
+
|
|
83
|
+
## [Unreleased]
|
|
84
|
+
|
|
85
|
+
Highlights queued for future releases:
|
|
86
|
+
|
|
87
|
+
- A finer-grained, per-output adequacy signal, so the gate can escalate only the outputs a misspecified model is uncertain about rather than the whole stream.
|
|
88
|
+
- Streaming and multi-rater score aggregation, with inter-annotator agreement.
|
|
89
|
+
- Drift and change-point detection over the calibrated models, to flag a shift in the score regime before it costs quality.
|
|
90
|
+
- Non-Beta score families (a calibrated mixture, a nonparametric density) for scores the Beta cannot fit.
|
|
91
|
+
- Turnkey runtime integrations (MCP server, orchestrator hooks) that consume the gate decision and act on it.
|
|
92
|
+
- Signed and timestamped audit seals for stronger third-party evidence.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for the acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your own
|
|
170
|
+
behalf and on Your sole responsibility, not on behalf of any other
|
|
171
|
+
Contributor, and only if You agree to indemnify, defend, and hold
|
|
172
|
+
each Contributor harmless for any liability incurred by, or claims
|
|
173
|
+
asserted against, such Contributor by reason of your accepting any
|
|
174
|
+
such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 David C Cavalcante
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@takk/bayesoutputgate
|
|
2
|
+
Copyright 2026 David C Cavalcante (Takk Innovate Studio)
|
|
3
|
+
|
|
4
|
+
This product includes software developed by David C Cavalcante
|
|
5
|
+
(https://takk.ag, davcavalcante@proton.me).
|
|
6
|
+
|
|
7
|
+
BayesOutputGate is a universal, zero-runtime-dependency library and CLI for
|
|
8
|
+
calibrated output validation with the Bayes Factor. You feed the per-dimension
|
|
9
|
+
quality scores of an output, from any scorer, and it weighs a high-quality
|
|
10
|
+
hypothesis against a low-quality one, returns a calibrated pass, fail, or
|
|
11
|
+
escalate decision on the Jeffreys scale, and seals the decision in a
|
|
12
|
+
tamper-evident audit trail, for Massive Intelligence (IM) systems and non-human
|
|
13
|
+
entities that must validate their own outputs before acting on them.
|
|
14
|
+
|
|
15
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
16
|
+
use the software in this repository except in compliance with the License.
|
|
17
|
+
A copy of the License is in the LICENSE file at the root of this repository,
|
|
18
|
+
and is also available at:
|
|
19
|
+
|
|
20
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
|
|
22
|
+
────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
THIRD-PARTY COMPONENTS
|
|
24
|
+
────────────────────────────────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
BayesOutputGate has ZERO required runtime dependencies. Its core is node-free; the
|
|
27
|
+
audit seal uses the Web Crypto API, not node:crypto. The @takk sibling packages
|
|
28
|
+
(@takk/keymesh and @takk/modelchain) are OPTIONAL peer dependencies, resolved
|
|
29
|
+
only when you compose with them, and each is distributed under the Apache
|
|
30
|
+
License, Version 2.0.
|
|
31
|
+
|
|
32
|
+
The core package pulls in none of the above. Only the @takk/bayesoutputgate/node
|
|
33
|
+
entry point uses the Node standard library (node:fs and node:path) for reading
|
|
34
|
+
labeled history and score vectors from disk.
|
|
35
|
+
|
|
36
|
+
Development-only tooling (NOT shipped in the published package):
|
|
37
|
+
|
|
38
|
+
- tsup MIT
|
|
39
|
+
- tsx MIT
|
|
40
|
+
- vitest MIT
|
|
41
|
+
- typescript Apache-2.0
|
|
42
|
+
- @biomejs/biome MIT OR Apache-2.0
|
|
43
|
+
- publint MIT
|
|
44
|
+
- @arethetypeswrong/cli MIT
|
|
45
|
+
- size-limit MIT
|