Skip to content

Module 0 core - #1

Merged
mohdcodes merged 4 commits into
mainfrom
module-0-core
Jul 19, 2026
Merged

Module 0 core#1
mohdcodes merged 4 commits into
mainfrom
module-0-core

Conversation

@mohdcodes

Copy link
Copy Markdown
Owner

Module 0 — Core Foundation

Establishes the foundation every later module builds on: the canonical result object, central configuration, and the logging system. No features yet by design — just the spine, done right and frozen, so Modules 1–11 never redefine it.

What's included

Core domain model (agentargus/core/results.py)

  • RunResult — the single canonical result object that is the spine of the system, plus value objects Span, ToolCall, Step, ErrorRecord, CostBreakdown.
  • Deep immutability: frozen=True dataclasses with collection fields stored as tuples and mappings as read-only views — genuinely immutable, not just top-level frozen.
  • with_scores() returns a new RunResult (copy-on-write) rather than mutating; to_dict() / from_dict() provide a JSON round-trip.

Configuration & judge seam (agentargus/config.py)

  • AgentArgusConfig — env + explicit-kwarg resolution (explicit wins).
  • Judge protocol — the injectable LLM-as-judge seam. No provider client ships in the base package (framework-agnostic, minimal deps); adapters live behind extras.
  • batch_complete() helper for optional batched judging.

Logging system (agentargus/logging.py)

  • Single get_logger() factory; color + JSON formatters.
  • trace_id correlation via contextvars (bridges logs ↔ traces, survives async boundaries).
  • Color auto-disabled off-TTY, on NO_COLOR, or via config; print() banned in library code via ruff T20.

Internal exceptions (agentargus/_internal/exceptions.py)

  • AgentArgusError, ConfigError, SerializationError — one home for library error types.

Tooling & packaging

  • pyproject.toml (hatchling), .ruff.toml, CI matrix on Python 3.10 / 3.11 / 3.12 (ruff → format-check → mypy strict → pytest).

Review-driven hardening (from HARD_QUESTIONS)

  • Fail-fast on malformed cost ceilingConfigError (never silently default a safety limit).
  • Serialization fails loudly, naming the offending field, instead of a silent lossy fallback.
  • Thread-safe configure_logging (lock + atomic handler swap).
  • Judge protocol kept minimal so simple complete-only adapters still satisfy isinstance (batching is a duck-typed optional extension).

Notes

  • Verified methodoverload (v0.1.7) against its source; documented the real API in docs/concepts/methodoverload.md. The spec's OverloadMeta metaclass is not part of the public API — @overload works on methods without it.
  • Removed the v0.0.0 reservation stub in favour of the standard root package layout.

Verification

  • ✅ 36 tests passing, 96% coverage (gate: 80%)
  • ruff check + ruff format --check clean
  • mypy --strict clean
  • ✅ Package imports; public API surface confirmed

Definition of Done

  • §6 core contract implemented
  • Mandatory §8 tests (immutability, serialization round-trip, config, logging)
  • ruff / mypy / pytest green
  • No print(); correct log levels + trace correlation
  • DESIGN_LOG.md entry + HARD_QUESTIONS.md batch written

arbaazcode and others added 4 commits July 19, 2026 16:01
- RunResult and value objects: deep-immutable frozen dataclasses (tuples +
  read-only mappings); with_scores returns a new object.
- AgentArgusConfig (env + kwargs) and injectable Judge protocol (no bundled
  provider client).
- Logging: get_logger factory, color + JSON formatters, contextvars trace
  correlation, TTY/NO_COLOR gating, print() banned via ruff T20.
- Tooling: hatchling pyproject, ruff, mypy strict, CI matrix 3.10/3.11/3.12.
- 30 tests, 96% coverage; ruff + mypy clean.
- DESIGN_LOG + HARD_QUESTIONS for Module 0. NOTE: methodoverload 0.1.7 has no
  OverloadMeta (spec §4 out of date); @overload works on methods with no
  metaclass. Documented in DESIGN_LOG.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
HARD_QUESTIONS-driven improvements (owner review):
- #5 configure_logging: threading.Lock + atomic handler swap (never half-configured)
- #6 batch_complete() helper probes optional complete_batch; Judge keeps
  complete as its only required protocol member (adding it broke isinstance)
- #7 to_dict coerces via _jsonable (JSON -> .to_dict() -> SerializationError
  naming the field); no silent lossy fallback
- #9 malformed AGENTARGUS_COST_CEILING_USD now raises ConfigError (fail-fast)
- new _internal/exceptions.py: AgentArgusError, ConfigError, SerializationError

methodoverload (studied gracefully, not forced):
- read installed source + PyPI; wrote docs/concepts/methodoverload.md
- public API is exactly overload/OverloadedFunction/NoMatchingOverloadError;
  OverloadMeta is internal-only (spec §4 out of date) -> we don't use it
- documented isinstance dispatch, no-generics, first-match-wins, the
  bool<:int ordering trap, and the callable non-fit for Agent.wrap

40 -> 36 tests all green, 96% coverage; ruff + mypy clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The nested AgentArgus/ folder was the PyPI name-reservation stub (empty
__init__, planning-stage pyproject, placeholder README). Module 0 supersedes
it with a real package at the repo root (standard Python layout). Remote
history is preserved; only the stub tree is dropped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Untrack IMPLEMENTAION.md (private build spec); the public decision record is
  DESIGN.md / DESIGN_LOG.md / HARD_QUESTIONS.md.
- gitignore IMPLEMENTAION.md and module_notes/ (local per-module study notes).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mohdcodes
mohdcodes merged commit ae12b3e into main Jul 19, 2026
3 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