Compare commits

..

8 Commits

Author SHA1 Message Date
didericis-codex 2879dc34cc test(gateway): cover single and simultaneous daemon crashes
tracker-policy-pr / check-pr (pull_request) Successful in 12s
test / integration-docker (pull_request) Successful in 34s
test / unit (pull_request) Successful in 45s
lint / lint (push) Successful in 53s
test / integration-firecracker (pull_request) Successful in 3m13s
test / coverage (pull_request) Successful in 17s
test / publish-infra (pull_request) Has been skipped
2026-07-23 19:33:03 -04:00
didericis-codex 5ded28896d fix(gateway): restart dead children before completion check 2026-07-23 19:33:03 -04:00
didericis-claude 1fd79dda9a fix(egress): restart dead daemons and cap inbound scan body size (#455)
Two complementary fixes for the egress gateway OOM:

1. gateway_init: auto-restart any daemon that dies unexpectedly. The
   supervisor already had restart_daemon()/request_restart() logic; this
   wires it into tick() so an OOM-killed mitmdump is respawned without
   operator intervention. Implements the "eventual" failure policy
   described in the original module docstring.

2. egress_addon: cap response body bytes passed to the DLP inbound scan
   at EGRESS_INBOUND_SCAN_LIMIT_BYTES (default 1 MiB). mitmproxy buffers
   the full response before the hook fires; capping at scan time limits
   the additional amplification from decoded text and regex strings. Bodies
   over the limit emit an egress_scan_truncated log event. Set to 0 to
   disable the cap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 19:33:03 -04:00
Quality Badge Bot 86c7ac1843 chore: update quality badges
- Coverage: 84%
- Core coverage: 94%

[skip ci]
2026-07-23 23:29:52 +00:00
didericis-claude 2e0414f969 fix(test): restore headless unit tests broken by PTY check in e719022
test / integration-docker (push) Successful in 15s
test / unit (push) Successful in 39s
Update Quality Badges / update-badges (push) Successful in 45s
lint / lint (push) Successful in 2m36s
test / integration-firecracker (push) Successful in 5m15s
test / coverage (push) Successful in 16s
test / publish-infra (push) Successful in 1m39s
The PTY check added in e719022 calls sys.stdin.fileno() which raises
io.UnsupportedOperation under pytest's stdin capture. Guard the fileno()
call with a try/except so the check degrades cleanly to "not a tty"
instead of crashing, then stub os.isatty in the test setUp so headless
unit tests aren't blocked on a real TTY.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 23:28:55 +00:00
didericis-claude 12b071833d test: annotate _git_repo helper to satisfy pyright strict mode
test / integration-docker (push) Successful in 13s
Update Quality Badges / update-badges (push) Successful in 40s
lint / lint (push) Successful in 53s
test / integration-firecracker (push) Successful in 4m56s
test / unit (push) Failing after 33s
test / coverage (push) Has been skipped
test / publish-infra (push) Has been skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 18:32:59 -04:00
didericis-claude bf72282f8e fix(manifest): avoid KeyError when override bottle has repos absent from base
merge_bottles_runtime used .get(n, base_repos_by_name[n]) which eagerly
evaluates the default, crashing when a repo exists only in the override
bottle. Replaced with a conditional expression so the base lookup only
runs when needed.

Adds three regression tests covering override-only, base-only, and
name-collision cases.

Closes #457

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-23 18:32:59 -04:00
Quality Badge Bot f2c3710d0d chore: update quality badges
- Coverage: 83%
- Core coverage: 94%

[skip ci]
2026-07-23 22:13:28 +00:00
4 changed files with 35 additions and 2 deletions
+6 -1
View File
@@ -14,6 +14,7 @@ the private orchestrator `_launch_bottle`.
from __future__ import annotations
import argparse
import io
import os
import shutil
import sys
@@ -195,7 +196,11 @@ def _start_headless(
path, so the agent still execs on the inherited stdio/PTY — an
orchestrator allocates that PTY and relays it to its
desktop/mobile clients."""
if not os.isatty(sys.stdin.fileno()):
try:
stdin_fd = sys.stdin.fileno()
except io.UnsupportedOperation:
stdin_fd = -1
if not os.isatty(stdin_fd):
die(
"--headless requires a PTY on stdin; run via:\n"
" script -q /dev/null ./cli.py start ..."
+1 -1
View File
@@ -57,7 +57,7 @@ def _merge_two_bottles_runtime(base: "ManifestBottle", override: "ManifestBottle
n for n in override_repos_by_name if n not in base_repos_by_name
]
merged_git = tuple(
override_repos_by_name.get(n, base_repos_by_name[n])
override_repos_by_name[n] if n in override_repos_by_name else base_repos_by_name[n]
for n in merged_repos_names
)
+3
View File
@@ -69,6 +69,9 @@ class TestCmdStartHeadless(unittest.TestCase):
self._modal = patch.object(tui_mod, "name_color_modal").start()
patch.dict(os.environ, {}, clear=False).start()
os.environ.pop("BOT_BOTTLE_BACKEND", None)
# PTY check uses os.isatty(sys.stdin.fileno()); stub both so
# headless unit tests aren't blocked on a real TTY.
patch("bot_bottle.cli.start.os.isatty", return_value=True).start()
self.addCleanup(patch.stopall)
def _spec(self):
+25
View File
@@ -25,6 +25,10 @@ def _bottle(**kwargs: object) -> ManifestBottle:
return ManifestBottle.from_dict("test", kwargs)
def _git_repo(url: str) -> dict[str, object]:
return {"url": url, "key": {"provider": "gitea", "forge_token_env": "TOK"}}
class TestMergeBottlesRuntime(unittest.TestCase):
def test_single_bottle_returns_as_is(self):
b = _bottle(env={"FOO": "1"})
@@ -115,6 +119,27 @@ class TestMergeBottlesRuntime(unittest.TestCase):
self.assertEqual("2", result.env["B"])
self.assertEqual("3", result.env["C"])
def test_git_repo_only_in_override_does_not_raise(self):
# Regression for issue #457: override bottle declares a repo that the
# base doesn't have → KeyError on base_repos_by_name[n].
base = _bottle(env={"X": "base"})
override = _bottle(**{"git-gate": {"repos": {"myrepo": _git_repo("ssh://git@example.com/repo.git")}}})
result = merge_bottles_runtime([base, override])
self.assertIn("myrepo", [e.Name for e in result.git])
def test_git_repo_only_in_base_survives_override(self):
base = _bottle(**{"git-gate": {"repos": {"myrepo": _git_repo("ssh://git@example.com/repo.git")}}})
override = _bottle(env={"X": "override"})
result = merge_bottles_runtime([base, override])
self.assertIn("myrepo", [e.Name for e in result.git])
def test_git_repo_override_wins_by_name(self):
base = _bottle(**{"git-gate": {"repos": {"myrepo": _git_repo("ssh://git@base.example.com/repo.git")}}})
override = _bottle(**{"git-gate": {"repos": {"myrepo": _git_repo("ssh://git@override.example.com/repo.git")}}})
result = merge_bottles_runtime([base, override])
self.assertEqual(1, len(result.git))
self.assertEqual("ssh://git@override.example.com/repo.git", result.git[0].Upstream)
def test_empty_list_raises(self):
with self.assertRaises(ValueError):
merge_bottles_runtime([])