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
26 changes: 26 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4062,3 +4062,29 @@ coercion but produced an inactive policy, silently skipping research evidence.
The existing configuration owner now refuses this malformed shape before IO;
documented scalar modes, defaults and errors retain their semantics. Real
File/SQLite negative cases guard this boundary without changing valid activation.


### 2026-11-14 — Policy observers recover the original signed source

- **Baseline:** `main@8d7d234c6f55`; C1 #8266 at `c3cb8b2fe7bf`.
- **Gap:** three current C1 guided-start and visible-Goal selection cases
rejected a required presentation as if it were the original signed decision.
The original capture passes both its physical digest and complete-contract
validation. Same-view Todo references and their read guidance change the
presentation body while retaining the original binding.
- **Delta:** the existing test policy observer follows the presentation's
declared immutable capture and digest before comparing decision facts. It
reuses the physical capture reader; inline/off outputs without such a
reference retain their current behavior. No producer, decision, hash codec,
admission, settlement owner or default changes.
- **Evidence:** the existing real guided-start/visible-Goal CLI cases pass on
the pinned C1 combination. The durable File/SQLite regression exercises the
shared typed projection and verifies original-source equality, its complete
binding, zero spend and rejection of changed or missing captured bytes, including a valid
replacement whose original binding differs. A
private matched observer comparison distinguishes the old and corrected
readers. Earlier failed and incomplete runs remain failed or incomplete.
- **Remaining:** this repairs a consumer-qualification prerequisite. Complete
V1–V5/V10, R1/M3, current D2/D5 closure, actual Host/model context adoption,
progressive product control, comparable complete costs, C1 default cutover
and original-Goal regression remain open.
19 changes: 19 additions & 0 deletions docs/architecture/rfcs/monorepo-distribution-split-v0.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3160,3 +3160,22 @@ R1/M3、C1 切换和原目标回归仍未完成资格验证。
通过字符串强制转换,却生成 inactive policy,静默跳过研究证据。既有配置 owner
现在在 IO 之前拒绝这种错误形状;已声明的标量 mode、默认值和错误语义保持不变。
真实 File/SQLite 负向用例保护这个边界,不改变合法激活规则。


### 2026-11-14 — 策略观察者恢复原始签名来源

- **基线:**`main@8d7d234c6f55`;C1 #8266 为 `c3cb8b2fe7bf`。
- **缺口:**当前 C1 的三条 guided-start 和可见 Goal 选择用例,把必要
展示页当成原始签名决策而拒绝。原始捕获的物理摘要和完整合同校验均
通过。同页 Todo 引用及其读取说明改变了展示正文,但保留原来源绑定。
- **交付:**既有测试策略观察者在比较决策事实前,沿展示页声明的不可变
捕获及摘要读取原来源,复用物理捕获 reader。没有该引用的 inline/off
输出保留现有行为。生产者、决策、哈希编码、准入、结算 owner 和默认值
均未改变。
- **证据:**固定 C1 组合的既有真实 guided-start/可见 Goal CLI 用例通过。
稳定 File/SQLite 回归执行共享 typed 投影,验证原来源相等、完整绑定、
零扣额,并拒绝捕获字节被改动或缺失,以及完整校验通过但原绑定不同的替代捕获。私有匹配观察者比较区分旧 reader
与修复 reader。历史失败及未完成运行继续保持失败或未完成。
- **剩余:**本切片修复消费者资格的前置缺口。完整 V1–V5/V10、R1/M3、
当前 D2/D5 闭包、真实 Host/模型上下文采用、渐进产品控制、可比完整成本、
C1 默认切换和原 Goal 回归仍开放。
20 changes: 19 additions & 1 deletion tests/control_plane/codex_checkpoint_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,25 @@ def read_cli_policy_payload(stdout, *, returncode):
recovery = payload["recovery"]
if "reference_file" in recovery:
recovery = read_context_read_reference(recovery["reference_file"])[1]
return read_context_capture_file(recovery["path"], recovery["sha256"], private=True)[2]
payload = read_context_capture_file(recovery["path"], recovery["sha256"], private=True)[2]
if returncode == 0 and payload.get("schema_version") == "loopx_turn_envelope_v1":
details = payload.get("context_details", {})
command = details.get("command_template") if isinstance(details, dict) else None
if isinstance(command, str):
# A required view can reuse Todo rows while retaining the original
# binding. Inspect its declared immutable source for policy tests;
# the display itself is not the signed decision or model retention.
argv = shlex.split(command)
for flag in ("--capture-file", "--capture-sha256"):
if argv.count(flag) != 1:
raise ValueError("policy view requires one original capture and digest")
original = read_context_capture_file(
argv[argv.index("--capture-file") + 1],
argv[argv.index("--capture-sha256") + 1], private=True,
)[2]
if original.get("contract_binding") != payload.get("contract_binding"):
raise ValueError("policy view original capture binding mismatch")
payload = original
return payload


