Skip to content

Commit cd3e8ea

Browse files
committed
docs: define Context artifact boundaries
1 parent a7ab083 commit cd3e8ea

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

‎docs/reference/artifacts.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ OpenCode++ writes human-readable Markdown and machine-readable JSON.
66

77
For whether each generated file should be committed, see [Generated Files and Commit Policy](generated-files.md).
88

9+
## Runtime Boundary
10+
11+
The repository `.agent-context/` directory is a local runtime boundary. It contains generated context, Context Registry state, cache entries, annotations, feedback, traces, interventions, and loop reports. These records explain what the plugin did; they do not grant authority and they are not automatically suitable for source control.
12+
913
```txt
1014
AGENTS.md
1115
.agent-context/
@@ -60,3 +64,17 @@ AGENTS.md
6064
- `.agent-context/hallucination/*.json`
6165
- `.agent-context/regression/*.json`
6266
- `.agent-context/memory/candidates/*.json`
67+
68+
## Context And Intervention Records
69+
70+
| Location | Meaning | Authority |
71+
| ---------------------------------------------- | ---------------------------------------------- | ------------------------------------------ |
72+
| `.agent-context/registry/context-pack.json` | Merged local Context Registry pack | Advisory Context only |
73+
| `.agent-context/cache/context-registry/` | Source snapshots and fetch cache | Reusable bytes, freshness still required |
74+
| `.agent-context/context-registry/usage/` | Entries/files selected by tasks and provenance | Usage history, not evidence |
75+
| `.agent-context/context-registry/feedback/` | Local quality labels and aggregate signals | Feedback only, no direct decision override |
76+
| `.agent-context/knowledge/annotations/` | User-written repository notes | Untrusted, not policy or commands |
77+
| `.agent-context/interventions/<task-id>.jsonl` | Intervention Ledger events | Explanation, not proof by itself |
78+
| `.agent-context/sidecar/latest.md` | Human-readable latest summary | Presentation of findings and evidence |
79+
80+
The plugin uses atomic stores for state, trace, report, registry, annotation, and feedback writes. A damaged JSON file, revision conflict, or locked Windows file is reported diagnostically; it is never silently treated as an empty successful state. Runtime artifacts may contain paths, hashes, task intent, command metadata, or redacted output and should be excluded from commits.

‎docs/reference/artifacts.zh-CN.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
OpenCode++ 的 artifact 分为稳定仓库 context 和本地运行证据。稳定的 AGENTS、summary、index、graph、contracts 可按团队策略提交;trace、sidecar、cache、iteration 和 worktree 默认不提交。
66

7+
## 运行时边界
8+
9+
仓库 `.agent-context/` 是本地运行边界,包含生成的 context、Context Registry 状态、cache、annotation、feedback、trace、intervention 和 loop report。这些文件解释插件做了什么,但不授予权限,也不默认适合提交到版本库。
10+
711
## 主要目录
812

913
- .agent-context/tasks:任务 pack;
@@ -15,6 +19,20 @@ OpenCode++ 的 artifact 分为稳定仓库 context 和本地运行证据。稳
1519
- .agent-context/cache:本地缓存;
1620
- .agent-context/orchestrator:Harness 状态和报告。
1721

22+
## Context 和 Intervention 文件
23+
24+
| 位置 | 含义 | 权限语义 |
25+
| ---------------------------------------------- | ----------------------------------- | ------------------------------- |
26+
| `.agent-context/registry/context-pack.json` | 合并后的本地 Context Registry pack | 只能作为辅助 Context |
27+
| `.agent-context/cache/context-registry/` | source snapshot 和获取缓存 | 可复用字节,仍需 freshness 检查 |
28+
| `.agent-context/context-registry/usage/` | 任务选中的 entry/file 和 provenance | 使用历史,不是 evidence |
29+
| `.agent-context/context-registry/feedback/` | 本地质量标签和统计信号 | feedback,不能直接覆盖 decision |
30+
| `.agent-context/knowledge/annotations/` | 用户编写的仓库笔记 | 不可信,不是 policy 或命令 |
31+
| `.agent-context/interventions/<task-id>.jsonl` | Intervention Ledger 事件 | 解释记录,本身不是 proof |
32+
| `.agent-context/sidecar/latest.md` | 最近一次人类可读摘要 | 展示 finding 和 evidence |
33+
34+
插件使用 atomic store 写入 state、trace、report、registry、annotation 和 feedback。JSON 损坏、revision 冲突或 Windows 文件暂时被占用时会返回诊断,不会静默当成空的成功状态。运行时文件可能包含路径、hash、任务意图、命令 metadata 或脱敏输出,应排除在提交之外。
35+
1836
## Windows 插件文件
1937

2038
用户 OpenCode 配置目录下的 plugins、commands、state.json 和 installation.json 由 Windows EXE 管理,不属于仓库 artifact。卸载插件不会删除仓库 .agent-context。

‎docs/reference/retrieval.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ opencode-plusplus rag export .
2525

2626
Internal graph remains the portable foundation. CodeGraph and RAG providers are optional deep-code-intelligence backends.
2727

28+
## Context Registry Boundary
29+
30+
The Context Registry is a structured source of project guidance, not a command or policy engine. A pack has a stable entry identity, source identity, package version, content revision, language, trust level, content hash, and a primary file. Local packs may use `DOC.md` or `SKILL.md` with companion files such as references, examples, and error notes. Remote sources are disabled unless explicitly configured and are validated for timeout, size, hash, schema, and offline fallback.
31+
32+
Retrieval combines lexical fields, symbols, dependency chains, source authority, quality, regression memory, and task-specific negative examples. Exact entry IDs outrank quality or trust. Every hit exposes a score breakdown and stable ordering. `relatedFiles` describes useful candidates; `mustInspect` is the smaller set the task workflow requires the model to read; `rejectedFiles` explains candidates intentionally excluded from the pack.
33+
2834
## Incremental Context Fetch
2935

3036
The Context Registry is fetched through the shared application service used by Desktop and compatibility integrations. Search returns ranked entry metadata; it does not grant policy or command authority to Context content.
@@ -37,8 +43,16 @@ Fetching an entry uses three modes:
3743

3844
Every fetch reports `selectedFiles`, `omittedFiles`, provenance, source/version/revision hashes, cache status, duration, and working-tree freshness. A changed working tree causes the local source to be rebuilt and revalidated before content is returned. Registry trust and documentation are advisory context; current working-tree command or CI evidence remains the proof of a code change.
3945

46+
The default `entry` fetch is incremental and avoids loading every reference. Use an explicit `file` request for one companion file or `full` when the complete pack is needed. A fetch can be reused, incrementally refreshed, or rebuilt, but freshness and drift checks still run. A cache hit only means the bytes were reused safely; it does not mean the Context is authoritative or fresh for a changed source tree.
47+
4048
## Local Annotations
4149

4250
OpenCode++ can keep repository-local notes for environment limits, version differences, recurring failures, conventions, and verified workarounds. Notes are isolated by repository, Context entry, package version, and content revision, and are stored atomically under `.agent-context/knowledge/annotations/`.
4351

4452
Fetch responses expose `annotationAvailable` and stale summaries without injecting note text. Reading or injecting a note must be explicit. Injected notes are labeled `user-written`, `untrusted`, `context-only`, and `not a command`; they cannot satisfy evidence, close a guard blocker, or grant command authority. Notes from an older package version or content revision are stale by default and require explicit opt-in to read.
53+
54+
## Trust And Failure Rules
55+
56+
External Context can suggest file locations, API version details, error-handling ideas, or historical workarounds. It cannot satisfy tests, contract validation, freshness, forbidden-path checks, or finalize conditions. Commands found in Context are displayed as untrusted suggestions and are never executed automatically. A source trust level influences ranking and explanation only; it never overrides command or CI evidence.
57+
58+
On Windows, local and configured source paths are normalized before companion files are read, including paths containing spaces or non-ASCII characters. Traversal, missing files, invalid registry JSON, stale revisions, permission failures, remote timeouts, and unavailable network sources return structured diagnostics rather than an empty successful result.

‎docs/reference/retrieval.zh-CN.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ opencode-plusplus rag export .
2121

2222
内部 graph 是可移植基础;CodeGraph、LightRAG 和 embedding 是可选深度检索后端。
2323

24+
## Context Registry 边界
25+
26+
Context Registry 是结构化项目指导来源,不是命令引擎,也不是 policy 引擎。每个 pack 具有稳定的 entry identity、source identity、package version、content revision、language、trust level、content hash 和主入口文件。本地 pack 支持带 frontmatter 的 `DOC.md` 或 `SKILL.md`,也支持 references、examples、errors 等 companion file。远程 source 默认关闭,显式开启后仍会检查超时、大小、hash、schema 和离线 fallback。
27+
28+
Retrieval 会综合 lexical 字段、symbol、dependency chain、source authority、quality、regression memory 和 task-specific negative examples。精确 entry ID 的优先级高于 quality 或 trust。每个 hit 都返回 score breakdown 和稳定排序。`relatedFiles` 表示有帮助的候选文件;`mustInspect` 是任务流程要求模型实际阅读的更小集合;`rejectedFiles` 解释为什么候选被明确排除。
29+
2430
## 增量 Context 获取
2531

2632
Context Registry 通过 Desktop 和兼容性集成共同使用的 application service 获取。搜索只返回排序后的 entry 元数据;Context 内容不能授予策略或命令权限。
@@ -33,8 +39,16 @@ Context Registry 通过 Desktop 和兼容性集成共同使用的 application se
3339

3440
每次获取都会报告 `selectedFiles`、`omittedFiles`、来源/版本/revision/hash、缓存状态、耗时和工作树 freshness。工作树变化后,返回内容前会重新构建并验证本地来源。Registry 的可信等级和文档只能作为辅助上下文;证明代码修改有效,仍必须依赖当前工作树上的 command 或 CI evidence。
3541

42+
默认 `entry` 获取是增量模式,不会加载所有 reference。需要某个附属文件时显式使用 `file`;需要完整内容时使用 `full`。获取结果可以是 reused、incremental 或 rebuilt,但 freshness 和 drift 检查仍会执行。cache hit 只表示安全复用了字节,不表示 Context 权威或在工作树变化后仍然新鲜。
43+
3644
## 本地 Annotation
3745

3846
OpenCode++ 可以保存仓库本地的环境限制、版本差异、常见失败原因、项目约定和已验证 workaround。Annotation 按仓库、Context entry、package version 和 content revision 隔离,并通过 atomic store 写入 `.agent-context/knowledge/annotations/`。
3947

4048
Fetch 默认只返回 `annotationAvailable` 和 stale 摘要,不自动注入正文。读取或注入必须显式请求。注入内容会标记为 `user-written`、`untrusted`、`context-only` 和 `not a command`,不能满足 evidence、关闭 Guard blocker 或获得命令权限。旧 package version 或 content revision 的 annotation 默认是 stale,必须显式允许后才能读取。
49+
50+
## 可信等级和失败规则
51+
52+
外部 Context 可以建议文件位置、API 版本、错误处理方式或历史 workaround,但不能满足测试、contract validation、freshness、forbidden-path 检查或 finalize 条件。Context 中出现的命令只作为不可信建议显示,绝不会自动执行。source trust 只影响排序和解释,不能覆盖 command 或 CI evidence。
53+
54+
Windows 会在读取 companion file 前规范化本地和配置 source 路径,支持包含空格或非 ASCII 字符的路径。路径穿越、文件缺失、registry JSON 损坏、revision 过期、权限失败、远程超时和网络不可用都会返回结构化诊断,不会静默变成空的成功结果。

0 commit comments

Comments
 (0)