[recipes] Wiki pipeline: OpenRouter + thought_edges + prompt safety#234
Open
AnkitClassicVision wants to merge 4 commits intoNateBJones-Projects:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove duplicated MyBCAT Universal Rules block from repo CLAUDE.md. Rules are now inherited via /repos/.claude/CLAUDE.md (Claude Code walks up the directory tree). Saves ~1,165 tokens per session. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…on + prompt safety Three related improvements to the wiki-generation pipeline, packaged together because they land as a coherent upgrade after the typed-reasoning-edges feature (PR NateBJones-Projects#208) merged. ## typed-edge-classifier: OpenAI-compatible LLM path Previously required ANTHROPIC_API_KEY direct to api.anthropic.com. Now accepts LLM_BASE_URL + LLM_API_KEY (e.g. OpenRouter) in addition, which is what the entity-wiki and wiki-synthesis recipes already use. Anthropic-direct remains the fallback when LLM_BASE_URL/LLM_API_KEY aren't set, so existing installs keep working unchanged. Rationale: running all three recipes through one provider (OpenRouter) avoids maintaining a second API key just for the classifier. ## entity-wiki: thought_edges integration Entity wiki pages now include a "Thought reasoning links" subsection under Relationships, rendering supports/contradicts/evolved_into/supersedes/depends_on edges between the evidence thoughts the page already cites. Graceful degradation: if schemas/typed-reasoning-edges/ isn't installed (table missing), the fetch returns [] and the subsection is omitted — no runtime error. This closes the loop opened by PR NateBJones-Projects#208: the typed-edge-classifier produces thought_edges rows; now entity-wiki actually renders them. ## wiki-synthesis: bounded-size prompt + schema tolerance - Autobiography builder now caps each entry at MAX_ENTRY_CHARS (240) and the per-year sample at MAX_SAMPLE_CHARS (25k), preventing model-context blow-ups on long entries (meeting notes, code blocks in Obsidian captures). Keeps at least 25 entries before applying the budget so sparse years still synthesize. - fetchThoughts gracefully handles deployments whose `thoughts` table does not carry a `source_type` column by falling back to metadata inference (metadata.source_type / source_system / source / kind). Preserves server-side filtering when the column exists. ## Provenance These changes were in my working tree when picking up wiki-compiler install work; I believe they came from an earlier Claude/Codex session that didn't land a commit. Code style and comment density match the rest of the repo, and the changes are tested end-to-end against a real Open Brain (2000+ thoughts, 5000+ entities). Opening as a PR so the maintainer can decide whether to accept or discard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three related wiki-pipeline improvements, packaged together because they land as a coherent upgrade after the typed-reasoning-edges feature (#208) merged.
1. typed-edge-classifier: OpenAI-compatible LLM path
Previously required
ANTHROPIC_API_KEYdirect toapi.anthropic.com. Now also acceptsLLM_BASE_URL+LLM_API_KEY(OpenRouter, LiteLLM, etc.) — the same pattern the siblingentity-wikiandwiki-synthesisrecipes use. Direct Anthropic remains the fallback when the OpenAI-compat vars aren't set, so existing installs keep working.Why: running all three recipes through one provider avoids maintaining a second API key just for the classifier.
2. entity-wiki: thought_edges integration
Entity wiki pages now include a Thought reasoning links subsection under Relationships, rendering supports / contradicts / evolved_into / supersedes / depends_on / related_to edges between the evidence thoughts the page already cites.
Graceful degradation: if
schemas/typed-reasoning-edges/isn't installed (table missing), the fetch returns[]and the subsection is omitted — no runtime error.Why: closes the loop opened by #208 — the classifier produces
thought_edgesrows; now entity-wiki actually renders them.3. wiki-synthesis: bounded-size prompt + schema tolerance
fetchThoughtsgracefully handles deployments whosethoughtstable lacks asource_typecolumn by falling back to metadata inference (metadata.source_type/source_system/source/kind). Preserves server-side filtering when the column exists.Provenance note
These changes were in my working tree when picking up wiki-compiler install work this week. I believe they came from an earlier Claude/Codex session that didn't land a commit — the code style and comment density match the rest of the repo, and the changes are tested end-to-end against a real Open Brain (2000+ thoughts, 5000+ entities). Opening as a PR so the maintainer can decide whether to accept or discard.
Test plan
LLM_BASE_URL=https://openrouter.ai/api/v1 LLM_MODEL=anthropic/claude-haiku-4-5) — 150 pairs processed, 4 edges inserted, $1.86 spent under $2 cap.LLM_BASE_URLset (falls back to Anthropic direct).🤖 Generated with Claude Code