Expand Down
55 changes: 54 additions & 1 deletion tests/control_plane/test_work_context_host_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,64 @@
initialize_canonical_authority, isolate_sqlite_runtime, read_fixture_todos,
)
from tests.control_plane.test_quota_settlement_cli import (
AGENT_ID, GOAL_ID, TODO_ID, TURN_ID, _configure_read_only_todo,
AGENT_ID, GOAL_ID, TODO_ID, TURN_ID, _configure_read_only_todo, _configure_selectable_alternative,
_heartbeat_receipt_count, _run_cli, _spend_run_count, _write_fixture,
)


@pytest.mark.parametrize('provider', ['file', 'sqlite'])
def test_policy_observer_reads_original_signed_capture_after_todo_references(tmp_path, monkeypatch, provider):
from loopx.control_plane.quota.turn_envelope import assert_complete_turn_decision, compose_turn_decision
from loopx.control_plane.turn_driver.decision_capture import capture_progressive_context, write_decision_capture
from tests.control_plane.canonical_authority_fixture import initialize_canonical_source_fixture
from tests.control_plane.codex_checkpoint_fixture import read_cli_policy_payload

isolate_sqlite_runtime(tmp_path, monkeypatch)
project, runtime, registry = _write_fixture(tmp_path)
_configure_selectable_alternative(project)
initialize_canonical_source_fixture(runtime, GOAL_ID,
state_path=project / f'.codex/goals/{GOAL_ID}/ACTIVE_GOAL_STATE.md', provider=provider)
capture = tmp_path / 'signed-capture'
code, view = _run_cli(registry, runtime, 'quota', 'should-run', '--goal-id', GOAL_ID,
'--agent-id', AGENT_ID, '--begin-turn',
'--codex-app', '--complete-turn', '--context-delivery', 'auto', '--delta-delivery', 'off',
'--decision-output-dir', str(capture))
assert code == 0, view
saved = capture / 'decision.json'
original_bytes = saved.read_bytes()
original = json.loads(original_bytes)
# Exercise the same typed projection used by C1's inline CLI presentation.
(tmp_path / 'view').mkdir(mode=0o700)
view = capture_progressive_context(original, directory=tmp_path / 'view', surface='complete_turn')[0]
assert 'context_reference_instruction' in view and view != original
source = tmp_path / 'view' / 'projection.json'
observed = read_cli_policy_payload(json.dumps(view), returncode=code)
assert observed == original
assert_complete_turn_decision(observed)
assert _spend_run_count(runtime) == 0 and saved.read_bytes() == original_bytes
replacement = compose_turn_decision({
**{key: value for key, value in original.items() if key not in {'schema_version', 'contract_binding'}},
'reason': 'a separate valid captured observation',
})
assert_complete_turn_decision(replacement)
replacement_path = source.with_name('replacement.json')
replacement_digest = write_decision_capture(replacement_path, replacement)
replaced_view = copy.deepcopy(view)
argv = shlex.split(replaced_view['context_details']['command_template'])
argv[argv.index('--capture-file') + 1] = str(replacement_path)
argv[argv.index('--capture-sha256') + 1] = replacement_digest
replaced_view['context_details']['command_template'] = shlex.join(argv)
with pytest.raises(ValueError, match='original capture binding mismatch'):
read_cli_policy_payload(json.dumps(replaced_view), returncode=code)
# A copied presentation must not mask corruption of its declared source.
source.write_text(json.dumps({**original, 'reason': 'changed after capture'}))
with pytest.raises(ValueError, match='capture digest mismatch'):
read_cli_policy_payload(json.dumps(view), returncode=code)
source.unlink()
with pytest.raises(FileNotFoundError):
read_cli_policy_payload(json.dumps(view), returncode=code)


@pytest.mark.parametrize('provider', ['file', 'sqlite'])
@pytest.mark.parametrize('repetitions', [1, 40])
def test_authored_requirements_survive_capture_projection_and_host(tmp_path, monkeypatch, provider, repetitions):
Expand Down
Loading