songe 0.0.0.dev0__tar.gz → 0.1.0a2__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 (155) hide show
  1. songe-0.1.0a2/.github/ci/platform_checks.py +67 -0
  2. songe-0.1.0a2/.gitignore +10 -0
  3. songe-0.1.0a2/PKG-INFO +152 -0
  4. songe-0.1.0a2/README.md +97 -0
  5. songe-0.1.0a2/docs/RELEASING.md +197 -0
  6. songe-0.1.0a2/packaging/homebrew/bump-formula.yml +42 -0
  7. songe-0.1.0a2/packaging/homebrew/songe.rb +38 -0
  8. songe-0.1.0a2/packaging/homebrew/test_update_formula.py +89 -0
  9. songe-0.1.0a2/packaging/homebrew/update_formula.py +107 -0
  10. songe-0.1.0a2/pyproject.toml +107 -0
  11. songe-0.1.0a2/src/songe/__init__.py +7 -0
  12. songe-0.1.0a2/src/songe/__main__.py +3 -0
  13. songe-0.1.0a2/src/songe/agents/__init__.py +291 -0
  14. songe-0.1.0a2/src/songe/agents/opencode.py +48 -0
  15. songe-0.1.0a2/src/songe/agents/pi.py +32 -0
  16. songe-0.1.0a2/src/songe/api.py +731 -0
  17. songe-0.1.0a2/src/songe/artifacts/__init__.py +204 -0
  18. songe-0.1.0a2/src/songe/artifacts/runtime.py +111 -0
  19. songe-0.1.0a2/src/songe/artifacts/storage.py +352 -0
  20. songe-0.1.0a2/src/songe/artifacts/tools.py +253 -0
  21. songe-0.1.0a2/src/songe/artifacts/worker.py +84 -0
  22. songe-0.1.0a2/src/songe/backends/__init__.py +58 -0
  23. songe-0.1.0a2/src/songe/backends/install.py +216 -0
  24. songe-0.1.0a2/src/songe/backends/mlx.py +515 -0
  25. songe-0.1.0a2/src/songe/backends/objective.py +64 -0
  26. songe-0.1.0a2/src/songe/backends/reference.py +45 -0
  27. songe-0.1.0a2/src/songe/backends/torch.py +732 -0
  28. songe-0.1.0a2/src/songe/backends/training.py +214 -0
  29. songe-0.1.0a2/src/songe/child.py +131 -0
  30. songe-0.1.0a2/src/songe/cli.py +954 -0
  31. songe-0.1.0a2/src/songe/config.py +250 -0
  32. songe-0.1.0a2/src/songe/experience.py +46 -0
  33. songe-0.1.0a2/src/songe/interface_copy.py +35 -0
  34. songe-0.1.0a2/src/songe/launchd.py +52 -0
  35. songe-0.1.0a2/src/songe/learning_summary.py +284 -0
  36. songe-0.1.0a2/src/songe/log.py +874 -0
  37. songe-0.1.0a2/src/songe/memory.py +843 -0
  38. songe-0.1.0a2/src/songe/models/__init__.py +22 -0
  39. songe-0.1.0a2/src/songe/models/convert.py +201 -0
  40. songe-0.1.0a2/src/songe/models/discovery.py +319 -0
  41. songe-0.1.0a2/src/songe/models/gguf.py +56 -0
  42. songe-0.1.0a2/src/songe/models/library.py +478 -0
  43. songe-0.1.0a2/src/songe/models/names.py +43 -0
  44. songe-0.1.0a2/src/songe/models/registry.py +374 -0
  45. songe-0.1.0a2/src/songe/models/worker.py +60 -0
  46. songe-0.1.0a2/src/songe/platform/__init__.py +123 -0
  47. songe-0.1.0a2/src/songe/platform/common.py +70 -0
  48. songe-0.1.0a2/src/songe/platform/darwin.py +184 -0
  49. songe-0.1.0a2/src/songe/platform/linux.py +261 -0
  50. songe-0.1.0a2/src/songe/platform/locking.py +21 -0
  51. songe-0.1.0a2/src/songe/platform/services.py +337 -0
  52. songe-0.1.0a2/src/songe/platform/windows.py +156 -0
  53. songe-0.1.0a2/src/songe/proxy.py +489 -0
  54. songe-0.1.0a2/src/songe/schedule.py +1166 -0
  55. songe-0.1.0a2/src/songe/sleep/__init__.py +1 -0
  56. songe-0.1.0a2/src/songe/sleep/anchors.json +152 -0
  57. songe-0.1.0a2/src/songe/sleep/calibrate.py +580 -0
  58. songe-0.1.0a2/src/songe/sleep/cleanup.py +180 -0
  59. songe-0.1.0a2/src/songe/sleep/compat.py +114 -0
  60. songe-0.1.0a2/src/songe/sleep/distill.py +11 -0
  61. songe-0.1.0a2/src/songe/sleep/evaluate.py +148 -0
  62. songe-0.1.0a2/src/songe/sleep/fuse.py +283 -0
  63. songe-0.1.0a2/src/songe/sleep/fuse_worker.py +21 -0
  64. songe-0.1.0a2/src/songe/sleep/gate.py +108 -0
  65. songe-0.1.0a2/src/songe/sleep/measurement.py +72 -0
  66. songe-0.1.0a2/src/songe/sleep/probe.py +218 -0
  67. songe-0.1.0a2/src/songe/sleep/prompts.py +91 -0
  68. songe-0.1.0a2/src/songe/sleep/retention.py +49 -0
  69. songe-0.1.0a2/src/songe/sleep/samples.py +118 -0
  70. songe-0.1.0a2/src/songe/sleep/select.py +69 -0
  71. songe-0.1.0a2/src/songe/sleep/sizing.py +259 -0
  72. songe-0.1.0a2/src/songe/sleep/swap.py +134 -0
  73. songe-0.1.0a2/src/songe/sleep/worker.py +889 -0
  74. songe-0.1.0a2/src/songe/status.py +295 -0
  75. songe-0.1.0a2/src/songe/steps.py +333 -0
  76. songe-0.1.0a2/src/songe/storage.py +129 -0
  77. songe-0.1.0a2/src/songe/telemetry.py +100 -0
  78. songe-0.1.0a2/src/songe/terminal.py +211 -0
  79. songe-0.1.0a2/src/songe/tui.py +387 -0
  80. songe-0.1.0a2/src/songe/ui/app.js +248 -0
  81. songe-0.1.0a2/src/songe/ui/index.html +25 -0
  82. songe-0.1.0a2/src/songe/ui/outfit-OFL.txt +93 -0
  83. songe-0.1.0a2/src/songe/ui/outfit.woff2 +0 -0
  84. songe-0.1.0a2/src/songe/ui/style.css +5 -0
  85. songe-0.1.0a2/src/songe/ui/syne-OFL.txt +93 -0
  86. songe-0.1.0a2/src/songe/ui/syne.woff2 +0 -0
  87. songe-0.1.0a2/src/songe/upstream/__init__.py +51 -0
  88. songe-0.1.0a2/src/songe/upstream/cleanup.py +143 -0
  89. songe-0.1.0a2/src/songe/upstream/llamacpp.py +258 -0
  90. songe-0.1.0a2/src/songe/upstream/lmstudio.py +417 -0
  91. songe-0.1.0a2/src/songe/upstream/mlx.py +215 -0
  92. songe-0.1.0a2/src/songe/upstream/ollama.py +311 -0
  93. songe-0.1.0a2/src/songe/upstream/protection.py +180 -0
  94. songe-0.1.0a2/src/songe/upstream/reuse.py +42 -0
  95. songe-0.1.0a2/src/songe/upstream/supervisor.py +293 -0
  96. songe-0.1.0a2/src/songe/upstream/vllm.py +176 -0
  97. songe-0.1.0a2/tests/__init__.py +0 -0
  98. songe-0.1.0a2/tests/conftest.py +50 -0
  99. songe-0.1.0a2/tests/crossplatform_helpers.py +95 -0
  100. songe-0.1.0a2/tests/crossplatform_smoke.py +222 -0
  101. songe-0.1.0a2/tests/snapshots/cli_error.txt +2 -0
  102. songe-0.1.0a2/tests/snapshots/cli_idle.txt +12 -0
  103. songe-0.1.0a2/tests/snapshots/cli_init.txt +11 -0
  104. songe-0.1.0a2/tests/snapshots/cli_learning.txt +12 -0
  105. songe-0.1.0a2/tests/snapshots/cli_library.txt +11 -0
  106. songe-0.1.0a2/tests/snapshots/cli_models.txt +6 -0
  107. songe-0.1.0a2/tests/snapshots/cli_undo.txt +1 -0
  108. songe-0.1.0a2/tests/snapshots/cli_uninstall.txt +3 -0
  109. songe-0.1.0a2/tests/test_agents.py +67 -0
  110. songe-0.1.0a2/tests/test_api.py +354 -0
  111. songe-0.1.0a2/tests/test_artifacts.py +320 -0
  112. songe-0.1.0a2/tests/test_backend_contract.py +52 -0
  113. songe-0.1.0a2/tests/test_cli.py +225 -0
  114. songe-0.1.0a2/tests/test_cli_output.py +364 -0
  115. songe-0.1.0a2/tests/test_compat.py +116 -0
  116. songe-0.1.0a2/tests/test_core_learning.py +346 -0
  117. songe-0.1.0a2/tests/test_crossplatform_upstreams.py +276 -0
  118. songe-0.1.0a2/tests/test_dashboard.py +451 -0
  119. songe-0.1.0a2/tests/test_data_cycles.py +451 -0
  120. songe-0.1.0a2/tests/test_disk_space.py +490 -0
  121. songe-0.1.0a2/tests/test_gate.py +57 -0
  122. songe-0.1.0a2/tests/test_guard_regressions.py +475 -0
  123. songe-0.1.0a2/tests/test_heavy.py +105 -0
  124. songe-0.1.0a2/tests/test_integration.py +458 -0
  125. songe-0.1.0a2/tests/test_learning.py +133 -0
  126. songe-0.1.0a2/tests/test_learning_levels.py +250 -0
  127. songe-0.1.0a2/tests/test_learning_summary.py +278 -0
  128. songe-0.1.0a2/tests/test_library_retention.py +829 -0
  129. songe-0.1.0a2/tests/test_lmstudio.py +193 -0
  130. songe-0.1.0a2/tests/test_memory.py +115 -0
  131. songe-0.1.0a2/tests/test_model_discovery.py +201 -0
  132. songe-0.1.0a2/tests/test_model_reuse.py +506 -0
  133. songe-0.1.0a2/tests/test_models.py +643 -0
  134. songe-0.1.0a2/tests/test_network.py +82 -0
  135. songe-0.1.0a2/tests/test_platform.py +217 -0
  136. songe-0.1.0a2/tests/test_power.py +336 -0
  137. songe-0.1.0a2/tests/test_pressure_baseline.py +322 -0
  138. songe-0.1.0a2/tests/test_probe.py +123 -0
  139. songe-0.1.0a2/tests/test_proxy.py +360 -0
  140. songe-0.1.0a2/tests/test_review2.py +863 -0
  141. songe-0.1.0a2/tests/test_review3.py +817 -0
  142. songe-0.1.0a2/tests/test_review_regressions.py +969 -0
  143. songe-0.1.0a2/tests/test_schedule.py +184 -0
  144. songe-0.1.0a2/tests/test_steps.py +118 -0
  145. songe-0.1.0a2/tests/test_store.py +67 -0
  146. songe-0.1.0a2/tests/test_swap.py +104 -0
  147. songe-0.1.0a2/tests/test_torch_backend.py +411 -0
  148. songe-0.1.0a2/tests/test_training_batches.py +275 -0
  149. songe-0.1.0a2/tests/test_tui.py +264 -0
  150. songe-0.1.0a2/tests/test_worker.py +239 -0
  151. songe-0.1.0a2/uv.lock +2438 -0
  152. songe-0.0.0.dev0/PKG-INFO +0 -20
  153. songe-0.0.0.dev0/README.md +0 -7
  154. songe-0.0.0.dev0/pyproject.toml +0 -23
  155. 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.0a2/PKG-INFO ADDED
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.5
2
+ Name: songe
3
+ Version: 0.1.0a2
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: gguf<1,>=0.19
16
+ Requires-Dist: httpx<1,>=0.28
17
+ Requires-Dist: jsonschema<5,>=4.26
18
+ Requires-Dist: lmstudio<2,>=1.5
19
+ Requires-Dist: mlx-lm<0.33,>=0.32; sys_platform == 'darwin' and platform_machine == 'arm64'
20
+ Requires-Dist: mlx<0.33,>=0.32.4; sys_platform == 'darwin' and platform_machine == 'arm64'
21
+ Requires-Dist: psutil<8,>=5.9
22
+ Requires-Dist: rich<16,>=15
23
+ Requires-Dist: starlette<2,>=0.49
24
+ Requires-Dist: textual<7,>=6.12
25
+ Requires-Dist: uvicorn<1,>=0.38
26
+ Provides-Extra: cuda
27
+ Requires-Dist: accelerate<2,>=1; extra == 'cuda'
28
+ Requires-Dist: bitsandbytes<1,>=0.45; (sys_platform == 'linux' or sys_platform == 'win32') and extra == 'cuda'
29
+ Requires-Dist: peft<1,>=0.21; extra == 'cuda'
30
+ Requires-Dist: protobuf<8,>=5; extra == 'cuda'
31
+ Requires-Dist: safetensors<1,>=0.5; extra == 'cuda'
32
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'cuda'
33
+ Requires-Dist: torch<3,>=2.11; extra == 'cuda'
34
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'cuda'
35
+ Provides-Extra: mlx
36
+ Requires-Dist: mlx-lm<0.33,>=0.32; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'mlx'
37
+ Requires-Dist: mlx<0.33,>=0.32.4; (sys_platform == 'darwin' and platform_machine == 'arm64') and extra == 'mlx'
38
+ Provides-Extra: rocm
39
+ Requires-Dist: accelerate<2,>=1; extra == 'rocm'
40
+ Requires-Dist: peft<1,>=0.21; extra == 'rocm'
41
+ Requires-Dist: protobuf<8,>=5; extra == 'rocm'
42
+ Requires-Dist: safetensors<1,>=0.5; extra == 'rocm'
43
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'rocm'
44
+ Requires-Dist: torch<3,>=2.11; extra == 'rocm'
45
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'rocm'
46
+ Provides-Extra: torch
47
+ Requires-Dist: accelerate<2,>=1; extra == 'torch'
48
+ Requires-Dist: peft<1,>=0.21; extra == 'torch'
49
+ Requires-Dist: protobuf<8,>=5; extra == 'torch'
50
+ Requires-Dist: safetensors<1,>=0.5; extra == 'torch'
51
+ Requires-Dist: sentencepiece<1,>=0.2; extra == 'torch'
52
+ Requires-Dist: torch<3,>=2.11; extra == 'torch'
53
+ Requires-Dist: transformers<6,>=5.22.2; extra == 'torch'
54
+ Description-Content-Type: text/markdown
55
+
56
+ # Songe
57
+
58
+ A local model that sleeps.
59
+
60
+ 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.
61
+
62
+ ## How it learns
63
+
64
+ 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:
65
+
66
+ - **Teacher**: the original model, shown the conversation *and* what happened next.
67
+ - **Student**: the model with a small LoRA adapter, shown only the conversation.
68
+ - 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.
69
+ - It practises the moments where hindsight changes the teacher's mind most.
70
+ - 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.
71
+ - 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.
72
+
73
+ Songe never runs your tools at night. It only reads what already happened.
74
+
75
+ ## Requirements
76
+
77
+ - Apple Silicon with MLX, Linux with NVIDIA or AMD, or Windows with NVIDIA.
78
+ - A locally accessible model served by LM Studio, Ollama, llama.cpp, mlx-lm, or vLLM.
79
+ - Python 3.11 or later for pip installation; Homebrew supplies Python 3.12.
80
+
81
+ Memory and training support are measured on your machine. CPU-only machines can serve and record experience. Calibration must complete before learning starts.
82
+
83
+ ## Install
84
+
85
+ ```sh
86
+ brew install sous-labs/tap/songe
87
+ pip install songe
88
+ songe init
89
+ ```
90
+
91
+ `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.
92
+
93
+ Choose Homebrew or pip, then run `songe init`. These release commands become
94
+ available after the first real PyPI release and creation of the Homebrew tap;
95
+ PyPI's `0.0.0.dev0` package only reserves the name.
96
+
97
+ | Platform | Dependencies | CI scope |
98
+ | --- | --- | --- |
99
+ | macOS Apple Silicon | MLX and MLX-LM install automatically | Python 3.12 tests on `main` and `v*` tags; Metal tests skip when unavailable |
100
+ | Linux NVIDIA / AMD | `init` installs missing training dependencies in its private environment | Ubuntu Python 3.11/3.12 CPU tests; GPU training unverified |
101
+ | Windows NVIDIA | `init` selects PyTorch wheels for the detected driver | Portable locks and services implemented; Windows GPU validation required |
102
+
103
+ The default Linux/Windows install contains the proxy, store, CLI, web assets and
104
+ Textual dependency without an ML framework. Init detects the accelerator and
105
+ plans any missing training stack. CPU tests cover the Torch pipeline; accelerator
106
+ and live server validation still require real hardware.
107
+ See [accelerator installation and CI limits](docs/RELEASING.md#accelerator-installation).
108
+
109
+ ## Use
110
+
111
+ There is nothing to do. When you want to look:
112
+
113
+ ```sh
114
+ songe # where things stand, in one block
115
+ songe open # now, next, models and learning results
116
+ songe models # learning levels, support reasons, and pending data
117
+ songe models MODEL off
118
+ songe models MODEL new
119
+ songe models MODEL all
120
+ songe undo MODEL # restore this model's previous version
121
+ ```
122
+
123
+ Also: `songe pause`, `songe resume`, `songe sleep --now`, `songe forget` (delete what it has seen), `songe uninstall`.
124
+
125
+ ## The dashboard
126
+
127
+ `songe open` starts with three lines: `now`, `next`, and `paused`. 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.
128
+
129
+ 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. Everything stays local.
130
+
131
+ ## What it changes on your machine
132
+
133
+ - Private data under the platform's application data directory: macOS `~/Library/Application Support/songe`, Linux `$XDG_DATA_HOME/songe`, or Windows `%LOCALAPPDATA%\songe`.
134
+ - LM Studio's models folder: a `songe/` folder holding the current and previous learned versions. Your existing models are never touched.
135
+ - opencode and pi: one added provider entry each, with a backup. `songe uninstall` restores them.
136
+ - A per-user background service through launchd, systemd, or Windows Task Scheduler.
137
+
138
+ It sends no notifications and needs no account. `songe uninstall --purge` removes everything it created.
139
+
140
+ ## When it sleeps
141
+
142
+ 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.
143
+
144
+ 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.
145
+
146
+ ---
147
+
148
+ Technical details, configuration and the development workflow: [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md). Design and first principles: [DESIGN.md](DESIGN.md).
149
+
150
+ Songe stops or unloads only work it started. Existing user model instances remain
151
+ resident; learning waits when they leave too little memory. For llama.cpp and
152
+ 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 three lines: `now`, `next`, and `paused`. 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. Everything stays 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,197 @@
1
+ # Packaging and releases
2
+
3
+ The package name is `songe`, the source repository is `sous-labs/songe`, and
4
+ the tap repository will be `sous-labs/homebrew-tap` (installed as
5
+ `sous-labs/tap/songe`). This workstream supplies release configuration; it does
6
+ not create repositories, publish packages, or configure external accounts.
7
+ PyPI currently contains only `0.0.0.dev0`, a name reservation without the CLI.
8
+
9
+ ## Dependency policy
10
+
11
+ Python 3.11 or later is required. The default install contains HTTP transport,
12
+ the proxy, SQLite store, CLI, bundled web assets, and the Textual dependency for
13
+ the TUI workstream. Apple Silicon installs also select MLX and MLX-LM through
14
+ `sys_platform == 'darwin' and platform_machine == 'arm64'` markers. `[mlx]`
15
+ explicitly requests the same marked dependencies; it does not enable MLX on
16
+ other platforms. The MLX 0.32 line matches the existing compatibility code.
17
+
18
+ `[torch]` adds PyTorch, Transformers, PEFT, Accelerate, and Safetensors.
19
+ `[cuda]` adds that stack plus the optional bitsandbytes dependency on
20
+ Linux/Windows. `[rocm]` adds the Torch stack without CUDA-specific quantization
21
+ packages. No ML framework is selected automatically on Linux or Windows;
22
+ Python environment markers cannot identify GPU hardware or installed drivers.
23
+ The Torch backend, portable CLI leases, and TUI are implemented. Installing dependencies is not a hardware training validation.
24
+
25
+ `uv.lock` records development resolution, including optional stacks; normal
26
+ `uv sync --locked` installs only base and development dependencies. Optional
27
+ frameworks are not downloaded merely because they appear in the lockfile.
28
+
29
+ ## Accelerator installation
30
+
31
+ Use a virtual environment for pip commands. On Apple Silicon,
32
+ `python -m pip install songe` selects MLX automatically.
33
+
34
+ For NVIDIA on Linux or Windows, use the command from the official
35
+ [PyTorch installer selector](https://pytorch.org/get-started/locally/) to
36
+ install `torch` with the CUDA wheel index matching the machine's driver and
37
+ Python version, then run:
38
+
39
+ ```sh
40
+ python -m pip install 'songe[cuda]'
41
+ ```
42
+
43
+ For AMD on Linux, select Linux / Pip / the supported ROCm version in the same
44
+ selector, install `torch` using its `https://download.pytorch.org/whl/rocm…`
45
+ index, then run:
46
+
47
+ ```sh
48
+ python -m pip install 'songe[rocm]'
49
+ ```
50
+
51
+ For Intel XPU, follow the official
52
+ [PyTorch XPU instructions](https://docs.pytorch.org/docs/stable/notes/get_start_xpu.html)
53
+ and install `songe[torch]` afterwards. For CPU-only Torch, first install `torch`
54
+ with `--index-url https://download.pytorch.org/whl/cpu`, then `songe[torch]`.
55
+ Installing Torch first lets pip reuse the selected build when it satisfies
56
+ Songe's declared range. Do not use `--upgrade` on the second command unless
57
+ intending to replace that build. Wheel availability and driver support are
58
+ defined by PyTorch; this project does not pin a CUDA/ROCm index in PyPI metadata.
59
+ ROCm/XPU quantization needs the vendor-supported implementation; the standard
60
+ bitsandbytes wheel is not evidence that it works there.
61
+
62
+ Check the selected accelerator with:
63
+
64
+ ```sh
65
+ python -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(getattr(torch.version, 'hip', None))"
66
+ ```
67
+
68
+ 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.
69
+
70
+ ## CI coverage
71
+
72
+ `.github/workflows/ci.yml` runs Ruff, pytest and `uv build` on Ubuntu and
73
+ Windows with Python 3.11 and 3.12 for every push and pull request. The
74
+ `macos-14` job asserts `arm64` and runs only on `main` pushes and `v*` tags.
75
+ It also checks `songe --version`. uv caches are managed by
76
+ [setup-uv](https://docs.astral.sh/uv/guides/integration/github/).
77
+
78
+ The test-only plugin in `.github/ci/platform_checks.py` reports Metal tests as
79
+ skipped when Metal cannot be imported or is unavailable, including sandboxed
80
+ Mac sessions. Non-MLX installations skip the model-support test that reads
81
+ 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
82
+ tests, including HTTP streaming, run on Windows. No job installs a CUDA/ROCm
83
+ training stack, loads real models, or establishes GPU training support.
84
+
85
+ ## One-time PyPI Trusted Publishing setup
86
+
87
+ In GitHub repository settings for `sous-labs/songe`, create an environment named
88
+ `pypi` and restrict deployment to release tags `v*`. Configure any desired
89
+ reviewers there. No PyPI API token is needed.
90
+
91
+ The GitHub pending-publisher settings are:
92
+
93
+ | Field | Value |
94
+ | --- | --- |
95
+ | PyPI project name | `songe` |
96
+ | Owner | `sous-labs` |
97
+ | Repository | `songe` |
98
+ | Workflow filename | `release.yml` |
99
+ | Environment | `pypi` |
100
+
101
+ Because `songe` is already registered, add this as a Trusted Publisher under
102
+ the existing project's **Manage → Publishing**, rather than creating another
103
+ pending project. If registering on an index where the project does not yet
104
+ exist, use these same values in its pending-publisher form. See
105
+ [PyPI's existing-project instructions](https://docs.pypi.org/trusted-publishers/adding-a-publisher/).
106
+
107
+ `release.yml` runs the reusable CI workflow before building. A separate build
108
+ job verifies that `v<version>`, `pyproject.toml`, and
109
+ `songe.__version__` agree, runs `uv build` and `twine check --strict`, and
110
+ uploads the sdist and wheel as one artifact. Only the subsequent publish job
111
+ gets `id-token: write` and the `pypi` environment. It downloads those artifacts
112
+ and uses `pypa/gh-action-pypi-publish` with Trusted Publishing and attestations.
113
+ See [the publisher action's instructions](https://github.com/pypa/gh-action-pypi-publish).
114
+
115
+ ## Release procedure
116
+
117
+ 1. Integrate all workstreams and resolve the documented Windows/backend gaps
118
+ appropriate to the release's advertised scope. Run CI on `main`.
119
+ 2. Set the same final version in `pyproject.toml` and
120
+ `src/songe/__init__.py`, and run `uv lock`. Tag names use `v`, for example
121
+ `v0.1.0`; the Homebrew updater accepts final `major.minor.patch` versions.
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
+ ## Bootstrap the future Homebrew tap
144
+
145
+ Create `sous-labs/homebrew-tap` with default branch `main`, then copy:
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 source formula is disabled while only the reservation package exists.
154
+ Its URL and SHA256 describe that actual artifact, rather than an invented
155
+ future checksum. After the first real release, generate its usable metadata:
156
+
157
+ ```sh
158
+ python3 scripts/update_formula.py 0.1.0 --formula Formula/songe.rb
159
+ brew install --build-from-source sous-labs/tap/songe
160
+ brew test sous-labs/tap/songe
161
+ ```
162
+
163
+ Run the updater in the tap checkout, then commit/push the generated formula
164
+ before running the brew commands. The updater fetches that exact version's
165
+ PyPI JSON, selects a non-yanked universal wheel, downloads and verifies its
166
+ SHA256, and checks the package metadata and CLI entry point. It removes the
167
+ reservation disable line only after verification, rejects downgrades and
168
+ prereleases, and is idempotent for an unchanged release. If PyPI propagation
169
+ delays the JSON response, rerun after the files become visible.
170
+
171
+ The formula uses `python@3.12`, an isolated Homebrew virtualenv, the pinned
172
+ PyPI wheel, and dependency wheels from PyPI. Dependency resolution runs inside
173
+ that virtualenv and honors the package's Apple Silicon markers. Third-party
174
+ tap policy permits these wheels; dependency hashes are not locked by this
175
+ formula. `brew test` runs only `songe --version`; caveats tell users to run
176
+ `songe init`, which is deliberately not run during installation or testing.
177
+ No separate Windows installer is supplied: pip installs the same Python wheel.
178
+
179
+ For automated bumps, allow the tap workflow's `GITHUB_TOKEN` to write contents
180
+ (and ensure branch rules permit its formula commits). In `sous-labs/songe`,
181
+ configure a fine-grained token or GitHub App token as `HOMEBREW_TAP_TOKEN`,
182
+ scoped to **Contents: write** on `sous-labs/homebrew-tap` for repository
183
+ dispatch, and set the repository variable `HOMEBREW_TAP_ENABLED=true`.
184
+ The default source-repository `GITHUB_TOKEN` cannot dispatch to another private
185
+ repository. After each successful publication, `release.yml` sends a
186
+ `songe-release` dispatch; the tap workflow verifies the published wheel and
187
+ commits the version/checksum update. The tap itself needs no PyPI secret.
188
+
189
+ For the first release, or to recover a failed notification:
190
+
191
+ ```sh
192
+ gh workflow run bump-formula.yml --repo sous-labs/homebrew-tap -f version=0.1.0
193
+ ```
194
+
195
+ The tap does not need read access to the private source repository: it consumes
196
+ public PyPI artifacts. Keep the updater and workflow copies synchronized when
197
+ this repository's packaging code changes.
@@ -0,0 +1,42 @@
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: Final 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
+ - name: Pin verified PyPI wheel
33
+ env:
34
+ RELEASE_VERSION: ${{ inputs.version || github.event.client_payload.version }}
35
+ run: python scripts/update_formula.py "$RELEASE_VERSION" --formula Formula/songe.rb
36
+ - name: Commit formula update
37
+ run: |
38
+ if ! git diff --quiet -- Formula/songe.rb; then
39
+ git add Formula/songe.rb
40
+ 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'
41
+ git push origin HEAD:main
42
+ fi
@@ -0,0 +1,38 @@
1
+ class Songe < Formula
2
+ include Language::Python::Virtualenv
3
+
4
+ desc "Local hindsight distillation for a model that sleeps"
5
+ homepage "https://github.com/sous-labs/songe"
6
+ # Pinned reservation artifact. The release updater replaces these three fields
7
+ # from PyPI and removes the disable line after verifying the real CLI wheel.
8
+ url "https://files.pythonhosted.org/packages/19/3b/ac8533e3dd3fe71e501aba46c742a25209b9cde57f2296e4e7a628abac54/songe-0.0.0.dev0-py3-none-any.whl", using: :nounzip
9
+ version "0.0.0.dev0"
10
+ sha256 "2ed2600c906bb188de35b5df2f9f448c915bde562680743668eba48474b60ed7"
11
+
12
+ disable! date: "2026-11-10", because: "only the PyPI name reservation exists"
13
+
14
+ depends_on "python@3.12"
15
+
16
+ def install
17
+ python = Formula["python@3.12"].opt_bin/"python3.12"
18
+ virtualenv_create(libexec, python, system_site_packages: false)
19
+ # This third-party tap permits PyPI dependency wheels. Homebrew's helper
20
+ # disables dependency resolution, so invoke pip explicitly in our virtualenv.
21
+ system python, "-m", "pip", "--python=#{libexec}/bin/python", "install",
22
+ "--isolated", "--disable-pip-version-check", "--no-cache-dir",
23
+ "--index-url=https://pypi.org/simple", "--only-binary=:all:",
24
+ buildpath/"songe-#{version}-py3-none-any.whl"
25
+ bin.install_symlink libexec/"bin/songe"
26
+ end
27
+
28
+ def caveats
29
+ <<~EOS
30
+ Run songe init to measure your machine and configure Songe.
31
+ EOS
32
+ end
33
+
34
+ test do
35
+ ENV["SONGE_DATA_DIR"] = testpath/"data"
36
+ assert_equal version.to_s, shell_output("#{bin}/songe --version").strip
37
+ end
38
+ end