Skip to content

test(stride): add synthetic stride-boundary shadow fixture - #3290

Merged
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:test/stride-boundary-synthetic-fixture
Aug 17, 2026
Merged

test(stride): add synthetic stride-boundary shadow fixture#3290
huangruiteng merged 1 commit into
huangruiteng:mainfrom
NIU-123370:test/stride-boundary-synthetic-fixture

Conversation

@NIU-123370

Copy link
Copy Markdown
Contributor

Adds one synthetic stride-boundary fixture for the read-only stride shadow observation (M1 #3207, RFC #3204), following the standing CONTRIBUTOR_TASKS.md invitation ("Add one synthetic lifecycle or stride-boundary fixture").

Test-only change: +241 lines appended to tests/control_plane/test_stride_observation.py under a single banner comment; zero runtime changes (git diff -- loopx/ is empty), so the canary baseline is untouched.

What the fixture proves

Four boundary tests, each pinned to an RFC §13 validation criterion (the mapping is cited in the test comments):

  • test_boundary_observation_stays_shadow_only_across_segment_states — criterion 8: shadow_only=True, effect.unknown=True, and empty recommendations across four synthetic segment states, plus a byte snapshot of the runtime tree before/after every build+evaluate proving the projection never mutates what it observes.
  • test_boundary_missing_metrics_stay_unknown_not_inferred_from_prose — criterion 2: when classification/delivery outcome are missing and marker words appear only in unread summary/notes prose, the projection reports material_slices=0, latest_outcome="none", segment_disposition="unknown" — never substring inference.
  • test_boundary_authority_changes_require_explicit_markers — criterion 6: status/monitor/review-style classifications never restart authority-window counting; only explicit replan/vision/gate markers do, and the latest marker wins.
  • test_boundary_projection_replays_byte_identical — criterion 3: two builds across two distinct runtime roots with identical synthetic receipts collapse to one unique sorted-key JSON serialization.

Fixture hygiene (per the invitation's constraints)

  • Explicit activation: hand-built synthetic run-index receipts only — no source/draft/review bodies, provider payloads, private locators, cursor state, or apply/publish authority.
  • No local paths or credentials anywhere in the fixtures.
  • Deterministic by construction: freshness offsets pinned at 45m and 12h, keeping replay assertions away from the 6h evidence-freshness wall-clock boundary.

Tests

python3.11 -m pytest tests/control_plane/test_stride_observation.py -q → 8 passed (4 pre-existing + 4 new), 0.03s.

Tracks #3203.

Assert the four RFC huangruiteng#3204 M1 shadow guarantees on hand-built synthetic
run receipts appended to the stride observation suite: shadow_only plus
a byte-identical runtime tree across boundary segment states (criterion
8), missing metrics stay unknown and are never inferred from prose
fields the projection never reads (criterion 2), authority changes
restart the bounded-slice count only via explicit replan/vision/gate
classifications and the latest marker wins (criterion 6), and identical
synthetic receipts replay byte-identical across two runtime roots
(criterion 3). No provider payloads, private locators, host paths, or
cursor state enter the fixture.

Tracks huangruiteng#3203

Signed-off-by: 牛瑞博 <912906590@qq.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: test(stride): add synthetic stride-boundary shadow fixture

Reviewed exact head: 321bcbae734dfde15645e570c75891e99d7fd6a7 (test/stride-boundary-synthetic-fixture), base main.

动机

RFC #3204 的 M1 stride shadow 观察目前只有 4 个基础测试,覆盖空目录、常规派生、陈旧证据与跨 agent 归属,但对 RFC §13 的边界准则(shadow-only 不变量、prose 不得被推断为指标、显式 authority marker 才重启计数、确定性 replay)没有回归锚点。本次按 CONTRIBUTOR_TASKS.md 的邀请新增一个合成边界 fixture,把四个最关键的只读投影契约钉死,防止后续实现 drift。

改动思路

纯测试改动:在 tests/control_plane/test_stride_observation.py 末尾追加 241 行,全部基于手工构造的 synthetic run-index receipts(复用已有 _write_run_index/_run 辅助函数),每个测试直接断言 build_stride_observation/evaluate_stride_observation 的输出。没有复制任何 provider payload、私有 locator、host 路径、凭据或 cursor 状态,canary baseline 未触碰(git diff -- loopx/ 为空)。

具体改动

四个测试分别对应 RFC §13 的一个准则:

  • test_boundary_observation_stays_shadow_only_across_segment_states(准则 8):四种 segment 状态下 shadow_only=Trueeffect.unknown=Truerecommendations=[],并用构建前后的字节级快照证明投影从不改写被观察的 runtime 树。
  • test_boundary_missing_metrics_stay_unknown_not_inferred_from_prose(准则 2):classification/delivery_outcome 缺失、而 "replan/gate/progress" 等词只出现在 summary/notes 时,material_slices=0latest_outcome="none"segment_disposition="unknown"——与模块只读 classificationdelivery_outcome、从不读 prose 字段的实现一致。
  • test_boundary_authority_changes_require_explicit_markers(准则 6):只有含 replan/vision/gate 的分类重启 bounded_slices_since_change 计数,status/monitor/review 分类不重启,且最新 marker 生效(marker 在 index 4 时计数为 1;无 marker 时 3 条全计)。
  • test_boundary_projection_replays_byte_identical(准则 3):相同 receipts 在两个不同 runtime root 各构建两次,序列化结果唯一——因为观察负载不包含 runtime_root 路径,确定性成立。

对主干的风险

  • 无运行时改动,风险面仅限测试文件本身;误判只会让 CI 捕获契约回归,不会改变任何 shipped 行为。
  • 时序确定性:freshness 偏移为 45m/5h/12h,5h 距 6h 新鲜边界仍有 1h 余量,测试在毫秒级内完成,不存在跨边界翻转的实际风险;datetime.now(UTC) 相对偏移是现有测试文件的既有模式。
  • 体积方面 4 个测试 +241 行偏厚,但每个都对应独立 RFC 准则且复用现有 helper;若后续补齐更多准则,可考虑参数化共享骨架,非本次阻塞项。
  • fixture 卫生已扫描:无凭据、私有路径或内部链接,git diff --check 干净。

验证

  • 本地:tests/control_plane/test_stride_observation.py 8 passed(4 旧 + 4 新)。
  • CI:Sign-off / dependency-review / pytest 全部成功,无 pending。
  • 语义核对:逐条对照 loopx/control_plane/runtime/stride_observation.py 实现(marker 子串匹配、latest-marker 覆盖、delivery_outcome=="outcome_progress" 计数、输出不含 runtime_root),断言与实现一致。
  • 变更仅 1 个文件、+241/−0,单 commit 且含 Signed-off-by。

整体评价

这是一个高质量、边界明确的合成 fixture:每个断言都能回溯到 RFC §13 的验收准则,且验证的是可复用的只读控制面契约,符合 durable smoke 保留标准。无阻塞项。


English verdict: APPROVE — test-only synthetic stride-boundary fixture with four assertions mapped to RFC #3204 §13 criteria (shadow-only read contract, no prose inference, explicit authority markers with latest-wins, byte-identical replay); verified against the implementation, no runtime changes, fixture hygiene clean, local 8/8 and all CI checks green. Reviewed at exact head 321bcbae734dfde15645e570c75891e99d7fd6a7. No blockers; optional P2 is to parameterize the shared state-dict skeleton if more §13 criteria follow.

@huangruiteng
huangruiteng merged commit 3c58445 into huangruiteng:main Aug 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants