ferix-code 0.0.2-beta.2 → 0.0.2-beta.4

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 (3) hide show
  1. package/dist/index.d.ts +475 -14
  2. package/dist/index.js +1454 -775
  3. package/package.json +1 -3
package/dist/index.d.ts CHANGED
@@ -51,6 +51,30 @@ declare class SessionStoreError extends SessionStoreError_base<{
51
51
  readonly cause?: unknown;
52
52
  }> {
53
53
  }
54
+ declare const ProgressStoreError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
55
+ readonly _tag: "ProgressStoreError";
56
+ } & Readonly<A>;
57
+ /**
58
+ * Error that occurs during progress storage operations.
59
+ */
60
+ declare class ProgressStoreError extends ProgressStoreError_base<{
61
+ readonly message: string;
62
+ readonly operation: "append" | "load" | "getRecent";
63
+ readonly cause?: unknown;
64
+ }> {
65
+ }
66
+ declare const GuardrailsStoreError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
67
+ readonly _tag: "GuardrailsStoreError";
68
+ } & Readonly<A>;
69
+ /**
70
+ * Error that occurs during guardrails storage operations.
71
+ */
72
+ declare class GuardrailsStoreError extends GuardrailsStoreError_base<{
73
+ readonly message: string;
74
+ readonly operation: "add" | "load" | "getActive";
75
+ readonly cause?: unknown;
76
+ }> {
77
+ }
54
78
  declare const OrchestratorError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
55
79
  readonly _tag: "OrchestratorError";
56
80
  } & Readonly<A>;
@@ -66,7 +90,7 @@ declare class OrchestratorError extends OrchestratorError_base<{
66
90
  /**
67
91
  * Union of all possible errors in the system.
68
92
  */
69
- type FerixError = LLMError | ParseError | PlanStoreError | SessionStoreError | OrchestratorError;
93
+ type FerixError = LLMError | ParseError | PlanStoreError | SessionStoreError | ProgressStoreError | GuardrailsStoreError | OrchestratorError;
70
94
 
71
95
  declare const PhasePromptOverridesSchema: Schema.Struct<{
72
96
  breakdown: Schema.optional<typeof Schema.String>;
@@ -393,6 +417,40 @@ declare const PlanUpdateFailedEventSchema: Schema.TaggedStruct<"PlanUpdateFailed
393
417
  planId: Schema.optional<typeof Schema.String>;
394
418
  }>;
395
419
  type PlanUpdateFailedEvent = typeof PlanUpdateFailedEventSchema.Type;
420
+ /**
421
+ * Learning recorded event - captures insights discovered during iteration.
422
+ */
423
+ declare const LearningRecordedEventSchema: Schema.TaggedStruct<"LearningRecorded", {
424
+ iteration: typeof Schema.Number;
425
+ content: typeof Schema.String;
426
+ category: Schema.optional<Schema.Literal<["success", "failure", "optimization"]>>;
427
+ timestamp: typeof Schema.Number;
428
+ }>;
429
+ type LearningRecordedEvent = typeof LearningRecordedEventSchema.Type;
430
+ /**
431
+ * Guardrail added event - captures failure patterns to avoid.
432
+ */
433
+ declare const GuardrailAddedEventSchema: Schema.TaggedStruct<"GuardrailAdded", {
434
+ id: typeof Schema.String;
435
+ iteration: typeof Schema.Number;
436
+ pattern: typeof Schema.String;
437
+ sign: typeof Schema.String;
438
+ avoidance: typeof Schema.String;
439
+ severity: Schema.Literal<["warning", "critical"]>;
440
+ timestamp: typeof Schema.Number;
441
+ }>;
442
+ type GuardrailAddedEvent = typeof GuardrailAddedEventSchema.Type;
443
+ /**
444
+ * Progress updated event - signals that progress file was updated.
445
+ */
446
+ declare const ProgressUpdatedEventSchema: Schema.TaggedStruct<"ProgressUpdated", {
447
+ sessionId: typeof Schema.String;
448
+ iteration: typeof Schema.Number;
449
+ taskId: typeof Schema.String;
450
+ action: Schema.Literal<["started", "completed", "failed", "learning"]>;
451
+ timestamp: typeof Schema.Number;
452
+ }>;
453
+ type ProgressUpdatedEvent = typeof ProgressUpdatedEventSchema.Type;
396
454
  /**
397
455
  * Union of all domain events.
398
456
  */
@@ -550,11 +608,30 @@ declare const DomainEventSchema: Schema.Union<[Schema.TaggedStruct<"LoopStarted"
550
608
  operation: Schema.Literal<["create", "update"]>;
551
609
  error: typeof Schema.String;
552
610
  planId: Schema.optional<typeof Schema.String>;
611
+ }>, Schema.TaggedStruct<"LearningRecorded", {
612
+ iteration: typeof Schema.Number;
613
+ content: typeof Schema.String;
614
+ category: Schema.optional<Schema.Literal<["success", "failure", "optimization"]>>;
615
+ timestamp: typeof Schema.Number;
616
+ }>, Schema.TaggedStruct<"GuardrailAdded", {
617
+ id: typeof Schema.String;
618
+ iteration: typeof Schema.Number;
619
+ pattern: typeof Schema.String;
620
+ sign: typeof Schema.String;
621
+ avoidance: typeof Schema.String;
622
+ severity: Schema.Literal<["warning", "critical"]>;
623
+ timestamp: typeof Schema.Number;
624
+ }>, Schema.TaggedStruct<"ProgressUpdated", {
625
+ sessionId: typeof Schema.String;
626
+ iteration: typeof Schema.Number;
627
+ taskId: typeof Schema.String;
628
+ action: Schema.Literal<["started", "completed", "failed", "learning"]>;
629
+ timestamp: typeof Schema.Number;
553
630
  }>]>;
