Skip to content

feat(v0.3): resolve trace + policy overrides#64

Merged
gladius merged 2 commits into
mainfrom
feat/v0.3-trace-and-policy
May 11, 2026
Merged

feat(v0.3): resolve trace + policy overrides#64
gladius merged 2 commits into
mainfrom
feat/v0.3-trace-and-policy

Conversation

@gladius
Copy link
Copy Markdown
Owner

@gladius gladius commented May 11, 2026

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

  • 74 lib tests pass, fmt + clippy clean, npm build clean.
  • The 4-way ablation (baseline / +lexical / +policy / +both) on EU AI Act + HIPAA has NOT run on this combined branch yet. If we want gated merge, the experiment runs against this PR. If we want fast merge, ship it and validate post-launch.

🤖 Generated with Claude Code

gladius and others added 2 commits May 11, 2026 08:58
…-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>
@gladius gladius merged commit 24aeb90 into main May 11, 2026
5 checks passed
@gladius gladius deleted the feat/v0.3-trace-and-policy branch May 11, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant