Skip to content

fix: canonical entity_type + remove unused docket type - #61

Merged
chitcommit merged 5 commits into
mainfrom
fix/canon-cleanup
Mar 25, 2026
Merged

chitcommit merged 5 commits into
mainfrom
fix/canon-cleanup

Conversation

@chitcommit

@chitcommit chitcommit commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove 'docket' from TimelineEvent type union — defined but never populated by any code path
  • Fix entity_type: 'dispute''event' in dispute classification (dispute-sync.ts + integrations.ts) per chittycanon://gov/governance#core-types — disputes are occurrences in time (Event/E), not a valid canonical type

Test plan

  • Verified no code populates type: 'docket' events
  • Verified entity_type change aligns with P/L/T/E/A canonical ontology
  • ChittyRouter classifyDispute accepts string entity_type (no breaking change)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Enhanced ledger audit trail with comprehensive entry tracking and structured metadata storage
    • Improved evidence document management system with better custody logging
  • Improvements

    • Refined dispute classification and tracking mechanism
    • Streamlined timeline and case history accuracy with updated event handling

chitcommit and others added 5 commits March 24, 2026 19:23
ledgerClient was calling /api/evidence, /api/cases/*, and
/api/evidence/*/custody — none of which exist on ChittyLedger.
These endpoints belong to ChittyEvidence.

- Rewrite ledgerClient to only expose real ChittyLedger endpoints:
  POST /entries, GET /entries, GET /custody/:id, GET /verify, GET /statistics
- Add submitDocument and addCustodyEntry to evidenceClient
- Update all callers (bridge, mcp, documents, timeline, dispute-sync)
  to use evidenceClient for evidence/case operations
- Remove duplicate evidence fetch in timeline route
- All operations include Bearer auth via CHITTYLEDGER_TOKEN

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The get_case_timeline handler still called ledger.getEvidenceByCase()
which was removed from the rewritten ledgerClient. Evidence documents
are already fetched via evidenceClient in the facts section above.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ledger_case_id is used for timeline/deadline joins and must be a stable
case reference (CC-DISPUTE-{prefix}), not a ledger audit entry UUID.
Store the entry UUID separately as ledger_entry_id.

Fixes CodeRabbit review findings on both mcp.ts and dispute-sync.ts.

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

- Fix Neon SQL template literal: conditional WHERE clauses don't work inline,
  use separate query branches for date filtering in get_case_timeline
- Fix cc_disputes query: 'domain' column doesn't exist, use 'dispute_type'
- Fix listJobs null guard: check Array.isArray(result.jobs) before .map()

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

- Remove 'docket' from TimelineEvent union (never populated)
- Fix entity_type: 'dispute' → 'event' in dispute-sync.ts and integrations.ts
  per chittycanon://gov/governance#core-types (disputes are Event (E))

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.

@chitcommit
chitcommit merged commit 6803c95 into main Mar 25, 2026
11 of 12 checks passed
@chitcommit
chitcommit deleted the fix/canon-cleanup branch March 25, 2026 17:42
@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.

@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: 6c301c4e-fd28-42b6-b94e-326e55e70ca9

📥 Commits

Reviewing files that changed from the base of the PR and between 0b4e594 and 2a16c51.

📒 Files selected for processing (8)
  • src/lib/dispute-sync.ts
  • src/lib/integrations.ts
  • src/lib/job-dispatcher.ts
  • src/routes/bridge/ledger.ts
  • src/routes/documents.ts
  • src/routes/ledger.ts
  • src/routes/mcp.ts
  • src/routes/timeline.ts

📝 Walkthrough

Walkthrough

This PR refactors the ledger and evidence integration system to use a generalized entity-driven model for audit entries and splits evidence operations into a dedicated evidenceClient. Key changes include replacing createCase/createEvidence with ledger.addEntry() and evidence.submitDocument(), updating payload discriminators from entity_type: 'dispute' to entity_type: 'event', and removing legacy ledger methods in favor of new query operations.

Changes

Cohort / File(s) Summary
Integration Layer Refactoring
src/lib/integrations.ts
Introduced new LedgerEntryPayload schema with generalized entityType/entityId/action/actor fields. Removed ledger methods (createEvidence, createCase, getEvidenceByCase, getFactsForCase, getContradictionsForCase) and added new operations (addEntry, searchEntries, getChainOfCustody, verifyChain, getStatistics). Added evidenceClient with submitDocument and addCustodyEntry methods. Updated routerClient.classifyDispute payload from entity_type: 'dispute' to entity_type: 'event'.
Dispute Sync & Ledger Entry Implementation
src/lib/dispute-sync.ts, src/routes/bridge/ledger.ts
Updated dispute-sync flow to use ledger.addEntry() with explicit entry attributes (entityType, entityId, action, actor) instead of createCase(). Changed metadata storage to include both ledger_case_id and ledger_entry_id. Document sync now uses evidence.submitDocument() and persists ledger_evidence_id; audit entries fire asynchronously via ledger.addEntry().
Evidence & Document Routes
src/routes/documents.ts, src/routes/ledger.ts
Migrated ledger operations to respective clients: document upload and evidence retrieval now use evidenceClient (submitDocument, searchDocuments, addCustodyEntry); ledger audit operations remain with ledgerClient. Updated method signatures and response shapes.
MCP Tool Updates
src/routes/mcp.ts
Replaced direct fetch calls to ChittyLedger with abstracted client calls; ledger evidence tools now use ev.getEnrichedFacts(), ev.getStatementOfFacts(), ev.getContradictions(); case creation now uses ledger.addEntry() and persists both ledger_case_id and ledger_entry_id. Removed "Documents from ChittyLedger" fetch block.
Timeline & Type Updates
src/routes/timeline.ts
Removed ledgerClient dependency and 'docket' from TimelineEvent.type union. Updated dispute query to use dispute_type instead of domain column and changed metadata structure from { domain: ... } to { disputeType: ... }.
Job Dispatcher Validation
src/lib/job-dispatcher.ts
Enhanced router result validation in listJobs to check Array.isArray(result.jobs) instead of truthy check. Updated total field fallback to use result.total ?? result.jobs.length.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hop-hop, the ledger splits in two,
Evidence hops its own way through,
Entry by entry, audit's clean,
The finest refactor we've ever seen!
From 'dispute' to 'event' the signal flies,
A generalized model—oh, what a prize! 🎉

✨ 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 fix/canon-cleanup

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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