Skip to content

Repository files navigation

STORY-ENGINE banner

nlp consistency long-form second-perspective

Long-Form Narrative Consistency Engine

[简体中文](README-zh.md) | English

✦ About

STORY-ENGINE consists of two clearly-positioned products:

  • Story Engine (for creators and the general public) — a long-form novel consistency engine that automatically audits character settings, causal timelines, and memory lines, keeping million-word works consistent in characters, plot, and worldview; it also provides the SPL four-stage narrative editing pipeline. It transforms an editor's intuitive verification into a reusable structured process.
  • Document Review Engine (for enterprises) — a zero-dependency, offline-capable enterprise-grade document compliance review engine that performs clause-level rule scanning and document-level auditing (element completeness / consistency / rights-obligation parity / formatting) on contracts, regulations, official documents, and general text, and outputs traceable review reports.

STORY-ENGINE overview

— ✦ —

✦ Design Direction

STORY-ENGINE consists of two independent products, each targeting a different user group:

Product Target Users Module Typical Input
Story Engine Creators / general public Story Engine for Creator.py + engine for business.py Characters / causal timeline / worldview / narrative elements
Document Review Engine Enterprises compliance_engine/ Contracts / regulations / official documents / general text

Both products share the same deterministic audit design language — responsibility-loop anchoring (ResponsibilityAccount), risk grading, and full-chain traceable logs. The Document Review Engine is a relatively independent offline rule module that does not depend on LLMs — pure rule base, zero third-party dependencies, runs offline, dedicated to enterprise document compliance scenarios.

— ✦ —

✦ Quick Start

# Primary: GitHub
git clone https://github.com/nohn3043-arch/story-engine.git
# Mirror: Gitee
# git clone https://gitee.com/sjiun/Story-engine.git
cd Story-engine
# Pure Python >=3.8. Engine files intentionally use space-separated names.
python "Story Engine for Creator.py"      # creator-facing second-perspective cognitive audit engine
# or: python "engine for business.py"     # SPL four-stage editorial pipeline

— ✦ —

✦ Features

STORY-ENGINE consists of two products, each serving a different user group:

Story Engine (for creators and the general public)

A long-form novel consistency engine that transforms an editor's intuitive verification into a reusable structured process. It has two layers:

  • Creator Engine (Story Engine for Creator.py) — the narrative-facing cognitive audit layer:
    • ResponsibilityAccount — every check is anchored to a named responsibility node (who / role / stage).
    • CognitiveAuditEngine + pluggable AuditPlugin + EmotionalConstraint — composable audit dimensions.
    • CausalNode carries implicit_assumptions and vulnerability_score — tracks because → therefore logic and quantifies fragility.
    • NarrativeStripper / ImplicitAssumptionDetector / VulnerabilityAssessor — the second-perspective operator pipeline.
    • AutomaticRepairEngine (full jump-word repair) / UltimateCausalNovelEngine / SecondPerspectiveCausalEngine / WorldBuilder (token-level worldview extraction) — the repair, whole-book audit, and worldview construction layer.
  • Business Engine (engine for business.py) — the SPL four-stage native reasoning pipeline:
    1. STRIP_NARRATIVE — identify narrative elements (foreshadowing / twist / climax / setup).
    2. SCAN_ASSUMPTION — ImplicitAssumptionScanner verifies motivation and plot logic.
    3. HEDGE_RISK — VulnerabilityHedge flags OOC, logic holes, and pacing issues; CausalIntersectionBroker merges worldlines.
    4. LOCK_RESPONSIBILITY — output a quality score with traceable optimizations.
    • Risk levels: SAFE / WARNING / CRITICAL / FATAL; node states: RAW / STRIPPED / AUDITED / PRUNED / ACTIVE.
    • SPLStoryGenerationEngine + StylisticScribe drive generation; DeepSeekProvider / MockLLM are replaceable LLM backends.

Document Review Engine (for enterprises)

An enterprise-grade document compliance review engine (compliance_engine/), zero-dependency and runs offline:

  • Supports clause-level rule scanning + document-level auditing (element completeness / consistency / rights-obligation parity / formatting) for four document types: contracts / regulations / official documents / general text.
  • ComplianceEngine orchestration: sectioning → rule scanning → document-level audit → responsibility loop → scoring → report.
  • ResponsibilityAccount responsibility-loop anchoring + TraceLog full-chain traceability; judgments are deterministic (hit = verdict), no probability output.
  • RuleEngine loads a pure JSON rule base (externally extensible via --rules-dir); four Auditor classes complement clause-level hits.
  • Reports support three formats: HTML (visualization) / JSON (structured) / Markdown (archiving); full CLI: audit / list-rules / demo.

Both products share the same deterministic audit design language (responsibility-loop anchoring, risk grading, full-chain traceability), but target creative narrative and enterprise document scenarios respectively.

