Skip to content

refactor: extract shared runtime foundation - #13

Merged
zhanghanduo merged 2 commits into
mainfrom
refactor/runtime-foundation
Sep 1, 2026
Merged

zhanghanduo merged 2 commits into
mainfrom
refactor/runtime-foundation

Conversation

@zhanghanduo

Copy link
Copy Markdown
Collaborator

Summary

  • extract product-neutral identity/status and kernel event contracts
  • extract execution ContextVars, including per-tool budget and provider-chain scope
  • extract failure-isolated async event dispatch
  • extract composable fail-closed tool permission policy
  • document the runtime-foundation boundary and compatibility union

Validation

  • uv run ruff check agent_core tests
  • uv run pyright agent_core (strict, 0 errors)
  • uv run pytest -q (483 passed)

Downstream

Follow-up PRs will stack on refactor/agent-core in ApodexHarness and FrontierAgentInternal and pin this immutable commit.

zhanghanduo and others added 2 commits September 1, 2026 17:09
tool_permission:
- from_execution_policy now tolerates None-valued deny attributes, which
  crashed policy construction for the common `deny_tools: tuple | None`
  shape (getattr only falls back when the attribute is absent).
- Normalize case in __post_init__ so direct construction no longer
  silently denies every tool a caller listed with mixed case.
- Document that a single True entry in a config map makes the map an
  exhaustive allowlist, and lock that semantic with a test.
- Widen filter() to Iterable[str].

execution_context:
- normalize_execution_context deep-copies, so mutating nested scope
  metadata no longer writes through to persisted checkpoint state; it
  degrades to a shallow copy with a warning if a value is uncopyable.
- role_id is authoritative for agent_id, so a stale value persisted by a
  previous phase no longer misattributes this role's work.

runtime/events:
- Give each handler its own payload copy (they interleave at every await)
  and let the published event_type win over one carried in the payload.
- Add unsubscribe/unsubscribe_all/clear so a long-lived bus no longer
  retains every finished task's handler.

Also re-export the new symbols from the package inits, matching the
convention set by SpillStore/LLMClient, and add 11 regression tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zhanghanduo
zhanghanduo merged commit f072088 into main Sep 1, 2026
1 check passed
@zhanghanduo
zhanghanduo deleted the refactor/runtime-foundation branch September 1, 2026 09:46
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.

1 participant