songe 0.0.0.dev0__tar.gz → 0.1.0a4__tar.gz

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.
Files changed (178) hide show
  1. songe-0.1.0a4/.github/ci/platform_checks.py +67 -0
  2. songe-0.1.0a4/.gitignore +10 -0
  3. songe-0.1.0a4/PKG-INFO +155 -0
  4. songe-0.1.0a4/README.md +97 -0
  5. songe-0.1.0a4/docs/RELEASING.md +221 -0
  6. songe-0.1.0a4/packaging/homebrew/bump-formula.yml +45 -0
  7. songe-0.1.0a4/packaging/homebrew/songe.rb +456 -0
  8. songe-0.1.0a4/packaging/homebrew/test_update_formula.py +233 -0
  9. songe-0.1.0a4/packaging/homebrew/update_formula.py +288 -0
  10. songe-0.1.0a4/pyproject.toml +111 -0
  11. songe-0.1.0a4/src/songe/__init__.py +7 -0
  12. songe-0.1.0a4/src/songe/__main__.py +3 -0
  13. songe-0.1.0a4/src/songe/agents/__init__.py +323 -0
  14. songe-0.1.0a4/src/songe/agents/opencode.py +105 -0
  15. songe-0.1.0a4/src/songe/agents/pi.py +46 -0
  16. songe-0.1.0a4/src/songe/api.py +807 -0
  17. songe-0.1.0a4/src/songe/artifacts/__init__.py +204 -0
  18. songe-0.1.0a4/src/songe/artifacts/runtime.py +111 -0
  19. songe-0.1.0a4/src/songe/artifacts/storage.py +352 -0
  20. songe-0.1.0a4/src/songe/artifacts/tools.py +253 -0
  21. songe-0.1.0a4/src/songe/artifacts/worker.py +84 -0
  22. songe-0.1.0a4/src/songe/backends/__init__.py +58 -0
  23. songe-0.1.0a4/src/songe/backends/install.py +216 -0
  24. songe-0.1.0a4/src/songe/backends/mlx.py +631 -0
  25. songe-0.1.0a4/src/songe/backends/objective.py +49 -0
  26. songe-0.1.0a4/src/songe/backends/reference.py +48 -0
  27. songe-0.1.0a4/src/songe/backends/torch.py +810 -0
  28. songe-0.1.0a4/src/songe/backends/training.py +208 -0
  29. songe-0.1.0a4/src/songe/child.py +131 -0
  30. songe-0.1.0a4/src/songe/cli.py +988 -0
  31. songe-0.1.0a4/src/songe/config.py +308 -0
  32. songe-0.1.0a4/src/songe/experience.py +46 -0
  33. songe-0.1.0a4/src/songe/interface_copy.py +35 -0
  34. songe-0.1.0a4/src/songe/launchd.py +52 -0
  35. songe-0.1.0a4/src/songe/learning_summary.py +306 -0
  36. songe-0.1.0a4/src/songe/log.py +1073 -0
  37. songe-0.1.0a4/src/songe/memory.py +861 -0
  38. songe-0.1.0a4/src/songe/models/__init__.py +22 -0
  39. songe-0.1.0a4/src/songe/models/convert.py +201 -0
  40. songe-0.1.0a4/src/songe/models/discovery.py +367 -0
  41. songe-0.1.0a4/src/songe/models/gguf.py +56 -0
  42. songe-0.1.0a4/src/songe/models/library.py +516 -0
  43. songe-0.1.0a4/src/songe/models/names.py +43 -0
  44. songe-0.1.0a4/src/songe/models/registry.py +418 -0
  45. songe-0.1.0a4/src/songe/models/worker.py +60 -0
  46. songe-0.1.0a4/src/songe/panels.py +238 -0
  47. songe-0.1.0a4/src/songe/pipeline.py +120 -0
  48. songe-0.1.0a4/src/songe/platform/__init__.py +125 -0
  49. songe-0.1.0a4/src/songe/platform/common.py +125 -0
  50. songe-0.1.0a4/src/songe/platform/darwin.py +206 -0
  51. songe-0.1.0a4/src/songe/platform/linux.py +344 -0
  52. songe-0.1.0a4/src/songe/platform/locking.py +21 -0
  53. songe-0.1.0a4/src/songe/platform/services.py +396 -0
  54. songe-0.1.0a4/src/songe/platform/windows.py +156 -0
  55. songe-0.1.0a4/src/songe/proxy.py +501 -0
  56. songe-0.1.0a4/src/songe/review.py +145 -0
  57. songe-0.1.0a4/src/songe/schedule.py +1312 -0
  58. songe-0.1.0a4/src/songe/sleep/__init__.py +1 -0
  59. songe-0.1.0a4/src/songe/sleep/anchors.json +152 -0
  60. songe-0.1.0a4/src/songe/sleep/calibrate.py +911 -0
  61. songe-0.1.0a4/src/songe/sleep/calibration_state.py +306 -0
  62. songe-0.1.0a4/src/songe/sleep/clean.py +82 -0
  63. songe-0.1.0a4/src/songe/sleep/cleanup.py +180 -0
  64. songe-0.1.0a4/src/songe/sleep/compat.py +114 -0
  65. songe-0.1.0a4/src/songe/sleep/distill.py +11 -0
  66. songe-0.1.0a4/src/songe/sleep/evaluate.py +163 -0
  67. songe-0.1.0a4/src/songe/sleep/fuse.py +283 -0
  68. songe-0.1.0a4/src/songe/sleep/fuse_worker.py +21 -0
  69. songe-0.1.0a4/src/songe/sleep/gate.py +108 -0
  70. songe-0.1.0a4/src/songe/sleep/lessons.py +328 -0
  71. songe-0.1.0a4/src/songe/sleep/measurement.py +72 -0
  72. songe-0.1.0a4/src/songe/sleep/probe.py +218 -0
  73. songe-0.1.0a4/src/songe/sleep/prompts.py +122 -0
  74. songe-0.1.0a4/src/songe/sleep/recovery.py +148 -0
  75. songe-0.1.0a4/src/songe/sleep/retention.py +49 -0
  76. songe-0.1.0a4/src/songe/sleep/samples.py +159 -0
  77. songe-0.1.0a4/src/songe/sleep/select.py +63 -0
  78. songe-0.1.0a4/src/songe/sleep/sizing.py +399 -0
  79. songe-0.1.0a4/src/songe/sleep/swap.py +134 -0
  80. songe-0.1.0a4/src/songe/sleep/worker.py +1012 -0
  81. songe-0.1.0a4/src/songe/status.py +369 -0
  82. songe-0.1.0a4/src/songe/steps.py +358 -0
  83. songe-0.1.0a4/src/songe/storage.py +129 -0
  84. songe-0.1.0a4/src/songe/telemetry.py +99 -0
  85. songe-0.1.0a4/src/songe/terminal.py +126 -0
  86. songe-0.1.0a4/src/songe/tui.py +276 -0
  87. songe-0.1.0a4/src/songe/ui/app.js +634 -0
  88. songe-0.1.0a4/src/songe/ui/index.html +37 -0
  89. songe-0.1.0a4/src/songe/ui/outfit-OFL.txt +93 -0
  90. songe-0.1.0a4/src/songe/ui/outfit.woff2 +0 -0
  91. songe-0.1.0a4/src/songe/ui/style.css +154 -0
  92. songe-0.1.0a4/src/songe/ui/syne-OFL.txt +93 -0
  93. songe-0.1.0a4/src/songe/ui/syne.woff2 +0 -0
  94. songe-0.1.0a4/src/songe/upgrade.py +305 -0
  95. songe-0.1.0a4/src/songe/upstream/__init__.py +51 -0
  96. songe-0.1.0a4/src/songe/upstream/cleanup.py +143 -0
  97. songe-0.1.0a4/src/songe/upstream/llamacpp.py +263 -0
  98. songe-0.1.0a4/src/songe/upstream/lmstudio.py +458 -0
  99. songe-0.1.0a4/src/songe/upstream/mlx.py +215 -0
  100. songe-0.1.0a4/src/songe/upstream/ollama.py +331 -0
  101. songe-0.1.0a4/src/songe/upstream/protection.py +184 -0
  102. songe-0.1.0a4/src/songe/upstream/reuse.py +42 -0
  103. songe-0.1.0a4/src/songe/upstream/supervisor.py +293 -0
  104. songe-0.1.0a4/src/songe/upstream/vllm.py +176 -0
  105. songe-0.1.0a4/src/songe/wording.py +384 -0
  106. songe-0.1.0a4/tests/__init__.py +0 -0
  107. songe-0.1.0a4/tests/conftest.py +93 -0
  108. songe-0.1.0a4/tests/crossplatform_helpers.py +96 -0
  109. songe-0.1.0a4/tests/crossplatform_smoke.py +223 -0
  110. songe-0.1.0a4/tests/fixtures/wording.json +909 -0
  111. songe-0.1.0a4/tests/snapshots/cli_error.txt +2 -0
  112. songe-0.1.0a4/tests/snapshots/cli_idle.txt +20 -0
  113. songe-0.1.0a4/tests/snapshots/cli_init.txt +10 -0
  114. songe-0.1.0a4/tests/snapshots/cli_learning.txt +21 -0
  115. songe-0.1.0a4/tests/snapshots/cli_library.txt +23 -0
  116. songe-0.1.0a4/tests/snapshots/cli_models.txt +6 -0
  117. songe-0.1.0a4/tests/snapshots/cli_undo.txt +1 -0
  118. songe-0.1.0a4/tests/snapshots/cli_uninstall.txt +3 -0
  119. songe-0.1.0a4/tests/test_accelerator_telemetry.py +1 -0
  120. songe-0.1.0a4/tests/test_agents.py +172 -0
  121. songe-0.1.0a4/tests/test_api.py +354 -0
  122. songe-0.1.0a4/tests/test_artifacts.py +320 -0
  123. songe-0.1.0a4/tests/test_backend_contract.py +52 -0
  124. songe-0.1.0a4/tests/test_clean.py +223 -0
  125. songe-0.1.0a4/tests/test_cli.py +225 -0
  126. songe-0.1.0a4/tests/test_cli_output.py +369 -0
  127. songe-0.1.0a4/tests/test_compat.py +116 -0
  128. songe-0.1.0a4/tests/test_context_distillation.py +321 -0
  129. songe-0.1.0a4/tests/test_core_learning.py +325 -0
  130. songe-0.1.0a4/tests/test_crossplatform_upstreams.py +368 -0
  131. songe-0.1.0a4/tests/test_dashboard.py +572 -0
  132. songe-0.1.0a4/tests/test_data_cycles.py +423 -0
  133. songe-0.1.0a4/tests/test_disk_space.py +489 -0
  134. songe-0.1.0a4/tests/test_gate.py +57 -0
  135. songe-0.1.0a4/tests/test_guard_regressions.py +475 -0
  136. songe-0.1.0a4/tests/test_heavy.py +105 -0
  137. songe-0.1.0a4/tests/test_integration.py +458 -0
  138. songe-0.1.0a4/tests/test_learning.py +148 -0
  139. songe-0.1.0a4/tests/test_learning_levels.py +257 -0
  140. songe-0.1.0a4/tests/test_learning_summary.py +278 -0
  141. songe-0.1.0a4/tests/test_lessons.py +348 -0
  142. songe-0.1.0a4/tests/test_library_retention.py +827 -0
  143. songe-0.1.0a4/tests/test_linux_cgroup.py +189 -0
  144. songe-0.1.0a4/tests/test_lmstudio.py +243 -0
  145. songe-0.1.0a4/tests/test_memory.py +141 -0
  146. songe-0.1.0a4/tests/test_model_discovery.py +273 -0
  147. songe-0.1.0a4/tests/test_model_reuse.py +506 -0
  148. songe-0.1.0a4/tests/test_models.py +663 -0
  149. songe-0.1.0a4/tests/test_network.py +82 -0
  150. songe-0.1.0a4/tests/test_nvidia_telemetry.py +85 -0
  151. songe-0.1.0a4/tests/test_panels.py +210 -0
  152. songe-0.1.0a4/tests/test_partial_calibration.py +691 -0
  153. songe-0.1.0a4/tests/test_platform.py +217 -0
  154. songe-0.1.0a4/tests/test_power.py +338 -0
  155. songe-0.1.0a4/tests/test_pressure_baseline.py +322 -0
  156. songe-0.1.0a4/tests/test_probe.py +123 -0
  157. songe-0.1.0a4/tests/test_proxy.py +360 -0
  158. songe-0.1.0a4/tests/test_registry_order.py +15 -0
  159. songe-0.1.0a4/tests/test_review2.py +865 -0
  160. songe-0.1.0a4/tests/test_review3.py +819 -0
  161. songe-0.1.0a4/tests/test_review_regressions.py +992 -0
  162. songe-0.1.0a4/tests/test_review_replies.py +134 -0
  163. songe-0.1.0a4/tests/test_schedule.py +184 -0
  164. songe-0.1.0a4/tests/test_steps.py +119 -0
  165. songe-0.1.0a4/tests/test_store.py +76 -0
  166. songe-0.1.0a4/tests/test_swap.py +104 -0
  167. songe-0.1.0a4/tests/test_torch_backend.py +463 -0
  168. songe-0.1.0a4/tests/test_training_batches.py +522 -0
  169. songe-0.1.0a4/tests/test_tui.py +318 -0
  170. songe-0.1.0a4/tests/test_undersized_scoring.py +338 -0
  171. songe-0.1.0a4/tests/test_upgrade.py +553 -0
  172. songe-0.1.0a4/tests/test_wording.py +63 -0
  173. songe-0.1.0a4/tests/test_worker.py +234 -0
  174. songe-0.1.0a4/uv.lock +2462 -0
  175. songe-0.0.0.dev0/PKG-INFO +0 -20
  176. songe-0.0.0.dev0/README.md +0 -7
  177. songe-0.0.0.dev0/pyproject.toml +0 -23
  178. songe-0.0.0.dev0/src/songe/__init__.py +0 -7
