attention-manifest-protocol 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +16 -2
  2. package/CHANGELOG.zh-CN.md +16 -2
  3. package/README.md +15 -15
  4. package/README.zh-CN.md +15 -15
  5. package/docs/schemas/collaboration.schema.json +73 -0
  6. package/docs/schemas/common.schema.json +125 -0
  7. package/docs/schemas/compaction.schema.json +121 -0
  8. package/docs/schemas/concept-compaction.schema.json +73 -0
  9. package/docs/schemas/concept.schema.json +97 -0
  10. package/docs/schemas/epistemic.schema.json +178 -0
  11. package/docs/schemas/federation.schema.json +66 -0
  12. package/docs/schemas/frame.schema.json +86 -0
  13. package/docs/schemas/ledger-snapshot.schema.json +30 -0
  14. package/docs/schemas/manifest.schema.json +169 -0
  15. package/docs/schemas/message.schema.json +41 -0
  16. package/docs/schemas/plan.schema.json +189 -0
  17. package/docs/schemas/receipt.schema.json +45 -0
  18. package/docs/schemas/social.schema.json +153 -0
  19. package/docs/schemas/team.schema.json +56 -0
  20. package/docs/schemas/verb.schema.json +120 -0
  21. package/lib/context/workspaceProtocol.d.ts +30 -0
  22. package/lib/context/workspaceProtocol.js +49 -0
  23. package/lib/discover/tree.js +77 -25
  24. package/lib/file/path.js +45 -15
  25. package/lib/file/service.d.ts +8 -1
  26. package/lib/file/service.js +122 -23
  27. package/lib/module/mcp/filesystemServer.d.ts +1 -0
  28. package/lib/module/mcp/filesystemServer.js +14 -1
  29. package/lib/module/tool/filesystemExecutor.d.ts +1 -1
  30. package/lib/module/tool/filesystemExecutor.js +1 -1
  31. package/lib/naming/aliases.js +10 -0
  32. package/lib/naming/ids.d.ts +10 -10
  33. package/lib/naming/ids.js +10 -10
  34. package/lib/protocol/filesystem.js +12 -12
  35. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.5] - 2026-10-31
11
+
12
+ ### Fixed
13
+
14
+ - Bound discovery tree construction and subtree lookahead under small output limits, deep or cyclic input, and exhausted traversal budgets; extensionless file filters now work consistently.
15
+ - Enforced filesystem session read/write/create permissions across MCP tools, sanitized classified failures, and kept stdio sessions alive after malformed or escaping requests.
16
+ - Checked excluded paths against case-folded Windows paths and resolved symlink targets; preserved selected-root routing for multi-root outlines and dependency graphs.
17
+ - Applied session and service read/tree/graph budgets consistently and report truncation instead of returning incomplete results as complete.
18
+
19
+ ### Changed
20
+
21
+ - Standardized TypeScript tool filenames on lowerCamelCase and updated repository documentation and references.
22
+ - Advanced the npm package version to 0.4.5.
23
+
10
24
  ### Added
11
25
 
12
26
  - `amp_tool_workspace_project`: offline brand detection from manifest/lockfile evidence (npm/pnpm/yarn/bun, Maven, Gradle, CMake, Cargo, Go, Python, Make, Composer, .NET, Bundler, Swift, sbt) plus host-delegated `build`/`compile`/`run`/`test`. The agent never supplies a command string; the brand table produces one and `WorkspaceServiceOptions.runner` decides whether to run it (`run_unavailable`, `unsupported_action`, bounded tail of stdout/stderr).
@@ -19,8 +33,8 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
19
33
  - Agent workspace: a `File`/`Directory` tree, paged reads, CAS atomic writes, strategy-based outlines, import/export/dependency graphs and Office parsing (DOCX/XLSX/PPTX, with best-effort DOC/XLS/PPT/PUB/ACCDB).
20
34
  - Session module: `ses_` identity, one-time bearer token, TTL, suspend/revoke/rotate, fork, per-session context isolation and quotas; SQLite adapters `SqliteWorkspaceSessionStore` / `SqliteWorkspaceSessionContextStore`.
21
35
  - `src/hook`: `useRead`, `useWrite`, `useDiff`, `useParse`, `useDependency`, `useExportation`, `useImportation`, `useOutline`, `useCode`, `useProject`. Every hook is read-only except `useWrite`, and runs are recorded in `hook_runs`.
