Phase 1: Design System and Shared Types
Status: Complete Spec ID prefix:
DSSTPhase: 1 Completed: 2026-02-20
Overview
Defines the core type system shared across all packages and establishes the design system used by the web frontend. The @nthtime/shared library exports pure types for packs, challenges, assertions (as a discriminated union), verification results, attempts, and user settings. These types form the contract between the verification engine, editor store, data access layer, and Spring Boot backend.
Dependencies
- [FOUND-01] (Nx monorepo with workspace linking)
User Flows
Library Consumer
- Import types from
@nthtime/sharedin any workspace package - Use discriminated union narrowing on
Assertiontype to handle different assertion kinds - Reference
Difficultyenum for challenge difficulty levels - Use
DEFAULT_FEEDBACKconstant for settings initialization
Acceptance Criteria
Type Definitions
- [ ] DSST-01 --
Packinterface includes name, slug, description, language, framework (optional), version, author, tags, and challenges. - [ ] DSST-02 --
Challengeinterface includes id, slug, title, prompt, difficulty, tags, timeEstimateSeconds, hints, assertions (AssertionSet), and referenceSolution (FileEntry[]). - [ ] DSST-03 --
Assertionis a discriminated union of 12 types: functionDeclaration, variableDeclaration, importDeclaration, exportDeclaration, methodCall, returnStatement, classDeclaration, jsxElement, pythonFunctionDef, pythonClassDef, pythonImport, sexpression. - [ ] DSST-04 --
AssertionSethasperFile(Record<string, Assertion[]>) andcrossFile(Assertion[]) fields for organizing assertions by scope. - [ ] DSST-05 --
VerificationResultincludes passed, fileResults, crossFileResults, totalAssertions, and passedAssertions fields. - [ ] DSST-06 --
Difficultyis an enum with Beginner, Intermediate, and Advanced values. - [ ] DSST-07 --
UserSettingsincludes feedback (FeedbackConfig), difficulty, keybindings, formatter, darkMode, autocomplete, promptCollapsed, and fileStubs fields.
Design System
- [ ] DSST-08 -- The web frontend uses shadcn/ui components with Tailwind CSS v3 and a teal/cyan design system.
Defaults
- [ ] DSST-09 --
DEFAULT_FEEDBACKprovides sensible defaults for all FeedbackConfig boolean flags.
Technical Context
Key Files
| File | Role |
|---|---|
libs/shared/src/index.ts | Re-exports all types from ./lib/types/ |
libs/shared/src/lib/types/pack.ts | Pack and FileEntry interfaces |
libs/shared/src/lib/types/challenge.ts | Challenge interface |
libs/shared/src/lib/types/assertion.ts | Assertion discriminated union (12 variants) and AssertionSet |
libs/shared/src/lib/types/verification.ts | VerificationResult, AssertionResult, SourceLocation |
libs/shared/src/lib/types/attempt.ts | Attempt interface |
libs/shared/src/lib/types/settings.ts | UserSettings, FeedbackConfig, Difficulty enum, formatter types |
Patterns and Decisions
- Discriminated union for assertions -- Each assertion variant has a
typefield as the discriminant. This enables exhaustiveswitchnarrowing in evaluators and UI components. - Pure types library --
@nthtime/sharedhas zero runtime dependencies. It exports only types, interfaces, enums, and constants. - AssertionSet dual scope --
perFileassertions are checked against individual files;crossFileassertions run against the combined file set. This models both file-local constraints (e.g., "this file must export X") and project-wide constraints (e.g., "some file must import Y").
Test Coverage
Unit Tests
| Criterion | Test File | Test Description |
|---|---|---|
| DSST-06 | libs/shared/src/lib/types/types.spec.ts | Difficulty enum has three string values |
| DSST-09 | libs/shared/src/lib/types/types.spec.ts | FeedbackConfig defaults has correct default values |
| DSST-03 | libs/shared/src/lib/types/types.spec.ts | Assertion discriminated union narrows correctly |
| DSST-04 | libs/shared/src/lib/types/types.spec.ts | AssertionSet shape is valid |
| DSST-01 | libs/shared/src/lib/types/types.spec.ts | Pack references Challenge and FileEntry |
| DSST-07 | libs/shared/src/lib/types/types.spec.ts | UserSettings has all required fields |
Open Questions
- None at this time.