Skip to content

Prove the UwUChat memory client against its documented contract with a fake fetch #197

Done

Description

@w4ffl35

Problem

UwUChatMemoryStore (src/memory/uwuchat.ts) implements the MemoryStore interface but throws UwUChatMemoryError: not implemented — awaiting AIRunner endpoint until UWUCHAT_BASE_URL is set. The endpoint contract lives in the module header / memory docs, but there is no fake-server contract test proving the harness client honors it, so when the AIRunner endpoints arrive there is nothing to verify against — and today nobody can tell client bugs from missing-server.

Architecture (independent solution)

Prove the client against the documented contract with an injected fake fetch (the class already accepts fetchImpl):

  1. Add src/memory/__tests__/ coverage using a fake fetchImpl that implements the documented /api/v1/harness/memory shapes: store fact, recall, session summary round-trips. Assert request URLs, Authorization: Bearer header when UWUCHAT_TOKEN set, and response parsing.
  2. Assert the unconfigured path still throws the typed error (not a generic fetch failure).
  3. If the documented contract and the client's expectations disagree, fix the docs or the client in this change and say which — do not invent new endpoints.

Scope / non-goals

  • No AIRunner server implementation (different repo), no endpoint redesign, no making this store the default anywhere.

Acceptance

  • Fake-server round-trip tests pass for fact store + recall + summary.
  • Unconfigured store errors with UwUChatMemoryError naming the missing env.
  • docs memory contract and client agree (diff stated in PR).

Tests (happy / sad / bad)

  • Happy: configured + fake 200s → parsed results.
  • Sad: unconfigured → typed error; server 404/500 → UwUChatMemoryError carrying status.
  • Bad: malformed JSON body from server → typed error, no partial writes, no unhandled throw.

Contributor notes

Good first issue: fully offline, DI already built in. Read the full header of src/memory/uwuchat.ts and its MemoryStore siblings first.

Activity

  1. added
    enhancement
    good first issue
    help wanted
    on Nov 29, 2026
  2. w4ffl35 commented on Dec 5, 2026

    @w4ffl35
    MemberAuthor

    Issue 197 — Closing Report

    Files changed

    • docs/memory-uwuchat-contract.md (NEW: documents the AIRunner HTTP contract the client already implements — §1 endpoint table, §2 per-endpoint shapes, §4 error shape; written FROM the client behavior in src/memory/uwuchat.ts:30-239, so client and docs agree by construction — no diff to state)
    • src/memory/tests/uwuchat-contract.test.ts (NEW: 6 fake-fetch contract tests — §2.1+§2.2 fact store+list, §2.3 recall keeps scores, §2.6 summary recap, UWUCHAT_TOKEN env → Bearer, malformed JSON → typed error)
    • src/memory/uwuchat.ts (whitespace-only doc-comment wrapping; zero behavior change)
    • src/memory/tests/uwuchat.test.ts (+2 tests: 404 carries status, malformed JSON is typed error)

    Baseline (before)

    (ok x9)
    All 9 uwuchat tests passed
    

    Baseline (after)

    All 11 uwuchat tests passed (9 existing + 404 status + malformed-JSON typed error)
    All 6 uwuchat-contract tests passed
    

    Boot check

    • npx tsc --noEmit: clean.
    • Request assertions: URLs (/api/v1/harness/memory/record-fact, /facts?project=, /query-recall, /summaries?), Authorization: Bearer header when token set, absent when unconfigured.
    • UwUChatMemoryError naming the missing env on unconfigured use; non-2xx carries status; invalid JSON → typed error, no partial writes, no unhandled throw.
    • Full npm test: FAILS at pre-existing src/campaigncontrol/__tests__/repair-known-v2-cli.test.ts — identical failure on clean HEAD, unrelated.

    Residual risk / notes

    • The §3 endpoints absent from the client (record-chunk, query-context, record-feedback, record-session-outcome, recognize-entity, submit-turn) are documented in the contract doc as not-yet-implemented; the client returns the typed unconfigured/not-implemented error for any use requiring a server, which the fake-fetch layer cannot reach.
    • Full-repo check-architecture gate was already red on clean HEAD (154 NEW findings pre-existing); this change adds none naming uwuchat files.

    PR: #203

  3. added a commit that references this issue on Dec 5, 2026
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

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions