Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/commandcenter/service_federal_signal.go |
| Original SHA-256 | c20a8d1697dda3ec30a36828c4734fd189d5952562bfdeaf70d0556e93c4629f |
| Git blob SHA | fca27f4e9cbc54c85bfd39420a2a7b0f7c65f6d4 |
| Reading-copy SHA-256 | c20a8d1697dda3ec30a36828c4734fd189d5952562bfdeaf70d0556e93c4629f |
Every recorded occurrence
These 15 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/commandcenter/service_federal_signal.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓183 lines · 7.4 KB
package commandcenter
import (
"context"
"fmt"
"strings"
"github.com/jackc/pgx/v5"
"github.com/missionworkforce/missionmatch/internal/platform/database/dbgen"
"github.com/missionworkforce/missionmatch/internal/platform/missionclass"
)
// openByMissionLimit caps the open requirements by mission panel.
const openByMissionLimit = 25
// incumbentMixLimit caps the incumbent staffing mix panel. It bounds the number of joined role rows the
// recompete query returns before grouping, so a heavily tagged award catalog cannot flood the panel.
const incumbentMixLimit = 200
// federalSignalProvenanceNote is the standing label on every federal signal panel, so the surface always
// reads as public federal data carrying its own provenance, never a verified or fabricated figure. It
// mirrors the clearance and demo data disclaimers on the rest of the Command Center.
const federalSignalProvenanceNote = "Public federal data. Mission tags and incumbent roles are deterministic inferences carrying their source evidence, never a scoring input and never a verified figure. Clearance is a self reported indicator confirmed by the hiring client FSO through DISS at onboarding."
// errUnknownMission is returned when a caller asks for a mission code that is not in the controlled
// vocabulary. The handler maps it to a bad request so the panel never silently runs an empty filter.
var errUnknownMission = fmt.Errorf("commandcenter: unknown mission code")
// validMissionCode reports whether code is one of the controlled mission_areas codes. The vocabulary is
// the single source of truth shared with the classifier, so the panel cannot drift from the tag tables.
func validMissionCode(code string) bool {
for _, c := range missionclass.Codes {
if c == code {
return true
}
}
return false
}
// FederalSignal builds the additive WS7 panel for the caller's org: the open solicitations tagged to the
// requested mission code, and the incumbent staffing mix on recompete relevant awards. It is read only and
// RLS scoped (both reads run inside one tenant transaction), never alters the readiness math, and never
// reaches the eeo schema. The mission code is validated against the controlled vocabulary first so an
// unknown code is rejected rather than silently returning everything.
//
// The opportunity_records and usaspending_awards catalogs are global public reference data; federal_mission_tags
// and award_incumbent_roles are global app SELECT tables. They are read inside RunInTenantTx only so the
// transaction is the same correctness boundary the rest of the dashboard uses, not because the rows are
// tenant scoped.
func (s *Service) FederalSignal(ctx context.Context, mission string) (FederalSignal, error) {
if s.db == nil {
return FederalSignal{}, ErrNoDatabase
}
mission = strings.ToUpper(strings.TrimSpace(mission))
if mission != "" && !validMissionCode(mission) {
return FederalSignal{}, errUnknownMission
}
out := FederalSignal{Mission: mission, Notes: []string{federalSignalProvenanceNote}}
err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error {
var err error
if mission != "" {
if out.OpenByMission, err = openByMission(ctx, tx, mission); err != nil {
return err
}
} else {
out.OpenByMission = []OpenMissionOpp{}
}
if out.IncumbentMix, err = incumbentMix(ctx, tx); err != nil {
return err
}
return nil
})
if err != nil {
return FederalSignal{}, err
}
return out, nil
}
// openByMission lists active solicitations tagged to one mission code via the WS7 ListOpportunityRecords
// missions narg, then enriches each row with the mission tag mechanism and evidence so the founder facing
// question open SIGINT requirements is traceable to the tag that matched. Soonest closing first, then id
// as the unique tiebreaker the query already carries, so output is byte stable.
func openByMission(ctx context.Context, tx pgx.Tx, mission string) ([]OpenMissionOpp, error) {
q := dbgen.New(tx)
recs, err := q.ListOpportunityRecords(ctx, dbgen.ListOpportunityRecordsParams{
Kinds: []string{"active_solicitation"},
Missions: []string{mission},
Lim: openByMissionLimit,
})
if err != nil {
return nil, fmt.Errorf("open by mission: %w", err)
}
out := make([]OpenMissionOpp, 0, len(recs))
for _, r := range recs {
o := OpenMissionOpp{
RecordID: r.ID.String(),
Title: r.Title,
Agency: r.Agency,
NAICS: r.Naics,
PSC: r.Psc,
PlaceOfPerformance: r.PopState,
SetAside: r.SetAside,
ValueSource: r.ValueSource,
UILink: r.UiLink,
MissionCode: mission,
Source: r.SourceName,
}
if r.EstimatedValue != nil {
vs := r.EstimatedValue.StringFixed(2)
o.Value = &vs
}
if r.ResponseDeadline != nil {
o.ResponseDeadline = r.ResponseDeadline.Format("2006-01-02")
}
// Read the mission tag provenance for this record and code so the row is traceable to the
// mechanism and evidence the classifier recorded, the WS7 acceptance criterion.
if err := tx.QueryRow(ctx,
`SELECT mechanism, evidence FROM federal_mission_tags
WHERE record_table='opportunity_records' AND record_id=$1 AND mission_code=$2`,
r.ID.String(), mission).Scan(&o.MissionMechanism, &o.MissionEvidence); err != nil {
if err != pgx.ErrNoRows {
return nil, fmt.Errorf("open by mission tag provenance: %w", err)
}
}
out = append(out, o)
}
return out, nil
}
// incumbentMix reads the incumbent labor roles on recompete relevant USASpending awards (the recompete
// signal is the period of performance end date) and groups the flat role rows into one entry per award.
// The query returns rows ordered by pop_end_date then award id then labor category, so the grouping
// preserves that byte stable order. Each role carries its evidence phrase, the WS7 traceability criterion.
func incumbentMix(ctx context.Context, tx pgx.Tx) ([]IncumbentMixAward, error) {
rows, err := dbgen.New(tx).ListIncumbentRolesByRecompete(ctx, dbgen.ListIncumbentRolesByRecompeteParams{
RowLimit: incumbentMixLimit,
})
if err != nil {
return nil, fmt.Errorf("incumbent mix: %w", err)
}
return groupIncumbentMix(rows), nil
}
// groupIncumbentMix folds the flat (award, role) rows into one IncumbentMixAward per award, preserving the
// query's pop_end_date ordering. It is a pure function so the grouping is unit tested without a DB. The
// rows arrive grouped by award id (the query orders by pop_end_date, then award id, then labor category),
// so a single pass keyed on the award id is sufficient and stable.
func groupIncumbentMix(rows []dbgen.ListIncumbentRolesByRecompeteRow) []IncumbentMixAward {
out := make([]IncumbentMixAward, 0)
idx := map[string]int{}
for _, r := range rows {
i, seen := idx[r.RecordID]
if !seen {
a := IncumbentMixAward{
RecordID: r.RecordID,
RecipientName: r.RecipientName,
Agency: r.AwardingAgency,
NAICS: r.NaicsCode,
Source: "USASpending",
Roles: []IncumbentRole{},
}
if r.AwardAmount != nil {
vs := r.AwardAmount.StringFixed(2)
a.AwardValue = &vs
}
if r.PopEndDate.Valid {
a.PopEndDate = r.PopEndDate.Time.Format("2006-01-02")
}
out = append(out, a)
i = len(out) - 1
idx[r.RecordID] = i
}
out[i].Roles = append(out[i].Roles, IncumbentRole{
LaborCategory: r.LaborCategory,
RoleCount: int(r.RoleCount),
Evidence: r.Evidence,
})
}
return out
}