Skip to content

[T-002b] core.errors: RoboProbeError hierarchy with stable error codes #16

Closed

Description

@CodewithJha

Task T-002b · Milestone M1 — Foundation · Size XS · Priority P0 · Epic #1

Implements FR-API-003

Branch feat/t-002b-core-errors-roboprobeerror-hierarchy-with — one task = one branch = one PR (doc 32 §6)

Summary

Implement the typed error hierarchy of doc 34 §5 with stable code, human message and structured context, used by API (problem+json), workers (INVALID mapping) and CLI (exit codes).

Context / motivation

Consistent errors are what let the API map exceptions to RFC 9457 responses and the CLI to exit codes (05 §11) without if isinstance chains spread across the code base.

Scope

In scope

  • RoboProbeError(code, message, context) base plus ConfigError, ValidationError, NotFoundError, ConflictError, BackendError → EpisodeLaunchError, EpisodeTimeoutError, OracleError, StrategyError → ModelFitError, StoreError → QueueError, PluginError.
  • Module-level registry of stable codes used in doc 12 §1.1 (VALIDATION_ERROR, NOT_FOUND, CAMPAIGN_INVALID_TRANSITION, SPACE_INVALID, BACKEND_UNSUPPORTED_PARAM, NO_WORKERS, PRECONDITION_FAILED, UNAUTHORIZED, INTERNAL).
  • is_transient(exc) helper used by retry logic (34 §5).

Out of scope

  • HTTP mapping (T-080b)
  • CLI exit-code mapping (T-008)

Implementation guidance

  • File backend/src/roboprobe/core/errors.py. Codes as a StrEnum ErrorCode; each subclass has a default code but accepts an override.
  • context is Mapping[str, JsonValue], never contains secrets (doc 34 §6).
  • __str__ returns f"{code}: {message}"; keep __reduce__ working so errors pickle across processes.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Acceptance criteria

  • Hierarchy exactly as doc 34 §5.
  • Every code in doc 12 §1.1 exists in ErrorCode.
  • Errors are picklable and carry context.
  • 100 % coverage.
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/unit/core/test_errors.py (hierarchy, codes, pickling, is_transient).

Dependencies

Blocked by: #12 (T-001)

Blocks: #19 (T-003a), #20 (T-008), #33 (T-020b), #48 (T-035a), #79 (T-041c), #143 (T-080b)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/core/errors.py
  • backend/tests/unit/core/test_errors.py

Independent single file; ideal first contribution.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-002b (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 34 §5 · doc 12 §1.1 · doc 05 §11

Requirements: FR-API-003 (traceability: doc 28)

External:

Activity

  1. added this to the M1 — Foundation milestone on Nov 19, 2026
  2. added
    area:coreDomain core, plugin registry, shared types
    priority:P0Critical path / blocks others
    taskChild task of a milestone epic
    on Nov 19, 2026
  3. CodewithJha commented on Nov 19, 2026

    @CodewithJha
    OwnerAuthor

    Implemented in #230.

  4. CodewithJha commented on Nov 19, 2026

    @CodewithJha
    OwnerAuthor

    Reopened: my automation closed this by mistake before PR #230 merged (merge conflict in CHANGELOG). Resolving the conflict now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreDomain core, plugin registry, shared typesgood first issueGood for newcomersmilestone:M1M1 — Foundationpriority:P0Critical path / blocks otherssize:XS< 2 hourstaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions