mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(agents): add a machine-wide Playwright browser resource budget
Playwright disables normal background throttling, so a hidden 5chan page keeps doing P2P and rendering work after a check finishes. Agents verifying in parallel across worktrees stacked whole browser engines on one machine. Add scripts/pw-session.sh, a wrapper that permits one active Playwright browser at a time and records who holds it: - The lock is machine-wide, not per-repository, because the contended resource is RAM and CPU. Every worktree and checkout shares one slot. - Acquisition is an atomic mkdir. Stale locks clear themselves: `open` reclaims any slot whose recorded browser is no longer `status: open` in `playwright-cli list --all`, so an interrupted workflow cannot strand the budget. When that list cannot be read the lock is left alone, so a broken CLI never silently disables the budget. - `open` exits 75 when the slot is busy; `--wait[=SECONDS]` blocks instead. - `close` always stops the browser, even when the lock was already lost, and never releases a slot held by a different session. - `status` reports the holder and whether its browser is still alive. Agent policy now runs browser engines and profiler batches sequentially, uses Chrome/Blink during iteration and the full engine matrix only for final verification, and never uses `close-all` or `kill-all` while other agents may own sessions. Covered by scripts/pw-session.test.js.
This commit is contained in:
@@ -33,6 +33,7 @@ Batch 3 (parallel): [tasks that depend on batch 2]
|
||||
**Rules:**
|
||||
|
||||
- Max 4 concurrent subagents, to bound machine load and coordination overhead
|
||||
- Never parallelize browser-driving work. Queue browser checks behind the machine-wide `./scripts/pw-session.sh` lock and run them sequentially after implementation work.
|
||||
- Tasks touching the same file(s) go in the same subagent or sequential batches — never parallel
|
||||
- Small related tasks can be grouped into one subagent to reduce overhead
|
||||
- Large independent tasks get their own subagent
|
||||
@@ -66,7 +67,7 @@ After all batches complete:
|
||||
1. Run `yarn build` to confirm everything compiles
|
||||
2. Run `yarn lint` and `yarn type-check`
|
||||
3. If the plan touched React components/hooks, run `yarn doctor`
|
||||
4. For UI changes, verify in the browser with `playwright-cli` across `chrome`, `firefox`, and `webkit`, plus a mobile viewport flow in each engine when relevant
|
||||
4. For UI changes, verify with `./scripts/pw-session.sh` across `chrome`, `firefox`, and `webkit` sequentially, reusing each engine session for the mobile viewport flow when relevant and closing it before opening the next
|
||||
|
||||
### 6. Report
|
||||
|
||||
@@ -92,5 +93,5 @@ Summarize to the user:
|
||||
|
||||
- **You orchestrate, subagents implement.** Don't code changes yourself unless it's a trivial one-liner fix for a subagent failure.
|
||||
- **Context is precious.** Every build log and file read you do in the main thread is context you can't get back. Delegate liberally.
|
||||
- **Parallelize aggressively.** The faster batches finish, the faster the plan is done. Only serialize when dependencies demand it.
|
||||
- **Parallelize non-browser work aggressively.** Browser-driving work is always serialized by the machine-wide resource lock, even when tasks are otherwise independent.
|
||||
- **Verify at the end, not in between.** Subagents run their own build checks. You do a final holistic verification.
|
||||
|
||||
Reference in New Issue
Block a user