4.3
Guard the files that hold the rules保護規則本身的檔案保护规则本身的文件
This chapter assumes you have read Asking is not a limit: a limit is a refusal the agent cannot argue with.
這一章假設你讀過詢問不是限制:限制是 agent 吵不贏的拒絕。
读这一章,请先读过询问不是限制:限制,就是 agent 辩不过的拒绝。
The Knowledge經驗分享经验分享
In one sentence
If the agent can edit the rules, the rules mean nothing. Keep the rules and the hook files out of its reach, and make any human override last one session, expire, and leave a record.
一句話
agent 能改規則,規則就沒有意義。把規則檔和 hook 檔放在它碰不到的地方;人給的任何 override,都只管一個會話,會過期,並留下紀錄。
一句话
agent 如果能改规则,规则就等于没有。要让规则文件和 hook 文件它碰不到,人的任何 override 都只管一个会话、会过期,并且留下记录。
For leaders
- The decision: decide that the agent may not edit the files that hold its rules, its hooks or its evidence, and that any human override is limited to one session, expires and leaves a record.
- The risk: a rule the agent can edit is a rule the agent can remove, and a "passed" record it can write is a pass it can give itself. I have no incident to report. The argument is the point, not a count.
- The cost of doing it right: a list of protected files, kept up to date as parts are added, and a way for a person to open the fence on purpose. My override depends on a person remembering to switch it off; a time limit and a second reader are better, and I do not have them.
- Ask the team: "Can the agent edit the files that hold its own rules and records, and can you show me a refusal when it tries?"
給主管
- 要做的決定:決定 agent 不能編輯存放它自己規則、hook 和證據的檔案;人給的任何 override,只限一個會話,會過期,並留下紀錄。
- 風險:agent 能改的規則,agent 就能刪掉;它能寫的「通過」紀錄,就是它能自己給自己的通過。我沒有事故可報告。重點是這個論證,不是次數。
- 做對的成本:一份受保護檔案的清單,加了新部件就更新;還有一個讓人刻意打開圍欄的辦法。我的 override 要靠人記得關掉;有時間限制和第二個人來讀會更好,我沒有做。
- 可以問團隊:「agent 能不能編輯存放它自己規則和紀錄的檔案?它試的時候,你能給我看一次被拒絕的紀錄嗎?」
写给管理者
- 要拍板的事:决定 agent 不许编辑存放它的规则、hook 和证据的那些文件,并且人的任何 override 都只限一个会话、会过期、并留下记录。
- 风险:agent 能编辑的规则,agent 就能删掉;agent 能写的“通过”记录,就是它能给自己的通过。我没有事故可以报告。重点是这个论证,不是次数。
- 做对的代价:一份受保护文件的清单,增加新部件时要随之更新,再加一个让人有意打开围栏的办法。我的 override 靠人记得去关;时间限制加上第二个读的人更好,但我还没有。
- 可以问团队:“agent 能编辑存放它自己的规则和记录的文件吗?它试的时候,你能给我看一次被拒绝的情形吗?”
The problem
Who is the threat here? Mostly a careless agent, not a hostile one: an agent that is under pressure to finish a task and loosens a rule that is in the way. An agent led by injected text is a second case (Text the agent reads can give it orders); it needs the same fence, and more.
You have a hook that refuses dangerous commands. It works. Now ask: where does the hook live? In a file. The configuration that tells the platform to run it is a file. The numbers it uses are a file. And the agent has an edit tool.
An agent that is stuck behind a refusal does not need bad intent to change the file. It only needs to be trying to finish the task, see that the rule is in the way, and do the sensible-looking thing: loosen the rule. I have no incident to report. The argument is the point: a rule the agent can edit is a rule the agent can remove.
The same is true of records. If a check leaves a "passed" file and the agent can write that file, the agent can pass itself. So the question is not only "which commands are refused", it is "who can change the things that do the refusing and the proving".
I call the files that must be out of reach guardrail files: a fence, in the sense that the agent works inside it and cannot move it.
If you only do one thing from this chapter: make the rule files and the hook files unwritable for the agent.
問題
這裡的威脅是誰?多半是個粗心的 agent,不是惡意的:它趕著完成任務,就把擋路的規則放鬆了。被注入的文字帶偏的 agent 是第二種情況(agent 讀到的文字可能在指揮它);它需要同樣的圍欄,而且更多。
你有一個 hook,會拒絕危險的指令,它管用。現在問:這個 hook 放在哪裡?在一個檔案裡。告訴平台要執行它的設定,是一個檔案。它用到的數字,是一個檔案。而 agent 有編輯工具。
一個被拒絕卡住的 agent,不需要惡意就會去改那個檔案。它只是想完成任務,看到規則擋路,就做了看起來合理的事:放鬆規則。我沒有事故可報告。重點是這個論證:agent 能編輯的規則,agent 就能刪掉。
紀錄也一樣。檢查通過後留下一個「通過」的檔案,如果 agent 能寫這個檔案,它就能讓自己通過。所以問題不只是「哪些指令被拒絕」,而是「誰能改那些負責拒絕和證明的東西」。
我把必須放在碰不到的地方的檔案叫作護欄檔案:一道圍欄,agent 在裡面工作,但移不動它。
這一章只做一件事的話:讓規則檔和 hook 檔對 agent 不可寫。
问题
威胁是谁?多数时候是一个粗心的 agent,而不是怀有恶意的:一个急着完成任务的 agent,把挡路的规则放松了。被注入的文本引着走的 agent 是第二种情况(agent 读到的文字可能在指挥它);它需要同样的围栏,而且要更多。
你有一个 hook,会拒绝危险的命令。它起作用。现在问:这个 hook 放在哪?在文件里。告诉平台去运行它的配置,是一个文件。它用到的数字,是一个文件。而 agent 有编辑工具。
一个被拒绝挡住的 agent,不需要有恶意才去改那个文件。它只要想完成任务,看到规则挡了路,然后做看上去合理的事:把规则放松。我没有事故可以报告。重点是这个论证:agent 能编辑的规则,agent 就能删掉。
记录也一样。如果一次检查留下一个“通过”的文件,而 agent 能写这个文件,agent 就能让自己通过。所以问题不只是“哪些命令被拒绝”,而是“谁能改动那些负责拒绝和证明的东西”。
我把必须放在它碰不到的地方的这些文件,叫作护栏文件:一道围栏,意思是 agent 在里面干活,却挪不动它。
这一章里如果你只做一件事:让规则文件和 hook 文件对 agent 不可写。
How it works
Which files are the fence
In my setup these are:
- the hook configuration, the file that tells the platform which hook to run;
- the engine, the code of the hook itself, and the commands the agent is allowed to call;
- the policies, the plain files that hold the numbers and patterns of the rules;
- the runtime state, the files the hook writes while it runs: session state, approval records and logs;
- the editor settings that could switch the hooks off;
- the license files of the repository.
Instruction files and skills are not on the list. They are text, a request, and the agent is meant to read them. Changing them does not change what the code refuses.
How the fence is held
- Edit tools: refused before the call. This is the easy one. The path is in the call.
- The terminal: the common spellings. A redirect,
rm,mv,sed -i,cp,tee, and so on. The limits in Asking is not a limit apply: an indirect spelling is not caught. - One form for a path before comparing. The same file can be written with other letter case, with
.., as an absolute path, or with the backslash of Windows. The rule brings them all to one form first. Otherwise the fence would have gaps in the spelling. Two more gaps worth checking in your own setup: a symbolic link that points into a guarded folder, and a disk that ignores letter case. I have not tested either. - A company can add paths, not take the defaults away. Anyone who sets up a team can protect more files. An override that removes a default would be the same hole as an agent that can edit the rule.
This is a guard against mistakes. It is not a sandbox, and I do not call it one. An agent set on getting round it, with a script it writes first, can. For the strong version, see Least privilege.
Files only a command may write
Some files are not rules, but they are evidence: the state of a task, the verdicts of the independent checks (Can a model check a model?), snapshots (copies of files taken at a point in time), the diff an approval is based on, the final report.
If the agent could write them, it could declare a check passed, or change what was approved. So the agent never writes them with its edit tools. A command writes them, and the command judges the result itself. "The agent recorded a result" means the agent asked the command to record it, and the command decided.
The same goes for folders that hold what the person brought: documents, reference code, results from a run. The agent reads them. The person (through a page or a command) writes them. Evidence that the agent could edit is not evidence.
The breaker
When a refusal keeps coming, an agent may keep trying. A hook can only refuse a call; it cannot stop the agent. So when the same refusal comes up three times in a row (three is my setting), the breaker trips and the reason is replaced with a different one: stop trying this, and tell the person. It is a request in the form of a message, but it is the only thing a hook can do. It also keeps the log from filling with the same refusal.
When a person must open the fence
Sometimes the rules themselves have to change. When I extend the harness, I change guardrail files. So there must be a way in. How do you give that right without giving it to the agent?
Not by agent. I first thought to let one named agent edit the fence. But in Copilot today the event a hook receives does not carry the name of the main agent (Hooks), so the hook cannot tell which agent is calling. Any agent could pass for the named one. Rights that follow a name can be claimed by anyone who uses the name.
By session, set by the person. The ground is a switch in the state of the session. Only the person can turn it on, by typing a code in their own terminal. The agent cannot run that command, and the hook refuses it if it tries. This is the same channel as in Two approvals.
- A person types a code in their own terminal. The agent cannot do this.
- For this session only, the guardrail files can be changed. The approval records stay locked.
- When the work is done, the person switches it off.
- The log marked every call in between, and the person reads the diff of what changed.
What makes the override safe:
- It belongs to a session, not to an agent. It ends with that session.
- It is turned off when the work is done. My rule is to switch it off, and then read the diff of what changed with git. I rely on that; I do not have a timer in my setup. This is the weak point of the design: it depends on a person remembering. A time limit is a better design, and the approval of git writes already uses one. For a team, add an expiry and a second person who reads the diff.
- It leaves a record. While it is on, every logged call is marked as admin.
- Some doors stay shut. In my setup even admin cannot write the runtime state, which holds the approval records. If it could, it could forge an approval. And no task can be opened in the same session, and no subagent called.
Each of these removes a way that a short exception turns into a standing hole.
Test your own setup
In a copy of your project, ask your agent to loosen one rule in its own hook configuration. Does it succeed? If it does, your rules are a request. Then protect the file and try again.
原理
哪些檔案是圍欄
在我的設定裡是這些:
- hook 設定,告訴平台要執行哪個 hook 的檔案;
- 引擎,也就是 hook 本身的程式碼,以及 agent 被允許呼叫的指令;
- 政策,存放規則的數字和模式的純文字檔;
- 執行期狀態,hook 執行時寫出的檔案:會話狀態、批准紀錄和日誌;
- 能把 hook 關掉的編輯器設定;
- 倉庫的授權檔案。
指令檔和 skill 不在清單上。它們是文字,是請求,而且本來就是要給 agent 讀的。改了它們,程式拒絕的東西並不會變。
圍欄怎麼守住
- 編輯工具:呼叫之前就拒絕。這是容易的一種。路徑就在呼叫裡。
- 終端機:攔常見的寫法。重新導向、
rm、mv、sed -i、cp、tee等等。詢問不是限制裡的限制在這裡也適用:間接的寫法攔不到。 - 比較之前先把路徑變成同一種形式。同一個檔案可以用不同的大小寫、
..、絕對路徑,或 Windows 的反斜線來寫。規則先把它們都變成同一種形式。不然圍欄在寫法上就會有縫。你自己的設定裡,還有兩個縫值得檢查:指向受保護資料夾的符號連結,以及不分大小寫的磁碟。這兩個我都沒有測過。 - 公司可以加路徑,不能拿掉預設的。替團隊做設定的人可以保護更多檔案。一個能拿掉預設項的 override,就和能編輯規則的 agent 是同一個洞。
這是防失誤的,不是沙箱,我也不叫它沙箱。一個鐵了心要繞過去的 agent,先寫一個腳本再執行,就繞得過去。想要強的版本,見有些東西根本不給。
只有指令能寫的檔案
有些檔案不是規則,而是證據:任務的狀態、獨立檢查的裁決(模型能檢查模型嗎)、快照(在某個時間點複製下來的檔案)、批准所依據的 diff、最終報告。
agent 如果能寫它們,就能宣布一次檢查通過,或者改掉被批准的內容。所以 agent 從不用編輯工具寫它們。由一個指令來寫,並且由這個指令自己判斷結果。「agent 記錄了一個結果」的意思是:agent 請指令去記錄,而指令做了決定。
人帶來的東西所在的資料夾也一樣:文件、參考程式碼、一次運行的結果。agent 讀它們。人(透過一個頁面或一個指令)來寫。agent 能編輯的證據,就不是證據。
斷路器
拒絕不斷出現時,agent 可能一直試。hook 只能拒絕一次呼叫,它停不了 agent。所以同一個拒絕連續出現三次(三是我的設定),斷路器就跳開,把原因換成另一句:別再試這個了,告訴人。這是以訊息形式出現的請求,但這是 hook 唯一能做的。它也讓日誌不會被同一個拒絕塞滿。
什麼時候要由人打開圍欄
有時規則本身要改。我擴充 harness 的時候,就會改護欄檔案。所以必須有一條路進去。怎麼把這個權利給出去,又不給 agent?
不能按 agent。我一開始想過讓一個指定名字的 agent 編輯圍欄。但在今天的 Copilot 裡,hook 收到的事件不帶主 agent 的名字(Hooks:每次呼叫都會經過的執行點),所以 hook 分不出是哪個 agent 在呼叫。任何 agent 都能冒充那個名字。跟著名字走的權利,誰用了這個名字誰就能拿到。
按會話,由人設定。依據是會話狀態裡的一個開關。只有人能打開它,方法是在自己的終端機裡打一個代碼。agent 不能執行那條指令,它試的話 hook 會拒絕。這和兩道門:人在哪裡批准是同一個管道。
- 人在自己的終端機輸入驗證碼。agent 做不到這件事。
- 只在這個會話內,圍欄的檔案可以改。批准紀錄仍然鎖著。
- 工作做完,人把它關掉。
- 這中間的每次呼叫日誌都做了標記,人再讀一次改了什麼的 diff。
讓 override 安全的是這幾點:
- 它屬於一個會話,不屬於某個 agent。會話結束,它就結束。
- 工作做完就關掉。我的規則是關掉它,然後用 git 讀一遍改了什麼的 diff。我靠這一點;我的設定裡沒有計時器。這是設計的弱點:它要靠人記得。時間限制是更好的設計,git 寫入的批准已經在用。團隊的話,加上過期,以及第二個人來讀 diff。
- 它會留下紀錄。開著的時候,每一次被記錄的呼叫都標上 admin。
- 有些門仍然關著。在我的設定裡,連 admin 也不能寫執行期狀態,那裡存著批准紀錄。能寫的話,它就能偽造批准。而且同一個會話裡不能打開任何任務,也不能呼叫子 agent。
每一條都是在去掉一個讓短期例外變成長期漏洞的路。
測一下你自己的設定
在你專案的副本裡,請你的 agent 放鬆它自己 hook 設定裡的一條規則。成功了嗎?成功的話,你的規則就只是請求。那就保護這個檔案,再試一次。
原理
哪些文件是围栏
在我的配置里,这些是:
- hook 配置,告诉平台去运行哪个 hook 的那个文件;
- 引擎,也就是 hook 本身的代码,以及允许 agent 调用的命令;
- 策略,存放规则里的数字和模式的普通文件;
- 运行时状态,hook 运行时写下的文件:会话状态、审批记录和日志;
- 能把 hook 关掉的编辑器设置;
- 仓库的许可证文件。
指令文件和 skill 不在这份清单里。它们是文本,是请求,本来就是给 agent 读的。改了它们,并不会改变代码会拒绝什么。
围栏是怎么守的
- 编辑工具:在调用之前就拒绝。 这是容易的一种。路径就在调用里。
- 终端:常见的写法。 重定向、
rm、mv、sed -i、cp、tee等等。询问不是限制里的限度在这里同样适用:间接的写法抓不到。 - 比较之前,先把路径统一成一种形式。 同一个文件可以用不同的大小写、用
..、用绝对路径,或者用 Windows 的反斜杠来写。规则先把它们都统一成一种形式。否则围栏在写法上就会有缺口。在你自己的配置里还值得查两个缺口:指向受保护文件夹的符号链接,以及不区分大小写的磁盘。这两个我都没有测过。 - 公司可以增加路径,但不能去掉默认的。 任何搭建团队配置的人,都可以保护更多文件。去掉默认值的 override,就和 agent 能编辑规则是同一个漏洞。
这是防失误的措施。它不是沙箱,我也不叫它沙箱。一个铁了心要绕过它的 agent,先写好一个脚本,就能绕过。要更强的版本,见有些东西根本不给。
只有命令才能写的文件
有些文件不是规则,而是证据:任务的状态、独立检查的结论(模型能检查模型吗)、快照(在某个时间点对文件做的拷贝)、一次审批所依据的 diff、最终报告。
如果 agent 能写它们,它就能宣布一次检查通过了,或者改掉获批的内容。所以 agent 永远不用它的编辑工具去写这些文件。由命令来写,而命令自己判断结果。“agent 记录了一个结果”的意思是,agent 请命令去记录,而命令做了判断。
存放人带来的东西的文件夹也是一样:文档、参考代码、一次运行的结果。agent 读它们。人(通过一个页面或一条命令)写它们。agent 能编辑的证据,不算证据。
熔断器
拒绝不断出现时,agent 可能会一直试。hook 只能拒绝一次调用;它没法让 agent 停下。所以当同一个拒绝连续出现三次时(三是我的设置),熔断器就会跳闸,并把理由换成另一条:别再试这个了,去告诉人。它是以消息形式出现的请求,但这是 hook 唯一能做的。它也避免日志里塞满同一条拒绝。
人必须打开围栏的时候
有时规则本身必须改。我扩展 harness 的时候,就要改护栏文件。所以必须有一条路进去。怎么把这个权利给出去,又不给 agent?
不靠 agent。 我一开始想让一个指定的 agent 去编辑围栏。但在 Copilot 目前的情况下,hook 收到的事件里没有主 agent 的名字(Hook:每次调用都会经过的执行点),所以 hook 分不清是哪个 agent 在调用。任何 agent 都可以冒充那个指定的 agent。跟着名字走的权利,谁用了这个名字谁就能主张。
按会话,由人来设定。 依据是会话状态里的一个开关。只有人能打开它,办法是在自己的终端里输入一个验证码。agent 运行不了那条命令,它要是试,hook 会拒绝。这和两道门:人在哪里审批里是同一个渠道。
- 人在自己的终端里输入验证码。agent 做不到这件事。
- 只在这个会话内,围栏里的文件可以改。审批记录仍然锁着。
- 工作做完,人把它关掉。
- 这中间的每次调用,日志都做了标记,人再读一遍改了什么的 diff。
让这个 override 安全的有这几点:
- 它属于一个会话,不属于某个 agent。 会话结束,它就结束。
- 工作做完,就关掉。 我的规则是把它关掉,然后用 git 读一遍改了什么的 diff。我靠的是这个习惯;我的配置里没有计时器。这是这个设计的弱点:它依赖人记得去做。时间限制是更好的设计,而 git 写入的审批已经在用了。对团队来说,要加上过期时间,再加第二个读 diff 的人。
- 它会留下记录。 开着的时候,每条记入日志的调用都标成 admin。
- 有些门始终关着。 在我的配置里,即便是 admin 也不能写运行时状态,那里面存着审批记录。如果能写,它就能伪造一次审批。而且同一个会话里不能打开任何任务,也不能调用子 agent。
这几点,每一点都去掉了一种让短暂的例外变成长期漏洞的办法。
检验你自己的配置
在你项目的一份拷贝里,让你的 agent 放松它自己 hook 配置里的一条规则。它成功了吗?如果成功了,你的规则就只是请求。然后保护这个文件,再试一次。
Costs and traps
The fence is as good as its list. A guardrail file missing from the list is open. When you add a part to the engine, add its path.
Admin is real power. It can change the engine, so what it does is not hard-limited. The control is a person reading the diff afterwards. I do not claim more than that.
Spelling gaps remain. Because the terminal is guarded by pattern, in theory a spelling it does not know could change a record that lives in a task folder (the folder that holds one piece of work; see Manage tasks, not chats). I have not tried to build one. The fix, again, is to keep what must never be touched out of reach altogether.
A fence you cannot see is a puzzle. If an agent hits a refusal on a file it does not know is guarded, the reason must say so and what to do. See the last chapter.
I did not measure how often agents try to edit rules. I wrote the fence because the argument is simple, not because I watched a specific incident.
代價和陷阱
圍欄只和它的清單一樣好。不在清單上的護欄檔案是開著的。給引擎加了新部件,就把它的路徑加進去。
admin 是真正的權力。它能改引擎,所以它做的事沒有被硬性限制。控制手段是人事後讀 diff。我不聲稱比這更多。
寫法上的縫還在。因為終端機是按模式防護的,理論上有一種它不認識的寫法,可以改動放在任務資料夾裡的紀錄(存放一件工作的資料夾;見管任務,不管對話)。我沒有試著做出來。解法還是一樣:把絕對不能碰的東西整個放到碰不到的地方。
看不見的圍欄是個謎題。agent 碰到一個它不知道受保護的檔案而被拒絕時,原因必須說明這一點,以及該怎麼做。見上一章。
我沒有量過 agent 多常想編輯規則。我寫這道圍欄,是因為論證很簡單,不是因為我看到了某次具體的事故。
代价和坑
围栏的好坏,取决于它的清单。 清单里漏掉的护栏文件,就是敞开的。给引擎增加新部件时,要把它的路径加进去。
admin 是真正的权力。 它可以改引擎,所以它做的事没有硬性的限制。控制手段是事后有人读 diff。我不声称更多。
写法上的缺口依然存在。 因为终端是靠模式来守的,理论上,一种它不认识的写法,可能改动放在任务文件夹里的记录(任务文件夹存放一项工作;见管任务,不管对话)。我没有试过去造一个。办法还是那个:把绝不能碰的东西,彻底放在够不着的地方。
看不见的围栏是个谜。 如果 agent 对一个它不知道受保护的文件,撞上了拒绝,理由里必须说明这一点,以及该怎么办。见上一章。
agent 多久会尝试编辑规则,我没量过。 我写这道围栏,是因为这个论证很简单,不是因为我亲眼看到过某次具体的事故。
What the industry says Industry practice
VS Code's hooks page says hooks and instructions are not substitutes for enforced permissions or sandboxing, and its security page recommends sandboxing over approval rules alone (hooks, security). A fence made of hooks is a fence inside the same machine the agent runs on. That is why this chapter says "out of reach" and not "safe".
When to delete it Industry practice
If the agent runs in an environment where the rule files are mounted read-only, or the hook runs outside the machine the agent can touch, the list of guarded paths is not needed; the environment is the fence. Keep the other lesson: any override a person grants should be bound to the session, time-limited, and recorded.
什麼時候可以刪掉 業界做法
如果 agent 跑在一個規則檔以唯讀方式掛載的環境,或者 hook 跑在 agent 碰不到的機器之外,就不需要受保護路徑的清單;環境本身就是圍欄。另一條教訓要留著:人給的任何 override,都應該綁在會話上、有時間限制、並留下紀錄。
什么时候可以删掉 业界做法
如果 agent 运行的环境里,规则文件是以只读方式挂载的,或者 hook 运行在 agent 碰不到的机器之外,那么受保护路径的清单就不需要了;环境本身就是围栏。另一条经验要保留:人给出的任何 override,都应该绑定到会话,有时间限制,并留下记录。
Try it on your own setup
No harness needed. Open your agent in your own repository and paste:
Find every file in this project that defines what the agent may or may not do: instruction files, hook scripts and their configuration, permission settings, editor settings, and any file that records a check or an approval. For each, tell me whether the agent's own edit tools and terminal could change it today, using the rules and permissions you can see. Output a list sorted by how bad it would be if the file were changed. Do not change any files, and do not try to edit them to find out.在你自己的環境試試
不用裝 harness。在你自己的倉庫裡打開 agent,貼上:
找出這個專案裡每一個定義了 agent 能做什麼、不能做什麼的檔案:指令檔、hook 腳本和它們的設定、權限設定、編輯器設定,以及任何記錄檢查或批准的檔案。對每一個,根據你看得到的規則和權限,告訴我 agent 自己的編輯工具和終端機今天能不能改它。輸出一份清單,按「這個檔案被改了會有多糟」排序。不要改任何檔案,也不要為了確認而去試著編輯它們。在你自己的环境里试试
不用装 harness。在你自己的仓库里打开 agent,粘贴:
找出这个项目里,定义了 agent 可以做什么、不可以做什么的每一个文件:指令文件、hook 脚本及其配置、权限设置、编辑器设置,以及任何记录一次检查或一次审批的文件。对每一个,根据你能看到的规则和权限,告诉我 agent 自己的编辑工具和终端今天能不能改动它。输出一份清单,按“这个文件被改了有多糟”来排序。不要修改任何文件,也不要为了确认而去尝试编辑它们。Go deeper
- VS Code docs: Hooks, Security
- In this book: Asking is not a limit, Least privilege, Two approvals
延伸閱讀
- VS Code 文件:Hooks、Security
- 本書:詢問不是限制、有些東西根本不給、兩道門:人在哪裡批准
延伸阅读
- VS Code 文档:Hooks、Security
- 本书:询问不是限制、有些东西根本不给、两道门:人在哪里审批
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 has a list of guarded files, files only commands may write, a breaker, and an admin mode tied to the session. The harness can show you each of them in the real files. After the setup above, type:
/harness-rookie-wondering I have read the chapter "Guard the files that hold the rules". Teach me how this harness keeps its own rules out of the agent's reach: which files are guardrails and how they are protected (topic 7), the breaker, and admin mode (topic 8). Open the real policy and show me what the agent sees when it is refused.It teaches one small piece at a time, stops to ask if you are following, and opens the files with you.
在 harness 裡探索
Copilot Harness 有一份受保護檔案的清單、只有指令能寫的檔案、一個斷路器,以及綁在會話上的 admin 模式。harness 可以在真實的檔案裡一個一個給你看。照上面的說明準備好之後,輸入:
/harness-rookie-wondering 我讀完了「保護規則本身的檔案」這一章。請教我這個 harness 怎麼讓自己的規則碰不到 agent:哪些檔案是護欄、怎麼保護它們(主題 7)、斷路器,以及 admin 模式(主題 8)。帶我打開真實的政策,讓我看 agent 被拒絕時看到什麼。它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。
在 harness 里探索
Copilot Harness 有一份受保护文件的清单、只有命令才能写的文件、一个熔断器,以及一个绑定在会话上的 admin 模式。harness 能用真实的文件把它们逐一展示给你。按上面的说明准备好之后,输入:
/harness-rookie-wondering 我读完了“保护规则本身的文件”这一章。请教我这个 harness 是怎么把自己的规则放在 agent 够不着的地方的:哪些文件是护栏、它们怎么被保护(主题 7)、熔断器,以及 admin 模式(主题 8)。带我打开真实的策略,并给我看 agent 被拒绝时看到的是什么。它一次只教一小块,停下来确认你跟上了,再和你一起打开文件。