diff --git a/apps/presentation/dashboard/src/data/workspace-progressive-status.ts b/apps/presentation/dashboard/src/data/workspace-progressive-status.ts index 4378a86d4e..7264bc259b 100644 --- a/apps/presentation/dashboard/src/data/workspace-progressive-status.ts +++ b/apps/presentation/dashboard/src/data/workspace-progressive-status.ts @@ -50,10 +50,9 @@ export function scopeWorkspaceDirectory( /** * Snapshots a same-source read may keep visible while it reconciles. * A directory entry is the cheap authoritative signal for "this Goal's - * lifecycle did not move here". - * A partial retry or known action may - * skip unaffected peers. Touched Goals and entries that moved or left the - * directory lose their snapshot. + * lifecycle did not move here". A full refresh still re-reads retained Goals; + * a partial retry or known action may skip unaffected peers. Touched Goals and + * entries that moved or left the directory lose their snapshot. */ export function reusableGoalSnapshots( previous: Pick | null, diff --git a/docs/book/chapters/06-codex-app.md b/docs/book/chapters/06-codex-app.md index 683c5a322b..77892eaf00 100644 --- a/docs/book/chapters/06-codex-app.md +++ b/docs/book/chapters/06-codex-app.md @@ -175,7 +175,7 @@ writeback 和 spend 历史。 **边界一:heartbeat 不创造 frontier。** 一个没有 Todo 的 Goal 不会因为被频繁唤醒而出现下一步。 App 能保证有人看,不能保证有东西可做;没有可运行候选时就该进入 wait 或 monitor,让 cadence 放慢。 -不要在 automation prompt 里复制 quota 状态机,也不要让 +**边界二:automation 不是第二控制面。** 不要在 automation prompt 里复制 quota 状态机,也不要让 它自己解析 Todo 是否 runnable。稳定 prompt 只负责协议,判断属于每次读到的 packet。 **边界三:切换 Host 要核对工作归属。** App 和 CLI 可以读同一 Goal;切换前应查清旧实例是否仍执行、claim/lease 由谁持有,以及当前 writer 的围栏模式。需要显式移交时走对应 lifecycle,不能仅凭新 Host 已启动就并发推进同一项工作。 @@ -231,13 +231,13 @@ Gate 而不重复同样的安静轮询;若 Host cadence 更新失败而留下 ## 不变式 -1. 判断真实性看 writeback 与 spend,不看触发次数。 +1. **heartbeat 触发不等于工作发生。** 判断真实性看 writeback 与 spend,不看触发次数。 2. **每次唤醒都过一次 `quota should-run`。** 没有这层 Gate,automation 就变成绕过决策的旁路。 3. **`should_run=false` 是合法结果,但它只关闭这一个 Turn。** 已结算回放保留当前 cadence,用新的 Turn identity 重新评估;`false` 的次数或本 Turn 的 receipt 都不能当作放慢 cadence 的依据。需要 放慢时,由当前 `scheduler_hint` 提出(`apply_needed=true`),再走第 4 条的四步。 4. **cadence 变化的四步缺一不可**:proposal、host apply、host readback、ACK。 -5. 只有 Host readback 与目标一致才闭合,不一致时按 +5. **本地 ACK ledger 不证明 Host 状态。** 只有 Host readback 与目标一致才闭合,不一致时按 `drift_detected` 修复。 6. **切换 Host 需要明确接管。** 同一 Goal 可被多处读取,写入仍须满足当前 authority、claim/lease 与围栏要求。 diff --git a/docs/book/chapters/08-extension-placement.md b/docs/book/chapters/08-extension-placement.md index be49ecf5e6..6237ec0f13 100644 --- a/docs/book/chapters/08-extension-placement.md +++ b/docs/book/chapters/08-extension-placement.md @@ -367,7 +367,7 @@ multi-agent preset、Provider 或 presentation 的组合,继续阅读 resolver 和 domain policy,它就不该出现在 catalog 里。 2. **capability 与 extension 是两个维度,一次改动可以只落在其中一个上。** 看到新 package 就直接推断新 capability,是放置错误最常见的形式。 -3. 判据是独立调用合同与生命周期,而非文件数量。 +3. **共享代码并不构成升级成 capability 的理由。** 判据是独立调用合同与生命周期,而非文件数量。 4. **manifest 可发现并不等于合同可调用。** `[[provides]]` 与 `[[implements]]` 只有在真实入口、 resolver 和 validation 就位后才应写入。 5. **Extension 的独立生命周期是用户可见的成本。** 声明它之前先确认这份成本换来了 caller diff --git a/docs/book/chapters/core-state-machines.md b/docs/book/chapters/core-state-machines.md index cd4fc34fc8..4c1ae061db 100644 --- a/docs/book/chapters/core-state-machines.md +++ b/docs/book/chapters/core-state-machines.md @@ -750,7 +750,7 @@ owner、协议 schema、characterization fixture 和 migration boundary。 **失败三:投影被当成事实源。** dashboard 上改一个 row 让显示正确,source 没变。症状是 UI 与 CLI 长期不一致,而每次刷新都回到旧值。恢复方式是修 source 或 builder,再 readback。 -Goal `stopped`、quota paused 或 peer coordination blocked +**失败四:停止的理由并不等于闭环。** Goal `stopped`、quota paused 或 peer coordination blocked 都可能停止轮询,它们各自是合法停止。只有 `terminal_no_followup` 表达 "因已验证 Goal closure 而停止"。把这几者混作一谈,会让一个被暂停的 Goal 看起来像已完成。 @@ -765,7 +765,7 @@ Goal `stopped`、quota paused 或 peer coordination blocked 处理拒绝结果。 5. **终局是合取。** 完整且闭合的 Todo source、没有未解决 frontier、结构化 `no_followup` intent,三者同时成立才算闭环。 -6. 改规则先确认 typed owner、协议 schema、characterization +6. **教学地图不等于实现规格。** 改规则先确认 typed owner、协议 schema、characterization fixture 和 migration boundary。 这六条回答的是同一个问题:**当机制被拆到九组机器、又只能通过持久事实互相说话时,凭什么 diff --git a/docs/book/chapters/source-protocol-map.md b/docs/book/chapters/source-protocol-map.md index 8f7aef9126..364e0423d9 100644 --- a/docs/book/chapters/source-protocol-map.md +++ b/docs/book/chapters/source-protocol-map.md @@ -461,7 +461,7 @@ grep -rln "required_decision_scopes" loopx/control_plane/todos/ | head 1. **一条规则的所有者是决定合法转换的模块。** 如果无法指出被保护的不变量,这次改动还没有定位到位。 2. **PR 描述里必须有一条完整的因果链:source、invariant、decision、projection 或 effect、receipt、validation。** 只能列出函数名的切片无法被评审。 3. **文档描述责任归属,代码描述当前行为。** 两者冲突时,按冲突类型选择权威,并让这次 PR 把另一方更新掉。 -4. 注册与真实 caller contract 才是发布判据,用 `loopx capability list --format json` 核对。 +4. **`loopx/capabilities//` 下有代码,不证明该 Capability 已经发布。** 注册与真实 caller contract 才是发布判据,用 `loopx capability list --format json` 核对。 5. **placement 先于实现。** capability id、provider id 与 built-in/extension-delivered 的选择,必须在写第一行代码之前写下理由。 6. **任务来自公开入口。** 公开的 Contributor Task、Issue 和 fixture 是可参与工作的唯一来源,live active state 与 maintainer-local 判断都不算。 diff --git a/docs/book/chapters/source-trace-protocol-chain.md b/docs/book/chapters/source-trace-protocol-chain.md index 39fa67963b..4113d87754 100644 --- a/docs/book/chapters/source-trace-protocol-chain.md +++ b/docs/book/chapters/source-trace-protocol-chain.md @@ -485,7 +485,7 @@ grep -rn "or \[\]\|or ()\|or {}\|\.get(.*, \[\])\|\.get(.*, {})" loopx/control_p 追踪结束后,下面几条应该能独立成立: 1. **每个被改名或改语义的字段,都要能列出全部消费者。** 只改生产者不算完成,缺失字段的回退值算一次消费者。 -2. 判断依据是第一处违反不变量的边界,而非最终返回值。 +2. **链上每一层返回成功,不构成链路正确的证据。** 判断依据是第一处违反不变量的边界,而非最终返回值。 3. **缺失字段的默认值会参与判定。** 因此必须明确写出它是 reject、repair 还是 compatibility fallback。 4. **authority 只有一份 canonical 来源。** 多处可以读同一个字段,只有一处拥有它;读取方被误当成 owner 是跨层变更最常见的解释残留。 5. **判断 authority 时以协议文档为准,判断当前行为时以源码为准。** 两者冲突时按冲突类型选权威,并让同一次改动把另一方更新掉。 diff --git a/docs/book/chapters/source-validation-to-pr.md b/docs/book/chapters/source-validation-to-pr.md index 847dbcfaf1..8c5eaa4829 100644 --- a/docs/book/chapters/source-validation-to-pr.md +++ b/docs/book/chapters/source-validation-to-pr.md @@ -34,7 +34,7 @@ public/private scan;完整公开 smoke fleet 是另一回事。更慢的是真 authority 的改动需要一个一次性隔离实例,跑完整套件是分钟到十几分钟量级。每个 PR 都等最宽矩阵, 代价会摊到所有贡献者身上。 -一百个命令如果都落在同一层,结论仍然只有一层。开头情境中的检查覆盖的是内存中的规则与静态约束,仍需补充受影响后端的证据。 +**跑得多不等于覆盖对。** 一百个命令如果都落在同一层,结论仍然只有一层。开头情境中的检查覆盖的是内存中的规则与静态约束,仍需补充受影响后端的证据。 **有些结论需要人工判断。** 自动检查可以提示默认行为变化是否有说明,但披露是否准确、证据是否覆盖真实影响,仍需要 review。 @@ -731,7 +731,7 @@ Projection/Docs/fixtures 与 Extension 等贡献面会有不同的最近验证 1. **每一项验证都要对应一个具名风险。** 对应不上的命令属于惯例,构不成本 PR 的证据。 2. **期望值先于实现。** 从当前输出反推的断言只能做 characterization,不能作为 correctness authority。 -3. 拿不到隔离环境时,正确动作是报告证据缺口并暂停交付。 +3. **跳过不等于通过。** 拿不到隔离环境时,正确动作是报告证据缺口并暂停交付。 4. **默认行为变化有三件必做:重命名 smoke、更新 docs/release note、点名受影响 lane。** 漏掉第一件的测试仍然是绿的,这正是它危险的原因。 5. **merged、released、deployed、observed 是四种状态。** 不能用前一种的证据宣称后一种。 diff --git a/docs/book/en/chapters/00-reading-guide.md b/docs/book/en/chapters/00-reading-guide.md index 4e71495349..6a6cdb001d 100644 --- a/docs/book/en/chapters/00-reading-guide.md +++ b/docs/book/en/chapters/00-reading-guide.md @@ -142,7 +142,7 @@ Operators need not run source tests first; prospective contributors can use Command categories remain explicit. **Runnable** requires the stated version, inputs, and authorization. **Based on the official scaffold** follows the existing teaching package without inventing a runtime. **Simplified for explanation** tables, labels, and data shapes must not be pasted into production -configuration. +configuration. Record preview, execution, readback, and test results separately. ## Four questions for an accountable explanation {#judgment-standard} diff --git a/docs/book/en/chapters/01-from-session-to-loop.md b/docs/book/en/chapters/01-from-session-to-loop.md index 4b128e4fc5..31d91c1c2b 100644 --- a/docs/book/en/chapters/01-from-session-to-loop.md +++ b/docs/book/en/chapters/01-from-session-to-loop.md @@ -147,7 +147,7 @@ Externalized state carries costs. Naming them is what lets you judge when it pay ## Invariants -1. Inspect addressable records, identity, and revision rather than whether a window is open. +1. **Prompt content alone does not prove durable writeback.** Inspect addressable records, identity, and revision rather than whether a window is open. 2. **The execution plane and control plane cannot substitute for each other.** The control plane does not write code; the execution plane does not decide whether it is allowed. 3. **What is reused is lifecycle invariants, not a prompt.** That is what lets three different domains share one control plane. 4. **The next executor does not need to trust the previous one's account.** If it does, the state was not externalized far enough. diff --git a/docs/book/en/chapters/04b-budget-and-admission.md b/docs/book/en/chapters/04b-budget-and-admission.md index f852135c3a..6438faa7ac 100644 --- a/docs/book/en/chapters/04b-budget-and-admission.md +++ b/docs/book/en/chapters/04b-budget-and-admission.md @@ -25,7 +25,7 @@ The following is a **hypothetical faulty policy**, not a claim that current impl | 11:00 | M1 | M1's second unchanged observation | Switch again and start counting again | | 11:30 | M1 and M2 are each due | Update each observation independently | Depends on processing order rather than actual stagnation | -Conflating different targets. Preserve each Monitor's identity and count instead of repeatedly lowering the threshold. Conversely, without a usable Host executing due observations, correct counters remain static records: that is a liveness gap, not no-change evidence. +The problem is conflating different targets. Preserve each Monitor's identity and count instead of repeatedly lowering the threshold. Conversely, without a usable Host executing due observations, correct counters remain static records: that is a liveness gap, not no-change evidence. ## Choose an observation frequency while waiting for CI {#running-wait} diff --git a/docs/book/en/chapters/06-codex-app.md b/docs/book/en/chapters/06-codex-app.md index 18b484f0df..d8ef6aaa87 100644 --- a/docs/book/en/chapters/06-codex-app.md +++ b/docs/book/en/chapters/06-codex-app.md @@ -194,7 +194,7 @@ both exit successfully. Telling them apart requires the writeback and spend hist **Boundary one: a heartbeat does not create a frontier.** A Goal with no Todos will not produce a next step because it was woken more often. With no runnable candidate, enter wait or monitor and let the cadence slow. -Do not copy the quota state machine into +**Boundary two: the automation is not a second control plane.** Do not copy the quota state machine into the automation prompt, and do not let it resolve runnable Todos on its own. The stable prompt carries protocol; the judgment belongs to the packet read on each wake. @@ -261,7 +261,7 @@ repeat reminders so that a wait does not become a high-frequency notification. this turn's receipt is grounds to slow the cadence. Slowing happens when the current `scheduler_hint` proposes it (`apply_needed=true`), through the four steps below. 4. **A cadence change needs all four steps**: proposal, host apply, host readback, ACK. -5. Only a Host readback that matches the target closes the +5. **A local ACK ledger does not prove Host state.** Only a Host readback that matches the target closes the loop; a mismatch is repaired as `drift_detected`. 6. **Switching Hosts needs explicit handoff.** Shared Goal reads do not replace current authority, claim/lease, and fence checks. diff --git a/docs/book/en/chapters/09-extension-scaffold.md b/docs/book/en/chapters/09-extension-scaffold.md index eaea4e38fd..997b8024eb 100644 --- a/docs/book/en/chapters/09-extension-scaffold.md +++ b/docs/book/en/chapters/09-extension-scaffold.md @@ -2,7 +2,7 @@ Use a complete zero-permission teaching package to learn requests, responses, validation, and packaging. [Companion source](https://github.com/loopx-project/loopx/tree/main/packages/loopx-text-stats) in `packages/loopx-text-stats/` includes its manifest, Python package, two JSON Schemas, sample input, and standard-library tests. -Does not read or write Goals. The package owns text input and results; the existing Extension lifecycle owns installation, activation, and managed calls. +It does not read or write Goals. The package owns text input and results; the existing Extension lifecycle owns installation, activation, and managed calls. ## Run the complete example first diff --git a/docs/book/en/chapters/core-state-machines.md b/docs/book/en/chapters/core-state-machines.md index 95bad6537f..5eb341e3e8 100644 --- a/docs/book/en/chapters/core-state-machines.md +++ b/docs/book/en/chapters/core-state-machines.md @@ -786,7 +786,7 @@ therefore not a state you can decide on; it has to be proven item by item. services, and extensions do not align to that number. What actually binds is the typed owner, the protocol schema, and the transition rules. -The owner in the diagram and the +**Boundary two: this map does not replace the migration boundary.** The owner in the diagram and the implementation language are separate dimensions. When a semantic is already carried by a TypeScript owner, rebuilding it in Python from this teaching map creates a second source of truth. @@ -795,7 +795,7 @@ durable journal, an `effect_ref`, and a provider readback resolver carry that gu external call is not automatically deduplicated because this chapter mentions reconciliation; settlement fails closed when the resolver is missing or returns an unknown state. -The diagrams here explain. Before changing a rule, confirm the current typed owner, protocol schema, +**Boundary four: the diagram does not go to the front line.** The diagrams here explain the architecture rather than specifying the implementation. Before changing a rule, confirm the current typed owner, protocol schema, characterization fixture, and migration boundary. ## Named failures: where the handoff breaks @@ -815,7 +815,7 @@ been replaced continuing to write. `needs_rebase` exists as the rejection path f while the source stays unchanged. The symptom is a persistent UI/CLI disagreement that returns to the old value on every refresh. Repair the source or builder, then read back. -**Failure four:** A stopped Goal, paused quota, or blocked peer +**Failure four: the reason to stop is not the same as closure.** A stopped Goal, paused quota, or blocked peer coordination can each stop polling; each is a legal stop. Only `terminal_no_followup` means "stopped because validated Goal closure was derived." Collapsing them lets a paused Goal look finished. @@ -832,7 +832,7 @@ paused Goal look finished. caller handles the rejection. 5. **Terminal is a conjunction.** Complete and closed Todo sources, no unresolved frontier, and a structured `no_followup` intent must all hold. -6. Change a rule only after confirming the typed owner, +6. **A teaching map is not an implementation spec.** Change a rule only after confirming the typed owner, protocol schema, characterization fixture, and migration boundary. These six answer one question: **when the mechanisms are split across nine families that can only speak diff --git a/docs/book/en/chapters/source-protocol-map.md b/docs/book/en/chapters/source-protocol-map.md index d7f2b4436e..28089b54fa 100644 --- a/docs/book/en/chapters/source-protocol-map.md +++ b/docs/book/en/chapters/source-protocol-map.md @@ -474,7 +474,7 @@ Before entering the source, confirm these hold on their own: 1. **The owner of a rule is the module that decides legal transitions, not the module that first prints words about it.** If you cannot name the protected invariant, the change is not yet located. 2. **A PR description carries one complete causal chain: source, invariant, decision, projection or effect, receipt, validation.** A slice that can only list function names cannot be reviewed. 3. **Documents describe responsibility ownership; code describes current behavior.** When they conflict, pick the authority by conflict type and make this PR update the other side. -4. Registration plus a real caller contract is the release test; verify with `loopx capability list --format json`. +4. **Code under `loopx/capabilities//` does not prove the Capability is shipped.** Registration plus a real caller contract is the release test; verify with `loopx capability list --format json`. 5. **Placement precedes implementation.** The capability id, provider id, and built-in or extension-delivered choice come with a written reason before the first line of code. 6. **Tasks come from public entrypoints.** Public Contributor Tasks, Issues, and fixtures are the only source of work you can participate in; live active state and maintainer-local judgment are not. diff --git a/docs/book/en/chapters/source-trace-protocol-chain.md b/docs/book/en/chapters/source-trace-protocol-chain.md index 943bdd380a..ae9b047a23 100644 --- a/docs/book/en/chapters/source-trace-protocol-chain.md +++ b/docs/book/en/chapters/source-trace-protocol-chain.md @@ -491,7 +491,7 @@ For a control-plane failure, verify in order: After a trace, these should hold on their own: 1. **Every renamed or redefined field comes with a full consumer list.** Updating producers alone is incomplete, and a missing-field fallback counts as a consumer. -2. The test is the first boundary that violates the invariant, not the final return value. +2. **Success at every layer is not evidence that the chain is correct.** The test is the first boundary that violates the invariant, not the final return value. 3. **A missing field's default participates in the decision.** So the contract must state whether absence means reject, repair, or compatibility fallback. 4. **Authority has exactly one canonical source.** Several places may read a field and only one owns it; mistaking a reader for the owner is the most common leftover from a cross-layer change. 5. **Judging authority follows the protocol document; judging current behavior follows the source.** When they conflict, pick by conflict type and make this change update the other side. diff --git a/docs/concepts/interaction-pattern-catalog.md b/docs/concepts/interaction-pattern-catalog.md index 524b18688c..0f1ab0a7db 100644 --- a/docs/concepts/interaction-pattern-catalog.md +++ b/docs/concepts/interaction-pattern-catalog.md @@ -2706,7 +2706,7 @@ keep "we stopped supporting this" from becoming "this was never configured". (`loopx/control_plane/coordination/local_authority_shadow.ts:57`) rather than disappearing into a transport error, because a rejection that looks like a transient failure invites a retry loop. -3. One setting is retired; the +3. **Clearing is neither enable nor bootstrap.** One setting is retired; the replacement capture path is configured on its own terms. `apply_coordination_shadow_changes` is documented as "Clear retired settings and configure the transaction-bound shadow independently" diff --git a/docs/development/control-plane-course/02-goal-control-plane-architecture.md b/docs/development/control-plane-course/02-goal-control-plane-architecture.md index 357b2699dc..0577c35fd9 100644 --- a/docs/development/control-plane-course/02-goal-control-plane-architecture.md +++ b/docs/development/control-plane-course/02-goal-control-plane-architecture.md @@ -127,8 +127,7 @@ fact,使下一轮可以重新计算 frontier: | 外部写入结果不确定 | effect receipt + provider readback/reconcile | 先确认外部事实,再决定 retry、successor 或 closeout | | PR merged、closed 或明确不再跟进 | terminal evidence + no-follow-up rationale | monitor 可关闭,后续 Turn 不会继续轮询已经结束的工作 | -它允许 -模型、session、host 和外部系统在边界处失败,但不允许丢失已经确认的事实、effect identity +这个 bot 的“稳定执行”允许模型、session、host 和外部系统在边界处失败,但不允许丢失已经确认的事实、effect identity 和下一步恢复路径。长程稳定的目标,是让错误可发现、可归因、可恢复;即使 Agent 犯错, 已提交事实仍然有效,系统仍能形成下一步 frontier。 diff --git a/docs/development/control-plane-course/06-quota-decision-kernel.md b/docs/development/control-plane-course/06-quota-decision-kernel.md index c60d169d07..7f6b55ea6e 100644 --- a/docs/development/control-plane-course/06-quota-decision-kernel.md +++ b/docs/development/control-plane-course/06-quota-decision-kernel.md @@ -688,6 +688,7 @@ cli_channel -> 下一条 CLI 写回、何时允许 spend 2. 为什么 projection repair 要覆盖正常 delivery? 3. workspace repair 为什么比 capability repair 更晚覆盖? 4. terminal closure 同时检查哪些 todo、monitor、successor、replan 与 acceptance 状态? +5. `action_required=false` 为什么不代表 agent 可以 quiet no-op? ## 代码阅读方法 diff --git a/docs/development/control-plane-course/11-extension-layer.md b/docs/development/control-plane-course/11-extension-layer.md index 207ffb9c64..8ea751e59a 100644 --- a/docs/development/control-plane-course/11-extension-layer.md +++ b/docs/development/control-plane-course/11-extension-layer.md @@ -354,6 +354,7 @@ loopx --format json configure-goal --goal-id 2. 阅读 exact delta 和 boundary; 3. 再显式 `--execute`; 4. 关闭 feature 时保留历史 evidence,只关闭未来行为; +5. feature gate 不等于 runtime permission。 ## Explore Graph:探索证据层 diff --git a/docs/development/design.md b/docs/development/design.md index 4c107a521d..347cb844c5 100644 --- a/docs/development/design.md +++ b/docs/development/design.md @@ -583,8 +583,7 @@ keys do not define tokens. PostCSS and its declared value parser distinguish stylesheet declarations and variable functions from quoted examples, comments and other declaration values. Parse errors fail the check. -Tokens -that are genuinely optional may keep a fallback (`var(--pw-surface, #fff)`). +Tokens that are genuinely optional may keep a fallback (`var(--pw-surface, #fff)`). ### Type Scale diff --git a/docs/development/testing-and-quality.md b/docs/development/testing-and-quality.md index c9800b3d48..e9e12f0194 100644 --- a/docs/development/testing-and-quality.md +++ b/docs/development/testing-and-quality.md @@ -266,7 +266,7 @@ implementations share the new rule is not a before/after compatibility test. 重构评审必须区分“相同判定”和“相同可观察语义”:同样拒绝但丢失对象状态或修复 提示仍是回归;新增认领前提可能阻断旧实现允许的未认领文案修正;`--note` 被 parser -接受或出现在成功响应中。先从旧调用 +接受或出现在成功响应中,也不能证明它经过 dispatch 后落盘并能独立回读。先从旧调用 方及公开契约列出合法/非法分支,再运行基线与精确 head 的对照,不从新实现生成期望。 Show regression sensitivity: the focused case must fail on the historical @@ -1183,7 +1183,8 @@ the daily full-public sweep, and high-risk release profiles. It aggregates duration, failures, timeouts, current-inventory coverage, and targeted profile ownership without copying stdout/stderr tails or repository-local paths. -full-public workflow 还会把各 shard 回执聚合成一个紧凑健康产物。报告区分四种频率。它会统计耗时、失败、超时、当前 +full-public workflow 还会把各 shard 回执聚合成一个紧凑健康产物。报告区分四种频率: +显式 PR 快速 smoke、catalog 选择的 canary、每日 full-public 全量,以及高风险 release profile。它会统计耗时、失败、超时、当前 清单覆盖率和定向 profile owner,同时不会复制 stdout/stderr tail 或仓库本地路径。 ```bash @@ -1693,7 +1694,7 @@ ceiling to 9,336, retaining the former 694 characters of headroom. Compare complete authoring bounds and parsed semantic-closeout arguments with the original admitted contract; recovery specializes the completed Task's boundary. Spend and settled -recovery keep their 2,000-character ceilings. This preserves useful guidance; +recovery keep their 2,000-character ceilings. This preserves useful guidance. Candidate measurements must still pass. 辅助 Monitor 的恢复夹具用缩进 JSON 测量完整的原始 writeback 步骤,File 与 SQLite @@ -1830,7 +1831,7 @@ provider permission and does not rewrite frozen experiment/promotion results. 完整性、安全或结算语义,不能只为过线缩字段名,也不为微小收益制造引用框架。 agent 读取的文字也是决策语义:逐条核对执行者、触发、时序、义务强度、证据来源、 范围限定、继续和停止条件。字段、命令、枚举和 - 合法结果未变。不能为字符上限损害有用语义;未证明无损压缩时, + 合法结果未变,不能证明指令等价。不能为字符上限损害有用语义;未证明无损压缩时, 优先基于证据调整回归预算。真实硬上限需要明确的无损调用方设计和读回,不能默删义务。 3. **选择并披露取舍。** 比较压缩、保持上限、合理扩容,也可组合使用。扩容需说明 保留信息的价值与成本、新旧上限、实测余量和预期波动或规模,不规定统一余量比例。 @@ -2122,7 +2123,7 @@ The complete required-vision journey has a 40-call bound; the narrow single-semantic-action qualifier retains seven. The increased budget covers evidence discovery, JSON authoring, refresh, settlement and bounded recovery, including multiple field-validation corrections before a final spend; - +it does not authorize more effects or weaken the checkpoint/readback oracle. Each receipt records `tool_call_limit` beside actual usage. Earlier seven- and sixteen-call failures remain failures; the revised budget defines a new qualification, not a retrospective pass. Limit exhaustion after refresh but before spend still @@ -2436,7 +2437,7 @@ MCP 可随完成操作携带 vision 判断,也可用 `review_task_vision` 在 复用 TS 的既有恢复规则,不新增结算引擎、不重扣额度;已提交的判断不能偷偷改写。 格式和预算预检在 Todo 完成前拒绝非法输入;若旧宿主已部分完成,则修正未提交的 vision 并重试原 `complete_task`,不能用仅补 checkpoint 的操作替代未完成结算。 - +`vision_closed` 只结束当前阶段,活跃 Goal 仍须继续规划后续缺口。 外层任务只描述业务验收,LoopX 协议由宿主内层指令和工具承接。 ## Exact Release Commit Gate / 精确发布 Commit 门 diff --git a/docs/guides/context-delivery.md b/docs/guides/context-delivery.md index b0e43248a7..75b014aff5 100644 --- a/docs/guides/context-delivery.md +++ b/docs/guides/context-delivery.md @@ -12,8 +12,7 @@ benchmark heartbeat callers when no machine preference is saved. Saved or explic off disables it; ordinary CLI, other hosts and unsupported platforms inherit full delivery. -The -complete C1 caller migration and long-horizon cost/outcome qualification remain +The complete C1 caller migration and long-horizon cost/outcome qualification remain open. Broad default adoption and old-path retirement need the evidence below. - To understand a work session, start with [the example](#one-task-four-situations). diff --git a/examples/dev-book-publication-smoke.py b/examples/dev-book-publication-smoke.py index 6fd3eade04..580b2658f2 100644 --- a/examples/dev-book-publication-smoke.py +++ b/examples/dev-book-publication-smoke.py @@ -104,6 +104,62 @@ def assert_bilingual_concepts( assert en_marker in en_text, f"{en_path}: missing bilingual marker {en_marker}" +def assert_chapter_invariants_and_sequences() -> None: + zh_ordinals = ("一", "二", "三", "四", "五", "六") + en_ordinals = ("one", "two", "three", "four", "five", "six") + for locale_dir in ("chapters", "en/chapters"): + for chapter in CHAPTERS: + rel = f"{locale_dir}/{chapter}.md" + text = read(BOOK / rel) + inv_match = re.search( + r"^##\s+(?:不变式|Invariants)\b[^\n]*\n(.*?)(?=^##\s+|\Z)", + text, + re.M | re.S, + ) + if inv_match is not None: + items = [ + (int(m.group(1)), m.group(2)) + for line in inv_match.group(1).splitlines() + for m in [re.match(r"^(\d+)\.\s+(.*)$", line)] + if m is not None + ] + if items: + numbers = [n for n, _ in items] + assert numbers == list(range(1, len(items) + 1)), ( + f"{rel}: non-contiguous Invariants numbering {numbers}" + ) + for n, body in items: + assert body.startswith("**"), ( + f"{rel}: Invariant {n} missing bold summary lead-in: {body[:60]!r}" + ) + for prefix in ("代价", "边界", "失败"): + found = re.findall( + rf"^\*\*{prefix}([一二三四五六])(?:[::]([^*]*))?\*\*", + text, + re.M, + ) + if found: + seq = [ordinal for ordinal, _ in found] + assert seq == list(zh_ordinals[: len(seq)]), ( + f"{rel}: non-contiguous {prefix} sequence {seq}" + ) + for ordinal, title in found: + assert title.strip(), f"{rel}: {prefix}{ordinal} missing bold title" + for prefix in ("Cost", "Boundary", "Failure"): + found = re.findall( + rf"^\*\*{prefix}\s+(one|two|three|four|five|six)(?:[::]\s*([^*]*))?\*\*", + text, + re.M | re.I, + ) + if found: + seq = [ordinal.lower() for ordinal, _ in found] + assert seq == list(en_ordinals[: len(seq)]), ( + f"{rel}: non-contiguous {prefix} sequence {seq}" + ) + for ordinal, title in found: + assert title.strip(), f"{rel}: {prefix} {ordinal} missing bold title" + + def assert_community_casebook_is_bilingual() -> None: protocol_map_zh = read(BOOK / "chapters" / "source-protocol-map.md") protocol_map_en = read(BOOK / "en" / "chapters" / "source-protocol-map.md") @@ -473,6 +529,7 @@ def main() -> int: assert (CONTROL_PLANE_COURSE / f"{page}.md").is_file(), page assert_community_casebook_is_bilingual() + assert_chapter_invariants_and_sequences() reading_guides = ( read(BOOK / "chapters" / "00-reading-guide.md"), @@ -524,6 +581,7 @@ def main() -> int: ("Stage 3 的第一个 receipt-bound scheduler follow-up 切片", "first receipt-bound scheduler follow-up slice of Stage 3"), ("Stage 4 distribution cleanup 仍是后续方向", "Stage 4 distribution cleanup remain future work"), ("安装 Provider 不会改变默认本地 authority", "installing a Provider does not change the default local authority"), + ("预览、实际执行、读回和测试结果分别记录", "Record preview, execution, readback, and test results separately."), ), ) assert_bilingual_concepts( diff --git a/loopx/capabilities/explore/README.zh-CN.md b/loopx/capabilities/explore/README.zh-CN.md index eb489895d6..b3db2cb601 100644 --- a/loopx/capabilities/explore/README.zh-CN.md +++ b/loopx/capabilities/explore/README.zh-CN.md @@ -58,7 +58,7 @@ `measurement_context` 对象。写入前会展开成原有完整记录,不保存可变上下文引用。 观测重复填写比较字段(即使值相同)、上下文字段缺失或多余都会在记录前拒绝。 原有完整条目格式继续可用。复用声明不认证可比性;任务、数据、评测器、模型或预算 -改变时另选上下文,条件未知时保持分开。 +改变时另选上下文,条件未知时保持分开。此便捷输入不授予评测、纠正或执行权限。 比较条件与候选、单次结果分别记录: @@ -154,13 +154,13 @@ loopx explore worker-branch-plan --goal-id --harness-profile adaptive-resil 两个门控相互独立且默认关闭(见下文“每 goal 独立 Opt-In 门控”)。以下是详细契约。 当已闭环、有证据的多个面之间存在显式理由需要组合验证时,下一次 `quota should-run` / turn packet 会投影 composition gap,并可衍生 joint experiment 后继 todo(见下文“Composition Frontier”)。 -长程探索目标(例如通过 LoopX 研究某个外部软件领域的 Codex loop)产生的结果,operator 希望读成**拓扑**。 +长程探索目标(例如通过 LoopX 研究某个外部软件领域的 Codex loop)产生的结果,operator 希望读成**拓扑**:探索过什么、循环卡在哪里以及为什么、发现了什么。 ## 角色边界 一句话概括: -- **Explore 能力(本层)** 拥有结构化探索**证据**:紧凑、public-safe、append-only 的 node/edge/finding/blocked-frontier 日志,以及有界读模型投影。因此日志位于 `loopx/capabilities/explore/`。 +- **Explore 能力(本层)** 拥有结构化探索**证据**:紧凑、public-safe、append-only 的 node/edge/finding/blocked-frontier 日志,以及有界读模型投影。下游消费者首先是 vision checkpoint、replan、后继 todo 生成和 user gate,其次才是展示,因此日志位于 `loopx/capabilities/explore/`。 - **展示(Presentation)** 把 public-safe 探索投影渲染成 operator 界面(Mermaid 图、飞书/Lark Base 行、卡片)。可复用展示实现位于 `loopx.extensions.lark.presentation.explore_results`;核心不保留 Lark 能力外观。兼容 CLI 委托在调用 provider 所属展示行为前必须显式激活扩展。 - **Value connectors** 仍是外部信号输入、权限和来源权威的边界。Lark 探索 sink 仅用于展示,绝不可与 connector 混为一谈。 diff --git a/loopx/capabilities/issue_fix/docs/state-kernel-domain-state-case-study.zh-CN.md b/loopx/capabilities/issue_fix/docs/state-kernel-domain-state-case-study.zh-CN.md index 9a9fc6354f..50210d2821 100644 --- a/loopx/capabilities/issue_fix/docs/state-kernel-domain-state-case-study.zh-CN.md +++ b/loopx/capabilities/issue_fix/docs/state-kernel-domain-state-case-study.zh-CN.md @@ -146,7 +146,7 @@ Issue-Fix 向 Kernel 返回有限几种 transition: | newer repair commit 已覆盖反馈且 threads 全 resolved | `monitor_continuation` | 等待 re-review,不重复生成 patch | | PR `MERGED` 或 `CLOSED` | `no_followup` / terminal transition | 完成 monitor,恢复显式 successor 或记录 no-follow-up | -它只是生成 typed proposal; +Domain transition 只生成 typed proposal; todo writer、gate scope、quota、authority 与 scheduler 仍会再次检查。 ## 五、以一次 OpenViking Issue-Fix 运行为例 diff --git a/loopx/capabilities/manager_context/README.md b/loopx/capabilities/manager_context/README.md index 14130fb5f8..230688538c 100644 --- a/loopx/capabilities/manager_context/README.md +++ b/loopx/capabilities/manager_context/README.md @@ -31,7 +31,8 @@ selected audience's previous enrollment boundary, explicitly set `"local_delivery_scope":"selected"` alongside its `targets` list before upgrading. Missing policy, missing source, a wrong sender or malformed scope grants nothing. Keep the policy private (0600); do not commit it. A read grant without a sender -grant is insufficient. +grant is insufficient. This does not grant remote delivery, evidence reads, +worker launch, Todo/lease changes or protected operations. ### Readable answers and original-conversation returns @@ -163,7 +164,7 @@ The native postcondition entry retires only its exact operation-owned temporary host input before checking a clean delivery worktree; unrelated files and actual artifact changes still fail canonical validation. Validation recovery resumes the original Turn after its retained host result, without invoking the model again. -The typed wake owner +An external conversation is not a native Goal wake owner. The typed wake owner settles that separate intent as `no_wake_owner`; the exact original inbox return still carries the receiver's conclusion, without a hidden Goal or retry loop. diff --git a/loopx/capabilities/native_chat/antigravity_adapter.py b/loopx/capabilities/native_chat/antigravity_adapter.py index 4311d965ca..48f2e27922 100644 --- a/loopx/capabilities/native_chat/antigravity_adapter.py +++ b/loopx/capabilities/native_chat/antigravity_adapter.py @@ -649,9 +649,8 @@ def quota_failure_observation(*, cascade_id: str, request_ref: str, message: str input_anchor: dict[str, Any]) -> dict[str, Any] | None: """Prove one native input ended at quota before any model/tool output. - Read - the exact original input twice from a stable idle cascade instead. Only - the latest two-step input/quota-error sequence qualifies; any output, + Read the exact original input twice from a stable idle cascade instead. + Only the latest two-step input/quota-error sequence qualifies; any output, tool, later input, cleared step or unknown native state fails closed. """ try: diff --git a/loopx/capabilities/native_chat/steward_managed_mode.py b/loopx/capabilities/native_chat/steward_managed_mode.py index 56f6af14e9..b5b9e30972 100644 --- a/loopx/capabilities/native_chat/steward_managed_mode.py +++ b/loopx/capabilities/native_chat/steward_managed_mode.py @@ -362,8 +362,7 @@ def creation_request(self, session_id: str) -> dict[str, Any] | None: def _original_task_entry(self, session_id: str) -> dict[str, Any]: """Observe the existing creation/validation owners without any effects. - Native - submit still rechecks current admission and every validation source. + Native submit still rechecks current admission and every validation source. """ from ...control_plane.effect_runtime import effect_runtime_result from ...control_plane.goals.acceptance import inspect_goal_acceptance diff --git a/loopx/capabilities/reliability_diagnostics/README.zh-CN.md b/loopx/capabilities/reliability_diagnostics/README.zh-CN.md index ac46bb9157..b36fb6436f 100644 --- a/loopx/capabilities/reliability_diagnostics/README.zh-CN.md +++ b/loopx/capabilities/reliability_diagnostics/README.zh-CN.md @@ -8,7 +8,9 @@ 实跑,以及明确的开销报告。 L1 observer 观察一个长时运行的 Agent 会话,并写下独立的诊断记录;它**永远不能** -影响该会话。 +影响该会话。本能力把这条承诺做成机器合约:envelope schema 无法表达 +命令,receipt 记录 outbound endpoint 为空集,observer 故障被计数并让证据进入 +quarantined,projection 携带 `mode: read_only` 与 `authority: none`。 ```mermaid flowchart LR @@ -150,7 +152,8 @@ loopx reliability-diagnostics ingest --goal-id --input observer.ndjso 不影响此校验。 `status --with-receipt` 从同一次 ledger 读取返回两个现有合同;省略该选项保留原来的 -projection-only 输出,不授予控制权限,也不激活 observer。接入轮询前应阅读 +projection-only 输出,不授予控制权限,也不激活 observer。并发追加不是原子快照, +末尾半行仍会导致 integrity 失败。接入轮询前应阅读 [DSH/Pi 评估](../../../docs/architecture/rfcs/harness-selection-dsh-pi-v0.zh-CN.md) 中的全量读取与身份边界。 diff --git a/loopx/capabilities/reward_memory/README.md b/loopx/capabilities/reward_memory/README.md index 6cd7f7d940..35f17c877f 100644 --- a/loopx/capabilities/reward_memory/README.md +++ b/loopx/capabilities/reward_memory/README.md @@ -655,7 +655,8 @@ against OpenViking's current public architecture and code: authority scope are independently verified. The content may be inferred; the authority may not. - Account, user, peer, session, and repository-revision boundaries remain part - of scope and privacy. + of scope and privacy. A peer label does not grant cross-user or cross-agent + authority. Provider health is intentionally decomposed into `corpus_present`, `index_present`, `retrieval_query_succeeded`, `result_readback_verified`, and diff --git a/loopx/capabilities/reward_memory/README.zh-CN.md b/loopx/capabilities/reward_memory/README.zh-CN.md index 433b512db1..5461cbfae1 100644 --- a/loopx/capabilities/reward_memory/README.zh-CN.md +++ b/loopx/capabilities/reward_memory/README.zh-CN.md @@ -430,7 +430,7 @@ apply、ignore 或 refute,并复用共享 application receipt;ingest seam repository/action authority scope 被独立验证后,内容才能成为 LoopX `hard_policy`。 内容可以推导,authority 不能推导。 - Account、user、peer、session 和 repository-revision boundary 始终属于 scope 与 - privacy。 + privacy。Peer label 不授予 cross-user 或 cross-agent authority。 Provider health 拆成 `corpus_present`、`index_present`、 `retrieval_query_succeeded`、`result_readback_verified` 和 diff --git a/loopx/control_plane/collaboration/conversation_binding.ts b/loopx/control_plane/collaboration/conversation_binding.ts index cecb9273ec..7fc2597b86 100644 --- a/loopx/control_plane/collaboration/conversation_binding.ts +++ b/loopx/control_plane/collaboration/conversation_binding.ts @@ -9,7 +9,7 @@ import {boundConversationExecutorMatches, normalizeProjectContext, normalizeStew import {bindStewardManagedActor, normalizeStewardManagedActor} from "./steward_managed_mode.ts"; /** Core owns the context and audience grant. A provider supplies verified, - * opaque identity observations; + * opaque identity observations. * Ordinary project bindings carry no Goal. A verified personal steward can * read the registered owner portfolio; legacy selected scopes stay bounded. */ diff --git a/loopx/control_plane/collaboration/source_grants.ts b/loopx/control_plane/collaboration/source_grants.ts index 1fbcaca90e..1d4fe964c0 100644 --- a/loopx/control_plane/collaboration/source_grants.ts +++ b/loopx/control_plane/collaboration/source_grants.ts @@ -70,7 +70,7 @@ export function configureOriginalConversationGrant(params: JsonObject): JsonObje } /** Retire only this exact native conversation's grants. Historical requests and - * receipts remain readable; + * receipts remain readable. */ export function revokeConversationSources(params: JsonObject): JsonObject { const id = requireNonEmptyString(params.binding_id, "conversation binding identity"); diff --git a/loopx/control_plane/quota/refresh_recovery.ts b/loopx/control_plane/quota/refresh_recovery.ts index 1d665f2143..d6a13243c5 100644 --- a/loopx/control_plane/quota/refresh_recovery.ts +++ b/loopx/control_plane/quota/refresh_recovery.ts @@ -108,7 +108,9 @@ export function refreshRecovery( ? normalizeDeliveryWorkspaceSnapshot(prior.delivery_workspace) : null; const missingWorkspace = request.workspace_requested && workspaceRequirement !== "not_required" && workspace === null; - // Once appended, the recovery digests restore strict replay. + // The receipt-bound first workspace supplement of a material poll may author + // next-action/vision through normal refresh validation. Once appended, the + // recovery digests restore strict replay. const firstMonitorCloseout = missingWorkspace && isMaterialMonitorPoll(prior) && prior.refresh_recovery == null && checkpoint === null; if (firstMonitorCloseout) { diff --git a/loopx/control_plane/runtime/receipt_log_snapshot.ts b/loopx/control_plane/runtime/receipt_log_snapshot.ts index 067c8d7f62..29f2f133e1 100644 --- a/loopx/control_plane/runtime/receipt_log_snapshot.ts +++ b/loopx/control_plane/runtime/receipt_log_snapshot.ts @@ -129,9 +129,9 @@ function decodeLine(line: string, schemaVersion?: string): JsonObject { /** * Read fresh bytes on EVERY invocation. Only reuse a parsed newline-terminated - * prefix after hashing those exact bytes; - * Rewrites, rotation, truncation and same-size edits all - * remain observable, including edits to an old identity-conflicting receipt. + * prefix after hashing those exact bytes. Rewrites, rotation, truncation and + * same-size edits all remain observable, including edits to an old + * identity-conflicting receipt. * Never cache an unterminated tail: an append can finish its UTF-8 character or * JSON token. The tail still participates in this read, including strict errors. * Cache loss/eviction/restart affects cost only, never the returned facts. diff --git a/loopx/control_plane/work_items/task_lease_eligibility.ts b/loopx/control_plane/work_items/task_lease_eligibility.ts index a94ce16f90..85aaab69c8 100644 --- a/loopx/control_plane/work_items/task_lease_eligibility.ts +++ b/loopx/control_plane/work_items/task_lease_eligibility.ts @@ -1,5 +1,5 @@ /** Owner eligibility is shared by acquisition, renewal, transfer and observation. - * */ + * Time, mode, proof, CAS and release remain with callers. */ export interface LeaseEligibilityTodo { readonly status: string; diff --git a/loopx/extensions/lark/private_ingress.py b/loopx/extensions/lark/private_ingress.py index ae316151e3..ddcb3fcffd 100644 --- a/loopx/extensions/lark/private_ingress.py +++ b/loopx/extensions/lark/private_ingress.py @@ -232,8 +232,7 @@ def project_private_reply_history(store: Any, session: dict[str, Any], raise ValueError("unreadable original event") source = lark_private_source(provider_ref=saved["provider_ref"], event=record["event"]) # Recovery moves the correlation journal forward, retaining its - # original failed Turn. Read those exact recorded identities; - + # original failed Turn. Read those exact recorded identities. recoveries = [native.get("context_recovery") or {}, *native.get("context_recovery_history", [])] if any(not isinstance(row, dict) for row in recoveries): raise ValueError("unreadable recovery identities") @@ -464,7 +463,7 @@ def answer_candidates(self, *, cancelled: Callable[[], bool] = lambda: False) -> **{key: canonical.get(key) for key in ("root_id", "parent_id", "thread_id")}} yield binding["transport_ref"], history except (OSError, ValueError, KeyError, TypeError): - continue # Preserve every gap; + continue # Preserve every gap. def _records(self) -> list[dict[str, Any]]: paths = sorted(self.transport.root.glob("*.json")) diff --git a/packages/loopx-codex-provider-routing/src/loopx_codex_provider_routing/openai_policy.ts b/packages/loopx-codex-provider-routing/src/loopx_codex_provider_routing/openai_policy.ts index eadaa8dbb6..cd5a2d9ace 100644 --- a/packages/loopx-codex-provider-routing/src/loopx_codex_provider_routing/openai_policy.ts +++ b/packages/loopx-codex-provider-routing/src/loopx_codex_provider_routing/openai_policy.ts @@ -25,7 +25,7 @@ export function apiStreamOutcome(value: unknown): {status: number; code: string} return null; } export function apiKeys(input: { now: number; model: string; keys: KeyRuntime[] }) { - // Expiry permits a future attempt; + // Expiry permits a future attempt. // Try alternatives before a known rejection, even when requests are spaced // farther apart than the cooldown. Oldest failures are reconsidered first. const rejectionTime = (key: KeyRuntime) => ["quota_exhausted", "authentication_failed", diff --git a/tests/test_dev_book_reader_checkpoints.py b/tests/test_dev_book_reader_checkpoints.py index c144006766..304b7ded09 100644 --- a/tests/test_dev_book_reader_checkpoints.py +++ b/tests/test_dev_book_reader_checkpoints.py @@ -6,6 +6,7 @@ from __future__ import annotations import ast +import importlib.util import os from pathlib import Path import re @@ -112,6 +113,15 @@ def require_heading(markdown: str, anchor: str) -> None: raise ValueError(f"missing heading anchor: {anchor}") +def load_dev_book_smoke() -> object: + smoke_path = REPO / "examples" / "dev-book-publication-smoke.py" + spec = importlib.util.spec_from_file_location("dev_book_publication_smoke", smoke_path) + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + class ReaderCheckpointReferences(unittest.TestCase): def test_bilingual_checkpoint_commands_match(self) -> None: zh, en = (checkpoint_sections(page.read_text(encoding="utf-8")) for page in PAGES) @@ -181,6 +191,10 @@ def test_all_teaching_code_fences_close(self) -> None: with self.subTest(locale=locale, page=name): self.assertIsNone(fence, "unclosed fenced example") + def test_chapter_invariants_and_named_sequences_hold(self) -> None: + smoke = load_dev_book_smoke() + smoke.assert_chapter_invariants_and_sequences() + class ReaderCheckpointGuardTests(unittest.TestCase): def setUp(self) -> None: @@ -252,6 +266,26 @@ def test_missing_heading_is_rejected(self) -> None: with self.assertRaisesRegex(ValueError, "missing heading"): require_heading("## A {#present}\n", "missing") + def test_chapter_invariant_and_sequence_guards_reject_truncation(self) -> None: + smoke = load_dev_book_smoke() + cases = ( + ("## Invariants\n\n1. Plain text without bold summary.\n", "missing bold summary"), + ("## Invariants\n\n1. **First.** Ok.\n3. **Third.** Skipped two.\n", "non-contiguous Invariants"), + ("**Boundary one: first.** Ok.\n\n**Boundary three: third.** Skipped two.\n", "non-contiguous Boundary"), + ("**Failure one: first.** Ok.\n\n**Failure two:** Body without title.\n", "Failure two missing bold title"), + ) + for bad_markdown, expected_error in cases: + with self.subTest(expected=expected_error), tempfile.TemporaryDirectory() as tmp: + book_dir = Path(tmp) + (book_dir / "chapters").mkdir() + (book_dir / "en" / "chapters").mkdir(parents=True) + (book_dir / "chapters" / "sample.md").write_text("# Sample\n", encoding="utf-8") + (book_dir / "en" / "chapters" / "sample.md").write_text(bad_markdown, encoding="utf-8") + smoke.BOOK = book_dir + smoke.CHAPTERS = ("sample",) + with self.assertRaisesRegex(AssertionError, expected_error): + smoke.assert_chapter_invariants_and_sequences() + @unittest.skipUnless(shutil.which("git"), "Git is required for the isolated onboarding example") class GitOnboardingEvidence(unittest.TestCase):