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

@@ -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)