research/semantic-kg: semantic probe + conflict taxonomy + temporal layer + derived-answer prover #24

Merged
onibot merged 14 commits from research/semantic-kg into main 2026-10-25 21:40:18 +01:00
2 changed files with 77 additions and 3 deletions
Showing only changes of commit 262f40b981 - Show all commits
+73 -1
View File
@@ -267,4 +267,76 @@ dependency for v1 of this.
- The ablation audit stays for the one job left to it: readings that - The ablation audit stays for the one job left to it: readings that
are NOT store-derivable (judge-visible ambiguity in free text). are NOT store-derivable (judge-visible ambiguity in free text).
- Branching (floop/branches.py) gains a cleaner trigger (a binding set) - Branching (floop/branches.py) gains a cleaner trigger (a binding set)
but its death/merge semantics are untouched. but its death/merge semantics are untouched.
## Implementation plan (proposed — awaiting his approval; no code yet)
Phases ordered by dependency; each closes with tests + live runs.
Phase 0 is main-bound and independent of the research direction.
### Phase 0 — hygiene (main; small, shippable alone)
1. (K5) fix: clean the judge's value at the output boundary
(_answer_from_rows) — regex anchored to TRAILING row-citation shapes
("(K5)", "(cited from rows K16 and K30)") so legitimate parentheticals
("(PSOE)") survive. Prompt side: value desc gains "answer only, no
row citations". Regression = the K5 repro pair (raw value → audit
runs and flags the Spain alternative).
2. --no-cache CLI flag (his ruling 25/10: the dspy disk cache is not a
bug; it stays the default): when set, configure_lm builds dspy.LM
with cache=False — a per-process bypass, the cache dir untouched.
For A/B and freshness testing.
3. Import assert at startup: the resolved floop/ and knowledge/ module
paths must be under the repo being run — the shared venv's editable
pth pins imports to MAIN's tree and ran main code inside the branch
worktree without any signal (run 085457). Abort loudly on mismatch.
### Phase 1 — conflict taxonomy at merge (this branch, store)
_classify 4 → 6 cases, signals in cost order: same quote_id →
co-asserted (conjunction, never a conflict); extracted windows →
temporal (interval arithmetic: disjoint = succession, overlapping =
alternatives); discriminant tokens + tail resolution against nodes →
alternatives vs paraphrase-merge (merge = same_as edge, append-only);
what survives with a functional relation = real contradiction. The
edge gains a class field; the alternatives bucket is exposed to the
audit and the render. Fixtures: the live 20-pair inventory (10
co-asserted, 3+1 temporal, 3 alternatives, 0 real).
### Phase 2 — temporal layer (this branch, extractor + store)
Typed Fact (feature/typed-facts vehicle) gains start/end/point/
granularity, orders [{before|after|concurrent, refs}], duration,
anchor (date | event node), immediacy — every field containment-
checked against the quote. Store: edge start/end columns + fact_order
table. _classify consumes interval arithmetic. Bounded backfill:
re-extract quotes of existing conflicting pairs with empty windows.
NO Allen labels anywhere — the algebra stays a computed view.
### Phase 3 — the query prover (the new core)
Hand-written goal-directed evaluator over SQLite: six operators
(lookup, temporal filter, order/select, setops, arithmetic
composition, path), typed DSL, proof term as the payload, re-execution
as the check. Translator question→DSL: one structured-output LLM call
(MASK/EXTRACT class), validated before execution. Wiring: the prover
becomes the real stop-check at machine._finish (derivability);
AnswerFromKG stays only as the fallback for non-translatable
questions. Regression: Pedro proves Rajoy as a closed path; "of what"
returns the three bindings as a set; rivers stay green; judge LLM
calls drop to zero on store-derivable paths.
### Phase 4 — consumers
The audit reduces to "is the binding set already multi?" (cheap,
deterministic) + ablation only for non-derivable readings. The branch
fork (floop/branches.py) starts from binding multiplicity. ANSWER and
any surviving judge render over proof terms, not free prose.
### Open decisions (his call, before Phase 3 coding)
- DSL vocabulary: the translator and the evaluator share one grammar —
its exact terms.
- Order primitives: inside Fact (same call) vs a separate pass.
- Translator location: inside INIT (the decomposition and the query
born together) vs a post-INIT step per question.
+4 -2
View File
@@ -147,13 +147,15 @@ cache deleted per run):
reading trap). Substrate state weighs as much as the model. reading trap). Substrate state weighs as much as the model.
- Cloud is non-deterministic at temperature 0: identical INIT prompt, - Cloud is non-deterministic at temperature 0: identical INIT prompt,
two different decompositions (2 vs 3 subquestions) across runs. two different decompositions (2 vs 3 subquestions) across runs.
- MEASUREMENT TRAP (both A/B sides): dspy.LM defaults cache=True and - MEASUREMENT NOTE (both A/B sides): dspy.LM defaults cache=True and
persists to ~/.dspy_cache ACROSS processes and days, keyed on the persists to ~/.dspy_cache ACROSS processes and days, keyed on the
request (model+prompt+params, not base_url). A repeated question is request (model+prompt+params, not base_url). A repeated question is
a byte-identical REPLAY wearing inference's clothes (0.4 s "runs"). a byte-identical REPLAY wearing inference's clothes (0.4 s "runs").
Proven by curl (server does not cache) and by running the whole app Proven by curl (server does not cache) and by running the whole app
in an isolated netns (unshare -rn) — it completed with no network. in an isolated netns (unshare -rn) — it completed with no network.
rm -rf ~/.dspy_cache before any run that must be fresh. HIS RULING (25/10): NOT a bug — caching doing its job; the CLI gains
a --no-cache flag for test runs, the default stays. Until that flag
exists: rm -rf ~/.dspy_cache before any run that must be fresh.
**The (K5) bug — the audit's silent death** (run 085457): **The (K5) bug — the audit's silent death** (run 085457):