Skip to content

Perplexity research queue + always-on browser-bridge keeper + reliability fixes#53

Merged
intellegix merged 1 commit into
masterfrom
feature/perplexity-research-queue
Jul 15, 2026
Merged

Perplexity research queue + always-on browser-bridge keeper + reliability fixes#53
intellegix merged 1 commit into
masterfrom
feature/perplexity-research-queue

Conversation

@intellegix

Copy link
Copy Markdown
Owner

Bundles the browser-bridge + Perplexity-automation infrastructure built over the last few sessions. All changes are additive and backward-compatible.

What's included

Perplexity research FIFO queue (earlier commits)

  • Cross-session global FIFO queue (research_queue.py) so concurrent /research-perplexity runs serialize instead of colliding on the shared keeper Chrome, with a central activity log + live snapshot and a queue_monitor.py sidecar. Kill-switch RESEARCH_QUEUE_ENABLED=0.

Always-on browser-bridge keeper (this session)

  • browser_bridge_keeper.py + install_bridge_keeper_task.ps1: a Task Scheduler watchdog (AtLogOn + 5 min) that keeps the Chrome hosting the bridge extension running, so the browser-bridge MCP is always connectable for remote sessions.
  • install_keeper_task.ps1: installer for the existing session_keeper.py.

Single-target command routing

  • lib/websocket-bridge.js: route each command to a single elected browser client (keeper-first via a hello role message) instead of broadcasting to every connected extension — prevents mutation commands (navigate/click/switch_tab) double-executing when two Chromes both have the extension. extension/background.js emits the hello.

Reliability fixes (empirically driven, Perplexity-verified)

  • council_browser._validate_result: gate the peak-regression truncation heuristic to non-substantial outputs, so complete 6–13K-char structured answers are no longer false-flagged as suspect_truncated (this was ~24–29% of flags). Structural checks (unclosed fence / dangling token) stay unconditional.
  • queue_monitor.py: detect stalled-near-empty runs (>300s wall-clock, <300 chars) and trigger a keeper cookie-refresh via the self-heal path.

Tests

  • New: test_validate_result.py (7), test_queue_monitor_stall.py (11), test-target-selection.js (8).
  • Regression: existing queue/monitor/wiring suites pass (37 python in-repo; node --check clean).

Notes

  • Deferred (not in this PR): true per-query auto-retry in the runner; persistent-stall escalation.
  • phase5_query.txt is a stray leftover prompt from an earlier resync — harmless but could be pruned.

🤖 Generated with Claude Code

…eeper + reliability fixes

Adds infrastructure so concurrent Claude sessions serialize Perplexity runs
and the browser-bridge Chrome stays alive for remote automation, plus two
failure-taxonomy fixes verified against a 3-day log audit.

Queue (research_queue.py + council_browser.run wiring):
- Global FIFO via atomic ticket files (ordering/visibility) + single
  active.lock (correctness) so up to N sessions serialize on the shared
  keeper Chrome instead of colliding (BROWSER_BUSY / keystroke races).
- Kill-switch RESEARCH_QUEUE_ENABLED=0; RESEARCH_QUEUE_MAX_WAIT timeout.
- Central log council-logs/perplexity-activity.jsonl + queue snapshot.

Monitoring (queue_monitor.py + research_queue_status server tool):
- Polling sidecar: pure evaluate() alert fn (stalled active, deep queue,
  long run, error/timeout) + Pushover + rate-limited keeper self-heal.
- New stalled-near-empty detector: completed runs with
  elapsed_wall_s>300 AND extracted_synthesis_chars<300 alert as
  stalled:empty:<id>, driving a keeper cookie-refresh (the root correlate).

Browser-bridge keeper (browser_bridge_keeper.py + installer):
- One-shot process-liveness keeper for the default-profile Chrome that
  hosts the bridge extension; Task Scheduler AtLogOn + 5-min watchdog.
- --stop clears keeper PID state only; never force-closes the user's Chrome.

Two-client fix (websocket-bridge.js + extension hello):
- Single-target election (keeper-first via hello role) so mutation
  commands execute once, not on every connected browser client.

Validator fix (council_browser._validate_result):
- Gate rule (d) peak-regression to len<SUBSTANTIAL_SYNTHESIS_CHARS(2500)
  so complete large structured answers stop false-flagging as truncated;
  structural rules (unclosed fence / dangling token) stay unconditional.

Tests: research_queue, queue_monitor(+stall), validate_result, wiring,
stopgap serialization, submission_lock scope, target-selection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpuwG5kvGqBwZtCKTSdAK6
@intellegix
intellegix force-pushed the feature/perplexity-research-queue branch from 19ec4e0 to 45a56a1 Compare July 14, 2026 14:56
@intellegix
intellegix merged commit badf4ae into master Jul 15, 2026
5 checks passed
@intellegix
intellegix deleted the feature/perplexity-research-queue branch July 15, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant