Skip to content

FEAT: Redesign Status/Codes taxonomy and lookup - #402

Merged
kishorereddy merged 3 commits into
mainfrom
fix/260718-codes-redesign
Jul 19, 2026
Merged

FEAT: Redesign Status/Codes taxonomy and lookup#402
kishorereddy merged 3 commits into
mainfrom
fix/260718-codes-redesign

Conversation

@kishorereddy

@kishorereddy kishorereddy commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Overview

Rewrites kiit-codes (Status.kt, Codes.kt, StatusException.kt) with a corrected taxonomy, a new bidirectional HTTP-code lookup abstraction, and fixes to two bugs. The changes here are only for kiit-codes, I'm not making changes to kiit-result, which depends on it, this will be a subsequent step.

Ticket(s)

n/a

Example

 * Hierarchy. Categories are closed/sealed and fixed by design, to enforce a consistent taxonomy
 * across every consumer. Individual codes *within* a category are open create new domain codes
 * by constructing a [Passed] or [Failed] subtype directly (see [Codes] for the built-in set):
 *
 *   Status  = Passed     | Failed
 *   Passed  = Succeeded  | Pending | Filtered | Information
 *   Failed  = Denied     | Invalid | Errored  | Unserviceable

Dependencies

None — self-contained within src/core/codes.

Design

  • Taxonomy: This is main design change
    • Status is a sealed interface with all subtypes enumerated in the same file.
    • Ignored removed as a type, merged into Filtered
    • Filtered created, with Codes.SKIPPED vs Codes.DISCARDED)
    • Fixes the original FILTERED/IGNORED code collision (both were 200204).
    • Information added as a fourth Passed category for ABOUT/VERSION ( was succeeded before)
    • Unknown renamed/re-scoped to Unserviceable
    • Denied narrowed to strictly security/access-control codes (UNAUTHENTICATED, UNAUTHORIZED);
    • FORBIDDEN moved to Errored.
  • Lookup: replaced Codes.toHttp / Codes.toStatus / Codes.ofCode / Codes.contains
    • Added a CodeLookup interface (toCode/toStatus, direction-explicit), a CodesToHttp
    • Default implementation (compiler-exhaustive when over categories + a small overrides map, toStatus derived from toCode so the two directions can never drift apart), and a CompositeLookup for client extension via composition rather than subclassing.
  • Duplicate-code protection: Codes now has an init block that fails fast if any two registered codes collide — a structural fix for the class of bug that caused the original FILTERED/IGNORED collision.

Notes

  • Bug fix: Status.ofCode's operator-precedence bug
  • Bug fix: success hoisted onto Passed/Failed directly as a get()
  • Status.toType's when is now genuinely exhaustive (no else)
  • README.md updated to match the new taxonomy, including a new "HTTP Conversion"

Pending

  • kiit-result, which depends on kiit-codes, has not yet been updated for the renamed/removed types

Tests

  • updated with new tests, changed taxonomy
  • All 69 tests pass; verified via ktlintCheck, detekt, and jvmTest.

@kishorereddy kishorereddy changed the title core-codes: redesign Status/Codes taxonomy, add CodeLookup FEAT: Redesign Status/Codes taxonomy and lookup Jul 19, 2026
@kishorereddy
kishorereddy merged commit c2bf883 into main Jul 19, 2026
1 check failed
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