@m13v/s4l 1.7.7-rc.6 → 1.7.7-rc.7
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.
- package/mcp/dist/repo.js +3 -1
- package/mcp/dist/version.json +2 -2
- package/mcp/manifest.json +1 -1
- package/mcp/menubar/s4l_menubar.py +38 -0
- package/mcp/menubar/s4l_state.py +118 -5
- package/mcp/package.json +1 -1
- package/package.json +1 -1
- package/scripts/context_mining.py +49 -23
- package/scripts/merge_review_queue.py +3 -1
package/mcp/dist/repo.js
CHANGED
|
@@ -211,7 +211,9 @@ export function readPlan(batchId) {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
export function writePlan(batchId, plan) {
|
|
214
|
-
|
|
214
|
+
// Compact (no indent): the review store reached 65 MB with pretty-printing
|
|
215
|
+
// (2026-08-02 lag incident) and every reader pays the parse.
|
|
216
|
+
fs.writeFileSync(planPath(batchId), JSON.stringify(plan), "utf-8");
|
|
215
217
|
}
|
|
216
218
|
// Find the newest plan file when no batch id is supplied.
|
|
217
219
|
export function latestBatchId() {
|
package/mcp/dist/version.json
CHANGED
package/mcp/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"dxt_version": "0.1",
|
|
3
3
|
"name": "social-autoposter",
|
|
4
4
|
"display_name": "S4L",
|
|
5
|
-
"version": "1.7.7-rc.
|
|
5
|
+
"version": "1.7.7-rc.7",
|
|
6
6
|
"description": "Draft, review, approve, and autopilot X/Twitter posts.",
|
|
7
7
|
"long_description": "## **⚠️ The disclaimer above is generic Claude boilerplate.** Anthropic shows the same warning on every plugin regardless of what it does; any plugin has the same level of access as any app you download from the internet.\n\nS4L is an open source product developed by Mediar.ai Incorporated, a VC-backed San Francisco-based startup.\n\nTo get started:\n\n1\\. Copy this prompt: **Set me up on S4L plugin end to end**\n\n2\\. Quit with CMD+Q, reopen Claude, paste into a new chat.\n\nWhat happens next:\n\n* About every 5 minutes S4L scans X for posts that match your topics and drafts replies in your voice.\n* Drafts show up as review cards, usually the first within a few minutes. Nothing is posted automatically; you approve each one.\n* Posting autopilot stays off until you explicitly turn it on.",
|
|
8
8
|
"author": {
|
|
@@ -27,6 +27,20 @@ import sys
|
|
|
27
27
|
import tempfile
|
|
28
28
|
import threading
|
|
29
29
|
import time
|
|
30
|
+
import warnings
|
|
31
|
+
|
|
32
|
+
# PyObjC emits an ObjCPointerWarning for every CGColor() handed to a CALayer
|
|
33
|
+
# (s4l_card's tile styling). The message embeds the pointer address, so the
|
|
34
|
+
# warnings module's once-per-location dedup never matches and a single card
|
|
35
|
+
# render sprayed ~100 lines/sec into menubar.err.log (13k+ lines by the
|
|
36
|
+
# 2026-08-02 lag incident). The pointers are handled correctly; silence the
|
|
37
|
+
# category before any card module loads.
|
|
38
|
+
try:
|
|
39
|
+
import objc
|
|
40
|
+
|
|
41
|
+
warnings.filterwarnings("ignore", category=objc.ObjCPointerWarning)
|
|
42
|
+
except Exception:
|
|
43
|
+
pass
|
|
30
44
|
|
|
31
45
|
# --- stderr timestamp wrapper -------------------------------------------------
|
|
32
46
|
# menubar.err.log (this process's stderr, redirected by the launchd plist) has
|
|
@@ -715,8 +729,28 @@ class S4LMenuBar(rumps.App):
|
|
|
715
729
|
self._tick_stats_at = 0.0
|
|
716
730
|
self._reloc_timer = rumps.Timer(self._maybe_relocate_tasks, 90)
|
|
717
731
|
self._reloc_timer.start()
|
|
732
|
+
# Store compaction: archive heavy fields off settled candidates so the
|
|
733
|
+
# review-queue file (and every 1s/5s poll that parses it) stays small.
|
|
734
|
+
# Boot pass runs off the main thread — the first pass after an
|
|
735
|
+
# un-compacted stretch can chew through tens of MB.
|
|
736
|
+
self._compacted_at = 0.0
|
|
737
|
+
self._compact_store_async()
|
|
718
738
|
self._tick(None)
|
|
719
739
|
|
|
740
|
+
def _compact_store_async(self):
|
|
741
|
+
self._compacted_at = time.time()
|
|
742
|
+
|
|
743
|
+
def run():
|
|
744
|
+
try:
|
|
745
|
+
n = st.compact_store()
|
|
746
|
+
if n:
|
|
747
|
+
sys.stderr.write(f"[s4l-menubar] store compaction archived {n} candidate(s)\n")
|
|
748
|
+
sys.stderr.flush()
|
|
749
|
+
except Exception:
|
|
750
|
+
pass
|
|
751
|
+
|
|
752
|
+
threading.Thread(target=run, daemon=True, name="s4l-compact-store").start()
|
|
753
|
+
|
|
720
754
|
# ---- side effects -----------------------------------------------------
|
|
721
755
|
def _open_claude(self, _=None):
|
|
722
756
|
subprocess.run(["open", "-a", CLAUDE_APP], capture_output=True,
|
|
@@ -3009,6 +3043,10 @@ class S4LMenuBar(rumps.App):
|
|
|
3009
3043
|
sys.stderr.flush()
|
|
3010
3044
|
except Exception:
|
|
3011
3045
|
pass
|
|
3046
|
+
# Hourly store compaction keeps the review-queue file small as posts
|
|
3047
|
+
# settle (boot already ran one pass; see _compact_store_async).
|
|
3048
|
+
if now_rc - self._compacted_at >= 3600:
|
|
3049
|
+
self._compact_store_async()
|
|
3012
3050
|
|
|
3013
3051
|
# ---- draft review pop-ups ---------------------------------------------
|
|
3014
3052
|
def _posting_activity_label_locked(self):
|
package/mcp/menubar/s4l_state.py
CHANGED
|
@@ -721,7 +721,9 @@ def _store_update(mutate):
|
|
|
721
721
|
data = {"candidates": []}
|
|
722
722
|
rv = mutate(data)
|
|
723
723
|
tmp = f"{sp}.tmp.{os.getpid()}"
|
|
724
|
-
|
|
724
|
+
# Compact separators: this file reached 65 MB with indent=2
|
|
725
|
+
# (2026-08-02 lag incident) and every reader pays the parse.
|
|
726
|
+
Path(tmp).write_text(json.dumps(data, separators=(",", ":")))
|
|
725
727
|
os.replace(tmp, sp)
|
|
726
728
|
return rv
|
|
727
729
|
finally:
|
|
@@ -779,6 +781,97 @@ def candidate_state(c):
|
|
|
779
781
|
return "awaiting_review"
|
|
780
782
|
|
|
781
783
|
|
|
784
|
+
# Draft-time payloads that are only needed while a candidate can still POST
|
|
785
|
+
# (awaiting_review: card rendering; approved/post_failed: the drain path
|
|
786
|
+
# rebuilds a mini-plan from reddit_decision/reddit_plan_meta). Once a candidate
|
|
787
|
+
# is posted or terminal these blobs are dead weight — and they dominated the
|
|
788
|
+
# 65 MB store that caused the 2026-08-02 UI lag (single reddit candidates
|
|
789
|
+
# carried ~180 KB). Compaction moves them to an append-only sidecar so the
|
|
790
|
+
# append-forever ledger keeps every byte while the hot file stays small.
|
|
791
|
+
HEAVY_ARCHIVE_FIELDS = ("reddit_plan_meta", "reddit_decision", "thread_selftext")
|
|
792
|
+
|
|
793
|
+
# Audit-only blobs inside reddit_plan_meta.style_assignment, stamped by
|
|
794
|
+
# engagement_styles.pick_style_for_post "for audit" and copied onto EVERY
|
|
795
|
+
# reddit candidate by merge_review_queue. distribution_snapshot alone was
|
|
796
|
+
# ~107 KB per candidate (7.6 MB across one pending backlog). Nothing on the
|
|
797
|
+
# card-render or posting path reads them (post_reddit.py --phase post uses
|
|
798
|
+
# only .style/.mode; index.ts forwards the dict opaquely), so they are safe
|
|
799
|
+
# to archive off candidates in ANY state, pending included.
|
|
800
|
+
STYLE_AUDIT_FIELDS = ("distribution_snapshot", "reference_styles")
|
|
801
|
+
|
|
802
|
+
ARCHIVE_STORE = "review-queue-archive.jsonl"
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def compact_store():
|
|
806
|
+
"""Archive heavy payloads out of the hot store into review-queue-archive
|
|
807
|
+
.jsonl, then rewrite the store compactly. Two passes over the candidates:
|
|
808
|
+
HEAVY_ARCHIVE_FIELDS come off SETTLED (posted/terminal) candidates only —
|
|
809
|
+
approved/post_failed rows still need reddit_decision/reddit_plan_meta for
|
|
810
|
+
a (re-)approval drain — while STYLE_AUDIT_FIELDS come off every candidate.
|
|
811
|
+
Runs under the same store lock as every other python writer. The archive
|
|
812
|
+
lines land (flush+fsync) BEFORE any field is stripped, so no data is ever
|
|
813
|
+
lost — a crash in between only risks a duplicate archive line, never a
|
|
814
|
+
missing one. Returns the number of candidates compacted (0 when there was
|
|
815
|
+
nothing to do), None on failure."""
|
|
816
|
+
|
|
817
|
+
ap = str(Path(state_dir()) / ARCHIVE_STORE)
|
|
818
|
+
|
|
819
|
+
def mutate(data):
|
|
820
|
+
records = [] # (candidate, archived-fields dict, strip callback)
|
|
821
|
+
for c in data.get("candidates") or []:
|
|
822
|
+
fields = {}
|
|
823
|
+
settled = candidate_state(c) in ("posted", "terminal")
|
|
824
|
+
if settled:
|
|
825
|
+
fields.update(
|
|
826
|
+
{k: c[k] for k in HEAVY_ARCHIVE_FIELDS if c.get(k)}
|
|
827
|
+
)
|
|
828
|
+
sa = (c.get("reddit_plan_meta") or {}).get("style_assignment")
|
|
829
|
+
audit = (
|
|
830
|
+
{}
|
|
831
|
+
if (settled and "reddit_plan_meta" in fields) or not isinstance(sa, dict)
|
|
832
|
+
else {k: sa[k] for k in STYLE_AUDIT_FIELDS if sa.get(k)}
|
|
833
|
+
)
|
|
834
|
+
if audit:
|
|
835
|
+
fields["style_assignment_audit"] = audit
|
|
836
|
+
|
|
837
|
+
def strip(c=c, settled=settled, sa=sa, audit=audit):
|
|
838
|
+
if settled:
|
|
839
|
+
for k in HEAVY_ARCHIVE_FIELDS:
|
|
840
|
+
c.pop(k, None)
|
|
841
|
+
for k in audit:
|
|
842
|
+
sa.pop(k, None)
|
|
843
|
+
|
|
844
|
+
if fields:
|
|
845
|
+
records.append((c, fields, strip))
|
|
846
|
+
if not records:
|
|
847
|
+
return 0
|
|
848
|
+
with open(ap, "a") as f:
|
|
849
|
+
for c, fields, _ in records:
|
|
850
|
+
f.write(
|
|
851
|
+
json.dumps(
|
|
852
|
+
{
|
|
853
|
+
"candidate_id": c.get("candidate_id"),
|
|
854
|
+
"our_url": c.get("our_url"),
|
|
855
|
+
"thread_url": c.get("thread_url"),
|
|
856
|
+
"archived_at": time_iso(),
|
|
857
|
+
"fields": fields,
|
|
858
|
+
},
|
|
859
|
+
separators=(",", ":"),
|
|
860
|
+
)
|
|
861
|
+
+ "\n"
|
|
862
|
+
)
|
|
863
|
+
f.flush()
|
|
864
|
+
os.fsync(f.fileno())
|
|
865
|
+
for c, fields, strip in records:
|
|
866
|
+
strip()
|
|
867
|
+
c["archived_fields"] = sorted(
|
|
868
|
+
set(c.get("archived_fields") or []) | set(fields)
|
|
869
|
+
)
|
|
870
|
+
return len(records)
|
|
871
|
+
|
|
872
|
+
return _store_update(mutate)
|
|
873
|
+
|
|
874
|
+
|
|
782
875
|
def store_stamp_decision(batch, decision):
|
|
783
876
|
"""Write a card decision INTO the store the instant the user clicks. This is
|
|
784
877
|
the durable record (the old approved-queue.json ledger is no longer
|
|
@@ -1001,13 +1094,22 @@ def store_reconcile_decisions(batch, decisions):
|
|
|
1001
1094
|
return fixed
|
|
1002
1095
|
|
|
1003
1096
|
|
|
1097
|
+
# (path, mtime_ns, size) -> posted count. review_queue_posted_count() is on the
|
|
1098
|
+
# menubar's 1-second activity poll; without this cache that poll re-parsed the
|
|
1099
|
+
# whole store every tick, which saturated the AppKit main thread once the file
|
|
1100
|
+
# grew (2026-08-02: 65 MB, 98% CPU, multi-second card lag).
|
|
1101
|
+
_posted_count_cache = {"key": None, "count": None}
|
|
1102
|
+
|
|
1103
|
+
|
|
1004
1104
|
def review_queue_posted_count():
|
|
1005
1105
|
"""Posts that have LANDED in the review-queue plan — the durable, cross-process
|
|
1006
1106
|
truth. Independent of the menu bar's in-memory burst queue (which dies on a
|
|
1007
1107
|
restart) and of WHICH process is posting (the menu bar worker, the autopilot,
|
|
1008
1108
|
or a host agent draining via approve_drafts). Returns the posted count, or None
|
|
1009
1109
|
when the plan can't be read. Drives the menu-bar posting indicator so progress
|
|
1010
|
-
stays visible regardless of how the drain is driven.
|
|
1110
|
+
stays visible regardless of how the drain is driven. Cached on the plan
|
|
1111
|
+
file's (mtime, size): the caller polls every second, the file changes only
|
|
1112
|
+
when a writer lands."""
|
|
1011
1113
|
plan_path = None
|
|
1012
1114
|
req = read_review_request()
|
|
1013
1115
|
if req:
|
|
@@ -1016,11 +1118,22 @@ def review_queue_posted_count():
|
|
|
1016
1118
|
plan_path = store_path()
|
|
1017
1119
|
if not Path(plan_path).exists():
|
|
1018
1120
|
plan_path = "/tmp/twitter_cycle_plan_review-queue.json"
|
|
1121
|
+
try:
|
|
1122
|
+
stt = os.stat(plan_path)
|
|
1123
|
+
cache_key = (os.path.realpath(plan_path), stt.st_mtime_ns, stt.st_size)
|
|
1124
|
+
except OSError:
|
|
1125
|
+
cache_key = None
|
|
1126
|
+
if cache_key is not None and _posted_count_cache["key"] == cache_key:
|
|
1127
|
+
return _posted_count_cache["count"]
|
|
1019
1128
|
plan = read_plan(plan_path)
|
|
1020
1129
|
cands = (plan or {}).get("candidates")
|
|
1021
|
-
if not cands
|
|
1022
|
-
|
|
1023
|
-
|
|
1130
|
+
count = None if not cands else sum(
|
|
1131
|
+
1 for c in cands if candidate_state(c) == "posted"
|
|
1132
|
+
)
|
|
1133
|
+
if cache_key is not None:
|
|
1134
|
+
_posted_count_cache["key"] = cache_key
|
|
1135
|
+
_posted_count_cache["count"] = count
|
|
1136
|
+
return count
|
|
1024
1137
|
|
|
1025
1138
|
|
|
1026
1139
|
def review_drafts(plan, batch="review-queue"):
|
package/mcp/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m13v/s4l-mcp",
|
|
3
|
-
"version": "1.7.7-rc.
|
|
3
|
+
"version": "1.7.7-rc.7",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Desktop MCP client for social-autoposter (X/Twitter rail): manual draft/review/approve loop, autopilot control, and stats. Thin wrapper over the existing pipeline scripts.",
|
|
6
6
|
"license": "MIT",
|
package/package.json
CHANGED
|
@@ -304,13 +304,20 @@ SCHEMA = {
|
|
|
304
304
|
"type": "array",
|
|
305
305
|
"items": {
|
|
306
306
|
"type": "object",
|
|
307
|
-
"required": [
|
|
307
|
+
"required": [
|
|
308
|
+
"action",
|
|
309
|
+
"title",
|
|
310
|
+
"story",
|
|
311
|
+
"conclusion",
|
|
312
|
+
"source_session",
|
|
313
|
+
"source_date",
|
|
314
|
+
],
|
|
308
315
|
"properties": {
|
|
309
316
|
"action": {"type": "string", "enum": ["add", "revise"]},
|
|
310
317
|
"revises_line": {"type": ["integer", "null"]},
|
|
311
|
-
"
|
|
312
|
-
"
|
|
313
|
-
"
|
|
318
|
+
"title": {"type": "string"},
|
|
319
|
+
"story": {"type": "string"},
|
|
320
|
+
"conclusion": {"type": "string"},
|
|
314
321
|
"source_session": {"type": "string"},
|
|
315
322
|
"source_date": {"type": "string"},
|
|
316
323
|
},
|
|
@@ -320,6 +327,15 @@ SCHEMA = {
|
|
|
320
327
|
}
|
|
321
328
|
|
|
322
329
|
|
|
330
|
+
def corpus_entry(p: dict) -> str:
|
|
331
|
+
"""Render one approved proposal as a single corpus line (numbering is
|
|
332
|
+
line-based, so the entry must not contain newlines)."""
|
|
333
|
+
story = " ".join((p.get("story") or "").split())
|
|
334
|
+
concl = " ".join((p.get("conclusion") or "").split())
|
|
335
|
+
title = " ".join((p.get("title") or "").split())
|
|
336
|
+
return f"{title}: {story} Conclusion: {concl}"
|
|
337
|
+
|
|
338
|
+
|
|
323
339
|
def build_prompt(sessions: list[dict], pending_props: list[dict] | None = None) -> str:
|
|
324
340
|
corpus_lines = read_corpus_lines()
|
|
325
341
|
corpus_block = (
|
|
@@ -327,11 +343,15 @@ def build_prompt(sessions: list[dict], pending_props: list[dict] | None = None)
|
|
|
327
343
|
if corpus_lines
|
|
328
344
|
else "(the corpus is currently empty)"
|
|
329
345
|
)
|
|
346
|
+
def _gist(r: dict) -> str:
|
|
347
|
+
# works for both the old one-line shape (text) and the story shape
|
|
348
|
+
return r.get("text") or f"{r.get('title', '')}: {r.get('conclusion', '')}"
|
|
349
|
+
|
|
330
350
|
considered = [
|
|
331
|
-
{"status": r.get("status"), "
|
|
332
|
-
] + [{"status": "pending", "
|
|
351
|
+
{"status": r.get("status"), "gist": _gist(r)} for r in read_ledger()[-60:]
|
|
352
|
+
] + [{"status": "pending", "gist": _gist(p)} for p in (pending_props or [])]
|
|
333
353
|
considered_block = (
|
|
334
|
-
"\n".join(f"- ({r['status']}) {r['
|
|
354
|
+
"\n".join(f"- ({r['status']}) {r['gist'][:200]}" for r in considered)
|
|
335
355
|
if considered
|
|
336
356
|
else "(nothing has been considered yet)"
|
|
337
357
|
)
|
|
@@ -346,7 +366,7 @@ def build_prompt(sessions: list[dict], pending_props: list[dict] | None = None)
|
|
|
346
366
|
|
|
347
367
|
# Role
|
|
348
368
|
|
|
349
|
-
You are the daily context miner for a personal "context corpus": a numbered list of durable
|
|
369
|
+
You are the daily context miner for a personal "context corpus": a numbered list of durable memories distilled from the user's own Claude conversations. Each entry is a short STORY plus a CONCLUSION: what actually happened (with its credible specifics) and the transferable lesson it taught. Entries are worth keeping and potentially worth sharing with the world: a specific experience, a hard-won conclusion, a non-obvious observation, or a concrete data point.
|
|
350
370
|
|
|
351
371
|
The user is Matthew, a solo founder building S4L (a social-media autoposting agent), Fazm, Mediar, and related products, and doing everything else through Claude sessions: fundraising, debugging, ops, legal, marketing.
|
|
352
372
|
|
|
@@ -389,11 +409,12 @@ The user is Matthew, a solo founder building S4L (a social-media autoposting age
|
|
|
389
409
|
# Your task
|
|
390
410
|
|
|
391
411
|
Propose 0-3 corpus changes, and only what clears EVERY bar above; most days the
|
|
392
|
-
right answer is 0 or 1. An empty proposals list is a valid, common answer.
|
|
393
|
-
|
|
394
|
-
-
|
|
395
|
-
-
|
|
396
|
-
-
|
|
412
|
+
right answer is 0 or 1. An empty proposals list is a valid, common answer. Each
|
|
413
|
+
proposal is a small STORY with a CONCLUSION, not a bare aphorism:
|
|
414
|
+
- action: "add" for a new entry, or "revise" when a new learning supersedes an existing corpus entry (set revises_line to that entry's number).
|
|
415
|
+
- title: a short, specific handle for the insight (max ~70 chars, not clickbait).
|
|
416
|
+
- story: 2-5 sentences telling what actually happened, in the user's plainspoken first-person voice. Keep the concrete specifics that make it credible and vivid (the numbers, the timeline, the failure mode, what was tried), but generalize or omit anything only an insider would care about. Anonymize people, redact secrets. No hashtags, no em dashes.
|
|
417
|
+
- conclusion: 1-2 sentences stating the transferable lesson a stranger could apply to their own work. This is the part that must stand on its own.
|
|
397
418
|
- source_session: the 8-char session id from the transcript header.
|
|
398
419
|
- source_date: the session date (YYYY-MM-DD).
|
|
399
420
|
|
|
@@ -457,9 +478,8 @@ def _run_one_batch(sessions: list[dict], pending_props: list[dict], ns) -> list[
|
|
|
457
478
|
|
|
458
479
|
stamped = []
|
|
459
480
|
for p in obj.get("proposals") or []:
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
).hexdigest()[:8]
|
|
481
|
+
key = (p.get("title") or p.get("text") or "") + p.get("source_session", "")
|
|
482
|
+
pid = "cm-" + hashlib.sha1(key.encode()).hexdigest()[:8]
|
|
463
483
|
p["id"] = pid
|
|
464
484
|
p["mined_at"] = datetime.now(timezone.utc).isoformat(timespec="seconds")
|
|
465
485
|
stamped.append(p)
|
|
@@ -549,10 +569,13 @@ def cmd_review(_ns) -> int:
|
|
|
549
569
|
else:
|
|
550
570
|
head += " ADD"
|
|
551
571
|
print(head)
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
print(f"
|
|
572
|
+
if p.get("title"):
|
|
573
|
+
print(f" title: {p['title']}")
|
|
574
|
+
print(f" story: {p.get('story', '')}")
|
|
575
|
+
print(f" concl: {p.get('conclusion', '')}")
|
|
576
|
+
else: # legacy one-line shape
|
|
577
|
+
print(f" text : {p.get('text', '')}")
|
|
578
|
+
print(f" why : {p.get('why', '')}")
|
|
556
579
|
print(f" src : {p.get('source_session', '?')} @ {p.get('source_date', '?')}")
|
|
557
580
|
print("=" * 72)
|
|
558
581
|
print(f"{len(props)} pending. approve/skip with: context_mining.py approve <id...>")
|
|
@@ -575,18 +598,21 @@ def _decide(ids: list[str], status: str) -> int:
|
|
|
575
598
|
print(f"unknown id: {pid}")
|
|
576
599
|
continue
|
|
577
600
|
if status == "approved":
|
|
601
|
+
entry = corpus_entry(p) if p.get("title") else p.get("text", "")
|
|
578
602
|
if p.get("action") == "revise" and p.get("revises_line"):
|
|
579
603
|
n = p["revises_line"]
|
|
580
604
|
if 0 < n <= len(corpus_lines):
|
|
581
|
-
corpus_lines[n - 1] =
|
|
605
|
+
corpus_lines[n - 1] = entry
|
|
582
606
|
else:
|
|
583
|
-
corpus_lines.append(
|
|
607
|
+
corpus_lines.append(entry)
|
|
584
608
|
else:
|
|
585
|
-
corpus_lines.append(
|
|
609
|
+
corpus_lines.append(entry)
|
|
586
610
|
append_ledger(
|
|
587
611
|
{
|
|
588
612
|
"id": pid,
|
|
589
613
|
"status": status,
|
|
614
|
+
"title": p.get("title", ""),
|
|
615
|
+
"conclusion": p.get("conclusion", ""),
|
|
590
616
|
"text": p.get("text", ""),
|
|
591
617
|
"source_session": p.get("source_session"),
|
|
592
618
|
"decided_at": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
|
@@ -101,7 +101,9 @@ def _atomic_write(path: str, obj) -> None:
|
|
|
101
101
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
102
102
|
tmp = f"{path}.tmp.{os.getpid()}"
|
|
103
103
|
with open(tmp, "w") as f:
|
|
104
|
-
|
|
104
|
+
# Compact separators: the review store reached 65 MB with indent=2
|
|
105
|
+
# (2026-08-02 lag incident) and every reader pays the parse.
|
|
106
|
+
json.dump(obj, f, separators=(",", ":"))
|
|
105
107
|
os.replace(tmp, path)
|
|
106
108
|
|
|
107
109
|
|