功能验证
Feature validation
Summary
Covers the human-in-the-loop validation step — reviewing code changes at a high level, catching spec-to-code mismatches, and correcting both specs and implementation through the agent. Introduces the concept of cognitive debt.
Key Takeaways
- Review high-level concerns first: focus on whether features work and reflect the spec, not minor implementation details
- Correct through the agent: when you find issues, ask the agent to fix both the spec and code to avoid drift
- Cognitive debt is real: agents generate code so fast that tracking what it does creates mental load — keep changes manageable
视频信息:Feature validation
English Script
It’s nice to have a feature ready, but don’t merge yet. In this last feature step, we collaborate with the agent to review the work. Fortunately, programmers have good tools for this validation task. After all, programmers have long spent several hours per week on code review. Start with the commit view. Let’s go through the changes. Focus your review on high-level concerns like whether the features work and reflect the spec, rather than details like which CSS classes were implemented. For example, the Home.tsx is minimal. Nano really meant nano. We want a layout component with clear landmarks for header, main, and footer, but do these as sub-components. And create a CSS file. As it turns out, this mistake in the code flowed from a mistake in the plan. We didn’t ask for this. Let’s ask the agent to do the fix, thus correcting both spec and implementation. This process that consists of the agent generating something and us verifying it is known as the human in the loop. Because agents are so fast at writing code, software developers have lately been talking about cognitive debt, the mental load of tracking what your code is doing and how it has evolved. That is why in order for this process to be fast and easy to control, and to reduce cognitive debt, the changes should be manageable. The agent is making our changes, but also validating that these changes didn’t break anything.
Good news, the agent finished and gave us a quick summary. You can also see this in the editor. The feature plan was changed to add a Group 5 to list these new steps. The code now has a layout component. and a CSS file was added. It looks like the three subcomponents were just put in the same file, but that doesn’t follow conventions. Let’s put these in their own files using the IDE move tool. These kinds of changes are easy in editors and we’ve always been good at this. No need for an agent, right? Let’s just do it. Not so fast. This can lead to drift where other artifacts, specs, readmes, get out of sync. Let’s ask the agent to fix any mentions and to make sure this doesn’t waste some time later. All changes are done. Did we break something? Tests would help, but the agent didn’t install our testing package. Since this is needed for all features, we’ll cover it in the next lesson.
Now we’re ready to mark this work as complete and merge our results. Notice that the part of the constitution was updated alongside the feature in this branch. How to handle versioning of the specs and how to associate which specs created which code changes is an evolving topic in the community. The change to the roadmap is small, just checking off a step in the roadmap. So it’s okay to keep these updates on the same branch. If the overall constitution update is more complicated, it might be better to do this in a separate branch. Now we’re ready to mark this work as complete and merge our results. We just used Spec-Driven Development to develop and validate our first feature. But wait, shouldn’t we take another look at the project’s broader scope?
功能验证
摘要
介绍人类干预(human-in-the-loop)验证步骤——从高层次审查代码变更、捕捉规格说明与代码的不匹配,并通过智能体同时修正规格说明和实现。引入认知债务(cognitive debt)的概念。
关键要点
- 优先审查高层次问题:关注功能是否有效以及是否反映了规格说明,而非细枝末节的实现细节
- 通过智能体修正:发现问题后,要求智能体同时修正规格说明和代码以避免脱节
- 认知债务是真实的:智能体生成代码太快,追踪其行为会产生心理负担——保持变更可控
视频信息:功能验证
视频脚本(中文翻译)
功能准备好了是很开心,但先别合并(merge)代码。在功能的最后一个步骤中,我们要与智能体协作来审查工作。幸运的是,程序员有很好的工具来完成这项验证任务。毕竟,长期以来程序员每周都会花好几个小时进行代码审查(Code Review)。从提交视图(commit view)开始,让我们浏览一下具体的改动。将你的审查重点放在高层次的关注点上,比如功能是否有效以及是否反映了规格说明,而不是哪些具体的 CSS 类被实现等微小细节。例如,Home.tsx 非常简陋。极简真的是极简。我们想要一个带有清晰的头部、主体和页脚地标的布局组件,但要把这些做成子组件。并且创建一个 CSS 文件。事实证明,代码中的这个错误源于计划中的遗漏。我们之前根本没要求做这些。让我们要求智能体进行修复,从而同时修正规格说明和代码实现。这种由智能体生成内容,由我们人类进行验证的过程被称为”人类干预(human-in-the-loop / 回路中的人类)“。因为智能体写代码的速度太快了,软件开发者最近一直在谈论”认知债务(cognitive debt)“——即追踪你的代码正在做什么以及它是如何演变所带来的心理负担。这就是为什么为了使这个过程快速、易于控制,并减少认知债务,变更的范围应该是可控的。智能体正在进行我们的修改,同时也顺便验证这些修改没有破坏任何东西。
好消息,智能体完成了并给出了一个快速总结。你也可以在编辑器中看到这一点。功能计划被修改,添加了一个任务组 5(Group 5)来列出这些新步骤。代码现在有了一个布局组件,并且添加了一个 CSS 文件。看起来那三个子组件都被放在了同一个文件里,但这不符合惯例。让我们使用 IDE 的移动工具把它们放到各自的文件中。这种修改在编辑器里很容易做,我们人类一直很擅长这个。没必要让智能体来做,对吧?我们自己动手就好了。别急。这可能会导致”脱节/偏离(drift)“,即其他工件、规格说明、自述文件会变得不同步。让我们要求智能体去修复相关的提及,并确保这不会在以后浪费我们的时间。所有更改都完成了。我们弄坏了什么吗?运行测试会有帮助,但智能体没有安装我们的测试包。由于这是所有功能都需要的基础设置,我们将在下一节课讨论它。
现在我们准备好将这项工作标记为完成,并合并我们的成果。请注意,项目章程的一部分也与该分支上的功能一起更新了。如何处理规格说明的版本控制,以及如何关联哪些规格说明产生了哪些代码变更,是社区中一个正在发展演变的话题。对路线图的修改很小,仅仅是在路线图里勾掉了一个步骤而已。所以将这些更新保留在同一个分支上是可以的。如果整体的项目章程更新比较复杂,最好在一个单独的分支中进行。现在我们准备好将这项工作标记为完成,并合并我们的成果了。我们刚刚使用了规格驱动开发来开发和验证我们的第一个功能。但是等等,我们难道不应该再从项目的宏观层面重新审视一下吗?