@jamesaphoenix/tx-types 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +480 -0
  2. package/dist/anchor.d.ts +93 -96
  3. package/dist/anchor.d.ts.map +1 -1
  4. package/dist/anchor.js +74 -1
  5. package/dist/anchor.js.map +1 -1
  6. package/dist/attempt.d.ts +36 -28
  7. package/dist/attempt.d.ts.map +1 -1
  8. package/dist/attempt.js +59 -1
  9. package/dist/attempt.js.map +1 -1
  10. package/dist/candidate.d.ts +117 -145
  11. package/dist/candidate.d.ts.map +1 -1
  12. package/dist/candidate.js +109 -0
  13. package/dist/candidate.js.map +1 -1
  14. package/dist/cycle.d.ts +130 -0
  15. package/dist/cycle.d.ts.map +1 -0
  16. package/dist/cycle.js +89 -0
  17. package/dist/cycle.js.map +1 -0
  18. package/dist/deduplication.d.ts +76 -92
  19. package/dist/deduplication.d.ts.map +1 -1
  20. package/dist/deduplication.js +63 -2
  21. package/dist/deduplication.js.map +1 -1
  22. package/dist/doc.d.ts +269 -0
  23. package/dist/doc.d.ts.map +1 -0
  24. package/dist/doc.js +232 -0
  25. package/dist/doc.js.map +1 -0
  26. package/dist/edge.d.ts +53 -56
  27. package/dist/edge.d.ts.map +1 -1
  28. package/dist/edge.js +51 -1
  29. package/dist/edge.js.map +1 -1
  30. package/dist/file-learning.d.ts +23 -28
  31. package/dist/file-learning.d.ts.map +1 -1
  32. package/dist/file-learning.js +22 -2
  33. package/dist/file-learning.js.map +1 -1
  34. package/dist/index.d.ts +14 -14
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +38 -21
  37. package/dist/index.js.map +1 -1
  38. package/dist/learning.d.ts +167 -172
  39. package/dist/learning.d.ts.map +1 -1
  40. package/dist/learning.js +109 -1
  41. package/dist/learning.js.map +1 -1
  42. package/dist/response.d.ts +636 -0
  43. package/dist/response.d.ts.map +1 -0
  44. package/dist/response.js +354 -0
  45. package/dist/response.js.map +1 -0
  46. package/dist/run.d.ts +73 -40
  47. package/dist/run.d.ts.map +1 -1
  48. package/dist/run.js +108 -1
  49. package/dist/run.js.map +1 -1
  50. package/dist/symbol.d.ts +42 -43
  51. package/dist/symbol.d.ts.map +1 -1
  52. package/dist/symbol.js +55 -1
  53. package/dist/symbol.js.map +1 -1
  54. package/dist/task.d.ts +114 -78
  55. package/dist/task.d.ts.map +1 -1
  56. package/dist/task.js +149 -2
  57. package/dist/task.js.map +1 -1
  58. package/dist/tracked-project.d.ts +24 -34
  59. package/dist/tracked-project.d.ts.map +1 -1
  60. package/dist/tracked-project.js +34 -0
  61. package/dist/tracked-project.js.map +1 -1
  62. package/package.json +7 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,aAAa,GACnB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,KAAK,cAAc,EACnB,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K,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,KAAK,GACX,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,aAAa,GACnB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,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KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,36 +1,53 @@
1
1
  /**
2
2
  * @tx/types - Shared TypeScript types for tx
3
3
  *
4
- * Zero runtime dependencies - pure TypeScript types only.
4
+ * Effect Schema definitions providing both compile-time types and runtime validation.
5
5
  * Works with any runtime (Node, Bun, Deno).
6
6
  *
7
7
  * @example
8
8
  * ```typescript
9
9
  * import { Task, TaskWithDeps, TaskId, TaskStatus } from "@jamesaphoenix/tx-types";
10
+ * import { TaskSchema, TaskWithDepsSchema } from "@jamesaphoenix/tx-types";
10
11
  * import { Learning, LearningWithScore } from "@jamesaphoenix/tx-types";
11
12
  * import { Attempt, Run } from "@jamesaphoenix/tx-types";
12
13
  *
13
14
  * // Or import from specific modules:
14
- * import type { Task, TaskWithDeps } from "@tx/types/task";
15
- * import type { Learning } from "@tx/types/learning";
15
+ * import { TaskSchema, type Task, type TaskWithDeps } from "@tx/types/task";
16
+ * import { LearningSchema, type Learning } from "@tx/types/learning";
16
17
  * ```
17
18
  */
18
- // Task types
19
- export { TASK_STATUSES, VALID_TRANSITIONS, } from "./task.js";
20
- // Learning types
21
- export { LEARNING_SOURCE_TYPES, } from "./learning.js";
22
- // Attempt types
23
- export { ATTEMPT_OUTCOMES, } from "./attempt.js";
24
- // Run types
25
- export { RUN_STATUSES, } from "./run.js";
26
- // Anchor types
27
- export { ANCHOR_TYPES, ANCHOR_STATUSES, INVALIDATION_SOURCES, } from "./anchor.js";
28
- // Edge types
29
- export { NODE_TYPES, EDGE_TYPES, } from "./edge.js";
30
- // Candidate types (learning extraction from transcripts)
31
- export { CANDIDATE_CONFIDENCES, CANDIDATE_CATEGORIES, CANDIDATE_STATUSES, } from "./candidate.js";
32
- // Symbol extraction types (code intelligence)
33
- export { SYMBOL_KINDS, IMPORT_KINDS, } from "./symbol.js";
34
- // Tracked project types (daemon monitoring)
35
- export { SOURCE_TYPES, } from "./tracked-project.js";
19
+ // Task types & schemas
20
+ export { TASK_STATUSES, VALID_TRANSITIONS, TASK_ID_PATTERN, TaskStatusSchema, TaskIdSchema, TaskSchema, TaskWithDepsSchema, TaskTreeSchema, TaskDependencySchema, CreateTaskInputSchema, UpdateTaskInputSchema, TaskCursorSchema, TaskFilterSchema, isValidTaskId, assertTaskId, InvalidTaskIdError, isValidTaskStatus, assertTaskStatus, InvalidTaskStatusError, } from "./task.js";
21
+ // Learning types & schemas
22
+ export { LEARNING_SOURCE_TYPES, LearningSourceTypeSchema, LearningIdSchema, LearningSchema, LearningWithScoreSchema, CreateLearningInputSchema, UpdateLearningInputSchema, LearningQuerySchema, ContextOptionsSchema, ContextResultSchema, LearningSearchResultSchema, DiversificationOptionsSchema, RetrievalOptionsSchema, } from "./learning.js";
23
+ // File learning types & schemas
24
+ export { FileLearningIdSchema, FileLearningSchema, CreateFileLearningInputSchema, } from "./file-learning.js";
25
+ // Attempt types & schemas
26
+ export { ATTEMPT_OUTCOMES, AttemptOutcomeSchema, AttemptIdSchema, AttemptSchema, CreateAttemptInputSchema, isValidAttemptOutcome, assertAttemptOutcome, InvalidAttemptOutcomeError, } from "./attempt.js";
27
+ // Run types & schemas
28
+ export { RUN_STATUSES, RunStatusSchema, RunIdSchema, RunSchema, CreateRunInputSchema, UpdateRunInputSchema, isValidRunStatus, assertRunStatus, InvalidRunStatusError, isValidRunId, assertRunId, InvalidRunIdError, } from "./run.js";
29
+ // Deduplication types & schemas
30
+ export { ProcessedHashSchema, CreateProcessedHashInputSchema, FileProgressSchema, UpsertFileProgressInputSchema, HashCheckResultSchema, LineProcessResultSchema, FileProcessResultSchema, DeduplicationOptionsSchema, } from "./deduplication.js";
31
+ // Tracked project types & schemas (daemon monitoring)
32
+ export { SOURCE_TYPES, SourceTypeSchema, TrackedProjectSchema, CreateTrackedProjectInputSchema, } from "./tracked-project.js";
33
+ // Doc types & schemas
34
+ export { DOC_KINDS, DOC_STATUSES, DOC_LINK_TYPES, TASK_DOC_LINK_TYPES, INVARIANT_ENFORCEMENT_TYPES, INVARIANT_STATUSES, DocKindSchema, DocStatusSchema, DocLinkTypeSchema, TaskDocLinkTypeSchema, DocIdSchema, isValidDocKind, assertDocKind, InvalidDocKindError, isValidDocStatus, assertDocStatus, InvalidDocStatusError, isValidDocLinkType, assertDocLinkType, InvalidDocLinkTypeError, DocSchema, DocWithLinksSchema, DocLinkSchema, TaskDocLinkSchema, CreateDocInputSchema, InvariantEnforcementSchema, InvariantStatusSchema, InvariantIdSchema, InvariantSchema, InvariantCheckSchema, UpsertInvariantInputSchema, RecordInvariantCheckInputSchema, DocGraphNodeSchema, DocGraphEdgeSchema, DocGraphSchema, } from "./doc.js";
35
+ // Cycle types & schemas (cycle-based issue discovery)
36
+ export { FINDING_SEVERITIES, LOSS_WEIGHTS, FindingSeveritySchema, FindingSchema, DuplicateSchema, DedupResultSchema, CycleConfigSchema, RoundMetricsSchema, CycleResultSchema, } from "./cycle.js";
37
+ // Response types & schemas (shared schemas for CLI, MCP, API, SDK)
38
+ export {
39
+ // Serialized entity schemas
40
+ TaskWithDepsSerializedSchema, LearningSerializedSchema, LearningWithScoreSerializedSchema, FileLearningsSerializedSchema, RunSerializedSchema, AttemptSerializedSchema,
41
+ // Serialization functions
42
+ serializeTask, serializeLearning, serializeLearningWithScore, serializeFileLearning, serializeRun, serializeAttempt,
43
+ // Response envelope schemas
44
+ ErrorResponseSchema,
45
+ // Task response schemas & types
46
+ TaskReadyResponseSchema, TaskListResponseSchema, TaskDetailResponseSchema, TaskCompletionResponseSchema, TaskTreeResponseSchema,
47
+ // Learning response schemas & types
48
+ LearningSearchResponseSchema, ContextResponseSchema, FileLearningListResponseSchema,
49
+ // Run response schemas & types
50
+ RunListResponseSchema, RunDetailResponseSchema,
51
+ // Sync response schemas & types
52
+ SyncExportResponseSchema, SyncImportResponseSchema, } from "./response.js";
36
53
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,aAAa;AACb,OAAO,EACL,aAAa,EACb,iBAAiB,GAalB,MAAM,WAAW,CAAC;AAEnB,iBAAiB;AACjB,OAAO,EACL,qBAAqB,GAiBtB,MAAM,eAAe,CAAC;AAUvB,gBAAgB;AAChB,OAAO,EACL,gBAAgB,GAMjB,MAAM,cAAc,CAAC;AAEtB,YAAY;AACZ,OAAO,EACL,YAAY,GAOb,MAAM,UAAU,CAAC;AAElB,eAAe;AACf,OAAO,EACL,YAAY,EACZ,eAAe,EACf,oBAAoB,GAYrB,MAAM,aAAa,CAAA;AAEpB,aAAa;AACb,OAAO,EACL,UAAU,EACV,UAAU,GASX,MAAM,WAAW,CAAC;AAkBnB,yDAAyD;AACzD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GAanB,MAAM,gBAAgB,CAAC;AAExB,8CAA8C;AAC9C,OAAO,EACL,YAAY,EACZ,YAAY,GAOb,MAAM,aAAa,CAAA;AAEpB,4CAA4C;AAC5C,OAAO,EACL,YAAY,GAMb,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,uBAAuB;AACvB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GAavB,MAAM,WAAW,CAAC;AAEnB,2BAA2B;AAC3B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACz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C1B,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC1B,+BAA+B,EAC/B,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GA0Bf,MAAM,UAAU,CAAC;AAElB,sDAAsD;AACtD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GASlB,MAAM,YAAY,CAAA;AAEnB,mEAAmE;AACnE,OAAO;AACL,4BAA4B;AAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACjC,6BAA6B,EAC7B,mBAAmB,EACnB,uBAAuB;AAQvB,0BAA0B;AAC1B,aAAa,EACb,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,YAAY,EACZ,gBAAgB;AAChB,4BAA4B;AAC5B,mBAAmB;AAMnB,gCAAgC;AAChC,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,4BAA4B,EAC5B,sBAAsB;AAMtB,oCAAoC;AACpC,4BAA4B,EAC5B,qBAAqB,EACrB,8BAA8B;AAI9B,+BAA+B;AAC/B,qBAAqB,EACrB,uBAAuB;AAGvB,gCAAgC;AAChC,wBAAwB,EACxB,wBAAwB,GAGzB,MAAM,eAAe,CAAC"}
@@ -3,154 +3,182 @@
3
3
  *
4
4
  * Type definitions for the contextual learnings system.
5
5
  * See PRD-010 and DD-010 for specification.
6
- * Zero runtime dependencies - pure TypeScript types only.
6
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
7
+ * Schema definitions provide both compile-time types and runtime validation.
7
8
  */
8
- import type { EdgeType } from "./edge.js";
9
+ import { Schema } from "effect";
9
10
  /**
10
11
  * Valid learning source types.
11
12
  */
12
13
  export declare const LEARNING_SOURCE_TYPES: readonly ["compaction", "run", "manual", "claude_md"];
13
- /**
14
- * Learning source type - where the learning came from.
15
- */
16
- export type LearningSourceType = (typeof LEARNING_SOURCE_TYPES)[number];
17
- /**
18
- * Branded type for learning IDs.
19
- */
20
- export type LearningId = number & {
21
- readonly _brand: unique symbol;
22
- };
23
- /**
24
- * Core learning entity.
25
- */
26
- export interface Learning {
27
- readonly id: LearningId;
28
- readonly content: string;
29
- readonly sourceType: LearningSourceType;
30
- readonly sourceRef: string | null;
31
- readonly createdAt: Date;
32
- readonly keywords: string[];
33
- readonly category: string | null;
34
- readonly usageCount: number;
35
- readonly lastUsedAt: Date | null;
36
- readonly outcomeScore: number | null;
37
- readonly embedding: Float32Array | null;
38
- }
39
- /**
40
- * Learning with relevance scoring from search results.
41
- */
42
- export interface LearningWithScore extends Learning {
43
- readonly relevanceScore: number;
44
- readonly bm25Score: number;
45
- readonly vectorScore: number;
46
- readonly recencyScore: number;
14
+ /** Learning source type - where the learning came from. */
15
+ export declare const LearningSourceTypeSchema: Schema.Literal<["compaction", "run", "manual", "claude_md"]>;
16
+ export type LearningSourceType = typeof LearningSourceTypeSchema.Type;
17
+ /** Learning ID - branded integer. */
18
+ export declare const LearningIdSchema: Schema.brand<Schema.filter<typeof Schema.Number>, "LearningId">;
19
+ export type LearningId = typeof LearningIdSchema.Type;
20
+ /** Core learning entity. */
21
+ export declare const LearningSchema: Schema.Struct<{
22
+ id: Schema.brand<Schema.filter<typeof Schema.Number>, "LearningId">;
23
+ content: typeof Schema.String;
24
+ sourceType: Schema.Literal<["compaction", "run", "manual", "claude_md"]>;
25
+ sourceRef: Schema.NullOr<typeof Schema.String>;
26
+ createdAt: typeof Schema.DateFromSelf;
27
+ keywords: Schema.Array$<typeof Schema.String>;
28
+ category: Schema.NullOr<typeof Schema.String>;
29
+ usageCount: Schema.filter<typeof Schema.Number>;
30
+ lastUsedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
31
+ outcomeScore: Schema.NullOr<typeof Schema.Number>;
32
+ embedding: Schema.NullOr<Schema.instanceOf<Float32Array<ArrayBuffer>>>;
33
+ }>;
34
+ export type Learning = typeof LearningSchema.Type;
35
+ /** Learning with relevance scoring from search results. */
36
+ export declare const LearningWithScoreSchema: Schema.Struct<{
37
+ relevanceScore: typeof Schema.Number;
38
+ bm25Score: typeof Schema.Number;
39
+ vectorScore: typeof Schema.Number;
40
+ recencyScore: typeof Schema.Number;
47
41
  /** RRF (Reciprocal Rank Fusion) score from combining BM25 and vector rankings */
48
- readonly rrfScore: number;
42
+ rrfScore: typeof Schema.Number;
49
43
  /** Rank in BM25 results (1-indexed, 0 if not in BM25 results) */
50
- readonly bm25Rank: number;
44
+ bm25Rank: Schema.filter<typeof Schema.Number>;
51
45
  /** Rank in vector similarity results (1-indexed, 0 if not in vector results) */
52
- readonly vectorRank: number;
46
+ vectorRank: Schema.filter<typeof Schema.Number>;
53
47
  /** LLM reranker score (0-1, optional - only present when reranking is applied) */
54
- readonly rerankerScore?: number;
55
- /** Number of hops from seed (0 = direct match from RRF, 1+ = expanded via graph) */
56
- readonly expansionHops?: number;
57
- /** Path of learning IDs from seed to this learning (only for expanded results) */
58
- readonly expansionPath?: readonly LearningId[];
59
- /** Edge type that led to this learning (null for direct matches) */
60
- readonly sourceEdge?: EdgeType | null;
48
+ rerankerScore: Schema.optional<typeof Schema.Number>;
61
49
  /** Feedback score from historical usage (0-1, 0.5 = neutral, optional) */
62
- readonly feedbackScore?: number;
63
- }
64
- /**
65
- * Input for creating a new learning.
66
- */
67
- export interface CreateLearningInput {
68
- readonly content: string;
69
- readonly sourceType?: LearningSourceType;
70
- readonly sourceRef?: string | null;
71
- readonly keywords?: string[];
72
- readonly category?: string | null;
73
- }
74
- /**
75
- * Input for updating an existing learning.
76
- */
77
- export interface UpdateLearningInput {
78
- readonly usageCount?: number;
79
- readonly lastUsedAt?: Date;
80
- readonly outcomeScore?: number;
81
- readonly embedding?: Float32Array;
82
- }
83
- /**
84
- * Options for graph expansion during search.
85
- * See PRD-016 for specification.
86
- */
87
- export interface GraphExpansionQueryOptions {
88
- /** Enable graph expansion (default: false) */
89
- readonly enabled: boolean;
90
- /** Maximum traversal depth (default: 2) */
91
- readonly depth?: number;
92
- /** Score decay factor per hop (default: 0.7) */
93
- readonly decayFactor?: number;
94
- /** Maximum nodes to return from expansion (default: 100) */
95
- readonly maxNodes?: number;
96
- /** Filter by specific edge types (default: all types) */
97
- readonly edgeTypes?: readonly EdgeType[];
98
- }
99
- /**
100
- * Query options for learning searches.
101
- */
102
- export interface LearningQuery {
103
- readonly query: string;
104
- readonly limit?: number;
105
- readonly minScore?: number;
106
- readonly category?: string;
107
- readonly sourceType?: LearningSourceType;
108
- /** Graph expansion options for traversing related learnings */
109
- readonly graphExpansion?: GraphExpansionQueryOptions;
110
- }
111
- /**
112
- * Options for context retrieval.
113
- */
114
- export interface ContextOptions {
115
- /** Enable graph expansion (default: false) */
116
- readonly useGraph?: boolean;
117
- /** Graph expansion depth (default: 2 per PRD-016) */
118
- readonly expansionDepth?: number;
119
- /** Edge types to include in expansion */
120
- readonly edgeTypes?: readonly EdgeType[];
121
- }
122
- /**
123
- * Statistics about graph expansion during context retrieval.
124
- */
125
- export interface GraphExpansionStats {
126
- readonly enabled: boolean;
127
- readonly seedCount: number;
128
- readonly expandedCount: number;
129
- readonly maxDepthReached: number;
130
- }
131
- /**
132
- * Result of context retrieval for a task.
133
- */
134
- export interface ContextResult {
135
- readonly taskId: string;
136
- readonly taskTitle: string;
137
- readonly learnings: readonly LearningWithScore[];
138
- readonly searchQuery: string;
139
- readonly searchDuration: number;
140
- /** Graph expansion statistics (only present when useGraph=true) */
141
- readonly graphExpansion?: GraphExpansionStats;
142
- }
143
- /**
144
- * Result of a learning search operation.
145
- */
146
- export interface LearningSearchResult {
147
- readonly learnings: readonly Learning[];
148
- readonly query: string;
149
- readonly searchDuration: number;
150
- }
151
- /**
152
- * Database row type for learnings (snake_case from SQLite).
153
- */
50
+ feedbackScore: Schema.optional<typeof Schema.Number>;
51
+ id: Schema.brand<Schema.filter<typeof Schema.Number>, "LearningId">;
52
+ content: typeof Schema.String;
53
+ sourceType: Schema.Literal<["compaction", "run", "manual", "claude_md"]>;
54
+ sourceRef: Schema.NullOr<typeof Schema.String>;
55
+ createdAt: typeof Schema.DateFromSelf;
56
+ keywords: Schema.Array$<typeof Schema.String>;
57
+ category: Schema.NullOr<typeof Schema.String>;
58
+ usageCount: Schema.filter<typeof Schema.Number>;
59
+ lastUsedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
60
+ outcomeScore: Schema.NullOr<typeof Schema.Number>;
61
+ embedding: Schema.NullOr<Schema.instanceOf<Float32Array<ArrayBuffer>>>;
62
+ }>;
63
+ export type LearningWithScore = typeof LearningWithScoreSchema.Type;
64
+ /** Input for creating a new learning. */
65
+ export declare const CreateLearningInputSchema: Schema.Struct<{
66
+ content: typeof Schema.String;
67
+ sourceType: Schema.optional<Schema.Literal<["compaction", "run", "manual", "claude_md"]>>;
68
+ sourceRef: Schema.optional<Schema.NullOr<typeof Schema.String>>;
69
+ keywords: Schema.optional<Schema.Array$<typeof Schema.String>>;
70
+ category: Schema.optional<Schema.NullOr<typeof Schema.String>>;
71
+ }>;
72
+ export type CreateLearningInput = typeof CreateLearningInputSchema.Type;
73
+ /** Input for updating an existing learning. */
74
+ export declare const UpdateLearningInputSchema: Schema.Struct<{
75
+ usageCount: Schema.optional<Schema.filter<typeof Schema.Number>>;
76
+ lastUsedAt: Schema.optional<typeof Schema.DateFromSelf>;
77
+ outcomeScore: Schema.optional<typeof Schema.Number>;
78
+ embedding: Schema.optional<Schema.instanceOf<Float32Array<ArrayBuffer>>>;
79
+ }>;
80
+ export type UpdateLearningInput = typeof UpdateLearningInputSchema.Type;
81
+ /** Query options for learning searches. */
82
+ export declare const LearningQuerySchema: Schema.Struct<{
83
+ query: typeof Schema.String;
84
+ limit: Schema.optional<Schema.filter<typeof Schema.Number>>;
85
+ minScore: Schema.optional<typeof Schema.Number>;
86
+ category: Schema.optional<typeof Schema.String>;
87
+ sourceType: Schema.optional<Schema.Literal<["compaction", "run", "manual", "claude_md"]>>;
88
+ }>;
89
+ export type LearningQuery = typeof LearningQuerySchema.Type;
90
+ /** Options for context retrieval. */
91
+ export declare const ContextOptionsSchema: Schema.Struct<{
92
+ /** Maximum number of learnings to return (default: 10, capped at 50). Misnamed — this is a result count, not a token budget. */
93
+ maxTokens: Schema.optional<Schema.filter<typeof Schema.Number>>;
94
+ }>;
95
+ export type ContextOptions = typeof ContextOptionsSchema.Type;
96
+ /** Result of context retrieval for a task. */
97
+ export declare const ContextResultSchema: Schema.Struct<{
98
+ taskId: typeof Schema.String;
99
+ taskTitle: typeof Schema.String;
100
+ learnings: Schema.Array$<Schema.Struct<{
101
+ relevanceScore: typeof Schema.Number;
102
+ bm25Score: typeof Schema.Number;
103
+ vectorScore: typeof Schema.Number;
104
+ recencyScore: typeof Schema.Number;
105
+ /** RRF (Reciprocal Rank Fusion) score from combining BM25 and vector rankings */
106
+ rrfScore: typeof Schema.Number;
107
+ /** Rank in BM25 results (1-indexed, 0 if not in BM25 results) */
108
+ bm25Rank: Schema.filter<typeof Schema.Number>;
109
+ /** Rank in vector similarity results (1-indexed, 0 if not in vector results) */
110
+ vectorRank: Schema.filter<typeof Schema.Number>;
111
+ /** LLM reranker score (0-1, optional - only present when reranking is applied) */
112
+ rerankerScore: Schema.optional<typeof Schema.Number>;
113
+ /** Feedback score from historical usage (0-1, 0.5 = neutral, optional) */
114
+ feedbackScore: Schema.optional<typeof Schema.Number>;
115
+ id: Schema.brand<Schema.filter<typeof Schema.Number>, "LearningId">;
116
+ content: typeof Schema.String;
117
+ sourceType: Schema.Literal<["compaction", "run", "manual", "claude_md"]>;
118
+ sourceRef: Schema.NullOr<typeof Schema.String>;
119
+ createdAt: typeof Schema.DateFromSelf;
120
+ keywords: Schema.Array$<typeof Schema.String>;
121
+ category: Schema.NullOr<typeof Schema.String>;
122
+ usageCount: Schema.filter<typeof Schema.Number>;
123
+ lastUsedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
124
+ outcomeScore: Schema.NullOr<typeof Schema.Number>;
125
+ embedding: Schema.NullOr<Schema.instanceOf<Float32Array<ArrayBuffer>>>;
126
+ }>>;
127
+ searchQuery: typeof Schema.String;
128
+ searchDuration: typeof Schema.Number;
129
+ }>;
130
+ export type ContextResult = typeof ContextResultSchema.Type;
131
+ /** Result of a learning search operation. */
132
+ export declare const LearningSearchResultSchema: Schema.Struct<{
133
+ learnings: Schema.Array$<Schema.Struct<{
134
+ id: Schema.brand<Schema.filter<typeof Schema.Number>, "LearningId">;
135
+ content: typeof Schema.String;
136
+ sourceType: Schema.Literal<["compaction", "run", "manual", "claude_md"]>;
137
+ sourceRef: Schema.NullOr<typeof Schema.String>;
138
+ createdAt: typeof Schema.DateFromSelf;
139
+ keywords: Schema.Array$<typeof Schema.String>;
140
+ category: Schema.NullOr<typeof Schema.String>;
141
+ usageCount: Schema.filter<typeof Schema.Number>;
142
+ lastUsedAt: Schema.NullOr<typeof Schema.DateFromSelf>;
143
+ outcomeScore: Schema.NullOr<typeof Schema.Number>;
144
+ embedding: Schema.NullOr<Schema.instanceOf<Float32Array<ArrayBuffer>>>;
145
+ }>>;
146
+ query: typeof Schema.String;
147
+ searchDuration: typeof Schema.Number;
148
+ }>;
149
+ export type LearningSearchResult = typeof LearningSearchResultSchema.Type;
150
+ /** Options for MMR (Maximal Marginal Relevance) diversification. See PRD-017. */
151
+ export declare const DiversificationOptionsSchema: Schema.Struct<{
152
+ /** Enable MMR diversification (default: false) */
153
+ enabled: Schema.optional<typeof Schema.Boolean>;
154
+ /** Trade-off between relevance (1.0) and diversity (0.0) (default: 0.7) */
155
+ lambda: Schema.optional<typeof Schema.Number>;
156
+ /** Maximum results per category for top 5 results (default: 2) */
157
+ maxPerCategory: Schema.optional<Schema.filter<typeof Schema.Number>>;
158
+ }>;
159
+ export type DiversificationOptions = typeof DiversificationOptionsSchema.Type;
160
+ /** Options for retrieval operations. Used by RetrieverService.search(). */
161
+ export declare const RetrievalOptionsSchema: Schema.Struct<{
162
+ /** Maximum number of results to return (default: 10) */
163
+ limit: Schema.optional<Schema.filter<typeof Schema.Number>>;
164
+ /** Minimum relevance score threshold (default: 0.1) */
165
+ minScore: Schema.optional<typeof Schema.Number>;
166
+ /** Optional category filter */
167
+ category: Schema.optional<typeof Schema.String>;
168
+ /** Optional source type filter */
169
+ sourceType: Schema.optional<Schema.Literal<["compaction", "run", "manual", "claude_md"]>>;
170
+ /** MMR diversification options for result variety */
171
+ diversification: Schema.optional<Schema.Struct<{
172
+ /** Enable MMR diversification (default: false) */
173
+ enabled: Schema.optional<typeof Schema.Boolean>;
174
+ /** Trade-off between relevance (1.0) and diversity (0.0) (default: 0.7) */
175
+ lambda: Schema.optional<typeof Schema.Number>;
176
+ /** Maximum results per category for top 5 results (default: 2) */
177
+ maxPerCategory: Schema.optional<Schema.filter<typeof Schema.Number>>;
178
+ }>>;
179
+ }>;
180
+ export type RetrievalOptions = typeof RetrievalOptionsSchema.Type;
181
+ /** Database row type for learnings (snake_case from SQLite). */
154
182
  export interface LearningRow {
155
183
  id: number;
156
184
  content: string;
@@ -164,40 +192,7 @@ export interface LearningRow {
164
192
  outcome_score: number | null;
165
193
  embedding: Buffer | null;
166
194
  }
167
- /**
168
- * Options for MMR (Maximal Marginal Relevance) diversification.
169
- * Balances relevance with diversity to avoid redundant results.
170
- * See PRD-017 for specification.
171
- */
172
- export interface DiversificationOptions {
173
- /** Enable MMR diversification (default: false) */
174
- readonly enabled?: boolean;
175
- /** Trade-off between relevance (1.0) and diversity (0.0) (default: 0.7) */
176
- readonly lambda?: number;
177
- /** Maximum results per category for top 5 results (default: 2) */
178
- readonly maxPerCategory?: number;
179
- }
180
- /**
181
- * Options for retrieval operations.
182
- * Used by RetrieverService.search() and custom retrievers.
183
- */
184
- export interface RetrievalOptions {
185
- /** Maximum number of results to return (default: 10) */
186
- readonly limit?: number;
187
- /** Minimum relevance score threshold (default: 0.1) */
188
- readonly minScore?: number;
189
- /** Optional category filter */
190
- readonly category?: string;
191
- /** Optional source type filter */
192
- readonly sourceType?: LearningSourceType;
193
- /** Graph expansion options for traversing related learnings */
194
- readonly graphExpansion?: GraphExpansionQueryOptions;
195
- /** MMR diversification options for result variety */
196
- readonly diversification?: DiversificationOptions;
197
- }
198
- /**
199
- * Learning row with BM25 score from FTS5 query.
200
- */
195
+ /** Learning row with BM25 score from FTS5 query. */
201
196
  export interface LearningRowWithBM25 extends LearningRow {
202
197
  bm25_score: number;
203
198
  }
@@ -1 +1 @@
1
- {"version":3,"file":"learning.d.ts","sourceRoot":"","sources":["../src/learning.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,qBAAqB,uDAKxB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,I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B;IACjC,wDAAwD;;IAExD,uDAAuD;;IAEvD,+BAA+B;;IAE/B,kCAAkC;;IAElC,qDAAqD;;QAnBrD,kDAAkD;;QAElD,2EAA2E;;QAE3E,kEAAkE;;;EAiBlE,CAAA;AACF,MAAM,MAAM,gBAAgB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAA;AAMjE,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,oDAAoD;AACpD,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,UAAU,EAAE,MAAM,CAAC;CACpB"}
package/dist/learning.js CHANGED
@@ -3,8 +3,13 @@
3
3
  *
4
4
  * Type definitions for the contextual learnings system.
5
5
  * See PRD-010 and DD-010 for specification.
6
- * Zero runtime dependencies - pure TypeScript types only.
6
+ * Core type definitions using Effect Schema (Doctrine Rule 10).
7
+ * Schema definitions provide both compile-time types and runtime validation.
7
8
  */
9
+ import { Schema } from "effect";
10
+ // =============================================================================
11
+ // CONSTANTS
12
+ // =============================================================================
8
13
  /**
9
14
  * Valid learning source types.
10
15
  */
@@ -14,4 +19,107 @@ export const LEARNING_SOURCE_TYPES = [
14
19
  "manual",
15
20
  "claude_md",
16
21
  ];
22
+ // =============================================================================
23
+ // SCHEMAS & TYPES
24
+ // =============================================================================
25
+ /** Learning source type - where the learning came from. */
26
+ export const LearningSourceTypeSchema = Schema.Literal(...LEARNING_SOURCE_TYPES);
27
+ /** Learning ID - branded integer. */
28
+ export const LearningIdSchema = Schema.Number.pipe(Schema.int(), Schema.brand("LearningId"));
29
+ /** Core learning entity. */
30
+ export const LearningSchema = Schema.Struct({
31
+ id: LearningIdSchema,
32
+ content: Schema.String,
33
+ sourceType: LearningSourceTypeSchema,
34
+ sourceRef: Schema.NullOr(Schema.String),
35
+ createdAt: Schema.DateFromSelf,
36
+ keywords: Schema.Array(Schema.String),
37
+ category: Schema.NullOr(Schema.String),
38
+ usageCount: Schema.Number.pipe(Schema.int()),
39
+ lastUsedAt: Schema.NullOr(Schema.DateFromSelf),
40
+ outcomeScore: Schema.NullOr(Schema.Number),
41
+ embedding: Schema.NullOr(Schema.instanceOf(Float32Array)),
42
+ });
43
+ /** Learning with relevance scoring from search results. */
44
+ export const LearningWithScoreSchema = Schema.Struct({
45
+ ...LearningSchema.fields,
46
+ relevanceScore: Schema.Number,
47
+ bm25Score: Schema.Number,
48
+ vectorScore: Schema.Number,
49
+ recencyScore: Schema.Number,
50
+ /** RRF (Reciprocal Rank Fusion) score from combining BM25 and vector rankings */
51
+ rrfScore: Schema.Number,
52
+ /** Rank in BM25 results (1-indexed, 0 if not in BM25 results) */
53
+ bm25Rank: Schema.Number.pipe(Schema.int()),
54
+ /** Rank in vector similarity results (1-indexed, 0 if not in vector results) */
55
+ vectorRank: Schema.Number.pipe(Schema.int()),
56
+ /** LLM reranker score (0-1, optional - only present when reranking is applied) */
57
+ rerankerScore: Schema.optional(Schema.Number),
58
+ /** Feedback score from historical usage (0-1, 0.5 = neutral, optional) */
59
+ feedbackScore: Schema.optional(Schema.Number),
60
+ });
61
+ /** Input for creating a new learning. */
62
+ export const CreateLearningInputSchema = Schema.Struct({
63
+ content: Schema.String,
64
+ sourceType: Schema.optional(LearningSourceTypeSchema),
65
+ sourceRef: Schema.optional(Schema.NullOr(Schema.String)),
66
+ keywords: Schema.optional(Schema.Array(Schema.String)),
67
+ category: Schema.optional(Schema.NullOr(Schema.String)),
68
+ });
69
+ /** Input for updating an existing learning. */
70
+ export const UpdateLearningInputSchema = Schema.Struct({
71
+ usageCount: Schema.optional(Schema.Number.pipe(Schema.int())),
72
+ lastUsedAt: Schema.optional(Schema.DateFromSelf),
73
+ outcomeScore: Schema.optional(Schema.Number),
74
+ embedding: Schema.optional(Schema.instanceOf(Float32Array)),
75
+ });
76
+ /** Query options for learning searches. */
77
+ export const LearningQuerySchema = Schema.Struct({
78
+ query: Schema.String,
79
+ limit: Schema.optional(Schema.Number.pipe(Schema.int())),
80
+ minScore: Schema.optional(Schema.Number),
81
+ category: Schema.optional(Schema.String),
82
+ sourceType: Schema.optional(LearningSourceTypeSchema),
83
+ });
84
+ /** Options for context retrieval. */
85
+ export const ContextOptionsSchema = Schema.Struct({
86
+ /** Maximum number of learnings to return (default: 10, capped at 50). Misnamed — this is a result count, not a token budget. */
87
+ maxTokens: Schema.optional(Schema.Number.pipe(Schema.int())),
88
+ });
89
+ /** Result of context retrieval for a task. */
90
+ export const ContextResultSchema = Schema.Struct({
91
+ taskId: Schema.String,
92
+ taskTitle: Schema.String,
93
+ learnings: Schema.Array(LearningWithScoreSchema),
94
+ searchQuery: Schema.String,
95
+ searchDuration: Schema.Number,
96
+ });
97
+ /** Result of a learning search operation. */
98
+ export const LearningSearchResultSchema = Schema.Struct({
99
+ learnings: Schema.Array(LearningSchema),
100
+ query: Schema.String,
101
+ searchDuration: Schema.Number,
102
+ });
103
+ /** Options for MMR (Maximal Marginal Relevance) diversification. See PRD-017. */
104
+ export const DiversificationOptionsSchema = Schema.Struct({
105
+ /** Enable MMR diversification (default: false) */
106
+ enabled: Schema.optional(Schema.Boolean),
107
+ /** Trade-off between relevance (1.0) and diversity (0.0) (default: 0.7) */
108
+ lambda: Schema.optional(Schema.Number),
109
+ /** Maximum results per category for top 5 results (default: 2) */
110
+ maxPerCategory: Schema.optional(Schema.Number.pipe(Schema.int())),
111
+ });
112
+ /** Options for retrieval operations. Used by RetrieverService.search(). */
113
+ export const RetrievalOptionsSchema = Schema.Struct({
114
+ /** Maximum number of results to return (default: 10) */
115
+ limit: Schema.optional(Schema.Number.pipe(Schema.int())),
116
+ /** Minimum relevance score threshold (default: 0.1) */
117
+ minScore: Schema.optional(Schema.Number),
118
+ /** Optional category filter */
119
+ category: Schema.optional(Schema.String),
120
+ /** Optional source type filter */
121
+ sourceType: Schema.optional(LearningSourceTypeSchema),
122
+ /** MMR diversification options for result variety */
123
+ diversification: Schema.optional(DiversificationOptionsSchema),
124
+ });
17
125
  //# sourceMappingURL=learning.js.map