Skip to main content

AI Change Impact

Find recorded RAG questions that retrieved a changed passage, then replay those questions against your updated pipeline. AI Change Impact stores provenance locally in SQLite and has no runtime dependencies.

Status: alpha prototype. Its API may change. It reports known line-level dependencies, not every potentially affected answer.

How it works

flowchart LR
    A["RAG application"] -->|"Record source, hash and retrieved lines"| B["Local SQLite"]
    C["Before and after documents"] --> D["Line diff"]
    B --> E["Match versions and spans"]
    D --> E
    E --> F["Affected observations"]
    E --> G["Version mismatches"]
    F -.-> H["Optional replay through your pipeline"]

Your application supplies the source text, a stable source identifier, and the line range it retrieved. The package hashes the source text and records the observation. During comparison, it computes a line diff and finds observations whose recorded spans overlap changed lines. It reports records for a different document version separately. Insertions are matched against adjacent old lines.

Replay is opt-in and calls your function once per affected observation. It compares returned strings with stored answers; it does not evaluate factual correctness or automatically update an index.

Installation

Requires Python 3.10 or newer. Install from PyPI:

python -m pip install ai-change-impact-prototype

Alternatively, install from the source checkout:

git clone https://github.com/Shubham-786/ai-change-impact.git
cd ai-change-impact
python -m pip install .

To build a local wheel, run python -m pip install build and then python -m build.

Try the demo

With version 0.3.0 or newer, run a small local keyword-retrieval example without a model, API key, or network:

python -m pip install --upgrade ai-change-impact-prototype
impact demo --html demo-report.html

Open the generated HTML file to inspect the recorded question and change. The command refuses to overwrite an existing report. The demo is illustrative: it does not run a language model or measure answer quality.

Record retrieved chunks

Version 0.3.0 and newer can map an exact chunk back to the source without manually counting lines:

from change_impact import ImpactStore

source_text = "Refund policy\nRefunds are available for 30 days.\n"
with ImpactStore("impact.sqlite3") as store:
    store.record_chunk(source="policy", document=source_text, question="Refund period?",
                       chunk="Refunds are available for 30 days.", chunk_id="refund-1")
    report = store.compare(source="policy", before=source_text,
                           after=source_text.replace("30 days", "14 days"))
    print(report["affected"])

Chunks must occur exactly in the original source text. If a chunk occurs more than once, provide its start_index as a Python character offset. Transformed or OCR-altered text must be mapped to the source by the caller; incorrect mappings are rejected rather than guessed. The chunk identifier is stored in observation metadata, preserving compatibility with the 0.2 SQLite schema.

For LangChain-style Document objects, impact_langchain.record_document accepts page_content and optional metadata["start_index"] and metadata["chunk_id"]. The adapter has no LangChain dependency. The application must provide the matching original source text; metadata is not copied automatically.

See examples/langchain_chunk.py for a runnable example using a real LangChain Document; install langchain-core separately to run it. It demonstrates the adapter with a constructed document, not a production retriever.

examples/rag_smoke_test.py exercises a small offline LangChain retrieval-and-answer pipeline end to end. It uses keyword retrieval and a deterministic answer function; it does not call an LLM or use a vector database. Install langchain-core separately, then run python examples/rag_smoke_test.py from the source checkout.

Record and replay from Python

No external service is required for recording or comparison.

from change_impact import ImpactStore, replay

before = "# Refund policy\nRefunds within 30 days.\n"
after = "# Refund policy\nRefunds within 14 days.\n"

with ImpactStore("impact.sqlite3") as store:
    store.record(source="refund-policy", document=before, question="Refund period?",
                 start_line=2, end_line=2, answer="30 days")
    report = store.compare(source="refund-policy", before=before, after=after)

    # Your callable must use the candidate index or document version.
    results = replay(report, lambda question: "14 days")
    print(results[0]["changed"])  # True

replay calls the supplied function for each affected observation; it does not update your index, run an evaluator, or verify correctness. Your function can make network calls, incur costs, or have side effects. Repeated observations are replayed separately. Version mismatches appear in the report and require review. The database stores questions, answers, and metadata in plaintext; handle access, retention, and deletion yourself.

Command-line example

From the repository directory, compare the included example documents:

impact-prototype examples/before.md examples/after.md examples/records.json --source policy

The JSON report includes changed lines, affected questions, and records whose document hash does not match the provided old version. The example identifies the refund-period question as affected by the change from 30 to 14 days.

Visualize an impact report

Version 0.2.0 and newer can render an analysis as a Mermaid flowchart:

from change_impact import render_flow

print(render_flow(report))  # report is returned by ImpactStore.compare()

Or generate the Mermaid source from the example files:

impact-prototype examples/before.md examples/after.md examples/records.json --source policy --format mermaid

Paste the output into a Mermaid code block in GitHub Markdown or another compatible viewer. The diagram shows change, affected-observation, and version-mismatch counts; it does not include source text or questions. The optional replay node describes an available next step and does not mean replay was performed. Use the JSON report to inspect the evidence.

For a self-contained local HTML report with clickable sections and the actual changed passages and questions:

impact-prototype examples/before.md examples/after.md examples/records.json --source policy --format html > impact-report.html

Open impact-report.html in a browser. No server or network connection is needed. The report contains potentially sensitive source excerpts and questions; store and share it accordingly. Python callers can use render_html(report) from change_impact.

Direct comparison without SQLite

Record the exact source identifier, document_hash(text), question, and 1-based inclusive line range for each retrieved passage. Hash the exact Unicode text passed to analyze.

from impact_prototype import analyze, document_hash

before = "Refunds within 30 days.\n"
records = [{"source": "policy", "question": "Refund period?", "start_line": 1,
            "end_line": 1, "document_hash": document_hash(before)}]
report = analyze(before, "Refunds within 14 days.\n", records, source="policy")

Scope and validation

This only identifies recorded retrievals overlapping line-level edits; insertions conservatively touch neighboring lines. It cannot identify indirect dependencies, newly relevant documents, changes in retrieval behavior, or semantic effects. Missing or stale provenance must not be treated as unaffected. Replay requires a user-supplied function; the package does not test answer correctness, parse PDFs, or connect to tracing systems. Run full evaluation suites as well. Source text and questions remain local unless the supplied function sends them elsewhere; reports can contain sensitive content.

Line numbers are 1-based and inclusive in the exact source text your application recorded. Document identity uses the SHA-256 hash of its UTF-8 text, so a version mismatch requires separate review. Diffing uses Python's splitlines(): changes that affect only line endings or the final newline do not produce changed line spans even though the document hashes differ. The matching algorithm can flag unchanged material around insertions and may align repeated lines in unexpected ways. An empty affected list is not a guarantee that no answer is impacted.

Data and security

The SQLite database contains source identifiers, questions, optional answers, line ranges, document hashes, and metadata in plaintext. It does not store the full source document, but reports include the changed text. Protect database files and reports using your environment's access controls and retention procedures. The SDK does not send telemetry or make network requests; your replay function may do both. See SECURITY.md for reporting vulnerabilities.

The store uses SQLite's default thread behavior: use a separate ImpactStore instance per thread. Database schema migrations, multi-process coordination beyond SQLite's own behavior, and compatibility guarantees across alpha versions are not yet provided.

Next validate with real users: compare the effort needed to find affected cases in Phoenix, Langfuse, and DeepEval against this approach on the same document changes. Measure setup time, relevant cases found and missed, and developer time saved. No user interviews or competitor hands-on benchmark have yet been conducted.

Development

Run the test suite with python -m unittest discover -s tests -v. Build distributions with python -m pip install build followed by python -m build. Contributions should include a focused test for behavior changes and avoid collecting user data or sending it over the network without explicit configuration.

License

MIT. See LICENSE.

Metadata

Release files for ai-change-impact-prototype 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-change-impact-prototype 0.3.0
File Size Uploaded Provenance Actions
ai_change_impact_prototype-0.3.0.tar.gz 11.5 kB Without provenance Details for ai_change_impact_prototype-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-change-impact-prototype 0.3.0
File Interpreter ABI Platform Actions
ai_change_impact_prototype-0.3.0-py3-none-any.whl Python 3 none any Details for ai_change_impact_prototype-0.3.0-py3-none-any.whl

Total release size: 24.9 kB

Release files / ai_change_impact_prototype-0.3.0.tar.gz

Download URL ai_change_impact_prototype-0.3.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
faa87bdaa0fd11ac727380873b38998a05f86f3cbf8c6cde06cd5da1a58cbee8
BLAKE2b-256 checksum
How to use checksums
988ed1513e0148e3a7e1e43d661e92f6cc3624da216550418d5a7ea8ae749813
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.6

Release files / ai_change_impact_prototype-0.3.0-py3-none-any.whl

Download URL ai_change_impact_prototype-0.3.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65e15c1fd3d7a5c4f5ba4cca62ea5ef3b030ba54373c61758f3b19441249d37c
BLAKE2b-256 checksum
How to use checksums
e5fd3de00308013765ecc28dbd9e1c14bd3f5275683872648e73ec51c45609c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.6

Security for ai-change-impact-prototype 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page