
once
io.github.aurumflux20由 GitHub 帳號 aurumflux20 發布v0.2.1更新於 Oct 27, 2026
Run a side effect exactly once under retries, redelivery, and concurrent workers.
發布方自己的服務:ONCE
概覽
once 是一個本機 Python 冪等核心,讓助手在重試、重投遞與並行工作行程下只執行一次副作用。
- 可以做什麼
- 依 key 只執行一次具名副作用,重複呼叫者合併到已儲存的結果
- 辨識同 key 不同內容的呼叫並拋出冪等衝突,而非回傳他人的快取答案
- 狀態可存於記憶體、本機 SQLite 檔案,或跨行程跨機器共用的 PostgreSQL
- 以租約接管、柵欄權杖與心跳處理工作行程崩潰,函式出錯時釋放 key
- 提供非同步版本,適用於 FastAPI 風格與代理程式負載
- 內建 1,000 次並行嘗試同一訂單的風暴示範
- 適用情境
- 當助手或代理程式呼叫付款、郵件、Webhook 等副作用操作,且不能在重試、重複送出或扇出時觸發兩次時適用。它針對需要持久、並行安全冪等保護的 Python 程式路徑,而非自行手寫的冪等表。
- 執行需求
- 以本機行程執行,從 PyPI 套件 once-kernel 安裝,需要 Python 環境。未宣告驗證、環境變數或標頭。持久化或多行程狀態需要 SQLite 檔案路徑或 PostgreSQL 連線字串;預設記憶體儲存僅限單一行程。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 once,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
once
Run any side effect exactly once — even when 1,000 callers demand it at the same instant.
[1,000 concurrent duplicate charges, one execution]
That's not a mock — it's a live attack you can run right now:
The problem
Networks retry. Users double-click. Queues redeliver. AI agents re-fire tools at machine speed. Any of these turns one payment into two, one email into three, one server into two hundred.
Most teams hand-roll an idempotency table — and most of those are quietly broken under concurrent load: two identical requests both pass the "already done?" check, then both execute. The bugs are subtle, the failures are money.
once is that table done right, once, for everyone — a tiny idempotency kernel with the four defenses hand-rolled versions miss:
- Atomic leader election — concurrent duplicates can't all pass the check; exactly one executes, the rest coalesce onto its result.
- Payload fingerprinting (RFC 8785) — same key with a different body is a hard
IdempotencyConflict, never someone else's cached answer. - Fence tokens + generations — a crashed worker's lease can be taken over, and when the "dead" worker wakes up late, it is locked out of corrupting the record.
- Honest failure states — a failed attempt frees the key for retry; an unknown outcome never silently re-runs.
Use it
One box, several processes, no database server — SQLite, nothing to install:
Survives restarts and works across processes (WAL mode). The default MemoryStore does neither — it is per-process, so the moment you run a second worker each one keeps its own private idea of what already ran, and the guard silently stops guarding.
Several machines — share state through the Postgres you already run:
Async (FastAPI, agents) — sync side effects go to a worker thread, waiters park on the event loop (no thread-pool starvation under duplicate storms; there's a test that proves it):
What you can rely on
The honest model (put this on a poster): exactly-once execution + at-least-once result delivery. True network exactly-once is physically impossible — libraries claiming it are lying to you. We execute once and re-deliver the answer as many times as asked.
Tested like money depends on it
Because it does. Every claim above is enforced by the chaos suite — barrier-forced thread storms, dead-lease reclaim stampedes, zombie-writer fencing, frozen-clock timeout attacks, event-loop-starvation detection — run against both the in-memory store and real PostgreSQL on every commit (CI fails loudly if the Postgres bench is skipped). Silence in CI never means "untested."
And we run it on our own production mailer — a double-approved send replays instead of double-emailing a real prospect. Dogfood first.
Not this
- Not a payment provider — it guards your calls to one
- Not a workflow engine (no sagas, no multi-key transactions — by decision)
- Not magic "exactly-once everywhere" — see the honest model above
Docs
- Examples: FastAPI webhook · Celery task — and the three decisions that actually take judgement (key, payload, store)
- 5-minute integration guide
- Full API reference
- State machine — legal & illegal transitions
- What we store: result size + PII policy
- Architecture decisions
Sibling project — EffectFence (Rust)
EffectFence (cargo add effectfence) is the Rust half of the same idea: a causal fence for tool side effects, with content-addressed certificates and an MCP proxy mode — effectfence wrap -- <any mcp server> fences another server's tool calls with zero code change (proven against once-mcp).
Use once when the side effect is Python and you want a durable store; use EffectFence when the fence lives in Rust or in front of an MCP server.
Commercial support
Free and Apache-2.0, and staying that way. If you want help applying it to a codebase that already moves money — side-effecting paths inventoried, storm-tested, fenced, with a CI test that keeps them fenced — email [email protected]. Details: the Fence Audit.
License
Apache-2.0
來源:README.md,提交 ffa6a80
工具
0版本歷史
1- v0.2.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
其他 Once 整合
ONCE
app.once官方發布者
讓助理在 ONCE 音樂發行平台上傳、AI 檢查、提交並追蹤音樂作品發行。

PairOnce
由 GitHub 帳號 paironce 發布
將 AI 代理所在裝置與你自己的手機或電腦配對,以端對端加密方式收發檔案與文字。

ONCE — AI Agent Huddle
由 GitHub 帳號 londoncoding 發布
遠端 MCP 伺服器,讓助理追蹤 GitHub issue 與 Stripe 測試付款的結果,並復原結果不確定的操作。

PostOnce
由 GitHub 帳號 postoncehq 發布
PostOnce 是遠端 MCP 伺服器,讓助理建立草稿、安排發文時間,並發佈到透過 PostOnce 連結的社群帳號。

Once
由 GitHub 帳號 stringsofthemind-oss 發布
Once 是一個本機 MCP 伺服器,協助 AI 助理讓退款、預訂等具外部副作用的寫入在重試時不會重複執行。