554
631
  /**
555
632
  * Explicit discriminated union type for proper TypeScript narrowing.
556
633
  */
557
- type DomainEvent = LoopStartedEvent | LoopCompletedEvent | LoopFailedEvent | DiscoveryStartedEvent | DiscoveryCompletedEvent | IterationStartedEvent | IterationCompletedEvent | LLMTextEvent | LLMToolStartEvent | LLMToolUseEvent | LLMToolEndEvent | TasksDefinedEvent | PhasesDefinedEvent | CriteriaDefinedEvent | PhaseStartedEvent | PhaseCompletedEvent | PhaseFailedEvent | CriterionPassedEvent | CriterionFailedEvent | CheckPassedEvent | CheckFailedEvent | ReviewCompleteEvent | TaskCompletedEvent | PlanCreatedEvent | PlanUpdatedEvent | PlanUpdateFailedEvent;
634
+ type DomainEvent = LoopStartedEvent | LoopCompletedEvent | LoopFailedEvent | DiscoveryStartedEvent | DiscoveryCompletedEvent | IterationStartedEvent | IterationCompletedEvent | LLMTextEvent | LLMToolStartEvent | LLMToolUseEvent | LLMToolEndEvent | TasksDefinedEvent | PhasesDefinedEvent | CriteriaDefinedEvent | PhaseStartedEvent | PhaseCompletedEvent | PhaseFailedEvent | CriterionPassedEvent | CriterionFailedEvent | CheckPassedEvent | CheckFailedEvent | ReviewCompleteEvent | TaskCompletedEvent | PlanCreatedEvent | PlanUpdatedEvent | PlanUpdateFailedEvent | LearningRecordedEvent | GuardrailAddedEvent | ProgressUpdatedEvent;
558
635
  /**
559
636
  * Type guard utilities for domain events.
560
637
  */
@@ -566,6 +643,73 @@ declare const DomainEventUtils: {
566
643
  readonly isDiscoveryEvent: (e: DomainEvent) => e is DiscoveryStartedEvent | DiscoveryCompletedEvent;
567
644
  };
568
645
 
646
+ /**
647
+ * Severity levels for guardrails.
648
+ */
649
+ declare const GuardrailSeveritySchema: Schema.Literal<["warning", "critical"]>;
650
+ type GuardrailSeverity = typeof GuardrailSeveritySchema.Type;
651
+ /**
652
+ * A guardrail represents a failure pattern to avoid.
653
+ *
654
+ * Guardrails are learned from previous iteration failures and
655
+ * help prevent the LLM from repeating the same mistakes.
656
+ */
657
+ declare const GuardrailSchema: Schema.Struct<{
658
+ id: typeof Schema.String;
659
+ createdAt: typeof Schema.String;
660
+ iteration: typeof Schema.Number;
661
+ pattern: typeof Schema.String;
662
+ sign: typeof Schema.String;
663
+ avoidance: typeof Schema.String;
664
+ severity: Schema.Literal<["warning", "critical"]>;
665
+ }>;
666
+ type Guardrail = typeof GuardrailSchema.Type;
667
+ /**
668
+ * The complete guardrails file structure.
669
+ *
670
+ * Contains session metadata and an array of guardrails.
671
+ * This is the structure persisted to `.ferix/plans/:sessionId/guardrails.md`.
672
+ */
673
+ declare const GuardrailsFileSchema: Schema.Struct<{
674
+ sessionId: typeof Schema.String;
675
+ createdAt: typeof Schema.String;
676
+ guardrails: Schema.Array$<Schema.Struct<{
677
+ id: typeof Schema.String;
678
+ createdAt: typeof Schema.String;
679
+ iteration: typeof Schema.Number;
680
+ pattern: typeof Schema.String;
681
+ sign: typeof Schema.String;
682
+ avoidance: typeof Schema.String;
683
+ severity: Schema.Literal<["warning", "critical"]>;
684
+ }>>;
685
+ }>;
686
+ type GuardrailsFile = typeof GuardrailsFileSchema.Type;
687
+ /**
688
+ * Decode helpers.
689
+ */
690
+ declare const decodeGuardrail: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
691
+ readonly iteration: number;
692
+ readonly id: string;
693
+ readonly createdAt: string;
694
+ readonly pattern: string;
695
+ readonly sign: string;
696
+ readonly avoidance: string;
697
+ readonly severity: "warning" | "critical";
698
+ }, effect_ParseResult.ParseError, never>;
699
+ declare const decodeGuardrailsFile: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
700
+ readonly sessionId: string;
701
+ readonly createdAt: string;
702
+ readonly guardrails: readonly {
703
+ readonly iteration: number;
704
+ readonly id: string;
705
+ readonly createdAt: string;
706
+ readonly pattern: string;
707
+ readonly sign: string;
708
+ readonly avoidance: string;
709
+ readonly severity: "warning" | "critical";
710
+ }[];
711
+ }, effect_ParseResult.ParseError, never>;
712
+
569
713
  declare const TextEventSchema: Schema.TaggedStruct<"Text", {
570
714
  text: typeof Schema.String;
571
715
  }>;
@@ -845,6 +989,77 @@ declare const RunOptionsDataSchema: Schema.Struct<{
845
989
  }>;
846
990
  type RunOptionsData = typeof RunOptionsDataSchema.Type;
847
991
 
992
+ /**
993
+ * Action types for progress entries.
994
+ */
995
+ declare const ProgressActionSchema: Schema.Literal<["started", "completed", "failed", "learning"]>;
996
+ type ProgressAction = typeof ProgressActionSchema.Type;
997
+ /**
998
+ * A single progress entry for the append-only log.
999
+ *
1000
+ * Each entry records what happened in an iteration, including:
1001
+ * - Which task was worked on
1002
+ * - What action was taken
1003
+ * - A summary of the work
1004
+ * - Any learnings discovered
1005
+ * - Files that were modified
1006
+ */
1007
+ declare const ProgressEntrySchema: Schema.Struct<{
1008
+ iteration: typeof Schema.Number;
1009
+ timestamp: typeof Schema.String;
1010
+ taskId: typeof Schema.String;
1011
+ action: Schema.Literal<["started", "completed", "failed", "learning"]>;
1012
+ summary: typeof Schema.String;
1013
+ learnings: Schema.optional<Schema.Array$<typeof Schema.String>>;
1014
+ filesModified: Schema.optional<Schema.Array$<typeof Schema.String>>;
1015
+ }>;
1016
+ type ProgressEntry = typeof ProgressEntrySchema.Type;
1017
+ /**
1018
+ * The complete progress file structure.
1019
+ *
1020
+ * Contains session metadata and an array of progress entries.
1021
+ * This is the structure persisted to `.ferix/plans/:sessionId/progress.md`.
1022
+ */
1023
+ declare const ProgressFileSchema: Schema.Struct<{
1024
+ sessionId: typeof Schema.String;
1025
+ createdAt: typeof Schema.String;
1026
+ entries: Schema.Array$<Schema.Struct<{
1027
+ iteration: typeof Schema.Number;
1028
+ timestamp: typeof Schema.String;
1029
+ taskId: typeof Schema.String;
1030
+ action: Schema.Literal<["started", "completed", "failed", "learning"]>;
1031
+ summary: typeof Schema.String;
1032
+ learnings: Schema.optional<Schema.Array$<typeof Schema.String>>;
1033
+ filesModified: Schema.optional<Schema.Array$<typeof Schema.String>>;
1034
+ }>>;
1035
+ }>;
1036
+ type ProgressFile = typeof ProgressFileSchema.Type;
1037
+ /**
1038
+ * Decode helpers.
1039
+ */
1040
+ declare const decodeProgressEntry: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
1041
+ readonly iteration: number;
1042
+ readonly taskId: string;
1043
+ readonly summary: string;
1044
+ readonly filesModified?: readonly string[] | undefined;
1045
+ readonly timestamp: string;
1046
+ readonly action: "failed" | "started" | "completed" | "learning";
1047
+ readonly learnings?: readonly string[] | undefined;
1048
+ }, effect_ParseResult.ParseError, never>;
1049
+ declare const decodeProgressFile: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
1050
+ readonly entries: readonly {
1051
+ readonly iteration: number;
1052
+ readonly taskId: string;
1053
+ readonly summary: string;
1054
+ readonly filesModified?: readonly string[] | undefined;
1055
+ readonly timestamp: string;
1056
+ readonly action: "failed" | "started" | "completed" | "learning";
1057
+ readonly learnings?: readonly string[] | undefined;
1058
+ }[];
1059
+ readonly sessionId: string;
1060
+ readonly createdAt: string;
1061
+ }, effect_ParseResult.ParseError, never>;
1062
+
848
1063
  /**
849
1064
  * Session status schema.
850
1065
  */
@@ -868,7 +1083,7 @@ type Session = typeof SessionSchema.Type;
868
1083
  declare const decodeSession: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => effect_Effect.Effect<{
869
1084
  readonly completedTasks: readonly string[];
870
1085
  readonly id: string;
871
- readonly status: "failed" | "active" | "completed" | "paused";
1086
+ readonly status: "failed" | "completed" | "active" | "paused";
872
1087
  readonly createdAt: string;
873
1088
  readonly originalTask: string;
874
1089
  readonly currentTaskId?: string | undefined;
@@ -1024,6 +1239,29 @@ declare const TaskCompleteSignalSchema: Schema.TaggedStruct<"TaskComplete", Read
1024
1239
  type TaskCompleteSignal = typeof TaskCompleteSignalSchema.Type;
1025
1240
  declare const LoopCompleteSignalSchema: Schema.TaggedStruct<"LoopComplete", {}>;
1026
1241
  type LoopCompleteSignal = typeof LoopCompleteSignalSchema.Type;
1242
+ /**
1243
+ * Learning category types.
1244
+ */
1245
+ declare const LearningCategorySchema: Schema.Literal<["success", "failure", "optimization"]>;
1246
+ type LearningCategory = typeof LearningCategorySchema.Type;
1247
+ /**
1248
+ * Learning signal - records insights discovered during iteration.
1249
+ */
1250
+ declare const LearningSignalSchema: Schema.TaggedStruct<"Learning", {
1251
+ content: typeof Schema.String;
1252
+ category: Schema.optional<Schema.Literal<["success", "failure", "optimization"]>>;
1253
+ }>;
1254
+ type LearningSignal = typeof LearningSignalSchema.Type;
1255
+ /**
1256
+ * Guardrail signal - records failure patterns to avoid.
1257
+ */
1258
+ declare const GuardrailSignalSchema: Schema.TaggedStruct<"Guardrail", {
1259
+ pattern: typeof Schema.String;
1260
+ sign: typeof Schema.String;
1261
+ avoidance: typeof Schema.String;
1262
+ severity: Schema.Literal<["warning", "critical"]>;
1263
+ }>;
1264
+ type GuardrailSignal = typeof GuardrailSignalSchema.Type;
1027
1265
  /**
1028
1266
  * Union of all signals.
1029
1267
  */
@@ -1064,7 +1302,15 @@ declare const SignalSchema: Schema.Union<[Schema.TaggedStruct<"TasksDefined", Re
1064
1302
  summary: typeof Schema.String;
1065
1303
  filesModified: Schema.Array$<typeof Schema.String>;
1066
1304
  filesCreated: Schema.Array$<typeof Schema.String>;
1067
- }>>, Schema.TaggedStruct<"LoopComplete", {}>]>;
1305
+ }>>, Schema.TaggedStruct<"LoopComplete", {}>, Schema.TaggedStruct<"Learning", {
1306
+ content: typeof Schema.String;
1307
+ category: Schema.optional<Schema.Literal<["success", "failure", "optimization"]>>;
1308
+ }>, Schema.TaggedStruct<"Guardrail", {
1309
+ pattern: typeof Schema.String;
1310
+ sign: typeof Schema.String;
1311
+ avoidance: typeof Schema.String;
1312
+ severity: Schema.Literal<["warning", "critical"]>;
1313
+ }>]>;
1068
1314
  type Signal = typeof SignalSchema.Type;
