Skip to content

Commit 7c5b252

Browse files
author
xiaoan17
committed
docs(rfc): narrow the activation guard's refusal to what it checks
The recorded decision claimed the guard refuses to continue while accepted work or ingress is pending. The real guard takes the ingress admission lock and refuses to continue only while a non-terminal Turn exists; it reads accepted work through the Turn state and never reads the ingress receipt ledger, so a pending queue or inbox receipt passes through. Narrow the English text, the Chinese mirror and Appendix A to the non- terminal Turn check, and pin the narrowed boundary with a test. Signed-off-by: xiaoan17 <anbc1224@gmail.com>
1 parent 3701644 commit 7c5b252

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

‎docs/architecture/rfcs/monorepo-distribution-split-v0.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@ transition of services that are already installed, and its
308308
ingress lock while a managed client restarts. `loopx-codex-provider-routing`
309309
uses that guard, and no other entry point of that module, to fence accepted Chat
310310
work before it restarts the Chat services it manages. The guard grants no work
311-
authority: it takes the ingress lock and refuses to continue while accepted
312-
work or ingress is pending. The import ratchet records that edge as well. This
311+
authority: it holds the ingress admission lock and refuses to continue while a
312+
non-terminal Turn is pending. A pending ingress receipt is not part of that
313+
check. The import ratchet records that edge as well. This
313314
is a third public module in the seam and does not widen it: a package still may
314315
not import the executor or another kernel-private module.
315316

@@ -716,14 +717,19 @@ Approval needs a reviewed decision, not implementation progress or silence.
716717
`managed_chat_activation_guard` to hold the accepted-Chat-work fence and the
717718
ingress lock while it restarts the Chat services it manages. The import
718719
ratchet records that edge.
719-
- **Boundary repair:** the guard grants no work authority — it takes the ingress
720-
lock and refuses to continue while accepted work or ingress is pending — and
720+
- **Boundary repair:** the guard grants no work authority — it holds the ingress
721+
admission lock and refuses to continue while a non-terminal Turn is pending,
722+
and a pending ingress receipt is not part of that check — and
721723
the package uses no other entry point of that module. The seam stays closed: a
722724
package still may not import the executor or another kernel-private module,
723725
and the pinned Ark/JEV edges remain migration debt.
724726
- **Evidence:** the import ratchet pins the edge instead of leaving it
725727
unrecorded, and the Codex provider-routing native host smoke exercises the
726-
guarded restart path.
728+
guarded restart path. `tests/test_chat_runtime_activation.py::
729+
test_a_pending_ingress_receipt_alone_does_not_defer_the_restart` pins the
730+
narrowed boundary: a pending `loopx_queue` or `loopx_inbox` receipt on its own
731+
does not defer the restart, because the guard reads accepted work through the
732+
Turn state.
727733
- **Remaining:** the wider M1–M5 distribution and zero-private-import acceptance
728734
is not closed; D1–D4 stay open. The seam records one module for one caller,
729735
not a general package-to-kernel permission.

‎docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ MemT 只使用这两个公开模块,不能直接 import executor 或其他内
212212
其 `managed_chat_activation_guard` 在受管客户端重启期间持有"已受理 Chat 工作"
213213
栅栏与入口锁。`loopx-codex-provider-routing` 只使用该栅栏、不使用该模块的其他
214214
入口,在重启自己管理的 Chat 服务之前为已受理的 Chat 工作加栅栏。该栅栏不授予
215-
工作权限:它获取入口锁,并在仍有已受理工作或入口流量时拒绝继续。import ratchet
215+
工作权限:它持有入口准入锁,并在仍有非终态 Turn 时拒绝继续。待处理的入口收据
216+
不在该检查范围内。import ratchet
216217
同样钉住这条边。这是接缝中的第三个公开模块,并没有放宽接缝:包依旧不能 import
217218
executor 或其他内核私有模块。
218219

@@ -514,11 +515,15 @@ R0 可以先于目录移动交付,但不代表内核合格。R3/R4 可选,
514515
`loopx-codex-provider-routing` 使用其 `managed_chat_activation_guard`,在重启
515516
自己管理的 Chat 服务期间持有"已受理 Chat 工作"栅栏与入口锁。import ratchet
516517
钉住这条边。
517-
- **边界修复:** 该栅栏不授予工作权限——它获取入口锁,并在仍有已受理工作或入口
518-
流量时拒绝继续——且该包不使用该模块的其他入口。接缝仍然闭合:包依旧不能
518+
- **边界修复:** 该栅栏不授予工作权限——它持有入口准入锁,并在仍有非终态 Turn 时
519+
拒绝继续;待处理的入口收据不在该检查范围内——且该包不使用该模块的其他入口。
520+
接缝仍然闭合:包依旧不能
519521
import executor 或其他内核私有模块,已钉住的 Ark/JEV 私有边仍是迁移积压。
520522
- **证据:** import ratchet 钉住这条边,而不是让它处于未记录状态;Codex
521523
provider-routing 的 native host smoke 覆盖受保护的重启路径。
524+
`tests/test_chat_runtime_activation.py::test_a_pending_ingress_receipt_alone_does_not_defer_the_restart`
525+
钉住收窄后的边界:只有一条待处理的 `loopx_queue` 或 `loopx_inbox` 收据并不会
526+
推迟重启,因为该栅栏是通过 Turn 状态读取已受理工作的。
522527
- **剩余:** 不关闭更广的 M1–M5 发行物与零私有 import 验收;D1–D4 仍未决。
523528
该接缝只为一个调用方记录一个模块,不是通用的包到内核许可。
524529

‎tests/test_chat_runtime_activation.py‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import pytest
1515

1616
from loopx.chat_store import ChatSessionStore
17-
from loopx.chat_ingress import chat_runtime_activation_lock
17+
from loopx.chat_ingress import chat_runtime_activation_lock, chat_runtime_activation_state
1818
from loopx.runtime_activation import restart_services_for_runtime_activation
1919
from loopx.self_update import execute_update_plan, render_update_plan_markdown
2020

@@ -112,6 +112,34 @@ def test_queue_without_an_active_pointer_still_defers_until_original_work_finish
112112
assert store.load_turn(sid, queued["turn_id"])["message"] == "later input"
113113

114114

115+
@pytest.mark.parametrize("mode", ["loopx_queue", "loopx_inbox"])
116+
def test_a_pending_ingress_receipt_alone_does_not_defer_the_restart(services, mode):
117+
"""The guard fences non-terminal Turns, not pending ingress receipts.
118+
119+
A pending ingress receipt reserves external input before the provider
120+
delivers it, so it is not a Turn yet. The activation guard reads the
121+
accepted work through the Turn state, so a pending receipt on its own
122+
does not defer the restart. This is the boundary the guard actually
123+
holds, not a promise that pending receipts are covered.
124+
"""
125+
runtime, _agents, calls = services
126+
store = ChatSessionStore(runtime)
127+
sid = session(store)
128+
receipt, created = store.create_ingress_receipt(
129+
sid,
130+
client_ingress_id=f"client-{mode}",
131+
mode=mode,
132+
message="reserved input",
133+
)
134+
assert created is True
135+
assert receipt["status"] == "pending"
136+
assert chat_runtime_activation_state(runtime)["nonterminal_turns"] == 0
137+
138+
result = activate()
139+
assert result["restart_status"] == "restarted"
140+
assert len(calls) == 2
141+
142+
115143
@pytest.mark.parametrize(
116144
"damage", ["session", "turn", "active_missing", "unknown_status", "invalid_status"]
117145
)

0 commit comments

Comments
 (0)