算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
du-dum【设计与创意】Separate expensive observation from cheap decision-making in autonomous agent loops using a two-clock architecture. A fast clock accumulates data into a digest file; a slow clock reads the digest and acts only when something is pending. Idle cycles cost nothing because the action clock returns immediately after reading an empty digest. Use when build…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
以二鐘之架構分昂貴之觀察與廉價之決策於自主代理之循環。快鐘積數據入摘要文件;慢鐘讀摘要,唯於有待處理者時作為。閒循環無費,以動鐘讀空摘要即刻返。
其名出於心跳之律:du-dum,du-dum。首拍(du)觀,次拍(dum)動。多時唯首拍發。
分所有工作為觀察(廉、頻)與動作(昂、罕)。
| 鐘 | 費用型態 | 頻率 | 例 |
|---|---|---|---|
| 快(分析) | 廉:API 讀、文件解析、無 LLM | 每日 4-6 次 | 掃 GitHub 通知、解 RSS、讀日誌 |
| 慢(動作) | 昂:LLM 推理、寫操作 | 每日一次 | 草擬回覆、更新儀表板、發告警 |
預期: 清二欄之分,每操作僅屬一鐘。快鐘無 LLM 呼;慢鐘無數據搜集。
失敗時: 若一操作兼需讀與 LLM 推理(如「摘要新 issue」),分之:快鐘集原始 issue 入摘要;慢鐘摘之。摘要乃界。
摘要乃架二鐘之低頻寬訊。宜緊湊、人可讀、機可解。
pending: none 或空區)摘要結構例:
# Digest — 2026-03-22T06:30:00Z
## Pending
- PR #42 needs review response (opened 2h ago, author requested feedback)
- Issue #99 has new comment from maintainer (action: reply)
## Status
- Last analyzed: 2026-03-22T06:30:00Z
- Sources checked: github-notifications, rss-feed, error-log
- Items scanned: 14
- Items pending: 2
無待處理時:
# Digest — 2026-03-22T06:30:00Z
## Pending
(none)
## Status
- Last analyzed: 2026-03-22T06:30:00Z
- Sources checked: github-notifications, rss-feed, error-log
- Items scanned: 8
- Items pending: 0
預期: 有明 pending/empty 態之摘要模板。動鐘可由一欄或一區判是否行。
失敗時: 若摘要過巨(逾 50 行),快鐘含過多原始數據。移細節至另一數據文件,留摘要為帶指標之概要。
建於快排程而行之觀察腳本。
# Pseudocode: analyze-notifications.sh
fetch_notifications()
filter_actionable(notifications)
format_as_digest_entries(filtered)
atomic_write(digest_path, entries)
log("analyzed {count} notifications, {pending} actionable")
排程例(cron):
# Fast clock: analyze every 4 hours
30 */4 * * * /path/to/analyze-notifications.sh >> /var/log/analysis.log 2>&1
0 6 * * * /path/to/analyze-pr-status.sh >> /var/log/analysis.log 2>&1
預期: 一或多分析腳本,各生或更新摘要文件。各腳本獨立——一敗,他仍更新其區。
失敗時: 數據源若暫不可得,腳本宜記錯誤而留舊摘要項不動。切勿因源敗而清摘要——陳舊之數據於動鐘勝於無。
建讀摘要並定是否動之動作腳本。
# Pseudocode: heartbeat.sh (the slow clock)
digest = read_file(digest_path)
if digest.pending is empty:
log("heartbeat: nothing pending, exiting")
exit(0)
# Only reaches here if work exists
response = call_llm(digest.pending, system_prompt)
execute_actions(response)
archive_digest(digest_path)
log("heartbeat: processed {count} items, cost: {tokens} tokens")
排程例(cron):
# Slow clock: act once per day at 7am
0 7 * * * /path/to/heartbeat.sh >> /var/log/heartbeat.log 2>&1
預期: 動作腳本於閒循環一秒內出(僅一文件讀與空檢)。於活循環,其處理待處理項並清摘要。
失敗時: 若 LLM 呼敗,勿清摘要。待處理項留於下一動作循環。可於摘要實作重試計數以免永久失敗項之無限重試。
費用之省出於閒檢——動鐘須以最小開銷可靠分「無事」與「有事」。
# Minimal idle check
if grep -q "^(none)quot; "$DIGEST_PATH" || grep -q "pending: 0" "$DIGEST_PATH"; then
echo "$(date -u +%FT%TZ) heartbeat: idle" >> "$LOG_PATH"
exit 0
fi
預期: 閒路徑乃一文件讀後一字串匹。無網呼,除腳本自身外無進程產生。
失敗時: 若閒檢不穩(偽陽致漏工,偽陰致不必要之 LLM 呼),簡化摘要格式。頂置單一布爾欄(has_pending: true/false)最為可靠。
算預期之費以確二鐘架構之省。
fast_runs = 24 / fast_interval_hoursfast_runs * cost_per_analysis_run(若無 LLM 宜近 $0)active_days_fraction * cost_per_action_run(1 - active_days_fraction) * cost_per_idle_check(宜近 $0)費用比較例:
| 架構 | 每日費(活) | 每日費(閒) | 每月費(80% 閒) |
|---|---|---|---|
| 單循環(每 30 分 LLM 一呼) | $13.74/37h | $13.74/37h | ~$400 |
| Du-dum(6 分析 + 1 動作) | $0.30 | $0.00 | ~$6 |
預期: 成本模型示 du-dum 架構於閒日至少較原省 10 倍。
失敗時: 若模型未示明顯之省,其一或真:(a) 快鐘過頻,(b) 快鐘含隱 LLM 呼,或 (c) 系統罕閒。Du-dum 惠於高閒比之系統。若系統恆活,更簡之輪詢法或更宜。
manage-token-budget — du-dum 使其實用之成本控制框架;du-dum 為架構式,token 預算為會計層circuit-breaker-pattern — 處理失敗之情(工具壞);du-dum 處理常情(無事)。合用:du-dum 為閒檢,circuit-breaker 為敗歸observe — 快鐘之觀察方法論;du-dum 架構何時何以觀察透過摘要成可行forage-resources — 策略探索層;du-dum 為 forage-resources 運行之執行律coordinate-reasoning — 踩跡信號之模式;摘要文件乃踩跡之一形(經環境產物之間接協調)