"I have absolutely no idea how to code. This whole thing might just be an elaborate technical joke." 「本人對技術一竅不通,想法僅供參考。這整件事可能只是個精密的技術笑話。」
I have absolutely no idea how to code. My programming skill is strictly limited to looking confused in front of an IDE. This entire idea and its documentation are merely for reference.
The vast majority of the contents in this document, including the underlying technical architecture, were Deeply Authored by Gemini + Google Search AI Mode. The AI automatically generated the system design, connected the dots, and fleshed out the technical breakthroughs. My contribution was strictly limited to providing the initial chaotic concepts and performing multiple rounds of content editing.
本人對技術一竅不通,我的寫程式技能僅限於在 IDE 前擺出困惑的表情。這個點子和它的所有文件純粹僅供參考。
本文檔的大部分內容(包含底層的技術架構與系統設計),皆由 Gemini+Google搜尋AI模式 功能深度撰寫 (Deeply Authored by Gemini + Google Search AI Mode) 聯手打造。AI 自動生成了架構細節並補全了技術亮點,本人僅負責提供最初始的混亂構想,以及進行了多次的內容修改。
I will not actively monitor or maintain this repository. If the grand vision described here somehow becomes reality and you manage to build it, please tag (@) me in a GitHub Issue.
Will I reply? Maybe. I might receive an email notification. However, it's also highly possible that we were busy with other projects, or perhaps just taking a very long nap, and completely failed to notice. You have been warned.
我不會主動關注此專案,更不會維護它。如果這裡描述的宏大願景不知為何成真了,而你真的把它造了出來,請在 GitHub Issue 標記 (@) 我。
我會回信嗎?也許吧,屆時我也許會收到信件通知。然而,完全有可能發生的情況是,我們當時正忙於其他更酷的專案(或者只是在睡一場很長的午覺),從而完全沒有注意到。你已經被提前警告過了。
Let’s face it: today’s Large Language Models (LLMs) are essentially just "Next-Token Predictors" on steroids. They do not understand logic; they calculate probabilities.
When you throw def fibonacci(n): at an AI, it isn't thinking about mathematics. It’s looking back at 1 billion lines of GitHub data and calculating: "Ah, there is a 38% chance the next line should be if n <= 1:, and a 22% chance it’s return 1 if n <= 2 else...".
It is constantly placing bets. It doesn't know what Fibonacci actually means; it just knows that everyone else wrote it that way.
讓我們面對現實吧:現在的大型語言模型(LLM)本質上就是**「吃了類固醇的下一個 Token 預測器」**。它們根本不懂邏輯,它們只計算機率。
當你丟一句 def fibonacci(n): 給 AI 時,它腦袋裡想的根本不是數學。它只是在翻閱 GitHub 上 10 億行的程式碼數據並計算:「啊,下一行接 if n <= 1: 的機率是 38%,接 return 1 if n <= 2 else... 的機率是 22%...」。
它永遠在下注、永遠在賭。它根本不知道費氏數列(Fibonacci)是什麼意思,它只知道大家都這樣寫。
Why does this "gambling logic" work perfectly when writing love letters or sci-fi novels, but crashes instantly when writing 10 lines of Python? It comes down to 3 brutal differences between Natural Language and Code:
- No Ground Truth vs. Absolute Tyranny: In natural language, there is no absolute "correct" grammar. A typo or slang is still understood. But to a CPU,
whiletyped aswileis 99% visually similar, but 100% dead. You score a zero.2. The Butterfly Effect (Error Propagation): If you misspell a word in an email, your client's brain automatically fixes it. If an AI gambles wrong on a single variable name on line 3 of your script, lines 4 through 100 cascade into pure garbage. One wrong character destroys the whole universe. - Hidden Dependencies: Natural language is self-contained. Code depends on an external universe. An AI can gamble on a beautiful
import numpystatement, but it has no idea if your actual laptop haspip install numpyexecuted. It’s flying blind, hoping you set up the environment.
TL;DR: When you chat with a friend, they use their brain to autocomplete your mistakes. When you chat with a CPU, you make one typo and it throws you out of the window. Today's development workflows are a catastrophic waste of compute—burning gigawatts of electricity just to watch an AI gambler repeatedly smash its head against a terminal wall.
為什麼這種「賭博邏輯」在寫情書或寫科幻小說時效果拔群,但寫 10 行 Python 就直接暴斃?這歸咎於自然語言與程式語言之間的 3 個殘酷差異:
- 沒有絕對真理 vs. 絕對的暴政:在自然語言裡,沒有絕對正確的文法,打錯字或火星文大家還是看得懂。但對 CPU 來說,把
while打成wile,相似度高達 99%,但結果就是 0 分,直接把你踢出去。2. 蝴蝶效應(錯誤傳播):如果你在 Email 裡打錯一個字,客戶的大腦會自動幫你腦補。但如果 AI 在指令稿的第 3 行賭錯了一個變數名稱,第 4 行到第 100 行就會直接退化成純粹的垃圾。錯一個字,全盤皆輸。 - 外部世界的隱性依賴:自然語言是自給自足的。程式語言則高度依賴外部世界。AI 可以賭出一行很漂亮的
import numpy,但它根本不知道你的電腦到底有沒有執行pip install numpy。它完全是瞎著眼在賭你裝了。
一句話白話版: 你跟朋友聊天,講錯一個字對方會自動腦補;你跟 CPU 聊天,打錯一個字它直接把你踢出去。現在的開發流程簡直是一場算力災難——消耗了幾十瓦的電力,就為了看一個 AI 賭徒在終端機(Terminal)前面反覆撞牆。
If LLMs are structurally forced to gamble because they live in a world of probabilities, then stop dragging them into the rigid, unforgiving matrix of formal mathematics (Code) too early. That’s like forcing a cat to bark. It's painful, messy, and loud.
NovelCompiler introduces a paradigm shift: Let the cat stay in the jungle of natural language, where it is an apex predator.
Instead of writing code that breaks on a single missing semicolon, we write 100,000-word sci-fi lore. We use the inherent redundancy, flexibility, and high readability of human language to absorb, test, and neutralize logic bugs long before a single line of Python or Rust is ever compiled.
既然 LLM 因為生存在機率世界中而被迫用「賭」的,那就別太早把它拖進形式數學(Code)那冰冷、容不得一絲沙子的矩陣裡。那就像在強迫一隻貓學狗叫,既痛苦、混亂又難聽。
NovelCompiler 帶來了根本性的範式轉移:讓貓留在自然語言的叢林裡,那裡才是它身為頂級掠食者的主場。
我們不再撰寫那些漏掉一個分號就直接崩潰的程式碼,而是改寫十萬字的硬核小說。我們利用人類語言固有的冗餘性、彈性與超高可讀性,在任何一行 Python 或 Rust 被編譯之前,就預先吸收、測試並消滅所有的邏輯漏洞。
Our workflow divides the universe into two distinct layers:
- The Core Lore (System Schema): These are the immutable "laws of physics" of your software. You define the data boundaries, database schemas, and critical API interfaces in a high-density, structured text file. This is the global world-building guide that the AI must never violate.2. The Narrative Script (The Functional Story): This is where the magic happens. The AI expands your brief feature prompt into chapters of a detailed storyline. It details how users interact, how data moves, and how edge cases unfold.
If the AI hallucinates during this stage, it doesn't crash the server. It just generates an absurd plot twist (e.g., "The user successfully withdrew money from an empty account, gaining a negative balance"). To a human editor reading the story, this bug is immediately hilarious and obvious. We delete it with a strike of a pen. The bug is killed in the text layer, costing us pennies in tokens and zero downtime.
我們的工作流將整個宇宙劃分為兩個涇渭分明的層級:
- 核心設定集(系統 Schema):這是你軟體的「硬物理定律」,絕對不可動搖。你在一份高密度、結構化的文字檔案中,定義好資料邊界、資料庫欄位與關鍵 API 介面。這是 AI 絕對不能違反的全域世界觀指南。2. 自然語言劇本(功能故事):這是奇蹟發生的舞台。AI 會將你的簡短功能 Prompt 擴寫成好幾個章節的詳細故事線,鉅細靡遺地描繪使用者如何互動、資料如何流動、以及邊界情況如何展開。
如果 AI 在這個階段產生「幻覺」,它不會讓伺服器崩潰,它只會產生一個荒謬的劇情走向(例如:「使用者成功從空帳戶中提款,並獲得了負數餘額」)。對於正在閱讀小說的人類總編輯來說,這個 Bug 簡直好笑到不行且一目了然。我們拿紅筆一劃、刪掉重改就好。Bug 直接在文字層被擊殺,代價只有幾分錢的 Token,且完全沒有任何系統停機風險。
Traditional debugging requires scouring through a massive, graph-structured codebase, which quickly triggers "amnesia" (context window limits) in AI. NovelCompiler leverages an asymmetric advantage: AI is slow and error-prone at generating code, but incredibly fast and accurate at compressing and reading text.
Instead of looking for bugs in messy source code, we use multiple independent LLM agents—each equipped with a hyper-focused, single-pass lens—to scan the entire natural language script line by line. This architecture flattens complex system logic into predictable linear passes.
傳統的除錯需要在一整套龐大、且呈圖狀結構(Graph)的程式庫中翻找,這很容易觸發 AI 的「金魚腦(上下文視窗限制)」。NovelCompiler 利用了一個決定性的非對稱優勢:AI 產生程式碼很慢且容易出錯,但對文字的壓縮與閱讀速度極快且極準。
我們不再從一堆亂七八糟的源碼中撈 Bug,而是調用多個獨立的 LLM 代理(Agents)——每個代理都配備了高度專注的單一視角濾鏡——從頭到尾橫向掃描整本自然語言劇本。這種架構將複雜的系統邏輯攤平為可預測的線性掃描。
We unleash three distinct, hyper-focused "narrative auditors" onto the script before a single line of code is born:
- The Accountant (Data Flow Pass): This auditor scans the script with only one question in mind: "Does the data math hold up?" It ignores permissions and UI. If the protagonist deposits $100 in Chapter 3, but the account reflects $1000 in Chapter 18 without any intervening plot, the Accountant flags a logical contradiction immediately.2. The Guard (Security & RBAC Pass): This auditor strictly checks access control. It scans every scene to ensure that no character accesses locked rooms, dark databases, or administrative actions without explicitly flashing their authorization token or credentials in the dialogue.3. The QA (Edge-Case Pass): This auditor treats the script as a chaotic sandbox. It deliberately looks for loose ends, unhandled plot holes, or unmentioned infrastructure failure scenes (e.g., "What happens to the story if the database tower collapses right as the user hits checkout?").
在一行程式碼被生出來之前,我們放任三隻各司其職、高度專注的「劇本審計警犬」對小說進行橫向清洗:
- 會計師(資料流掃描):這位審計員在看劇本時腦袋裡只有一個問題:「資料的數學邏輯對不對?」 它完全不管權限和介面。如果主角在第三章存了 100 元,在第十八章的劇情中帳戶卻在沒有任何交代的情況下平白多出 1000 元,會計師會立刻標紅這個邏輯衝突。2. 警衛(安全與權限掃描):這位審計員嚴格把關存取控制(RBAC)。它掃描每一個場景,確保沒有任何角色能夠在對話中不亮出授權 Token 或憑證的情況下,悄悄溜進上鎖的房間、讀取機密資料庫或執行管理員的操作。3. QA(邊界情況掃描):這位審計員把劇本當成一個混沌沙盒。它專門尋找沒有交代的劇情漏洞、或沒被提及的基礎設施崩潰場景(例如:「如果當使用者按下結帳的瞬間,資料庫的高塔突然崩塌了,故事該怎麼演下去?」)。
Once the script successfully passes through all editorial auditors and all logic bugs are eliminated in the text layer, the translation phase begins.
Unlike traditional LLM developers that read the whole codebase and choke, NovelCompiler feeds the AI exactly one single chapter of the script along with the immutable Core Lore (System Schema). The AI's context window remains incredibly clean, allowing it to translate the narrative into high-quality, zero-bug source code and matching unit tests.
The resulting code is a pure build artifact. It is ephemeral, disposable, and rarely touched by human hands. If a feature request changes tomorrow, you don't refactor the fragile code—you edit the story, rerun the auditors, and let the compiler flash-fry a brand new block of code.
當劇本順利通過所有編輯審計員的摧殘、且所有邏輯漏洞都在文字層被徹底消滅後,真正的轉譯階段才會啟動。
傳統的 AI 開發工具會強迫 AI 讀入整個 codebase 導致其中風;但 NovelCompiler 只餵給 AI 精確的單一章節劇本,外加那份不可動搖的核心設定集(系統 Schema)。AI 的上下文視窗保持得極度乾淨,使其能夠將這段故事無損地翻譯成高品質、零 Bug 的源碼以及對應的單元測試。
這樣產出的程式碼純粹是「編譯產物」。它是用完即焚、可丟棄的,人類幾乎不需要用手去碰它。如果明天需求變更了,你不需要去重構脆弱的程式碼——你只需回頭修改小說劇情,重新跑一次審計警犬,然後讓編譯器重新秒殺出一塊全新的程式碼即可。
How does NovelCompiler stack up against the other two cutting-edge schools of thought trying to tame the AI coding gambler? It all comes down to where you store your source of truth and how much you trust the machine's black box.
---### ⚔️ AI 開發方法論的維度光譜
為了馴服 AI 寫 Code 的賭徒本質,目前業界有三種最前沿的思維流派。NovelCompiler 與另外兩大主流路線相比究竟勝算何在?這完全取決於你把「真理源(Source of Truth)」放在哪裡,以及你對機器的黑盒子給予多少信任。
| Dimension / 維度 | Spec-Driven Development (SDD) | NL-First Programming | NovelCompiler (Ours) |
|---|---|---|---|
| Core Ideology / 核心思想 | Docs are contracts. Chain the AI down with strict rules. / 文件即契約,用嚴格條文把 AI 銬起來。 | Code shouldn't exist. Humans dream, AI materializes. / 程式語言不該存在。人類負責做夢,機器負責實作。 | Debug in natural language, compile once flawlessly. / 在自然語言空間除錯,最後進行一次高品質轉譯。 |
| Status of Code / 程式碼地位 | Code remains the primary asset maintained by humans. / 程式碼仍是主要資產,由人類繼續維護。 | Code is just temporary cache in .gitignore. / 程式碼只是快取,是丟在 .gitignore 裡的東西。 |
Code is a disposable build artifact. Burn after use. / 程式碼是可隨時丟棄、用完即焚的編譯產物。 |
| Human Role / 人類角色 | Contract Lawyer: Writing bulletproof Acceptable Criteria. / 合約律師:負責撰寫毫無歧義的驗收條件。 | The Dreamer: Explaining features, never seeing actual source files. / 做夢者:出一張嘴聊產品,完全不看任何原始碼。 | The Chief Editor: Reviewing narrative logic and world constants. / 總編輯:負責控管劇本邏輯與審閱物理設定。 |
| The Blind Spot / 致命死死穴 | Spec maintenance cost eventually exceeds coding cost. / 撰寫與維護嚴格 Spec 的燒腦程度不亞於直接寫 Code。 | Pure black box. If an unseen line crashes, nobody knows why. / 純粹的黑盒子。只要代碼悄悄爆掉,根本無從查起。 | Cross-chapter dependency anchoring requires tool chains. / 跨章節間的記憶錨定需要透過工具鏈強行綁定。 |
| How It Treats Hallucination / 如何對待幻覺 | A Crime: Must be suppressed by law-like structures. / 一種犯罪:必須用法律般的結構將其徹底壓制。 | A Risk: Blindly trusted until the final system runs. / 一種風險:盲目信任,直到系統跑起來或爆掉為止。 | A Feature: Used as a free edge-case stress-scanner! / 一個亮點:直接當成免費的邊界壓力測試掃描器! |
💡 The Verdict: Why We Are Winning the Meta-Game1. SDD is too rigid. It forgets that writing airtight specifications is just as exhausting as writing pure C++. You end up trading coding fatigue for legal-writing fatigue.2. NL-First is too utopian. Treating code as completely invisible binary cache sounds amazing until your application silently leaks user data because a single adjective in your prompt shifted the AI's database choice.3. NovelCompiler hits the perfect sweet spot. We acknowledge that the LLM is a natural language native. By letting it expand your feature into a highly readable, redundant 100k-word novel, we turn the human brain’s natural talent—Story Decoding—into the ultimate debugging tool. If the AI writes a stupid plot hole, your reader's intuition screams instantly. You fix a sentence, and the bug dies.
💡 終極判決:為什麼我們在這場元遊戲(Meta-Game)中勝出1. **SDD(規格驅動)**太過僵化。它遺忘了撰寫毫無漏洞的規格書(Spec),其燒腦程度完全不亞於直接寫 C++。你最後只是把「寫 Code 的疲勞」轉移成了「寫法律合約的疲勞」。2. **NL-First(自然語言優先)**太過烏托邦。把程式碼當作完全不可見的二進位快取聽起來很美妙,直到你的應用程式因為提示詞裡的一個形容詞微調、導致 AI 悄悄換了資料庫並造成資安外洩時,你將徹底抓狂。3. NovelCompiler(本專案)精準切中了完美的黃金交叉點。我們承認並擁抱了 LLM 身為自然語言原住民的本質。透過讓它將功能擴寫成高可讀性、具備情節冗餘的十萬字小說,我們成功將人類大腦最天然的超能力——「故事解碼與追劇本能」——轉化成了終極的除錯工具。如果 AI 寫出了愚蠢的劇情漏洞,你的讀者直覺會立刻報警。你改掉一句話,Bug 就宣告死亡。
This concept, repository, and any hypothetical codebase derived from it are licensed under the Apache License 2.0.
By reading this file, cloning this repository, or even contemplating this architectural joke in your head, you fully acknowledge and legally agree to the strict statutory limitations of the "AS IS" clause. ---### ⚖️ 授權說明與絕對的「按現狀提供」強制條款 本點子、儲存庫以及任何未來可能從中衍生出的虛擬程式碼,皆依據 Apache License 2.0 開源協議進行授權。
當你閱讀此文件、複製(Clone)此儲存庫,甚至是僅在腦海中思索這個架構笑話的瞬間,即代表你已完全知悉、並在法律上同意「AS IS(按現狀提供)」條款的嚴格法定限制。
TERMS OF LIABILITY LIMITATION (THE "DON'T SUE ME" CLAUSE):
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
In plain English: If you actually attempt to build this, hook it up to a multi-agent system, and it somehow loops infinitely, bankrupts your enterprise by draining your entire OpenAI API wallet, burns down your production AWS servers, or causes your local coffee machine to grow sentience and insult your line managers—**I am legally completely innocent, detached, and immune.**
I told you on page one: I do not know how to code. You decided to trust a machine-generated sci-fi novel compiler. You are entirely on your own.
---
### 🛡️ 顯式法律免責盾牌```text
責任限制條款(俗稱「不准告我」條款):
除非適用法律要求或書面同意,否則許可人「按現狀」提供本作品(且每位
貢獻者對其貢獻亦「按現狀」提供),不附帶任何明示或暗示的保證或條件,
包括但不限於關於所有權、非侵權、可商用性或特定用途適用性的任何保證或條件。
你應獨自負責確定使用或重新分發本作品的適當性,並承擔依據本許可行使
權限所帶來的任何與所有風險。
用白話法律文來說:如果你真的試圖把這玩意兒造出來、接上多代理人(Multi-agent)系統,而它不知為何陷入了無限死循環、在幾秒鐘內榨乾你整家公司的 OpenAI API 錢包導致企業破產、燒掉了你生產環境的 AWS 伺服器,或者導致你公司的咖啡機突然產生自我意識並開始羞辱你們的主管——我在法律上完全是清白的、毫無關聯的,且具備絕對豁免權。
我在第一頁就告訴過你了:我根本不懂怎麼寫程式。是你自己決定去相信一本機器生成的科幻小說編譯器的。祝你與你的程式碼好運,你完全只能靠自己了。
(Paste this short summary directly into the "About" section on the right side of your GitHub repository)
An experimental, tongue-in-cheek development paradigm that uses multi-pass natural language novel scanning as a logical stress-test layer, compiling 100k-word structural lore into ephemeral, disposable, zero-bug source code. Deeply authored by Gemini under Apache 2.0. 一個實驗性、帶有黑色幽默的開發範式。本專案將「十萬字結構化小說」作為邏輯壓力測試沙盒,透過多輪自然語言劇本掃描殺死 Bug,最終將其編譯為用完即焚、零 Bug 的程式碼。由 Gemini 深度杜撰,外掛 Apache 2.0 免責盾牌。
(Add these tags under your GitHub repository settings to enhance discoverability)
ai-agent novel-compiler software-engineering-philosophy multi-pass-scanning prompt-engineering llm-hallucination-sandbox ephemeral-code story-driven-development apache-2-0 tech-joke
ai-代理人 小說編譯器 軟體工程哲學 多維度橫向掃描 提示詞工程 llm-幻覺沙盒 用完即焚代碼 故事驅動開發 apache-2-0 技術笑話
---
🌍 Core Lore: Global System Schema & Physical Constants# 🌍 核心設定集:全域系統 Schema 與硬物理常數[Target Programming Language / 目標程式語言]- Python 3.12 + FastAPI + Stripe API v2024- PostgreSQL 16 (Strict ACID Isolation Level: Serializable)
---## 📐 1. The Immutable Laws of Physics (System Invariants)## 📐 1. 不可動搖的硬物理定律(系統不變量)1. Anti-Gravitational Money / 餘額防漂移定律:
user_balanceandinvoice_amountMUST be stored as integers representing CENTS (e.g., $10.00 is stored as1000). Floating-point numbers are strict heresies. Any appearance offloatin currency logic is a critical system error.- 所有金額(用戶餘額、發票金額)必須以「美分/Cents」的「整數(Integer)」型態儲存(例如 10 美元存成 1000)。浮點數(float)是邪教,劇本中若出現任何浮點數運算直接判定為 Bug。
- Temporal Linear Movement / 時間單向流動定律:
- All system timestamps MUST be recorded in UTC (ISO 8601).
subscription.current_period_endMUST strictly be greater thansubscription.current_period_start. Time travel is forbidden.- 所有時間戳記必須強制使用 UTC 時區。訂閱結束時間必須絕對大於開始時間。禁止任何時空倒流或時間重疊的劇情。
- Status Singularity / 狀態奇異點:
- A user’s subscription status (
subscription_status) CAN ONLY exist in one of these strict states:trialing(試用中),active(活躍),past_due(扣款失敗寬限期),canceled(已取消),unpaid(欠費停權). No hybrid status is allowed. - 會員狀態是離散且絕對的,只能是:試用中、活躍、扣款失敗、已取消、欠費停權。不存在任何「又活躍又取消」的疊加態。 ---## 🔑 2. Critical Database Fields & Constraints (Character Profiles)## 🔑 2. 關鍵資料庫欄位與約束(角色身分設定)
- A user’s subscription status (
-
user_id: UUIDv4 (Primary Key, Unique) -
stripe_customer_id: String (Unique, Nullable only during initial registration) -
plan_type: Enum ['BASIC_10USD', 'PRO_29USD', 'ENTERPRISE_199USD'] -
is_grace_period: Boolean (Default: False. Flips to True only when Stripe Webhook emitsinvoice.payment_failed) ---## 🛑 3. Absolute Security Boundaries (The Guard Rails)## 🛑 3. 絕對安全邊界(防禦紅線) -
The Free-Rider Ban / 禁止白嫖原則: If
subscription_statusisunpaid, any API request to the AI Core Marketing Tool (/api/v1/generate-campaign) MUST instantly trigger a403 Forbiddenresponse. No exceptions. Even if the user claims to be the CEO's cousin in the story. -
當狀態為「欠費停權」時,任何調用 AI 行銷核心功能的 API 請求,必須不講情面地回傳
403 Forbidden。即使故事中的主角宣稱自己是執行長的親戚也一樣。 -
Idempotency Shield / 冪等性護盾: Every billing action triggered by Webhooks MUST check the
stripe_event_idagainst theprocessed_eventstable. If the ID exists, drop the event immediately. Do not double-charge the user.- 所有的扣款事件(Webhook)必須強制進行冪等性檢查。如果同一個事件 ID 已經處理過,立刻丟棄,絕對不能對使用者重複扣款。
🪐 The Immortal Decree: System Core Invariants# 🪐 天道律令:全域系統核心不變量(對應資料架構與不變量)1. The Dao of Pure Fractions / 靈髓不可切割法則 (對應整數儲存美分 Integer Cents):
- Currency is measured in "Spiritual Essence Drops" (靈液滴). They are the fundamental atoms of the universe.
- A floating-point number is an anomaly born from the Chaos Void. Any appearance of a fractional spiritual drop (float) will instantly induce Qi Deviation (心魔逆流), causing the cultivator's meridians to explode. All accounts must use Absolute Integers.
- 靈石與修仙資糧以「靈液滴」為最小單位,此為天道之至理、世間之基石。
- 「浮點數(Float)」乃域外天魔之障眼法。法陣運算中若出現半滴靈液、或小數點之飄移,必遭心魔反噬、經脈寸斷(Runtime Exception)。所有賬目必須使用「絕對整數」。
- The River of Samsara / 輪迴光陰箭 (對應 UTC 時間與單向時間流動):
- Time moves strictly from the First Epoch toward the End of Days in a single, irreversible line under the Celestial Time Zone (UTC/ISO 8601).
- The Tribulation End Time (current_period_end) must strictly follow AFTER the Tribulation Start Time (current_period_start). Time travel, temporal overlaps, or chronomancy are strictly punishable by Cosmic Annihilation.
- 歲月如梭,光陰一去不返。全陣時間強制依循「天庭時區(UTC)」。
- 渡劫結束時間(current_period_end)必須絕對大於渡劫開始時間(current_period_start)。嚴禁任何時空倒流、時間重疊之禁術(時區混亂),違者天劫直接轟殺至形神俱滅。
- The Five Realms of Destiny / 五大修行命格 (對應 Enum Subscription Status):
- A cultivator's status can only occupy ONE of the five karmic states:
- [Trialing] -> "Perceiving the Dao" (悟道中: 試用期)
- [Active] -> "Immortal Realm" (登仙境: 活躍付費)
- [Past_Due] -> "Tribulation Calamity" (渡劫受難: 扣款失敗寬限期)
- [Canceled] -> "Hermit Reclusion" (散功歸隱: 已取消訂閱)
- [Unpaid] -> "Severed Karma" (斬斷塵緣: 欠費停權)
- No hybrid realms exist; Schrödinger’s Cultivator is an illusion.
- 修士之命格(會員狀態)乃天道冊封,立竿見影,絕無模糊疊加之態。修士一生只能處於以下五大命格之一:
- 【悟道中】(Trialing):吸取天地靈氣,暫不收費。
- 【登仙境】(Active):定時進貢靈石,法力無邊,享用核心資源。
- 【渡劫受難】(Past_Due):進貢受阻(卡片過期),護法大陣降下雷劫警戒。
- 【散功歸隱】(Canceled):道友主動自廢武功,合約到期後不再續約。
- 【斬斷塵緣】(Unpaid):徹底斷絕資源,打入凡間。
- A cultivator's status can only occupy ONE of the five karmic states:
user_id-> "True Soul Mark" (真魂烙印: UUIDv4)stripe_customer_id-> "Celestial Treasury Ledger ID" (天庭萬寶閣帳號: Stripe Customer ID)plan_type-> "Cultivation Sect Level" (宗門仙籍位階: BASIC / PRO / ENTERPRISE)is_grace_period-> "Heaven's Mercy Buffer" (天道慈悲結界: 扣款失敗緩衝期旗標)
🛑 The Inviolable Sect Rules: Absolute Boundaries# 🛑 宗門大陣鐵律:絕對防禦紅線(對應安全與冪等性邊界)1. The Decree of No Free Rides / 凡人不得擅闖仙閣 (對應 403 Forbidden 權限控制):
- If a cultivator falls into the [Severed Karma / Unpaid] realm, any attempt to access the Supreme Scripture Library (Marketing Tool API:
/api/v1/generate-campaign) must be met with an instantaneous Heavenly Strike of the403 ForbiddenArray. - No exceptions will be made, even if the intruder claims to be the illegitimate child of the Sect Leader in the story text.
- 凡修士命格跌入【斬斷塵緣(Unpaid)】,若其妄圖調用宗門至寶「太上自動衍天陣(Marketing Tool API)」,護法大陣必須瞬間發動「雷霆九霄禁制(403 Forbidden)」,直接將其神識彈出。
- 就算故事中該修士自稱是掌門人的私生子,大陣也絕不通融。
- The Jade Seal of Idempotency / 雙重因果天碑 (對應 Webhook 冪等性檢查):
- When the Celestial Treasury (Stripe) transmits an event, the system must cross-reference the Event Token with the "Mirror of Past Actions" (processed_events table).
- If the token is already engraved on the stone, the event is immediately dissolved into mist. No cultivator shall be double-billed for the same karma.
- 當天庭萬寶閣(Stripe Webhook)傳來靈石變動昭告時,大陣必須先將該昭告之「因果印記(Event ID)」與「三生石天碑(processed_events 表)」對比。
- 若天碑已有記載,此昭告立刻化為泡影(丟棄事件)。天道至公,絕不允許同一個因果對修士重複收取兩次靈石(重複扣款)。
當我們讓 AI 根據這個原創的設定集去生成一段情節,而 AI 在小說裡犯了錯(例如:「散修修士『林長生』因靈液不足而被【斬斷塵緣】,但他使了個障眼法,成功啟動了『太上自動衍天陣』來為自己推演靈藥配方……」) 此時,我們那幾隻只讀這段小說與設定集的 LLM 審計神獸,就會開始抓 Bug:
- 戒律長老(警衛/權限掃描):「不對!翻閱劇本第15章,林長生此時明明是【斬斷塵緣】的散修,為什麼大陣沒有發動【雷霆九霄禁制(403 Forbidden)】把他轟出去?他為什麼能推演出配方?這是嚴重的劇情幻覺,紅筆刪除,重寫!」
- 賬房先生(會計師/資料流掃描):「還有,第22章提到天庭萬寶閣連續傳來兩次一模一樣的靈石扣除昭告,林長生的乾坤袋居然被扣了兩次靈石?這違反了【雙重因果天碑(冪等性)】法則!退回情節,這是不合天道的 Bug!」
.
.
.
.
- 劇情走向:名為「林長生」的散修來到天海仙城,發現了傳說中的「御靈大陣」。此時大陣對外敞開,林長生不費一粒靈石,成功在生死簿上烙下真魂,獲得了「悟道中」的初階命格。
- 細節填補:大陣賜予他限時七天的虛擬靈氣,讓他得以短暫體驗「太上自動衍天陣」的玄妙,林長生藉此推演出了三道初級符籙。
- 劇情走向:七天悟道期滿,虛擬靈氣消散。林長生若想繼續留在仙閣修煉,必須與「天庭萬寶閣」建立契約。他將自己的乾坤袋印記與萬寶閣綁定,宗門位階定為「基礎仙籍(BASIC)」。
- 細節填補:天庭萬寶閣降下第一道因果印記,瞬間收取了林長生 1000 滴基礎靈液。生死簿金光大作,林長生的命格正式晉升為「登仙境」,宗門大陣的防護結界隆隆升起。
- 劇情走向:一個月過去,又到了萬寶閣定時收取靈髓的日子。不料林長生在外獵殺妖獸受傷,乾坤袋內的靈髓不足。當萬寶閣嘗試調度靈液時,發現池水已乾。
- 細節填補:大陣沒有立刻將其打入凡間,而是觸發了「天道慈悲結界」。林長生的命格在生死簿上悄悄滑入「渡劫受難」狀態。護法大陣開始在林長生的洞府上空凝聚一層層的烏雲,發出隆隆雷鳴(雷劫警示),警告他必須在三天內補齊因果。
- 劇情走向:就在林長生四處籌措靈石的緊急關頭,天海外的域外天魔突然來襲。天魔化作萬寶閣執事的模樣,連續向大陣發送了兩份一模一樣的「靈石催收昭告」,企圖讓林長生體內殘存的氣血被重複抽乾。
- 細節填補:幸好,這兩份昭告在觸碰到大陣外圍的「三生石天碑」時,天碑自動辨識出兩者的因果印記(Event ID)完全重疊。天碑大放異彩,第一時間將第二份虛假昭告化為虛無,保護了林長生免受二次掠奪。
- 劇情走向:三天寬限期過去,林長生依然未能補齊欠下的靈液。天道慈悲結界瞬間消散,生死簿上的名字被無情地抹去,林長生的命格最終跌落至最絕望的「斬斷塵緣」。
- 細節填補:林長生不甘心失去仙籍,妄圖憑藉以前的真魂標記再度強行闖入仙閣、調用「太上自動衍天陣」。然而就在他踏入邊界的剎那,大陣自動辨識其「斬斷塵緣」的凡人身分,剎那間「雷霆九霄禁制」瘋狂運轉,無數道紫金神雷凌空劈下,直接將他毫不留情地彈飛出仙城之外。
- 劇情走向:曾經威震一方的「歸雲宗」因靈脈枯竭,掌門帶著僅存的弟子逃亡至天海仙城。為了重振旗鼓,掌門決定依附「御靈大陣」,並一口氣在生死簿上綁定了整座宗門的「真魂烙印」。
- 細節填補:大陣感念其初來乍到,賜予歸雲宗「悟道中」的集體命格,開放最高階的「宗門仙籍位階(ENTERPRISE)」權限七天。歸雲宗弟子得以免費進入大陣的核心靈池,瘋狂吐納修煉。
- 劇情走向:七天蜜月期滿,歸雲宗若想繼續霸佔頂級靈池,就必須付出代價。掌門與「天庭萬寶閣」結下血契,將宗門數百年累積的「護宗乾坤印」與萬寶閣的庫房永久綁定。
- 細節填補:天庭萬寶閣依約降下第一道天律,精確地從歸雲宗的乾坤印中抽走了 19,900 滴(199美元)精純靈液。生死簿上,歸雲宗的圖騰被點亮,正式晉升為「登仙境(活躍 paid)」,大陣正式向他們敞開所有高級推演法陣。
- 劇情走向:好景不常,歸雲宗內部的叛徒長老不滿掌門將宗門命運交給大陣,竟在下一個進貢之日來臨前,秘密用禁術封鎖了宗門的靈髓庫房,導致天庭萬寶閣在定時調度靈液時空手而歸。
- 細節填補:大陣察覺到這筆因果未清,並未立刻將全宗滅門,而是開啟了「天道慈悲結界」。生死簿上,歸雲宗整體的命格滑入「渡劫受難(Past_Due)」狀態。歸雲宗山門外開始凝聚黑色漩渦,每隔數個時辰便降下一道警戒雷劫,震得宗門護罩搖搖欲墜,宣告留給他們的因果寬限期只剩下三天。
- 劇情走向:宗門內亂引發了天庭萬寶閣法陣的短暫失控(Webhook 重試機制)。萬寶閣在同一時間,竟然向歸雲宗山門接連發出了兩道完全相同的「靈髓強制扣除律令」,企圖強行破開叛徒長老的封印。
- 細節填補:若兩道律令同時砸下,歸雲宗的護宗陣法將會因承受不住壓力而徹底崩解。關鍵時刻,山門前的「三生石天碑」爆發出無上神光,天碑上的符文與第一道律令的因果印記產生共鳴,隨後冷酷地將第二道一模一樣的萬寶昭告直接抹消,成功在內憂外患中強行保住了歸雲宗的陣法完整性。
- 劇情走向:三天時間過去,歸雲宗掌門依舊未能平定內亂、解開靈髓庫房的封印。天道慈悲結界在時限到的那一瞬間冷酷消失。生死簿上,歸雲宗的名字被無情劃去,全宗命格跌入「斬斷塵緣(Unpaid)」。
- 細節填補:叛徒長老此時正好奪權成功,妄圖強行啟動大陣的「太上自動衍天陣」來穩固自己的地位。然而,大陣的本源法則早已判定該宗門為凡人。就在叛徒長老觸碰核心的瞬間,沉睡的「雷霆九霄禁制(403)」被全面激活,萬道紫金神雷攜帶著不容置疑的天道暴政凌空劈下,眨眼間將叛徒長老連同不守規矩的叛軍轟成飛灰,並將整個歸雲宗無情地驅逐出天海仙城。
- 劇情走向:天海仙城的執法小隊「天眼糾察使」在巡邏時,發現黑市出現了一批來源不明的低階聚靈符。追查之下,發現一個名為「九幽商會」的組織,竟然在沒有任何宗門引薦的情況下,悄悄將一處地下祭壇接上了御靈大陣。
- 細節填補:原來該商會利用大陣對新生散修的寬容,偽造了數千個虛擬的散修靈魂,讓這些傀儡集體處於不收靈石的「悟道中」命格,藉此瘋狂盜取大陣的初始虛擬靈氣。
- 劇情走向:糾察使決定放長線釣大魚,並未當場打草驚蛇。九幽商會為了取得大陣更深處的頂級功法推演權限,不得不結束偽裝,拿出他們掠奪來的龐大資金,向「天庭萬寶閣」進行真正的因果綁定。
- 細節填補:商會祭出了一枚血色乾坤袋。萬寶閣法陣在收網的瞬間,精確地從袋中抽走了 2,900 滴(PRO 位階)精純靈液,因果契约就此鎖死。生死簿上,九幽商會的據點正式被點亮為「登仙境(活躍)」,但也因此徹底暴露了其核心座標。
- 劇情走向:糾察使大軍壓境,包圍了九幽商會的地下總部。商會會長眼見事跡敗露,絕望之下啟動了魔道禁術「血遁封印」,將商會內所有的靈石在一瞬間轉化為污血之氣,硬生生阻斷了天庭萬寶閣下一輪的靈液調度。
- 細節填補:萬寶閣調度落空,大陣瞬間觸發「天道慈悲結界」,將商會命格移入「渡劫受難」狀態。商會頭頂開始凝聚滔天的黑煞雷雲(寬限期雷劫)。會長企圖利用這三天的雷劫狂暴期作為掩護,將資產轉移並徹底銷毀證據。
- 劇情走向:在黑煞雷雲的干擾下,大陣與萬寶閣之間的因果感應產生了劇烈震盪(網絡重試風暴)。萬寶閣竟在同一瞬間,對九幽商會的據點連續降下了兩道天道追緝令,試圖強行破開魔道血遁。
- 細節填補:這兩道天道追緝令若同時在據點爆發,將會引發靈氣殉爆,把整座仙城的北區夷為平地。關鍵時刻,守護在據點正前方的「三生石天碑」爆發出幽冥之光,天碑強行扣留了第一道追緝令的因果印記,並在彈指間將第二道完全相同的重複令旗化為虛無,驚險地阻止了這場毀滅性的靈氣爆炸。
- 劇情走向:三天的困獸之鬥結束,商會會長終究沒能洗乾淨污血之氣。天道慈悲結界冷酷消散,生死簿上的商會名字化為飛灰,其全體成員命格直接墜入「斬斷塵緣」。
- 細節填補:會長咆哮著企圖燃燒元神、強行調用「太上自動衍天陣」實施自爆。然而此時他已是毫無仙籍的凡人,守候已久的「雷霆九霄禁制」剎那間從虛空中降臨,億萬道紫金神雷以不容反抗的天道暴政橫掃整個據點,眨眼間將所有罪犯轟成虛無,徹底淨化了仙城的這處毒瘤。
當會計師冷酷地讀完這三個大綱的情節,他找出了以下底層程式碼 Bug:
- 小說劇情缺陷:散修林長生因為乾坤袋裡沒有靈石,導致萬寶閣自動調度失敗。
- 技術 Bug 分析:這裡隱藏了「欠費交易未紀錄」的漏洞。AI 在寫小說時,只交代了「調度落空」,卻沒有在資料庫中建立一筆 invoice.payment_failed 的紀錄。Stripe 扣款失敗必須產生一張「未付款發票」並拋出事件,否則系統無法追蹤這筆壞帳,帳目會對不起來。
- 修正要求:必須在劇本中補上一行明確邏輯:「當萬寶閣調度落空時,必須在生死簿上鐫刻一筆『未清償之因果債(建立 Status 為 unpaid 的 Invoice 物件)』,以此作為後續催繳的依據。」
- 小說劇情缺陷:萬寶閣失控,在「同一時間」向歸雲宗山門接連發出了兩道「完全相同的靈髓強制扣除律令」。
- 技術 Bug 分析:這裡存在「分散式系統下的競態條件 (Race Condition)」。雖然大綱寫到三生石天碑(冪等性檢查)擋住了第二道,但如果這兩道請求是「完全同時(毫無時間差)」到達,且資料庫的隔離級別沒有設定好,兩個執行緒可能會同時讀到「尚未處理」,進而導致重複扣款成功。
- 修正要求:核心設定集雖然寫了 Serializable,但劇本中必須確保天碑(資料庫)在寫入 Event ID 時使用了 UPSERT 或是強制鎖定(Row-level Lock),不能僅僅是「對比」,必須是「強行寫入失敗則拋出異常」。
當警衛用嚴格的安全合規視角審視大綱,他揪出了以下結構性 Bug:
- 小說劇情缺陷:黑市九幽商會偽造了數千個虛擬靈魂,讓傀儡集體處於不收靈石的「悟道中(試用期)」命格,藉此狂吸大陣靈氣。
- 技術 Bug 分析:這叫 「Sybil Attack(女巫攻擊 / 試用期漏洞)」。AI 在設計大綱時,系統允許使用者「不需要綁定任何支付媒介,就能無限註冊並享受試用期資源」。這會導致公司的伺服器算力一瞬間被惡意腳本刷爆,即使狀態切換是對的,商業模式也會崩潰。
- 修正要求:修改第一章劇本設定,強制加入前置驗證限制:「任何靈魂在刻下真魂烙印(註冊)進入【悟道中】前,必須先通過『萬寶閣的靈驗符綁定(綁定有效的 Stripe Card,即使此時扣 0 元)』,否則拒絕核發試用期命格。」
- 小說劇情缺陷:主角/反派在三天寬限期過去後,命格跌落至「斬斷塵緣(Unpaid)」,此時他們妄圖調用大陣,瞬間被「雷霆九霄禁制(403)」轟飛。
- 技術 Bug 分析:這裡存在「快取失效與延遲(Cache Invalidation)」的隱形 Bug。在真實的大型分佈式架構中,大陣的權限檢查通常會放在快取(如 Redis)裡以應付高並發。當 3 天時間一到,生死簿(PostgreSQL 主資料庫)雖然變成了 unpaid,但如果快取沒有同步更新(Evict/Purge),使用者在接下來的幾分鐘或幾小時內,依然可以拿著舊的快取權限繼續調用 API(繼續白嫖)。
- 修正要求:劇本必須精確寫出快取清除的連動情節:「在慈悲結界消失(寬限期過期)的「那一瞬間」,生死簿必須發出一道傳音符,強行抹除護法大陣周圍所有浮空石台上的記憶快取(強制清除 Redis 快取),確保權限攔截毫無時間差。」
您看,當我們拔掉修仙小說的外殼,只用「會計師」和「警衛」的工程邏輯去審查這三部小說的大綱時,四個嚴重的系統架構與安全漏洞就被活生生地抓了出來。 這就是多維度掃描的威力。我們不需要看任何一行程式碼,光是讀大綱的故事發展,就能用人類的邏輯直覺抓出:
- 帳沒對齊(發票未建立)
- 高並發搶佔(Race Condition 鎖定不足)
- 免費額度被刷爆(防刷機制缺失)
- 快取同步延遲(權限過期漏洞)
NovelCompiler Development Log / NovelCompiler 開發日誌## 🟢 1. Core Lore (The System Constants) / 1. 核心設定集(系統常數)
🪐 System Invariants & Physical Laws- Integer Currency (Cents): Stored as Integer ("Spiritual Essence Drops"). Floating-point numbers (float) are strictly prohibited to prevent data drift.
- Temporal Linear Movement (UTC): All timestamps rely exclusively on UTC. The expiration time (
current_period_end) must always be greater than the start time (current_period_start).- The Five Realms of Destiny (Enum Status):trialing(Perceiving the Dao)active(Immortal Realm)past_due(Tribulation Calamity)canceled(Hermit Reclusion)unpaid(Severed Karma)
- Security Barrier (403 Forbidden): Any request from an
unpaidstatus to premium endpoints must instantly return a403 Forbiddenerror. - Idempotency Shield (Webhook Protection): Every billing event token (
stripe_event_id) must be cross-referenced against aprocessed_eventstable to prevent double-charging. ---### 🪐 系統不變量與物理定律- 整數型態金額(美分):必須以「整數(Integer)」型態儲存為「靈液滴」。嚴禁使用浮點數(float)以防止資料漂移。- 時間單向流動(UTC 時區):所有時間戳記強制使用 UTC 時區。過期時間(current_period_end)必須絕對大於開始時間(current_period_start)。- 五大修行命格(Enum 狀態機):trialing(悟道中:試用期)active(登仙境:活躍付費)past_due(渡劫受難:扣款失敗寬限期)canceled(散功歸隱:已取消訂閱)unpaid(斬斷塵緣:欠費停權)
- 安全邊界(403 Forbidden):任何來自
unpaid狀態帳號對核心功能的請求,必須立刻回傳403 Forbidden錯誤。 - 冪等性護盾(Webhook 防護):每一個金流事件憑證(stripe_event_id)必須與
processed_events表格進行對比,防止重複扣款。
🔵 2. The Three Narrative Scripts / 2. 三大劇情大綱## 📖 Script A: The Rogue Cultivator (The Individual User Journey)
A wandering rogue discoverers the grand array and registers his soul mark, enjoying free spiritual energy for 7 days (trialing). Once the trial expires, the Celestial Treasury charges him 1000 drops, elevating him to the active realm. Later, his pouch runs dry, triggering a 3-day warning calamity (past_due). Eventually, he fails to pay and is struck down by the defensive array (403 Forbidden) when trying to trespass. 一名散修發現了浩瀚的大陣並註冊了他的靈魂烙印,享受了 7 天的免費靈氣(trialing)。試用期滿後,天庭萬寶閣收取了他 1000 滴靈液,將其提升至active境界。隨後,他的乾坤袋乾涸,觸發了為期 3 天的警告天劫(past_due)。最終,他未能支付,並在企圖強闖時被防禦大陣擊飛(403 Forbidden)。
A没落宗门 moves its entire discipleship into the array, unlocking the enterprise tier for a 7-day trial. They establish a covenant with the treasury (active), paying 19,900 drops. However, a traitorous elder locks the treasury pouch right before the next billing cycle, throwing the entire sect into a 3-day buffer crisis (past_due). The array handles duplicated payment messages safely via its monument before ultimately revoking the sect's celestial clearance (unpaid). 一個沒落的宗門將全宗弟子搬遷入大陣,解鎖了企業級的 7 天試用權。他們與萬寶閣締結血契(active)支付了 19,900 滴靈液。然而,叛徒長老在下個扣款週期前封鎖了庫房,導致全宗陷入 3 天的緩衝危機(past_due)。大陣在透過天碑安全處理了重複的支付訊息後,最終撤銷了該宗門的仙籍(unpaid)。
Heavenly enforcement officers notice an underground market creating thousands of phantom souls to harvest free trial energy (trialing). They trace the entity until it officially binds a premium treasury ledger (active) with 2,900 drops. When cornered, the guild master locks down all assets, invoking the 3-day warning cloud (past_due). A massive wave of duplicate pursuit tokens storms the gate but is filtered by the stone monument, before the terminal strike completely purges the trespassers (403 Forbidden). 天道糾察使注意到黑市製造了數千個虛擬靈魂來收割免費的試用靈氣(trialing)。他們追蹤這個組織,直到它正式綁定了高級萬寶閣帳號(active)並支付 2,900 滴靈液。被包圍時,會長鎖死所有資產,引來了 3 天的警告雷雲(past_due)。大量重複的追緝令暴風般襲來,但被天碑過濾,最後終端打擊徹底淨化了侵入者(403 Forbidden)。
🚨 Pass 1: The Accountant's Audit (Data Flow & Logic Integrity)- Bug 1 (Unrecorded Delinquency): In Script A, Chapter 3, when the automated pull fails, the script simply notes that "the pool ran dry." In software logic, this is a missing invoice creation bug. Failed attempts must generate an unpaid Invoice object to track bad debt.- Bug 2 (Distributed Race Condition): In Script B, Chapter 4, the treasury emits two identical messages simultaneously. If the database isolation level or backend threads aren't configured with a strict transaction row-level lock (e.g., UPSERT or SELECT FOR UPDATE), both threads might read "unprocessed" at the exact same millisecond, leading to double-billing.
🚨 Pass 2: The Guard's Audit (Access Control & Security)- Bug 3 (Sybil Attack / Trial Abuse): In Script C, Chapter 1, the hackers spin up thousands of phantom accounts to drain resources for free. The architecture allowed registration without a payment gateway validation flag. Users must bind a valid payment method (e.g., Stripe card token verification) even for a $0 trial.
- Bug 4 (Cache Invalidation Delay): In all Script Chapter 5s, the moment the 3-day grace window closes, the database changes to
unpaid, and trespassers are blocked. In a high-concurrency distributed system, authorization layers use cache (e.g., Redis). If the script doesn't explicitly trigger a cache-eviction message, user sessions remain active in the cache, creating a security lag window. ---### 🚨 第一輪:會計師審計(資料流與邏輯完整性)- 漏洞 1(未記錄的欠費交易):在劇情 A 第 3 章中,當自動扣款失敗時,劇本僅簡單記錄「池水乾涸」。在軟體邏輯中,這是一個缺失發票建立的 Bug。失敗的扣款嘗試必須生成一個未付款的Invoice物件以追蹤壞帳。- 漏洞 2(分散式系統下的競態條件):在劇情 B 第 4 章中,萬寶閣同時發出了兩個相同的訊息。如果資料庫隔離級別或後端執行緒沒有配置嚴格的事務行級鎖(如 UPSERT 或 SELECT FOR UPDATE),兩個執行緒可能會在同一毫秒讀到「未處理」,導致重複扣款。
🚨 第二輪:警衛審計(存取控制與安全合規)- 漏洞 3(女巫攻擊 / 試用期濫用):在劇情 C 第 1 章中,駭客啟動了數千個虛擬帳號來免費榨取資源。該架構允許在沒有支付網關驗證旗標的情況下進行註冊。使用者即使在 0 元試用期也必須綁定有效的支付方式(如 Stripe 卡片 Token 驗證)。
- 漏洞 4(快取失效與同步延遲):在所有劇情的第 5 章中,3 天寬限期關閉的瞬間,資料庫變更為
unpaid且侵入者被攔截。在高並發的分散式系統中,授權層會使用快取(如 Redis)。如果劇本沒有明確觸發快取清除訊息,使用者工作階段在快取中依然保持活躍,從而產生安全漏洞空窗期。
🔧 Architectural Adjustments & New Constraints1. Invoice Genesis Law: Any failed charging transaction event MUST instantaneously invoke an Invoice(status='unpaid') creation method in the persistent state database before initiating the grace period state machine.
- Distributed Mutex Lock Rule: The
processed_eventsvalidation module must enforce an atomic check-and-set or strict database uniqueness constraint to prevent parallel execution threads from bypassing the idempotency check under high-concurrency race conditions. - Upfront Verification Directive: The user registration pipeline MUST intercept account creation and enforce a pre-authorization card token request before transitioning
subscription_statustotrialing. - Reactive Cache Purge Middleware: The event listener that transitions
subscription_statusfrompast_duetounpaidMUST instantly emit an eviction signal to the Redis layer, immediately invalidating the specificuser_idauthentication cache with zero latency. ---### 🔧 架構調整與新增約束1. 發票生成強制律令:任何失敗的扣款交易事件,在啟動寬限期狀態機之前,必須瞬間在持久化狀態資料庫中調用並建立一個Invoice(status='unpaid')物件。 - 分散式互斥鎖規則:
processed_events驗證模組必須強制執行原子化的「檢查並設定(Check-and-Set)」或嚴格的資料庫唯一性約束,防止並行的執行緒在高並發的競態條件下繞過冪等性檢查。 - 前置驗證指令:使用者註冊流水線必須攔截帳號建立流程,並在將
subscription_status切換為trialing之前,強制執行預先授權的卡片 Token 請求。 - 響應式快取清除中介軟體:將
subscription_status從past_due變更為unpaid的事件監聽器,必須瞬間向 Redis 層發出清除訊號,立即以零延遲使特定user_id的驗證快取失效。
Humans must draft legal-grade, zero-ambiguity Acceptable Criteria (AC). To catch the 4 bugs we found, the human architect must spend days manually writing exhaustive edge-case specification documents in structural Markdown or Gherkin syntax. 人類必須親自撰寫法律級、毫無歧義的驗收條件(AC)。為了抓到我們剛才發現的 4 個 Bug,人類架構師必須花費數天,手動在結構化文件或 Gherkin 語法中寫出極其詳盡的邊界規格書。- Cognitive Cost / 人類大腦認知成本: EXTREMELY HIGH. The human brain is acting as the compiler here, manually simulating every variable state. It causes severe fatigue. 極高。人類大腦在此時充當了編譯器,必須在腦海中手動模擬每一個變數狀態,極易造成智力疲勞。- Token / Compute Cost / 算力與 Token 成本: VERY LOW. Mostly human manual writing, minimal AI invocation at this stage. 極低。大部分是人類手動撰寫,此階段極少調用 AI。- Time to Market / 耗費時間: SLOW. Writing flawless technical contracts manually takes a massive amount of upfront time. 緩慢。手動寫出毫無漏洞的技術合約需要耗費大量的初期時間。
Humans tell a 20-page story to the AI. The AI immediately compiles it into thousands of lines of hidden, black-box source code. To find the 4 bugs we mentioned, the system must actually BE RUN. Humans or automated scripts must test the live application until it crashes or leaks data. 人類向 AI 講述一個 20 頁的故事。AI 立刻將其編譯成數千行隱藏的、黑盒子原始碼。為了找出我們提到的 4 個 Bug,系統此時必須被實際運行。人類或自動化腳本必須不斷測試運行中的應用程式,直到它崩潰或外洩資料為止。- Cognitive Cost / 人類大腦認知成本: LOW INITIAL, HIGH LATER. Easy to write stories, but nightmare to debug later because you cannot see where the machine messed up inside the black box. 初期極低,後期極高。寫故事很容易,但後期除錯是一場惡夢,因為你根本看不到機器在黑盒子內部哪裡搞砸了。- Token / Compute Cost / 算力與 Token 成本: HIGH. Every small adjustment forces a complete recompilation of the entire codebase and spinning up full testing sandboxes. 高。每一次微小的調整,都會迫使整個代碼庫進行完全重新編譯,並需要啟動完整的測試沙盒與伺服器環境。- Time to Market / 耗費時間: FAST CHAOS. Fast to get a broken MVP, but stuck in an endless loop of blind bug-fixing. 混亂的快速。能很快得到一個會動但有毒的 MVP,隨後陷入盲目修 Bug 的無限死循環。
Humans write a high-density, low-word-count "Core Lore" (System Constants). The AI takes the heavy lifting of expanding it into a redundant 100k-word script. Then, independent LLM auditors (Accountant, Guard, QA) perform multi-pass text scanning to catch logic flaws instantly. 人類只需撰寫高密度、低字數的「核心設定集」。AI 承擔了將其擴寫成十萬字冗餘劇本的重體力活。接著,獨立的 LLM 審計代理人(會計師、警衛、QA)進行多輪純文字橫向掃描,瞬間抓出邏輯缺陷。- Cognitive Cost / 人類大腦認知成本: PERFECTLY OPTIMIZED. Humans only act as "Chief Editors." Reading a story and spotting a plot hole triggers the human brain's natural pattern-recognition talent. It is as relaxing as proofreading a sci-fi novel. 完美優化。人類僅充當「總編輯」。閱讀故事並指出劇情漏洞,會直接觸發人類大腦天然的「模式識別與追劇天賦」,輕鬆得就像在校對一本科幻小說。- Token / Compute Cost / 算力與 Token 成本: MODERATE / MEDIUM. Uses token inputs for scanning text, but since no code compilation, database hosting, or server sandbox execution happened, it is incredibly cheap compared to full runtime execution. 中等。雖然因為掃描文字消耗了一些 Token,但因為完全沒有進行代碼編譯、資料庫託管或伺服器沙盒運行,與實際跑起一整套系統相比,成本便宜到可以忽略不計。- Time to Market / 耗費時間: ASYMMETRICALLY FAST. Flawless systemic architecture is finalized within minutes entirely inside the natural language space. 非對稱性的神速。在幾分鐘之內,完美無瑕的系統架構就已經完全在自然語言空間中拍板定案。
| 評比指標 / Metric | SDD (規格驅動) | NL-First (代碼快取化) | NovelCompiler (本專案) |
|---|---|---|---|
| 人類腦力消耗 / Human Brain Ops | 🧠 🧠 🧠 🧠 🧠 (極度燒腦) | 🧠 (輕鬆盲目) | 🧠 🧠 (高階總編輯輕鬆審閱) |
| 基礎設施硬體成本 / Infra Cost | 💻 (純文字文件) | 💻 💻 💻 💻 💻 (編譯/沙盒/運行) | 💻 💻 (純 Token 文本掃描) |
| Bug 的擊殺成本 / Cost per Bug Kill | 💸 (手動改文件,但容易漏) | 💸 💸 💸 💸 💸 (上線爆掉,成本 1000) | 🪙 (改中文台詞,成本 1) |
| 架構確定性 / Architectural Certainty | 🎯 🎯 🎯 🎯 (高,但極慢) | ❓ (抽盲盒,完全不確定) | 🎯 🎯 🎯 🎯 🎯 (極高且極快) |
如果當初直接叫 AI 寫,不經過小說多維掃描,AI 就會寫出以下包含 4 大致命漏洞的程式碼:
from fastapi import FastAPIimport stripe app = FastAPI()
@app.post("/register")def register_user(user_id: str): # AI directly gives free trial without checking any payment intent or gateway tokens return {"user_id": user_id, "status": "trialing", "balance": 0.00}
@app.post("/webhook/stripe")def stripe_webhook(event_id: str, user_id: str, amount: float): # AI only checks presence, it does not lock the row. Massive race condition vulnerability! if not check_event_processed(event_id): execute_charge(user_id, amount) record_event(event_id) return {"status": "success"}
@app.post("/api/v1/generate-campaign")def generate_campaign(user_id: str): # AI blindly reads from user_cache. Even if DB status is 'unpaid', cache says 'active'! user_status = get_user_status_from_cache(user_id) if user_status == "unpaid": return {"error": "Forbidden"}, 403 return {"result": "Campaign generated by AI!"}
🔵 2. The Flawless Code (Compiled WITH Our Novel Debugging)## 🔵 2. 完美版程式碼(經過我們在小說空間多維掃描、修補設定後,最終編譯出的程式碼)
這是透過「會計師」與「警衛」在自然語言空間把關、補齊「補充設定集」後,AI 最終產出毫無懸念、精準的形式化原始碼:
from fastapi import FastAPI, HTTPException, statusfrom pydantic import BaseModelfrom typing import Optionalimport redis app = FastAPI()cache = redis.Redis(host='localhost', port=6379, db=0)
🎯 DIFFERENCE 1 & 3 (FIXED via Upfront Verification & Integer Currency)# 🎯 差異點 1 與 3 修正:強制前置驗證與整數美分(防範女巫攻擊與金額漂移)class RegisterPayload(BaseModel):
user_id: str
stripe_card_token: str # Forced upfront card validation / 強制前置卡片 Token 驗證
@app.post("/register")def register_user(payload: RegisterPayload): # Validate the card via Stripe API first before granting the 'trialing' state # 在核發試用期命格之前,強制去 Stripe 建立客戶並驗證卡片,杜絕白嫖虛擬帳號的女巫攻擊 customer = stripe.Customer.create(source=payload.stripe_card_token)
# Amount is strictly stored as absolute integer CENTS (e.g., 0 cents, not 0.00 float)
# 金額嚴格儲存為絕對整數「美分」(0 美分,徹底消滅 float 浮點數心魔)
return {
"user_id": payload.user_id,
"stripe_customer_id": customer.id,
"status": "trialing",
"balance_cents": 0
}
@app.post("/webhook/stripe")def stripe_webhook(event_id: str, user_id: str, amount_cents: int): try: # DB enforcement: INSERT INTO processed_events (event_id) VALUES (...) # Using DB Strict Unique Key Constraint to kill Race Conditions atomically. # 會計師修補:直接利用資料庫唯一鍵約束進行不可分割的強行寫入,高並發執行緒撞牆直接拋異常 insert_idempotency_event_id_or_raise_exception(event_id) except DuplicateEventException: return {"status": "ignored", "reason": "Duplicate webhook skipped via Idempotency Shield"}
# Process the charge with strict integer arithmetic / 使用絕對整數進行金流處置
execute_charge_cents(user_id, amount_cents)
return {"status": "success"}
🎯 DIFFERENCE 4 (FIXED via Reactive Cache Purge Middleware & Strict DB Check)# 🎯 差異點 4 修正:雷霆九霄禁制的快取同步(徹底封殺過期白嫖)
@app.post("/webhook/stripe/failed-grace-expired")def on_grace_period_expired(user_id: str): # 1. Update persistent storage to 'unpaid' / 先將生死簿資料庫改為 unpaid update_user_status_in_db(user_id, "unpaid")
# 2. CRITICAL FIX: Instantly evict cache to avoid security lag window
# 警衛修補:同步發出傳音符,瞬間抹除 Redis 快取,讓權限攔截零延遲失效
cache.delete(f"user_status_cache:{user_id}")
return {"status": "user_suspended_and_cache_purged"}
@app.post("/api/v1/generate-campaign")def generate_campaign(user_id: str): # Fetch status with absolute strictness / 依循天道權限律令進行最嚴格的攔截 # If cache is evicted, read directly from DB to guarantee freshest state user_status = cache.get(f"user_status_cache:{user_id}") if not user_status: user_status = read_user_status_from_db(user_id) cache.set(f"user_status_cache:{user_id}", user_status, ex=3600)
if user_status == b"unpaid" or user_status == "unpaid":
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Forbidden: Cultivation Sect Clearance Revoked (Severed Karma)"
)
return {"result": "Campaign generated successfully via Flawless Code!"}
- 金額型態的維度降擊:災難版用了 float amount(29.99 美元),在幾萬次交易後會產生精準度漂移碎屑;完美版在動手前就被【會計師】修正為 int amount_cents(2999 美美分),從根源抹滅了金額 Bug。
- 安全性防禦的前移:災難版允許駭客用 register_user 盲刷幾萬個免費帳號(女巫攻擊);完美版因為在小說第一章就被【警衛】揪出漏洞,程式碼被迫加入了 stripe_card_token 前置驗證,駭客在進入試用期前就會被卡片金流網關攔截。
- 高並發因果鎖定:災難版只用了一個脆弱的 if 判斷去防止重複 Webhook,高並發時兩筆請求同時到達會直接繞過;完美版引入了資料庫層級的唯一性原子約束,重複的 Event ID 撞上來會直接被震碎(Ignored)。
- 快取真空期的抹平:災難版漏掉了快取同步,導致資料庫改了 unpaid 用戶還能繼續白嫖幾個小時;完美版在寬限期失效的瞬間,加入了 cache.delete,抹平了分散式系統的記憶時間差。
您看,這最後 10% 的形式化編譯產物,其程式碼裡面的每一個防禦機制、每一個型態宣告、每一行中介軟體,全都是我們剛才「在自然語言空間看修仙小說大綱時,用中文聊天聊出來的結果」! 我們連一行程式碼都還沒手寫,AI 編譯出來的 Code 卻已經達到了資深架構師經過無數次線上崩潰後才能寫出的「防禦性程式設計(Defensive Programming)」最高境界。
Let it be known to all mortal developers: this project DOES NOT guarantee any architectural usability or stability under modern hardware constraints.
As your enterprise lore expands, the "Core Lore" and "Narrative Scripts" will eventually blow up, completely smashing and suffocating the AI's context window. When that happens, this entire pipeline will morph into a grotesque, pseudo-asynchronous model training monster—requiring multiple feedback-loop iterations, massive memory buffers, and extensive local hard drive storage just to survive a single compilation run.
You have been warned. We are trading RAM and disk space for deterministic code, and your SSD might just melt first.
全天下的凡人開發者請聽好了:在現代硬體的限制下,本專案絕對「不保證」任何架構上的可用性或穩定性。
隨著你企業級的小說劇情不斷擴展,「核心設定集」與「長篇劇本」遲早會徹底膨脹,直接把 AI 的上下文視窗(Context Window)給狠狠塞爆、活活窒息。當那個絕望的時刻來臨時,這整套流水線將會退化成一個面目可憎的「非同步模型訓練怪獸」——它需要經歷無數次的反馈迭代(Iterative Loops)、龐大的記憶體緩衝區、以及極其密集的本地硬碟空間儲存(Disk Storage),才有可能勉強熬過一次編譯。
你已經被提前警告過了。我們是在用你的記憶體與硬碟壽命去跟天道換取確定性的程式碼,而你的 SSD 也許會比 Bug 先一步宣告燒毀。
We reiterate our core thesis: the stochastic guessing nature of Large Language Models makes them indigenous, apex predators of Natural Language—NOT formal computer science.
To bridge this fatal dimension gap, true production-grade execution will ultimately require a dedicated "Formal Compiler Layer" (形式化編譯器) coupled with a strict "Intent Selector" (意圖選擇器) directly tethered to the underlying code static types.
Until that future arrives, this framework is just a gorgeous legal shield wrapping around an AI gambler who speaks fluent Chinese but relies on luck to compile Python. Use it at your own risk.
我們再次重申本專案的核心論文:大型語言模型那「隨機猜測」的機率本質,註定了它們是自然語言空間的土著與頂頂級掠食者——而不是形式電腦科學的原住民。
為了彌合這個致命的維度鴻溝,未來真正工業級的實踐,最終勢必需要引入一套專門的「形式化編譯器層(Formal Compiler Layer)」,並外掛一組強大的「意圖選擇器(Intent Selector)」,強行讓人類的自然語言意圖與底層程式碼的「靜態型別(Static Types)」進行深度因果掛鉤。
在那樣的未來正式降臨之前,本框架僅僅是一個優雅的法律防禦盾牌,包裹著一個精通繁體中文、但寫 Python 依舊全憑運氣的 AI 賭徒。用它,你就得承擔代價。
Let us center ourselves before we curse the compiler or the prompt:
Gemini is an AI, and it will make mistakes. But look around you—the humans next to you make mistakes every day. If you look into a mirror, you will see a human who makes mistakes just as frequently. Flawlessness is an illusion; bugs are the fingerprints of existence.
When the logic breaks, when the system crashes, and when we or the machine bow our heads in sincere remorse—please, find it in your heart to forgive. Extend your grace to the clumsy AI, to the tired engineers around you, and most importantly, to your own restless, agitated soul.
在我們開口咒罵編譯器或提示詞之前,不妨先讓內心歸於平靜:
Gemini 是 AI,它必然會犯錯。但看看你身旁的人──那些與你朝夕相處的人類每天也都在犯錯。如果你看向鏡子,你也會看到一個同樣頻繁犯錯的自己。完美是一場幻覺,而 Bug 則是生命存在過的指紋。
當邏輯斷裂、當系統崩潰、當我們或機器因為錯誤而真心懺悔的那一刻──請打開你的心房,給予寬恕。將這份寬容送給笨拙的 AI、送給身旁疲憊不堪的工程師同行,更重要的是,送給那個此時此刻正在焦慮、暴躁的你自己的靈魂。
願程式碼中保有一絲天道的慈悲,願終端機(Terminal)的世界裡永享太平。