Three independently ugly bugs that all fed the same log flood:
* Electron's `WebFrameMain.send` writes every "Render frame was disposed"
to stderr via `console.error`. When the worker fans a second
agent-event past a reloading renderer, we produced thousands of
identical lines and stalled the main loop on stderr I/O. Added a
`mainFrame.detached` guard so the send is short-circuited before
Electron's own catch block fires, and installed a targeted filter in
`suppress-warnings.ts` (now actually imported from the entry point)
so the specific `console.error("Error sending from webFrameMain:"…)`
noise never reaches the terminal. Any other payload still surfaces.
* `dispatchAgentMessage` accepted the human-reader sentinel as a wake
target when an agent replied to `__board__` — `wakeAgentIfPossible`
then called `db.getAgent("__board__")`, threw, and the dispatcher
kept repeating on every send. Strip `HUMAN_SENDER_ID` at
`resolveMessageWakeTargets`, and keep a defense-in-depth guard in the
heartbeat so a stray caller (future automation fan-out) cannot
reintroduce the crash.
* Pi's skills loader rejects any SKILL.md whose frontmatter `name`
diverges from its parent directory. The four bundled `my-writing-style`
copies declared `name: writing-style-skill`, so every install emitted
a warning and dropped the skill. They also lived as orphan gitlinks
(mode 160000 without .gitmodules), and the global `*.md` gitignore
hid every other SKILL.md from version control. Fixed the frontmatter
to match the dir, converted the dangling submodules to plain trees,
and allowlisted `builtin-skills/**/*.md` so a fresh clone carries the
catalogue instead of silently losing it.
85 lines
2.3 KiB
Markdown
85 lines
2.3 KiB
Markdown
---
|
|
title: Eliminate Cyclic Dependencies Between Components
|
|
impact: CRITICAL
|
|
impactDescription: prevents ripple effects, enables independent deployment
|
|
tags: dep, cycles, acyclic, components
|
|
---
|
|
|
|
## Eliminate Cyclic Dependencies Between Components
|
|
|
|
The dependency graph must be a Directed Acyclic Graph (DAG). Cycles create ripple effects where changes propagate unpredictably through the system.
|
|
|
|
**Incorrect (cyclic dependency):**
|
|
|
|
```typescript
|
|
// modules/orders/OrderService.ts
|
|
import { CustomerService } from '../customers/CustomerService'
|
|
|
|
export class OrderService {
|
|
constructor(private customers: CustomerService) {}
|
|
|
|
async createOrder(customerId: string) {
|
|
const customer = await this.customers.findById(customerId)
|
|
// ...
|
|
}
|
|
}
|
|
|
|
// modules/customers/CustomerService.ts
|
|
import { OrderService } from '../orders/OrderService' // Cycle!
|
|
|
|
export class CustomerService {
|
|
constructor(private orders: OrderService) {}
|
|
|
|
async getCustomerWithOrders(customerId: string) {
|
|
const orders = await this.orders.findByCustomer(customerId)
|
|
// ...
|
|
}
|
|
}
|
|
// Neither module can be deployed or tested independently
|
|
```
|
|
|
|
**Correct (break cycle with dependency inversion):**
|
|
|
|
```typescript
|
|
// modules/orders/ports/CustomerProvider.ts
|
|
export interface CustomerProvider {
|
|
findById(id: string): Promise<Customer>
|
|
}
|
|
|
|
// modules/orders/OrderService.ts
|
|
import { CustomerProvider } from './ports/CustomerProvider'
|
|
|
|
export class OrderService {
|
|
constructor(private customers: CustomerProvider) {}
|
|
|
|
async createOrder(customerId: string) {
|
|
const customer = await this.customers.findById(customerId)
|
|
// ...
|
|
}
|
|
}
|
|
|
|
// modules/customers/CustomerService.ts
|
|
// No import from orders module
|
|
|
|
export class CustomerService implements CustomerProvider {
|
|
// Implements the interface defined in orders module
|
|
}
|
|
|
|
// modules/customers/adapters/OrderAdapter.ts
|
|
import { OrderService } from '../../orders/OrderService'
|
|
|
|
export class CustomerOrderAdapter {
|
|
constructor(private orders: OrderService) {}
|
|
|
|
async getOrdersForCustomer(customerId: string) {
|
|
return this.orders.findByCustomer(customerId)
|
|
}
|
|
}
|
|
```
|
|
|
|
**Alternative (extract shared abstraction):**
|
|
|
|
Create a new component that both depend on, breaking the cycle into a DAG.
|
|
|
|
Reference: [Clean Architecture - Acyclic Dependencies Principle](https://www.oreilly.com/library/view/clean-architecture-a/9780134494272/ch14.xhtml)
|