“Harness Engineering”概念及其插件实现旨在通过确定性工具、基于代理的审查和周期性熵检查来约束 AI 辅助代码生成,防止代码库随时间漂移和退化 1。该概念源自 Birgitta Boeckeler 在 martinfowler.com 上发表的文章,写作背景为 ThoughtWorks 1。这一框架主要由上下文工程(Context Engineering)、架构约束(Architectural Constraints)和垃圾回收(Garbage Collection)三大核心组件构成 1。
在具体机制上,上下文工程通过维护 HARNESS.md 文档来捕获技术栈、架构决策、命名约定和 AI 约束条件 1。架构约束利用“验证槽”机制,采用确定性工具(如 linters、脚本)或基于语言模型的代理审查进行验证 1。垃圾回收则通过周期性流程处理死代码、过时依赖和废弃约定,以对抗系统熵增 1。该框架还引入了“渐进硬化”(Progressive Hardening)原则,将约束划分为未验证、代理和确定性三个晋升层级 1。相关插件实现了三个执行循环:在编辑时提供建议的内循环、在 PR 时进行严格检查的中循环,以及按计划进行调查的外循环 1。此外,插件支持通过 /reflect 命令将会话结果记录到学习日志中以指导未来代理决策,并能通过 harness-init 过程从现有代码推断约束,从而引导生成候选的 HARNESS.md 1。
The concept of "Harness Engineering" originates from an article by Birgitta Boeckeler on martinfowler.com, written in the ThoughtWorks context, and aims to constrain AI-assisted code generation to prevent codebases from drifting and degrading over time 1. To achieve this, the framework utilizes deterministic tools, agent-based reviews, and periodic entropy checks 1. The harness consists of three core components: Context Engineering, Architectural Constraints, and Garbage Collection 1.
Context Engineering involves maintaining a document named HARNESS.md that captures the stack, architectural decisions, naming conventions, and constraints for the AI 1. Architectural Constraints use "verification slots" that employ either deterministic tools like linters and scripts, or agent-based review using language models 1. To fight entropy, the Garbage Collection component operates as a periodic process targeting dead code, stale dependencies, and abandoned conventions 1. Furthermore, the framework applies a "Progressive Hardening" principle, which serves as a promotion ladder for constraints moving from Unverified to Agent, and finally to Deterministic 1.
A plugin implementing this framework enforces rules through three distinct loops 1. The inner loop operates in an advisory capacity at edit time, the middle loop enforces strict checks at PR time, and the outer loop conducts investigative reviews on a schedule 1. Additionally, the plugin features a /reflect command that captures session outcomes into a learnings log to inform future agent decisions 1. The harness-init process can infer constraints from existing code to bootstrap a candidate HARNESS.md 1.
评论
还没有评论,欢迎留下第一条。