Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/architecture/SPEC/kb_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,35 @@ infermatrix-copilot kb init REPO --stage feature-discovery --from-existing \
```

`--dry-run` 保存目录和 PR 正文供审查;省略它时沿用 init 的发布权限与 PR 流程。
已有知识库没有本地 skeleton 记录时,目录 PR 合并后可运行
`kb init REPO --stage modules --from-existing --pin FULL_SHA`,从已合并的仓库
入口、owner 路由及页面复核结构,再补充导航。随后使用
`--stage knowledge --from-existing`;已有 modules 记录仍须完成并合并,
已有 skeleton 记录的状态与合并门禁同样保留。该模式不生成历史阶段记录,
不绕过发现目录的源码及哈希绑定;省略 `--from-existing` 时保留原阶段顺序。
重复初始化若遇到已合并旧批次仍保留的发布分支,可在新批次启动前设置
`KB_INIT_BRANCH_SUFFIX=<batch-slug>`,使用 `kb/init-REPO-STAGE-SUFFIX`;未设置时
沿用旧分支名及检查点身份。后缀仅允许 1–40 位小写字母、数字和连字符,
首尾不能为连字符;非法值在模型调用前拒绝。配置的后缀绑定输入身份及
已准备发布的分支,恢复发布时不能更换;不会删除或覆盖旧批次分支。
订阅模式明确使用 Zcode GLM‑5.3 提取、Codex 独立评审,不使用 Claude Code。
默认并发上限为 13,两轮按顺序运行,轮内共享线程池;Zcode 请求沿用共享排期。
`KB_DISCOVERY_GENERATOR`、`KB_DISCOVERY_JUDGE`、`KB_DISCOVERY_CONCURRENCY`
覆盖发现阶段配置;提取与评审必须属于不同模型家族。`--budget-usd` 与
`--unlimited-subscription` 互斥。未报告实际费用时保持未知,记账值不当作发票费用。

`KB_DISCOVERY_PACKET_CHARS` 设置每次提取组合的正文字符预算(整数 24000–192000,
默认 24000);仅组合已有完整分片,不删除或截断输入。`KB_DISCOVERY_START_INTERVAL_S`
设置 Zcode 初始启动间隔(有限数值 1–60 秒,默认 15 秒);原生 429/1302 仍触发共享
冷却和自适应限速。较大的包可能仍有候选遗漏,不能据此声称所有功能已发现。
`ZCODE_REASONING_LEVEL=low|high|max` 设置实际写入 Zcode 会话配置的推理强度,默认 max;
Zcode 模型角色中的 `effort` 被 transport 忽略,不能代替该设置。网关追踪和原生 attempt
均记录 `native_reasoning_level`;发现的输入身份、检查点及紧凑报告 `run_config` 同时绑定
包大小、启动间隔和实际配置的推理强度。改变任何一项需新批次;旧检查点未记录这些
配置时不能安全恢复,须保留旧档案并使用新的状态目录。
返回恰好 24 个候选的分片记录 `candidate_limit_reached`,报告列出数量及任务 ID,
作为候选可能遗漏的线索;本轮不自动拆分重采样,也不把饱和结果称为穷尽。

发现使用完整文件库存和分片,不把前 N 个文件、前 N 行当作全仓库。范围、排除规则、
文档入口与功能分母按仓库配置;未知语言使用文本和入口线索,并保留未解析关系。
没有文档不阻断源码轮,正式功能允许 `docs: []`。目录以外的疑似第一方代码列为
Expand Down
2 changes: 2 additions & 0 deletions doc/architecture/SPEC/playbooks/PLAYBOOKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ success, steps[]`。
pr-history → harvest-calibration),每阶段一个由人合并的 PR。只由 `kb init REPO --stage S` 运行,不经 `kb serve`,不写服务账本。
`feature-discovery` 先提取文档功能基线,再遍历固定源码与测试库存;独立评审后的目录 PR
合并后冻结,下游核对目录哈希与源码版本。新初始化模板启用发现;旧仓库保持兼容。
`from_existing` 可用于发现、modules 与解释性知识:缺少本地 skeleton 记录时
核验已合并入口与 owner 页面;已有阶段记录及发现目录仍保留完成和合并门禁。
默认 GLM‑5.3 提取、Codex 独立评审,共享并发 13;支持 `from_existing`、
`retry_unfinished`、`budget_usd` 或 `unlimited_subscription`。未知项不增加正式功能计数,
原生追踪归档在 Git 外。详细契约见 [`../kb_service.md`](../kb_service.md)。
Expand Down
4 changes: 3 additions & 1 deletion doc/architecture/SPEC/trace_store.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# trace_store.py —— 规范

<!-- verified-against: 2026-10-04 -->
<!-- verified-against: 2026-10-05 -->

`LOC ~500 · trace/1:Copilot 与 RB 共用的模型调用/工具调用/判定/结果记录 · refactor-status: stable`

Expand All @@ -18,6 +18,8 @@
`native-events.jsonl`,保留原生会话、输出、错误与调度等待事件。结束时绑定唯一的
`model_call` 回执及输出、用量、耗时与状态;journal 不是另一笔调用,不能重复计费。
中断未完成的 journal 保留输入和已收到的事件,未报告用量及费用保持未知。
对 Zcode,网关调用的 model 与 attempt.model 额外记录 `native_reasoning_level`,
表示实际写入会话配置的 low/high/max;role.effort 不是该 transport 的有效推理设置。

- `bind_store(store)` / `current_store()`:把一个 store 绑定为当前进程/任务的采集汇(`tools.dispatch` 与
`LLM.create` 两个 choke point 据此写 `tool_call` / `model_call`,失败调用记 `error` 且无 `outputs`);
Expand Down
8 changes: 8 additions & 0 deletions eval/feature-discovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ infermatrix-copilot kb init REPO --stage feature-discovery --from-existing \
`KB_DISCOVERY_GENERATOR`、`KB_DISCOVERY_JUDGE`、`KB_DISCOVERY_CONCURRENCY` 可覆盖。
`--budget-usd` 与不限订阅模式互斥。未报告实际费用时保持未知。

批量提取可设置 `KB_DISCOVERY_PACKET_CHARS`(24000–192000,默认 24000),完整索引
分片和读取范围保持不变。`KB_DISCOVERY_START_INTERVAL_S`(1–60 秒,默认 15)只配置
启动间隔,仍保留 429/1302 冷却。`ZCODE_REASONING_LEVEL=low|high|max` 控制实际原生
推理配置;模型角色的 effort 后缀不会替代它。三项设置记录在检查点和报告的
`run_config`;原生追踪另存 `native_reasoning_level`。配置变化或旧检查点缺少这些身份
字段时使用新状态目录,保留旧轨迹。扩大包不会证明已发现所有功能,也不取消独立评审。
恰好达到每包 24 个候选上限的任务另列数量和 ID,保留为潜在遗漏线索。

检查点绑定源码、范围、种子目录、索引版本、提示词与模型配置。成功分片、评审和待审修正稿可复用;预算中断不标为完成。竞争启动同一批次不会覆盖检查点。单项最多三次修正;通道故障保持未知,不重做已成功的提取。仅有文档的未知声明不通过重复改写变成实现证明。

紧凑摘要写入 `eval/feature-discovery/`。完整输入、原生输出、工具事件、配置、用量和修正过程留在 Git 外。恢复时核验每个完成分片的原生归档,包括返回空候选的分片。Zcode 保存原生流式事件;Codex 保存 CLI 结束后按原顺序转发的事件。
Expand Down
2 changes: 1 addition & 1 deletion playbooks/kb-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ params:
pin: "upstream commit to pin (default: the default branch head)"
pr_count: "pr-history only: merged upstream PRs to replay (default: adapter pr_history_count or 1000)"
budget_usd: "discovery/pr-history/depth: cumulative spend ceiling; increasing it resumes the same pinned batch"
from_existing: "discovery/explanatory knowledge: enrich a merged index and owner routes without local earlier-stage records"
from_existing: "discovery/modules/explanatory knowledge: enrich a merged index and owner routes without local skeleton records; existing stage merge gates remain required"
retry_unfinished: "feature-discovery/knowledge-deepen: retry unfinished work while retaining accepted work and cumulative spend"
subscription_generator: "explicit subscription backend; generator USD unreported, fees outside stage USD accounting"
unlimited_subscription: "feature-discovery/knowledge-deepen: authenticated Zcode GLM-5.3 generator and independent Codex subscription judge without fixed accounting ceiling; incompatible with budget_usd"
Expand Down
24 changes: 22 additions & 2 deletions plugins/infermatrix-copilot/skills/imkbinit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,28 @@ The next stage is the first one that isn't done. If an earlier stage's PR is
open, stop and say it's waiting for the owner's review. If a record says
`blocked`, report its `problems` and stop.

