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
5 changes: 3 additions & 2 deletions docs/examples/dashboard-profile-review.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ <h2 class="panel-heading" aria-labelledby="chart-title"></h2>
const position=(p,axis)=>axis==='timestamp'?(p.timestamp?Date.parse(p.timestamp):null):p[axis];
const roleLabel={local_baseline:'Local baseline',external_reference:'External reference',frozen_target:'Frozen target'};
function create({getData,getLanguage,openExperiment,narrative=s=>s}) {
const state={workload:'',metric:'',axis:getData().evaluation_mode==='service_reuse'?'order':'round',selected:null};
const data=getData();
const state={workload:'',metric:'',axis:data.sequential_optimization||data.service_optimization?'order':'round',selected:null};
let moreAxesOpen=false;
let roots=[];
const t=s=>{
Expand Down Expand Up @@ -828,7 +829,7 @@ <h2 class="panel-heading" aria-labelledby="chart-title"></h2>
const root=document.getElementById('knowledge-navigation');if(!root)return;
root.replaceChildren();root.classList.add('kt-view');root.setAttribute('data-no-translate','');
const view=getData(),data=view.knowledge_trace||{}, captures=data.retrievals||[],searches=data.searches||[];
const service=view.evaluation_mode==='service_reuse', deliveries=service?view.managed_retrievals||[]:[];
const service=view.sequential_optimization||view.service_optimization, deliveries=service?view.managed_retrievals||[]:[];
const usage=view.round_token_usage||[];
const title=tr('Knowledge trace','知识检索 Trace');
if(navLink){navLink.textContent=title;navLink.hidden=!service&&!captures.length&&!searches.length&&!usage.length;}
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ has its own delivery receipt. A large file returns `next_read_args`; run those
arguments until no continuation remains. Each page records only its returned
bytes, with UTF-8 boundaries preserved. The continuation keeps the same
resource, revision and search reference.
Cite a used read's `reference.path` with `round --knowledge-ref` in an AB/BA
Cite a used read's `reference.path` with `round --knowledge-ref` in a one-shot
project or benchmark. A service-reuse attempt retains prepared contexts
automatically. Record any passage that influenced the candidate in its
hypothesis. If the host clipped an asynchronous round's response, use
Expand All @@ -41,8 +41,8 @@ See [round decisions](knowledge/knowledge-retrieval-trace.md#round-decisions).
| --- | --- | --- | --- |
| Verify whether RSI knowledge improves optimization efficiency | CLI `benchmarks compare`; [comparison workflow](../benchmarks/benchmark-comparison.md) | Local experiment records / explicit native handoff / report-generating | Apps freezes two-task on/off plans, returns host actions, verifies retained finals and reports Benchmark comparisons; no hidden Agent launch |
| Complete a task optimization in the current Agent | CLI `session start benchmark/round/status/final/recover`, `find --session` / `read` | Experiment-executing / local records | Frozen budget, actual candidates and independent task outcomes. The current Agent drives edits. Real usage is imported explicitly. Recovery collects an existing execution using its [pinned runtime](optimization-workflow-unification.md#release-boundary-recovery) |
| Optimize an ordinary project in the current Agent | CLI `session start project/round/status/final/recover`, `find --session` / `read` | Experiment-executing / local records | Harness freezes explicit caller-provided checks, manages multi-file candidates, executes and assesses retained results. This path does not depend on Benchmark or infer acceptance from the goal. See [shared workflow](optimization-workflow-unification.md) |
| Reuse one project service across multi-scenario checks | CLI `session start project --evaluation-mode service_reuse`, then `baseline/round/profile/status/recover/final` | Experiment-executing / local records | Caller supplies protocol and service scripts. An optional profiler can run inline or on a settled round. `resume`, `refresh-references` and explicit retry retain recovery decisions. See [service reuse](service-reuse-campaigns.md) |
| Optimize an ordinary project in the current Agent | CLI `session start project --reference-guard <json>`, then `baseline/diagnose/round/status/final/recover` | Experiment-executing / local records | The default measures A once per reference epoch, then measures candidates in order. Use `--comparison abba` for paired samples. See [shared workflow](optimization-workflow-unification.md) |
| Reuse one project service across multi-scenario checks | CLI `session start project --evaluation-config <json>`, then `baseline/round/profile/status/recover/final` | Experiment-executing / local records | The evaluation config contains the explicit reference guard and service commands. `refresh-references --drift` resets stale references after verified cleanup. See [service reuse](service-reuse-campaigns.md) |
| Prepare and record a fresh native Agent | CLI `agents prepare/dispatch/bind/record/status` | Local records / explicit host handoff | The initiating Agent calls native host tools. Records prevent repeated dispatch; exported host observations do not establish task acceptance. See [native sessions](native-agent-sessions.md) |
| Discover packaged tasks | CLI `benchmarks list [--iterative]` / `benchmarks show`; Python `benchmark.registry.builtin_tasks` / `describe_task` | Read-only | Reads the installed registry and [task manifests](../benchmarks/engineering-benchmarks.md). The optional filter selects task packages with an `optimization.py` file at their root |
| Execute one packaged task | CLI `benchmarks run`; Python `apps.workflows.benchmark_operations.run_task` | Experiment-executing | Application launches the task entry, supplies the execution callback and preserves arguments and exit status. The task owns its device, measurement and assessment protocol |
Expand Down Expand Up @@ -423,7 +423,7 @@ CLI. Update installed plugin bundles to get the matching instructions and runtim
| `knowledge research MODEL`, `find --model MODEL` | Ask each research question with `find QUERY` and follow its read command. Model profiles and inventories are resources of their owning procedure. |
| `context QUERY` | `find QUERY`, then `context --id ID` for each selected package record to export cited Markdown. A filtered export still accepts `context --repo-type REPO --backend BACKEND`. |
| `collect QUERY` or `collect --relevance QUERY` | `find QUERY`, then the selected hit's read command. To assemble a group, use `collect --id REF` with a flag for each selected identity and its revision. |
| `campaign knowledge` or `benchmarks session knowledge` | `find QUERY --session DIR`, then the returned scoped read. AB/BA projects and benchmarks accept its delivery receipt with `round --knowledge-ref`. |
| `campaign knowledge` or `benchmarks session knowledge` | `find QUERY --session DIR`, then the returned scoped read. One-shot projects and benchmarks accept its delivery receipt with `round --knowledge-ref`. |
| `campaign capture-context` with a question | `find QUERY --session DIR`, then the scoped read. Use `collect --archive DIR --capture-id ID --id REF` to retain a known bundle. |
| `cannbot search QUERY` | `find QUERY --backend ascend` with the project grant. Set the upstream cap with `--external-limit N` and use the returned locator for a card read. |
| `mindie query --input FILE` | `find --input FILE` with the same native request and project grant. |
Expand Down
50 changes: 42 additions & 8 deletions docs/guides/optimization-workflow-unification.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CLI `final` 返回后自动生成 `delivery/<export-id>/report.md`、离线 `rep

## 时序图

以下是普通项目默认 AB/BA 模式的完整流程。CLI 将参数转为会话请求,调用 `inferrsi.harness.manager.run_session`。Manager 负责初始化、预算和结算,Executor 执行,Evaluator 判定。CLI 注入 KnowledgeReader 和 `apps/workflows/campaign.py` 的知识捕获回调。`apps/views` 展示结果,`harness/records` 保存记录。
下图以显式 `--comparison abba` 的配对模式为例。CLI 将参数转为会话请求,调用 `inferrsi.harness.manager.run_session`。Manager 负责初始化、预算和结算,Executor 执行,Evaluator 判定。CLI 注入 KnowledgeReader 和 `apps/workflows/campaign.py` 的知识捕获回调。`apps/views` 展示结果,`harness/records` 保存记录。

先准备任务条件,再调用 start。start 内复制任务、脚本和基线并写入计划/状态,不执行测量。Agent 逐次调用 round,最后调用 final 独立重测已保存的最佳版本。

Expand Down Expand Up @@ -161,9 +161,41 @@ Harness 没有常驻 Agent 驱动。Agent 逐次调用这些操作,代码在

## 普通项目怎么接入

普通项目默认使用下面的 AB/BA 流程。需要复用服务时,可显式选择
[service_reuse 模式](service-reuse-campaigns.md),按该协议准备初始 baseline、
多场景指标、同服务质量与 profile 脚本,以及恢复和 final 所需条件。
### Default sequential evaluation

New project sessions measure A once per reference epoch, then measure B, C and
later candidates in submission order. Run `baseline` before `diagnose`. Each
round checks the retained parent and initial A. Only a passing, strictly better
candidate becomes the next parent. Final is a new evaluation of the retained
winner against its recorded acceptance parent and A.

Use one-shot commands for `service_lifetime.scope = "task_protocol"` or
`--evaluation-config` for an [attempt-scoped managed service](service-reuse-campaigns.md).
For one-shot commands, supply an approved `--reference-guard <json>`. Choose a
maximum reference age, completed round limit, or both. An optional short check
measures the frozen baseline, not the candidate. Use the
[Intake procedure](task-intake.md#campaign-hand-off) to approve the policy.
`--cumulative-regression-limit` sets the allowed percentage regression
against A for one-shot campaigns. Its default is zero.

Use `refresh-references --drift --reason <text>` to remeasure A and the parent
after a stale or drifted reference, then record a new diagnosis. A refresh keeps
the remeasured parent as incumbent. Final requires a new candidate to beat it
in the current epoch. Use `--retry-of <attempt-id>` to repeat a failed refresh
or retry a candidate whose short check was unavailable. An unqualified round
keeps its slot on explicit retry or when reused after a reference refresh.
After `resume` abandons an unresolved candidate, a new submission takes the
next logical slot. Use `final --end-search --reason <text>` to close an
unresolved search without overwriting prior final evidence. The close records a
structured `terminal_inconclusive` code and the caller's `stop_reason`.

| Previous selector | New selector |
| --- | --- |
| `--evaluation-mode abba` | `--comparison abba` for paired one-shot samples |
| `--evaluation-mode service_reuse` | `--evaluation-config <json>` with an approved `reference_guard` |

Do not combine old and new selectors. Existing sessions continue under their
frozen plans, and deprecated options warn on stderr.

无需先登记成题库任务。Agent 准备一个协议目录,包含测量、质量脚本以及要固定的输入/配置,再调用 `session start project --help` 按实际项目填写参数。

Expand All @@ -175,6 +207,7 @@ Harness 没有常驻 Agent 驱动。Agent 逐次调用这些操作,代码在
inferrsi session start project --intake <approved-record.json> --directory <campaign-dir-outside-project> \
--repo <editable-project> --include <source-dir> --include <config-file> \
--protocol <acceptance-dir> --instructions <task.md> \
--reference-guard <approved-guard.json> \
--measure-command '"{python}" "{protocol}/measure.py" --project "{candidate}" --result "{result}"' \
--quality-command '"{python}" "{protocol}/quality.py" --project "{candidate}" --reference "{baseline}" --result "{result}"' \
--metric-key <json.field> --metric-unit <unit> --direction <maximize-or-minimize> \
Expand All @@ -187,9 +220,9 @@ inferrsi session start project --intake <approved-record.json> --directory <camp

`{candidate}` 在基线步骤指向留存基线,在候选步骤指向本轮快照;`{baseline}` 始终是基线。`{protocol}` 指向冻结协议,`{result}` 是本步骤输出文件。脚本需从这些路径读取项目和条件;已有 editable 安装、绝对导入或外部服务不会被自动改成候选版本。Agent 必须验证脚本确实测到指定版本。

项目适配器先检查基线和候选质量,再做 warmup 和交替顺序的基线/候选测量;每轮和 final 使用相同协议。每步骤启动新进程,因此跨进程 warmup 只能预热可持久缓存;设备/进程内 warmup 必须在测量脚本内完成并说明。性能取声明指标的中位数,当前没有通用服务生命周期管理器或统计显著性判定。
默认顺序模式每次尝试只运行一个版本的质量检查、warmup 和正式测量。需要同期配对时,将示例中的 `--reference-guard` 替换为 `--comparison abba`,适配器会交替运行基线和候选。两种一次性命令路径均在每步启动新进程,因此跨进程 warmup 只能预热可持久缓存。设备/进程内 warmup 必须由测量脚本完成并说明。性能取声明指标的中位数。

assessment 另附 `paired_statistics`:同一次重复内的第 k 个基线与第 k 个候选样本按顺序配对,计算逐对加速比的中位数及其 95% 精确次序统计量区间(即符号检验反演),并给出区间与冻结门槛的关系(`above_gate`、`straddles_gate`、`below_gate`;门槛没有有限加速比时为 `gate_unreachable`;对数不足时为 `insufficient_pairs`;样本或派生值无效为 `unavailable`)。`agrees_with_point_gate` 标出中位数点估计的判定与配对区间是否一致。默认只报告,不改变 verdict、eligible 或选优,记录 `report_only: true`,`statistical_significance` 仍为 `not_established`;只有 `--decision paired` 用它判定,此时记录 `report_only: false`。
AB/BA assessment 另附 `paired_statistics`:同一次重复内的第 k 个基线与第 k 个候选样本按顺序配对,计算逐对加速比的中位数及其 95% 精确次序统计量区间(即符号检验反演),并给出区间与冻结门槛的关系(`above_gate`、`straddles_gate`、`below_gate`;门槛没有有限加速比时为 `gate_unreachable`;对数不足时为 `insufficient_pairs`;样本或派生值无效为 `unavailable`)。`agrees_with_point_gate` 标出中位数点估计的判定与配对区间是否一致。默认只报告,不改变 verdict、eligible 或选优,记录 `report_only: true`,`statistical_significance` 仍为 `not_established`;只有 `--decision paired` 用它判定,此时记录 `report_only: false`。

区间取逐对加速比排序后的第 j 小与第 j 大,j 是使 P(Bin(n, 1/2) ≤ j−1) ≤ 2.5% 的最大秩,并记录 `order_statistic_rank` 和实际置信度 `achieved_confidence`。当各对独立、来自连续分布时,下界高于真实中位数的概率不超过 2.5%,与重复次数无关;因此真实中位加速比恰好等于门槛时(门槛为 0% 即 A/A),`above_gate` 的概率不超过 2.5%。5 对时最极端的一对也有 1/32 ≈ 3.1% 的单侧误差,所以至少需要 6 对才给区间。区间假设各次重复独立,不能消除同一对内共同的设备争用,也不构成环境资格。合成对照可用 `python tools/measurement_simulation.py` 复算,`--gate-pct 0` 给出门槛处的 A/A 比例与精确上界 `exact_one_sided_bound`。

Expand All @@ -204,6 +237,7 @@ assessment 另附 `paired_statistics`:同一次重复内的第 k 个基线与
准备后,Agent 在当前会话循环:

```bash
inferrsi session baseline --directory <campaign-dir>
inferrsi session diagnose --directory <campaign-dir> --bottleneck '<observed-bottleneck>' --evidence <measurement-summary.txt>
inferrsi find '<current-question>' --session <campaign-dir>
# 运行所选命中返回的 read 命令,取得正文和读取凭据。
Expand All @@ -218,7 +252,7 @@ inferrsi dashboard --input <campaign-dir> --output <report.html>
Harness 将证据优先的顺序默认写入新会话计划,适用于知识开启和关闭。Agent 先用同条件的
profile 或测量确定瓶颈,提交包含 workload 和观测值的 UTF-8 摘要,再按需检索和
提交候选。Harness 保留摘要,并把检索和候选轮次关联到诊断记录。已有记录可以
继续使用,瓶颈变化时重新运行 `diagnose`。service-reuse 的 reference epoch 改变后
继续使用,瓶颈变化时重新运行 `diagnose`。顺序评测的 reference epoch 改变后
需要记录新诊断。已有会话按其冻结计划继续。

每次主动查询都有独立的请求 ID。相同交付再次返回时只登记一次。Manager 在会话锁内
Expand Down Expand Up @@ -262,7 +296,7 @@ assessment 的 `profile_evidence` 按重复配对比较每个区域和计数,`

两个开关同时打开时按固定顺序判定:先由 `--decision` 得到性能结论,`--require-explanation` 只作用于性能结论为 PASS 的轮次,把它降为 FAIL 或 INCONCLUSIVE,不会提升或改写非 PASS 的结论。因此性能结论已是 FAIL 或 INCONCLUSIVE(包括 `within_noise`)时,无论 `explanation.status` 是什么,最终 verdict 和 `reason` 都保持性能结论;`explanation` 仍完整写入报告。

两个开关和 `--mechanism-file` 只适用于默认的 AB/BA 评估:`--evaluation-mode service_reuse` 不产生这些开关读取的 AB/BA 逐对样本和逐次测量的 `breakdown`/`counters`(它可选的 profiling 阶段,包括 `session profile` 补采,产生的是 profiler 回执和产物,不是这些开关的输入),因此该模式下 `session start project` 拒绝这两个开关,`session round` 拒绝 `--mechanism-file`,不会悄悄忽略。
两个开关和 `--mechanism-file` 只适用于显式 `--comparison abba`。顺序评测不产生 AB/BA 逐对样本,不接受这些参数。受管服务可选的 profiling 阶段和 `session profile` 补采保留 profiler 回执与产物,不能替代同期配对证据。

提交未修改的候选可以作为 A/A 对照,`paired_statistics` 的区间即给出该环境的噪声范围;`--require-explanation` 下的 A/A 轮次在声明的变化项上应为 `not_shown`。

Expand Down
Loading
Loading