feat(v0.3): resolve trace + policy overrides#64
Merged
Conversation
…-tracing-explore) Squashed merge of the entire feat/v0.3-tracing-explore branch — final state includes both the trace primitive (per-token / per-intent attribution) and the policy_overrides feature, on top of current main (lexical groups + dependabot bumps + 8 ALPHA packs). # Trace primitive (purely additive observability) - TokenContribution + IntentTraceSummary types in scoring.rs - New scoring path `score_with_attribution()` emits per-token deltas + per-intent summaries alongside the score (no behavior change) - `/api/resolve?trace=1` returns the full trace structure - Studio Router page renders a collapsible TracePanel showing which tokens drove which intent at what weight - Compact trace summary embedded in audit log entries when trace is requested — supports Art. 13 "explain your decision" with the exact tokens that fired # Policy overrides (compositional bonuses) - Per-namespace `policy_overrides: Vec<PolicyOverride>` field on IntentIndex — each rule names N words + an intent + a bonus - Loader reads `policy_overrides` array from _ns.json after _index.json - Scoring applies the bonus to a candidate intent if ALL listed words appear in the normalized query - Engine API on NamespaceHandle: list_policy_overrides, add_, remove_, update_ with validation (≥2 distinct words, non-empty intent, bonus > 0) - Server CRUD at /api/policy-overrides with audit-mutation hooks - Studio PolicyOverridesPage with form + live test query showing which rules fired (uses trace API) - 5 packs already ship `policy_overrides` in _ns.json (data was preserved by the unknown-fields save logic from lexical groups) # What's NOT validated yet The 4-way ablation (none / lexical / policy / both) has not run on this combined branch. The empirical case for the combination is still TBD — this PR puts the feature in place to enable the experiment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Validates lexical_groups + policy_overrides as additive, not redundant: config F1 ΔF1 benign-FP baseline 0.817 — 17.5% lex_only 0.842 +2.5pp 17.5% policy_only 0.825 +0.8pp 15.0% both 0.851 +3.4pp 15.0% D > A + 1pp F1? ✓ (+3.4pp) D > B + 0.5pp F1? ✓ (+0.85pp — policy adds value over morph) D - B regression ≤ 1pp F1? ✓ D - B benign-FP ≤ 2pp? ✓ (−2.5pp — policy actually reduces FP) 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.
Squashed merge of `feat/v0.3-tracing-explore` onto current main.
What's in
Trace primitive — per-token contribution and per-intent summary shown in the Studio Router page when you resolve a query. Pure observability — no resolve behavior change.
Policy overrides — per-namespace compositional rules ("if these N tokens co-occur, boost intent X by Y"). Hand-curated, ≤10 per pack, operator-controlled. CRUD endpoints at `/api/policy-overrides` + UI page. 5 packs already ship `policy_overrides` arrays in their `_ns.json` (engine ignored them before this PR; will read them now).
Validation status
🤖 Generated with Claude Code