For an explicit knowledge rerun of an already merged KB with no local
skeleton/modules records, use `--stage knowledge --from-existing`. The CLI
For an explicit breadth rerun of an already merged KB with no local skeleton
record, use `--stage modules --from-existing`. Merge its PR before running
`--stage knowledge --from-existing`; no skeleton record is manufactured.
For a knowledge-only rerun with no local skeleton/modules records, use
`--stage knowledge --from-existing`. The CLI
checks the merged index and every owner route. Existing stage records still
keep their review and merge gates; never manufacture records to skip them.
An enabled or started feature-discovery batch must still finish and its
catalog PR must merge before publishing modules or knowledge.

For implementation knowledge in an existing KB, use the independent stage
`knowledge-deepen` (`kb deepen <repo>` is its `--from-existing` alias).
It is distinct from the ordinary `deepen` stage that generates hot-module rules.
`kb widen <repo>` similarly selects `knowledge --from-existing`.
Use a new state directory when the knowledge baseline or source pin changes;
retain prior native records and accepted blocks as audit evidence.
If a previous merged batch's publication branch still exists, set
`KB_INIT_BRANCH_SUFFIX=<batch-slug>` before starting the new batch. It appends
the slug to the default stage branch without replacing old branches. Use
1–40 lowercase letters, digits or hyphens, with no leading or trailing hyphen.
The suffix is part of the checkpoint identity; retain it when resuming or
publishing that batch, including a publication waiting for PR confirmation.

## 3. Run it

Expand Down Expand Up @@ -143,6 +154,15 @@ What each stage opens:
Zcode GLM-5.3 extracts and independent Codex reviews with shared concurrency 13.
`KB_DISCOVERY_GENERATOR`, `KB_DISCOVERY_JUDGE` and `KB_DISCOVERY_CONCURRENCY`
override the stage configuration; discovery rejects same-family review.
`KB_DISCOVERY_PACKET_CHARS` groups complete indexed chunks (24000–192000,
default 24000); `KB_DISCOVERY_START_INTERVAL_S` sets the initial Zcode spacing
(1–60 seconds, default 15) while native rate-limit cooldown stays enabled.
`ZCODE_REASONING_LEVEL=low|high|max` controls the effective native reasoning;
a Zcode role's effort suffix does not. These settings are frozen in the batch
and report, with reasoning also recorded in both trace and attempt archives.
Changed settings or old checkpoints without them require a fresh state
directory; retain the previous archive. Larger packets do not prove all
features were found.
`--from-existing` checks merged skeleton routes, while `--retry-unfinished`
resumes supported work. `--budget-usd` controls cumulative accounting;
`--unlimited-subscription` authenticates both roles and removes that ceiling.
Expand Down
6 changes: 3 additions & 3 deletions src/infermatrix_copilot/kb_service/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def _init_command(args, state_dir: Path) -> int:
return 2
params["acceptance_mode"] = args.acceptance_mode
if args.from_existing:
if args.stage not in ("feature-discovery", "knowledge", "knowledge-deepen"):
print("--from-existing is for feature-discovery, knowledge or knowledge-deepen only", file=sys.stderr)
if args.stage not in ("feature-discovery", "modules", "knowledge", "knowledge-deepen"):
print("--from-existing is for feature-discovery, modules, knowledge or knowledge-deepen only", file=sys.stderr)
return 2
params["from_existing"] = "true"
if args.subscription_generator:
Expand Down Expand Up @@ -227,7 +227,7 @@ def main(argv: list[str] | None = None) -> int:
init.add_argument("--pin", help="upstream commit to pin (default: the default branch head)")
init.add_argument("--suggest-seeds", action="store_true")
init.add_argument("--from-existing", action="store_true",
help="enrich a merged KB without local skeleton/modules records (discovery and knowledge stages)")
help="enrich a merged KB without local skeleton records (discovery, modules and knowledge stages)")
init.add_argument("--subscription-generator", action="store_true",
help="explicit subscription generator; unreported fees outside stage USD accounting")
init.add_argument("--unlimited-subscription", action="store_true",
Expand Down
Loading
Loading