# 第二章：Harness 架构全景

本章从架构设计的高度，对Harness系统进行全面的剖析。

首先，我们提出一个通用的参考架构（三层 + 横切关注点），这个架构在不同的Harness实现中都能找到对应的概念——虽然名称和细节可能有所不同，但核心的分层思想是一致的。

接着，我们深入讨论每一层的设计原则、职责范围和接口规范。特别是，我们将对比三个业界的参考实现——OpenAI Codex的性能型架构、Claude Code的任务型架构和OpenClaw的自驱型架构——展示不同应用场景下的架构取舍。

在随后的章节中，我们特别关注两个横切的关注点——安全性和可观测性——它们虽然不是独立的层，但贯穿整个系统的各个角落，对系统的可靠性至关重要。

最后，本章通过MiniHarness项目的脚手架搭建，将所有的理论概念转化为可运行的代码。通过这一实践过程，读者不仅能够深化对架构的理解，更能为后续的系统开发奠定坚实的基础。

本章是连接第一章概念认识和后续各章深入设计的桥梁。

## 本章结构

* 2.1：通用参考架构
* 2.2：执行层的详细设计
* 2.3：安全层与可观测性层
* 2.4：层间接口设计
* 2.5：MiniHarness脚手架搭建


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/harness_engineering_guide/di-yi-bu-fen-harness-gong-cheng-ji-chu/02_architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
