feat: scaffold go backend foundation
This commit is contained in:
@@ -8,13 +8,13 @@ interview-ready after each short practice loop.
|
|||||||
|
|
||||||
### Backend and Workflow
|
### Backend and Workflow
|
||||||
|
|
||||||
- [ ] **BACK-01**: Backend service is implemented in Go.
|
- [x] **BACK-01**: Backend service is implemented in Go.
|
||||||
- [ ] **BACK-02**: Backend exposes typed interfaces for tutor workflows.
|
- [x] **BACK-02**: Backend exposes typed interfaces for tutor workflows.
|
||||||
- [ ] **BACK-03**: Backend integrates internalized `agent-farm-go` workflow
|
- [x] **BACK-03**: Backend integrates internalized `agent-farm-go` workflow
|
||||||
patterns without ad hoc handler shellouts.
|
patterns without ad hoc handler shellouts.
|
||||||
- [ ] **BACK-04**: Workflow LLM execution uses `third-one` with configurable
|
- [x] **BACK-04**: Workflow LLM execution uses `third-one` with configurable
|
||||||
runtime and default `deepseek-v4-flash`.
|
runtime and default `deepseek-v4-flash`.
|
||||||
- [ ] **BACK-05**: Manually authored source files stay at or below 600 lines.
|
- [x] **BACK-05**: Manually authored source files stay at or below 600 lines.
|
||||||
|
|
||||||
### Interview Practice
|
### Interview Practice
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ interview-ready after each short practice loop.
|
|||||||
|
|
||||||
| Requirement | Phase | Status |
|
| Requirement | Phase | Status |
|
||||||
|-------------|-------|--------|
|
|-------------|-------|--------|
|
||||||
| BACK-01..BACK-05 | Phase 1 | Pending |
|
| BACK-01..BACK-05 | Phase 1 | Complete |
|
||||||
| INT-01..INT-06 | Phase 2 | Pending |
|
| INT-01..INT-06 | Phase 2 | Pending |
|
||||||
| MEM-01..MEM-05 | Phase 3 | Pending |
|
| MEM-01..MEM-05 | Phase 3 | Pending |
|
||||||
| PROG-01..PROG-05 | Phase 4 | Pending |
|
| PROG-01..PROG-05 | Phase 4 | Pending |
|
||||||
@@ -108,4 +108,4 @@ interview-ready after each short practice loop.
|
|||||||
|
|
||||||
---
|
---
|
||||||
*Requirements defined: 2026-04-26*
|
*Requirements defined: 2026-04-26*
|
||||||
*Last updated: 2026-04-26 after Go backend direction was locked.*
|
*Last updated: 2026-04-26 after Phase 1 execution.*
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ See: `.planning/PROJECT.md` (updated 2026-04-26)
|
|||||||
**Core value:** The user should feel and prove that they are becoming more
|
**Core value:** The user should feel and prove that they are becoming more
|
||||||
interview-ready after each short practice loop.
|
interview-ready after each short practice loop.
|
||||||
|
|
||||||
**Current focus:** Phase 1: Go Backend Foundation and Workflow Boundary.
|
**Current focus:** Phase 2 planning: Diagnostic Interview Loop.
|
||||||
|
|
||||||
## Current Decisions
|
## Current Decisions
|
||||||
|
|
||||||
@@ -21,13 +21,15 @@ interview-ready after each short practice loop.
|
|||||||
- OpenSpec is the intent/requirements source of truth.
|
- OpenSpec is the intent/requirements source of truth.
|
||||||
- First interview track is Backend Developer Interview.
|
- First interview track is Backend Developer Interview.
|
||||||
- Phase 1 has context, research, and plan artifacts.
|
- Phase 1 has context, research, and plan artifacts.
|
||||||
|
- Phase 1 Go backend scaffold is implemented and verified.
|
||||||
|
|
||||||
## Next Actions
|
## Next Actions
|
||||||
|
|
||||||
1. Execute Phase 1 Go backend foundation plan.
|
1. Plan Phase 2 diagnostic interview loop with GSD.
|
||||||
2. Keep `docs/planning/WORKFLOW_CONTRACTS.md` aligned with Go structs during
|
2. Keep `docs/planning/WORKFLOW_CONTRACTS.md` aligned with Go structs during
|
||||||
implementation.
|
future workflow implementation.
|
||||||
3. After Phase 1, plan Phase 2 diagnostic interview loop.
|
3. Decide whether Phase 2 starts with in-memory diagnostic sessions or a small
|
||||||
|
persistence boundary.
|
||||||
|
|
||||||
## Validation Log
|
## Validation Log
|
||||||
|
|
||||||
@@ -35,6 +37,9 @@ interview-ready after each short practice loop.
|
|||||||
before GSD planning docs were created.
|
before GSD planning docs were created.
|
||||||
- 2026-04-26: First track, workflow contracts, and Phase 1 GSD plan were
|
- 2026-04-26: First track, workflow contracts, and Phase 1 GSD plan were
|
||||||
created.
|
created.
|
||||||
|
- 2026-04-26: Phase 1 implementation verified with `go test ./...`,
|
||||||
|
`openspec validate bootstrap-job-tutor-platform --strict`, and Go source
|
||||||
|
line-count check.
|
||||||
|
|
||||||
---
|
---
|
||||||
*State initialized: 2026-04-26.*
|
*State initialized: 2026-04-26.*
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Phase 1 Summary
|
||||||
|
|
||||||
|
**Status:** Complete
|
||||||
|
**Completed:** 2026-04-26
|
||||||
|
|
||||||
|
## Delivered
|
||||||
|
|
||||||
|
- Initialized Go backend module.
|
||||||
|
- Added `cmd/tutor-api` entrypoint.
|
||||||
|
- Added app assembly package.
|
||||||
|
- Added environment-backed config with defaults for:
|
||||||
|
- HTTP address
|
||||||
|
- environment
|
||||||
|
- workflow runtime path
|
||||||
|
- model key defaulting to `deepseek-v4-flash`
|
||||||
|
- third-one binary path
|
||||||
|
- Added HTTP health endpoint at `GET /healthz`.
|
||||||
|
- Added typed workflow boundary and stub runner.
|
||||||
|
- Added tests for config, health endpoint, and workflow stub behavior.
|
||||||
|
- Updated `AGENTS.md` with concrete Go validation commands.
|
||||||
|
|
||||||
|
## Files Added
|
||||||
|
|
||||||
|
- `go.mod`
|
||||||
|
- `cmd/tutor-api/main.go`
|
||||||
|
- `internal/app/server.go`
|
||||||
|
- `internal/config/config.go`
|
||||||
|
- `internal/config/config_test.go`
|
||||||
|
- `internal/httpapi/handler.go`
|
||||||
|
- `internal/httpapi/handler_test.go`
|
||||||
|
- `internal/workflows/contracts.go`
|
||||||
|
- `internal/workflows/runner.go`
|
||||||
|
- `internal/workflows/runner_test.go`
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
gofmt -w cmd internal
|
||||||
|
go test ./...
|
||||||
|
openspec validate bootstrap-job-tutor-platform --strict
|
||||||
|
```
|
||||||
|
|
||||||
|
All checks passed.
|
||||||
|
|
||||||
|
Go source line-count check passed; no manually authored Go file exceeds 600
|
||||||
|
lines.
|
||||||
|
|
||||||
|
## Deferred
|
||||||
|
|
||||||
|
- Real diagnostic interview workflow execution.
|
||||||
|
- Persistence.
|
||||||
|
- Auth.
|
||||||
|
- Live third-one execution.
|
||||||
|
- Frontend.
|
||||||
|
- Ontology and asset generation.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Phase 1 Verification
|
||||||
|
|
||||||
|
## Verdict
|
||||||
|
|
||||||
|
PASS
|
||||||
|
|
||||||
|
## Requirement Coverage
|
||||||
|
|
||||||
|
- BACK-01: PASS. Go module and backend entrypoint exist.
|
||||||
|
- BACK-02: PASS. `internal/workflows` exposes typed contracts and runner
|
||||||
|
interface.
|
||||||
|
- BACK-03: PASS. HTTP handler receives a workflow runner dependency and does
|
||||||
|
not shell out.
|
||||||
|
- BACK-04: PASS. Config includes workflow runtime, model key, and third-one
|
||||||
|
binary path. Default model key is `deepseek-v4-flash`.
|
||||||
|
- BACK-05: PASS. Go source files are all under 600 lines.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
- `go test ./...` passed.
|
||||||
|
- `openspec validate bootstrap-job-tutor-platform --strict` passed.
|
||||||
|
- Go line-count check passed.
|
||||||
|
|
||||||
|
## Residual Risk
|
||||||
|
|
||||||
|
The workflow runner is intentionally a stub. Real internalized `agent-farm-go`
|
||||||
|
execution belongs to a later phase when diagnostic and grading behavior are
|
||||||
|
implemented.
|
||||||
12
AGENTS.md
12
AGENTS.md
@@ -56,5 +56,13 @@ For planning/spec-only changes, run:
|
|||||||
openspec validate bootstrap-job-tutor-platform --strict
|
openspec validate bootstrap-job-tutor-platform --strict
|
||||||
```
|
```
|
||||||
|
|
||||||
For future code changes, add project-specific build and test commands here once
|
For Go backend changes, run:
|
||||||
the implementation stack is initialized.
|
|
||||||
|
```powershell
|
||||||
|
gofmt -w cmd internal
|
||||||
|
go test ./...
|
||||||
|
openspec validate bootstrap-job-tutor-platform --strict
|
||||||
|
```
|
||||||
|
|
||||||
|
Before completing implementation work, confirm manually authored Go files stay
|
||||||
|
at or below 600 lines.
|
||||||
|
|||||||
45
cmd/tutor-api/main.go
Normal file
45
cmd/tutor-api/main.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"tutor/internal/app"
|
||||||
|
"tutor/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cfg := config.LoadFromEnv()
|
||||||
|
server := app.NewServer(cfg)
|
||||||
|
|
||||||
|
errs := make(chan error, 1)
|
||||||
|
go func() {
|
||||||
|
log.Printf("starting tutor-api on %s", cfg.HTTPAddr)
|
||||||
|
errs <- server.ListenAndServe()
|
||||||
|
}()
|
||||||
|
|
||||||
|
stop := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case sig := <-stop:
|
||||||
|
log.Printf("received signal %s; shutting down", sig)
|
||||||
|
case err := <-errs:
|
||||||
|
if err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
|
log.Fatalf("server error: %v", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
if err := server.Shutdown(ctx); err != nil {
|
||||||
|
log.Fatalf("shutdown error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
19
internal/app/server.go
Normal file
19
internal/app/server.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"tutor/internal/config"
|
||||||
|
"tutor/internal/httpapi"
|
||||||
|
"tutor/internal/workflows"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewServer(cfg config.Config) *http.Server {
|
||||||
|
runner := workflows.NewStubRunner()
|
||||||
|
handler := httpapi.NewHandler(cfg, runner)
|
||||||
|
|
||||||
|
return &http.Server{
|
||||||
|
Addr: cfg.HTTPAddr,
|
||||||
|
Handler: handler.Routes(),
|
||||||
|
}
|
||||||
|
}
|
||||||
37
internal/config/config.go
Normal file
37
internal/config/config.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultHTTPAddr = ":8080"
|
||||||
|
defaultEnvironment = "development"
|
||||||
|
defaultModelKey = "deepseek-v4-flash"
|
||||||
|
defaultThirdOneBin = "thirdone"
|
||||||
|
defaultWorkflowRuntime = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
HTTPAddr string
|
||||||
|
Environment string
|
||||||
|
WorkflowRuntime string
|
||||||
|
ModelKey string
|
||||||
|
ThirdOneBin string
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadFromEnv() Config {
|
||||||
|
return Config{
|
||||||
|
HTTPAddr: envOrDefault("TUTOR_HTTP_ADDR", defaultHTTPAddr),
|
||||||
|
Environment: envOrDefault("TUTOR_ENV", defaultEnvironment),
|
||||||
|
WorkflowRuntime: envOrDefault("TUTOR_WORKFLOW_RUNTIME", defaultWorkflowRuntime),
|
||||||
|
ModelKey: envOrDefault("TUTOR_MODEL_KEY", defaultModelKey),
|
||||||
|
ThirdOneBin: envOrDefault("THIRDONE_BIN", defaultThirdOneBin),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func envOrDefault(key string, fallback string) string {
|
||||||
|
value := os.Getenv(key)
|
||||||
|
if value == "" {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
52
internal/config/config_test.go
Normal file
52
internal/config/config_test.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestLoadFromEnvDefaults(t *testing.T) {
|
||||||
|
t.Setenv("TUTOR_HTTP_ADDR", "")
|
||||||
|
t.Setenv("TUTOR_ENV", "")
|
||||||
|
t.Setenv("TUTOR_WORKFLOW_RUNTIME", "")
|
||||||
|
t.Setenv("TUTOR_MODEL_KEY", "")
|
||||||
|
t.Setenv("THIRDONE_BIN", "")
|
||||||
|
|
||||||
|
cfg := LoadFromEnv()
|
||||||
|
|
||||||
|
if cfg.HTTPAddr != defaultHTTPAddr {
|
||||||
|
t.Fatalf("HTTPAddr = %q, want %q", cfg.HTTPAddr, defaultHTTPAddr)
|
||||||
|
}
|
||||||
|
if cfg.Environment != defaultEnvironment {
|
||||||
|
t.Fatalf("Environment = %q, want %q", cfg.Environment, defaultEnvironment)
|
||||||
|
}
|
||||||
|
if cfg.ModelKey != defaultModelKey {
|
||||||
|
t.Fatalf("ModelKey = %q, want %q", cfg.ModelKey, defaultModelKey)
|
||||||
|
}
|
||||||
|
if cfg.ThirdOneBin != defaultThirdOneBin {
|
||||||
|
t.Fatalf("ThirdOneBin = %q, want %q", cfg.ThirdOneBin, defaultThirdOneBin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadFromEnvOverrides(t *testing.T) {
|
||||||
|
t.Setenv("TUTOR_HTTP_ADDR", ":9090")
|
||||||
|
t.Setenv("TUTOR_ENV", "test")
|
||||||
|
t.Setenv("TUTOR_WORKFLOW_RUNTIME", "runtime.yaml")
|
||||||
|
t.Setenv("TUTOR_MODEL_KEY", "other-model")
|
||||||
|
t.Setenv("THIRDONE_BIN", "C:/bin/thirdone.exe")
|
||||||
|
|
||||||
|
cfg := LoadFromEnv()
|
||||||
|
|
||||||
|
if cfg.HTTPAddr != ":9090" {
|
||||||
|
t.Fatalf("HTTPAddr = %q", cfg.HTTPAddr)
|
||||||
|
}
|
||||||
|
if cfg.Environment != "test" {
|
||||||
|
t.Fatalf("Environment = %q", cfg.Environment)
|
||||||
|
}
|
||||||
|
if cfg.WorkflowRuntime != "runtime.yaml" {
|
||||||
|
t.Fatalf("WorkflowRuntime = %q", cfg.WorkflowRuntime)
|
||||||
|
}
|
||||||
|
if cfg.ModelKey != "other-model" {
|
||||||
|
t.Fatalf("ModelKey = %q", cfg.ModelKey)
|
||||||
|
}
|
||||||
|
if cfg.ThirdOneBin != "C:/bin/thirdone.exe" {
|
||||||
|
t.Fatalf("ThirdOneBin = %q", cfg.ThirdOneBin)
|
||||||
|
}
|
||||||
|
}
|
||||||
47
internal/httpapi/handler.go
Normal file
47
internal/httpapi/handler.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"tutor/internal/config"
|
||||||
|
"tutor/internal/workflows"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
cfg config.Config
|
||||||
|
runner workflows.Runner
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHandler(cfg config.Config, runner workflows.Runner) Handler {
|
||||||
|
return Handler{
|
||||||
|
cfg: cfg,
|
||||||
|
runner: runner,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h Handler) Routes() http.Handler {
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.HandleFunc("GET /healthz", h.health)
|
||||||
|
return mux
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h Handler) health(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
writeJSON(w, http.StatusOK, healthResponse{
|
||||||
|
Status: "ok",
|
||||||
|
Environment: h.cfg.Environment,
|
||||||
|
ModelKey: h.cfg.ModelKey,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type healthResponse struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Environment string `json:"environment"`
|
||||||
|
ModelKey string `json:"model_key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeJSON(w http.ResponseWriter, status int, value any) {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.WriteHeader(status)
|
||||||
|
_ = json.NewEncoder(w).Encode(value)
|
||||||
|
}
|
||||||
42
internal/httpapi/handler_test.go
Normal file
42
internal/httpapi/handler_test.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package httpapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"tutor/internal/config"
|
||||||
|
"tutor/internal/workflows"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestHealth(t *testing.T) {
|
||||||
|
cfg := config.Config{
|
||||||
|
Environment: "test",
|
||||||
|
ModelKey: "deepseek-v4-flash",
|
||||||
|
}
|
||||||
|
handler := NewHandler(cfg, workflows.NewStubRunner())
|
||||||
|
|
||||||
|
req := httptest.NewRequest(http.MethodGet, "/healthz", nil)
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
|
||||||
|
handler.Routes().ServeHTTP(rec, req)
|
||||||
|
|
||||||
|
if rec.Code != http.StatusOK {
|
||||||
|
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body healthResponse
|
||||||
|
if err := json.NewDecoder(rec.Body).Decode(&body); err != nil {
|
||||||
|
t.Fatalf("decode health response: %v", err)
|
||||||
|
}
|
||||||
|
if body.Status != "ok" {
|
||||||
|
t.Fatalf("body.Status = %q", body.Status)
|
||||||
|
}
|
||||||
|
if body.Environment != "test" {
|
||||||
|
t.Fatalf("body.Environment = %q", body.Environment)
|
||||||
|
}
|
||||||
|
if body.ModelKey != "deepseek-v4-flash" {
|
||||||
|
t.Fatalf("body.ModelKey = %q", body.ModelKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
192
internal/workflows/contracts.go
Normal file
192
internal/workflows/contracts.go
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
package workflows
|
||||||
|
|
||||||
|
type EvidenceKind string
|
||||||
|
|
||||||
|
const (
|
||||||
|
EvidenceAnswer EvidenceKind = "answer"
|
||||||
|
EvidenceGrading EvidenceKind = "grading"
|
||||||
|
EvidenceSource EvidenceKind = "source"
|
||||||
|
EvidenceSession EvidenceKind = "session"
|
||||||
|
EvidenceAsset EvidenceKind = "asset"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EvidenceRef struct {
|
||||||
|
Kind EvidenceKind `json:"kind"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Quote string `json:"quote,omitempty"`
|
||||||
|
Confidence float64 `json:"confidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConceptRef struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Label string `json:"label"`
|
||||||
|
Track string `json:"track"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadinessState string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReadinessUnknown ReadinessState = "unknown"
|
||||||
|
ReadinessFragile ReadinessState = "fragile"
|
||||||
|
ReadinessImproving ReadinessState = "improving"
|
||||||
|
ReadinessInterviewReady ReadinessState = "interview_ready"
|
||||||
|
ReadinessStrongSignal ReadinessState = "strong_signal"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DiagnosticResult struct {
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
Track string `json:"track"`
|
||||||
|
TargetRole string `json:"target_role"`
|
||||||
|
Stack []string `json:"stack"`
|
||||||
|
InitialReadiness ReadinessState `json:"initial_readiness"`
|
||||||
|
ConceptFindings []ConceptFinding `json:"concept_findings"`
|
||||||
|
RecommendedNextConcepts []ConceptRef `json:"recommended_next_concepts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConceptFinding struct {
|
||||||
|
Concept ConceptRef `json:"concept"`
|
||||||
|
Readiness ReadinessState `json:"readiness"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
Evidence []EvidenceRef `json:"evidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GradedAnswer struct {
|
||||||
|
AnswerID string `json:"answer_id"`
|
||||||
|
QuestionID string `json:"question_id"`
|
||||||
|
Concepts []ConceptRef `json:"concepts"`
|
||||||
|
Scores AnswerScores `json:"scores"`
|
||||||
|
Overall AnswerOverall `json:"overall"`
|
||||||
|
Strengths []string `json:"strengths"`
|
||||||
|
Gaps []string `json:"gaps"`
|
||||||
|
MisconceptionCandidates []MisconceptionCandidate `json:"misconception_candidates"`
|
||||||
|
FollowUp FollowUpRecommendation `json:"follow_up"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AnswerScores struct {
|
||||||
|
Correctness int `json:"correctness"`
|
||||||
|
Depth int `json:"depth"`
|
||||||
|
Communication int `json:"communication"`
|
||||||
|
ProductionJudgment int `json:"production_judgment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AnswerOverall string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AnswerMiss AnswerOverall = "miss"
|
||||||
|
AnswerPartial AnswerOverall = "partial"
|
||||||
|
AnswerSolid AnswerOverall = "solid"
|
||||||
|
AnswerStrong AnswerOverall = "strong"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MisconceptionCandidate struct {
|
||||||
|
Label string `json:"label"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Evidence []EvidenceRef `json:"evidence"`
|
||||||
|
Confidence float64 `json:"confidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FollowUpRecommendation struct {
|
||||||
|
Needed bool `json:"needed"`
|
||||||
|
Question string `json:"question,omitempty"`
|
||||||
|
Purpose FollowUpPurpose `json:"purpose,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FollowUpPurpose string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FollowUpClarify FollowUpPurpose = "clarify"
|
||||||
|
FollowUpRepair FollowUpPurpose = "repair"
|
||||||
|
FollowUpStretch FollowUpPurpose = "stretch"
|
||||||
|
FollowUpPressureTest FollowUpPurpose = "pressure_test"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MemoryUpdateCandidate struct {
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
SourceAnswerID string `json:"source_answer_id"`
|
||||||
|
Updates []MemoryUpdate `json:"updates"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MemoryUpdate struct {
|
||||||
|
Kind MemoryUpdateKind `json:"kind"`
|
||||||
|
Concept ConceptRef `json:"concept"`
|
||||||
|
ProposedState ReadinessState `json:"proposed_state"`
|
||||||
|
Summary string `json:"summary"`
|
||||||
|
Evidence []EvidenceRef `json:"evidence"`
|
||||||
|
Confidence float64 `json:"confidence"`
|
||||||
|
Durability Durability `json:"durability"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MemoryUpdateKind string
|
||||||
|
|
||||||
|
const (
|
||||||
|
MemoryConceptMastery MemoryUpdateKind = "concept_mastery"
|
||||||
|
MemoryMisconception MemoryUpdateKind = "misconception"
|
||||||
|
MemoryIntervention MemoryUpdateKind = "intervention"
|
||||||
|
MemoryReviewSchedule MemoryUpdateKind = "review_schedule"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Durability string
|
||||||
|
|
||||||
|
const (
|
||||||
|
DurabilityTentative Durability = "tentative"
|
||||||
|
DurabilityConfirmed Durability = "confirmed"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NextChallenge struct {
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
Track string `json:"track"`
|
||||||
|
Concept ConceptRef `json:"concept"`
|
||||||
|
LadderLevel LadderLevel `json:"ladder_level"`
|
||||||
|
Question string `json:"question"`
|
||||||
|
Rationale string `json:"rationale"`
|
||||||
|
DifficultyAction DifficultyAction `json:"difficulty_action"`
|
||||||
|
Evidence []EvidenceRef `json:"evidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LadderLevel string
|
||||||
|
|
||||||
|
const (
|
||||||
|
LadderDefine LadderLevel = "define"
|
||||||
|
LadderTradeoffs LadderLevel = "tradeoffs"
|
||||||
|
LadderDebug LadderLevel = "debug"
|
||||||
|
LadderDesignConstraints LadderLevel = "design_constraints"
|
||||||
|
LadderInterviewPressure LadderLevel = "interview_pressure"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DifficultyAction string
|
||||||
|
|
||||||
|
const (
|
||||||
|
DifficultyLower DifficultyAction = "lower"
|
||||||
|
DifficultyHold DifficultyAction = "hold"
|
||||||
|
DifficultyRaise DifficultyAction = "raise"
|
||||||
|
DifficultyRecover DifficultyAction = "recover"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ReadinessUpdate struct {
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
Track string `json:"track"`
|
||||||
|
ConceptUpdates []ConceptReadinessDelta `json:"concept_updates"`
|
||||||
|
Unlocks []Unlock `json:"unlocks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConceptReadinessDelta struct {
|
||||||
|
Concept ConceptRef `json:"concept"`
|
||||||
|
Previous ReadinessState `json:"previous"`
|
||||||
|
Next ReadinessState `json:"next"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
Evidence []EvidenceRef `json:"evidence"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Unlock struct {
|
||||||
|
Kind UnlockKind `json:"kind"`
|
||||||
|
Label string `json:"label"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UnlockKind string
|
||||||
|
|
||||||
|
const (
|
||||||
|
UnlockBossQuestion UnlockKind = "boss_question"
|
||||||
|
UnlockReviewCard UnlockKind = "review_card"
|
||||||
|
UnlockPortfolioEntry UnlockKind = "portfolio_entry"
|
||||||
|
)
|
||||||
66
internal/workflows/runner.go
Normal file
66
internal/workflows/runner.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package workflows
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrNotImplemented = errors.New("workflow runner not implemented")
|
||||||
|
|
||||||
|
type DiagnosticInput struct {
|
||||||
|
UserID string
|
||||||
|
Track string
|
||||||
|
TargetRole string
|
||||||
|
Stack []string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Runner interface {
|
||||||
|
DiagnoseJobSeeker(context.Context, DiagnosticInput) (DiagnosticResult, error)
|
||||||
|
GradeInterviewAnswer(context.Context, GradeAnswerInput) (GradedAnswer, error)
|
||||||
|
ExtractLearningMemory(context.Context, GradedAnswer) (MemoryUpdateCandidate, error)
|
||||||
|
SelectNextChallenge(context.Context, NextChallengeInput) (NextChallenge, error)
|
||||||
|
UpdateReadinessMap(context.Context, ReadinessUpdateInput) (ReadinessUpdate, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type GradeAnswerInput struct {
|
||||||
|
UserID string
|
||||||
|
QuestionID string
|
||||||
|
AnswerID string
|
||||||
|
AnswerText string
|
||||||
|
}
|
||||||
|
|
||||||
|
type NextChallengeInput struct {
|
||||||
|
UserID string
|
||||||
|
Track string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReadinessUpdateInput struct {
|
||||||
|
UserID string
|
||||||
|
Track string
|
||||||
|
}
|
||||||
|
|
||||||
|
type StubRunner struct{}
|
||||||
|
|
||||||
|
func NewStubRunner() StubRunner {
|
||||||
|
return StubRunner{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (StubRunner) DiagnoseJobSeeker(context.Context, DiagnosticInput) (DiagnosticResult, error) {
|
||||||
|
return DiagnosticResult{}, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (StubRunner) GradeInterviewAnswer(context.Context, GradeAnswerInput) (GradedAnswer, error) {
|
||||||
|
return GradedAnswer{}, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (StubRunner) ExtractLearningMemory(context.Context, GradedAnswer) (MemoryUpdateCandidate, error) {
|
||||||
|
return MemoryUpdateCandidate{}, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (StubRunner) SelectNextChallenge(context.Context, NextChallengeInput) (NextChallenge, error) {
|
||||||
|
return NextChallenge{}, ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
|
func (StubRunner) UpdateReadinessMap(context.Context, ReadinessUpdateInput) (ReadinessUpdate, error) {
|
||||||
|
return ReadinessUpdate{}, ErrNotImplemented
|
||||||
|
}
|
||||||
21
internal/workflows/runner_test.go
Normal file
21
internal/workflows/runner_test.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package workflows
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStubRunnerReturnsTypedNotImplemented(t *testing.T) {
|
||||||
|
runner := NewStubRunner()
|
||||||
|
|
||||||
|
_, err := runner.DiagnoseJobSeeker(context.Background(), DiagnosticInput{
|
||||||
|
UserID: "user-1",
|
||||||
|
Track: "backend-developer",
|
||||||
|
TargetRole: "junior-backend-developer",
|
||||||
|
})
|
||||||
|
|
||||||
|
if !errors.Is(err, ErrNotImplemented) {
|
||||||
|
t.Fatalf("err = %v, want %v", err, ErrNotImplemented)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user