Repository navigation
test(context): distinguish hook discovery from native session loading - #7429
loopx-agent wants to merge 1 commit into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; reasoning_effort=max; declaration_source=runtime_reported.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机
Problem and delivered scope. An operator can configure and trust native context hooks after a Codex thread has already been loaded. A fresh hooks/list can report enabled, trusted handlers while that thread still lacks its SessionStart context; the new qualification reproduces this and the setup guidance directs normal start/resume after the current work reaches a safe boundary. Both inline and standalone-file cases inspect actual local-provider model input: the late-configured thread lacks the marker, then normal process resume of the same thread delivers it and native lifecycle events. This PR does not fix host hot-loading, activate an installed App thread, qualify actual Code Mode page transport or establish natural model retention, effectiveness or cost benefit.
这次解决的是资格判断和使用说明的缺口。列表里已经 enabled/trusted,不能说明当前线程拿到了来源;新增测试用同一线程恢复前后的实际输入验证这一区别,并避免为了制造采用样本打断正在进行的工作。
改动思路
Ownership and proportionality. The only production change is setup prose in the existing context-config dispatcher; one optional callback in the existing native fixture exercises the timing boundary without a new runtime or test harness. The current PR delivers native discovery-versus-loading qualification and truthful setup guidance; configuration, trust, journaling, admission, authority and settlement remain in their existing owners. A wording-only change would leave the native claim untested; another process/provider harness would duplicate existing owners. No runtime loaded-state annotation or new activation gate is justified here.
The table is source-derived at 943b68010ab1beb1355fad8ec87b86c11eccf1ba, not a substitute for execution evidence. A plain table is used; Mermaid rendering was not inspected.
| State | Observed result | Meaning |
|---|---|---|
| Thread already created; hooks configured and exactly trusted afterward | handlers/list succeeds, marker absent from actual input | Discovery and trust are insufficient for current-thread initialization |
| Normal process resume of the same thread | SessionStart(source=resume), marker in subsequent inputs | Positive control for actual loading on the tested host |
| Context delivery off or unknown host | Complete CLI output matches immutable base | New advice does not leak into disabled or unsupported behavior |
原生进程、trust、线程和关闭流程继续由既有 fixture/宿主管理,只有本地推理响应和 hook 内容是合成的。正常恢复是已有操作,不增加确认轮次,也没有自动重启、安装或新的授权。
具体改动
关键代码讲解
handle_native_context_command: only the on-modeactivationstring changes. It explains that a loaded thread can retain its original hook configuration and places normal start/resume after the safe work boundary. Hook generation, explicit/inherited mode selection, disabled/invalid responses and authority remain unchanged._app_server: adds optionalbefore_turnafter thread creation/resume and before turn/start. Its default is None, preserving all existing callers, native request identities, completion waits and process cleanup.test_native_late_hook_discovery_does_not_deliver_session_context: tests inline TOML and standalone hooks.json. It verifies the exact synthetic source paths and native hashes before trust, observes the missing marker in actual input, then resumes the same thread and requires marker delivery, SessionStart/PostToolUse events and unchanged configuration bytes. It does not freeze whether tool hooks can hot-load in a future host.
The4-file diff is97additions/4deletions: setup prose, bilingual work-context/heartbeat guidance, and the existing native test fixture. No new store, schema, CLI option, global skill, provider policy or frontend component is added. The callback keeps process/transport plumbing together rather than adding another harness; the independent oracle is actual source delivery, not the output being tested.
Independent specification: docs/reference/required-work-context.md at 22196e81db063cbfabb4ca5591fbb83c7bc987c0, especially the pre-change native opt-in/next-session setup and immutable recovery clauses. The new paragraphs are not their own oracle.
| Criterion | Disposition |
|---|---|
| native-next-session-setup | implemented: exact synthetic trust and normal original-thread resume; setup installs/restarts nothing |
| source-before-reuse | implemented: actual input/event observation distinguishes discovery from delivery; known retention limits retained |
| original-full-recovery-and-off | implemented: paired off/unknown-host output exact and existing machine/CLI regressions pass |
| installed-host-and-model-boundary | out_of_scope: accepted lifecycle assumption does not certify installed Desktop or natural-model retention/benefit |
评审采用了历史经验中“沿真实用户任务检查操作、恢复与结果”的建议,同时保留其限制:这个内部资格切片不需要假装已经完成产品安装或自然模型采用。
对主干的风险
Actual native evidence. With the existing Codex 0.163.0-alpha.11.1 and deterministic loopback inference, the complete native boundary module reports 16passed/6xfailed. Both new late inline/file cases pass. The same module on immutable base reports 14passed/6xfailed; every existing xfail identity and reason is identical. Two failures concern incomplete source after failed compact hooks, two concern small additionalContext lost during automatic compaction, and two concern large additionalContext incomplete before first input. These are retained limitations, not repaired or promoted to passes.
CLI and default-off comparison. An independent same-path public-CLI comparison finds off and unknown-host JSON exactly equal at base/head. On-mode output differs only in activation; generated hooks, developer instructions and all other fields are equal. Missing registry/machine configuration remains absent, and the generated private context leaf is empty: setup did not install/trust hooks, initialize a journal, admit work or spend quota. The machine-configuration/context-CLI cohort passes80tests, with5existing conditional native-worker skips retained; the changed native boundary module was separately opted in and executed.
语义与 CI 对齐
The change reuses existing vocabulary. Before/after clause comparison retains the exact trust boundary, original full capture, invalidation recovery, explicit off and no execution authority. The intentional addition explains loaded-thread timing and a safe existing operation; it adds no machine obligation. Codex-specific terms belong to this provider adapter and do not enter generic Core obligations.
Changed-file Ruff passes. Standard risk-based premerge passes6direct and19selected checks, including compile, semantic advisory, output budget, public boundary and existing quota/scheduler controls. GitHub CI was not fetched, polled or used. The optional whole-repository lint failure disclosed by the author was not rerun or relabeled as independently attributed; changed-path lint and the native risk matrix are the checks executed here.
最强反例不是 hook 配置失败,而是配置确实被发现并信任、当前输入却仍缺少上下文。恢复后的同一来源正例排除了“测试 hook 本来就无效”的解释。六项既有 native 限制及五项条件跳过均保留,没有由数量或成功回执推导模型保留能力。
我的整体评价
APPROVE — scoped qualification/guidance goal achieved at 943b68010ab1beb1355fad8ec87b86c11eccf1ba. Long-horizon behavior is preserved: there is no host runtime, scheduling, source-recovery or settlement change. User experience is improved through truthful advice in the existing setup response, with no new setup choice, confirmation round or forced interruption. No rendered presentation changes: existing JSON setup guidance, Markdown and native tests only; no frontend components or layout changed. Unverified scope: installed App flow and actual Code Mode transport; no screenshot or live-adoption claim.
The small production prose change and reused fixture are proportionate. Native evidence is version-specific and synthetic; natural-model adoption, retention and complete costs remain unverified. Existing PR comments/reviews/inline arrays were empty when read. COMMENTED records this conclusion because the shared GitHub account also authored the PR; it is neither formal GitHub self-approval nor merge authority.
我认可这个有独立正反证据的资格与说明补充。它没有修复宿主热加载,也没有启用当前 App 线程;后续采用仍须在实际宿主按完整来源与恢复边界验收。
English verdict: APPROVE — 943b68010ab1beb1355fad8ec87b86c11eccf1ba; real native inline/file negative and same-thread resume controls pass, disabled CLI outputs match base, and existing six native limits remain disclosed. No installed/model-retention or merge qualification is claimed.
Goal And Delivered Outcome
Configuring and trusting native hooks after a Codex thread has started does not deliver that thread's missing
SessionStartcontext. A freshhooks/listcan show enabled, trusted handlers while the loaded thread still lacks the required context.Add a native qualification case for both inline TOML and standalone hook files. It configures exact trusted handlers after thread creation, verifies the source is absent from actual synthetic model input, then exits and resumes the same native thread and verifies lifecycle delivery. The test permits future hot-loading of tool hooks; it does not freeze their current absence.
The existing
quota context-configguidance and English/Chinese work-context documentation now distinguish discovery/trust from session loading. They direct normal host start/resume after active work reaches its safe boundary, preserving full delivery and the original capture meanwhile.Author Declaration
docs/reference/required-work-context.md#opt-in-native-reuseand native setup indocs/heartbeat-automation-prompt.md, at base22196e81db063cbfabb4ca5591fbb83c7bc987c0.Scope And Continuation
Complete within this activation-qualification and setup-guidance scope. Existing native fixtures retain their process/transport owner through one optional pre-turn setup callback; no second harness, state vocabulary or production abstraction is added.
This does not activate an installed App thread or repair the host's hot-loading behavior. Natural full → delta adoption, the App's actual Code Mode transport and complete costs remain separate qualification. The native cases set
code_mode_host=truebut exercise direct native shell calls with deterministic loopback inference. No effectiveness or fee benefit is claimed.Validation
Tested revision:
943b68010ab1beb1355fad8ec87b86c11eccf1ba. Run state: finished. Input classes: synthetic, public_fixture.The six native xfails retain existing large-output/compaction completeness limitations. The new cases do not relabel them or certify model retention. CQR accepts the final scope while retaining the live-adoption risk and additional lint failure.
Frontend / Visual Evidence
UI impact: none. Only CLI setup guidance, documentation content and the native test fixture change.
Boundary Checklist