Skip to content

docs: 把三份裁決史表移出自動載入的 .claude/rules/(移到 docs/rulings/) - #736

Merged
kiki830621 merged 3 commits into
mainfrom
claude/trim-startup-rules
Oct 18, 2026
Merged

kiki830621 merged 3 commits into
mainfrom
claude/trim-startup-rules

Conversation

@kiki830621

@kiki830621 kiki830621 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Requested by che830621 · project thread

之前

.claude/rules/ 會在每個 session 自動注入。2026-10-15 量得 738,145 位元組(超過 30 萬 token),雲端 session 因此 context 溢出。其中三份規則檔佔了大部分:mcp-cli-parity(281,520)、zero-instance-guards(187,777)、two-kinds-of-edits(73,158)。這三份的主體都是逐輪累積的裁決史表。

之後

這三份的裁決史表與相關段落逐位元組搬到 docs/rulings/<同名>.md,該目錄不自動載入。規則檔只留規則本文、各節標題,以及指向新位置的指標。

之前(位元組) 之後(位元組)
.claude/rules/mcp-cli-parity.md 281,520 23,893
.claude/rules/zero-instance-guards.md 187,777 9,175
.claude/rules/two-kinds-of-edits.md 73,158 6,463
.claude/rules/ 合計 738,145 235,377
CLAUDE.md 42,246 42,381
每個 session 自動載入的合計 780,391 277,758

新增檔案:docs/rulings/mcp-cli-parity.md(259,453 位元組)、docs/rulings/zero-instance-guards.md(180,620 位元組,102 列)、docs/rulings/two-kinds-of-edits.md(67,915 位元組)。

做法

  • 規則檔:搬走的內容一字不改。
  • CLAUDE.md:只改搬移後會變成錯誤的那一句(zero-instance-guards 那一列,現在指向 docs/rulings/),其餘不動。
  • measurement-commands-self-prove.md、docs/zero-instance-measurements.md:只更新引用位置。後者另補一段 2026-10-15 的補記。
  • Changelog:新增 changelog/2026-10-15-rulings-out-of-autoload.md,記錄原因與搬移前後的位元組數。

改了哪些守衛、為什麼

這些守衛原本直接解析規則檔裡的表,所以要改讀新位置。沒有拿掉、跳過或放寬任何一道。

  • ZeroInstanceRowsAudit.swift
    • 裁決列、〈各列共通的東西〉與自證量測改從 docs/rulings/zero-instance-guards.md 讀取。
    • 規則檔裡若又出現裁決列,判紅。
    • 棘輪標記不論出現在規則檔或 rulings 檔,都判紅;它只能放在量測文件。
    • 檔案大小上限的檢查也涵蓋 rulings 檔。
    • rulings 檔不存在時,rc=1 並具名報錯,不會當成「沒有量測」。
  • ParityTableDrift.swift:把規則檔與 docs/rulings/mcp-cli-parity.md 接起來一起讀;rulings 檔不存在時判紅。
  • MeasuredNumbersAudit.swift:多掃一個來源 docs/rulings/*.md。
  • ProtectedInventory.swift、.githooks/protected-ratchet.txt:把 docs/rulings/*.md 三個檔加入受保護清單。
  • AuditGuardsMutations.swift、AuditGuardsMutationsData.swift
    • 把 needle 改指到新位置;agmWatched 加入兩份 rulings 檔。
    • 新增三格負控:rulings 被刪、裁決列被塞回規則檔、棘輪標記被放進規則檔。
  • TriggerCoverageMutations.swift、PluginRootsMutations.swift:建副本時一併複製 docs/rulings。
  • .github/workflows/census-parity.yml:paths 加上 "docs/rulings/**",改動 rulings 檔時也會觸發 CI。

驗證:本機沒有 Swift,靠 macOS CI(Census parity 已在 3860f6e 通過)

這個環境沒有 Swift toolchain。本機沒有編譯、沒有跑 swift test,也沒有執行任何守衛;守衛是在 CI 上執行並通過的(Census parity run 38702392253)。本機只做了以下比對,全部通過:

  • 以 python 模擬 parity-table-drift:35 個工具對 35 列,沒有差集;第一欄 token 65 = 65。
  • 以 python 模擬 zero-instance-rows-audit:102 列連續,沒有殘留在規則檔的列,也沒有未被引用的列。棘輪標記只出現在量測文件。
  • 以 python 模擬 measured-numbers-audit:docs/rulings/*.md 共 23 個來源檔,裸數字 0。
  • audit-guards-mutations 的 needle:51 個都能在目標檔裡找到(0 個找不到)。
  • trigger-coverage 的路徑:缺口 0,needle 76 個全部命中。

CI 的狀態:

  • 帳務沒有被擋:main 上最近的 census-parity.yml 與 ci.yml 都有在 macos-15 runner 上啟動並執行步驟,不是 steps=0。
  • main 的 Build 一直是紅的,這個 PR 現在一併修了。 原因之一是 Swift 對 Sources/AkashicStoreIO/DivergenceResolve.swift 裡三段很長的 + 字串串接 type-check 逾時("the compiler is unable to type-check this expression in reasonable time";census-parity.yml run 37925990395,head f2a321e,ci.yml 在同一個 commit 上也是 failure)。三處在第 149、162、188 行,分別是 .wouldContradictClassificationTail、.namedByLibraryRule、.wouldLeaveTwoConfirmedLiterals 的訊息。這個 PR(commit a5666f0)把每一段拆成幾個宣告為 String 型別的 let,訊息文字完全相同。
  • 另一個同型的既有逾時(main 上也有)在 commit 3860f6e 修掉。 位置是 Sources/AkashicAppKit/AdjudicationViews.swift:135(OrphanView.body):navigationTitle 的字串改在 private var navigationTitleText: String 裡組出,其中的三元運算拆成一個宣告為 String 型別的 let;確認對話框的訊息改用 Text(verbatim:)。畫面上顯示的文字完全相同。
  • Census parity 在 3860f6e 上通過(run 38702392253):Build 成功,26 支守衛全部跑完且乾淨,負控也包括在內。
  • 這個 PR 的 CI(census-parity)會跑 swift build 與守衛,但不跑 swift test,也不把 warning 當成 error;這兩項只會在合併後於 main 上執行,而 main 的 Build 至少從 2026-09-28 起就是紅的,所以這段期間 CI 上沒有跑過 swift test。

沒有改的地方

  • paths: frontmatter 的候選:無。 三份規則都橫跨多個程式區域,沒有一份明確只關係到單一區域,所以都沒有加。
  • 程式碼註解:有三處仍寫「見 .claude/rules/zero-instance-guards.md 第 N 列」,分別在 VenueBootstrap.swift、Organization.swift、VenueBootstrapTests.swift。那份規則檔現在會指向新位置,所以這次沒有改這些註解(changelog 有記錄)。

🤖 Generated with Claude Code

https://claude.ai/code/session_01SmKsv9UzG8wS7ZnrYhy4ck


Generated by Claude Code

.claude/rules/ 每個 session 都自動注入,2026-10-15 量到 738,145 位元組(30 萬 token 以上),
雲端 session 因此 context 溢出。mcp-cli-parity、two-kinds-of-edits、zero-instance-guards 三份的
裁決史表與相關段落逐位元組搬到 docs/rulings/<同名>.md(不自動載入),規則檔留規則本文、標題與指標。

- 自動載入:.claude/rules/ 738,145 → 235,377 位元組;連同 CLAUDE.md 780,391 → 277,758 位元組
- 守衛同批改讀新位置,不放寬任何一道:zero-instance-rows-audit、parity-table-drift、
  measured-numbers-audit、受保護清單與 ratchet、三支 mutations harness(複製 docs/rulings 進副本,
  audit-guards-mutations 多三格:rulings 被刪、列被塞回規則檔、棘輪標記放進規則檔)
- census-parity.yml 的 paths 加 docs/rulings/**
- CLAUDE.md 只改因搬移而變假的一句;changelog/2026-10-15-rulings-out-of-autoload.md

本機沒有 Swift toolchain:沒有編譯、沒有跑 swift test 與守衛,只以 python 模擬比對;靠 macOS CI 驗。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SmKsv9UzG8wS7ZnrYhy4ck
@kiki830621 kiki830621 self-assigned this Oct 15, 2026
main 的 CI(ci.yml 與 census-parity.yml)在 Build 這一步失敗:Swift 對
Sources/AkashicStoreIO/DivergenceResolve.swift 的 149:20、162:20、188:20 報
「the compiler is unable to type-check this expression in reasonable time」。
三處都是 errorDescription 裡一長串 `+`,運算元夾著 `.map { "  • " + $0 }` 的
closure 與三元運算式(wouldContradictClassificationTail、namedByLibraryRule、
wouldLeaveTwoConfirmedLiterals)。

改法:closure 與三元先拆成具型別(String)的 let,串接裡只剩字面與 String 變數;
wouldLeaveTwoConfirmedLiterals 末段的出路說明另成一個 let。子運算式的文字、
display-safe-exempt 註記與字面內容都沒改,組出來的訊息逐字相同(字面的多重集合
前後比對一致)。existingBlock 取代原本的巢狀三元,existing 為空時同樣是 ""。

本機沒有 Swift toolchain,沒有編譯、沒有跑 swift test;靠 macOS CI 驗證。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbLpV1bKG2y76nAnGyK9dp
a5666f0 修好 DivergenceResolve 之後,census-parity 的 Build 往前走到 AkashicAppKit,在
Sources/AkashicAppKit/AdjudicationViews.swift:135:25(OrphanView 的 `var body`)報
「the compiler is unable to type-check this expression in reasonable time」(run 38700806531)。
全份 log 只有這一個錯誤;akashic-guards 已經連結成功(這個 PR 改的守衛程式碼編得過)。

body 是一整串 modifier 鏈,其中兩處讓求解爆量:
- `.navigationTitle("Orphans(\(…)" + (… > 0 ? "+\(…) 附加來源" : "") + ")")`:帶插值的
  字面、三元與 `+` 夾在 navigationTitle 的多個多載裡。移成 `navigationTitleText: String`
  計算屬性,三元先拆成具型別的 let;組出來的字串逐字不變,走的仍是 StringProtocol 那個多載。
- 確認拿掉來源的訊息 `Text("…\(pending.sourcesLabel)…" + "…" + "…")`:改成
  `Text(verbatim:)`,串接直接定型成 String。`+` 的結果本來就是 String、走的就是不翻譯的
  init,顯示不變;仍是 `Text(` sink,display-safe-exempt 註記留在插值那一行。

PeopleResolveView 有同形的標題,這一輪沒有報錯,沒動。

本機沒有 Swift toolchain,沒有編譯;靠 macOS CI 驗證。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XbLpV1bKG2y76nAnGyK9dp
@kiki830621
kiki830621 marked this pull request as ready for review October 18, 2026 13:07
@kiki830621
kiki830621 merged commit e02a14a into main Oct 18, 2026
1 check passed
kiki830621 added a commit that referenced this pull request Oct 19, 2026
…t 的讀取 (#711)

- selfProofMeasurementCommands 24 → 18 格:query、graph(--output)、person、get-entry、venue、venues 會建 index 檔(scratch store 逐一量過)
- measured-numbers-audit:每一行先看長度(fence 裡的行與分隔行也一樣),判準 3 的視窗不讀超長行;讀不到的檔、沒收尾的 fence 具名紅;
  找「標題宣稱的列數」改用同一個 ATX 判準
- runGuardProcess:stdout 讀取也以期限為界,背景行程握著 pipe 時帶回已收到的輸出、rc 124;逾時不記成如預期
- 散文鏈的行數算到鏈實際接到的那一行
- 第 99 列的量測在 #736 整合後的樹上重量(補 docs/rulings、tuple 取最大改成各取最大);說法與數字的殘留收窄
- audit-guards-mutations 130 → 140:七格須紅、兩格須綠、一項後設檢查(含 b39 漏掉的 CR 與 .readOnly 對帳分支)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants