Skip to content

fix: phantom ledger paths, SQL errors, deterministic case refs - #60

Merged
chitcommit merged 5 commits into
mainfrom
feat/case-synthesis
Mar 25, 2026
Merged

chitcommit merged 5 commits into
mainfrom
feat/case-synthesis

Conversation

@chitcommit

@chitcommit chitcommit commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Redirects phantom /api/evidence and /api/cases/* ledger paths to correct services (ChittyEvidence, ChittyCommand)
  • Fixes SQL errors in timeline/jobs routes (conditional query building, missing column references, null guards)
  • Uses deterministic case ref for ledger_case_id instead of entry UUID
  • Removes dead ledger API calls from MCP get_case_timeline tool

Test plan

  • tsc --noEmit passes
  • Timeline endpoint returns events without SQL errors
  • MCP get_case_timeline tool works end-to-end
  • Bridge ledger routes proxy correctly to ChittyLedger

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Expanded AI tool capabilities from 28 to 48 tools across 12 domains
    • Added authenticated API endpoints for case timeline retrieval, litigation fact synthesis, email drafting, quality control review, and scrape job queue management
    • Enhanced integration with evidence system for improved case fact and document aggregation
  • Documentation

    • Updated system charter and API documentation to reflect expanded capabilities and new endpoints

chitcommit and others added 5 commits March 24, 2026 17:55
Schema Overlord audit findings (6 fixes):
- EvidenceFact: entity_type not type, amount_value not value, nullable
  fields from LEFT JOINs (confidence, verification_status, fact_type)
- EvidenceDocument: file_name not filename, created_at not uploaded_at
- searchDocuments: GET→POST (ChittyEvidence /search is POST)
- getContradictions: pointed to facts?conflicts_only=true (no dedicated
  contradictions endpoint exists)
- timeline.ts: map entity_type→type and amount_value→value for consumers
- mcp.ts + litigation.ts: fix a.value→a.amount_value references

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added 5 evidence tools: get_case_timeline, get_case_facts,
get_case_contradictions, get_pending_facts, synthesize_case_facts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add @canon governance annotations to entity_type fields in integrations.ts
- Fix MCP JSDoc: "38 tools across 9 domains" → "48 tools across 12 domains"
- Add date filtering to deadlines query in MCP get_case_timeline
- Add ChittyLedger document fetching to MCP get_case_timeline for REST parity

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…endpoints

- CHARTER.md: add ChittyEvidence dependency, timeline/litigation/jobs endpoints,
  update MCP tool count (28→48), add case timeline and litigation scope items
- CHITTY.md: add same endpoints, update MCP tool count (32→48), add ChittyEvidence
  to direct API data sources

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds missing columns from migrations 0008/0009 to schema.ts:
- ccObligations: escalation tracking (5 cols)
- ccRecommendations: planner-aware fields (6 cols)
- ccEmailConnections + ccUserNamespaces: 2 new tables

Also adds drizzle.config.ts and updates drizzle-orm to match drizzle-kit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
  1. @coderabbitai review
  2. @copilot review
  3. @codex review
  4. @claude review
    Adversarial review request: evaluate security, policy bypass paths, regression risk, and merge-gating bypass attempts.

@chitcommit
chitcommit merged commit 0b4e594 into main Mar 25, 2026
30 of 31 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chitcommit
chitcommit deleted the feat/case-synthesis branch March 25, 2026 17:05
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47607df5-d640-4fa1-9bd7-da30d63b4bdc

📥 Commits

Reviewing files that changed from the base of the PR and between 23cecc0 and c5ffcca.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (16)
  • CHARTER.md
  • CHITTY.md
  • CLAUDE.md
  • drizzle.config.ts
  • migrations/0000_aromatic_diamondback.sql
  • migrations/0001_dashing_bulldozer.sql
  • migrations/meta/0000_snapshot.json
  • migrations/meta/0001_snapshot.json
  • migrations/meta/_journal.json
  • package.json
  • src/db/schema.ts
  • src/lib/integrations.ts
  • src/routes/litigation.ts
  • src/routes/mcp.ts
  • src/routes/timeline.ts
  • tests/mcp.test.ts

📝 Walkthrough

Walkthrough

This PR adds a complete database schema with migrations, extends the MCP toolkit from 38–43 tools to 48 tools across 12 domains (including a new Evidence domain), introduces REST API endpoints for case timelines/litigation operations/scrape job management, updates type definitions to align with ChittyEvidence API changes, and refreshes documentation to reflect expanded capabilities.

Changes

Cohort / File(s) Summary
Documentation Updates
CHARTER.md, CHITTY.md, CLAUDE.md
Updated metadata, capability statements, and endpoint/data-source tables to reflect expanded MCP toolkit (48 tools across 12 domains), new authenticated REST endpoints for litigation/timeline/job management, and ChittyEvidence as upstream provider. Charter version bumped to 1.2.0.
Database Configuration & Migrations
drizzle.config.ts, package.json, migrations/0000_aromatic_diamondback.sql, migrations/0001_dashing_bulldozer.sql, migrations/meta/_journal.json
Added Drizzle ORM configuration, upgraded drizzle-orm to ^0.45.1, and defined two PostgreSQL migrations establishing credit/collections schema (17 tables with UUIDs, timestamps, JSONB metadata, status fields, foreign keys) and extending obligations/recommendations with escalation and planning columns; added email connections and user namespace tables with idempotent constraint application.
Database Schema Snapshots
migrations/meta/0000_snapshot.json, migrations/meta/0001_snapshot.json
Added full schema snapshots (PostgreSQL version 7) documenting table definitions, column types, indexes, and foreign key relationships for the initial and extended migrations.
TypeScript Schema Definition
src/db/schema.ts
Added escalation tracking and planner-aware columns to obligations/recommendations tables; introduced new ccEmailConnections and ccUserNamespaces exported tables with metadata, sync tracking, and uniqueness constraints.
Evidence Integration Types
src/lib/integrations.ts
Updated EvidenceFact and EvidenceDocument types to make fact metadata optional, reshaped entities (added id, entity_type, confidence) and amounts (added id, fact_id, amount_value, confidence), renamed document fields (filenamefile_name, uploaded_atcreated_at), and changed searchDocuments from GET query-param to POST JSON with error-swallowing return (null on failure).
Route Implementations
src/routes/timeline.ts, src/routes/litigation.ts, src/routes/mcp.ts
Updated case timeline route to normalize missing fact metadata with null defaults and reshape entities/amounts to match new API shapes. Updated litigation synthesize-from-case to use amount_value instead of value. Enhanced MCP server with 48 tools across 12 domains; updated synthesize_case_facts for new amount field shape and get_case_timeline to optionally filter legal deadlines by date range and fetch related documents from ChittyLedger.
Test Updates
tests/mcp.test.ts
Updated MCP tools count assertion from 43 to 48 to match expanded toolkit.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Timeline API
    participant ChittyEvidence
    participant ChittyLedger
    participant Database

    Client->>Timeline API: GET /api/v1/timeline/:caseId
    Timeline API->>Database: Query facts by caseId
    Database-->>Timeline API: Return facts with metadata
    Timeline API->>ChittyEvidence: getContradictions(caseId)
    ChittyEvidence-->>Timeline API: Return contradictions
    Timeline API->>Database: Query legal_deadlines by caseId
    Database-->>Timeline API: Return deadlines (optional date filter)
    Timeline API->>ChittyLedger: getEvidenceByCase(caseId)
    ChittyLedger-->>Timeline API: Return document evidence
    Timeline API->>Timeline API: Normalize metadata shapes & flatten<br/>entities/amounts arrays
    Timeline API-->>Client: Return unified timeline events<br/>(facts, contradictions, deadlines, documents)
Loading
sequenceDiagram
    participant Client
    participant Litigation API
    participant ChittyEvidence
    participant ChittyConnect/AI Gateway
    participant Database

    Client->>Litigation API: POST /api/v1/litigation/synthesize-from-case
    Litigation API->>Database: Query case facts, obligations, disputes
    Database-->>Litigation API: Return case context
    Litigation API->>ChittyEvidence: Fetch evidence facts & amounts
    ChittyEvidence-->>Litigation API: Return facts with reshaped<br/>entities (id, entity_type, confidence)<br/>amounts (id, fact_id, amount_value, confidence)
    Litigation API->>Litigation API: Synthesize narrative from facts,<br/>obligations, disputes
    Litigation API->>ChittyConnect: POST prompt with synthesized facts<br/>(or fallback to AI Gateway)
    ChittyConnect-->>Litigation API: Return synthesis response
    Litigation API-->>Client: Return synthesized facts JSON
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 With paws a-twitching, I hop with glee,
Forty-eight tools now dancing free,
Twelve domains bloom like gardens wide,
Evidence flows, timelines collide!
Our schemas grow, so strong and true,
A chirpy feast of facts—brand new! 🥕

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/case-synthesis

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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