8.4
Learning a domain in batches分批學一個領域分批学一个领域
This chapter follows The audit. The map is now trusted enough to learn from. This is steps four to six of the road. It leans on Context budget for why one big context is a bad place to learn a lot. Two words from earlier: a task is one piece of work with a plan, a to-do list and its own files (5.1); a write-back is the single copy of finished work into the base, which a person approves (5.3).
這一章接在 地圖對不對:盲抽查 後面。地圖現在可信到足以拿來學。這是路線的第四到第六步。它靠 上下文是一份預算 來說明,為什麼一個大的上下文不適合一次學很多。前面出現過的兩個詞:任務是一件有計劃、待辦清單和自己檔案的工作(5.1);寫回是把做完的工作一次複製進知識庫,由人批准(5.3)。
这一章接在地图对不对:盲抽查后面。地图现在可信了,可以拿来学。这是路线的第四到第六步。为什么在一个大上下文里学很多东西不合适,要靠上下文是一份预算来理解。先回顾前面出现过的两个词:任务是一件有计划、待办清单和自己文件的工作(5.1);写回是把做完的工作一次性复制进知识库,由人审批(5.3)。
The Knowledge經驗分享经验分享
In one sentence
Learn from the bottom of the dependency tree upward, in batches small enough to read in one go. What an object uses is learned before it, so the cards above can point down at the cards below instead of reading their code again.
一句話
從依賴樹的底部往上學,分成小到一次讀得完的批次。一個物件用到的東西,先於它被學到,所以上面的卡片可以指向下面的卡片,不用再讀它們的程式碼。
一句话
从依赖树的底部往上学,分成小到一次读得完的批次。一个对象用到的东西,先于它被学到,这样上面的卡片可以指向下面的卡片,不用再读一遍它们的代码。
For leaders
- The decision: approve, for each domain, the entry points, the plan, and the final write-back into the base. A person chooses where a domain starts and ends.
- The risk: the checks cover structure, not meaning. A note can pass every check and still misstate what a rule is for, and a wrong note low in the order spreads to the notes above it. Cited lines are checked only to fall inside the object, which a made-up citation can pass.
- The cost of doing it right: the model reads each object's code once, which is the real token cost of the whole base. Review time can be the slowest part. The batch size (up to 20 objects, about 1500 lines) is a number I picked, not a measured one.
- Ask the team: "Who reviews whether each note's rule means what the cited code says, not only that the lines exist?"
給主管
- 要做的決定:對每個領域,批准入口、計劃,和最後寫回知識庫。由人選擇一個領域從哪裡開始、到哪裡結束。
- 風險:檢查涵蓋結構,不涵蓋意義。一則筆記可以通過每個檢查,還是講錯了一條規則是做什麼的,而順序低處的一則錯誤筆記,會傳到它上面的筆記。引用的行只檢查落在物件裡面,編造的引用也能通過。
- 做對的成本:模型把每個物件的程式碼讀一遍,這是整個知識庫真正的 token 成本。審查的時間可能是最慢的部分。批次大小(最多 20 個物件、約 1500 行)是我挑的數字,不是量出來的。
- 可以問團隊:「誰來審查每則筆記的規則,意思是不是和引用的程式碼說的一樣,而不只是那些行存在?」
写给管理者
- 要拍板的事:对每个领域,审批入口、计划和最后写回知识库这三处。一个领域从哪里开始、到哪里结束,由人来选。
- 风险:检查覆盖的是结构,不是含义。一条笔记可以通过每项检查,却仍然讲错了某条规则是干什么的;顺序靠下的一条错误笔记,还会传到它上面的笔记。引用的行只检查是否落在对象之内,编造的引用也能通过。
- 做对的代价:模型把每个对象的代码读一遍,这是整个知识库真正的 token 成本。审查的时间可能是最慢的一环。批次大小(最多 20 个对象、约 1500 行)是我挑的数字,不是测出来的。
- 可以问团队:“谁来审查每条笔记里的规则,意思是不是和引用的代码一致,而不只是那些行存在?”
The problem
You have a trusted map and a few thousand objects, and you want a card for each. Two simple plans do not work.
Plan one: one big prompt. "Learn the whole domain." One context holds everything the agent reads. As it fills, the agent can forget and mix things up toward the end (context budget), so I expect the cards written last to be the worst ones. That is reasoning; I have not compared the plans.
Plan two: object by object, in any order. Say the agent starts with a procedure that calls three others. To explain it properly, it has to read those three. So it reads them too. A few objects later it meets one of those three on its own and reads it again. The same code is read many times, and each card was written without the cards below it.
A good order would learn the three first. Then the procedure's card can say "it calls A, B and C" and point to their cards. The agent never reads their code again.
問題
你有一張可信的地圖,和幾千個物件,你想為每個物件寫一張卡片。兩個簡單的計劃都行不通。
計劃一:一個大 prompt。「學完整個領域。」一個上下文裝著 agent 讀的一切。裝滿的時候,agent 可能忘掉並在接近尾聲時搞混(上下文預算),所以我預期最後寫的卡片是最差的。這是推理;我沒有比較過這幾個計劃。
計劃二:一個物件一個物件來,順序隨意。假設 agent 從一個呼叫其他三個的預存程序開始。要好好解釋它,就得讀那三個。所以它也讀了它們。幾個物件之後,它自己遇到那三個之一,又讀了一遍。同樣的程式碼讀了很多次,而且每張卡片寫的時候,下面的卡片都還沒有。
好的順序,是先學那三個。這樣預存程序的卡片就可以說「它呼叫 A、B 和 C」,並指向它們的卡片。agent 不用再讀它們的程式碼。
问题
你有一张可信的地图,有几千个对象,想给每个对象写一张卡片。两个简单的计划都行不通。
计划一:一个大 prompt。“把整个领域学完。”一个上下文装着 agent 读过的所有东西。装满之后,agent 可能忘掉前面的,到后面还会搞混(上下文预算),所以我预计最后写的卡片质量最差。这是推理;这几个计划我没有对比过。
计划二:一个对象一个对象地学,顺序随意。假设 agent 从一个调用另外三个的存储过程开始。要讲清楚它,就得读那三个,于是它也读了。几个对象之后,它自己撞上那三个之一,又读了一遍。同样的代码读了很多次,而且每张卡片写的时候,下面的卡片都还没有。
好的顺序是先学那三个。这样存储过程的卡片就可以写“它调用 A、B 和 C”,并指向它们的卡片。agent 不用再读它们的代码。
How it works
Start from the entry points
A domain (see A knowledge base: an honest index of the code) is a group of objects that serve one job. To learn one, you need to say where it begins. An entry point is an object that the outside world calls: a screen's controller, a public API, a scheduled job. Starting from entry points, the map shows everything they reach.
A person chooses the entry points and the boundaries. A script and a research note can propose them, and the agent asks, but it is the person who knows which is which. Two boundaries matter:
- Stop at code you do not own. Framework code and another team's code are cut off, so the domain does not grow into them.
- Cut off what is shared. An object used from many entry points belongs to no single domain. It is set aside, so that one domain does not swallow everything. (How many entry points make an object shared is a setting you can lower if one domain still swallows the rest.) Who learns the shared objects, and when, is left open in this chapter; they are the ones many things depend on, so it should be planned.
A script sets the order
A script walks the map from the entry points, bottom up. An object that uses nothing comes first. An object comes only after everything it uses. Then the script cuts this order into batches.
- Batch 1: the tables. They use nothing else, so they come first.
- Batch 2: the entities. Each one maps a table whose card now exists, so its card can point down to it.
- Batch 3: the repositories, which read the entities.
- Batch 4: the controller, last. It uses cards that are all written, so it does not re-read their code.
Here is a real order, from the open-source spring-petclinic sample. Four tables first (owners, pets, types, visits). Then the entities that map them. Then the repositories that read the entities. Then the controllers that sit on top. Each controller card points at the cards below it.
How big is a batch
A batch is objects of one type, at most 20 objects and about 1500 lines of code in all. I picked these numbers so that one batch fits in a context with room to think. An object longer than that is a batch of its own and is read in parts.
One type per batch helps because objects of one type share a card form and the same questions.
One domain, one task, one write-back
All the batches of a domain are one task (see Manage tasks, not chats). The task has:
- A plan, listing every batch, approved by a person once.
- A to-do list with one step per batch.
- The cards, kept inside the task until the whole domain is done.
Then the domain is written into the knowledge base in one write-back (the single copy of the finished cards into the base, see Two gates: where a person approves), which the person approves. So the base never holds half a domain.
Chats come and go. After every two or three batches I start a new chat and say "continue". The task keeps the state: the plan, what is learned, what is left. The next batch is the first one the script gives once the learned objects are left out. This is the same idea as work that survives across sessions: memory in files, not in a chat.
Checks on what the model writes
The model writes each card. Its words are its own, but two parts are checked by script:
- The relations line must equal the map. The "uses" a card lists have to be the same as the map's uses for that object. The card cannot add or drop one.
- Every rule cites its lines, and the check makes sure those lines fall inside that object's code. A rule that cites lines outside the object is wrong. This is a weak check: it shows the lines exist, not that they support the rule. A made-up citation inside the right range passes. A person or an independent reviewer should spot-check whether the cited lines say what the rule says.
The flows on the architecture page also come from paths on the map, and are checked in the same way.
Here is the form of one card, from the harness's guide for writing them. The example is a stored procedure; the relations line is the one the script checks.
A card: what it is for, relations (checked against the map), the level, the rules with their lines, what is not known, traps.
```markdown
## sp:Db.dbo.usp_load_orders
- What: loads the day's orders from staging into dbo.orders, then logs the run
- Reads: `table:Db.dbo.stg_orders`, `table:Db.dbo.calendar` · Writes: `table:Db.dbo.orders` · Called by: `job:Daily_Load` · Calls: `sp:Db.dbo.usp_log`
- Level: verified (read in repo_a at 3f1c0a9e)
In: @run_date (date, default today). Out: none; rows in dbo.orders.
Changes: MERGE into dbo.orders on id (L18-L26): new rows inserted, known rows updated; then sets flag = 1 (L28).
Twice: safe; the MERGE matches on id.
On an error: no TRY/CATCH; the error goes to the job step, nothing is logged.
Logic: only rows whose date is a working day in dbo.calendar (L12-L16). See the card of `sp:Db.dbo.usp_log` for the log.
Not known: which environments run it on holidays (req-0004).
Traps: a staging row with a NULL id is dropped by the MERGE, with no error (L19).
```.github/skills/generic-kb-learn-batch/references/card.md L5–L22 @ 1.5.50
A card that points at a lower card inherits that card's mistakes, since it does not read the code again. A wrong card low in the order can therefore spread upward (8.5).
What remains unchecked is whether the model understood a rule correctly. A script cannot tell. That is for a person's review, or an independent reviewer (5.6). I do not claim the checks cover meaning.
When the code shows a use the map lacks
While reading, the agent may see a use in the code that the map does not have. It must not add the use to the card by hand. The check would refuse it, and the next object written in the same form would be missed too. It notes the use, and the note goes back to the toolkit as a new example to fix. Then the map is rebuilt and checked again (8.3).
The last step: the architecture page
When all batches are done, the model writes the domain's architecture page: its purpose, main flows, where to start reading, traps and limits. The flows are paths taken from the map, and the model puts them into words. That page is the part most readers see first.
Test your own setup
- Pick one small domain and one entry point.
- Ask a script, or an agent, to list what the entry point reaches, deepest first.
- Learn in that order, in one task, in two or three batches.
- Check that each card's "uses" equal the map's, and that every cited line is inside the object.
原理
從入口開始
領域(見 知識庫:程式碼的誠實索引)是為了同一件工作的一組物件。要學一個領域,你得說它從哪裡開始。入口是外面的世界呼叫的物件:畫面的 controller、公開的 API、排程工作。從入口開始,地圖顯示它們碰得到的一切。
由人選擇入口和邊界。腳本和一份研究筆記可以提議,agent 也會問,但哪個是哪個,是人才知道。有兩個邊界很重要:
- 停在不是你的程式碼上。框架的程式碼和別的團隊的程式碼要切開,這樣領域才不會長進去。
- 切開共用的。從很多入口被用到的物件,不屬於任何單一領域。把它放在一邊,這樣一個領域才不會吞掉所有東西。(要有多少個入口,物件才算共用,是一個設定;如果一個領域還是吞掉其餘的,可以調低它。)共用的物件由誰、什麼時候學,這一章沒有決定;它們是很多東西依賴的對象,所以應該有計劃。
腳本定順序
腳本從入口開始,由下往上走地圖。什麼都不用的物件排第一。一個物件只排在它用到的一切之後。然後腳本把這個順序切成批次。
- 第 1 批:資料表。它們不用別的東西,所以最先學。
- 第 2 批:實體。每個實體對應一張資料表,那張表的卡片已經有了,所以它的卡片可以指向下面。
- 第 3 批:儲存庫,它們讀實體。
- 第 4 批:控制器,最後學。它用到的卡片都已寫好,所以不必再讀那些程式碼。
這是開源範例 spring-petclinic 的真實順序。先是四張資料表(owners、pets、types、visits)。然後是對應它們的 entity。然後是讀 entity 的 repository。然後是最上面的 controller。每張 controller 的卡片都指向它下面的卡片。
一批有多大
一批是同一種類型的物件,總共最多 20 個物件和約 1500 行程式碼。我挑這些數字,是為了讓一批放得進一個上下文,還留有思考的空間。比這更長的物件自己是一批,分段讀。
一批只有一種類型有幫助,因為同一種類型的物件,共用卡片的形式和同樣的問題。
一個領域,一個任務,一次寫回
一個領域的所有批次是一個任務(見 管任務,不管對話)。任務有:
- 一份計劃,列出每一批,由人批准一次。
- 一份待辦清單,每批一步。
- 卡片,在整個領域完成之前,留在任務裡面。
然後領域用一次寫回寫進知識庫(把做完的卡片一次複製進知識庫,見 兩道門:人在哪裡批准),由人批准。所以知識庫從不會有半個領域。
對話來來去去。每兩、三批之後,我就開一個新對話,說「繼續」。任務保留狀態:計劃、學了什麼、還剩什麼。下一批,是把學過的物件排除之後,腳本給的第一批。這和 跨會話的長任務 是同一個想法:記憶放在檔案裡,不放在對話裡。
對模型寫的東西的檢查
每張卡片由模型寫。裡面的話是它自己的,但有兩個部分由腳本檢查:
- 關係那一行必須等於地圖。一張卡片列的「用到」,必須和地圖上那個物件的使用一樣。卡片不能多加或少掉一個。
- 每條規則都引用它的行,檢查確保那些行落在那個物件的程式碼裡面。引用物件之外的行的規則是錯的。這是個弱的檢查:它顯示那些行存在,不顯示它們支持這條規則。落在正確範圍內的編造引用,可以通過。人或獨立的 reviewer 應該抽查,引用的行說的是不是和規則說的一樣。
架構頁上的流程,也來自地圖上的路徑,以同樣的方式檢查。
這是一張卡片的形式,來自 harness 寫卡片的指南。例子是一個預存程序;關係那一行就是腳本檢查的那一行。
一張卡片:它做什麼、關係(對照地圖檢查)、層級、附行號的規則、不知道的部分、陷阱。
```markdown
## sp:Db.dbo.usp_load_orders
- What: loads the day's orders from staging into dbo.orders, then logs the run
- Reads: `table:Db.dbo.stg_orders`, `table:Db.dbo.calendar` · Writes: `table:Db.dbo.orders` · Called by: `job:Daily_Load` · Calls: `sp:Db.dbo.usp_log`
- Level: verified (read in repo_a at 3f1c0a9e)
In: @run_date (date, default today). Out: none; rows in dbo.orders.
Changes: MERGE into dbo.orders on id (L18-L26): new rows inserted, known rows updated; then sets flag = 1 (L28).
Twice: safe; the MERGE matches on id.
On an error: no TRY/CATCH; the error goes to the job step, nothing is logged.
Logic: only rows whose date is a working day in dbo.calendar (L12-L16). See the card of `sp:Db.dbo.usp_log` for the log.
Not known: which environments run it on holidays (req-0004).
Traps: a staging row with a NULL id is dropped by the MERGE, with no error (L19).
```.github/skills/generic-kb-learn-batch/references/card.md L5–L22 @ 1.5.50
指向下層卡片的卡片,會繼承那張卡片的錯誤,因為它不再讀程式碼。所以順序低處的一張錯誤卡片,會往上傳(8.5)。
剩下沒檢查的,是模型有沒有正確理解一條規則。腳本分辨不出來。這要靠人的審查,或獨立的 reviewer(5.6)。我不宣稱這些檢查涵蓋了意義。
程式碼顯示了地圖沒有的使用
讀的時候,agent 可能看到程式碼裡有地圖上沒有的使用。它不能手動把這個使用加進卡片。檢查會拒絕,而且用同樣的形式寫的下一個物件,也會漏掉。它把這個使用記下來,這則備註回到 toolkit,成為一個要修的新例子。然後地圖重建並再檢查一次(8.3)。
最後一步:架構頁
所有批次完成後,模型寫這個領域的架構頁:它的用途、主要的流程、從哪裡開始讀、陷阱和限制。流程是從地圖取來的路徑,模型把它們寫成文字。那一頁是多數讀者最先看到的部分。
測你自己的設定
- 挑一個小的領域和一個入口。
- 請腳本或 agent 列出這個入口碰得到的東西,最深的排最前。
- 照那個順序學,在一個任務裡,分兩、三批。
- 檢查每張卡片的「用到」等於地圖上的,而且每一行引用都在物件裡面。
原理
从入口开始
领域(见知识库:代码的诚实索引)是为同一项工作服务的一组对象。要学一个领域,得先说清它从哪里开始。入口是外部会调用的对象:某个页面的 controller、公开的 API、定时任务。从入口出发,地图会显示它们能碰到的一切。
入口和边界由人来选。脚本和调研笔记可以提议,agent 也会来问,但哪个是哪个,只有人知道。有两条边界要紧:
- 停在不归你管的代码上。框架代码和别的团队的代码要切开,这样领域才不会长进它们里面去。
- 切开共用的对象。被很多入口用到的对象不属于任何一个领域。把它放在一边,一个领域才不会吞掉所有东西。(多少个入口用到才算共用,是一个可调的设置;如果一个领域还是吞掉了其余的,可以调低。)共用对象由谁来学、什么时候学,这一章没有定下来;很多东西依赖它们,所以应该有计划。
脚本定顺序
脚本从入口出发,自底向上走一遍地图。什么都不用的对象排第一。一个对象,要等它用到的所有东西都排完才轮到。然后脚本把这个顺序切成批次。
- 第 1 批:数据表。它们不依赖别的东西,所以最先学。
- 第 2 批:实体。每个实体对应一张数据表,那张表的卡片已经有了,所以它的卡片可以指向下面。
- 第 3 批:仓库层,它们读实体。
- 第 4 批:控制器,最后学。它用到的卡片都已写好,所以不必再读那些代码。
下面是一个真实的顺序,来自开源示例 spring-petclinic。先是四张表(owners、pets、types、visits)。然后是映射它们的实体。再然后是读取实体的仓库。最上面是 controller。每张 controller 卡片都指向它下面的卡片。
一批有多大
一批是同一种类型的对象,最多 20 个对象、合计约 1500 行代码。我挑这些数字,是为了让一批能装进一个上下文,还留有思考的空间。比这更长的对象自成一批,分段来读。
一批只放一种类型有好处:同一类型的对象,卡片格式一样,要问的问题也一样。
一个领域,一个任务,一次写回
一个领域的所有批次是一个任务(见管任务,不管对话)。这个任务有:
- 一份计划,列出所有批次,由人审批一次。
- 一份待办清单,每批一步。
- 卡片,整个领域学完之前都放在任务里。
之后,整个领域通过一次写回写进知识库(把写好的卡片一次性复制进知识库,见两道门:人在哪里审批),由人审批。所以知识库里不会出现只有半个领域的情况。
对话会来来去去。每学两三批,我就开一个新对话,说“继续”。状态由任务保存:计划、已经学了什么、还剩什么。下一批,就是把已学的对象去掉之后,脚本给出的第一批。这和跨会话的长任务是同一个思路:记忆放在文件里,不放在对话里。
检查模型写的东西
每张卡片由模型来写。措辞由它自己定,但有两部分由脚本检查:
- 关系行必须和地图一致。卡片列出的“用到”,要和地图上这个对象的“用到”相同。卡片不能多加,也不能漏掉。
- 每条规则都要引用行号,检查会确认这些行落在这个对象的代码之内。引用的行在对象之外,这条规则就是错的。这是个弱检查:它只能说明这些行存在,不能说明这些行支持这条规则。落在正确范围内的编造引用也能通过。引用的行是不是真的说了规则说的话,要由人或独立的 reviewer 抽查。
架构页上的流程同样来自地图上的路径,用同样的办法检查。
下面是一张卡片的样子,取自 harness 里写卡片的指南。例子是一个存储过程;关系行就是脚本要检查的那一行。
一张卡片:它是干什么的、关系(对照地图检查)、层级、带行号的规则、不知道的部分、坑。
```markdown
## sp:Db.dbo.usp_load_orders
- What: loads the day's orders from staging into dbo.orders, then logs the run
- Reads: `table:Db.dbo.stg_orders`, `table:Db.dbo.calendar` · Writes: `table:Db.dbo.orders` · Called by: `job:Daily_Load` · Calls: `sp:Db.dbo.usp_log`
- Level: verified (read in repo_a at 3f1c0a9e)
In: @run_date (date, default today). Out: none; rows in dbo.orders.
Changes: MERGE into dbo.orders on id (L18-L26): new rows inserted, known rows updated; then sets flag = 1 (L28).
Twice: safe; the MERGE matches on id.
On an error: no TRY/CATCH; the error goes to the job step, nothing is logged.
Logic: only rows whose date is a working day in dbo.calendar (L12-L16). See the card of `sp:Db.dbo.usp_log` for the log.
Not known: which environments run it on holidays (req-0004).
Traps: a staging row with a NULL id is dropped by the MERGE, with no error (L19).
```.github/skills/generic-kb-learn-batch/references/card.md L5–L22 @ 1.5.50
指向下层卡片的卡片,会继承那张卡片的错误,因为它不再读代码。所以顺序靠下的一张错卡片,可能一路传到上面(8.5)。
没有检查的是:模型有没有把一条规则理解对。脚本分不出来。这要靠人审查,或者靠独立的 reviewer(5.6)。我不会说这些检查覆盖了含义。
代码里有地图没有的调用关系
读的时候,agent 可能看到代码里有一处调用关系,地图上没有。它不能手动把这条关系加进卡片。检查会拒绝,而且之后按同样格式写的对象也会漏掉它。它要把这一处记下来,这条记录作为一个待修的新例子回到 toolkit。然后重新生成地图,再检查一遍(8.3)。
最后一步:架构页
所有批次做完后,模型写这个领域的架构页:目的、主要流程、从哪里开始读、坑和边界。流程是从地图上取下来的路径,模型把它们写成文字。这一页是大多数读者最先看到的部分。
测一测你自己的配置
- 挑一个小领域和一个入口。
- 让脚本或 agent 列出这个入口能碰到的一切,最深的排最前。
- 按这个顺序学,放在一个任务里,分两三批。
- 检查每张卡片的“用到”和地图一致,每条引用的行都在对象之内。
Costs and traps
- The model reads each object's code once. That is the real token cost of the whole base. The scripts are free.
- Batches take patience. A domain of a few hundred objects is many batches. The plan lists them all, and a person must approve it. With approvals for the plan, each write-back and the entry points, review time can be the slowest part of the work.
- Caching may change the bill. Cached reads of repeated context cost far less than fresh ones (Anthropic's docs: about a tenth). I have not checked how much this helps on Copilot (1.1).
- A long object breaks the pattern. A procedure of thousands of lines is its own batch, read in parts. Its card may be longer.
- Order helps only if the map is right. A map that misses a use gives a wrong order and a card that lacks a relation. The audit is there for this.
- Unchecked meaning. See above. A card can pass every check and still misstate what a rule is for.
代價和陷阱
- 模型把每個物件的程式碼讀一遍。這是整個知識庫真正的 token 成本。腳本是免費的。
- 批次需要耐心。幾百個物件的領域有很多批。計劃把它們全列出來,人必須批准。加上計劃、每次寫回和入口的批准,審查的時間可能是這份工作裡最慢的部分。
- 快取可能改變帳單。重複上下文的快取讀取,比全新的便宜得多(Anthropic 的文件:約十分之一)。這在 Copilot 上幫多少,我沒有確認(1.1)。
- 很長的物件會打破這個規律。幾千行的預存程序自己是一批,分段讀。它的卡片可能比較長。
- 順序只有在地圖對的時候才有用。漏掉一個使用的地圖,會給出錯的順序,和少一個關係的卡片。抽查就是為這個而有的。
- 沒檢查的意義。見上面。一張卡片可以通過每個檢查,還是講錯一條規則是做什麼的。
代价和坑
- 模型把每个对象的代码读一遍。这是整个知识库真正的 token 成本。脚本是免费的。
- 分批要有耐心。几百个对象的领域有很多批。计划里全部列出,必须由人审批。计划、每次写回、入口都要审批,审查的时间可能是整件事里最慢的一环。
- 缓存可能改变账单。重复上下文的缓存读取比新读便宜得多(Anthropic 文档:约十分之一)。在 Copilot 上能省多少,我没查过(1.1)。
- 特别长的对象会打破这个模式。几千行的存储过程自成一批,分段读。它的卡片可能更长。
- 顺序有用的前提是地图对。地图漏了一处调用关系,顺序就是错的,卡片也会缺一条关系。盲抽查就是为这个设的。
- 含义没有检查。见上文。一张卡片可以通过每项检查,却仍然讲错了某条规则是干什么的。
When to delete it
The batch size is a guess for today's context windows and models. If a model can reliably read and write far more in one go, make the batches larger, or measure it (6.3). The bottom-up order stays useful as long as cards point at other cards.
什麼時候可以刪掉
批次大小是對今天的上下文視窗和模型的猜測。如果模型能可靠地一次讀和寫多得多,就把批次加大,或者去量(6.3)。只要卡片指向別的卡片,由下往上的順序就一直有用。
什么时候可以删掉
批次大小是针对今天的上下文窗口和模型猜的。如果有模型一次能可靠地读和写多得多的内容,就把批次调大,或者去测一测(6.3)。只要卡片还指向别的卡片,自底向上的顺序就一直有用。
Go deeper
- The audit: the map this order comes from.
- Keeping it true: what happens after the cards are written.
- Long work across sessions
You can stop here: that is the whole idea. The next part shows where it runs, so you can look inside.讀到這裡就夠了,這就是整個想法。下一部分告訴你它在哪裡運行,可以進去看看。读到这里就够了,核心思路就是这些。下一部分告诉你它在哪里跑,可以进去看看。
In my practice (Copilot Harness)實作实战
Copilot Harness is my open-source harness for VS Code Copilot.
Repository: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
Get started: clone it, open it in VS Code, and type /harness-rookie-get-me-ready in Copilot Chat. You need Python 3.9 or later and git.
Copilot Harness 是我開源的 VS Code Copilot harness。
倉庫: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
開始:clone 下來,用 VS Code 打開,在 Copilot Chat 裡輸入 /harness-rookie-get-me-ready。需要 Python 3.9 以上和 git。
Copilot Harness 是我开源的 VS Code Copilot harness。
仓库: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
上手:把仓库 clone 下来,用 VS Code 打开,在 Copilot Chat 里输入 /harness-rookie-get-me-ready。需要 Python 3.9 及以上版本和 git。
Explore it in the harness
Copilot Harness orders the objects, cuts them into batches and checks the cards. After the setup above, type:
/harness-rookie-wondering I have read the chapter "Learning a domain in batches". Teach me topic 16, parts 16.4 and 16.5: how the order and the batches are worked out, and which checks run on a card. Walk me through the Spring sample's four batches and one card check.It teaches one small piece at a time, stops to ask if you are following, and opens the files with you.
在 harness 裡探索
Copilot Harness 把物件排序、切成批次,並檢查卡片。照上面的說明準備好之後,輸入:
/harness-rookie-wondering 我讀完了「分批學一個領域」這一章。請教我主題 16 的 16.4 和 16.5:順序和批次是怎麼算出來的,以及卡片上跑哪些檢查。帶我走一遍 Spring 範例的四批,和一次卡片檢查。它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。
在 harness 里探索
Copilot Harness 会给对象排序、切成批次,并检查卡片。按上面的说明准备好之后,输入:
/harness-rookie-wondering 我读完了“分批学一个领域”这一章。请教我主题 16 的 16.4 和 16.5:顺序和批次是怎么算出来的,卡片上会跑哪些检查。带我走一遍 Spring 示例的四个批次和一次卡片检查。它一次只教一小块,停下来问你跟上了没有,再和你一起打开文件。