Skip to content

Commit cfabab3

Browse files
committed
sync: update Agent Workspaces/_sync/sync.py
1 parent 7649d27 commit cfabab3

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

Agent Workspaces/_sync/sync.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -604,23 +604,34 @@ def write_insights(all_recs):
604604
for c in active: f.write(json.dumps(c) + "\n")
605605
with open(os.path.join(INSIGHTS, "candidates_synthesized.jsonl"), "w") as f: # archive (provenance / export)
606606
for c in archived: f.write(json.dumps(c) + "\n")
607-
# human MOC (active only)
607+
# DEDUPED exemplar queue — distinct problems, recurrence-weighted. Consumed by
608+
# auto_improve.py (autonomous) and synthesize.py (manual) so the paid model sees
609+
# ~one row per real pattern instead of dozens of near-identical repeats.
610+
clusters = cluster_candidates(active)
611+
with open(os.path.join(INSIGHTS, "clusters.jsonl"), "w") as f:
612+
for cl in clusters:
613+
f.write(json.dumps({**cl, "projects": sorted(cl["projects"])}) + "\n")
614+
# human MOC (active only, DEDUPED to distinct problems)
608615
by_tool = collections.Counter(c["tool"] for c in active)
609616
by_topic = collections.Counter(t for c in active for t in c["topics"])
610-
lines = [frontmatter({"type":"insights-index","candidates":len(active),"synthesized":len(archived),"tags":["moc","insights"]}),
617+
lines = [frontmatter({"type":"insights-index","candidates":len(active),"distinct":len(clusters),
618+
"synthesized":len(archived),"tags":["moc","insights"]}),
611619
"", "# 🔧 Mined Insights — Debugging & Fixes", "",
612-
f"**{len(active)}** active candidate lessons "
613-
f"({', '.join(f'{k}: {v}' for k,v in by_tool.items()) or '—'})"
620+
f"**{len(clusters)}** distinct problems "
621+
f"(deduped from {len(active)} raw candidates · {', '.join(f'{k}: {v}' for k,v in by_tool.items()) or '—'})"
614622
+ (f" · ✅ **{len(archived)}** already synthesized → [[Agent Workspaces/_insights/Synthesized|archive]]" if archived else ""), "",
615623
"**By topic:** " + (" · ".join(f"`#topic/{t}` {n}" for t, n in by_topic.most_common()) or "—"), "",
616-
"Top un-synthesized candidates (highest signal first). Run `synthesize.py --confirm` to distill them; "
617-
"once synthesized they move to the archive and the next batch rises here.", "",
618-
"| Score | Topics | Problem → Fix | Project | Session |", "|---|---|---|---|---|"]
619-
for c in active[:200]:
620-
prob = oneline(c["error"],62).replace("|","/"); fix = oneline(c["fix"],62).replace("|","/")
621-
link = f"[[{c['note']}|{oneline(c['session'],30).replace('|','/')}]]"
624+
"Distinct problems (deduped, recurrence-weighted; highest signal first). `×N` = how many "
625+
"sessions hit this same pattern — the strongest promote signal. The autonomous loop "
626+
"(`auto_improve.py`) distills these into skills; once done they move to the archive.", "",
627+
"| Score | ×N | Topics | Problem → Fix | Projects | Session |", "|---|---|---|---|---|---|"]
628+
for c in clusters[:200]:
629+
prob = oneline(c["error"],60).replace("|","/"); fix = oneline(c["fix"],60).replace("|","/")
630+
link = f"[[{c['note']}|{oneline(c['session'],28).replace('|','/')}]]"
622631
ttags = " ".join("#topic/"+t for t in c["topics"]) or "—"
623-
lines.append(f"| {c['score']} | {ttags} | **{prob}** → {fix} | `{c['project']}` | {link} |")
632+
nproj = len(c["projects"])
633+
projcell = f"`{c['project']}`" + (f" +{nproj-1}" if nproj > 1 else "")
634+
lines.append(f"| {c['agg_score']} | ×{c['cluster_size']} | {ttags} | **{prob}** → {fix} | {projcell} | {link} |")
624635
with open(os.path.join(INSIGHTS, "Insights.md"), "w") as f:
625636
f.write("\n".join(lines))
626637
# archive view

0 commit comments

Comments
 (0)