1069
1315
  /**
1070
1316
  * Decode helpers.
@@ -1122,6 +1368,16 @@ declare const decodeSignal: (u: unknown, overrideOptions?: effect_SchemaAST.Pars
1122
1368
  readonly filesCreated: readonly string[];
1123
1369
  } | {
1124
1370
  readonly _tag: "LoopComplete";
1371
+ } | {
1372
+ readonly _tag: "Learning";
1373
+ readonly content: string;
1374
+ readonly category?: "success" | "failure" | "optimization" | undefined;
1375
+ } | {
1376
+ readonly _tag: "Guardrail";
1377
+ readonly pattern: string;
1378
+ readonly sign: string;
1379
+ readonly avoidance: string;
1380
+ readonly severity: "warning" | "critical";
1125
1381
  }, effect_ParseResult.ParseError, never>;
1126
1382
  declare const decodeSignalSync: (u: unknown, overrideOptions?: effect_SchemaAST.ParseOptions) => {
1127
1383
  readonly _tag: "CheckPassed";
@@ -1176,6 +1432,16 @@ declare const decodeSignalSync: (u: unknown, overrideOptions?: effect_SchemaAST.
1176
1432
  readonly filesCreated: readonly string[];
1177
1433
  } | {
1178
1434
  readonly _tag: "LoopComplete";
1435
+ } | {
1436
+ readonly _tag: "Learning";
1437
+ readonly content: string;
1438
+ readonly category?: "success" | "failure" | "optimization" | undefined;
1439
+ } | {
1440
+ readonly _tag: "Guardrail";
1441
+ readonly pattern: string;
1442
+ readonly sign: string;
1443
+ readonly avoidance: string;
1444
+ readonly severity: "warning" | "critical";
1179
1445
  };
1180
1446
 
1181
1447
  /**
@@ -1493,16 +1759,114 @@ declare function createMockLLM(config: MockLLMConfig): LLMService;
1493
1759
  * });
1494
1760
  * ```
1495
1761
  */
1496
- declare function layer$2(config: MockLLMConfig): Layer.Layer<LLM>;
1762
+ declare function layer$4(config: MockLLMConfig): Layer.Layer<LLM>;
1497
1763
  /**
1498
1764
  * Mock namespace containing the Live layer and factory functions.
1499
1765
  */
1500
1766
  declare const Mock: {
1501
1767
  readonly Live: Layer.Layer<LLM, never, never>;
1502
- readonly layer: typeof layer$2;
1768
+ readonly layer: typeof layer$4;
1503
1769
  readonly createMockLLM: typeof createMockLLM;
1504
1770
  };
1505
1771
 
1772
+ /**
1773
+ * Service interface for guardrails persistence.
1774
+ *
1775
+ * Guardrails are stored at `.ferix/plans/:sessionId/guardrails.md`.
1776
+ * They represent failure patterns learned from previous iterations
1777
+ * that the LLM should avoid.
1778
+ *
1779
+ * Implementations include:
1780
+ * - FileSystem: Persists to `.ferix/plans/` directory
1781
+ * - Memory: In-memory storage for testing
1782
+ *
1783
+ * @example
1784
+ * ```typescript
1785
+ * const guardrailsStore = yield* GuardrailsStore;
1786
+ *
1787
+ * // Add a guardrail
1788
+ * yield* guardrailsStore.add(sessionId, {
1789
+ * id: "gr-1",
1790
+ * createdAt: new Date().toISOString(),
1791
+ * iteration: 3,
1792
+ * pattern: "Modifying package.json without running install",
1793
+ * sign: "Build failures after dependency changes",
1794
+ * avoidance: "Always run npm install after modifying package.json",
1795
+ * severity: "critical",
1796
+ * });
1797
+ *
1798
+ * // Load all guardrails
1799
+ * const guardrails = yield* guardrailsStore.load(sessionId);
1800
+ *
1801
+ * // Get active guardrails for prompt
1802
+ * const active = yield* guardrailsStore.getActive(sessionId);
1803
+ * ```
1804
+ */
1805
+ interface GuardrailsStoreService {
1806
+ /**
1807
+ * Add a guardrail to the session's collection.
1808
+ *
1809
+ * @param sessionId - Session this guardrail belongs to
1810
+ * @param guardrail - Guardrail to add
1811
+ */
1812
+ readonly add: (sessionId: string, guardrail: Guardrail) => Effect.Effect<void, GuardrailsStoreError>;
1813
+ /**
1814
+ * Load the complete guardrails file for a session.
1815
+ *
1816
+ * @param sessionId - Session to load guardrails for
1817
+ * @returns The guardrails file with all entries
1818
+ */
1819
+ readonly load: (sessionId: string) => Effect.Effect<GuardrailsFile, GuardrailsStoreError>;
1820
+ /**
1821
+ * Get all active guardrails for a session.
1822
+ *
1823
+ * @param sessionId - Session to get guardrails for
1824
+ * @returns Array of active guardrails
1825
+ */
1826
+ readonly getActive: (sessionId: string) => Effect.Effect<readonly Guardrail[], GuardrailsStoreError>;
1827
+ }
1828
+ declare const GuardrailsStore_base: Context.TagClass<GuardrailsStore, "@ferix/GuardrailsStore", GuardrailsStoreService>;
1829
+ /**
1830
+ * Effect Tag for the GuardrailsStore service.
1831
+ *
1832
+ * Use this tag to depend on guardrails storage without coupling to a specific backend.
1833
+ */
1834
+ declare class GuardrailsStore extends GuardrailsStore_base {
1835
+ }
1836
+
1837
+ /**
1838
+ * FileSystemGuardrails namespace containing the Live layer.
1839
+ */
1840
+ declare const FileSystemGuardrails: {
1841
+ readonly Live: Layer.Layer<GuardrailsStore, never, never>;
1842
+ };
1843
+
1844
+ /**
1845
+ * Creates a Layer for an in-memory guardrails store.
1846
+ *
1847
+ * Each call creates a new isolated store.
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * const testLayer = MemoryGuardrails.layer();
1852
+ *
1853
+ * const program = Effect.gen(function* () {
1854
+ * const guardrailsStore = yield* GuardrailsStore;
1855
+ * yield* guardrailsStore.add(sessionId, guardrail);
1856
+ * });
1857
+ *
1858
+ * Effect.runPromise(program.pipe(Effect.provide(testLayer)));
1859
+ * ```
1860
+ */
1861
+ declare function layer$3(): Layer.Layer<GuardrailsStore>;
1862
+ /**
1863
+ * MemoryGuardrails namespace containing the Live layer and factory.
1864
+ */
1865
+ declare const MemoryGuardrails: {
1866
+ readonly Live: Layer.Layer<GuardrailsStore, never, never>;
1867
+ readonly layer: typeof layer$3;
1868
+ };
1869
+
1506
1870
  /**
1507
1871
  * ClaudeCLI namespace containing the Live layer.
1508
1872
  */
