Skip to content

feat/codex state provenance - #6580

Merged
M4n5ter merged 7 commits into
rust-previewfrom
feat/codex-state-provenance
Nov 3, 2026
Merged

M4n5ter merged 7 commits into
rust-previewfrom
feat/codex-state-provenance

Conversation

@me2seeks

@me2seeks me2seeks commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #6579. Stack layer 1/4: retain subscription comp_hash and record immutable, non-secret producer observations in each logical model request.

ChatGPT-only discovery is owned by Host and shared per connection. It refreshes on use at 270 seconds, rereads canonical configuration, and conditionally commits through existing model-fetch/OAuth tickets. Each discovery has a 15-second deadline; a replaced account may wait for the old flight before starting its own. Failures retain ordinary model execution without stamping new compatibility evidence and back off for 30–60 seconds. Warm/backed-off preparation does not await discovery. The 300-second TTL governs catalog refresh, not the lifetime of recorded checkpoints or producer facts. Account/connection scope isolates observations and does not forbid cross-account replay.

Accepted work freezes user controls separately from live inventory observations and uses those controls for every logical step, auxiliary preparation and restore. Each logical preparation derives capabilities, options, context limits and output budget from one current model snapshot; physical retries retain their frozen request. Discovery recovery can update an unknown budget without rejecting unchanged accepted/restored work. Later default and presentation edits apply only to subsequently accepted messages; the running/queued message continues with its captured model override, thinking/tool settings, threshold and body controls. Provider identity, connection availability, current credential authorization and actual adapter/protocol/endpoint remain checked independently. The old output-capacity fallback is not restored, and there is no migration/compatibility decoder. Arbitrary 1,024-entry cache and 128-byte hash limits are removed.

Native /compact, unified cross-model replay admission and switch/window preflight remain separate stack layers.

Latest review fixes

Changing only a selected model's display name no longer interrupts accepted work. The previous whole-override/body/configuration equality guard is removed; request resolution uses the accepted override and body rather than current defaults, while a small resolved-route check retains transport authority. The existing frozen-tool-policy test still expects successful restoration and now also checks old/new output budgets and body controls. An actual Host test covers presentation edits, auxiliary preparation, route replacement and connection disabling. Workhub fixtures use the current accepted-model shape; the inventory test accepts and preserves a 129-byte hash rather than restoring a length limit.

Verification

  • Host selection: 4 passed, including frozen old settings/new-message defaults and display-only edits with route/disable checks. Workhub catalog transaction/pagination: 2 passed. Provider inventory: 4 passed, including a long opaque hash.
  • cargo test --locked -p maka-agent-native --lib model::codex_inventory::tests: 9 passed at this layer, including discovery failure/recovery, restoration with live facts and frozen controls, and long opaque hashes. Existing single-flight, cancellation, supersession, login replacement, restart and backoff scenarios remain covered.
  • cargo clippy --locked -p maka-agent-native --lib --tests -- -D warnings: passed at this layer.
  • The updated full stack additionally passes facts (63), model (48), event-log compaction (15), native engine (6), text/background compaction, handoff, pruning and frozen-request checks; Host test compilation and scoped Clippy also pass.
  • Formatting and git diff --check pass. Full repository just check was not run. The latest hosted run passed build, Clippy, packaging and Desktop checks, but failed two Goal tests whose expectations conflicted with this PR’s frozen admitted-settings behavior. Those tests now verify that existing Goal grants retain approved defaults, newly admitted messages use edited defaults, and a real endpoint replacement still pauses until reapproval. All 11 Goal tests pass locally; hosted CI must rerun on the updated stack.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex implementation and tests; independent GPT-6.1 Terra medium read-only review of the fixes found no concrete remaining issue. AI review does not replace human review.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…tory refresh

Refs #6579. Stack layer 1: capture comp_hash and immutable request provenance, with Host-owned single-flight refresh and bounded failure backoff.

Generated-by: Codex
Recheck canonical observations after a superseded identity flight and reuse a newer committed connection revision for queued callers. Capture request account provenance after OAuth resolution and discard proof for a different account.

Generated-by: Codex
@me2seeks
me2seeks marked this pull request as ready for review November 2, 2026 14:30
@me2seeks
me2seeks added this pull request to stack #6585 November 2, 2026 16:42

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

I reviewed all 20 changed files at 09d7215e758735d7ca3a4a688de9d9adc307d414, including the new inventory owner and seven lifecycle tests, model selection/capture, OAuth ticket acceptance, request facts, inventory parsing and the removed output-capacity fallback.

I found one P2, detailed inline at plugins/agent/native/src/model.rs:447: discovery failure followed by successful refresh can change the output budget and make the unchanged accepted execution fail its configuration comparison. Previously accepted requests can encounter the same comparison failure on restoration. The isolated Rust probe uses extracted production expressions/functions with controlled surrounding types; restoring only the removed capacity fallback fixes both rejection scenarios. Six controlled scenarios completed as expected. This does not establish a full Host, actual HTTP or real OAuth reproduction.

The shared work is owned by the Host, with a 15-second discovery bound and 30–60 second failure backoff. The code rereads canonical configuration after waits, conditionally commits through the existing model-fetch ticket, scopes observations by connection/account material, and omits compatibility evidence when it cannot establish a fresh matching observation. Request preparation reconciles the recorded account with the resolved credential. I did not find a confirmed cross-account proof leak in those paths. This layer records provenance; it does not implement native compaction, cross-model replay admission or model-switch capacity recovery.

CI run 41461222710 is failed. I read its logs: the missing Input.base and three plugin-core Clippy diagnostics are unchanged current-base content. The desktop suite recorded 18 passes and one failure: desktop_mermaid_renders_in_the_real_conversation_and_keeps_source_available could not find a single “Hide diagram source” control. I have not established that this PR caused that UI failure. The root tests were skipped, so CI does not supply execution evidence for the seven new inventory lifecycle tests. The PR's reported package-test results remain author-provided evidence.

A fresh static merge into rust-preview 44c626fc50267b902873c1dac2d799ce27f1a9da succeeds. I did not run repository Cargo suites, a real login/account replacement, persisted-root upgrade, or the complete native Host. The six-case probe used a temporary standalone Rust compiler and controlled catalog data. Those limits, the P2 above and the failed hosted run remain relevant to the merge decision.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

.observe_model(self.accepted.binding.clone())
.await
.map_err(|_| unavailable())?
.ok_or_else(unavailable)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Keep accepted execution valid when inventory discovery recovers

The automatic refresh can change main_output_limit underneath an accepted request. With a saved/empty account model lacking output capacity and a captured absence of public defaults, failed initial discovery now admits gpt-6-luna with None: this PR removed the provider's known-capacity fallback. After the 30–60 second backoff, successful discovery supplies Some(128000) through decode_model_inventory. The reread here then reaches the unchanged ExecutionBasis comparison below and returns agent_model_unavailable, although the model, account, route and user settings did not change. A persisted request accepted by the parent with Some(128000) also fails if discovery is unavailable after upgrading.

I compiled the actual model initializer, ExecutionBasis::new and rejection guard with controlled model/catalog types. The failure→recovery case changes None to Some(128000) and rejects; restoring only the deleted fallback keeps the basis equal and passes. The corresponding old-accepted-request case rejects on the new code and passes with that same branch restored; unchanged discovered capacity and an explicit 4096-token override are passing controls. The 128000 value comes from this commit's bundled openai-codex facts; its bundled catalog has no chatgpt provider entry. This is an isolated comparison probe, not a full Host or live OAuth run.

Keep accepted execution parameters stable across automatic discovery recovery, and cover both recovery after a failed fetch and restoration of a previously accepted request. Preserve the checks for actual route/control changes.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

English

The stack-wide feedback is in the review on #6579. For this PR, the relevant points are 1, 4 and 5:

  1. Separate accepted user configuration from live model observations. In native/src/model.rs, ExecutionBasis includes resolved capabilities, options and output budget, and observe() compares a new resolution against that entire accepted basis. A catalog refresh that changes the resolved output budget can therefore invalidate accepted work even when the user changed nothing. At the same time, request context continues to come from accepted.context. Please clarify the freezing boundary, use one prepared snapshot per logical request, and retain that snapshot for physical retries. Restoring the old capacity fallback would leave the underlying fact-model problem in place.

  2. Remove limits without an actual constraint behind them. I have not found a basis for the 1,024-entry inventory cache limit or the 128-byte comp_hash limit. The cache-capacity branch stops refresh for new connections, so this affects functionality rather than just cache efficiency. The 300-second model-catalog TTL does have an upstream precedent; it is a refresh policy, not a checkpoint/provenance expiration rule. Please separately explain the 270-second early refresh, 15-second timeout and 30–60-second backoff.

  3. Explain foreground waiting for automatic discovery. auto_context::start() awaits compact::capture() before spawning background execution, and the new preparation path may await catalog network I/O. Necessary foreground preparation is legitimate and also exists upstream. Please make clear which operations must wait for new observations, which ordinary requests can proceed without them, and the cold-cache/slow-network latency tradeoff. I am asking for an explicit waiting policy, not claiming that async compaction has already regressed.

Please address points 1 and 4 before merging and clarify point 5. Preserve Host ownership of shared discovery and its cancellation/settlement behavior. Upstream's missing-hash behavior and catalog TTL should not be turned into additional replay restrictions without a product requirement.

简体中文

整组改动的意见见 #6579 总评。这条 PR 对应总评的 第 1、4、5 项:

  1. 区分已受理的用户配置和动态模型观测。 native/src/model.rs 的 ExecutionBasis 包含解析后的能力、选项和输出预算,observe() 又拿最新解析结果与整个 accepted basis 比较。模型列表刷新改变输出预算时,用户没有修改过的已受理执行也可能失效;与此同时,请求 context 仍来自 accepted.context。请明确冻结边界,为每个逻辑请求准备一致的快照,并让物理重试沿用该快照。恢复旧容量兜底仍会留下事实模型上的问题。

  2. 删除没有实际约束依据的限制。 目前未看到 inventory 缓存 1024 条上限、comp_hash 128 字节上限的依据。缓存容量分支会停止新连接的刷新,因此会影响功能,并非只影响缓存效率。300 秒模型列表 TTL 有上游先例,它是刷新策略,不是检查点或来源事实的过期规则。270 秒提前刷新、15 秒超时和 30–60 秒退避,请分别说明取值依据。

  3. 说明自动发现的前台等待策略。 auto_context::start() 在启动后台执行前,会先等待 compact::capture(),而新的准备路径可能等待模型列表网络请求。必要的前台准备是合理的,上游也有这个阶段。请说清哪些操作必须等待新观测,哪些普通请求可以继续,以及冷缓存、慢网络时的延迟取舍。这里要求明确等待策略,没有认定异步压缩已经发生回归。

第 1、4 项建议在合并前处理,第 5 项请明确取舍。共享发现任务的 Host 所有权,以及取消和结算行为,应当保留。上游的 hash 缺失处理和模型列表 TTL,不应在没有产品需求的情况下变成额外的回放限制。

Prepare request context and output budgets from one current model observation. Preserve accepted user controls across discovery recovery and restoration, remove arbitrary inventory/hash limits, and document foreground refresh policy.

Refs #6579

Generated-by: Codex
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Nov 3, 2026

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

English

This revision separates live model observations from user configuration and removes the unsupported inventory-cache and hash-length limits. Those changes are heading in the right direction.

However, Source::observe() still compares the entire ModelOverride. I verified with an actual Host test that, after the system accepts a message and selects its model, changing only that model’s display name makes the next request preparation return agent_model_unavailable. This affects providers beyond ChatGPT.

I think the execution model deserves further discussion here, rather than just adjusting which fields participate in equality. Could we use the following rules?

  1. When the system accepts a message, record the user settings for processing it: the model, thinking level, tool policy, request-parameter overrides, and so on.
  2. Processing that message may involve several model and tool calls, all using those recorded user settings. Later changes to defaults apply to subsequently accepted messages.
  3. When preparing each new model request, still read the latest provider model information, such as capacity, capabilities and comp_hash, and combine it with the recorded user settings.
  4. Retries of the same request continue using its original parameters and content.

This would remove the mechanism that repeatedly checks whether current configuration is exactly equal to the old configuration. Connection disabling, credential revocation and actual route changes would remain subject to the existing validity and authorization checks; display names, descriptions and other metadata would not interrupt messages already running or queued.

Does that match the intended behavior here? If some settings should immediately affect messages already running, we can discuss those exceptions explicitly, rather than letting equality of the entire configuration structure decide implicitly.

There are also two CI updates still needed:

  • The Workhub tests still construct the old context and basis fields, so two transaction and pagination tests fail during deserialization. Please update their fixtures and retain the behavioral checks.
  • The provider inventory test still requires a 129-byte hash to be rejected. With the length limit removed, that assertion should also be removed; please do not restore the limit to satisfy the old test.

The existing frozen-tool-policy test should not simply be changed to expect failure after a settings change. I suggest agreeing on the execution behavior first, then updating the tests accordingly.

简体中文

这次修改分开了动态模型信息和用户配置,也删除了没有依据的缓存及 hash 长度上限,方向是对的。

不过,Source::observe() 仍然对整份 ModelOverride 判等。我用实际 Host 测试确认:系统接收一条消息、确定使用的模型后,仅修改这个模型的显示名称,下一次准备模型请求就会返回 agent_model_unavailable。这个影响不限于 ChatGPT。

我觉得这里值得进一步讨论执行方式,而不只是调整参与判等的字段。能否采用下面的规则:

  1. 系统接收一条消息时,记录处理这条消息所使用的模型、思考级别、工具策略和请求参数覆盖等用户设置。
  2. 处理这条消息可能需要多次模型调用和工具调用,期间继续使用已经确定的用户设置。之后修改默认设置,影响后续新接收的消息。
  3. 每次准备新的模型请求时,仍读取最新的提供商模型信息,例如容量、能力和 comp_hash,再结合上述用户设置生成请求。
  4. 同一个请求发生重试时,继续使用原请求的参数和内容。

这样就可以删除“每次比较当前配置是否仍与旧配置完全相同”的机制。连接停用、凭据撤销和实际路由变化,继续通过现有的有效性及授权检查处理;显示名称、描述等元数据则不会中断正在执行或排队的消息。

这是否符合这里预期的行为?如果某些设置确实需要立即影响正在执行的消息,也可以明确讨论这些例外,而不是让整份配置结构的判等隐含决定。

另外,当前 CI 还有两处需要同步:

  • Workhub 测试仍构造旧的 context、basis 字段,导致两个事务及分页测试在反序列化阶段就失败。请更新测试数据,保留这些行为验证。
  • 提供商目录测试仍要求拒绝 129 字节的 hash。删除长度上限后,对应断言也应删除,不要恢复上限来满足旧测试。

已有的工具策略冻结测试不宜直接改成“修改设置后应当失败”。建议先对齐执行行为,再调整测试。

Resolve each logical request from current model observations and captured user overrides and body controls. Guard actual transport routes instead of comparing mutable defaults; retain the frozen tool-policy test and update Workhub and inventory fixtures.

Refs #6579

Generated-by: Codex
Retain both the upstream performance documentation and the subscription inventory guidance.

Generated-by: Codex
Keep admitted Goal settings frozen while requiring fresh approval for an endpoint replacement. Verify new messages receive edited defaults.

Refs #6579

Generated-by: Codex
@M4n5ter
M4n5ter merged commit cc87960 into rust-preview Nov 3, 2026
38 checks passed
@M4n5ter
M4n5ter deleted the feat/codex-state-provenance branch November 3, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants