SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.14665 · 2026

Falkor-IRAC: Graph-Constrained Generation for Verified Legal Reasoning in Indian Judicial AI

Joy Bose

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 6 failures of our instrument; 4 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2605.14665.json · badge: /api/ran/2605.14665.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
joyboseroy/falkor-irac canonical (classifier label)
classifier basis: census
8 ran · 4 no recorded run
FunctionStatusWhere it lives
detect_citation Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/ingestion/pdf_extractor.py
code served (permissive licence) · get_code("d1fe4d356d401f00")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re
from typing import Optional

# The function takes a single parameter: text (a string)
# It searches for citation patterns in the first 2000 characters of the text
# We need to provide a string that contains at least one of the citation patterns

ARGS = {
    "text": "(2004) 5 SCC 123 - This is a legal citation in Indian court format"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
detect_court Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/ingestion/pdf_extractor.py
code served (permissive licence) · get_code("e29770d432dc4f78")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re
from typing import Optional

COURT_PATTERNS = {'Supreme Court': 'IN\\s+THE\\s+SUPREME\\s+COURT\\s+OF\\s+INDIA', 'Delhi High Court': 'IN\\s+THE\\s+HIGH\\s+COURT\\s+OF\\s+DELHI', 'Bombay High Court': 'IN\\s+THE\\s+HIGH\\s+COURT\\s+AT\\s+BOMBAY', 'Madras High Court': 'IN\\s+THE\\s+HIGH\\s+COURT\\s+OF\\s+JUDICATURE\\s+AT\\s+MADRAS', 'Calcutta High Court': 'IN\\s+THE\\s+HIGH\\s+COURT\\s+AT\\s+CALCUTTA', 'Karnataka High Court': 'IN\\s+THE\\s+HIGH\\s+COURT\\s+OF\\s+KARNATAKA'}

def detect_court(text: str) -> Optional[str]:
    header = text[:1000].upper()
    for court_name, pattern in COURT_PATTERNS.items():
        if re.search(pattern, header, re.IGNORECASE):
            return court_name
    return None

# Setup code to construct valid arguments
test_text_supreme = "IN THE SUPREME COURT OF INDIA\nCase No. 123/2024\nAppellant v. Respondent"
test_text_delhi = "IN THE HIGH COURT OF DELHI\nBench: Justice Smith\nPetition No. 456/2024"
test_text_no_match = "This is a regular document without any court header information"

ARGS = {
    "text": test_text_supreme
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
escape Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/ingestion/graph_loader.py
code served (permissive licence) · get_code("1d137fb5f729b044")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

ARGS = {
    's': "Hello 'world' with\\backslash"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_llm_response Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/ingestion/irac_parser.py
code served (permissive licence) · get_code("96dfc6d8c642a7ea")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import re

# The function parse_llm_response accepts either a dict or a raw string
# Let's construct valid arguments for both cases

# Case 1: dict input (from Ollama path)
dict_input = {
    "response": "Hello, world!",
    "model": "llama2",
    "status": "success"
}

# Case 2: raw string input with json code block
raw_string_input = """```json
{
    "message": "This is a test",
    "value": 42
}
"""

# Case 3: raw string input with plain json (no code block markers)
raw_string_plain = '{"key": "value", "number": 123}'

# Case 4: raw string with markdown json block (no explicit json language tag)
raw_string_markdown = """
{
    "data": "test",
    "count": 5
}
"""

# We'll use the dict input as the primary test case
ARGS = {
    "raw_or_dict": dict_input
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
repair_json Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/agents/llm.py
code served (permissive licence) · get_code("9603579fd6185f42")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def repair_json(raw: str) -> str:
    """
    Attempt to repair truncated JSON from TinyLlama.
    Closes any unclosed braces/brackets so json.loads has a chance.
    """
    raw = raw.strip()
    raw = re.sub('^```(?:json)?\\s*', '', raw)
    raw = re.sub('\\s*```$', '', raw)
    start = raw.find('{')
    if start == -1:
        return raw
    raw = raw[start:]
    open_braces = 0
    open_brackets = 0
    in_string = False
    escape_next = False
    for ch in raw:
        if escape_next:
            escape_next = False
            continue
        if ch == '\\' and in_string:
            escape_next = True
            continue
        if ch == '"':
            in_string = not in_string
            continue
        if in_string:
            continue
        if ch == '{':
            open_braces += 1
        elif ch == '}':
            open_braces -= 1
        elif ch == '[':
            open_brackets += 1
        elif ch == ']':
            open_brackets -= 1
    if in_string:
        raw += '"'
    raw += ']' * max(0, open_brackets)
    raw += '}' * max(0, open_braces)
    return raw


ARGS = {
    "raw": '```json\n{"name": "test", "values": [1, 2, 3'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
truncate_for_context Ran
ran; our contract draft was wrong, not the code
joyboseroy/falkor-irac/ingestion/irac_parser.py
code served (permissive licence) · get_code("fdec49c6eae9eef7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

# Construct arguments for truncate_for_context function
torch.manual_seed(0)

# The function only uses:
# - text: str (required)
# - max_chars: int (optional, default=600)

# Create a sample judgment text that is longer than the truncation limit
sample_text = """
SUPREME COURT OF THE UNITED STATES

Case Name: Smith v. Jones
Citation: 123 U.S. 456 (2023)

FACTS:
The plaintiff, John Smith, filed a complaint against Jane Jones regarding a contract dispute. 
The contract was signed on January 1, 2020, and involved the sale of commercial property located 
in New York. The defendant failed to deliver the property as agreed, causing significant damages 
to the plaintiff. The case involves questions of contract law, specifically regarding the interpretation 
of ambiguous terms and the remedies available for breach of contract. Additional facts include 
discussions of prior dealings between the parties, market conditions at the time of the agreement, 
and correspondence between counsel. The court must determine whether the defendant's actions 
constitute a material breach justifying rescission and damages.

HOLDING:
The Court holds that...
""" * 3  # Repeat to ensure it's longer than max_chars

ARGS = {
    "text": sample_text,
    "max_chars": 600
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
verify_connection Ran
ran, violated the contract we drafted
joyboseroy/falkor-irac/graph_schema/setup_schema.py
code served (permissive licence) · get_code("fbc62886ef9841c8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

class MockGraphQuery:
    """Mock graph object that supports query() method"""
    def query(self, query_string):
        """Returns a result object with result_set"""
        return MockQueryResult()

class MockQueryResult:
    """Mock query result with result_set attribute"""
    def __init__(self):
        self.result_set = [['connected']]

graph = MockGraphQuery()

ARGS = {
    'graph': graph
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
verify_load Ran
ran, honoured the contract we drafted
joyboseroy/falkor-irac/ingestion/load_sample_graph.py
code served (permissive licence) · get_code("7fce5d31c561a72c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

class MockGraph:
    """Mock graph object that simulates a Neo4j graph with query capability."""
    
    def __init__(self):
        self.cases = 5
        self.statutes = 3
        self.relationships = 12
    
    def query(self, query_string):
        """Mock query method that returns results based on the query."""
        mock_result = MockResult()
        
        if 'MATCH (c:Case)' in query_string:
            mock_result.result_set = [[self.cases]]
        elif 'MATCH (s:Statute)' in query_string:
            mock_result.result_set = [[self.statutes]]
        elif 'MATCH ()-[r]->()' in query_string:
            mock_result.result_set = [[self.relationships]]
        
        return mock_result


class MockResult:
    """Mock result object that contains query results."""
    
    def __init__(self):
        self.result_set = []


ARGS = {
    'graph': MockGraph()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
call_llm Not yet run
unverified (harvested, no recorded run)
joyboseroy/falkor-irac/ingestion/irac_parser.py
code served (permissive licence) · get_code("c222c3061de78f7f")
How it ran

no invocation recorded.

call_llm Not yet run
unverified (harvested, no recorded run)
joyboseroy/falkor-irac/agents/orchestrator.py
code served (permissive licence) · get_code("46783c92264f8631")
How it ran

no invocation recorded.

call_llm_json Not yet run
unverified (harvested, no recorded run)
joyboseroy/falkor-irac/agents/llm.py
code served (permissive licence) · get_code("c53e9e86b1c4f039")
How it ran

no invocation recorded.

call_ollama Not yet run
unverified (harvested, no recorded run)
joyboseroy/falkor-irac/agents/llm.py
code served (permissive licence) · get_code("bc9c0638538453d5")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 12 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Legal reasoning is not semantic similarity search. A court judgment encodes constrained symbolic reasoning: precedent propagation, procedural state transitions, and statute-bound inference. These are properties that vector-based retrieval-augmented generation (RAG) cannot faithfully represent. Hallucinated precedents, outdated statute citations, and unsupported reasoning chains remain persistent failure modes in LLM-based legal AI, with real consequences for access to justice in high-caseload jurisdictions such as India. This paper presents Falkor-IRAC, a graph-constrained generation framework for Indian legal AI that grounds generation in structured reasoning over an IRAC (Issue, Rule, Analysis, Conclusion) knowledge graph. Judgments from the Supreme Court and High Courts of India are ingested as IRAC node structures enriched with procedural state transitions, precedent relationships, and statutory references, stored in FalkorDB for low-latency agentic traversal. At inference time, LLM-generated answers are accepted only if a valid supporting path can be traced through the graph, a check performed by a falsifiability oracle called the Verifier Agent. The system also detects doctrinal conflicts as a first-class output rather than silently resolving them. Falkor-IRAC is evaluated using graph-native metrics: citation grounding accuracy, path validity rate, hallucinated precedent rate, and conflict detection rate. These metrics are argued to be more appropriate for legal reasoning evaluation than BLEU and ROUGE. On a proof-ofconcept corpus of 51 Supreme Court judgments, the Verifier Agent correctly validated citations on completed queries and correctly rejected fabricated citations. Evaluation against vector-only RAG baselines is left for future work, as is GPU-accelerated inference to address current timeout rates on CPU hardware. The companion InIRAC dataset, 500+ structured Indian court judgments with IRAC annotations, procedural event chains, and typed precedent relationships, is released alongside this paper at https://huggingface.co/datasets/joyboseroy/inIRAC.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2605.14665")
get_code_for_paper("2605.14665")
have("2605.14665")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2605.14665.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2605.14665.svg)](https://syntology.ai/paper/2605.14665)

Connect an agent — have() is free.