anhtnm1andClaude Opus 5 e5c184ce07 feat(gates): thêm cổng CASAN thứ tư (Gate O) và mở cổng LOC ra cả cây mã
Gate O — module production phải có ít nhất một nơi import
---------------------------------------------------------
Ba cổng đang có đều không bắt được mã chết, đúng như 1.400 dòng ở commit
trước đã chứng minh. Gate O dựng đồ thị import bằng AST từ
`__init__`/`__main__`/`app`, theo cả import muộn trong thân hàm.

Hai ngoại lệ tự động để `ALLOWLIST` không phải chép lại cùng một lý do nhiều
lần: `__init__.py` của gói mà mọi thành viên đều dormant, và module chỉ được
chính mã dormant đã miễn trừ import.

Cổng cũng đếm tuổi 9 seam chưa nối dây (nhãn `SEAM · dựng <ngày>`) và nhắc
khi quá 30 ngày. Chỉ [WARN], không làm CI đỏ: để nó đỏ thì CI sẽ đỏ vào một
buổi sáng mà không ai sửa gì, và cách nhanh nhất để xanh lại là sửa ngày.

Cổng LOC — quét 366 file thay vì 191
------------------------------------
`DEFAULT_TARGET_DIRS` chỉ có 4 gói Clean Architecture, nên một file 944 dòng
trong `ui/` vẫn qua cổng. Nay quét cả `ui/`, `core/`, `providers/`,
`security/`, `mcp_servers/` và các module ở thư mục gốc.

18 file đã dài hơn 400 dòng từ trước nằm trong `LEGACY_ALLOWANCE` — bánh cóc
chỉ quay một chiều, và nó đo DÒNG MÃ chứ không đo dòng vật lý. Bánh cóc chỉ
hỏi một câu, "file này có đang để thêm việc vào không?", mà viết thêm một
docstring thì không. Đếm dòng vật lý ở đó biến cổng thành thứ phạt người viết
tài liệu, và cách dễ nhất để làm nó xanh lại sẽ là xoá bớt chú thích. Trần
400 vẫn đếm dòng vật lý — đó là hợp đồng đã chốt của cổng S.

CI
--
Ghim tên thư mục checkout là `cowork_local`: nhiều test characterization sinh
tiến trình con `python -c "from cowork_local... import ..."`, mà tiến trình
con chỉ import được khi trên sys.path có thư mục mang đúng tên gói. Checkout
vào thư mục tên khác làm 73 test đỏ vì lý do không liên quan tới mã.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 10:36:52 +09:00
2026-08-20 12:12:56 +00:00

Cowork Local

Cowork Local is the internal AI cowork desktop platform. It provides a local-first desktop runtime, multi-turn conversational agents, workspace isolation, task scheduling, MCP connectors, security guardrails, and model routing.


🏛️ 4-Tier Clean Architecture

The codebase strictly adheres to Clean Architecture with unidirectional inward dependencies:

presentation/ (PySide6 UI, Shell, NavRail, Chat, Scheduling, Settings, Dashboard)
      │
      ▼
application/ (Pure Python Orchestration: Conversations, Scheduling, Workspaces, Monitoring, Routing)
      │
      ▼
domain/ (Pure Python: Entities, Immutable Execution Requests, Agent Events, Descriptors)
      ▲
      │
infrastructure/ (Adapters, LLM Providers, Atomic Persistence, Keyring SecretStore, MCP)
  • Domain & Application Layers: 100% Pure Python (zero Qt/UI imports).
  • Single Responsibility: Every production module is strictly <= 400 LOC.
  • Security & Durability: API keys stored in OS Keyring; atomic JSON disk persistence.

🚀 Quick Start

1. Run the Desktop Application

From the repository root:

python -m cowork_local

2. Run Automated Tests

python -m pip install -r requirements-test.txt
pytest -q

🛡️ CASAN Quality Gate & Verification

Before submitting any Pull Request, run the unified CASAN Quality Gate:

# Run all 4 quality gates (Clean Arch, Secrets, LOC, and Pytest Suite)
python scripts/run_quality_gate.py

# Run static and architectural guards only (fast check)
python scripts/run_quality_gate.py --skip-tests

Individual guard scripts:

  • Clean Architecture Import Guard: python scripts/check_imports.py
  • Secrets & Plaintext Audit: python scripts/audit_security.py
  • Single Responsibility LOC Guard: python scripts/check_loc.py --max-lines 400
  • Release E2E Smoke Test: pytest tests/e2e/test_smoke.py -v

🤝 Contributing & Recipes

S
Description
Cowork Local — internal AI cowork platform and shared foundation for FSG AI capabilities.
Readme
34 MiB
Languages
Python 97.8%
HTML 1.7%
Batchfile 0.4%