bound
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBOUND
BOUND
Use BOUND after meaningful execution steps to decide whether the agent should
continue, retry, replan, or roll back. BOUND evaluates completed work; it does
not decide what code to write.
在完成有意义的执行步骤后使用BOUND,以此决定Agent应继续、重试、重新规划还是回滚。BOUND用于评估已完成的工作,不负责决定编写何种代码。
Agent integration types
Agent集成类型
All BOUND agent integrations are instruction-only — they are prompts that
the agent reads and follows. There are no enforced integrations (no
programmatic hooks into the agent's event system, MCP servers, rules, or
lifecycle events). Every integration relies on the agent to voluntarily
follow the instructions and act on BOUND's decisions.
| Agent | File | Type | Mechanism |
|---|---|---|---|
| Cline | | Instruction-only | Prompt-based; agent follows instructions |
| Codex | | Instruction-only | Prompt-based; agent follows instructions |
| Claude Code | | Instruction-only | Prompt-based; agent follows instructions |
| Hermes Agent | | Instruction-only | Prompt-based; agent follows instructions |
| Kilo Code | | Instruction-only | Prompt-based; agent follows instructions |
| Generic | | Instruction-only | Prompt-based; any agent follows instructions |
Key distinction: Instruction-only integrations describe the BOUND control
loop and instruct the agent to manually call BOUND's CLI or Python API at
each boundary. The agent is responsible for acting on the decision — BOUND
does not enforce the action. Enforced integrations (future) would hook into
the agent's event system to intercept decisions before they reach the agent.
所有BOUND Agent集成均为仅指令型——即供Agent阅读并遵循的提示词。不存在强制集成(无针对Agent事件系统、MCP服务器、规则或生命周期事件的编程钩子)。所有集成均依赖Agent自愿遵循指令并根据BOUND的决策采取行动。
| Agent | 文件 | 类型 | 机制 |
|---|---|---|---|
| Cline | | 仅指令型 | 基于提示词;Agent遵循指令 |
| Codex | | 仅指令型 | 基于提示词;Agent遵循指令 |
| Claude Code | | 仅指令型 | 基于提示词;Agent遵循指令 |
| Hermes Agent | | 仅指令型 | 基于提示词;Agent遵循指令 |
| Kilo Code | | 仅指令型 | 基于提示词;Agent遵循指令 |
| Generic | | 仅指令型 | 基于提示词;任意Agent均可遵循指令 |
核心区别:仅指令型集成描述BOUND控制循环,并指示Agent在每个边界手动调用BOUND的CLI或Python API。Agent负责执行决策——BOUND不会强制行动。未来的强制集成将接入Agent的事件系统,在决策传递给Agent之前进行拦截。
Inspect before integrating
集成前检查
-
Install the latest stable package into the project's environment:bash
pip install bound-policy -
Inspect the installed API instead of relying on remembered signatures:bash
python -c "import bound; print(bound.__version__); print(bound.__all__)" bound integration-spec -
Confirm the project's real test, lint, type-check, and build commands.
-
Inspect the agent's actual hooks, modes, instructions, commands, task boundaries, telemetry, and checkpoint support. Do not invent a native BOUND integration or an undocumented framework mechanism.
-
Find existing,
INTEGRATION.md,INTEGRATION_REPORT.md, andPLAN.mdfiles. Treat recorded results as claims to reproduce, not authoritative evidence.bound_integration/
-
将最新稳定包安装到项目环境中:bash
pip install bound-policy -
检查已安装的API,而非依赖记忆中的签名:bash
python -c "import bound; print(bound.__version__); print(bound.__all__)" bound integration-spec -
确认项目真实的测试、代码检查、类型检查和构建命令。
-
检查Agent实际的钩子、模式、指令、命令、任务边界、遥测和 checkpoint 支持。不要虚构原生BOUND集成或未文档化的框架机制。
-
查找现有的、
INTEGRATION.md、INTEGRATION_REPORT.md和PLAN.md文件。将记录的结果视为需要复现的声明,而非权威证据。bound_integration/
Establish execution lineage
建立执行谱系
For multi-step work, maintain at the repository root. A small
one-step task may use an inline plan. Give each meaningful phase a stable id
and define its goal, observable acceptance checks, risk checks, verification
commands, budget, expected artifacts, owner, and dependencies where relevant.
PLAN.mdMaintain this lineage:
text
intent -> plan phase -> StepContract -> execution -> ExecutionEvidence
-> BOUND evaluation -> control action -> integration reportPreserve a phase after execution. When the strategy changes materially, create
a derived id such as ; do not rewrite history to hide a replan.
PHASE-002-R1对于多步骤工作,在仓库根目录维护。小型单步骤任务可使用内联计划。为每个有意义的阶段分配稳定ID,并定义其目标、可观察的验收检查、风险检查、验证命令、预算、预期产物、负责人及相关依赖项(如有)。
PLAN.md维护以下谱系:
text
意图 -> 计划阶段 -> StepContract -> 执行 -> ExecutionEvidence
-> BOUND评估 -> 控制行动 -> 集成报告执行后保留阶段信息。当策略发生重大变化时,创建衍生ID(如);不要重写历史以隐藏重新规划的操作。
PHASE-002-R1Choose meaningful boundaries
选择有意义的边界
Call BOUND after implementation plus verification, after a focused retry, and
before deciding to keep refining the same objective. Do not call it after each
token, file read, shell command, or low-level tool call.
Each boundary must have observable completion criteria. Combine or redefine a
step when no meaningful success or risk signal can be observed.
在实现加验证后、聚焦重试后,以及决定是否继续优化同一目标前调用BOUND。不要在每个token、文件读取、shell命令或低级工具调用后调用它。
每个边界必须具备可观察的完成标准。当无法观察到有意义的成功或风险信号时,合并或重新定义步骤。
Report the proposal before modifying the project
修改项目前提交方案报告
Record these headings before implementation:
text
Integration point:
Step boundary:
Available evidence:
Missing evidence:
Control-flow mapping:
Files to modify:List exact verification commands and the small, removable set of integration
files. Represent unavailable metrics as unavailable rather than estimating
them.
在实现前记录以下标题内容:
text
集成点:
步骤边界:
可用证据:
缺失证据:
控制流映射:
待修改文件:列出确切的验证命令和少量可移除的集成文件。将不可用的指标标记为不可用,而非估算。
Build contracts and evidence
构建合约与证据
Map each phase to a with at least one , optional
s, expected artifacts, and a . Collect
only from observations made during the run: command exit
codes, check results, changed artifacts, retries, tool calls, tokens, runtime,
and rollback availability when exposed.
StepContractAcceptanceCheckRiskCheckStepBudgetExecutionEvidenceKeep values aligned between contract and evidence. Missing evidence
for a required check is not a pass. Distinguish an unset budget (), an
unavailable measurement, and an observed zero.
check_idNonePrefer the installed helper when its inspected API
provides it. Otherwise call and use exactly:
evaluate_agent_step(...)BoundWorkflow.evaluate_step(...)text
ACCEPT -> continue
RETRY -> retry
REPLAN -> replan
ROLLBACK -> rollbackNever add a fifth action or reproduce BOUND's scoring and decision formula.
将每个阶段映射到一个,其中至少包含一个、可选的、预期产物和。仅收集运行期间观察到的:命令退出码、检查结果、变更的产物、重试记录、工具调用、token数、运行时,以及暴露的回滚可用性。
StepContractAcceptanceCheckRiskCheckStepBudgetExecutionEvidence保持合约与证据中的值一致。必填检查的缺失证据不算通过。区分未设置的预算()、不可用的测量值和观察到的零值。
check_idNone如果已安装的辅助函数可用,则优先使用。否则调用并严格使用以下映射:
evaluate_agent_step(...)BoundWorkflow.evaluate_step(...)text
ACCEPT -> 继续
RETRY -> 重试
REPLAN -> 重新规划
ROLLBACK -> 回滚绝不要添加第五种操作,也不要复现BOUND的评分和决策公式。
Verified evidence & provenance (v0.7.0)
已验证证据与来源(v0.7.0)
BOUND v0.7.0 separates who reports evidence from who verifies it. The agent
is a participant, not the judge.
-
Define the contract upfront, including provenance requirements. Each/
AcceptanceCheckmay declareRiskCheck(which trust provenances it accepts),accepted_provenance,on_missing, and — for risk checks —on_claimed(missing/claimed evidence then forcesdecision_criticalassurance and blocks a cleanINSUFFICIENT).ACCEPT -
Configure allowed collectors; BOUND performs objective verification. Use the BOUND collectors (,
PytestCollector,GitCollector,JUnitCollector,BudgetCollector,ProcessRuntimeCollector, plus nativeCommandCollector,RuffEvidence,MypyEvidence) to execute verification BOUND controls. They recordCoverageEvidenceaudit events withevidence.collected/VERIFIEDprovenance, a collector name/version, artefact hash and a timezone-aware timestamp. A collector crash or stale artefact is recorded honestly (OBSERVED/evidence.collection_failed), never a verified pass.INVALID -
The agent CANNOT assignprovenance. Agent self-report is always
VERIFIED, neverCLAIMED/VERIFIED. The agent must not override or suppress a collector result.OBSERVEDmeans "not collected" — never silentlyMISSING;0on a telemetry metric is missing, not a measured zero.None -
Subjective criteria use a separate evaluator (). Criteria that cannot be independently re-run (e.g. UX quality) are
EVALUATED— honest but neverEVALUATED.VERIFIED -
BOUND logs what the agent reports; the agent executes control actions. BOUND records(
action.reported); an independent hook may addreported_provenance=CLAIMEDto confirm it. The agent executes control actions. BOUND is a thin harness: it emitsobserved_actionand may independently verify the resulting state. It can roll back the workspace with explicitROLLBACKagainst a previously confirmed checkpoint, but never without explicit opt-in.bound rollback --execute -
Assurance gates the candidate decision. BOUND computes a(
DecisionAssurance/VERIFIED/MIXED/CLAIMED) from the decision-critical checks' provenance. A candidateINSUFFICIENTbacked only byACCEPT/CLAIMEDcritical evidence is downgraded to the contract'sMISSING/on_missingaction. Inspect it:on_claimedbashbound inspect <run_id> # per-check provenance + candidate vs final + assurance + coverage bound inspect <run_id> --only-unverified # only unverified/claimed/missing/invalid evidence bound inspect <run_id> --json # machine-readable: provenance + assurance + coverage
BOUND v0.7.0区分了报告证据的主体和验证证据的主体。Agent是参与者,而非裁判。
-
**提前定义合约,包括来源要求。**每个/
AcceptanceCheck可声明RiskCheck(接受的信任来源)、accepted_provenance、on_missing,以及针对风险检查的on_claimed(缺失/声明的证据会导致decision_critical保证,并阻止干净的INSUFFICIENT决策)。ACCEPT -
**配置允许的收集器;BOUND执行客观验证。**使用BOUND收集器(、
PytestCollector、GitCollector、JUnitCollector、BudgetCollector、ProcessRuntimeCollector,以及原生的CommandCollector、RuffEvidence、MypyEvidence)执行BOUND控制的验证。它们会记录带有CoverageEvidence/VERIFIED来源、收集器名称/版本、产物哈希和时区感知时间戳的OBSERVED审计事件。收集器崩溃或过期产物会被如实记录(evidence.collected/evidence.collection_failed),绝不会被标记为已验证通过。INVALID -
**Agent无法分配来源。**Agent的自我报告始终为
VERIFIED,而非CLAIMED/VERIFIED。Agent不得覆盖或抑制收集器的结果。OBSERVED表示“未收集”——绝不要默认为MISSING;遥测指标中的0表示缺失,而非测量得到的零值。None -
**主观标准使用独立评估器()。**无法独立重新运行的标准(如UX质量)标记为
EVALUATED——诚实但绝非EVALUATED。VERIFIED -
**BOUND记录Agent报告的内容;Agent执行控制行动。**BOUND记录(
action.reported);独立钩子可添加reported_provenance=CLAIMED以确认行动。**Agent负责执行控制行动。**BOUND是一个轻量框架:它发出observed_action指令,并可独立验证最终状态。它可以通过显式的ROLLBACK命令针对先前确认的checkpoint回滚工作区,但绝不会在无显式 opt-in 的情况下执行。bound rollback --execute -
**保证机制约束候选决策。**BOUND从决策关键检查的来源计算(
DecisionAssurance/VERIFIED/MIXED/CLAIMED)。仅由INSUFFICIENT/CLAIMED关键证据支持的候选MISSING决策会降级为合约中ACCEPT/on_missing指定的行动。可通过以下命令检查:on_claimedbashbound inspect <run_id> # 按检查项展示来源 + 候选vs最终决策 + 保证级别 + 覆盖范围 bound inspect <run_id> --only-unverified # 仅展示未验证/声明/缺失/无效的证据 bound inspect <run_id> --json # 机器可读格式:来源 + 保证级别 + 覆盖范围
Persist the numeric evaluation
持久化数值评估结果
For every evaluation, read the numbers from the returned BOUND object and emit:
text
BOUND evaluation
Acceptance (A): <4 decimals>
Influence (I): <4 decimals>
Risk (R): <4 decimals>
Cost (C): <4 decimals>
Score (S): <4 decimals>
Threshold (T): <4 decimals>
Decision: <ACCEPT|RETRY|REPLAN|ROLLBACK>
Next action: <continue|retry|replan|rollback>Also persist exposed weights, weighted components, retry margin,
rollback-risk threshold, and score provenance. Read
for the required report structure.
references/integration-report.md每次评估时,从返回的BOUND对象中读取数值并输出:
text
BOUND评估结果
验收值 (A): <保留4位小数>
影响值 (I): <保留4位小数>
风险值 (R): <保留4位小数>
成本值 (C): <保留4位小数>
评分 (S): <保留4位小数>
阈值 (T): <保留4位小数>
决策: <ACCEPT|RETRY|REPLAN|ROLLBACK>
下一步行动: <继续|重试|重新规划|回滚>同时持久化暴露的权重、加权组件、重试余量、回滚风险阈值和评分来源。参考获取所需的报告结构。
references/integration-report.mdValidate earlier scores
验证历史评分
When an earlier integration record exists, compare its contract, evidence,
criteria, budgets, scores, decision, and action with the current run. When its
inputs are complete, reconstruct them and call BOUND again. Compare returned
A/I/R/C/S/T, decision, and action with the record.
- Mark incomplete historical results and list missing data.
not reproducible - Mark evaluations when evidence or configuration changed.
stale - Append a new evaluation instead of silently overwriting history.
- Treat a mismatch as a failed consistency check and investigate it before continuing.
- Do not independently implement the formula as a second evaluator.
当存在早期集成记录时,将其合约、证据、标准、预算、评分、决策和行动与当前运行结果进行比较。当历史输入完整时,重构输入并再次调用BOUND。将返回的A/I/R/C/S/T、决策和行动与记录进行对比。
- 将不完整的历史结果标记为,并列出缺失的数据。
不可复现 - 当证据或配置发生变化时,将评估结果标记为。
过期 - 添加新的评估结果,而非静默覆盖历史记录。
- 将不匹配视为一致性检查失败,在继续前进行调查。
- 不要独立实现公式作为第二个评估器。
React to the result
响应评估结果
- : stop refining this phase and continue.
ACCEPT - : preserve the strategy, make one focused correction, collect fresh evidence, and re-evaluate within the budget.
RETRY - : stop the current strategy, choose a materially different approach, and create a derived contract id.
REPLAN - : restore only a previously confirmed safe checkpoint without discarding unrelated or pre-existing changes, then replan. If no safe checkpoint exists, report that and avoid a destructive approximation.
ROLLBACK
- :停止优化当前阶段并继续。
ACCEPT - :保留当前策略,进行一次聚焦修正,收集新证据,并在预算内重新评估。
RETRY - :停止当前策略,选择差异显著的方法,并创建衍生合约ID。
REPLAN - :仅恢复先前确认的安全checkpoint,不丢弃无关或预先存在的变更,然后重新规划。如果没有安全checkpoint,需如实报告,避免破坏性的近似操作。
ROLLBACK
Record decision lineage (v0.7.0)
记录决策谱系(v0.7.0)
BOUND v0.7.0 can record every evaluation as a reproducible, append-only local
lineage — — under
. It is opt-in per run and backwards compatible: if
you never start a run, nothing is recorded. Disable it with
.
contract → evidence → scores → decision → agent outcome.bound/runs/<run_id>/BOUND_LINEAGE_DISABLED=1For any non-trivial task you evaluate with BOUND, follow these rules:
-
Start ONE run per task.bash
bound run start "<task>" --metadata phase=PHASE-001(In Python:.)with bound.start_run("<task>") as run: -
Use STABLE step/contract ids. Carry the same id from→
PLAN.md→ lineage. A replan of the same step appendsStepContract(id=...)(-R<N>→PHASE-001); never invent an unrelated id or rewrite history to hide a replan.PHASE-001-R1 -
Evaluate only MEANINGFUL boundaries (after implementation + verification, not after every token/file/command), and record the evaluation into the run:bash
bound evaluate --run <run_id> --step PHASE-001 --attempt 1 \ --action "..." --goal "..." \ --acceptance A --influence I --risk R --cost C \ --threshold 0.7 --retry-margin 0.1This writes+step_startedand adds aevaluation_recordedblock to the JSON.lineage -
Record the REAL follow-up action you actually took — not what BOUND "should" have produced:bash
bound outcome --run <run_id> --step PHASE-001 --attempt 1 \ --decision REPLAN --note "switched strategy to validator + parametrized tests"and--next-actionare derived from--reason-code(--decision) when omitted.ACCEPT|RETRY|REPLAN|ROLLBACK -
Explicitly CLOSE the run when the task ends:bash
bound run finish <run_id> --status completed|interrupted|failed --note "..."A missingmarks an incomplete/crashed run (the log stays readable). If you usedrun_finishedthe context manager auto-finishes an interrupted run on exit.with bound.start_run(...) -
REPORT the local lineage path —(
.bound/runs/<run_id>/+ the append-onlyrun.json) — and show the decision tree:events.jsonlbashbound inspect <run_id>
The canonical flow is one run, two attempts:
text
Attempt 1 → evidence 1/3 (A=0.3333) → REPLAN → switch strategy
(new step PHASE-001-R1, attempt 2)
Attempt 2 → evidence 3/3 (A=1.0000) → ACCEPT → continue to next stepThe event log is append-only: a replan emits a new with
and a -suffixed contract id; earlier attempts are never
rewritten. Prompts, tokens, and source code are never stored — only the
contract id, scores, threshold, decision, reason code, and your follow-up
action/note. See for the full data model and API.
step_startedattempt+1-R<N>docs/lineage.mdBOUND v0.7.0可将每次评估记录为可复现、仅追加的本地谱系————存储在下。此功能按运行 opt-in且向后兼容:如果从未启动运行,则不会记录任何内容。可通过禁用。
合约 → 证据 → 评分 → 决策 → Agent结果.bound/runs/<run_id>/BOUND_LINEAGE_DISABLED=1对于使用BOUND评估的任何非 trivial 任务,请遵循以下规则:
-
每个任务启动一次运行。bash
bound run start "<任务>" --metadata phase=PHASE-001Python中使用:。with bound.start_run("<任务>") as run: -
**使用稳定的步骤/合约ID。**将同一ID从传递到
PLAN.md再到谱系。同一步骤的重新规划需追加StepContract(id=...)(如-R<N>→PHASE-001);绝不要使用无关ID或重写历史以隐藏重新规划操作。PHASE-001-R1 -
仅评估有意义的边界(在实现+验证后,而非每个token/文件/命令后),并将评估结果记录到运行中:bash
bound evaluate --run <run_id> --step PHASE-001 --attempt 1 \ --action "..." --goal "..." \ --acceptance A --influence I --risk R --cost C \ --threshold 0.7 --retry-margin 0.1此命令会写入+step_started事件,并向JSON中添加evaluation_recorded块。lineage -
记录实际执行的后续行动——而非BOUND“应该”生成的行动:bash
bound outcome --run <run_id> --step PHASE-001 --attempt 1 \ --decision REPLAN --note "切换策略为验证器+参数化测试"当省略和--next-action时,会从--reason-code(--decision)推导得出。ACCEPT|RETRY|REPLAN|ROLLBACK -
任务结束时显式关闭运行:bash
bound run finish <run_id> --status completed|interrupted|failed --note "..."缺失事件会标记运行为不完整/崩溃状态(日志仍可读)。如果使用run_finished,上下文管理器会在退出时自动完成中断的运行。with bound.start_run(...) -
报告本地谱系路径——(包含
.bound/runs/<run_id>/和仅追加的run.json),并展示决策树:events.jsonlbashbound inspect <run_id>
标准流程为一次运行、两次尝试:
text
尝试1 → 证据1/3(A=0.3333) → REPLAN → 切换策略
(新步骤PHASE-001-R1,尝试2)
尝试2 → 证据3/3(A=1.0000) → ACCEPT → 继续到下一步事件日志为仅追加模式:重新规划会发出一个带有和后缀合约ID的新事件;早期尝试绝不会被重写。提示词、token和源代码绝不会被存储——仅存储合约ID、评分、阈值、决策、原因代码和后续行动/备注。完整数据模型和API请参考。
attempt+1-R<N>step_starteddocs/lineage.mdVerify the integration
验证集成
Add an end-to-end test that builds a real contract, collects real observed
evidence, calls BOUND, asserts one of the four decisions, and asserts the exact
control-flow mapping. Do not hardcode unless the evidence genuinely
satisfies the contract.
ACCEPTKeep all wiring thin and outside in consumer repositories. Never
fabricate evidence, duplicate policy logic, or use an LLM as the final judge.
src/bound/添加端到端测试,构建真实合约、收集真实观察证据、调用BOUND、断言四个决策之一,并断言精确的控制流映射。除非证据真正满足合约要求,否则不要硬编码。
ACCEPT在消费者仓库中,保持所有连接逻辑轻量且位于外部。绝不要伪造证据、重复策略逻辑或使用LLM作为最终裁判。
src/bound/