feat(server): INGEST_WING_ROUTING wires the Router; remove the classifier path (#208)
Removes the LLM classifier, the substring 'BM25' scorer, the agreement gate, the backtest and the old migrate/wingmigrate tooling: measured at 2 of 55 pages placed (#208), and the migration was built for the per-wing facts layout this branch replaces. wing now holds the decision types, the Router and KnownWings. INGEST_WING_ROUTING=1 builds the Router (default wing INGEST_DEFAULT_WING=web-clip, client pattern from INGEST_CLIENT_BLOCK or CLAUDE_INGEST_CLIENT_BLOCK); a bad default or pattern is fatal at startup. Watcher tests rewritten for the Router, including a deliberate subfolder into any existing wing, typo'd folders parked, forged-key and edit-while-placing cases. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -150,17 +150,6 @@ func envInt(key string, fallback int) int {
|
||||
return fallback
|
||||
}
|
||||
|
||||
// envFloat reads a confidence-style value in [0,1]. Anything unparseable or
|
||||
// outside the range falls back: a threshold of 0 would auto-place everything.
|
||||
func envFloat(key string, fallback float64) float64 {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
if f, err := strconv.ParseFloat(v, 64); err == nil && f >= 0 && f <= 1 {
|
||||
return f
|
||||
}
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
// buildNotifier returns the ntfy notifier, or a nil interface when
|
||||
// BRAIN_NTFY_URL is unset. A nil *interface* (not a typed-nil) is required so
|
||||
// DegradingSink/Reconcile and the governance observer skip it cleanly.
|
||||
@@ -406,26 +395,34 @@ func main() {
|
||||
}
|
||||
|
||||
if watchInterval > 0 {
|
||||
// INGEST_WING_RESOLVE=1 routes raw/ notes into wiki/<wing>/ by
|
||||
// subfolder, frontmatter or classifier+scorer, and parks the rest in
|
||||
// raw/needs-review/ (hyperguild#205). Off = the retired layout. Set
|
||||
// explicitly, a failure to build the resolver is fatal: silently
|
||||
// falling back would write into the layout this flag exists to leave.
|
||||
var wingResolver *wing.Resolver
|
||||
if os.Getenv("INGEST_WING_RESOLVE") == "1" {
|
||||
var rerr error
|
||||
wingResolver, rerr = wing.NewConfiguredResolver(brainDir, llmClient.Complete, envFloat("INGEST_WING_THRESHOLD", 0.9))
|
||||
// INGEST_WING_ROUTING=1 files raw/ notes by rule (hyperguild#208): a
|
||||
// deliberate raw/<wing>/ folder or `wing:` frontmatter, else the default
|
||||
// wing (INGEST_DEFAULT_WING, "web-clip"); a note whose text matches the
|
||||
// client-content pattern (INGEST_CLIENT_BLOCK, else
|
||||
// CLAUDE_INGEST_CLIENT_BLOCK) or that names an unknown wing is parked in
|
||||
// raw/needs-review/. Off = the retired layout. Set explicitly, a bad
|
||||
// default or pattern is fatal: silently falling back would write into
|
||||
// the layout this flag exists to leave. The interface stays nil when off
|
||||
// (a nil *Router inside it would not be nil).
|
||||
var placer wing.Placer
|
||||
if os.Getenv("INGEST_WING_ROUTING") == "1" {
|
||||
pattern := os.Getenv("INGEST_CLIENT_BLOCK")
|
||||
if pattern == "" {
|
||||
pattern = os.Getenv("CLAUDE_INGEST_CLIENT_BLOCK")
|
||||
}
|
||||
router, rerr := wing.NewRouter(brainDir, envOr("INGEST_DEFAULT_WING", "web-clip"), pattern)
|
||||
if rerr != nil {
|
||||
logger.Error("build wing resolver", "err", rerr)
|
||||
logger.Error("build wing router", "err", rerr)
|
||||
os.Exit(1)
|
||||
}
|
||||
logger.Info("wing resolver enabled", "wings", len(wingResolver.Known), "threshold", wingResolver.Threshold)
|
||||
placer = router
|
||||
logger.Info("wing routing enabled", "default_wing", router.Default, "client_filter", router.ClientBlock != nil)
|
||||
}
|
||||
watcher.Start(ctx, watcher.Config{
|
||||
BrainDir: brainDir,
|
||||
Interval: time.Duration(watchInterval) * time.Second,
|
||||
Pipeline: pipelineCfg,
|
||||
Resolver: wingResolver,
|
||||
Resolver: placer,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user