84 lines
4.5 KiB
HTML
84 lines
4.5 KiB
HTML
<section class="module" id="module-4">
|
||||
|
|
<div class="module-inner">
|
|||
|
|
<p class="eyebrow animate-in">模块 4 · 生产认知</p>
|
|||
|
|
<h1 class="module-title animate-in">审计只 INSERT<br>Redis 6380 与 fail-open</h1>
|
|||
|
|
<p class="module-lead animate-in">
|
|||
|
|
共用底座课讲了双栈鉴权与 input_guard,这模块补<strong>生产环境行为</strong>和<strong>画像/cache 接缝</strong>——
|
|||
|
|
指挥 AI 改「吊销 fail-closed」或「审计可改」前必看。
|
|||
|
|
</p>
|
|||
|
|
|
|||
|
|
<div class="screen animate-in">
|
|||
|
|
<h2>G-02:审计表只 INSERT</h2>
|
|||
|
|
<p><code>audit_log</code> · <code>input_guard_log</code> · <code>risk_suitability_log</code> 等合规留痕表<strong>禁止 UPDATE/DELETE</strong>。任何「改历史审计」需求都应被拒绝,改为追加更正记录。</p>
|
|||
|
|
<div class="callout callout-warning">
|
|||
|
|
<strong>input_guard 命中:</strong> fail-fast,<strong>不建会话</strong>——和 LangGraph 内 fallback 不同,没有 reply 回合入库。
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="screen animate-in">
|
|||
|
|
<h2>fail-open 与 debug 双闸门</h2>
|
|||
|
|
<div class="step-cards">
|
|||
|
|
<div class="step-card">
|
|||
|
|
<span class="step-num">①</span>
|
|||
|
|
<p><strong>Redis 会话窗口 fail-open</strong> — Redis 挂了对话仍能回,只是少短期记忆(客服线同样策略)。</p>
|
|||
|
|
</div>
|
|||
|
|
<div class="step-card">
|
|||
|
|
<span class="step-num">②</span>
|
|||
|
|
<p><strong>jti 吊销 fail-open</strong> — 吊销服务异常时 token 仍可能通过;生产要监控 Redis。</p>
|
|||
|
|
</div>
|
|||
|
|
<div class="step-card">
|
|||
|
|
<span class="step-num">③</span>
|
|||
|
|
<p><strong>debug 头</strong> — 仅 <code>APP_ENV=development</code> 且<strong>无 RS256 公钥</strong>;生产有公钥时 debug 头失效。</p>
|
|||
|
|
</div>
|
|||
|
|
<div class="step-card">
|
|||
|
|
<span class="step-num">④</span>
|
|||
|
|
<p><strong>Redis 6380 + RESP2</strong> — Docker 映射 6380;Windows 本机 6379 旧 Redis 3 不兼容。</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="screen animate-in">
|
|||
|
|
<h2>L1/L2 热缓存:谁接了谁没接</h2>
|
|||
|
|
<div class="translation-block">
|
|||
|
|
<div class="translation-code">
|
|||
|
|
<span class="translation-label">接缝快照</span>
|
|||
|
|
<pre><code><span class="code-line">客服 profile_maybe_extract → L1 抽槽 ✓</span>
|
|||
|
|
<span class="code-line">ProfileHotCache → 部分读 ✓</span>
|
|||
|
|
<span class="code-line">L2 Repository / 全量 Redis L1 → 开放项</span>
|
|||
|
|
<span class="code-line">宿主 POST /api/chat 非 customer → 未全接 L1 热缓存</span></code></pre>
|
|||
|
|
</div>
|
|||
|
|
<div class="translation-english">
|
|||
|
|
<span class="translation-label">白话</span>
|
|||
|
|
<div class="translation-lines">
|
|||
|
|
<p class="tl">指挥 AI「全 Agent 统一画像 Redis」前,先对 FRAMEWORK 实现状态表。</p>
|
|||
|
|
<p class="tl">Bearer 全环境优先——pytest 仍用 dev token,但生产必须 RS256 + 禁 debug 头冒充。</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="quiz-container" id="quiz-shared-m4">
|
|||
|
|
<div class="quiz-question-block"
|
|||
|
|
data-correct="option-a"
|
|||
|
|
data-explanation-right="对。审计表只追加;更正应新 INSERT 带引用 trace,不能 UPDATE 原记录。"
|
|||
|
|
data-explanation-wrong="改 audit_log 历史行违反 G-02,合规不可接受。">
|
|||
|
|
<h3 class="quiz-question">运维说「把 audit_log 里错的那条改成正确 decision」,你怎么回?</h3>
|
|||
|
|
<div class="quiz-options">
|
|||
|
|
<button class="quiz-option" data-value="option-a" onclick="selectOption(this)">
|
|||
|
|
<div class="quiz-option-radio"></div><span>不行,追加新审计记录说明更正</span>
|
|||
|
|
</button>
|
|||
|
|
<button class="quiz-option" data-value="option-b" onclick="selectOption(this)">
|
|||
|
|
<div class="quiz-option-radio"></div><span>好,SQL UPDATE 一行</span>
|
|||
|
|
</button>
|
|||
|
|
<button class="quiz-option" data-value="option-c" onclick="selectOption(this)">
|
|||
|
|
<div class="quiz-option-radio"></div><span>好,DELETE 后重插</span>
|
|||
|
|
</button>
|
|||
|
|
</div>
|
|||
|
|
<div class="quiz-feedback"></div>
|
|||
|
|
</div>
|
|||
|
|
<button class="quiz-check-btn" onclick="checkQuiz('quiz-shared-m4')">检查答案</button>
|
|||
|
|
<button class="quiz-reset-btn" onclick="resetQuiz('quiz-shared-m4')">重做</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</section>
|