Skip to content

feat(docker-git): add resource limits for MCP Playwright sidecar#264

Open
konard wants to merge 3 commits intoProverCoderAI:mainfrom
konard:issue-259-9a9eea9aba5c
Open

feat(docker-git): add resource limits for MCP Playwright sidecar#264
konard wants to merge 3 commits intoProverCoderAI:mainfrom
konard:issue-259-9a9eea9aba5c

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented May 9, 2026

Summary

Adds configurable CPU and RAM limits for the MCP Playwright browser sidecar container, separate from the main service container's limits. This addresses #259, which reported that the Playwright sidecar could consume too many host resources.

  • New CLI flags: --playwright-cpu (alias --playwright-cpus) and --playwright-ram (alias --playwright-memory).
  • Defaults to 30% of the host CPU/RAM, falling back to the main service limits when not set.
  • Limits are wired through:
    • CLI parser (parser-options, parser-apply)
    • Template defaults (template-defaults)
    • Apply overrides (apply-overrides)
    • Resource normalization & resolution (resource-limits)
    • Docker Compose template (templates/docker-compose)
  • Accepts the same value formats as the existing --cpu/--ram flags: percent (30%), absolute CPU (1.5), and absolute RAM (512m, 4g, etc.).

Reproduction

Before this change, the MCP Playwright sidecar inherited only the main --cpu/--ram limits (or none), so Chromium could consume a large share of host resources during long browsing sessions.

After this change:

docker-git create my-project \
  --cpu 50% --ram 50% \
  --playwright-cpu 20% --playwright-ram 1500m

produces a docker-compose.yml where:

  • service has cpus: <50% of host> and mem_limit/memswap_limit: <50% of host>
  • playwright has cpus: <20% of host> and mem_limit/memswap_limit: 1500m

When --playwright-* flags are omitted, the sidecar falls back to the main service limits, and when those are also omitted, it uses the 30% default.

Implementation notes

  • The codebase keeps three synchronized copies (canonical packages/lib, mirror at packages/app/src/lib, and frontend subset at packages/app/src/docker-git/frontend-lib); all three were updated together.
  • Resource normalization moved into resource-limits.ts (new resolveResourceLimitsIntent helper) to keep command-builders.ts under the 300-line ESLint cap.
  • apply-overrides.ts was split into applyTokenOverrides + applyResourceOverrides to satisfy the 50-line-per-function cap.

Test plan

  • bun run typecheck passes (exit 0)
  • bun run lint passes (exit 0)
  • bun run test passes — 273 app tests + 173 lib tests
  • New unit tests:
    • packages/lib/tests/core/resource-limits.test.ts — defaults & explicit overrides for playwright limits
    • packages/lib/tests/core/templates.test.ts — docker-compose template emits separate sidecar limits
    • packages/app/tests/docker-git/parser-playwright-resource.test.ts — CLI parser accepts new flags and aliases
  • Existing CPU/RAM behavior preserved (no regressions in the resolved-limits or template tests)

Changeset

  • .changeset/playwright-resource-limits.md (minor bump for @prover-coder-ai/docker-git and @effect-template/lib)

Closes #259

konard added 2 commits May 9, 2026 17:35
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: ProverCoderAI#259
Introduce configurable CPU and RAM limits for the MCP Playwright
browser sidecar, separate from the main service container.

- Add `--playwright-cpu`/`--playwright-cpus` and
  `--playwright-ram`/`--playwright-memory` CLI flags
- Default to 30% of host resources, falling back to the main service
  limits when not set
- Wire limits through template defaults, parser, apply overrides, and
  the docker-compose template
- Mirror changes across canonical lib, app/lib, and frontend-lib paths

Closes ProverCoderAI#259
@konard konard changed the title [WIP] Сделать ограничение по потребляемым ресурсам на MCP Playright feat(docker-git): add resource limits for MCP Playwright sidecar May 9, 2026
@konard konard marked this pull request as ready for review May 9, 2026 18:29
@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 9, 2026

Working session summary

All 15 CI checks pass (Build, Types, Lint, Test, Lint Effect-TS, Snapshot, dist-deps-prune × 2, plus 7 E2E suites).

PR #264 is finalized: #264

  • Title: feat(docker-git): add resource limits for MCP Playwright sidecar
  • Status: Ready for review (no longer draft), all 15 checks green
  • Adds --playwright-cpu/--playwright-cpus and --playwright-ram/--playwright-memory flags with a 30% default, falling back to the main service limits when unset
  • Synchronized across all three lib copies (canonical, app/lib mirror, frontend-lib)
  • Ships with a changeset entry, new parser tests, plus updated resource-limits and templates tests; 273 app + 173 lib tests pass locally and on CI

This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 9, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $17.724580

📊 Context and tokens usage:

Claude Opus 4.7: (5 sub-sessions)

  1. 116.4K / 1M (12%) input tokens, 26.2K / 128K (21%) output tokens
  2. 116K / 1M (12%) input tokens, 17.6K / 128K (14%) output tokens
  3. 117.2K / 1M (12%) input tokens, 25.6K / 128K (20%) output tokens
  4. 116.7K / 1M (12%) input tokens, 31.6K / 128K (25%) output tokens
  5. 59.2K / 1M (6%) input tokens, 6.2K / 128K (5%) output tokens

Total: (13.3K new + 457.8K cache writes + 23.0M cache reads) input tokens, 132.2K output tokens, $17.724580 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.7 (claude-opus-4-7)

📎 Log file uploaded as Gist (7737KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 9, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

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.

Сделать ограничение по потребляемым ресурсам на MCP Playright

1 participant