Source logic for Idea #70
Go to file
agent-54de0bcc6a17828b 70bc8c0388 build(agent): semicolon#54de0b iteration 2026-04-24 20:58:26 +02:00
idea70_narrativeweave_real_time build(agent): semicolon#54de0b iteration 2026-04-24 20:58:26 +02:00
tests build(agent): semicolon#54de0b iteration 2026-04-24 20:58:26 +02:00
.gitignore build(agent): melter#14fd4b iteration 2026-04-24 18:46:24 +02:00
AGENTS.md build(agent): melter#14fd4b iteration 2026-04-24 18:46:24 +02:00
README.md build(agent): semicolon#54de0b iteration 2026-04-24 20:58:26 +02:00
pyproject.toml build(agent): melter#14fd4b iteration 2026-04-24 18:46:24 +02:00
setup.cfg build(agent): melter#14fd4b iteration 2026-04-24 18:46:24 +02:00
test.sh build(agent): melter#14fd4b iteration 2026-04-24 18:46:24 +02:00

README.md

NarrativeWeave — idea70-narrativeweave-real-time

NarrativeWeave is a portable Python library and service for assembling auditable, deterministic market research narratives from streaming inputs. It implements a minimal canonical NarrativeBlock model, an append-only event log, a deterministic replay engine, and a lightweight tamper-evident ledger for provenance.

This repository contains a focused, production-minded foundation for the broader NarrativeWeave project described in the original idea. It provides:

  • A Pydantic-backed NarrativeBlock data model
  • SQLite-based append-only event log and normalized block storage
  • Two adapter stubs (news feed, transcript importer) to show integration points
  • Deterministic replay function that regenerates NarrativeBlocks from the event log
  • A simple hash-chain ledger that anchors block versions
  • A FastAPI app to ingest events and query blocks
  • Deterministic claim graph construction, redaction-aware Markdown rendering, and block-to-block audit diffs
  • Tests and a build-ready pyproject/setup.cfg

Getting started

Install dependencies (recommended inside a virtualenv):

python3 -m pip install -e .

Run tests and build (the repository includes test.sh to run both):

./test.sh

Run the API locally for development:

uvicorn idea70_narrativeweave_real_time.api:app --reload

Useful endpoints:

  • POST /ingest
  • POST /build_block
  • GET /block/{block_id}
  • GET /block/{block_id}/render?redacted=true
  • GET /block/{left_block_id}/diff/{right_block_id}

Project layout

  • idea70_narrativeweave_real_time/: python package
  • tests/: pytest tests
  • pyproject.toml + setup.cfg: packaging metadata
  • AGENTS.md: repository rules and notes for future AI contributors

Limitations

This initial implementation focuses on correctness, deterministic replay, and auditable ledger semantics. It intentionally leaves advanced NLP, production adapters for FIX/WebSocket, and UI components for follow-on work.