Robustness hardening (2026-08 fixes):

  • Character-name plausibility filter — _extract_plausible_name excludes pronouns / verb phrases / weather-scene words, preferring absence over noise: "坚持己见" → "", "他说:我们走吧" → "", "林夏在评审会上坚持自研方案" → "林夏".
  • Token-level worldbuilding extraction — WorldBuilder pre-tokenizes on connectives / punctuation, then matches whole words with longest-suffix priority: "青云宗与魔道势力在苍云大陆" → factions ["青云宗","魔道势力"], geography ["苍云大陆"], connectives are no longer swallowed.
  • Full-text revision replacement — AutomaticRepairEngine replaces all stiff transition words at once (突然 / 莫名 / 鬼使神差 …) and merges adjacent duplicate transition phrases.
  • Engine isolation detection — both engines embed _ENGINE_FINGERPRINT and check_engine_isolation(): mixing both in one process warns immediately, preventing data corruption and crashes caused by homonymous but heterogeneous data classes (CausalNode / ResponsibilityAccount, etc.) overwriting each other.

— ✦ —

✦ Usage

import importlib.util

def load(name, path):
    spec = importlib.util.spec_from_file_location(name, path)
    m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m); return m

biz = load("biz", "engine for business.py")
print([s.name for s in biz.SPLStage])   # STRIP_NARRATIVE … LOCK_RESPONSIBILITY

# Engine isolation detection: clear warning when both engines are mixed
# (both engines register a fingerprint in sys.modules; any load path is detectable)
for conflict in biz.check_engine_isolation():
    print(f"⚠️ {conflict}")

Or run the built-in engines directly:

python "Story Engine for Creator.py"
python "engine for business.py"
python -m compliance_engine audit --type contract --input contract.txt --output report.html
python -m compliance_engine list-rules --type regulation
python -m compliance_engine demo

— ✦ —

✦ Project Structure

STORY-ENGINE/
├── Story Engine for Creator.py    # creator-facing narrative cognitive audit engine
├── engine for business.py         # SPL four-stage editorial + contract-review pipeline
├── compliance_engine/             # enterprise document compliance audit engine (offline, zero-dep)
│   ├── engine.py / models.py / auditors.py / rules.py / report.py
│   ├── cli.py                     # audit / list-rules / demo
│   ├── rules/                     # contract.json / regulation.json / official_doc.json / common.json
│   └── demo.py
├── assets/                        # banner.svg/png, overview.svg/png
└── LICENSE

— ✦ —

✦ Ecosystem

STORY-ENGINE is a member of the NOHN AI ecosystem — a family of projects built around second-perspective causal auditing and deterministic execution:

Project Repo Positioning
Second-Perspective (GCAE) nohn3043-arch/second-perspective Global cognitive audit engine — five-operator causal audit core (IMDA 95/100)
NOMOS nohn3043-arch/second-perspective (Intelligent-Decision-Hub--Nomos branch) Auditable deterministic decision hub (IMDA 95/100)
SPL-G1 nohn3043-arch/SPL-G1 Hardware causal-audit trusted computing unit (TCU)
SPL-Virtual-World-Base nohn3043-arch/Second-Reality Virtual-world & metaverse infrastructure (constitution / law / bridge)
Story-Engine nohn3043-arch/story-engine Story Engine (creators/public) + Document Review Engine (enterprise)
Antares nohn3043-arch/Antares GFSIP v1.0 — causally-audited federated stable interoperability protocol
Anthropomorphic-Agent-Engine nohn3043-arch/Anthropomorphic-Agent-Engine Deterministic anthropomorphic psychology engine (SPL Pure Core V8.0)
PAGES nohn3043-arch/pages NOHN AI ecosystem official landing page

— ✦ —

✦ License & Authorization

This repository is not open source and adopts a dual-track model: free for personal non-commercial research; government / enterprises require a paid commercial license. See LICENSE.

User Purpose License requirement
Individual (natural person) Non-commercial academic research / study / personal experiments Free under LICENSE "Personal Free Research License"
Government agency / public institution / enterprise Any purpose (incl. internal deployment, product development, service provision) Paid commercial license required in advance
  • Individual researchers may use it free for non-commercial research, but not for any commercial purpose, nor may they provide services to any enterprise or government agency.
  • Government / enterprise users may not copy, deploy, run, integrate, or distribute this work before signing a commercial license agreement and paying the agreed fee.
  • Apply for license: International / Global — ai@nohnlins.com · China — lin@secondai.top

The licensor, applicable law, and dispute resolution follow LICENSE based on the user's location: users within China → Shanghai Linming Junhua Technology Co., Ltd. (PRC law); users outside China → NOHN AI TECHNOLOGY PTE. LTD. (Singapore law, SIAC arbitration).

GitHub  ·  nohnlins.com  ·  ai@nohnlins.com

NOHN AI · STORY-ENGINE

About

确定性故事生成引擎:基于因果逻辑审计的叙事生成工具,保持角色性格与剧情发展完全一致,彻底消除逻辑漏洞与设定冲突,适用于游戏叙事、影视剧本创作、互动小说、IP内容生产、AIGC内容生成场景。

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages