mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 04:44:19 +01:00
- I18: the proxy, the cockpit and opencode-web restart only when they are not running, when the run changed what they run, or when they started before a file they read changed (stale_since); units, the proxy copy and the generated opencode config are written only when their content changes. The proxy still follows an engine restart. On 1m, step 7 keeps a fitted pair under the table's bounds (oc-merge-limits.py --keep-lower, and the generator), instead of writing the bounds for the end fit to undo: 49 opencode-web and 36 cockpit starts on 2026-09-23, 79 config backups - I13: engine-inputs.py resolves a branch revision through refs/ and counts the ref, and reads the image wherever it is named (a moving tag); the flash draft vocabulary is built for MODEL_REV=main - I14: an explicit CONTEXT_MODE=native writes the native opencode limits - I15: an oc at ~/.local/bin/oc that is not ours is left alone; the command offered instead carries OPENCODE_CONFIG (I35) - I16/I17: the summary sends clients to the proxy; --no-service names what ./uninstall.sh --list shows, the key-reading provider included - tests: the smoke extraction ends at its own last check; the abort test's fake engine registers a request before its headers, as SGLang does (an abort landed in that gap once in a CI run) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.3 KiB
Python
52 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""An explicit CONTEXT_MODE=native on a 1m box brings opencode's limits down with it.
|
|
|
|
install.sh keeps the opencode limits of a 27B unit that serves a larger window than this
|
|
run computed, so that a re-install cannot shrink a 1m user's limits. Since the mode
|
|
converges on the installed unit, the only way to reach that guard is an explicit
|
|
CONTEXT_MODE=native, and that installs the native unit at step 8: the guard then kept
|
|
700,000/200,000 against a 262,144 window, a 400 past it, and advised CONTEXT_MODE=1m
|
|
(found in review, 2026-09-24). The installer's lines run here with oc-merge-limits.py
|
|
replaced by a stub that records what it is asked to write.
|
|
"""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
TEXT = (REPO / "install.sh").read_text()
|
|
START = TEXT.index(" # Never downgrade a 27B unit that serves a larger window than this run's")
|
|
END = TEXT.index(" # Offered whatever the limits branch decided above", START)
|
|
BLOCK = TEXT[START:END]
|
|
|
|
|
|
def run(env_mode):
|
|
d = pathlib.Path(tempfile.mkdtemp(prefix="native-limits-"))
|
|
(d / "unit").write_text("ExecStart=... --context-length 1010000 ...\n")
|
|
(d / "oc-merge-limits.py").write_text(
|
|
"import sys\nopen(sys.argv[0] + '.log', 'a').write(' '.join(sys.argv[1:]) + '\\n')\n")
|
|
script = ("set -euo pipefail\n"
|
|
f'REPO_DIR="{d}"; SGL_UNIT_PATH="{d}/unit"; OC_USER_CFG="{d}/opencode.json"\n'
|
|
f"CONTEXT_MODE=native; _ENV_CONTEXT_MODE={env_mode}; OC_CTX=173000; OC_OUT=64000; OC_KEEP=38000\n"
|
|
+ BLOCK)
|
|
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30)
|
|
log = d / "oc-merge-limits.py.log"
|
|
return r.stdout + r.stderr, log.read_text() if log.exists() else ""
|
|
|
|
|
|
class NativeOnA1mBox(unittest.TestCase):
|
|
def test_an_explicit_native_writes_the_native_limits(self):
|
|
out, merged = run("native")
|
|
self.assertIn("qwen38 qwen3.8-27b 173000 64000", merged, out)
|
|
self.assertNotIn("keeping the existing", out)
|
|
|
|
def test_a_mode_nobody_asked_for_still_keeps_them(self):
|
|
out, merged = run("")
|
|
self.assertIn("keeping the existing", out)
|
|
self.assertNotIn("173000", merged)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|