Uh oh!
There was an error while loading. Please reload this page.
feat(cli): configurable insert_mode (fail-fast / fail-at-end) for strict compile-failure handling - #241
Open
sebastianbraun25 wants to merge 1 commit into
Conversation
…ict compile-failure handling - Add `insert_mode` config key (`.openkb/config.yaml`) with three values: - "normal" (default): unchanged behavior — a concept/entity generation failure during compile is logged as a warning and the file is still reported "added". - "fail-fast": the first concept/entity generation failure cancels every other still-pending generation in the batch and immediately raises `ConceptCompilationError` — nothing from the batch is written. - "fail-at-end": every planned concept/entity generation is attempted (so every failure for the document is logged in one pass) before `ConceptCompilationError` is raised if anything failed. - Both strict modes rely entirely on the existing mutation-snapshot rollback (`openkb.add_coordinator`/`openkb.mutation`) to discard the add and report it "failed" — no new rollback path needed. The existing "keep raw/ on failed" and "keep the debug log on a non-'added' outcome" behaviors already cover the raw-file and log-preservation requirements for strict mode. - `_compile_concepts`'s three early-return paths (unparseable plan, scalar plan, all-items-filtered-as-malformed) now also raise under a strict insert_mode, not just individual concept/entity generation failures — a genuinely empty plan (nothing was ever planned) still counts as complete success in every mode. - `compile_short_doc`/`compile_long_doc` resolve `insert_mode` from the already-loaded KB config, so no CLI-level plumbing is needed. ResolvesVectifyAI#239 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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 freeto 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.
Note
This PR was created in collaboration between a human and AI: implementation, tests, and
PR text were created by an AI assistant under the guidance and review of the human author.
Problem
openkb addcurrently reports a whole-file"added"outcome even when one or more individualconcepts/entities failed to generate during compilation.
_compile_conceptsinopenkb/agent/compiler.pycollects exceptions from the per-concept/per-entity generation tasksvia
asyncio.gather(..., return_exceptions=True), logs a[WARN] ... planned but only N writtenline, and continues — but the file's hash is still registered and the source is still eligible for
auto_delete_added_files, so a partially-compiled document looks identical to a fully successfulone from the CLI/API caller's point of view.
Solution / Changes
insert_modeconfig key (.openkb/config.yaml) with three values:"normal"(default): unchanged behavior — a concept/entity generation failure during compileis logged as a warning and the file is still reported
"added"."fail-fast": the first concept/entity generation failure cancels every other still-pendinggeneration in the batch and immediately raises
ConceptCompilationError— nothing from thebatch is written.
"fail-at-end": every planned concept/entity generation is attempted (so every failure for thedocument is logged in one pass) before
ConceptCompilationErroris raised if anything failed.(
openkb.add_coordinator/openkb.mutation) to discard the add and report it"failed"— no newrollback path needed. The existing "keep
raw/on failed" and "keep the debug log on anon-
'added'outcome" behaviors already cover raw-file and log-preservation for strict mode._compile_concepts's three early-return paths (unparseable plan, scalar plan,all-items-filtered-as-malformed) now also raise under a strict
insert_mode, not just individualconcept/entity generation failures — a genuinely empty plan (nothing was ever planned) still
counts as complete success in every mode.
compile_short_doc/compile_long_docresolveinsert_modefrom the already-loaded KB config, sono CLI-level plumbing is needed.
"normal"behavior is unchanged.Issues