<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>锡安的自留地</title>
        <link>https://gendlee.github.io/</link>
        <description>这是一个由NotionNext生成的站点</description>
        <lastBuildDate>Wed, 15 Apr 2026 14:37:59 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, zion</copyright>
        <item>
            <title><![CDATA[0024 Claude Code顶级Harness工程图纸 ：来自那泄漏的51万行代码]]></title>
            <link>https://gendlee.github.io/claude-code-design</link>
            <guid>https://gendlee.github.io/claude-code-design</guid>
            <pubDate>Mon, 06 Apr 2026 16:00:00 GMT</pubDate>
            <description><![CDATA[Claude Code顶级Harness工程]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-33ba920890b180d7aac7e855284ab51e"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-33ba920890b180529e4ed09bda5bbaab">近期泄漏的51万行Claude Code源代码为我们揭开了这个顶级AI编程助手的神秘面纱。本文将深入剖析其核心架构设计和工程实现原理。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180a3afcbd2fc3ecdf072" data-id="33ba920890b180a3afcbd2fc3ecdf072"><span><div id="33ba920890b180a3afcbd2fc3ecdf072" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180a3afcbd2fc3ecdf072" title="🏗️ 整体架构设计"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🏗️ 整体架构设计</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1805b84ecc547cb01d8db" data-id="33ba920890b1805b84ecc547cb01d8db"><span><div id="33ba920890b1805b84ecc547cb01d8db" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1805b84ecc547cb01d8db" title="核心组件架构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">核心组件架构</span></span></h4><div class="notion-text notion-block-33ba920890b180d3946ee54e714a1e9f">Claude Code采用了模块化的Harness架构，主要包含以下几个核心层次：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b18028a70cf8f1292681a1"><li><b>Agent层：</b>负责任务规划、决策制定和执行协调</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1800f9b6bda6a1b602957"><li><b>Tool层：</b>提供文件操作、代码执行、搜索等基础能力</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180b5b9c7ca3d2f5944ce"><li><b>Context层：</b>管理会话上下文、代码库索引和知识检索</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180fb8ccad96d2b66f87b"><li><b>Execution层：</b>安全沙箱环境，执行代码和命令</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1804c995ddf3726fe1458"><li><b>Interface层：</b>与用户交互的前端接口</li></ul><div class="notion-blank notion-block-33ba920890b180bbb319dd41dd85f1b2"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1804691ebeaa6efb50413" data-id="33ba920890b1804691ebeaa6efb50413"><span><div id="33ba920890b1804691ebeaa6efb50413" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1804691ebeaa6efb50413" title="Harness框架特点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Harness框架特点</span></span></h4><div class="notion-text notion-block-33ba920890b1802bbf86d59a5341c6ef">从代码中可以看出，Harness框架具有以下显著特点：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b180749a3fda156bc4a020"><li><b>高度可扩展性：</b>插件化的工具系统，易于添加新能力</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180d8a772cdd2d00106e9"><li><b>安全隔离：</b>多层沙箱机制确保代码执行安全</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180b0ba76f8d124e87aab"><li><b>状态管理：</b>完善的会话状态持久化和恢复机制</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b18018b6fac8c0b9805afa"><li><b>错误处理：</b>细粒度的异常捕获和优雅降级策略</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-476cdfd24a2246f5bda399840a40bc02" data-id="476cdfd24a2246f5bda399840a40bc02"><span><div id="476cdfd24a2246f5bda399840a40bc02" class="notion-header-anchor"></div><a class="notion-hash-link" href="#476cdfd24a2246f5bda399840a40bc02" title="架构图（概览）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">架构图（概览）</span></span></h4><div class="notion-blank notion-block-33ba920890b18005a526c29be0bc4d12"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180a29fdcdd36ea76adf9" data-id="33ba920890b180a29fdcdd36ea76adf9"><span><div id="33ba920890b180a29fdcdd36ea76adf9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180a29fdcdd36ea76adf9" title="🔧 核心技术实现"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🔧 核心技术实现</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1803da226f645c4f97cde" data-id="33ba920890b1803da226f645c4f97cde"><span><div id="33ba920890b1803da226f645c4f97cde" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1803da226f645c4f97cde" title="1. 智能代码理解系统"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 智能代码理解系统</span></span></h4><div class="notion-text notion-block-33ba920890b180568758dd6d084715bd">Claude Code使用了多层次的代码理解机制：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b180d9b692eb3ec761d916"><li><b>AST解析：</b>通过抽象语法树深度理解代码结构</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b18048a5a8d4df890a3e16"><li><b>语义分析：</b>结合类型系统和符号表进行语义理解</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180cebb48d962a5c4b8ce"><li><b>依赖图构建：</b>自动分析模块间依赖关系</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180028a36e140af0aa996"><li><b>上下文索引：</b>建立代码库的高效检索索引</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b180c4b1d1fd98c8630d43" data-id="33ba920890b180c4b1d1fd98c8630d43"><span><div id="33ba920890b180c4b1d1fd98c8630d43" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180c4b1d1fd98c8630d43" title="2. 任务规划与执行引擎"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 任务规划与执行引擎</span></span></h4><div class="notion-text notion-block-33ba920890b1802a98d8cf4de3161e71">系统采用分层的任务规划策略：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b180a8a419ed5fed789138" data-id="33ba920890b180a8a419ed5fed789138"><span><div id="33ba920890b180a8a419ed5fed789138" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180a8a419ed5fed789138" title="3. 工具调用系统"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 工具调用系统</span></span></h4><div class="notion-text notion-block-33ba920890b18014a107eb6d3509d24c">Claude Code实现了一个强大的工具调用框架：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b1805b94a5cf574050bbe4"><li><b>工具注册：</b>动态注册和发现可用工具</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1808fbd56f04d48b8af7b"><li><b>参数验证：</b>严格的类型检查和参数校验</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1805eabd7cd786bb87e87"><li><b>结果处理：</b>标准化的返回值格式</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180d8afb3e2fce4f0abcc"><li><b>错误重试：</b>智能的失败重试和回退机制</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1808481c0ceecdc70179a" data-id="33ba920890b1808481c0ceecdc70179a"><span><div id="33ba920890b1808481c0ceecdc70179a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1808481c0ceecdc70179a" title="4. 安全沙箱机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 安全沙箱机制</span></span></h4><div class="notion-text notion-block-33ba920890b18043af6cf20a61ee4b71">多层安全防护确保代码执行安全：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b1808c986de7752cff8896"><li><b>容器隔离：</b>使用Docker容器隔离执行环境</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b18038a8e4c39087e66ffa"><li><b>资源限制：</b>CPU、内存、网络等资源的严格限制</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1800899bcff15629b4383"><li><b>文件系统保护：</b>只读挂载和路径白名单机制</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180ce8893cb8dcab57b9a"><li><b>权限控制：</b>最小权限原则和能力限制</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b1805a8d8fc23ad42fd9bd" data-id="33ba920890b1805a8d8fc23ad42fd9bd"><span><div id="33ba920890b1805a8d8fc23ad42fd9bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1805a8d8fc23ad42fd9bd" title="💡 关键设计模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💡 关键设计模式</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1800d9903f8591dafe651" data-id="33ba920890b1800d9903f8591dafe651"><span><div id="33ba920890b1800d9903f8591dafe651" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1800d9903f8591dafe651" title="Agentic Pattern"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Agentic Pattern</span></span></h4><div class="notion-text notion-block-33ba920890b180768641c0ec262dfa55">Claude Code采用了Agent设计模式，使系统具备自主规划和决策能力：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b1809692dbd4aa1a4301f3"><li><b>感知（Perception）：</b>理解用户意图和当前环境状态</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180c29af6e8ce6a77a9ac"><li><b>规划（Planning）：</b>制定达成目标的行动计划</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180d7b01ff64884f5a30f"><li><b>执行（Action）：</b>调用工具执行具体操作</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180b1b13aff5fb3a25d4f"><li><b>反思（Reflection）：</b>评估结果并调整策略</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b1803f837df16db29a32b8" data-id="33ba920890b1803f837df16db29a32b8"><span><div id="33ba920890b1803f837df16db29a32b8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b1803f837df16db29a32b8" title="Tool Use Pattern"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Tool Use Pattern</span></span></h4><div class="notion-text notion-block-33ba920890b1802a8eded5194c11a57b">标准化的工具使用模式：</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180a1a9aff4e905dc8f4c" data-id="33ba920890b180a1a9aff4e905dc8f4c"><span><div id="33ba920890b180a1a9aff4e905dc8f4c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180a1a9aff4e905dc8f4c" title="📊 性能优化策略"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📊 性能优化策略</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b180abbe92f9adac27b69e" data-id="33ba920890b180abbe92f9adac27b69e"><span><div id="33ba920890b180abbe92f9adac27b69e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180abbe92f9adac27b69e" title="代码索引优化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码索引优化</span></span></h4><div class="notion-text notion-block-33ba920890b180b981c9c7cd1518ca12">从源码中可以看到多项索引优化技术：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b1802f9f72ebbc75d4b43d"><li><b>增量索引：</b>只索引变更的文件，避免全量重建</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b18073aa63c49cd565380e"><li><b>多级缓存：</b>内存、磁盘多级缓存策略</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180c89de4f1f1e64d20b0"><li><b>并行处理：</b>多线程并行索引大型代码库</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1802688e4ddbf15126910"><li><b>智能预加载：</b>根据使用模式预测性加载代码</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b18064b694f9b4faab6361" data-id="33ba920890b18064b694f9b4faab6361"><span><div id="33ba920890b18064b694f9b4faab6361" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b18064b694f9b4faab6361" title="上下文管理优化"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">上下文管理优化</span></span></h4><ul class="notion-list notion-list-disc notion-block-33ba920890b180339ad2f347e6b7a4d3"><li><b>上下文窗口管理：</b>智能选择最相关的代码片段</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180e99a01d3be1f4829c0"><li><b>压缩算法：</b>高效压缩历史会话数据</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180d09baaf9bdce091634"><li><b>分层存储：</b>热数据内存，冷数据磁盘</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180e5acf0eace54a755b7" data-id="33ba920890b180e5acf0eace54a755b7"><span><div id="33ba920890b180e5acf0eace54a755b7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180e5acf0eace54a755b7" title="🔐 安全与隐私保护"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🔐 安全与隐私保护</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b180809e51ef1aeeda9328" data-id="33ba920890b180809e51ef1aeeda9328"><span><div id="33ba920890b180809e51ef1aeeda9328" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180809e51ef1aeeda9328" title="数据安全"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">数据安全</span></span></h4><ul class="notion-list notion-list-disc notion-block-33ba920890b1806aaae6c348f344bf76"><li><b>端到端加密：</b>敏感数据传输加密</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180f090c3d38f5f7b1736"><li><b>本地优先：</b>尽可能在本地处理敏感代码</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b1806db647d777607f3ecb"><li><b>数据脱敏：</b>自动识别和脱敏敏感信息</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180e3a432d64063e575ad"><li><b>访问控制：</b>细粒度的权限管理系统</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-33ba920890b18040a047fb1e950e30e2" data-id="33ba920890b18040a047fb1e950e30e2"><span><div id="33ba920890b18040a047fb1e950e30e2" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b18040a047fb1e950e30e2" title="代码执行安全"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">代码执行安全</span></span></h4><ul class="notion-list notion-list-disc notion-block-33ba920890b1807daeabe74622f5a73f"><li><b>静态分析：</b>执行前的危险代码检测</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180b0a421ef78901b9457"><li><b>运行时监控：</b>实时监控异常行为</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180879e96d276e7c73a59"><li><b>回滚机制：</b>支持操作撤销和状态恢复</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180f9a398c195b98d0fcf" data-id="33ba920890b180f9a398c195b98d0fcf"><span><div id="33ba920890b180f9a398c195b98d0fcf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180f9a398c195b98d0fcf" title="🚀 工程亮点总结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">🚀 工程亮点总结</span></span></h3><div class="notion-text notion-block-33ba920890b18063ad01f29febd06c32">通过对51万行代码的分析，Claude Code的工程亮点包括：</div><ol start="1" class="notion-list notion-list-numbered notion-block-33ba920890b180d48465cda6b16ca628" style="list-style-type:decimal"><li><b>模块化架构：</b>清晰的分层设计，高内聚低耦合</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-33ba920890b180238fdecd7cf70ff512" style="list-style-type:decimal"><li><b>智能Agent系统：</b>具备自主规划和决策能力</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-33ba920890b180fbadfcebe5271c923c" style="list-style-type:decimal"><li><b>强大的工具生态：</b>可扩展的工具框架</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-33ba920890b18092a9c9c5f5be15f738" style="list-style-type:decimal"><li><b>完善的安全机制：</b>多层防护确保执行安全</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-33ba920890b1807398e9eb9e3ce81555" style="list-style-type:decimal"><li><b>高性能实现：</b>多项优化技术支撑大规模代码库</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-33ba920890b1801bb0a3e42b3b03c0fb" style="list-style-type:decimal"><li><b>优秀的错误处理：</b>健壮的异常处理和恢复机制</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-33ba920890b180e29355f6d1f43fad9b" data-id="33ba920890b180e29355f6d1f43fad9b"><span><div id="33ba920890b180e29355f6d1f43fad9b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#33ba920890b180e29355f6d1f43fad9b" title="📖 延伸阅读"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">📖 延伸阅读</span></span></h3><div class="notion-text notion-block-33ba920890b180359d68e0a9a0eada75">这次代码泄漏为我们提供了难得的学习机会，让我们能够深入了解顶级AI编程助手的工程实现。无论是架构设计、技术选型还是工程实践，都值得我们深入研究和借鉴。</div><div class="notion-text notion-block-33ba920890b180628e49e6d1eda5a6ab">如果你对AI Agent系统设计感兴趣，可以从以下几个方向深入学习：</div><ul class="notion-list notion-list-disc notion-block-33ba920890b1808b88c6c0143fecf85b"><li>Agent架构模式与最佳实践</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180d199f3f160608960aa"><li>Tool Use Pattern的实现细节</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180e5b3aec03d2a66f915"><li>代码理解与索引技术</li></ul><ul class="notion-list notion-list-disc notion-block-33ba920890b180eca224efc5e219821c"><li>安全沙箱的设计与实现</li></ul><div class="notion-blank notion-block-33ba920890b180ec982ae5b392e888a1"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0023 OpenClaw底层原理]]></title>
            <link>https://gendlee.github.io/open-claw-info</link>
            <guid>https://gendlee.github.io/open-claw-info</guid>
            <pubDate>Sun, 05 Apr 2026 16:00:00 GMT</pubDate>
            <description><![CDATA[OpenClaw底层原理]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-33aa920890b18048b39fc07809a17558"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-52ccd8022de6472db09d072cd921d4cf" data-id="52ccd8022de6472db09d072cd921d4cf"><span><div id="52ccd8022de6472db09d072cd921d4cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#52ccd8022de6472db09d072cd921d4cf" title="OpenClaw 底层原理：从 Agent 运行时到工具调用的全链路拆解"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OpenClaw 底层原理：从 Agent 运行时到工具调用的全链路拆解</span></span></h2><div class="notion-callout notion-blue_background_co notion-block-c12f3e99826245c584789e9cdcbc3c32"><div class="notion-page-icon-inline notion-page-icon-span"><span class="notion-page-icon" role="img" aria-label="🦞">🦞</span></div><div class="notion-callout-text"><div class="notion-text notion-block-e255cd48b5314c9abe1210a27b822f32">本文面向希望“看懂 + 跑通”的读者：先讲 OpenClaw 的核心抽象与运行时机制，再给出一套可复现的本地实操教程，并补充常见坑位与调优建议。</div></div></div><hr class="notion-hr notion-block-2a38f21e34e94e50b3bb82e44bbdc645"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-169810e5442b4f55810982ee043e0a3e" data-id="169810e5442b4f55810982ee043e0a3e"><span><div id="169810e5442b4f55810982ee043e0a3e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#169810e5442b4f55810982ee043e0a3e" title="1. OpenClaw 是什么：它解决了哪类问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. OpenClaw 是什么：它解决了哪类问题</span></span></h3><div class="notion-text notion-block-09dd710081f348f595b4f99d0ff3bd02">OpenClaw 可以理解为一套 <b>Agent Runtime（智能体运行时）</b>：</div><ul class="notion-list notion-list-disc notion-block-a02b20177f364d3394ee56be8a21fb69"><li>把“大模型能力”封装成可控的 <b>任务执行系统</b>。</li></ul><ul class="notion-list notion-list-disc notion-block-68b1e2322c2d49fab19032fcd4c27c33"><li>用 <b>工具（Tools）</b>、<b>记忆（Memory）</b>、<b>规划（Planning）</b>、<b>执行（Execution）</b> 等模块，把一次对话变成可重复、可观测、可评估的流程。</li></ul><ul class="notion-list notion-list-disc notion-block-17f6a19dfaf74374b327faa5f95a8eb7"><li>将“模型输出文本”升级为“在约束内完成目标”的工程化能力。</li></ul><div class="notion-text notion-block-e557516b023247a4ba2680f23db97bf9">典型适用场景：</div><ul class="notion-list notion-list-disc notion-block-72027dfafd7a4eada8d4566c07ec02ab"><li>多步骤任务自动化（信息收集、对齐、生成、校验、落库）。</li></ul><ul class="notion-list notion-list-disc notion-block-02830f3578dd4f2bb380fc2c285b4015"><li>带外部依赖的工作流（调用 API、数据库、文件系统、浏览器）。</li></ul><ul class="notion-list notion-list-disc notion-block-b452e10c33b7448cbdf7422d2bd27fc3"><li>需要回溯与审计的生产任务（可观测、可重放、可评测）。</li></ul><hr class="notion-hr notion-block-c3bd33e15392444e965a1ffa55d0ff13"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-974aabc279dd42d6b5a7329a587c72cf" data-id="974aabc279dd42d6b5a7329a587c72cf"><span><div id="974aabc279dd42d6b5a7329a587c72cf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#974aabc279dd42d6b5a7329a587c72cf" title="2. 核心抽象：OpenClaw 的关键对象"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 核心抽象：OpenClaw 的关键对象</span></span></h3><div class="notion-text notion-block-4beaec0581fc454ca3dc4eee739a3782">从底层实现视角，OpenClaw 通常会围绕这些“稳定抽象”组织：</div><ol start="1" class="notion-list notion-list-numbered notion-block-ed2909b8c3ba479b9d6889a539d33806" style="list-style-type:decimal"><li><b>Agent</b></li><ol class="notion-list notion-list-numbered notion-block-ed2909b8c3ba479b9d6889a539d33806" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-6fc2904727594d1495befdd030e07122"><li>对外暴露的执行入口。</li></ul><ul class="notion-list notion-list-disc notion-block-55c4f97de1cc41938e31b118dc61694d"><li>绑定模型、工具集、策略与状态。</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-f024cb0b24d146d18f572a780e40390c" style="list-style-type:decimal"><li><b>Model Adapter（模型适配层）</b></li><ol class="notion-list notion-list-numbered notion-block-f024cb0b24d146d18f572a780e40390c" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-e725f48ad9b343d8b9cdde298faf2c07"><li>统一不同厂商、不同接口范式（Chat Completions / Responses / Function Calling）。</li></ul><ul class="notion-list notion-list-disc notion-block-7c1921cd1690446cabca7487e8ef0f69"><li>产出结构化的 <code class="notion-inline-code">assistant_message</code>，包含 tool call 或普通文本。</li></ul></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-bfe86707b5a548f8bbe698c89af88cda" style="list-style-type:decimal"><li><b>Tool（工具）</b></li><ol class="notion-list notion-list-numbered notion-block-bfe86707b5a548f8bbe698c89af88cda" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1d6b0bb4bdbb4088b91972085ff20df0"><li>标准化的可执行动作：<code class="notion-inline-code">name</code>、<code class="notion-inline-code">schema</code>、<code class="notion-inline-code">handler</code>。</li></ul><ul class="notion-list notion-list-disc notion-block-93c9aaae3e08478f94b07f07a3308419"><li>运行时会进行参数校验、超时控制、重试、隔离。</li></ul></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-48b89d28cbe8400cb7c9a5c3fa49e421" style="list-style-type:decimal"><li><b>Planner / Policy（规划与策略）</b></li><ol class="notion-list notion-list-numbered notion-block-48b89d28cbe8400cb7c9a5c3fa49e421" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-d1ceadcec41142a398cf9586d024479c"><li>决定“要不要调用工具、调用哪个工具、何时停止”。</li></ul><ul class="notion-list notion-list-disc notion-block-7e06d8f9880042f298cbb510d64d7a80"><li>常见实现：ReAct、Plan-and-Execute、Graph/State Machine。</li></ul></ol></ol><ol start="5" class="notion-list notion-list-numbered notion-block-2cd2d11761d842d0948ec8d8402b75da" style="list-style-type:decimal"><li><b>Memory（记忆）</b></li><ol class="notion-list notion-list-numbered notion-block-2cd2d11761d842d0948ec8d8402b75da" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-5e47bd32d6b848c1ae6776a482eff18b"><li>短期记忆：当前对话窗口内的信息。</li></ul><ul class="notion-list notion-list-disc notion-block-2bf296280ebb42b6a963f250fea079de"><li>长期记忆：向量检索、知识库、历史轨迹。</li></ul><ul class="notion-list notion-list-disc notion-block-0dd98c7984174da4ba6be120acfa2100"><li>关键在于“写入策略”和“读取策略”。</li></ul></ol></ol><ol start="6" class="notion-list notion-list-numbered notion-block-a11c57d92ec0418c882ab9d8e1418a94" style="list-style-type:decimal"><li><b>State / Trace（状态与轨迹）</b></li><ol class="notion-list notion-list-numbered notion-block-a11c57d92ec0418c882ab9d8e1418a94" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-fb5ab9473b984a02a930f9efa6b4a05b"><li>每一步的输入、输出、工具调用、耗时、错误，形成可观测链路。</li></ul><ul class="notion-list notion-list-disc notion-block-593d6c071d6f455583cd53acf9a4a3f3"><li>支持回放、评测与问题定位。</li></ul></ol></ol><hr class="notion-hr notion-block-92e76f46cf4c4f3b9a57149463758be8"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-36f267c08fea48d2a18cbee422861a5a" data-id="36f267c08fea48d2a18cbee422861a5a"><span><div id="36f267c08fea48d2a18cbee422861a5a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#36f267c08fea48d2a18cbee422861a5a" title="3. 运行时全链路：一次请求是如何被执行的"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 运行时全链路：一次请求是如何被执行的</span></span></h3><div class="notion-text notion-block-5853807ef1a34c4fa32ee8cc19f20f66">下面用“任务 → 规划 → 工具 → 汇总”的典型链路说明底层原理。</div><div class="notion-text notion-block-abc9266abf954291822ee7d10ce427ac">关键点拆解：</div><ul class="notion-list notion-list-disc notion-block-f0df6d6583484656af26aa762f6fd1ed"><li><b>Prompt 不是一次性模板</b>：运行时会把系统提示、工具描述、上下文、记忆检索结果、上一步工具结果按策略拼装。</li></ul><ul class="notion-list notion-list-disc notion-block-90a0769bfdbf495f9db056dd24f0d412"><li><b>工具调用是强约束出口</b>：LLM 只能“声明要调用工具”，真正执行由 Tool Executor 完成。</li></ul><ul class="notion-list notion-list-disc notion-block-855e58db95eb4293b0163584f08d5663"><li><b>Stop 条件是工程策略</b>：不是“模型说结束就结束”。可以结合最大步数、置信度、评估器结果、预算等限制。</li></ul><hr class="notion-hr notion-block-4fbc0cfe9cf64507bad1b205dfaf43e4"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-b27bf98493e7447aa2e4fe1512c97b8f" data-id="b27bf98493e7447aa2e4fe1512c97b8f"><span><div id="b27bf98493e7447aa2e4fe1512c97b8f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b27bf98493e7447aa2e4fe1512c97b8f" title="4. 工具调用（Tool Calling）的底层机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 工具调用（Tool Calling）的底层机制</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-226736198b37477bbe81a3076cb6d7db" data-id="226736198b37477bbe81a3076cb6d7db"><span><div id="226736198b37477bbe81a3076cb6d7db" class="notion-header-anchor"></div><a class="notion-hash-link" href="#226736198b37477bbe81a3076cb6d7db" title="4.1 工具的“接口契约”"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.1 工具的“接口契约”</span></span></h4><div class="notion-text notion-block-aa435fdb66d84dc4b5321357e26c9cd6">工具本质是一个可被运行时调用的函数，但必须具备可机器理解的协议：</div><ul class="notion-list notion-list-disc notion-block-a7bc8b098efc4ba99187445078bfe95e"><li><code class="notion-inline-code">name</code>: 全局唯一标识。</li></ul><ul class="notion-list notion-list-disc notion-block-042290d97961449680f0ff908b474a6a"><li><code class="notion-inline-code">description</code>: 给模型看的行为说明。</li></ul><ul class="notion-list notion-list-disc notion-block-a166662a5370458ba78e3ffdf8fd515d"><li><code class="notion-inline-code">input_schema</code>: JSON Schema 或等价的参数约束。</li></ul><ul class="notion-list notion-list-disc notion-block-8fb5be2d88db4c828c93a361737548ac"><li><code class="notion-inline-code">handler(ctx, args)</code>: 真正执行。</li></ul><div class="notion-text notion-block-18ececfccd9d4fc9841daca6be9c6e04">这样，运行时才能做到：</div><ul class="notion-list notion-list-disc notion-block-e3bad9a68c4c4c4e82aa6796260d2c51"><li>参数校验（缺字段、类型不对、越界）。</li></ul><ul class="notion-list notion-list-disc notion-block-0fc85d62a2194d88acc7e0c948abed5c"><li>结果格式化（让模型更稳定地消费工具结果）。</li></ul><ul class="notion-list notion-list-disc notion-block-3cbe1600efd841de93afa45fba5b45e2"><li>观测与审计（每次调用可追踪）。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-2776908a10c141c6865fbb611c7de7a8" data-id="2776908a10c141c6865fbb611c7de7a8"><span><div id="2776908a10c141c6865fbb611c7de7a8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2776908a10c141c6865fbb611c7de7a8" title="4.2 Tool Executor 的工程职责"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4.2 Tool Executor 的工程职责</span></span></h4><div class="notion-text notion-block-f08922a321824798bf88be71898a6226">Tool Executor 往往比你想象得“重”，核心职责包括：</div><ul class="notion-list notion-list-disc notion-block-7e299bd98aef460b926e9895df293beb"><li><b>参数校验与反序列化</b>：将 LLM 输出的 arguments 变成安全的结构化输入。</li></ul><ul class="notion-list notion-list-disc notion-block-8f93e221e2ae4d7aa021684947266e79"><li><b>超时与取消</b>：防止工具卡死拖垮链路。</li></ul><ul class="notion-list notion-list-disc notion-block-bc8c1982fa4648e194cb3fcb7792235f"><li><b>重试与幂等</b>：对可重试错误做退避重试，并避免重复副作用。</li></ul><ul class="notion-list notion-list-disc notion-block-71a77e9209ae4bc992ff0b103efc9227"><li><b>沙箱隔离</b>：不同工具可在独立进程或容器内执行。</li></ul><ul class="notion-list notion-list-disc notion-block-b518c69f1f8e4a4181ebc138893542b2"><li><b>结果截断与脱敏</b>：避免把过长或敏感数据直接喂回模型。</li></ul><hr class="notion-hr notion-block-ea3d32778ae44c5db9ae776d42d72c1a"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-2b23e189abfa4188aa9a5982578df4ce" data-id="2b23e189abfa4188aa9a5982578df4ce"><span><div id="2b23e189abfa4188aa9a5982578df4ce" class="notion-header-anchor"></div><a class="notion-hash-link" href="#2b23e189abfa4188aa9a5982578df4ce" title="5. 记忆系统：如何“记得住”又“不乱记”"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">5. 记忆系统：如何“记得住”又“不乱记”</span></span></h3><div class="notion-text notion-block-65aeafdc8b7d4bcebb591c645af16881">建议把记忆设计成三层：</div><ul class="notion-list notion-list-disc notion-block-88c4184fa1604eadbf1e8fd767b10e92"><li><b>会话记忆（Conversation Buffer）</b>：始终存在，但窗口有限。</li></ul><ul class="notion-list notion-list-disc notion-block-a36cd759ce674004904824499fb1aab1"><li><b>摘要记忆（Summarization Memory）</b>：对长会话做压缩，保留决策与结论。</li></ul><ul class="notion-list notion-list-disc notion-block-fe6d6019b39a48118aa67c912b3b3980"><li><b>检索记忆（RAG / Vector Store）</b>：把事实与文档索引起来，按需检索。</li></ul><div class="notion-text notion-block-5834d459d988488c8c413d18b280597d">一个实用的写入策略：</div><ul class="notion-list notion-list-disc notion-block-3431fbca8d8f4b1b89756289c2c899a6"><li>只有当信息满足“长期可复用”才写入检索记忆。</li></ul><ul class="notion-list notion-list-disc notion-block-b31810e82a0e46efbd7728787f44a788"><li>只有当信息满足“对后续决策重要”才写入摘要记忆。</li></ul><hr class="notion-hr notion-block-1f9e76d62f52439b840e8581dd803a45"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-371dcc73f5cf475697e96449c466ace5" data-id="371dcc73f5cf475697e96449c466ace5"><span><div id="371dcc73f5cf475697e96449c466ace5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#371dcc73f5cf475697e96449c466ace5" title="6. 规划与执行：从“想”到“做”的两段式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">6. 规划与执行：从“想”到“做”的两段式</span></span></h3><div class="notion-text notion-block-f855e6dd9b134a9bbb070b448f667579">常见的工程落地方式是：</div><ol start="1" class="notion-list notion-list-numbered notion-block-f15c2c57d4fe412e9921a7fffdf1ccd9" style="list-style-type:decimal"><li><b>规划（Plan）</b>：先输出一个可执行计划（若干步骤）。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-ef06710e9eaf4caab8afff9418f2cf7e" style="list-style-type:decimal"><li><b>执行（Execute）</b>：按步骤逐个执行，每步允许调用工具，并把结果写入状态。</li></ol><div class="notion-text notion-block-0a0521a920d642208d463a8c93dd45ce">优点：</div><ul class="notion-list notion-list-disc notion-block-28a35910214c48509fd030e0b74704ab"><li>可控：可以审计计划，也可以让人类在关键步骤审批。</li></ul><ul class="notion-list notion-list-disc notion-block-e08c124c84b0487b8fb56bf2fc34e151"><li>可评测：每个步骤可以做单独指标（成功率、成本、耗时）。</li></ul><ul class="notion-list notion-list-disc notion-block-eeeed014a3524173b39ccbd104ab2936"><li>可恢复：失败时只重试失败步骤。</li></ul><hr class="notion-hr notion-block-9360570f7217416b9fed12072ac7589d"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-9036cba404f848fe90262c7e86004eec" data-id="9036cba404f848fe90262c7e86004eec"><span><div id="9036cba404f848fe90262c7e86004eec" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9036cba404f848fe90262c7e86004eec" title="7. 架构图：推荐的工程分层"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">7. 架构图：推荐的工程分层</span></span></h3><div class="notion-text notion-block-726bef276973498d96504b93a0202111">落地建议：</div><ul class="notion-list notion-list-disc notion-block-794f5d87dd7848ea9f5245c1dd1860fa"><li>Runtime 只做编排与通用能力，不要把业务逻辑写在 Runtime。</li></ul><ul class="notion-list notion-list-disc notion-block-d25deb86b5114cba803affd8f7827829"><li>Tool 层与业务系统集成要“窄接口”，避免把业务复杂度泄漏给模型。</li></ul><hr class="notion-hr notion-block-3f49f45957194bebb1c04ac6c2a1a73a"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-8a4f5fd221164221a6ec60871681bde0" data-id="8a4f5fd221164221a6ec60871681bde0"><span><div id="8a4f5fd221164221a6ec60871681bde0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#8a4f5fd221164221a6ec60871681bde0" title="8. 实操体验教程：本地跑一个最小可用 Agent"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8. 实操体验教程：本地跑一个最小可用 Agent</span></span></h3><div class="notion-text notion-block-34b646bd0bb94010ae37238dd272d4dc">下面是一套“最小闭环”示例：</div><ul class="notion-list notion-list-disc notion-block-3a77828b335d41ca8a4fde3b8080ecea"><li>一个 Agent</li></ul><ul class="notion-list notion-list-disc notion-block-db70fd224328491a99110fd79c964a5b"><li>两个工具：<code class="notion-inline-code">calculator</code> 与 <code class="notion-inline-code">http_get</code></li></ul><ul class="notion-list notion-list-disc notion-block-71826f33bc274e15aa9a2b5125ac169d"><li>一次任务：先计算，再拉取网页，再总结</li></ul><blockquote class="notion-quote notion-block-947b6085ab6640c6ad45046fa4d7e63b"><div>说明：不同 OpenClaw 版本或实现会有差异。你可以把下面示例当作“工程骨架”，按你的实际 SDK/接口名替换。</div></blockquote><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-48e95436259d4375964ecee8c947f24e" data-id="48e95436259d4375964ecee8c947f24e"><span><div id="48e95436259d4375964ecee8c947f24e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#48e95436259d4375964ecee8c947f24e" title="8.1 环境准备"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.1 环境准备</span></span></h4><ul class="notion-list notion-list-disc notion-block-8946013d4b1e49c2a1668b10dcd771d4"><li>Node.js 18+ 或 Python 3.10+</li></ul><ul class="notion-list notion-list-disc notion-block-332f1d0247eb4d44a69513d43d42a958"><li>一个可用的大模型 API Key</li></ul><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-90ded50e8b7a4663b807fa64269632b7" data-id="90ded50e8b7a4663b807fa64269632b7"><span><div id="90ded50e8b7a4663b807fa64269632b7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#90ded50e8b7a4663b807fa64269632b7" title="8.2 定义工具（示例：Python）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.2 定义工具（示例：Python）</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-ceb85d2b03c74b3aaf844fc113a39738" data-id="ceb85d2b03c74b3aaf844fc113a39738"><span><div id="ceb85d2b03c74b3aaf844fc113a39738" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ceb85d2b03c74b3aaf844fc113a39738" title="8.3 运行时循环（工具调用 + 继续推理）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.3 运行时循环（工具调用 + 继续推理）</span></span></h4><div class="notion-text notion-block-f6b8d205b5f941339fc9b1f38ee202e7">核心是一个 loop：</div><ol start="1" class="notion-list notion-list-numbered notion-block-bf11e3b08f20435fb16c586155d734b0" style="list-style-type:decimal"><li>把 tools 描述传给模型。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-791a7a8921d84b35bf6e383fa7394f85" style="list-style-type:decimal"><li>如果模型返回 tool call，就执行工具。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-e0163186657b407d93b76f7aa1ad559c" style="list-style-type:decimal"><li>把 tool result 再喂给模型。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-db04cf36c4ae4df9ab4decd68072927a" style="list-style-type:decimal"><li>直到模型返回最终答案，或达到最大步数。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-9868635c70e14227b08934e587fdb4bd" data-id="9868635c70e14227b08934e587fdb4bd"><span><div id="9868635c70e14227b08934e587fdb4bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#9868635c70e14227b08934e587fdb4bd" title="8.4 你应该看到什么"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">8.4 你应该看到什么</span></span></h4><ul class="notion-list notion-list-disc notion-block-ac4a03bc8dab4812a7ef29534a43cde5"><li>Trace 里有清晰的步骤：</li><ul class="notion-list notion-list-disc notion-block-ac4a03bc8dab4812a7ef29534a43cde5"><li>tool: calculator</li><li>tool: http_get</li><li>assistant: final answer</li></ul></ul><ul class="notion-list notion-list-disc notion-block-130072a1e72249f09fa7669de033bf75"><li>每一步都有耗时与 token 使用（如果你的运行时接入了观测）。</li></ul><hr class="notion-hr notion-block-5412e326c994413995069b10ada5c4dd"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-cc81cbaf0bd54ea5a9dc49c077b23730" data-id="cc81cbaf0bd54ea5a9dc49c077b23730"><span><div id="cc81cbaf0bd54ea5a9dc49c077b23730" class="notion-header-anchor"></div><a class="notion-hash-link" href="#cc81cbaf0bd54ea5a9dc49c077b23730" title="9. 常见问题与调优建议"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">9. 常见问题与调优建议</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-66cda1d87c604b22a71138f165040bda" style="list-style-type:decimal"><li><b>模型乱编工具参数</b></li><ol class="notion-list notion-list-numbered notion-block-66cda1d87c604b22a71138f165040bda" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-241a4e4771fd4ab0bebf16089b7b8695"><li>给工具 schema 加严格约束。</li></ul><ul class="notion-list notion-list-disc notion-block-a93dc9e8ec3a47c391a5ec62c75f149d"><li>对关键字段做白名单校验。</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-e0704c014e41413fbaf611cf47be4a6b" style="list-style-type:decimal"><li><b>工具结果太长导致上下文爆炸</b></li><ol class="notion-list notion-list-numbered notion-block-e0704c014e41413fbaf611cf47be4a6b" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-5308ff33924243b09043422640544aa4"><li>工具层做截断与结构化摘要。</li></ul><ul class="notion-list notion-list-disc notion-block-1ac2f9ff770b4731949f56b94d2cfbc0"><li>把原文放存储，模型只拿到引用与摘要。</li></ul></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-549015b8cac5439ca24a0768ce551a8e" style="list-style-type:decimal"><li><b>循环不停止</b></li><ol class="notion-list notion-list-numbered notion-block-549015b8cac5439ca24a0768ce551a8e" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1a8c43bc4bf84df78d96c5544b800b8b"><li>设定 <code class="notion-inline-code">max_steps</code>。</li></ul><ul class="notion-list notion-list-disc notion-block-486dff1910f4407293ac1a28ad045ffb"><li>增加“完成条件”评估器（例如：是否已满足用户要求）。</li></ul></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-c86f8ebfa210419ba11e7c84c65e73a6" style="list-style-type:decimal"><li><b>成本与延迟过高</b></li><ol class="notion-list notion-list-numbered notion-block-c86f8ebfa210419ba11e7c84c65e73a6" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-86aa3547ad414cc99ac4bff8d8c53542"><li>先用小模型做规划或筛选，再用大模型做关键生成。</li></ul><ul class="notion-list notion-list-disc notion-block-313a71a6ddf742eb9b7afe7950b0fe99"><li>缓存工具结果与检索结果。</li></ul></ol></ol><hr class="notion-hr notion-block-a7f072e5ae4f4d86996e0f8683183061"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-3815a2ffe5164699852bc8cdb57b072e" data-id="3815a2ffe5164699852bc8cdb57b072e"><span><div id="3815a2ffe5164699852bc8cdb57b072e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#3815a2ffe5164699852bc8cdb57b072e" title="10. 结语：把 OpenClaw 当作“可控的执行系统”"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">10. 结语：把 OpenClaw 当作“可控的执行系统”</span></span></h3><div class="notion-text notion-block-51a412f2ae44488485a6860c0350ee40">理解 OpenClaw 的底层原理，关键不在于“提示词写得多漂亮”，而在于：</div><ul class="notion-list notion-list-disc notion-block-5f3c4bceae524387ace82ecab21f0f51"><li>通过稳定抽象把模型放进工程体系。</li></ul><ul class="notion-list notion-list-disc notion-block-38ea5c50ddd54e57a545f6c15694ab76"><li>通过工具与状态让执行可控、可观测、可评测。</li></ul><ul class="notion-list notion-list-disc notion-block-db4f8e7bb35442bfa9c8efb913e3057f"><li>通过记忆与规划让任务可复用、可扩展。</li></ul><div class="notion-blank notion-block-33aa920890b18079af1dda15f4b727b8"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0022 AI淘金新时代：DeepSeek+工具矩阵的7大变现路径]]></title>
            <link>https://gendlee.github.io/deepseek</link>
            <guid>https://gendlee.github.io/deepseek</guid>
            <pubDate>Sun, 22 Dec 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[AI变现工具]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-164a920890b1800d9a1af2c8fb13f2fa"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1aaa920890b1802690bcfae553b60445" data-id="1aaa920890b1802690bcfae553b60445"><span><div id="1aaa920890b1802690bcfae553b60445" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b1802690bcfae553b60445" title="AI淘金新时代：DeepSeek+工具矩阵的7大变现路径"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AI淘金新时代：DeepSeek+工具矩阵的7大变现路径</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b180708528da19421e152c" data-id="1aaa920890b180708528da19421e152c"><span><div id="1aaa920890b180708528da19421e152c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b180708528da19421e152c" title="一、智能创作矩阵（0基础启动）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、智能创作矩阵（0基础启动）</span></span></h3><div class="notion-text notion-block-1aaa920890b18012b767c4da98544059"><b>工具组合</b>：DeepSeek+Gamma+Midjourney+CapCut</div><ul class="notion-list notion-list-disc notion-block-1aaa920890b180b5924aefe90fb9a6a0"><li><b>PPT工业化生产</b>：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b1806f8604fc23afc57d2d" style="list-style-type:decimal"><li>用DeepSeek生成结构化大纲（/format ppt指令）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b1808eb0fdd1f3644a0b10" style="list-style-type:decimal"><li>Gamma自动排版设计（支持团队协作功能）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180f49c7ce4ad6ad48bd1" style="list-style-type:decimal"><li>Midjourney定制主题插画</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b180f49c7ce4ad6ad48bd1" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b18015a2f3cac9d3e4e7ad"><em>变现案例</em>：某团队承接企业路演PPT，单份报价3000-8000元，日产能达5份</div></ol></ol><ul class="notion-list notion-list-disc notion-block-1aaa920890b180299e56f76a4446f3c6"><li><b>短视频流水线</b>：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b180a08aa7cb7b90b1282b" style="list-style-type:decimal"><li>DeepSeek生成分镜脚本（包含场景/台词/特效提示）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b180e38b47ddbf5f87d830" style="list-style-type:decimal"><li>RunwayML生成视频素材</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180f59fb1c738e3b7fa4a" style="list-style-type:decimal"><li>CapCut智能剪辑（AI自动卡点功能）</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b180f59fb1c738e3b7fa4a" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b180c4b318e56976f733fc"><em>实战数据</em>：某MCN机构用此模式单月产出300+带货视频，ROI提升400%</div></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b180eaab47f9739e894073" data-id="1aaa920890b180eaab47f9739e894073"><span><div id="1aaa920890b180eaab47f9739e894073" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b180eaab47f9739e894073" title="二、专业服务增强方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、专业服务增强方案</span></span></h3><div class="notion-text notion-block-1aaa920890b180d89517f05993086cf3"><b>工具组合</b>：DeepSeek+Wolfram Alpha+Overleaf</div><ul class="notion-list notion-list-disc notion-block-1aaa920890b1800fb8b1c08c953b24b9"><li><b>教育服务升级</b>：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b180ffac8bc84cb108181a" style="list-style-type:decimal"><li>数学建模：DeepSeek解析问题→Wolfram验证计算</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b18031813dda52b2fcedc4" style="list-style-type:decimal"><li>论文辅导：Latex模板自动生成（Overleaf协作）</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b18031813dda52b2fcedc4" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b180518fa4cd18909e45e3"><em>定价策略</em>：复杂问题按步骤收费（50-200元/题）</div></ol></ol><ul class="notion-list notion-list-disc notion-block-1aaa920890b18044a8d6cc6542ef0de5"><li><b>商业咨询2.0</b>：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b1808098cfe367d44a57b6" style="list-style-type:decimal"><li>输入企业数据→获取SWOT分析框架</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b1804a88efe4b012073f2d" style="list-style-type:decimal"><li>自动生成可执行方案（附甘特图代码）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b1808ca46bff0c46db8320" style="list-style-type:decimal"><li>Tableau可视化呈现</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b1808ca46bff0c46db8320" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b18021a53ac080e2be673e"><em>服务溢价</em>：某咨询公司收费标准提升60%，交付时间缩短70%</div></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b1806dad00f2e57763db9f" data-id="1aaa920890b1806dad00f2e57763db9f"><span><div id="1aaa920890b1806dad00f2e57763db9f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b1806dad00f2e57763db9f" title="三、技术开发生态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、技术开发生态</span></span></h3><div class="notion-text notion-block-1aaa920890b180e08032d5ac9b54bb72"><b>工具组合</b>：DeepSeek-API+GitHub Copilot+Replit</div><ul class="notion-list notion-list-disc notion-block-1aaa920890b1805ab35beaaa87c18926"><li><b>敏捷开发流程</b>：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b180c080bfce8cb6fcaa96" style="list-style-type:decimal"><li>自然语言转技术文档（自动生成API文档）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b1800e910fce3f989fd8e3" style="list-style-type:decimal"><li>Copilot实时代码补全</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180fc94c4dc45dc5617b7" style="list-style-type:decimal"><li>Replit云端调试（支持协同编程）</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b180fc94c4dc45dc5617b7" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b180ea93e2d085269595b0"><em>接单技巧</em>：在Upwork承接紧急开发需求，报价可达$50-150/小时</div></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b1800fb08ddcd740c4d2ad" data-id="1aaa920890b1800fb08ddcd740c4d2ad"><span><div id="1aaa920890b1800fb08ddcd740c4d2ad" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b1800fb08ddcd740c4d2ad" title="四、科研加速方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、科研加速方案</span></span></h3><div class="notion-text notion-block-1aaa920890b1802289cbe7b004c29873"><b>工具组合</b>：DeepSeek+ResearchRabbit+Zotero</div><ul class="notion-list notion-list-disc notion-block-1aaa920890b18039aafbf7a961ab3240"><li>文献综述革命：</li></ul><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b180cba649e7afc08beb3f" style="list-style-type:decimal"><li>输入关键词获取领域知识图谱</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b180a2a922d8436b918919" style="list-style-type:decimal"><li>自动生成文献评述框架</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180309adbd16893254849" style="list-style-type:decimal"><li>Zotero智能引用（支持跨格式导出）</li><ol class="notion-list notion-list-numbered notion-block-1aaa920890b180309adbd16893254849" style="list-style-type:lower-alpha"><div class="notion-text notion-block-1aaa920890b180dd82d3e8584a77fa43"><em>学术服务</em>：指导SCI论文写作，单篇收费5000-20000元</div></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b1803fa005cecdd9b33602" data-id="1aaa920890b1803fa005cecdd9b33602"><span><div id="1aaa920890b1803fa005cecdd9b33602" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b1803fa005cecdd9b33602" title="五、变现渠道矩阵"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">五、变现渠道矩阵</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b18054933dd9473763c78f" style="list-style-type:decimal"><li>知识付费：Notion模板商店出售工作流</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b18031b40ee53cfc455713" style="list-style-type:decimal"><li>众包平台：承接Fiverr复杂订单</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180a1988ed0d286e8771b" style="list-style-type:decimal"><li>企业服务：通过Pipedrive管理定制化需求</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1aaa920890b1807caf13cd67bcb71ccc" style="list-style-type:decimal"><li>自媒体运营：用AI生成的内容矩阵获客</li></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b1804a9468e94223847852" data-id="1aaa920890b1804a9468e94223847852"><span><div id="1aaa920890b1804a9468e94223847852" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b1804a9468e94223847852" title="六、风险控制指南"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">六、风险控制指南</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b1809e8160e563f55d0f6e" style="list-style-type:decimal"><li>版权声明：使用AI生成内容需添加免责条款</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b18045ae66d9c47bb8eb04" style="list-style-type:decimal"><li>质量校验：重要交付物保留人工审核环节</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180768361f263146cb073" style="list-style-type:decimal"><li>数据安全：通过ZeroTrust架构保护客户隐私</li></ol><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1aaa920890b18091b206d9c876338081" data-id="1aaa920890b18091b206d9c876338081"><span><div id="1aaa920890b18091b206d9c876338081" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1aaa920890b18091b206d9c876338081" title="七、进化路线图"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">七、进化路线图</span></span></h3><ul class="notion-list notion-list-disc notion-block-1aaa920890b180428297f72c76019bf9"><li>2024Q3：建立自动化工作流（Zapier集成）</li></ul><ul class="notion-list notion-list-disc notion-block-1aaa920890b1805cbcbbefed36cdf458"><li>2024Q4：训练垂直领域微调模型</li></ul><ul class="notion-list notion-list-disc notion-block-1aaa920890b180a0b3eaf2520bbf8ee6"><li>2025：构建AI代理协作网络</li></ul><blockquote class="notion-quote notion-block-1aaa920890b180c799abd620477987aa"><div>当前行动清单：</div></blockquote><ol start="1" class="notion-list notion-list-numbered notion-block-1aaa920890b1804ca44bdc65dabae72a" style="list-style-type:decimal"><li>选择2-3个优势领域建立最小可行性产品</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1aaa920890b180cba279d83733c4d66f" style="list-style-type:decimal"><li>在LinkedIn/电鸭平台创建专家身份</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1aaa920890b180bda0ebd2c383136db0" style="list-style-type:decimal"><li>用AI生成100个精准客户画像</li></ol></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0021 跨境支付流程]]></title>
            <link>https://gendlee.github.io/inter-payment</link>
            <guid>https://gendlee.github.io/inter-payment</guid>
            <pubDate>Thu, 31 Oct 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[跨境支付涉及跨行、汇兑等流程，本文介绍跨境支付的业务流程。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-130a920890b18069889deac1ba869f26"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b1808bb3c8cdfd85dda141" data-id="130a920890b1808bb3c8cdfd85dda141"><span><div id="130a920890b1808bb3c8cdfd85dda141" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1808bb3c8cdfd85dda141" title="情景假设"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">情景假设</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b180999618fc43ec171224" data-id="130a920890b180999618fc43ec171224"><span><div id="130a920890b180999618fc43ec171224" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b180999618fc43ec171224" title="跨境扫码支付场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>跨境扫码支付场景</b></span></span></h4><div class="notion-text notion-block-130a920890b18053b05fceb0d60ca469">1. 付款方用户支付的是<b>人民币</b>。</div><div class="notion-text notion-block-130a920890b1806d8759f58b28b5aee1">2. 付款方的借记卡是国内银行 A 发行的，简称<b>买家开户行</b>。</div><div class="notion-text notion-block-130a920890b180f4a85cc57044dba2b4">3. 第三方支付公司的备付金账户在国内银行 B，简称<b>第三方开户行</b>。</div><div class="notion-text notion-block-130a920890b180079d71d9f907b195a3">4. 收款方接受的是<b>美元</b>。</div><div class="notion-text notion-block-130a920890b1802184e6d819314491e8">5. 收款方的借记卡是国外银行 C 发行的，简称<b>卖家开户行</b>。</div><div class="notion-text notion-block-130a920890b1806f9822f66f6aaa4677">6. 第三方公司是通过银行 D 进行外币兑换业务，简称<b>汇兑提供行</b>。</div><div class="notion-blank notion-block-130a920890b18050ab86c720fbf4ca51"> </div><div class="notion-text notion-block-130a920890b18095bc3ed3eb3bac11c4">由于国内对人民币相关的外汇交易有管制，本外币交易需要满足一定要求，比如要求电商平台有对应的交易明细。为了方便你理解，我们假设已经在其他部分完成了相应的合规流程。那么接下来，我会分 4 个部分给你讲解整个支付过程：用户扫码支付、第三方公司进行本币代收、外汇交易以及外币代付。</div><div class="notion-blank notion-block-130a920890b1802fb0d9e3c88e1c555a"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b1802b87a3dda532b03b2b" data-id="130a920890b1802b87a3dda532b03b2b"><span><div id="130a920890b1802b87a3dda532b03b2b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1802b87a3dda532b03b2b" title="用户扫码"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">用户扫码</span></span></h4><div class="notion-text notion-block-130a920890b18051bbbff4adbc40c1ea">扫二维码支付显然是以用户扫码作为整个业务的起点。从终端用户的角度来看，扫码由鉴权、支付和拉取状态三个步骤组成。接下来，我们就来详细看看这几个步骤。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b18048a049ec67f4bfb589" data-id="130a920890b18048a049ec67f4bfb589"><span><div id="130a920890b18048a049ec67f4bfb589" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b18048a049ec67f4bfb589" title="鉴权"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">鉴权</span></span></h4><div class="notion-text notion-block-130a920890b180609c41dfe8a8e5ddb2">扫码支付最终会用买家的银行卡进行支付。在你开始扫码支付之前，第三方公司需要核实你是否有这张卡的使用权，俗称“绑卡”。</div><div class="notion-text notion-block-130a920890b180d9815cc5579767992f">那第三方公司是怎么验证用户的使用权呢？</div><div class="notion-text notion-block-130a920890b180f08101ee6ab37bea3f">在国内，我们一般采用下面这 4 个要素来进行验证：用户姓名用户身份证号码银行卡号码银行注册的手机号这 4 个要素都是银行记录的信息，因此虽然看起来你是在第三方支付公司的 App 上进行绑卡操作，其实是银行在背后进行相关信息的验证工作。</div><div class="notion-text notion-block-130a920890b180f8a73cd384d61d0963">由于这 4 个要素都是电子信息，可能会被人盗用，所以为了进一步增强安全性，银行在验证手机号码的时候还需要验证你是否拥有这个手机号码。具体的方式是发一条验证码给在你在银行柜台办借记卡时注册的手机号码。</div><div class="notion-blank notion-block-130a920890b18017a32bc7c7cd4f4a45"> </div><div class="notion-text notion-block-130a920890b18030bf74cec96688a7b9">结合前面的内容，我们可以把鉴权的过程分为 4 步：</div><div class="notion-text notion-block-130a920890b180d28daaeaa3f5e2d55b">第 1 步，用户填写前 3 个要素和手机号码；</div><div class="notion-text notion-block-130a920890b1808bb4b7d8a160a6979b">第 2 步，银行发短信验证码给用户手机号；</div><div class="notion-text notion-block-130a920890b180a6ae7efa65649812e1">第 3 步，用户将前 3 个要素和短信验证码发给第三方支付公司；</div><div class="notion-text notion-block-130a920890b180f489d9d3fb6eeda6bd">第 4 步，第三方支付公司再将所有信息发送给银行进行确认。</div><div class="notion-text notion-block-130a920890b1802b81e0d7f363458c96">所以鉴权的过程其实是验证了 5 个信息，其中 4 个是静态信息，1 个是动态信息。在用户绑卡通过之后，银行会返回给第三方支付公司这个用户的内部 ID 信息（也叫 Token）。之后第三方支付公司就可以拿这个 ID 进行所有合法的操作。刚才给你讲解的流程示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180589fe5ff9e7660cc0f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2Fd9cc7871-27f4-4afb-9282-e76805228227%2F59bef589edd40a17ccfb71b2334b9132.webp?table=block&amp;id=130a9208-90b1-8058-9fe5-ff9e7660cc0f&amp;t=130a9208-90b1-8058-9fe5-ff9e7660cc0f&amp;width=1112.1875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b180d79200fb2d133acba3"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b18004b29feea770959afe" data-id="130a920890b18004b29feea770959afe"><span><div id="130a920890b18004b29feea770959afe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b18004b29feea770959afe" title="支付"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">支付</span></span></h4><div class="notion-text notion-block-130a920890b180fa859fce4ecd2c1c61">鉴权完成之后，就可以扫二维码，进行支付了。二维码其实是一个图形化的字符串，背后是这笔交易对应的订单。当用户点击“确认”之后，就会开始整个支付流程。</div><div class="notion-blank notion-block-130a920890b180debe5ad7c174687880"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b1802d88c7f5e121e76ba1" data-id="130a920890b1802d88c7f5e121e76ba1"><span><div id="130a920890b1802d88c7f5e121e76ba1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1802d88c7f5e121e76ba1" title="拉取支付状态"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">拉取支付状态</span></span></h4><div class="notion-text notion-block-130a920890b18007a759ef8c66e51208">那为什么需要拉取支付状态呢？</div><div class="notion-text notion-block-130a920890b180929c8ac375b9389385">我们还是从台前转到幕后，从系统功能的角度思考。用户 App 的支付确认按钮是有局限的，它只能确认后台是否已经收到了支付请求，并不能确认支付是否已经成功。这是因为支付后台需要花一些时间和银行沟通，在这个期间后台并不知道银行的支付流程进行到了哪一步。</div><div class="notion-text notion-block-130a920890b1800799b4d241f8b92727">由于不知道支付什么时候才能完成，用户 App 需要每隔一段时间就向支付后台拉取交易情况，我们通常会把这个过程叫作<b>轮询</b>。这个过程一般在几百毫秒内就能结束，所以你一般察觉不到延时。</div><div class="notion-text notion-block-130a920890b180919551f0c27ef8d13a">那为什么会出现轮询这种系统对接方式呢？金融机构每天会面对大量的用户资金操作，这些操作的时间和频率有很大的偶然性。</div><div class="notion-blank notion-block-130a920890b18092b19ec53c2ae15350"> </div><div class="notion-text notion-block-130a920890b1803dbcbef42389eb91d1">为了应对用户操作的峰值情况，<span class="notion-orange_background">金融机构普遍通过异步消息处理的架构来对极端流量进行削峰填谷</span>。如果流量突然增大，异步消息架构会缓存所有请求，慢慢处理。这样就能避免核心金融系统超载。异步消息架构的结果就是用户不会及时得到处理结果，需要自己不断地去查询处理情况。</div><div class="notion-text notion-block-130a920890b1800c9ae2fc807da2cf13">当银行处理完支付后，银行会把支付成功的消息推送给用户和第三方支付公司。第三方支付公司也会推送给你支付成功的消息。所以你在扫码支付成功后，通常还能听到两个手机消息通知的声音。</div><div class="notion-text notion-block-130a920890b180d5ac3fed556cb98482">到这里我们看到了两种不同的获取最新状态的方式。<span class="notion-orange_background">一种是用户定期去拉取状态，另一种是服务器将状态消息实时推送给用户</span>。这种推拉结合的消息通知方式，其实是架构设计中常见的异步系统处理方式。支付状态获取的流程图如下</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180afaf31ec1bd815b944"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2F87cdd781-6cdd-458f-ba06-f9541ba9b52f%2Fcc4e483abaf4a4b12a741fec9bb30bb1.webp?table=block&amp;id=130a9208-90b1-80af-af31-ec1bd815b944&amp;t=130a9208-90b1-80af-af31-ec1bd815b944&amp;width=3200&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b1804d9762fdda80bdbf9e" data-id="130a920890b1804d9762fdda80bdbf9e"><span><div id="130a920890b1804d9762fdda80bdbf9e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1804d9762fdda80bdbf9e" title="本币代收"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">本币代收</span></span></h3><div class="notion-text notion-block-130a920890b180a6af3fce4b3ddff042">前面我们假设了这笔支付涉及到外汇交易，由于买家的和卖家使用的币种不同，就无法直接转账。这时候就需要第三方支付公司这个中间人来帮忙了。中间人角色要做 3 件事情：</div><div class="notion-text notion-block-130a920890b180f5b119cc0343b29b61">1. 本币代收</div><div class="notion-text notion-block-130a920890b180728be3d07f913bd811">2. 外汇交易</div><div class="notion-text notion-block-130a920890b180429760d74324d331fb">3. 外币代付</div><div class="notion-blank notion-block-130a920890b18099b4e4e5dfca249f41"> </div><div class="notion-text notion-block-130a920890b18072ba22e1109722a3a8">我先给你说说本币代收，也就是第三方支付公司代收用户资金。通俗一点来说，本币代收就是将你该付的钱先打到第三方支付公司账上。</div><div class="notion-text notion-block-130a920890b180488b5fd9d79bf2827a">由于第三方支付公司的账号和买家的银行卡在两家不同的银行，本币代收需要进行跨行转账。跨行转账会涉及到整个银行系统的大小额系统和超级网银等，非常复杂。所以这里我们对场景进行一些简化，但是会和现实有一些出入，主要是方便你理解。</div><div class="notion-blank notion-block-130a920890b180a8b81bc564ecabafbe"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b1809ba1fdfc02f51958b4" data-id="130a920890b1809ba1fdfc02f51958b4"><span><div id="130a920890b1809ba1fdfc02f51958b4" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1809ba1fdfc02f51958b4" title="央行和清算机构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">央行和清算机构</span></span></h4><div class="notion-text notion-block-130a920890b1802d815fe2c5804b6361">跨行转账的时候，钱是在不同的银行。因此我们想要实现跨行转账，就需要解决两个问题:</div><div class="notion-text notion-block-130a920890b180039e63fec45a569438"><b>第一个问题是怎么将钱在两家银行之间转来转去，另一个问题是转的金额是多少</b>。</div><div class="notion-text notion-block-130a920890b18000b541c5fd6c83a06a">我们先看第一个问题，那就是怎么跨行搬钱。最直接的方法是用汽车将钱从一家银行的金库搬到另一家银行。但这个方法其实不太实用，汽车能运的钱重量有限，路上也不太安全。所以钱最好不要挪动地方。这时候又需要另一个第三方机构出马了。所有银行都在这个新的第三方机构里放足够多的钱，一般叫做存款准备金。</div><div class="notion-text notion-block-130a920890b18037a54cd189f7a0faac">当两家银行之间需要转账的时候，第三方机构在内部搬运一下就好。比如美国的黄金交易所就是这种工作模式，每个客户都有自己专属的黄金仓库，很多小车在仓库之间搬运黄金。</div><div class="notion-text notion-block-130a920890b180129bdbe0a7e80512c8">如果这个第三方机构足够可信，那么连内部搬运都不需要。这个第三方机构只需要记录一下谁的钱有多少，以及从哪里搬了多少到另一个地方就行。信用级别最高的金融机构就是国家的中央银行，简称央行。所以央行解决了真实资金的转移问题。</div><div class="notion-blank notion-block-130a920890b180d98ce2cec2f2a15e12"> </div><div class="notion-text notion-block-130a920890b180dabeccc3617fd8daa7">我们再来看另一个问题，那就是怎么知道转移的金额有多少。</div><div class="notion-text notion-block-130a920890b180fb8a51d47061e3d3aa">会有这个问题的原因是每天银行之间的跨行交易非常多，不可能每一笔都通过央行转一次钱。</div><div class="notion-text notion-block-130a920890b180e5a7baf1ba9530119d">所以银行系统对跨行转账的流程进行了优化。那就是在白天只做记录，不进行任何实质性的跨行转账。等每天结束的时候计算一下两个银行之间交易金额的差额是多少，最后通过央行进行一笔跨行转账就可以了。</div><div class="notion-text notion-block-130a920890b1804c9004e8920d975ce7"><b>这种计算交易差额的方式叫做轧差</b>。这个<b>记录白天跨行转账细节和晚上进行交易轧差的第三方机构叫作清算机构</b>。你熟悉的银联及网联，以及国外的万事达，它们都是清算机构。前面我们在介绍拉取支付状态的时候，讲过金融系统采用异步消息处理架构应对支付流量。轧差是另一种金融机构应对大流量的一种处理方式。</div><div class="notion-text notion-block-130a920890b180149d22eef8237c9914"><b>轧差的本质是实时消息的批量处理，从某种程度来讲是延时更大的异步处理框架</b>。</div><div class="notion-blank notion-block-130a920890b180f6b8edf1d6309623d1"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b180e984fef3f014c20e56" data-id="130a920890b180e984fef3f014c20e56"><span><div id="130a920890b180e984fef3f014c20e56" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b180e984fef3f014c20e56" title="跨行转账"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">跨行转账</span></span></h3><div class="notion-text notion-block-130a920890b180d3bf01e3c97d5e1222">流程讲完央行和清算机构之后，我们就可以对跨行转账过程做一个详细的梳理了。整个过程分为七步：</div><div class="notion-text notion-block-130a920890b180e4a4e5e1e8b8b6f326">第一步，第三方支付公司发送指令给第三方开户行，要求将钱从用户的买家开户行转到第三方开户行。</div><div class="notion-text notion-block-130a920890b180bab678d5dfd4f9bfb0">第二步，第三方支付公司拥有用户在买家开户行的 Token，所以可以合法发起这笔转账。跨行转账流程开始。</div><div class="notion-text notion-block-130a920890b1804c8b3bc752dc3e5438">第三步，第三方开户行将所有信息交给清算机构。清算机构作为第三方负责记录这些信息，并通知买家开户行和第三方开户行记录这笔转账。</div><div class="notion-text notion-block-130a920890b1803fbdc5debb69751b3d">第四步，买家开户行记录的结果是对用户的账号进行扣款。扣款结束后用短信的方式通知用户。</div><div class="notion-text notion-block-130a920890b180c184e1c6505f6439c0">第五步，第三方开户行记录的结果是对第三方支付公司的账号进行打款。打款结束后第三方支付公司可以通过银行网页看到对公账户金额发生变化。白天的工作到此结束。此时买家开户行的账面上的资金虽然减少，但是减少的钱并没有实质性到达第三方开户行。</div><div class="notion-text notion-block-130a920890b18012aaa6cd648d9b40b1">第六步，到了晚上，清算机构对白天发生的交易进行盘存，发现有一笔从买家开户行到第三方开户行的跨行转账还没有真正完成。清算机构会将这笔未完成的跨行转账信息发送给央行。</div><div class="notion-text notion-block-130a920890b180f5a28ff7c643b2947b">最后一步，央行收到信息之后，将买家开户行在央行的存款准备金调低，并将第三方开户行在央行的存款准备金调高。这样钱就真正地从买家开户行转到了第三方开户行。这七步的示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180e88af9eb5152883215"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2Fe62c61be-2662-4d5f-9e9d-bfe24ddcc082%2Fa05832c24e6370d3096c27cb3a6f5944.webp?table=block&amp;id=130a9208-90b1-80e8-8af9-eb5152883215&amp;t=130a9208-90b1-80e8-8af9-eb5152883215&amp;width=1112.1875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b180db9026f928998c8fb8" data-id="130a920890b180db9026f928998c8fb8"><span><div id="130a920890b180db9026f928998c8fb8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b180db9026f928998c8fb8" title="外汇交易"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">外汇交易</span></span></h3><div class="notion-text notion-block-130a920890b180fcb6d5dfc3c9127295">转账交易的第二步是第三方支付公司进行外汇交易。当第三方支付公司完成了用户的本币代扣之后，第三方支付公司账上就有了对应的人民币。接下来的一步是将这些人民币变成美元，这样才能将美元转给国外的卖家。那么外汇交易的过程又是怎样的呢？按照交易量的大小，可以分为<b> C 端外汇零售业务</b>和 <b>B 端外汇批发业务</b>两个部分。</div><div class="notion-blank notion-block-130a920890b180e6b6f7db1256e719b3"> </div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-130a920890b180d2bd84e72b8026474d" data-id="130a920890b180d2bd84e72b8026474d"><span><div id="130a920890b180d2bd84e72b8026474d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b180d2bd84e72b8026474d" title="C 端外汇零售业务"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">C 端外汇零售业务</span></span></h4><div class="notion-text notion-block-130a920890b18029a613f4f70156c373">外汇交易和电商一样，也是一个买卖的过程。第三方支付公司作为中间人，需要用人民币购买美元。那美元从哪里购买呢？人民币有外汇管制，不能随意买卖，需要通过一些有特殊资质的银行才行。如果外汇不涉及到人民币，那么选择面会宽泛很多，银行、投行或者其他金融机构都可以。</div><div class="notion-text notion-block-130a920890b180309660d9655f70485e"><b>账务原理建议一个账号只处理同一个币种的交易</b>。</div><div class="notion-text notion-block-130a920890b18063a81cd012071240bb">外汇交易涉及到两个币种的货币，因此需要两个不同的账号。</div><div class="notion-text notion-block-130a920890b1801598b8c0a91a5e805e">假设了第三方支付公司是通过汇兑提供行进行外汇交易的。那么第三方公司需要在汇兑提供行里建两个账号，一个人民币账号和一个美元账号。</div><div class="notion-text notion-block-130a920890b1808fbee5d32db41f9968">同时，汇兑提供行内部也需要有对应两个币种的账号，一个对应着人民币资金池，另一个则是美元资金池。所以，一笔外币的购买涉及到 4 个账号之间的 2 笔支付订单。交易过程的示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180399a4edcc5507682d5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2F711f5307-10b0-4b75-8274-fb0501e9f668%2F3359eb5e5b0d08c3a1cc5bb27b2ec512.webp?table=block&amp;id=130a9208-90b1-8039-9a4e-dcc5507682d5&amp;t=130a9208-90b1-8039-9a4e-dcc5507682d5&amp;width=1112.175048828125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b18019afd3e3cb038b18ac"> </div><div class="notion-text notion-block-130a920890b1806ebad6c38f91ae278d">外汇交易完成之后，第三方支付公司在汇兑提供行的人民币账户金额减少，美元账户金额增加。这样第三方支付公司就有了足够的美元来支付给卖家。</div><div class="notion-text notion-block-130a920890b1806e9196f30580fba1ed">我们需要注意的是，外汇交易是有成本的。第一个成本是<b>时间成本</b>。当天购买的外汇可能隔天才到账。</div><div class="notion-text notion-block-130a920890b180619e04f76f1a4a30cd">另一个成本是<b>交易成本</b>。外汇交易一般会按照交易次数收费。</div><div class="notion-text notion-block-130a920890b1806ea69cd54df1692a64">因此为了节省成本，第三方支付公司通常会提前购买大量的外汇，用来应对日间的业务。只有当外汇储备下降到警戒线之后再做下一笔大额外汇的购买。</div><div class="notion-text notion-block-130a920890b180ca93dffd477d7fbb48">讲到这里，我们解决了第三方支付公司美元账户不足的问题，但是它用来购汇的人民币账户一直在往外出钱，总会有枯竭的一天，又该怎么办呢。</div><div class="notion-text notion-block-130a920890b1803fad73fb6d2e2232d1">所以我们还需要考虑从外部调资金进来。由于第三方支付公司的备付金账户在第三方开户行，因此需要做从第三方开户行到汇兑提供行的跨行转账，示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b18081b73de51b5d86d82b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2F29aeaed5-7451-49b5-8f03-fdc586bd36d3%2F75a91b3a675a8a1db40499cf2275fd84.webp?table=block&amp;id=130a9208-90b1-8081-b73d-e51b5d86d82b&amp;t=130a9208-90b1-8081-b73d-e51b5d86d82b&amp;width=1112.175048828125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b1808284e4f0c0d4b00155"> </div><div class="notion-text notion-block-130a920890b180d59c84cdd92968ef93">但是第三方公司在<b>第三方开户行</b>的账户也在一直出钱，我们往上推演一步，就会发现第三方开户行账户也需要有进来资金的渠道。这个是由前面我们提到的本币代收的过程实现的。我们把买家出资的流程补充完整。整个过程的示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b18049920bf4075b672be0"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2F4d2cb0d8-c6ac-4c25-9302-c80cd85756f6%2F0a01f80965bcb884cd488e1ee50712d3.webp?table=block&amp;id=130a9208-90b1-8049-920b-f4075b672be0&amp;t=130a9208-90b1-8049-920b-f4075b672be0&amp;width=1112.175048828125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b18050b445e29be2f26d4b"> </div><div class="notion-text notion-block-130a920890b180ea81a1d43d900f33b0">这样梳理下来，你是不是觉得我们已经考虑得足够全面了呢？</div><div class="notion-text notion-block-130a920890b180b8a0a8fce3853fdcc8">其实这里还有一个问题需要我们考虑：汇兑提供行帮助第三方支付公司实现了外汇购买。但是汇兑提供行的美元账户一直在出钱。那这个美元账户钱不够了怎么办？这时候汇兑提供行需要从其他银行寻求帮助。这个过程就涉及到了 B 端外汇批发交易。</div><div class="notion-blank notion-block-130a920890b180af85d3f18d4ebad848"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b1805a936adcb3016379fc" data-id="130a920890b1805a936adcb3016379fc"><span><div id="130a920890b1805a936adcb3016379fc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b1805a936adcb3016379fc" title="B 端外汇批发业务"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">B 端外汇批发业务</span></span></h3><div class="notion-text notion-block-130a920890b1808db65ed7451d17fbff">前面提到的电商相关的外汇交易属于外汇的零售业务。银行、投行和其他外汇提供商之间形成了一个有层级的跨国组织，专门从事外汇的批发业务。批发业务的业务量非常巨大，通常每天都有几万亿美元的规模。</div><div class="notion-text notion-block-130a920890b180f1821cc957272e76b2">外汇市场是按照交易量大小来划分层次的。最底层的是面对终端用户的外汇零售商。这些零售商负责给一般用户提供小额的外汇交易。这些小笔的外汇交易汇集在一起之后，就会形成一笔大的外汇订单，然后继续往上层交易。</div><div class="notion-text notion-block-130a920890b1805b8b76c8875348ba84">和底层的外汇零售商一样，上一层的机构将所有外汇交易汇集在一起之后，形成更大的外汇订单，再往更上一层交易。一直往上汇集这种事情不会永无止境地进行下去。</div><div class="notion-text notion-block-130a920890b180ec9e58cbdebad5c361">这个流程的尽头是全球最大的<b>外汇做市商</b>，一般是巨型的跨国商业银行。这些跨国商业银行面对的是全球不同国家大量的储蓄用户，所以它们手上就拥有不同币种的巨额存款。这些做市商之间通过交换不同币种的大额固定利息存折来实现外汇交易，从而决定最终汇率。示意图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b1803289b6f535abf16057"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2Fa602e8a2-c8a5-40d8-811f-b8dd04590b10%2F92c49aa31fc90f61f15a962f94ddd6fa.webp?table=block&amp;id=130a9208-90b1-8032-89b6-f535abf16057&amp;t=130a9208-90b1-8032-89b6-f535abf16057&amp;width=1112.1875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b18081b7b0de3a7b52853d"> </div><div class="notion-text notion-block-130a920890b18088abd1ee4b88b911b4">之前我给你提到过外汇交易有时间成本，当天购买的外汇需要隔天才能到账。在这一天的时间间隔之内，外汇市场可能会有巨大的波动，从而造成金融机构账面上的资金亏损。所以，参与外汇业务的金融机构都会处理外汇相关的市场风险，比如用期货、期权等衍生品来对冲风险。这些金融衍生品，我们会在后面的章节详细展开，这里你先有个印象就行。</div><div class="notion-text notion-block-130a920890b180d29857fae7e8dee84a">为了方便你理解，我们把到目前为止的流程画一个简单的示意图：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180e485cbdc05b768bf42"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2F7df6e9ad-4a40-4416-9ccd-6b04b69af90e%2F4c3dd63bf3be60824c525007bd270e12.webp?table=block&amp;id=130a9208-90b1-80e4-85cb-dc05b768bf42&amp;t=130a9208-90b1-80e4-85cb-dc05b768bf42&amp;width=1112.1875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b18058a33cdaec3f5e729f" data-id="130a920890b18058a33cdaec3f5e729f"><span><div id="130a920890b18058a33cdaec3f5e729f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b18058a33cdaec3f5e729f" title="外币代付"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">外币代付</span></span></h3><div class="notion-text notion-block-130a920890b180a8a0acf96972e9370c">外币代付流程和本币代收流程在原则上是一样的。不同点在于外币代付的金额是美元，流出账号是第三方支付公司的美元账号。由于卖家的账号在<b>卖家开户行</b>，第三方支付的美元账号在<b>汇兑提供行</b>，这时候需要走的是国际的清结算过程。流程的核心思想和之前的类似，只是具体的细节会更加复杂。下图展示了简化版的支付流程。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b1807eb26cdaf4120f5872"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2Ff6a9e13a-62c4-4cfe-b0dc-a417eee6356e%2Fb56afd2d461efef5e2757d37b6bafd21.webp?table=block&amp;id=130a9208-90b1-807e-b26c-daf4120f5872&amp;t=130a9208-90b1-807e-b26c-daf4120f5872&amp;width=1112.175048828125&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b1800f9751fafba4320c91"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-130a920890b18032b4cef2b73e4b7273" data-id="130a920890b18032b4cef2b73e4b7273"><span><div id="130a920890b18032b4cef2b73e4b7273" class="notion-header-anchor"></div><a class="notion-hash-link" href="#130a920890b18032b4cef2b73e4b7273" title="小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">小结</span></span></h3><div class="notion-text notion-block-130a920890b180b78e17e46298e27841">用户在扫码支付前需要证明自己合法拥有银行卡，需要给开卡行提供 <b>4 要素</b>：姓名、身份证、银行卡号和手机号。验证通过后便可以开始支付流程。支付完成后用户可以通过轮询的方式<b>异步获取支付状态</b>。</div><div class="notion-text notion-block-130a920890b18061b24ed29afca156c2">异步处理是金融机构应对支付流量的一种架构设计。</div><div class="notion-text notion-block-130a920890b1808fa0e6c48b503b5abc">在第三方支付公司收到支付请求后，开始进行本币代收业务。由于账号设立的关系，需要进行跨行转账。此时清算中心和央行一起提供了跨行转账功能。</div><div class="notion-text notion-block-130a920890b180d9bb69d69b50a50a0a"><b>跨行转账一般采用了日间交易、日终轧差结算的方式进行</b>。轧差处理是金融机构应对支付流量的另一种架构设计。</div><div class="notion-text notion-block-130a920890b180c888a6f3cadad23e89">第三方支付公司在完成本币代收业务之后，还要进行汇兑业务，具体分为外汇零售业务和批发业务。如果涉及外币代付业务，第三方支付公司还需要借助国际清结算组织的相关功能。</div><div class="notion-text notion-block-130a920890b180c0a53cd604c756cd8e">你需要注意的是，二维码支付涉及的大多数环节都是异步系统，比如用户 App 的异步支付状态查询，以及清算中心和央行及银行之间的跨行转账清结算过程。异步系统不会将结果同步返回给调用方。因此，我们在设计系统的时候，就需要支持状态的查询以及状态消息的推送功能。</div><div class="notion-text notion-block-130a920890b180efa6b2ca5fb47cec6f"><span class="notion-red_background">总结脑图</span></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-130a920890b180b3acacdf777a6011f8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F333b4f28-5127-4daf-8c39-ec7700f99e1b%2Fb45f89fe-9540-4733-9566-06d394d30bd2%2F20321d2ec6c580db82f3f6yycc756ea9.jpg?table=block&amp;id=130a9208-90b1-80b3-acac-df777a6011f8&amp;t=130a9208-90b1-80b3-acac-df777a6011f8&amp;width=1112.1875&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-130a920890b180299c41f797c65b70bc"> </div><div class="notion-text notion-block-130a920890b180a09638ce1111f90404">（原文：<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://time.geekbang.org/column/article/323701">https://time.geekbang.org/column/article/323701</a>）</div><div class="notion-blank notion-block-130a920890b180549d94e5c60892455c"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0002 LRU算法浅析]]></title>
            <link>https://gendlee.github.io/lru</link>
            <guid>https://gendlee.github.io/lru</guid>
            <pubDate>Thu, 14 Oct 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[LRU（Least Recently Used)，最近最少使用原则算法浅析。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-6fd483888d694184a4ed7699568a65b5"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-orange notion-block-5897dd9b8ab24f66a698b2833d2aa058">✏️原理概述：LRU（Least Recently Used)，最近最少使用原则实现的缓存淘汰算法。</div><div class="notion-blank notion-block-6bbc1062a5fe44b19eff15509d20af3f"> </div><div class="notion-text notion-block-9561b6080afe409982de38b1265e7c90">❌<b>“最近最少”的误解</b>：很多人看字面意思很可能理解为“最近使用和最少使用的被淘汰”，理解几乎完全相反了。</div><div class="notion-blank notion-block-3a226f8bff94430baaa98c7f9ed0f16f"> </div><div class="notion-text notion-block-c06b71337e644052a5c20c7eec371641"><span class="notion-orange">✔️</span><b>“最近最少”的正确理解</b>：基于这一种准则：<b>刚使用过的、最新添加的元素，被（再次）使用到的概率更大，因此要放到队列读取的最前端，最先淘汰队列尾端的元素（说明它被添加的时间很长了而且很少被访问到过，若是新添加的、经常被访问过的应该在靠近读取端头部）</b>。</div><div class="notion-blank notion-block-54c3ea94ca264c59850b8c12da6c0afc"> </div><div class="notion-text notion-block-f52de4a60a3a4026a347a5c11381ab82">看这样一个例子：<span class="notion-teal"><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://leetcode-cn.com/problems/lru-cache-lcci/">面试题 16.25. LRU 缓存</a></span></div><h4 class="notion-h notion-h3 notion-h-indent-0 notion-block-f9857400883c4b29aecf6d066dc3fa61" data-id="f9857400883c4b29aecf6d066dc3fa61"><span><div id="f9857400883c4b29aecf6d066dc3fa61" class="notion-header-anchor"></div><a class="notion-hash-link" href="#f9857400883c4b29aecf6d066dc3fa61" title="✏️下面是图解:"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">✏️下面是图解:</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b171928d497d4d71b912299331ef761a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F5d10821b-753a-4174-b7fe-c22f83a8e338%2Fpic.jpg?table=block&amp;id=b171928d-497d-4d71-b912-299331ef761a&amp;t=b171928d-497d-4d71-b912-299331ef761a&amp;width=2736&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><hr class="notion-hr notion-block-98b2bedd09684920bc4e15beca5a7e4f"/><div class="notion-blank notion-block-cceed4c3ce144d9db36a683c0af40452"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-584690fc25194b6aa539ee5b26d97ac3" data-id="584690fc25194b6aa539ee5b26d97ac3"><span><div id="584690fc25194b6aa539ee5b26d97ac3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#584690fc25194b6aa539ee5b26d97ac3" title="💠实现方式① ：利用LinkedHashMap的accessOrder"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💠实现方式① ：利用LinkedHashMap的accessOrder</span></span></h3><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-fbe8693d17b0476ab234b7e39bec6f12" data-id="fbe8693d17b0476ab234b7e39bec6f12"><span><div id="fbe8693d17b0476ab234b7e39bec6f12" class="notion-header-anchor"></div><a class="notion-hash-link" href="#fbe8693d17b0476ab234b7e39bec6f12" title="💠实现方式②：继承LinkedHashMap重写"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💠实现方式②：继承LinkedHashMap重写</span></span></h3><div class="notion-text notion-block-a9172dab8ec0410eac853e20ebfdf0b3">LinkedHashMap的最大价值就是缓存淘汰实现，其<b>内部已经被实现了LRU基础功能</b>，需要修改的是removeEldestEntry方法，<b>即在什么情况下才会触发删除策略，我们这里是当容器满了的时候，触发删除策略</b>。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-0d5cfa93bc9e4110a8a6ccab399d3785" data-id="0d5cfa93bc9e4110a8a6ccab399d3785"><span><div id="0d5cfa93bc9e4110a8a6ccab399d3785" class="notion-header-anchor"></div><a class="notion-hash-link" href="#0d5cfa93bc9e4110a8a6ccab399d3785" title="💠实现方式③：HashMap + 双向链表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💠实现方式③：HashMap + 双向链表</span></span></h3><div class="notion-text notion-block-452b89e169544150badf6a9734174f99">操作方式：读取在链表尾，删除在链表头，所以要增加移动到链表尾的操作。</div><div class="notion-text notion-block-6c1f5dace7a74a8db2550ffd7e94ceb7">注意，双向链表中，<b>head和tail是哨兵节点</b>，不存储实际值，实际链表的值在两者之间。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-62a71c29e5234c64b02db34806a69fc0" data-id="62a71c29e5234c64b02db34806a69fc0"><span><div id="62a71c29e5234c64b02db34806a69fc0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#62a71c29e5234c64b02db34806a69fc0" title="💠实现方式④：HashMap + 单向链表"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">💠实现方式④：HashMap + 单向链表</span></span></h3></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[0003 Redis数据结构及应用]]></title>
            <link>https://gendlee.github.io/redis-structure</link>
            <guid>https://gendlee.github.io/redis-structure</guid>
            <pubDate>Sat, 20 Nov 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[redis的一些学习分享]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-d992f3f69c664567b2dd9b6b32f5cb3b"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-6528dc8f540845b38a10688411a49336">以下是个人学习总结的redis知识内容，供学习参考。</div><hr class="notion-hr notion-block-656419bdd67f44e7897c72d39ccbe660"/><div class="notion-blank notion-block-15c59bc3fd9d42218149bf3627bc4dbd"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5b804ce64417439c9026bf0cb831a8a2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F82eab49c-5249-4ed1-8b9b-64f6bdc7315a%2F%E5%B9%BB%E7%81%AF%E7%89%871.png?table=block&amp;id=5b804ce6-4417-439c-9026-bf0cb831a8a2&amp;t=5b804ce6-4417-439c-9026-bf0cb831a8a2&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1bb9b0a0534f4b0dbd87561b2b8bd6a1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fee6a7bbd-05db-4911-9abc-043c6b1286a6%2F%E5%B9%BB%E7%81%AF%E7%89%872.png?table=block&amp;id=1bb9b0a0-534f-4b0d-bd87-561b2b8bd6a1&amp;t=1bb9b0a0-534f-4b0d-bd87-561b2b8bd6a1&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5a63f3091aa84e7f940a3ccaa0607f17"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F0a03556a-aba1-40a5-8f8b-e76ae9b6bf8d%2F%E5%B9%BB%E7%81%AF%E7%89%873.png?table=block&amp;id=5a63f309-1aa8-4e7f-940a-3ccaa0607f17&amp;t=5a63f309-1aa8-4e7f-940a-3ccaa0607f17&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-cf8f4de770ad46fc87b02473a0efc5ba"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fce5f68f9-45a3-4393-9f6a-7c860574ba53%2F%E5%B9%BB%E7%81%AF%E7%89%874.png?table=block&amp;id=cf8f4de7-70ad-46fc-87b0-2473a0efc5ba&amp;t=cf8f4de7-70ad-46fc-87b0-2473a0efc5ba&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d325bd48cb83416fa61e186be2c8d324"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fc6dd6a86-2f44-4c8f-9d04-4420be50b5ee%2F%E5%B9%BB%E7%81%AF%E7%89%875.png?table=block&amp;id=d325bd48-cb83-416f-a61e-186be2c8d324&amp;t=d325bd48-cb83-416f-a61e-186be2c8d324&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-76356d0379324e10bd95402cf3021d18"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F861ebf71-9d73-4fc9-bc5f-e8ca92df1a0a%2F%E5%B9%BB%E7%81%AF%E7%89%876.png?table=block&amp;id=76356d03-7932-4e10-bd95-402cf3021d18&amp;t=76356d03-7932-4e10-bd95-402cf3021d18&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e9d90c2404ee42b5b7d8182c57d1c3e8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F4116bdc3-3782-407c-8ea7-9411658cdf44%2F%E5%B9%BB%E7%81%AF%E7%89%877.png?table=block&amp;id=e9d90c24-04ee-42b5-b7d8-182c57d1c3e8&amp;t=e9d90c24-04ee-42b5-b7d8-182c57d1c3e8&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5a3c2697df1646548bb8cc5420d0e178"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fe3b7864d-b0aa-4c6d-93ba-b8735ebf1e24%2F%E5%B9%BB%E7%81%AF%E7%89%878.png?table=block&amp;id=5a3c2697-df16-4654-8bb8-cc5420d0e178&amp;t=5a3c2697-df16-4654-8bb8-cc5420d0e178&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-8c137b377e6a4142ab7136382893693f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa581dafd-b4b2-4aad-92cf-c53f087a7942%2F%E5%B9%BB%E7%81%AF%E7%89%879.png?table=block&amp;id=8c137b37-7e6a-4142-ab71-36382893693f&amp;t=8c137b37-7e6a-4142-ab71-36382893693f&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-8f97fec504084a6bb1f48523a4ad289d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F8de8ae6a-7ce6-4bbd-be76-baca08424d06%2F%E5%B9%BB%E7%81%AF%E7%89%8710.png?table=block&amp;id=8f97fec5-0408-4a6b-b1f4-8523a4ad289d&amp;t=8f97fec5-0408-4a6b-b1f4-8523a4ad289d&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-9ca292e88be0405a99932731d7a7c0c5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F65bb0a95-be46-4c37-8e37-8052fcb933b1%2F%E5%B9%BB%E7%81%AF%E7%89%8711.png?table=block&amp;id=9ca292e8-8be0-405a-9993-2731d7a7c0c5&amp;t=9ca292e8-8be0-405a-9993-2731d7a7c0c5&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a469818297a644d1b6171a0c26161dd5"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fd267bc8f-6921-44e8-97ce-ee9c12a1c925%2F%E5%B9%BB%E7%81%AF%E7%89%8712.png?table=block&amp;id=a4698182-97a6-44d1-b617-1a0c26161dd5&amp;t=a4698182-97a6-44d1-b617-1a0c26161dd5&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-16a4961baf194b98b2a2ccc90fe4910f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Ff6da3f66-bb6f-4951-a0de-5c718a28a5f3%2F%E5%B9%BB%E7%81%AF%E7%89%8713.png?table=block&amp;id=16a4961b-af19-4b98-b2a2-ccc90fe4910f&amp;t=16a4961b-af19-4b98-b2a2-ccc90fe4910f&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f691d691fe174f728dceee0b5e5221f4"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fd182776f-07a8-46a5-8f23-9fc512bb2d89%2F%E5%B9%BB%E7%81%AF%E7%89%8714.png?table=block&amp;id=f691d691-fe17-4f72-8dce-ee0b5e5221f4&amp;t=f691d691-fe17-4f72-8dce-ee0b5e5221f4&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-d4a7795affd4429fa21a9d6e43f09caf"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb5e0b244-428a-4a55-af2e-c1a0f1c447c3%2F%E5%B9%BB%E7%81%AF%E7%89%8715.png?table=block&amp;id=d4a7795a-ffd4-429f-a21a-9d6e43f09caf&amp;t=d4a7795a-ffd4-429f-a21a-9d6e43f09caf&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-13728992f45d4326981246d274b4b999"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Ffda7a693-221e-4fae-a6aa-d7140480b70b%2F%E5%B9%BB%E7%81%AF%E7%89%8716.png?table=block&amp;id=13728992-f45d-4326-9812-46d274b4b999&amp;t=13728992-f45d-4326-9812-46d274b4b999&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b1a7f0dd743f4b2fa1fc87d372c458b1"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F03ecb35e-59f8-49c4-9296-f852f0a5dc55%2F%E5%B9%BB%E7%81%AF%E7%89%8717.png?table=block&amp;id=b1a7f0dd-743f-4b2f-a1fc-87d372c458b1&amp;t=b1a7f0dd-743f-4b2f-a1fc-87d372c458b1&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-5a2fdf3febff4888bcaa9a291aacefcc"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F18709c60-03c8-4efd-836a-72bb270c439a%2F%E5%B9%BB%E7%81%AF%E7%89%8718.png?table=block&amp;id=5a2fdf3f-ebff-4888-bcaa-9a291aacefcc&amp;t=5a2fdf3f-ebff-4888-bcaa-9a291aacefcc&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-4b798f17309f46378c6057176b6d900c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fd8e3d851-abba-4b5a-bc77-5508f2acca12%2F%E5%B9%BB%E7%81%AF%E7%89%8719.png?table=block&amp;id=4b798f17-309f-4637-8c60-57176b6d900c&amp;t=4b798f17-309f-4637-8c60-57176b6d900c&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-100dc5981500479fb54f097ced53ecc6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F8c027211-ebe2-4592-b026-8cdca6886ed3%2F%E5%B9%BB%E7%81%AF%E7%89%8720.png?table=block&amp;id=100dc598-1500-479f-b54f-097ced53ecc6&amp;t=100dc598-1500-479f-b54f-097ced53ecc6&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a70a914f0bc046979b5e047932905b42"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F21ec7f53-0b7b-4561-9485-81690a91ee86%2F%E5%B9%BB%E7%81%AF%E7%89%8721.png?table=block&amp;id=a70a914f-0bc0-4697-9b5e-047932905b42&amp;t=a70a914f-0bc0-4697-9b5e-047932905b42&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-3106412051084719972bf7d25acebf91"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F82073895-4089-40da-91e7-01005e97b114%2F%E5%B9%BB%E7%81%AF%E7%89%8722.png?table=block&amp;id=31064120-5108-4719-972b-f7d25acebf91&amp;t=31064120-5108-4719-972b-f7d25acebf91&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-a8c6ae0e379f4a92b930b1976081398f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb7495bc8-0843-44f4-84f0-98831dfab827%2F%E5%B9%BB%E7%81%AF%E7%89%8723.png?table=block&amp;id=a8c6ae0e-379f-4a92-b930-b1976081398f&amp;t=a8c6ae0e-379f-4a92-b930-b1976081398f&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-53bae21991b146e4a60b293e203ca463"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa4eed530-4053-415e-80dd-7801e3280890%2F%E5%B9%BB%E7%81%AF%E7%89%8724.png?table=block&amp;id=53bae219-91b1-46e4-a60b-293e203ca463&amp;t=53bae219-91b1-46e4-a60b-293e203ca463&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-381e0367f4f44b4d94401d9a36b9b0d3"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fcea54844-13ba-4876-a89b-8a953c1fbba3%2F%E5%B9%BB%E7%81%AF%E7%89%8725.png?table=block&amp;id=381e0367-f4f4-4b4d-9440-1d9a36b9b0d3&amp;t=381e0367-f4f4-4b4d-9440-1d9a36b9b0d3&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1d807c1e80aa47e097d10b31d043bdcd"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F2361e9d4-66a5-4cbe-8d66-16eaa842780d%2F%E5%B9%BB%E7%81%AF%E7%89%8726.png?table=block&amp;id=1d807c1e-80aa-47e0-97d1-0b31d043bdcd&amp;t=1d807c1e-80aa-47e0-97d1-0b31d043bdcd&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-390703bf299f4f759f18220a53e77f51"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa30b1793-8d5c-4159-ba70-477ecb4ab5d8%2F%E5%B9%BB%E7%81%AF%E7%89%8727.png?table=block&amp;id=390703bf-299f-4f75-9f18-220a53e77f51&amp;t=390703bf-299f-4f75-9f18-220a53e77f51&amp;width=1280&amp;cache=v2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-a5ff322660404c04ba3e672c64de127e">参考资料：</div><div class="notion-text notion-block-3713d30b464042dba359c48bfeaed276">[1] 黄健宏 《redis设计与实现》
