Nº11 · Independent rebuild · private repo独立重建 · 私有仓库Privacy & policy platform · Sep 2026隐私与策略平台 · 2026 年 9 月

AI Governance Platform

Detect personal data in what employees send to AI tools, decide allow / mask / watch / block, and keep an audit trail no one can quietly edit.检测员工发往 AI 工具内容中的个人数据,决定放行 / 脱敏 / 观察 / 拦截,并保留无法被悄悄修改的审计记录。

  1. AI-tool eventAI 工具事件
  2. OutboxOutbox
  3. Worker · row lockWorker · 行锁
  4. Policy decides策略判定
  5. Incident + audit chain事件 + 审计链
SECTION · AI GOVERNANCE PLATFORMDesign view · code private设计视图 · 代码私有

01Problem问题

AI-usage governance needs three things to hold at once: detection that works in English and Chinese, policy decisions that are deterministic, and an audit history that survives worker crashes and retries.AI 使用治理需要同时成立三件事:中英文都可用的检测、确定性的策略判定、以及在 worker 崩溃和重试后依然正确的审计历史。

02What I built我做了什么

  • Policy engine as one pure function over the event and policy set, so every decision is reproducible.策略引擎是对事件与策略集的一个纯函数,每次判定都可复现。
  • Separate governance and PII-detection APIs with role-based access; audit records keep categories, hashes and offsets, never the raw input text.治理 API 与 PII 检测 API 分开部署,按角色控制访问;审计记录只保留类别、哈希和位置,从不保存原始输入文本。
  • Ingestion through a Postgres transactional outbox; workers claim events with SKIP LOCKED and record findings and incidents in a hash-chained history.通过 Postgres 事务性 outbox 接入;worker 用 SKIP LOCKED 领取事件,把发现与事件写入哈希链历史。
  • Found and fixed a lease-expiry race: a stalled worker could finish an event another worker had already processed. It now locks the row and proceeds only while the status is still processing.发现并修复租约过期竞态:卡住的 worker 可能重复处理别人已完成的事件。现在会锁行,且仅在状态仍为 processing 时继续。
  • Credentials use envelope encryption; 17 architecture decision records document each choice.凭据使用信封加密;17 份架构决策记录说明每个选择。

03Architecture架构

Admin UI · React管理端 · ReactMachine client · API key机器客户端 · API keyAPI · routes, JWT + RBACAPI · 路由、JWT + RBACDomain services · users,policies, vault, files业务服务 · 用户、策略、凭据、文件Policy evaluator · purefunction策略评估 · 纯函数Chat + retrieval · off bydefault对话 + 检索 · 默认关闭PostgreSQL 16 + pgvectorPostgreSQL 16 +pgvectorIngest worker · SKIPLOCKED + lease接收 worker · SKIPLOCKED + 租约Detector service · offsetsonly检测服务 · 只返回位置LLM provider · maskedprompt onlyLLM 服务 · 只收到脱敏后的提示REST + JWTREST + JWT/ingest/ingestdecides判定preview + recheck预览 + 复查masked脱敏后findings + audit发现 + 审计
System overview系统结构Drawn from the source architecture board依据源码架构看板绘制
Client reports a finding客户端上报发现POST /ingest/eventsPOST /ingest/events202 Accepted · receipt202 已接收 · 回执Queue · unique clientevent id队列 · 客户端事件 ID唯一Worker claims a batch ·leaseworker 领取一批 · 租约Evaluate current rules按当前规则评估Attempts left?还有重试次数?One transaction: findings,incident, hash chain单一事务:发现、事件、哈希链Done · visible in theconsole完成 · 控制台可见Failed · attemptsexhausted失败 · 次数用尽hashes + offsets哈希 + 位置after commit提交后idempotent insert幂等写入error · rollback出错 · 回滚yes · backoff是 · 退避no否
One event, start to finish一条事件的完整处理Retries never write a finding twice重试不会重复写入
Prompt用户输入Detect + policy · maskedpreview检测 + 策略 · 脱敏预览Explicit send · serverrechecks明确发送 · 服务器复查Permission + quota · keyfrom vault权限 + 额度 · 凭据库取keyModel provider模型服务Original files原始文件Trusted embedding host可信 embedding 服务pgvector · vectors +hashespgvector · 向量 + 哈希Retrieve · visibility +hash check检索 · 可见性 + 哈希校验Mask by policy按策略脱敏index索引context上下文
What may reach a model什么能到达模型Indexing and retrieval have different trust boundaries索引和检索的信任边界不同

04Measured测量结果

213
API tests (pytest, collected)API 测试(pytest 收集)
src · governance-platform/apps/api/tests (private)
30
detector tests检测器测试
src · governance-platform/apps/detector/tests (private)
17
architecture decision records架构决策记录
src · governance-platform/docs/adr (private)
5,466
synthetic bilingual records in the CI benchmarkCI 基准中的合成双语记录
src · governance-platform/evals (private)

05Limits, stated plainly局限,直说

  • AWS infrastructure is designed in OpenTofu, not deployed. Throughput has only been measured locally.AWS 基础设施以 OpenTofu 设计,未部署;吞吐量仅在本地测量。