@armoriq/policy-ir

中文文档
0.1.8发布于 2026/11/04MITTypeScriptESM + CJS近 30 天下载 4162

Armor Policy v2 intermediate representation: types, canonical serializer, policy hash, evaluator, compiler and the golden vectors every runtime must pass

原始使用文档
文档目录3 节
  1. What is here
  2. Vectors
  3. Development

@armoriq/policy-ir

The Armor Policy v2 intermediate representation, shared by every runtime that evaluates a policy: conmap, the Armor CLI daemon, the SDK pre-check and OPA.

The IR is data, never a program. One canonical serialization and one policyHash make it the hashing and signing boundary; one golden-vector suite, exported from this package, is what every evaluator must pass before release.

What is here

ExportPurpose
PolicyDocument, Statement, …the armor.policy.v2 types
canonicalJson(value)sorted keys, compact, ASCII escapes; the platform's one hashing rule
policyHash(document)sha256: over the canonical document without policyHash
schemaHash(inputSchema)sha256: over the canonicalized tool input schema, as the SDKs and the tool inventory compute it
@armoriq/policy-ir/vectorsthe fixtures: canonical forms, policy hashes, schema hashes
@armoriq/policy-ir/documentparseYaml, parseDocument, validate, serialize, the glob helpers matchGlob and isGlob, the compose types and the source grammar types, with no Node built-ins, for browsers

C0 is complete in this package; the conmap binding of the inventory port and the compile endpoint follow in conmap-auto.

Vectors

vectors/*.json are generated by npm run vectors:generate and committed. The evaluation vectors are authored expectations; generation fails if the evaluator disagrees with one, so a wrong expectation cannot be pinned by accident. CI fails if regenerating them changes anything. A consumer asserts equality against them; it never edits them.

Development

npm ci
npm run check   # lint, typecheck, test, build, smoke (ESM and CJS consumers)

Every function is held under a cyclomatic complexity of 10 by lint. Releases are tags vX.Y.Z matching package.json; the publish workflow runs the full check before npm publish.

版本与发布记录

@armoriq/policy-ir 共发布 9 个版本,首次发布于 2026/09/21;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.1.8latest2026/11/043 天前
0.1.72026/11/034 天前
0.1.62026/10/317 天前
0.1.52026/10/317 天前
0.1.42026/10/2415 天前
0.1.32026/10/1920 天前

关于 @armoriq/policy-ir 的常见问题

@armoriq/policy-ir 是什么?

Armor Policy v2 intermediate representation: types, canonical serializer, policy hash, evaluator, compiler and the golden vectors every runtime must pass

如何安装 @armoriq/policy-ir?

在项目目录运行 npm install @armoriq/policy-ir,或使用 pnpm add / yarn add / bun add。

@armoriq/policy-ir 支持 TypeScript 吗?

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

@armoriq/policy-ir 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@armoriq/policy-ir 需要什么版本的 Node.js?

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

@armoriq/policy-ir 可以商用吗?

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

@armoriq/policy-ir 的下载量有多少?

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

@armoriq/policy-ir 还在维护吗?

最新版本 0.1.8 发布于 2026/11/04(3 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/09/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。