7.0 KiB
7.0 KiB
AgentCompany Full System Audit + Cross-Feature Remediation (2026-03-18)
Scope and Method
- Repository scan scope:
src/main,src/preload,src/renderer,src/shared,tests,scripts, build config. - File inventory baseline:
173tracked files (rg --files | wc -l). - Validation gates executed after remediation:
pnpm typecheckpnpm lintpnpm typecheck:allpnpm test:unitpnpm test:integrationpnpm test:packagespnpm test:e2eAGENTCOMPANY_BUILD_VERSION=0.4.28 pnpm build
Mandatory Pipeline Mapping
Phase 1 (ProjectManager): Scope + Milestones
- Current working milestone interpreted as: stabilize autonomous coordination + message workflow + desktop shell release readiness.
- Release artifact target confirmed: macOS arm64 zip output in
/build/release.
Phase 2 (ResearchAnalyst): Electron + Desktop Constraints
- Security baseline validated against Electron guidance:
- renderer with
contextIsolation: true,nodeIntegration: false,sandbox: truein desktop shell and browser windows. - webview attach blocked; external navigation constrained in shell manager.
- renderer with
- Packaging/update baseline validated against
electron-builder.ymland runtime build script.
Phase 3 (TechnicalImplementationResearcher): Integration Model
- High-friction subsystem identified: message pipeline drift across API/IPC/automation/renderer.
- Root cause: duplicated validation + duplicated wake/emit logic + per-entrypoint special behavior.
- Strategy used: unify dispatch semantics in one
mainmodule and route all entrypoints through it.
Phase 4 (EnterpriseArchitect): Boundary Enforcement
- Main/preload/renderer boundary retained.
- IPC contract hardened for message semantics (
direct/department/projectrequirements). - Connector execution defaults tightened to avoid implicit unsafe permission bypass.
Phase 5-8 (Implementation + Verification)
Implemented and validated in this cycle (details below).
Cross-Feature Coupling Audit (Before Fix)
Critical coupling defects
- Message contract drift between API / IPC / automation
- Different validation, wake-up targeting, and event emission behavior.
- Direct-message send path in renderer could lose recipient context outside reply mode.
- Mark-read visibility check used bounded list (
limit=500), causing false negatives at scale. - API message write path did not emit
new-messageevent, unlike IPC/automation. - Connector execution safety policy inconsistent (
claude_localbypass always on). - Console visibility control removed from header, breaking e2e contract and operator UX.
Remediation Implemented
1) Unified message dispatch (single source of truth)
- Added:
src/main/message-dispatch.ts - Centralized:
- input normalization
- company/agent/project/parent validation
- send + event emission
- domain refresh publication
- wake target resolution by channel
2) API, IPC, automation now use same dispatch behavior
- API send route now uses
dispatchAgentMessageand shared schema parse. - IPC send handler now uses
dispatchAgentMessage. - Automation actions (
send_message, escalation, cross-department notify) now usedispatchAgentMessage.
3) IPC + API mark-read visibility correction
- Added
messageIdfilter support todb.listAgentMessages(...). - Replaced broad visibility scans with targeted message visibility lookup (
limit: 1+messageId). - Removed over-restrictive direct-recipient-only mark-read branch to avoid false denial when sender marks visible thread entries.
4) API event parity restored
AgentApiServernow receives and usesemitEventcallback.- API-originated message writes now emit
new-messageevent consistently with IPC/automation.
5) Connector security tightening
claude_localexecution config now tiesdangerouslySkipPermissionstoAGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS(default false)..env.exampledocuments this guard variable.
6) Renderer communication channel correctness
- DM channels now store participant sets and resolve recipient deterministically for composer send path.
- Compose modal enforces target requirements per channel (department/project require target; non-target channels clear target state).
7) Contract hardening
agentMessageInputSchema.superRefine(...)enforces:- direct must provide
toAgentId - department/project must provide
channelTargetId - non-direct must not provide
toAgentId
- direct must provide
- Dispatch layer now enforces the same non-direct recipient prohibition, eliminating API/automation semantic mismatch.
8) Desktop UX/e2e compatibility restore
- Restored header
Show console / Hide consolecontrol inApp.tsxwith stable ARIA/title semantics used by e2e.
Adversarial Review (Opposite Model CLI)
- Ran
claude -pin three lenses:skeptic,architect,minimalist. - Output artifacts stored under
/tmp/adversarial-review-agentcompany-20260318-120225/. - Key accepted findings addressed in this cycle:
- unsafe connector bypass inconsistency
- API event parity gap
- bounded mark-read visibility check correctness gap
- Remaining contested/medium findings (deferred) tracked in “Open Risks”.
Open Risks / Remaining Work
resolveMessageWakeTargetsis snapshot-based and can be heavy at larger org scale.- Incident/company channel wake fan-out can cause high wake volume without throttling.
- Message attachment JSON is stored as raw string; no structural JSON validation yet.
- Some renderer DM channel avatar semantics still depend on ambiguous channel-level
agentIdfor two-party threads. - Update/notarization production credential flow still depends on release environment material availability.
Verification Evidence
- Type safety: pass (
pnpm typecheck,pnpm typecheck:all). - Lint: pass (
pnpm lint). - Unit/integration/package tests: pass.
- E2E smoke: pass.
- Build packaging:
- build folder cleaned by script
- version used:
0.4.28 - artifact produced:
build/release/AgentCompany-0.4.28-arm64-mac.zip
External Research References
- Electron security checklist and architecture guidance:
- Preload and contextBridge guidance:
- BrowserWindow/webPreferences hardening:
- Utility/background process model:
- Packaging and auto-update config:
Changed Files (this remediation wave)
src/main/message-dispatch.ts(new)src/main/api-server.tssrc/main/ipc-agent-coordination-handlers.tssrc/main/database.tssrc/main/automation-service.tssrc/main/bootstrap-application.tssrc/main/orchestrator/worker.tssrc/shared/contracts.tssrc/renderer/components/communication.tsxsrc/renderer/App.tsx.env.examplepackage.json