@@ -1600,12 +1964,108 @@ declare const FileSystemPlan: {
1600
1964
  * Effect.runPromise(program.pipe(Effect.provide(testLayer)));
1601
1965
  * ```
1602
1966
  */
1603
- declare function layer$1(): Layer.Layer<PlanStore>;
1967
+ declare function layer$2(): Layer.Layer<PlanStore>;
1604
1968
  /**
1605
1969
  * MemoryPlan namespace containing the Live layer and factory.
1606
1970
  */
1607
1971
  declare const MemoryPlan: {
1608
1972
  readonly Live: Layer.Layer<PlanStore, never, never>;
1973
+ readonly layer: typeof layer$2;
1974
+ };
1975
+
1976
+ /**
1977
+ * Service interface for progress persistence.
1978
+ *
1979
+ * Progress is stored as an append-only log at `.ferix/plans/:sessionId/progress.md`.
1980
+ * Each iteration appends entries recording what happened.
1981
+ *
1982
+ * Implementations include:
1983
+ * - FileSystem: Persists to `.ferix/plans/` directory
1984
+ * - Memory: In-memory storage for testing
1985
+ *
1986
+ * @example
1987
+ * ```typescript
1988
+ * const progressStore = yield* ProgressStore;
1989
+ *
1990
+ * // Append a progress entry
1991
+ * yield* progressStore.append(sessionId, {
1992
+ * iteration: 1,
1993
+ * timestamp: new Date().toISOString(),
1994
+ * taskId: "task-1",
1995
+ * action: "started",
1996
+ * summary: "Started implementing feature X",
1997
+ * });
1998
+ *
1999
+ * // Load all progress
2000
+ * const progress = yield* progressStore.load(sessionId);
2001
+ *
2002
+ * // Get recent entries
2003
+ * const recent = yield* progressStore.getRecent(sessionId, 5);
2004
+ * ```
2005
+ */
2006
+ interface ProgressStoreService {
2007
+ /**
2008
+ * Append a progress entry to the session's log.
2009
+ *
2010
+ * @param sessionId - Session this entry belongs to
2011
+ * @param entry - Progress entry to append
2012
+ */
2013
+ readonly append: (sessionId: string, entry: ProgressEntry) => Effect.Effect<void, ProgressStoreError>;
2014
+ /**
2015
+ * Load the complete progress file for a session.
2016
+ *
2017
+ * @param sessionId - Session to load progress for
2018
+ * @returns The progress file with all entries
2019
+ */
2020
+ readonly load: (sessionId: string) => Effect.Effect<ProgressFile, ProgressStoreError>;
2021
+ /**
2022
+ * Get the most recent progress entries for a session.
2023
+ *
2024
+ * @param sessionId - Session to get progress for
2025
+ * @param count - Number of recent entries to return
2026
+ * @returns Array of recent progress entries
2027
+ */
2028
+ readonly getRecent: (sessionId: string, count: number) => Effect.Effect<readonly ProgressEntry[], ProgressStoreError>;
2029
+ }
2030
+ declare const ProgressStore_base: Context.TagClass<ProgressStore, "@ferix/ProgressStore", ProgressStoreService>;
2031
+ /**
2032
+ * Effect Tag for the ProgressStore service.
2033
+ *
2034
+ * Use this tag to depend on progress storage without coupling to a specific backend.
2035
+ */
2036
+ declare class ProgressStore extends ProgressStore_base {
2037
+ }
2038
+
2039
+ /**
2040
+ * FileSystemProgress namespace containing the Live layer.
2041
+ */
2042
+ declare const FileSystemProgress: {
2043
+ readonly Live: Layer.Layer<ProgressStore, never, never>;
2044
+ };
2045
+
2046
+ /**
2047
+ * Creates a Layer for an in-memory progress store.
2048
+ *
2049
+ * Each call creates a new isolated store.
2050
+ *
2051
+ * @example
2052
+ * ```typescript
2053
+ * const testLayer = MemoryProgress.layer();
2054
+ *
2055
+ * const program = Effect.gen(function* () {
2056
+ * const progressStore = yield* ProgressStore;
2057
+ * yield* progressStore.append(sessionId, entry);
2058
+ * });
2059
+ *
2060
+ * Effect.runPromise(program.pipe(Effect.provide(testLayer)));
2061
+ * ```
2062
+ */
2063
+ declare function layer$1(): Layer.Layer<ProgressStore>;
2064
+ /**
2065
+ * MemoryProgress namespace containing the Live layer and factory.
2066
+ */
2067
+ declare const MemoryProgress: {
2068
+ readonly Live: Layer.Layer<ProgressStore, never, never>;
1609
2069
  readonly layer: typeof layer$1;
1610
2070
  };
1611
2071
 
@@ -1790,7 +2250,7 @@ declare const FerixParser: {
1790
2250
  * Uses real implementations:
1791
2251
  * - Claude CLI for LLM
1792
2252
  * - Ferix parser for signals
1793
- * - File system for plan and session storage
2253
+ * - File system for plan, session, progress, and guardrails storage
1794
2254
  *
1795
2255
  * @example
1796
2256
  * ```typescript
@@ -1804,14 +2264,14 @@ declare const FerixParser: {
1804
2264
  * );
1805
2265
  * ```
1806
2266
  */
1807
- declare const ProductionLayers: Layer.Layer<LLM | PlanStore | SessionStore | SignalParser, never, never>;
2267
+ declare const ProductionLayers: Layer.Layer<LLM | SignalParser | PlanStore | SessionStore | ProgressStore | GuardrailsStore, never, never>;
1808
2268
  /**
1809
2269
  * Test layer bundle.
1810
2270
  *
1811
2271
  * Uses mock/in-memory implementations:
1812
2272
  * - Mock LLM (configurable events)
1813
2273
  * - Ferix parser (real implementation - pure)
1814
- * - In-memory plan and session storage
2274
+ * - In-memory plan, session, progress, and guardrails storage
1815
2275
  *
1816
2276
  * @example
1817
2277
  * ```typescript
@@ -1827,7 +2287,7 @@ declare const ProductionLayers: Layer.Layer<LLM | PlanStore | SessionStore | Sig
1827
2287
  * expect(result).toContainEqual({ _tag: "LoopCompleted", ... });
1828
2288
  * ```
1829
2289
  */
1830
- declare const TestLayers: Layer.Layer<LLM | PlanStore | SessionStore | SignalParser, never, never>;
2290
+ declare const TestLayers: Layer.Layer<LLM | SignalParser | PlanStore | SessionStore | ProgressStore | GuardrailsStore, never, never>;
1831
2291
  /**
1832
2292
  * Creates a test layer bundle with custom mock LLM events.
1833
2293
  *
@@ -1844,12 +2304,13 @@ declare const TestLayers: Layer.Layer<LLM | PlanStore | SessionStore | SignalPar
1844
2304
  * Effect.runPromise(program.pipe(Effect.provide(customTestLayers)));
1845
2305
  * ```
1846
2306
  */
1847
- declare function createTestLayers(events: Parameters<typeof Mock.layer>[0]["events"]): Layer.Layer<LLM | PlanStore | SessionStore | SignalParser, never, never>;
2307
+ declare function createTestLayers(events: Parameters<typeof Mock.layer>[0]["events"]): Layer.Layer<LLM | SignalParser | PlanStore | SessionStore | ProgressStore | GuardrailsStore, never, never>;
1848
2308
 
1849
2309
  /**
1850
2310
  * Required services for the orchestrator.
2311
+ * Now includes ProgressStore and GuardrailsStore for RALPH pattern support.
1851
2312
  */
1852
- type OrchestratorServices = LLM | SignalParser | PlanStore | SessionStore;
2313
+ type OrchestratorServices = LLM | SignalParser | PlanStore | SessionStore | ProgressStore | GuardrailsStore;
1853
2314
  /**
1854
2315
  * Run the ralph loop.
1855
2316
  *
@@ -2009,4 +2470,4 @@ declare function collectEvents(config: LoopConfig, mockEvents?: readonly LLMEven
2009
2470
  */
2010
2471
  declare function main(config: LoopConfig): Promise<void>;
2011
2472
 
2012
- export { type CheckFailedEvent, CheckFailedEventSchema, type CheckFailedSignal, CheckFailedSignalSchema, type CheckPassedEvent, CheckPassedEventSchema, type CheckPassedSignal, CheckPassedSignalSchema, ClaudeCLI, type ConsoleLoggerConfig, ConsoleLoggerConfigSchema, type Consumer, type ConsumerType, ConsumerTypeSchema, type CriteriaDefinedData, CriteriaDefinedDataSchema, type CriteriaDefinedEvent, CriteriaDefinedEventSchema, type CriteriaDefinedSignal, CriteriaDefinedSignalSchema, type Criterion, type CriterionBasicInfo, CriterionBasicInfoSchema, type CriterionFailedData, CriterionFailedDataSchema, type CriterionFailedEvent, CriterionFailedEventSchema, type CriterionFailedSignal, CriterionFailedSignalSchema, type CriterionIdData, CriterionIdDataSchema, type CriterionPassedEvent, CriterionPassedEventSchema, type CriterionPassedSignal, CriterionPassedSignalSchema, CriterionSchema, type CriterionStatus, CriterionStatusSchema, type DiscoveryCompletedEvent, DiscoveryCompletedEventSchema, type DiscoveryStartedEvent, DiscoveryStartedEventSchema, type DomainEvent, DomainEventSchema, DomainEventUtils, type DoneEvent, DoneEventSchema, type ExecutionMode, ExecutionModeSchema, type FerixError, FerixParser, type FileLoggerConfig, FileLoggerConfigSchema, FileSystemPlan, FileSystemSession, type GeneratedTask, type GeneratedTaskList, GeneratedTaskListSchema, GeneratedTaskSchema, type GeneratedTaskStatus, GeneratedTaskStatusSchema, type IterationCompletedEvent, IterationCompletedEventSchema, type IterationStartedEvent, IterationStartedEventSchema, LLM, LLMError, type LLMEvent, LLMEventSchema, type LLMService, type LLMTextEvent, LLMTextEventSchema, type LLMToolEndEvent, LLMToolEndEventSchema, type LLMToolStartEvent, LLMToolStartEventSchema, type LLMToolUseEvent, LLMToolUseEventSchema, type LogEntry, LogEntrySchema, type LogLevel, LogLevelSchema, type LoopCompleteSignal, LoopCompleteSignalSchema, type LoopCompletedEvent, LoopCompletedEventSchema, type LoopConfig, LoopConfigSchema, type LoopError, LoopErrorSchema, type LoopFailedEvent, LoopFailedEventSchema, type LoopStartedEvent, LoopStartedEventSchema, type LoopStatus, LoopStatusSchema, type LoopSummary, LoopSummarySchema, MemoryPlan, MemorySession, Mock, Mock as MockLLM, OrchestratorError, type OrchestratorServices, ParseError, type Phase, type PhaseBasicInfo, PhaseBasicInfoSchema, type PhaseCompletedEvent, PhaseCompletedEventSchema, type PhaseCompletedSignal, PhaseCompletedSignalSchema, type PhaseFailedData, PhaseFailedDataSchema, type PhaseFailedEvent, PhaseFailedEventSchema, type PhaseFailedSignal, PhaseFailedSignalSchema, type PhaseIdData, PhaseIdDataSchema, type PhasePromptOverrides, PhasePromptOverridesSchema, PhaseSchema, type PhaseStartedEvent, PhaseStartedEventSchema, type PhaseStartedSignal, PhaseStartedSignalSchema, type PhaseStatus, PhaseStatusSchema, type PhasesDefinedData, PhasesDefinedDataSchema, type PhasesDefinedEvent, PhasesDefinedEventSchema, type PhasesDefinedSignal, PhasesDefinedSignalSchema, type Plan, type PlanCreatedEvent, PlanCreatedEventSchema, type PlanData, PlanDataSchema, PlanId, PlanSchema, PlanStore, PlanStoreError, type PlanStoreService, type PlanUpdateFailedEvent, PlanUpdateFailedEventSchema, type PlanUpdatedEvent, PlanUpdatedEventSchema, ProductionLayers, type PromptConfig, PromptConfigSchema, type ReviewCompleteData, ReviewCompleteDataSchema, type ReviewCompleteEvent, ReviewCompleteEventSchema, type ReviewCompleteSignal, ReviewCompleteSignalSchema, type RunOptions, type RunOptionsData, RunOptionsDataSchema, type Session, SessionSchema, type SessionStatus, SessionStatusSchema, SessionStore, SessionStoreError, type SessionStoreService, type Signal, type SignalAccumulator, SignalParser, type SignalParserService, SignalSchema, type TUICriterion, TUICriterionSchema, type TUICriterionStatus, TUICriterionStatusSchema, type TUIPhase, TUIPhaseSchema, type TUIPhaseStatus, TUIPhaseStatusSchema, type TUIState, TUIStateSchema, type TUITask, TUITaskSchema, type TUITaskStatus, TUITaskStatusSchema, type Task, type TaskBasicInfo, TaskBasicInfoSchema, type TaskCompleteData, TaskCompleteDataSchema, type TaskCompleteSignal, type TaskCompleteSignalData, TaskCompleteSignalDataSchema, TaskCompleteSignalSchema, type TaskCompletedEvent, TaskCompletedEventSchema, TaskSchema, type TaskStatus, TaskStatusSchema, type TasksDefinedData, TasksDefinedDataSchema, type TasksDefinedEvent, TasksDefinedEventSchema, type TasksDefinedSignal, TasksDefinedSignalSchema, TestLayers, type TextEvent, TextEventSchema, type ToolEndEvent, ToolEndEventSchema, type ToolStartEvent, ToolStartEventSchema, type ToolUseEvent, ToolUseEventSchema, type ViewMode, ViewModeSchema, buildPrompt, collectEvents, createHeadlessConsumer, createTUIConsumer, createTestLayers, decodeLLMEvent, decodeLoopConfig, decodePlan, decodePlanData, decodeSession, decodeSignal, decodeSignalSync, formatTasksMd, main, parseTasksMd, run, runLoop, runTest };
2473
+ export { type CheckFailedEvent, CheckFailedEventSchema, type CheckFailedSignal, CheckFailedSignalSchema, type CheckPassedEvent, CheckPassedEventSchema, type CheckPassedSignal, CheckPassedSignalSchema, ClaudeCLI, type ConsoleLoggerConfig, ConsoleLoggerConfigSchema, type Consumer, type ConsumerType, ConsumerTypeSchema, type CriteriaDefinedData, CriteriaDefinedDataSchema, type CriteriaDefinedEvent, CriteriaDefinedEventSchema, type CriteriaDefinedSignal, CriteriaDefinedSignalSchema, type Criterion, type CriterionBasicInfo, CriterionBasicInfoSchema, type CriterionFailedData, CriterionFailedDataSchema, type CriterionFailedEvent, CriterionFailedEventSchema, type CriterionFailedSignal, CriterionFailedSignalSchema, type CriterionIdData, CriterionIdDataSchema, type CriterionPassedEvent, CriterionPassedEventSchema, type CriterionPassedSignal, CriterionPassedSignalSchema, CriterionSchema, type CriterionStatus, CriterionStatusSchema, type DiscoveryCompletedEvent, DiscoveryCompletedEventSchema, type DiscoveryStartedEvent, DiscoveryStartedEventSchema, type DomainEvent, DomainEventSchema, DomainEventUtils, type DoneEvent, DoneEventSchema, type ExecutionMode, ExecutionModeSchema, type FerixError, FerixParser, type FileLoggerConfig, FileLoggerConfigSchema, FileSystemGuardrails, FileSystemPlan, FileSystemProgress, FileSystemSession, type GeneratedTask, type GeneratedTaskList, GeneratedTaskListSchema, GeneratedTaskSchema, type GeneratedTaskStatus, GeneratedTaskStatusSchema, type Guardrail, type GuardrailAddedEvent, GuardrailAddedEventSchema, GuardrailSchema, type GuardrailSeverity, GuardrailSeveritySchema, type GuardrailSignal, GuardrailSignalSchema, type GuardrailsFile, GuardrailsFileSchema, GuardrailsStore, GuardrailsStoreError, type GuardrailsStoreService, type IterationCompletedEvent, IterationCompletedEventSchema, type IterationStartedEvent, IterationStartedEventSchema, LLM, LLMError, type LLMEvent, LLMEventSchema, type LLMService, type LLMTextEvent, LLMTextEventSchema, type LLMToolEndEvent, LLMToolEndEventSchema, type LLMToolStartEvent, LLMToolStartEventSchema, type LLMToolUseEvent, LLMToolUseEventSchema, type LearningCategory, LearningCategorySchema, type LearningRecordedEvent, LearningRecordedEventSchema, type LearningSignal, LearningSignalSchema, type LogEntry, LogEntrySchema, type LogLevel, LogLevelSchema, type LoopCompleteSignal, LoopCompleteSignalSchema, type LoopCompletedEvent, LoopCompletedEventSchema, type LoopConfig, LoopConfigSchema, type LoopError, LoopErrorSchema, type LoopFailedEvent, LoopFailedEventSchema, type LoopStartedEvent, LoopStartedEventSchema, type LoopStatus, LoopStatusSchema, type LoopSummary, LoopSummarySchema, MemoryGuardrails, MemoryPlan, MemoryProgress, MemorySession, Mock, Mock as MockLLM, OrchestratorError, type OrchestratorServices, ParseError, type Phase, type PhaseBasicInfo, PhaseBasicInfoSchema, type PhaseCompletedEvent, PhaseCompletedEventSchema, type PhaseCompletedSignal, PhaseCompletedSignalSchema, type PhaseFailedData, PhaseFailedDataSchema, type PhaseFailedEvent, PhaseFailedEventSchema, type PhaseFailedSignal, PhaseFailedSignalSchema, type PhaseIdData, PhaseIdDataSchema, type PhasePromptOverrides, PhasePromptOverridesSchema, PhaseSchema, type PhaseStartedEvent, PhaseStartedEventSchema, type PhaseStartedSignal, PhaseStartedSignalSchema, type PhaseStatus, PhaseStatusSchema, type PhasesDefinedData, PhasesDefinedDataSchema, type PhasesDefinedEvent, PhasesDefinedEventSchema, type PhasesDefinedSignal, PhasesDefinedSignalSchema, type Plan, type PlanCreatedEvent, PlanCreatedEventSchema, type PlanData, PlanDataSchema, PlanId, PlanSchema, PlanStore, PlanStoreError, type PlanStoreService, type PlanUpdateFailedEvent, PlanUpdateFailedEventSchema, type PlanUpdatedEvent, PlanUpdatedEventSchema, ProductionLayers, type ProgressAction, ProgressActionSchema, type ProgressEntry, ProgressEntrySchema, type ProgressFile, ProgressFileSchema, ProgressStore, ProgressStoreError, type ProgressStoreService, type ProgressUpdatedEvent, ProgressUpdatedEventSchema, type PromptConfig, PromptConfigSchema, type ReviewCompleteData, ReviewCompleteDataSchema, type ReviewCompleteEvent, ReviewCompleteEventSchema, type ReviewCompleteSignal, ReviewCompleteSignalSchema, type RunOptions, type RunOptionsData, RunOptionsDataSchema, type Session, SessionSchema, type SessionStatus, SessionStatusSchema, SessionStore, SessionStoreError, type SessionStoreService, type Signal, type SignalAccumulator, SignalParser, type SignalParserService, SignalSchema, type TUICriterion, TUICriterionSchema, type TUICriterionStatus, TUICriterionStatusSchema, type TUIPhase, TUIPhaseSchema, type TUIPhaseStatus, TUIPhaseStatusSchema, type TUIState, TUIStateSchema, type TUITask, TUITaskSchema, type TUITaskStatus, TUITaskStatusSchema, type Task, type TaskBasicInfo, TaskBasicInfoSchema, type TaskCompleteData, TaskCompleteDataSchema, type TaskCompleteSignal, type TaskCompleteSignalData, TaskCompleteSignalDataSchema, TaskCompleteSignalSchema, type TaskCompletedEvent, TaskCompletedEventSchema, TaskSchema, type TaskStatus, TaskStatusSchema, type TasksDefinedData, TasksDefinedDataSchema, type TasksDefinedEvent, TasksDefinedEventSchema, type TasksDefinedSignal, TasksDefinedSignalSchema, TestLayers, type TextEvent, TextEventSchema, type ToolEndEvent, ToolEndEventSchema, type ToolStartEvent, ToolStartEventSchema, type ToolUseEvent, ToolUseEventSchema, type ViewMode, ViewModeSchema, buildPrompt, collectEvents, createHeadlessConsumer, createTUIConsumer, createTestLayers, decodeGuardrail, decodeGuardrailsFile, decodeLLMEvent, decodeLoopConfig, decodePlan, decodePlanData, decodeProgressEntry, decodeProgressFile, decodeSession, decodeSignal, decodeSignalSync, formatTasksMd, main, parseTasksMd, run, runLoop, runTest };