// contracts §8 — Project and Session Contracts
// File: project.ts — ProjectContext, ProjectInitOptions, ProjectStore,
//   SessionContext, OpenSessionOptions, SessionManager

import type { ProjectID, SessionID, ProviderID, ModelID } from './ids'

// §8.1 ProjectContext — runtime context for an opened AirCoding project
export interface ProjectContext {
  project_id: ProjectID
  project_root: string
  air_root: string
  shared_root: string
  local_root: string
  schema_version: number
}

// §8.2 ProjectInitOptions — options for initializing a new project
export interface ProjectInitOptions {
  force?: boolean
  title?: string
  default_rules?: boolean
}

// §8.3 ProjectStore — locate, initialize, and open projects
export interface ProjectStore {
  locate(start_path: string): Promise<ProjectContext | undefined>
  initialize(project_root: string, options?: ProjectInitOptions): Promise<ProjectContext>
  open(project_root: string): Promise<ProjectContext>
}

// §8.4 SessionContext — runtime context for an open session
export interface SessionContext {
  session_id: SessionID
  project_id: ProjectID
  project_root: string
  db_path: string
  artifact_root: string
}

// §8.5 OpenSessionOptions — options for opening a session
export interface OpenSessionOptions {
  session_id?: SessionID
  title?: string
  model_provider_id?: ProviderID
  model_id?: ModelID
}

// §8.6 SessionManager — open and close sessions
export interface SessionManager {
  open_session(project: ProjectContext, options?: OpenSessionOptions): Promise<SessionContext>
  close_session(session_id: SessionID): Promise<void>
}