@@ -0,0 +1,67 @@
1
+ """Report platform gaps without importing unavailable APIs or GPU runtimes.
2
+
3
+ This is test infrastructure only. Remove the Windows exceptions as the platform
4
+ workstream replaces POSIX locks and permission assertions in the existing tests.
5
+ """
6
+
7
+ import importlib
8
+ import importlib.metadata
9
+ import platform
10
+ import sys
11
+ from functools import cache
12
+
13
+ import pytest
14
+
15
+
16
+ @cache
17
+ def metal_unavailable():
18
+ if sys.platform != "darwin" or platform.machine() != "arm64":
19
+ return "Metal tests require an Apple Silicon Mac"
20
+ try:
21
+ mx = importlib.import_module("mlx.core")
22
+ if not mx.metal.is_available():
23
+ return "Metal is unavailable in this session"
24
+ except (ImportError, RuntimeError) as error:
25
+ return f"Metal is unavailable: {error}"
26
+ return None
27
+
28
+
29
+ def module_unavailable(name):
30
+ if name == "test_compat.py":
31
+ return metal_unavailable()
32
+ return None
33
+
34
+
35
+ class UnavailableModule(pytest.Module):
36
+ def collect(self):
37
+ pytest.skip(module_unavailable(self.path.name), allow_module_level=True)
38
+
39
+
40
+ def pytest_pycollect_makemodule(module_path, parent):
41
+ if module_unavailable(module_path.name):
42
+ return UnavailableModule.from_parent(parent, path=module_path)
43
+ return None
44
+
45
+
46
+ def pytest_collection_modifyitems(items):
47
+ try:
48
+ importlib.metadata.version("mlx-lm")
49
+ has_mlx_lm = True
50
+ except importlib.metadata.PackageNotFoundError:
51
+ has_mlx_lm = False
52
+ for item in items:
53
+ if (
54
+ not has_mlx_lm
55
+ and item.name
56
+ == "test_unsupported_and_known_slow_architectures_are_excluded_without_metal"
57
+ ):
58
+ item.add_marker(
59
+ pytest.mark.skip(reason="Requires installed MLX-LM metadata")
60
+ )
61
+ if (
62
+ sys.platform == "win32"
63
+ and item.name == "test_durable_atomic_swap_and_restart"
64
+ ):
65
+ item.add_marker(
66
+ pytest.mark.skip(reason="Existing test asserts POSIX mode 0700")
67
+ )
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ *.egg-info/
8
+ .DS_Store
9
+ .codex-run/
10
+ test-output/
songe-0.1.0a4/PKG-INFO ADDED
@@ -0,0 +1,155 @@
1
+ Metadata-Version: 2.5
2
+ Name: songe
3
+ Version: 0.1.0a4
4
+ Summary: Local hindsight distillation for a model that sleeps.
5
+ Project-URL: Homepage, https://github.com/sous-labs/songe
6
+ Project-URL: Repository, https://github.com/sous-labs/songe
7
+ Project-URL: Issues, https://github.com/sous-labs/songe/issues
8
+ Author: Sous Labs
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: bashlex<1,>=0.18
16
+ Requires-Dist: gguf<1,>=0.19
17
+ Requires-Dist: httpx<1,>=0.28
18
+ Requires-Dist: jsonschema<5,>=4.26
19
+ Requires-Dist: lmstudio<2,>=1.5
20
+ Requires-Dist: mlx-lm<0.33,>=0.32; sys_platform == 'darwin' and platform_machine == 'arm64'
21
+ Requires-Dist: mlx<0.33,>=0.32.4; sys_platform == 'darwin' and platform_machine == 'arm64'
22
+ Requires-Dist: packaging<27,>=24.2
23
+ Requires-Dist: psutil<8,>=5.9
24
+ Requires-Dist: rich<16,>=15
25
+ Requires-Dist: starlette<2,>=0.49
26
+ Requires-Dist: textual<7,>=6.12
27
+ Requires-Dist: uvicorn<1,>=0.38
28
+ Provides-Extra: cuda
29
+ Requires-Dist: accelerate<2,>=1; extra == 'cuda'
30
+ Requires-Dist: bitsandbytes<1,>=0.45; (sys_platform == 'linux' or sys_platform == 'win32') and extra == 'cuda'
31
+ Requires-Dist: nvidia-ml-py>=12; (sys_platform == 'linux' or sys_platform == 'win32') and extra == 'cuda'
32
+ Requires-Dist: peft<1,>=0.21; extra == 'cuda'
33
+ Requires-Dist: protobuf<8,>=5; extra == 'cuda'
34
+ Requires-Dist: safetensors<1,>=0.5; extra == 'cuda'
35
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'cuda'
36
+ Requires-Dist: torch<3,>=2.11; extra == 'cuda'
37
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'cuda'
38
+ Provides-Extra: mlx
39
+ Requires-Dist: mlx-lm<0.33,>=0.32; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'mlx'
40
+ Requires-Dist: mlx<0.33,>=0.32.4; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'mlx'
41
+ Provides-Extra: rocm
42
+ Requires-Dist: accelerate<2,>=1; extra == 'rocm'
43
+ Requires-Dist: peft<1,>=0.21; extra == 'rocm'
44
+ Requires-Dist: protobuf<8,>=5; extra == 'rocm'
45
+ Requires-Dist: safetensors<1,>=0.5; extra == 'rocm'
46
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'rocm'
47
+ Requires-Dist: torch<3,>=2.11; extra == 'rocm'
48
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'rocm'
49
+ Provides-Extra: torch
50
+ Requires-Dist: accelerate<2,>=1; extra == 'torch'
51
+ Requires-Dist: peft<1,>=0.21; extra == 'torch'
52
+ Requires-Dist: protobuf<8,>=5; extra == 'torch'
53
+ Requires-Dist: safetensors<1,>=0.5; extra == 'torch'
54
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'torch'
55
+ Requires-Dist: torch<3,>=2.11; extra == 'torch'
56
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'torch'
57
+ Description-Content-Type: text/markdown
58
+
59
+ # Songe
60
+
61
+ A local model that sleeps.
62
+
63
+ You use your model as usual, through opencode, pi or any OpenAI-compatible tool. When your computer is idle and on power, Songe reads back what happened after each of the model's actions — the tool result, the error, your next message — and teaches the model to anticipate it. After a candidate passes the checks, the same model name serves that version. Nothing leaves your machine.
64
+
65
+ ## How it learns
66
+
67
+ The only new information a local model ever gets is what happened *after* it acted. Given that hindsight, the same model can usually tell what it should have done; without it, it can't. Songe closes that gap:
68
+
69
+ - **Teacher**: the original model, shown the conversation *and* what happened next.
70
+ - **Student**: the model with a small LoRA adapter, shown only the conversation.
71
+ - The student writes its own answers and the teacher scores them token by token (on-policy distillation, as in Google DeepMind's GKD). The student learns where it was wrong, in its own words, so it forgets little.
72
+ - It practises the moments where hindsight changes the teacher's mind most.
73
+ - It continues the current adapter with replay, rebuilding from the original base when experience is forgotten or the base, tools, or accumulated drift require it.
74
+ - A new version is served only if it is measurably better on conversations it never trained on and not measurably worse at general tasks. Otherwise nothing changes.
75
+
76
+ Songe never runs your tools at night. It only reads what already happened.
77
+
78
+ ## Requirements
79
+
80
+ - Apple Silicon with MLX, Linux with NVIDIA or AMD, or Windows with NVIDIA.
81
+ - A locally accessible model served by LM Studio, Ollama, llama.cpp, mlx-lm, or vLLM.
82
+ - Python 3.11 or later for pip installation; Homebrew supplies Python 3.12.
83
+
84
+ Memory and training support are measured on your machine. CPU-only machines can serve and record experience. Calibration must complete before learning starts.
85
+
86
+ ## Install
87
+
88
+ ```sh
89
+ brew install sous-labs/tap/songe
90
+ pip install songe
91
+ songe init
92
+ ```
93
+
94
+ `songe init` finds your model server and agents, shows a short facts list, and asks once. Use `--show-diff` for exact dependency commands and config diffs, or `--yes` to accept the plan in a script. It exposes your models through the Songe provider. Pick a model in your agent as usual; Songe follows each one you use. Training support and memory are measured during idle gaps. `--model PATH` optionally pre-enables a local base. Existing single-model installs retain their versions and undo history.
95
+
96
+ Choose Homebrew or pip, then run `songe init`. These release commands become
97
+ available after the first real PyPI release and creation of the Homebrew tap;
98
+ PyPI's `0.0.0.dev0` package only reserves the name.
99
+
100
+ | Platform | Dependencies | CI scope |
101
+ | --- | --- | --- |
102
+ | macOS Apple Silicon | MLX and MLX-LM install automatically | Python 3.12 tests on `main` and `v*` tags; Metal tests skip when unavailable |
103
+ | Linux NVIDIA / AMD | `init` installs missing training dependencies in its private environment | Ubuntu Python 3.11/3.12 CPU tests; GPU training unverified |
104
+ | Windows NVIDIA | `init` selects PyTorch wheels for the detected driver | Portable locks and services implemented; Windows GPU validation required |
105
+
106
+ The default Linux/Windows install contains the proxy, store, CLI, web assets and
107
+ Textual dependency without an ML framework. Init detects the accelerator and
108
+ plans any missing training stack. CPU tests cover the Torch pipeline; accelerator
109
+ and live server validation still require real hardware.
110
+ See [accelerator installation and CI limits](docs/RELEASING.md#accelerator-installation).
111
+
112
+ ## Use
113
+
114
+ There is nothing to do. When you want to look:
115
+
116
+ ```sh
117
+ songe # where things stand, in one block
118
+ songe open # now, next, models and learning results
119
+ songe models # learning levels, support reasons, and pending data
120
+ songe models MODEL off
121
+ songe models MODEL new
122
+ songe models MODEL all
123
+ songe undo MODEL # restore this model's previous version
124
+ ```
125
+
126
+ Also: `songe pause`, `songe resume`, `songe sleep --now`, `songe forget` (delete what it has seen), `songe uninstall`.
127
+
128
+ ## The dashboard
129
+
130
+ `songe open` starts with `now`, `next`, and `paused`, followed by the Learning switch. They show the current model and work, measured progress and ETA when available, the next action and its condition, or a concrete waiting reason. The models table groups formats into one row with expandable files, followed by learning summaries and retained versions. Returning to a retained version loads and checks its weights before switching.
131
+
132
+ The browser paints the last state from session storage while fetching. Polls use ETags and separate status, models, learning, and versions revisions; unchanged sections retain their controls, focus, and expanded details. Static assets use content hashes and long-term caching. The dashboard is local.
133
+
134
+ ## What it changes on your machine
135
+
136
+ - Private data under the platform's application data directory: macOS `~/Library/Application Support/songe`, Linux `$XDG_DATA_HOME/songe`, or Windows `%LOCALAPPDATA%\songe`.
137
+ - LM Studio's models folder: a `songe/` folder holding the current and previous learned versions. Your existing models are never touched.
138
+ - opencode and pi: one added provider entry each, with a backup. `songe uninstall` restores them.
139
+ - A per-user background service through launchd, systemd, or Windows Task Scheduler.
140
+
141
+ It sends no notifications and needs no account. `songe uninstall --purge` removes everything it created.
142
+
143
+ ## When it sleeps
144
+
145
+ Each model has three learning levels: **off** forwards and records without training; **new** (the default) learns only from exchanges recorded after that model's level was set; **all** also learns from earlier shared experience, including exchanges with other models. Switching back to new starts a fresh window. Scoring, on-policy sampling, training and held-out checks are per model. Songe trains one model at a time, choosing the most eligible pending experience, then the least recently trained. The GUI and TUI offer the same three choices. Existing on/off installs migrate to new/off while preserving versions and undo.
146
+
147
+ During learned idle gaps without proxy traffic, with adequate memory, power, a safe temperature, and new learnable experience. There is no daily time limit: Songe scores all new experience, trains the selected new pool once plus replay and anchors, then checks and switches the version if it passes. New data starts the next cycle; it never repeats a pool to fill time. The initial gap is ten minutes; later it follows your traffic history. The moment you come back it stops, saves its place, and continues later. A MacBook with its lid closed sleeps too, so learning waits for the next time it is open and idle.
148
+
149
+ ---
150
+
151
+ Technical details, configuration and the development workflow: [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md). Design and first principles: [DESIGN.md](DESIGN.md).
152
+
153
+ Songe stops or unloads only work it started. Existing user model instances remain
154
+ resident; learning waits when they leave too little memory. For llama.cpp and
155
+ vLLM, init provisions a separate loopback endpoint for Songe’s own server. Before each learning slice, Songe sizes context, responses, logit chunks and serial microbatches from live memory and calibration. Observed pressure transitions set the RAM margin; the live guard remains the hard stop.
@@ -0,0 +1,97 @@
1
+ # Songe
2
+
3
+ A local model that sleeps.
4
+
5
+ You use your model as usual, through opencode, pi or any OpenAI-compatible tool. When your computer is idle and on power, Songe reads back what happened after each of the model's actions — the tool result, the error, your next message — and teaches the model to anticipate it. After a candidate passes the checks, the same model name serves that version. Nothing leaves your machine.
6
+
7
+ ## How it learns
8
+
9
+ The only new information a local model ever gets is what happened *after* it acted. Given that hindsight, the same model can usually tell what it should have done; without it, it can't. Songe closes that gap:
10
+
11
+ - **Teacher**: the original model, shown the conversation *and* what happened next.
12
+ - **Student**: the model with a small LoRA adapter, shown only the conversation.
13
+ - The student writes its own answers and the teacher scores them token by token (on-policy distillation, as in Google DeepMind's GKD). The student learns where it was wrong, in its own words, so it forgets little.
14
+ - It practises the moments where hindsight changes the teacher's mind most.
15
+ - It continues the current adapter with replay, rebuilding from the original base when experience is forgotten or the base, tools, or accumulated drift require it.
16
+ - A new version is served only if it is measurably better on conversations it never trained on and not measurably worse at general tasks. Otherwise nothing changes.
17
+
18
+ Songe never runs your tools at night. It only reads what already happened.
19
+
20
+ ## Requirements
21
+
22
+ - Apple Silicon with MLX, Linux with NVIDIA or AMD, or Windows with NVIDIA.
23
+ - A locally accessible model served by LM Studio, Ollama, llama.cpp, mlx-lm, or vLLM.
24
+ - Python 3.11 or later for pip installation; Homebrew supplies Python 3.12.
25
+
26
+ Memory and training support are measured on your machine. CPU-only machines can serve and record experience. Calibration must complete before learning starts.
27
+
28
+ ## Install
29
+
30
+ ```sh
31
+ brew install sous-labs/tap/songe
32
+ pip install songe
33
+ songe init
34
+ ```
35
+
36
+ `songe init` finds your model server and agents, shows a short facts list, and asks once. Use `--show-diff` for exact dependency commands and config diffs, or `--yes` to accept the plan in a script. It exposes your models through the Songe provider. Pick a model in your agent as usual; Songe follows each one you use. Training support and memory are measured during idle gaps. `--model PATH` optionally pre-enables a local base. Existing single-model installs retain their versions and undo history.
37
+
38
+ Choose Homebrew or pip, then run `songe init`. These release commands become
39
+ available after the first real PyPI release and creation of the Homebrew tap;
40
+ PyPI's `0.0.0.dev0` package only reserves the name.
41
+
42
+ | Platform | Dependencies | CI scope |
43
+ | --- | --- | --- |
44
+ | macOS Apple Silicon | MLX and MLX-LM install automatically | Python 3.12 tests on `main` and `v*` tags; Metal tests skip when unavailable |
45
+ | Linux NVIDIA / AMD | `init` installs missing training dependencies in its private environment | Ubuntu Python 3.11/3.12 CPU tests; GPU training unverified |
46
+ | Windows NVIDIA | `init` selects PyTorch wheels for the detected driver | Portable locks and services implemented; Windows GPU validation required |
47
+
48
+ The default Linux/Windows install contains the proxy, store, CLI, web assets and
49
+ Textual dependency without an ML framework. Init detects the accelerator and
50
+ plans any missing training stack. CPU tests cover the Torch pipeline; accelerator
51
+ and live server validation still require real hardware.
52
+ See [accelerator installation and CI limits](docs/RELEASING.md#accelerator-installation).
53
+
54
+ ## Use
55
+
56
+ There is nothing to do. When you want to look:
57
+
58
+ ```sh
59
+ songe # where things stand, in one block
60
+ songe open # now, next, models and learning results
61
+ songe models # learning levels, support reasons, and pending data
62
+ songe models MODEL off
63
+ songe models MODEL new
64
+ songe models MODEL all
65
+ songe undo MODEL # restore this model's previous version
66
+ ```
67
+
68
+ Also: `songe pause`, `songe resume`, `songe sleep --now`, `songe forget` (delete what it has seen), `songe uninstall`.
69
+
70
+ ## The dashboard
71
+
72
+ `songe open` starts with `now`, `next`, and `paused`, followed by the Learning switch. They show the current model and work, measured progress and ETA when available, the next action and its condition, or a concrete waiting reason. The models table groups formats into one row with expandable files, followed by learning summaries and retained versions. Returning to a retained version loads and checks its weights before switching.
73
+
74
+ The browser paints the last state from session storage while fetching. Polls use ETags and separate status, models, learning, and versions revisions; unchanged sections retain their controls, focus, and expanded details. Static assets use content hashes and long-term caching. The dashboard is local.
75
+
76
+ ## What it changes on your machine
77
+
78
+ - Private data under the platform's application data directory: macOS `~/Library/Application Support/songe`, Linux `$XDG_DATA_HOME/songe`, or Windows `%LOCALAPPDATA%\songe`.
79
+ - LM Studio's models folder: a `songe/` folder holding the current and previous learned versions. Your existing models are never touched.
80
+ - opencode and pi: one added provider entry each, with a backup. `songe uninstall` restores them.
81
+ - A per-user background service through launchd, systemd, or Windows Task Scheduler.
82
+
83
+ It sends no notifications and needs no account. `songe uninstall --purge` removes everything it created.
84
+
85
+ ## When it sleeps
86
+
87
+ Each model has three learning levels: **off** forwards and records without training; **new** (the default) learns only from exchanges recorded after that model's level was set; **all** also learns from earlier shared experience, including exchanges with other models. Switching back to new starts a fresh window. Scoring, on-policy sampling, training and held-out checks are per model. Songe trains one model at a time, choosing the most eligible pending experience, then the least recently trained. The GUI and TUI offer the same three choices. Existing on/off installs migrate to new/off while preserving versions and undo.
88
+
89
+ During learned idle gaps without proxy traffic, with adequate memory, power, a safe temperature, and new learnable experience. There is no daily time limit: Songe scores all new experience, trains the selected new pool once plus replay and anchors, then checks and switches the version if it passes. New data starts the next cycle; it never repeats a pool to fill time. The initial gap is ten minutes; later it follows your traffic history. The moment you come back it stops, saves its place, and continues later. A MacBook with its lid closed sleeps too, so learning waits for the next time it is open and idle.
90
+
91
+ ---
92
+
93
+ Technical details, configuration and the development workflow: [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md). Design and first principles: [DESIGN.md](DESIGN.md).
94
+
95
+ Songe stops or unloads only work it started. Existing user model instances remain
96
+ resident; learning waits when they leave too little memory. For llama.cpp and
97
+ vLLM, init provisions a separate loopback endpoint for Songe’s own server. Before each learning slice, Songe sizes context, responses, logit chunks and serial microbatches from live memory and calibration. Observed pressure transitions set the RAM margin; the live guard remains the hard stop.
@@ -0,0 +1,221 @@
1
+ # Packaging and releases
2
+
3
+ The package name is `songe`, the source repository is `sous-labs/songe`, and
4
+ the public tap is `sous-labs/homebrew-tap` (installed as
5
+ `sous-labs/tap/songe`). PyPI includes the CLI release `0.1.0a2`. The original
6
+ `0.0.0.dev0` package was a name reservation without the CLI.
7
+
8
+ ## Dependency policy
9
+
10
+ Python 3.11 or later is required. The default install contains HTTP transport,
11
+ the proxy, SQLite store, CLI, bundled web assets, and the Textual dependency for
12
+ the TUI workstream. Apple Silicon installs also select MLX and MLX-LM through
13
+ `sys_platform == 'darwin' and platform_machine == 'arm64'` markers. `[mlx]`
14
+ explicitly requests the same marked dependencies; it does not enable MLX on
15
+ other platforms. The MLX 0.32 line matches the existing compatibility code.
16
+
17
+ `[torch]` adds PyTorch, Transformers, PEFT, Accelerate, and Safetensors.
18
+ `[cuda]` adds that stack plus the optional bitsandbytes dependency on
19
+ Linux/Windows. `[rocm]` adds the Torch stack without CUDA-specific quantization
20
+ packages. No ML framework is selected automatically on Linux or Windows;
21
+ Python environment markers cannot identify GPU hardware or installed drivers.
22
+ The Torch backend, portable CLI leases, and TUI are implemented. Installing dependencies is not a hardware training validation.
23
+
24
+ `uv.lock` records development resolution, including optional stacks; normal
25
+ `uv sync --locked` installs only base and development dependencies. Optional
26
+ frameworks are not downloaded merely because they appear in the lockfile.
27
+
28
+ ## Accelerator installation
29
+
30
+ Use a virtual environment for pip commands. On Apple Silicon,
31
+ `python -m pip install songe` selects MLX automatically.
32
+
33
+ For NVIDIA on Linux or Windows, use the command from the official
34
+ [PyTorch installer selector](https://pytorch.org/get-started/locally/) to
35
+ install `torch` with the CUDA wheel index matching the machine's driver and
36
+ Python version, then run:
37
+
38
+ ```sh
39
+ python -m pip install 'songe[cuda]'
40
+ ```
41
+
42
+ For AMD on Linux, select Linux / Pip / the supported ROCm version in the same
43
+ selector, install `torch` using its `https://download.pytorch.org/whl/rocm…`
44
+ index, then run:
45
+
46
+ ```sh
47
+ python -m pip install 'songe[rocm]'
48
+ ```
49
+
50
+ For Intel XPU, follow the official
51
+ [PyTorch XPU instructions](https://docs.pytorch.org/docs/stable/notes/get_start_xpu.html)
52
+ and install `songe[torch]` afterwards. For CPU-only Torch, first install `torch`
53
+ with `--index-url https://download.pytorch.org/whl/cpu`, then `songe[torch]`.
54
+ Installing Torch first lets pip reuse the selected build when it satisfies
55
+ Songe's declared range. Do not use `--upgrade` on the second command unless
56
+ intending to replace that build. Wheel availability and driver support are
57
+ defined by PyTorch; this project does not pin a CUDA/ROCm index in PyPI metadata.
58
+ ROCm/XPU quantization needs the vendor-supported implementation; the standard
59
+ bitsandbytes wheel is not evidence that it works there.
60
+
61
+ Check the selected accelerator with:
62
+
63
+ ```sh
64
+ python -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(getattr(torch.version, 'hip', None))"
65
+ ```
66
+
67
+ This checks the installed framework, not a Songe training run. `songe init` discovers the accelerator and installs a missing training stack in a private environment after showing the exact commands. It asks once for dependencies and agent/service changes; `--yes` accepts the plan. Apple Silicon uses its existing MLX dependencies for native MLX models. GGUF import/export additionally needs the CPU converter stack; init displays and provisions that private converter environment when missing. CPU-only installs remain serve-only.
68
+
69
+ ## CI coverage
70
+
71
+ `.github/workflows/ci.yml` runs Ruff, pytest and `uv build` on Ubuntu and
72
+ Windows with Python 3.11 and 3.12 for every push and pull request. The
73
+ `macos-14` job asserts `arm64` and runs only on `main` pushes and `v*` tags.
74
+ It also checks `songe --version`. uv caches are managed by
75
+ [setup-uv](https://docs.astral.sh/uv/guides/integration/github/).
76
+
77
+ The test-only plugin in `.github/ci/platform_checks.py` reports Metal tests as
78
+ skipped when Metal cannot be imported or is unavailable, including sandboxed
79
+ Mac sessions. Non-MLX installations skip the model-support test that reads
80
+ MLX-LM's installed metadata. Windows uses the same portable worker and mutation leases as Unix. The remaining store permission assertion skips on Windows because POSIX mode `0700` is not a Windows ACL check. Other portable
81
+ tests, including HTTP streaming, run on Windows. No job installs a CUDA/ROCm
82
+ training stack, loads real models, or establishes GPU training support.
83
+
84
+ ## One-time PyPI Trusted Publishing setup
85
+
86
+ In GitHub repository settings for `sous-labs/songe`, create an environment named
87
+ `pypi` and restrict deployment to release tags `v*`. Configure any desired
88
+ reviewers there. No PyPI API token is needed.
89
+
90
+ The GitHub pending-publisher settings are:
91
+
92
+ | Field | Value |
93
+ | --- | --- |
94
+ | PyPI project name | `songe` |
95
+ | Owner | `sous-labs` |
96
+ | Repository | `songe` |
97
+ | Workflow filename | `release.yml` |
98
+ | Environment | `pypi` |
99
+
100
+ Because `songe` is already registered, add this as a Trusted Publisher under
101
+ the existing project's **Manage → Publishing**, rather than creating another
102
+ pending project. If registering on an index where the project does not yet
103
+ exist, use these same values in its pending-publisher form. See
104
+ [PyPI's existing-project instructions](https://docs.pypi.org/trusted-publishers/adding-a-publisher/).
105
+
106
+ `release.yml` runs the reusable CI workflow before building. A separate build
107
+ job verifies that `v<version>`, `pyproject.toml`, and
108
+ `songe.__version__` agree, runs `uv build` and `twine check --strict`, and
109
+ uploads the sdist and wheel as one artifact. Only the subsequent publish job
110
+ gets `id-token: write` and the `pypi` environment. It downloads those artifacts
111
+ and uses `pypa/gh-action-pypi-publish` with Trusted Publishing and attestations.
112
+ See [the publisher action's instructions](https://github.com/pypa/gh-action-pypi-publish).
113
+
114
+ ## Release procedure
115
+
116
+ 1. Integrate all workstreams and resolve the documented Windows/backend gaps
117
+ appropriate to the release's advertised scope. Run CI on `main`.
118
+ 2. Set the same stable or preview version in `pyproject.toml` and
119
+ `src/songe/__init__.py`, and run `uv lock`. Tag names use `v`, for example
120
+ `v0.1.0` or `v0.1.0a2`; the Homebrew updater accepts stable versions and
121
+ `a`, `b`, and `rc` previews, ordered using PEP 440.
122
+ 3. Validate from a clean checkout:
123
+
124
+ ```sh
125
+ export UV_CACHE_DIR=/Volumes/disk/sous-build-cache/uv # this development Mac
126
+ uv sync --locked
127
+ uv run ruff check src tests scripts .github/ci packaging/homebrew
128
+ uv run pytest
129
+ uv build
130
+ uvx twine check --strict dist/*
131
+ ```
132
+
133
+ 4. Commit the version changes, create the matching `v<version>` tag, and push
134
+ the reviewed commit and tag when ready to publish. The tag starts release
135
+ CI, then the build and PyPI publishing jobs. Do not reuse an uploaded version.
136
+ 5. Check the [PyPI release files](https://pypi.org/project/songe/#files), their
137
+ attestations, and an installation in a fresh environment. A successful CI
138
+ build alone does not verify a live PyPI install or accelerator training.
139
+ 6. Update the tap as below. The optional notification job runs only after PyPI
140
+ publication. If it fails, rerun that job or dispatch the tap updater manually;
141
+ do not rerun a successful PyPI upload to repair a tap notification.
142
+
143
+ ## Homebrew tap
144
+
145
+ Keep these source files synchronized with the public tap:
146
+
147
+ | Source in this repository | Destination in the tap |
148
+ | --- | --- |
149
+ | `packaging/homebrew/songe.rb` | `Formula/songe.rb` |
150
+ | `packaging/homebrew/update_formula.py` | `scripts/update_formula.py` |
151
+ | `packaging/homebrew/bump-formula.yml` | `.github/workflows/bump-formula.yml` |
152
+
153
+ The checked-in formula pins the published CLI wheel and every dependency
154
+ wheel with a SHA256. The updater requires Python 3.11+ and uv; its inline
155
+ script metadata supplies `packaging` automatically. To generate a release in
156
+ the tap checkout:
157
+
158
+ ```sh
159
+ uv run --script scripts/update_formula.py 0.1.0a2 --formula Formula/songe.rb
160
+ ```
161
+
162
+ The updater fetches that exact version's PyPI JSON, rejects yanked or
163
+ unexpected artifacts, verifies the universal wheel's SHA256, package metadata,
164
+ and `songe` console entry point, and rejects version downgrades. Previews are
165
+ allowed. It then resolves the published wheel's dependencies for CPython 3.12
166
+ on macOS ARM64/Intel and Linux ARM64/x86_64. It does not use this repository's
167
+ pyproject or development lockfile. All dependencies must have compatible
168
+ wheels; a missing platform wheel fails the update before writing the formula.
169
+ Resolution excludes uploads newer than the release wheel, making repeat
170
+ updates reproducible when index metadata is unchanged.
171
+
172
+ macOS wheels target macOS 14 or newer (including the MLX stack on Apple
173
+ Silicon); Linux wheels target glibc 2.28 or newer. These minimums are explicit
174
+ in the resolver and wheel selector. Universal resources are shared; native
175
+ wheels and platform-specific dependencies appear in conditional resource
176
+ blocks. Linux and Intel wheel resolution is checked during every update;
177
+ an actual installation must still be tested on those hosts before claiming
178
+ runtime validation there.
179
+
180
+ Homebrew downloads and verifies every resource before the build sandbox.
181
+ Inside the sandbox the formula creates an isolated virtualenv without pip,
182
+ loads the pinned pure Python `installer` wheel through `PYTHONPATH`, and
183
+ installs the already downloaded wheels. `installer` performs wheel extraction,
184
+ script generation, and RECORD installation without resolving dependencies,
185
+ accessing the network, or asking for the macOS version. This avoids the pip
186
+ truststore import and uv interpreter-inspection failures seen when the
187
+ sandbox makes `platform.mac_ver()` empty. Neither pip nor uv is used during
188
+ `brew install`, and users need no trust override or environment variables.
189
+ See [installer's CLI documentation](https://installer.pypa.io/en/stable/cli/installer/).
190
+
191
+ After reviewing and pushing a generated formula, verify it with:
192
+
193
+ ```sh
194
+ brew install --build-from-source sous-labs/tap/songe
195
+ songe --version
196
+ brew test sous-labs/tap/songe
197
+ brew uninstall songe
198
+ ```
199
+
200
+ For local verification before pushing, copy the generated formula into an
201
+ existing local tap checkout used by Homebrew, or use a temporary local tap.
202
+ Remove any temporary tap afterwards. `brew test` runs only `songe --version`
203
+ with a temporary data directory. Neither installation nor testing runs
204
+ `songe init`, configures agents, or starts/stops a service.
205
+
206
+ For automated bumps, allow the tap workflow's `GITHUB_TOKEN` to write contents
207
+ (and ensure branch rules permit its formula commits). In `sous-labs/songe`,
208
+ configure a fine-grained token or GitHub App token as `HOMEBREW_TAP_TOKEN`,
209
+ scoped to **Contents: write** on `sous-labs/homebrew-tap` for repository
210
+ dispatch, and set the repository variable `HOMEBREW_TAP_ENABLED=true`.
211
+ The default source-repository `GITHUB_TOKEN` cannot dispatch to another private
212
+ repository. After each successful publication, `release.yml` sends a
213
+ `songe-release` dispatch; the tap workflow uses uv and the updater to verify
214
+ the published CLI wheel and commit the complete formula with dependency hashes.
215
+ The tap itself needs no PyPI secret or access to the private source repository.
216
+
217
+ To recover a failed notification:
218
+
219
+ ```sh
220
+ gh workflow run bump-formula.yml --repo sous-labs/homebrew-tap -f version=0.1.0a2
221
+ ```
@@ -0,0 +1,45 @@
1
+ # Copy to sous-labs/homebrew-tap:.github/workflows/bump-formula.yml.
2
+ name: Bump Songe formula
3
+
4
+ on:
5
+ repository_dispatch:
6
+ types: [songe-release]
7
+ workflow_dispatch:
8
+ inputs:
9
+ version:
10
+ description: Stable or preview PyPI version without the v prefix
11
+ required: true
12
+ type: string
13
+
14
+ permissions:
15
+ contents: write
16
+
17
+ concurrency:
18
+ group: songe-formula
19
+ cancel-in-progress: false
20
+
21
+ jobs:
22
+ bump:
23
+ if: github.repository == 'sous-labs/homebrew-tap'
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ with:
28
+ ref: main
29
+ - uses: actions/setup-python@v5
30
+ with:
31
+ python-version: "3.12"
32
+ - uses: astral-sh/setup-uv@v7
33
+ with:
34
+ version: "0.13.7"
35
+ - name: Pin verified PyPI wheel and offline dependencies
36
+ env:
37
+ RELEASE_VERSION: ${{ inputs.version || github.event.client_payload.version }}
38
+ run: uv run --script scripts/update_formula.py "$RELEASE_VERSION" --formula Formula/songe.rb
39
+ - name: Commit formula update
40
+ run: |
41
+ if ! git diff --quiet -- Formula/songe.rb; then
42
+ git add Formula/songe.rb
43
+ git -c user.name='github-actions[bot]' -c user.email='41898282+github-actions[bot]@users.noreply.github.com' commit -m 'Bump Songe to the published PyPI release'
44
+ git push origin HEAD:main
45
+ fi