sqa-bi 0.1.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.
- checksums.yaml +7 -0
- data/.github/workflows/docs.yml +55 -0
- data/.quality/reek_baseline.txt +5 -0
- data/.rubocop.yml +224 -0
- data/CHANGELOG.md +33 -0
- data/CLAUDE.md +128 -0
- data/COMMITS.md +196 -0
- data/LICENSE.txt +21 -0
- data/README.md +229 -0
- data/Rakefile +170 -0
- data/decision_support_techniques.md +391 -0
- data/docs/EXPLORATION.md +128 -0
- data/docs/api/index.md +66 -0
- data/docs/api/likelihood.md +78 -0
- data/docs/api/llm-elicitors.md +119 -0
- data/docs/api/llm-support.md +136 -0
- data/docs/api/posterior.md +106 -0
- data/docs/api/prior.md +81 -0
- data/docs/api/time-series-predictor.md +96 -0
- data/docs/assets/css/custom.css +25 -0
- data/docs/assets/diagrams/architecture.svg +75 -0
- data/docs/assets/diagrams/bayes-pipeline.svg +48 -0
- data/docs/assets/diagrams/kde.svg +52 -0
- data/docs/assets/diagrams/llm-bayes-loop.svg +58 -0
- data/docs/assets/diagrams/provider-resolution.svg +77 -0
- data/docs/assets/js/mathjax.js +18 -0
- data/docs/development.md +164 -0
- data/docs/examples/index.md +198 -0
- data/docs/getting-started/core-concepts.md +119 -0
- data/docs/getting-started/installation.md +112 -0
- data/docs/getting-started/quick-start.md +143 -0
- data/docs/guide/likelihood.md +132 -0
- data/docs/guide/posterior.md +135 -0
- data/docs/guide/predictor.md +191 -0
- data/docs/guide/prior.md +141 -0
- data/docs/guide/tuning.md +156 -0
- data/docs/guide/uncertainty.md +148 -0
- data/docs/index.md +110 -0
- data/docs/llm/index.md +124 -0
- data/docs/llm/likelihood-estimation.md +161 -0
- data/docs/llm/prior-elicitation.md +172 -0
- data/docs/llm/providers.md +184 -0
- data/docs/requirements.txt +8 -0
- data/lib/sqa/bi/likelihood.rb +167 -0
- data/lib/sqa/bi/llm_likelihood_estimator.rb +110 -0
- data/lib/sqa/bi/llm_prior_elicitor.rb +110 -0
- data/lib/sqa/bi/llm_support.rb +299 -0
- data/lib/sqa/bi/posterior.rb +189 -0
- data/lib/sqa/bi/prior.rb +135 -0
- data/lib/sqa/bi/time_series_predictor.rb +219 -0
- data/lib/sqa/bi/version.rb +7 -0
- data/lib/sqa/bi.rb +57 -0
- data/mkdocs.yml +174 -0
- metadata +272 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: dedd5b9513ae1c858799e16819c4936b41efafaf6475a9aa0b8e0923dc1309bb
|
|
4
|
+
data.tar.gz: deeadd9357583787d6e3078c23eea4dc73c1544a76acc3e85687d8a17c1348a7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c95f2a403ded00c675827833e4b177a9d1a08e1ad246300d9a771f4d3207624218cc53348fc2d0224a6eb0fc6728a188090c94d7a6f9e6e1e749b5a95d47b93b
|
|
7
|
+
data.tar.gz: 47d3fc0e5264e5d9c27a89d99acce5326e25df8f83d3931670998a82fb06ed6325e439db012d5230912bb54caa1497d2b66ec5da9f4768cfe6da9cd130952020
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Publish the MkDocs site to GitHub Pages.
|
|
2
|
+
#
|
|
3
|
+
# Requires Pages to be enabled for the repository with "GitHub Actions"
|
|
4
|
+
# as the source (Settings → Pages → Build and deployment → Source).
|
|
5
|
+
name: docs
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [main]
|
|
10
|
+
paths:
|
|
11
|
+
- "docs/**"
|
|
12
|
+
- "mkdocs.yml"
|
|
13
|
+
- ".github/workflows/docs.yml"
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
pages: write
|
|
19
|
+
id-token: write
|
|
20
|
+
|
|
21
|
+
concurrency:
|
|
22
|
+
group: pages
|
|
23
|
+
cancel-in-progress: false
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
build:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
|
|
31
|
+
- uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: "3.12"
|
|
34
|
+
cache: pip
|
|
35
|
+
cache-dependency-path: docs/requirements.txt
|
|
36
|
+
|
|
37
|
+
- run: pip install -r docs/requirements.txt
|
|
38
|
+
|
|
39
|
+
# --strict turns the link and anchor validation in mkdocs.yml into
|
|
40
|
+
# build failures, so a broken cross-reference never ships.
|
|
41
|
+
- run: mkdocs build --strict
|
|
42
|
+
|
|
43
|
+
- uses: actions/upload-pages-artifact@v3
|
|
44
|
+
with:
|
|
45
|
+
path: site
|
|
46
|
+
|
|
47
|
+
deploy:
|
|
48
|
+
needs: build
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
environment:
|
|
51
|
+
name: github-pages
|
|
52
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
53
|
+
steps:
|
|
54
|
+
- id: deployment
|
|
55
|
+
uses: actions/deploy-pages@v4
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
SuggestExtensions: false
|
|
4
|
+
TargetRubyVersion: 4.0
|
|
5
|
+
Exclude:
|
|
6
|
+
- 'examples/**/*'
|
|
7
|
+
- 'docs/**/*'
|
|
8
|
+
- 'site/**/*'
|
|
9
|
+
- 'pkg/**/*'
|
|
10
|
+
- 'coverage/**/*'
|
|
11
|
+
# Untracked scratch/dev scripts left at repo root in sqa-tai (not part of the shipped gem)
|
|
12
|
+
- 'add_array_order_note.rb'
|
|
13
|
+
- 'complete_all_patterns.rb'
|
|
14
|
+
- 'generate_remaining_patterns.rb'
|
|
15
|
+
|
|
16
|
+
# ── Style: disabled cops ───────────────────────────────────────────────────
|
|
17
|
+
Style/StringLiterals:
|
|
18
|
+
Enabled: false
|
|
19
|
+
|
|
20
|
+
Style/StringLiteralsInInterpolation:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
Style/Documentation:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
# Ruby 4.0 freezes string literals by default
|
|
27
|
+
Style/FrozenStringLiteralComment:
|
|
28
|
+
Enabled: false
|
|
29
|
+
|
|
30
|
+
Style/IfUnlessModifier:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
Style/RescueModifier:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
Style/TrivialAccessors:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
Style/MultilineTernaryOperator:
|
|
40
|
+
Enabled: false
|
|
41
|
+
|
|
42
|
+
Style/SafeNavigation:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/EmptyClassDefinition:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
Style/ClassAndModuleChildren:
|
|
49
|
+
Enabled: false
|
|
50
|
+
|
|
51
|
+
Style/RescueStandardError:
|
|
52
|
+
Enabled: false
|
|
53
|
+
|
|
54
|
+
Style/OneClassPerFile:
|
|
55
|
+
Enabled: false
|
|
56
|
+
|
|
57
|
+
# Both % and format/sprintf are acceptable
|
|
58
|
+
Style/FormatString:
|
|
59
|
+
Enabled: false
|
|
60
|
+
|
|
61
|
+
# String concatenation and interpolation are both acceptable
|
|
62
|
+
Style/StringConcatenation:
|
|
63
|
+
Enabled: false
|
|
64
|
+
|
|
65
|
+
# OpenStruct is a deliberate architectural choice throughout this ecosystem —
|
|
66
|
+
# strategy/backtest/stream vectors are built as OpenStructs on purpose (see
|
|
67
|
+
# sqa/CLAUDE.md). Not a candidate for a Struct/class/test-double rewrite.
|
|
68
|
+
Style/OpenStructUse:
|
|
69
|
+
Enabled: false
|
|
70
|
+
|
|
71
|
+
# $DEBUG_ME (debug_me gem convention) and test fixture globals like $data are
|
|
72
|
+
# established patterns here, not accidental global-variable leaks.
|
|
73
|
+
Style/GlobalVars:
|
|
74
|
+
Enabled: false
|
|
75
|
+
|
|
76
|
+
# ── Layout ─────────────────────────────────────────────────────────────────
|
|
77
|
+
Layout/LineLength:
|
|
78
|
+
Max: 140
|
|
79
|
+
|
|
80
|
+
Layout/ExtraSpacing:
|
|
81
|
+
Enabled: false
|
|
82
|
+
|
|
83
|
+
Layout/HashAlignment:
|
|
84
|
+
Enabled: false
|
|
85
|
+
|
|
86
|
+
Layout/FirstHashElementIndentation:
|
|
87
|
+
Enabled: false
|
|
88
|
+
|
|
89
|
+
Layout/EmptyLineAfterGuardClause:
|
|
90
|
+
Enabled: false
|
|
91
|
+
|
|
92
|
+
# ── Naming ─────────────────────────────────────────────────────────────────
|
|
93
|
+
# Single-char params (c, e, n) are acceptable throughout
|
|
94
|
+
Naming/MethodParameterName:
|
|
95
|
+
Enabled: false
|
|
96
|
+
|
|
97
|
+
# sma_20, percentile_95, and similar parameterized names are more readable
|
|
98
|
+
# than the normalcase default (sma20, percentile95). alpha_vantage_api.rb is
|
|
99
|
+
# excluded entirely: it mirrors Alpha Vantage's literal API function/parameter
|
|
100
|
+
# names (t3, timeperiod1/2/3, ...) verbatim, which we can't rename. Same
|
|
101
|
+
# reasoning for sqa-tai's overlap_studies.rb (t3) and momentum_indicators.rb
|
|
102
|
+
# (ultosc's time_period1/2/3) — TA-Lib's own C function/parameter names.
|
|
103
|
+
Naming/VariableNumber:
|
|
104
|
+
EnforcedStyle: snake_case
|
|
105
|
+
Exclude:
|
|
106
|
+
- 'test/**/*'
|
|
107
|
+
- 'lib/api/alpha_vantage_api.rb'
|
|
108
|
+
- 'lib/sqa/tai/overlap_studies.rb'
|
|
109
|
+
- 'lib/sqa/tai/momentum_indicators.rb'
|
|
110
|
+
- 'lib/sqa/data_frame/yahoo_finance.rb' # period1/period2 mirror Yahoo's own chart API query params verbatim
|
|
111
|
+
|
|
112
|
+
# sqa-cli's gem entry point must be lib/sqa-cli.rb (hyphen) so that
|
|
113
|
+
# `require 'sqa-cli'` resolves by exact match on the gem name; renaming to
|
|
114
|
+
# snake_case would break the require path. (Only sqa-cli has such a file.)
|
|
115
|
+
# Archspec.rb must be PascalCase, matching the archspec gem's own
|
|
116
|
+
# Rakefile/Gemfile-style convention-named config file.
|
|
117
|
+
Naming/FileName:
|
|
118
|
+
Exclude:
|
|
119
|
+
- 'lib/sqa-cli.rb'
|
|
120
|
+
- 'Archspec.rb'
|
|
121
|
+
|
|
122
|
+
Naming/RescuedExceptionsVariableName:
|
|
123
|
+
Enabled: false
|
|
124
|
+
|
|
125
|
+
# set_results and similar explicit setters are clear and conventional
|
|
126
|
+
Naming/AccessorMethodName:
|
|
127
|
+
Enabled: false
|
|
128
|
+
|
|
129
|
+
# has_tool_calls? and similar are clear and conventional
|
|
130
|
+
Naming/PredicatePrefix:
|
|
131
|
+
Enabled: false
|
|
132
|
+
|
|
133
|
+
# Test helper methods don't need to follow predicate naming rules
|
|
134
|
+
Naming/PredicateMethod:
|
|
135
|
+
Exclude:
|
|
136
|
+
- 'test/**/*'
|
|
137
|
+
|
|
138
|
+
# ── Lint: relax noisy cops on intentional patterns ─────────────────────────
|
|
139
|
+
Lint/EmptyBlock:
|
|
140
|
+
Exclude:
|
|
141
|
+
- 'test/**/*'
|
|
142
|
+
|
|
143
|
+
# Library and framework methods commonly accept args for API/documentation purposes
|
|
144
|
+
Lint/UnusedMethodArgument:
|
|
145
|
+
Enabled: false
|
|
146
|
+
|
|
147
|
+
Lint/ConstantDefinitionInBlock:
|
|
148
|
+
Exclude:
|
|
149
|
+
- 'Rakefile'
|
|
150
|
+
- 'test/**/*'
|
|
151
|
+
|
|
152
|
+
# ── Gemspec ────────────────────────────────────────────────────────────────
|
|
153
|
+
# All 5 sqa gem repos declare dev deps directly in the gemspec (not a Gemfile
|
|
154
|
+
# group) — the opposite convention from robot_lab_project, so match reality.
|
|
155
|
+
Gemspec/DevelopmentDependencies:
|
|
156
|
+
EnforcedStyle: gemspec
|
|
157
|
+
|
|
158
|
+
Gemspec/RequiredRubyVersion:
|
|
159
|
+
Enabled: false
|
|
160
|
+
|
|
161
|
+
Gemspec/OrderedDependencies:
|
|
162
|
+
Enabled: false
|
|
163
|
+
|
|
164
|
+
# ── Metrics ────────────────────────────────────────────────────────────────
|
|
165
|
+
# Flog is the primary complexity gate (see repo_dev.loki flog_check) — these
|
|
166
|
+
# RuboCop thresholds catch only egregious outliers without duplicating flog's
|
|
167
|
+
# more precise per-method scoring.
|
|
168
|
+
|
|
169
|
+
Metrics/MethodLength:
|
|
170
|
+
Max: 35
|
|
171
|
+
CountAsOne:
|
|
172
|
+
- heredoc
|
|
173
|
+
- array
|
|
174
|
+
- hash
|
|
175
|
+
Exclude:
|
|
176
|
+
- 'test/**/*'
|
|
177
|
+
- 'bin/**/*'
|
|
178
|
+
|
|
179
|
+
Metrics/AbcSize:
|
|
180
|
+
Max: 40
|
|
181
|
+
Exclude:
|
|
182
|
+
- 'test/**/*'
|
|
183
|
+
- 'bin/**/*'
|
|
184
|
+
|
|
185
|
+
Metrics/ClassLength:
|
|
186
|
+
Max: 650 # matches robot_lab_project: central orchestrator classes are legitimately large
|
|
187
|
+
Exclude:
|
|
188
|
+
- 'test/**/*'
|
|
189
|
+
- 'bin/**/*'
|
|
190
|
+
|
|
191
|
+
Metrics/ModuleLength:
|
|
192
|
+
Max: 200
|
|
193
|
+
Exclude:
|
|
194
|
+
- 'test/**/*'
|
|
195
|
+
- 'bin/**/*'
|
|
196
|
+
# Many independent thin TA-Lib indicator wrappers — naturally long by breadth, not complexity
|
|
197
|
+
- 'lib/sqa/tai/pattern_recognition.rb'
|
|
198
|
+
- 'lib/sqa/tai/momentum_indicators.rb'
|
|
199
|
+
# Cohesive groups of route helpers extracted during the flog complexity pass
|
|
200
|
+
- 'lib/sqa_demo/sinatra/helpers/api_helpers.rb'
|
|
201
|
+
- 'lib/sqa_demo/sinatra/helpers/stock_loader.rb'
|
|
202
|
+
|
|
203
|
+
Metrics/CyclomaticComplexity:
|
|
204
|
+
Max: 20
|
|
205
|
+
Exclude:
|
|
206
|
+
- 'test/**/*'
|
|
207
|
+
- 'bin/**/*'
|
|
208
|
+
|
|
209
|
+
Metrics/PerceivedComplexity:
|
|
210
|
+
Max: 20
|
|
211
|
+
Exclude:
|
|
212
|
+
- 'test/**/*'
|
|
213
|
+
- 'bin/**/*'
|
|
214
|
+
|
|
215
|
+
# Long method signatures with keyword args are common in this codebase
|
|
216
|
+
Metrics/ParameterLists:
|
|
217
|
+
Enabled: false
|
|
218
|
+
|
|
219
|
+
Metrics/BlockLength:
|
|
220
|
+
Exclude:
|
|
221
|
+
- 'Rakefile'
|
|
222
|
+
- '*.gemspec'
|
|
223
|
+
- 'test/**/*'
|
|
224
|
+
- 'bin/**/*'
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-09-20
|
|
4
|
+
|
|
5
|
+
Initial release. Ported from the `bayesian_inference` prototype in
|
|
6
|
+
`experiments/ai_misc/` into the SQA workspace under the `SQA::BI`
|
|
7
|
+
namespace.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `SQA::BI::Prior` — prior distributions over discrete outcomes, with
|
|
12
|
+
Laplace smoothing, weighted combination, and entropy.
|
|
13
|
+
- `SQA::BI::Likelihood` — Gaussian kernel density estimation of
|
|
14
|
+
P(features | outcome) from historical observations.
|
|
15
|
+
- `SQA::BI::Posterior` — Bayes' theorem, plus entropy, confidence,
|
|
16
|
+
KL divergence from the prior, MAP estimate, and sampling.
|
|
17
|
+
- `SQA::BI::TimeSeriesPredictor` — the main `train` / `predict` interface.
|
|
18
|
+
- `SQA::BI::LlmPriorElicitor` — an LLM supplies the prior from a
|
|
19
|
+
natural-language description of the situation.
|
|
20
|
+
- `SQA::BI::LlmLikelihoodEstimator` — an LLM acts as a likelihood
|
|
21
|
+
function over textual evidence; Ruby chains the updates.
|
|
22
|
+
- `SQA::BI::LlmSupport` — provider resolution (LM Studio, Apfel, cloud),
|
|
23
|
+
JSON extraction, re-keying, normalization, and clamping.
|
|
24
|
+
- Examples `01`–`05`, including a market prediction demo that bridges
|
|
25
|
+
`SQA::DataFrame`.
|
|
26
|
+
|
|
27
|
+
### Changed from the prototype
|
|
28
|
+
|
|
29
|
+
- Namespace `BayesianInference` → `SQA::BI`; entry point `require "sqa/bi"`.
|
|
30
|
+
- Environment overrides are now `SQA_BI_LLM_PROVIDER` / `SQA_BI_LLM_MODEL`.
|
|
31
|
+
The unprefixed `BI_LLM_*` names are still honored as a fallback.
|
|
32
|
+
- Adopted the workspace quality gates (RuboCop, Flog, Flay, Reek,
|
|
33
|
+
SimpleCov) and the `asgard` / direnv bundle-mode conventions.
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
Guidance for Claude Code (claude.ai/code) working in this repository.
|
|
4
|
+
The workspace-level `sqa_project/CLAUDE.md` covers cross-repo structure,
|
|
5
|
+
bundle mode, and the shared quality gates; this file covers what is
|
|
6
|
+
specific to `sqa-bi`.
|
|
7
|
+
|
|
8
|
+
## What this gem is
|
|
9
|
+
|
|
10
|
+
`SQA::BI` does Bayesian inference over a small ordered set of discrete
|
|
11
|
+
outcomes (typically `[-2, -1, 0, 1, 2]`) given a numeric feature vector.
|
|
12
|
+
Prior × likelihood → posterior, where the likelihood is a Gaussian kernel
|
|
13
|
+
density estimate over historical observations. The posterior reports
|
|
14
|
+
entropy, confidence, KL divergence from the prior, MAP, and sampling.
|
|
15
|
+
|
|
16
|
+
**The core math is domain-agnostic — it knows nothing about markets.**
|
|
17
|
+
Keep it that way. Market-facing code belongs in `sqa`, or in the examples.
|
|
18
|
+
|
|
19
|
+
## Dependency position — this is a LEAF
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
sqa-tai ─┐
|
|
23
|
+
sqa-bi ─┴→ sqa → sqa-cli / sqa-advisor / sqa-rails / sqa-sinatra
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`sqa-bi` has **no runtime dependencies at all** and deliberately does
|
|
27
|
+
**not** depend on `sqa` — it sits beside `sqa-tai` so that `sqa` can
|
|
28
|
+
depend on IT. Do not add a `sqa` dependency to the gemspec; that would
|
|
29
|
+
invert the graph and create a cycle the moment `sqa` picks this gem up.
|
|
30
|
+
|
|
31
|
+
`examples/03_stock_market_prediction_v2.rb` does need `sqa`, and gets it
|
|
32
|
+
from `Gemfile.local` (`gem "sqa", path: "../sqa"`) in dev bundle mode
|
|
33
|
+
only. Run it with `asgard dev` active at the workspace root.
|
|
34
|
+
|
|
35
|
+
### The ruby_llm resolution, since it looks like a conflict
|
|
36
|
+
|
|
37
|
+
`sqa` → `shared_tools` → `ruby_llm-mcp`, which pins `ruby_llm ~> 1.9`,
|
|
38
|
+
while `sqa` itself and the local provider gems want `ruby_llm >= 2.0`.
|
|
39
|
+
Bundler resolves this by backing `shared_tools` down to 0.2.3, which has
|
|
40
|
+
no `ruby_llm-mcp` dependency — the same resolution `sqa`'s own
|
|
41
|
+
`Gemfile.local.lock` lands on. Verified: `Gemfile.local` here resolves
|
|
42
|
+
`sqa 0.4.0` + `ruby_llm 2.0.0` + `shared_tools 0.2.3`, and example 03
|
|
43
|
+
runs end to end. If a future `shared_tools` release drops the
|
|
44
|
+
`ruby_llm-mcp` pin, this note becomes moot.
|
|
45
|
+
|
|
46
|
+
## The LLM design rule
|
|
47
|
+
|
|
48
|
+
> **The LLM judges. Ruby computes.**
|
|
49
|
+
|
|
50
|
+
Ask the LLM only for isolated, independent judgments — a relative weight,
|
|
51
|
+
a single conditional probability. Never ask it to accumulate, normalize,
|
|
52
|
+
or update beliefs; that is Bayes' job, done in Ruby. Every change to
|
|
53
|
+
`LlmPriorElicitor` or `LlmLikelihoodEstimator` must preserve this split.
|
|
54
|
+
|
|
55
|
+
Consequences already baked in, don't remove them:
|
|
56
|
+
|
|
57
|
+
- `ruby_llm` is required **lazily** inside `LlmSupport.build_chat`, so
|
|
58
|
+
the core math library loads and the KDE path works without it. It is a
|
|
59
|
+
development dependency only.
|
|
60
|
+
- Both LLM classes accept an injectable `chat:` object; `FakeChat` in
|
|
61
|
+
`test/test_helper.rb` keeps the suite at zero network calls. Keep it
|
|
62
|
+
that way — no test may hit a real provider.
|
|
63
|
+
- Likelihoods are clamped to `[0.001, 0.999]` (Cromwell's rule) so an
|
|
64
|
+
overconfident model can never zero out a hypothesis in one step.
|
|
65
|
+
- `LlmSupport` methods are all `module_function` so each is testable in
|
|
66
|
+
isolation.
|
|
67
|
+
|
|
68
|
+
Provider resolution is local-first: LM Studio → Apfel → cloud. Override
|
|
69
|
+
with `SQA_BI_LLM_PROVIDER` / `SQA_BI_LLM_MODEL`; the unprefixed
|
|
70
|
+
`BI_LLM_*` names from before the workspace move are honored as a
|
|
71
|
+
fallback (`LlmSupport.env_value`).
|
|
72
|
+
|
|
73
|
+
**The fallback to cloud is silent**, and that has already cost debugging
|
|
74
|
+
time once: LM Studio's desktop app running is not the same as its server
|
|
75
|
+
running (`lms status` → `lms server start`), and a server with only
|
|
76
|
+
embedding models loaded resolves to no chat model at all. Either way
|
|
77
|
+
resolution drops to cloud, hits `CLOUD_DEFAULT_MODEL`
|
|
78
|
+
(`claude-haiku-4-5`), and surfaces as an Anthropic 401 rather than
|
|
79
|
+
anything mentioning LM Studio. `LlmSupport.current_resolution` exists to
|
|
80
|
+
make that visible, and examples 04/05 print it before their first call —
|
|
81
|
+
keep that, and prefer it to adding warnings inside the library.
|
|
82
|
+
|
|
83
|
+
## Quality gates
|
|
84
|
+
|
|
85
|
+
Standard workspace setup — `asgard quality` runs tests+coverage, Flog,
|
|
86
|
+
Flay, and Reek. Notes specific to this repo:
|
|
87
|
+
|
|
88
|
+
- `.quality/reek_baseline.txt` grandfathers **11** smells across 5 files,
|
|
89
|
+
all deliberate:
|
|
90
|
+
- FeatureEnvy in the `reduce`-based `Prior#entropy`,
|
|
91
|
+
`Posterior#entropy`, `#kl_divergence_from_prior`, and
|
|
92
|
+
`Likelihood#euclidean_distance`.
|
|
93
|
+
- TooManyStatements in `configure_ruby_llm` and `compute_posterior`.
|
|
94
|
+
- ControlParameter in `LlmSupport.local_api_base` and
|
|
95
|
+
`.resolution_label` — both are small lookup/format functions where
|
|
96
|
+
branching on the argument *is* the function.
|
|
97
|
+
- BooleanParameter / ControlParameter on `TimeSeriesPredictor`'s
|
|
98
|
+
`update_prior:` and `reset!(keep_prior:)` — API shape, not accidents.
|
|
99
|
+
|
|
100
|
+
Regenerate with `asgard reek_baseline` after a real improvement. Note
|
|
101
|
+
the counting subtlety if you ever hand-edit the file: reek prints
|
|
102
|
+
"1 warning:" (singular) for single-smell files, so grepping for
|
|
103
|
+
"warnings:" silently drops them — derive counts from
|
|
104
|
+
`Reek::Examiner`, the way `rake reek_check` does.
|
|
105
|
+
- `SQA::BI::Posterior#summary` sits at Flog 21.2 — above the warn
|
|
106
|
+
threshold, below the fail threshold. It is a formatting heredoc.
|
|
107
|
+
- `.rubocop.yml` is generated from the workspace `.rubocop.yml.common`.
|
|
108
|
+
Edit that and run `asgard sync_rubocop`; don't edit this repo's copy.
|
|
109
|
+
|
|
110
|
+
## History and open threads
|
|
111
|
+
|
|
112
|
+
Ported 2026-09-20 from the `bayesian_inference` prototype in
|
|
113
|
+
`~/sandbox/git_repos/madbomber/experiments/ai_misc/`. The running
|
|
114
|
+
investigation log is `decision_support_techniques.md` in this repo —
|
|
115
|
+
read it before proposing a different inference engine, since the
|
|
116
|
+
tree-ensemble (`eps`/LightGBM) and Laya typed-decision routes were each
|
|
117
|
+
evaluated there and set aside for recorded reasons.
|
|
118
|
+
|
|
119
|
+
Open, per that log:
|
|
120
|
+
|
|
121
|
+
- Multi-horizon prediction (k = 1…10), sharing strength across horizons
|
|
122
|
+
rather than fitting each independently. `TimeSeriesPredictor` is
|
|
123
|
+
single-horizon today.
|
|
124
|
+
- A Laya sidecar as an alternative likelihood backend behind
|
|
125
|
+
`LlmSupport`'s provider dispatch, benchmarked on latency and ECE.
|
|
126
|
+
- `eps`/LightGBM kept as a **benchmark** to score the posterior against,
|
|
127
|
+
not as a replacement engine.
|
|
128
|
+
- Research JEV properly before it influences any design decision.
|
data/COMMITS.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
url: https://www.conventionalcommits.org/en/v1.0.0/
|
|
3
|
+
title: Conventional Commits
|
|
4
|
+
description: A specification for adding human and machine readable meaning to commit messages
|
|
5
|
+
access_date: 2025-07-31T20:51:29.000Z
|
|
6
|
+
current_date: 2025-07-31T20:51:29.601Z
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Conventional Commits
|
|
10
|
+
|
|
11
|
+
A specification for adding human and machine readable meaning to commit messages
|
|
12
|
+
|
|
13
|
+
Quick Summary Full Specification Contribute
|
|
14
|
+
|
|
15
|
+
# Conventional Commits 1.0.0
|
|
16
|
+
|
|
17
|
+
## Summary
|
|
18
|
+
|
|
19
|
+
The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.
|
|
20
|
+
|
|
21
|
+
The commit message should be structured as follows:
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
<type>[optional scope]: <description>
|
|
27
|
+
|
|
28
|
+
[optional body]
|
|
29
|
+
|
|
30
|
+
[optional footer(s)]
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
The commit contains the following structural elements, to communicate intent to the consumers of your library:
|
|
37
|
+
|
|
38
|
+
1. **fix:** a commit of the _type_ `fix` patches a bug in your codebase (this correlates with `PATCH` in Semantic Versioning).
|
|
39
|
+
2. **feat:** a commit of the _type_ `feat` introduces a new feature to the codebase (this correlates with `MINOR` in Semantic Versioning).
|
|
40
|
+
3. **BREAKING CHANGE:** a commit that has a footer `BREAKING CHANGE:`, or appends a `!` after the type/scope, introduces a breaking API change (correlating with `MAJOR` in Semantic Versioning). A BREAKING CHANGE can be part of commits of any _type_.
|
|
41
|
+
4. _types_ other than `fix:` and `feat:` are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends `build:`, `chore:`,`ci:`, `docs:`, `style:`, `refactor:`, `perf:`, `test:`, and others.
|
|
42
|
+
5. _footers_ other than `BREAKING CHANGE: <description>` may be provided and follow a convention similar to git trailer format.
|
|
43
|
+
|
|
44
|
+
Additional types are not mandated by the Conventional Commits specification, and have no implicit effect in Semantic Versioning (unless they include a BREAKING CHANGE). A scope may be provided to a commit’s type, to provide additional contextual information and is contained within parenthesis, e.g., `feat(parser): add ability to parse arrays`.
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Commit message with description and breaking change footer
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
feat: allow provided config object to extend other configs
|
|
52
|
+
|
|
53
|
+
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Commit message with `!` to draw attention to breaking change
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
feat!: send an email to the customer when a product is shipped
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Commit message with scope and `!` to draw attention to breaking change
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
feat(api)!: send an email to the customer when a product is shipped
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Commit message with both `!` and BREAKING CHANGE footer
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
chore!: drop support for Node 6
|
|
75
|
+
|
|
76
|
+
BREAKING CHANGE: use JavaScript features not available in Node 6.
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Commit message with no body
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
docs: correct spelling of CHANGELOG
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Commit message with scope
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
feat(lang): add Polish language
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Commit message with multi-paragraph body and multiple footers
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
fix: prevent racing of requests
|
|
98
|
+
|
|
99
|
+
Introduce a request id and a reference to latest request. Dismiss
|
|
100
|
+
incoming responses other than from latest request.
|
|
101
|
+
|
|
102
|
+
Remove timeouts which were used to mitigate the racing issue but are
|
|
103
|
+
obsolete now.
|
|
104
|
+
|
|
105
|
+
Reviewed-by: Z
|
|
106
|
+
Refs: #123
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Specification
|
|
111
|
+
|
|
112
|
+
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
|
|
113
|
+
|
|
114
|
+
1. Commits MUST be prefixed with a type, which consists of a noun, `feat`, `fix`, etc., followed by the OPTIONAL scope, OPTIONAL `!`, and REQUIRED terminal colon and space.
|
|
115
|
+
2. The type `feat` MUST be used when a commit adds a new feature to your application or library.
|
|
116
|
+
3. The type `fix` MUST be used when a commit represents a bug fix for your application.
|
|
117
|
+
4. A scope MAY be provided after a type. A scope MUST consist of a noun describing a section of the codebase surrounded by parenthesis, e.g., `fix(parser):`
|
|
118
|
+
5. A description MUST immediately follow the colon and space after the type/scope prefix. The description is a short summary of the code changes, e.g., _fix: array parsing issue when multiple spaces were contained in string_.
|
|
119
|
+
6. A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.
|
|
120
|
+
7. A commit body is free-form and MAY consist of any number of newline separated paragraphs.
|
|
121
|
+
8. One or more footers MAY be provided one blank line after the body. Each footer MUST consist of a word token, followed by either a `:<space>` or `<space>#` separator, followed by a string value (this is inspired by the git trailer convention).
|
|
122
|
+
9. A footer’s token MUST use `-` in place of whitespace characters, e.g., `Acked-by` (this helps differentiate the footer section from a multi-paragraph body). An exception is made for `BREAKING CHANGE`, which MAY also be used as a token.
|
|
123
|
+
10. A footer’s value MAY contain spaces and newlines, and parsing MUST terminate when the next valid footer token/separator pair is observed.
|
|
124
|
+
11. Breaking changes MUST be indicated in the type/scope prefix of a commit, or as an entry in the footer.
|
|
125
|
+
12. If included as a footer, a breaking change MUST consist of the uppercase text BREAKING CHANGE, followed by a colon, space, and description, e.g.,_BREAKING CHANGE: environment variables now take precedence over config files_.
|
|
126
|
+
13. If included in the type/scope prefix, breaking changes MUST be indicated by a`!` immediately before the `:`. If `!` is used, `BREAKING CHANGE:` MAY be omitted from the footer section, and the commit description SHALL be used to describe the breaking change.
|
|
127
|
+
14. Types other than `feat` and `fix` MAY be used in your commit messages, e.g., _docs: update ref docs._
|
|
128
|
+
15. The units of information that make up Conventional Commits MUST NOT be treated as case sensitive by implementors, with the exception of BREAKING CHANGE which MUST be uppercase.
|
|
129
|
+
16. BREAKING-CHANGE MUST be synonymous with BREAKING CHANGE, when used as a token in a footer.
|
|
130
|
+
|
|
131
|
+
## Why Use Conventional Commits
|
|
132
|
+
|
|
133
|
+
* Automatically generating CHANGELOGs.
|
|
134
|
+
* Automatically determining a semantic version bump (based on the types of commits landed).
|
|
135
|
+
* Communicating the nature of changes to teammates, the public, and other stakeholders.
|
|
136
|
+
* Triggering build and publish processes.
|
|
137
|
+
* Making it easier for people to contribute to your projects, by allowing them to explore a more structured commit history.
|
|
138
|
+
|
|
139
|
+
## FAQ
|
|
140
|
+
|
|
141
|
+
### How should I deal with commit messages in the initial development phase?
|
|
142
|
+
|
|
143
|
+
We recommend that you proceed as if you’ve already released the product. Typically _somebody_, even if it’s your fellow software developers, is using your software. They’ll want to know what’s fixed, what breaks etc.
|
|
144
|
+
|
|
145
|
+
### Are the types in the commit title uppercase or lowercase?
|
|
146
|
+
|
|
147
|
+
Any casing may be used, but it’s best to be consistent.
|
|
148
|
+
|
|
149
|
+
### What do I do if the commit conforms to more than one of the commit types?
|
|
150
|
+
|
|
151
|
+
Go back and make multiple commits whenever possible. Part of the benefit of Conventional Commits is its ability to drive us to make more organized commits and PRs.
|
|
152
|
+
|
|
153
|
+
### Doesn’t this discourage rapid development and fast iteration?
|
|
154
|
+
|
|
155
|
+
It discourages moving fast in a disorganized way. It helps you be able to move fast long term across multiple projects with varied contributors.
|
|
156
|
+
|
|
157
|
+
### Might Conventional Commits lead developers to limit the type of commits they make because they’ll be thinking in the types provided?
|
|
158
|
+
|
|
159
|
+
Conventional Commits encourages us to make more of certain types of commits such as fixes. Other than that, the flexibility of Conventional Commits allows your team to come up with their own types and change those types over time.
|
|
160
|
+
|
|
161
|
+
### How does this relate to SemVer?
|
|
162
|
+
|
|
163
|
+
`fix` type commits should be translated to `PATCH` releases. `feat` type commits should be translated to `MINOR` releases. Commits with `BREAKING CHANGE` in the commits, regardless of type, should be translated to `MAJOR` releases.
|
|
164
|
+
|
|
165
|
+
### How should I version my extensions to the Conventional Commits Specification, e.g. `@jameswomack/conventional-commit-spec`?
|
|
166
|
+
|
|
167
|
+
We recommend using SemVer to release your own extensions to this specification (and encourage you to make these extensions!)
|
|
168
|
+
|
|
169
|
+
### What do I do if I accidentally use the wrong commit type?
|
|
170
|
+
|
|
171
|
+
#### When you used a type that’s of the spec but not the correct type, e.g. `fix` instead of `feat`
|
|
172
|
+
|
|
173
|
+
Prior to merging or releasing the mistake, we recommend using `git rebase -i` to edit the commit history. After release, the cleanup will be different according to what tools and processes you use.
|
|
174
|
+
|
|
175
|
+
#### When you used a type _not_ of the spec, e.g. `feet` instead of `feat`
|
|
176
|
+
|
|
177
|
+
In a worst case scenario, it’s not the end of the world if a commit lands that does not meet the Conventional Commits specification. It simply means that commit will be missed by tools that are based on the spec.
|
|
178
|
+
|
|
179
|
+
### Do all my contributors need to use the Conventional Commits specification?
|
|
180
|
+
|
|
181
|
+
No! If you use a squash based workflow on Git lead maintainers can clean up the commit messages as they’re merged—adding no workload to casual committers. A common workflow for this is to have your git system automatically squash commits from a pull request and present a form for the lead maintainer to enter the proper git commit message for the merge.
|
|
182
|
+
|
|
183
|
+
### How does Conventional Commits handle revert commits?
|
|
184
|
+
|
|
185
|
+
Reverting code can be complicated: are you reverting multiple commits? if you revert a feature, should the next release instead be a patch?
|
|
186
|
+
|
|
187
|
+
Conventional Commits does not make an explicit effort to define revert behavior. Instead we leave it to tooling authors to use the flexibility of _types_ and _footers_ to develop their logic for handling reverts.
|
|
188
|
+
|
|
189
|
+
One recommendation is to use the `revert` type, and a footer that references the commit SHAs that are being reverted:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
revert: let us never again speak of the noodle incident
|
|
193
|
+
|
|
194
|
+
Refs: 676104e, a215868
|
|
195
|
+
|
|
196
|
+
```
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dewayne VanHoozer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|