@donmai/architectural-intelligence

中文文档
0.10.0发布于 2026/10/28MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 1.9万

(原始内容存档于2017-10-21). DePRECATED——建筑智能 (TypeScript). 被土生土长的人所取代 donmai arch 执行;只为开放源码软件的连续性/下游针头保留.

此软件包已被标记为弃用

@donmai/architectural-intelligence is deprecated and will be removed in a future major. The architectural-intelligence layer is now native Go inside the donmai binary (use `donmai arch`). This package is preserved for OSS continuity / downstream pins only and receives no further feature work.

中文使用文档
文档目录9 节
  1. 它会做什么
  2. 安装
  3. 快开始
  4. 工作流程动词集成
  5. 多租户部署(Postgres + RLS)
  6. 联网交易
  7. RLS DDL 示例
  8. 状态
  9. 许可证

@domai/architectural-intelligence (英语)

失败. 此包被堕. 建筑情报 层正在原地执行 donmai 二进制,以及 此 TypeScript 软件包没有实时运行时间消费者 。 保留下来(不是 由于下游npm的消费者可能会把它钉上 今后将取消该课程. 新工作应针对当地人 donmai arch 表面.

系统层面综合图案,公约,决定,并跨代码库漂移.

部分 东迈 工具链.

它会做什么

建筑智能观察一个代码库的进化,并综合了有关它的结构化知识:

  • 模式 ——反复出现的结构形状(例如"所有路线输出a") POST 打电话的管理员 requireOrgAccess" )
  • 公约 ——所商定的规范(例如,“试验在源头旁边进行,作为 *.test.ts" )
  • 决定 ——有记录的建筑选择(例如"Auth使用WorkOS,不是Auth0")
  • 绕行 将密码库置于偏离自身模式/公约/决定的地方
  • 漂流 跨越阈值并需要干预的量化偏离压力

包裹船:

能力入境点
当地单租店SqliteArchitecturalIntelligence
多租户商店(注入Postgres手柄)PostgresArchitecturalIntelligence, (中文(简体) ), adapterFromPostgresJs
观察管道runObservationPass, (中文(简体) ), attachPipelineSubscribers, (中文(简体) ), readDiffObservations
综合提示(版本登记册)promptRegistry, (中文(简体) ), currentPrompt, (中文(简体) ), versionedPrompt
Eval / A/B 测试带evaluatePrompt, (中文(简体) ), compareABPrompts
漂流探测assessChange, (中文(简体) ), resolveDriftGatePolicy, (中文(简体) ), evaluateGate
工作流程动词登记registerArchitectureVerbs, (中文(简体) ), ASSESS_CHANGE_VERB

安装

pnpm add @donmai/architectural-intelligence

22号节点.

快开始

import {
  SqliteArchitecturalIntelligence,
  runObservationPass,
  assessChange,
} from '@donmai/architectural-intelligence'

// 1. Open or create the per-tenant store
const store = new SqliteArchitecturalIntelligence({ dbPath: '.donmai/arch.db' })

// 2. Run an observation pass over the change set
const result = await runObservationPass({
  store,
  changeRef: { sha: 'abc123', baseSha: 'main', files: [/* PrDiff entries */] },
})

// 3. Gate on drift — block the merge / open a review issue when the threshold trips
const drift = await assessChange({ store, changeRef: result.changeRef })
if (drift.driftScore > drift.policy.maxDrift) {
  // surface the deviations to the agent or human reviewer
}

工作流程动词集成

对通过工作流程引擎驱动Donmai的平台消费者,注册 assess-change 动词 :

import { registerArchitectureVerbs } from '@donmai/architectural-intelligence'

registerArchitectureVerbs(verbRegistry)

动词接受 changeRef 输入和输出 a assessment 输出(drift分数+标出偏差),下游工作流程节点可以上分.

多租户部署(Postgres + RLS)

PostgresArchitecturalIntelligence 为SaaS的部署设计,许多租户共用一个数据库。 它分两层实施租户隔离:

  1. 应用层. 每个读取包括 WHERE org_id = $orgId; 每张邮票 org_id 在排队.
  2. 数据库层 (推荐). 当消费者应用已运出的 RLS DDL 时, SDK 会在运行的交易中将每个操作附加包装 SET LOCAL rensei.current_org_id = '<orgId>' 因此,Postgres的行级安全政策 强制隔离作为防御深度.

联网交易

提供a transaction 运行在您的适配器。 参考文献 postgres -js 助手已经这样做了.. adapterFromPostgresJs(sql) 羽毛穿过 sql.begin(...) 和 JSONB 参数解框.

import postgres from 'postgres'
import { adapterFromPostgresJs, PostgresArchitecturalIntelligence } from '@donmai/architectural-intelligence'

const sql = postgres(process.env.DATABASE_URL!)
const arch = new PostgresArchitecturalIntelligence({
  db: adapterFromPostgresJs(sql),
  orgId: ctx.orgId,
  projectId: ctx.projectId,
})

当适配器不曝光时 transaction,SDK又回到了平面查询——应用程序级范围界定仍然适用,但数据库级的RLS被跳过.

RLS DDL 示例

每个数据库一次应用此 DDL( 通过您所选择的迁移工具 ) 。 SDK不运行DDL本身.

-- Multi-tenant RLS for @donmai/architectural-intelligence
ALTER TABLE observations ENABLE ROW LEVEL SECURITY;
ALTER TABLE graph_nodes  ENABLE ROW LEVEL SECURITY;

-- FORCE so the table owner is not exempt — a misconfigured connection
-- string can't accidentally bypass tenant isolation.
ALTER TABLE observations FORCE ROW LEVEL SECURITY;
ALTER TABLE graph_nodes  FORCE ROW LEVEL SECURITY;

CREATE POLICY arch_intel_observations_tenant_isolation ON observations
  USING (org_id = current_setting('rensei.current_org_id', true)::uuid)
  WITH CHECK (org_id = current_setting('rensei.current_org_id', true)::uuid);

CREATE POLICY arch_intel_graph_nodes_tenant_isolation ON graph_nodes
  USING (org_id = current_setting('rensei.current_org_id', true)::uuid)
  WITH CHECK (org_id = current_setting('rensei.current_org_id', true)::uuid);

从软件包中导出此 DDL 的正文副本为 RLS_DDL_EXAMPLE gUC 名称导出为 RLS_ORG_ID_SETTING 这样消费者就可以不用打字就可以参考两者.

所需经费:

  • 应用程序数据库的作用不得有 BYPASSRLS超级用户和 BYPASSRLS 角色忽略了政策;创造了一个最不优惠的应用角色.
  • 需要操作跨租户的行政管理/移民工具应使用一个单独的角色,配置为 BYPASSRLS 并记录在您的运行簿中.
  • SET LOCAL 被使用(不是) SET因此GUC范围在 COMMIT编号 :ROLLBACK 并且不会从池中漏出到下一个检出连接.

状态

堕地. 没有现成的消费者遗迹——建筑智能 层正在移动到本地 donmai 二进制. 这个 软件包只为开放源码软件的连续性和下游针头而保留;预计没有 其他专题工作.

许可证

麻省理工学院——见 自由主义。 。 。 .

版本与发布记录

@donmai/architectural-intelligence 共发布 18 个版本,首次发布于 2026/05/25;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.0latest2026/10/2816 天前
0.9.152026/09/122 个月前
0.9.142026/08/252 个月前
0.9.132026/08/232 个月前
0.9.122026/08/232 个月前
0.9.112026/08/142 个月前

关于 @donmai/architectural-intelligence 的常见问题

@donmai/architectural-intelligence 是什么?

(原始内容存档于2017-10-21). DePRECATED——建筑智能 (TypeScript). 被土生土长的人所取代 donmai arch 执行;只为开放源码软件的连续性/下游针头保留.注意:该包已被作者标记为弃用——@donmai/architectural-intelligence is deprecated and will be removed in a future major. The architectural-intelligence layer is now native Go inside the donmai binary (use `donmai arch`). This package is preserved for OSS continuity / downstream pins only and receives no further feature work.

如何安装 @donmai/architectural-intelligence?

在项目目录运行 npm install @donmai/architectural-intelligence,或使用 pnpm add / yarn add / bun add。

@donmai/architectural-intelligence 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@donmai/architectural-intelligence 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@donmai/architectural-intelligence 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.23.4。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@donmai/architectural-intelligence 可以商用吗?

@donmai/architectural-intelligence 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@donmai/architectural-intelligence 的下载量有多少?

根据 npm 官方下载统计,@donmai/architectural-intelligence 在 2026/10/13 – 2026/11/11 这 30 天内被下载 19,324 次,日均约 644 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@donmai/architectural-intelligence 还在维护吗?

最新版本 0.10.0 发布于 2026/10/28(16 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/05/25。作者已将其标记为弃用,新项目建议寻找替代方案。