feat(matching): rank with semantic embeddings and explain matches by evidence
This commit is contained in:
1 parent
facc1789b1
commit
24b64d698a
215 files changed
+16951
-327
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// Package policypublish implements the local operator command that adds the
|
||||
// demo matching section to the product policy. Until an administrative policy
|
||||
// demo matching section, or the semantic matching section, to the product
|
||||
// policy. Until an administrative policy
|
||||
// editor exists, this is how a stand gets the coefficients that the match
|
||||
// search needs: startup seeds only the first demo version.
|
||||
package policypublish
|
||||
@@ -20,24 +21,38 @@ import (
|
||||
"lincodex/backend/internal/usecase/policy"
|
||||
)
|
||||
|
||||
const usage = "usage: policy-publish matching --actor operator:<handle>"
|
||||
const usage = "usage: policy-publish matching|semantic --actor operator:<handle>"
|
||||
|
||||
// Track names which section a command publishes.
|
||||
type Track string
|
||||
|
||||
const (
|
||||
// TrackMatching adds the PRD matching section (Sem weight 0.10).
|
||||
TrackMatching Track = "matching"
|
||||
// TrackSemantic adds the semantic matching section (Sem weight 0.5, the
|
||||
// encoder identity, the calibration, and the explanation thresholds).
|
||||
TrackSemantic Track = "semantic"
|
||||
)
|
||||
|
||||
// Command is a parsed, validated request.
|
||||
type Command struct {
|
||||
Track Track
|
||||
Author domain.PolicyAuthor
|
||||
}
|
||||
|
||||
// Extender publishes the demo matching section.
|
||||
type Extender interface {
|
||||
EnsureDemoMatchingSection(ctx context.Context, author domain.PolicyAuthor) (policy.MatchingResult, error)
|
||||
EnsureDemoSemanticMatchingSection(ctx context.Context, author domain.PolicyAuthor) (policy.MatchingResult, error)
|
||||
}
|
||||
|
||||
// Parse validates every argument before Run reads configuration or connects.
|
||||
func Parse(args []string) (Command, error) {
|
||||
if len(args) == 0 || args[0] != "matching" {
|
||||
if len(args) == 0 || (args[0] != string(TrackMatching) && args[0] != string(TrackSemantic)) {
|
||||
return Command{}, errors.New(usage)
|
||||
}
|
||||
flags := flag.NewFlagSet("policy-publish matching", flag.ContinueOnError)
|
||||
track := Track(args[0])
|
||||
flags := flag.NewFlagSet("policy-publish "+args[0], flag.ContinueOnError)
|
||||
flags.SetOutput(io.Discard)
|
||||
actor := flags.String("actor", "", "operator handle")
|
||||
if err := flags.Parse(args[1:]); err != nil || flags.NArg() != 0 {
|
||||
@@ -48,7 +63,7 @@ func Parse(args []string) (Command, error) {
|
||||
if err != nil || !strings.HasPrefix(value, "operator:") {
|
||||
return Command{}, errors.New("actor must be operator:<handle>")
|
||||
}
|
||||
return Command{Author: author}, nil
|
||||
return Command{Track: track, Author: author}, nil
|
||||
}
|
||||
|
||||
// Run parses the command, loads only DATABASE_URL from the supplied
|
||||
@@ -81,7 +96,14 @@ func Execute(ctx context.Context, command Command, extender Extender, output io.
|
||||
if extender == nil || output == nil {
|
||||
return errors.New("policy publication command dependencies are required")
|
||||
}
|
||||
result, err := extender.EnsureDemoMatchingSection(ctx, command.Author)
|
||||
publish, section, note := extender.EnsureDemoMatchingSection, "the demo matching section",
|
||||
"note: demonstration values, not calibrated; they apply to new searches at once and change no stored result\n"
|
||||
if command.Track == TrackSemantic {
|
||||
publish, section, note = extender.EnsureDemoSemanticMatchingSection, "the semantic matching section",
|
||||
"note: research-calibrated values (LincodexMatch DEV split), not product measurements; searches use them at once,\n"+
|
||||
"and Sem stays neutral for subjects without vectors until the semantic-backfill command has run\n"
|
||||
}
|
||||
result, err := publish(ctx, command.Author)
|
||||
if err != nil {
|
||||
return safeOperationError(err)
|
||||
}
|
||||
@@ -89,11 +111,7 @@ func Execute(ctx context.Context, command Command, extender Extender, output io.
|
||||
if result.Created {
|
||||
status = "published"
|
||||
}
|
||||
if _, err := fmt.Fprintf(output,
|
||||
"%s: product policy version %d carries the demo matching section\n"+
|
||||
"note: demonstration values, not calibrated; they apply to new searches at once and change no stored result\n",
|
||||
status, result.Version.Version(),
|
||||
); err != nil {
|
||||
if _, err := fmt.Fprintf(output, "%s: product policy version %d carries %s\n%s", status, result.Version.Version(), section, note); err != nil {
|
||||
return errors.New("could not write the result")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -13,9 +13,10 @@ import (
|
||||
)
|
||||
|
||||
type extenderFake struct {
|
||||
result policy.MatchingResult
|
||||
err error
|
||||
author domain.PolicyAuthor
|
||||
result policy.MatchingResult
|
||||
err error
|
||||
author domain.PolicyAuthor
|
||||
semantic bool
|
||||
}
|
||||
|
||||
func (extender *extenderFake) EnsureDemoMatchingSection(_ context.Context, author domain.PolicyAuthor) (policy.MatchingResult, error) {
|
||||
@@ -23,11 +24,21 @@ func (extender *extenderFake) EnsureDemoMatchingSection(_ context.Context, autho
|
||||
return extender.result, extender.err
|
||||
}
|
||||
|
||||
func (extender *extenderFake) EnsureDemoSemanticMatchingSection(_ context.Context, author domain.PolicyAuthor) (policy.MatchingResult, error) {
|
||||
extender.author = author
|
||||
extender.semantic = true
|
||||
return extender.result, extender.err
|
||||
}
|
||||
|
||||
func TestParseRequiresTheMatchingTrackAndAnOperatorHandle(t *testing.T) {
|
||||
command, err := Parse([]string{"matching", "--actor", "operator:night"})
|
||||
if err != nil || command.Author != "operator:night" {
|
||||
if err != nil || command.Author != "operator:night" || command.Track != TrackMatching {
|
||||
t.Fatalf("Parse(valid) = %+v, %v", command, err)
|
||||
}
|
||||
semantic, err := Parse([]string{"semantic", "--actor", "operator:night"})
|
||||
if err != nil || semantic.Track != TrackSemantic {
|
||||
t.Fatalf("Parse(semantic) = %+v, %v", semantic, err)
|
||||
}
|
||||
for _, args := range [][]string{
|
||||
nil, {"list"}, {"matching"}, {"matching", "--actor", "alice"}, {"matching", "--actor", "system:demo-seed"},
|
||||
{"matching", "--actor", "operator:night", "extra"},
|
||||
@@ -62,3 +73,14 @@ func TestExecutePrintsOnlyTheVersionAndMapsFailuresToSafeMessages(t *testing.T)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteSemanticTrackPublishesTheSemanticSection(t *testing.T) {
|
||||
var output bytes.Buffer
|
||||
extender := &extenderFake{}
|
||||
if err := Execute(context.Background(), Command{Track: TrackSemantic, Author: "operator:night"}, extender, &output); err != nil {
|
||||
t.Fatalf("Execute() error = %v", err)
|
||||
}
|
||||
if !extender.semantic || !strings.Contains(output.String(), "the semantic matching section") {
|
||||
t.Fatalf("output = %q, semantic called %v", output.String(), extender.semantic)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// Package semanticbackfill implements the operator command that schedules
|
||||
// vector jobs for existing published candidates and needs, for example after
|
||||
// semantic matching is enabled, the semantic policy is published, or the ML
|
||||
// model changes. The jobs run in the backend worker; the command only
|
||||
// schedules them and prints the resume cursor of every page.
|
||||
package semanticbackfill
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/config"
|
||||
"lincodex/backend/internal/adapter/secondary/postgres"
|
||||
"lincodex/backend/internal/usecase/semantic"
|
||||
)
|
||||
|
||||
const usage = "usage: semantic-backfill candidates|needs|all --run <label> [--after <uuid>]"
|
||||
|
||||
// Command is a parsed, validated request.
|
||||
type Command struct {
|
||||
Scopes []semantic.BackfillScope
|
||||
Run string
|
||||
After uuid.UUID
|
||||
}
|
||||
|
||||
// Runner schedules the jobs of one scope.
|
||||
type Runner interface {
|
||||
Run(ctx context.Context, scope semantic.BackfillScope, run string, after uuid.UUID, report func(semantic.BackfillProgress) error) error
|
||||
}
|
||||
|
||||
// Parse validates every argument before Run reads configuration or connects.
|
||||
func Parse(args []string) (Command, error) {
|
||||
if len(args) == 0 {
|
||||
return Command{}, errors.New(usage)
|
||||
}
|
||||
var scopes []semantic.BackfillScope
|
||||
switch args[0] {
|
||||
case string(semantic.BackfillCandidates):
|
||||
scopes = []semantic.BackfillScope{semantic.BackfillCandidates}
|
||||
case string(semantic.BackfillNeeds):
|
||||
scopes = []semantic.BackfillScope{semantic.BackfillNeeds}
|
||||
case "all":
|
||||
scopes = []semantic.BackfillScope{semantic.BackfillCandidates, semantic.BackfillNeeds}
|
||||
default:
|
||||
return Command{}, errors.New(usage)
|
||||
}
|
||||
flags := flag.NewFlagSet("semantic-backfill", flag.ContinueOnError)
|
||||
flags.SetOutput(io.Discard)
|
||||
run := flags.String("run", "", "run label; a new label recomputes again")
|
||||
after := flags.String("after", "", "resume after this identifier")
|
||||
if err := flags.Parse(args[1:]); err != nil || flags.NArg() != 0 || *run == "" {
|
||||
return Command{}, errors.New(usage)
|
||||
}
|
||||
command := Command{Scopes: scopes, Run: *run}
|
||||
if *after != "" {
|
||||
if len(scopes) != 1 {
|
||||
return Command{}, errors.New("--after needs a single scope")
|
||||
}
|
||||
parsed, err := uuid.Parse(*after)
|
||||
if err != nil {
|
||||
return Command{}, errors.New("--after must be a UUID")
|
||||
}
|
||||
command.After = parsed
|
||||
}
|
||||
return command, nil
|
||||
}
|
||||
|
||||
// Run parses the command, loads only DATABASE_URL, and schedules.
|
||||
func Run(ctx context.Context, args []string, lookup config.LookupEnv, output io.Writer, clock func() time.Time) error {
|
||||
command, err := Parse(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if lookup == nil || output == nil || clock == nil {
|
||||
return errors.New("semantic backfill command dependencies are required")
|
||||
}
|
||||
databaseURL := config.DatabaseURLFromEnv(lookup)
|
||||
if databaseURL == "" {
|
||||
return errors.New("DATABASE_URL is not set")
|
||||
}
|
||||
pool, err := postgres.NewPool(ctx, databaseURL)
|
||||
if err != nil {
|
||||
return errors.New("database configuration is invalid")
|
||||
}
|
||||
defer pool.Close()
|
||||
if err := pool.Ping(ctx); err != nil {
|
||||
return errors.New("database is unavailable")
|
||||
}
|
||||
backfill, err := semantic.NewBackfill(postgres.NewTransactor(pool), clock)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return Execute(ctx, command, backfill, output)
|
||||
}
|
||||
|
||||
// Execute runs every scope and prints one line per page.
|
||||
func Execute(ctx context.Context, command Command, runner Runner, output io.Writer) error {
|
||||
for _, scope := range command.Scopes {
|
||||
total := 0
|
||||
err := runner.Run(ctx, scope, command.Run, command.After, func(progress semantic.BackfillProgress) error {
|
||||
total += progress.Scheduled
|
||||
_, err := fmt.Fprintf(output, "%s: scheduled %d (total %d), resume with --after %s\n",
|
||||
progress.Scope, progress.Scheduled, total, progress.After)
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return errors.New("the backfill stopped; run it again with --after of the last printed line")
|
||||
}
|
||||
if _, err := fmt.Fprintf(output, "%s: done, %d jobs scheduled; the backend worker computes them\n", scope, total); err != nil {
|
||||
return errors.New("could not write the result")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package semanticbackfill
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/usecase/semantic"
|
||||
)
|
||||
|
||||
type runnerFake struct {
|
||||
scopes []semantic.BackfillScope
|
||||
err error
|
||||
}
|
||||
|
||||
func (runner *runnerFake) Run(_ context.Context, scope semantic.BackfillScope, _ string, after uuid.UUID, report func(semantic.BackfillProgress) error) error {
|
||||
runner.scopes = append(runner.scopes, scope)
|
||||
if runner.err != nil {
|
||||
return runner.err
|
||||
}
|
||||
return report(semantic.BackfillProgress{Scope: scope, Scheduled: 2, After: after, Done: true})
|
||||
}
|
||||
|
||||
func TestParseRequiresAScopeAndARunLabel(t *testing.T) {
|
||||
command, err := Parse([]string{"all", "--run", "2026-10-11"})
|
||||
if err != nil || len(command.Scopes) != 2 || command.Run != "2026-10-11" {
|
||||
t.Fatalf("Parse(all) = %+v, %v", command, err)
|
||||
}
|
||||
after := uuid.New()
|
||||
command, err = Parse([]string{"needs", "--run", "r1", "--after", after.String()})
|
||||
if err != nil || command.After != after {
|
||||
t.Fatalf("Parse(needs --after) = %+v, %v", command, err)
|
||||
}
|
||||
for _, args := range [][]string{
|
||||
nil, {"vectors"}, {"candidates"}, {"all", "--run", "r1", "--after", after.String()},
|
||||
{"needs", "--run", "r1", "--after", "x"}, {"needs", "--run", "r1", "extra"},
|
||||
} {
|
||||
if _, err := Parse(args); err == nil {
|
||||
t.Errorf("Parse(%v) accepted invalid arguments", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteReportsEveryScopeAndHidesStorageErrors(t *testing.T) {
|
||||
var output bytes.Buffer
|
||||
runner := &runnerFake{}
|
||||
command := Command{Scopes: []semantic.BackfillScope{semantic.BackfillCandidates, semantic.BackfillNeeds}, Run: "r1"}
|
||||
if err := Execute(context.Background(), command, runner, &output); err != nil {
|
||||
t.Fatalf("Execute() error = %v", err)
|
||||
}
|
||||
if len(runner.scopes) != 2 || !strings.Contains(output.String(), "needs: done, 2 jobs scheduled") {
|
||||
t.Fatalf("output = %q", output.String())
|
||||
}
|
||||
failing := &runnerFake{err: errors.New("pq: password authentication failed for user x")}
|
||||
err := Execute(context.Background(), command, failing, &bytes.Buffer{})
|
||||
if err == nil || strings.Contains(err.Error(), "password") {
|
||||
t.Fatalf("Execute(failing) error = %v, want a safe message", err)
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ var regexMap = map[string]ogenregex.Regexp{
|
||||
"^__Host-lincodex_session=": ogenregex.MustCompile("^__Host-lincodex_session="),
|
||||
"^cv1_[A-Za-z0-9_-]{43}$": ogenregex.MustCompile("^cv1_[A-Za-z0-9_-]{43}$"),
|
||||
"^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$": ogenregex.MustCompile("^https://[^\\s/?#@]+(?:[/?#][^\\s]*)?$"),
|
||||
"^https://github\\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$": ogenregex.MustCompile("^https://github\\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$"),
|
||||
}
|
||||
var (
|
||||
// Allocate option closure once.
|
||||
|
||||
@@ -12806,6 +12806,223 @@ func (s *Server) handleRequestMyAccountDeletionRequest(args [0]string, argsEscap
|
||||
}
|
||||
}
|
||||
|
||||
// handleRequestMyRepositoryChecksRequest handles RequestMyRepositoryChecks operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The request has no body. It schedules a new check of every repository that
|
||||
// the current profile links, for example after the candidate made a repository public, and answers 202
|
||||
// with the number of scheduled checks; the checks run in the background and `GetMyProfile` shows their
|
||||
// state in `projects[].repository_check`. A profile without linked repositories answers 202 with 0.
|
||||
//
|
||||
// A check reads only public metadata from the public GitHub API (`api.github.com`): whether the
|
||||
// repository exists and is public, its description, topics, languages, and the beginning of its README
|
||||
// as plain text. The server never fetches any other host, never follows a redirect to another host,
|
||||
// and never shows the fetched text; it uses it only for semantic ranking. A verified repository does
|
||||
// not prove that the candidate wrote the code.
|
||||
//
|
||||
// The operation is limited per candidate: a second request inside the versioned window answers 429
|
||||
// rate_limited with Retry-After and schedules nothing. A missing, unknown, expired, or revoked session
|
||||
// answers 401 unauthenticated; an employer account answers 403 forbidden.
|
||||
//
|
||||
// POST /api/v1/me/profile/repository-checks
|
||||
func (s *Server) handleRequestMyRepositoryChecksRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
|
||||
statusWriter := &codeRecorder{ResponseWriter: w}
|
||||
w = statusWriter
|
||||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("RequestMyRepositoryChecks"),
|
||||
semconv.HTTPRequestMethodKey.String("POST"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/me/profile/repository-checks"),
|
||||
}
|
||||
// Add attributes from config.
|
||||
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
|
||||
|
||||
// Start a span for this request.
|
||||
ctx, span := s.cfg.Tracer.Start(r.Context(), RequestMyRepositoryChecksOperation,
|
||||
trace.WithAttributes(otelAttrs...),
|
||||
serverSpanKind,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
// Add Labeler to context.
|
||||
labeler := &Labeler{attrs: otelAttrs}
|
||||
ctx = contextWithLabeler(ctx, labeler)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
defer func() {
|
||||
elapsedDuration := time.Since(startTime)
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
code := statusWriter.status
|
||||
if code != 0 {
|
||||
codeAttr := semconv.HTTPResponseStatusCode(code)
|
||||
attrs = append(attrs, codeAttr)
|
||||
span.SetAttributes(attrs...)
|
||||
}
|
||||
attrOpt := metric.WithAttributes(attrs...)
|
||||
|
||||
// Increment request counter.
|
||||
s.requests.Add(ctx, 1, attrOpt)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
|
||||
}()
|
||||
|
||||
var (
|
||||
recordError = func(stage string, err error) {
|
||||
span.RecordError(err)
|
||||
|
||||
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
|
||||
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
|
||||
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
|
||||
// max redirects exceeded), in which case status MUST be set to Error.
|
||||
code := statusWriter.status
|
||||
if code < 100 || code >= 500 {
|
||||
span.SetStatus(codes.Error, stage)
|
||||
}
|
||||
|
||||
attrSet := labeler.AttributeSet()
|
||||
attrs := attrSet.ToSlice()
|
||||
if code != 0 {
|
||||
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
|
||||
}
|
||||
|
||||
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
|
||||
}
|
||||
err error
|
||||
opErrContext = ogenerrors.OperationContext{
|
||||
Name: RequestMyRepositoryChecksOperation,
|
||||
ID: "RequestMyRepositoryChecks",
|
||||
}
|
||||
)
|
||||
{
|
||||
type bitset = [1]uint8
|
||||
var satisfied bitset
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCookie(ctx, RequestMyRepositoryChecksOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCookie",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCookie", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 0
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
{
|
||||
sctx, ok, err := s.securitySessionCsrf(ctx, RequestMyRepositoryChecksOperation, r)
|
||||
if err != nil {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Security: "SessionCsrf",
|
||||
Err: err,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security:SessionCsrf", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if ok {
|
||||
satisfied[0] |= 1 << 1
|
||||
ctx = sctx
|
||||
}
|
||||
}
|
||||
|
||||
if ok := func() bool {
|
||||
nextRequirement:
|
||||
for _, requirement := range []bitset{
|
||||
{0b00000011},
|
||||
} {
|
||||
for i, mask := range requirement {
|
||||
if satisfied[i]&mask != mask {
|
||||
continue nextRequirement
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}(); !ok {
|
||||
err = &ogenerrors.SecurityError{
|
||||
OperationContext: opErrContext,
|
||||
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
|
||||
}
|
||||
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
|
||||
defer recordError("Security", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var rawBody []byte
|
||||
|
||||
var response RequestMyRepositoryChecksRes
|
||||
if m := s.cfg.Middleware; m != nil {
|
||||
mreq := middleware.Request{
|
||||
Context: ctx,
|
||||
OperationName: RequestMyRepositoryChecksOperation,
|
||||
OperationSummary: "Ask the server to check the linked project repositories again.",
|
||||
OperationID: "RequestMyRepositoryChecks",
|
||||
Body: nil,
|
||||
RawBody: rawBody,
|
||||
Params: middleware.Parameters{},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
type (
|
||||
Request = struct{}
|
||||
Params = struct{}
|
||||
Response = RequestMyRepositoryChecksRes
|
||||
)
|
||||
response, err = middleware.HookMiddleware[
|
||||
Request,
|
||||
Params,
|
||||
Response,
|
||||
](
|
||||
m,
|
||||
mreq,
|
||||
nil,
|
||||
func(ctx context.Context, request Request, params Params) (response Response, err error) {
|
||||
response, err = s.h.RequestMyRepositoryChecks(ctx)
|
||||
return response, err
|
||||
},
|
||||
)
|
||||
} else {
|
||||
response, err = s.h.RequestMyRepositoryChecks(ctx)
|
||||
}
|
||||
if err != nil {
|
||||
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
|
||||
if err := encodeErrorResponse(errRes, w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ht.ErrNotImplemented) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
return
|
||||
}
|
||||
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
|
||||
defer recordError("Internal", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := encodeRequestMyRepositoryChecksResponse(response, w, span); err != nil {
|
||||
defer recordError("EncodeResponse", err)
|
||||
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
|
||||
s.cfg.ErrorHandler(ctx, w, r, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// handleResendEmailVerificationRequest handles ResendEmailVerification operation.
|
||||
//
|
||||
// Public operation without a session. The answer is the same 202 for an unknown email, a verified
|
||||
@@ -13976,13 +14193,23 @@ func (s *Server) handleSaveMyQuestionnaireRequest(args [0]string, argsEscaped bo
|
||||
// The card context is limited to safe public fields: recognized stack tags, coarse experience,
|
||||
// accepted work formats, and coarse salary compatibility. It contains no contact, candidate location,
|
||||
// salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data.
|
||||
// Evidence explanations use bounded codes, not free text. When ML is unavailable, semantic similarity
|
||||
// uses the neutral 0.5 specified by FR09 and `unknown_flags` names `ml_unavailable`. For fewer than 30
|
||||
// comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names
|
||||
// `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile
|
||||
// is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5,
|
||||
// the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not
|
||||
// fail.
|
||||
// Evidence explanations use bounded codes, not free text.
|
||||
//
|
||||
// Semantic similarity `Sem` is the calibrated cosine between the stored vector of the need's confirmed
|
||||
// requirements snapshot and the stored vector of the candidate's published card text (roles,
|
||||
// recognized stack, and published projects with the public metadata of their verified repositories).
|
||||
// The search never calls the ML service: vectors are computed in the background after a change, and an
|
||||
// entry whose vectors are missing, stale for the current model, or not computed because ML is
|
||||
// unavailable uses the neutral 0.5 and names `ml_unavailable` in `unknown_flags`. `semantic_evidence`
|
||||
// lists, for a need search, the confirmed requirements whose closest published card item reaches a
|
||||
// similarity band of the versioned policy; it names a project only by the title that the candidate
|
||||
// published with the `projects` card field and says whether its repository is a verified public one,
|
||||
// never the repository address or owner. Showing a project title records the `projects` field in the
|
||||
// candidate's access history. For fewer than 30 comparable real candidates, the search uses neutral T
|
||||
// = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of
|
||||
// a category reaches the minimum, the percentile is still not computed (the organization-safe
|
||||
// projection carries no theta), T stays the neutral 0.5, the percentile stays null, and
|
||||
// `unknown_flags` names `percentile_not_computed`; the search does not fail.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account
|
||||
// answers 403 forbidden; an unknown organization or account without active membership answers 404
|
||||
|
||||
@@ -221,6 +221,10 @@ type RequestMyAccountDeletionRes interface {
|
||||
requestMyAccountDeletionRes()
|
||||
}
|
||||
|
||||
type RequestMyRepositoryChecksRes interface {
|
||||
requestMyRepositoryChecksRes()
|
||||
}
|
||||
|
||||
type ResendEmailVerificationRes interface {
|
||||
resendEmailVerificationRes()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -63,6 +63,7 @@ const (
|
||||
RecordMyAssessmentAttemptSignalsOperation OperationName = "RecordMyAssessmentAttemptSignals"
|
||||
RegisterAccountOperation OperationName = "RegisterAccount"
|
||||
RequestMyAccountDeletionOperation OperationName = "RequestMyAccountDeletion"
|
||||
RequestMyRepositoryChecksOperation OperationName = "RequestMyRepositoryChecks"
|
||||
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
|
||||
RevokeMyConsentOperation OperationName = "RevokeMyConsent"
|
||||
RevokeMyOrganizationContactConsentOperation OperationName = "RevokeMyOrganizationContactConsent"
|
||||
|
||||
@@ -4933,6 +4933,97 @@ func encodeRequestMyAccountDeletionResponse(response RequestMyAccountDeletionRes
|
||||
}
|
||||
}
|
||||
|
||||
func encodeRequestMyRepositoryChecksResponse(response RequestMyRepositoryChecksRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ProfileRepositoryCheckRequestHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(202)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *RequestMyRepositoryChecksUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *RequestMyRepositoryChecksForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *TooManyRequestsHeaders:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Retry-After" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Retry-After",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := response.RetryAfter.Get(); ok {
|
||||
return e.EncodeValue(conv.Int32ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Retry-After header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(429)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeResendEmailVerificationResponse(response ResendEmailVerificationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *IdentityRequestAccepted:
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
rn84AllowedHeaders = map[string]string{
|
||||
rn85AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn9AllowedHeaders = map[string]string{
|
||||
@@ -35,13 +35,13 @@ var (
|
||||
rn12AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn95AllowedHeaders = map[string]string{
|
||||
rn96AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn23AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn94AllowedHeaders = map[string]string{
|
||||
rn95AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn79AllowedHeaders = map[string]string{
|
||||
@@ -50,7 +50,7 @@ var (
|
||||
rn5AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn86AllowedHeaders = map[string]string{
|
||||
rn87AllowedHeaders = map[string]string{
|
||||
"DELETE": "X-Csrf-Token",
|
||||
}
|
||||
rn54AllowedHeaders = map[string]string{
|
||||
@@ -66,7 +66,7 @@ var (
|
||||
rn20AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn96AllowedHeaders = map[string]string{
|
||||
rn97AllowedHeaders = map[string]string{
|
||||
"POST": "X-Csrf-Token",
|
||||
}
|
||||
rn73AllowedHeaders = map[string]string{
|
||||
@@ -76,15 +76,18 @@ var (
|
||||
"DELETE": "X-Csrf-Token",
|
||||
"PUT": "X-Csrf-Token",
|
||||
}
|
||||
rn91AllowedHeaders = map[string]string{
|
||||
rn92AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn92AllowedHeaders = map[string]string{
|
||||
rn93AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn39AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn83AllowedHeaders = map[string]string{
|
||||
"POST": "X-Csrf-Token",
|
||||
}
|
||||
rn40AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
@@ -106,13 +109,13 @@ var (
|
||||
rn78AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn89AllowedHeaders = map[string]string{
|
||||
rn90AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn97AllowedHeaders = map[string]string{
|
||||
rn98AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn87AllowedHeaders = map[string]string{
|
||||
rn88AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn19AllowedHeaders = map[string]string{
|
||||
@@ -278,7 +281,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn84AllowedHeaders,
|
||||
allowedHeaders: rn85AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -607,7 +610,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn95AllowedHeaders,
|
||||
allowedHeaders: rn96AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -700,7 +703,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn94AllowedHeaders,
|
||||
allowedHeaders: rn95AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -938,7 +941,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "DELETE",
|
||||
allowedHeaders: rn86AllowedHeaders,
|
||||
allowedHeaders: rn87AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1180,7 +1183,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn96AllowedHeaders,
|
||||
allowedHeaders: rn97AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1527,7 +1530,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "PUT",
|
||||
allowedHeaders: rn91AllowedHeaders,
|
||||
allowedHeaders: rn92AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1554,7 +1557,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "PUT",
|
||||
allowedHeaders: rn92AllowedHeaders,
|
||||
allowedHeaders: rn93AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1576,7 +1579,6 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
@@ -1593,6 +1595,33 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/repository-checks"
|
||||
|
||||
if l := len("/repository-checks"); len(elem) >= l && elem[0:l] == "/repository-checks" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "POST":
|
||||
s.handleRequestMyRepositoryChecksRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn83AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2000,7 +2029,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn89AllowedHeaders,
|
||||
allowedHeaders: rn90AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -2030,7 +2059,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn97AllowedHeaders,
|
||||
allowedHeaders: rn98AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -2063,7 +2092,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn87AllowedHeaders,
|
||||
allowedHeaders: rn88AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -3759,7 +3788,6 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyProfileOperation
|
||||
@@ -3783,6 +3811,33 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/repository-checks"
|
||||
|
||||
if l := len("/repository-checks"); len(elem) >= l && elem[0:l] == "/repository-checks" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "POST":
|
||||
r.name = RequestMyRepositoryChecksOperation
|
||||
r.summary = "Ask the server to check the linked project repositories again."
|
||||
r.operationID = "RequestMyRepositoryChecks"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile/repository-checks"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -106,6 +106,7 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
RaiseOrganizationInvitationSalaryOperation: []string{},
|
||||
RecordMyAssessmentAttemptSignalsOperation: []string{},
|
||||
RequestMyAccountDeletionOperation: []string{},
|
||||
RequestMyRepositoryChecksOperation: []string{},
|
||||
RevokeMyConsentOperation: []string{},
|
||||
RevokeMyOrganizationContactConsentOperation: []string{},
|
||||
SaveMyProfileOperation: []string{},
|
||||
@@ -165,6 +166,7 @@ var operationRolesSessionCsrf = map[string][]string{
|
||||
RaiseOrganizationInvitationSalaryOperation: []string{},
|
||||
RecordMyAssessmentAttemptSignalsOperation: []string{},
|
||||
RequestMyAccountDeletionOperation: []string{},
|
||||
RequestMyRepositoryChecksOperation: []string{},
|
||||
RevokeMyConsentOperation: []string{},
|
||||
RevokeMyOrganizationContactConsentOperation: []string{},
|
||||
SaveMyProfileOperation: []string{},
|
||||
|
||||
@@ -1556,6 +1556,26 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/me/account-deletion-requests
|
||||
RequestMyAccountDeletion(ctx context.Context) (RequestMyAccountDeletionRes, error)
|
||||
// RequestMyRepositoryChecks implements RequestMyRepositoryChecks operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The request has no body. It schedules a new check of every repository that
|
||||
// the current profile links, for example after the candidate made a repository public, and answers 202
|
||||
// with the number of scheduled checks; the checks run in the background and `GetMyProfile` shows their
|
||||
// state in `projects[].repository_check`. A profile without linked repositories answers 202 with 0.
|
||||
//
|
||||
// A check reads only public metadata from the public GitHub API (`api.github.com`): whether the
|
||||
// repository exists and is public, its description, topics, languages, and the beginning of its README
|
||||
// as plain text. The server never fetches any other host, never follows a redirect to another host,
|
||||
// and never shows the fetched text; it uses it only for semantic ranking. A verified repository does
|
||||
// not prove that the candidate wrote the code.
|
||||
//
|
||||
// The operation is limited per candidate: a second request inside the versioned window answers 429
|
||||
// rate_limited with Retry-After and schedules nothing. A missing, unknown, expired, or revoked session
|
||||
// answers 401 unauthenticated; an employer account answers 403 forbidden.
|
||||
//
|
||||
// POST /api/v1/me/profile/repository-checks
|
||||
RequestMyRepositoryChecks(ctx context.Context) (RequestMyRepositoryChecksRes, error)
|
||||
// ResendEmailVerification implements ResendEmailVerification operation.
|
||||
//
|
||||
// Public operation without a session. The answer is the same 202 for an unknown email, a verified
|
||||
@@ -1730,13 +1750,23 @@ type Handler interface {
|
||||
// The card context is limited to safe public fields: recognized stack tags, coarse experience,
|
||||
// accepted work formats, and coarse salary compatibility. It contains no contact, candidate location,
|
||||
// salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data.
|
||||
// Evidence explanations use bounded codes, not free text. When ML is unavailable, semantic similarity
|
||||
// uses the neutral 0.5 specified by FR09 and `unknown_flags` names `ml_unavailable`. For fewer than 30
|
||||
// comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names
|
||||
// `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile
|
||||
// is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5,
|
||||
// the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not
|
||||
// fail.
|
||||
// Evidence explanations use bounded codes, not free text.
|
||||
//
|
||||
// Semantic similarity `Sem` is the calibrated cosine between the stored vector of the need's confirmed
|
||||
// requirements snapshot and the stored vector of the candidate's published card text (roles,
|
||||
// recognized stack, and published projects with the public metadata of their verified repositories).
|
||||
// The search never calls the ML service: vectors are computed in the background after a change, and an
|
||||
// entry whose vectors are missing, stale for the current model, or not computed because ML is
|
||||
// unavailable uses the neutral 0.5 and names `ml_unavailable` in `unknown_flags`. `semantic_evidence`
|
||||
// lists, for a need search, the confirmed requirements whose closest published card item reaches a
|
||||
// similarity band of the versioned policy; it names a project only by the title that the candidate
|
||||
// published with the `projects` card field and says whether its repository is a verified public one,
|
||||
// never the repository address or owner. Showing a project title records the `projects` field in the
|
||||
// candidate's access history. For fewer than 30 comparable real candidates, the search uses neutral T
|
||||
// = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of
|
||||
// a category reaches the minimum, the percentile is still not computed (the organization-safe
|
||||
// projection carries no theta), T stays the neutral 0.5, the percentile stays null, and
|
||||
// `unknown_flags` names `percentile_not_computed`; the search does not fail.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account
|
||||
// answers 403 forbidden; an unknown organization or account without active membership answers 404
|
||||
|
||||
@@ -1732,6 +1732,29 @@ func (UnimplementedHandler) RequestMyAccountDeletion(ctx context.Context) (r Req
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// RequestMyRepositoryChecks implements RequestMyRepositoryChecks operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The request has no body. It schedules a new check of every repository that
|
||||
// the current profile links, for example after the candidate made a repository public, and answers 202
|
||||
// with the number of scheduled checks; the checks run in the background and `GetMyProfile` shows their
|
||||
// state in `projects[].repository_check`. A profile without linked repositories answers 202 with 0.
|
||||
//
|
||||
// A check reads only public metadata from the public GitHub API (`api.github.com`): whether the
|
||||
// repository exists and is public, its description, topics, languages, and the beginning of its README
|
||||
// as plain text. The server never fetches any other host, never follows a redirect to another host,
|
||||
// and never shows the fetched text; it uses it only for semantic ranking. A verified repository does
|
||||
// not prove that the candidate wrote the code.
|
||||
//
|
||||
// The operation is limited per candidate: a second request inside the versioned window answers 429
|
||||
// rate_limited with Retry-After and schedules nothing. A missing, unknown, expired, or revoked session
|
||||
// answers 401 unauthenticated; an employer account answers 403 forbidden.
|
||||
//
|
||||
// POST /api/v1/me/profile/repository-checks
|
||||
func (UnimplementedHandler) RequestMyRepositoryChecks(ctx context.Context) (r RequestMyRepositoryChecksRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ResendEmailVerification implements ResendEmailVerification operation.
|
||||
//
|
||||
// Public operation without a session. The answer is the same 202 for an unknown email, a verified
|
||||
@@ -1921,13 +1944,23 @@ func (UnimplementedHandler) SaveMyQuestionnaire(ctx context.Context, req *Candid
|
||||
// The card context is limited to safe public fields: recognized stack tags, coarse experience,
|
||||
// accepted work formats, and coarse salary compatibility. It contains no contact, candidate location,
|
||||
// salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data.
|
||||
// Evidence explanations use bounded codes, not free text. When ML is unavailable, semantic similarity
|
||||
// uses the neutral 0.5 specified by FR09 and `unknown_flags` names `ml_unavailable`. For fewer than 30
|
||||
// comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names
|
||||
// `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile
|
||||
// is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5,
|
||||
// the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not
|
||||
// fail.
|
||||
// Evidence explanations use bounded codes, not free text.
|
||||
//
|
||||
// Semantic similarity `Sem` is the calibrated cosine between the stored vector of the need's confirmed
|
||||
// requirements snapshot and the stored vector of the candidate's published card text (roles,
|
||||
// recognized stack, and published projects with the public metadata of their verified repositories).
|
||||
// The search never calls the ML service: vectors are computed in the background after a change, and an
|
||||
// entry whose vectors are missing, stale for the current model, or not computed because ML is
|
||||
// unavailable uses the neutral 0.5 and names `ml_unavailable` in `unknown_flags`. `semantic_evidence`
|
||||
// lists, for a need search, the confirmed requirements whose closest published card item reaches a
|
||||
// similarity band of the versioned policy; it names a project only by the title that the candidate
|
||||
// published with the `projects` card field and says whether its repository is a verified public one,
|
||||
// never the repository address or owner. Showing a project title records the `projects` field in the
|
||||
// candidate's access history. For fewer than 30 comparable real candidates, the search uses neutral T
|
||||
// = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of
|
||||
// a category reaches the minimum, the percentile is still not computed (the organization-safe
|
||||
// projection carries no theta), T stays the neutral 0.5, the percentile stays null, and
|
||||
// `unknown_flags` names `percentile_not_computed`; the search does not fail.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account
|
||||
// answers 403 forbidden; an unknown organization or account without active membership answers 404
|
||||
|
||||
@@ -396,6 +396,42 @@ func (s *AnonymousCardContent) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Projects == nil {
|
||||
return nil // null
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(s.Projects)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s.Projects {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "projects",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
@@ -5687,6 +5723,42 @@ func (s *CandidateProfile) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Projects == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(s.Projects)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s.Projects {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "projects",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Terms.Validate(); err != nil {
|
||||
return err
|
||||
@@ -6000,6 +6072,42 @@ func (s *CandidateProfileUpdate) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Projects == nil {
|
||||
return nil // optional
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(s.Projects)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s.Projects {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "projects",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Terms.Validate(); err != nil {
|
||||
return err
|
||||
@@ -6454,6 +6562,8 @@ func (s CardField) Validate() error {
|
||||
return nil
|
||||
case "work_formats":
|
||||
return nil
|
||||
case "projects":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
@@ -6467,7 +6577,7 @@ func (s CardFieldSet) Validate() error {
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 9,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(alias)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
@@ -6599,6 +6709,107 @@ func (s *CardPreviewHeaders) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *CardProject) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 100,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(s.Title)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "title",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.Description.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 500,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "description",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if s.Stack == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(s.Stack)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range s.Stack {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "stack",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *CardSelfAssessment) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
@@ -12275,6 +12486,17 @@ func (s *MatchConfirmedCandidate) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.SemanticEvidence.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "semantic_evidence",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Components.Validate(); err != nil {
|
||||
return err
|
||||
@@ -12713,6 +12935,19 @@ func (s MatchPublicStack) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MatchRequirementKind) Validate() error {
|
||||
switch s {
|
||||
case "required_skill":
|
||||
return nil
|
||||
case "desired_skill":
|
||||
return nil
|
||||
case "task":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s MatchScore) Validate() error {
|
||||
alias := (float64)(s)
|
||||
if err := (validate.Float{
|
||||
@@ -13322,6 +13557,161 @@ func (s MatchSearchStackTag) Validate() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MatchSemanticEvidence) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := s.RequirementKind.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "requirement_kind",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 300,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(s.RequirementText)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "requirement_text",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.ItemKind.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "item_kind",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.ProjectTitle.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 100,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "project_title",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Similarity.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "similarity",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MatchSemanticEvidenceList) Validate() error {
|
||||
alias := ([]MatchSemanticEvidence)(s)
|
||||
if alias == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 12,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(alias)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range alias {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s MatchSemanticItemKind) Validate() error {
|
||||
switch s {
|
||||
case "project":
|
||||
return nil
|
||||
case "stack":
|
||||
return nil
|
||||
case "roles":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s MatchSimilarityBand) Validate() error {
|
||||
switch s {
|
||||
case "high":
|
||||
return nil
|
||||
case "medium":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s MatchStrength) Validate() error {
|
||||
switch s {
|
||||
case "standard":
|
||||
@@ -13412,6 +13802,17 @@ func (s *MatchUnconfirmedCandidate) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.SemanticEvidence.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "semantic_evidence",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Components.Validate(); err != nil {
|
||||
return err
|
||||
@@ -19485,6 +19886,8 @@ func (s ProblemCode) Validate() error {
|
||||
return nil
|
||||
case "not_implemented":
|
||||
return nil
|
||||
case "service_unavailable":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
@@ -20803,6 +21206,270 @@ func (s *ProfilePhoneInput) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ProfileProjectDescription) Validate() error {
|
||||
alias := (string)(s)
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 500,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(alias)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileProjectItem) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := s.Title.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "title",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.Description.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "description",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Stack.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "stack",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.RepositoryURL.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "repository_url",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.RepositoryCheck.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "repository_check",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Status.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "status",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Source.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "source",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileProjectItemInput) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := s.Title.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "title",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.Description.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "description",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Stack.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "stack",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.RepositoryURL.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := value.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "repository_url",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Status.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "status",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ProfileProjectStack) Validate() error {
|
||||
alias := ([]StackTag)(s)
|
||||
if alias == nil {
|
||||
return errors.New("nil is invalid value")
|
||||
}
|
||||
if err := (validate.Array{
|
||||
MinLength: 0,
|
||||
MinLengthSet: false,
|
||||
MaxLength: 10,
|
||||
MaxLengthSet: true,
|
||||
}).ValidateLength(len(alias)); err != nil {
|
||||
return errors.Wrap(err, "array")
|
||||
}
|
||||
var failures []validate.FieldError
|
||||
for i, elem := range alias {
|
||||
if err := func() error {
|
||||
if err := elem.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: fmt.Sprintf("[%d]", i),
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ProfileProjectTitle) Validate() error {
|
||||
alias := (string)(s)
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 100,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^\\S(?:.*\\S)?$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(alias)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileRelocationClaim) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
@@ -20867,6 +21534,131 @@ func (s *ProfileRelocationInput) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileRepositoryCheck) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := s.State.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "state",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileRepositoryCheckRequest) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 0,
|
||||
MaxSet: true,
|
||||
Max: 10,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
Pattern: nil,
|
||||
}).Validate(int64(s.Scheduled)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "scheduled",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileRepositoryCheckRequestHeaders) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if err := s.CacheControl.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "CacheControl",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if err := s.Response.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "Response",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if len(failures) > 0 {
|
||||
return &validate.Error{Fields: failures}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s ProfileRepositoryCheckState) Validate() error {
|
||||
switch s {
|
||||
case "pending":
|
||||
return nil
|
||||
case "verified":
|
||||
return nil
|
||||
case "not_found":
|
||||
return nil
|
||||
case "unavailable":
|
||||
return nil
|
||||
default:
|
||||
return errors.Errorf("invalid value: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
func (s ProfileRepositoryUrl) Validate() error {
|
||||
alias := (string)(s)
|
||||
if err := (validate.String{
|
||||
MinLength: 22,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 160,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^https://github\\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(alias)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ProfileRoleItem) Validate() error {
|
||||
if s == nil {
|
||||
return validate.ErrNilPointer
|
||||
@@ -22099,6 +22891,22 @@ func (s *RequestMyAccountDeletionUnauthorized) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *RequestMyRepositoryChecksForbidden) Validate() error {
|
||||
alias := (*Problem)(s)
|
||||
if err := alias.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *RequestMyRepositoryChecksUnauthorized) Validate() error {
|
||||
alias := (*Problem)(s)
|
||||
if err := alias.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ResendEmailVerificationBadRequest) Validate() error {
|
||||
alias := (*Problem)(s)
|
||||
if err := alias.Validate(); err != nil {
|
||||
|
||||
@@ -33,7 +33,7 @@ var (
|
||||
hiddenSchemas = []string{"HiddenOrganization", "HiddenOrganizationList", "PrivacyOrganization"}
|
||||
privacyOnlySchemas = []string{
|
||||
"PrivacySettings", "CardPreview", "AnonymousCardContent", "CardCategory", "CardCategoryStrength", "CardSelfAssessment",
|
||||
"CardSelfAssessmentConfirmationStatus",
|
||||
"CardSelfAssessmentConfirmationStatus", "CardProject",
|
||||
"CandidateExperienceBand", "CandidateWorkFormat", "CandidateSalaryCompatibility",
|
||||
"PrivacyEvent", "PrivacyEventKind", "PrivacyEventList", "CardAccess", "CardAccessKind", "CardAccessList",
|
||||
}
|
||||
@@ -218,14 +218,14 @@ func TestPublicationAndSearchStatusAreNotConsents(t *testing.T) {
|
||||
fields := enumValues(t, resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/CardField"}))
|
||||
want := []string{
|
||||
"categories", "stack", "experience", "soft_skills", "location", "relocation",
|
||||
"self_assessment", "work_formats", "salary_compatibility",
|
||||
"self_assessment", "work_formats", "salary_compatibility", "projects",
|
||||
}
|
||||
slices.Sort(fields)
|
||||
slices.Sort(want)
|
||||
if !slices.Equal(fields, want) {
|
||||
t.Errorf("CardField = %v, want %v", fields, want)
|
||||
}
|
||||
if update := spec.Components.Schemas["CardFieldSet"]; update.UniqueItems != true || update.MaxItems == nil || *update.MaxItems != 9 {
|
||||
if update := spec.Components.Schemas["CardFieldSet"]; update.UniqueItems != true || update.MaxItems == nil || *update.MaxItems != 10 {
|
||||
t.Error("CardFieldSet must hold distinct items and at most one per field")
|
||||
}
|
||||
status := enumValues(t, resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/SearchStatusValue"}))
|
||||
@@ -246,7 +246,7 @@ func TestAnonymousCardReachesNoProfileOrContactSchema(t *testing.T) {
|
||||
t.Fatal("the contract has no AnonymousCardContent")
|
||||
}
|
||||
if got, want := propertyNames(card), []string{
|
||||
"categories", "experience_band", "pseudonym", "salary_compatibility", "self_assessment", "stack", "work_formats",
|
||||
"categories", "experience_band", "projects", "pseudonym", "salary_compatibility", "self_assessment", "stack", "work_formats",
|
||||
}; !slices.Equal(got, want) {
|
||||
t.Errorf("AnonymousCardContent properties = %v, want %v", got, want)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func TestAnonymousCardReachesNoProfileOrContactSchema(t *testing.T) {
|
||||
allowed := slices.Concat([]string{
|
||||
"AnonymousCardContent", "CardCategory", "CardCategoryStrength", "CardSelfAssessment", "CardSelfAssessmentConfirmationStatus", "CandidateExperienceBand", "CandidateWorkFormat",
|
||||
"CandidateSalaryCompatibility", "CardField", "CardFieldSet", "PublicationState", "SpecializationCode",
|
||||
"GradeCode", "StackTag", "Timestamp", "CardPreview",
|
||||
"GradeCode", "StackTag", "Timestamp", "CardPreview", "CardProject",
|
||||
}, previewEvidenceSchemas)
|
||||
for _, name := range []string{"AnonymousCardContent", "CardPreview"} {
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, spec.Components.Schemas[name])) {
|
||||
@@ -323,7 +323,7 @@ func TestAnonymousCardReachesNoProfileOrContactSchema(t *testing.T) {
|
||||
slices.Contains([]string{
|
||||
"AnonymousCardContent", "CardCategory", "CardCategoryStrength", "CardSelfAssessment",
|
||||
"CardSelfAssessmentConfirmationStatus", "CandidateExperienceBand", "CandidateWorkFormat",
|
||||
"CandidateSalaryCompatibility",
|
||||
"CandidateSalaryCompatibility", "CardProject",
|
||||
}, reached) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func TestCandidateProfileSeparatesSelfAssessedGradeFromConfirmedCategory(t *test
|
||||
t.Error("the profile does not state confirmed categories apart from the claims")
|
||||
}
|
||||
update := resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/CandidateProfileUpdate"})
|
||||
wantUpdate := []string{"confirmed_parallel_periods", "contacts", "expected_version", "experience", "full_name", "roles", "soft_skills", "stack", "terms"}
|
||||
wantUpdate := []string{"confirmed_parallel_periods", "contacts", "expected_version", "experience", "full_name", "projects", "roles", "soft_skills", "stack", "terms"}
|
||||
if got := propertyNames(update); !slices.Equal(got, wantUpdate) {
|
||||
t.Errorf("CandidateProfileUpdate properties = %v, want %v", got, wantUpdate)
|
||||
}
|
||||
|
||||
@@ -128,6 +128,11 @@ var definitions = map[api.ProblemCode]definition{
|
||||
title: "Operation not implemented",
|
||||
detail: "This operation is not available yet.",
|
||||
},
|
||||
api.ProblemCodeServiceUnavailable: {
|
||||
status: http.StatusServiceUnavailable,
|
||||
title: "Service unavailable",
|
||||
detail: "The service cannot serve the request now. Retry later.",
|
||||
},
|
||||
}
|
||||
|
||||
// New returns the problem response for code with its fixed status, title,
|
||||
|
||||
@@ -219,6 +219,7 @@ func matchConfirmedCandidate(entry matching.Entry) api.MatchConfirmedCandidate {
|
||||
ConfirmationStatus: api.MatchConfirmedCandidateConfirmationStatusConfirmed,
|
||||
PublicContext: matchPublicContext(entry.PublicContext),
|
||||
EvidenceSummary: matchEvidenceSummary(entry.EvidenceSummary),
|
||||
SemanticEvidence: matchSemanticEvidence(entry.SemanticEvidence),
|
||||
UnknownFlags: matchUnknownFlags(entry.UnknownFlags),
|
||||
}
|
||||
candidate.DeclaredGrade = matchDeclaredGrade(entry.DeclaredGrade)
|
||||
@@ -251,6 +252,7 @@ func matchUnconfirmedCandidate(entry matching.Entry) api.MatchUnconfirmedCandida
|
||||
DeclaredGrade: matchDeclaredGrade(entry.DeclaredGrade),
|
||||
PublicContext: matchPublicContext(entry.PublicContext),
|
||||
EvidenceSummary: matchEvidenceSummary(entry.EvidenceSummary),
|
||||
SemanticEvidence: matchSemanticEvidence(entry.SemanticEvidence),
|
||||
Components: api.MatchUnconfirmedComponents{Fit: entry.Components.Fit, Coverage: entry.Components.Coverage},
|
||||
UnknownFlags: matchUnknownFlags(entry.UnknownFlags),
|
||||
}
|
||||
@@ -300,6 +302,24 @@ func matchEvidenceSummary(items []matching.EvidenceItem) api.MatchEvidenceSummar
|
||||
return summary
|
||||
}
|
||||
|
||||
// matchSemanticEvidence maps the computed explanation. The list is never
|
||||
// null, so a client tells "nothing to explain" from a missing field.
|
||||
func matchSemanticEvidence(items []matching.SemanticEvidence) api.MatchSemanticEvidenceList {
|
||||
evidence := make(api.MatchSemanticEvidenceList, 0, len(items))
|
||||
for _, item := range items {
|
||||
title := api.NilString{Null: true}
|
||||
if item.ProjectTitle != nil {
|
||||
title = api.NewNilString(*item.ProjectTitle)
|
||||
}
|
||||
evidence = append(evidence, api.MatchSemanticEvidence{
|
||||
RequirementKind: api.MatchRequirementKind(item.RequirementKind), RequirementText: item.RequirementText,
|
||||
ItemKind: api.MatchSemanticItemKind(item.ItemKind), ProjectTitle: title,
|
||||
RepositoryVerified: item.RepositoryVerified, Similarity: api.MatchSimilarityBand(item.Similarity),
|
||||
})
|
||||
}
|
||||
return evidence
|
||||
}
|
||||
|
||||
func matchUnknownFlags(flags []matching.UnknownFlag) api.MatchUnknownFlags {
|
||||
response := make(api.MatchUnknownFlags, 0, len(flags))
|
||||
for _, flag := range flags {
|
||||
|
||||
@@ -112,7 +112,7 @@ func TestSearchOrganizationMatchesMapsANeedRequestAndKeepsUnconfirmedEntriesStri
|
||||
}
|
||||
want := `[{"candidate_handle":"` + handle + `","specialization":"network_engineer","confirmation_status":"unconfirmed","declared_grade":"junior",` +
|
||||
`"category":null,"strength":null,"public_context":{"stack":null,"experience_band":null,"work_formats":null,"salary_compatibility":null},` +
|
||||
`"evidence_summary":[{"code":"declared_grade","state":"declared_only"}],"components":{"fit":0.3125,"coverage":0.25},` +
|
||||
`"evidence_summary":[{"code":"declared_grade","state":"declared_only"}],"semantic_evidence":[],"components":{"fit":0.3125,"coverage":0.25},` +
|
||||
`"unknown_flags":[{"component":"assessment","reason":"no_confirmation_for_specialization"}]}]`
|
||||
if string(encoded) != want {
|
||||
t.Fatalf("unconfirmed entries = %s\nwant %s", encoded, want)
|
||||
|
||||
@@ -565,6 +565,19 @@ func anonymousCardResponse(view domain.AnonymousCandidateViewDTO) api.AnonymousC
|
||||
if view.SalaryCompatibility != nil {
|
||||
content.SalaryCompatibility.SetTo(api.CandidateSalaryCompatibility(*view.SalaryCompatibility))
|
||||
}
|
||||
for _, project := range view.Projects {
|
||||
description := api.NilString{Null: true}
|
||||
if project.Description != nil {
|
||||
description.SetTo(*project.Description)
|
||||
}
|
||||
stack := make([]api.StackTag, 0, len(project.Stack))
|
||||
for _, tag := range project.Stack {
|
||||
stack = append(stack, api.StackTag(tag))
|
||||
}
|
||||
content.Projects = append(content.Projects, api.CardProject{
|
||||
Title: project.Title, Description: description, Stack: stack, RepositoryVerified: project.RepositoryVerified,
|
||||
})
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package v1
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
type ProfileOperations interface {
|
||||
GetMyProfile(ctx context.Context, userID uuid.UUID) (profile.View, error)
|
||||
SaveMyProfile(ctx context.Context, userID uuid.UUID, expectedVersion int64, input domain.CandidateProfileInput) (profile.View, error)
|
||||
RequestRepositoryChecks(ctx context.Context, userID uuid.UUID) (int, error)
|
||||
}
|
||||
|
||||
// ProfileHandler serves the candidate's own profile operations.
|
||||
@@ -46,6 +48,39 @@ func (handler *Handler) SaveMyProfile(ctx context.Context, request *api.Candidat
|
||||
return handler.profile.SaveMyProfile(ctx, request)
|
||||
}
|
||||
|
||||
func (handler *Handler) RequestMyRepositoryChecks(ctx context.Context) (api.RequestMyRepositoryChecksRes, error) {
|
||||
if handler.profile == nil {
|
||||
return handler.UnimplementedHandler.RequestMyRepositoryChecks(ctx)
|
||||
}
|
||||
return handler.profile.RequestMyRepositoryChecks(ctx)
|
||||
}
|
||||
|
||||
// RequestMyRepositoryChecks schedules new checks of the linked repositories.
|
||||
func (handler *ProfileHandler) RequestMyRepositoryChecks(ctx context.Context) (api.RequestMyRepositoryChecksRes, error) {
|
||||
principal, ok := PrincipalFromContext(ctx)
|
||||
if !ok {
|
||||
return (*api.RequestMyRepositoryChecksUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
|
||||
}
|
||||
scheduled, err := handler.operations.RequestRepositoryChecks(ctx, principal.UserID)
|
||||
if err != nil {
|
||||
if limit, ok := errors.AsType[*profile.RepositoryCheckLimitError](err); ok {
|
||||
return problem.RateLimited(ctx, int32(math.Ceil(limit.RetryAfter.Seconds()))), nil
|
||||
}
|
||||
switch {
|
||||
case errors.Is(err, profile.ErrForbidden), errors.Is(err, profile.ErrEmailNotVerified):
|
||||
return (*api.RequestMyRepositoryChecksForbidden)(&problem.New(ctx, api.ProblemCodeForbidden).Response), nil
|
||||
case errors.Is(err, outbound.ErrUserNotFound):
|
||||
return (*api.RequestMyRepositoryChecksUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &api.ProfileRepositoryCheckRequestHeaders{
|
||||
CacheControl: api.CacheControlNoStoreNoStore,
|
||||
Response: api.ProfileRepositoryCheckRequest{Scheduled: int32(scheduled)}, //nolint:gosec // at most ten projects
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (handler *ProfileHandler) GetMyProfile(ctx context.Context) (api.GetMyProfileRes, error) {
|
||||
principal, ok := PrincipalFromContext(ctx)
|
||||
if !ok {
|
||||
@@ -167,6 +202,7 @@ func candidateProfileInput(request *api.CandidateProfileUpdate) domain.Candidate
|
||||
for _, item := range request.SoftSkills {
|
||||
input.SoftSkills = append(input.SoftSkills, domain.ProfileClaimInput[string]{Value: string(item.Skill), Status: domain.ProfileClaimStatus(item.Status)})
|
||||
}
|
||||
input.Projects = projectInputs(request.Projects)
|
||||
if value, ok := request.Terms.Location.Get(); ok {
|
||||
input.Location = profileStringInput(string(value.Value), value.Status)
|
||||
}
|
||||
@@ -277,6 +313,7 @@ func candidateProfileResponse(view profile.View) api.CandidateProfile {
|
||||
Skill: api.ProfileSoftSkill(item.Value()), Status: api.ProfileItemStatus(item.Status()), Source: profileClaimSourceResponse(item.Source()),
|
||||
})
|
||||
}
|
||||
response.Projects = projectResponses(content, view.RepositoryChecks)
|
||||
response.Terms = candidateProfileTerms(content)
|
||||
updatedAt := api.NilTimestamp{}
|
||||
if saved.UpdatedAt().IsZero() {
|
||||
@@ -289,6 +326,75 @@ func candidateProfileResponse(view profile.View) api.CandidateProfile {
|
||||
return response
|
||||
}
|
||||
|
||||
// projectInputs maps the request projects. An absent list keeps the stored
|
||||
// projects and maps to nil; an empty one clears them.
|
||||
func projectInputs(items []api.ProfileProjectItemInput) *[]domain.ProfileClaimInput[domain.ProfileProject] {
|
||||
if items == nil {
|
||||
return nil
|
||||
}
|
||||
projects := make([]domain.ProfileClaimInput[domain.ProfileProject], 0, len(items))
|
||||
for _, item := range items {
|
||||
description := ""
|
||||
if value, ok := item.Description.Get(); ok {
|
||||
description = string(value)
|
||||
}
|
||||
repository := ""
|
||||
if value, ok := item.RepositoryURL.Get(); ok {
|
||||
repository = string(value)
|
||||
}
|
||||
stack := make([]string, 0, len(item.Stack))
|
||||
for _, tag := range item.Stack {
|
||||
stack = append(stack, string(tag))
|
||||
}
|
||||
projects = append(projects, domain.ProfileClaimInput[domain.ProfileProject]{
|
||||
Value: domain.NewProfileProject(string(item.Title), description, stack, repository),
|
||||
Status: domain.ProfileClaimStatus(item.Status),
|
||||
})
|
||||
}
|
||||
return &projects
|
||||
}
|
||||
|
||||
func projectResponses(content domain.CandidateProfileContent, checks map[string]outbound.RepositoryCheck) []api.ProfileProjectItem {
|
||||
projects := make([]api.ProfileProjectItem, 0, len(content.Projects()))
|
||||
for _, item := range content.Projects() {
|
||||
projects = append(projects, profileProjectResponse(item, checks))
|
||||
}
|
||||
return projects
|
||||
}
|
||||
|
||||
// profileProjectResponse maps one project with the state of its repository
|
||||
// check. A linked repository without a stored check is pending.
|
||||
func profileProjectResponse(item domain.ProfileClaim[domain.ProfileProject], checks map[string]outbound.RepositoryCheck) api.ProfileProjectItem {
|
||||
value := item.Value()
|
||||
description := api.NilProfileProjectDescription{Null: true}
|
||||
if value.Description != "" {
|
||||
description.SetTo(api.ProfileProjectDescription(value.Description))
|
||||
}
|
||||
stack := make(api.ProfileProjectStack, 0, len(value.StackTags()))
|
||||
for _, tag := range value.StackTags() {
|
||||
stack = append(stack, api.StackTag(tag))
|
||||
}
|
||||
project := api.ProfileProjectItem{
|
||||
Title: api.ProfileProjectTitle(value.Title), Description: description, Stack: stack,
|
||||
RepositoryURL: api.NilProfileRepositoryUrl{Null: true}, RepositoryCheck: api.NilProfileRepositoryCheck{Null: true},
|
||||
Status: api.ProfileItemStatus(item.Status()), Source: profileClaimSourceResponse(item.Source()),
|
||||
}
|
||||
repository, linked := value.Repository()
|
||||
if !linked {
|
||||
return project
|
||||
}
|
||||
project.RepositoryURL.SetTo(api.ProfileRepositoryUrl(repository.URL()))
|
||||
check := api.ProfileRepositoryCheck{State: api.ProfileRepositoryCheckStatePending, CheckedAt: api.NilTimestamp{Null: true}}
|
||||
if stored, ok := checks[repository.Key()]; ok {
|
||||
check.State = api.ProfileRepositoryCheckState(stored.State)
|
||||
if !stored.CheckedAt.IsZero() {
|
||||
check.CheckedAt.SetTo(api.Timestamp(stored.CheckedAt))
|
||||
}
|
||||
}
|
||||
project.RepositoryCheck.SetTo(check)
|
||||
return project
|
||||
}
|
||||
|
||||
// confirmedCategoriesResponse maps the categories in their stored order. The
|
||||
// result is never nil, so a profile without categories encodes as an empty list.
|
||||
func confirmedCategoriesResponse(categories []domain.CandidateAssessmentCategory) []api.ProfileConfirmedCategory {
|
||||
|
||||
Reference in new issue
Block a user