[2] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://www.redis.cn/articles.html">http://www.redis.cn/articles.html</a>
[3] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.bilibili.com/video/BV1xv41137Yj?from=search&amp;seid=440206642219339402&amp;spm_id_from=333.337.0.0">https://www.bilibili.com/video/BV1xv41137Yj?from=search&amp;seid=440206642219339402&amp;spm_id_from=333.337.0.0</a>
[4] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://try.redis.io/">https://try.redis.io/</a> (可在线玩耍)
[5] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.lammertbies.nl/comm/info/crc-calculation">https://www.lammertbies.nl/comm/info/crc-calculation</a> (crc算法)
[6] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.cnblogs.com/itplay/p/10030292.html">https://www.cnblogs.com/itplay/p/10030292.html</a> (取余等价于与运算)
[7] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://edgar615.github.io/raft.html">https://edgar615.github.io/raft.html</a> (raft算法详解)
[8] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://thesecretlivesofdata.com/raft/">http://thesecretlivesofdata.com/raft/</a> (raft算法理解动画)
[9] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://www.bilibili.com/s/video/BV1Fi4y147ad">https://www.bilibili.com/s/video/BV1Fi4y147ad</a> (raft算法动画视频)
[10] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/alibaba/canal#readme">https://github.com/alibaba/canal#readme</a> (canal组件)
[11] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://llimllib.github.io/bloomfilter-tutorial/zh_CN/">https://llimllib.github.io/bloomfilter-tutorial/zh_CN/</a> (布隆过滤器）
[12] 吴军 《数学之美》——布隆过滤器在谷歌搜索中的应用
[13] <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://github.com/gendlee/user_register_center/">https://github.com/gendlee/user_register_center/</a> （demo地址）</div><div class="notion-blank notion-block-9b7d20f8a3a143e28522a0dc278a6848"> </div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>