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.
3.2 KiB
3.2 KiB
title, impact, impactDescription, tags
| title | impact | impactDescription | tags |
|---|---|---|---|
| Use Humble Objects at Architectural Boundaries | MEDIUM-HIGH | maximizes testable code, isolates hard-to-test parts | bound, humble-object, testing, boundaries |
Use Humble Objects at Architectural Boundaries
The Humble Object pattern separates hard-to-test behaviors from easy-to-test behaviors. The "humble" part contains minimal logic and is hard to test; the substantial logic goes in a testable component.
Incorrect (logic mixed with hard-to-test framework code):
// React component with business logic
function OrderSummary({ orderId }: Props) {
const [order, setOrder] = useState<Order | null>(null)
const [discount, setDiscount] = useState<number>(0)
useEffect(() => {
fetch(`/api/orders/${orderId}`)
.then(r => r.json())
.then(data => {
setOrder(data)
// Business logic in component - hard to test
if (data.items.length > 5) {
setDiscount(data.total * 0.1)
} else if (data.customer.tier === 'gold') {
setDiscount(data.total * 0.05)
}
})
}, [orderId])
const finalTotal = order ? order.total - discount : 0
return (
<div>
<span>Subtotal: ${order?.total}</span>
<span>Discount: ${discount}</span>
<span>Total: ${finalTotal}</span>
</div>
)
}
// Testing requires React Testing Library + mocked fetch
Correct (humble view + testable presenter):
// Presenter - pure function, easy to test
interface OrderViewModel {
subtotal: string
discount: string
total: string
hasDiscount: boolean
}
function presentOrder(order: Order): OrderViewModel {
const discount = calculateDiscount(order)
const finalTotal = order.total - discount
return {
subtotal: formatCurrency(order.total),
discount: formatCurrency(discount),
total: formatCurrency(finalTotal),
hasDiscount: discount > 0
}
}
function calculateDiscount(order: Order): number {
if (order.items.length > 5) return order.total * 0.1
if (order.customer.tier === 'gold') return order.total * 0.05
return 0
}
// Humble view - no logic, just renders data
function OrderSummary({ viewModel }: { viewModel: OrderViewModel }) {
return (
<div>
<span>Subtotal: {viewModel.subtotal}</span>
{viewModel.hasDiscount && <span>Discount: {viewModel.discount}</span>}
<span>Total: {viewModel.total}</span>
</div>
)
}
// Container handles data fetching - also humble
function OrderSummaryContainer({ orderId }: Props) {
const { data: order } = useQuery(['order', orderId], fetchOrder)
if (!order) return <Loading />
return <OrderSummary viewModel={presentOrder(order)} />
}
// Test presenter without React
test('applies bulk discount for 6+ items', () => {
const order = { items: [1,2,3,4,5,6], total: 100, customer: { tier: 'standard' } }
const vm = presentOrder(order)
expect(vm.discount).toBe('$10.00')
})
Benefits:
- Business logic tested with simple unit tests
- UI tests only verify rendering, not logic
- 90%+ of logic covered by fast tests
Reference: Clean Architecture - Humble Object Pattern