Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / cmd/verify-resolver/main.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | cmd/verify-resolver/main.go |
| Original SHA-256 | bddeab42d906d8c2bb776be56d4951f180f0ea10d09d4abdf19ce0ff08147e9c |
| Git blob SHA | 0d82447973c1f9c4195ab813c2149496822207fa |
| Reading-copy SHA-256 | bddeab42d906d8c2bb776be56d4951f180f0ea10d09d4abdf19ce0ff08147e9c |
Recovered source transcript
Download complete source text ↓65 lines · 2.5 KB
// Command verify-resolver loads the deterministic alias and relationship resolver against a database and
// proves that a curated alias and a curated relationship resolve end to end. It is the live counterpart
// to the resolver unit tests, which inject the maps directly: this exercises the real DB load (the
// skills, skill_aliases, and skill_relationships queries, including the numeric strength scan). Read only.
//
// Usage: verify-resolver -dsn <app or migrator DSN>
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"github.com/missionworkforce/missionmatch/internal/modules/matching"
"github.com/missionworkforce/missionmatch/internal/modules/matching/engine"
"github.com/missionworkforce/missionmatch/internal/platform/database"
"github.com/missionworkforce/missionmatch/internal/platform/tenant"
)
func main() {
dsn := flag.String("dsn", "", "database DSN (app or migrator), defaults to MM_APP_DATABASE_URL")
flag.Parse()
if *dsn == "" {
*dsn = os.Getenv("MM_APP_DATABASE_URL")
}
if *dsn == "" {
log.Fatal("verify-resolver: -dsn is required")
}
ctx := context.Background()
pool, err := database.NewPool(ctx, *dsn)
if err != nil {
log.Fatalf("db: %v", err)
}
defer pool.Close()
resolver := matching.NewDeterministicAliasResolver(tenant.New(pool))
failed := false
// Alias: a candidate holding Signals Intelligence resolves a SIGINT requirement (exact, similarity 1.0).
probe(ctx, resolver, "alias SIGINT", engine.RequiredSkill{Name: "SIGINT"}, "Signals Intelligence", true, &failed)
// Relationship: OpenShift substitutes_for Kubernetes, a partial credit at the curated strength.
probe(ctx, resolver, "rel OpenShift to Kubernetes", engine.RequiredSkill{Name: "Kubernetes"}, "OpenShift", false, &failed)
if failed {
fmt.Println("VERIFY-RESOLVER: FAIL")
os.Exit(1)
}
fmt.Println("VERIFY-RESOLVER: PASS (the resolver loaded the curated layer and resolved both probes)")
}
func probe(ctx context.Context, r *matching.DeterministicAliasResolver, label string, req engine.RequiredSkill, candName string, wantAlias bool, failed *bool) {
m, ok := r.ResolveAlias(ctx, req, []engine.CandidateSkill{{Name: candName}})
if !ok || !m.Matched {
fmt.Printf(" %-28s FAIL (no match for candidate %q)\n", label, candName)
*failed = true
return
}
fmt.Printf(" %-28s matched: similarity=%s exact=%v aliasMatched=%v\n", label, m.Similarity.String(), m.Exact, m.AliasMatched)
if wantAlias && !m.AliasMatched {
fmt.Printf(" %-28s FAIL (expected an alias sourced match)\n", label)
*failed = true
}
}