Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/features/cycle-management/bridge-run-syncer.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { expect, vi } from 'vitest';
import type { BetOutcome } from '@domain/types/bet.js';
import type { Cycle } from '@domain/types/cycle.js';
import { logger } from '@shared/lib/logger.js';
import type { BetOutcomeRecord, IncompleteRunInfo } from './cooldown-session.js';
import type { BetOutcomeRecord, IncompleteRunInfo } from './cooldown-types.js';
import { BridgeRunSyncer, type BridgeRunSyncerDeps } from './bridge-run-syncer.js';

// ── World ────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion src/features/cycle-management/bridge-run-syncer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
import { vi } from 'vitest';
import type { Cycle } from '@domain/types/cycle.js';
import { BridgeRunSyncer, type BridgeRunSyncerDeps } from './bridge-run-syncer.js';
import type { BetOutcomeRecord } from './cooldown-session.js';
import type { BetOutcomeRecord } from './cooldown-types.js';

// ── Helpers ──────────────────────────────────────────────────

Expand Down
2 changes: 1 addition & 1 deletion src/features/cycle-management/bridge-run-syncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CycleManager } from '@domain/services/cycle-manager.js';
import { logger } from '@shared/lib/logger.js';
import { JsonStoreError } from '@infra/persistence/json-store.js';
import { readRun } from '@infra/persistence/run-store.js';
import type { BetOutcomeRecord, IncompleteRunInfo } from './cooldown-session.js';
import type { BetOutcomeRecord, IncompleteRunInfo } from './cooldown-types.js';
import {
collectBridgeRunIds,
isJsonFile,
Expand Down
2 changes: 2 additions & 0 deletions src/features/cycle-management/cooldown-belt-computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export interface CooldownBeltDeps {
beltCalculator?: Pick<BeltCalculator, 'computeAndStore'>;
projectStateFile?: string;
agentConfidenceCalculator?: Pick<KataAgentConfidenceCalculator, 'compute'>;
/** @deprecated Use `agentConfidenceCalculator` instead. Will be removed in v1. */
katakaConfidenceCalculator?: Pick<KataAgentConfidenceCalculator, 'compute'>;
agentDir?: string;
/** @deprecated Use `agentDir` instead. Will be removed in v1. */
katakaDir?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { After, Given, Then, When, QuickPickleWorld } from 'quickpickle';
import { expect, vi } from 'vitest';
import { logger } from '@shared/lib/logger.js';
import type { Cycle } from '@domain/types/cycle.js';
import type { BetOutcomeRecord } from './cooldown-session.js';
import type { BetOutcomeRecord } from './cooldown-types.js';
import type { CooldownDiaryWriter, CooldownDiaryDeps, DiaryEntryInput } from './cooldown-diary-writer.js';
import type { SynthesisProposal } from '@domain/types/synthesis.js';
import type { SessionBuilder } from '@features/dojo/session-builder.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { vi } from 'vitest';
import { logger } from '@shared/lib/logger.js';
import { CooldownDiaryWriter, type CooldownDiaryDeps } from './cooldown-diary-writer.js';
import type { Cycle } from '@domain/types/cycle.js';
import type { BetOutcomeRecord } from './cooldown-session.js';
import type { BetOutcomeRecord } from './cooldown-types.js';
import type { SynthesisProposal } from '@domain/types/synthesis.js';

function makeCycle(bets: { id: string; description: string; outcome?: string }[]): Cycle {
Expand Down
2 changes: 1 addition & 1 deletion src/features/cycle-management/cooldown-diary-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DiaryWriter } from '@features/dojo/diary-writer.js';
import { DiaryStore } from '@infra/dojo/diary-store.js';
import { DataAggregator } from '@features/dojo/data-aggregator.js';
import { logger } from '@shared/lib/logger.js';
import type { BetOutcomeRecord } from './cooldown-session.js';
import type { BetOutcomeRecord } from './cooldown-types.js';
import type { CycleProposal } from './proposal-generator.js';
import type { RunSummary } from './types.js';
import {
Expand Down
82 changes: 6 additions & 76 deletions src/features/cycle-management/cooldown-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { HierarchicalPromoter } from '@infra/knowledge/hierarchical-promoter.js'
import { FrictionAnalyzer } from '@features/self-improvement/friction-analyzer.js';
import type { SynthesisProposal } from '@domain/types/synthesis.js';
import type { BeltCalculator } from '@features/belt/belt-calculator.js';
import type { BeltComputeResult } from '@features/belt/belt-calculator.js';
import type { KataAgentConfidenceCalculator } from '@features/kata-agent/kata-agent-confidence-calculator.js';
import { CooldownBeltComputer } from './cooldown-belt-computer.js';
import { CooldownDiaryWriter } from './cooldown-diary-writer.js';
Expand All @@ -34,6 +33,10 @@ import {
shouldWarnOnIncompleteRuns,
} from './cooldown-session.helpers.js';
import { BridgeRunSyncer } from './bridge-run-syncer.js';
import type { BetOutcomeRecord, IncompleteRunInfo, CooldownSessionResult, CooldownPrepareResult } from './cooldown-types.js';

// Re-export shared types so existing consumers don't break
export type { BetOutcomeRecord, IncompleteRunInfo, CooldownSessionResult, CooldownPrepareResult } from './cooldown-types.js';

/**
* Dependencies injected into CooldownSession for testability.
Expand Down Expand Up @@ -121,15 +124,15 @@ export interface CooldownSessionDeps {
*/
agentConfidenceCalculator?: Pick<KataAgentConfidenceCalculator, 'compute'>;
/**
* Compatibility alias for older callers still passing kataka-named deps.
* @deprecated Use `agentConfidenceCalculator` instead. Will be removed in v1.
*/
katakaConfidenceCalculator?: Pick<KataAgentConfidenceCalculator, 'compute'>;
/**
* Optional path to the agent registry directory. Required when agentConfidenceCalculator is provided.
*/
agentDir?: string;
/**
* Compatibility alias for older callers still passing katakaDir.
* @deprecated Use `agentDir` instead. Will be removed in v1.
*/
katakaDir?: string;
/**
Expand Down Expand Up @@ -158,79 +161,6 @@ export interface CooldownSessionDeps {
dojoSessionBuilder?: Pick<SessionBuilder, 'build'>;
}

/**
* A run that was found to be incomplete when cooldown was triggered.
*/
export interface IncompleteRunInfo {
runId: string;
betId: string;
status: 'pending' | 'running';
}

/**
* Record of a bet's outcome after cooldown review.
*/
export interface BetOutcomeRecord {
betId: string;
outcome: 'complete' | 'partial' | 'abandoned';
notes?: string;
/** Human-readable bet description, for display in diary entries. */
betDescription?: string;
}

/**
* Full result of a cooldown session.
*/
export interface CooldownSessionResult {
report: CooldownReport;
betOutcomes: BetOutcomeRecord[];
proposals: CycleProposal[];
learningsCaptured: number;
/** Per-bet run summaries from .kata/runs/ data. Present when runsDir was provided. */
runSummaries?: RunSummary[];
/** Pending rule suggestions loaded during cooldown. Present when ruleRegistry was provided. */
ruleSuggestions?: RuleSuggestion[];
/** ID of the synthesis input file written by prepare(). */
synthesisInputId?: string;
/** Path to the synthesis input file written by prepare(). */
synthesisInputPath?: string;
/** Synthesis proposals that were applied during complete(). */
synthesisProposals?: SynthesisProposal[];
/** Belt computation result. Present when beltCalculator was provided. */
beltResult?: BeltComputeResult;
/**
* Runs that were found to be incomplete (pending/running) when cooldown was triggered.
* Non-empty only when runsDir is provided and incomplete runs were detected.
* Always present (may be empty array) when runsDir is configured.
*/
incompleteRuns?: IncompleteRunInfo[];
/**
* LLM-generated next-keiko bet proposals. Present when runsDir is configured
* and NextKeikoProposalGenerator ran successfully during complete().
*/
nextKeikoResult?: NextKeikoResult;
}

/**
* Intermediate result returned by prepare() before synthesis.
* Does NOT include completedAt (cycle not yet 'complete').
*/
export interface CooldownPrepareResult {
report: CooldownReport;
betOutcomes: BetOutcomeRecord[];
proposals: CycleProposal[];
learningsCaptured: number;
runSummaries?: RunSummary[];
ruleSuggestions?: RuleSuggestion[];
synthesisInputId: string;
synthesisInputPath: string;
/**
* Runs that were found to be incomplete (pending/running) when cooldown was triggered.
* Non-empty only when runsDir is provided and incomplete runs were detected.
* Always present (may be empty array) when runsDir is configured.
*/
incompleteRuns?: IncompleteRunInfo[];
}

/**
* Orchestrates the full cooldown experience for a cycle.
Expand Down
81 changes: 81 additions & 0 deletions src/features/cycle-management/cooldown-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import type { CooldownReport } from '@domain/services/cycle-manager.js';
import type { RuleSuggestion } from '@domain/types/rule.js';
import type { SynthesisProposal } from '@domain/types/synthesis.js';
import type { BeltComputeResult } from '@features/belt/belt-calculator.js';
import type { CycleProposal } from './proposal-generator.js';
import type { NextKeikoResult } from './next-keiko-proposal-generator.js';
import type { RunSummary } from './types.js';

/**
* A run that was found to be incomplete when cooldown was triggered.
*/
export interface IncompleteRunInfo {
runId: string;
betId: string;
status: 'pending' | 'running';
}

/**
* Record of a bet's outcome after cooldown review.
*/
export interface BetOutcomeRecord {
betId: string;
outcome: 'complete' | 'partial' | 'abandoned';
notes?: string;
/** Human-readable bet description, for display in diary entries. */
betDescription?: string;
}

/**
* Full result of a cooldown session.
*/
export interface CooldownSessionResult {
report: CooldownReport;
betOutcomes: BetOutcomeRecord[];
proposals: CycleProposal[];
learningsCaptured: number;
/** Per-bet run summaries from .kata/runs/ data. Present when runsDir was provided. */
runSummaries?: RunSummary[];
/** Pending rule suggestions loaded during cooldown. Present when ruleRegistry was provided. */
ruleSuggestions?: RuleSuggestion[];
/** ID of the synthesis input file written by prepare(). */
synthesisInputId?: string;
/** Path to the synthesis input file written by prepare(). */
synthesisInputPath?: string;
/** Synthesis proposals that were applied during complete(). */
synthesisProposals?: SynthesisProposal[];
/** Belt computation result. Present when beltCalculator was provided. */
beltResult?: BeltComputeResult;
/**
* Runs that were found to be incomplete (pending/running) when cooldown was triggered.
* Non-empty only when runsDir is provided and incomplete runs were detected.
* Always present (may be empty array) when runsDir is configured.
*/
incompleteRuns?: IncompleteRunInfo[];
/**
* LLM-generated next-keiko bet proposals. Present when runsDir is configured
* and NextKeikoProposalGenerator ran successfully during complete().
*/
nextKeikoResult?: NextKeikoResult;
}

/**
* Intermediate result returned by prepare() before synthesis.
* Does NOT include completedAt (cycle not yet 'complete').
*/
export interface CooldownPrepareResult {
report: CooldownReport;
betOutcomes: BetOutcomeRecord[];
proposals: CycleProposal[];
learningsCaptured: number;
runSummaries?: RunSummary[];
ruleSuggestions?: RuleSuggestion[];
synthesisInputId: string;
synthesisInputPath: string;
/**
* Runs that were found to be incomplete (pending/running) when cooldown was triggered.
* Non-empty only when runsDir is provided and incomplete runs were detected.
* Always present (may be empty array) when runsDir is configured.
*/
incompleteRuns?: IncompleteRunInfo[];
}
2 changes: 1 addition & 1 deletion src/features/dojo/diary-writer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mkdtempSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
import { DiaryStore } from '@infra/dojo/diary-store.js';
import type { BetOutcomeRecord } from '@features/cycle-management/cooldown-session.js';
import type { BetOutcomeRecord } from '@features/cycle-management/cooldown-types.js';
import type { CycleProposal } from '@features/cycle-management/proposal-generator.js';
import type { RunSummary } from '@features/cycle-management/types.js';
import { DiaryWriter, type DiaryWriterInput } from './diary-writer.js';
Expand Down
2 changes: 1 addition & 1 deletion src/features/dojo/diary-writer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DojoDiaryEntry } from '@domain/types/dojo.js';
import { DojoDiaryEntrySchema, type DojoMood } from '@domain/types/dojo.js';
import { DiaryStore } from '@infra/dojo/diary-store.js';
import type { BetOutcomeRecord } from '@features/cycle-management/cooldown-session.js';
import type { BetOutcomeRecord } from '@features/cycle-management/cooldown-types.js';
import type { CycleProposal } from '@features/cycle-management/proposal-generator.js';
import type { RuleSuggestion } from '@domain/types/rule.js';
import type { RunSummary } from '@features/cycle-management/types.js';
Expand Down
Loading