Optimize continuous-improve loop: skip redundant review checks, dedup bugs, no double commits, default skip-unchanged

This commit is contained in:
daniel
2026-02-23 00:40:06 +00:00
parent 8ee54f4c75
commit 42d45b317e
7 changed files with 76 additions and 77 deletions

View File

@@ -38,3 +38,4 @@
785e2c 1771806758
78a490 1771806810
78e9e7 1771806915
801168 1771807000
1 0648e6 1771799566
38 785e2c 1771806758
39 78a490 1771806810
40 78e9e7 1771806915
41 801168 1771807000

View File

@@ -6269,3 +6269,13 @@ To https://gitea.home.everyonce.com/daniel/factbase-ancient-history.git
[?25h
status: UPDATED | Cyrus the Great | changes: Applied 23 answered review questions; fixed duplicate title; added Old Persian name (Kūruš); added parentage (father Cambyses I, mother Mandane daughter of Astyages); added successor Cambyses II; noted Astyages was Cyrus's maternal grandfather; added Edict of Cyrus (~538 BCE) with Ezra citation; enriched Cyrus Cylinder entry (Akkadian cuneiform, found 1879 in Ésagila temple, "first charter of human rights"); added Tomyris as Massagetae queen; added Syr Darya as battle location; added Pasargadae UNESCO World Heritage status; added geographic extent (Egypt to Indus Valley); added Herodotus as new footnote [^3]
[main 8ee54f4] improve: Cyrus the Great
5 files changed, 114 insertions(+)
delete mode 100644 .factbase/factbase.db-shm
delete mode 100644 .factbase/factbase.db-wal
[2026-02-23 00:36:40] ✅ Committed: improve: Cyrus the Great
[2026-02-23 00:36:40] Done (77s) — UPDATED
[2026-02-23 00:36:45] [33/66] Next up...
[2026-02-23 00:36:45] ━━━ [Alexander the Great] (817dc2) reviews=0 garbage=0 ━━━
[2026-02-23 00:36:45] 🧹 Bash cleanup applied
[2026-02-23 00:36:45] 🔍 Enrichment + review pass

View File

@@ -18,7 +18,7 @@ PRIORITY="reviews"
CYCLE_DELAY=5
MODEL="claude-sonnet-4.6"
START_AT=0
SKIP_UNCHANGED=false
SKIP_UNCHANGED=true
while [[ $# -gt 0 ]]; do
case "$1" in
--priority) PRIORITY="$2"; shift 2 ;;
@@ -190,11 +190,19 @@ ${excerpt}
echo "$related"
}
# ─── Fetch existing Vikunja bug titles (for dedup) ───
get_existing_bug_titles() {
curl -s "https://vikunja.home.everyonce.com/api/v1/projects/2/tasks" \
-H "Authorization: Bearer tk_ff251f3d3512775c71913bc2f8ec0dabbf5016a8" \
2>/dev/null | grep -oP '"title":"[^"]*"' | sed 's/"title":"//;s/"$//' || true
}
# ─── Agent-based processing (review questions + enrichment) ───
process_entity_agent() {
local fb_id="$1"
local file="$2"
local title="$3"
local review_count="${4:-0}"
cd "$DOCS_DIR"
@@ -204,6 +212,9 @@ process_entity_agent() {
local related
related=$(get_related_context "$file")
local existing_bugs
existing_bugs=$(get_existing_bug_titles)
local prompt
prompt="You are continuously improving a factbase knowledge base, one entity at a time.
Use factbase MCP tools — call get_authoring_guide if you need formatting rules.
@@ -223,12 +234,19 @@ $related
=== END MENTIONS ==="
fi
prompt+='
if [[ -n "$existing_bugs" ]]; then
prompt+="
STEPS — work through in order, skip any that do not apply:
=== EXISTING VIKUNJA BUG REPORTS (do NOT file duplicates) ===
$existing_bugs
=== END EXISTING BUGS ==="
fi
1. RESOLVE REVIEW QUESTIONS:
Call get_review_queue(doc_id='"'"''"$fb_id"''"'"') — if there are open questions, answer them.
# Build review step conditionally
local review_step=""
if [[ "$review_count" -gt 0 ]]; then
review_step='1. RESOLVE REVIEW QUESTIONS:
Call get_review_queue(doc_id='"'"''"$fb_id"''"'"') — if there are open (unanswered) questions, answer them.
Patterns learned from resolving thousands of these:
- CONFLICT (chronological overlaps): Boundary-year overlaps in sequential reigns or periods
@@ -244,9 +262,18 @@ STEPS — work through in order, skip any that do not apply:
for newer scholarship.
- MISSING: Search with search_knowledge and search_content. If not found, defer.
After answering, call apply_review_answers(doc_id='"'"''"$fb_id"''"'"'). Then re-read the
file with get_entity and verify apply did not corrupt it (garbage footnotes, mangled title).
If it did, fix with update_document.
IMPORTANT: Only call apply_review_answers if get_review_queue shows unanswered > 0.
After applying, re-read the file with get_entity and verify apply did not corrupt it
(garbage footnotes, mangled title). If it did, fix with update_document.'
else
review_step='1. REVIEW QUESTIONS: SKIP — the wrapper already confirmed 0 open review questions for this entity.'
fi
prompt+='
STEPS — work through in order, skip any that do not apply:
'"$review_step"'
2. IDENTITY & ORGANIZATION:
For ruler documents: if the title is a single name, alias, or epithet (not a full name),
@@ -280,6 +307,10 @@ STEPS — work through in order, skip any that do not apply:
FEATURES — any friction, missing capability, awkward multi-step workaround, or gap that
slowed you down or limited what you could accomplish. Use title prefix "[factbase][feature]".
CRITICAL: Before filing ANY bug or feature request, check the EXISTING VIKUNJA BUG REPORTS
section above. If a similar issue is already filed, do NOT file a duplicate. Only file if
the issue is genuinely new.
CRITICAL: Factbase is domain-agnostic — it is used for many different knowledge bases, not
just this one. Your bug reports and feature requests MUST describe the issue in terms of
factbase tool behavior, not in terms of ancient history content. For example:
@@ -301,7 +332,10 @@ STEPS — work through in order, skip any that do not apply:
Priority: 1-2 for features/minor issues, 3 for normal bugs, 4-5 for data loss or blocking failures.
RULES:
- The document content is already provided above — do NOT call get_entity to re-read it
unless you just called apply_review_answers and need to verify the result
- Use update_document to edit — be surgical, change only what needs changing
- Do NOT run git add, git commit, or git push — the wrapper script handles all git operations
- If nothing needs changing, say so and move on
IMPORTANT: When finished, output exactly one line:
@@ -369,7 +403,7 @@ process_entity() {
if [[ "$needs_agent" == true ]]; then
local agent_output
agent_output=$(process_entity_agent "$fb_id" "$file" "$title")
agent_output=$(process_entity_agent "$fb_id" "$file" "$title" "$review_count")
echo "$agent_output"
summary=$(echo "$agent_output" | grep -oP '(?<=<action_summary>).*(?=</action_summary>)' | tail -1)

View File

@@ -118,3 +118,6 @@
[2026-02-23T00:35:15+00:00] 78e9e7 | Zoroastrianism
status: UPDATED | Zoroastrianism | changes: Applied 24 answered review questions; fixed duplicate H1 heading and spurious @t[~2001] tag (bug filed as Vikunja #94); enriched with Encyclopaedia Iranica scholarship — added Aməša Spəntas, Magi priesthood, Saošyant savior figure, Frašō-kərəti eschatology, Parthian/Sasanian period details with dates, Avesta canonization under Khosrow I, Parsi migration timing (8th9th c. CE), updated population figures (~50,000 Parsis per 2011 census, ~100,000120,000 worldwide); added two new footnotes (Encyclopaedia Iranica, Wikipedia population list)
duration: 98s
[2026-02-23T00:36:40+00:00] 801168 | Cyrus the Great
status: UPDATED | Cyrus the Great | changes: Applied 23 answered review questions; fixed duplicate title; added Old Persian name (Kūruš); added parentage (father Cambyses I, mother Mandane daughter of Astyages); added successor Cambyses II; noted Astyages was Cyrus's maternal grandfather; added Edict of Cyrus (~538 BCE) with Ezra citation; enriched Cyrus Cylinder entry (Akkadian cuneiform, found 1879 in Ésagila temple, "first charter of human rights"); added Tomyris as Massagetae queen; added Syr Darya as battle location; added Pasargadae UNESCO World Heritage status; added geographic extent (Egypt to Indus Valley); added Herodotus as new footnote [^3]
duration: 77s