tmdiff 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tmdiff/__init__.py +0 -0
- tmdiff/causal.py +118 -0
- tmdiff/cli.py +57 -0
- tmdiff/fingerprint.py +49 -0
- tmdiff/timeline.py +69 -0
- tmdiff/transport.py +39 -0
- tmdiff-0.1.0.dist-info/METADATA +61 -0
- tmdiff-0.1.0.dist-info/RECORD +12 -0
- tmdiff-0.1.0.dist-info/WHEEL +5 -0
- tmdiff-0.1.0.dist-info/entry_points.txt +2 -0
- tmdiff-0.1.0.dist-info/licenses/LICENSE +21 -0
- tmdiff-0.1.0.dist-info/top_level.txt +1 -0
tmdiff/__init__.py
ADDED
|
File without changes
|
tmdiff/causal.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Stage 4: Forward & retrocausal error-driven learning (√(F · Bᵀ)) + surprise detection."""
|
|
2
|
+
import math
|
|
3
|
+
import numpy as np
|
|
4
|
+
from tmdiff.fingerprint import tokenize
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _softmax(logits: np.ndarray) -> np.ndarray:
|
|
8
|
+
shifted = logits - np.max(logits)
|
|
9
|
+
exps = np.exp(shifted)
|
|
10
|
+
return exps / np.sum(exps)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CausalOrganism:
|
|
14
|
+
def __init__(self, max_vocab: int = 2000, lr: float = 0.08, decay: float = 0.5):
|
|
15
|
+
self.max_vocab = max_vocab
|
|
16
|
+
self.lr = lr
|
|
17
|
+
self.decay = decay
|
|
18
|
+
self.vocab: dict[str, int] = {}
|
|
19
|
+
self.inv_vocab: list[str] = []
|
|
20
|
+
self.W_fwd: np.ndarray | None = None
|
|
21
|
+
self.W_bwd: np.ndarray | None = None
|
|
22
|
+
|
|
23
|
+
def _build_vocab(self, tokenized_events: list[list[str]], max_df_ratio: float = 0.35):
|
|
24
|
+
n_docs = max(1, len(tokenized_events))
|
|
25
|
+
df: dict[str, int] = {}
|
|
26
|
+
tf: dict[str, int] = {}
|
|
27
|
+
for toks in tokenized_events:
|
|
28
|
+
seen = set()
|
|
29
|
+
for t in toks:
|
|
30
|
+
tf[t] = tf.get(t, 0) + 1
|
|
31
|
+
if t not in seen:
|
|
32
|
+
df[t] = df.get(t, 0) + 1
|
|
33
|
+
seen.add(t)
|
|
34
|
+
|
|
35
|
+
# Filter out high-frequency boilerplate (> max_df_ratio) unless archive is tiny
|
|
36
|
+
filtered = [
|
|
37
|
+
t for t, freq in tf.items()
|
|
38
|
+
if (df[t] / n_docs) <= max_df_ratio or n_docs < 10
|
|
39
|
+
]
|
|
40
|
+
filtered.sort(key=lambda t: (-tf[t], t))
|
|
41
|
+
selected = filtered[: self.max_vocab]
|
|
42
|
+
self.vocab = {t: i for i, t in enumerate(selected)}
|
|
43
|
+
self.inv_vocab = selected
|
|
44
|
+
V = len(selected)
|
|
45
|
+
# Born with W = 2I ("what was just said tends to recur")
|
|
46
|
+
self.W_fwd = 2.0 * np.eye(V, dtype=np.float64)
|
|
47
|
+
self.W_bwd = 2.0 * np.eye(V, dtype=np.float64)
|
|
48
|
+
|
|
49
|
+
def _vec(self, toks: list[str]) -> np.ndarray:
|
|
50
|
+
V = len(self.vocab)
|
|
51
|
+
v = np.zeros(V, dtype=np.float64)
|
|
52
|
+
for t in toks:
|
|
53
|
+
idx = self.vocab.get(t)
|
|
54
|
+
if idx is not None:
|
|
55
|
+
v[idx] += 1.0
|
|
56
|
+
norm = np.linalg.norm(v)
|
|
57
|
+
return v / norm if norm > 0 else v
|
|
58
|
+
|
|
59
|
+
def _run_pass(self, vectors: list[np.ndarray], W: np.ndarray) -> list[float]:
|
|
60
|
+
V = W.shape[0]
|
|
61
|
+
ctx = np.zeros(V, dtype=np.float64)
|
|
62
|
+
surprises = []
|
|
63
|
+
for y in vectors:
|
|
64
|
+
if np.sum(y) == 0:
|
|
65
|
+
surprises.append(0.0)
|
|
66
|
+
ctx *= self.decay
|
|
67
|
+
continue
|
|
68
|
+
y_dist = y / np.sum(y)
|
|
69
|
+
p = _softmax(W.T @ ctx)
|
|
70
|
+
# Cross-entropy surprise in bits
|
|
71
|
+
bits = -float(np.sum(y_dist * np.log2(np.clip(p, 1e-12, 1.0))))
|
|
72
|
+
surprises.append(bits)
|
|
73
|
+
# Update solely from prediction error
|
|
74
|
+
W += self.lr * np.outer(ctx, (y_dist - p))
|
|
75
|
+
ctx = self.decay * ctx + y
|
|
76
|
+
return surprises
|
|
77
|
+
|
|
78
|
+
def fit_and_score(self, events: list[dict]) -> list[dict]:
|
|
79
|
+
tokenized = [tokenize(e.get("text", "")) for e in events]
|
|
80
|
+
self._build_vocab(tokenized)
|
|
81
|
+
V = len(self.vocab)
|
|
82
|
+
if V == 0:
|
|
83
|
+
return [dict(e, surprise_bits=0.0, turning_point=False) for e in events]
|
|
84
|
+
|
|
85
|
+
vecs = [self._vec(toks) for toks in tokenized]
|
|
86
|
+
fwd_bits = self._run_pass(vecs, self.W_fwd)
|
|
87
|
+
bwd_bits = list(reversed(self._run_pass(list(reversed(vecs)), self.W_bwd)))
|
|
88
|
+
|
|
89
|
+
combined = [math.sqrt(max(0.0, f * b)) for f, b in zip(fwd_bits, bwd_bits)]
|
|
90
|
+
mean_s = sum(combined) / max(1, len(combined))
|
|
91
|
+
std_s = math.sqrt(sum((x - mean_s) ** 2 for x in combined) / max(1, len(combined)))
|
|
92
|
+
threshold = mean_s + 0.75 * std_s
|
|
93
|
+
|
|
94
|
+
scored = []
|
|
95
|
+
for ev, f_b, b_b, c_b in zip(events, fwd_bits, bwd_bits, combined):
|
|
96
|
+
row = dict(ev)
|
|
97
|
+
row["fwd_bits"] = round(f_b, 3)
|
|
98
|
+
row["bwd_bits"] = round(b_b, 3)
|
|
99
|
+
row["surprise_bits"] = round(c_b, 3)
|
|
100
|
+
row["turning_point"] = bool(c_b > threshold and c_b > 0)
|
|
101
|
+
scored.append(row)
|
|
102
|
+
return scored
|
|
103
|
+
|
|
104
|
+
def symmetric_links(self, top_k: int = 10) -> list[tuple[str, str, float]]:
|
|
105
|
+
if self.W_fwd is None or self.W_bwd is None or len(self.inv_vocab) == 0:
|
|
106
|
+
return []
|
|
107
|
+
F = np.maximum(0.0, self.W_fwd - 2.0 * np.eye(len(self.inv_vocab)))
|
|
108
|
+
B = np.maximum(0.0, self.W_bwd - 2.0 * np.eye(len(self.inv_vocab)))
|
|
109
|
+
sym = np.sqrt(F * B.T)
|
|
110
|
+
np.fill_diagonal(sym, 0.0)
|
|
111
|
+
pairs = []
|
|
112
|
+
V = len(self.inv_vocab)
|
|
113
|
+
for i in range(V):
|
|
114
|
+
for j in range(V):
|
|
115
|
+
if sym[i, j] > 0:
|
|
116
|
+
pairs.append((self.inv_vocab[i], self.inv_vocab[j], round(float(sym[i, j]), 4)))
|
|
117
|
+
pairs.sort(key=lambda x: -x[2])
|
|
118
|
+
return pairs[:top_k]
|
tmdiff/cli.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""CLI entry point for tmdiff."""
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
from tmdiff.timeline import anchor_event
|
|
5
|
+
from tmdiff.fingerprint import structural_hash
|
|
6
|
+
from tmdiff.causal import CausalOrganism
|
|
7
|
+
from tmdiff.transport import pack_events
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
parser = argparse.ArgumentParser(prog="tmdiff", description="Causal & structural archive diff")
|
|
12
|
+
parser.add_argument("input", help="Path to JSONL file of {platform, id, text} events")
|
|
13
|
+
parser.add_argument("--pack", help="Optional path to write round-trip verified .utf8.json envelope")
|
|
14
|
+
parser.add_argument("--links", type=int, default=8, help="Number of symmetric causal links to display")
|
|
15
|
+
args = parser.parse_args()
|
|
16
|
+
|
|
17
|
+
raw_events = []
|
|
18
|
+
with open(args.input, "r", encoding="utf-8") as f:
|
|
19
|
+
for line in f:
|
|
20
|
+
if line.strip():
|
|
21
|
+
raw_events.append(json.loads(line))
|
|
22
|
+
|
|
23
|
+
enriched = []
|
|
24
|
+
seen_hashes = set()
|
|
25
|
+
for ev in raw_events:
|
|
26
|
+
e = anchor_event(ev)
|
|
27
|
+
h = structural_hash(e.get("text", ""))
|
|
28
|
+
e["struct_hash"] = h
|
|
29
|
+
e["duplicate_structure"] = h in seen_hashes
|
|
30
|
+
seen_hashes.add(h)
|
|
31
|
+
enriched.append(e)
|
|
32
|
+
|
|
33
|
+
# Sort anchored events chronologically while preserving relative order of unanchored ones
|
|
34
|
+
enriched.sort(key=lambda x: (0, x["timestamp"]) if x["anchored"] else (1, ""))
|
|
35
|
+
|
|
36
|
+
org = CausalOrganism()
|
|
37
|
+
scored = org.fit_and_score(enriched)
|
|
38
|
+
|
|
39
|
+
print(f"Processed {len(scored)} events | Turning points isolated:")
|
|
40
|
+
for row in scored:
|
|
41
|
+
if row["turning_point"]:
|
|
42
|
+
ts = row["timestamp"] or "UNANCHORED"
|
|
43
|
+
print(f" [{ts}] ({row['surprise_bits']} bits) {row['text'][:72]}")
|
|
44
|
+
|
|
45
|
+
print("\nTop symmetric causal links √(F·Bᵀ):")
|
|
46
|
+
for a, b, score in org.symmetric_links(top_k=args.links):
|
|
47
|
+
print(f" {a} <-> {b} : {score}")
|
|
48
|
+
|
|
49
|
+
if args.pack:
|
|
50
|
+
env = pack_events(scored, source=args.input)
|
|
51
|
+
with open(args.pack, "w", encoding="utf-8") as f:
|
|
52
|
+
json.dump(env, f, ensure_ascii=False, indent=2)
|
|
53
|
+
print(f"\nPacked verified UTF-8 envelope -> {args.pack}")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
main()
|
tmdiff/fingerprint.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Stage 3: Structural fingerprinting & negation-aware tokenization."""
|
|
2
|
+
import hashlib
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
NEGATIONS = {"not", "no", "never", "nahi", "na", "mat", "dont", "don't", "cannot", "can't", "!"}
|
|
6
|
+
BOILERPLATE_RE = re.compile(
|
|
7
|
+
r"^(signed-off-by:|co-authored-by:|generated by|copyright\s+\d{4})",
|
|
8
|
+
re.IGNORECASE,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def normalize_skeleton(text: str) -> str:
|
|
13
|
+
"""Strip variable literals (numbers, hex IDs, URLs, timestamps) to expose structural skeleton."""
|
|
14
|
+
lines = [
|
|
15
|
+
line.strip()
|
|
16
|
+
for line in text.splitlines()
|
|
17
|
+
if line.strip() and not BOILERPLATE_RE.match(line.strip())
|
|
18
|
+
]
|
|
19
|
+
joined = " ".join(lines).lower()
|
|
20
|
+
joined = re.sub(r"https?://\S+", "<URL>", joined)
|
|
21
|
+
joined = re.sub(r"\b[0-9a-f]{8,}\b", "<HEX>", joined)
|
|
22
|
+
joined = re.sub(r"\b\d+(\.\d+)?\b", "<NUM>", joined)
|
|
23
|
+
joined = re.sub(r"\s+", " ", joined).strip()
|
|
24
|
+
return joined
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def structural_hash(text: str) -> str:
|
|
28
|
+
skel = normalize_skeleton(text)
|
|
29
|
+
return hashlib.sha256(skel.encode("utf-8")).hexdigest()[:16]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def tokenize(text: str) -> list[str]:
|
|
33
|
+
"""Tokenize content words while binding negation markers to the following term."""
|
|
34
|
+
skel = normalize_skeleton(text)
|
|
35
|
+
raw_tokens = re.findall(r"[a-z_<>]+", skel)
|
|
36
|
+
out = []
|
|
37
|
+
negate_next = False
|
|
38
|
+
for tok in raw_tokens:
|
|
39
|
+
if tok in NEGATIONS:
|
|
40
|
+
negate_next = True
|
|
41
|
+
continue
|
|
42
|
+
if len(tok) < 2:
|
|
43
|
+
continue
|
|
44
|
+
if negate_next:
|
|
45
|
+
out.append(f"¬{tok}")
|
|
46
|
+
negate_next = False
|
|
47
|
+
else:
|
|
48
|
+
out.append(tok)
|
|
49
|
+
return out
|
tmdiff/timeline.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Stage 1: Recover exact birth timestamps from platform IDs without guessing."""
|
|
2
|
+
from datetime import datetime, timezone
|
|
3
|
+
from typing import Optional
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
TWITTER_EPOCH_MS = 1288834974657
|
|
7
|
+
DISCORD_EPOCH_MS = 1420070400000
|
|
8
|
+
UUID_EPOCH_OFFSET_100NS = 0x01B21DD213814000 # 1582-10-15 to 1970-01-01
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UndecodableID(ValueError):
|
|
12
|
+
"""Raised when an identifier carries no embedded timestamp."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def decode_id(platform: str, raw_id: str | int) -> datetime:
|
|
16
|
+
p = platform.strip().lower()
|
|
17
|
+
s = str(raw_id).strip()
|
|
18
|
+
|
|
19
|
+
if p == "slack":
|
|
20
|
+
if s.startswith("p") and s[1:].isdigit() and len(s) >= 17:
|
|
21
|
+
sec = int(s[1:11])
|
|
22
|
+
usec = int(s[11:17])
|
|
23
|
+
return datetime.fromtimestamp(sec + usec / 1_000_000, tz=timezone.utc)
|
|
24
|
+
if "." in s:
|
|
25
|
+
return datetime.fromtimestamp(float(s), tz=timezone.utc)
|
|
26
|
+
raise UndecodableID(f"Slack ID lacks microsecond ts: {s}")
|
|
27
|
+
|
|
28
|
+
if p in ("twitter", "x"):
|
|
29
|
+
if not s.isdigit() or len(s) < 15:
|
|
30
|
+
raise UndecodableID(f"Sequential/pre-snowflake Twitter ID: {s}")
|
|
31
|
+
ms = (int(s) >> 22) + TWITTER_EPOCH_MS
|
|
32
|
+
return datetime.fromtimestamp(ms / 1000.0, tz=timezone.utc)
|
|
33
|
+
|
|
34
|
+
if p == "discord":
|
|
35
|
+
if not s.isdigit():
|
|
36
|
+
raise UndecodableID(f"Invalid Discord snowflake: {s}")
|
|
37
|
+
ms = (int(s) >> 22) + DISCORD_EPOCH_MS
|
|
38
|
+
return datetime.fromtimestamp(ms / 1000.0, tz=timezone.utc)
|
|
39
|
+
|
|
40
|
+
if p == "gmail":
|
|
41
|
+
if len(s) <= 5 or not all(c in "0123456789abcdefABCDEF" for c in s):
|
|
42
|
+
raise UndecodableID(f"Invalid Gmail hex ID: {s}")
|
|
43
|
+
ms = int(s[:-5], 16)
|
|
44
|
+
return datetime.fromtimestamp(ms / 1000.0, tz=timezone.utc)
|
|
45
|
+
|
|
46
|
+
if p == "uuid":
|
|
47
|
+
u = uuid.UUID(s)
|
|
48
|
+
if u.version == 7:
|
|
49
|
+
ms = int.from_bytes(u.bytes[:6], "big")
|
|
50
|
+
return datetime.fromtimestamp(ms / 1000.0, tz=timezone.utc)
|
|
51
|
+
if u.version == 1:
|
|
52
|
+
ts_100ns = u.time - UUID_EPOCH_OFFSET_100NS
|
|
53
|
+
return datetime.fromtimestamp(ts_100ns / 10_000_000.0, tz=timezone.utc)
|
|
54
|
+
raise UndecodableID(f"UUIDv{u.version} carries no timestamp: {s}")
|
|
55
|
+
|
|
56
|
+
raise UndecodableID(f"Unsupported or unanchored platform: {platform}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def anchor_event(event: dict) -> dict:
|
|
60
|
+
"""Attach ISO timestamp if decodable; otherwise explicitly mark unanchored."""
|
|
61
|
+
out = dict(event)
|
|
62
|
+
try:
|
|
63
|
+
dt = decode_id(event.get("platform", ""), event.get("id", ""))
|
|
64
|
+
out["timestamp"] = dt.isoformat()
|
|
65
|
+
out["anchored"] = True
|
|
66
|
+
except (UndecodableID, ValueError):
|
|
67
|
+
out["timestamp"] = None
|
|
68
|
+
out["anchored"] = False
|
|
69
|
+
return out
|
tmdiff/transport.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Stage 2: Self-describing UTF-8 byte-list transport with round-trip verification."""
|
|
2
|
+
import json
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
HOW = (
|
|
6
|
+
"Each list in 'parts' is UTF-8 bytes. Decode with bytes(list).decode('utf-8'). "
|
|
7
|
+
"'kind' specifies reassembly."
|
|
8
|
+
)
|
|
9
|
+
JOIN = {
|
|
10
|
+
"text": "parts are paragraphs: join with \\n\\n",
|
|
11
|
+
"jsonl": "parts are lines: join with \\n",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def pack_events(events: list[dict], source: str = "stream.jsonl") -> dict:
|
|
16
|
+
lines = [json.dumps(e, ensure_ascii=False, separators=(",", ":")) for e in events]
|
|
17
|
+
parts = [list(line.encode("utf-8")) for line in lines]
|
|
18
|
+
envelope = {
|
|
19
|
+
"format": "utf-8 byte lists",
|
|
20
|
+
"kind": "jsonl",
|
|
21
|
+
"join": JOIN["jsonl"],
|
|
22
|
+
"how_to_decode": HOW,
|
|
23
|
+
"source": source,
|
|
24
|
+
"parts": parts,
|
|
25
|
+
}
|
|
26
|
+
unpacked = unpack_events(envelope)
|
|
27
|
+
assert unpacked == events, "Round-trip verification failed"
|
|
28
|
+
return envelope
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def unpack_events(envelope: dict) -> list[dict]:
|
|
32
|
+
if envelope.get("format") != "utf-8 byte lists":
|
|
33
|
+
raise ValueError("Unsupported envelope format")
|
|
34
|
+
strs = [bytes(p).decode("utf-8") for p in envelope["parts"]]
|
|
35
|
+
if envelope.get("kind") == "jsonl":
|
|
36
|
+
return [json.loads(s) for s in strs if s.strip()]
|
|
37
|
+
if envelope.get("kind") == "text":
|
|
38
|
+
return [{"text": "\n\n".join(strs)}]
|
|
39
|
+
raise ValueError(f"Unsupported kind: {envelope.get('kind')}")
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tmdiff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: git diff for chat exports and logs — 100% offline, zero LLMs, pure arithmetic.
|
|
5
|
+
Author-email: Abhishek Srivastava <bitsabhi@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/0x-auth/tmdiff
|
|
8
|
+
Project-URL: Repository, https://github.com/0x-auth/tmdiff
|
|
9
|
+
Keywords: diff,timeline,snowflake,causality,logs,archaeology
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Text Processing
|
|
15
|
+
Classifier: Topic :: Utilities
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy>=1.24
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# tmdiff
|
|
23
|
+
|
|
24
|
+
**`git diff` for your chat exports, logs, and notes — 100% offline, zero LLMs.**
|
|
25
|
+
|
|
26
|
+
When you export years of messages from Slack, Discord, Gmail, or AI chats, 95% of the file is repetitive noise, boilerplate, and broken timestamps. `tmdiff` filters out the predictable background and hands you back **only the turning points** where a new idea, bug, or shift actually happened.
|
|
27
|
+
|
|
28
|
+
## What It Does in 4 Steps
|
|
29
|
+
|
|
30
|
+
1. **Rebuilds the True Timeline (`timeline.py`)**
|
|
31
|
+
Extracts exact microsecond creation timestamps straight from platform IDs (Slack `ts`, Discord/X snowflakes, Gmail hex IDs, UUIDv1/v7). If an ID has no timestamp (like UUIDv4 or Reddit), it marks it `UNANCHORED` instead of guessing.
|
|
32
|
+
2. **Strips Boilerplate & Variables (`fingerprint.py`)**
|
|
33
|
+
Ignores numbers, URLs, hex hashes, and commit/export boilerplate (`Signed-off-by`, etc.), and binds negations (`not converge` → `¬converge`) so opposites don't look identical.
|
|
34
|
+
3. **Finds the Turning Points (`causal.py`)**
|
|
35
|
+
Runs a lightweight forward-and-backward prediction model (`numpy` only) over your timeline. Routine messages score low surprise and get ignored; sudden conceptual shifts score high surprise (`bits`) and get flagged as **turning points**.
|
|
36
|
+
4. **Packs Lossless Handoffs (`transport.py`)**
|
|
37
|
+
Optionally exports the cleaned timeline into a self-describing, round-trip-verified UTF-8 byte envelope (`.utf8.json`) that never breaks on quotes or special characters.
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e .
|
|
43
|
+
python3 -m tmdiff.cli examples/sample_archive.jsonl
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Example Output
|
|
47
|
+
```text
|
|
48
|
+
Processed 6 events | Turning points isolated:
|
|
49
|
+
[2025-10-31T17:15:00.500000+00:00] (5.911 bits) Solver did not converge when mirror partner was omitted from state
|
|
50
|
+
[2026-08-26T13:16:58.180000+00:00] (5.842 bits) Verified Davenport-Heilbronn mod 5 crossing at n=285 without Euler product
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Run Tests
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python3 -m unittest discover -v tests
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
tmdiff/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
tmdiff/causal.py,sha256=VKeU7DttDW6oqAUEmrvDxX_P_lu3lqPiLrMyaK_J-zI,4639
|
|
3
|
+
tmdiff/cli.py,sha256=l5OAHmNFZL0GDcoTZBoUofCWNQL3J6ZS3mtOMhcffME,2104
|
|
4
|
+
tmdiff/fingerprint.py,sha256=LTybY1S2KVMB4x_IbYmzTYq42rEq0kcnHlIkgOCwQ84,1575
|
|
5
|
+
tmdiff/timeline.py,sha256=cln45lxcKlF5SBJP9e_r_fw2Yvrkw_Ke8NKd3-SzMJE,2612
|
|
6
|
+
tmdiff/transport.py,sha256=ll0bTXkKRmvv7z9hlhZhrbyatoUUXD-aFr_DfOlnqL8,1368
|
|
7
|
+
tmdiff-0.1.0.dist-info/licenses/LICENSE,sha256=tfBbTtYxuz2lZdOoptovubLtDHM5AwB2o4AYsnzvTWI,1076
|
|
8
|
+
tmdiff-0.1.0.dist-info/METADATA,sha256=esRXraxyIGAsh3QEyYBmEfNizdEBMj3CqFh5mN7QIB4,2725
|
|
9
|
+
tmdiff-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
10
|
+
tmdiff-0.1.0.dist-info/entry_points.txt,sha256=Lv3OtM5f9lIiaiCH5roSzf1rPvmNc5M5odGG8q8kBps,43
|
|
11
|
+
tmdiff-0.1.0.dist-info/top_level.txt,sha256=q5uizC_zveSb5YJUeD2U_jEo9p9Vx9rSvhPy5_llwns,7
|
|
12
|
+
tmdiff-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abhishek Srivastava
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tmdiff
|