22
- - `amp_tool_filesystem_*` (ten tools), the `amp_tool_globalfs_*` global naming adapter, and `amp_service_filesystem` / `amp_protocol_filesystem`.
23
- - Lossless read-only syntax trees: `amp_tool_filesystem_ast`, `useAst`, `src/syntax/syntaxTree.ts` and `src/syntax/syntaxRegistry.ts`; languages, token kinds and node kinds are registry data, every token keeps UTF-8 byte and line ranges, and the target file is never executed.
36
+ - `amp_tool_file_*` (ten tools), the `amp_tool_globalfs_*` global naming adapter, and `amp_service_filesystem` / `amp_protocol_filesystem`.
37
+ - Lossless read-only syntax trees: `amp_tool_file_ast`, `useAst`, `src/syntax/syntaxTree.ts` and `src/syntax/syntaxRegistry.ts`; languages, token kinds and node kinds are registry data, every token keeps UTF-8 byte and line ranges, and the target file is never executed.
24
38
  - SQLite tables: `workspace_sessions`, `session_roots`, `session_context`, `file_nodes`, `file_annotations`, `file_writes`, `file_outlines`, `file_imports`, `file_exports`, `file_dependencies`, `hook_runs`.
25
39
  - Data structures: `Trie`, `ByteLineIndex` (segment-tree prefix sums) and `OutlineIndex` (AST + Trie + SegmentTree).
26
40
  - Outline strategies cover code (TS/JS/Python/Java/C/C++/C#/Go/Rust), Vue, project manifests (npm/Maven/Gradle/CMake/Cargo/Go/pyproject/Make), prose (Markdown/TeX/plain text), HTML/CSS/SCSS/Sass/XML/OPML and Office; `outlineCoverageCheck` verifies 74 cases.
@@ -7,13 +7,27 @@
7
7
 
8
8
  ## [未发布]
9
9
 
10
+ ## [0.4.5] - 2026-10-31
11
+
12
+ ### 修复
13
+
14
+ - 对小输出限额、深层或循环输入以及遍历预算耗尽场景限制 discovery 树构建和子树探测;无扩展名文件过滤现在保持一致。
15
+ - 在 MCP 工具中落实 filesystem session 的读取、写入和创建权限,统一错误分类并隐藏主机路径;畸形或越界请求后 stdio 会话仍可继续处理。
16
+ - 路径排除检查覆盖 Windows 大小写折叠及符号链接真实目标;多根 workspace 的大纲和依赖查询保持所选根目录。
17
+ - 一致执行 session 与 service 的读取、目录树和依赖图预算;结果截断时明确标记,不再伪报完整。
18
+
19
+ ### 变更
20
+
21
+ - TypeScript 工具文件名统一为小写开头的 camelCase,并更新仓库内路径引用和文档。
22
+ - npm 包版本升至 0.4.5。
23
+
10
24
  ### 新增
11
25
 
12
26
  - Agent 工作区:`File`/`Directory` 树、分页读、CAS 原子写、策略化大纲、import/export/dependency 图与 Office(DOCX/XLSX/PPTX,DOC/XLS/PPT/PUB/ACCDB best-effort)解析。
13
27
  - Session 模块:`ses_` 身份、一次性 bearer 令牌、TTL、暂停/撤销/rotate、fork、每会话上下文隔离与配额;SQLite 适配器 `SqliteWorkspaceSessionStore` / `SqliteWorkspaceSessionContextStore`。
14
28
  - `src/hook` 组合层:`useRead`、`useWrite`、`useDiff`、`useParse`、`useDependency`、`useExportation`、`useImportation`、`useOutline`、`useCode`、`useProject`;除 `useWrite` 外只读,并记录 `hook_runs`。
15
- - `amp_tool_filesystem_*` 十个工具与 `amp_tool_globalfs_*` 全局命名适配器;`amp_service_filesystem` / `amp_protocol_filesystem`。
16
- - 无损只读语法树:`amp_tool_filesystem_ast`、`useAst`、`src/syntax/syntaxTree.ts` 与 `src/syntax/syntaxRegistry.ts`;语言/Token/节点类别由注册中心管理,全部 token 保留 UTF-8 字节与行范围,不执行目标文件。`syntaxTreeCheck` 8 例,完整 verify 135/135。
29
+ - `amp_tool_file_*` 十个工具与 `amp_tool_globalfs_*` 全局命名适配器;`amp_service_filesystem` / `amp_protocol_filesystem`。
30
+ - 无损只读语法树:`amp_tool_file_ast`、`useAst`、`src/syntax/syntaxTree.ts` 与 `src/syntax/syntaxRegistry.ts`;语言/Token/节点类别由注册中心管理,全部 token 保留 UTF-8 字节与行范围,不执行目标文件。`syntaxTreeCheck` 8 例,完整 verify 135/135。
17
31
  - SQLite 表:`workspace_sessions`、`session_roots`、`session_context`、`file_nodes`、`file_annotations`、`file_writes`、`file_outlines`、`file_imports`、`file_exports`、`file_dependencies`、`hook_runs`。
18
32
  - 数据结构:`Trie`、`ByteLineIndex`(SegmentTree 前缀和)、`OutlineIndex`(AST + Trie + SegmentTree)。
19
33
  - 大纲策略覆盖代码(TS/JS/Python/Java/C/C++/C#/Go/Rust)、Vue、项目清单(npm/Maven/Gradle/CMake/Cargo/Go/pyproject/Make)、文章(Markdown/TeX/plain text)、HTML/CSS/SCSS/Sass/XML/OPML 与 Office;`outlineCoverageCheck` 74 例逐项验证。
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **English** · [简体中文](README.zh-CN.md) · [Changelog](CHANGELOG.md)
4
4
 
5
- AMP is a metacognitive protocol for agents: declare knowledge and obligations, allocate finite attention, obtain evidence, and record costs and outcomes. The reference implementation is version `0.4.2`, requires **Node.js 24 or later**, and uses Apache-2.0.
5
+ AMP is a metacognitive protocol for agents: declare knowledge and obligations, allocate finite attention, obtain evidence, and record costs and outcomes. The reference implementation is version `0.4.5`, requires **Node.js 24 or later**, and uses Apache-2.0.
6
6
 
7
7
  ## Architecture
8
8
 
@@ -85,7 +85,7 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
85
85
 
86
86
  `npm run build:lib` rebuilds `lib/` and `prepublishOnly` runs it before publishing. The build compiles only the library; the Vite demo entry (`src/main.ts`) is not part of it.
87
87
 
88
- Focused checks: `npm run workspace-agent-check`, `workspace-project-check`, `workspace-diff-check`, `workspace-reactive-diff-check` and the `workspace-*-boundary-check` suites, `workspace-context-check`, `document-context-check`, `tex-context-check`, `governance-check`, `assignment-check`, `interaction-binding-check`, `discover-check`, `discover-agent-check`, `typecheck` and `typecheck:tools`. `verify` runs the full chain and both type checks. Evaluation inputs/reports remain in [docs/eval](docs/eval/) and [docs/probes](docs/probes/) as JSON; fixture and recorded-probe results are not independent human studies or production-quality evidence.
88
+ Focused checks can be run directly with the corresponding camelCase tools, such as `node tools/workspaceAgentCheck.ts`, `node tools/workspaceProjectCheck.ts`, `node tools/workspaceDiffCheck.ts`, `node tools/workspaceReactiveDiffCheck.ts`, `node tools/discoverCheck.ts` and `node tools/discoverAgentCheck.ts`. `verify` runs the full chain and both type checks. Evaluation inputs/reports remain in [docs/eval](docs/eval/) and [docs/probes](docs/probes/) as JSON; fixture and recorded-probe results are not independent human studies or production-quality evidence.
89
89
 
90
90
  ## Agent tools
91
91
 
@@ -116,20 +116,20 @@ The `amp_protocol_workspace` v1 response contains `protocol`, `version`, `revisi
116
116
 
117
117
  ### Filesystem tools
118
118
 
119
- `amp_tool_filesystem_*` is bound to one authenticated Session; the bearer token never appears in a tool argument. Every tool except `write` is read-only.
119
+ `amp_tool_file_*` is bound to one authenticated Session; the bearer token never appears in a tool argument. Every tool except `write` is read-only.
120
120
 
121
121
  | Tool | Purpose |
122
122
  | --- | --- |
123
- | `amp_tool_filesystem_session` | Current identity, roots, permissions, remaining TTL and quotas |
124
- | `amp_tool_filesystem_file` | One File/Directory node; `depth`/`offset`/`limit` bound the subtree |
125
- | `amp_tool_filesystem_directory` | Flat listing of direct children |
126
- | `amp_tool_filesystem_read` | 1-based line page with fingerprint, charset and the next line |
127
- | `amp_tool_filesystem_write` | Atomic write; create/overwrite/upsert/append, CAS, dry-run |
128
- | `amp_tool_filesystem_outline` | Structural outline with `query`/`startLine`/`endLine` filters |
129
- | `amp_tool_filesystem_import` | Outgoing, incoming or two-way imports |
130
- | `amp_tool_filesystem_export` | Exported symbols, signatures and re-export edges |
131
- | `amp_tool_filesystem_dependency` | Cycles, topological order and bounded closures |
132
- | `amp_tool_filesystem_ast` | Lossless syntax tree: every non-whitespace token, declaration/markup hierarchy, UTF-8/line ranges; read-only, never executes |
123
+ | `amp_tool_file_session` | Current identity, roots, permissions, remaining TTL and quotas |
124
+ | `amp_tool_file_file` | One File/Directory node; `depth`/`offset`/`limit` bound the subtree |
125
+ | `amp_tool_file_directory` | Flat listing of direct children |
126
+ | `amp_tool_file_read` | 1-based line page with fingerprint, charset and the next line |
127
+ | `amp_tool_file_write` | Atomic write; create/overwrite/upsert/append, CAS, dry-run |
128
+ | `amp_tool_file_outline` | Structural outline with `query`/`startLine`/`endLine` filters |
129
+ | `amp_tool_file_import` | Outgoing, incoming or two-way imports |
130
+ | `amp_tool_file_export` | Exported symbols, signatures and re-export edges |
131
+ | `amp_tool_file_dependency` | Cycles, topological order and bounded closures |
132
+ | `amp_tool_file_ast` | Lossless syntax tree: every non-whitespace token, declaration/markup hierarchy, UTF-8/line ranges; read-only, never executes |
133
133
 
134
134
  The global variant is `amp_tool_globalfs_*`, a naming adapter in [src/global/filesystem.ts](src/global/filesystem.ts) that grants no new root or permission. Outline nodes carry `isFile`/`isDirectory`/`file?`/`directory?`/`path` (for example `add.py#add`) and `range` (UTF-8 bytes plus 1-based lines as bigint; decimal strings on the wire). Strategies cover code, Vue, project manifests, Markdown/TeX/plain text, CSS/SCSS/Sass, HTML, XML/OPML and Office; Office parsing covers DOCX/XLSX/PPTX and treats DOC/XLS/PPT/PUB/ACCDB as best-effort CFB.
135
135
 
@@ -153,8 +153,8 @@ await diff.run({ path: "src/new.ts", before: "" });
153
153
  ### MCP stdio
154
154
 
155
155
  ```sh
156
- npm run workspace-agent-demo
157
- npm run workspace-agent -- --config .cache/workspace-agent.local
156
+ node tools/workspaceAgentDemo.ts
157
+ node tools/workspaceAgentServer.ts --config .cache/workspace-agent.local
158
158
  ```
159
159
 
160
160
  For an MCP client, start Node directly to keep package-manager banners out of stdout. Replace absolute paths with your checkout location:
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) · **简体中文** · [更新日志](CHANGELOG.zh-CN.md)
4
4
 
5
- AMP 是供 agent 使用的元认知协议:声明知识和义务,分配有限注意力,获取证据,记录成本与结果。当前参考实现为 `0.4.2`,要求 **Node.js 24 或以上**,使用 Apache-2.0 许可证。
5
+ AMP 是供 agent 使用的元认知协议:声明知识和义务,分配有限注意力,获取证据,记录成本与结果。当前参考实现为 `0.4.5`,要求 **Node.js 24 或以上**,使用 Apache-2.0 许可证。
6
6
 
7
7
  ## 架构
8
8
 
@@ -85,7 +85,7 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
85
85
 
86
86
  `npm run build:lib` 重新构建 `lib/`,发布前由 `prepublishOnly` 自动执行。该构建只编译库代码,Vite 演示入口(`src/main.ts`)不在其中。
87
87
 
88
- 专项检查为 `npm run workspace-agent-check`、`workspace-project-check`、`workspace-diff-check`、`workspace-reactive-diff-check` 与 `workspace-*-boundary-check` 系列、`workspace-context-check`、`document-context-check`、`tex-context-check`、`governance-check`、`assignment-check`、`interaction-binding-check`、`discover-check`、`discover-agent-check`、`typecheck` 与 `typecheck:tools`。`verify` 执行完整验证链和两份类型检查。评测输入/结果以 JSON 保存在 [docs/eval](docs/eval/) 与 [docs/probes](docs/probes/),夹具与录制探针不等同于独立的人类研究或生产质量证明。
88
+ 专项检查可直接运行对应的 camelCase 工具,例如 `node tools/workspaceAgentCheck.ts`、`node tools/workspaceProjectCheck.ts`、`node tools/workspaceDiffCheck.ts`、`node tools/workspaceReactiveDiffCheck.ts`、`node tools/discoverCheck.ts` 与 `node tools/discoverAgentCheck.ts`。`verify` 执行完整验证链和两份类型检查。评测输入/结果以 JSON 保存在 [docs/eval](docs/eval/) 与 [docs/probes](docs/probes/),夹具与录制探针不等同于独立的人类研究或生产质量证明。
89
89
 
90
90
  ## Agent 工具
91
91
 
@@ -116,20 +116,20 @@ import { ToolIds, parseId } from "attention-manifest-protocol/naming";
116
116
 
117
117
  ### 文件系统工具
118
118
 
119
- `amp_tool_filesystem_*` 绑定一个已认证 Session;令牌不出现在工具参数里。除 `write` 外全部只读。
119
+ `amp_tool_file_*` 绑定一个已认证 Session;令牌不出现在工具参数里。除 `write` 外全部只读。
120
120
 
121
121
  | 工具 | 用途 |
122
122
  | --- | --- |
123
- | `amp_tool_filesystem_session` | 当前身份、根、权限、剩余 TTL 与配额 |
124
- | `amp_tool_filesystem_file` | 返回一个 File/Directory 节点;`depth`/`offset`/`limit` 控制子树与分页 |
125
- | `amp_tool_filesystem_directory` | 平铺列出一级子节点 |
126
- | `amp_tool_filesystem_read` | 按 1-based 行号读取文本页;返回指纹、字符集与下一页行号 |
127
- | `amp_tool_filesystem_write` | 原子写入;create/overwrite/upsert/append、CAS、dry-run |
128
- | `amp_tool_filesystem_outline` | 结构化大纲;支持 `query`/`startLine`/`endLine` 过滤 |
129
- | `amp_tool_filesystem_import` | 出边/入边/两向导入关系 |
130
- | `amp_tool_filesystem_export` | 导出符号、签名与 re-export 边 |
131
- | `amp_tool_filesystem_dependency` | 环、拓扑序、依赖/被依赖闭包 |
132
- | `amp_tool_filesystem_ast` | 无损语法树:每个非空白 token、声明/块/标签层级、UTF-8 字节与行范围;只读,不执行 |
123
+ | `amp_tool_file_session` | 当前身份、根、权限、剩余 TTL 与配额 |
124
+ | `amp_tool_file_file` | 返回一个 File/Directory 节点;`depth`/`offset`/`limit` 控制子树与分页 |
125
+ | `amp_tool_file_directory` | 平铺列出一级子节点 |
126
+ | `amp_tool_file_read` | 按 1-based 行号读取文本页;返回指纹、字符集与下一页行号 |
127
+ | `amp_tool_file_write` | 原子写入;create/overwrite/upsert/append、CAS、dry-run |
128
+ | `amp_tool_file_outline` | 结构化大纲;支持 `query`/`startLine`/`endLine` 过滤 |
129
+ | `amp_tool_file_import` | 出边/入边/两向导入关系 |
130
+ | `amp_tool_file_export` | 导出符号、签名与 re-export 边 |
131
+ | `amp_tool_file_dependency` | 环、拓扑序、依赖/被依赖闭包 |
132
+ | `amp_tool_file_ast` | 无损语法树:每个非空白 token、声明/块/标签层级、UTF-8 字节与行范围;只读,不执行 |
133
133
 
134
134
  全局变体为 `amp_tool_globalfs_*`,由 [src/global/filesystem.ts](src/global/filesystem.ts) 做命名适配;它不扩大任何根或权限。
135
135
  大纲节点带 `isFile`/`isDirectory`/`file?`/`directory?`/`path`(如 `add.py#add`)与 `range`(UTF-8 字节 + 1-based 行,bigint;JSON 中为十进制字符串)。策略覆盖代码、Vue、项目清单、Markdown/TeX/纯文本、CSS/SCSS/Sass、HTML、XML/OPML 与 Office;Office 文件由 `office.ts` 解析 DOCX/XLSX/PPTX,DOC/XLS/PPT/PUB/ACCDB 为 CFB best-effort。
@@ -154,8 +154,8 @@ await diff.run({ path: "src/new.ts", before: "" });
154
154
  ### MCP stdio 接入
155
155
 
156
156
  ```sh
157
- npm run workspace-agent-demo
158
- npm run workspace-agent -- --config .cache/workspace-agent.local
157
+ node tools/workspaceAgentDemo.ts
158
+ node tools/workspaceAgentServer.ts --config .cache/workspace-agent.local
159
159
  ```
160
160
 
161
161
  真实 MCP 客户端应直接启动 Node,避免包管理器提示混入协议 stdout。将以下绝对路径替换为实际项目目录:
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amp.dev/schema/0.1/collaboration.schema.json",
4
+ "title": "AMP collaboration objects (delegation | lease | result-contract)",
5
+ "type": "object",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "required": ["amp", "kind", "id", "granter", "delegatee", "goal_digest", "scope", "budget", "deadline", "may_redelegate", "depth"],
10
+ "properties": {
11
+ "amp": { "const": "0.1" },
12
+ "kind": { "const": "delegation" },
13
+ "id": { "$ref": "common.schema.json#/$defs/id" },
14
+ "parent": { "$ref": "common.schema.json#/$defs/id" },
15
+ "granter": { "$ref": "common.schema.json#/$defs/id" },
16
+ "delegatee": { "$ref": "common.schema.json#/$defs/id" },
17
+ "goal_digest": { "$ref": "common.schema.json#/$defs/digest" },
18
+ "scope": { "type": "array", "items": { "type": "string" } },
19
+ "budget": { "$ref": "common.schema.json#/$defs/budget" },
20
+ "deadline": { "$ref": "common.schema.json#/$defs/ts" },
21
+ "may_redelegate": { "type": "boolean" },
22
+ "depth": { "type": "integer", "minimum": 0, "maximum": 2 }
23
+ },
24
+ "additionalProperties": false
25
+ },
26
+ {
27
+ "type": "object",
28
+ "required": ["amp", "kind", "id", "delegation", "task_id", "holder", "fence", "goal_digest", "budget", "deadline", "status"],
29
+ "properties": {
30
+ "amp": { "const": "0.1" },
31
+ "kind": { "const": "lease" },
32
+ "id": { "$ref": "common.schema.json#/$defs/id" },
33
+ "delegation": { "$ref": "common.schema.json#/$defs/id" },
34
+ "task_id": { "$ref": "common.schema.json#/$defs/id" },
35
+ "holder": { "$ref": "common.schema.json#/$defs/id" },
36
+ "fence": { "type": "integer", "minimum": 1 },
37
+ "goal_digest": { "$ref": "common.schema.json#/$defs/digest" },
38
+ "budget": { "$ref": "common.schema.json#/$defs/budget" },
39
+ "deadline": { "$ref": "common.schema.json#/$defs/ts" },
40
+ "status": { "type": "string", "enum": ["active", "done", "cancelled"] }
41
+ },
42
+ "additionalProperties": false
43
+ },
44
+ {
45
+ "type": "object",
46
+ "required": ["amp", "kind", "id", "lease", "goal_digest", "claims", "evidence", "unknowns", "artifacts", "status"],
47
+ "properties": {
48
+ "amp": { "const": "0.1" },
49
+ "kind": { "const": "result-contract" },
50
+ "id": { "$ref": "common.schema.json#/$defs/id" },
51
+ "lease": { "$ref": "common.schema.json#/$defs/id" },
52
+ "goal_digest": { "$ref": "common.schema.json#/$defs/digest" },
53
+ "claims": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/ref" } },
54
+ "evidence": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/ref" } },
55
+ "unknowns": { "type": "array", "items": { "type": "string" } },
56
+ "artifacts": {
57
+ "type": "array",
58
+ "items": {
59
+ "type": "object",
60
+ "required": ["id", "digest"],
61
+ "properties": {
62
+ "id": { "$ref": "common.schema.json#/$defs/id" },
63
+ "digest": { "$ref": "common.schema.json#/$defs/digest" }
64
+ },
65
+ "additionalProperties": false
66
+ }
67
+ },
68
+ "status": { "type": "string", "enum": ["ok", "partial", "failed"] }
69
+ },
70
+ "additionalProperties": false
71
+ }
72
+ ]
73
+ }
@@ -0,0 +1,125 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amp.dev/schema/0.1/common.schema.json",
4
+ "title": "AMP common definitions",
5
+ "$defs": {
6
+ "id": {
7
+ "type": "string",
8
+ "pattern": "^[a-z][a-z0-9._:-]{0,63}$"
9
+ },
10
+ "digest": {
11
+ "type": "string",
12
+ "pattern": "^sha256:[a-f0-9]{64}$"
13
+ },
14
+ "ts": {
15
+ "type": "string",
16
+ "format": "date-time"
17
+ },
18
+ "confidence": {
19
+ "type": "number",
20
+ "minimum": 0,
21
+ "maximum": 1
22
+ },
23
+ "trust": {
24
+ "type": "string",
25
+ "enum": ["self", "verified", "trusted", "asserted", "inferred", "external"]
26
+ },
27
+ "tier": {
28
+ "type": "string",
29
+ "enum": ["T0", "T1", "T2", "T3", "T4"]
30
+ },
31
+ "refKind": {
32
+ "type": "string",
33
+ "enum": [
34
+ "entity", "concept", "process", "thread", "question", "hypothesis", "claim",
35
+ "evidence", "goal", "plan", "task", "tool", "memory", "other",
36
+ "human", "event", "handle", "frame", "self", "unknown", "common-ground",
37
+ "capability", "agent", "receipt", "org"
38
+ ]
39
+ },
40
+ "ref": {
41
+ "type": "object",
42
+ "required": ["kind", "id"],
43
+ "properties": {
44
+ "kind": { "$ref": "#/$defs/refKind" },
45
+ "id": { "$ref": "#/$defs/id" },
46
+ "label": { "type": "string" }
47
+ },
48
+ "additionalProperties": false
49
+ },
50
+ "provenance": {
51
+ "type": "object",
52
+ "required": ["source"],
53
+ "properties": {
54
+ "source": { "type": "string" },
55
+ "kind": {
56
+ "type": "string",
57
+ "enum": ["observation", "testimony", "inference", "tool", "memory", "document", "simulation"]
58
+ },
59
+ "trust": { "$ref": "#/$defs/trust" },
60
+ "at": { "$ref": "#/$defs/ts" },
61
+ "digest": { "$ref": "#/$defs/digest" },
62
+ "note": { "type": "string" }
63
+ },
64
+ "additionalProperties": false
65
+ },
66
+ "budget": {
67
+ "type": "object",
68
+ "properties": {
69
+ "tokens": { "type": "integer", "minimum": 0 },
70
+ "ms": { "type": "integer", "minimum": 0 },
71
+ "calls": { "type": "integer", "minimum": 0 },
72
+ "interrupts": { "type": "integer", "minimum": 0 },
73
+ "money": { "type": "number", "minimum": 0 }
74
+ },
75
+ "additionalProperties": false
76
+ },
77
+ "usage": {
78
+ "type": "object",
79
+ "properties": {
80
+ "tokens": { "type": "integer", "minimum": 0 },
81
+ "ms": { "type": "integer", "minimum": 0 },
82
+ "calls": { "type": "integer", "minimum": 0 },
83
+ "interrupts": { "type": "integer", "minimum": 0 },
84
+ "money": { "type": "number", "minimum": 0 }
85
+ },
86
+ "additionalProperties": false
87
+ },
88
+ "signature": {
89
+ "type": "object",
90
+ "required": ["role", "alg", "kid", "sig"],
91
+ "properties": {
92
+ "role": { "type": "string", "enum": ["self", "host", "registry", "org", "tenant"] },
93
+ "alg": { "type": "string", "const": "ed25519" },
94
+ "kid": { "type": "string" },
95
+ "sig": { "type": "string" }
96
+ },
97
+ "additionalProperties": false
98
+ },
99
+ "criterion": {
100
+ "type": "object",
101
+ "required": ["id", "statement", "check"],
102
+ "properties": {
103
+ "id": { "$ref": "#/$defs/id" },
104
+ "statement": { "type": "string" },
105
+ "check": { "type": "string" },
106
+ "kind": { "type": "string", "enum": ["observe", "query", "assert"] }
107
+ },
108
+ "additionalProperties": false
109
+ },
110
+ "handle": {
111
+ "type": "object",
112
+ "required": ["id", "kind", "scope"],
113
+ "properties": {
114
+ "id": { "type": "string" },
115
+ "kind": { "type": "string", "enum": ["table", "text", "tree", "blob", "graph"] },
116
+ "tokens": { "type": "integer", "minimum": 0 },
117
+ "bytes": { "type": "integer", "minimum": 0 },
118
+ "preview": { "type": "string" },
119
+ "scope": { "type": "string", "enum": ["turn", "session", "task"] },
120
+ "ttl_ms": { "type": "integer", "minimum": 0 }
121
+ },
122
+ "additionalProperties": false
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,121 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amp.dev/schema/0.1/compaction.schema.json",
4
+ "title": "AMP checkpoint | prune plan",
5
+ "type": "object",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "required": [
10
+ "amp",
11
+ "kind",
12
+ "id",
13
+ "agent",
14
+ "from",
15
+ "to",
16
+ "count",
17
+ "tip",
18
+ "root",
19
+ "created",
20
+ "policy"
21
+ ],
22
+ "properties": {
23
+ "amp": { "const": "0.1" },
24
+ "kind": { "const": "checkpoint" },
25
+ "id": { "$ref": "common.schema.json#/$defs/id" },
26
+ "agent": { "$ref": "common.schema.json#/$defs/id" },
27
+ "from": { "type": "integer", "minimum": 0 },
28
+ "to": { "type": "integer", "minimum": 0 },
29
+ "count": { "type": "integer", "minimum": 1 },
30
+ "tip": { "$ref": "common.schema.json#/$defs/digest" },
31
+ "root": { "$ref": "common.schema.json#/$defs/digest" },
32
+ "created": { "$ref": "common.schema.json#/$defs/ts" },
33
+ "policy": {
34
+ "type": "object",
35
+ "required": ["keepRecent"],
36
+ "properties": {
37
+ "keepRecent": { "type": "integer", "minimum": 0 }
38
+ },
39
+ "additionalProperties": false
40
+ }
41
+ },
42
+ "additionalProperties": false
43
+ },
44
+ {
45
+ "type": "object",
46
+ "required": [
47
+ "amp",
48
+ "kind",
49
+ "agent",
50
+ "sourceTip",
51
+ "sourceCount",
52
+ "kept",
53
+ "dropped",
54
+ "reclaimedBytes",
55
+ "estimatedTokens",
56
+ "policy"
57
+ ],
58
+ "properties": {
59
+ "amp": { "const": "0.1" },
60
+ "kind": { "const": "prune-plan" },
61
+ "agent": { "$ref": "common.schema.json#/$defs/id" },
62
+ "sourceTip": { "$ref": "common.schema.json#/$defs/digest" },
63
+ "sourceCount": { "type": "integer", "minimum": 0 },
64
+ "kept": {
65
+ "type": "array",
66
+ "items": { "type": "integer", "minimum": 0 }
67
+ },
68
+ "dropped": {
69
+ "type": "array",
70
+ "items": {
71
+ "type": "object",
72
+ "required": ["seq", "kind", "id", "reason", "revisit_if", "bytes"],
73
+ "properties": {
74
+ "seq": { "type": "integer", "minimum": 0 },
75
+ "kind": {
76
+ "enum": [
77
+ "event",
78
+ "frame",
79
+ "receipt",
80
+ "claim",
81
+ "hypothesis",
82
+ "unknown",
83
+ "goal",
84
+ "plan"
85
+ ]
86
+ },
87
+ "id": { "$ref": "common.schema.json#/$defs/id" },
88
+ "reason": { "enum": ["superseded", "closed", "resolved"] },
89
+ "revisit_if": { "type": "string", "minLength": 1 },
90
+ "bytes": { "type": "integer", "minimum": 0 }
91
+ },
92
+ "additionalProperties": false
93
+ }
94
+ },
95
+ "reclaimedBytes": { "type": "integer", "minimum": 0 },
96
+ "estimatedTokens": { "type": "integer", "minimum": 0 },
97
+ "policy": {
98
+ "type": "object",
99
+ "required": [
100
+ "amp",
101
+ "kind",
102
+ "keepRecent",
103
+ "dropSupersededClaims",
104
+ "dropClosedHypotheses",
105
+ "dropResolvedUnknowns"
106
+ ],
107
+ "properties": {
108
+ "amp": { "const": "0.1" },
109
+ "kind": { "const": "prune-policy" },
110
+ "keepRecent": { "type": "integer", "minimum": 0 },
111
+ "dropSupersededClaims": { "type": "boolean" },
112
+ "dropClosedHypotheses": { "type": "boolean" },
113
+ "dropResolvedUnknowns": { "type": "boolean" }
114
+ },
115
+ "additionalProperties": false
116
+ }
117
+ },
118
+ "additionalProperties": false
119
+ }
120
+ ]
121
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amp.dev/schema/0.1/concept-compaction.schema.json",
4
+ "title": "AMP concept prune plan | concept checkpoint",
5
+ "type": "object",
6
+ "oneOf": [
7
+ {
8
+ "type": "object",
9
+ "required": ["amp", "kind", "concept", "version", "dropped", "reclaimedBytes", "budget"],
10
+ "properties": {
11
+ "amp": { "const": "0.1" },
12
+ "kind": { "const": "concept-prune-plan" },
13
+ "concept": { "$ref": "common.schema.json#/$defs/id" },
14
+ "version": { "type": "integer", "minimum": 1 },
15
+ "dropped": {
16
+ "type": "array",
17
+ "items": {
18
+ "type": "object",
19
+ "required": ["slot", "index", "summary", "reason", "revisit_if"],
20
+ "properties": {
21
+ "slot": { "enum": ["example", "relation", "extension"] },
22
+ "index": { "type": "integer", "minimum": 0 },
23
+ "summary": { "type": "string", "minLength": 1 },
24
+ "reason": { "enum": ["duplicate", "over-budget", "dangling"] },
25
+ "revisit_if": { "type": "string", "minLength": 1 }
26
+ },
27
+ "additionalProperties": false
28
+ }
29
+ },
30
+ "reclaimedBytes": { "type": "integer", "minimum": 0 },
31
+ "budget": {
32
+ "type": "object",
33
+ "required": ["amp", "kind", "maxExamples", "minExamples", "maxRelations", "keepVersions"],
34
+ "properties": {
35
+ "amp": { "const": "0.1" },
36
+ "kind": { "const": "concept-budget" },
37
+ "maxExamples": { "type": "integer", "minimum": 0 },
38
+ "minExamples": { "type": "integer", "minimum": 0 },
39
+ "maxRelations": { "type": "integer", "minimum": 0 },
40
+ "keepVersions": { "type": "integer", "minimum": 1 }
41
+ },
42
+ "additionalProperties": false
43
+ }
44
+ },
45
+ "additionalProperties": false
46
+ },
47
+ {
48
+ "type": "object",
49
+ "required": ["amp", "kind", "id", "concept", "from", "to", "count", "tip", "root", "created", "budget"],
50
+ "properties": {
51
+ "amp": { "const": "0.1" },
52
+ "kind": { "const": "concept-checkpoint" },
53
+ "id": { "$ref": "common.schema.json#/$defs/id" },
54
+ "concept": { "$ref": "common.schema.json#/$defs/id" },
55
+ "from": { "type": "integer", "minimum": 1 },
56
+ "to": { "type": "integer", "minimum": 1 },
57
+ "count": { "type": "integer", "minimum": 1 },
58
+ "tip": { "$ref": "common.schema.json#/$defs/digest" },
59
+ "root": { "$ref": "common.schema.json#/$defs/digest" },
60
+ "created": { "$ref": "common.schema.json#/$defs/ts" },
61
+ "budget": {
62
+ "type": "object",
63
+ "required": ["keepVersions"],
64
+ "properties": {
65
+ "keepVersions": { "type": "integer", "minimum": 1 }
66
+ },
67
+ "additionalProperties": false
68
+ }
69
+ },
70
+ "additionalProperties": false
71
+ }
72
+ ]
73
+ }