Skip to content

test(lark): pin the manager context window's bounds and order - #4900

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
hahahahahayesyeseys:codex/test-manager-context-window
Sep 22, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
hahahahahayesyeseys:codex/test-manager-context-window

Conversation

@hahahahahayesyeseys

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Goal/source and gap: Lark manager: decouple context capture from Turn authority #4318's capture/authority split is implemented and its read side is manager_context_materials(). Its contract is three named limits -- at most MANAGER_CONTEXT_ITEM_LIMIT messages, at most MANAGER_CONTEXT_CHARACTER_LIMIT characters, consumed newest-first so the surviving set is returned in chronological order. None of the three was tested: searching the suite for the constants, the per-item cap or context_window_exceeded returns nothing, and only the _for_ids replay sibling is exercised directly. So the issue's "bounded" clause had no enforcement behind it.
  • Observable before -> after: before, three mutations of the window all passed unnoticed or were caught only indirectly; after, each is caught by a named case (see the mutation row). No production behavior changes.
  • Issue reference: Refs Lark manager: decouple context capture from Turn authority #4318. Tests only.

Scope And Continuation

  • Delivered: three cases in the file that already owns manager context and its retention receipts, written from the contract rather than from recorded output -- window keeps the newest and restores arrival order, the character budget is spent from the newest side so the oldest survivor is the clipped one, and addressed/current messages never enter context while replayed history does.
  • Remaining work, named rather than folded in: MANAGER_CONTEXT_RETENTION_LIMIT = 32 and MANAGER_CONTEXT_MAX_AGE are partially covered by the retention test in the same file, and the context_window_exceeded label still has no case of its own. Those belong to the retention path, not to this window, and none of them is a blocker here.
  • Boundary / successor: this adds coverage to a merged contract (fix(lark): preserve context without granting Turn authority #4319); no follow-up PR is implied.

Validation

  • Tested revision: 4496de4 (current head).
  • Run state: finished. Input classes: synthetic.
Check kind Result Public-safe evidence / limitation
unit passed tests/extensions/test_lark_manager_reply_delivery.py: 8 passed, of which the 3 added here are new
unit passed tests/extensions: 952 passed at this head -- the added file is collected with its neighbors unchanged
regression_parity passed mutation, not assertion count: take the oldest slice instead of the newest -> only the window case fails; drop the final chronological restore -> all three fail; let addressed messages into the window -> only the exclusion case fails. Each case therefore binds a distinct property
static passed ruff check clean on the changed file; py_compile clean; git diff --check clean; loopx check --scan-path on the changed file reports 0 errors
  • Base note, stated rather than left to inspection: this branch is rooted at 04ba65ac1, which is behind main. The two files it depends on -- loopx/extensions/lark/manager_context.py and this test file -- are byte-identical between that revision and current main (verified by blob hash), so nothing here is measured against stale behavior. It is based there because pushing a current-main branch from this fork requires a token scope this author's token does not carry, while a fork sync is pending.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A -- no persisted schema, receipt or cursor contract changes.
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A -- tests only.
  • Provider conformance arms run: none; no provider or AuthorityStore selection changes.
  • Read-only legacy/file/PostgreSQL three-arm rehearsal: not applicable.

Boundary Checklist

  • Neither the diff nor this PR body discloses private state, credentials, raw traces, internal links or local machine paths.
  • I did not duplicate maintainer-owned work.
  • I kept the change scoped to the linked issue.
  • I completed the visual evidence section for UI changes, or marked UI impact none. -- UI impact: none; no presentation surface is touched, the change is a test file.
  • Every commit includes a DCO Signed-off-by trailer.

`manager_context_materials()` is the read side of loopx-project#4318's capture/authority
split, and its contract is three named limits -- at most
MANAGER_CONTEXT_ITEM_LIMIT messages, at most MANAGER_CONTEXT_CHARACTER_LIMIT
characters, consumed newest-first so the surviving set stays chronological.
None of the three had a test: searching the suite for the constants, the
per-item cap or `context_window_exceeded` returns nothing, and only the
`_for_ids` replay sibling is exercised directly.

Each case is written from the contract rather than from current output, and
each is checked by mutation: taking the oldest slice instead of the newest
fails the window case, dropping the final chronological restore fails all
three, and letting addressed messages into the window fails the exclusion
case. No production behavior changes.

Refs loopx-project#4318

Signed-off-by: hahahahahayesyeseys <95999512+hahahahahayesyeseys@users.noreply.github.com>

@huangruiteng huangruiteng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

动机

#4318 已交付 Lark manager 的“context capture 与 Turn authority 分离”,但它要求后续 authorized Turn 只读取有界的近期上下文。现有测试覆盖 retention、receipt-bound replay 和 capture/authority 分离,却没有直接调用 manager_context_materials() 来约束三个关键性质:最多 8 条、总计最多 4000 字符、从最新消息一侧消费预算后按时间顺序返回。这个 PR 只补这一真实 coverage gap,不改变生产行为。

改动思路

三个测试都从公开的持久行为设计 oracle,而不是照抄当前输出:超出 item limit 时必须丢最旧三条并保持 survivor arrival order;字符预算必须优先保护最新消息,只有最旧 survivor 可被截断;current/addressed authority-bearing 消息不得同时作为 quiet context,而 historical_context_only replay 仍可进入窗口。测试直接走生产 read helper,没有新增 fixture framework、mock owner 或第二套规则。

具体改动

  • 在既有 test_lark_manager_reply_delivery.py 中增加一个小型 _chat_window synthetic fixture。
  • 增加 newest-window/order 用例,直接绑定 MANAGER_CONTEXT_ITEM_LIMIT。
  • 增加 newest-side character-budget 用例,绑定 MANAGER_CONTEXT_CHARACTER_LIMIT 和截断方向。
  • 增加 current/addressed exclusion 与 historical replay inclusion 用例,守住 context/authority 分界。

关键测试讲解

test_context_window_keeps_the_newest_messages_in_arrival_order 同时防止“取 oldest slice”和“返回 reverse order”;test_context_character_budget_is_spent_from_the_newest_side 让 8×1200 字符触发 4000 限制,期望 chronological sizes 为 [400, 1200, 1200, 1200];test_context_materials_exclude_the_addressed_and_the_current_message 用同一 projection 同时证明 current/addressed 被排除而 explicit historical context 被保留。

对主干的风险

这是 test-only diff,无 schema、runtime、permission、quota 或 UI 变化。独立覆盖扫描确认 merge base 上只有 _for_ids replay sibling 被直接调用,item/character constants 没有测试;同作者当前只有这一项 open PR,没有 same-shape batch farming。exact head 的 changed file suite 8 passed,Ruff、py_compile、diff check 与 public boundary scan通过;标准 canary通过。由于该分支基于旧 merge base,我还把 patch 干净合入最新 origin/main@0d464d2ac,保留主干后来新增的 proposal-delivery test,合并态 suite 6 passed。

有一个非阻塞的证据表述需要更正:PR body 说 production file 和 test file 在旧 base 与当前 main 间都 byte-identical;独立 blob hash 显示 production manager_context.py 的确相同,但 test file 不同(主干后来新增了其它测试)。这不影响 patch 的可合并性或测试结论,因为合并态已单独验证,但建议作者把 body 改成“production file identical,test patch cleanly integrates”。

我的整体评价

这 82 行不是一次性 walkthrough:它给已发布的 manager context window 增加三条互补、可产生突变敏感性的长期 contract tests,位置与现有 retention/replay suite一致,且没有重复覆盖或批量灌水。除 PR body 的非阻塞 base 描述修正外,未发现 blocker,我赞成在当前 exact head 上 APPROVE;合并动作仍由 maintainer 决定。

English verdict: APPROVE - head 4496de4; three durable tests now pin newest-first bounds, chronological output, and context/authority exclusion, while the stale-base body note should be corrected; exact-head 8/8 and latest-main integration 6/6 passed with static and boundary checks clean.

@huangruiteng
huangruiteng merged commit 709734c into loopx-project:main Sep 22, 2026
18 of 22 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