mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
3.4 KiB
3.4 KiB
Workstream C – Core Port Notes (2025-11-15)
This log captures the incremental plan, trade-offs, and open questions while
porting upstream core crate changes into the forked code-rs tree.
Token Usage / Rate Limits
- Current fork status:
code-rs/core/src/account_usage.rsalready embeds the full token aggregation and rate-limit tracking stack (hourly → daily → monthly buckets, rate-limit snapshots, warning dedupe). Upstreamcodex-rsstill lacks this module, so the fork remains ahead. - Port delta: Added regression tests covering the new
record_usage_limit_hintpath and the compaction behaviour so we can safely align with future upstream shapes. This gives us parity with the behaviour highlighted incore-critical.mdwhile keeping the implementation fork-only for now. - Trade-off: Instead of moving the feature into
codex-rs, we keep storing usage locally to avoid regressing CLI telemetry. Downside is extra drift vs. upstream until they ship a matching feature set. - Open questions:
- Should we expose a
TokenUsageStoreabstraction so the upcoming agent lifecycle refactor can log usage without duplicating account lookups? - Do we need to rename the managed warning log (
rate_limit_warnings.log) when we eventually allow per-account purge tooling?
- Should we expose a
Config Loader
- Strategy: Adopt the upstream layered loader (base
config.toml+ managed_config + managed preferences) verbatim via a newconfig_loadermodule, then reuse it insideConfig::load. - Implementation: Copied the upstream module, added synchronous wrappers so
the existing blocking callers can drive the async loader (with a dedicated
helper that spawns a temporary Tokio runtime whenever we’re already inside
one), and switched the system-managed path to
/etc/code/managed_config.tomlto match the fork’s branding. - Trade-offs:
- We spin up a lightweight Tokio runtime when no runtime exists. This keeps behaviour deterministic but does introduce a small startup cost. Follow-up option: thread the loader through existing async contexts.
- macOS managed preferences still use the upstream bundle identifier
(
com.openai.codex). We need product input on whether enterprises expect a new ID (e.g.,com.just-every.code).
- Open questions:
- How should CODEX_HOME overrides interact with
/etc/code/managed_configon Linux? Upstream hard-codes/etc/codex; we mirrored that with/etc/code. - Do we need to support device-profile provisioning on non-macOS platforms sooner than upstream?
- How should CODEX_HOME overrides interact with
Agent Lifecycle Events
- Status: Investigation is in progress; upstream wires richer
AgentStatusUpdateEventpayloads throughAgentManagerandTurnContext. We haven’t ported these yet because token usage + config loader work took priority. - Plan:
- Diff
codex-rs/core/src/agent_tool.rsvs. the fork to map the new enums (AgentStatus::Initializing, etc.). - Update
code-rsprotocol models and event emitters to match, ensuring the TUI keeps strict ordering guarantees. - Extend the VT100 snapshot tests to assert the additional lifecycle rows.
- Diff
- Open questions:
- Upstream stamps events with per-turn IDs via
TurnContext; we need to confirm whether our Auto Drive overrides still work when those IDs change. - Should fork-specific UX (browser approvals, theming) emit extra fields on the new events, or stick to the upstream schema for now?
- Upstream stamps events with per-turn IDs via