Commit Graph
769 Commits
Author SHA1 Message Date
Alexandre Teixeira f74a262f73 merge: reconcile PR 40 with current lab
Integrate lab fff55a78 into PR #40 (cc25d5ba). Lab's modular email
backend/frontend, modular settings, split stylesheets (static/style.css
stays deleted), procfs compatibility, and request-scoped TurnContract
authority win; PR #40's routing classifiers, editor/email/task features,
and style.css changes are ported into lab's module and stylesheet homes.

Integration fixes:
- settings/api.js imports ui.js under its canonical versioned URL
- browser observations keep legacy CAPTCHA/access-block evidence
- artifact turns do not re-trigger broad-web research recovery
- env reference documents PR test-tool variables; page regenerated

PR #40 defects surfaced by lab gates and fixed here:
- web_fetch generic schema drops top-level anyOf (OpenAI contract);
  the compact preview contract still requires url or urls
- get_weather registered as a brokered network read
- new lazy editor modules precached for offline use
- SearXNG pin mirrored into GPU standalone compose files
- image model picker again skips offline endpoints

Tests updated where PR #40 changed behaviour on purpose, and PR tests
moved onto lab's document_source helpers.
2026-10-01 05:03:58 +01:00
Alexandre Teixeira d63932f1ad Merge lab into fix/procfs-pid-file-liveness 2026-10-01 03:10:10 +01:00
pewdiepie-archdaemon 2e8413a54a Preserve preview harness, editor, email and task improvements
Snapshot current maintainer-preview application changes and regression fixtures for integration into lab. Excludes local runtime data, evaluation outputs and source backups. Focused Python regression selection: 140 passed; full suite not certified.
2026-10-01 01:34:26 +00:00
Alexandre Teixeira b0bc0b8c40 Merge lab into fix/6174-singleflight-cancel 2026-10-01 02:27:49 +01:00
Alexandre Teixeira bfae249120 Merge pull request #28 from o3LL/fix/cookbook-stop-procfs-guard
fix(cookbook): skip the pid sweep when the host has no procfs
2026-09-30 18:07:07 +01:00
Léo 5ce2394adb fix(browser): probe pid liveness through the platform-safe helper
_process_is_alive used os.kill(pid, 0). That probe is POSIX-only:
CPython's Windows os.kill calls TerminateProcess(handle, sig) for any
signal other than CTRL_C/CTRL_BREAK, so it terminates the process it is
asked about. This function is only reached when there is no procfs to
read a command line from, which is exactly the macOS and Windows case
the rest of this change exists to handle.

core/platform_compat.py already owns that probe and documents the
hazard; its module docstring asks callers to import from there rather
than spell a POSIX-only call out locally. Delegate to it.

pid_alive answers False where os.kill raises PermissionError — a live
process owned by another user. Both call sites want that reading: the
sweep only unlinks a pid file it wrote itself, and a pid it cannot
confirm is not the daemon it is looking for.
2026-09-30 17:13:29 +02:00
Léo 6e4b3aa5bd fix(tasks): clean up the singleflight cache on cancellation
`_cached` deduplicates the scheduler's outbound fetches — Miniflux unread
counts and MCP tool snapshots — by parking every concurrent caller on one
shared Future. Two cancellation paths left that Future stranded.

A waiter awaited the shared Future directly, so cancelling the waiter
cancelled the Future the owner and every other waiter were using. It now
awaits through `asyncio.shield`.

The owner removed its pending entry inside the success and `except Exception`
branches. `CancelledError` is a `BaseException`, so it took neither: the key
stayed in `_shared_cache_pending` pointing at a Future nobody would ever
resolve, and every later caller for that key waited forever. Cleanup moves to
a `finally` that is synchronous on purpose, and the owner cancels its own
Future so current waiters wake while a later caller can still retry.

Ported from public `dev` (`ce04dc1d`, #6174 upstream), with its test.
2026-09-30 16:05:09 +02:00
Léo f8269a829f fix(discovery): cache a successful but empty Tailscale lookup
The host cache was gated on the list being non-empty, so "queried fine, no
eligible peers" looked exactly like a cold cache and every caller paid for
another `tailscale status --json` — a subprocess with a 5s timeout.

Gate on the timestamp instead. Failures still leave the timestamp unset, so a
missing binary, a non-zero exit or unparseable output stays retryable rather
than being cached for the full TTL.

Ported from public `dev` (`affaee1e`, #6228 upstream), with its test.
2026-09-30 12:14:03 +02:00
Léo 30ef7652c0 fix(cookbook): skip the pid sweep when the host has no procfs
`_cookbook_kill_session` kills the tmux session, then sweeps /proc for
model servers that survived the SIGHUP. The sweep had no guard, so on
macOS and Windows `os.listdir("/proc")` raised FileNotFoundError after
the kill had already succeeded. The function's outer except turned that
into `{"error": "...No such file or directory: '/proc'", "exit_code": 1}`
and skipped the state write that marks the session stopped — the agent
is told a stop failed that actually worked.

Guard the sweep with a procfs check, the way `_scan_running_model_processes`
already does a few hundred lines up. The root and the check now live in
`core/platform_compat`, which is where OS differences belong and which
makes both branches patchable from a test on either kind of host.

Adds a class-level guard test: the third instance of this defect, and two
of the three were found by reading source rather than by a test.
2026-09-30 12:13:04 +02:00
Léo 6cda92080c fix(browser): stop treating a missing cmdline as proof the daemon exited
_terminate_owned_daemon() read /proc/<pid>/cmdline and, on FileNotFoundError,
unlinked the pid file on the stated assumption that "the daemon may have
exited". Off Linux that file is always missing, so the branch always fired:
the pid file of a live daemon was deleted and the daemon itself never killed.
_owned_daemon_exists() swallowed the same error and therefore always returned
False, which is precisely the state its own docstring warns about, since a
close against an unrecognised session can bootstrap a fresh daemon and wait on
its browser indefinitely.

Demonstrated on macOS before the change: a pid file holding a live pid is
removed by _terminate_owned_daemon() and _owned_daemon_exists() reports False.
After it, the file survives and the daemon is reported present.

_process_command_line() now returns None for "this host cannot tell" and
_process_is_alive() answers the separate question of whether the pid exists.
Without procfs we decline to kill a process we cannot confirm is ours, and we
only forget a pid file once the pid is genuinely gone. Linux behaviour is
unchanged: the command-line identity check still gates both paths.
2026-09-29 16:27:22 +02:00
Léo 8b85e11fb4 fix(browser): skip the Chrome sweep when the host has no procfs
_terminate_owned_chrome() walked Path("/proc") unconditionally, so on macOS
and Windows iterdir() raised FileNotFoundError out of private-browser session
shutdown. src/tools/cookbook.py already guards the same kind of scan with
os.path.isdir("/proc").

The sweep only reclaims Chrome trees that agent-browser reparented, so it is
an optimisation rather than a correctness requirement: degrade to a no-op
rather than failing the whole shutdown path.

_PROC_ROOT is a module attribute so both branches are testable on either kind
of host. The procfs-present path had no coverage at all before this.
2026-09-25 10:30:49 +02:00
Alexandre Teixeira 11ad4e2739 fix(url-safety): resolve NAT64 well-known prefix to IPv4 target
The R09 scholarly hardening routes every hop through check_outbound_url with
block_private=True. On a DNS64/NAT64 network, an IPv4-only host can resolve
through the RFC 6052 Well-Known Prefix. For example, export.arxiv.org resolved
to 64:ff9b::924b:5b2a in the reproduced environment.

CPython classifies that outer IPv6 prefix as reserved, so the URL guard rejected
the request before examining the effective IPv4 destination.

Decode addresses in exactly 64:ff9b::/96 to their embedded IPv4 destination and
evaluate that destination under the strict outbound policy.

The translated target is always checked with private-address blocking enabled.
This prevents the NAT64 prefix from becoming a path to loopback, private,
shared/CGNAT, link-local, multicast, unspecified, or other non-global IPv4
space.

Network-specific translation prefixes are not decoded. In particular,
64:ff9b:1::/48 remains subject to the existing IPv6 policy.

Coverage includes:

- public IPv4 destinations embedded through the RFC 6052 prefix
- loopback, link-local, private, CGNAT, multicast, unspecified, benchmark, and
  TEST-NET rejection
- network-specific NAT64 prefixes remaining undecoded
- deterministic scholarly provider tests without live DNS dependence
- redirect query parameter isolation
- relative redirect resolution
- HTTP error fallback behavior
- editor draft GET and DELETE behavior remaining unaffected

R09, R11, and R01 were independently audited and otherwise left unchanged.
2026-09-23 15:32:04 +01:00
Alexandre Teixeira 0784cd2fed fix(review): harden scholarly redirects, editor draft limits, and threat model
- Enforce outbound URL policy on all hops via bounded manual redirects in scholarly lookups
- Guard declared Content-Length in EditorDraftRoute before request body parsing
- Keep scholarly lookup timeouts and budgets as internal constants rather than surface env vars
- Narrow TUI threat-model description around demonstrable host shell bridge behavior
- Add behavioral regression tests for redirect security and pre-parsing body size guards
2026-09-23 12:53:06 +01:00
Alexandre Teixeira c90a81dbdc Merge commit '14afd3afb6274ff986733ddff992001e19c80e29' into fix/pr10-merge-ready 2026-09-23 12:29:27 +01:00
Léo edc94a244e fix(search): bound and police the scholarly metadata lookups
The arXiv and OpenAlex title resolvers called two hardcoded endpoints with a
hand-written "Odysseus/0.20" User-Agent, no outbound-URL policy, and a full
12s timeout each. APP_VERSION was already 1.0.3, so the agent string was wrong
the moment it was written, and a scholarly query could hold a user-facing
search open for the sum of all three hops.

Move the endpoints to named constants, build the User-Agent from APP_VERSION,
run both calls through check_outbound_url (they follow redirects, so the final
host is not the one in the constant), and give the whole SearXNG -> OpenAlex ->
arXiv chain one shared wall-clock budget.

The budget is a ContextVar rather than a parameter so the existing test doubles
for _openalex_title_results and _arxiv_title_results keep working unchanged.
2026-09-23 11:09:48 +02:00
pewdiepie-archdaemon 86f376ac3a Show provider failures as inline chat stream errors 2026-09-23 01:13:46 +00:00
Alexandre Teixeira c0b71a5cef fix(tools): constrain Python environment namespace mount 2026-09-23 00:10:50 +01:00
Alexandre Teixeira b9cccb93ac fix(tools): expose active Python environment in workspace namespace 2026-09-22 23:26:28 +01:00
Alexandre Teixeira 79a55fac38 fix(agent): preserve focused turn contracts and verified completion 2026-09-22 23:26:16 +01:00
Alexandre Teixeira 8bb48780a1 feat(provider): add lazy Featherless model discovery 2026-09-22 13:12:19 +01:00
Alexandre Teixeira 411559913c feat(ui): refine subscription model and usage controls 2026-09-22 13:12:19 +01:00
Alexandre Teixeira ed7ccfd584 feat(provider): support multiple ChatGPT subscriptions with usage 2026-09-22 13:12:19 +01:00
Alexandre Teixeira 822ceaaac4 fix(ci): make maintainer harness contract self-contained and portable 2026-09-22 11:31:45 +01:00
pewdiepie-archdaemon 297ad19248 Harden maintainer-preview harness and review fixes
Unify conversational domain routing, preserve artifact completion evidence, replace provisional tool-round prose with terminal synthesis, and resolve verified maintainer review findings across search, frontend module identity, path policy, configuration, and built-in skill startup.
2026-09-21 06:54:03 +00:00
pewdiepie-archdaemon d7cad0621f reserve wall time for artifact completion 2026-09-19 12:45:09 +00:00
pewdiepie-archdaemon efe8dbeab3 preserve research tools through artifact completion 2026-09-19 09:24:22 +00:00
pewdiepie-archdaemon 3f9ff9d580 trust runtime materialization evidence 2026-09-19 02:44:36 +00:00
pewdiepie-archdaemon e0c21b28d5 validate executable artifact completion code 2026-09-19 02:33:33 +00:00
pewdiepie-archdaemon f5e3119b10 bind directory completion to output descendants 2026-09-19 02:25:27 +00:00
pewdiepie-archdaemon 27affcdb58 use native python for directory artifact completion 2026-09-19 02:14:13 +00:00
pewdiepie-archdaemon b4cd39657d recover mixed artifact tool payloads 2026-09-19 02:07:04 +00:00
pewdiepie-archdaemon 2308ff9b80 recover concatenated artifact writes 2026-09-19 01:53:12 +00:00
pewdiepie-archdaemon b32fa31b37 bound malformed artifact recovery loops 2026-09-19 01:37:46 +00:00
pewdiepie-archdaemon fbaa184a7b recover required artifacts after tool suppression 2026-09-19 00:28:08 +00:00
pewdiepie-archdaemon d0044163bf exclude known inputs from completion artifacts 2026-09-19 00:08:57 +00:00
pewdiepie-archdaemon f086f66a4f preserve native web tools after network guard rejection 2026-09-18 21:41:24 +00:00
pewdiepie-archdaemon 75b2420239 constrain directory completion to child files 2026-09-18 20:51:04 +00:00
pewdiepie-archdaemon ceb79d072a handle directory artifact completion safely 2026-09-18 20:43:51 +00:00
pewdiepie-archdaemon 0865e0e8da require content in directory artifact outputs 2026-09-18 20:17:19 +00:00
pewdiepie-archdaemon 27e53e857c recover boundedly from action-only replies 2026-09-18 18:22:34 +00:00
pewdiepie-archdaemon d550bc0e74 bind binary completion code to required path 2026-09-18 18:16:12 +00:00
pewdiepie-archdaemon 7b5288f097 route binary artifact completion through Python 2026-09-18 18:08:32 +00:00
pewdiepie-archdaemon 43e50185f9 normalize named tool choice for Kimi thinking mode 2026-09-18 17:00:54 +00:00
pewdiepie-archdaemon 3985172885 recover empty artifact writer turns through body handoff 2026-09-18 16:33:30 +00:00
pewdiepie-archdaemon 629bd32d03 preserve output budget for artifact body recovery 2026-09-18 16:29:04 +00:00
pewdiepie-archdaemon a394ea25d3 drop provider-invalid reasoning-only history turns 2026-09-18 16:22:59 +00:00
pewdiepie-archdaemon 508e017d89 preserve DeepSeek reasoning across clean tool rounds 2026-09-18 16:16:09 +00:00
pewdiepie-archdaemon a453b71651 count artifact handoff once per response batch 2026-09-18 16:10:02 +00:00
pewdiepie-archdaemon 60de3b951f retry invalid artifact body immediately 2026-09-18 16:07:34 +00:00
pewdiepie-archdaemon a09acc43a6 retry bounded artifact body handoff 2026-09-18 16:02:26 +00:00