feat(platform): add the notification inbox and deterministic match search

This commit is contained in:
shira committed 2026-10-09 13:14:46 +03:00
1 parent 5edff21d2d
commit 0b11021b16
169 files changed
+17083 -443

No files matched your search

+127 -4
View File
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"slices"
)
const (
@@ -36,6 +37,7 @@ type productPolicyDocument struct {
Identity *identityPolicyDocument `json:"identity"`
SearchStatus *searchStatusDocument `json:"search_status"`
Support *supportPolicyDocument `json:"support,omitempty"`
Matching *matchingPolicyDocument `json:"matching,omitempty"`
}
// productPolicyV1Document deliberately excludes extension keys. Its strict
@@ -157,6 +159,39 @@ type identityPolicyDocument struct {
SessionAbsoluteLifetimeDays *CalendarDays `json:"session_absolute_lifetime_days"`
}
type matchingPolicyDocument struct {
FitCoverageWeightBP *BasisPoints `json:"fit_coverage_weight_bp"`
FitDomainWeightBP *BasisPoints `json:"fit_domain_weight_bp"`
FitSemanticsWeightBP *BasisPoints `json:"fit_semantics_weight_bp"`
RankFitWeightBP *BasisPoints `json:"rank_fit_weight_bp"`
RankStrengthWeightBP *BasisPoints `json:"rank_strength_weight_bp"`
FreshnessFloorBP *BasisPoints `json:"freshness_floor_bp"`
ResponsivenessFloorBP *BasisPoints `json:"responsiveness_floor_bp"`
CompetitionBoostBP *BasisPoints `json:"competition_boost_bp"`
NeutralUnknownBP *BasisPoints `json:"neutral_unknown_bp"`
NearSkillThresholdBP *BasisPoints `json:"near_skill_threshold_bp"`
RequiredSkillWeight *int32 `json:"required_skill_weight"`
DesiredSkillWeight *int32 `json:"desired_skill_weight"`
TrustStatedBP *BasisPoints `json:"trust_stated_bp"`
TrustOnlineBP *BasisPoints `json:"trust_online_bp"`
TrustIdentityBP *BasisPoints `json:"trust_identity_bp"`
TrustInPersonBP *BasisPoints `json:"trust_in_person_bp"`
AttributionPersonalBP *BasisPoints `json:"attribution_personal_bp"`
AttributionTeamRoleBP *BasisPoints `json:"attribution_team_role_bp"`
AttributionTeamUnattributed *BasisPoints `json:"attribution_team_unattributed_bp"`
RelationExactBP *BasisPoints `json:"relation_exact_bp"`
RelationNarrowerBP *BasisPoints `json:"relation_narrower_bp"`
RelationBroaderBP *BasisPoints `json:"relation_broader_bp"`
PercentileMinCohort *int32 `json:"percentile_min_cohort"`
MaxResultsPerGroup *int32 `json:"max_results_per_group"`
SkillTaxonomy *[]matchingSkillGroupDocument `json:"skill_taxonomy"`
}
type matchingSkillGroupDocument struct {
Specialization *SpecializationCode `json:"specialization"`
Skills *[]CandidateViewSkillCode `json:"skills"`
}
type searchStatusDocument struct {
SearchingConfirmationIntervalDays *CalendarDays `json:"searching_confirmation_interval_days"`
}
@@ -178,7 +213,8 @@ func encodeProductPolicy(policy ProductPolicy) ([]byte, PolicyDocumentHash, erro
}
}
schemaVersion := int32(productPolicySchemaVersionV1)
if policy.Assessment.Attempt != nil || policy.Assessment.Training != nil || policy.Assessment.Signals != nil || policy.Support != nil {
if policy.Assessment.Attempt != nil || policy.Assessment.Training != nil || policy.Assessment.Signals != nil ||
policy.Support != nil || policy.Matching != nil {
schemaVersion = productPolicySchemaVersionV2
}
document := productPolicyDocument{
@@ -230,7 +266,8 @@ func encodeProductPolicy(policy ProductPolicy) ([]byte, PolicyDocumentHash, erro
SearchStatus: &searchStatusDocument{
SearchingConfirmationIntervalDays: pointer(policy.SearchStatus.SearchingConfirmationInterval),
},
Support: support,
Support: support,
Matching: encodeMatchingPolicy(policy.Matching),
}
encoded, err := json.Marshal(document)
if err != nil {
@@ -292,6 +329,49 @@ func encodeAssessmentSignalPolicy(policy *AssessmentSignalPolicy) *assessmentSig
}
}
func encodeMatchingPolicy(policy *MatchingPolicy) *matchingPolicyDocument {
if policy == nil {
return nil
}
return &matchingPolicyDocument{
FitCoverageWeightBP: pointer(policy.FitCoverageWeight),
FitDomainWeightBP: pointer(policy.FitDomainWeight),
FitSemanticsWeightBP: pointer(policy.FitSemanticsWeight),
RankFitWeightBP: pointer(policy.RankFitWeight),
RankStrengthWeightBP: pointer(policy.RankStrengthWeight),
FreshnessFloorBP: pointer(policy.FreshnessFloor),
ResponsivenessFloorBP: pointer(policy.ResponsivenessFloor),
CompetitionBoostBP: pointer(policy.CompetitionBoost),
NeutralUnknownBP: pointer(policy.NeutralUnknown),
NearSkillThresholdBP: pointer(policy.NearSkillThreshold),
RequiredSkillWeight: pointer(policy.RequiredSkillWeight),
DesiredSkillWeight: pointer(policy.DesiredSkillWeight),
TrustStatedBP: pointer(policy.TrustStated),
TrustOnlineBP: pointer(policy.TrustOnline),
TrustIdentityBP: pointer(policy.TrustIdentity),
TrustInPersonBP: pointer(policy.TrustInPerson),
AttributionPersonalBP: pointer(policy.AttributionSelf),
AttributionTeamRoleBP: pointer(policy.AttributionTeamRole),
AttributionTeamUnattributed: pointer(policy.AttributionTeamUnattributed),
RelationExactBP: pointer(policy.RelationExact),
RelationNarrowerBP: pointer(policy.RelationNarrower),
RelationBroaderBP: pointer(policy.RelationBroader),
PercentileMinCohort: pointer(policy.PercentileMinCohort),
MaxResultsPerGroup: pointer(policy.MaxResultsPerGroup),
SkillTaxonomy: pointer(encodeMatchingSkillGroups(policy.SkillTaxonomy)),
}
}
func encodeMatchingSkillGroups(groups []MatchingSkillGroup) []matchingSkillGroupDocument {
documents := make([]matchingSkillGroupDocument, 0, len(groups))
for _, group := range groups {
documents = append(documents, matchingSkillGroupDocument{
Specialization: pointer(group.Specialization), Skills: pointer(slices.Clone(group.Skills)),
})
}
return documents
}
func encodeTierQuota(quota OrganizationTierQuota) *organizationTierQuotaDocument {
return &organizationTierQuotaDocument{
Active: pointer(quota.Active),
@@ -347,7 +427,7 @@ func decodeProductPolicy(document []byte) (ProductPolicy, error) {
}
assessment := parsed.Assessment
hasAssessmentExtension := assessment != nil && (assessment.Attempt != nil || assessment.Training != nil || assessment.Signals != nil)
if !hasAssessmentExtension && parsed.Support == nil {
if !hasAssessmentExtension && parsed.Support == nil && parsed.Matching == nil {
return ProductPolicy{}, invalidPolicy(location, "schema_version 2 requires at least one policy extension")
}
default:
@@ -493,7 +573,8 @@ func decodeProductPolicyFields(parsed productPolicyDocument, schemaVersion int32
SearchStatus: SearchStatusPolicy{
SearchingConfirmationInterval: require(&reader, "search_status.searching_confirmation_interval_days", searchStatus.SearchingConfirmationIntervalDays),
},
Support: decodeOptionalSupportPolicy(&reader, parsed.Support),
Support: decodeOptionalSupportPolicy(&reader, parsed.Support),
Matching: decodeOptionalMatchingPolicy(&reader, parsed.Matching),
}
if reader.missing != "" {
return ProductPolicy{}, invalidPolicy(location, reader.missing+" is required")
@@ -501,6 +582,48 @@ func decodeProductPolicyFields(parsed productPolicyDocument, schemaVersion int32
return policy, nil
}
// decodeOptionalMatchingPolicy keeps documents that predate the matching
// section without it and never fills an omitted section with demo values.
func decodeOptionalMatchingPolicy(reader *documentReader, document *matchingPolicyDocument) *MatchingPolicy {
if document == nil {
return nil
}
taxonomy := make([]MatchingSkillGroup, 0)
for _, group := range require(reader, "matching.skill_taxonomy", document.SkillTaxonomy) {
taxonomy = append(taxonomy, MatchingSkillGroup{
Specialization: require(reader, "matching.skill_taxonomy.specialization", group.Specialization),
Skills: require(reader, "matching.skill_taxonomy.skills", group.Skills),
})
}
return &MatchingPolicy{
FitCoverageWeight: require(reader, "matching.fit_coverage_weight_bp", document.FitCoverageWeightBP),
FitDomainWeight: require(reader, "matching.fit_domain_weight_bp", document.FitDomainWeightBP),
FitSemanticsWeight: require(reader, "matching.fit_semantics_weight_bp", document.FitSemanticsWeightBP),
RankFitWeight: require(reader, "matching.rank_fit_weight_bp", document.RankFitWeightBP),
RankStrengthWeight: require(reader, "matching.rank_strength_weight_bp", document.RankStrengthWeightBP),
FreshnessFloor: require(reader, "matching.freshness_floor_bp", document.FreshnessFloorBP),
ResponsivenessFloor: require(reader, "matching.responsiveness_floor_bp", document.ResponsivenessFloorBP),
CompetitionBoost: require(reader, "matching.competition_boost_bp", document.CompetitionBoostBP),
NeutralUnknown: require(reader, "matching.neutral_unknown_bp", document.NeutralUnknownBP),
NearSkillThreshold: require(reader, "matching.near_skill_threshold_bp", document.NearSkillThresholdBP),
RequiredSkillWeight: require(reader, "matching.required_skill_weight", document.RequiredSkillWeight),
DesiredSkillWeight: require(reader, "matching.desired_skill_weight", document.DesiredSkillWeight),
TrustStated: require(reader, "matching.trust_stated_bp", document.TrustStatedBP),
TrustOnline: require(reader, "matching.trust_online_bp", document.TrustOnlineBP),
TrustIdentity: require(reader, "matching.trust_identity_bp", document.TrustIdentityBP),
TrustInPerson: require(reader, "matching.trust_in_person_bp", document.TrustInPersonBP),
AttributionSelf: require(reader, "matching.attribution_personal_bp", document.AttributionPersonalBP),
AttributionTeamRole: require(reader, "matching.attribution_team_role_bp", document.AttributionTeamRoleBP),
AttributionTeamUnattributed: require(reader, "matching.attribution_team_unattributed_bp", document.AttributionTeamUnattributed),
RelationExact: require(reader, "matching.relation_exact_bp", document.RelationExactBP),
RelationNarrower: require(reader, "matching.relation_narrower_bp", document.RelationNarrowerBP),
RelationBroader: require(reader, "matching.relation_broader_bp", document.RelationBroaderBP),
PercentileMinCohort: require(reader, "matching.percentile_min_cohort", document.PercentileMinCohort),
MaxResultsPerGroup: require(reader, "matching.max_results_per_group", document.MaxResultsPerGroup),
SkillTaxonomy: taxonomy,
}
}
func decodeTierQuota(reader *documentReader, field string, document *organizationTierQuotaDocument) OrganizationTierQuota {
tier := require(reader, field, document)
return OrganizationTierQuota{